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
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
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.
Hi Brian,
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...
Thanks,
Bruce
Here's an example of getting and setting range things:
public void processChart( Object chart, Map params )
{
//call to super
try
{
super.processChart(chart, params);
JFreeChart jfc = (JFreeChart) chart;
// StandardLegend sl = (StandardLegend) jfc.getLegend();
// Font font = sl.getItemFont();
// float newsize = font.getSize() -1;
// sl.setItemFont(font.deriveFont(newsize));
// with our combined chart, the data set is null, we have to get the sub
// plots
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));
plot.getRangeAxis().setLabelAngle(.45);
plot.getRangeAxis().setTickLabelsVisible(false);
StandardXYItemRenderer rr = new StandardXYItemRenderer();
rr.setPlotShapes(true);
rr.setShapesFilled(true);
for (int k = 0; k < 6; k++)
{
rr.setSeriesShape(k, getShape(j, k));
rr.setSeriesPaint(k, getColor(j, k));
}
rr.setPlotLines(false);
plot.setRenderer(rr);
}
}
//do some different rendering
}
catch (Exception e)
{
e.printStackTrace();
}
}
Hi Brian,
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();
xrangeAxis.setLowerBound(10);
}
};
Log in to post a comment.