title: Iterating through array in Chart.js data field
body: <h2>Update:</h2>
  
  <pre><code>var voltagedata1 = [];
      batterybank1.forEach(function(element){
          var voltage = {x: element.timestamp, y:element.voltage};
          voltagedata1.push(voltage);
  })
  </code></pre>
  
  <pre><code>data: voltagedata1
  </code></pre>
  
  <p><hr>
  I have an array which I want to iterate through in the data field of the Chart.js chart.</p>
  
  <p>This code works for example:</p>
  
  <pre><code>data: [
      {x: '2019-08-12 09:40:15', y:4}, {x: '2019-08-13 09:40:15', y:5}, {x: '2019-08-14 09:40:15', y:6},
  ],
  </code></pre>
  
  <p>Then trying to iterate through the array as follows:</p>
  
  <pre><code>batterybank1.forEach(function(element){
      console.log(element)
      "{x:\'element.timestamp', y:element.voltage},"
  })
  </code></pre>
  
  <p>The console.log(element) gives a correct output, however the chart is not getting updated... on the console I am getting no warnings/errors - just the graph does not output.</p>
  
  <p>The following does not work either, only the console.log is outputted but the graph is not updated.</p>
  
  <pre><code>batterybank1.forEach(function(element){
      console.log(element)
      "{x:\'2019-08-12 09:40:15', 1},"
  })
  </code></pre>