如何用代码控制开始缩放模式开启
(toolbox.feature.dataZoom)是工具栏里的内置的缩放,正常使用是鼠标点击开启后,在图表中框选放大的范围。
想要实现的效果是,不需要去点击开启,可以直接在图表中框选。
查看了api,没有开启的方法或action。
配置项如下
var base = +new Date(2016, 9, 3);
var oneDay = 24 * 3600 * 1000;
var valueBase = Math.random() * 300;
var data = [];
for (var i = 1; i < 10; i++) {
var now = new Date(base += oneDay);
var dayStr = [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('-');
valueBase = Math.round((Math.random() - 0.5) * 20 + valueBase);
valueBase <= 0 && (valueBase = Math.random() * 300);
data.push([dayStr, valueBase]);
}
option = {
animation: false,
title: {
left: 'center',
text: '如何用代码开启toolbox.dataZoom的鼠标框选',
},
legend: {
top: 'bottom',
data: ['意向']
},
tooltip: {
triggerOn: 'none',
position: function(pt) {
return [pt[0], 130];
}
},
toolbox: {
left: 'center',
itemSize: 25,
top: 55,
feature: {
dataZoom: {
yAxisIndex: 'none'
},
restore: {}
}
},
xAxis: {
type: 'time',
splitLine: {
show: false
}
},
yAxis: {
type: 'value',
axisTick: {
inside: true
},
splitLine: {
show: false
},
axisLabel: {
inside: true,
formatter: '{value}\n'
},
z: 10
},
grid: {
top: 110,
left: 15,
right: 15,
height: 160
},
series: [{
name: '模拟数据',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 5,
sampling: 'average',
itemStyle: {
normal: {
color: '#8ec6ad'
}
},
stack: 'a',
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: '#8ec6ad'
}, {
offset: 1,
color: '#ffe'
}])
}
},
data: data
}
]
};