ich have a small problem with my chart. I have something like the MultipleAxisDemo, and setting the same color for the axis like the datasets is working fine.
now i implemented a button with which you can switch between a colored chart and a black&white chart. but when i want the chart to be displayed in black, only the axis and the first dataset get black, but the other lines (datasets) stay colored.
what did i do wrong?
here´s my sample code for what should happen when clicking on the button:
Code: Select all
case LINE_BTN:
JButton lineButton = datasetView.getLineButton();
JFreeChart chart = datasetView.chartPanel.getChart();
int count = chart.getXYPlot().getDatasetCount();
for (int i = 0; i < count; i++)
{
XYItemRenderer r = chart.getXYPlot().getRendererForDataset(chart.getXYPlot().getDataset(i));
if (!linesColored)
{
lineButton.setIcon(Icons.lineBWIcon);
lineButton.setToolTipText("Display black/white chart");
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setSeriesPaint(i, axisColor[i]);
chart.getXYPlot().getRangeAxisForDataset(i).setLabelPaint(axisColor[i]);
chart.getXYPlot().getRangeAxisForDataset(i).setTickLabelPaint(axisColor[i]);
chart.getXYPlot().setRenderer(i, renderer);
}
else
{
lineButton.setIcon(Icons.lineColorIcon);
lineButton.setToolTipText("Display colored chart");
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setSeriesPaint(i, axisColor[15]);
chart.getXYPlot().getRangeAxisForDataset(i).setLabelPaint(axisColor[15]);
chart.getXYPlot().getRangeAxisForDataset(i).setTickLabelPaint(axisColor[15]);
chart.getXYPlot().setRenderer(i, renderer);
}
}
if (!linesColored) linesColored = true;
else linesColored = false;
}
break;
any ideas?
thanks in advance...