0
我有一個折線圖,帶有dateTime軸。我通過actionscript將數據提供者設置爲該線圖。圖形繪製完成。當我爲數據提供者分配一個空值以使圖形變爲空時,就會出現問題。清除/清空Flex中的lineChart
實際代碼類似於下面的代碼:
var actualValues:XMLList=flowChartDP.upFlows;
var localSeries1:LineSeries = new LineSeries();
localSeries1.dataProvider = actualValues;
localSeries1.yField = "flow";
localSeries1.xField = "time";
localSeries1.setStyle("form","curve");
var currentSeries1:Array =lineChart.series;
currentSeries1.push(localSeries1);
lineChart.series = currentSeries1;
var actualValues2:XMLList=flowChartDP.downFlows;
var localSeries2:LineSeries = new LineSeries();
localSeries2.dataProvider = actualValues2;
localSeries2.yField = "flow";
localSeries2.xField = "time";
localSeries2.setStyle("form","curve");
var currentSeries2:Array =lineChart.series;
currentSeries2.push(localSeries2);
lineChart.series = currentSeries2;
而且我會在samefashion到lineChart.Although正好被增加了兩個系列我想不會writung代碼這個作品的最好方式精細。 問題在於重置圖形。
我有一個按鈕,當點擊時: lineChart.dataprovider = null; lineChart.series = null;
但我的flash播放器(FP 10調試版)拋出了以下錯誤
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.charts::AxisRenderer/measureHorizontalGutters()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\AxisRenderer.as:2275]
at mx.charts::AxisRenderer/calcRotationAndSpacing()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\AxisRenderer.as:1889]
at mx.charts::AxisRenderer/adjustGutters()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\AxisRenderer.as:1565]
at mx.charts.chartClasses::CartesianChart/updateAxisLayout()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\chartClasses\CartesianChart.as:2133]
at mx.charts.chartClasses::CartesianChart/updateDisplayList()[E:\dev\4.0.0\frameworks\projects\datavisualization\src\mx\charts\chartClasses\CartesianChart.as:1391]
at mx.core::UIComponent/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:8531]
at mx.managers::LayoutManager/validateDisplayList()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:663]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:736]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
什麼解決的辦法?它不會拋出錯誤時
lineChart.series=null;
被刪除。但聲明
lineChart.dataprovider=null;
不使圖表爲空。
我正在創建一系列關於流動的流程並將數據提供者分配給該系列。 – Arun
無論是在運行時動態創建還是設置,除非Flex中存在一個缺陷,這兩者都應該像工作一樣。所有這些代碼無論如何都會在編譯時轉換爲ActionScript。你能用相關的代碼更新你的問題嗎?顯示按鈕的代碼。 –
數據提供者是XMLList 對象。例如var actualValues:XMLList = flowChartDP.flows; var localSeries1:LineSeries = new LineSeries(); localSeries1.dataProvider = actualValues; localSeries1.yField = 「流」; localSeries1.xField =「time」; localSeries1.setStyle(「form」,「curve」); var currentSeries1:Array = lineChart.series; currentSeries1.push(localSeries1); lineChart.series = currentSeries1; – Arun