visualMap-scatter-symbolSize.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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/visualMapContinuous'
  22. ], function (echarts) {
  23. var chart = echarts.init(document.getElementById('main'));
  24. var data1 = [];
  25. var data2 = [];
  26. var data3 = [];
  27. var symbolCount = 6;
  28. // for (var i = 0; i < 100; i++) {
  29. // data1.push([
  30. // Math.random() * 5, Math.random() * 4, Math.random() * 20,
  31. // Math.round(Math.random() * (symbolCount - 1))
  32. // ]);
  33. // data2.push([
  34. // Math.random() * 10, Math.random() * 5, Math.random() * 20,
  35. // Math.round(Math.random() * (symbolCount - 1))
  36. // ]);
  37. // data3.push([
  38. // Math.random() * 15, Math.random() * 10, Math.random() * 20,
  39. // Math.round(Math.random() * (symbolCount - 1))
  40. // ]);
  41. // }
  42. for (var i = 0; i < 5; i++) {
  43. data1.push([
  44. i * 5, i * 4, i * 20
  45. ]);
  46. // data2.push([
  47. // i * 10, Math.random() * 5, Math.random() * 20,
  48. // Math.round(Math.random() * (symbolCount - 1))
  49. // ]);
  50. // data3.push([
  51. // Math.random() * 15, Math.random() * 10, Math.random() * 20,
  52. // Math.round(Math.random() * (symbolCount - 1))
  53. // ]);
  54. }
  55. chart.setOption({
  56. legend: {
  57. top: 50,
  58. data: ['scatter', 'scatter2', 'scatter3']
  59. },
  60. grid: {
  61. top: '26%',
  62. bottom: '26%'
  63. },
  64. xAxis: {
  65. type: 'value',
  66. splitLine: {
  67. show: false
  68. }
  69. },
  70. yAxis: {
  71. type: 'value',
  72. splitLine: {
  73. show: false
  74. }
  75. },
  76. visualMap: [
  77. {
  78. min: 0,
  79. max: 200,
  80. show: true,
  81. itemWidth: 30,
  82. calculable: true,
  83. inverse: true,
  84. dimension: 'z',
  85. inRange: {
  86. symbolSize: [10, 180]
  87. }
  88. }
  89. ],
  90. series: [
  91. {
  92. name: 'scatter',
  93. type: 'scatter',
  94. itemStyle: {
  95. normal: {
  96. opacity: 0.8,
  97. shadowBlur: 10,
  98. shadowOffsetX: 0,
  99. shadowOffsetY: 0,
  100. shadowColor: 'rgba(0, 0, 0, 0.5)'
  101. }
  102. },
  103. data: data1
  104. },
  105. {
  106. name: 'scatter2',
  107. type: 'scatter',
  108. itemStyle: {
  109. normal: {
  110. opacity: 0.8,
  111. shadowBlur: 10,
  112. shadowOffsetX: 0,
  113. shadowOffsetY: 0,
  114. shadowColor: 'rgba(0, 0, 0, 0.5)'
  115. }
  116. },
  117. data: data2
  118. },
  119. {
  120. name: 'scatter3',
  121. type: 'scatter',
  122. itemStyle: {
  123. normal: {
  124. opacity: 0.8,
  125. shadowBlur: 10,
  126. shadowOffsetX: 0,
  127. shadowOffsetY: 0,
  128. shadowColor: 'rgba(0, 0, 0, 0.5)'
  129. }
  130. },
  131. data: data3
  132. }
  133. ]
  134. });
  135. })
  136. </script>
  137. </body>
  138. </html>