hichamuradess / achartengine

Automatically exported from code.google.com/p/achartengine
0 stars 0 forks source link

Pie chart #437

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I want to create a pie chart that is updated continuously. I tried this piece 
of code but I can not update it. Can anyone help me?

private void openChart(){
        // Pie Chart Section Names
        String[] code = new String[] {
                "Eclair & Older", "Froyo", "Gingerbread", "Honeycomb"
        };      

        // Pie Chart Section Value
        double[] distribution = { risultato, risultato2, risultato3, risultato4};

        // Color of each Pie Chart Sections
        int[] colors = { Color.BLUE, Color.MAGENTA, Color.GREEN, Color.CYAN};

        // Instantiating CategorySeries to plot Pie Chart       
        CategorySeries distributionSeries = new CategorySeries(" Android version distribution as on October 1, 2012");
        for(int i=0 ;i < distribution.length;i++){
            // Adding a slice with its values and name to the Pie Chart
            distributionSeries.add(code[i], distribution[i]);
        }   

        // Instantiating a renderer for the Pie Chart
        DefaultRenderer defaultRenderer  = new DefaultRenderer();       
        for(int i = 0 ;i<distribution.length;i++){          
            SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();       
            seriesRenderer.setColor(colors[i]);
            seriesRenderer.setDisplayChartValues(true);
            // Adding a renderer for a slice
            defaultRenderer.addSeriesRenderer(seriesRenderer);
        }

        defaultRenderer.setChartTitle("Title ");
        defaultRenderer.setChartTitleTextSize(25);
        defaultRenderer.setZoomButtonsVisible(true);    
        defaultRenderer.setLabelsTextSize(25);
        defaultRenderer.setLegendTextSize(40);

        // Creating an intent to plot bar chart using dataset and multipleRenderer      
        Intent intent = ChartFactory.getPieChartIntent(getBaseContext(), distributionSeries , defaultRenderer, "AChartEnginePieChartDemo");     

        // Start Activity
        startActivity(intent);

   /*   for (int i=0; i<5; i=1)
        {
            double[] distributions = { risultato, risultato2, risultato3, risultato4} ;
            for(int b = 0 ;i<distributions.length;i++){         
                SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();       
                seriesRenderer.setColor(colors[b]);
                seriesRenderer.setDisplayChartValues(true);
                // Adding a renderer for a slice
                defaultRenderer.addSeriesRenderer(seriesRenderer);

            }
        }*/

    }

Original issue reported on code.google.com by torchiad...@gmail.com on 18 Sep 2014 at 10:07