Hi,
Quite new to flex but think i am on the right track with
this. I have been getting a strange error and hope someone can help
me with it.
I am putting together a linechart which shows the number of
unique visitors on my site. It contains two datefields which the
user enters the start and end date.
I am receiving the xml data from my webservice which looks
like this
<data>
<result day="3/14/2008">
<visitors>347</visitors>
</result>
<result day="3/13/2008">
<visitors>389</visitors>
</result>
<result day="3/12/2008">
<visitors>276</visitors>
</result>
<result day="3/11/2008">
<visitors>461</visitors>
</result>
</data>
When i attempt to bind this as a string to my linechart i get
this error ""
ReferenceError: Error #1069:
Property visitors not found on String and there is no default
value.When i convert the string to XML i get no error but nothing
appears on my line chart.
My code is as follows:
Attach Code:
<?xml version="1.0"?>
<!-- charts/XMLFileDataProvider.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"horizontalAlign="center" layout="vertical" verticalAlign="top">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.collections.XMLListCollection;
import mx.controls.Alert;
import mx.controls.Label;
import mx.containers.Canvas;
import flash.external.*;
import mx.core.Application;
import mx.rpc.events.FaultEvent;
import mx.controls.Text;
[Bindable]
private var myData:String;
[Bindable]
private var myXMLData:XML;
private function resultHandler(event:ResultEvent):void {
myData = event.result as String;
myXMLData = new XML(myData);
//Alert.show(myData);
}
]]>
</mx:Script>
<mx:WebService id="statsService" wsdl="
http://localhost/sampleapp/ws/getXML.asmx?WSDL" showBusyCursor="true">
<mx:operation name="getStatsByDayXML"
result="resultHandler(event)">
<mx:request>
<dateFrom>{dateFromTxt.text}</dateFrom>
<dateTo>{dateToTxt.text}</dateTo>
</mx:request>
</mx:operation>
</mx:WebService>
<mx:Canvas width="732" height="35">
<mx:DateField x="69" id="dateFromTxt" y="10" width="174"
showToday="true" enabled="true"/>
<mx:Label x="0" y="14" text="Start Date"
fontWeight="bold" color="#ffffff"/>
<mx:Label x="266" y="14" text="End Date"
fontWeight="bold" color="#ffffff"/>
<mx:DateField id="dateToTxt" width="174" x="329" y="10"
showToday="true" enabled="true"/>
<mx:Button x="530" y="10" label="Get Stats"
click="statsService.getStatsByDayXML()" />
</mx:Canvas>
<mx:Panel title="CareerQuestions ::: Unique Visitors"
width="735">
<mx:LineChart name="visitors" dataProvider="{myData}"
id="chart" height="265" width="692">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="day"/>
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries yField="visitors" displayName="Unique
Visitors"/>
</mx:series>
</mx:LineChart>
</mx:Panel>
<mx:Label text="{myData}" width="402" height="204"
color="#ffffff"/>
</mx:Application>