我使用 PhilJay 的 MPAndroidChart 库来创建组合图表(线和条)。我想更改情节的图例顺序。从像这样的默认选项: 默认选项 到这个: 订单已更改
我已阅读文档并尝试更改 setDrwaOrder 但没有发生任何更改。
¿ 一些帮助或建议?
Android MPchart Piechart Legend setCustom 错误
使用这个问题的答案作为指导,我能够找出解决我的问题的以下方法:
LegendEntry l1=new LegendEntry("Bank", Legend.LegendForm.DEFAULT,10f,2f,null, Color.RED);
LegendEntry l2=new LegendEntry("Chitfund", Legend.LegendForm.CIRCLE,10f,2f,null, Color.GREEN);
l.setCustom(new LegendEntry[]{l1,l2});
setCustom(int[] colors, String[] labels):设置自定义图例的标签和颜色数组。颜色计数应与标签计数相匹配。每种颜色都用于在相同索引处绘制的表格。
您需要按如下方式设置自定义图例:
Legend l = chart.getLegend();
l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "Line Data", "Bar Data" });
通过这种方式,您可以将您的订单用于图例。您还可以将颜色数组作为您选择的颜色的第一个参数。