Hi,
I am drawing multiple area charts in a single xygraph.
when one area chart drwan on top of the other area chart it masks the original color of the supressed chart.
It neither displays the its original color or the color of supressed chart.
it displays the chart with combination of both the colors.
Please click on the link to see the graph and observe the color in legend and the original color drawn.
http://pg.photos.yahoo.com/ph/sridharra ... pg&.src=ph
Please help me how to get the colors as the same displayed in the legend.
For the information please find attached the source code
package cpm.client;
import java.awt.Color;
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
public class TestGraph
{
/**
*
*/
public TestGraph()
{
int[] adsl5 = new int[] { 5,90,180, 450,590,560,400,200,100,50, 40, 30, 20, 10, 9, 0, 0, 0,0, 0 };
int[] adsl8 = new int[] { 5,90,180, 450,590,560,400,100,50, 30, 20, 10, 5, 2, 1, 0, 0, 0,0, 0 };
int[] adsl16 = new int[] {5,90,180, 450,590,560,150,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0 };
int areadata[][] = new int[3][];
areadata[0] = new int[adsl5.length];
for (int i = 0; i < adsl5.length; i++)
{
areadata[0] = adsl5;
}
areadata[1] = new int[adsl8.length];
for (int i = 0; i < adsl8.length; i++)
{
areadata[1] = adsl8;
}
areadata[2] = new int[adsl16.length];
for (int i = 0; i < adsl16.length; i++)
{
areadata[2] = adsl16;
}
JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Demo",
"Domain (X)", "Range (Y)", createXYDataSet1(areadata),
PlotOrientation.VERTICAL, true, true, false);
XYPlot xyplot = (XYPlot)chart.getPlot();
XYItemRenderer renderer = xyplot.getRenderer(0);
renderer.setSeriesPaint(0, Color.YELLOW);
renderer.setSeriesPaint(1, Color.RED);
renderer.setSeriesPaint(2, Color.GREEN);
ChartPanel panel = new ChartPanel(chart);
JFrame f = new JFrame();
f.getContentPane().add(panel);
f.pack();
f.show();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private XYDataset createXYDataSet1(int[][] dataArr)
{
XYSeries xyseries = null;
XYSeriesCollection xyseriescollection = new XYSeriesCollection();
for (int lineNo = 1; lineNo <= dataArr.length; lineNo++)
{
xyseries = new XYSeries(lineNo + "", true, false);
for (int dataIndex = 0; dataIndex < 20; dataIndex++)
{
xyseries.add(dataIndex, dataArr[lineNo - 1][dataIndex]);
}
xyseriescollection.addSeries(xyseries);
}
return xyseriescollection;
}
public static void main(String[] args)
{
new TestGraph();
}
}
Multiple area charts overlapping - color representation prob
-
- Posts: 3
- Joined: Mon Jul 18, 2005 9:54 am
- Contact:
-
- Posts: 3
- Joined: Mon Jul 18, 2005 9:54 am
- Contact: