- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2014 09:23 AM
Hi,
I wanted to create a custom assignment group stacked bar graph like the one listed in below link-
JFreeChart: Stacked Bar Chart Demo 4 : Bar Stacked Chart « Chart « Java
I'm not very familiar to JFree chart API but if anyone can help in creating the above in ServiceNow that would be great
Thanks
Bhupinder
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2014 08:38 AM
Hi Kevin,
Thanks for response. But I have little different requirement here that goes-
Let me explain the graph I want to generate
1. Problems Created vs Closed Stacked on Assignment group
2. I'm able to generate garph for all Problems Created vs Closed (Attaching the image)
3. I need to stack on Assignment group for each bar in the above graph like Problems created should be stacked on Assignment group and same for Problems closed
4. As an aletrnative if we can group by Assignment group and for each assignment group if we can show Problems created vs closed that would also do the purpose
5. I'm attaching all the pieces of code that generate graph mentioned in step#2
Below is the graph for which I want to stack on against assignment group
I used custom chart reporting to build above graph and now want to extend the reporting further using Java JFree chart API. For the above graph I used the below piece of code-
Here's the code -
Data Generators
Trend of Open Problems Task
var opened = new SummaryTableWriter("problem_task", '');
- opened.setTitle("Trend of Open Problems Task");
- opened.setTrend('opened_at', 'month');
- current.summary = opened.generate();
- current.setWorkflow(false);
- current.update();
Trend of Closed Problems Task
var closed = new SummaryTableWriter("problem_task", '');
- closed.setTitle("Trend of Closed Problems Task");
- closed.setTrend('closed_at', 'month');
- current.summary = closed.generate();
- current.setWorkflow(false);
- current.update();
Renderer Script
//Get the sys_id values for the sys_report_summary table entries build by our generators
var openID = summary_sets.get("Trend of Open Problems Task");
var closedID = summary_sets.get("Trend of Closed Problems Task");
// Gets a utility class for dataset manipulation
var cu = new ChartUtil();
- cu.setTable('problem_task');
- cu.setColors("#FFDEAD,#7FFF00");
// Get the dataset for the Open incidents
var open = new ChartGenerator("bar");
- open.setTable('problem_task');
- open.setSummaryID(openID);
var ds = open.getDataset();
// Get the dataset for the Closed incidents and combine with the open incidents into
// a multi series dataset
var closed = new ChartGenerator("bar");
- closed.setTable('problem_task');
- closed.setSummaryID(closedID);
ds = cu.mergeDatasets(ds, "Created", closed.getDataset(), "Closed");
var chart = closed.getChart(ds);
// Change the spacing
- closed.setNoMargins();
// return our chart
answer = chart;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2014 01:08 PM
I believe you would put this code inside a script include, unfortunately I am not an expert at scripting. I am trying myself to do complex graphs with no success.