Upgrade from 2002 version of jFreeChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
eselick
Posts: 7
Joined: Sat Apr 16, 2016 1:24 am
antibot: No, of course not.

Upgrade from 2002 version of jFreeChart

Post by eselick » Sat Apr 16, 2016 1:44 am

Hi
I need to upgrade to the latest version which I have downloaded and am desperately trying to avoid a rewrite :-)

I've added jcommon-1.0.23.jar and jfreechart-1.0.19.jar to my Netbeans project library.
I also tried replacing the following with the org.jfree equivalents as show below.

Code: Select all

/*
import com.jrefinery.data.*;
import com.jrefinery.chart.*;
import com.jrefinery.chart.ChartPanel;
import com.jrefinery.chart.data.*;
import com.jrefinery.chart.ui.*;
import com.jrefinery.layout.LCBLayout;
*/
import org.jfree.data.*;
import org.jfree.chart.*;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.data.*;
import org.jfree.chart.ui.*;
import org.jfree.layout.LCBLayout;
I'm getting "package does not exist" errors on these two lines:

Code: Select all

import org.jfree.chart.data.*;
import org.jfree.chart.ui.*;
How can I fix this?

Thanks in advance. I really appreciate the help.
Elliot

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Upgrade from 2002 version of jFreeChart

Post by paradoxoff » Sat Apr 16, 2016 8:08 pm

eselick wrote:How can I fix this?
By deleting the import statement!
PLease check what classes were imported from the com.jrefinery.chart.data and com.jrefinery.chart.ui packages. Then try to find them in the current package structure.

eselick
Posts: 7
Joined: Sat Apr 16, 2016 1:24 am
antibot: No, of course not.

Re: Upgrade from 2002 version of jFreeChart

Post by eselick » Mon Apr 18, 2016 9:55 pm

Hi

I've just purchased the developer guide but still need some help

The old code is creating a dataset using three array lists for the series, categories and data.
These are created before the dataset itself is created and and I would like to keep the existing code for that part.

Is there a way of creating a dataset in the same way with the new version of jFree?

The guts of the old code is shown below and I would like to get rid of the MyCategoryDataSet class and replace it with a simpler updated version.

Code: Select all

private ArrayList categories, series, dataAL, tmp_categories;
 
private CategoryDataset createCategoryDataSet() {
	return (new MyCategoryDataSet(generateSeries(series),
			generateCategory(tmp_categories),
			generateData(dataAL)));
}

The declaration for MycategoryDataset is as follows:

Code: Select all

public class MyCategoryDataSet extends AbstractSeriesDataset implements CategoryDataset {

    /** The series names. */
    protected String[] seriesNames;

    /** The categories. */
    protected Object[] categories;

    /** Storage for the data. */
    protected Number[][] data;
	/**
public MyCategoryDataSet(String[] seriesNames, Object[] categories, Number[][] data) {

Thanks
Elliot

eselick
Posts: 7
Joined: Sat Apr 16, 2016 1:24 am
antibot: No, of course not.

Re: Upgrade from 2002 version of jFreeChart

Post by eselick » Tue Apr 19, 2016 9:23 pm

Hi

I've decided to rewrite the routine that creates the dataset. The code has to parse a socket stream that is sending a tokenized list of rows and categories. I have the following declarations

Code: Select all

private DefaultCategoryDataset dataset;
private String dateTok;
private String seriesTtl;
private Integer intValue;

i'm getting a "nullpointer exception" when I execute the following line:

Code: Select all

dataset.addValue(intValue, seriesTtl, dateTok);

The three fields being passed into the addValue method are show in the Netbeans debugger as an Integer, a String and a String so I don't think that's the problem

Is there sometihng incorrect about using the addvalue method with a DefaultCategoryDataset? Will it only work with a CategoryDataset class?

I hope someone's out there to give a hand :-)
Thanks
Elliot

eselick
Posts: 7
Joined: Sat Apr 16, 2016 1:24 am
antibot: No, of course not.

Re: Upgrade from 2002 version of jFreeChart

Post by eselick » Tue Apr 19, 2016 10:33 pm

Please forget the last post/question.The following should have been.

Code: Select all

 private  DefaultCategoryDataset dataset = new DefaultCategoryDataset();
not
 private  DefaultCategoryDataset datase;
It's been a while since I've done any Java but it's working now :-)
Elliot

Locked