3 Replies Latest reply on Nov 16, 2009 9:38 AM by PoorOldCoder

    Newbie: why can't I use an array collection to feed a line series chart

    PoorOldCoder Level 1

      Alas, I have a simple wish but am spending hours trying to get this to work in flex.

       

      1. Take an array collection

      2. show the data in a chart.

       

      To bind the data to the chart..i have tried all sorts of combinations of "@date" or data.date or {date}...etc....

       

      This below, does now work...why?  (Note, when I se an XMLListcollection and @close for data binding, it seems to work)

       

      I am at the start of the "flex" career and must admit finding it tough with lack of detailed examples, so hopeful of inspiration.

       

       

            <mx:ArrayCollection id="dp2">
              <mx:source>
                      <mx:Object date="8" open="40.38" close="40.81" />
                      <mx:Object date="9" open="40.5" close="40.41" />
                      <mx:Object date="10" open="40.82" close="40.6" />
              </mx:source>
          </mx:ArrayCollection>
       
          <mx:Panel title="LineChart and AreaChart Controls Example3"
              height="491" width="729" layout="horizontal" x="350" y="84">
              <mx:LineChart id="linechart" height="100%" width="100%"
                  paddingLeft="5" paddingRight="5"
                  showDataTips="true" dataProvider="{dp2}">      
              <mx:horizontalAxis>
                  <mx:CategoryAxis id="ca" categoryField="{data.date}" title="Date" />
              </mx:horizontalAxis>
                  <mx:series>
                      <mx:LineSeries yField="{data.close}" form="curve" displayName="Profit" lineStroke="{s1}"/>
                  </mx:series>
              </mx:LineChart>
              <mx:Legend dataProvider="{linechart}"/>
          </mx:Panel>