MPAndroidChart setting chart padding / offset

Asilvia picture Asilvia · Feb 17, 2015 · Viewed 12.5k times · Source

I'm using the MPAndroidChart for my bar graph and I'm struggling with removing the padding of the graph (see pic below)

enter image description here

My approaches regarding this problem were:

  1. chart.setDrawLegend(false);
    chart.setDrawMarkerViews(false);
    chart.setDrawUnitsInChart(false);
    chart.setDrawValueAboveBar(false);
    chart.setDrawXLabels(false);
    chart.setDrawYLabels(false);
    chart.setDescription("");
    
  2. chart.setOffsets(0, 0, 0, 0);
    chart.getTransformer().prepareMatrixValuePx(chart);
    chart.getTransformer().prepareMatrixOffset(chart);
    chart.getContentRect().set(0, 0, chart.getWidth(),chart.getHeight());
    

And nothing has worked so far. Do you know another approach for this problem?

Answer

Danil picture Danil · Oct 8, 2015

I know that's pretty late for answer, but now Chart has the following method:

setViewPortOffsets(-40f, 0f, 0f, 0f)

(setting weird -40f value instead 0 seems unnatural, but it still works)