1个回答
展开全部
没有现成的代码,你只有自己多看例子.分析自己想要的,做好笔记,总结,对学习帮助很大的. ?xml version="1.0" ? charts/MakeChartFromSelection.mxml http://www.adobe.com/2006/mxml" creationComplete="initApp()"> ![CDATA[ import mx.collections.ArrayCollection; import mx.charts.chartClasses.ChartBase; import mx.charts.ChartItem; import mx.charts.series.items.ColumnSeriesItem; import mx.charts.PieChart; import mx.charts.series.PieSeries; import mx.charts.events.ChartItemEvent; [Bindable] public var newDataProviderAC:ArrayCollection; [Bindable] private var expensesAC:ArrayCollection = new ArrayCollection([ { Month: "Jan", Expenses: 1500 }, { Month: "Feb", Expenses: 200 }, { Month: "Mar", Expenses: 500 }, { Month: "Apr", Expenses: 1200 }, { Month: "May", Expenses: 575 } ]); private function initApp():void { myColumnChart.addEventListener(ChartItemEvent.CHANGE, createNewChart); setupPieChart(); } private function getNewDataProvider():ArrayCollection { newDataProviderAC = new ArrayCollection(); for (var i:int=0; i<series1.selectedItems.length; i++) { var o:Object = new Object(); o.Month = expensesAC.getItemAt(series1.selectedIndices[i]).Month; o.Expenses = expensesAC.getItemAt(series1.selectedIndices[i]).Expenses; newDataProviderAC.addItem(o); } return newDataProviderAC; } private var newChart:PieChart; private var newSeries:PieSeries; [Bindable] private var explodedPiece:Array; private function explodePiece(e:Event):void { explodedPiece = new Array(); explodedPiece[newSeries.selectedIndex] = .2; newSeries.perWedgeExplodeRadius = explodedPiece; } private function setupPieChart():void { newChart = new PieChart(); newChart.showDataTips = true; newChart.selectionMode = "single"; newSeries = new PieSeries(); newSeries.field = "Expenses"; newSeries.nameField = "Month"; newSeries.setStyle("labelPosition", "callout"); newSeries.setStyle("showDataEffect", "interpol"); var newSeriesArray:Array = new Array(); newSeriesArray.push(newSeries); newChart.series = newSeriesArray; newChart.addEventListener(ChartItemEvent.CHANGE, explodePiece); p1.addChild(newChart); } private function createNewChart(e:Event):void { newChart.dataProvider = getNewDataProvider(); } ]]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询