如何计算JFreeChart中条形图的系列数? [英] How to count the number of series of a bar chart in JFreeChart?

查看:49
本文介绍了如何计算JFreeChart中条形图的系列数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JFreeChart创建条形图时,我遇到了一些问题. 我必须根据条形图上可用的多个序列来编写条件,但我不知道该如何获得.

I am facing the some problems when creating bar chart using JFreeChart. I have to write a condition according to a number of series available on the bar chart, but I don't know how to get it.

推荐答案

条形图通常使用

Bar charts typically use a CategoryDataset, all of which implement the KeyedValues2D interface. Use dataset.getRowCount() to get the number of series. Use dataset.getColumnCount() to get the number of distinct categories. Their product is the total number of bars.

作为一个具体示例,我向

As a concrete example, I added a spurious new series to BarChartDemo1 to get three series (rows) and two categories (columns).

private static CategoryDataset createDataset() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    …
    dataset.addValue(8000, "Meretricious", "Warm-up");
    dataset.addValue(24000, "Meretricious", "Test");
    return dataset;
}

这篇关于如何计算JFreeChart中条形图的系列数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆