Solved

formating column chart

Posted on 2011-09-26
6
377 Views
Last Modified: 2012-05-12
Hello,

I have a question I have a column chart but I'm from Brazil and formatting of our currency is: 1568.22 and the United States is: 1.568,22 I wonder if I have to format the values ¿¿that comes from mysql to chart as the currency of my country?

Example: 1568.22 to ---->  1,568.22
0
Comment
Question by:eduardo12fox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 36712677
You can format on the fly in ActionScript using labelFunction

http://livedocs.adobe.com/flex/3/html/help.html?content=charts_displayingdata_07.html
0
 

Author Comment

by:eduardo12fox
ID: 36716012
my question is not about the label and the value of the currency formatted for the currency of my country. See U.S. currency is so 1500.00 in my country is like this: 1500.00 has commas and periods, this is what the graph need formatters

sage This answer was not helpful.
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36718916
If you want to format your number the best way to use CurrenFormatter

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/formatters/CurrencyFormatter.html
0
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 

Author Comment

by:eduardo12fox
ID: 36720135
ok I understand but how I apply it to the chart?



<?xml version="1.0"?>
<!-- charts/BasicColumn.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script><![CDATA[
     import mx.collections.ArrayCollection;
     [Bindable]
     public var expenses:ArrayCollection = new ArrayCollection([
        {Month:"Jan", Profit:1.540, Expenses:1500.00},
        {Month:"Feb", Profit:15.00, Expenses:200.00},
        {Month:"Mar", Profit:16.55, Expenses:5000.54}
     ]);
     
  ]]></mx:Script>
  
  
<mx:CurrencyFormatter id="MoedaFormatter" precision="2" currencySymbol="R$" decimalSeparatorTo="," decimalSeparatorFrom=","  
thousandsSeparatorFrom="." thousandsSeparatorTo="."/>


  <mx:Panel title="Column Chart">
     <mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true">
        <mx:horizontalAxis>
        
           <mx:CategoryAxis dataProvider="{expenses}" categoryField="Month" />
           
        </mx:horizontalAxis>
        <mx:series>
        
           <mx:ColumnSeries xField="Month" yField="Profit" displayName="Profit" />
           <mx:ColumnSeries xField="Month" yField="Expenses" displayName="Expenses" />
           
        </mx:series>
     </mx:ColumnChart>
     <mx:Legend dataProvider="{myChart}"/>
  </mx:Panel>
</mx:Application>

Open in new window

0
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
ID: 36720662
Here is two implementation of formation for Axis and tooltip

<?xml version="1.0"?>
<!-- charts/BasicColumn.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
	<mx:Script><![CDATA[
		import mx.charts.HitData;
		import mx.charts.series.items.ColumnSeriesItem;
		import mx.collections.ArrayCollection;
		import mx.utils.StringUtil;
		[Bindable]
		public var expenses:ArrayCollection = new ArrayCollection([
			{Month:"Jan", Profit:1.540, Expenses:1500.00},
			{Month:"Feb", Profit:15.00, Expenses:200.00},
			{Month:"Mar", Profit:16.55, Expenses:5000.54}
		]);
		
		private function columnChartDataTipFunction(item:HitData):String {
			var csi:ColumnSeriesItem = item.chartItem as ColumnSeriesItem;
			var xcol:String = ColumnSeries(item.element).xField;
			var ycol:String = ColumnSeries(item.element).yField;
			return StringUtil.substitute("<b>{0}</b><br>{1}<br>{2}", ycol, csi.item[xcol], currencyFormatter.format(csi.item[ycol]));
		}

	]]></mx:Script>
	
	
	<mx:CurrencyFormatter id="currencyFormatter" precision="2" currencySymbol="R$" decimalSeparatorTo="," decimalSeparatorFrom=","  
						  thousandsSeparatorFrom="." thousandsSeparatorTo="."/>
	
	
	<mx:Panel title="Column Chart">
		<mx:ColumnChart id="myChart" dataProvider="{expenses}" showDataTips="true"
						dataTipFunction="columnChartDataTipFunction">
			<mx:verticalAxisRenderers>
				<mx:AxisRenderer 
					axis="{vla}" 
					canDropLabels="false" 
					>
					<mx:labelRenderer>
						<mx:Component>
							<mx:Label>
								<mx:Script><![CDATA[
									override public function set data(value:Object):void{
										if(value == null)
											return;
										text = outerDocument.currencyFormatter.format(value.text);
									}
								]]></mx:Script>
							</mx:Label>
						</mx:Component>
					</mx:labelRenderer>
				</mx:AxisRenderer>                
			</mx:verticalAxisRenderers>

			<mx:verticalAxis>
				<mx:LinearAxis id="vla"/>
			</mx:verticalAxis>

			<mx:horizontalAxis>
				<mx:CategoryAxis dataProvider="{expenses}" categoryField="Month"/>
			</mx:horizontalAxis>
			<mx:series>
				
				<mx:ColumnSeries xField="Month" yField="Profit" displayName="Profit" />
				<mx:ColumnSeries xField="Month" yField="Expenses" displayName="Expenses" />
				
			</mx:series>
		</mx:ColumnChart>
		<mx:Legend dataProvider="{myChart}"/>
	</mx:Panel>
</mx:Application>

Open in new window

0
 

Author Closing Comment

by:eduardo12fox
ID: 36813943
Very good it was what I needed! Thank you was very very good!

The cool thing about this site that is an example to every problem because often the person has already tried google already seen the documentation but can not implement this site and we got a practical use

I usually do when I get link, do not usually look for the most part I've gone through the link and did not understand, but here the staff almost always put a step by step how to do

Thank you!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question