Page 1 of 1

Saving & Loading TeeChart defaults

Posted: Mon Apr 21, 2008 11:28 am
by 10048370
I would like for the end user to define the look of there chart using the build in Edit Chart functions. I can save and load OK but when I try to added data after loading the Series1 is no longer defind ie the pointer to Series1 is Null. How do I redefine this so that it will works as it did before loading.

Posted: Mon Apr 21, 2008 1:09 pm
by narcis
Hi bing,

You have 2 options here:

1. Using series index in the chart's series collection, for example:

Code: Select all

Chart1[0].Color:=clRed;
2. Assigning each series to the variable you want after loading the chart, eg.:

Code: Select all

Series1:=Chart1[0];

Posted: Mon Apr 21, 2008 5:32 pm
by 10048370
Hi Narcís

I don't think you have understood if I load a previously save chart series into a current chart the series defined by the loaded graph has a NULL pointer. I can't add new data to the graph.

I added the following lines into the demo progam in the Export SVG to test this as part of your demo software

Code: Select all

//---------------------------------------------------------------------------

void __fastcall TSVGExportForm::Button3Click(TObject *Sender)
{
   SaveChartDialog(Chart1);
   if (OpenDialog1->Execute())
      LoadChartFromFile(dynamic_cast<TCustomChart*>(Chart1),OpenDialog1->FileName);
   
   Series1->FillSampleValues();
  
}
the line Series1->FillSampleValues(); Cause a violation error why???
if i put a watch variable onto Series1 than before load it has a valid pointer after load it has a NULL pointer


Barry

Posted: Tue Apr 22, 2008 10:24 am
by narcis
Hi Barry,

Yes, that's the problem I tried to explain you. In that case, before calling FillSampleValues you need to do this:

Code: Select all

Series1=Chart1->Series[0];
or alternativelly use this:

Code: Select all

Chart1->Series[0]->FillSampleValues();
Hope this helps!

Posted: Tue Apr 22, 2008 12:16 pm
by 10048370
Narcís

Problem solved thanks for your help.