Easy enough, create a dictionary (id or name) when the series's are created; 
with the index.  And/Or you can get the count from myChart.series.length.

-TH

--- In flexcoders@yahoogroups.com, "Monette" <monett...@...> wrote:
>
> This will work.  However, the series count is not limited to just "3" series, 
> it's count is dynamic depending on the amount of data collected.  So the code 
> needs to check how many series exists and then generate the datatip for the 
> different series data points.  It is easy for me to accomplish this in VB.NET 
> or vbscript but I am just having problems accomplishing what I need in AS.
> 
> --- In flexcoders@yahoogroups.com, "turbo_vb" <TimHoff@> wrote:
> >
> > Ok, good.  Not sure exactly what you're trying to do, but it's basically 
> > the same type of thing as the data function.  It's all about getting to 
> > right data for the series.  Here's some code for getting individual values 
> > and for calculating totals for the week
> > 
> > private function dtFunction( o:HitData ):String
> > {
> >     var seriesId:String = LineSeries( o.element ).id;
> >     var seriesIndex:int;
> > 
> >     switch ( seriesId )
> >     {
> >             case "s0":
> >                     seriesIndex = 0;
> >                     break;
> >             case "s1":
> >                     seriesIndex = 1;
> >                     break;
> >             case "s2":
> >                     seriesIndex = 2;
> >                     break;
> >             default:
> >                     break;
> >     }
> > 
> >     var totalBooksForWeek:int = 0;
> > 
> >     for ( var a:int = 0; a < 3; a++ )
> >     {
> >             var sessionBooks:int = o.item.session[ a ].books;
> >             totalBooksForWeek += sessionBooks;
> >     }
> > 
> >     var s:String = "<b>" + LineSeries( o.element ).displayName + "</b>\n";
> >     s += "<b>Books:</b> " + LineSeriesItem( o.chartItem ).yValue + "\n";
> >     s += "<b>Book rate:</b> " + o.item.session[ seriesIndex ].bookrate + 
> > "\n";
> >     s += "<b>Status:</b> " + o.item.session[ seriesIndex ].status + "\n";
> >     s += "<b>Total Books for All Sessions:</b> " + totalBooksForWeek + "\n";
> > 
> >     return s;
> > }
> > 
> > -TH
> > 
> > --- In flexcoders@yahoogroups.com, "Monette" <monettemm@> wrote:
> > >
> > > Almost there!  I assigned an id to each series - s1, s2, s3 etc. Below I
> > > am trying to loop for the total amount of series.  The values show up
> > > for bookrate and status but they are the incorrect values for some of
> > > the datapoints.  If I define a as 0, 1 or 3 without the loop the values
> > > are correct for just that particular series.  Why isn't the for loop or
> > > while loop working?
> > > 
> > > Thanks so much for your help Tim!
> > > Monette
> > > 
> > > private function dtFunction( o:HitData ):String
> > > var s:String;
> > >                  for (var a:int=0; a < 3; a++)
> > >                  {
> > >                  var index:int = (LineSeries(o.element).id == "s" + a)? 0
> > > : 1;
> > >                  s =  "<b>" + LineSeries(o.element).displayName + "</b>
> > > \n";
> > >                  s += "<b>Books:</b> " +
> > > LineSeriesItem(o.chartItem).yValue + "\n" + "<b>Book rate:</b> " +
> > > o.item.session[index].bookrate +  "\n" ;
> > >                  s += "<b>Status:</b> " + o.item.session[index].status +
> > > "\n" ;
> > >                  }
> > >                  return s;
> > >              }
> > > --- In flexcoders@yahoogroups.com, "turbo_vb" <TimHoff@> wrote:
> > > >
> > > > Assuming that you have assigned an id to each series
> > > > ("baseline","2009-8"), you could use something like this:
> > > >
> > > > private function dtFunction( o:HitData ):String
> > > >
> > > > {
> > > >
> > > >       var index:int = ( LineSeries( o.element ).id == "baseline" ) ? 0
> > > :
> > > > 1;
> > > >
> > > >       var s:String = "<b>Book rate:</b> " + o.item.session[ index
> > > > ].bookrate;
> > > >
> > > >       return s;
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > > -TH
> > > >
> > > >
> > > >
> > > > --- In flexcoders@yahoogroups.com, "Monette" monettemm@ wrote:
> > > > >
> > > > > Tim,
> > > > > Your recommendation sounds so simple and logical but I am not
> > > getting
> > > > it
> > > > > to work.  My problem is parsing the XML and returning the correct
> > > info
> > > > > for the datapoints.  Following, is a sample of my XML file:
> > > > >
> > > > > <items>
> > > > >      <week name="1">
> > > > >          <session>
> > > > >              <sessionname>Baseline</sessionname>
> > > > >              <books>0</books>
> > > > >              <bookrate>2</bookrate>
> > > > >              <status>red</status>
> > > > >          </session>
> > > > >          <session>
> > > > >              <sessionname>2009-8</sessionname>
> > > > >              <books>0</books>
> > > > >              <bookrate>6</bookrate>
> > > > >              <status>red</status>
> > > > >          </session>
> > > > >      </week>
> > > > >      <week name="2">
> > > > >          <session>
> > > > >              <sessionname>Baseline</sessionname>
> > > > >              <books>0</books>
> > > > >              <bookrate>3</bookrate>
> > > > >              <status>red</status>
> > > > >          </session>
> > > > >          <session>
> > > > >              <sessionname>2009-8</sessionname>
> > > > >              <books>0</books>
> > > > >              <bookrate>1</bookrate>
> > > > >              <status>red</status>
> > > > >          </session>
> > > > >      </week>
> > > > > </items>
> > > > >
> > > > > What are your thoughts?
> > > > > Thanks.
> > > > > Monette
> > > > >
> > > > > --- In flexcoders@yahoogroups.com, "turbo_vb" TimHoff@ wrote:
> > > > > >
> > > > > > Yeah, you're very close.  Now it's just a matter of xml.  I'd
> > > start
> > > > by
> > > > > tracing o.  If the children are still in o, then drill down.
> > > > Otherwise,
> > > > > you'll have to go and find the nodes; like you're trying below. 
> > > Some
> > > > > things that you can start with:
> > > > > >
> > > > > > trace( o.toXMLString() );
> > > > > >
> > > > > > var myXMLChildren:XMLList = o.children();
> > > > > >
> > > > > > o.child("myProperty")[0].valueOf();
> > > > > >
> > > > > > -TH
> > > > > >
> > > > > > --- In flexcoders@yahoogroups.com, "Monette" monettemm@ wrote:
> > > > > > >
> > > > > > > Below is my DataTipFunction.  The commented part on top works
> > > > fine.
> > > > > > > However, there is additional information that I need to include
> > > > from
> > > > > the
> > > > > > > XML file into the data tip.
> > > > > > > When I mouse over the datapoint I would like to retrieve from
> > > the
> > > > > XML
> > > > > > > file the additional child nodes that correspond with that
> > > > datapoint.
> > > > > I
> > > > > > > feel that I am very close and missing one piece. How can I
> > > > > accomplish
> > > > > > > this dynamically by displaying the correct data for the series?
> > > > > Note, I
> > > > > > > can have more than 1 series in the XML data file.
> > > > > > >
> > > > > > > private  function DTPFunction(o:HitData):String
> > > > > > >              {
> > > > > > >                  //WORKS for data that is used on the chart x
> > > and
> > > > y
> > > > > > > values
> > > > > > >                  //var s:String;
> > > > > > >                  //s =  "<b>" +
> > > LineSeries(o.element).displayName
> > > > +
> > > > > "</b>
> > > > > > > \n";
> > > > > > >                  //s += "<b>Books:</b> " +
> > > > > > > LineSeriesItem(o.chartItem).yValue + "\n" + "<b>Book rate:</b> "
> > > +
> > > > > > > series. o.item.session.bookrate + "\n" ;
> > > > > > >                  //s += "<b>Status:</b> " +
> > > o.item.session.status
> > > > +
> > > > > "\n"
> > > > > > > ;
> > > > > > >                   //END WORKS
> > > > > > >
> > > > > > >                  var s:String;
> > > > > > >                  var a:int=0;
> > > > > > >                  var fNode:XML = chart.dataProvider[0];
> > > > > > >                  if ((LineSeries(o.element).displayName) ==
> > > > > > > fNode.child('sessionname'))
> > > > > > >                  {
> > > > > > >                  s =  "<b>" + o.item.session.sessionname[a] +
> > > > "</b>
> > > > > \n";
> > > > > > >                  s += "<b>Books:</b> " + o.item.session.books[a]
> > > +
> > > > > "\n" +
> > > > > > > "<b>Book rate:</b> " + o.item.session.bookrate[a] +  "\n" ;
> > > > > > >                  s += "<b>Status:</b> " +
> > > o.item.session.status[a]
> > > > +
> > > > > > > "</size>\n" ;
> > > > > > >                  a++
> > > > > > >                  }
> > > > > > >              return s;
> > > > > > >              }
> > > > > > >
> > > > > > > Thanks.
> > > > > > > Monette
> > > > > > >
> > > > > > > --- In flexcoders@yahoogroups.com, "turbo_vb" <TimHoff@> wrote:
> > > > > > > >
> > > > > > > > If the dataTipFunction doesn't give you enough flexibility,
> > > you
> > > > > could
> > > > > > > try a dataTipRenderer.  In either case, you can drill down to
> > > the
> > > > > child
> > > > > > > nodes there.
> > > > > > > >
> > > > > > > > -TH
> > > > > > > >
> > > > > > > > --- In flexcoders@yahoogroups.com, "Monette" monettemm@ wrote:
> > > > > > > > >
> > > > > > > > > The line chart displays multiple series created with the
> > > > > > > seriesDataFunction (assigning the x and y points).  The XML file
> > > > > > > includes additional child nodes per item that I would like to
> > > > > include in
> > > > > > > the datatip.  How do I include those items?  When I use
> > > > o.item.rate,
> > > > > it
> > > > > > > lists all the rates for each series in the datatip.
> > > > > > > > > Thanks.
> > > > > > > > > Monette
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>


Reply via email to