简体   繁体   English

创建旋转饼图(方向盘)Android

[英]Creating a spinning pie chart (wheel) android

I have created an Pie chart which I want to spin randomly and stop on click. 我创建了一个饼图,我想随机旋转并停止点击。
Then my android program needs to read which value is above. 然后我的android程序需要读取上面的哪个值。

I already got this: 我已经知道了:

    PieDataSet dataSet = new PieDataSet(yvalues, "");

    ArrayList<String> xVals = new ArrayList<String>();
    ArrayList<Integer> colors = new ArrayList<Integer>();
    pieChart.setDrawHoleEnabled(false);
    pieChart.animateXY(1400, 1400);

    pieChart.getLegend().setEnabled(false);
    pieChart.setDrawSliceText(false);
    dataSet.setDrawValues(false);
    xVals.add("Correct");
    xVals.add("Wrong");
    colors.add(Color.rgb(115, 255, 134));
    colors.add(Color.rgb(255, 115, 115));
    dataSet.setColors(colors);
    pieChart.setDescription("");

    PieData data = new PieData(xVals, dataSet);

    data.setValueFormatter(new PercentFormatter());
    data.setValueTextSize(18f);
    data.setValueTextColor(Color.BLACK);
    pieChart.setData(data);
    pieChart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            pieChart.spin( 500,0,-360f, Easing.EasingOption.EaseInOutQuad);
        }
    });

I don't know how to spin this chart on click and stop it randomly. 我不知道如何在点击时旋转此图表并随机将其停止。
Then I need to get the value of the chart which is spinned. 然后,我需要获取已旋转图表的值。

You can use this library. 您可以使用此库。 (Easy and simple implementation of PieChart with Scatter) This library will fulfill all the requirements you have mentioned above. (带有散点图的PieChart的简单实现)此库将满足您上面提到的所有要求。

https://android-arsenal.com/details/1/4492 https://android-arsenal.com/details/1/4492

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM