simple-bubble.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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/vue/dist/vue.min.js"></script>
  30. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  31. <script src="https://cdn.jsdelivr.net/npm/vue-apexcharts"></script>
  32. <script>
  33. /*
  34. // this function will generate output in this format
  35. // data = [
  36. [timestamp, 23],
  37. [timestamp, 33],
  38. [timestamp, 12]
  39. ...
  40. ]
  41. */
  42. function generateData(baseval, count, yrange) {
  43. var i = 0;
  44. var series = [];
  45. while (i < count) {
  46. var x = Math.floor(Math.random() * (750 - 1 + 1)) + 1;;
  47. var y = Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min;
  48. var z = Math.floor(Math.random() * (75 - 15 + 1)) + 15;
  49. series.push([x, y, z]);
  50. baseval += 86400000;
  51. i++;
  52. }
  53. return series;
  54. }
  55. </script>
  56. </head>
  57. <body>
  58. <div id="app">
  59. <div id="chart">
  60. <apexchart type="bubble" height="350" :options="chartOptions" :series="series"></apexchart>
  61. </div>
  62. </div>
  63. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  64. <div id="html">
  65. &lt;div id=&quot;chart&quot;&gt;
  66. &lt;apexchart type=&quot;bubble&quot; height=&quot;350&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  67. &lt;/div&gt;
  68. </div>
  69. <script>
  70. new Vue({
  71. el: '#app',
  72. components: {
  73. apexchart: VueApexCharts,
  74. },
  75. data: {
  76. series: [{
  77. name: 'Bubble1',
  78. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  79. min: 10,
  80. max: 60
  81. })
  82. },
  83. {
  84. name: 'Bubble2',
  85. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  86. min: 10,
  87. max: 60
  88. })
  89. },
  90. {
  91. name: 'Bubble3',
  92. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  93. min: 10,
  94. max: 60
  95. })
  96. },
  97. {
  98. name: 'Bubble4',
  99. data: generateData(new Date('11 Feb 2017 GMT').getTime(), 20, {
  100. min: 10,
  101. max: 60
  102. })
  103. }],
  104. chartOptions: {
  105. chart: {
  106. height: 350,
  107. type: 'bubble',
  108. },
  109. dataLabels: {
  110. enabled: false
  111. },
  112. fill: {
  113. opacity: 0.8
  114. },
  115. title: {
  116. text: 'Simple Bubble Chart'
  117. },
  118. xaxis: {
  119. tickAmount: 12,
  120. type: 'category',
  121. },
  122. yaxis: {
  123. max: 70
  124. }
  125. },
  126. },
  127. })
  128. </script>
  129. </body>
  130. </html>