Form Ajax not working when rendered from Ajax callback
I have fixed the issue I was having by just returning the render array of the form rather than trying to get the form's HTML. So my AJAX callback function now looks something like this: 

public static function OnPanelSwitch(array &amp;$form, FormStateInterface $form_state) {

   $ajax_response = new AjaxResponse();

   $AddChartForm = \Drupal::formBuilder()-&gt;getForm('Drupal\dashboard\Form\AddChartForm');

   $ajax_response-&gt;addCommand(new HtmlCommand('#formarea', $AddChartForm));

return $ajax_response;