0

The BarChart x-axis value label position and the LineChart x-axis value label position mismatch slightly. What can I do to fix this?

an anmiated gif of a bar chart and a line chart

mismatched labels on the x-axis]

David Rawson
  • 20,912
  • 7
  • 88
  • 124

1 Answers1

0

For what it's worth, I find that the mismatch is barely noticeable and if you hadn't have pointed it out I would not have seen it.

You can tweak the offset of the x-values using XAxis#setXOffset(float f):

mChart.getXAxis().setXOffset(10f);

Use a negative offset (e.g., -10f) if you want to move the labels in the opposite direction.

If you want to tweak the offset of the value on the LineChart it is a bit more complicated - you would have to subclass LineChartRenderer and override the method drawValues.

Please see How do MPAndroidChart renderers work and how do I write a custom renderer? if you wish to attempt that.

David Rawson
  • 20,912
  • 7
  • 88
  • 124