You set the data provider of the series to nothing.
myService.lastResult is not set to anything until the HTTPService has
returned.

I normally call send(), and then in a seperate function handle the
complete event. Then the the lastResult will be set.

I suppose you could data bind the data provider of the line series to
the lastResult of the HTTPService via BindingUtils.

--- In [email protected], "tedgies" <[EMAIL PROTECTED]> wrote:
>
> Has anyone had any success in creating a chart with a series that 
> you can add to at runtime?  (Like Yahoo finance charts 2.0).  I 
> haven't yet seen an example where the LinSeries is based upon a 
> changing (growing) set of external xml data files.  Below i paste a 
> snippet where i try to for loop through an Array Collection and 
> create a separate httpservice call for each dataset (each baseball 
> player).  The httpservice URL is created dynamically based upon the 
> arraycollection.  I don't get any errors, but my chart will not 
> paint my data.  I think my problem is in:
> 
> newSeries.dataProvider = myService.lastResult.item;
> 
> thanks,
> Ted
> 
>   <mx:Script><![CDATA[
>       import mx.rpc.http.mxml.HTTPService;
>       import mx.charts.chartClasses.StackedSeries;
>       import mx.charts.chartClasses.Series;
>       import mx.events.IndexChangedEvent;
>       import mx.events.ListEvent;
>       import mx.utils.StringUtil;
>     import mx.controls.Alert;
>     import mx.charts.events.ChartItemEvent;
>     import mx.collections.ArrayCollection;
>     import mx.utils.ArrayUtil;
>     import mx.charts.series.LineSeries;
>     import mx.charts.DateTimeAxis;
>     import mx.charts.CategoryAxis;
> 
> [Bindable]
>         public var ItemsInChart:ArrayCollection = new ArrayCollection
> ([            
>               {playerName: "Babe_Ruth", playerID: "123456"},
>               {playerName: "Hank_Aaron", playerID: "123457"}]);
>           
>     public function initApp():void {     
>        //Loop through the ArrayCollection ItemsinChart and create 
> a new httpservice and line for each.
>                 var i:int;
>                 for (i = 0; i < ItemsInChart.length; i++) {
>                           var myService:HTTPService = new 
> HTTPService();
>                           var playerStr:String = 
> ItemsInChart.getItemAt(i).playerName;          
>                           myService.url = "assets/" + playerStr 
> + ".xml";
>                           myService.send();
>                
>          // Create the new series and set its properties.
>                var series:Array = myChart.series;
>                var newSeries:LineSeries = new LineSeries;
>                newSeries.dataProvider = myService.lastResult.item;
>                newSeries.xField = "Year";
>                newSeries.yField = "Home_Runs";
>                newSeries.displayName = "Home Runs for Baseball 
> Greats";
>                newSeries.name = "Home Runs";   
>              // Add the new series to the current Array of series.
>            series.push(newSeries);
>                myChart.series = series;
>             }
>     }        
>   ]]>
>        </mx:Script>
>


Reply via email to