Erreur when loading chart file

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Erreur when loading chart file

Post by Calou » Mon Nov 23, 2009 10:10 am

Hello,

Here is the code to save charts to file

Code: Select all

      SaveChartToFile(ChrtProdSynthese,frmMain.PathAppli+'Config\GraphSynthese0.tee',FALSE);
      SaveChartToFile(ChrtDispoSynthese,frmMain.PathAppli+'Config\GraphSynthese1.tee',FALSE);
      SaveChartToFile(ChrtVitSynthese,frmMain.PathAppli+'Config\GraphSynthese2.tee',FALSE);
      SaveChartToFile(ChrtRealTheoSynthese,frmMain.PathAppli+'Config\GraphSynthese3.tee',FALSE)
Here is the code to load the charts

Code: Select all

  SetLength(frmMain.ChrtModel,4);
  //si un fichier de config des courbes existe on le charge
  for i := 0 to High(frmMain.ChrtModel) do
  begin
    if FileExists(frmMain.PathAppli+'Config\GraphSynthese'+IntToStr(i)+'.tee') then
    begin
      frmMain.ChrtModel[i]:=TChart.Create(self);
      LoadChartfromFile(frmMain.ChrtModel[i],frmMain.PathAppli+'Config\GraphSynthese'+IntToStr(i)+'.tee');
    end;
  end;
When the loadchartfromfile is called with i=1 i have the message "components named _1 already exists"

I don't understand why ?

Thanks for help

Regards

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Mon Nov 23, 2009 12:10 pm

I have done some other tests.

The error occur only when i use the TADVStringGrid (version 5) from TMSSoftware.

You can do a simple exampe. If you call loadchartfromfile with a TadvSTringgrid on the form it crashes

Regards

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

Re: Erreur when loading chart file

Post by Yeray » Mon Nov 23, 2009 12:21 pm

Hi Calou,

I've been doing some tests to try to reproduce the error but couldn't. Here is the complete demo example I've been testing with:

Code: Select all

uses Chart, Series, TeeStore, TeeEditPro;

var Charts: array[0..3] of TCustomChart;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to length(Charts)-1 do
  begin
    Charts[i]:=TChart.Create(self);
    Charts[i].Parent:=Form1;

    Charts[i].Left:=Charts[i].Width*(i mod 2);
    Charts[i].Top:=Charts[i].Height*(i div 2);

    case i of
      0: Charts[i].AddSeries(TPointSeries.Create(self));
      1: Charts[i].AddSeries(TBarSeries.Create(self));
      2: Charts[i].AddSeries(TLineSeries.Create(self));
      else
       Charts[i].AddSeries(TFastLineSeries.Create(self));
    end;

     Charts[i][0].FillSampleValues();
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  for i:=0 to length(Charts)-1 do
    SaveChartToFile(Charts[i],'C:\tmp\Chart' + inttostr(i) + '.tee',true,true);
end;

procedure TForm1.Button2Click(Sender: TObject);
var i: Integer;
    FileName: string;
begin
  for i := 0 to length(Charts)-1 do
  begin
    FileName:='C:\tmp\Chart' + inttostr(i) + '.tee';
    if FileExists(FileName) then
    begin
      Charts[i]:=TChart.Create(self);
      Charts[i].Parent:=Form1;

      Charts[i].Left:=Charts[i].Width*(i mod 2);
      Charts[i].Top:=Charts[i].Height*(i div 2);

      LoadChartfromFile(Charts[i],FileName);
    end;
  end;
end;
As you say, this could be due to another component compatibility problem. Please check if you can obtain a simple string from the TADVStringGrid, if there are related problems with that component and if you can reproduce the error without using TeeChart or without TadvSTringgrid.
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

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Mon Nov 23, 2009 12:58 pm

I have tested your example

Without the ADVSTringGrid no error. With the ADVStringGrid there is the error (name _1)
After called the LoadChartFromfile Function, without AdvStringGrid the name of charts (Charts.name) is '' and with the AdvStringGrid it is '_1'
It is the same behavior if charts is not an array

Thanks for help

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Mon Nov 23, 2009 1:39 pm

I am not able to reproduce this behavior with only AdtStringGrid.
Let me know if you want that i do others tests

Regards

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Tue Nov 24, 2009 8:45 am

Hello,

Have you found something? Sorry to insist but my developpement is stopped now :oops:

Thanks for feedback

Regards

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

Re: Erreur when loading chart file

Post by Yeray » Tue Nov 24, 2009 3:56 pm

Hi Calou,

I've been testing this and yes, it seems that having a TAdvStringGrid in the same form than a Chart, makes the following code to crash the second time the button is pressed (the second time the chart is imported).

But I've also found that freeing the chart variable seems to solve the problem:

Code: Select all

uses Chart, Series, TeeStore, TeeEditPro;

var Chart1: TCustomChart;
    FileName: string;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1:=TChart.Create(self);
  Chart1.Parent:=Self;
  Chart1.AddSeries(TPointSeries.Create(self));
  Chart1[0].FillSampleValues();

  FileName:='C:\tmp\Chart1.tee';

  SaveChartToFile(Chart1,FileName,true,true);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  //Chart1.Free;  //This seems to solve the problem when a TAdvStringGrid is in the form

  if FileExists(FileName) then
  begin
    Chart1:=TChart.Create(self);
    Chart1.Parent:=Self;
    LoadChartfromFile(Chart1,FileName);
  end;
end;
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

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Tue Nov 24, 2009 4:24 pm

hello,

I have modified your example like this :

Code: Select all

procedure TForm1.Button2Click(Sender: TObject);
var i: Integer;
    FileName: string;
begin
  for i := 0 to length(Charts)-1 do
  begin
    FileName:='C:\tmp\Chart' + inttostr(i) + '.tee';
    if FileExists(FileName) then
    begin
      Charts[i].free;//for test with advstringgrid

      Charts[i]:=TChart.Create(self);
      Charts[i].Parent:=Form1;

      Charts[i].Left:=Charts[i].Width*(i mod 2);
      Charts[i].Top:=Charts[i].Height*(i div 2);

      LoadChartfromFile(Charts[i],FileName);
    end;
  end;
end;
But i always have the error

Thanks

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Wed Nov 25, 2009 3:47 pm

Hello,

I am very sorry to insist :oops: but have you find something to correct the problem?

Thank you very much for the feedback

Regards

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

Re: Erreur when loading chart file

Post by Yeray » Wed Nov 25, 2009 4:04 pm

Hi Calou,

We will study the problem and to be back to you asap. If you want, you can get priority support.
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

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Wed Nov 25, 2009 4:07 pm

Many thanks Yeray

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

Re: Erreur when loading chart file

Post by Yeray » Wed Nov 25, 2009 4:37 pm

Hi Calou,

Adding the following line in the for loop, just before the LoadChartFromFile call, seems to solve the problem. Could you please verify it?

Code: Select all

Charts[i].Name:='Chart' + inttostr(i);
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

Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Re: Erreur when loading chart file

Post by Calou » Wed Nov 25, 2009 5:10 pm

I will do more tests tomorrow but it seems to be good

Many thanks

Post Reply