3

In CombinedChart by adding chart.setFitBars(true) will make the first and last bars visible.

I need to do the same for combining LineChart with BarChart.
Now, first and last bars aren't visible completely.

enter image description here

I've tried

xAxis.setAxisMaximum(data.getXMax() + 1f);

to extend X-Axis towards right side so that the last bar will get enough space. This did the trick.

But what should I do for left side bar?
setAxisMinimum doesn't help.

After adding setAxisMaximum :

enter image description here

EDIT

I've referred this but it gives the solution for only BarChart.

Prabs
  • 4,923
  • 6
  • 38
  • 59
  • 1
    Possible duplicate of [MPAndroidChart - First and last bars not rendering correctly](http://stackoverflow.com/questions/38838362/mpandroidchart-first-and-last-bars-not-rendering-correctly) – TR4Android Feb 06 '17 at 10:25
  • @TR4Android Nope. The solution provided there isn't applicable for CombinedChart – Prabs Feb 06 '17 at 10:51
  • 1
    I've added a solution for `CombinedChart`s using `setSpaceMin()` and `setSpaceMax()` on the `XAxis` of the chart. – TR4Android Feb 06 '17 at 10:52

1 Answers1

7

Got it.

xAxis.setAxisMinimum(-0.5f);

enter image description here

I guess, Edited X-Axis label will make it look good.

For editing labels in MPAndroidchart refer this answer

Prabs
  • 4,923
  • 6
  • 38
  • 59
  • 1
    This might be better as an additional answer on the question @TR4Android mentioned as duplicate rather than a separate Q&A here. Your answer applies to `BarChart` as well as `CombinedChart`. – David Rawson Feb 06 '17 at 23:46