当在烛台上运行update时,我得到了Uncaught TypeError: Cannot read properties of undefined (reading 'year')。数据的准备方式与setData相同,如下所示:[{time: 1649068320, open: '0.15721000', high: '0.15776000', low: '0.15710000', close: '0.15760000'}]。
我在这里错过了什么?
我尝试用与setData相同的数据进行更新,得到了相同的错误。
还试图以这种方式准备数据:var time = moment(item.openTime); time = { year: time.year(), month: time.month(), day: time.day(), hour: time.hour(), minute: time.minute(), second: time.second(), }和var time = new Date(item.openTime)
复制的最小步骤
import { createChart } from 'lightweight-charts';
var container = document.getElementById('price-chart');
const chart = createChart(container, {height:300});
chart.applyOptions({
timeScale: {
visible: true,
timeVisible: true,
},
});
const candlestick = chart.addCandlestickSeries();
candlestick.setData([{time: 1649102700, open: '3.39110000', high: '3.39130000', low: '3.38610000', close: '3.38670000'}]);
candlestick.update([{time: 1649102700, open: '3.39110000', high: '3.39130000', low: '3.38610000', close: '3.38670000'}]);发布于 2022-04-05 09:02:32
update接受单个对象。因此,不是
candlestick.update([{time: 1649102700, open: '3.39110000', high: '3.39130000', low: '3.38610000', close: '3.38670000'}]);它应该是
candlestick.update({time: 1649102700, open: '3.39110000', high: '3.39130000', low: '3.38610000', close: '3.38670000'});另外:
update。因此,当向后滚动时,需要使用setDataUncaught Error: Value is null.。
https://stackoverflow.com/questions/71744851
复制相似问题