flex--LineChart
山森
2023-12-01
最近工作上用到了linechart,在网上查的资料还是非常少的,特此记录一下,以便后来人,顺便也记录自己的生活.废话不多说,开始吧.
另外,在http://blog.minidx.com/category/flex/legend-flex上也有很生动的例子. //创建图表方法 private function getPMSDPanel(tbTitleDataPMS:ArrayCollection):DPane l { var dPanelByGrid:DPanel=new DPanel(); dPanelByGrid.title=(tbTitleDataPMS.length >5?"PMS工单等级图":"PMS工单状态图"); dPanelByGrid.setStyle("horizontalAlign","center"); dPanelByGrid.showBtn=false; //设置LineChart相关属性 var lineChart:LineChart=new LineChart(); lineChart.dataProvider=(tbTitleDataPMS.length >5?chartPMSLData:chartPMSSData); lineChart.height=180; lineChart.width=360; lineChart.showDataTips=true; lineChart.selectionMode="single"; lineChart.seriesFilters=[]; lineChart.validateNow(); var categoryAxis:CategoryAxis=new CategoryAxis(); categoryAxis.categoryField="EMERGE_TIME"; categoryAxis.displayName="时段"; categoryAxis.labelFunction=hoursOfTime; var lineSeries:Array =new Array(); for each (var item in tbTitleDataPMS) { var lineSerie:LineSeries=new LineSeries(); lineSerie.selectable=true; lineSerie.setStyle("form", "curve"); lineSerie.setStyle("showDataEffect", zoomIn); lineSerie.yField=item.data; lineSerie.displayName=item.label; lineSeries.push(lineSerie); } var axisRen:AxisRenderer=new AxisRenderer(); axisRen.axis=categoryAxis; axisRen.setStyle("canDropLabels", true); axisRen.setStyle("labelRotation", -90); //设置图表的轴线及数据源 lineChart.horizontalAxis=categoryAxis; lineChart.horizontalAxisRenderer=axisRen; lineChart.series=lineSeries;//设置数据源 //增加图示,并设置一些属性 var chartLegend:Legend =new Legend(); chartLegend.width=360; chartLegend.height=48; chartLegend.dataProvider=lineChart; chartLegend.direction="horizontal"; //先放图示再放图表,此处控制顺序 dPanelByGrid.addChild(chartLegend); dPanelByGrid.addChild(lineChart); return dPanelByGrid; }