1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | private function createPieChart():void { pieBox.removeAllChildren(); var length:int = dim1list.length; for each (var s:String in dim2list) { var pieChartPanelanel = new Panel(); var localXML:XMLList = chartXML.item.(dim2==s); // 与清单 1 在 mxml 中设置默认的 columnChartcreate 不同,此处是在 actionscript 中 // 以面向对象的编程方式创建 pieChart,但他们的效果是一样的 var pieChartieChart = new PieChart(); pieChart.showDataTips = true; // 创建饼图对应的 series var localSeriesieSeries = new PieSeries();localSeries.dataProvider = localXML;localSeries.field = "measure";localSeries.nameField = "dim1"; localSeries.displayName = s; pieChart.series.push(localSeries); pieChartPanel.title = s; // 为了此处扩展需要,将一个 pieChart 置于一个 pieChartPanel 中 pieChartPanel.addChild(pieChart); // 每次遍历将创建完的 pieChart 置于 pieBox 中 pieBox.addChild(pieChartPanel); } var piePanelanel = new Panel(); piePanel.horizontalScrollPolicy = "off"; piePanel.title = chartXML.dim1label; // legend 是图 3 右边的指示板 var pieLegendBox:Box = new Box(); pieLegendBox.horizontalScrollPolicy = "off"; pieLegendBox.maxHeight = 250; var pieLegendegend = new Legend(); pieLegend.dataProvider = pieChart; pieLegendBox.addChild(pieLegend); piePanel.addChild(pieLegendBox); pieBox.addChild(piePanel); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |