Page 1 of 1

Creating DrawLines in code at run time

Posted: Wed May 13, 2009 11:11 pm
by 10548832
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.

Posted: Thu May 14, 2009 8:17 am
by yeray
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.