I can't seem to enable padding on the horizontal BarChart
in MPAndroidChart... Like on the screenshot below..the word commentary is cut off..even on tablets, both orientations e.t.c
Have a look at the viewport documentation of the MPAndroidChart library.
There you find a method called setExtraOffsets(float left, float top, float right, float bottom)
that allows to set additional offsets (as you require) for the chart.
chart.minOffset = 0f
it will remove space on top/right/bottom/left
, but it have 1 problem. A half of the HIGHEST label on left/right axis will above (overflow) another view on top)
chart.setViewPortOffsets(left, top, right, bottom)
it help us set the space in top/right/bottom/left
but from the axis not from the label (eg: if we set left = 0 we will not see the label on the left). so if I only want to set the space on top only, this function is not suitable
chart.setExtraOffsets(left, top, right, bottom)
chart.extraTopOffset
chart.extraBottomOffset
chart.extraRightOffset
it helps us set space to top/right/bottom/left but it is the EXTRA space so to make it look as same as the design (eg: 40dp), I use
chart.extraTopOffset = getDimension(R.dimen_40dp) - chart.minOffset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With