123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <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>
|