Page 1 of 1

CloneChart in C++

Posted: Wed Jun 26, 2019 3:09 pm
by 16886444
Hi,

Using C++ how can i clone a chart (not the series data, just the chart)? I don't know object pascal so i can't translate to C++.

Also, i'd like to clone charts so i can access them something like this Chart[1], Chart[2] for convenience (like an array).

thank you,
russ

p.s. I'm using Rad Studio 10.3.1 and working in C++ Builder.

Re: CloneChart in C++

Posted: Thu Jun 27, 2019 10:54 am
by yeray
You can do this as follows:

Code: Select all

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  TChart *Charts[2];

  Charts[0] = new TChart(this);
  Charts[0]->Parent = this;
  TLineSeries *series = new TLineSeries(this);
  Charts[0]->AddSeries(series);
  series->FillSampleValues();

  Charts[1] = new TChart(this);
  CloneChart(Charts[1], Charts[0], this, false);
  Charts[1]->RemoveAllSeries();
  Charts[1]->Parent = this;
  Charts[1]->Top=Charts[0]->Height;

}