Chart data not showing- help!

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

Chart data not showing- help!

Post by Paul Deason » Sat Mar 01, 2003 5:00 pm

Hi,

I am trying to draw a vertical combination line graph using the below code. When it is run, no data is graphed- only the title, axis, legend.....

Would anyone have an idea to why that is? I presume it is attempting to chart the data because I can see some colour at the edge of the window. Do I therefore need to position it properly or something so I can see it??

// create a parent plot...
CombinedXYPlot plot = new CombinedXYPlot(new HorizontalNumberAxis("Date"),
CombinedXYPlot.VERTICAL);

// create a fill paint supplier to ensure all series use a unique color...
DrawingSupplier supplier = new DefaultDrawingSupplier();

// create subplot 1...
IntervalXYDataset data1 = createDataset1(plota, f1);//my own dataset
XYItemRenderer renderer1 = new StandardXYItemRenderer();
renderer1.setDrawingSupplier(supplier);
renderer1.setToolTipGenerator(new TimeSeriesToolTipGenerator("d-MMM", "0,000.0"));
XYPlot subplot1 = new XYPlot(data1, null, new VerticalNumberAxis("Price(£)"), renderer1);
//subplot1.addAnnotation(new XYTextAnnotation("Hello!",
//new Font("SansSerif", Font.PLAIN, 9),
//50.0, 10000.0));
// create subplot 2...
IntervalXYDataset data2 = createDataset2(plotb, f2);
XYPlot subplot2 = new XYPlot(data2, null, new VerticalNumberAxis("Price(£)"));
XYItemRenderer renderer2 = subplot2.getRenderer();
renderer2.setDrawingSupplier(supplier);
renderer2.setToolTipGenerator(new TimeSeriesToolTipGenerator("d-MMM", "0,000.0"));
// add the subplots...
plot.add(subplot1, 1);
plot.add(subplot2, 1);

// return a new chart containing the overlaid plot...
JFreeChart chart = new JFreeChart("Comparison of the TWO Funds "+f1.name+" and "+f2.name,
JFreeChart.DEFAULT_TITLE_FONT, plot, true);


ChartPanel panel = new ChartPanel(chart, true, true, true, false, true);
panel.setPreferredSize(new java.awt.Dimension(700, 470));
setContentPane(panel);


Thanks.

David Gilbert

Re: Chart data not showing- help!

Post by David Gilbert » Tue Mar 04, 2003 10:07 am

It's difficult to tell. I can't see anything obviously wrong with your code, but I also can't see how you have created the datasets...the problem might be in there.

Regards,

Dave Gilbert

Locked