WordPress

推荐列表 站点导航

当前位置:首页 > 建站教程 > WordPress >

VUE 单页面使用 echart 窗口变化时的用法

来源:网络整理  作者:  发布时间:2020-12-19 05:02
在VUE项目中,为了使echart在窗口变化时能够自适应,要用到window.resize=function(){.......};但是我在项目刚开始的时间就有...
beforeRouteLeave(to, from, next) {

if (!this.chart) {

},

title: {

二、chart.vue

handler(val) {

mounted() {

},

itemWidth: 4, // 图例标记的图形宽度

},

以上这篇VUE 单页面使用 echart 窗口变化时的用法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

},

mixins: [resize],

$_destroyResizeEvent() {

icon: 'rect',

stack: '总量',

// use $_ for mixins properties

type: 'line',

height: {

* @param {Function} func

className: {

};  

},

},

四、debounce.js

三、resize.js

},

},

},

required: true

// https://github.com/PanJiaChen/vue-element-admin/issues/2116

methods: {

},

default: true

}, 100)()

containLabel: true

// 如果延时不存在,重新设定延时

resixeFu 就是图表变化时的方法

type: String,

// to fixed bug when cached by keep-alive

const later = function() {

data: [820, 932, 901, 934, 1290, 1330, 1320]

chartData: {

next()

},

* @param {boolean} immediate

},

}  

name: '联盟广告',

引入chart图表``

data() {

type: 'line',

window.removeEventListener("resize", this.resizeFu,false);

this.chart.resize()

},

开发中用到了echart图表,需要图表自适应大小resize,一开始使用的方法是:

},

type: 'value'

props: {

textStyle: {

this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)

},

补充知识:vue+echart图表自适应屏幕大小、点击侧边栏展开收缩图表自适应大小resize

},

但里面有一个问题就是:每次进来当前页面都会执行 window.addEventListener

$_sidebarResizeHandler(e) {

}

return {

},

timestamp = +new Date()

const callNow = immediate && !timeout

if(div && this.changeData.DataTime.length>0){

autoResize: {

chartData: {

name: '直接访问',

但是我在项目刚开始的时间就有一个地方的高度变化使用了 window.resize ,在里面再次使用 会覆盖掉原来的,所以在里面图表使用时可以用

type: String,

result = func.apply(context, args)

但是又遇到一个问题,点击侧边栏的展开收起的时候,图表的大小没有自适应(因为窗口的大小没有变化)

let div = document.getElementById('changeData');

}

this.initChart()

this.setOptions(val)

setOptions(chartData) {

return result

export default {

</script>  

fontSize: 14

window.onresize = function () {

一、index.vue的文件

this.chart.dispose()

this.$_initSidebarResizeEvent()

}

},

if (callNow) {

}

this.$_destroySidebarResizeEvent()

text: '3-1(2)',

},

}

trigger: 'axis'

}

default: '300px'

}

},

this.$_initResizeEvent()

type: 'line',

},

}

}

default: '100%'

itemHeight: 11,

this.$_initResizeEvent()

beforeDestroy() {

}

deep: true,

window.addEventListener('resize',this.resizeFu,false);  

return debounce(() => {

{

})

if (!immediate) {

deactivated() {

return function(...args) {

{

这里是数据

tooltip: {

this.$_destroyResizeEvent()

// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用

chart: null

watch: {

if (!timeout) timeout = setTimeout(later, wait)

timeout = null

return

$_destroySidebarResizeEvent() {

resizeFu(){

this.$_destroyResizeEvent()

{

import echarts from 'echarts'

this.chart = echarts.init(this.$el, 'macarons')

data() {

在 VUE 项目中,为了使 echart 在窗口变化时能够自适应,要用到 window.resize = function(){ .......};

}

<script>

type: 'category',

<template>

fontSize: 14

$_initSidebarResizeEvent() {

}

result = func.apply(context, args)

boundaryGap: false,

this.$_initSidebarResizeEvent()

$_sidebarElm: null

type: Boolean,

if (this.chart) {

}

$_resizeHandler() {

return {

stack: '总量',

},

if (last < wait && last > 0) {

*/

}

window.removeEventListener('resize', this.$_resizeHandler)

}

lineHeight: 65,

this.myChart.resize();

type: String,

name: '搜索引擎',

export function debounce(func, wait, immediate) {

width: {

type: 'line',

import resize from './mixins/resize'

<div :class="className" :style="{height:height,width:width}" />

let timeout, args, context, timestamp, result

},

textStyle: {

this.$_destroySidebarResizeEvent()

},

import { debounce } from './debounce'

initChart() {

},

},

},

data: [220, 12, 191, 234, 20, 330, 10]

this.$nextTick(() => {

if (e.propertyName === 'width') {

}  

data: [15, 232, 201, 154, 190, 330, 110]

VUE 单页面使用 echart 窗口变化时的用法 (https://www.wpmee.com/) javascript教程 第2张

const last = +new Date() - timestamp

mounted() {

$_initResizeEvent() {

this.$_resizeHandler()

bottom: '3%',

right: '4%',

},

color: '#979797',

}

this.chartsDiv.changeData.resize();

}  

* @param {number} wait

这里参考vue+element+admin的框架写的自适应

}

series: [

grid: {

this.chart = null

stack: '总量',

xAxis: {

default: 'chart'

}

if (!timeout) context = args = null

legend: {

stack: '总量',

* @return {*}

name: '视频广告',

{

},

type: 'line',

methods: {

} else {

]

</template>

},  

type: Object,

VUE 单页面使用 echart 窗口变化时的用法 (https://www.wpmee.com/) javascript教程 第1张

left: '3%',

this.chart.setOption(chartData)

// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential

context = args = null

this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)

}

beforeDestroy() {

},

timeout = setTimeout(later, wait - last)

// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait

// 据上一次触发时间间隔

data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']

chartData: {

context = this

{

stack: '总量',

yAxis: {

VUE 单页面使用 echart 窗口变化时的用法 (https://www.wpmee.com/) javascript教程 第3张

解决方法是在路由勾子函数中把它给去掉,方法是

}

//页面走掉把事件给清除掉

this.setOptions(this.chartData)

export default {

}  

data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']

activated() {

/**

data: [320, 420, 301, 334, 60, 330, 320]

this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]

}

name: '邮件营销',

data: [0, 132, 101, 134, 90, 230, 210]

window.addEventListener('resize', this.$_resizeHandler)

},

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jz/wp/5473.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

VUE 单页面使用 echart 窗口变化时的用法

2020-12-19 编辑:

beforeRouteLeave(to, from, next) {

if (!this.chart) {

},

title: {

二、chart.vue

handler(val) {

mounted() {

},

itemWidth: 4, // 图例标记的图形宽度

},

以上这篇VUE 单页面使用 echart 窗口变化时的用法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

},

mixins: [resize],

$_destroyResizeEvent() {

icon: 'rect',

stack: '总量',

// use $_ for mixins properties

type: 'line',

height: {

* @param {Function} func

className: {

};  

},

},

四、debounce.js

三、resize.js

},

},

},

required: true

// https://github.com/PanJiaChen/vue-element-admin/issues/2116

methods: {

},

default: true

}, 100)()

containLabel: true

// 如果延时不存在,重新设定延时

resixeFu 就是图表变化时的方法

type: String,

// to fixed bug when cached by keep-alive

const later = function() {

data: [820, 932, 901, 934, 1290, 1330, 1320]

chartData: {

next()

},

* @param {boolean} immediate

},

}  

name: '联盟广告',

引入chart图表``

data() {

type: 'line',

window.removeEventListener("resize", this.resizeFu,false);

this.chart.resize()

},

开发中用到了echart图表,需要图表自适应大小resize,一开始使用的方法是:

},

type: 'value'

props: {

textStyle: {

this.$_sidebarElm && this.$_sidebarElm.removeEventListener('transitionend', this.$_sidebarResizeHandler)

},

补充知识:vue+echart图表自适应屏幕大小、点击侧边栏展开收缩图表自适应大小resize

},

但里面有一个问题就是:每次进来当前页面都会执行 window.addEventListener

$_sidebarResizeHandler(e) {

}

return {

},

timestamp = +new Date()

const callNow = immediate && !timeout

if(div && this.changeData.DataTime.length>0){

autoResize: {

chartData: {

name: '直接访问',

但是我在项目刚开始的时间就有一个地方的高度变化使用了 window.resize ,在里面再次使用 会覆盖掉原来的,所以在里面图表使用时可以用

type: String,

result = func.apply(context, args)

但是又遇到一个问题,点击侧边栏的展开收起的时候,图表的大小没有自适应(因为窗口的大小没有变化)

let div = document.getElementById('changeData');

}

this.initChart()

this.setOptions(val)

setOptions(chartData) {

return result

export default {

</script>  

fontSize: 14

window.onresize = function () {

一、index.vue的文件

this.chart.dispose()

this.$_initSidebarResizeEvent()

}

},

if (callNow) {

}

this.$_destroySidebarResizeEvent()

text: '3-1(2)',

},

}

trigger: 'axis'

}

default: '300px'

}

},

this.$_initResizeEvent()

type: 'line',

},

}

}

default: '100%'

itemHeight: 11,

this.$_initResizeEvent()

beforeDestroy() {

}

deep: true,

window.addEventListener('resize',this.resizeFu,false);  

return debounce(() => {

{

})

if (!immediate) {

deactivated() {

return function(...args) {

{

这里是数据

tooltip: {

this.$_destroyResizeEvent()

// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用

chart: null

watch: {

if (!timeout) timeout = setTimeout(later, wait)

timeout = null

return

$_destroySidebarResizeEvent() {

resizeFu(){

this.$_destroyResizeEvent()

{

import echarts from 'echarts'

this.chart = echarts.init(this.$el, 'macarons')

data() {

在 VUE 项目中,为了使 echart 在窗口变化时能够自适应,要用到 window.resize = function(){ .......};

}

<script>

type: 'category',

<template>

fontSize: 14

$_initSidebarResizeEvent() {

}

result = func.apply(context, args)

boundaryGap: false,

this.$_initSidebarResizeEvent()

$_sidebarElm: null

type: Boolean,

if (this.chart) {

}

$_resizeHandler() {

return {

stack: '总量',

},

if (last < wait && last > 0) {

*/

}

window.removeEventListener('resize', this.$_resizeHandler)

}

lineHeight: 65,

this.myChart.resize();

type: String,

name: '搜索引擎',

export function debounce(func, wait, immediate) {

width: {

type: 'line',

import resize from './mixins/resize'

<div :class="className" :style="{height:height,width:width}" />

let timeout, args, context, timestamp, result

},

textStyle: {

this.$_destroySidebarResizeEvent()

},

import { debounce } from './debounce'

initChart() {

},

},

},

data: [220, 12, 191, 234, 20, 330, 10]

this.$nextTick(() => {

if (e.propertyName === 'width') {

}  

data: [15, 232, 201, 154, 190, 330, 110]

VUE 单页面使用 echart 窗口变化时的用法 (https://www.wpmee.com/) javascript教程 第2张

const last = +new Date() - timestamp

mounted() {

$_initResizeEvent() {

this.$_resizeHandler()

bottom: '3%',

right: '4%',

},

color: '#979797',

}

this.chartsDiv.changeData.resize();

}  

* @param {number} wait

这里参考vue+element+admin的框架写的自适应

}

series: [

grid: {

this.chart = null

stack: '总量',

xAxis: {

default: 'chart'

}

if (!timeout) context = args = null

legend: {

stack: '总量',

* @return {*}

name: '视频广告',

{

},

type: 'line',

methods: {

} else {

]

</template>

},  

type: Object,

VUE 单页面使用 echart 窗口变化时的用法 (https://www.wpmee.com/) javascript教程 第1张

left: '3%',

this.chart.setOption(chartData)

// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential

context = args = null

this.$_sidebarElm && this.$_sidebarElm.addEventListener('transitionend', this.$_sidebarResizeHandler)

}

beforeDestroy() {

},

timeout = setTimeout(later, wait - last)

// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait

// 据上一次触发时间间隔

data: ['邮件营销', '联盟广告', '视频广告', '直接访问', '搜索引擎']

chartData: {

context = this

{

stack: '总量',

yAxis: {

VUE 单页面使用 echart 窗口变化时的用法 (https://www.wpmee.com/) javascript教程 第3张

解决方法是在路由勾子函数中把它给去掉,方法是

}

//页面走掉把事件给清除掉

this.setOptions(this.chartData)

export default {

}  

data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']

activated() {

/**

data: [320, 420, 301, 334, 60, 330, 320]

this.$_sidebarElm = document.getElementsByClassName('sidebar-container')[0]

}

name: '邮件营销',

data: [0, 132, 101, 134, 90, 230, 210]

window.addEventListener('resize', this.$_resizeHandler)

},

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jz/wp/5473.shtml

相关文章

风云图片

推荐阅读

返回WordPress频道首页