Chris, here's an example that uses your data format (in a file called
"alldata.xml"). It uses e4x syntax to extract an array of names from the
file, then creates a series for each of those names...

<?xml version="1.0"?>
<!-- charts/XMLFileDataProvider2.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="initApp();">
  <mx:Script><![CDATA[
        import mx.charts.series.LineSeries;
        import mx.charts.CategoryAxis;
    
        public function initApp():void { 
            var wholist:Array = new Array();
            for each(var property:XML in results.item.who) {
                wholist[property] = property;
            }
            
            for (var s:String in wholist) {
                trace(wholist[s]);
                var localXML:XMLList = results.item.(who==s); 
    
               var localSeries:LineSeries = new LineSeries();
               localSeries.dataProvider = localXML;
               localSeries.yField = "hours";
               localSeries.displayName = s;

               var hAxis:CategoryAxis = new CategoryAxis();
               hAxis.dataProvider = localXML;
               hAxis.categoryField = "when";
               myChart.horizontalAxis = hAxis;
            
               var currentSeries:Array = myChart.series;
               currentSeries.push(localSeries);
               myChart.series = currentSeries;
            
               trace(localXML);
            }
        }   
    ]]></mx:Script>

  <mx:XML id="results" source="alldata.xml"/>

  <mx:Panel title="Line Chart with Variable Number of Series">
     <mx:LineChart id="myChart" showDataTips="true"/>
     <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
</mx:Application>

hth,

matt horn
flex docs



> -----Original Message-----
> From: [email protected] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Chris Alvarado
> Sent: Tuesday, September 26, 2006 11:41 AM
> To: [email protected]
> Subject: [flexcoders] Line Chart
> 
> Hello all,
> 
>  
> 
> First time posting to the list here.
> 
>  
> 
> I am working with the Line Chart component and having some problems.
> 
>  
> 
> I am delivering the data through an XML document.
> 
>  
> 
> I have: 
> 
>  
> 
> Employees
> 
> Date
> 
> Hours
> 
>  
> 
> The selected dataset changes based on some input criteria 
> such as which employees to show.
> 
>  
> 
> Ideally what I am wanting is to have a line that represents 
> each employee with a separate line.
> 
>  
> 
> The x-axis will be the dates I have data for.
> 
>  
> 
> And the y-axis will represent number of hours.
> 
>  
> 
> At the moment my xml doc's format looks like this:
> 
>  
> 
> <dataset>
> 
>             <item>
> 
>                         <who>Some Person</who>
> 
>                         <when>Some Date</when>
> 
>                         <hours>Some Hours</hours>
> 
> </item>
> 
> </dataset>
> 
>  
> 
> dataProvider="{myServiceGraph.lastResult.dataset.item}"
> 
>  
> 
> First, I cannot seem to figure out how to get the graph to 
> display a dynamic number of lines based on how many <who> 
> elements I have.
> 
>  
> 
> Second, it seems like I might even have the data arranged 
> incorrectly for what im trying to accomplish.
> 
> Any ideas?
> 
>  
> 
> Thanks for any help and im looking forward to some great 
> conversation on this list.
> 
> ________________________________
> 
> I've stopped 4,856 spam and fraud messages. You can too!
> Free trial of spam and fraud protection at www.cloudmark.com 
> <http://www.cloudmark.com/sigs?rc=m874hl>
> Cloudmark Desktop - Join the fight against spam! 
> <http://www.cloudmark.com/sigs?rc=m874hl> 
> 
> 
> 
>  
> 
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.12.9/456 - Release 
> Date: 9/25/2006
> 
> 
>  
> 


--
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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> 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/
 


Reply via email to