123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- <html>
- <head>
- <meta charset="utf-8">
- <script src="esl.js"></script>
- <script src="config.js"></script>
- </head>
- <body>
- <style>
- #main {
- position: relative;
- text-align: center;
- }
- .title {
- display: block;
- cursor: pointer;
- text-decoration: none;
- clear: both;
- text-align: center;
- margin: 0;
- background: #eef;
- line-height: 22px;
- }
- .block {
- display: inline-block;
- *display: inline;
- *zoom: 1;
- vertical-align: top;
- margin: 30px 0 30px 50px;
- }
- .block .ec {
- width: 800px;
- height: 240px;
- }
- .block .info {
- display: block;
- text-align: left;
- background: #eee;
- border-radius: 3px;
- font-size: 12px;
- line-height: 18px;
- padding: 0 5px;
- }
- .block .info td {
- font-size: 12px;
- border: 1px solid #bbb;
- padding: 1px 3px;
- }
- strong {
- color: red;
- font-weight: bold;
- font-size: 18px;
- padding: 0 3px;
- }
- </style>
- <div id="main"></div>
- <script>
- var echarts;
- var zrUtil;
- var charts = [];
- var els = [];
- require([
- 'echarts',
- 'zrender/core/util',
- 'echarts/chart/line',
- 'echarts/chart/scatter',
- 'echarts/component/legend',
- 'echarts/component/grid',
- 'echarts/component/tooltip',
- 'echarts/component/toolbox',
- 'echarts/component/dataZoom'
- ], function (ec, zu) {
- echarts = ec;
- zrUtil = zu;
- renderTitle('Order sensitive in processing: no min/max on y (<strong>Try zooming y slider to check if normal</strong>)');
- makeChart(getOption(
- makeSpecialTrendData(),
- {
- xAxisType: 'value',
- xStart: 15,
- xEnd: 80,
- yScale: true,
- symbolSize: 5
- }
- ), 500);
- renderTitle('Order sensitive in processing: min/max set on y (<strong>Try zooming y slider to check if normal</strong>)');
- makeChart(getOption(
- makeSpecialTrendData(),
- {
- xAxisType: 'value',
- xStart: 15,
- xEnd: 80,
- yScale: true,
- symbolSize: 5,
- yMin: 500,
- yMax: 3000
- }
- ), 500);
- renderTitle('Order sensitive in processing: only max set on y and scale (<strong>Try zooming y slider to check if normal</strong>)');
- makeChart(getOption(
- makeSpecialTrendData(),
- {
- xAxisType: 'value',
- xStart: 15,
- xEnd: 80,
- yScale: true,
- symbolSize: 5,
- yMax: 3000
- }
- ), 500);
- renderTitle('Order sensitive in processing: only max set on y and no scale (<strong>Try zooming y slider to check if normal</strong>)');
- makeChart(getOption(
- makeSpecialTrendData(),
- {
- xAxisType: 'value',
- xStart: 15,
- xEnd: 80,
- yScale: false,
- symbolSize: 5,
- yMax: 3000
- }
- ), 500);
- });
- function makeSpecialTrendData() {
- var data = {data1: []};
- var base = -100;
- for (var i = 0; i < 50; i++) {
- if (i < 10) {
- data.data1.push([i * 10, base += 197 + random(3)]);
- }
- else if (i < 20) {
- data.data1.push([i * 10, base -= 17 + random(3)]);
- }
- else if (i < 30) {
- data.data1.push([i * 10, base += 3 + random(3)]);
- }
- else if (i < 40) {
- data.data1.push([i * 10, base -= 5 + random(3)]);
- }
- else {
- data.data1.push([i * 10, base += 157 + random(3)]);
- }
- }
- return data;
- }
- function renderTitle(label) {
- var containerEl = document.getElementById('main');
- var el = document.createElement('a');
- el.className = 'title';
- var html = label; // label is html
- el.innerHTML = html;
- el.href = '#' + html.replace(/\s/g, '_');
- el.name = html.replace(/\s/g, '_');
- containerEl.appendChild(el);
- }
- function makeChart(opt, height) {
- var heightStyle = height ? ' style="height:' + height + 'px;" ' : '';
- var containerEl = document.getElementById('main');
- var el = document.createElement('div');
- el.className = 'block';
- el.innerHTML = '<div ' + heightStyle + ' class="ec"></div><div class="info"></div>';
- containerEl.appendChild(el);
- var chart = echarts.init(el.firstChild, null, {renderer: 'canvas'});
- chart.setOption(opt);
- charts.push(chart);
- els.push(el);
- chart.on('dataZoom', zrUtil.curry(renderProp, chart, el, false));
- renderProp(chart, el, true);
- }
- function renderProp(chart, el, isInit) {
- var resultOpt = chart.getOption();
- var dataZoomOpt = zrUtil.map(resultOpt.dataZoom, function (rawOpt) {
- return ''
- + '<tr>'
- + '<td>name:</td><td>' + encodeHTML(rawOpt.name) + '</td>'
- + '<td>start:</td><td>' + encodeHTML(rawOpt.start) + '</td>'
- + '<td>end:</td><td>' + encodeHTML(rawOpt.end) + '</td>'
- + '<td>startValue:</td><td>' + encodeHTML(rawOpt.startValue) + '</td>'
- + '<td>endValue:</td><td>' + encodeHTML(rawOpt.endValue) + '</td>'
- + '</tr>';
- });
- el.lastChild.innerHTML = ''
- + (isInit ? 'ON_INIT: ' : 'ON_EVENT: ') + '<br>'
- + '<table><tbody>' + dataZoomOpt.join('') + '</tbody></table>';
- }
- function encodeHTML(source) {
- return source == null
- ? ''
- : String(source)
- .replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"')
- .replace(/'/g, ''');
- }
- function random(max) {
- return +(Math.random() * max).toFixed(3);
- };
- function getOption(data, args) {
- args = zrUtil.defaults(
- args || {},
- {
- symbol: null,
- xStart: 1,
- xEnd: 5,
- yStart: 0,
- yEnd: 100,
- yFitlerMode: 'empty',
- symbolSize: 10
- }
- );
- var option = {
- animation: false,
- legend: {
- data: ['n1', 'n2']
- },
- toolbox: {
- feature: {
- dataView: {},
- dataZoom: {show: true},
- restore: {show: true},
- saveAsImage: {}
- }
- },
- tooltip: {
- trigger: 'axis'
- },
- xAxis: {
- type: args.xAxisType,
- splitLine: {
- show: true
- },
- data: args.xAxisData
- },
- yAxis: {
- scale: args.yScale,
- type: 'value',
- min: args.yMin,
- max: args.yMax,
- splitLine: {
- show: true
- }
- },
- dataZoom: [
- {
- id: 'xSlider',
- name: 'xSlider',
- show: true,
- filterMode: args.xFilterMode,
- xAxisIndex: [0],
- start: args.xStart,
- end: args.xEnd
- },
- {
- name: 'ySlider',
- show: true,
- filterMode: args.yFitlerMode,
- yAxisIndex: [0],
- start: args.yStart,
- end: args.yEnd
- },
- {
- name: 'xInside',
- type: 'inside',
- filterMode: args.xFilterMode,
- xAxisIndex: [0],
- start: args.xStart,
- end: args.xEnd
- },
- {
- name: 'yInside',
- type: 'inside',
- filterMode: args.yFilterMode,
- yAxisIndex: [0],
- start: args.yStart,
- end: args.yEnd
- }
- ],
- series: [
- {
- name: 'n1',
- type: 'line',
- symbolSize: args.symbolSize,
- symbol: args.symbol,
- data: data.data1
- },
- {
- name: 'n2',
- type: 'line',
- symbol: args.symbol,
- symbolSize: args.symbolSize,
- data: data.data2
- }
- ]
- };
- if (!data.data2) {
- option.series.splice(1, 1);
- }
- return option;
- }
- </script>
- </body>
- </html>
|