priceVolumeChart problem

Discussion about JFreeChart related to stockmarket charts.
Locked
johnnyhall81
Posts: 3
Joined: Tue Oct 24, 2006 9:43 am

priceVolumeChart problem

Post by johnnyhall81 » Tue Oct 24, 2006 9:52 am

Hi guys,

I have a dataset which contains the price data for two stocks over a period of time. When plotting the dataset, both line graphs are of the same color.

Code: Select all

JFreeChart chart = ChartFactory.createTimeSeriesChart(title, "", "", priceDataset, true, true, false);

chart.setBackgroundPaint(new Color(255, 255, 240));

XYPlot plot = chart.getXYPlot();
NumberAxis rangeAxis1 = (NumberAxis) plot.getRangeAxis();
rangeAxis1.setLowerMargin(0.5);
rangeAxis1.setUpperMargin(0.4);
DecimalFormat format = new DecimalFormat("0");
rangeAxis1.setNumberFormatOverride(format);
XYItemRenderer renderer1 = plot.getRenderer();
renderer1.setPaint(new Color(0, 102, 221));
Is it possible to alter the colors of the lines without having to specify two different datasets - similar to a highLowChart?

johnnyhall81
Posts: 3
Joined: Tue Oct 24, 2006 9:43 am

Post by johnnyhall81 » Tue Oct 24, 2006 11:28 am

Fixed it. I was explicitly setting the color, when I should have relied on the renderer. Removing the line

Code: Select all

renderer1.setPaint(new Color(0, 102, 221));
fixed the problem.

Locked