Creating a TChartShape at Runtime

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
madup
Newbie
Newbie
Posts: 28
Joined: Fri Oct 07, 2005 4:00 am

Creating a TChartShape at Runtime

Post by madup » Mon May 07, 2007 5:30 am

I have a Chart that I want to add a TChartShape at runtime.
I have been able to do this, in an event handler. I can later alter the Shape's
proerties, by calling it form the SeriesList, My only issue is I have to know the
correct index. All is well until I remove a series and now the known index is not correct.
What is the best method to
1) Create the Shape at runtime
2) Be able to reference this shape elsewhere in the program ?

I am using TChartPro 7.08
Delphi 7 Ent

Thanks for your help

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 May 07, 2007 7:51 am

Hi madup,

What you request is shown here.
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

madup
Newbie
Newbie
Posts: 28
Joined: Fri Oct 07, 2005 4:00 am

Post by madup » Mon May 07, 2007 8:06 am

Hi Narcis,
Thanks for the reply
For the attached post, i have gotten that far,
Maybe I'm making this harder than it is. After I have created the Shape, let's say the chart gets scrolled, now I want to reposition the shape created above.
What is the best method to reference this Shape ?
Thanks Again
Mike

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 May 07, 2007 8:24 am

Hi Mike,

You have several options:

1. If nothing specific to TChartShape type needs to be done you can use the series index, for example: Chart1[ShapeIndex].Active=true;

2. You can declare the series variable in the unit's private section so you can use it anywhere in the unit.

3. Type cast the series:

Code: Select all

  (Chart1[0] as TChartShape).Style:=chasRectangle;
4. Loop through the chart's series collection and check whether they are shape series or not:

Code: Select all

  for i:=0 to Chart1.SeriesCount-1 do
    if Chart1[i] is TChartShape then
    begin
      //Do something
    end;
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

madup
Newbie
Newbie
Posts: 28
Joined: Fri Oct 07, 2005 4:00 am

Post by madup » Mon May 07, 2007 8:37 am

Hi Narcis
Thanks once more.
I guess in the end I was looking for a method that didn't require looping thru a list. With the list if there is more than 1 shape, you need to check another property to make sure you have the correct shape.

The series variable I think limits the number of shapes ?

Again Thanks for the help
Regards
Mike

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 May 07, 2007 9:08 am

Hi Mike,
The series variable I think limits the number of shapes ?


No, but if you may need one variable for each shape. You could also use an array of TChartShape or even an array containing records with TChartShape and some other field to mark series as you wish.
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