VUE 单页面使用 echart 窗口变化时的用法
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]

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,

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: {

解决方法是在路由勾子函数中把它给去掉,方法是
}
//页面走掉把事件给清除掉
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
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
ludou_se_only); } add_action(s
时间:2021-01-23
-
所以经常导致输错密码的
时间:2021-01-23
-
WordPress措施打开速度慢的
时间:2021-01-22
-
WordPress回覆评论自动添加
时间:2021-01-22
-
我们可以通过下面的代码
时间:2021-01-22
-
如何修改WordPress默认脚色
时间:2021-01-20
-
同样的修改文件就行
时间:2021-01-20
-
少数善意的转载者既使没
时间:2021-01-20
热门文章
-
WordPress新手安装教程(图文)
时间:2020-12-28
-
在设置菜单中增加WordPress私密 隐藏的全部
时间:2021-01-10
-
WordPress博客程序常见错误的解决方法
时间:2020-12-28
-
WordPress程序打开速度慢的三种解决方法
时间:2021-01-10
-
wordpress使用代码在每篇文章尾部添加版权
时间:2020-12-14
-
WordPress博客措施常见错误的办理要领
时间:2021-01-15
-
关于WordPress的SEO优化相关的一些PHP页面脚
时间:2021-01-07
-
WordPress措施打开速度慢的三种办理要领
时间:2021-01-22
-
详解WordPress中的头像缓存和署理中的缓存
时间:2021-01-15
-
少数善意的转载者既使没有看到版权信息
时间:2021-01-20
