line-with-annotations.html 6.1 KB

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