Problem with Charts involving DataSeriesItem - bug?

I have the following weird problem when using Charts.

I have six DataSeries named A, B, C, D, E, and F - each with a single DataSeriesItem. Five of the six DataSeriesItem were created with a category X and one of them with category Y. Something like this:

A = new DataSeries(“A”);
A.add(new DataSeriesItem(“X”, 6);
B = new DataSeries(“B”);
B.add(new DataSeriesItem(“X”, 5);
C = new DataSeries(“C”);
C.add(new DataSeriesItem(“Y”, 4);
D = new DataSeries(“D”);
D.add(new DataSeriesItem(“X”, 3);
E = new DataSeries(“E”);
E.add(new DataSeriesItem(“X”, 2);
F = new DataSeries(“F”);
F.add(new DataSeriesItem(“X”, 1);
ArrayList list = new ArrayList();
list.add(A); list.add(B); list.add(C); list.add(D); list.add(E); list.add(F);

Then I create an X-Axis with two categories - “X” and “Y” and add it to the Configuration:

XAxis xAxis = new XAxis();
xAxis.setCategories(new String {“X”, “Y”});

But when the chart gets displayed, only category “X” shows up on the X-Axis and all 6 series’ data items get shown over that one category, including C’s data item - which is actually of category “Y”. Can anyone tell me what I"m doing wrong - or if this is a bug?

Thanks in advance for all help

As an additional data point: when I add an additional data item for series C that is of category “X”, everything works as expected:

C.add(new DataSeriesItem(“X”, 12);

It seems that the “Category” on the DataSeriesItem is totally ignored and, instead, positional logic is used to determine which category a given DataSeriesItem goes into - i.e. the 1st element of each series always goes into the 1st category, the 2nd element of each series into the 2nd category, etc. If that’s the case, it begs the question "Why have category names for DataSeriesItems?

To me this looks like a bug, no?

Bump - does anyone have an opinion on whether this is a bug or my misunderstanding? Any feedback is much appreciated.

Same problem here.

Simple code to reproduce:

        xAxis.setCategories(new String [] {"C1", "C2", "C3"});

        dataSeries.add(new DataSeriesItem("C1", 1));
        dataSeries.add(new DataSeriesItem("C3", 3));

The second item is added to category “C2” - instead of “C3”

Therefore I would consider it a bug. The tooltip is correct, but the xAxis is wrong


If you wish the category name of a DataSeriesItem to have effect, change the type of axis to AxisType.CATEGORY like this:


Then don’t call setCategories at all. The setCategories should only be used if you use x value to map to category:

        chart.getConfiguration().getxAxis().setCategories(new String [] {"C1", "C2", "C3"});

        DataSeries dataSeries = new DataSeries();

        dataSeries.add(new DataSeriesItem(0, 1)); // 0 = index of  C1

        dataSeries.add(new DataSeriesItem(2, 3)); // 2 = C3


This method is initially designed to work with ListSeries, where indexes are used as “x value”.


Matti, Gerhard,
The suggestion of using “chart.getConfiguration().getxAxis().setType(AxisType.CATEGORY);” instead of using setCategories() didn’t work - same result. The chart ends up just showing one label - “X”. So this is a bug - I filed it at

Thanks for trying to help, though.