views:

175

answers:

0

I have an mx:PieChart component where each wedge acts like a toggle button. Thus, I'd like to change the transparency or color of the currently selected wedge(s). I think I have to use the fillFunction property but I can't figure out how it works.

Changing the item-selection-color css property of mx|PieChart doesn't seem to help, as I manually control the on/off state for each wedge (because by default, multiple selections are allowed, but only the last clicked wedge is highlighted as selected, so I don't have a proper visual feedback for one or more selected wedges).

[edit: added code snippets]

Code for the piechart:

<mx:PieChart x="0" y="0" id="piechart1" dataProvider="{pieAC}" selectionMode="multiple" itemClick="piechart1_itemClickHandler(event)">

The itemClick handler:

protected function piechart1_itemClickHandler(event:ChartItemEvent):void {
  if(pieSeries.selectedIndices.toString().indexOf("0") != -1) // that means that "0" is part of the selectedIndices array
    wedge1IsSelected = !wedge1IsSelected; // this is what I mean by "toggle"
  if(pieSeries.selectedIndices.toString().indexOf("1") != -1)
    wedge2IsSelected = !wedge2IsSelected;
  if(pieSeries.selectedIndices.toString().indexOf("2") != -1)
    wedge3IsSelected = !wedge3IsSelected;
  // So here, I want to change the alpha of each wedge, if the corresponding boolean is false

  // Right now, I'm using this, but the effect is confusing..
  pieSeries.perWedgeExplodeRadius=[redIsSelected? 0: 0.1, yellowIsSelected? 0: 0.1, greenIsSelected? 0: 0.1];

}

I hope it makes more sense now; instead of checking the selectedIndex/ices method, I refer to the three boolean values I created. Based on them, I want to change the alpha of the coressponding wedge.