MPAndroidChart setting chart padding / offset

会有一股神秘感。 提交于 2020-01-21 06:25:06

问题


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

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?


回答1:


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)




回答2:


I am currently working on an update that will allow to set all paddings!

The currently available method for setting the offsets is buggy.

In the meantime you could try to set a negative padding or margin via .xml. Let me know if this works!



来源:https://stackoverflow.com/questions/28563051/mpandroidchart-setting-chart-padding-offset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!