Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPAndroidChart - How to align seekbar with x-axis skipping extra padding?

I'm working with MPAndroidChart and I'm really enjoying it since it's really well done.

But I've got a problem that I haven't been able to resolve in a few hours. I've got a seekbar under the three charts (as you can see from the screenshots below) and I'd like to align it with the X-axis, skipping the space occupied by the Y-axis' labels on the left and the padding that gets added on the right.

Have you got any suggestion on how to achieve my goal? Is there a way of knowing the labels' width and the charts' extra-padding? Or, better, can I get the X-axis width?

Thanks in advance! Bye!

left padding right padding

like image 781
andrea.rinaldi Avatar asked Jan 30 '26 01:01

andrea.rinaldi


1 Answers

Update to the latest version of the library if you have not already. Then, just remove all offsets from the chart. It's in the documentation.

Call:

chart.setViewPortOffsets(0f, 0f, 0f, 0f);

This will remove all padding / margin / offset from the chart, making the actual content of the chart (the data) being the next thing to your screen edge.

like image 63
Philipp Jahoda Avatar answered Feb 01 '26 17:02

Philipp Jahoda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!