Page 1 of 1
how to let one Annotation responsed to Click or doubleclick
Posted: Wed Jan 07, 2009 8:01 am
by 6919081
i add two annotations on one chart,when click one annotation,how to response with one funciton.
showMessage('this is one annation') or do other things
thanks a lot
Posted: Wed Jan 07, 2009 9:08 am
by narcis
Hi Richard,
You can use its OnClick event, for example:
Code: Select all
procedure TForm1.ChartTool1Click(Sender: TAnnotationTool;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowMessageUser('this is my annotation!');
end;
Posted: Wed Jan 07, 2009 9:27 am
by 6919081
thanks a lot for your response.
i dynamicly add many annotationtool in order to show some text. and how can i dynamicly text.i can't find the property.
do you have other good way to solve this problem that i only want to show some digital numer and text dynamicly.
Posted: Wed Jan 07, 2009 9:43 am
by narcis
Hi Richard,
Yes, you can also assign the event dynamically as shown here:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
ChartTool1.OnClick:=ChartTool1Click;
end;
procedure TForm1.ChartTool1Click(Sender: TAnnotationTool;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
ShowMessageUser(Sender.Text);
end;
Posted: Wed Jan 07, 2009 9:59 am
by 6919081
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.RemoveAllSeries;
Chart1.Tools.Clear;
chart1.tools.add(Tannotationtool);
chart1.tools.add(Tannotationtool);
chart1.tools.add(Tannotationtool);
chart1.tools.add(Tannotationtool);
end;
when i click one annatation ,
how to reponse with mouseEvent. thanks a lot.
Posted: Wed Jan 07, 2009 10:15 am
by narcis
Hi Richard,
I'm sorry but I'm not sure about what you are trying to achieve here. Could you please give us some more details about it?
Thanks in advance.
Posted: Thu Jan 08, 2009 2:48 am
by 6919081
Code: Select all
procedure TMainForm.ResetChart;
var tmpEmpty:TChart;
begin
Chart1.RemoveAllSeries;
Chart1.Tools.Clear;
tmpEmpty:=TChart.Create(nil);
try
tmpEmpty.AllowZoom:=False;
tmpEmpty.AllowPanning:=pmNone;
tmpEmpty.Color:=clWhite;
Chart1.Assign(tmpEmpty);
finally
tmpEmpty.Free;
end;
end;
procedure TMainForm.Button2Click(Sender: TObject);
var
tmpChart:TCustomChart;
begin
ResetChart;
tmpChart:=TCustomChart(Chart1);
LoadchartFromfile(tmpchart,'test.tee');
Chart1:=TChart(tmpChart);
Chart1.BackImage.LoadFromFile('turbine.gif');
chart1.BackImageMode:=pbmCenter;
//chart1.Tools.items[0].onClick ?
end;
chart1.Tools.items[0].onClick ?
There's no this function
thanks a lot for your focusing on this.
I have used the TeeChart office to edit the customized chart(test.tee file),and when I loaded the file ,and I now want to set the Tannotationtool's click property to realize some functions. Can you tee me how to do this.
Posted: Thu Jan 08, 2009 8:32 am
by narcis
Hi Richard,
In that case you need to typecast the tools like this:
Code: Select all
for i:=0 to Chart1.Tools.Count-1 do
if Chart1.Tools.Items[i] is TAnnotationTool then
(Chart1.Tools.Items[i] as TAnnotationTool).OnClick:=ChartTool1Click;
Hope this helps!