Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>.

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());
    }
}

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

I want to display like

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
419 views
Welcome To Ask or Share your Answers For Others

1 Answer

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...