全屏按钮实现:
let element = document.getElementById("container")
if(element.requestFullscreen){
element.requestFullscreen()
document.getElementById("container").style.position = "absolute"
}
element.requestFullscreen()可实现全屏,position = "absolute"解决esc退出全屏后图表外的容器错位与无背景色的问题
缩放按钮实现
首先在图表series里定义zoom:1 roam:true
添加 监听graphroam:
this.graphEchart.on('graphroam',function(params){
if('zoom' in params){
if(params.zoom > 1){
this.zoom += 0.2
}else{
this.zoom -= 0.2
}
}
})
添加放大按钮事件:
this.zoom += 0.2
this,option.series[0].zoom = this.zoom
this.graphEchart.setOption(this.zoom)
添加缩小按钮事件:
this.zoom -= 0.2
this,option.series[0].zoom = this.zoom
this.graphEchart.setOption(this.zoom)