Search code examples
achartengine

achartenginge manual legends and labels


I developed an app for Android using achartengine for some charts. I have 68 XYseries in my chart, but I want to have only 2 Legends. All XYSeries in red = one legend. All XYSeries in green = second legend.

Also I need manual Labels for the Y Axis. Y=1 should be g for example.


Solution

  • There is a setShowLegendItem(boolean showLegend) method in SimpleSeriesRenderer, so it is inherited by XYSeriesRenderer. You should call this method for most of your renderers excepting 2 of them.

    In order to have custom Y axis labels, you need to do the following for each such lavel:

    renderer.addYTextLabel(y, "text");
    

    And you also need to disable the default labels:

    renderer.setYLabels(0);