[comment]: # translation:outdated

[comment]: # ({000fdd04-000fdd04})
# graph.create

[comment]: # ({/000fdd04-000fdd04})

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

`object graph.create(object/array graphs)`

该方法允许create新图表.

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

:::

[comment]: # ({/c0a9ce2e-e0ee1e5d})

[comment]: # ({a3a03cd9-fc8b02f4})
### 参数

`(object/array)` 图表至 create.

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

| 参数 | [数据类型](/manual/api/reference_commentary#数据类型) | 描述 |
|--|--|------|
| gitems | array | 为图表创建的[Graph items](/manual/api/reference/graphitem/object)。<br><br>[参数行为](/manual/api/reference_commentary#参数行为):<br>- *必填* |

[comment]: # ({/a3a03cd9-fc8b02f4})

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

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

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

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

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

[comment]: # ({a5d4a0e3-cd12048c})
#### 创建图表

创建包含两个监控项的图表.

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

```json
{
    "jsonrpc": "2.0",
    "method": "graph.create",
    "params": {
        "name": "MySQL bandwidth",
        "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]: # ({/a5d4a0e3-cd12048c})

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

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

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

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

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

[comment]: # ({/4e535c8e-4e535c8e})
