This is a migrated thread and some comments may be shown as answers.

Custom Colors for PieChart

0 Answers 50 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nicholas
Top achievements
Rank 1
Nicholas asked on 12 May 2015, 08:27 PM

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

Tags
Chart
Asked by
Nicholas
Top achievements
Rank 1
Share this question
or