Tom,

 

In my chart, I have the following:

 

// some parent container tag

 

<mx:Script>

                        <![CDATA[

                                    import mx.charts.series.ColumnSeries;

                                    import mx.controls.gridclasses.*;

                                   

                                    function formatDataTip(eventObj) {

                                                // Get the hit data structure from the event object:

                                       var hd : mx.charts.HitData = eventObj.hitData;

                                       // Cast element to a columnSeries:

                                       var col : mx.charts.series.ColumnSeries = mx.charts.series.ColumnSeries(hd.element);

                                       // Get the yValue out of the data point:

                                       return col.name + ":\n" + "$" + thousandsformatter.format(hd.item[col.yField]);

                                    }

                                   

                                    function formatThousands(val) {

                                                return "$" + thousandsformatter.format(val);

                                    }

                        ]]>

            </mx:Script>

           

            <mx:VBox width="100%" height="100%" id="balChartBox">

                                   

                        <mx:ColumnChart id="balChart" width="100%" height="100%" dataProvider="{rawData}" showDataTips="true" dataTipFunction="formatDataTip" series="{series}" initialize="setSeries();">

 

                                    <mx:horizontalAxis>

                                                <mx:CategoryAxis dataProvider="{rawData}" categoryField="{field}" name="Drill-down" />

                                    </mx:horizontalAxis>

                                   

                                    <mx:verticalAxisRenderer>

                                                <mx:AxisRenderer labelFunction="formatThousands" />

                                    </mx:verticalAxisRenderer>

                                   

                                    <mx:verticalAxis>

                                                <mx:LinearAxis name="U.S. Dollars" />

                                    </mx:verticalAxis>

           

                        </mx:ColumnChart>

           

            </mx:VBox>

           

            <mx:NumberFormatter id="thousandsformatter" precision="2" useThousandsSeparator="true" useNegativeSign="false"/>

 

// parent container end tag

 

Which should do what you’re asking…just add the AxisRenderer with the format function and add the format function itself with the NumberFormatter component and you should be good to go.

 

Hope that helps!

 

Rob


From: Tom Fitzpatrick [mailto:[EMAIL PROTECTED]
Sent: Monday, February 28, 2005 7:53 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] chart formatting

 

What's the most efficient way to format the axis labels of a chart?

The dataProvider is providing values such as 135000. I want to be able to
format these values as, for example, $135,000 or $135K. What's the best
approach?

- Tom Fitzpatrick
Streamline Studios






 

This message contains information from Merlin Securities, LLC, or from one of its affiliates, that may be confidential and privileged. If you are not an intended recipient, pleaserefrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify the sender immediately by telephone or by replying to this transmission.
 
Merlin Securities, LLC is a registered broker-dealer. Services offered through Merlin Securities, LLC are not insured by the FDIC or any other Federal Government Agency, are not deposits of or guaranteed by Merlin Securities, LLC and may lose value. Nothing in this communication shall constitute a solicitation or recommendation to buy or sell a particular security.

Reply via email to