title: How to Clear a Chart form
body: <p>i'm currently working on a project (WOL) where i have a program that launch as a window form and have few components which one of them is a chart form.</p>
  <p>Basically, the program can re-launch multiple times as the user wants but i'm trying to clear/reset the chart form (that is in Pie style) at each launch = delete the previous datas of the chart.</p>
  <p>My code is way too long so i will post only the concerned parts</p>
  <pre><code>$WOL_W = New-Object System.Windows.Forms.Form
  
  .... (skipping useless code part)
  function Chart {
      param(
          [Parameter(Mandatory)]
          [PSCustomObject[]]
          $Results
      )
      $G_Graphique = New-object System.Windows.Forms.DataVisualization.Charting.Chart
      
      $G_Graphique.Location = New-Object System.Drawing.Point(300,350)
      $WOL_W.Controls.Add($G_Graphique)
      $Wol_W.Add_Shown({$Graphique.Activate()})
      $G_Graphique.Anchor = [System.Windows.Forms.AnchorStyles]::Bottom -bor [System.Windows.Forms.AnchorStyles]::Right -bor [System.Windows.Forms.AnchorStyles]::Top -bor [System.Windows.Forms.AnchorStyles]::Left
  
      # Objet Zone Graphique (ZG_)
      $ZG_GraphArea = New-Object System.Windows.Forms.DataVisualization.Charting.ChartArea
      $G_Graphique.ChartAreas.Add($ZG_GraphArea)
      [void]$G_Graphique.Titles.Add(&quot;Réussite du WOL&quot;)
      $G_Graphique.BackColor = [System.Drawing.Color]::White
      $G_Graphique.BorderColor = 'Black'
      $G_Graphique.BorderDashStyle = 'Solid'
      [void]$G_Graphique.Series.Add(&quot;Data&quot;)
      $G_Graphique.Series[&quot;Data&quot;].ChartType = [System.Windows.Forms.DataVisualization.Charting.SeriesChartType]::Pie
      $G_Graphique.Series[&quot;Data&quot;].Points.DataBindXY($Results.Keys,$Results.Values)
      
  }
  </code></pre>
  <p>Note : i've tried to use the followings command in another function (function of the creation for the main window)  :</p>
  <pre><code>$G_Graphique.ChartAreas.Clear()
  $Wol_W.Controls.Remove($G_Graphique)
  </code></pre>
  <p>Which failed as i want.</p>