5

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.

easycheese
  • 5,859
  • 10
  • 53
  • 87

3 Answers3

7

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.

harry
  • 310
  • 1
  • 4
  • 17
  • 4
    I had to take out the negative value (made it 0) for bottom on the margin and made the LegendHeight(50). In order for it to look right. Seems to be an odd relationship between the 2. I wish there was some sort of documentation that helped. – easycheese Oct 22 '11 at 10:39
2

This works:

renderer.setYLabelsAlign(Align.LEFT, 0)
Anne
  • 26,765
  • 9
  • 65
  • 71
Anjani
  • 21
  • 2
2

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.

BobbyG
  • 536
  • 1
  • 7
  • 20