显示具有不同颜色的饼图切片时出现问题

时间:2017-11-20 06:05:10

标签: android pie-chart mpandroidchart

我使用piechart创建了MPAndroidChart,如下所示,

    List<PieEntry> yvalues = new ArrayList<PieEntry>();
    yvalues.add(new PieEntry(1f,1));
    yvalues.add(new PieEntry(15f,2));
    yvalues.add(new PieEntry(15f,3));
    PieDataSet dataSet = new PieDataSet(yvalues,null);
    PieData data = new PieData(dataSet);
    dataSet.setColors(Color.rgb(34,140,0),Color.rgb(225,0,0),Color.BLUE);
    pieChart.setData(data);

问题是,启动应用时,第一个切片color不会显示(更改为透明)。但另外两个切片与我提到的color相同。我不知道这有什么问题。

  

我使用过 com.github.PhilJay:MPAndroidChart:v3.0.0

     

引导我的朋友们。感谢!!!

1 个答案:

答案 0 :(得分:0)

我认为问题出在图书馆内。将第一个值更改为2f并检查。现在它显示了颜色。 1f没有显示颜色。尝试使用此库 hellocharts library