I created a simple example... if you wanted to populate a grid using the following xml : http://www.bluetube.com/temp/data.xml and you wanted a grid that said Date fruit1 fruit2 fruit 3 Jan-03 200781 225971 161280
etc... what is the most efficient way of doing it? Right now I'd take
the xml and process it into a new array of objects like :
object:Object = { date:theDate, fruit1:fruit[0], fruit2:fruit[1],
fruit3:fruit[2] };
And this sucks when you use more complex xml.
Grant
...........................................
> b l u e t u b e i n t e r a c t i v e.
.: grant davies
.: 404.428.6839 (c)
.: 708-983-1577 (F)
> [EMAIL PROTECTED]
> http://www.bluetube.com/bti <http://www.bluetube.com/bti>
> A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/>
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Grant Davies
Sent: Monday, February 05, 2007 12:17 PM
To: [email protected]
Subject: [flexcoders] Transforming XML for graphs and datagrids
Hey guys,
We just spent some time writing e4x code to take the contents of an XML
response and transform it into something my grid/graph can use and I'm
sure we are making this much harder than it needs to be...
The examples for data binding from the flex help and online are always
the picture perfect XML that was designed specifically for the grid or
graph example, where as in the real world the XML is never quite how you
need it.
The XML we consume looks like this :
http://www.bluetube.com/temp/getVisitorsOverTimeResponse.xml
<http://www.bluetube.com/temp/getVisitorsOverTimeResponse.xml>
What I need to do is plot the time/date and then the 5 rates in a graph,
the rates are just a count at that timestamp.
What I'm having to do right now is take the xml and translate it into an
arrayCollection of objects each object has
class SeriesData
{
timeStamp:String;
rate1:String;
rate2:String;
rate3:String;
rate4:String;
rate5:String;
}
So in my graph I then plot each rate as a series
<code>
<mx:LineSeries yField="rate1" form="curve"
displayName="Rate1" showDataEffect="interpolate"/>
<mx:LineSeries yField="rate2" form="horizontal"
displayName="Rate2" showDataEffect="interpolate"/>
<mx:LineSeries yField="rate3" form="horizontal"
displayName="Rate3" showDataEffect="interpolate"/>
<!-- <mx:LineSeries yField="rate3" form="horizontal"
displayName="Rate4" showDataEffect="interpolate"/>
<mx:LineSeries yField="rate5" form="horizontal"
displayName="Rate5"showDataEffect="interpolate"/ >-->
</code>
I've got about 8 lines of code to take the data, put it into objects
then stuff it into an arraylist for the graph to consume, I'd rather be
taking the xml directly to the graph.
what I really want to do is take the xml piece
<code>
<visitors>
<visitor>
<date>2006-12-31 12:01:00</date>
<rates>
<rate id="1">897878</rate>
<rate id="2">8787</rate>
<rate id="3">897878</rate>
<rate id="4">8787</rate>
<rate id="5">897878</rate>
</rates>
</visitor>
<visitor>
<date>2006-12-31 12:02:00</date>
<rates>
<rate id="1">897878</rate>
<rate id="2">8787</rate>
<rate id="3">897878</rate>
<rate id="4">8787</rate>
<rate id="5">897878</rate>
</rates>
</visitor>
<visitor>
<date>2006-12-31 12:03:00</date>
<rates>
<rate id="1">897878</rate>
<rate id="2">8787</rate>
<rate id="3">897878</rate>
<rate id="4">8787</rate>
<rate id="5">897878</rate>
</rates>
</visitor>
</visitors>
</code>
thats repeated and apply that to a series, so each rate with a different
id would get a series...
I'm looking for a tutorial on xml transformation I guess...
...........................................
> b l u e t u b e i n t e r a c t i v e.
.: grant davies
.: 404.428.6839 (c)
.: 708-983-1577 (F)
> [EMAIL PROTECTED]
> http://www.bluetube.com/bti <http://www.bluetube.com/bti>
> A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/>
<<attachment: small.jpg>>
<<attachment: small.jpg>>

