2014-01-23 48 views
3

我有一個TChart(斯蒂馬TeeChart包含在Delphi IDE)組件,它可能有多達64個圖表系列(在我的情況下,堆積區)。我需要在圖表中顯示所有現有的系列,但不幸的是,Legend並未顯示現有的所有系列,只有其中的第一個10-16(請參見圖片)。 Chart with 64 seriesDelphi7 TeeChart v4圖例 - 如何滾動?

是否有可能以某種方式滾動傳說查看所有現有的系列? 如果不是直接也許有些解決方法?

使用Delphi7,圖表v4

回答

1

這是根據我自己的實現,對TChart.OnMouseWheel事件,模擬傳說滾動(它是滾動的,但沒有任何滾動條 - 也許這將是未來的任務):

procedure TForm1.Chart1MouseWheel(Sender: TObject; Shift: TShiftState; 
    WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 

    function GetChartActiveSeriesCount(aChart: TChart): Integer; 
    var 
    iIdx: Integer; 
    begin 
    Result := 0; 
    for iIdx := 0 to aChart.SeriesCount-1 do 
    begin 
     if aChart.Series[iIdx].Active = True then 
     Inc(Result); 
    end; 
    end; 

var 
    lCliMousePos: TPoint; 
    lActiveCount: Integer; 
    lChart: TChart; 
begin 
    lChart := TChart(Sender); 
    lCliMousePos := lChart.ScreenToClient(MousePos); 
    if PtInRect(lChart.Legend.RectLegend, lCliMousePos) then 
    begin 
    if WheelDelta > 0 then 
    begin 
     if lChart.Legend.FirstValue > 0 then 
     lChart.Legend.FirstValue := lChart.Legend.FirstValue-1; 
    end 
    else 
    begin 
     lActiveCount := GetChartActiveSeriesCount(lChart); 
     if (lChart.Legend.FirstValue + lChart.Legend.NumRows) < lActiveCount then 
     lChart.Legend.FirstValue := lChart.Legend.FirstValue+1; 
    end; 
    end; 
    Handled := True; 
end; 

也有一些技巧如何觸發TChart.OnMouseWheel事件,因爲Tchart無法獲得焦點,因此需要使用主窗體OnMouseWheel事件或WM_MOUSEWHEEL窗口消息進行播放。 HowTos here: http://delphi.about.com/od/delphitips2010/qt/delphi-redirect-mouse-wheel-control-under-the-mouse.htm or here:http://delphi.about.com/od/delphitips2010/qt/timage-handling-mouse-wheel-messages.htm

1

這隻適用於專業版的TeeChart。它包括用於此目的的Legend ScrollBar工具(TLegendScrollBar)。功能齊全的評估版可以下載here

+0

謝謝,@NarcísCalvet,但也許有一些解決方法? 也請給我一個鏈接,如果可能的話,如何指導安裝PRO7 for Delphi7,因爲我沒有找到它,但發現其他人因爲舊版本(包含在Delphi7中)有一些問題 – ALZ

+1

一般,Pro版本安裝程序備份並卸載IDE隨附的標準版本沒有問題。如果您發現任何問題,請聯繫支持團隊(https://www.steema.com/licensing/support/?steema/licensing_support)。關於圖例滾動的解決方法,您是否嘗試過在此處建議的解決方案? http://stackoverflow.com/a/21315439/509369 – Yeray

+0

Hi @Yeray,謝謝。我會嘗試安裝。 關於你提到的解決方法 - 我試過了,它的工作,而且它是由我寫的:),但我問是否有其他人,也許更好的解決方案:) – ALZ