View Full Version : XML object VS Array Collection
kminev
07-02-2008, 08:25 PM
I had my chart initially set up to use array collections, but soon enough I realized array collections will not be the way to go in my case scenario due to the large amount of data processed, so I switched to XML object.
I have spots where I need to obtain the length of my object with data e.g.
( chartData.length - rightBoundary ) and so forth
Also can I also slice the xml e.g. xml.slice(2,19); likewise ArrayCollection
Can I accomplish that with XML object???
Another question I have is can I pass xml object to Chart control as a data source?
Thanks in advance.
matlevy
07-03-2008, 12:55 AM
TBH I've nt had experience of using the Chart Controls in flex, but Imagine they function very much in the same way as other components when specify the data soure you will also specify the various properties to look at for chart / data (eg with the combo box you specify the label property as well as the datasource).
If you are not worried about updating elements (ie you data source is read only) you could simply use and Array object, if you are worried about the extra crap flex throw in there. Could I ask why you think using the XML object is more preferential for you over the ArrayCollection?
drkstr
07-03-2008, 04:35 AM
I had my chart initially set up to use array collections, but soon enough I realized array collections will not be the way to go in my case scenario due to the large amount of data processed, so I switched to XML object. I think you had the wrong idea there. XML is for laziness, ArrayCollection of strongly typed Objects is for speed. If you are experiencing slow downs on your ArrayCollection, you are probably not parsing them right. for instance, instead of touching each item in a loop, touch each item in an array then update the ArrayCollection after your done processing. Otherwise you will have a lot of propertyChange events firing off. But if done correctly, Binary data is always always always faster then XML. For best results, create a data model class to describe your data and drop them in an ArrayCollection.
Best Regards,
~Aaron
matlevy
07-03-2008, 10:12 AM
For best results, create a data model class to describe your data and drop them in an ArrayCollection.
I agree, realistically you should have some sort of application model where your data is stored and access from, either as some sort of model locator or model dictionary, specifically because your objects are then strongly typed and allow for easier error trapping. If you want to control the binding simply create a class that implement the IList interface (and for iterating, the ICollectionView interface), you can then control the binding events and how and when they are dispatched yourself.
kminev
07-03-2008, 02:56 PM
Thanks for everyones' input on my question. I am new to Flex and I don't know many of the tricks. Well the reason I thought xml would be faster is because I've been told than any time the ArrayCollection is utilized numerous events are being triggered which is slowing down the app. Long story short I am using a slider which controls the chart by sliding left and right in time. Something similar to the google analytics date range selector. It seems that my slider it just runs so slow it is almost useless.
Anybody who had experience with setting up charts and slide left and right on the slides by updating data on the chart, please some advices, tips and pointers?
The way my slider works which is mainly open source code I got with some customizing from my side is that any time the slider is used I am updating the values on the x Axis.
Can I also assign XML object to array collection and what would be the proper syntax?
Thanks in advance.
kminev
07-03-2008, 03:06 PM
I am trying to convert my XML to array collection using the following syntax, but not succesfully:
mainData is ArrayCollection object
mainData.source = new XML(e.result).children() as Array;
This is my xml structure: (Would it be faster if I substitute my Elements with attributes?
<NFS>
<Trade>
<OrNo>xxxxx</OrNo>
<Date>Fri Jun 06 08:03:00 GMT -0500 2008</Date>
<IP>xx.xx.x.xx</IP>
<Ex>CME-D</Ex>
<A>Add</A>
<Trd>xxxx</Trd>
<W2G>32</W2G>
<W2E>47</W2E>
<G2E>15</G2E>
</Trade>
</NFS>
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.