Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

How to copy TeeChart1 to ppTeeChart1so that duplicated in a report?

edited December 2007 in General
Hello,

Well let me try and explain.

I have a TChart on a delphi form.
The user then selects from parameters, and data is displayed in the chart,
based on parameters selected, and populated from a memo filled from a
database, based on the selections.

This is real nice, and works. I can print this chart using TchartPreview.

But I want a specific header and footer, added to the page when printed.

I set up a ppReport, with a ppTeeChart, with the necessary headers and
footers.

I then assign the charts as follows:
ppTeeChart1.Chart.Assign(Chart1);

then call ppReport1.print.

This works fine in that a chart displays, with the correct theme, correct
title, but no series, no legend, no bars etc.

How do I get it to CLONE the chart from tChart to ppTeechart with all the
data?

Thanks in advance

Adrian

Comments

  • edited December 2007
    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;

    I hope to be to help.

    Nicoletta

    "Adrian Wreyford" ha scritto nel messaggio
  • edited December 2007
    This didn't want to work for me.
    Still empty graph.

    PS I find no info in help files on CloneChartSeries .. intersting?

    But gave me an idea, and the following code worked:
    ppTeeChart1.Chart.Assign(Chart1);
    for j := 0 to Chart1.SeriesCount-1 do
    ppTeeChart1.Chart.AddSeries(Chart1[j]);

    Regards

    Adrian
  • edited December 2007
    Unfortunately it only appeared to work.

    The graph is rendered correctly for printing, but once you close the report
    the original graph is destroyed .. ie the assigned series are removed from
    the original graph

    So I tried again with clonechartseries, as this appears to be the way to go.

    ppTeeChart1.Chart.AddSeries(CloneChartSeries(Chart1[j]));

    adds the sereis, as I can check wioth code to see if is there, but on the
    report generated, there is an empty graph.

    So please, the people at Steema says you guys wrote own wrapper, and they
    cannot help .. please Help.

    Adrian

  • edited December 2007
    Hi Adrian,

    Sorry, I was not monitoring this thread close enough to guide you in the
    right direction.

    The easiest way to display a chart created on a form in ReportBuilder is to
    use the TeeCreateMetaFile routine and show the chart inside a TppImage
    component. Something like the following...

    var
    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);

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited December 2007
    Thanks .. This was one of the first things I tried, except, I just exported
    to picture, and then the image quality was not good, as the image was scaled
    depending on the users screen size, and the paper image size.

    Well now I got it going.

    BUT, if I may ask, why doesnt, the CloneSeriesData work?

  • edited December 2007
    Hi Adrian,

    The following test code worked correctly for me. Are you sure you are
    cloning a valid series?

    procedure TForm1.Button1Click(Sender: TObject);
    var
    lChartSeries: TChartSeries;
    begin

    lChartSeries := CloneChartSeries(Chart1.Series[0]);
    lChartSeries.ParentChart := ppTeeChart1.Chart;
    ppReport1.Print;

    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.