visualMap-scatter-colorAndSymbol.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. </head>
  7. <body>
  8. <style>
  9. html, body, #main {
  10. width: 100%;
  11. height: 100%;
  12. }
  13. </style>
  14. <div id="main"></div>
  15. <script>
  16. require([
  17. 'echarts',
  18. 'echarts/chart/scatter',
  19. 'echarts/component/legend',
  20. 'echarts/component/grid',
  21. 'echarts/component/visualMapPiecewise'
  22. ], function (echarts) {
  23. var chart = echarts.init(document.getElementById('main'), null, {
  24. renderer: 'canvas'
  25. });
  26. var data1 = [];
  27. var data2 = [];
  28. var data3 = [];
  29. var symbolCount = 6;
  30. // for (var i = 0; i < 100; i++) {
  31. // data1.push([
  32. // Math.random() * 5, Math.random() * 4, Math.random() * 20,
  33. // Math.round(Math.random() * (symbolCount - 1))
  34. // ]);
  35. // data2.push([
  36. // Math.random() * 10, Math.random() * 5, Math.random() * 20,
  37. // Math.round(Math.random() * (symbolCount - 1))
  38. // ]);
  39. // data3.push([
  40. // Math.random() * 15, Math.random() * 10, Math.random() * 20,
  41. // Math.round(Math.random() * (symbolCount - 1))
  42. // ]);
  43. // }
  44. for (var i = 0; i < 5; i++) {
  45. data1.push([
  46. i * 5, i * 4, i * 20,
  47. i * 123
  48. ]);
  49. // data2.push([
  50. // i * 10, Math.random() * 5, Math.random() * 20,
  51. // Math.round(Math.random() * (symbolCount - 1))
  52. // ]);
  53. // data3.push([
  54. // Math.random() * 15, Math.random() * 10, Math.random() * 20,
  55. // Math.round(Math.random() * (symbolCount - 1))
  56. // ]);
  57. }
  58. chart.setOption({
  59. legend: {
  60. top: 50,
  61. data: ['scatter', 'scatter2', 'scatter3']
  62. },
  63. grid: {
  64. top: '26%',
  65. bottom: '26%'
  66. },
  67. xAxis: {
  68. type: 'value',
  69. splitLine: {
  70. show: false
  71. }
  72. },
  73. yAxis: {
  74. type: 'value',
  75. splitLine: {
  76. show: false
  77. }
  78. },
  79. visualMap: [
  80. {
  81. show: true,
  82. splitNumber: 7,
  83. // selectedMode: 'single',
  84. selectedMode: 'multiple',
  85. backgroundColor: '#eee',
  86. color: ['red', 'pink', 'black']
  87. // unselectedSymbol: []
  88. },
  89. {
  90. splitNumber: 3,
  91. x: 'right',
  92. // selectedMode: 'single',
  93. selectedMode: 'multiple',
  94. dimension: 3,
  95. backgroundColor: '#eee',
  96. inRange: 'symbol'
  97. }
  98. ],
  99. series: [
  100. {
  101. name: 'scatter',
  102. type: 'scatter',
  103. itemStyle: {
  104. normal: {
  105. opacity: 0.8,
  106. shadowBlur: 10,
  107. shadowOffsetX: 0,
  108. shadowOffsetY: 0,
  109. shadowColor: 'rgba(0, 0, 0, 0.5)'
  110. }
  111. },
  112. symbolSize: function (val) {
  113. return val[2] * 2;
  114. },
  115. data: data1
  116. },
  117. {
  118. name: 'scatter2',
  119. type: 'scatter',
  120. itemStyle: {
  121. normal: {
  122. opacity: 0.8,
  123. shadowBlur: 10,
  124. shadowOffsetX: 0,
  125. shadowOffsetY: 0,
  126. shadowColor: 'rgba(0, 0, 0, 0.5)'
  127. }
  128. },
  129. symbolSize: function (val) {
  130. return val[2] * 2;
  131. },
  132. data: data2
  133. },
  134. {
  135. name: 'scatter3',
  136. type: 'scatter',
  137. itemStyle: {
  138. normal: {
  139. opacity: 0.8,
  140. shadowBlur: 10,
  141. shadowOffsetX: 0,
  142. shadowOffsetY: 0,
  143. shadowColor: 'rgba(0, 0, 0, 0.5)'
  144. }
  145. },
  146. symbolSize: function (val) {
  147. return val[2] * 2;
  148. },
  149. data: data3
  150. }
  151. ]
  152. });
  153. })
  154. </script>
  155. </body>
  156. </html>