[comment]: # ({576421be-576421be})
# graphprototype.create

[comment]: # ({/576421be-576421be})

[comment]: # ({fc8d3493-fc8d3493})
### 描述

`object graphprototype.create(object/array graphPrototypes)`

该方法允许create新的图形原型.

::: noteclassic
此方法仅适用于*管理员*和*超级管理员*用户类型. 调用该方法的权限可在用户角色设置中撤销. 更多信息请参阅[User
roles](/manual/web_interface/frontend_sections/administration/user_roles).

:::

[comment]: # ({/fc8d3493-fc8d3493})

[comment]: # ({378ef202-9beca929})
### 参数

`(object/array)` 图形原型至create.

除[图表原型](object#图表原型)外，该方法还接受以下参数。

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| **gitems**<br>(required) | array | 为图形原型创建的图形[items](/manual/api/reference/graphitem/object)。图形监控项可同时引用监控项和监控项原型，但必须至少存在一个监控项原型。 |

[comment]: # ({/378ef202-9beca929})

[comment]: # ({f1317691-f1317691})
### 返回值

`(object)` 返回一个包含所创建图形原型ID的object，这些ID存储在`graphids`属性下。返回的ID顺序与传入的图形原型顺序保持一致。

[comment]: # ({/f1317691-f1317691})

[comment]: # ({b41637d2-b41637d2})
### 示例

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({668e82cb-24ec4c22})
#### 创建图形原型

创建一个包含两个监控项的图形原型.

请求:

```json
{
    "jsonrpc": "2.0",
    "method": "graphprototype.create",
    "params": {
        "name": "Disk space usage {#FSNAME}",
        "width": 900,
        "height": 200,
        "gitems": [
            {
                "itemid": "22828",
                "color": "00AA00"
            },
            {
                "itemid": "22829",
                "color": "3333FF"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```
响应:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "graphids": [
            "652"
        ]
    },
    "id": 1
}
```

[comment]: # ({/668e82cb-24ec4c22})

[comment]: # ({88266563-88266563})
### 另请参阅

-   [图表-监控项](/manual/api/reference/graphitem/object#图表-监控项)

[comment]: # ({/88266563-88266563})

[comment]: # ({c4b4834a-c4b4834a})
### 来源

CGraphPrototype::create() 位于
*ui/include/classes/api/services/CGraphPrototype.php* 文件中.

[comment]: # ({/c4b4834a-c4b4834a})
