Page 1 of 1
Creating a TChartShape at Runtime
Posted: Mon May 07, 2007 5:30 am
by 9343745
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
Posted: Mon May 07, 2007 7:51 am
by narcis
Hi madup,
What you request is shown
here.
Posted: Mon May 07, 2007 8:06 am
by 9343745
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
Posted: Mon May 07, 2007 8:24 am
by narcis
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;
Posted: Mon May 07, 2007 8:37 am
by 9343745
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
Posted: Mon May 07, 2007 9:08 am
by narcis
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.