Creating DrawLines in code at run time

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Phineas
Newbie
Newbie
Posts: 18
Joined: Wed Apr 09, 2008 12:00 am

Creating DrawLines in code at run time

Post by Phineas » Wed May 13, 2009 11:11 pm

I am having no joy creating a TDrawLineTool and placing it on the chart programmatically.

TrendLineTool := TDrawLineTool.Create(Chart1);
TrendLineTool.ParentChart := Chart1;
TrendLineTool.Series := Series1;
Chart1.Tools.Add(TrendLineTool);
x1 := Series1.CalcXPosValue(Read Saved Position from TInifile);
y1 := Series1.CalcYPosValue(Read Saved Position from TInifile);
x2 := Series1.CalcXPosValue(Read Saved Position from TInifile);
y2 := Series1.CalcYPosValue(Read Saved Position from TInifile);
TDrawLine.CreateXY(TrendLineTool.Lines,x1,y1,x2,y2);
with TrendLineTool do
begin
Name := 'WhatEver';
Pen.Width := 1;
Pen.Color := clRed;
end;

I use the exact same method to create TAnnotationTools and place them on the chart. No Problem. Why are my DrawLines not appearing on the Chart? I have placed the code in the Chart1.OnAfterDraw event. Still no joy.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Thu May 14, 2009 8:17 am

Hi Phineas,

Have you seen the example at All features/Welcome !/Tools/Draw Line/Draw Line Tool? You should find all features demos at teechart's program group.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply