Duplicate a chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Calou
Advanced
Posts: 104
Joined: Wed Nov 19, 2008 12:00 am

Duplicate a chart

Post by Calou » Tue Feb 24, 2009 5:15 pm

Hello,

On a form at design time i have created a chart with one series.
I would like to create at run time one or several charts with the same series and the same properties than the previous and draw it below the first chart (the series values are not the same).

What is the best way to do that? Is there is a function which could duplicate a chart and its content?

Thank you for help

Regards

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

Post by Yeray » Wed Feb 25, 2009 8:39 am

Hi Calou,

I'm afraid there isn't a single function to do this. The simplest way probably is :
- Create your new chart at runtime
- Save your old chart in a tee file
- Import the tee file to the new chart
- Remove all series or clear the data of the new chart
- Verify and copy the original's chart properties that weren't exported to the tee file

If you find problems at any step, please, don't hesitate to let us know.
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

tp
Newbie
Newbie
Posts: 1
Joined: Mon Oct 06, 2008 12:00 am

Post by tp » Wed Feb 25, 2009 9:39 am

Hello,

You can also do it directly from memory.
For example, in C++ Builder, assuming that vChrt1 is your source chart, this should copy chart properties and data to a new chart:

Code: Select all

  
#include <TeeStore.hpp>
...

  TMemoryStream* pStream = new TMemoryStream;
  SaveChartToStream(vChrt1, pStream, true, true);

  TChart* pTChart = new TChart(this);
  pStream->Position = 0;
  LoadChartFromStream((TCustomChart*)pTChart, pStream);
  pTChart->Parent = this;
  pTChart->Top = vChrt1->Top + vChrt1->Height;
  pTChart->Left = vChrt1->Left;

  delete pStream;

Post Reply