以间隔更改交易视图小部件的代码 [英] Change ticker of tradingview widget with an interval
本文介绍了以间隔更改交易视图小部件的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能真的很简单,但我就是不知道如何更改 Tradingview 小部件中的股票代码.我希望图表更改为我得到的数组中的代码.图表需要每 30 秒更换一次新的代码,并且永远如此.
这是我目前得到的:
希望大家帮帮我.已经为此苦苦挣扎了太久.
解决方案
尝试使用:
setInterval(function(){创建图表()}, 10000);
由于某些原因,它通常不会以其他方式工作
It's probably really easy but I just can't figure out how to change the ticker symbol in the Tradingview widget. I want the chart to change to the tickers in a array i got. The chart needs to change every 30 seconds with a new ticker and do that forever.
This is what I got so far:
<div class="tradingview-widget-container">
<div id="tradingview_5889e"></div>
<div class="tradingview-widget-copyright"><a href="https://www.tradingview.com/symbols/NYSE-RIG/" rel="noopener" target="_blank"><span class="blue-text">RIG</span> <span class="blue-text">chart</span> by TradingView</a></div>
<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>
<script type="text/javascript">
var i = 0
function createchart(){
var companies = ['NYSE:SDRL','NYSE:RIG','CHXEUR:SEVDRO','NYSE:TK','CHXEUR:GBBP']
new TradingView.widget(
{
"width": 980,
"height": 610,
"symbol": companies[i],
"interval": "15",
"timezone": "Etc/UTC",
"theme": "Light",
"style": "1",
"locale": "en",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"hide_top_toolbar": true,
"save_image": false,
"hideideas": true,
"container_id": "tradingview_5889e"
}
);
i++;
}
setInterval(createchart(),10000)
</script>
</div>
Hope you guys can help me out. Been struggeling on this for way too long.
解决方案
Try using:
setInterval(function(){
createchart()
}, 10000);
For some reasons it usually doesnt work the other way
这篇关于以间隔更改交易视图小部件的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文