title: How to improve WinForms MSChart performance?
body: <p>I have created some simple charts (of type FastLine) with MSChart and update them with live data, like below:</p>
  
  <p><img src="https://i.stack.imgur.com/5WoRx.png" alt="MSCharts Level Chart"></p>
  
  <p>To do so, I bind an observable collection of a custom type to the chart like so:</p>
  
  <pre><code>                // set chart data source
              this._Chart.DataSource = value; //is of type ObservableCollection&lt;SpectrumLevels&gt;
  
              //define x and y value members for each series
              this._Chart.Series[0].XValueMember = "Index";
              this._Chart.Series[1].XValueMember = "Index";
              this._Chart.Series[0].YValueMembers = "Channel0Level";
              this._Chart.Series[1].YValueMembers = "Channel1Level";
  
              // bind data to chart
              this._Chart.DataBind(); //lasts 1.5 seconds for 8000 points per series
  </code></pre>
  
  <p>At each refresh, the dataset completely changes, it is not a scrolling update!</p>
  
  <p>With a profiler I have found that the <code>DataBind()</code> call takes about 1.5 seconds. The other calls are negligible.</p>
  
  <p><strong>How can I make this faster?</strong></p>
  
  <ul>
  <li>Should I use another type than ObservableCollection? An array probably?</li>
  <li>Should I use another form of data binding?</li>
  <li>Is there some tweak for the MSChart that I may have missed?</li>
  <li>Should I use a sparsed set of date, having one value per pixel only?</li>
  <li>Have I simply reached the performance limit of MSCharts?</li>
  </ul>
  
  <p>From the type of the application to keep it "fluent", we should have multiple refreshes per second.</p>
  
  <p>Thanks for any hints!</p>
  
  <p><strong>EDIT: Solution as proposed by leppie:</strong></p>
  
  <pre><code>                this._Chart.Series[0].Points.Clear();
              foreach (var item in value) //iterates over the list of custom objects
              {
                      this._Chart.Series[0].Points.Add(new DataPoint
                      {
                          XValue = item.Index,
                          YValues = new double[] { item.Channel0Level.Value }
                      });
  
              }
  </code></pre>
  
  <p><strong>This now works more than twice as fast!</strong></p>