Struggling to integrate TradingView due to a recurring error when attempting to load the data:
vendor.js:782 Uncaught TypeError: Cannot read property 'loadChart' of undefined
The issue is specifically tied to the "item.load(data)" line.
To address this, I introduced a time delay using setTimeOut which worked for me as shown below:
setTimeout(function (){
item.load(data);
}, 500);
item.onChartReady(chartReadyHandler);
However, varying the delay from 500ms to 1000ms resulted in mixed outcomes among users. Increasing the timeout isn't a viable solution as it leads to delays and "Invalid Symbol" errors before loading correctly after 1s.
Is there a way to ensure that the data loads at the right time without resorting to trial and error with timeouts?
Efforts to place the code within chartReadyHandler proved futile, as it seems to trigger only after data has been loaded.
This dilemma has kept me stuck for two days now – any guidance would be greatly appreciated.