[comment]: # translation:outdated

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

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

[comment]: # ({c20e2556-43f81439})
### 描述

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

此方法用于创建新的图表原型。

[comment]: # ({/c20e2556-43f81439})

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

`(对象/数组)` 将要创建的图表原型。

除了[标准图表原型参数](object#graph_prototype)外, 此方法还接受以下参数：

|参数          类|描述|<|
|-------------------|------|-|
|**gitems**<br>(必选)|array|创建到图表原型中的图表监控项。图表监控项能同时被监控项与监控项原型检索到，但必须至少有一个监控项原型。|

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

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

`(对象)`
在`graphids`属性下，返回一个包含已被创建的图表原型ID的对象。返回的ID的顺序与传递的图表原型的顺序相匹配。

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

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

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

[comment]: # ({6a7ea033-24ec4c22})
#### 创建一个图表原型

创建一个含有两个监控项的图表原型。

请求:

``` {.java}
{
    "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
}
```

响应:

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

[comment]: # ({/6a7ea033-24ec4c22})

[comment]: # ({18d0ba38-88266563})
### 参考

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

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

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

CGraphPrototype::create() in
*frontends/php/include/classes/api/services/CGraphPrototype.php*.

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