Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pie chart #437

Open
GoogleCodeExporter opened this issue Apr 22, 2015 · 0 comments
Open

Pie chart #437

GoogleCodeExporter opened this issue Apr 22, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 18 Sep 2014 at 10:07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant