chart_update_from_json
Update all value of a chart by giving json string.
Syntax
chart_update_from_json(chart, json)
Argument | Description |
---|---|
series | The chart id to check. |
json | The json string. |
Return: True
Description
This function will update all value of chart with json string given it. This function useful if you want update chart data from another platform or API that you created.
The json string must be based on this formula.
{
"data": [
{
"series": "SeriesName",
"value": 10
},
{
"series": "SeriesName",
"value": 20
},
...
]
}
The property with "series" name is case-sensitive and must be same with Argument "name" on function chart_add_series(...)
. The list number of "data" name must be same with the number of chart data (or label) and written sequentially.
Example
company = chart_create(chart_line, 32, 16, 448, 256);
product = chart_add_series(company, "Product(s)", c_teal);
service = chart_add_series(company, "Service(s)", c_maroon);
chart_add_data(product, 24);
chart_add_data(product, 26);
chart_add_data(product, 18);
chart_add_data(service, 34);
chart_add_data(service, 28);
chart_add_data(service, 26);
var jsonString = '{"data": [
{"series": "Product(s)","value": 28},
{"series": "Product(s)","value": 27},
{"series": "Product(s)","value": 20},
{"series": "Service(s)","value": 30},
{"series": "Service(s)","value": 26},
{"series": "Service(s)","value": 18}
]
}';
chart_update_from_json(company, jsonString);
The above code will update all value of the chart "company" with the json string that you has been given.