Assuming you want to use this example with Flex 2, then yes, you have to change the namespace. You must also have the data.xml file in the same directory as the app (unless you change the way it's loaded). Here are some ideas.
You can load the file directly as a source of a Model, as the following example shows: <?xml version="1.0" encoding="utf-8"?> <!-- charts/XMLFileTest.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Model id="results" source="data.xml"/> <mx:LineChart id="chart" dataProvider="{results.result}"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="month"/> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="banana" displayName="Banana"/> <mx:LineSeries yField="apple" displayName="Apple"/> <mx:LineSeries yField="orange" displayName="Orange"/> </mx:series> </mx:LineChart> </mx:Application> If you want to use an ArrayCollection as the chart's data provider, you can convert the Model to one using the following example: <?xml version="1.0" encoding="utf-8"?> <!-- charts/XMLFileTest2.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%"> <mx:Script> import mx.utils.ArrayUtil; </mx:Script> <mx:Model id="results" source="data.xml"/> <mx:ArrayCollection id="myAC" source="{ArrayUtil.toArray(results.result)}"/> <mx:LineChart id="chart" dataProvider="{myAC}"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="month"/> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="banana" displayName="Banana"/> <mx:LineSeries yField="apple" displayName="Apple"/> <mx:LineSeries yField="orange" displayName="Orange"/> </mx:series> </mx:LineChart> </mx:Application> You can also define the XML file as a URL for an HTTPService component, and then bind the HTTPService result directly to the chart's data provider, as the following example shows: <?xml version="1.0" encoding="utf-8"?> <!-- charts/XMLFileTest3.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" creationComplete="srv.send()"> <mx:HTTPService id="srv" url="data.xml"/> <mx:LineChart id="chart" dataProvider="{srv.lastResult.data.result}"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="month"/> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="apple" name="Apple"/> <mx:LineSeries yField="orange" name="Orange"/> <mx:LineSeries yField="banana" name="Banana"/> </mx:series> </mx:LineChart> </mx:Application> Again, to use an ArrayCollection, you can load the HTTPService result as an ArrayCollection by way of a Model, as the following example shows: <?xml version="1.0" encoding="utf-8"?> <!-- charts/XMLFileTest4.mxml --> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" creationComplete="srv.send()"> <mx:Script> import mx.utils.ArrayUtil; </mx:Script> <mx:HTTPService id="srv" url="data.xml"/> <mx:Model id="results">{srv.lastResult}</mx:Model> <mx:LineChart id="chart" dataProvider="{results.data.result}"> <mx:horizontalAxis> <mx:CategoryAxis categoryField="month"/> </mx:horizontalAxis> <mx:series> <mx:LineSeries yField="apple" name="Apple"/> <mx:LineSeries yField="orange" name="Orange"/> <mx:LineSeries yField="banana" name="Banana"/> </mx:series> </mx:LineChart> </mx:Application> hth, matt horn flex docs > -----Original Message----- > From: [email protected] > [mailto:[EMAIL PROTECTED] On Behalf Of Pramod > Sent: Monday, July 31, 2006 12:18 AM > To: [email protected] > Subject: [flexcoders] Flex charting > > Hi All, > > Maybe a basic question being a new to Flex. I was working the > Charting Componets in Flex. Here's what i did: copied the > code from - > http://flexapps.macromedia.com/flex15/chartexplorer/explorer.m > xml > <http://flexapps.macromedia.com/flex15/chartexplorer/explorer.mxml> > (i guess it's not a new URL to this forum) and tried > executing it locally. However when i copy the same code into > my system and execute i get an error on the <mx:Model>. > I have pasted the code below for reference - > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml > <http://www.macromedia.com/2003/mxml> " > width="100%" height="100%" > initialize="srv.send()"> > > <mx:HTTPService id="srv" url="data.xml"/> > > <mx:Model id="results">{srv.result.data.result}</mx:Model> > > <mx:LineChart id="chart" dataProvider="{results}" > showDataTips="true" width="100%" height="100%"> > > <mx:horizontalAxis> > <mx:CategoryAxis dataProvider="{results}" > categoryField="month"/> > </mx:horizontalAxis> > > <mx:series> > <mx:Array> > <mx:LineSeries yField="apple" name="Apple"/> <mx:LineSeries > yField="orange" name="Orange"/> <mx:LineSeries > yField="banana" name="Banana"/> </mx:Array> </mx:series> > > </mx:LineChart> > > </mx:Application> > > Where am I do it wrong? Also the Namespace in the URL is > Macromedia and in my System is Adobe? Dose this make a difference? > > Please, please do help me. > > Thanks and Regards, > Pramod > > > > > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

