title: Chart.js: get chart data from canvas
body: <p>I have several Chart.js charts that I may need to update at a later time.</p>
  
  <p>Is it possible to extract the myChart object from the canvas element at the time when I need to update the chart? Or do I have to save every myChart object in the global scope?</p>
  
  <pre><code>for(var i=1; i&lt;=5; i++) {
    createChart(i);
  }
  
  function createChart(i) {
    var $chart = $('&lt;canvas id="chart-' + i + '" width="400" height="400"&gt;&lt;/canvas&gt;').appendTo('body');
    var myChart = new Chart($chart, {
      data: {
        datasets: [{
            data: [Math.random(), Math.random(), Math.random(), Math.random()]
        }]
      }
    });
  }
  </code></pre>
  
  <p>Now some pseudo-code how I would like to update say chart 2 at a later time:</p>
  
  <pre><code>var updateChart = $('#chart-2'); // This is where I'd need to get the chart data from the canvas element
  
  updateChart.data.datasets[0].data = updateChart.data.datasets[0].data.push(Math.random());
  
  updateChart.update();
  </code></pre>