overlaying different charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
schmidt

overlaying different charts

Post by schmidt » Tue Feb 04, 2003 11:31 am

Hi,
Can anyone tell me ,how to overlay line chart on a vertical bar chart.

Dmitry Kashin

Re: overlaying different charts

Post by Dmitry Kashin » Tue Feb 04, 2003 2:02 pm

Something like this:

ValueAxis timeAxis;
NumberAxis valueAxis;

timeAxis = new HorizontalDateAxis(yLabel);
timeAxis.setAutoRange(true);
valueAxis = new VerticalNumberAxis(xLabel);
valueAxis.setAutoRangeIncludesZero(false);
linePlot = new XYPlot(new TimeSeriesCollection(series), null, null);
indexValuesPlot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES, new TimeSeriesToolTipGenerator()));
barPlot = new XYPlot(new TimeSeriesCollection(serie2), null, null);
limitsPlot.setRenderer(new VerticalXYBarRenderer(0, null));
overlaidChartPlot = new OverlaidXYPlot(yLabel, xLabel);
overlaidChartPlot.setDomainAxis(timeAxis);
overlaidChartPlot.setRangeAxis(valueAxis);
overlaidChartPlot.add(barPlot);
overlaidChartPlot.add(linePlot);

schmidt

Re: overlaying different charts

Post by schmidt » Wed Feb 05, 2003 9:34 am

Thanks Dmitry. But the overlaid plot so created gives null pointer exception when asked to saveChartAsJPEG in ChartUtilities. Any reason for this?

Locked