本文介绍了如何将JFreeChart设置为不订购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

例如,我添加了10个点坐标,这些坐标或多或​​少是这样的:

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);

之后,我想再增加一个点11th(5,7:5,7),第10个必须与第11个连接.因此,线必须向左走.现在XYPlot对我的XYDataset进行排序,第11点被绘制在第5点和第6点之间,我不希望这样.

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.

任何人都可以帮忙吗?

更新:正如Trashgod先生所正确假设的那样,我正在使用org.jfree.data.xy.XYSeries(),并将autosort标志设置为错误导致正确绘图.

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

推荐答案

在不知道您使用哪个XYDataset的情况下,很难一一列举.几个XxxSeriesCollection子类通常包含在构造函数中具有可选autoSort参数的系列.例如,XYSeriesCollection包含零个或多个 XYSeries 具有合适的构造函数:

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)

这篇关于如何将JFreeChart设置为不订购DataSet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 00:33