Repeatedly create Series at Runtime

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Luca
Newbie
Newbie
Posts: 7
Joined: Thu Jun 10, 2021 12:00 am

Repeatedly create Series at Runtime

Post by Luca » Tue May 03, 2022 6:46 am

Hello,
i'm using C++ Builder 10.4.2 with the classic compiler for my 32 bit application. In this application i have a Main Form and a Secondary Form that has a Chart with between 2 to 5 TFastLine Series, the user get to decide the number of Serie and data is different everytime. So everytime the user opens the Secondary Form i need to populate the Chart with these Series, and so everytime the Secondary Form closes i need to free and remove the Series. My code:

Code: Select all

//---------------------------------------------------------------------------
void __fastcall SecondaryForm::FormShow(TObject *Sender)
{
 TFastLineSeries *Sc;
 Chart->Canvas->ReferenceCanvas->Pen->OwnerCriticalSection = NULL;
 for(k=0; k<nSeries; k++)
 { 
 Chart->AddSeries(new TFastLineSeries(Chart)); 
 Sc = dynamic_cast<TFastLineSeries*>(Chart->Series[k]);
 Sc->ParentChart = Chart;
        
 //instruction to speed-up
 Sc->LinePen->Width = 0;
 Sc->LinePen->OwnerCriticalSection = NULL;

 //other code that populate the Series with dynamic array method

}
//---------------------------------------------------------------------------
void __fastcall SecondaryForm::FormClose(TObject *Sender, TCloseAction &Action)
{
      Chart->SeriesList->Clear();   //free and remove Series ??
}
My question is: am i doing right with the code? i have some runtime errors and i think the error may come from this code.

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

Re: Repeatedly create Series at Runtime

Post by Yeray » Wed May 18, 2022 4:45 pm

Hello,

Sorry for the late reply here.
I've done a simple example project to test this and it seems to work without errors for me in RAD 11.1, both with the new and the classic compiler.
CleanSeriesCBuilder.zip
(9.42 KiB) Downloaded 252 times
Please, give it a try at the project above and let us know if it works fine for you.
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