Misunderstood the template technology ?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Misunderstood the template technology ?

Post by moelski » Sat Dec 22, 2007 11:11 pm

Hi Support,

today I played around a while with the template function and I wont get it working as I expect.

Let me explain what I think the templates should work :wink:
A template contains only the appearance of a chart. In other words it contains everthings except the data information.

My problem is the following ...
I have a chart with two series. Each of the series contains data (lets say 100 points in each series). I save a template of this chart with this code:

Code: Select all

SaveChartToFile(Chart1, dir + 'Template.lvt', False, True);
So I get something like this in the TEE file:

Code: Select all

object TChart
  Left = 1
  Top = 1
  Width = 681
  Height = 495
  Title.Text.Strings = (
    'TChart')
  CustomAxes = <
    item
      Horizontal = False
      OtherSide = False
    end
    item
      Horizontal = False
      OtherSide = False
    end>
  Align = alClient
  TabOrder = 0
  object Series1: TFastLineSeries
    Marks.Arrow.Visible = True
    Marks.Callout.Brush.Color = clBlack
    Marks.Callout.Arrow.Visible = True
    Marks.Visible = False
    VertAxis = aCustomVertAxis
    LinePen.Color = clRed
    XValues.Name = 'X'
    XValues.Order = loAscending
    YValues.Name = 'Y'
    YValues.Order = loNone
    CustomVertAxis = 0
  end
  object Series2: TFastLineSeries
    Marks.Arrow.Visible = True
    Marks.Callout.Brush.Color = clBlack
    Marks.Callout.Arrow.Visible = True
    Marks.Visible = False
    VertAxis = aCustomVertAxis
    LinePen.Color = clGreen
    XValues.Name = 'X'
    XValues.Order = loAscending
    YValues.Name = 'Y'
    YValues.Order = loNone
    CustomVertAxis = 1
  end
end
Now I change some properties of the chart. Lets say I change the color of the both series.

Now I want to load back the templates I saved seconds before.

Code: Select all

LoadChartfromFile(TCustomChart(Chart1), OpenDialog1.FileName);
The expected result should be the view as I started. But what I get i a complete empty chart. Only the appearance of my template is loaded. The data is gone.

So how can I load a template without loosing my data which is shown in the series? As I said before ... The template should only change the appearance and shouldn´t touch the data. Or am I wrong?

I can send you a small demo application if you need one.

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Sun Dec 23, 2007 11:12 pm

Hi, Greetz!
I guess your question is quite common for those trying to play with this function. Before I got source code I tried to write down my own implementation. The only suggestion I have is to comment lines #341 and 342 in TeeStore.pas
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Wed Dec 26, 2007 4:50 pm

Hi !
Hi, Greetz!
My name is Dominik and not Greetz ...

Greetz like Greetings !!! :wink:

Code: Select all

The only suggestion I have is to comment lines #341 and 342 in TeeStore.pas
Well I think it is not a good idea to change the source from steema. You have to fix it with every new version :(

Hopefully the have a solution for this problem (or a working function).

xxxxxx
Advanced
Posts: 128
Joined: Tue Jun 19, 2007 12:00 am
Location: Russia
Contact:

Post by xxxxxx » Wed Dec 26, 2007 6:10 pm

Frohe Weihnachten (Merry Christmas), Dominik :)
I didn't mean modifying Steema source but using it for your own procedure instead.
In general there are not so much problems when you use fixed amount of series and other features.
I think a scheme could be something like this (roughly):

Code: Select all

procedure GetChartTemplateFromFile(var AChart:TChart; const FName: String;
const ASeriesList: TChartSeriesList //List of your series in your program
);
var
  iSer: integer;
  Stream :TFileStream;
begin
  Stream:=TFileStream.Create(FName,fmOpenRead);
  try
    Stream.ReadComponent(AChart);
    AChart.RemoveAllSeries;
    with AChart, ASeriesList do
    for iSer:=0 to Count-1 do
      AChart.AddSeries(ASeriesList[iSer]);
  finally
    Stream.Free;
  end;
end;

procedure PutChartTemplateToFile(const Chart:TChart; const FName: String);
var
  Stream : TFileStream;
begin
  Stream:=TFileStream.Create(FName,fmCreate);
  try
    Chart.RemoveAllSeries;
    Stream.WriteComponent(Chart);
  finally
    Stream.Free;
  end;
end;
This is just an idea - not actually working code!!!
Regards, Alexander
=================
TeeChart Pro v8.05, Delphi 5 & Turbo Delphi Professional for Win32., Delphi & C++Builder 2009

moelski
Advanced
Posts: 212
Joined: Mon Apr 23, 2007 12:00 am
Location: Germany
Contact:

Post by moelski » Thu Dec 27, 2007 1:38 pm

Hi Alex,

thx for your suggestion. But it would great to get a solution from steema. This is a very important feature for us.

Maybe I have to spend a pro support mail if I don´t get an answer here.

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Dec 27, 2007 6:30 pm

Hi Dominik,

once you load the Chart from .tee file all the Series DataSource must be reassigned (or load the data again), there's not a method to load just the Chart appearance having created other Series before (just setting to true the export Data param).
In your case, a workaround could be to export the data you want to maintain after to load the template just before load the saved template, and then load the saved data again.

Post Reply