XY Line Chart, question about how XY values are connected ..

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Augusto
Posts: 12
Joined: Wed Jan 21, 2004 9:02 pm

XY Line Chart, question about how XY values are connected ..

Post by Augusto » Thu Jan 22, 2004 5:25 am

I have a weird chart with X,Y values that actually form an oval, that is, instead of the typical chart going from 0 -> n in the X axis (or Y axis too), it goes from 0->n and then from n->0.

So when I create an XY Line chart, I add the XY values in that order as described, yet when the lines are connected, they don't follow the order I inserted them in. Instead, they create the form of an oval with zig zag lines.

ex: (what I want)

values : (1,2), (2,3), (3,2), (2,1)

Code: Select all

3|   X
+| /   \
2| X   X
+| \   /
1|   X
 +-----------
0  1 2 3
What I get :

Code: Select all

3|   X
+|   |\
2| X | X
+|  \| 
1|   X
 +-----------
0  1 2 3
How can I create a chart with XY values that draws a line that can form arbitrary line shapes? Maybe I'm using the wrong chart type? (I also need to fill the area ...)

Augusto
Posts: 12
Joined: Wed Jan 21, 2004 9:02 pm

Post by Augusto » Thu Jan 22, 2004 7:49 pm

Any ideas anybody? Is this possible? If I'm not being clear, please let me know so I can post some images. Thanks!

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Jan 22, 2004 9:17 pm

The XYDataset interface doesn't require the x-values to be in ascending order, so what you are trying to do is possible.

The problem is that the XYSeries class (which is used by the XYSeriesCollection class to provide an implementation of the XYDataset interface) *does* order the data items by x-value. So you need to modify XYSeries so that it leaves items in the order that you add them.

Filling the area isn't possible with the existing renderers.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Augusto
Posts: 12
Joined: Wed Jan 21, 2004 9:02 pm

Post by Augusto » Thu Jan 22, 2004 11:58 pm

Thanks!

Locked