【发布时间】:2018-03-07 08:58:47
【问题描述】:
我使用了legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER); 它有效,但我希望图例位于顶部
如果我使用legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART); 图例和图形重叠
也许有办法改变图表的位置?
【问题讨论】:
我使用了legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART_CENTER); 它有效,但我希望图例位于顶部
如果我使用legend.setPosition(Legend.LegendPosition.RIGHT_OF_CHART); 图例和图形重叠
也许有办法改变图表的位置?
【问题讨论】:
不推荐使用此方法以更好地使用它。
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)
【讨论】:
我能够使用
得到想要的结果legend.setPosition(Legend.LegendPosition.ABOVE_CHART_LEFT);
legend.setWordWrapEnabled(true);
legend.setMaxSizePercent(0.20f);
【讨论】:
尝试在所有自定义后将所有数据设置为图表,一切都会正常工作..像这样:
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
【讨论】:
使用下面的行:
legend.setPosition(Legend.LegendPosition.ABOVE_CHART_RIGHT);
【讨论】:
是的,您可以在更改偏移量的值时:
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/
【讨论】: