Flex 实现LineChart曲线――动态加载组件


   width="100%" initialize="addArray()"> Width:int = 1000 private var Height:int = 400 private var fontColor:String = "0x000000" import mx.charts.CategoryAxis; import mx.charts.LineChart; import mx.charts.Legend; import mx.charts.series.LineSeries;d import mx.containers.HBox; import mx.collections.ArrayCollection; import ChatCreate; [Bindable] public var expenses:ArrayCollection = new ArrayCollection([ { Day: 100, a: 200, b: 1500,c: 450 }, { Day: 300, a: 100, b: 200, c: 600 }, { Day: 500, a: 450, b: 500, c: 300 }, { Day: 700, a: 280, b: 1200,c: 900 }, { Day: 900, a: 640, b: 575, c: 500 } ]); public var chartArray:Array = new Array public static var lineChart:LineChart=new LineChart; public static var myArray:Array = new Array("a","b","c"); public function addArray():void{ var myLineSeries:Array=new Array(); for (var i:int=0; i Width lineChart.height=Height lineChart.setStyle("color", fontColor) lineChart.dataProvider=expenses; var lineHAxis:CategoryAxis=new CategoryAxis() lineHAxis.categoryField="Day"; lineHAxis.dataProvider=expenses; lineChart.horizontalAxis=lineHAxis; for (var j:int=0; j    下面是运行效果:
  
  这是本人苦苦研究一周的结果,尚有不足之处请各位多多指教。 
  而且本人本想将上面的ArrayCollection 做成动态的。但时间有限 ,二来确实有点棘手,毕竟刚开始学习。
  所以,请各位高手各抒己见。在此先行谢过。

你可能感兴趣的:(chart)