How to set colors in MPAndroidChart?

后端 未结 2 1160
挽巷
挽巷 2021-02-20 10:13

I\'m using MPChartlib for a basic \"Barchart\" (3 bars and values between 0 and 100).

the background of the app is dark so I\'d like to put the text in white but when I

2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-20 11:00

    if you want change bars color prefer pass context as well like example below

    ArrayList entries = new ArrayList<>();
            entries.add(new BarEntry(87f, 0));
            entries.add(new BarEntry(90f, 1));
    
    
            ArrayList labels = new ArrayList<>();
            labels.add("title 1");
            labels.add("title 2);
    
            BarDataSet dataSet = new BarDataSet(entries, "# of Calls ");
            BarData barData = new BarData(labels, dataSet);
            dataSet.setColors(new int[]{R.color.color1 , R.color.color2} , context);
            barChart.setData(barData);
            barChart.animateY(3000 , Easing.EasingOption.EaseOutBack );
    

提交回复
热议问题