The way you did it...changing the styles array on the pie series...is the easiest way.  That's where individual wedges get their data from. You might be able to reach in and muck with internal values in individual wedges, but that's a risky proposition.  Those values aren't 'truth...'  Truth is what the series wants the wedges to be, and other things that invalidate the series (like resizing the chart) would end up blowing away your change.
 
An alternative would be to write a custom renderer for the pie wedges, which has a concept of 'selected.'  When a wedge is selected, it ignores the color being passed in by the series, and draws itself in a different color. But I think your approach is probably the easiest.
 
Ely.
 
 
 


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of shemeshkale
Sent: Wednesday, November 01, 2006 2:23 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: how to explode a wedge on mouse over?

OK, i got it!!
i made the chart explode on mouse over a wedge, working great !
next step: on click on a wedge the wedge will change color (or alpha
or ratio), click on another wedge will revert the previous wedge to
its original color and will change color of current wedge.
i got the start of it, but i m stuck!!
i used setStyle to change the color but there must be a better way -
like accessing the wedge directly and changing its own style.

HOW ???

here is the code:

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="init()">
<mx:Script><![CDATA[
import mx.charts.events.ChartItemEvent;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
[Bindable]
private var dataSet:ArrayCollection = new ArrayCollection([
{Month: "Jan", Expenses: 150},
{Month: "Feb", Expenses: 200},
{Month: "BLOODKLAAT", Expenses: 600},
{Month: "Mar", Expenses: 500}
]);

private var lastIndex:Number;
private function boom(e:ChartItemEvent):void {
// explode wedge
if(e.hitData.chartItem.index != lastIndex){
var explodeWedge:Array = [];
explodeWedge[e.hitData.chartItem.index] = 0.1;
chart.series[0].perWedgeExplodeRadius = explodeWedge;
}
lastIndex = e.hitData.chartItem.index
}

private function changeColor(e:ChartItemEvent):void{
chart.series[0].setStyle("fills",[0xff0000, 0x00ff00,
0x0000ff, 0x000000]);
}

private function init():void {
chart.addEventListener(ChartItemEvent.ITEM_ROLL_OVER,boom);
chart.addEventListener(ChartItemEvent.ITEM_CLICK,changeColor);
}
]]></mx:Script>
<mx:SeriesInterpolate id="chartEffect" elementOffset="10"/>
<mx:Panel title="Event handling" verticalGap="0">
<mx:PieChart id="chart" dataProvider="{dataSet}" >
<mx:series>
<mx:PieSeries labelPosition="inside" field="Expenses"
showDataEffect="chartEffect" >
<mx:fills>
<mx:SolidColor color="#ff0000" />
<mx:SolidColor color="#00ff00" />
<mx:SolidColor color="#0000ff" />
<mx:SolidColor color="#00ffff" />
</mx:fills>
</mx:PieSeries>
</mx:series>
</mx:PieChart>
</mx:Panel>
</mx:Application>

--- In [EMAIL PROTECTED]ups.com, "Ely Greenfield" <[EMAIL PROTECTED].> wrote:
>
>
>
>
> What error are you getting?
>
> PieSeries has a property called called perWedgeExplodeRadius. This is an
> array of values from 0 to 1. The Nth value in this array corresponds to
> how far the nth value in the dataProvider should be exploded. 0 is no
> explode, 1 is fully exploded (which means there's no room to actually
> render anything, so probably not what you want. Choose something in
> between).
>
> So get the index of the item under the mouse (listen for itemRollOver
> and itemRollOut events), and update the perWedgeExplodeRadius property
> accordingly.
>
> Ely.
>
>
>
> ________________________________
>
> From: [EMAIL PROTECTED]ups.com [mailto:[EMAIL PROTECTED]ups.com] On
> Behalf Of shemeshkale
> Sent: Tuesday, October 31, 2006 12:42 AM
> To: [EMAIL PROTECTED]ups.com
> Subject: [flexcoders] how to explode a wedge on mouse over?
>
>
>
> hello,
> i have a pieChart.
> how do i make a specific wedge explode on mouse over on it?
> mouse out will revert the explosion.
>
> plus:
> how do i alert the wedge under the mouse?
> got this : mouseOver="Alert.show('over: '+event.hitData.index)"
> but it is error, what is right?
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to