when i add the tag <mx:Legend dataProvider="{myChart}"/> which myChart represent the id of the lineChart,
i have this error: TypeError:Error #1034: Type Coercion failed: cannot convert mx.charts.chartClasses::legendd...@cc33701 to mx.charts.ChartItem. i tried to add the import like import mx.charts.Legend; import mx.charts.LegendItem; import mx.charts.chartClasses.LegendData; but the error still appear thank you in advance that is the code: ---------LabelRenderer2.as------------ package { import flash.display.Graphics; import flash.geom.Rectangle; import mx.charts.ChartItem; import mx.charts.chartClasses.GraphicsUtilities; import mx.core.IDataRenderer; import mx.graphics.IFill; import mx.graphics.IStroke; import mx.skins.ProgrammaticSkin; import mx.controls.Label; import mx.core.UIComponent; import mx.charts.LineChart; import mx.charts.series.items.LineSeriesItem; import mx.charts.Legend; import mx.charts.LegendItem; import mx.charts.chartClasses.LegendData; public class LabeledRenderer2 extends UIComponent implements IDataRenderer { private var _label:Label; public function LabeledRenderer2():void { super(); _label = new Label(); addChild(_label); _label.setStyle("color",0x000000); } private var _chartItem:ChartItem; public function get data():Object { return _chartItem; } public function set data(value:Object):void { if (_chartItem == value) return; _chartItem = ChartItem(value); if(_chartItem != null) _label.text = LineSeriesItem(_chartItem).yValue.toString(); } private static const fills:Array = [0xFF0000,0x00FF00,0x0000FF, 0x00FFFF,0xFF00FF,0xFFFF00, 0xAAFFAA,0xFFAAAA,0xAAAAFF]; override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); _label.setActualSize(_label.getExplicitOrMeasuredWidth(),_label.getExplicitOrMeasuredHeight()); _label.move(unscaledWidth - _label.getExplicitOrMeasuredWidth(), unscaledHeight/2 - _label.getExplicitOrMeasuredHeight()/2); } } } ------------LineChart.mxml------------- <?xml version="1.0"?> <mx:Script> import mx.graphics.Stroke; [Bindable] public var expenses:Object = [{Month: "Jan", Profit: 2000, Expenses: 1500, Amount: 450}, {Month: "Feb", Profit: 1000, Expenses: 200, Amount: 600}, {Month: "Mar", Profit: 1500, Expenses: 500, Amount: 300}]; public var s:Stroke = new Stroke(0x001100); </mx:Script> <mx:Panel title="Line Chart" borderStyle="solid" textAlign="center"> <mx:Label text=" "/> <mx:LineChart id="myChart" dataProvider="{expenses}" > <mx:horizontalAxis> <mx:CategoryAxis dataProvider="{expenses}" categoryField="Month" /> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="Profit" itemRenderer="LabeledRenderer2"/> <mx:LineSeries yField="Expenses"/> <mx:LineSeries yField="Amount"/> </mx:series> </mx:LineChart> <mx:Legend dataProvider="{myChart}"/> </mx:Panel> </mx:Application> ****************************** message error : TypeError: Error #1034: Echec de la contrainte de type : conversion de mx.charts.chartClasses::legendd...@9ad4381 en mx.charts.ChartItem impossible. at LabelRenderer2/set data()[D:\LabelChart\src\LabelRenderer2.as:31] at mx.charts::LegendItem/set legendData()[C:\work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\LegendItem.as:254] at mx.charts::Legend/addLegendItem()[C:\work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\Legend.as:651] at mx.charts::Legend/populateFromArray()[C:\work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\Legend.as:678] at mx.charts::Legend/commitProperties()[C:\work\flex\dmv_automation\projects\datavisualisation\src\mx\charts\Legend.as:449] at mx.core::UIComponent/validateProperties()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:5807] at mx.managers::LayoutManager/validateProperties()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:539] at mx.managers::LayoutManager/doPhasedInstantiation()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:659] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/callLaterDispatcher2()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8628] at mx.core::UIComponent/callLaterDispatcher()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8568]