?
Solved

formating column chart

Posted on 2011-09-26
6
Medium Priority
?
378 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
Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

 

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 2000 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

When ransomware hits your clients, what do you do?

MSPs: Endpoint security isn’t enough to prevent ransomware.
As the impact and severity of crypto ransomware attacks has grown, Webroot has fought back, not just by building a next-gen endpoint solution capable of preventing ransomware attacks but also by being a thought leader.

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…
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

765 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