views:

2226

answers:

2

Hello all,

I have a Flex bar chart with two data series in a clustered format. The series are called RequiredFunding and ApprovedFunding, so they're plotted next to each other. The problem I am having is trying to format the label function on the Funding axis. I have several thousands of dollars being displayed and it needs to be formatted with dollar signs and commas (I have this functionality already).

When I try to apply a label function to the horizontal axis, I return MoneyFormatter.format(labelValue), which is my app-wide money formatter, but this doesn't work because there are two different money amounts in the dataProvider... there is labelValue.RequiredFunding and labelValue.ApprovedFunding.

Hopefully I explaned this correctly... does anyone have any ideas?

Much appreciated,

-Matt

EDIT: I was afraid I didn't explain this clearly enough! No worries. Basically, I want to format my bottom axis which currently says 8000, 16000, 24000, and 32000 to say $8,000, $16,000, $24,000, and $32,000. But the problem is, that axis isn't going off the RequiredFunding amount or the ApprovedFunding amount... it's automatically accomodating for whichever is the larger value... or somehow treating the two grouped series as individual series... I'm not certain. If I set it to return MoneyFormatter.format(RequiredFunding), for example, it will format it correctly... but it will only put the label for the RequiredFunding amounts (like $14,543, $2,543, $31,230) and won't plot either bar series. I hope this clears it up. If necessary I could upload some screen caps.

A: 

I'm not really sure what you want. You can just call the MoneyFormatter.format() after eachother with labelValue.RequiredFunding and after that labelValue.ApprovedFunding or not? Probably I don't get it right

Arno
Thanks for the reply! I provided an edit. I hope that clears it up!
mattdell
+1  A: 

I have this and it is working:

    <mx:CurrencyFormatter id="moneyFormatter" currencySymbol="$" thousandsSeparatorTo="," />
    <mx:BarChart dataProvider="{testData.Sample}">
     <mx:series>
      <mx:BarSeries yField="visitors"  />
      <mx:BarSeries yField="overhead" />
     </mx:series>
     <mx:horizontalAxis>
      <mx:CategoryAxis dataFunction="moneyFormat"/>
     </mx:horizontalAxis>
    </mx:BarChart>

moneyFormat function:

private function moneyFormat(cat:Object, labelItem:Object):String{
       return moneyFormatter.format(labelItem.value);
}

I used some test data that I had myself so don't mind the strange yFields. I hope this helps

Arno