当鼠标在CHART的SERIES中移动的时候,如何把该点的数据以hint的形式显示出来?(100分)

  • 主题发起人 主题发起人 wsz1220
  • 开始时间 开始时间
W

wsz1220

Unregistered / Unconfirmed
GUEST, unregistred user!
我的目的:在已经生成的线状图中,移动鼠标,在label中显示离鼠标最近的折点的数值。
请大家帮忙!
TEECHART PRO6 的说明中有如下解释:
All Series styles now provide OnMouseEnter and OnMouseLeave events.
These events are triggered when the mouse enters and exits a series point.
Move the mouse over points to test...
并有一些代码:
unit Series_MouseEnter;
{$I TeeDefs.inc}
interface
uses
{$IFNDEF LINUX}
Windows, Messages,
{$ENDIF}
SysUtils, Classes,
{$IFDEF CLX}
QGraphics, QControls, QForms, QDialogs, QStdCtrls, QExtCtrls,
{$else
}
Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
{$ENDIF}
Base, Series, TeEngine, TeeProcs, Chart;
type
TSeriesMouseEnter = class(TBaseForm)
Series1: TBarSeries;
Series2: TLineSeries;
Label1: TLabel;
procedure Series1MouseLeave(Sender: TObject);
procedure Series1MouseEnter(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

implementation
{$IFNDEF CLX}
{$R *.dfm}
{$else
}
{$R *.xfm}
{$ENDIF}
procedure TSeriesMouseEnter.Series1MouseLeave(Sender: TObject);
begin
Label1.Caption:='';
end;

procedure TSeriesMouseEnter.Series1MouseEnter(Sender: TObject);
var tmp : TChartSeries;
clicked : Integer;
begin
tmp:=Sender as TChartSeries;
// Sender is the Series
// Obtain point index under mouse cursor
clicked:=tmp.GetCursorValueIndex;
// Show Series name and point index and value
Label1.Caption:='Series: '+tmp.Name+
' point: '+IntToStr(clicked)+
' value: '+tmp.YValues.ToString(clicked);
end;

initialization
RegisterClass(TSeriesMouseEnter);
end.

我在DELPHI7中调试,根本没有任何反映,郁闷中..
 
你上面说的情况我没研究过。
你可以这样来完成你的要求。使用Tools TMarksTipTool。
在编辑TeeChart时选择tools工具,add Mark Tips 然后作点简单的设置就行了
 
試一下tchart的onClickAxis事件和onClickSeries事件,GetAxisLabel事件中取值...
 
后退
顶部