2

Fetch is ok, incoming data granted. Problem is - put data in library. Please help. Here is the pen.

https://codepen.io/disapology/pen/xxWomzB

fetch(
  "https://iss.moex.com/iss/engines/stock/markets/shares/securities/SBER/candles.json?iss.meta=off&iss.reverse=true&interval=7&from=2014-09-01"
)
  .then((response) => {
    return response.json();
  })

// convert data to array

  .then((data) => {

    const bars = data.candles.data;
    //
    var chart = LightweightCharts.createChart(document.body, {
      width: 600, //(window.innerWidth -20),
      height: 300 //(window.innerHeight - 20),
      
    });
    var candlestickSeries = chart.addCandlestickSeries();
    const cdata = bars.map(d => {
      let tempTime = d[7].slice(0, -9);
      return {time: tempTime, open: parseFloat(d[0]), high: parseFloat(d[2]), low: parseFloat(d[3]), close: parseFloat(d[1])};
    });
    candlestickSeries.setData(cdata);
  })
Alexey
  • 21
  • 2
  • Could you please check the console within the browser to see if there are any warnings or errors reported by the library or browser? – SlicedSilver Sep 14 '22 at 13:29
  • TypeError: t is undefined. This is lib error. – Alexey Sep 14 '22 at 14:44
  • I'm unable to access the data feed you included within your code so I can't check if that data is valid. I've replicated your code in a JSFiddle (which skips the data loading part) and it works as expected. I would focus on the data which you are passing into the library as the source of the issue. https://jsfiddle.net/msilverwood/96w4xckn/ – SlicedSilver Sep 16 '22 at 08:05

0 Answers0