1 Reply Latest reply on May 16, 2012 10:46 AM by JorAndra026

    Keep color index in piechart

    JorAndra026 Level 1



      I have a Piechart working with an ArrayCollection, and i control the showing slices of the PieChart with its respective Checkbox.


      I can set my custom colors for each slice and they show correcly. But when i erase a slice from the chart with the checkbox (erasing the respective data from the ArrayCollection), the index color of the slices regroup, and what was a blue slice now its another color.




      Lets say that the data of the pie chart its:



      the colors for each data is:



      And if i delete the element [two] wich color its [yellow], the colors now change to:



      Is there a way to hardcode the color of each slice so that they dont fix when a data its erased? i create this piechart via ActionScript:

        • 1. Re: Keep color index in piechart
          JorAndra026 Level 1

          Done it =) so i answer my self:


          When i create the piechart serie via actionScript, i add the serie.fillFunction = setear_colores; prop. And in that function, i read the data of the current element and set the color manualy. In my problem i needed to match the color of the columnseries in a columnchart. So the function is:


          private function setear_colores(item:ChartItem, index:Number):IFill {

             var currItem:PieSeriesItem = PieSeriesItem(item);

             var color:SolidColor = new SolidColor();


            for each(var serie:Series in linechart.series){

                 if(serie is ColumnSeries){

                         var nombre:String = currItem.item.Nombre as String;

                         if(serie.displayName == nombre){

                               color = serie.getStyle("fill");

                               return color;




             //Default return color

             return new SolidColor(0x000000);