0 Replies Latest reply on Apr 20, 2010 2:32 PM by crissy84

    Line Charts and XML Hierarchies

    crissy84 Level 1

      Hello,

      I'm having some conceptual issues with charting data.

      Right now I am using plain ol objects as source data for charting which is working,

      but now I'm trying to migrate this to XML for a number of reasons.

      Here is a hypothetical situation... trying to graph monthly sales of cars by color.

       

       

      <data>
           <period date="1/1/10">
                <cars color="yellow" sold="2"/>
      
                <cars color="blue" sold="4"/>
      
                <cars color="white" sold="6"/>
           </period >
      
      
           <period date="2/1/10">
                <cars color="yellow" sold="6"/>
      
                <cars color="blue" sold="4"/>
      
                <cars color="white" sold="2"/>
           </period>
      
      
      </data>
      
      
      I want to graph this where Y-Axis is the number of cars sold and X-Axis is month.  
      I have a couple questions.
      
      Based on my previous experience with Flex charts, it seems that it 
      demands the data be structured more like this (instead of what's above)...
      
      
      <data>
           <cars date="1/1/10" color="yellow" sold="2"/>
           <cars date="1/1/10" color="blue" sold="4"/>
           <cars date="1/1/10" color="white" sold="6"/>
           <cars date="2/1/10" color="yellow" sold="6"/>
           <cars date="2/1/10" color="blue" sold="4"/>
           <cars date="2/1/10" color="white" sold="2"/>
      </data>
      
      Is that assumption correct?  Or is there a way to use the more hierarchical data (1st xml sample)?
      If my assumption is correct and I have to use the flattened example, 
      is there a simple/elegant want to transform the 1st example in to the 2nd example?  
      I know how I can do it with a looping/brute force approach by building a brand new tree, 
      but maybe there's a some kind of XML query trick.
      
      
      Lastly, if I'm using XML as the dataprovider like above, how do I convert the date strings 
      to actual dates so that I can format them to a specific date format?  
      I know how to convert them programatically, but if I'm just passing in XML, 
      how does the chart to know how to convert to dates?
      
      
      Thanks!