Custom Colors for PieChart

1 posts, 0 answers
  1. Nicholas
    Nicholas avatar
    4 posts
    Member since:
    Jun 2012

    Posted 12 May 2015 Link to this post

    Hi --

    I figured this out today and thought others might want to know how to do this since the examples I found were all for Bar Charts.

     

    RadPieChartView chartView = new RadPieChartView(this);
      
    PieSeries pieSeries = new PieSeries();
    pieSeries.setShowLabels(true);
    pieSeries.setSliceOffset(Util.getDimen(TypedValue.COMPLEX_UNIT_DIP, 2));
    pieSeries.setValueBinding(new PropertyNameDataPointBinding(
            "Value"));
    pieSeries.setData(tpvSummary);    
    chartView.getSeries().add(pieSeries);
      
    ChartPalette customPalette = chartView.getPalette().clone();
      
    PaletteEntry green = customPalette.getEntry(ChartPalette.PIE_FAMILY,0);
    green.setFill(0xff33cc00);
      
    PaletteEntry red = customPalette.getEntry(ChartPalette.PIE_FAMILY,1);
    red.setFill(0xffcc3333);
      
    pieSeries.setLabelRenderer(new CustomLabelRenderer(pieSeries));
      
    chartView.setPalette(customPalette);

    Rich

Back to Top