原創|使用教程|編輯:郝浩|2013-04-25 11:32:59.000|閱讀 637 次
概述:本教程就為大家提供幾種,老牌圖表控件TeeChart Pro VCL可以確保數據繪制速度的方法。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
所謂實時數據圖,就是圖表中的數據與圖表的生成為同一瞬間。當然這是非常理想化的,在現實中,只有提高繪圖速度,盡可能減少測量和繪制數據之間的延遲,本教程就為大家提供幾種,老牌圖表控件TeeChart Pro VCL可以確保數據繪制速度的方法。
以下方法都可以加快繪制實時數據圖的時間:
圖表中的每個元素的繪制都會增加繪制圖表的時間,所以隱藏所有不必要的圖表元素對TeeChart Pro VCL繪制實時數據圖是意義重大的。
可以禁用的不必要元素包括圖表圖例,圖表標題,圖表框架等。
還可以手動定義圖表軸的遞增單位和軸范圍,這樣可以避免被執行的內部calculatation算法過于頻繁。
此外,還可以使用一個從TeeChart V6版本后開始引入的新屬性——TChartAxes.FastCal。把這個屬性設置為True后,他額外的減少圖表的繪制時間。
下面這個代碼示例中就包括上述所提到的所有屬性和方法設置。
  // Prepare chart for maximum speed:
  with Chart1 do
  begin
    ClipPoints := False;
    Title.Visible := False;
    Legend.Visible := False;
    LeftAxis.Axis.Width:=1;
    BottomAxis.Axis.Width:=1;
    BottomAxis.RoundFirstLabel := False;
    View3D := False;
  end;
  // Number of points we'll be displaying
  MaxPoints:=10000;
  // Number of points deleted when scrolling chart
  ScrollPoints := 5000;
  // Prepare series.
  // Disable AutoRepaint and X Order
  // AutoRepaint=False means "real-time" drawing mode.
  // Points are displayed just after adding them,
  // without redrawing the whole chart.
  Series1.AutoRepaint := False;
  // Set Ordering to none, to increment speed when adding points
  Series1.XValues.Order := loNone;
  // Initialize axis scales
  // we're assuming left axis values are within [0,1000]
  Chart1.LeftAxis.SetMinMax(0,10000); 
  Chart1.BottomAxis.SetMinMax(1,MaxPoints);
  // Speed tips:
  // When using only a single thread, disable locking:
  Chart1.Canvas.ReferenceCanvas.Pen.OwnerCriticalSection := nil;
  Series1.LinePen.OwnerCriticalSection := nil;
  // For Windows NT, 2000 and XP only:
  // Speed realtime painting with solid pens of width 1.
  Series1.FastPen := True;
  // Set axis calculations in "fast mode".
  // Note: For Windows Me and 98 might produce bad drawings when
  //       chart zoom is very big.
  Chart1.Axes.FastCalc := True;
					本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉載自:慧都控件網