All of the data examples I see for Flex charting are simply string months and 
number attributes, but that doesn't mesh with normal query results. Let's say 
this is my dataset from a query (returns all my withdrawals for the month). 

//my data
var expensesAC:ArrayCollection = new ArrayCollection( [
     { date: "1/12/10", type: 'checking', Amount: 450 },
     { date: "1/13/10", type: 'savings', Amount: 600 },
     { date: "1/15/10", type: 'checking', Amount: 300 },
     { date: "1/19/10", type: 'savings', Amount: 900 },
     { date: "1/20/10", type: 'checking', Amount: 500 } ]);

I'd like to have a 2-line chart...1 line for checking and 1 line for savings, 
but no lines appear. I tried implementing a dataFunction and debugging shows 
it's returns values at the correct type, but that doesn't work (no lines 
appear). Any ideas?
  
Here's the full mxml...if you remove the dataFunction attribute from the 2 
LineSeries, then the map (as expected) draws both lines on top of each other. 
Thanks in advance.

<?xml version="1.0"?>
<!-- Simple example to demonstrate the LineChart and AreaChart controls. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
   <mx:Script>
      <![CDATA[
        import mx.charts.chartClasses.Series;
        import mx.collections.ArrayCollection;
        
        [Bindable]                      
        private var expensesAC:ArrayCollection = new ArrayCollection( [
        { date: "1/12/10", type: 'checking', Amount: 450 },
        { date: "1/13/10", type: 'savings', Amount: 600 },
        { date: "1/15/10", type: 'checking', Amount: 300 },
        { date: "1/19/10", type: 'savings', Amount: 900 },
        { date: "1/20/10", type: 'checking', Amount: 500 } ]);
                        
        private function dataFunc(series:Series, item:Object, 
fieldName:String):Object {
           trace("fieldName: " + fieldName);
           if(series.id=="checkingSeries" && item.type == 'checking')
                return item.Amount;
           else if(series.id=="savingsSeries" && item.type == 'savings')
                return item.Amount;
           else
                return null;
           }
]]>
        </mx:Script>
        <!-- Line colors -->
        <mx:Stroke id = "s1" color="blue" weight="6"/>
        <mx:Stroke id = "s2" color="red" weight="2"/>
        
        
        <mx:Panel title="LineChart and AreaChart Controls Example" 
                  height="100%" width="100%" layout="horizontal">
                
        <mx:LineChart id="linechart" height="100%" width="45%"
          paddingLeft="5" paddingRight="5" showDataTips="true" 
dataProvider="{expensesAC}">
             <mx:horizontalAxis>
                <mx:CategoryAxis categoryField="date"/>
             </mx:horizontalAxis>
                        
        <mx:series>
        <mx:LineSeries id="checkingSeries" yField="Amount" 
dataFunction="dataFunc" form="curve" displayName="Checking" lineStroke="{s1}" />
        <mx:LineSeries id="savingsSeries" yField="Amount" 
dataFunction="dataFunc" form="curve" displayName="Savings" lineStroke="{s2}" />
        </mx:series>
        </mx:LineChart>
                
     <mx:Legend dataProvider="{linechart}"/>
                
        </mx:Panel>
</mx:Application>

Reply via email to