echarts的legend显示不全_vue中的echarts的legend的显示问题

可以把option写在computed里面,option里面的变量可以通过写在method或者watch里,变量变化eCharts就会重新渲染

以下是我自己的一段代码:

computed里面的option:

computed: {

option () {

return {

legend: {

show: true,

bottom: 'bottom',

data: this.typeStr

},

grid: { // 调整图表与容器距离

left: '4%',

right: '4%',

containLabel: true

},

tooltip: {

trigger: 'axis'

},

xAxis: {

data: this.localDateStrAxis,

type: 'category',

min: 'datamin',

boundaryGap: true, // x坐标轴两端留白

axisLine: {

lineStyle: {

color: '#f0f0f0'

}

},

axisTick: {

lineStyle: {

color: '#f0f0f0'

}

},

axisLabel: {

color: '#5b5d61'

}

},

yAxis: this.yAxis,

series: this.series

}

}

}

watch里面的内容:

watch: {

// 值更新时即时更新eCharts

localValueAxis: {

handler: function (n, o) {

this.series = []

this.yAxis = []

for (let i = 0; i < n.length; i++) {

this.series.push({

name: this.typeStr[i],

type: 'line',

data: n[i],

yAxisIndex: i,

areaStyle: { opacity: 0.3 }

})

this.yAxis.push({

name: this.typeStr[i],

type: 'value',

axisLine: {

show: false

},

axisLabel: {

color: '#787a7d'

},

axisTick: {

show: false

},

splitNumber: 3,

splitLine: {

show: true

}

})

}

},

deep: true

}

}

不用太过在意watch里的具体代码,逻辑就是:当localValueAxis这个值变化后我让eCharts的yAxis、series等重新赋值,vue自然就会重新渲染eCharts了。希望能帮到题主。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值