HI
I have created chart with Two Y-Axis using CEWolf and JFreeChart. I am using Two different DataSets, one for each Y-Axis. I have used two seperate Renders, one for each DataSet. Because of this, two bars are getting overlapped. So how to seperate these bars. Code that I am usong is below.
Suggest any modification needed in the code.
*************************************************************
JFreeChart chart = (JFreeChart) Chart;
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinesVisible(false);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinesVisible(false);
plot.setRangeGridlinePaint(Color.white);
// set the range axis to display integers only...
final NumberAxis rangeAxis0 = new NumberAxis("Interest");
rangeAxis0.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
final NumberAxis rangeAxis1 = new NumberAxis("Principal");
rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
plot.setRangeAxis(0, rangeAxis0);
plot.setRangeAxis(1, rangeAxis1);
dataset1.addValue(100,"I","Jan");
dataset2.addValue(60,"P","Jan");
dataset1.addValue(340,"I","Feb");
dataset2.addValue(50,"P","Feb");
dataset1.addValue(300,"I","Mar");
dataset2.addValue(40,"P","Mar");
dataset1.addValue(260,"I","Apr");
dataset2.addValue(20,"P","Apr");
dataset1.addValue(240,"I","May");
dataset2.addValue(30,"P","May");
dataset1.addValue(270,"I","Jun");
dataset2.addValue(45,"P","Jun");
dataset1.addValue(220,"I","Jul");
dataset2.addValue(70,"P","Jul");
dataset1.addValue(180,"I","Aug");
dataset2.addValue(35,"P","Aug");
dataset1.addValue(212,"I","Sep");
dataset2.addValue(22,"P","Sep");
dataset1.addValue(230,"I","Oct");
dataset2.addValue(43,"P","Oct");
dataset1.addValue(320,"I","Nov");
dataset2.addValue(25,"P","Nov");
dataset1.addValue(295,"I","Dec");
dataset2.addValue(65,"P","Dec");
plot.setDataset(0, dataset1);
plot.setDataset(1, dataset2);
plot.mapDatasetToRangeAxis(0, 0);
plot.mapDatasetToRangeAxis(1, 1);
BarRenderer renderer0 = new BarRenderer();
renderer0.setSeriesPaint(0, Color.blue);
plot.setRenderer(0, renderer0);
BarRenderer renderer1 = new BarRenderer();
renderer1.setSeriesPaint(0, Color.red);
plot.setRenderer(1, renderer1);
*************************************************************
Gaps between Bars of BarChart having multipal DataSet
-
- Posts: 10
- Joined: Tue Mar 14, 2006 12:24 pm
- Location: Mumbai, India