思路:监听datazoom事件,同时更新option的datazoom属性。
template:`
<div>
//监测datazoom事件,进行处理
<v-chart :options="options1" @datazoom='onDataZoom($event,options1)' />
</div>
`,
data:function(){
return {
options1:{
...
dataZoom: [{
type: 'inside',
start: 0,
end: 100,
zoomOnMouseWheel:'ctrl'
}, {
start: 0,
end: 100
}],
...
}
}
},
methods:{
onDataZoom(event,option){
if(event.batch){ //若是滚轮缩放
options.dataZoom[0].start = event.batch[0].start
options.dataZoom[1].start = event.batch[0].start
options.dataZoom[0].end = event.batch[0].end
options.dataZoom[1].end = event.batch[0].end
}else{ //滚动条缩放
options.dataZoom[0].start = event.start
options.dataZoom[1].start = event.start
options.dataZoom[0].end = event.end
options.dataZoom[1].end = event.end
}
}
}