我该如何修复图例? (MPAndroid图表)
How i can fix legend ? (MPAndroidChart)
我用过 legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER);
它有效,但我希望图例位于顶部
如果我使用 legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
图例和图表重叠
也许有办法改变图表的位置?
使用下面一行:
legend.setPosition(Legend.LegendPosition.ABOVE_CHART_RIGHT);
我能够使用
获得想要的结果
legend.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
legend.setWordWrapEnabled(true);
legend.setMaxSizePercent(0.20f);
不推荐使用此方法,以便更好地使用它。
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
作为参考,您可以在此处查看The legend can't display when call setPosition(LegendPosition.BELOW_CHART_CENTER)
尝试在所有自定义后将所有数据设置为图表,一切都会正常工作..像这样:
l.setCustom(arrayOf(firstLegend, secondLegend))
l.verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM
l.horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT
l.orientation = Legend.LegendOrientation.HORIZONTAL
l.setDrawInside(false)
然后将数据设置为图表..
chart.data = data // set the data and list of labels into chart
是的,您可以在更改偏移值时:
pieChart.setExtraTopOffset(15);
pieChart.setExtraBottomOffset(15);
pieChart.setExtraLeftOffset(0);
pieChart.setExtraRightOffset(50);
或者用一行
setExtraOffsets(float left, float top, float right, float bottom)
结果:
一个很好的例子及其参数和一些描述:
https://www.programmersought.com/article/99524092993/
我用过 legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER);
它有效,但我希望图例位于顶部
如果我使用 legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
图例和图表重叠
也许有办法改变图表的位置?
使用下面一行:
legend.setPosition(Legend.LegendPosition.ABOVE_CHART_RIGHT);
我能够使用
获得想要的结果legend.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
legend.setWordWrapEnabled(true);
legend.setMaxSizePercent(0.20f);
不推荐使用此方法,以便更好地使用它。
l.setVerticalAlignment(Legend.LegendVerticalAlignment.BOTTOM);
l.setHorizontalAlignment(Legend.LegendHorizontalAlignment.CENTER);
l.setOrientation(Legend.LegendOrientation.HORIZONTAL);
l.setDrawInside(false);
作为参考,您可以在此处查看The legend can't display when call setPosition(LegendPosition.BELOW_CHART_CENTER)
尝试在所有自定义后将所有数据设置为图表,一切都会正常工作..像这样:
l.setCustom(arrayOf(firstLegend, secondLegend))
l.verticalAlignment = Legend.LegendVerticalAlignment.BOTTOM
l.horizontalAlignment = Legend.LegendHorizontalAlignment.LEFT
l.orientation = Legend.LegendOrientation.HORIZONTAL
l.setDrawInside(false)
然后将数据设置为图表..
chart.data = data // set the data and list of labels into chart
是的,您可以在更改偏移值时:
pieChart.setExtraTopOffset(15);
pieChart.setExtraBottomOffset(15);
pieChart.setExtraLeftOffset(0);
pieChart.setExtraRightOffset(50);
或者用一行
setExtraOffsets(float left, float top, float right, float bottom)
结果:
一个很好的例子及其参数和一些描述: https://www.programmersought.com/article/99524092993/