this works, i couldnt try out urs since i dont have the data and the other stuff but maybe try data.toString(); </mx:Script> <mx:ComboBox change="myChart.type=myCombo.selectedItem.toString()" id="myCombo"> <mx:dataProvider> <mx:String>overlaid</mx:String> <mx:String>stacked</mx:String> <mx:String>100%</mx:String> </mx:dataProvider> </mx:ComboBox> <mx:Script><![CDATA[ import mx.collections.ArrayCollection; [Bindable] public var expenses:ArrayCollection = new ArrayCollection([ {Month:"Jan", Profit:2000, Expenses:1500, Amount:450}, {Month:"Feb", Profit:1000, Expenses:200, Amount:600}, {Month:"Mar", Profit:1500, Expenses:500, Amount:300} ]); ]]></mx:Script> <mx:Panel title="Area Chart"> <mx:AreaChart id="myChart" dataProvider="{expenses}" showDataTips="true"> <mx:horizontalAxis> <mx:CategoryAxis dataProvider="{expenses}" categoryField="Month" /> </mx:horizontalAxis> <mx:series> <mx:AreaSeries yField="Profit" displayName="Profit" /> <mx:AreaSeries yField="Expenses" displayName="Expenses" /> </mx:series> </mx:AreaChart> <mx:Legend dataProvider="{myChart}"/> </mx:Panel>
----- Original Message ---- From: Guido <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.com Sent: Wednesday, February 13, 2008 12:15:57 PM Subject: [flexcoders] AreaChart bug when changing 'type' property Hi, fellow coders! I'm having an issue with an AreaChart when changing its type property. There's a ComboBox that lets the user select how it wishes to see the AreaChart (either overlaid, stacked or 100%). The method for this is as simple as: areaChart.type = comboBox.selectedIt em.data; (I've debugged it and data holds the proper string required by the type property). My code is as follows: <mx:AreaChart id="areaChart" dataTipFunction="chartDataTipRender" height="100%" showDataTips="true" width="100%"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="{dataSet.keyFieldNam e}" dataProvider="{dataSet.dataSet}" labelFunction="{dataSet.labelFuncti on}"/> </mx:horizontalAxis> <mx:verticalAxis> <mx:LinearAxis minimum="{verticalAxisMinimum}" maximum="{verticalAxisMaximum}"/> </mx:verticalAxis> <mx:series> <mx:AreaSeries alpha="0.8" dataProvider="{dataSet.dataSet}" displayName="{dataSet.dataSource. name}" form="curve" showDataEffect="interpolate" xField="{dataSet.keyFieldNam e}" yField="{dataSet.valueFieldN ame}"/> </mx:series> </mx:AreaChart> <mx:SeriesInterpolat e id="interpolate" elementOffset="10"/> You might wonder why I want to stack or overlay the chart, since it has only one series... well, the thing is more series may be added in runtime, and so it comes to play the area chart type feature. So, whenever I change the AreaChart's type property, I get the following error and stack trace: TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.charts.chartClas ses::Series/ mx.charts. chartClasses: Series::stripNaN s() at mx.charts.series: :AreaSeries/ mx.charts. series:AreaSerie s::updateFilter( ) at mx.charts.chartClas ses::Series/ mx.charts. chartClasses: Series::validate Transform( ) at mx.charts.chartClas ses::Series/ getRenderDataFor Transition( ) at mx.charts.effects. effectClasses: :SeriesInterpola teInstance/ play() at mx.effects:: EffectInstance/ startEffect( ) at mx.effects.effectCl asses::ParallelI nstance/play( ) at mx.charts.chartClas ses::ChartBase/ ::advanceEffectS tate() at mx.charts.chartClas ses::ChartBase/ mx.charts. chartClasses: ChartBase: :updateDisplayLi st() at mx.charts.chartClas ses::CartesianCh art/mx.charts. chartClasses: CartesianChart: :updateDisplayLi st() at mx.core::UIComponen t/validateDispla yList() at mx.managers: :LayoutManager/ ::validateDispla yList() at mx.managers: :LayoutManager/ ::doPhasedInstan tiation() at Function/http: //adobe.com/ AS3/2006/ builtin:: apply() at mx.core::UIComponen t/::callLaterDis patcher2( ) at mx.core::UIComponen t/::callLaterDis patcher() at flash.utils: :Timer/flash. utils:Timer: :_timerDispatch( ) at flash.utils: :Timer/flash. utils:Timer: :tick() And... I don't understand why, since I'm already seeing the chart as it is when I make the change to the type property. I mean, it works perfectly up to the moment I try to change this property, then it blows up. BTW, I'm using Flex 2. Any help on this one? Thanks in advance!! Guido. ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs