UNPKG

di-echarts

Version:

Apache ECharts is a powerful, interactive charting and data visualization library for browser

202 lines (189 loc) 6.89 kB
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <html> <head> <meta charset="utf-8"> <script src="lib/simpleRequire.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' ], 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>