2 Replies Latest reply on Apr 30, 2009 10:19 PM by vpablo

    Charting - multiple plots with different X axis

    vpablo

      Hello all,

       

      I'm trying to chart multiple lines that contain a date on the X axis and a double on the Y one. Trouble is that the X points are different across lines. I don't know how to do that in flex since I can use only 1 datasource. I tried something like:

       

           <mx:ArrayCollection id="test">
              <mx:Object x="01/01/2007" y0="1" y1="2" />
              <mx:Object x="01/01/2008" y0="1" y1="34" />                           
              <mx:Object x="01/01/2009" y1="26" />
              <mx:Object x="01/01/2010" y0="90" y1="12" />
          </mx:ArrayCollection>

       

                     <mx:LineChart id="linechart1" dataProvider="{test}">
                          <mx:horizontalAxis>                   
                              <mx:CategoryAxis categoryField="x" />
                          </mx:horizontalAxis>
                          <mx:series>
                              <mx:LineSeries displayName="y0" yField="y0"/>
                              <mx:LineSeries displayName="y1" yField="y1"/>
                          </mx:series>
                      </mx:LineChart>

       

      but this would plot only the first 2 values of y0 and not the last one.

       

      Any advice?

       

      Thanks

        • 1. Re: Charting - multiple plots with different X axis
          Srirangan

          Hi,

           

          Multiple fixes available:

           

          1. You can either specify the range for the chart axis so that it includes 90 as part of the default view

           

          2. You can add padding to the axis

           

          or

           

          3. You can turn on interpolation of the LineSeries. See example below:

           

                   <mx:ArrayCollection id="test">
                  <mx:Object x="01/01/2007" y0="1" y1="2" />
                  <mx:Object x="01/01/2008" y0="1" y1="34" />                          
                  <mx:Object x="01/01/2009" y1="26" />
                  <mx:Object x="01/01/2010" y0="90" y1="12" />
              </mx:ArrayCollection>

           

           

           

                         <mx:LineChart id="linechart1" dataProvider="{test}" showDataTips="true">
                              <mx:horizontalAxis>                  
                                  <mx:CategoryAxis categoryField="x" />
                              </mx:horizontalAxis>
                              <mx:series>
                                  <mx:LineSeries displayName="y0" yField="y0" interpolateValues="true"/>
                                  <mx:LineSeries displayName="y1" yField="y1" interpolateValues="true"/>
                              </mx:series>
                          </mx:LineChart>

          • 2. Re: Charting - multiple plots with different X axis
            vpablo Level 1

            Thanks, seems that interpolation is exactly what I was looking for! working fine now