Page 1 of 1

Misunderstood the template technology ?

Posted: Sat Dec 22, 2007 11:11 pm
by 9349911
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.

Posted: Sun Dec 23, 2007 11:12 pm
by 9047589
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

Posted: Wed Dec 26, 2007 4:50 pm
by 9349911
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).

Posted: Wed Dec 26, 2007 6:10 pm
by 9047589
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!!!

Posted: Thu Dec 27, 2007 1:38 pm
by 9349911
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.

Posted: Thu Dec 27, 2007 6:30 pm
by Pep
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.