title: Looping through every value from an Object (JSON) and passing it to setData series
body: <p>Context: I'm trying to put data from MySQL in a tradingview graph and the data I'm using is in JSON.</p>
  <p>This is the format of the data that I have from my MySQL query and PHP:</p>
  <pre><code>[
  {&quot;Date&quot;:&quot;2010-07-01&quot;,&quot;Open&quot;:5,&quot;High&quot;:5.184000015258789,&quot;Low&quot;:2.996000051498413,&quot;Close&quot;:3.98799991607666}
  {&quot;Date&quot;:&quot;2010-08-01&quot;,&quot;Open&quot;:4.099999904632568,&quot;High&quot;:4.435999870300293,&quot;Low&quot;:3.4779999256134033,&quot;Close&quot;:3.8959999084472656},
  {&quot;Date&quot;:&quot;2010-09-01&quot;,&quot;Open&quot;:3.9240000247955322,&quot;High&quot;:4.631999969482422,&quot;Low&quot;:3.9000000953674316,&quot;Close&quot;:4.081999778747559},
  {&quot;Date&quot;:&quot;2010-10-01&quot;,&quot;Open&quot;:4.138000011444092,&quot;High&quot;:4.374000072479248,&quot;Low&quot;:4,&quot;Close&quot;:4.368000030517578},
  {...}
  ]
  </code></pre>
  <p>Problem: When doing this, I am only being able to get the last set of properties of the object on the graph and not the previous properties.</p>
  <p>This code:</p>
  <pre><code>    let dateData;
      let lowData;
      let openData;
      let closeData;
      let highData;
  
      let data = &lt;?php echo json_encode($data_array) ?&gt;;
      data.map(function(element) {
        dateData = element.Date;
        lowData = element.Low;
        openData = element.Open;
        closeData = element.Close;
        highData = element.High;
      })
  
      const chart2 = LightweightCharts.createChart(document.body, { width: 400, height: 300 });
      const candlestickSeries = chart2.addCandlestickSeries();
    
      candlestickSeries.setData([{ time: dateData, open: openData, high: highData, low: lowData, close: closeData }]);
      }
  </code></pre>
  <p>Results in this graph:</p>
  <p><a href="https://i.stack.imgur.com/zBmY2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zBmY2.png" alt="graph output" /></a></p>
  <p>The reason I did the map function first is to try and save all the values as variables and then pass them onto the setData, but that clearly isn't working since it is only saving the latest values.</p>
  <p>I've tried looping through each value of the object and put it on the candlestick.setData series, but no success:</p>
  <pre><code>const candlestickSeries = chart2.addCandlestickSeries();
  for (let [value] of Object.entries(data)) {
    candlestickSeries.setData([{ time: dateData[value], open: openData[value], high: highData[value], low: lowData[value], close: closeData[value] }]);
  }
  </code></pre>
  <p>Any help is very welcome!</p>