【问题标题】:Delphi7 TeeChart v4 Legend - How to Scroll?Delphi7 TeeChart v4 Legend - 如何滚动?
【发布时间】:2014-02-13 20:37:10
【问题描述】:

我有一个 TChart(Delphi IDE 中包含 Steema TeeChart)组件,它可能有多达 64 个图表系列(在我的例子中是堆叠区域)。我需要在图表中显示所有现有系列,但不幸的是,传奇并没有显示所有现有系列,只有 10-16 中的一些第一个(见图)。

是否有可能以某种方式滚动传奇来查看所有现有系列? 如果不是直接可能有一些解决方法?

使用 Delphi7, Chart v4

【问题讨论】:

    标签: delphi charts delphi-7 vcl teechart


    【解决方案1】:

    这仅适用于 TeeChart 专业版。为此,它包括 Legend ScrollBar 工具 (TLegendScrollBar)。全功能评估版可在here下载。

    【讨论】:

    • 谢谢@Narcís Calvet,但也许有一些解决方法?另外请给我一个链接,如果可能的话,如何安装Delphi7 PRO版本的说明,因为我没有找到它,但发现其他人因为旧版本(包含在Delphi7中)而出现了一些问题
    • 一般来说,专业版安装程序可以毫无问题地备份和卸载 IDE 附带的标准版。如果您发现任何问题,请联系支持团队 (steema.com/licensing/support/?steema/licensing_support)。关于图例滚动的解决方法,您是否尝试过此处建议的解决方案? stackoverflow.com/a/21315439/509369
    • 嗨@Yeray,谢谢。我会尝试安装。关于你提到的解决方法 - 我试过它并且它正在工作,而且它是我写的:),但我问是否有人有其他的,也许是更好的解决方案:)
    【解决方案2】:

    这是我自己的实现,基于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 windows消息。方法在这里: http://delphi.about.com/od/delphitips2010/qt/delphi-redirect-mouse-wheel-control-under-the-mouse.htm 或这里:http://delphi.about.com/od/delphitips2010/qt/timage-handling-mouse-wheel-messages.htm

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多