TypeError: Cannot read property 'interval_ms' of undefined
kempsteven opened this issue · 6 comments
Description
I am trying to update the an overlays data, specifically "ROC" Overlay, i am using .merge
to update the data,
i use that to update chart.data this.chart.merge('chart.data', data)
, and it works perfectly, but when I update an Overlay like
ROC I get the error TypeError: Cannot read property 'interval_ms' of undefined
Screenshot
Code (MVP)
const data = [[1617978600000, 2.38], [1618237800000, 2.31], [1618324200000, 1.58]]
this.chart.merge(`offchart.ROC5C.data`, data)
Console errors (if any)
Additional Info
(tvjs version, OS, browser, npm version...)
"trading-vue-js": "^1.0.2"
I know the project's not being maintained, just hoping someone will help. thanks in advanced!
I've looked through the source code and it seems this.$refs.chart
& this.tv.$refs.chart
is undefined, not sure why tho
I had a similar problem and the problem was about the frequency of calling update().
by adding some sleep between calls, the problem was solved.
Here is my working example .
async mounted() {
for (const cdl of json.chart.data) {
await new Promise((resolve) => setTimeout(resolve, 100))
this.chart.update({ candle: cdl })
}
},
Same problem. Do you find solution @kempsteven ?
@mjzarrin where do you put this code? I have this problem when adding a new indicator, not on initial load.
Proper fix is to give the timeframe interval when you specify the datacube.
this.chart = new DataCube({
chart: { tf: '1m '},
This is only an issue with ohlcv chart I guess?
@Swoorup nope, the error not about missing TF but not able to get chart ref because its undefined. I found my problem.
I was using v-if on TradingView component while loading chart data. Removing it fixed the issue.
So the main problem is tv extensions do not check for undefined refs.