partTimeNinja
partTimeNinja

Reputation: 301

How to set JFreeChart to not order DataSet?

I have small project which makes a graph plot of a data in database. One record in DB is like this:

ID, Name, Xcoord, Ycoord

For example, I've added 10 points coordinates of which is more or less like this:

1st(1:1) 2nd(2:2) 3rd(3:3) 4th(4:4) ... 10th(10:10);

After that I want to add one more point 11th(5,7:5,7), and 10th must connect with 11th. So line must go leftwards. Now XYPlot sorts my XYDataset and 11th point gets plotted in between of 5th and 6th Points, and I don't want that.

Can anyone help?

UPDATE : As correctly supposed by mr.Trashgod i was using org.jfree.data.xy.XYSeries(), and setting autosort flag to false lead to correct plotting.

Upvotes: 3

Views: 1737

Answers (1)

trashgod
trashgod

Reputation: 205875

Without knowing which XYDataset you are using, it's hard to be specific. The several XxxSeriesCollection subclasses typically contain series that have an optional autoSort parameter in the constructor. For example, an XYSeriesCollection contains zero or more XYSeries with a suitable constructor:

XYSeries(java.lang.Comparable key, boolean autoSort)
XYSeries(java.lang.Comparable key, boolean autoSort, boolean allowDuplicateXValues)

Upvotes: 6

Related Questions