Hello,
TChart can't be cloned with Clone() Function?
The exception shows that "The TChart class can't be found"..
TChart can't be cloned with Clone() Function?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: TChart can't be cloned with Clone() Function?
Hi elmec,
Are you adding FMXTee.Chart unit to your project's uses section? Code below works fine for me.
If the problem persists please attach a simple example project we can run "as-is" to reproduce the problem here.
Thanks in advance.
Are you adding FMXTee.Chart unit to your project's uses section? Code below works fine for me.
Code: Select all
uses
FMXTee.Chart;
procedure TForm2.FormCreate(Sender: TObject);
var Chart1,Chart2: TChart;
begin
Chart1:=TChart.Create(Self);
Chart2:=(Chart1.Clone(Self) as TChart);
end;
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: TChart can't be cloned with Clone() Function?
The example project.
- Attachments
-
- CopyChart.zip
- (74.6 KiB) Downloaded 519 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: TChart can't be cloned with Clone() Function?
Hi elmec,
C++ Builder needs to call RegisterClass befor calling Clone:
If there were series on tha chart you should also use:
C++ Builder needs to call RegisterClass befor calling Clone:
Code: Select all
void __fastcall TForm12::btnCopyClick(TObject *Sender)
{
RegisterClass(__classid(TChart));
TChart* chartcopyed = (TChart*)(Chart1->Clone(Chart1));
chartcopyed->Parent = this;
chartcopyed->Align = TAlignLayout::alClient;
}
Code: Select all
#pragma link "FMXTee.Series"
RegisterTeeStandardSeries();
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: TChart can't be cloned with Clone() Function?
After the follow code added,
The TChart gets to OK, but the series still failed to be cloned.
Code: Select all
RegisterClass(__classid(TChart));
RegisterTeeStandardSeries();
- Attachments
-
- CopyChart.zip
- (81.7 KiB) Downloaded 572 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: TChart can't be cloned with Clone() Function?
Hi elmec,
Actually series are being cloned. What is not cloned is their data. You should manually do that using AssignValues:
Actually series are being cloned. What is not cloned is their data. You should manually do that using AssignValues:
Code: Select all
void __fastcall TForm12::btnCopyClick(TObject *Sender)
{
TChart* chartcopyed = (TChart*)(Chart1->Clone(this));
chartcopyed->Parent = this;
chartcopyed->Align = TAlignLayout::alClient;
for (int i = 0; i < Chart1->SeriesCount(); i++) {
chartcopyed->Series[i]->AssignValues(Chart1->Series[i]);
//Code to clone series
//CloneChartSeries(Chart1->Series)->ParentChart=chartcopyed;
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: TChart can't be cloned with Clone() Function?
Hello Narcís ,
It works!
Thank you so much!
BTW, is it a bug or just Tchart's behavior?
It works!
Thank you so much!
BTW, is it a bug or just Tchart's behavior?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: TChart can't be cloned with Clone() Function?
Hi elmec,
You're welcome.elmec wrote:Hello Narcís ,
It works!
Thank you so much!
This is as designed.elmec wrote:Hello Narcís ,
BTW, is it a bug or just Tchart's behavior?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |