line-with-annotations.html 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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>Line Chart with Annotations</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="../../assets/stock-prices.js"></script>
  33. </head>
  34. <body>
  35. <div id="app">
  36. <div id="chart">
  37. <apexchart type="line" 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;line&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. data: series.monthDataSeries1.prices
  55. }],
  56. chartOptions: {
  57. chart: {
  58. height: 350,
  59. type: 'line',
  60. id: 'areachart-2'
  61. },
  62. annotations: {
  63. yaxis: [{
  64. y: 8200,
  65. borderColor: '#00E396',
  66. label: {
  67. borderColor: '#00E396',
  68. style: {
  69. color: '#fff',
  70. background: '#00E396',
  71. },
  72. text: 'Support',
  73. }
  74. }, {
  75. y: 8600,
  76. y2: 9000,
  77. borderColor: '#000',
  78. fillColor: '#FEB019',
  79. opacity: 0.2,
  80. label: {
  81. borderColor: '#333',
  82. style: {
  83. fontSize: '10px',
  84. color: '#333',
  85. background: '#FEB019',
  86. },
  87. text: 'Y-axis range',
  88. }
  89. }],
  90. xaxis: [{
  91. x: new Date('23 Nov 2017').getTime(),
  92. strokeDashArray: 0,
  93. borderColor: '#775DD0',
  94. label: {
  95. borderColor: '#775DD0',
  96. style: {
  97. color: '#fff',
  98. background: '#775DD0',
  99. },
  100. text: 'Anno Test',
  101. }
  102. }, {
  103. x: new Date('26 Nov 2017').getTime(),
  104. x2: new Date('28 Nov 2017').getTime(),
  105. fillColor: '#B3F7CA',
  106. opacity: 0.4,
  107. label: {
  108. borderColor: '#B3F7CA',
  109. style: {
  110. fontSize: '10px',
  111. color: '#fff',
  112. background: '#00E396',
  113. },
  114. offsetY: -10,
  115. text: 'X-axis range',
  116. }
  117. }],
  118. points: [{
  119. x: new Date('01 Dec 2017').getTime(),
  120. y: 8607.55,
  121. marker: {
  122. size: 8,
  123. fillColor: '#fff',
  124. strokeColor: 'red',
  125. radius: 2,
  126. cssClass: 'apexcharts-custom-class'
  127. },
  128. label: {
  129. borderColor: '#FF4560',
  130. offsetY: 0,
  131. style: {
  132. color: '#fff',
  133. background: '#FF4560',
  134. },
  135. text: 'Point Annotation',
  136. }
  137. }, {
  138. x: new Date('08 Dec 2017').getTime(),
  139. y: 9340.85,
  140. marker: {
  141. size: 0
  142. },
  143. image: {
  144. path: '../../assets/images/ico-instagram.png'
  145. }
  146. }]
  147. },
  148. dataLabels: {
  149. enabled: false
  150. },
  151. stroke: {
  152. curve: 'straight'
  153. },
  154. grid: {
  155. padding: {
  156. right: 30,
  157. left: 20
  158. }
  159. },
  160. title: {
  161. text: 'Line with Annotations',
  162. align: 'left'
  163. },
  164. labels: series.monthDataSeries1.dates,
  165. xaxis: {
  166. type: 'datetime',
  167. },
  168. },
  169. },
  170. })
  171. </script>
  172. </body>
  173. </html>