Page 1 of 1

Adding a Shape in code

Posted: Sun Jul 03, 2005 9:07 pm
by 9231397
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

Posted: Mon Jul 04, 2005 8:25 am
by narcis
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.