時間軸上,缺列時畫圖出錯

來源:互聯網
上載者:User

如果時間軸上缺了一列,按周期畫圖會出現錯誤,其情況如下所示:

按正常畫圖,可以看到如下效果:

10-20之間沒有點,是跳變的。這是正確的圖形。

問題一:如圖,1、3列之間缺了第二列,周期性畫圖的時候,20-30,即對應第二列卻化了點,這顯然不合理;

問題二:還存在一個另外的問題是,每個10分點之間都會有跳變。

而以上兩個問題如果第一列和最後一列之間沒有空列的話,就不會出現,這也費解。見下圖:

其他存在的一些問題:

      這裡,在第二個時間點上開始化了放了兩個訊號,也就是0-20,不畫東西,而20-40有,如果按照周期來算,40-60,是不是也該不畫東西,而不是像本圖一樣,按周期畫出來。

解決方案:

代碼如下:

private voidtTicker_Tick(object sender, EventArgs e)        {            int yAssemblyCount = yAssembly.Count;            if (yAssemblyCount > 0)            {                int index = xCount % yAssemblyCount;                int cycleNo = xCount / yAssemblyCount ;                int oneRoundNum = calCulateCycleNo(xAssembly) ; ①                double xValue = (double)(xAssembly[index]+ cycleNo * oneRoundNum);                double yValue = yAssembly[index];                SeriesPoint p = newSeriesPoint(xValue,yValue);                updateGraphDelegate upGraph = this.updateGraph;                this.BeginInvoke(upGraph, p, 0);                SwiftPlotDiagram xyaxis = (SwiftPlotDiagram)chartControl1.Diagram;               xyaxis.AxisX.Range.SetMinMaxValues(xAssembly[index] + cycleNo *oneRoundNum - 60, xAssembly[index] + cycleNo * oneRoundNum + 60);               xCount++;            }            else            {               tTicker.Stop();                MessageBox.Show("沒有點可以畫");            }        }

①    處的代碼出現了點問題,之前函數寫成這樣

private intcalCulateCycleNo(List<double> inputAssembly)        {            int noCnt = 1;            if (inputAssembly.Count == 1)            {               noCnt = 1;            }            else            {                for (int i = 1; i< inputAssembly.Count; i++)                {                   if (inputAssembly[i] != inputAssembly[i- 1])                   {                       noCnt++;                   }                }            }            return noCnt;        }

現在改為:

private intcalCulateCycleNo(List<double> inputAssembly)        {            return (int)inputAssembly[inputAssembly.Count-1];        }

      在這裡應用,上面那個函數返回的是x座標上點的實際數量,而修改之後則返回的是最後一個小標,如Array1 Array2 Array3 如果array2裡面沒填Signal,那麼修改前的函數返回20,修改之後返回最後一個元素的下標,即Array3最後一個元素,下標為30,這樣畫圖就是0-30,30-60,60-90……

      再解釋下為什麼會出現第二幅圖那種現象,由於修改前代碼返回的是周期數為20,那麼第一個周期0-30(如第一幅圖一樣,10-20沒有畫點),而第二個周期開始,就是20-50,第三個周期40-70,這樣每個周期都是有重疊的,故而圖形出現膠著狀態。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.