geo-data-stream.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/config.js"></script>
  7. <script src="lib/jquery.min.js"></script>
  8. <script src="lib/facePrint.js"></script>
  9. </head>
  10. <body>
  11. <style>
  12. html, body, #main {
  13. width: 100%;
  14. height: 100%;
  15. margin: 0;
  16. }
  17. </style>
  18. <div id="main"></div>
  19. <script>
  20. var lngRange = [79.781327, 131.48];
  21. var lngExtent = lngRange[1] - lngRange[0];
  22. var latRange = [18.252847, 52.33];
  23. var latExtent = latRange[1] - latRange[0];
  24. var chunkMax = 100;
  25. var chunkCount = 0;
  26. function genData(count) {
  27. var data = [];
  28. for (var i = 0; i < count; i++) {
  29. data.push([
  30. Math.random() * lngExtent + lngRange[0],
  31. Math.random() * latExtent + latRange[0],
  32. Math.random() * 1000
  33. ]);
  34. }
  35. return data;
  36. }
  37. var initData = genData(2001);
  38. require([
  39. 'echarts'
  40. // 'echarts/chart/map',
  41. // 'echarts/chart/scatter',
  42. // 'echarts/component/title',
  43. // 'echarts/component/legend',
  44. // 'echarts/component/geo',
  45. // 'echarts/component/visualMap',
  46. // 'echarts/component/markPoint',
  47. // 'echarts/component/tooltip'
  48. ], function (echarts) {
  49. require(['map/js/china'], function () {
  50. var chart = echarts.init(document.getElementById('main'));
  51. chart.setOption({
  52. tooltip: {},
  53. legend: {
  54. orient: 'vertical',
  55. left: 'left',
  56. data:['categoryA','categoryB','categoryC']
  57. },
  58. // ???
  59. // visualMap: {
  60. // min: 0,
  61. // max: 1500,
  62. // left: 'left',
  63. // top: 'bottom',
  64. // text: ['High','Low'],
  65. // seriesIndex: [1, 2, 3],
  66. // inRange: {
  67. // color: ['#006edd', '#e0ffff']
  68. // },
  69. // calculable : true
  70. // },
  71. geo: {
  72. map: 'china',
  73. roam: true,
  74. label: {
  75. normal: {
  76. show: true,
  77. textStyle: {
  78. color: 'rgba(0,0,0,0.4)'
  79. }
  80. }
  81. },
  82. itemStyle: {
  83. normal:{
  84. borderColor: 'rgba(0, 0, 0, 0.2)'
  85. },
  86. emphasis:{
  87. color: null,
  88. areaColor: null,
  89. shadowOffsetX: 0,
  90. shadowOffsetY: 0,
  91. shadowBlur: 20,
  92. borderWidth: 0,
  93. shadowColor: 'rgba(0, 0, 0, 0.5)'
  94. }
  95. }
  96. },
  97. series : [{
  98. name: 'pm2.5',
  99. type: 'scatter',
  100. stream: true,
  101. coordinateSystem: 'geo',
  102. data: initData,
  103. symbolSize: 4,
  104. // symbol: 'rect',
  105. itemStyle: {
  106. normal: {
  107. // color: '#ddb926'
  108. color: '#dda'
  109. }
  110. },
  111. progressive: 100
  112. }]
  113. });
  114. chart.on('click', function (param) {
  115. alert('asdf');
  116. });
  117. next();
  118. function next() {
  119. if (chunkCount++ < chunkMax) {
  120. var newData = genData(1000);
  121. chart.appendData({seriesIndex: 0, data: newData});
  122. setTimeout(next, 1000);
  123. }
  124. }
  125. });
  126. });
  127. </script>
  128. </body>
  129. </html>