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

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

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

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

此方法用于create新的图形原型。

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

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

[comment]: # ({807fd05e-9beca929})
### 参数

`(object/array)` 要创建的图形原型。

除了[标准图形原型属性](object#graph-prototype)之外，该方法还接受以下参数。

|Parameter|[Type](/manual/api/reference_commentary#data-types)|Description|
|--|--|------|
|gitems|array|要为图形原型创建的[图形项](/manual/api/reference/graphitem/object)。图形项可以引用监控项和监控项原型，但至少必须存在一个监控项原型。<br><br>[参数行为](/manual/api/reference_commentary#parameter-behavior):<br>- *required*|

[comment]: # ({/807fd05e-9beca929})

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

`(object)` 返回一个 object，其中包含在 `graphids` 属性下列出的已创建图形原型的 ID。返回的 ID 顺序与传入的图形原型顺序一致。

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

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

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

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

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

[执行请求](/manual/api#执行请求):


```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"
            }
        ]
    },
    "id": 1
}
```
响应：


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

[comment]: # ({/89fcb1e2-24ec4c22})

[comment]: # ({9c4b324a-88266563})
### 另请参见

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

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

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

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

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