Page 1 of 1

Adding Line to Chart

Posted: Wed Feb 11, 2009 2:11 pm
by 9337074
I am using Delphi 2006 Professional with Teechart Pro 7.12. I have a dbChart filled with lines series. I want to allow the user to set a threshold line on the chart. I want to have the user select a number within the Y axis range and have a horizontal line appear in the dbChart. Can anyone guide me how I could programmatically have that line added to the chart?

Posted: Wed Feb 11, 2009 3:06 pm
by narcis
Hi McMClark,

Yes, you can use a TColorLineTool for that, for example:

Code: Select all

uses TeeTools;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var ColorLine1: TColorLineTool;
begin
  ColorLine1:=TColorLineTool.Create(self);
  Chart1.Tools.Add(ColorLine1);
  ColorLine1.Axis:=Chart1.Axes.Left;
  ColorLine1.AllowDrag:=false;
  ColorLine1.Pen.Color:=clRed;
  ColorLine1.Value:=Chart1.Axes.Left.CalcPosPoint(Y);
end;
Hope this helps!

Posted: Wed Feb 11, 2009 7:00 pm
by 9337074
Thanks