Here is the final code. It may not be the most efficient code, but it
works. I can't show the entire application code, but you should get
teh general idea from reading through the code. Thank you Ely and
everyone else for all of your help, you saved me some late nights. Its
funny how you get so frustrated you can't see simple solutions right
in front of your face.
///////////////XML used to populate the graph////////////
<list>
<month monthname="Jan-04" revenue="400263" average="80052"
customers="256700" kw="820000" applications="1892">
<region name="Kansas" revenue="106976" customers="25670"
kw="34000" applications="189"/>
<region name="Utah" revenue="147776" customers="25670"
kw="72000" applications="189"/>
<region name="Montana" revenue="79554" customers="25670"
kw="66000" applications="157"/>
<region name="Florida" revenue="39252" customers="25670"
kw="81100" applications="167"/>
<region name="Arizona" revenue="128351" customers="25670"
kw="81110" applications="144"/>
</month>
<month monthname="Feb-04" revenue="379145" average="75829"
customers="255750" kw="820800" applications="1512">
<region name="Kansas" revenue="69912" customers="22370"
kw="82990" applications="133"/>
<region name="Utah" revenue="22312" customers="35670"
kw="80000" applications="111"/>
<region name="Montana" revenue="69677" customers="27650"
kw="81420" applications="177"/>
<region name="Florida" revenue="59428" customers="25570"
kw="89990" applications="115"/>
<region name="Arizona" revenue="90804" customers="23670"
kw="11100" applications="121"/>
</month>
</list>
////////////////////////End XML ///////////////////////////////
///////////////Revenue formatter (used later)////////////////////
protected function currencyFormat(value:Object, arg2:Object,
arg3:Object):String
{
return cf.format(value);
}
/////////////End Revenue formatter///////////////////
///////////////The Datatip////////////////////////////////////
private function formatDataTip(hitData:HitData):String{
var months:String = hitData.item.month;
var name:String = LineSeries(hitData.element).yField;
var revenue:Object = LineSeriesItem(hitData.chartItem).yValue;
return "<b>"+name+"</b><br>"+months+"<br>"+cf.format(revenue);
}
////////////////////End DataTip Code////////////////////
//////////////Code to fill my Array//////////////////
private function LoadXML(event:ResultEvent):void{
xmldpAddress = new XML(event.target.lastResult);
districts = new
XMLListCollection([EMAIL PROTECTED]);
slicedMonthData = new ArrayCollection();
slicedRevenueData = new ArrayCollection();
monthlysVO = new Array();
monthlyRev = new Array();
monthsArray = new Array();
var children:XMLList = xmldpAddress.month;
var child:XML;
var objRegion:Object;
var objMonth:Object;
var j:int;
var g:int;
var mlength_int:int = children.length();
var rlength_int:int = children[0].region.length();
for (j=0; j<mlength_int; j++){
child = children[j];
monthsArray[j] = [EMAIL PROTECTED];
objRegion = new Object();
objMonth = new Object();
objMonth["month"[EMAIL PROTECTED];
objMonth["revenue:"[EMAIL PROTECTED];
objMonth["customers:"[EMAIL PROTECTED];
objMonth["kw:"[EMAIL PROTECTED];
objMonth["applications:"[EMAIL PROTECTED];
for(g=0; g<rlength_int; g++){
objRegion["month"[EMAIL PROTECTED];
[EMAIL PROTECTED] + ":"[EMAIL PROTECTED];
}
monthlysVO.push(objRegion);
monthlyRev.push(objMonth);
}
//////////////End Code to fill my Array//////////////////
///////////////Put the Array into an Array Collection//////////
////////////// To gain the benefits of the ArrayCollection/////
slicedMonthData.source = monthlysVO;
slicedRevenueData.source = monthlyRev;
///////////////End put the Array into an Array Collection//////////
//////////////MXML Code to use the dataTip////////////////////////
<mx:CurrencyFormatter id="cf"/>
<mx:Panel id="ComparePanel" title="State Comparison" width="75%"
height="100%">
<mx:LineChart id="revlinechart"
dataProvider="{slicedMonthData.source}"
showDataTips="true" dataTipFunction="formatDataTip" width="100%"
height="100%">
<mx:horizontalAxis>
<mx:CategoryAxis
categoryField="month"/>
</mx:horizontalAxis>
<mx:verticalAxis>
<mx:LinearAxis
maximum="160000" minimum="0"
labelFunction="currencyFormat"/>
</mx:verticalAxis>
</mx:LineChart>
</mx:Panel>
//////////////End MXML Code to use the dataTip////////////////////////
J
--- In [email protected], "jnewport" <[EMAIL PROTECTED]> wrote:
>
> Ok got it. Thanks for all your help Ely! I decided to rework my
> ArrayCollection and now can just use "month" for the categoryAxis
> instead of "month:", which means I can just use hitData.item.month to
> get the month for the dataTip.
>
> J :)
>
>
>
> --- In [email protected], "jnewport" <jason_newport@> wrote:
> >
> > Can you get direct access of horizontalAxis? No matter what I try it
> > does not like horizontalAxis. Maybe giving it an id and directly
> > accessing it by reference?
> >
> > J
> >
> > --- In [email protected], "Ely Greenfield" <egreenfi@> wrote:
> > >
> > >
> > >
> > >
> > > Yup. If you don't specify an x value, it assumes the item's ordinal
> > > position in the data is its x value. The Cateogry Axis then lines
> up the
> > > value N to the nth category in _its_ data.
> > >
> > > The Axis objects all implement a function called formatForScreen().
> > > Pass it a value (i.e., like the value in xValue) and it will
> return what
> > > it considers to be an appropriate string to represent that value on
> > > string (in this case, the category name). So get access to the
> > > horizontal axis, and call formatForScreen on it.
> > >
> > > Ely.
> > >
> > >
> > > ________________________________
> > >
> > > From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> > > Behalf Of jnewport
> > > Sent: Friday, October 06, 2006 2:12 PM
> > > To: [email protected]
> > > Subject: [flexcoders] Re: Format a datatip.
> > >
> > >
> > >
> > > Ok, I have the revenue part working and formatting it. Thank you.
> > > But, I cannot get the MONTH to show. Month is my categoryField.
> > >
> > > categoryField="month:"
> > >
> > > Below is what I have for my formatDataTip, but I cannot seem to find
> > > the MONTH. I have tried useing hitData.element and hitData.item.
> > > I thought it would be LineSeriesItem(hitData.chartItem).xValue, but
> > > that just gives me 0, 1, 2, n.... (guessing it is the position
of data
> > > in the ArrayCollection I am using to populate my graph.
> > >
> > > Any suggestions?
> > >
> > > private function formatDataTip(hitData:HitData):String{
> > > //var months:String = LineSeries(hitData.element);//Not working
> > > var name:String = LineSeries(hitData.element).yField;
> > > var revenue:Object = LineSeriesItem(hitData.chartItem).yValue;
> > > return "<b>"+name+"</b><br>"+months+"<br>"+cf.format(revenue);
> > > }
> > >
> > > --- In [email protected]
> <mailto:flexcoders%40yahoogroups.com>
> > > , "Ely Greenfield" <egreenfi@> wrote:
> > > >
> > > >
> > > >
> > > > Sorry...try:
> > > >
> > > > LineSeriesItem(hitData.chartItem).y.value;
> > > >
> > > > Ely.
> > > >
> > > >
> > > > ________________________________
> > > >
> > > > From: [email protected]
> <mailto:flexcoders%40yahoogroups.com>
> > > [mailto:[email protected]
> <mailto:flexcoders%40yahoogroups.com>
> > > ] On
> > > > Behalf Of jnewport
> > > > Sent: Tuesday, October 03, 2006 12:47 PM
> > > > To: [email protected]
> <mailto:flexcoders%40yahoogroups.com>
> > > > Subject: [flexcoders] Re: Format a datatip.
> > > >
> > > >
> > > >
> > > > This throws an error.
> > > >
> > > > "Cannot convert Object@ to mx.chart.series.items.LineSeriesItem"
> > > >
> > > > /////////Start of datatipcode///////////////////////////
> > > > private function formatDataTip(hitData:HitData):String{
> > > >
> > > > var months:String = LineSeriesItem(hitData.item).yValue;
> > > > var name:String = hitData.item.toString();
> > > > var revenue:Number = hitData.item.revenue;
> > > > return "<b>"+name+"</b><br>"+months+"<br>"+cf.format(revenue);
> > > > }
> > > >
> > > > //////////////////End datatip code////////////////
> > > >
> > > > Any suggestions?
> > > >
> > > > --- In [email protected]
> > > <mailto:flexcoders%40yahoogroups.com>
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > , "Ely Greenfield" <egreenfi@> wrote:
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > LineSeriesItem(hitData.item).yValue
> > > > >
> > > > > Ely.
> > > > >
> > > > >
> > > > > ________________________________
> > > > >
> > > > > From: [email protected]
> > > <mailto:flexcoders%40yahoogroups.com>
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > [mailto:[email protected]
> > > <mailto:flexcoders%40yahoogroups.com>
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > ] On
> > > > > Behalf Of jnewport
> > > > > Sent: Friday, September 29, 2006 12:35 PM
> > > > > To: [email protected]
> <mailto:flexcoders%40yahoogroups.com>
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > > Subject: [flexcoders] Re: Format a datatip.
> > > > >
> > > > >
> > > > >
> > > > > I tried that, but didn't work correctly.
> > > > >
> > > > > LineSeries.(hitData.element).yField. which gave me the State
name,
> > > > > but it won't give me the amount, which is what I am trying to
> get to
> > > > > do format.
> > > > >
> > > > > I have been trying to use chartItem, but no success. Flex can
> get me
> > > > > all the data on its own with the showDataTips=true, so it
> knows how
> > > to
> > > > > get the data out of my ArrayCollection. I just want to be
able to
> > > get
> > > > > at what Flex knows.
> > > > >
> > > > > I need to get at what showDataTips is doing when set to True.
> > > > >
> > > > > Anyone know what it is?
> > > > >
> > > > > --- In [email protected]
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > > , "Mehdi, Agha" <Agha.Mehdi@> wrote:
> > > > > >
> > > > > > J,
> > > > > >
> > > > > > Try event.hitData.element.yField/.xField
> > > > > >
> > > > > > Agha Mehdi
> > > > > > IDT - eBusiness Program Manager
> > > > > >
> > > > > > -----Original Message-----
> > > > > > From: [email protected]
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > > [mailto:[email protected]
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > > ] On
> > > > > > Behalf Of jnewport
> > > > > > Sent: Friday, September 29, 2006 9:11 AM
> > > > > > To: [email protected]
> > > <mailto:flexcoders%40yahoogroups.com>
> > > <mailto:flexcoders%40yahoogroups.com>
> > > > <mailto:flexcoders%40yahoogroups.com>
> > > > > > Subject: [flexcoders] Format a datatip.
> > > > > >
> > > > > > I was wondering how to format a datatip for a LineChart. If
> I use
> > > > > > showDataTips everything looks good but the amounts are not
> > > formatted
> > > > > > to $##,###. I have created an ArrayCollection that looks
> like the
> > > > > > following.
> > > > > >
> > > > > > private var expensesAC:ArrayCollection = new
ArrayCollection( [
> > > > > > { Month: "Jan", Texas: 2000, Utah: 1500, Kansas: 450 },
> > > > > > { Month: "Feb", Texas: 1000, Utah: 200, Kansas: 600 },
> > > > > > { Month: "Mar", Texas: 1500, Utah: 500, Kansas: 300 },
> > > > > > { Month: "Apr", Texas: 1800, Utah: 1200, Kansas: 900 },
> > > > > > { Month: "May", Texas: 2400, Utah: 575, Kansas: 500 } ]);
> > > > > >
> > > > > > I have tried to use cf.format(); on the data before its
put into
> > > the
> > > > > > ArrayCollection, which works so I get something like this.
> > > > > >
> > > > > > private var expensesAC:ArrayCollection = new
ArrayCollection( [
> > > > > > { Month: "Jan", Texas: $2,000, Utah: $1,500, Kansas: $450 },
> > > > > >
> > > > > > But then Flex won't plot the data....guessing it doesn't
> like the
> > > > "$".
> > > > >
> > > > > >
> > > > > >
> > > > > > So I am trying to use a function like this
> > > > > >
> > > > > > private function formatDataTip(hitData:HitData):String {
> > > > > > var month:String = hitData.item.DONTKNOWWHATSHOULDGOHERE
> > > > > >
> > > > > > but I don't know what should come after item. I have tried
> to do a
> > > > > > trace(hitData.item.toString), but I get object object. Is
> there a
> > > > way
> > > > > > to trace out whats in the hitData.item?
> > > > > >
> > > > > > J
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Flexcoders Mailing List
> > > > > > FAQ:
> > > > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>
> > > > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > >
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt> >
> > > > >
<http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>
> > > > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>
> > >
> > > > > > Search Archives:
> > > > > > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com>
> > > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com> >
> > > > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com>
> > > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > <http://www.mail-archive.com/flexcoders%40yahoogroups.com> > >
> > > > > > Yahoo! Groups Links
> > > > > >
> > > > >
> > > >
> > >
> >
>
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/flexcoders/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/