What is the recommended way to display simple line and bar graphs in a self made widget?

xstaffelbach
Kilo Contributor

I am making a widget that will display some pie & bar graphs concerning some very simple data that I send to serviceNOW via the server side script in the widget.

I want my client side script to take the data, like:

{

  • Operating Systems: {}
    • aix: 45,
    • ios: 4,
    • linux: 57,
    • solaris: 15,
    • unix: 52,
    • windows: 140

}

And make a simple pie chart. I already have serviceNOW receiving this data and the client side script can access it.

I see that I can make a simple HTML JS pie chart like here: https://stackoverflow.com/questions/6995797/html5-canvas-pie-chart  

But I am hoping that there is a better built in way of doing this. I have seen that ServiceNOW has reporting, but adding this to a widget and having it work with personalized Jsons as opposed to glider objects is not a functionality that I have seen.

END GOAL FOR CONTEXT: I am going to have the widget pull about 10 differing small Json's from my server. Then the widget will have a drop down menu with a list of all the titles of the Jsons like "Operating Systems". When the user clicks on a title the space below the dropdown will fill with the respective chart.

1 ACCEPTED SOLUTION

larstange
Mega Sage

Hi



I would recommend using angular-chart.js - beautiful, reactive, responsive charts for Angular.JS using Chart.js



Import it as a Portal Dependency library and add it to your widget. Then you can generate graphs with almost no code



find_real_file.png


View solution in original post

9 REPLIES 9

You need to open your widget (using the normal interface) and add the dependency in the related list.


I'm not sure if the spaces in you Angular module name is an issue.


find_real_file.png


Lars, I did add the dependencies using the related list. I removed the space in the name of the dependency just to see. Still no chart displays. If I click the Include on page load control the page won't even load.



find_real_file.png


find_real_file.png


Hi



you need both chart.js and angular-chart.js for it to work. The files you are including are both the same.



They are already in the source of the platform though - this is how mine looks:



find_real_file.png


did u get the output for the widget dependency

jillellaK
Tera Contributor

How do you add colors to this chart any idea??