echarts图表全屏

本文详细介绍了如何使用Echarts实现图表的全屏功能,包括配置项设置、全屏事件监听以及不同浏览器的全屏API兼容处理。通过对`toolbox`配置项的定制,实现了全屏按钮的展示和点击事件,触发图表元素的全屏显示和退出全屏操作。代码中还包含了窗口大小变化时图表的自动调整大小逻辑。
摘要由CSDN通过智能技术生成
toolbox:{
                show: true,
                feature: {
                  // dataView: { show: true },
                  // dataZoom: { show: true },
                  // restore: { show: true },
                  // saveAsImage: { show: true },
                  myFull: {
                    show: true,
                    title: '全屏查看',
                    icon: 'path://M432.45,595.444c0,2.177-4.661,6.82-11.305,6.82c-6.475,0-11.306-4.567-11.306-6.82s4.852-6.812,11.306-6.812C427.841,588.632,432.452,593.191,432.45,595.444L432.45,595.444z M421.155,589.876c-3.009,0-5.448,2.495-5.448,5.572s2.439,5.572,5.448,5.572c3.01,0,5.449-2.495,5.449-5.572C426.604,592.371,424.165,589.876,421.155,589.876L421.155,589.876z M421.146,591.891c-1.916,0-3.47,1.589-3.47,3.549c0,1.959,1.554,3.548,3.47,3.548s3.469-1.589,3.469-3.548C424.614,593.479,423.062,591.891,421.146,591.891L421.146,591.891zM421.146,591.891',
                    onclick: (e) => {
                      this.fullFlag = true
                      let element = document.getElementById('onejinshui');
                      // element.setOption(pacchartOption4);
                      if (element.requestFullScreen) { // HTML W3C 提议
                        element.requestFullScreen();
                      } else if (element.msRequestFullscreen) { // IE11
                        element.msRequestFullScreen();
                      } else if (element.webkitRequestFullScreen) { // Webkit (works in Safari5.1 and Chrome 15)
                        element.webkitRequestFullScreen();
                      } else if (element.mozRequestFullScreen) { // Firefox (works in nightly)
                        element.mozRequestFullScreen();
                      }
                      // 退出全屏
                      if (element.requestFullScreen) {
                        document.exitFullscreen();
                      } else if (element.msRequestFullScreen) {
                        document.msExitFullscreen();
                      } else if (element.webkitRequestFullScreen) {
                        document.webkitCancelFullScreen();
                      } else if (element.mozRequestFullScreen) {
                        document.mozCancelFullScreen();
                      }
                    },
                  }
                }
              },
          this.pacchart= echarts.init(document.getElementById('onejinshui'));

        this.pacchart.setOption(pacchartOption4);

created(){
      this.rangeDate = this.timeDefault;
      let that = this
      window.onresize = function(){
        if(that.pacchart){
          that.pacchart.resize()
        }
        if(that.twojinshui){
          that.twojinshui.resize()
        }
        if(that.yuanshuichart){
          that.yuanshuichart.resize()
        }
        if(that.dixiashuichart){
          that.dixiashuichart.resize()
        }
      } 
    },
遍历图表全屏
 onclick: (e,index) => {
                        this.fullFlag = true
                        console.log('------',index.getDom())
                          const element = index.getDom()
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值