blob: 564f3a8852446e359a7a5482acf5a160cbcbefb2 [file] [log] [blame]
<html>
<head>
<meta charset="utf-8">
<script src="lib/esl.js"></script>
<script src="lib/config.js"></script>
</head>
<body>
<style>
html, body{
padding: 0;
margin: 0;
}
#main {
height: 500px;
}
body {
margin: 0;
}
h3 {
text-align: center;
background: #eee;
line-height: 30px;
}
</style>
<h3>
Check the highlighted label while data zooming.<br>
Check the minSpan and maxSpan (both in slider and inside and toolbox zoom).
</h3>
<div id="main"></div>
<script>
require([
'echarts'
// 'echarts/chart/bar',
// 'echarts/chart/line',
// 'echarts/component/legend',
// 'echarts/component/grid',
// 'echarts/component/axis',
// 'echarts/component/dataZoom',
// 'echarts/component/tooltip',
// 'echarts/component/toolbox',
// 'echarts/component/markPoint',
// 'echarts/component/markLine'
], function (echarts) {
chart = echarts.init(document.getElementById('main'), null, {
});
var xAxisData = [];
var data1 = [];
var data2 = [];
var data3 = [];
for (var i = 0; i < 200; i++) {
var data1Val;
var data2Val;
var data3Val;
if (Math.random() < 0.03) {
data1Val = '-';
data2Val = '-';
data3Val = '-';
}
else {
data1Val = (Math.random() + 0.1).toFixed(2);
data2Val = (Math.random() + 1).toFixed(2);
data3Val = Math.random().toFixed(2);
}
if (i === 10 || i === 16) {
xAxisData.push({
value: '类目' + i,
textStyle: {
fontSize: 14,
color: 'red',
fontWeight: 'bold'
}
});
data1.push({
value: data1Val,
itemStyle: {
normal: {
color: 'yellow'
}
}
});
data2.push(data2Val);
data3.push(data3Val);
}
else {
xAxisData.push(i);
data1.push(data1Val);
data2.push(data2Val);
data3.push(data3Val);
}
}
chart.setOption({
legend: {
data: ['bar', 'line', 'bar3']
},
tooltip: {
trigger: 'axis'
},
toolbox: {
feature: {
dataZoom: {
show: true,
xAxisIndex: false
},
saveAsImage: {},
restore: {show: true}
}
},
yAxis: {
data: xAxisData,
// inverse: true,
boundaryGap: false
},
xAxis: {
// inverse: true,
// scale: true
},
series: [
{
name: 'line',
type: 'line',
// stack: 'all',
data: data2,
smooth: true
},
{
name: 'bar3',
type: 'bar',
stack: 'all',
data: data3,
smooth: 0.1
},
{
name: 'bar',
type: 'bar',
data: data1,
smooth: true,
stack: 'all',
itemStyle: {
normal: {
areaStyle: {}
}
},
markPoint: {
data: [{
type: 'max'
}]
},
markLine: {
data: [
[{
type: 'average'
}, {
type: 'max'
}]
]
}
}
],
dataZoom: [
{
show: true,
startValue: 2,
end: 30,
borderColor: 'rgba(0,0,0,0.15)',
backgroundColor: 'rgba(200,200,200,0)',
yAxisIndex: 0,
minValueSpan: 5,
maxValueSpan: 80
},
{
type: 'inside',
startValue: 2,
end: 30,
yAxisIndex: 0,
minSpan: 5,
maxSpan: 80
}
]
});
})
</script>
</body>
</html>