I have a form in which I've placed a TChartBook component Data_Man_ChartBook. However, when I try to add a chart to this component using the following:
TCustomChart* tmp;
//Add a new chart to the Data_Man_ChartBook
Data_Man_ChartBook->AddChart();
Data_Man_ChartBook->ActivePageIndex = Data_Man_ChartBook->PageCount - 1;
tmp = Data_Man_ChartBook->ActiveChart();
tmp returns NULL. Any attempt to reference the chart, for example:
Data_Man_ChartBook->ActiveChart()->View3D = false;
gives an error.
What am I doing wrong?
TChartBook->AddChart() returns NULL
Re: TChartBook->AddChart() returns NULL
Found the answer. I used the above code in the initialization of the class:
__fastcall TFrame1::TFrame1(TComponent* Owner)
:TFrame(Owner)
{
//Try to add a chart here
}
That doesn't work. So, I did the following:
__fastcall TFrame1::TFrame1(TComponent* Owner)
:TFrame(Owner)
{
}
void TFrame1::InitFrame ()
{
//Add the chart to the chartbook.
}
.....
__fastcall TMainForm::TMainForm(TComponent *Owner)
: TForm(Owner)
{
Frame11->InitFrame();
...
}
Now it works. I guess the ChartBook isn't created until the entire frame is created. So, DON'T try to add a chart to a chart book inside the initialization of the frame.
Reef
__fastcall TFrame1::TFrame1(TComponent* Owner)
:TFrame(Owner)
{
//Try to add a chart here
}
That doesn't work. So, I did the following:
__fastcall TFrame1::TFrame1(TComponent* Owner)
:TFrame(Owner)
{
}
void TFrame1::InitFrame ()
{
//Add the chart to the chartbook.
}
.....
__fastcall TMainForm::TMainForm(TComponent *Owner)
: TForm(Owner)
{
Frame11->InitFrame();
...
}
Now it works. I guess the ChartBook isn't created until the entire frame is created. So, DON'T try to add a chart to a chart book inside the initialization of the frame.
Reef
Re: TChartBook->AddChart() returns NULL
Hi reef,
Thanks for the feedback. I hope it will help another user.
Thanks for the feedback. I hope it will help another user.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |