Answer the question
In order to leave comments, you need to log in
Displaying data on a chart via API?
To display data (date and price) on the stock price chart received through the Moscow Exchange API, I use this code:
(async () => { // асинхронная функция
for (start = 0;; start += 500) {
let url = 'https://iss.moex.com/iss/engines/stock/markets/shares/boards/TQBR/securities/SBER/candles.json?interval=24&start=' + start;
let response = await fetch(url);
let data = await response.json();
let formattedData = data.candles.data.map(item => ({ // благодаря объекту map вывожу на график каждый элемент массива
time: item[7].split(" ")[0],
value: item[1],
}));
let Itemlength = data['candles']['data'].length
if (Itemlength < 500) break; // пока не достигнут последний блок данных (их меньше 500), параметр start в url увеличивается на 500
areaSeries.setData(formattedData) // функция графика
}
})();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question