line-with-annotations.html 4.2 KB

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