| <!DOCTYPE html> | |
| <!-- | |
| 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"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | |
| <script src="lib/simpleRequire.js"></script> | |
| <script src="lib/config.js"></script> | |
| <script src="lib/jquery.min.js"></script> | |
| <script src="lib/facePrint.js"></script> | |
| <script src="lib/testHelper.js"></script> | |
| <link rel="stylesheet" href="lib/reset.css"> | |
| </head> | |
| <body> | |
| <style> | |
| .test-title { | |
| background: #146402; | |
| color: #fff; | |
| } | |
| </style> | |
| <div id="main0"></div> | |
| <script> | |
| require([ | |
| 'echarts', | |
| './data/life-expectancy.json' | |
| ], function (echarts, data) { | |
| var option = { | |
| grid: { | |
| left: 0, | |
| bottom: 0, | |
| containLabel: true, | |
| top: 80 | |
| }, | |
| xAxis: { | |
| type: 'value' | |
| }, | |
| yAxis: { | |
| type: 'value', | |
| scale: true | |
| }, | |
| toolbox: { | |
| feature: { | |
| dataZoom: {} | |
| } | |
| }, | |
| dataZoom: { | |
| type: 'inside' | |
| }, | |
| series: [] | |
| }; | |
| var series = data.series; | |
| option.visualMap = { | |
| show: false, | |
| min: 0, | |
| max: 100, | |
| dimension: 1 | |
| }; | |
| option.legend = { | |
| // data: data.countries.map(function (item) {return item[2];}), | |
| selectedMode: 'single', | |
| right: 100 | |
| }; | |
| data.countries.forEach(function (country) { | |
| var data = series.map(function (yearData) { | |
| var item = yearData.filter(function (item) { | |
| return item[3] === country[2]; | |
| })[0]; | |
| return { | |
| label: { | |
| normal: { | |
| position: 'top', | |
| show: item[4] % 20 === 0 && item[4] > 1940 | |
| }, | |
| emphasis: { | |
| position: 'top', | |
| show: true | |
| } | |
| }, | |
| name: item[4], | |
| value: item | |
| }; | |
| }); | |
| var links = data.map(function (item, idx) { | |
| return { | |
| source: idx, | |
| target: idx + 1 | |
| }; | |
| }); | |
| links.pop(); | |
| option.series.push({ | |
| name: country[2], | |
| type: 'graph', | |
| coordinateSystem: 'cartesian2d', | |
| data: data, | |
| links: links, | |
| edgeSymbol: ['none', 'arrow'], | |
| edgeSymbolSize: 5, | |
| legendHoverLink: false, | |
| lineStyle: { | |
| normal: { | |
| color: '#333' | |
| } | |
| }, | |
| itemStyle: { | |
| normal: { | |
| borderWidth: 1, | |
| borderColor: '#333' | |
| } | |
| }, | |
| label: { | |
| normal: { | |
| textStyle: { | |
| color: '#333' | |
| } | |
| } | |
| }, | |
| symbolSize: 10, | |
| animationDelay: function (idx) { | |
| return idx * 100; | |
| } | |
| }); | |
| }); | |
| testHelper.create(echarts, 'main0', { | |
| option: option | |
| }); | |
| }); | |
| </script> | |
| </body> | |
| </html> |