Query related to rectangle tool children.

TeeChart for ActiveX, COM and ASP
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Query related to rectangle tool children.

Post by amol » Tue May 19, 2020 12:30 pm

Hi,

We are currently using Active X 2018. We have added a rectangle tool and are able to add its text, font and children etc. But we are unable to add text to its children.

Following is the code we are currently using

Code: Select all

ui->mChart->Tools()->Add(tcRectangle);
ui->mChart->Tools()->Items(0)->asRectangle()->SetText("Technology - Software - Infrastructure");
ui->mChart->Tools()->Items(0)->asRectangle()->Shape()->Font()->SetSize(12);
ui->mChart->Tools()->Items(0)->asRectangle()->Shape()->SetTransparency(30);
ui->mChart->Tools()->Items(0)->asRectangle()->SetAllowDrag(false);
ui->mChart->Tools()->Items(0)->asRectangle()->SetAllowResize(false);
ui->mChart->Tools()->Items(0)->asRectangle()->SetAutoSize(true);

ui->mChart->Tools()->Items(0)->asRectangle()->Shape()->Children()->Add();
ui->mChart->Tools()->Items(0)->asRectangle()->Shape()->Children()->Item(0)->Shape()->Font()->SetSize(16);
Please guide us as to how we could add text to the children elements too. Our target is to view different text with different font size and colors.

Regards,
Amol

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Query related to rectangle tool children.

Post by Yeray » Fri May 22, 2020 9:09 am

Hello Amol,

You need to cast the Shape child to TCustomTextShape to access the Text property. Ie, this in Delphi:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TRectangleTool(Chart1.Tools.Add(TRectangleTool)) do
  begin
    Text:='Rectangle Tool';
    Shape.Transparency:=10;
    Shape.Font.Color:=clRed;
    Shape.Font.Style:=Shape.Font.Style+[fsBold];
    AutoSize:=True;
    Left:=100;
    Top:=100;

    with Shape.Children.Add do
    begin
      Shape.Font.Color:=clGreen;
      TCustomTextShape(Shape).Text:='Children';
    end;
  end;
end;
Project1_2020-05-22_11-07-09.png
Project1_2020-05-22_11-07-09.png (4.83 KiB) Viewed 31038 times

Sorry, I thought it was VCL. Let me check if this property is mapped in ActiveX.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Query related to rectangle tool children.

Post by Yeray » Fri May 22, 2020 10:41 am

Hello,

Indeed the Text property isn't accessible by code. I've added i to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=2330
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply