Java – basic histogram in JfreeChart

I need to create a simple histogram using JfreeChart There should be 3 sets of numeric values assigned to these groups The problem is that defaultcategorydataset needs to specify "group" and "subgroup" (that is, dataset.setvalue (5, "subgroup1.1", "group1");), But I don't have subgroups What is an alternative to defaultcategorydataset? I need something like this:

DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(2,"Group1");
dataset.setValue(3,"Group2");
dataset.setValue(5,"Group3");

Solution

You can use the same row key for each bin and change the column key as follows:

DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(561,"Age","1 - 10");
dataset.addValue(1231,"10 - 20");
dataset.addValue(12323,"20+");
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>