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

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

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

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

这种方法允许创建新的图表原型。

::: noteclassic
这个方法只可用于 *管理员* 和 *超级管理员* 的用户类型。调用该方法的权限可以在用户角色设置中被撤销。 前往[用户角色](/manual/web_interface/frontend_sections/users/user_roles)以了解更多信息。
:::

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

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

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

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

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

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

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

`(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() in
*ui/include/classes/api/services/CGraphPrototype.php*.

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