2016-04-25 29 views
1

我使用tchart組件顯示一個任務的進度舊,保持顯示任務的進度,進度,動態顯示,這樣的事情:如何動態地通過清除使用TChart組件

enter image description here

我將底軸的最大值設置爲50,因此當超出此值時,不會顯示圖形。我怎麼能動態地通過清除舊的開始顯示了新的進展繼續顯示任務的進度,我想應該是這樣的:

while Progress do 
begin 
    if series1.bottomaxis.value = maxvalue then 
    Series1.clear; 
end; 
series1.add(x,y); 

好吧,這只是解釋什麼是我想要做的。 那麼如何在不改變最大值的情況下繼續顯示進度?

回答

0

使用新數據填充系列最簡單的解決方案是使用AddXY方法爲一系列添加點。這種方法的一大優點是使用起來非常簡單。如果您實時繪圖並且顯示的點數不超過幾千,這是添加點的首選方法。連同TChartSeries.Delete方法它提供了一個強大的方法來做實時繪圖。在TeeChart示例之一中使用以下兩個例程來執行圖表的實時滾動。首先,常規增加了新的指向系列,第二個常規滾動點作爲新數據添加和刪除舊的不必要點:

// Adds a new random point to Series 
    Procedure RealTimeAdd(Series:TChartSeries); 
    var XValue,YValue : Double; 
    begin 
    if Series.Count=0 then // First random point 
    begin 
     YValue:=Random(10000); 
     XValue:=1; 
    end 
    else 
    begin 
     // Next random point 
     YValue:=Series.YValues.Last+Random(10)-4.5; 
     XValue:=Series.XValues.Last+1; 
    end; 
    // Add new point 
    Series.AddXY(XValue,YValue); 
    end; 

    // When the chart is filled with points, this procedure 
    // deletes and scrolls points to the left. 
    Procedure DoScrollPoints(Series: TChartSeries); 
    var tmp,tmpMin,tmpMax : Double; 
    begin 
    // Delete multiple points with a single call. 
    // Much faster than deleting points using a loop. 

    Series.Delete(0,ScrollPoints); 

    // Scroll horizontal bottom axis 
    tmp := Series.XValues.Last; 
    Series.GetHorizAxis..SetMinMax(tmp-MaxPoints+ScrollPoints,tmp+ScrollPoints); 

    // Scroll vertical left axis 
    tmpMin := Series.YValues.MinValue; 
    tmpMax = Series.YValues.MaxValue; 

    Series.GetVertAxis.SetMinMax(tmpMin-tmpMin/5,tmpMax+tmpMax/5); 

    // Do chart repaint after deleting and scrolling 
    Application.ProcessMessages; 
    end; 

有關實時更詳細的信息圖表,請閱讀文章here

+0

只有一個鏈接到一個非現場位置的答案是不可接受的。如果該非現場位置不可用,則依賴於該位置的答案將失去所有價值。該場外內容的相關部分應在此處,在答案本身中,將該鏈接用作附加參考。如果這是不可能的,那麼這應該是對問題的評論,因爲它不是一個答案。 –

+0

@KenWhite好的,我在這裏根據這個問題在本文中介紹了最相關的部分。 –