Home » Android » java – Margin Between X-Axis Title and X-Axis Labels in AChartEngine

java – Margin Between X-Axis Title and X-Axis Labels in AChartEngine

Posted by: admin June 15, 2020 Leave a comment

Questions:

Iam using AChartEngine Stacked Bar Chart. Can i add spacing between X-Axis Title and X-Axis Labels. They are too closed to each other.

set Bottom Margin will only add spacing between X-Axis Title and Legend.

How to&Answers:

A quick patch which solved my problem, modify your X-Axis Title and prefix it with new lines, e.g

    renderer.setXTitle("\n\n\n Months");

Answer:

Use the setMargins() method. You can set the margins between the chart and the margins of the screen.

renderer.setMargins(new int[] {30, 100, 10, 0);

The order of the values in the parameter array is: top, left, bottom, right. So, you will need to increase the left value.

Answer:

use this method: setXLabelsPadding