Drawing curve

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

Drawing curve

Post by George Bilas » Fri Nov 08, 2002 3:22 pm

Hi there,

I'm having troubles trying to draw a function like 'x=y*y', or 'y=sqrt(x)' which is the same. I tried StandardXYItemRenderer first and XYSeriesCollection as a dataset. But that's not good 'cause for one x-value there're two y-values and drawing goes up and down at that point. Can anyone give a hint what else I could use? I've spent 4-5 hours with JFreeChart so I'm new to it.

Thank you.

Rene Teekema

Re: Drawing curve

Post by Rene Teekema » Fri Nov 08, 2002 4:36 pm

Hi George,

I had the same problem. To solve this I did extend the XYseries class and did override the add method to unconditionally add the provided pair to the dataset. In this way you get around the sorting of your data.
See the following code snippet for the add method.

public void add(XYDataPair pair) throws SeriesException {

// check arguments...
if (pair == null) {
throw new IllegalArgumentException("XYSeries.add(...): null item not allowed.");
}

data.add(pair);


}

Regards RT

George Bilas

Re: Drawing curve

Post by George Bilas » Tue Nov 12, 2002 5:27 pm

Hi Rene,

This probably works if you use something different than XYSeriesCollection. That beast has "private List data" where it keeps series.
But you were definitelly right about the root of the problem. Sorting is what's screwing things up. I think we sould point this out to the developers, shouldn't we?

Regards GB

Locked