Page 1 of 1

Saving/Loading-Chart - Legend.Visible Problem

Posted: Fri Jul 01, 2005 8:34 am
by 9237041
Hello!

I'm using Delphi 4 and TeeChart Pro 7.04

I have a problem with saving the Chart.Legend.Visible property to the chart.

I'm doing the following:
1) Creating my chart at runtime, the legend is hidden for default
2) Then I save the chart to a file with the editor (export), for example xy.tee (with invisible legend)
3) After saving, I set Chart.Legend.Visible = TRUE, the legend in the chart appears.
4) Now I load the chart from the file xy.tee (with invisible legend), but the legend still appears.

Is the property stored in the file, or not? What I'm doing wrong? :cry:

THX

Posted: Fri Jul 01, 2005 11:00 am
by narcis
Hello ghisa,

It works fine here using the code below. Could you please check if this work for you? Please feel free to modify it or send an example we can "as-is" to reproduce the problem here.

You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  tmpSeries:TLineSeries;
begin
  tmpChart:=TChart.Create(self);
  tmpChart.Parent:=self;

  tmpSeries:=TLineSeries.Create(self);
  With tmpSeries do
  begin
    ParentChart:=tmpChart;
    Randomize;
    FillSampleValues();
  end;

  tmpChart.Legend.Visible:=false;
end;

procedure TForm1.CheckBox1Click(Sender: TObject);
begin
   tmpChart.Legend.Visible := not tmpChart.Legend.Visible;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   SaveChartToFile(tmpChart, 'mychart.tee');
   tmpChart.Legend.Visible:=true;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   LoadChartfromFile(TCustomChart(tmpChart), 'mychart.tee');
end;

Posted: Fri Jul 01, 2005 11:26 am
by 9237041
Hello narcis!

I've tried your example. There's the same problem, it works only in one way.
If the chart.legend is hidden and I save the chart to a file (without legend, I have controlled it with TeeChartOffice) and load it into the chart on the form with visible legend, the legend disapperas. Thats ok.

But in the other way, it doesn't work. I save the chart with legend (VISIBLE) and load it into the chart on the form without legend, the legend doesn't appear.

When I take a look into the file with TeeChartOffice, the legend is saved in the chart.

Please also try this way (saving with legend), and tell me if this works for you.

I think this is a bug in the TChart.

THX

Posted: Fri Jul 01, 2005 11:43 am
by narcis
Hi Ghisa,

Yes, it works for me in both ways. If I export the chart with the legend it is imported if is not exported then it's not imported.

I've already attached the application I used and works for me at the attachments newsgroup.

Posted: Fri Jul 01, 2005 12:01 pm
by 9237041
Hi narcis!

I've downloaded your application and compiled it.

I do the following:

1) Run the application
2) Click on "Legend Visible"-Checkbox (now it is checked, legend visible)
3) Click on Button1
4) Click on "Legend Visible"-Checkbox (now it is not checked, legend unvisible)
5) Click on Button2

Now the legend should appear, but it doesn't.
In the mychart.tee-file there is the legend.

I'm desperated.

Do you know a way out?

THX a lot!

With best regards

Posted: Fri Jul 01, 2005 12:45 pm
by narcis
Hi Ghisa,

I've been able to reproduce the problem following your steps. I've modified slightly the import code so that it works now:

Code: Select all

procedure TForm1.Button2Click(Sender: TObject);
var
   tmpChart2: TCustomChart;
begin
    tmpChart.Free;   //assuming Chart1 is already on the Form
    tmpChart2:=TChart.Create(Self);

    LoadChartfromFile(tmpChart2, 'mychart.tee');
    tmpChart := tmpChart2 as TChart;
    tmpChart.Parent:=Self;
end;
I'm going to post the updated version at attachments newsgroups. BTW: Sorry for not having set a self explainatory text at the buttons :wink:.

Posted: Fri Jul 01, 2005 1:17 pm
by 9237041
Hi narcis!

I've changed the source of Button2 as you have written. Now it works!!!!!

Thanks a lot for your help!!!!!!!!!!!!!!!!!!

:D :D :D :D :D :D :D :D :D


Wish you a nice day!!!

Best regards

Posted: Fri Jul 01, 2005 1:36 pm
by narcis
Hi Ghisa,

You're welcome. I'm glad to hear now it works for you.

Thanks, have a nice day and weekend!