Creating DrawLines in code at run time
Posted: 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.
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.