Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 236

Summary: [TV52016346] TLegendPaletteTool does not serialize: procedure TForm1.InitializeCh...
Product: VCL TeeChart Reporter: christopher ireland <chris>
Component: ChartAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED NOTABUG    
Severity: major CC: david
Priority: Normal    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Chart Series: --- Delphi / C++ Builder RAD IDE Version:
Attachments: LegendPalette_Serialization example

Description christopher ireland 2013-11-20 10:33:52 EST
TLegendPaletteTool does not serialize:
procedure TForm1.InitializeChart;
var Series1:TSurfaceSeries;
var Tool1: TLegendPaletteTool;
begin
  Series1 := TSurfaceSeries.Create(self);
  Chart1.AddSeries(Series1);
  Chart1.View3D:=true;
  Tool1 := TLegendPaletteTool.Create(self);
  Chart1.Tools.Add(Tool1);
  Tool1.Series:=Series1;
  //Tool1.Chart.Axes.Visible:=false;
  Series1.FillSampleValues();
end;

procedure TForm1.Button2Click(Sender: TObject);
var Stream1: TMemoryStream;
begin
  Stream1:=TMemoryStream .Create();
  SaveChartToStream(Chart1, Stream1);
  Stream1.Position:=0;
  LoadChartFromStream(TCustomChart(Chart2), Stream1);
end; [created:2012-09-19T16:55:18.000+01:00 reported by:chris@steema.com reported in version:]
Comment 1 david berneda 2013-12-19 13:39:17 EST
The problem is the LegendPalette "Series" property, when deserialized, is not correctly assigned, so LegendPalette Series remains nil.

A workaround fix is to reset Series after loading the chart:

  LoadChartFromStream(Chart2, Stream1);

  (Chart2.Tools[0] as TLegendPaletteTool).Series:=Chart2[0];
Comment 2 david berneda 2013-12-19 13:48:48 EST
Found the problem. 
Series was not being serialized because RTL mechanism implies Components need a Name to be able to serialize / deserialize.

Setting Series1.Name:='Series1' works fine.

I've attached a reproduceable project.
Comment 3 david berneda 2013-12-19 13:50:02 EST
Created attachment 62 [details]
LegendPalette_Serialization example