graph.create

Description

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

This method allows to create new graphs.

This method is only available to Admin and Super admin user types. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Graphs to create.

Additionally to the standard graph properties, the method accepts the following parameters.

ParameterTypeDescription
gitems
(required)
arrayGraph items to be created for the graph.

Return values

(object) Returns an object containing the IDs of the created graphs under the graphids property. The order of the returned IDs matches the order of the passed graphs.

Examples

Creating a graph

Create a graph with two items.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "graph.create",
  4. "params": {
  5. "name": "MySQL bandwidth",
  6. "width": 900,
  7. "height": 200,
  8. "gitems": [
  9. {
  10. "itemid": "22828",
  11. "color": "00AA00"
  12. },
  13. {
  14. "itemid": "22829",
  15. "color": "3333FF"
  16. }
  17. ]
  18. },
  19. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  20. "id": 1
  21. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "graphids": [
  5. "652"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

CGraph::create() in ui/include/classes/api/services/CGraph.php.