NullPointerException and Question

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

NullPointerException and Question

Post by Shailesh Gokhale » Wed Dec 11, 2002 5:06 pm

Hi JFreeChart Developers,

I have found jfreechart to be a very useful tool for an application that I am developing. I have come up with a problem while working with the api though.

I get the following NullPointerException for one of the data sets (DefaultPieDataset) that I am using. The stack trace and the data that I am using is pasted at the end of this mail.

I have traced my application with console messages and found that my code doesnt seem to have any problem except if I am using the api wrongly.

Kindly help resolve this problem.

I also have an enquiry. Is it possible to generate a chart such as the following with the present api?

? The required chart is an overlaid chart with two different datasets. For one part of the overlaid chart I want a VerticalBarChart. At the same time it should be able to show a trend line graph on the same canvas. ?

Regards
Shailesh Gokhale

****** Begin Stack Trace ******
java.lang.NullPointerException
at sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:53)
at sun.java2d.pipe.DuctusShapeRenderer.fill(DuctusShapeRenderer.java:49)

at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2190)
at com.jrefinery.chart.Pie3DPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.ChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java:804)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4735)

at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4688)
at javax.swing.JComponent._paintImmediately(JComponent.java:4632)
at javax.swing.JComponent.paintImmediately(JComponent.java:4464)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:404)

at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
java.lang.NullPointerException
at sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:53)
at sun.java2d.pipe.DuctusShapeRenderer.fill(DuctusShapeRenderer.java:49)

at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2190)
at com.jrefinery.chart.Pie3DPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.ChartPanel.paintComponent(Unknown Source)
at javax.swing.JComponent.paint(JComponent.java:804)
at javax.swing.JComponent.paintChildren(JComponent.java:643)
at javax.swing.JComponent.paint(JComponent.java:813)
at javax.swing.JComponent.paintChildren(JComponent.java:643)
at javax.swing.JComponent.paint(JComponent.java:813)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:552)
at javax.swing.JComponent.paintChildren(JComponent.java:643)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4742)

at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4688)
at javax.swing.JComponent.paint(JComponent.java:794)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)

at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1123)
at sun.awt.RepaintArea.paint(RepaintArea.java:180)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)
at java.awt.Component.dispatchEventImpl(Component.java:3586)
at java.awt.Container.dispatchEventImpl(Container.java:1437)
at java.awt.Window.dispatchEventImpl(Window.java:1566)
at java.awt.Component.dispatchEvent(Component.java:3367)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
****** End Stack Trace ******

****** Begin Dataset ******
Wed Dec 11 16:20:07 GMT+05:30 2002
Category -> Value
Failed -> 10
Second Class -> 0
First Class -> 0
First Class[Distinction] -> 0
Genius -> 0
===========================
Wed Dec 11 16:20:11 GMT+05:30 2002
Category -> Value
Failed -> 50
Second Class -> 0
First Class -> 0
First Class[Distinction] -> 0
Genius -> 0
===========================
****** End Dataset ******

David Gilbert

Re: NullPointerException and Question

Post by David Gilbert » Wed Dec 11, 2002 11:53 pm

There is a problem with the 3D pie plot and zero values in 0.9.4. It has been fixed in CVS - you can browse the CVS source code online via the JFreeChart project page on SourceForge:

http://sourceforge.net/projects/jfreechart

It is possible to overlay a line chart on top of a bar chart, but only if both datasets are CategoryDatasets and share the same set of categories. There is a demo in the download, OverlaidBarChartDemo I think...

Regards,

DG

Locked