title: Chart js: Update line chart having two data sets
body: <p>I want to update a line chart in chart js with two data sets. I've somehow managed to empty the chart and then able to fill in one of the data set. but unable to make both data sets working. here's the code.</p>
  
  <pre class="lang-js prettyprint-override"><code>ajaxRequest(
      {
          url: 'reports/updateChart/?filter=true',
          method: 'post',
          data: data
      }, function (response)
          {
              /*refresh the tables with the new data sets*/
              removeData(myChart);
              let label = [1, 234, 234, 234, 234, 234, 234, 34, 234, 23, 23, 41, 3, 2, 4];
              let data = [234, 234, 5, 23, 34, 234, 234, 234],[22, 1, 123, 14, 2]
          }; addData(myChart, label, data);
      });
  
  });
  </code></pre>
  
  <p>functions:</p>
  
  <pre class="lang-js prettyprint-override"><code>function removeData(chart) {
      chart.data.labels = [];
      chart.data.datasets.forEach((dataset) =&gt; {
          dataset.data = [];
      });
      chart.update();
  }
  
  function addData(chart, label, data) {
      $.each(label, function (index, value) {
          chart.data.labels.push(value);
      });
  
      chart.data.datasets.forEach((dataset) =&gt; {
          $.each(data, function (index, value) {
              dataset.data.push(value);
          });
      });
      chart.update();
  }
  </code></pre>