stacked-area.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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>Stacked Area</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>
  36. var generateDayWiseTimeSeries = function (baseval, count, yrange) {
  37. var i = 0;
  38. var series = [];
  39. while (i < count) {
  40. var x = baseval;
  41. var y = Math.floor(Math.random() * (yrange.max - yrange.min + 1)) + yrange.min;
  42. series.push([x, y]);
  43. baseval += 86400000;
  44. i++;
  45. }
  46. return series;
  47. }
  48. </script>
  49. </head>
  50. <body>
  51. <div id="app"></div>
  52. <div id="html">
  53. &lt;div id=&quot;chart&quot;&gt;
  54. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;area&quot; height={350} /&gt;
  55. &lt;/div&gt;
  56. </div>
  57. <script type="text/babel">
  58. class ApexChart extends React.Component {
  59. constructor(props) {
  60. super(props);
  61. this.state = {
  62. series: [
  63. {
  64. name: 'South',
  65. data: generateDayWiseTimeSeries(new Date('11 Feb 2017 GMT').getTime(), 20, {
  66. min: 10,
  67. max: 60
  68. })
  69. },
  70. {
  71. name: 'North',
  72. data: generateDayWiseTimeSeries(new Date('11 Feb 2017 GMT').getTime(), 20, {
  73. min: 10,
  74. max: 20
  75. })
  76. },
  77. {
  78. name: 'Central',
  79. data: generateDayWiseTimeSeries(new Date('11 Feb 2017 GMT').getTime(), 20, {
  80. min: 10,
  81. max: 15
  82. })
  83. }
  84. ],
  85. options: {
  86. chart: {
  87. type: 'area',
  88. height: 350,
  89. stacked: true,
  90. events: {
  91. selection: function (chart, e) {
  92. console.log(new Date(e.xaxis.min))
  93. }
  94. },
  95. },
  96. colors: ['#008FFB', '#00E396', '#CED4DC'],
  97. dataLabels: {
  98. enabled: false
  99. },
  100. stroke: {
  101. curve: 'smooth'
  102. },
  103. fill: {
  104. type: 'gradient',
  105. gradient: {
  106. opacityFrom: 0.6,
  107. opacityTo: 0.8,
  108. }
  109. },
  110. legend: {
  111. position: 'top',
  112. horizontalAlign: 'left'
  113. },
  114. xaxis: {
  115. type: 'datetime'
  116. },
  117. },
  118. };
  119. }
  120. render() {
  121. return (
  122. <div>
  123. <div id="chart">
  124. <ReactApexChart options={this.state.options} series={this.state.series} type="area" height={350} />
  125. </div>
  126. <div id="html-dist"></div>
  127. </div>
  128. );
  129. }
  130. }
  131. const domContainer = document.querySelector('#app');
  132. ReactDOM.render(React.createElement(ApexChart), domContainer);
  133. </script>
  134. </body>
  135. </html>