Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Achartengine legend location

Does anyone know how to change the location of the legend? I am trying to expand the graph to make use of all the space.

So far I have

mRenderer.setMargins(new int[] { 20, 30, -50, 0 });

This expands the graph lower but the legend stays in the same location so it is now above the x axis

I tried

mRenderer.setLegendHeight(5);

with both negative and positive values. I'm not sure what this is supposed to do but it makes my graph go wayyyy low on the the screen (turns it into a scrollable view).

Also, may not be important but this is in a fragment and is a XYChart type.

like image 755
easycheese Avatar asked Sep 25 '11 16:09

easycheese


3 Answers

The property setLegendHeight(..) moves the position of the legend. Try to change the values you are using in both functions, that would work. cheers.

Harry.

like image 107
harry Avatar answered Oct 22 '22 19:10

harry


This works:

renderer.setYLabelsAlign(Align.LEFT, 0)
like image 45
Anjani Avatar answered Oct 22 '22 19:10

Anjani


In addition to using the advice above I found the following useful…

// Temporarily show margins so I can work out what is going on
renderer.setMarginsColor(Color.RED);

// Legend was being cropped or not shown at all until I did this
renderer.setFitLegend(true);

In the end I had both the bottom margin and the legend height set to zero but still saw it on the screen with margins showing up in Red (from my diagnostic above). I think some margins must be auto calculated for the legend from the setFitLegend.

like image 21
BobbyG Avatar answered Oct 22 '22 19:10

BobbyG