MPAndroidChart-删除顶部和底部空间
我正在使用图书馆 我在应用程序中实现了一个PieChart。一切正常,但在图表的顶部和末尾都有空白。 我需要删除此空间以正确显示我的活动布局 我的问题是:MPAndroidChart-删除顶部和底部空间,android,mpandroidchart,Android,Mpandroidchart,我正在使用图书馆 我在应用程序中实现了一个PieChart。一切正常,但在图表的顶部和末尾都有空白。 我需要删除此空间以正确显示我的活动布局 我的问题是: 是否可以通过编程方式删除它们 p.D.在我的布局中,有非marginTop或marginBottom 布局xml: <com.github.mikephil.charting.charts.PieChart android:id="@+id/pieChart" android:layout_width="match_pa
- 是否可以通过编程方式删除它们
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/pieChart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/_home_consumed" >
</com.github.mikephil.charting.charts.PieChart>
您是否尝试调用
图表上的设置偏移量(左浮动、上浮动、右浮动、下浮动)
// add data...
chart.setData(...);
// define new offsets
chart.setOffsets(0, 0, 0, 0);
// update transformation matrix
chart.getTransformer().prepareMatrixValuePx(chart);
chart.getTransformer().prepareMatrixOffset(chart);
chart.getContentRect().set(0, 0, chart.getWidth(), chart.getHeight());
// redraw
chart.invalidate();
这应该在程序上消除所有偏移。由于调用setData(…)
方法时图表会自动调整其偏移量,因此为了保持偏移量,每次为图表设置新数据对象时都需要调用此方法
我也知道这很复杂,以后我会简化流程。试试这个
pieChart.setExtraOffsets(-10,-10,-10,-10);
您可以按如下方式设置负值偏移量:-transactionTrendPieChart.SetExtraOffset(0,-100,0,-150)饼图不仅默认偏移量为10,而且还添加了额外的空间以突出显示所选条目。要删除所有填充,还需要删除所选条目的空间:
pieChart.setExtraOffset(0,0,0,0);
PieDataSet数据集=新的PieDataSet([…]);
dataSet.setSelectionShift(0f);
的图表。setMinOffset(0);
答案对我有用。此时(2016年)PyScript没有<代码> SETOBSE/<代码>方法,我已经尝试过<代码> StimOpOffice 方法,但空白仍然在这里,有什么帮助吗?@ RoSordopisher,我知道这是一个解决办法,但是尝试使用带有负值的SETUTROOFSET。它对我起作用。我在屏幕截图中描述了完全相同的问题。但是<代码>raOffset的行为异常。它似乎有问题。如何找到偏移量?请注意,如果生成的偏移量大小低于默认的最小值15,则可能还需要调用chart.setMinOffset()
。