NetXMS Support Forum

English Support => General Support => Topic started by: ahasbini on December 08, 2024, 02:08:29 PM

Title: Scripted Pie Chart Example
Post by: ahasbini on December 08, 2024, 02:08:29 PM
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
Title: Re: Scripted Pie Chart Example
Post by: ahasbini on December 08, 2024, 02:09:33 PM
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.
Title: Re: Scripted Pie Chart Example
Post by: Filipp Sudanov on December 08, 2024, 02:28:13 PM
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)
Title: Re: Scripted Pie Chart Example
Post by: ahasbini on December 08, 2024, 04:42:18 PM
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.
Title: Re: Scripted Pie Chart Example
Post by: lhpaladin on December 13, 2024, 12:51:16 PM
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;