I can confirm that ShinobiCharts for Android doesn’t yet include the data point label functionality that our sister iOS version has. There also isn’t a direct way of obtaining the area taken up by the columns.
That said, if your chart is static (or at least doesn’t allow zooming) you can work out the column width as follows:
- divide the current displayed width of the x axis by the number of columns - this will be the width (in datat terms) of each column if there was no interSeriesPadding and no interSeriesSetPadding
- in your picture above it looks like you have 0 interSeriesPadding but 0.5 interSeriesSetPadding in which case you will want to multiply the above column width by 1 - 0.5 to get the actual column width
- that value divided by 2 will be the offset in data terms for your annotations but you’ll need to convert it to pixels: use the Axis.getPixelValueForUserValue() method to convert the half column width value to pixels, the minimum of the displayed range to pixels and finally the difference between the half column pixel value and the range minimum pixel value
In order for the getPixelValueForUserValue() method to return meaningful answers the chart needs to be laid out. As such we provide the ShinobiChart.OnInternalLayoutListener callback interface. So, if you add your annotations at the data points just as you have been doing and then in the onInternalLayout callback method calculate the offset you can adjust the position of the annotations by that offset
Annotation annotation = chart.getAnnotationsManager().getAnnotations().get(0);
This should work fine when panning the chart. However, zooming the chart will change the width of the columns and so you may be able to hook into some of the other callback interfaces to calculate an amount to ‘zoom’ the width by (e.g. OnGestureListener.onPinch or even OnAxisRangeChangeListener).
Hope that helps! I know it sounds quite fiddly but, particularly if you’re not zooming, it’s actually pretty straight forward and doesn’t require much extra code.