title: How clone TChart in FMX
body: <p>How do i clone a TChart at runtime?  I found <a href="https://community.idera.com/developer-tools/b/blog/posts/clone-firemonkey-objects" rel="nofollow noreferrer">this link</a> but it is Delphi and i can't translate to C++ Builder. </p>
  
  <p>Here is what i tried but i get an error at runtime of <code>Class TChart not found</code>:</p>
  
  <pre><code>TChart *tmp = new TChart(Chart1-&gt;Clone(this));
  tmp-&gt;Parent = this-&gt;Panel2;
  </code></pre>
  
  <p>Also, how can i clone so that i can easily reference the new clones in code  - e.g. <code>Chart(2)</code>, <code>Chart(3)</code> etc.</p>
  
  <p><strong>EDIT 1</strong>:  I can clone a button with the following code, but i'm still getting the <code>Class TChart not found</code> when i try with a TChart.</p>
  
  <pre><code>TButton *tmp;
  tmp = new TButton(Button1-&gt;Clone(this));
  tmp-&gt;Parent=ToolBar1;  // put it on ToolBar1
  tmp-&gt;Text = "Cloned Button";
  </code></pre>
  
  <p><strong>EDIT 2</strong>:  The following code makes a chart clone and solved the <code>Class TChart not found</code> issue but it does not make a true clone. The image below shows Chart1 and the resulting clone (on Win32). My goal was to make a template chart (Chart1) and then just clone it as i needed new charts...without having to set gobs of properties to make it look like Chart1.</p>
  
  <pre><code>void __fastcall TForm1::Button2Click(TObject *Sender)
  {
  RegisterClass(__classid(TChart));   
  TChart* tmp =  (TChart*)(Chart1-&gt;Clone(Chart1));  // clone Chart1
  tmp-&gt;Parent = Panel2;  // put the new clone on Panel2
  tmp-&gt;Position-&gt;Y = 300;  
  tmp-&gt;BottomAxis-&gt;Minimum = -8;
  tmp-&gt;BottomAxis-&gt;Maximum = 8;
  tmp-&gt;LeftAxis-&gt;Minimum = 0;
  tmp-&gt;LeftAxis-&gt;Maximum = 10;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/HY57W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HY57W.png" alt="Chart1 and its clone"></a></p>