4

I am using achartengine for drawing a chart in my app. So far the chart is drawn succesfully. the only problem i have is when i try to remove the legends. As for my app I feel I do not want the legends. So I used

renderer.setShowLegend(false);

and it did takeaway the legends but it also takes away the x axis labels. can anybody tell me what is happening? or where i am doing mistake.

i tried adding

renderer.setDisplayChartValues(true); 

but it does not do anything.

Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240
Ajax3.14
  • 1,647
  • 5
  • 24
  • 42

3 Answers3

6

You may want to set the margins of the chart manually. Something like this:

renderer.setMargins(new int[] { 20, 30, 15, 20 });

Also, make sure that the labels are enabled for displaying:

renderer.setShowLabels(true);
Dan D.
  • 32,246
  • 5
  • 63
  • 79
5

Detail for below method's arguments are as follow :

    renderer.setMargins(new int[] {10, 40, 0, 10});         //first value is space between top edge and end of Y-Axe    
                                                            //second value is space between left edge and labels of Y-Axe
                                                            //third value is space between bottom edge and labels of X-Axe
                                                            //forth value is space between right edge and end of X-Axe

It helps me and I hope this will help someone.

Darshit Patel
  • 147
  • 1
  • 8
1

Setting true for the setFitLegend() will make the chart renderer occupy only the space that is required and will make the chart fit the screen. Alternatively, you can also set the margins manually with required values.

renderer.setFitLegend(true);

OR

renderer.setMargins(new int[] {30, 30, -100, 30});

Have only one or both of the above methods. Note that you will need to adjust the margin values by trial and error if you choose to have both the methods to render the chart correctly. The values in the setMargins() are values fitting my needs. Change them as required.

P.S: The setMargins() method takes values as Top, Left, Bottom and Right, in that order.

Ram Iyer
  • 1,621
  • 1
  • 23
  • 25