Adding a Shape in code

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
seanmurphy
Newbie
Newbie
Posts: 48
Joined: Fri Mar 12, 2004 5:00 am

Adding a Shape in code

Post by seanmurphy » Sun Jul 03, 2005 9:07 pm

I have the code

var
myrig:tchartshape;

then..
myrig:=Tchartshape.Create(chart);
chart.AddSeries(myrig);
myrig.Title:='Myrig';
Myrig.ShowInLegend := True;
Myrig.Marks.Visible := true;
myrig.SeriesColor:=clred;
myrig.XValues[0]:=X1;
myrig.XValues[0]:=Y1;
myrig.Style:=chasCircle;


this creates the object and adds it to my chart legend okay, but I can't find hw to draw the object on the chart. I want to draw the object as a circle at point X, Y with a given radius.

How do I do this please?

cheers
Sean

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

Post by Narcís » Mon Jul 04, 2005 8:25 am

Hi Sean,

You could do something like:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  myrig:tchartshape;
begin
  myrig:=Tchartshape.Create(self);
  chart1.AddSeries(myrig);
  myrig.Title:='Myrig';
  Myrig.ShowInLegend := True;
  Myrig.Marks.Visible := true;
  myrig.SeriesColor:=clred;
  myrig.X0:=10;
  myrig.Y0:=10;
  myrig.X1:=0;
  myrig.Y1:=20;
  myrig.Style:=chasCircle;
end;
According to TeeChart help and referring to X0,Y0, X1 and Y1:

These properties define the Top - Left and Bottom - Right coordinates of the englobing TChartShape rectangle.

The values should be expressed in Axis coordinates.

You can convert from Screen pixel coordinates to values and vice-versa using several TChart and TChartSeries methods like XScreenToValue and YScreenToValue.
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

Post Reply