News:

We really need your input in this questionnaire

Main Menu

Scripted Pie Chart Example

Started by ahasbini, December 08, 2024, 02:08:29 PM

Previous topic - Next topic

ahasbini

In dashboard elements, there is the option of adding a scripted pie chart, I have tried to search the docs for an example but could not find any. Are there any guides on making a scripted pie chart?

Thanks,
ahasbini

ahasbini

Specifically, an example on the script used in the Scripted Pie Chart to display in the dashboard based on some logic that retrieves data from DCIs.

Thanks.

Filipp Sudanov

Scripted bar or pie charts either accept array with values:
return [1,2,3];

or hashmap, which allows to provide names in additions to values:
v = %{};
v["name1"] = 1;
v["name2"] = 2;
v["name3"] = 3;
return v;

Functions to get DCI values are described here https://www.netxms.org/documentation/nxsl-latest/#func-getdcivaluebyname
I can provide a detailed example of how to use them in the coming days (you can give some details on what data do you need)

ahasbini

Thanks a million, I just couldn't figure out the map or array part out from the docs so I had to ask. I'm familiar with the DCI part, so I will give it a try. Thanks again.

lhpaladin

#4
Hi,

If you need to specify colors for each item, the hashmap can be used for this:
values.append(%{"name":"Item X", "value":10, "color": "#f5f5f5"});
return values;