How to Copy Chart1 to ppTeeChart1, ie including all data?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Doogie
Newbie
Newbie
Posts: 12
Joined: Mon Oct 22, 2007 12:00 am
Contact:

How to Copy Chart1 to ppTeeChart1, ie including all data?

Post by Doogie » Sun Dec 09, 2007 6:39 pm

I need to copy a Chart to a ppTeeChart.

The Chart is set up by the user. The chart then needs to be copied as is to a ppTeeChart to be used in a ppReport.

I tried:
uses TeeStore, TeeEditPro
..
var
stream: TMemoryStream;
begin
stream:=TMemoryStream.Create;
try
SaveChartToStream(Chart1,stream);
stream.Position:=0;
LoadChartFromStream(TCustomChart(ppTeeChart1.Chart),stream);
finally
stream.Free;
end;

This doesn't compile ie the 'ppTeeChart1.Chart' part.

If I make this: LoadChartFromStream(TCustomChart(ppTeeChart1),stream);
ie get an access violation at runtime.

I also tried:
begin
ppTeeChart1.Chart.Assign(Chart1);

This works in that the chart appears with the title, but no series or legend or data?

Please could you help .. PS I? need the exact replica .ie a clone of the chart data and all.

Thanks in advance

Doogie

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Dec 10, 2007 10:05 am

Hi Doogie,

Sorry but I can' tell you if this is supported in ppTeeChart as we are not the component developers. Digital Metaphors, ReportBuilder manufactureres, are the developers and the ones who support the ReportBuilder wrapper for TeeChart. So you may better ask them.

Another option is that you export the chart created with TeeChart to an image and then use this image in ReportBuilder.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Doogie
Newbie
Newbie
Posts: 12
Joined: Mon Oct 22, 2007 12:00 am
Contact:

Post by Doogie » Tue Dec 11, 2007 9:01 pm

Thanks Narcis.

Assign to Picture, works, but there is an issue with quality of final image, when scaled from screen display size, to paper size. So this one didn't work for me.

I tried the following code, and worked 100%:
ppTeeChart1.Chart.Assign(Chart1);
for x := 0 to Chart1.SeriesCount-1 do
ppTeeChart1.Chart.AddSeries(Chart1[x]);

I was advised to use the following code in a Digital Metaphors newsgroup:
"I use this source code :

for j := 0 to Chart.SeriesCount-1 do
CloneChartSeries(Chart[j]).ParentChart := ppTeeChart;

in your case

for j := 0 to Chart1.SeriesCount-1 do
CloneChartSeries(Chart1[j]).ParentChart := ppTeeChart1;"
but this didn't change anything, and nothing more than an empty chart displayed.

What did tickle me however, is that I can find NO documentation on CLONECHARTSERIES in your help files, also no example that uses this code.

Regards

Doogie

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Dec 12, 2007 9:38 am

Hi Doogie,

I'm glad to hear you solved the issue. You can find several CloneChartSeries examples at this forum using its search feature, for example here.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Doogie
Newbie
Newbie
Posts: 12
Joined: Mon Oct 22, 2007 12:00 am
Contact:

Post by Doogie » Thu Dec 13, 2007 5:30 pm

I spoke too soon, well it works, but once you exit the report, all the original chart is destroyed, Ie series missing.

I was then advised by digital-metaphors to:
lMetaFile: TMetaFile;
lRect: TRect;
begin

lRect.Left := 0;
lRect.Top := 0;
lRect.Right:=ppImage1.spWidth;
lRect.Bottom:=ppImage1.spHeight;

lMetaFile := Chart1.TeeCreateMetafile(True,lRect);
ppImage1.Picture.Metafile.Assign(lMetaFile);


Well this works, and results in a properly scaled image, with the original quality! (You did advise me to use an image, but I exported to picture, and not this way)

I still don't understand why CloneSeriesData wont work .. but that left there.

Thanks once again
Doogie :D

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Thu Jul 10, 2008 2:36 pm

I try this solution :

Code: Select all

ppTeeChart1.Chart.Assign(Chart1);
[/b]

but Chart is unknowed..

may be an uses ?


thank you

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Jul 10, 2008 2:42 pm

Hello,

Which is the exact error message you get?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Thu Jul 10, 2008 2:59 pm

Hi Narcis,

TCustomAxisPanel and TppDPTeeChart incompatibles

thank you

Didier

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Thu Jul 10, 2008 3:22 pm

sorry, in fact :

Code: Select all

   
ppDPTeeChart1.Chart.Assign(DBCProductionMois);

 for i := 0 to Chart1.SeriesCount - 1 do

// Error on this lline
 CloneChartSeries(Chart1.Series[i]).ParentChart := ppDPTeeChart1;

 

thank you

Didier

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Thu Jul 10, 2008 3:24 pm

[/code]

ppDPTeeChart1.Chart.Assign(Chart1);

for i := 0 to Chart1.SeriesCount - 1 do

// Error on this lline
CloneChartSeries(Chart1.Series).ParentChart := ppDPTeeChart1;

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Thu Jul 10, 2008 3:32 pm

Hi Narcis,

Can you give me the complete method described by Doogie
in order to copy a Tchart in a TppTeeChart.


I thank you in advance


Didier

Clara Genermont
Newbie
Newbie
Posts: 42
Joined: Mon Jun 11, 2007 12:00 am
Contact:

Post by Clara Genermont » Fri Jul 11, 2008 9:20 am

Hi Narcis,

a little surprised to have a short code, I thought that other records were
needed ..

But in fact the method (Doogie : .....

ppImage1.Picture.Metafile.Assign(lMetaFile); )

works very well!


thank you
happy holidays


Didier

Post Reply