arChart行键未添加到DefaultCategoryData

arChart行键未添加到DefaultCategoryData

本文介绍了StackedBarChart行键未添加到DefaultCategoryDataSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个实体类:A和B.A有B个实体,并且我有以以下格式定义的Map:.

I have two entity Classes: A and B. A has B entities, and I have a Map defined in the following format: Map<A, List<B>.

我想将所有地图数据添加到 DefaultCategoryDataset 和以下代码.例如,如果有5个A,每个A有4个B,我想有25个行键. (一个实体号*(每个A中的A实体编号+ B实体编号).存储A类的Row键必须具有相同的宽度;存储B实体的所有其他行必须具有相同的宽度.为此,我给出了在添加A行键((double)1/(1 + bResultList .size())的同时提供相同的值,在添加A行键((double)1/(1 + bResultList .size()+ 6)的同时提供较小的值.

I want to add all map data to DefaultCategoryDataset with following code. For example, if have 5 A and each A has 4 B, I want to have 25 row keys. (A entity number * (A entityNumber + B entity number in each A). A Row key that stores A class must be same width; all other rows that store B entities must have same width. To succeed in this, I am giving the same values while adding A row keys((double) 1 / (1 + bResultList .size()), and giving smaller values while adding A row keys((double) 1 / (1 + bResultList .size() + 6).

DefaultCategoryDataset dataset = new DefaultCategoryDataset();
/** for each workpoint */
for (A aResult : map.keySet()) {
    List<B> bResultList = map.get(aResult);
    dataset.addValue(
        (double) 1 / (1 + bResultList.size()),
        "WorkPoint " + aResult.getTimeStep(),
        "WP T=" + aResult.getTimeStep());
    /** for each contingency result */
    for (B bResult : bResultList) {
        dataset.addValue(
            (double) 1 / (1 + bResultList.size() + 6),
            bResult.getName(),
            "WP T=" + aResult.getTimeStep());
    }
}

但是当我将所有地图数据添加到数据集中时,不会存储所有行键.当我调试时,数据集只有9行. (A1,B1,B2,B3,B4,A2,A3,A4,A5)仅将第一个A实体的B个实体存储为行键.其他A实体的其他B实体未存储在数据库中.

But when I add all map data to data set all row keys are not stored. When I debug, Dataset only has 9 rows. (A1,B1,B2,B3,B4,A2,A3,A4,A5) Only B entities of first A entity is stored as row keys. Other B entities of other A entity is not stored in database.

但是当我显示图形时,所有数据都显示在图形中,但顺序错误.订单在后面.

But when I display graph, all data is displayed in graph but in wrong order.Order is following.

A1-B1-B2-B3-B4
B1-B2-B3-B4-A2
B1-B2-B3-B4-A3
B1-B2-B3-B4-A4
B1-B2-B3-B4-A5

我想显示为

A1-B1-B2-B3-B4
A2-B1-B2-B3-B4
A3-B1-B2-B3-B4
A4-B1-B2-B3-B4
A5-B1-B2-B3-B4

推荐答案

如果没有sscce,问题就不明显了.将您的数据集与典型的CategoryDataset进行比较可能会有所帮助,例如具有不同的系列(行)和类别(列)键.另外,添加CategoryItemLabelGenerator可能有助于调试.

Absent your sscce the problem is not apparent. It may help to compare your data set to a typical CategoryDataset such as this one that has distinct series (row) and category (column) keys. Also, adding a CategoryItemLabelGenerator may aid debugging.

renderer.setBaseItemLabelGenerator(
    new StandardCategoryItemLabelGenerator(
        "{0} {1} {2}", NumberFormat.getInstance()));
renderer.setBaseItemLabelsVisible(true);

这篇关于StackedBarChart行键未添加到DefaultCategoryDataSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 00:03