更新轻量级图表烛台系列会导致未捕获的类型错误:无法读取未定义的属性(读取“年份”)
在烛台系列上运行更新
时,我收到Uncaught TypeError:无法读取未定义的属性(读取“年份”)
。数据的准备方式与 setData
相同,如下所示:[{time: 1649068320, open: '0.15721000', high: '0.15776000', low: '0.15710000', close : '0.15760000'}]
。
我在这里缺少什么?
我尝试使用与 setData 相同的数据进行更新,但出现了相同的错误。
还尝试以这种方式准备数据: var time = moment(item.openTime); time = { 年:time.year(),月:time.month(),日:time.day(),小时:time.hour(),分钟:time.min(),秒: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'}]);
When running update
on candlestick series I'm getting Uncaught TypeError: Cannot read properties of undefined (reading 'year')
. Data is prepared the same way it was for setData
and look like this: [{time: 1649068320, open: '0.15721000', high: '0.15776000', low: '0.15710000', close: '0.15760000'}]
.
What am I missing here?
I tried to update with same data as was used with setData and got same error.
Also tried to prepare data this way:var time = moment(item.openTime); time = { year: time.year(), month: time.month(), day: time.day(), hour: time.hour(), minute: time.minute(), second: time.second(), }
and var time = new Date(item.openTime)
Minimum steps to reproduce
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'}]);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新
采用单个对象。因此,还应该是
:
Update
。因此,当向后滚动时,您需要使用setData
undfult的错误:值是null
。update
takes single object. so instead ofit should be
Also:
update
on past data. So when scrolling backwards, you need to usesetData
Uncaught Error: Value is null
.