Draw Pie Chart in Android?

前端 未结 5 1408
耶瑟儿~
耶瑟儿~ 2020-12-14 12:09

I need to draw Pie Chart (Dynamic Values).How to create the Chart without using 3rd party API.

5条回答
  •  鱼传尺愫
    2020-12-14 12:55

    Below shows simple pie-chart and you have to extend for more features...values[] and colors array should be equal....

    public class Demo extends Activity {
        /** Called when the activity is first created. */
        float values[]={300,400,100,500};
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            LinearLayout linear=(LinearLayout) findViewById(R.id.linear);
            values=calculateData(values);
            linear.addView(new MyGraphview(this,values));
    
        }
        private float[] calculateData(float[] data) {
            // TODO Auto-generated method stub
            float total=0;
            for(int i=0;i

提交回复
热议问题