Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

formating column chart

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
eduardo12fox
Asked:
eduardo12fox
  • 3
  • 3
1 Solution
 
dgofmanCommented:
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
 
eduardo12foxAuthor Commented:
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
 
dgofmanCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
eduardo12foxAuthor Commented:
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
 
dgofmanCommented:
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
 
eduardo12foxAuthor Commented:
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

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now