Reports and Custom Charts

bhenson
Kilo Expert

Good morning all,

 

Still learning ServiceNow and making my first foray into Custom Charts.   I have 2 reports that separately display the data I want to combine into 1 custom chart.   Is there any way to use those 2 reports as my Data Generators or find the code that renders those reports to copy into my Data Generators when I create them?

 

Struggling with getting the code right to generate the data and hoping for a way to leverage what I have already created in SN to create something new and wonderful.   🙂

 

Thanks in advance for your assistance.

20 REPLIES 20

I don't really see what's wrong.   Here's mine though.   I use some different methods, and the big one I noticed is I didn't use the mergeDatasets, and maybe some stuff is in a different order.



  var userID = summary_sets.get("Weekly User Count by Type");


  var totalID = summary_sets.get("Total License Count");



  // Get the dataset for the Open incidents


  var user = new ChartGenerator("bar");


  user.setSummaryID(userID);


  user.setStacked();


  var ds = user.getDataset();


  var cu = new ChartUtil();



  // Get the chart for the multi series bar chart of open and closed incidents


  var chart = user.getChart(ds);



  user.setNoMargins();



  var line = new ChartGenerator("line");


  line.setSummaryID(totalID);


  var lineDS = line.getDataset();


  lineDS = cu.changeDatasetLabel(lineDS, "Total Licenses");


  var renderer = line.getChartGenerator().getLineRenderer(Packages.java.awt.Color.RED, 1.0, false, true, true);



  user.addRenderer(renderer, lineDS, true, "", 0);


  cu.setToolTipGenerator(renderer, "Total Licenses - {2}");



  answer = chart;


When I turn on diagnostics I get a javascript compiler exception in my rendering script:



"Javascript complier exception: Can't find method com.glide.ui.chart.AChartGenerator.getChart(org.ifree.data.category.DefaultCategoryDataset).



A print screen of the entire entry from the debug log is attached.


Hmm, not sure what could cause that.   Sounds like your instance is missing a plugin or something


That's what I thought Chris - it is being generated by the " var chart = closed.getChart(ds);' line.   I have submitted an incident to SN to see if they have an answer as to which plugin I am missing.



Thanks for all your help - if I can ever make it to one of the Eastern MO User Group meetings I will thank you in person for all your help but right now I'll just say thanks SO much for all your help!


Reply from ServiceNow:



"Unfortunately, the getChart(Dataset) method for a custom line chart does not execute and throws an error on Berlin. This problem was documented in PRB575811, and was fixed in Calgary.


Your Custom Chart on Berlin will work as a bar chart or a pie chart, but not as a line chart. Please consider using a bar or pie chart on the Berlin release."



So I have it kind of working as a bar chart.   My issue is that my datasets are from 2 different time frames and the chart tries to render both data sets for a single time frame.   So even though my summary sets have valid data for the 2 time periods I want, it tries to render data from each summary set for a single time frame so one data set returns "0" for that time frame (because that data doesn't exist in the summary set).



Why does it have to be SO complicated to display data from 2 time periods for comparison purposes?   It seems like that is something a lot of users would want to do.