graph-grid-life.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <script src="lib/esl.js"></script>
  7. <script src="lib/config.js"></script>
  8. <script src="lib/jquery.min.js"></script>
  9. <script src="lib/facePrint.js"></script>
  10. <script src="lib/testHelper.js"></script>
  11. <link rel="stylesheet" href="lib/reset.css">
  12. </head>
  13. <body>
  14. <style>
  15. .test-title {
  16. background: #146402;
  17. color: #fff;
  18. }
  19. </style>
  20. <div id="main0"></div>
  21. <script>
  22. require([
  23. 'echarts'/*, 'map/js/china' */
  24. ], function (echarts) {
  25. $.getJSON('./data/life-expectancy.json', function (data) {
  26. var option = {
  27. grid: {
  28. left: 0,
  29. bottom: 0,
  30. containLabel: true,
  31. top: 80
  32. },
  33. xAxis: {
  34. type: 'value'
  35. },
  36. yAxis: {
  37. type: 'value',
  38. scale: true
  39. },
  40. toolbox: {
  41. feature: {
  42. dataZoom: {}
  43. }
  44. },
  45. dataZoom: {
  46. type: 'inside'
  47. },
  48. series: []
  49. };
  50. var series = data.series;
  51. option.visualMap = {
  52. show: false,
  53. min: 0,
  54. max: 100,
  55. dimension: 1
  56. };
  57. option.legend = {
  58. // data: data.countries.map(function (item) {return item[2];}),
  59. selectedMode: 'single',
  60. right: 100
  61. };
  62. data.countries.forEach(function (country) {
  63. var data = series.map(function (yearData) {
  64. var item = yearData.filter(function (item) {
  65. return item[3] === country[2];
  66. })[0];
  67. return {
  68. label: {
  69. normal: {
  70. show: item[4] % 20 === 0 && item[4] > 1940
  71. },
  72. emphasis: {
  73. position: 'top',
  74. show: true
  75. }
  76. },
  77. name: item[4],
  78. value: item
  79. };
  80. });
  81. var links = data.map(function (item, idx) {
  82. return {
  83. source: idx,
  84. target: idx + 1
  85. };
  86. });
  87. links.pop();
  88. option.series.push({
  89. name: country[2],
  90. type: 'graph',
  91. coordinateSystem: 'cartesian2d',
  92. data: data,
  93. links: links,
  94. edgeSymbol: ['none', 'arrow'],
  95. edgeSymbolSize: 5,
  96. legendHoverLink: false,
  97. lineStyle: {
  98. normal: {
  99. color: '#333'
  100. }
  101. },
  102. itemStyle: {
  103. normal: {
  104. borderWidth: 1,
  105. borderColor: '#333'
  106. }
  107. },
  108. label: {
  109. normal: {
  110. textStyle: {
  111. color: '#333'
  112. },
  113. position: 'right'
  114. }
  115. },
  116. symbolSize: 10,
  117. animationDelay: function (idx) {
  118. return idx * 100;
  119. }
  120. });
  121. });
  122. testHelper.create(echarts, 'main0', {
  123. option: option
  124. });
  125. });
  126. });
  127. </script>
  128. </body>
  129. </html>