0

是否可以遍历属于 JFreechart 中系列的点?谢谢

4

2 回答 2

2

是的,例如带有一个 XYSeries 的 XYSeriesColleciton,其中包括简单的数字:
这是代码:

XYSeriesCollection dataSet0 = (XYSeriesCollection) plot.getDataset(0);
XYSeries series0 = dataSet0.getSeries(0);
for (Object i : series0.getItems()) {
  XYDataItem item = (XYDataItem) i;
  double x = item.getXValue();
  double y = item.getYValue();
}
于 2011-07-14T19:24:58.947 回答
1

您可以遍历任何给定图中的列和行,但正如垃圾神评论的那样:您应该在数据模型中进行循环。

如果你坚持循环遍历这些点,你可以通过两种方式做到这一点:

  • 循环遍历行/列的数量并获取行/列的给定索引的值
  • 循环遍历行/列的键并获取给定行/列键对的值

这是在给定系列的数据集上完成的。您应该能够使用以下方法来实现:

int getColumnCount(); // Returns the number of columns in the table.
int getRowCount(); // Returns the number of rows in the table.

java.util.List getColumnKeys(); // Returns the column keys.
java.util.List getRowKeys(); // Returns the row keys.

java.lang.Number getValue(java.lang.Comparable rowKey, java.lang.Comparable columnKey); // Returns the value for a pair of keys.

有关更多信息,请参阅此处的 JFreeChart 文档,或购买开发人员手册以深入了解这些类。

于 2011-06-22T11:17:11.320 回答