multi-series.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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>Multi-series Timeline</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 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
  33. </head>
  34. <body>
  35. <div id="app">
  36. <div id="chart">
  37. <apexchart type="rangeBar" height="350" :options="chartOptions" :series="series"></apexchart>
  38. </div>
  39. </div>
  40. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  41. <div id="html">
  42. &lt;div id=&quot;chart&quot;&gt;
  43. &lt;apexchart type=&quot;rangeBar&quot; height=&quot;350&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  44. &lt;/div&gt;
  45. </div>
  46. <script>
  47. new Vue({
  48. el: '#app',
  49. components: {
  50. apexchart: VueApexCharts,
  51. },
  52. data: {
  53. series: [
  54. {
  55. name: 'Bob',
  56. data: [
  57. {
  58. x: 'Design',
  59. y: [
  60. new Date('2019-03-05').getTime(),
  61. new Date('2019-03-08').getTime()
  62. ]
  63. },
  64. {
  65. x: 'Code',
  66. y: [
  67. new Date('2019-03-08').getTime(),
  68. new Date('2019-03-11').getTime()
  69. ]
  70. },
  71. {
  72. x: 'Test',
  73. y: [
  74. new Date('2019-03-11').getTime(),
  75. new Date('2019-03-16').getTime()
  76. ]
  77. }
  78. ]
  79. },
  80. {
  81. name: 'Joe',
  82. data: [
  83. {
  84. x: 'Design',
  85. y: [
  86. new Date('2019-03-02').getTime(),
  87. new Date('2019-03-05').getTime()
  88. ]
  89. },
  90. {
  91. x: 'Code',
  92. y: [
  93. new Date('2019-03-06').getTime(),
  94. new Date('2019-03-09').getTime()
  95. ]
  96. },
  97. {
  98. x: 'Test',
  99. y: [
  100. new Date('2019-03-10').getTime(),
  101. new Date('2019-03-19').getTime()
  102. ]
  103. }
  104. ]
  105. }
  106. ],
  107. chartOptions: {
  108. chart: {
  109. height: 350,
  110. type: 'rangeBar'
  111. },
  112. plotOptions: {
  113. bar: {
  114. horizontal: true
  115. }
  116. },
  117. dataLabels: {
  118. enabled: true,
  119. formatter: function(val) {
  120. var a = moment(val[0])
  121. var b = moment(val[1])
  122. var diff = b.diff(a, 'days')
  123. return diff + (diff > 1 ? ' days' : ' day')
  124. }
  125. },
  126. fill: {
  127. type: 'gradient',
  128. gradient: {
  129. shade: 'light',
  130. type: 'vertical',
  131. shadeIntensity: 0.25,
  132. gradientToColors: undefined,
  133. inverseColors: true,
  134. opacityFrom: 1,
  135. opacityTo: 1,
  136. stops: [50, 0, 100, 100]
  137. }
  138. },
  139. xaxis: {
  140. type: 'datetime'
  141. },
  142. legend: {
  143. position: 'top'
  144. }
  145. },
  146. },
  147. })
  148. </script>
  149. </body>
  150. </html>