Name
global.ChartGenerator
Description
Utilities to create JFreeCharts
Script
gs.include("PrototypeServer");
var ChartGenerator = Class.create();
ChartGenerator.prototype = {
initialize : function(type) {
this.type = type;
this.summaryID = null;
this.chart = null;
this.index = 0;
this.stacked = false;
this.table = "sys_report_summary";
this.cu = new ChartUtil();
},
setSummaryID : function(id) {
this.summaryID = id;
},
getDataset : function() {
this.getChartGenerator();
return this.chart.getDataset();
},
getChart : function(ds) {
this.getChartGenerator();
this.jfreeChart = this.chart.getChart(ds);
return this.jfreeChart;
},
addRenderer : function(renderer, ds, tips, axis, rangeaxis) {
if (typeof(rangeaxis) == 'undefined')
rangeaxis = 1;
this.index = this.index+1;
var plot = this.getPlot();
plot.setDataset(this.index, ds);
plot.setRenderer(this.index, renderer);
if (tips)
this.cu.setToolTipGenerator(renderer, "{1} - {2}");
if (axis) {
this.getChartGenerator().addNumberAxis(plot, axis, rangeaxis);
plot.mapDatasetToRangeAxis(this.index, rangeaxis);
}
plot.setDatasetRenderingOrder(this.cu.getForwardRenderingOrder());
},
setTable : function(table) {
this.table = table;
},
setStacked : function() {
this.stacked = true;
},
setNoMargins : function() {
var plot = this.getPlot();
var ca = plot.getDomainAxis();
ca.setCategoryMargin(0.30);
ca.setLowerMargin(0.01);
ca.setUpperMargin(0.01);
plot.getRenderer().setItemMargin(0.00);
},
getPlot : function() {
return this.jfreeChart.getPlot();
},
getChartParameters: function() {
if (this.cp)
return this.cp;
this.cp = new GlideappChartParameters(this.type, this.table, "");
return this.cp;
},
getChartGenerator : function() {
if (this.chart)
return this.chart;
this.getChartParameters();
this.cp.setSummaryID(this.summaryID);
if (this.stacked)
this.cp.setStacked(true);
this.chart = GlideChartGeneratorFactory.get(this.cp);
return this.chart;
}
};
Sys ID
f552e998c0a8016a00606cb68068f0ff