Android MPchart Piechart Legend setCustom错误 [英] Android MPchart Piechart Legend setCustom error

查看:89
本文介绍了Android MPchart Piechart Legend setCustom错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MPchart饼图.当我设置自定义图例数组时,它不接受该数组.

I am using MPchart piechart. When i set custom legend arrays it not accepting that array.

我的代码...

Legend l = chart.getLegend();
    l.setCustom(ColorTemplate.VORDIPLOM_COLORS, new String[] { "aaaaa", "bbbbb", "ccccc"});

错误...

Cannot resolve method 'setCustom(int[],java.lang.String[])'

我的MPchart版本:v3.0.0

My MPchart version : v3.0.0

我该如何解决此问题.

推荐答案

这对我来说可以设置自定义图例:

This worked for me to set a custom legend:

 // Use Legend Entry

    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);
    LegendEntry l3=new LegendEntry("Mobile", Legend.LegendForm.LINE,10f,1f,null,Color.BLACK);
    LegendEntry l4=new LegendEntry("Internet", Legend.LegendForm.DEFAULT,10f,2f,null, Color.BLUE);
    LegendEntry l5=new LegendEntry("ATM", Legend.LegendForm.DEFAULT,10f,2f,null, Color.DKGRAY);
    LegendEntry l6=new LegendEntry("Check", Legend.LegendForm.SQUARE,10f,1f,null,Color.CYAN);

    Legend l=piechart.getLegend();
    l.setCustom(new LegendEntry[]{l1,l2,l3,l4,l5,l6});

    //For set the same color to chart
    piedataSet.setColors(new int[]{Color.RED, Color.GREEN, Color.BLACK, Color.BLUE, Color.DKGRAY, Color.CYAN});//Color is set based on your Legend entry color

图例输入参数的说明:

 LegendEntry l1=new LegendEntry("Bank", Legend.LegendForm.DEFAULT,10f,2f,null, Color.RED);

         Parameter                   Example
   --------------------------------------------------------

         legend label         -      "Bank"
         legend form          -      Legend.LegendForm.DEFAULT[ (DEFAULT Shape is Square) Default instead of any (like Square, circle, line)]
         formsize             -      10f,2f [height of the width]
         dashboard effect     -      null
         color                -      Color.RED

这篇关于Android MPchart Piechart Legend setCustom错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆