Name
global.CustomChart
Description
JFreeChart wrapper
Script
var CustomChart = Class.create();
CustomChart.prototype = {
initialize : function() {
},
/*
* Creates a line graph with x number of data series.
*
* dataSeries takes is an array of functions with two properties: label and seriesData.
* seriesName - the label of the series to use on the legend
* seriesData - array of values
*
*/
createXYLine : function(title, xAxisLabel, yAxislabel, displayLegend, dataCollection) {
title = title ? title : "";
displayLegend = dataCollection && dataCollection.length > 1;
var xyCollection = new Packages.org.jfree.data.xy.XYSeriesCollection();
for (var i in dataCollection){
var xySeries = new Packages.org.jfree.data.xy.XYSeries(dataCollection[i].seriesName, true);
xyCollection.addSeries(xySeries);
var dataSeries = dataCollection[i].seriesData;
for (var j in dataSeries){
xySeries.add(j, dataSeries[j]);
}
}
var chart = Packages.org.jfree.chart.ChartFactory.createXYLineChart(title, xAxisLabel, yAxislabel, xyCollection, Packages.org.jfree.chart.plot.PlotOrientation.VERTICAL, displayLegend, false, false);
chart.setAntiAlias(true);
chart.setBackgroundPaint(Packages.java.awt.Color.white);
var lineAndShapeRenderer = new Packages.org.jfree.chart.renderer.xy.XYLineAndShapeRenderer();
lineAndShapeRenderer.setLinesVisible(true);
lineAndShapeRenderer.setShapesVisible(true);
var xyPlot = chart.getPlot();
xyPlot.setRenderer(lineAndShapeRenderer);
xyPlot.getRangeAxis().setStandardTickUnits(Packages.org.jfree.chart.axis.NumberAxis.createIntegerTickUnits());
xyPlot.getDomainAxis().setStandardTickUnits(Packages.org.jfree.chart.axis.NumberAxis.createIntegerTickUnits());
return chart;
},
type : "CustomChart"
};
Sys ID
a3c073ab37311000913e40ed9dbe5d68