Is there a way to plot two XY graphs using the XYChart and ChartPostProcessor? When I use overlaidchart the X values always start from zero so I was thinking the CPP might resolve this issue. Any help would be greatly appreciated.
Bruce, I remember this problem but not the solution. Is this the problem with the axis always starting at 0? If so, in your postprocessor, you can change the axis range as needed.
Thanks for the reply. Do you happen to remember how to change the axis range in the CPP? I'm still in the learning phase...
Here's an example of getting and setting range things:
public void processChart( Object chart, Map params )
//call to super
JFreeChart jfc = (JFreeChart) chart;
// StandardLegend sl = (StandardLegend) jfc.getLegend();
// Font font = sl.getItemFont();
// float newsize = font.getSize() -1;
// with our combined chart, the data set is null, we have to get the sub
if ( jfc.getXYPlot() instanceof CombinedDomainXYPlot )
List subplots = ((CombinedDomainXYPlot) jfc.getXYPlot()).getSubplots();
int j = 0;
for (Iterator i = subplots.iterator(); i.hasNext(); j++)
XYPlot plot = (XYPlot) i.next();
plot.getRangeAxis().setRange(new Range(1, 3));
StandardXYItemRenderer rr = new StandardXYItemRenderer();
for (int k = 0; k < 6; k++)
rr.setSeriesShape(k, getShape(j, k));
rr.setSeriesPaint(k, getColor(j, k));
//do some different rendering
catch (Exception e)
Thanks very nuch for the reply. I think I've got it now. The working code:
ChartPostProcessor combinedPP = new ChartPostProcessor()
public void processChart(Object chartobj, Map params)
JFreeChart chart = (JFreeChart) chartobj;
XYPlot xyp = chart.getXYPlot();
ValueAxis xrangeAxis = xyp.getDomainAxis();
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.