TradingView全屏显示后,依旧保持可打开/关闭全屏功能
emer 发布于 2021-6-29 09:47 1546 次阅读
简单说,需要你自定义图表~
思路:就是将TradingView自带的全屏按钮给隐藏起来,然后自定义图表实现逻辑咯。
let's do it!
1.首先将header_fullscreen_button如下配置
disabled_features: [
"header_fullscreen_button", //隐藏头部全屏按钮
]
2.然后再chartReady函数里进行如下代码配置即可:
const buttonEvent = widget.createButton({align: "right"});
const button = buttonEvent[0];
button.title = '打开/关闭全屏';
button.className = 'button fullscreen iconed apply-common-tooltip';
buttonEvent.append($('<span class="icon-full"><img src="/static/images/iconfull.png"></span>')); //图片地址
button.onclick = function() {
const tvid = $('#tv_chart_container')[0];
if (tvid.className === 'tv_chart_container_full') {
tvid.className = '';
return;
}
tvid.className = 'tv_chart_container_full';
}