Problems using Load-/SaveChartToFile with TMapSeries
Posted: Wed Jun 28, 2006 11:10 am
Hi,
I have created a TMapSeries with some polygons, in this test case a square, what I would like to do is to save the chart with the TMapSeries and its corresponding polygon to file and then load it again. What seems to occur is that the TMapSeries is there but the polygon points doesnt appear after LoadChartFromFile. See the test code below:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, TeCanvas,
Dialogs, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Series, TeeStore, TeeMapSeries;
type
TForm1 = class(TForm)
Chart1: TChart;
btnCreate: TButton;
btnLoad: TButton;
procedure btnCreateClick(Sender: TObject);
procedure btnLoadClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnCreateClick(Sender: TObject);
var
ASerie: TMapSeries;
APol: TTeePolygon;
i: integer;
begin
ASerie:=TMapSeries.Create(Chart1);
ASerie.ParentChart:=Chart1;
APol:=ASerie.Shapes.Add;
with APol.Points do
begin
AddXY(1,1);
AddXY(1,10);
AddXY(10,10);
AddXY(10,1);
end;
SaveChartToFile(Chart1,'C:\test.tee');
end;
procedure TForm1.btnLoadClick(Sender: TObject);
var tmpChart:TCustomChart;
begin
Chart1.Free; //assuming Chart1 is already on the Form
tmpChart:=TChart.Create(Self);
LoadChartfromFile(tmpChart,'c:\test.tee');
Chart1 := tmpChart as TChart;
Chart1.Parent:=Self;
end;
end.
If anyone has any idea how to make this work I would be grateful.
Best Regards,
Johan Ingemansson
I have created a TMapSeries with some polygons, in this test case a square, what I would like to do is to save the chart with the TMapSeries and its corresponding polygon to file and then load it again. What seems to occur is that the TMapSeries is there but the polygon points doesnt appear after LoadChartFromFile. See the test code below:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, TeCanvas,
Dialogs, StdCtrls, ExtCtrls, TeeProcs, TeEngine, Chart, Series, TeeStore, TeeMapSeries;
type
TForm1 = class(TForm)
Chart1: TChart;
btnCreate: TButton;
btnLoad: TButton;
procedure btnCreateClick(Sender: TObject);
procedure btnLoadClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btnCreateClick(Sender: TObject);
var
ASerie: TMapSeries;
APol: TTeePolygon;
i: integer;
begin
ASerie:=TMapSeries.Create(Chart1);
ASerie.ParentChart:=Chart1;
APol:=ASerie.Shapes.Add;
with APol.Points do
begin
AddXY(1,1);
AddXY(1,10);
AddXY(10,10);
AddXY(10,1);
end;
SaveChartToFile(Chart1,'C:\test.tee');
end;
procedure TForm1.btnLoadClick(Sender: TObject);
var tmpChart:TCustomChart;
begin
Chart1.Free; //assuming Chart1 is already on the Form
tmpChart:=TChart.Create(Self);
LoadChartfromFile(tmpChart,'c:\test.tee');
Chart1 := tmpChart as TChart;
Chart1.Parent:=Self;
end;
end.
If anyone has any idea how to make this work I would be grateful.
Best Regards,
Johan Ingemansson