【问题标题】:Change combined chart legends order, MPAndroidChart更改组合图表图例顺序,MPAndroidChart
【发布时间】:2018-06-20 21:56:58
【问题描述】:

我正在使用 PhilJay 的 MPAndroidChart 库来创建组合图表(线和条)。我想更改情节的图例顺序。 从这样的默认选项: Default option 对此: Order changed

我已阅读文档并尝试更改 setDrwaOrder 但没有发生任何更改。

¿一些帮助或建议?

【问题讨论】:

    标签: android mpandroidchart


    【解决方案1】:

    setCustom(int[] colors, String[] labels): 设置自定义图例的标签和颜色数组。颜色计数应与标签计数相匹配。每种颜色都用于在相同索引处绘制的表单。

    您需要设置自定义图例如下:

    Legend l = chart.getLegend();
    l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "Line Data", "Bar Data" });
    

    通过这种方式,您可以将您的订单用于图例。 您还可以将颜色数组作为您选择的颜色的第一个参数。

    【讨论】:

    • 您发布的解决方案已过时stackoverflow.com/questions/42802952/… 但感谢您我找到了这个解决方案 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});谢谢
    【解决方案2】:

    Android MPchart Piechart Legend setCustom error

    使用这个问题的答案作为指导,我能够找出解决我问题的以下方法:

    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});
    

    【讨论】:

      猜你喜欢
      • 2014-05-09
      • 2020-12-02
      • 1970-01-01
      • 2018-12-18
      • 2021-09-28
      • 1970-01-01
      • 1970-01-01
      • 2020-06-22
      • 2019-06-19
      相关资源
      最近更新 更多