How to set JFreeChart to not order DataSet?

偶尔善良 提交于 2019-12-23 23:11:47

问题


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.


回答1:


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)


来源:https://stackoverflow.com/questions/14395673/how-to-set-jfreechart-to-not-order-dataset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!