Adding Line to Chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Adding Line to Chart

Post by McMClark » Wed Feb 11, 2009 2:11 pm

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?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Feb 11, 2009 3:06 pm

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!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Post by McMClark » Wed Feb 11, 2009 7:00 pm

Thanks

Post Reply