How to get lines count on dual axis chart?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
aurorean

How to get lines count on dual axis chart?

Post by aurorean » Fri Feb 21, 2003 3:03 am

I create a dual vertical axis timeseries line chart. But distinguishing the different lines on plot is not very easy because the default color of the lines. So, I want to change the default color of the lines in renderer. Before the version 0.9.5, I do this like these codes:

Paint[] paint = { .... }; // An array of Color objects. paint.length=10;
XYPlot plot = chart.getXYPlot();
XYItemRenderer renderer = plot.getRenderer();
int linesCount = plot.getSeriesCount();
int colorsCount = paint.length;
int j = 0;
for (int i = 0; i < linesCount; i++) {
if (j > colorsCount - 1)
j = 0;
plot.setSeriesPaint(i, paint[j]);
j ++;
}
}

But in dual vertical axis timeseries line chart, these codes just change the color of lines corresponding to left vertical axis. How to change the color of lines corresponding to the secondary vertical axis?

David Gilbert

Re: How to get lines count on dual axis chart?

Post by David Gilbert » Fri Feb 21, 2003 1:03 pm

The setSeriesPaint(int, Paint) method defaults to setting the color for the primary dataset. If you want to set the color for the secondary dataset, use the setSeriesPaint(int, int, Paint) method - the first argument is the dataset index, 0 for the primary dataset and 1 for the secondary dataset.

Regards,

Dave Gilbert

Locked