gpt4 book ai didi

java - 将 DefaultCategoryDataset 值写入文件

转载 作者:行者123 更新时间:2023-12-01 14:39:37 26 4
gpt4 key购买 nike

我在程序中使用jfree图表。我使用 DefaultCategoryDataset 来保存我想要在图表中显示的数据。现在我想写入 DefaultCategoryDataset 值包括列、行和值的列表。有人知道我该怎么做吗??

frame = new JFrame();
frame.setBounds(50, 50, 1135, 1029);

DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
for (int i = 0; i < observedEWMAs.size(); i++) {
dataSet.addValue(observedEWMAs.get(i), "observed" + title,
((Integer) (i + 1)).toString());
//here i want to write data set fo file

最佳答案

使用DefaultCategoryDataset定义于 BarChartDemo1 ,见过here ,以下代码产生预期的输出:

代码:

for (int r = 0; r < dataset.getRowCount(); r++) {
String series = (String) dataset.getRowKey(r);
for (int c = 0; c < dataset.getColumnCount(); c++) {
System.out.println(series
+ ", " + dataset.getColumnKey(c)
+ ", " + dataset.getValue(r, c));
}
}

控制台:

First, Category 1, 1.0First, Category 2, 4.0First, Category 3, 3.0First, Category 4, 5.0First, Category 5, 5.0Second, Category 1, 5.0Second, Category 2, 7.0Second, Category 3, 6.0Second, Category 4, 8.0Second, Category 5, 4.0Third, Category 1, 4.0Third, Category 2, 3.0Third, Category 3, 2.0Third, Category 4, 3.0Third, Category 5, 6.0

关于java - 将 DefaultCategoryDataset 值写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16110617/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com