package com.twobowl.component.manualTopo { import com.amcharts.AmPieChart; import com.amcharts.chartClasses.AmChart; public class MYAmPieChart extends AmPieChart { public function MYAmPieChart() { super(); } override protected function createChildren():void{ super.createChildren(); if(_amchartsLink){ _amchartsLink.alpha=0; _amchartsLink.width=0; _amchartsLink.height=0; } _amchartsLink.visible = false; return; } } }
package com.twobowl.component.manualTopo//自己定义包名 { import com.amcharts.AmSerialChart; import com.amcharts.chartClasses.AmChart; public class MYAmchartst extends AmSerialChart { public function MYAmchartst() { super(); } override protected function createChildren():void{ super.createChildren(); if(_amchartsLink){ _amchartsLink.alpha=0; _amchartsLink.width=0; _amchartsLink.height=0; } _amchartsLink.visible = false; return; } } }
2.
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:amcharts="http://www.amcharts.com/com_internal" xmlns:am="com.twobowl.component.manualTopo.*" backgroundColor="#FFFFFF" width="100%" height="100%" > <s:layout> <s:VerticalLayout horizontalAlign="center" paddingTop="30"/> </s:layout> <fx:Script> <![CDATA[ import com.amcharts.events.PieChartEvent; import com.twobowl.component.manualTopo.*; import mx.collections.ArrayCollection; [Bindable] private var chartData:ArrayCollection = new ArrayCollection( [ {year:"2000",a:20,b:5,c:10,d:5}, {year:"2001",a:21,b:6,c:10,d:10}, {year:"2002",a:24,b:7,c:9,d:10}, {year:"2003",a:21,b:5,c:10,d:8}, {year:"2004",a:24,b:4,c:10,d:8}, {year:"2005",a:26,b:8,c:10,d:9}, {year:"2006",a:27,b:9,c:12,d:9}, {year:"2007",a:29,b:9,c:13,d:8}, {year:"2008",a:30,b:10,c:14,d:7}, {year:"2009",a:26,b:12,c:15,d:8}, {year:"2010",a:24,b:11,c:13,d:9}, {year:"2011",a:22,b:14,c:11,d:8}, {year:"2012",a:21,b:16,c:11,d:7}, {year:"2013",a:20,b:17,c:13,d:6}, {year:"2014",a:15,b:19,c:13,d:5}, {year:"2015",a:14,b:18,c:14,d:3}]); [Bindable] private var chartDatas:ArrayCollection = new ArrayCollection([ {year:2005,income:23.5,expenses:18.1}, {year:2006,income:26.2,expenses:22.8}, {year:2007,income:30.1,expenses:23.9}, {year:2008,income:29.5,expenses:25.1}, {year:2009,income:24.6,expenses:25.0} ]); protected function myampiechart1_clickHandler(event:PieChartEvent):void { // TODO Auto-generated method stub //event.item.dataContext. chart.dataProvider=chartDatas; } ]]> </fx:Script> <s:HGroup width="100%" height="50%"> <s:VGroup width="50%" height="100%"> <am:MYAmPieChart width="50%" height="100%" dataProvider="{chartData}" titleField="year" valueField="a" clickSlice=" myampiechart1_clickHandler(event)" /> </s:VGroup> <s:VGroup width="50%" height="100%"> <am:MYAmchartst width="50%" height="100%" id="chart2" dataProvider="{chartData}" categoryField="year" plotAreaFillAlphas="[0]"> <am:graphs> <amcharts:AmGraph color="#FFFFFF" title="Sample a" valueField="a" type="line" lineThickness="2" lineAlpha="1" fillAlphas="[0.7]" showBalloon="false"/> <amcharts:AmGraph color="#FFFFFF" title="Sample b" valueField="b" type="line" lineThickness="2" lineAlpha="1" fillAlphas="[0.7]"/> <amcharts:AmGraph color="#FFFFFF" title="Sample c" valueField="c" type="line" lineThickness="2" lineAlpha="1" fillAlphas="[0.7]" showBalloon="false"/> <amcharts:AmGraph color="#FFFFFF" title="Sample d" valueField="d" type="line" lineThickness="2" lineAlpha="1" fillAlphas="[0.7]"/> </am:graphs> <am:valueAxes> <amcharts:ValueAxis stackType="regular" gridAlpha="0.1"/> </am:valueAxes> <am:categoryAxis> <amcharts:CategoryAxis gridAlpha="0.1" fontWeight="bold" startOnAxis="true" position="top"/> </am:categoryAxis> <am:chartScrollbar> <amcharts:ChartScrollbar height="20"/> </am:chartScrollbar> <am:chartCursor> <amcharts:ChartCursor/> </am:chartCursor> </am:MYAmchartst> <amcharts:AmLegend fontWeight="bold" reversedOrder="true" rollOverGraphAlpha="0.1" dataProvider="{chart2}" width="100%" marginLeft="35" marginRight="15" markerType="circle" switchType="v"/> </s:VGroup> </s:HGroup> <s:VGroup width="100%" height="50%"> <am:MYAmchartst width="100%" height="100%" id="chart" dataProvider="{chartDatas}" categoryField="year" startDuration="1" angle="30" depth3D="30"> <am:categoryAxis> <amcharts:CategoryAxis gridPosition="start"/> </am:categoryAxis> <am:graphs> <amcharts:AmGraph title="Income" id="g0" valueField="income" type="column" lineAlpha="0" fillAlphas="[1]"/> <amcharts:AmGraph title="Expenses" id="g1" valueField="expenses" type="line" lineThickness="2" bullet="round"/> </am:graphs> </am:MYAmchartst> <amcharts:AmLegend dataProvider="{chart}" width="100%" switchType="v" marginRight="20" marginLeft="40" textClickEnabled="false" marginBottom="15"/> </s:VGroup> </s:Application>