Page 1 of 1
How to Copy Chart1 to ppTeeChart1, ie including all data?
Posted: Sun Dec 09, 2007 6:39 pm
by 10547084
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
Posted: Mon Dec 10, 2007 10:05 am
by narcis
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.
Posted: Tue Dec 11, 2007 9:01 pm
by 10547084
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
Posted: Wed Dec 12, 2007 9:38 am
by narcis
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.
Posted: Thu Dec 13, 2007 5:30 pm
by 10547084
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
Posted: Thu Jul 10, 2008 2:36 pm
by 9350489
I try this solution :
[/b]
but Chart is unknowed..
may be an uses ?
thank you
Posted: Thu Jul 10, 2008 2:42 pm
by narcis
Hello,
Which is the exact error message you get?
Thanks in advance.
Posted: Thu Jul 10, 2008 2:59 pm
by 9350489
Hi Narcis,
TCustomAxisPanel and TppDPTeeChart incompatibles
thank you
Didier
Posted: Thu Jul 10, 2008 3:22 pm
by 9350489
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
Posted: Thu Jul 10, 2008 3:24 pm
by 9350489
[/code]
ppDPTeeChart1.Chart.Assign(Chart1);
for i := 0 to Chart1.SeriesCount - 1 do
// Error on this lline
CloneChartSeries(Chart1.Series
).ParentChart := ppDPTeeChart1;
Posted: Thu Jul 10, 2008 3:32 pm
by 9350489
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
Posted: Fri Jul 11, 2008 9:20 am
by 9350489
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