| <?xml version="1.0"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <!-- Simple example to demonstrate the PieChart control. --> |
| <mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" |
| paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" |
| height="100%" width="100%"> |
| |
| <fx:Script> |
| <![CDATA[ |
| import mx.collections.ArrayCollection; |
| |
| [Bindable] |
| private var medalsAC:ArrayCollection = new ArrayCollection( [ |
| { Country: "USA", Gold: 35, Silver:39, Bronze: 29 }, |
| { Country: "China", Gold: 32, Silver:17, Bronze: 14 }, |
| { Country: "Russia", Gold: 27, Silver:27, Bronze: 38 } ]); |
| |
| private function displayGold(data:Object, field:String, index:Number, percentValue:Number):String { |
| var temp:String= (" " + percentValue).substr(0,6); |
| return data.Country + ": " + '\n' + "Total Gold: " + data.Gold + '\n' + temp + "%"; |
| } |
| ]]> |
| </fx:Script> |
| |
| <fx:Declarations> |
| <!-- Define custom colors for use as pie wedge fills. --> |
| <mx:SolidColor id="sc1" alpha=".6"/> |
| <mx:SolidColor id="sc2" color="red" alpha=".6"/> |
| <mx:SolidColor id="sc3" color="0x663300" alpha=".6"/> |
| |
| <!-- This Stroke is used for the callout lines. --> |
| <mx:SolidColorStroke id="callouts" weight="2" color="0x999999" alpha=".8" caps="square"/> |
| |
| <!-- This Stroke is used to separate the wedges in the pie. --> |
| <mx:SolidColorStroke id="radial" weight="1" color="0xFFFFCC" alpha=".3"/> |
| |
| <!-- This Stroke is used for the outer border of the pie. --> |
| <mx:SolidColorStroke id="pieborder" color="0x000000" weight="2" alpha=".5"/> |
| </fx:Declarations> |
| |
| <mx:Panel title="Olympics 2004 Medals Tally Panel" |
| paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" |
| height="100%" width="100%"> |
| <mx:PieChart id="chart" |
| height="100%" |
| width="100%" |
| paddingRight="5" |
| paddingLeft="5" |
| showDataTips="true" |
| dataProvider="{medalsAC}"> |
| <mx:series> |
| <mx:PieSeries |
| nameField="Country" |
| labelPosition="callout" |
| field="Gold" |
| labelFunction="displayGold" |
| calloutStroke="{callouts}" |
| radialStroke="{radial}" |
| stroke="{pieborder}" |
| fills="{[sc1, sc2, sc3]}"> |
| <!-- Clear the drop shadow filters from the chart. --> |
| <mx:filters> |
| <fx:Array/> |
| </mx:filters> |
| </mx:PieSeries> |
| </mx:series> |
| </mx:PieChart> |
| <mx:Legend dataProvider="{chart}"/> |
| </mx:Panel> |
| </mx:Module> |