vue 根据屏幕大小重新加载 echarts

摘要:
mounted(){this.resizefun=()=˃{this.$echarts.init(document.getElementById('myChart')).resize()};window.addEventListener('ssi
<template>
  <div     :style="{ '100%', height: '350px'}"></div>
</template>
mounted() {
  this.resizefun = ()=>{     this.$echarts.init(document.getElementById('myChart')).resize()   };   window.addEventListener('resize',this.resizefun); }
//移除事件监听
beforeDestroy() {
  window.removeEventListener('resize', this.resizefun);
  this.resizefun = null
}
// 基于准备好的dom,初始化echarts实例
        var myChart = this.$echarts.init(document.getElementById('myChart'));
        // 绘制图表
        myChart.setOption({
          tooltip : {
            trigger: 'axis',
            axisPointer : {            // 坐标轴指示器,坐标轴触发有效
              type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
            }
          },
          legend: {
            x:'left',
            icon: "roundRect",
            data:['交易金额','交易笔数']
          },
          toolbox: {
            show : false,
            orient: 'vertical',
            x: 'right',
            y: 'center',
            feature : {
              mark : {show: true},
              dataView : {show: true, readOnly: false},
              magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
              restore : {show: true},
              saveAsImage : {show: true}
            }
          },
          calculable : true,
          xAxis : [
            {
              type : 'category',
              data: [...this.dates]
            }
          ],
          yAxis : [
            {
              type : 'value',
              splitLine:{
                show:true,
                lineStyle:{
                  type:'dashed'
                }
              }
            }
          ],
          series : [
            {
              name:'交易金额',
              type:'bar',
              barWidth: 10,
              itemStyle: {
                normal: {
                  color: '#2464fc',
                  barBorderRadius:[10, 10, 0, 0],
                }
              },
              data:[...this.amounts],
            },
            {
              name:'交易笔数',
              type: "line",
              smooth:true,//平滑曲线
              itemStyle: {
                normal: {
                  color: '#c23531'
                }
              },
              data:[...this.counts],
            },
          ]
     });

 

屏幕放大:                                                                                                                         屏幕缩小:

vue 根据屏幕大小重新加载 echarts第1张                        vue 根据屏幕大小重新加载 echarts第2张

免责声明:文章转载自《vue 根据屏幕大小重新加载 echarts》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇xinetd网络(2) 协议头解析tmpfs使用探讨下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

vue项目准备工作(一)

1.写文档: 产品说明、工作日志、接口说明文档、数据库说明文档、项目架构说明文档等···· 例如:后台管理系统:商品的管理、店铺的管理、店铺类别管理、管理员的管理、用户管理等·····     前端渲染。前端站点、首页,用户界面。搜索。类别。详情。api:接口。 2.vue脚手架 1. 全局安装vue的脚手架 cnpm install @vu...

vscode Vue格式化HTML标签换行问题

解决方法:在设置里面直接贴上代码: "vetur.format.defaultFormatter.html": "js-beautify-html","vetur.format.defaultFormatterOptions": {"js-beautify-html": {"wrap_attributes": "auto",}}, 注: // 对属性进行换...

学习vue之windows下安装live-server 超级详细篇

最近项目要求用vue2.0所以开始着手学习。 前期准备: 下载Node.js 地址:http://nodejs.cn/download/ 选择自己对应的版本,我下载的是.msi 64位的 然后就双击下一步吧。完成之后,记得配置环境变量(不知道环境变量在哪里的 先拉到最下面) 因为我把Node.js安装到了D盘nodeJs目录下。 呼出cmd,命令走起 ,...

vue发布IIS踩坑记

步骤一:复制文件 把build之后的文件(dist文件夹)拷贝到IIS存放网站文件的目录 步骤二:在IIS中新建站点  在"网站"执行鼠标右键,选择添加网站。 网站名称:按照用途或者项目起名即可 应用程序池:部署前端项目,这个可以忽略,任意选择即可 内容目录:网站存放的路径,最好以英文命名 端口:端口自己设置即可 步骤三:访问网站  访问网站可以在II...

Vue 简单实例 地址选配8

我们可以看到所有的地址都是点亮的状态,就是外面都有个橙色的框。我们需要把默认地址,才设置为点亮的状态。 1、新建变量checkedIndex,默认为 0,然后把遍历地址列表,把字段isDefault为true的地址索引赋值给checkedIndex data() { return{ checkedIndex: 0, //默认选中的索引...

vue中使用v-chart改变柱状图颜色以及X轴Y轴的文字颜色和大小以及标题

1.html部分 <ve-histogram :tooltip-visible="true" :x-axis="xAxis" :y-axis="yAxis" :title="title"...