如何从StackedBarChart(jFreeChart)获取最大Y值? [英] How to get max Y value from StackedBarChart (jFreeChart)?
本文介绍了如何从StackedBarChart(jFreeChart)获取最大Y值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从创建的图表中获取最大轴值?
How to get the maximum axis value from a created chart?
创建方式如下:
final JFreeChart chart = ChartFactory.createStackedBarChart("", "", symbol, dataSet,PlotOrientation.VERTICAL, false, false, false);
我可能必须从图表中获取数据集,然后从中获取最大轴值.数据集为DefaultCategoryDataset
.
I probably have to get the dataset from the chart and then get the maximum axis value from it. The dataset is DefaultCategoryDataset
.
推荐答案
只需遍历CategoryDataset
CategoryDataset dataset = createDataset();
for (int r = 0; r < dataset.getRowCount(); r++) {
double max = Double.MIN_VALUE;
for (int c = 0; c < dataset.getColumnCount(); c++) {
Number number = dataset.getValue(r, c);
double value = number == null ? Double.NaN : number.doubleValue();
if (value > max) {
max = value;
}
}
System.out.println(dataset.getRowKey(r) + ": " + max);
}
使用 查看全文