Hi all,
I am currently integrating JFreeChart 0.91 with the Echo Web Application Framework.
<shamelss plug>
What is Echo? Echo is a framework for developing object-oriented, event-driven Web applications. Essentially Echo allows you to build web applications in the same manner you build Swing applications, without needing to bother with HTML, HTTP, JavaScript or the Servlet api. Echo is open-source software distributed under the terms of the GNU LGPL License. If you would like to escape the dark side and learn how easy web development can be then head on over to www.nextapp.com/products/echo
</shamelss plug>
The integration I've been doing is to create a ChartPanel component that plays the same role as JFreeChart's own ChartPanel class.
My problem is my demo app is throwing a null pointer exception when trying to render a Vertical Stacked 3D Bar Chart. (Note: I've got 15 other chart examples working with out any problems.)
The stack trace I'm getting is...
at com.jrefinery.chart.StackedVerticalBarRenderer3D.drawCategoryItem(Unknown Source)
at com.jrefinery.chart.VerticalCategoryPlot.render(Unknown Source)
at com.jrefinery.chart.VerticalCategoryPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.createBufferedImage(Unknown Source)
The chart is being created with...
private JFreeChart createStackedVertical3DBarChart() {
String title = "Vertical Stacked 3D Bar Chart";
String categoryAxisLabel = "Categories";
String valueAxisLabel = "Values";
JFreeChart chart = ChartFactory.createStackedVerticalBarChart3D(title, categoryAxisLabel, valueAxisLabel, categoryData, true);
setBackground(chart);
return chart;
}
The categoryData dataset being used is based on the JFreeChart examples...
double[][] data = new double[][] {
{ 1.0, 4.0, 3.0, 5.0, 5.0, 7.0, 7.0, 8.0 },
{ 5.0, 7.0, 6.0, 8.0, 4.0, 4.0, 2.0, 1.0 },
{ 4.0, 3.0, 2.0, 3.0, 6.0, 3.0, 4.0, 3.0 }
};
categoryData = new DefaultCategoryDataset(data);
categoryData.setSeriesName(0, "First");
categoryData.setSeriesName(1, "Second");
categoryData.setSeriesName(2, "Third");
String[] categories = new String[] { "Type 1", "Type 2", "Type 3", "Type 4",
"Type 5", "Type 6", "Type 7", "Type 8" };
categoryData.setCategories(categories);
I've put the same code into a JFrame and it works as expected. The problem is only appearing when called via JFreeChart.createBufferedImage().
In the StackedVerticalBarRenderer3D class there is the comment...
"There are some bug-fixes in the StackedVerticalBarRenderer class that need to get applied here...", it just seems a little strange that it works in one context and not in the other.
Anyone got any ideas?
thanks
/PhillipB
Integration with Echo Web Framework
Re: Integration with Echo Web Framework
Hi Phillip,
Thanks for reporting this. The problem is that the code in the drawCategoryItem method is not checking for a null info object (null is permitted). The ChartPanel passes in an info object by default (to collect tooltip information and so forth), so it won't fail when you display a chart on screen.
I've fixed the bug and committed the change to CVS.
Regards,
DG.
P.S. I'll take a look at Echo and add a link on the JFreeChart page. It's always good to see JFreeChart being used in other free/open source packages.
Thanks for reporting this. The problem is that the code in the drawCategoryItem method is not checking for a null info object (null is permitted). The ChartPanel passes in an info object by default (to collect tooltip information and so forth), so it won't fail when you display a chart on screen.
I've fixed the bug and committed the change to CVS.
Regards,
DG.
P.S. I'll take a look at Echo and add a link on the JFreeChart page. It's always good to see JFreeChart being used in other free/open source packages.
Re: createStackedVertical3DBarChart in v.9 -> Was: Re: ..
For what it's worth, I am seeing the same thing:
I upgraded from v.0.81 jars to v.0.91 and now I am seeing this stack trace:
Exception in thread "main" java.lang.NullPointerException
at com.jrefinery.chart.StackedVerticalBarRenderer3D.drawCategoryItem(Unknown Source)
at com.jrefinery.chart.VerticalCategoryPlot.render(Unknown Source)
at com.jrefinery.chart.VerticalCategoryPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.createBufferedImage(Unknown Source)
at com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown Source)
at com.jrefinery.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at jp.co.macnica.cms.web.common.chart.BarChartGeneratorPngImpl.generate(BarChartGeneratorPngImpl.java:123)
at jp.co.macnica.cms.web.common.chart.Examples.main(Examples.java:152)
when I call ChartFactory.createStackedVerticalBarChart3D() from previously working code. Also, when I replace the 3D call with the 2D version - ChartFactory.createStackedVerticalBarChart() - it succesfully creates the chart. Has this been fixed yet? Will there be another binary release soon?
-Best regards,
Ray Mercer
Yokohama, Japan
I upgraded from v.0.81 jars to v.0.91 and now I am seeing this stack trace:
Exception in thread "main" java.lang.NullPointerException
at com.jrefinery.chart.StackedVerticalBarRenderer3D.drawCategoryItem(Unknown Source)
at com.jrefinery.chart.VerticalCategoryPlot.render(Unknown Source)
at com.jrefinery.chart.VerticalCategoryPlot.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.draw(Unknown Source)
at com.jrefinery.chart.JFreeChart.createBufferedImage(Unknown Source)
at com.jrefinery.chart.ChartUtilities.writeChartAsPNG(Unknown Source)
at com.jrefinery.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at jp.co.macnica.cms.web.common.chart.BarChartGeneratorPngImpl.generate(BarChartGeneratorPngImpl.java:123)
at jp.co.macnica.cms.web.common.chart.Examples.main(Examples.java:152)
when I call ChartFactory.createStackedVerticalBarChart3D() from previously working code. Also, when I replace the 3D call with the 2D version - ChartFactory.createStackedVerticalBarChart() - it succesfully creates the chart. Has this been fixed yet? Will there be another binary release soon?
-Best regards,
Ray Mercer
Yokohama, Japan
Re: createStackedVertical3DBarChart in v.9 -> Was: Re: ..
Oops. I guess you posted the reply while I was composing my msg.
Thanks!
P.S. Do you have a feel for when the next binary release will happen?
Thanks!
P.S. Do you have a feel for when the next binary release will happen?
Re: Integration with Echo Web Framework
I'd like to make another release before the end of next week, but don't take that as a promise.
Regards,
DG.
Regards,
DG.
Re: Integration with Echo Web Framework
David,
I should point out the integration between JFreeChart and Echo has not yet been released. It is unlikely this component will be included in the Echo distribution as the project owners wish to keep dependancies to 3rd party libraries to a minimum. I will however be releasing the code probably via a sourceforge project or similar and will post an update here when this is done. This will probably be within the next couple of weeks.
/PhillipB
I should point out the integration between JFreeChart and Echo has not yet been released. It is unlikely this component will be included in the Echo distribution as the project owners wish to keep dependancies to 3rd party libraries to a minimum. I will however be releasing the code probably via a sourceforge project or similar and will post an update here when this is done. This will probably be within the next couple of weeks.
/PhillipB