How to set JFreeChart to not order DataSet?
Asked Answered
C

1

3

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.

Commercialize answered 18/1, 2013 at 9:15 Comment(1)
Which XYDataset are you using?Leverrier
L
6

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)
Leverrier answered 18/1, 2013 at 13:28 Comment(1)
Thank you! This helped me alot :) I'd be glad to give to this answer an upvote, but not enough reputation i got.Commercialize

© 2022 - 2024 — McMap. All rights reserved.