5 Replies Latest reply on Jul 16, 2009 11:18 AM by _Natasha_

    Multiple dataproviders for charts

    ross a

      Hi guys, i can get the basics of multiple data providers working for my charts (i can have two seperate lines on my column chart from 2 seperate sources)

       

      However my problem is with setting both axis, i have no problem setting the y-axis to teh players score and the x-axis based on the number of inputs (each object in my array collectuion gets a new data point). BUT when i attempt to set the x-axis to be based onvalues solely from the array collection i can no longer display both graphs.

       

      I am currently using the bellow code snippet to display both lines:

       

      <mx:series>
                <mx:Array id="StatisticsArray">
                       <mx:LineSeries yField="total_score" id="SummaryLine"

                          form="curve" lineStroke="{s1}" dataProvider = "{StatsShown}">
                         <mx:itemRenderer>                               
                          <mx:Component>                                       
                           <mx:DiamondItemRenderer/>                            
                          </mx:Component>                       
                         </mx:itemRenderer>
                      </mx:LineSeries>
                      <mx:LineSeries yField="total_score" id="ExtraSummaryLine"
                           form="curve" lineStroke="{s2}" dataProvider = "{ExtraStatsShown}">
                       <mx:itemRenderer>                               
                        <mx:Component>                                       
                         <mx:DiamondItemRenderer/>                            
                        </mx:Component>                       
                       </mx:itemRenderer>
                    </mx:LineSeries>
                </mx:Array>
      </mx:series>

       

      So if a set the xField value of each to game_end_at (a date value) it no longer shows both line series

        • 1. Re: Multiple dataproviders for charts
          _Natasha_ Level 4

          Hi,

          yes, it's possible for your question.

           

          What is the code for horizontalAxis?

          • 2. Re: Multiple dataproviders for charts
            ross a Level 1

            I can not set the code for my horizontal axis except from:

             

            <mx:horizontalAxis>
                  <mx:LinearAxis padding=".5" id="HAxis" />
            </mx:horizontalAxis>

                <!-- horizontal axis renderer -->
            <mx:horizontalAxisRenderers>
                 <mx:AxisRenderer axis="{HAxis}" showLabels="false"/>
            </mx:horizontalAxisRenderers>

             

            As i can't set a data provider (because i need 2 different providers) or set the category field I can not base the x-axis on any particular value.. any help is appreciated. :-)

            • 3. Re: Multiple dataproviders for charts
              _Natasha_ Level 4

              It's not correct to use LinearAxis for date values.

              Try CategoryAxis.

              • 4. Re: Multiple dataproviders for charts
                ross a Level 1

                Thanks but i have tried category axis before, the problem arises when i attempt to give my line series an xField :

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                <mx:horizontalAxis>

                 

                 

                <mx:CategoryAxis id="HAxis" />

                 

                 

                </mx:horizontalAxis>

                 

                 

                 

                <!-- horizontal axis renderer -->

                 

                 

                <mx:horizontalAxisRenderers>

                 

                 

                <mx:AxisRenderer axis="{HAxis}" showLabels="false"/>

                 

                 

                </mx:horizontalAxisRenderers>

                 

                 

                 

                <mx:series>

                 

                 

                <mx:Array id="StatisticsArray">

                 

                 

                <mx:LineSeries yField="total_score" xField="game_end_at" id="SummaryLine" displayName="{MainGame}"

                form="

                curve" lineStroke="{s1}" dataProvider = "{StatsShown}">

                 

                 

                <mx:itemRenderer>

                 

                 

                <mx:Component>

                 

                 

                <mx:DiamondItemRenderer/>

                 

                 

                </mx:Component>

                 

                 

                </mx:itemRenderer>

                 

                 

                </mx:LineSeries>

                 

                 

                <mx:LineSeries yField="total_score" xField="game_end_at" id="ExtraSummaryLine" displayName="{ExtraGame}"

                form="

                curve" lineStroke="{s2}" dataProvider = "{ExtraStatsShown}">

                 

                 

                <mx:itemRenderer>

                 

                 

                <mx:Component>

                 

                 

                <mx:DiamondItemRenderer/>

                 

                 

                </mx:Component>

                 

                 

                </mx:itemRenderer>

                 

                 

                </mx:LineSeries>

                 

                 

                </mx:Array>

                 

                 

                </mx:series>

                 

                This displays nothing due to the addition of the xField value, the 2 dataproviders have this value but the data does not exactly match as they are date/time values. I need my x-axis to be based on the time values from each data provider (the y-axis can handle two dataproviders total_score values but teh x-axis can not do teh same with end_game_at)

                 

                Thanks again

                • 5. Re: Multiple dataproviders for charts
                  _Natasha_ Level 4

                  I use personal dataProvider per series in my project and there is no problem. But it's a Numbers on X Axis.

                   

                  You should understand that if you use LinearAxis for your chart Number is expected for x-axis values. But Date is not a Number and you don't get what you want.

                   

                  The best way is to write an DateAxis to work with Dates.