Annotation in CategoryChart always inside of bars
I've been trying to make the annotations in the CategoryChart to be always outside the bars but im getting this result:

i followed the example codes in the XChart Website
This is my code:
Font font = new Font("Arial", Font.PLAIN, 12);
CategoryChart chart = new CategoryChartBuilder().width(800).height(600).title(tituloGrafico).xAxisTitle(nombreEjeX).yAxisTitle(nombreEjeY).theme(ChartTheme.GGPlot2).build();
chart.getStyler().setChartBackgroundColor(ChartColor.getAWTColor(ChartColor.WHITE));
chart.getStyler().setPlotBackgroundColor(ChartColor.getAWTColor(ChartColor.WHITE));
chart.getStyler().setChartTitleBoxBackgroundColor(ChartColor.getAWTColor(ChartColor.WHITE));
chart.getStyler().setChartTitleBoxBorderColor(ChartColor.getAWTColor(ChartColor.WHITE));
chart.getStyler().setChartTitleBoxVisible(false);
chart.getStyler().setLegendVisible(true);
chart.getStyler().setLegendPosition(LegendPosition.InsideNW);
chart.getStyler().setHasAnnotations(true);
chart.getStyler().setAnnotationsPosition(1);
chart.getStyler().setShowTotalAnnotations(true);
chart.getStyler().setBaseFont(font);
As you can see im using chart.getStyler().setAnnotationsPosition(1); to force the annotation to be at the top (and i think outside the bars). After this im jut going adding the series in a for loop like this
chart.addSeries(datosSeriesHistograma.get(i).getNombreSerie(), Arrays.asList(serieX),Arrays.asList( serieY)).setFillColor(new Color(datosSeriesHistograma.get(i).getColorSerie().getRed(), datosSeriesHistograma.get(i).getColorSerie().getGreen(),datosSeriesHistograma.get(i).getColorSerie().getBlue()));
Is this some kind of "error" or am i making a something wrong?
Hi, I have a big issue for Category's annotations. I don't understand how to have on the top bars annotations (globalAnnotations) and haven't any annotations inside the bars. Can I manage in some way this requirement?
Another issue for Category If I have a big number the numbers exceds from margin bars. How I can resolve?
Thank in advance
Hi Thanks. I'm looking into it...
Right now this feature is not supported. I will leave this open as a feature request...
I'm pretty sure its a bug (this, just if im not doing something wrong). The annotations in the examples page are outside the bars in the categorychart (basic bar chart).

yeah, it's a bug. I'll add the bug tag.
Not sure if this is documented anywhere, but currently setAnnotationsPosition taking values from the range of [0.0, 1.0] is for placing the values within the bar. 0 makes it, the lowest possible place within the bar. 1 makes it the highest possible place within the bar.
So, in order to support placing the values outside of the bar I see several options for the API:
- change semantics of
1.0to mean "just above the bar" - allow for values outside of the range
[0.0, 1.0], so that people can specify e.g.1.1(would most likely look ugly) - add another method, e.g.
setAnnotationsPositionOutside(boolean)or something similar, the currentsetAnnotationsPositionwould only be used if the new property is set tofalse - ... else?
@timmolter what should happen here?
The 1.1 idea is ugly. I tried that. Whatever the solution it has to be a fixed distance, say 4 pixels above the bar. I think the best would be:
chart.getStyler().setLabelsOutside(true)