Problem with legend

I use achartengine to draw a chart in my application. So far, the schedule has been completed successfully. the only problem i am facing is when i try to remove the legends. As for my application, I feel like I don't want legends. Therefore i used

renderer.setShowLegend(false); 

and he canceled the legends, but also removed the x-axis labels. can anyone tell me what is going on? or where am I making a mistake.

I tried adding

 renderer.setDisplayChartValues(true); 

but he does nothing.

+4
source share
3 answers

You might want to manually set the chart fields. Something like that:

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

Also, make sure that these labels are turned on to display:

 renderer.setShowLabels(true); 
+6
source

The following are the arguments of the method below:

  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 it helps someone.

+5
source

A value of true for setFitLegend () will cause the chart to render only the space that is required and make the chart fit the screen. In addition, you can also manually set the fields with the required values.

 renderer.setFitLegend(true); 

OR

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

Have only one or both of these methods. Please note that you will need to adjust the margin values ​​by trial and error if you decide that both methods display the chart correctly. The values ​​in setMargins () are values ​​that fit my needs. Change them as needed.

PS: The setMargins () method takes values ​​in the form of top, left, bottom, and right in this order.

+1
source

All Articles