Questions regarding LoadGraphOptions

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Geocentrix
Newbie
Newbie
Posts: 2
Joined: Thu Sep 30, 2021 12:00 am

Questions regarding LoadGraphOptions

Post by Geocentrix » Mon Jun 13, 2022 4:37 pm

I have some questions about loading TChart options from previously saved *.tee files.

The tee files have been saved using a call like this:

Code: Select all

SaveChartToFile(Chart, filename, false, true);
The false flag means that the data in the graph is NOT included in the tee file (which I have checked).

When I use the function LoadChartFromFile(Chart, filename) to reinstate the graph's options, the data disappears from my chart (but the options saved in the tee file are applied as expected).

Q1. What do I have to do to redraw the graph with the new options?

Q2. What function should I call to load the graph options from a previously saved XML file?

I would prefer to save the graph options in XML format, using using a call like this:

Code: Select all

SaveChartToXMLFile(Chart, filename, false, true);
where the final true flag denotes inclusion of the XML header.

However, I cannot find a function that allows me to load the options from this XML file. There is no LoadChartFromXMLFile function, AFAIK, and the LoadChartFromFile function issues an error if it is passed an XML file.

What am I missing here?


Thanks in advance fort any help anyone can give.

Andrew

Geocentrix
Newbie
Newbie
Posts: 2
Joined: Thu Sep 30, 2021 12:00 am

Re: Questions regarding LoadGraphOptions

Post by Geocentrix » Mon Jun 13, 2022 5:06 pm

I have found the function LoadChartFromXMLFile but ...

After I have saved the same options to both the tee file and the xml file and then load those files, the tee file works as expected (apart form the data not being drawn) but the XML file does not. I attach three screenshots showing what I am getting:


Screenshot 1 = before saving to *.tee and *.xml files
Screenshot1.jpg
Screenshot1.jpg (41.83 KiB) Viewed 4712 times

Screenshot 2 = after loading *.tee and *.xml file
Screenshot2.jpg
Screenshot2.jpg (25.81 KiB) Viewed 4712 times

Screenshot 3 = after loading *.xml file
Screenshot3.jpg
Screenshot3.jpg (20.59 KiB) Viewed 4712 times

Has anyone had this problem before?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Questions regarding LoadGraphOptions

Post by Yeray » Wed Jun 29, 2022 2:51 pm

Hello,

I've done a test and it seems to work fine for me here both without and with data:
withoutData.png
withoutData.png (26.59 KiB) Viewed 4521 times
withData.png
withData.png (50.37 KiB) Viewed 4521 times
Note I'm using streams instead of files, but it shouldn't be very different:

Code: Select all

uses Chart, Series, TeeGDIPlus, TeeStore, TeeProcs;

var origChart, teeChart, xmlChart: TChart;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
    teeStream, xmlStream: TMemoryStream;
const withData=false;
begin
  //Create origChart
  origChart:=TChart.Create(Self);
  origChart.Parent:=Self;
  origChart.View3D:=False;
  origChart.Gradient.Visible:=False;
  origChart.Color:=clWhite;
  origChart.Walls.Back.Gradient.Visible:=False;
  origChart.Walls.Back.Color:=clWhite;
  origChart.Title.Text.Text:='Original Chart';
  origChart.Legend.CheckBoxes:=True;
  origChart.Legend.Alignment:=laBottom;

  for i:=0 to 3 do
    origChart.AddSeries(TLineSeries).FillSampleValues;

  //Export to tee stream
  teeStream:=TMemoryStream.Create;
  SaveChartToStream(origChart, teeStream, withData);

  //Load tee stream to teeChart
  teeStream.Position:=0;
  teeChart:=TChart.Create(Self);
  LoadChartFromStream(teeChart, teeStream);
  teeChart.Parent:=Self;
  teeChart.Title.Text.Text:='Chart from tee stream';
  teeChart.Top:=origChart.Height+10;

  //Export to xml stream
  xmlStream:=TMemoryStream.Create;
  SaveChartToXMLStream(origChart, xmlStream, withData);

  //Load tee stream to teeChart
  xmlStream.Position:=0;
  xmlChart:=TChart.Create(Self);
  LoadChartFromStream(xmlChart, ConvertXMLToText(xmlStream));
  xmlChart.Parent:=Self;
  xmlChart.Title.Text.Text:='Chart from xml stream';
  xmlChart.Top:=origChart.Height+10;
  xmlChart.Left:=origChart.Width+10;
end;

initialization
  RegisterTeeStandardSeries;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply