Category axis custom range of categories



I am wondering if it is possible to set a specific custom range for Category Axis. For example my data points have values of A, B, C, D, F, H and I need to display A, B, C, D, E, F, G and H categories. By default only the ones available are added.

Thank you.


Hi alin,

A CategoryAxis will have no knowledge of the X values other than what it finds in the data points. I know you only gave it as an example, but take what you put in your post: as far as the axis is concerned it does not know that the what you want is an ordered list of the letters of the alphabet. It only knows about the categories A, B, C, D, F and H as it has found data points with these X values.

Therefore, to get it to show all the categories you want, simply add some extra data points (in the same order you wish them to be displayed) with a Y value of 0 (or whatever value makes sense for your chart).

Incidentally, under the hood the categories are mapped to numeric values which means you set any ranges on the axis in terms of Doubles, not Strings. CategoryAxis.getCategories() will give you a list of all the categories on the axis - the index of each category is the numeric value it’s mapped to. The values set in the ranges don’t have to be integer values either (if you’re using a ColumnSeries you’ll probably want to add 0.5 either side, for example).

I hope that helps but do post back if you have any further questions!

Kind regards,