echart vue 图表大小_vue echarts监听页面随页面大小变化而刷新图表

mounted() {

this.draw();

window.addEventListener('resize', this.draw)

},

beforeRouteLeave(to, from, next) {

// 离开页面时取消监听

window.removeEventListener('resize', this.draw)

next()

},

methods: {

draw() {

// 基于准备好的dom,初始化echarts实例

this.chart = this.$echarts.init(document.getElementById("centreLeft2Chart"));

// ----------------------------------------------------------------

let option = {

tooltip: {

trigger: 'axis',

show: true,

},

legend: {

show: true,

icon: 'circle',

top: 0,

textStyle: {

fontSize: 12,

color: '#9bc7c7'

},

},

grid: {

left: '5%',

right: '5%',

top: '15%',

bottom: '6%',

containLabel: true

},

xAxis: {

splitLine: {

show: false

},

axisTick: {

show: false

},

axisLine: {

lineStyle: {

color: '#2b5050',

width: 1,//这里是为了突出显示加上的

},

},

axisLabel: {

textStyle: {

color: '#b6e5e5', //更改坐标轴文字颜色

fontSize: 12 //更改坐标轴文字大小

}

},

data: ['11-26', '11-26', '11-26', '11-26', '11-26', '11-26', '11-26']

},

yAxis: {

axisLine: {

lineStyle: {

color: '#2b5050',

width: 1,//这里是为了突出显示加上的

},

},

axisLabel: {

textStyle: {

color: '#b6e5e5', //更改坐标轴文字颜色

fontSize: 12 //更改坐标轴文字大小

}

},

axisTick: {

show: false

},

splitLine: {

show: false

}

},

series: [{

name: '外来人员滞留人次',

type: 'line',

smooth: true,

symbol: 'circle',

symbolSize: 10,

itemStyle: {

color: '#77f0ff',

},

data: [5, 10, 41, 35, 51, 49, 62]

},

{

name: '本单位外出未归人次',

type: 'line',

smooth: true,

symbol: 'circle',

symbolSize: 10,

itemStyle: {

color: '#00c75f',

},

data: [50, 20, 35, 20, 75, 30, 60]

},

{

name: '黑名单人员入侵人次',

type: 'line',

smooth: true,

symbol: 'circle',

symbolSize: 10,

itemStyle: {

color: '#f5d500',

},

data: [15, 30, 15, 40, 55, 20, 40]

},

]

};

this.chart.clear();

this.chart.resize();

this.chart.setOption(option);

}

},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值