Solved

formating column chart

Posted on 2011-09-26
6
371 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
  • 3
  • 3
6 Comments
 
LVL 29

Expert Comment

by:dgofman
Comment Utility
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
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:eduardo12fox
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Advanced Datagrid with checkbox 4 293
Dashboard Examples 1 578
Flash As3 Swf 3 750
How width columns automaticaly 4 401
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…
Find out what Office 365 Transport Rules are, how they work and their limitations managing Office 365 signatures.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now