PDA

View Full Version : using var to retrieve chartItem data


tsj4
11-04-2008, 11:36 PM
I have a variable which hold the name of the object I am trying to target in my array collection.

example

var ac:ArrayCollection = new ArrayCollection([{country:"USA", amount:19000}, {country:"JPN", amount:7800 }])
var label:String = "country";


I need to access this value for my custom dataTipFunction. I have tried this with no success


private function pieDataTipFunc(h:HitData) :String
{
var psi:PieSeriesItem = h.chartItem as PieSeriesItem;
var s:String;

s = psi.item(label)+"\nTotal Offload : "+decimalToPercentage(Number(psi.value));

return s;
}



Also when I try this it fails


private function pieDataTipFunc(h:HitData) :String
{
var psi:PieSeriesItem = h.chartItem as PieSeriesItem;
var s:String;

s = psi.item.label+"\nTotal Offload : "+decimalToPercentage(Number(psi.value));

return s;
}

tsj4
11-05-2008, 06:11 PM
if this is not possible what would the equiv to xFeild and yFeild of xValue or yValue be since a pie chart does not use these properties?

such as

PieChartItem(hitData.element).field
PieChartItem(hitData.element).nameField

tsj4
11-05-2008, 10:05 PM
Ok, both example of what I was trying are clearly wrong since I should be using the hitData info.

I have modified the attempts to reflect a more accurate approach but still with no success.

var ac:ArrayCollection = new ArrayCollection([{country:"USA", amount:19000}, {country:"JPN", amount:7800 }])
var label:String = "country";


private function pieDataTipFunc(h:HitData) :String
{
var psi:PieSeriesItem = h.chartItem as PieSeriesItem;
var s:String;

s = h.item.label+"\n"+"Total Offload : "+decimalToPercentage(Number(psi.value));

return s;
}




The part in question is

h.item.label