Search code examples
androidannotationsachartengine

Android - achartengine annotation rotation


How to rotate annotations on bar chart 90 degrees? I want to set annotations with horizantal BarChart from left to right opposed to top-down.

The numbers are chartvalues but I want to rotate annotations "annot", "test" added by AddAnnotation(annotation,x,y) method.

Sample Screnshot for Annotations


Solution

  • For this you have edit library code.

    Change in BarChart.java in method drawChartValuesText() .

    Make 0 to 90.

     if (value >= 0) {
              drawText(canvas, getLabel(renderer.getChartValuesFormat(), value), x, points.get(i + 1)
                  - renderer.getChartValuesSpacing(), paint, 90);
            } else {
              drawText(canvas, getLabel(renderer.getChartValuesFormat(), value), x, points.get(i + 1)
                  + renderer.getChartValuesTextSize() + renderer.getChartValuesSpacing() - 3, paint, 90);
            }
    

    For Annotation change this in draw() of XYChart.java

    drawString(canvas, series.getAnnotationAt(j), xS, yS, paint);
    

    to

     drawText(canvas, series.getAnnotationAt(j), xS, yS, paint,90);