Detailed Bug-report: verticalXYBarChart

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

Detailed Bug-report: verticalXYBarChart

Post by BugHunter » Wed Mar 20, 2002 11:47 pm

Hello,
I'm using JFreeChart 0.7.4 on Windows NT.

I get a bug when I use verticalXYBarChart:

My code is pretty much like the code from the Demo, the only difference is that I take a day interval instead of a year interval to make the TimeSeries.
Here is where I make the TimeSeriesCollection, reading the data from a MySQL database:

public TimeSeriesCollection readTimeSeriesCollection(String table){
//read the data from the table

BasicTimeSeries ts = new BasicTimeSeries("Dolar", "Day", "Value", Day.class);
try{
System.out.println("Reading chart data");
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);

String dbQuery = "select * from " + table;
ResultSet rs = stmt.executeQuery(dbQuery);

Day day = null;
Double d = null;
int counter = 1;
//copy the resultSet into the BasicTimeSeries:
while(rs.next()){
day = new Day(counter++, 1, 2002);
d = new Double(rs.getDouble(2));
//here is where the data is added to the BasicTimeSeries:
ts.add(day, d);
}
}catch(Exception e){
e.printStackTrace();
}
return new TimeSeriesCollection(ts);
}

After that I take that TimeSeriesCollection and create a Chart with it, like in the demo:

IntervalXYDataset data = ds.readTimeSeriesCollection("timeSeries");
chart = ChartFactory.createVerticalXYBarChart(title, xAxisLabel, yAxisLabel, data, true);

It works, and actually displays a chart. But when the chart is displayed I get these error messages:

sun.dc.pr.PRException: endPath: bad path
at sun.dc.pr.Rasterizer.endPath(Unknown Source)
at sun.java2d.pipe.DuctusRenderer.createShapeRasterizer(Unknown Source)
at sun.java2d.pipe.DuctusShapeRenderer.renderPath(Unknown Source)
at sun.java2d.pipe.DuctusShapeRenderer.draw(Unknown Source)
at sun.java2d.pipe.ValidatePipe.draw(Unknown Source)
at sun.java2d.SunGraphics2D.draw(Unknown Source)
at com.jrefinery.chart.XYPlot.drawVerticalLine(Unknown Source)
at com.jrefinery.chart.XYPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at sun.awt.RepaintArea.paint(Unknown Source)
at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


This message gets displayed when the chart is first drawn and almost every time I resize it. I noticed that if I resize it to a small chart the exception doesn't happen.

Hope this helps to fix the bug.

David Gilbert

Re: Detailed Bug-report: verticalXYBarChart

Post by David Gilbert » Thu Mar 21, 2002 9:36 am

Thanks for the report...the detail is good, better than I get for some bug reports!

I don't think the problem is your dataset, it looks like you are creating it correctly. It might be related to another bug report to do with the cross-hairs. Try turning them off and see if you still get the problem...I'll take a closer look at the code, because something needs fixing.

To turn off crosshairs, you need to get a reference to each axis (cast to ValueAxis) and call setCrosshairVisible(false).

Regards,

DG

P.S The PRException typically shows up when you try to render a shape in Java2D with either very large coordinates or NaN values.

Locked