charting-library-tutorial icon indicating copy to clipboard operation
charting-library-tutorial copied to clipboard

npx serve fail to load data correctly: Cannot read property 'time' of undefined

Open vozni4iy opened this issue 3 years ago • 4 comments

I tried to complete the tutorial. First of all, I need to change container to container_id in main.js to avoid an error. When I run npx serve, I see graph to be build, but no candles data to load. In a console I see an error Uncaught TypeError: Cannot read property 'time' of undefined at Socket. (streaming.js:45) at Socket.Emitter.emit (index.js:133) at Socket.onevent (socket.js:270) at Socket.onpacket (socket.js:228) at Manager. (index.js:21) at Manager.Emitter.emit (index.js:133) at Manager.ondecoded (manager.js:332) at Decoder. (index.js:21) at Decoder.Emitter.emit (index.js:134) at Decoder.add (index.js:246)

When I try to find out what is happening, I see that lastDailyBar is undefined, and those lines

if (firstDataRequest) {
           lastBarsCache.set(symbolInfo.full_name, {
					...bars[bars.length - 1],
				});
			}

didn't fire because firstDataRequest is undefined, too. So never get the first candle and all others are undefined

vozni4iy avatar May 06 '21 12:05 vozni4iy

I need to change container to container_id in main.js to avoid an error.

That's because tutorial is adapted to be used with the latest unstable charting library version (which is v19 at the time), I think we need to mark it somewhere in the docs...

When I try to find out what is happening, I see that lastDailyBar is undefined, and those lines

Can you please try with the latest unstable version? I think it's related because we've changed the API in v19 for requesting bars.

timocov avatar May 06 '21 12:05 timocov

Thanks a lot! Seems working with unstable version. If I find other issues I will update.

vozni4iy avatar May 06 '21 13:05 vozni4iy

@timocov could you please help: I added 1H and 4H to supported_resolutions, but they didn't work. Resolutions are added to the dropdown, but when I click it dropped back to 1D. Day, week and month resolution works ok. Did I do something wrong or do I need external conditions (like paid plan) to enable resolutions less than 1D? I checked that in tradingview chart demo 1h interval could be enabled, but I can't do this in my project.

vozni4iy avatar May 07 '21 08:05 vozni4iy

Day, week and month resolution works ok. Did I do something wrong or do I need external conditions (like paid plan) to enable resolutions less than 1D?

Your symbols should support such resolutions, see https://github.com/tradingview/charting_library/wiki/Symbology#supported_resolutions

timocov avatar May 07 '21 15:05 timocov