gpt4 book ai didi

java - MPAndroidChart 值没有像我提到的那样出现?

转载 作者:行者123 更新时间:2023-12-01 19:31:37 26 4
gpt4 key购买 nike

我正在使用“implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'”这个库来创建饼图,并且我手动输入的饼图条目值显示不正确。我按照教程进行操作,教程中的结果也是如此,没有出现正确的值。

       PieChart pieChart=findViewById(R.id.pieChart);
pieChart.setUsePercentValues(true);

pieChart.getDescription().setEnabled(false);

pieChart.setExtraOffsets(5,10,5,10);
pieChart.setDragDecelerationFrictionCoef(0.95f); //how smooth it should spin

pieChart.setDrawHoleEnabled(true);
pieChart.setHoleColor(Color.WHITE);
pieChart.setTransparentCircleRadius(60f);

List<PieEntry> value=new ArrayList<>();
value.add(new PieEntry(23.2f,"value1");
value.add(new PieEntry(92.2f,"value2");
value.add(new PieEntry(12.3f,"value3");

PieDataSet pieDataSet= new PieDataSet(value,"Months");
pieDataSet.setSliceSpace(3f); //between the slice spaces
pieDataSet.setSelectionShift(5f);

pieDataSet.setColors(ColorTemplate.MATERIAL_COLORS); //for variety of colors

PieData pieData=new PieData(pieDataSet);
pieData.setValueTextSize(10f);
pieData.setValueTextColors(Collections.singletonList(Color.WHITE));

pieChart.animateXY(1400,1400);

pieChart.setData(pieData);

23.2f 显示为 18.2,92.2f 显示为 72.2,12.3 显示为 9.6为什么这些值不像我提到的那样出现?

最佳答案

它显示饼图的百分比值。

请使其为假以显示真实值(value)。像下面这样

pieChart.setUsePercentValues(false);

关于java - MPAndroidChart 值没有像我提到的那样出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59657886/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com