simple-bubble.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  7. <title>Simple Bubble</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. #chart {
  11. max-width: 650px;
  12. margin: 35px auto;
  13. }
  14. </style>
  15. <script>
  16. window.Promise ||
  17. document.write(
  18. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  19. )
  20. window.Promise ||
  21. document.write(
  22. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  23. )
  24. window.Promise ||
  25. document.write(
  26. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  27. )
  28. </script>
  29. <script src="https://cdn.jsdelivr.net/npm/react@16.12/umd/react.production.min.js"></script>
  30. <script src="https://cdn.jsdelivr.net/npm/react-dom@16.12/umd/react-dom.production.min.js"></script>
  31. <script src="https://cdn.jsdelivr.net/npm/prop-types@15.7.2/prop-types.min.js"></script>
  32. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
  33. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  34. <script src="https://cdn.jsdelivr.net/npm/react-apexcharts@1.3.6/dist/react-apexcharts.iife.min.js"></script>
  35. <script>
  36. /*
  37. // this function will generate output in this format
  38. // data = [
  39. [timestamp, 23],
  40. [timestamp, 33],
  41. [timestamp, 12]
  42. ...
  43. ]
  44. */
  45. function generateData(baseval, count, yrange) {
  46. var i = 0;
  47. var series = [];
  48. while (i < count) {
  49. var x = Math.floor(Math.random() * (750 - 1 + 1)) + 1;;
  50. var y = Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min;
  51. var z = Math.floor(Math.random() * (75 - 15 + 1)) + 15;
  52. series.push([x, y, z]);
  53. baseval += 86400000;
  54. i++;
  55. }
  56. return series;
  57. }
  58. </script>
  59. </head>
  60. <body>
  61. <div id="app"></div>
  62. <div id="html">
  63. &lt;div id=&quot;chart&quot;&gt;
  64. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;bubble&quot; height={350} /&gt;
  65. &lt;/div&gt;
  66. </div>
  67. <script type="text/babel">
  68. class ApexChart extends React.Component {
  69. constructor(props) {
  70. super(props);
  71. this.state = {
  72. series: [{
  73. name: 'Bubble1',
  74. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  75. min: 10,
  76. max: 60
  77. })
  78. },
  79. {
  80. name: 'Bubble2',
  81. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  82. min: 10,
  83. max: 60
  84. })
  85. },
  86. {
  87. name: 'Bubble3',
  88. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  89. min: 10,
  90. max: 60
  91. })
  92. },
  93. {
  94. name: 'Bubble4',
  95. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  96. min: 10,
  97. max: 60
  98. })
  99. }],
  100. options: {
  101. chart: {
  102. height: 350,
  103. type: 'bubble',
  104. },
  105. dataLabels: {
  106. enabled: false
  107. },
  108. fill: {
  109. opacity: 0.8
  110. },
  111. title: {
  112. text: 'Simple Bubble Chart'
  113. },
  114. xaxis: {
  115. tickAmount: 12,
  116. type: 'category',
  117. },
  118. yaxis: {
  119. max: 70
  120. }
  121. },
  122. };
  123. }
  124. render() {
  125. return (
  126. <div>
  127. <div id="chart">
  128. <ReactApexChart options={this.state.options} series={this.state.series} type="bubble" height={350} />
  129. </div>
  130. <div id="html-dist"></div>
  131. </div>
  132. );
  133. }
  134. }
  135. const domContainer = document.querySelector('#app');
  136. ReactDOM.render(React.createElement(ApexChart), domContainer);
  137. </script>
  138. </body>
  139. </html>