• 一个页面多个echarts图表自适应


    methods 方法

        // 订单Echarts
        drawOrder () {
          this.charts = echarts.init(document.getElementById('order'))
          // 绘制图表
          this.charts.setOption({
            title: {
              text: '',
              subtext: '',
              left: 'center'
            },
            tooltip: {
              trigger: 'item',
            },
            // legend: {
            //   orient: 'horizontal',
            //   left: 'top',
            //   data: ['直接访问', '邮件营销', '联盟广告', '视频广告', '搜索引擎']
            // },
            series: [
              {
                name: '订单数量',
                type: 'pie',
                radius: '70%',
                center: ['50%', '60%'],
                data: [
                  { value: 335, name: '直接访问' },
                  { value: 310, name: '邮件营销' },
                  { value: 234, name: '联盟广告' },
                  { value: 135, name: '视频广告' },
                  { value: 1548, name: '搜索引擎' }
                ],
                emphasis: {
                  itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                  }
                }
              }
            ]
          });
        },

    自适应

    在需要window.onresize的函数内直接使用echarts.init()去取:

      mounted () {
        this.$nextTick(function () {
          // 图表自适应
          window.onresize = function () {
            echarts.init(document.getElementById("order")).resize();
            echarts.init(document.getElementById("ranking")).resize();
          };
          this.drawOrder()
          this.drawRanking()
        });
      },

     借鉴:https://www.pianshen.com/article/5586274051/

  • 相关阅读:
    Rust 总章
    GO 总章
    vue引入d3
    echarts地图修改高亮颜色及区域界线颜色
    vue+element 树形穿梭框组件
    element表格上下固定,内容高度自适应
    echarts在dialog弹框中不显示的解决方案
    echarts 饼图给外层加边框
    selenium等待元素出现
    Pycharm永久激活
  • 原文地址:https://www.cnblogs.com/xiaoxiao2017/p/14297369.html
Copyright © 2020-2023  润新知