histogram_bar.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. </head>
  10. <body>
  11. <style>
  12. html, body, #main {
  13. width: 100%;
  14. height: 100%;
  15. margin: 0;
  16. padding: 0;
  17. }
  18. </style>
  19. <div id="main"></div>
  20. <script>
  21. require([
  22. 'echarts',
  23. 'ecStat'
  24. ], function (echarts, ecStat) {
  25. echarts.registerTransform(ecStat.transform.histogram);
  26. var chart = echarts.init(document.getElementById('main'));
  27. var option = {
  28. dataset: [{
  29. source: [
  30. [8.3, 143],
  31. [8.6, 214],
  32. [8.8, 251],
  33. [10.5, 26],
  34. [10.7, 86],
  35. [10.8, 93],
  36. [11.0, 176],
  37. [11.0, 39],
  38. [11.1, 221],
  39. [11.2, 188],
  40. [11.3, 57],
  41. [11.4, 91],
  42. [11.4, 191],
  43. [11.7, 8],
  44. [12.0, 196],
  45. [12.9, 177],
  46. [12.9, 153],
  47. [13.3, 201],
  48. [13.7, 199],
  49. [13.8, 47],
  50. [14.0, 81],
  51. [14.2, 98],
  52. [14.5, 121],
  53. [16.0, 37],
  54. [16.3, 12],
  55. [17.3, 105],
  56. [17.5, 168],
  57. [17.9, 84],
  58. [18.0, 197],
  59. [18.0, 155],
  60. [20.6, 125]
  61. ]
  62. }, {
  63. transform: {
  64. type: 'ecStat:histogram'
  65. }
  66. }, {
  67. transform: {
  68. type: 'ecStat:histogram',
  69. print: true,
  70. config: { dimensions: [1] }
  71. }
  72. }],
  73. tooltip: {
  74. },
  75. grid: [{
  76. top: '50%',
  77. right: '50%'
  78. }, {
  79. bottom: '52%',
  80. right: '50%',
  81. }, {
  82. top: '50%',
  83. left: '52%'
  84. }],
  85. xAxis: [{
  86. scale: true,
  87. gridIndex: 0
  88. }, {
  89. type: 'category',
  90. scale: true,
  91. axisTick: { show: false },
  92. axisLabel: { show: false },
  93. axisLine: { show: false },
  94. gridIndex: 1
  95. }, {
  96. scale: true,
  97. gridIndex: 2
  98. }],
  99. yAxis: [{
  100. gridIndex: 0
  101. }, {
  102. gridIndex: 1
  103. }, {
  104. type: 'category',
  105. axisTick: { show: false },
  106. axisLabel: { show: false },
  107. axisLine: { show: false },
  108. gridIndex: 2
  109. }],
  110. series: [{
  111. name: 'origianl scatter',
  112. type: 'scatter',
  113. xAxisIndex: 0,
  114. yAxisIndex: 0,
  115. encode: { tooltip: [0, 1] },
  116. datasetIndex: 0
  117. }, {
  118. name: 'histogram',
  119. type: 'bar',
  120. xAxisIndex: 1,
  121. yAxisIndex: 1,
  122. barWidth: '99.3%',
  123. label: {
  124. show: true,
  125. position: 'top'
  126. },
  127. encode: { x: 0, y: 1, itemName: 4 },
  128. datasetIndex: 1
  129. }, {
  130. name: 'histogram',
  131. type: 'bar',
  132. xAxisIndex: 2,
  133. yAxisIndex: 2,
  134. barWidth: '99.3%',
  135. label: {
  136. show: true,
  137. position: 'right'
  138. },
  139. encode: { x: 1, y: 0, itemName: 4 },
  140. datasetIndex: 2
  141. }]
  142. };
  143. chart.setOption(option);
  144. });
  145. </script>
  146. </body>
  147. </html>