JFreeChart's Problem

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

JFreeChart's Problem

Post by Emmet » Thu Feb 27, 2003 2:10 am

Please help me ~~~
-----------------------------------------------------------------------------
Environment
-----------------------------------------------------------------------------
Red Hat Linux 8.0 (include X-window)
JDK 1.4
Resin 2.1.5
JFreeChart 0.9.6
jfreechart-0.9.4.jar and jcommon-0.7.1.jar copied to $RESIN_HOME/WEB-INF/lib/
-----------------------------------------------------------------------------
Error Message
-----------------------------------------------------------------------------
Note: sun.tools.javac.Main has been deprecated.
/examples/chart.jsp:16: Wrong number of arguments in constructor.
DefaultCategoryDataset dataSet = new DefaultCategoryDataset(year,data);
^
/examples/chart.jsp:18: Method setCategories(java.lang.String[]) not found
in class com.jrefinery.data.DefaultCategoryDataset.
dataSet.setCategories(xAxisData);
^
/examples/chart.jsp:21: Wrong number of arguments in method.
chart = ChartFactory.createVerticalBarChart("Year", "Month", "Pcs", dataSet, true);
^
3 errors, 1 warning
-----------------------------------------------------------------------------

Emmet

Re: JFreeChart's Problem

Post by Emmet » Thu Feb 27, 2003 2:11 am

Revise--
jfreechart-0.9.6.jar and jcommon-0.7.2.jar copied to $RESIN_HOME/WEB-INF/lib/

Arnaud

Re: JFreeChart's Problem

Post by Arnaud » Thu Feb 27, 2003 8:50 am

Hello,

1) The error msg says You have not the correct nb of arguments in Your DefaultCategoryDataset constructor ; have a look at the javadoc (http://www.object-refinery.com/jfreecha ... taset.html)... and You will learn that the constructor takes no argument.

2) and 3) ... msg errors looks similar...

Btw, it's never a good idea to mix different versions of a package... don't use 0.9.4 and 0.9.6 together, jar or not jar...

Regards,
Arnaud

Emmet

Re: JFreeChart's Problem

Post by Emmet » Thu Feb 27, 2003 10:50 am

This is my source code ~~Please help me again~~
------------------------------------------------------------------------------------------------
<%@page contentType="image/jpeg;charset=MS950"%>
<%@page import="java.util.*,java.io.*,java.awt.*"%>
<%@page import="com.jrefinery.data.*,com.jrefinery.chart.*,com.jrefinery.chart.ui.*"%>
<%
String[] xAxisData = {"January", "February", "March"};
Number[][] data ={
{new Integer(120),new Integer(138),new Integer(300)},
{new Integer(95),new Integer(87),new Integer(99)},
{new Integer(180),new Integer(156),new Integer(173)}
};
String[] year ={"2000","2001","2002"};
DefaultCategoryDataset dataSet = new DefaultCategoryDataset(year,data);
dataSet.setCategories(xAxisData);
JFreeChart chart=null;
chart = ChartFactory.createVerticalBarChart("Year", "Month", "Pcs", dataSet, true);
OutputStream ostream = response.getOutputStream();
ChartUtilities.writeChartAsJPEG(ostream, chart, 300, 200);
ostream.close();
%>
------------------------------------------------------------------------------------------------

David Gilbert

Re: JFreeChart's Problem

Post by David Gilbert » Fri Feb 28, 2003 1:11 am

Hi Emmet,

The problem is that the API has changed between 0.9.4 and 0.9.5 - the DefaultCategoryDataset no longer has the constructor you are using. There is a method in the DatasetUtilities class that will create a CategoryDataset from a double[][], though.

Regards,

Dave Gilbert

Locked