Making dynamic bar chart series stack? [message #1175310] |
Thu, 07 November 2013 12:19  |
Eclipse User |
|
|
|
I had a line chart for which I used a script to dynamically create a number of series.
I wanted to convert this chart to a bar chart and additionally make it a stacked bar chart.
The conversion went fine except that I can't get my dynamically added series to stack!
If I add the series via the GUI then no problem. So I'm guessing that there is a simple tweak to my script that will do the trick but so far it has eluded me. My current script is as follows:
function TargetAppliedChart(numThreads) {
cht = reportContext.getDesignHandle().findElement("ThroughputChart2");
mychart = cht.getReportItem().getProperty("chart.instance");
// Get the x axis and the first y axis
xAxis = mychart.getAxes().get(0);
yAxis1 = xAxis.getAssociatedAxes().get(0);
if (params["hasTargetStats"].value) {
for (i=1; i <= numThreads; i++) {
var sdNew = yAxis1.getSeriesDefinitions().get(0).copyInstance();
var ls = sdNew.getSeries().get(0);
var identifier = "Applied Operations";
if (numThreads > 1) {
identifier += " - Apply Thread: " + i;
}
ls.setSeriesIdentifier(identifier);
// Create the query
var qry = QueryImpl.create("if (row['MIRROR_TOTAL_RATE'] != null && row['APPLYTHREAD'] == " + i + ")\n row['MIRROR_TOTAL_RATE'];" );
ls.getDataDefinition().remove(0);
ls.getDataDefinition().add(qry);
shiftValue = i <= 2 ? i-1 : i;
sdNew.getSeriesPalette().shift(shiftValue);
sdNew.getSeries().remove(0);
sdNew.getSeries().add(ls);
//Add the new series definition to the first y axis
yAxis1.getSeriesDefinitions().add(sdNew);
}
// Remove the dummy placeholder series
yAxis1.getSeriesDefinitions().remove(0);
}
return 0;
}
Thanks in advance...
Mike
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04145 seconds