stacked-column-with-line.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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 Column with line</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. </head>
  36. <body>
  37. <div id="app"></div>
  38. <div id="html">
  39. &lt;div id=&quot;chart&quot;&gt;
  40. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;line&quot; /&gt;
  41. &lt;/div&gt;
  42. </div>
  43. <script type="text/babel">
  44. class ApexChart extends React.Component {
  45. constructor(props) {
  46. super(props);
  47. this.state = {
  48. series: [
  49. {
  50. "name": "Line",
  51. "type": "line",
  52. "data": [
  53. 37,
  54. 38.3,
  55. 33.01,
  56. 30,
  57. 29.7,
  58. 30,
  59. 35.2,
  60. 44,
  61. 45,
  62. 41,
  63. 22,
  64. 22.5,
  65. 29.1,
  66. 25.5,
  67. 41.2,
  68. 43.8,
  69. 39,
  70. 23,
  71. 26,
  72. 22,
  73. 34,
  74. 37,
  75. 43,
  76. 41,
  77. 17
  78. ]
  79. },
  80. {
  81. "name": "Bar1",
  82. "type": "bar",
  83. "data": [
  84. -1.57,
  85. -1.83,
  86. -0.29,
  87. 2,
  88. 0.23,
  89. 3,
  90. 0,
  91. -0.77,
  92. 0,
  93. 0,
  94. 0,
  95. -0.16,
  96. -0.5,
  97. -0.75,
  98. -0.93,
  99. -0.93,
  100. -0.45,
  101. 0,
  102. 0,
  103. -0.23,
  104. -0.95,
  105. -1.12,
  106. -0.51,
  107. 0.76
  108. ]
  109. },
  110. {
  111. "name": "Bar2",
  112. "type": "bar",
  113. "data": [
  114. -2.99,
  115. -0.43,
  116. 0.39,
  117. 2.8,
  118. 0.23,
  119. 1.2,
  120. -0.06,
  121. -2.96,
  122. -2.74,
  123. -2.58,
  124. -1.79,
  125. -2.16,
  126. -1.9,
  127. -1.75,
  128. -2,
  129. -2.16,
  130. -1.75,
  131. -1.9,
  132. -2.74,
  133. -2.58,
  134. -3.8,
  135. -1.24,
  136. -0.01,
  137. 1.89
  138. ]
  139. },
  140. {
  141. "name": "Bar3",
  142. "type": "bar",
  143. "data": [
  144. 0.09,
  145. 4,
  146. 4.83,
  147. 6.86,
  148. 3.86,
  149. 5,
  150. 1.7,
  151. -1.21,
  152. 0,
  153. 0.02,
  154. 0.07,
  155. -0.15,
  156. -0.09,
  157. 0,
  158. -0.61,
  159. -1.75,
  160. 0,
  161. -0.43,
  162. -1.5,
  163. -0.66,
  164. -3.06,
  165. 0.06,
  166. 0.15,
  167. 1.48
  168. ]
  169. },
  170. {
  171. "name": "bar4",
  172. "type": "bar",
  173. "data": [
  174. 5.95,
  175. 5.86,
  176. 0.92,
  177. -1.2,
  178. -2.73,
  179. -0.32,
  180. 0.12,
  181. -0.55,
  182. 0.78,
  183. 0,
  184. -1.73,
  185. -2.52,
  186. -1.26,
  187. -0.8,
  188. -0.75,
  189. 0,
  190. -3,
  191. 0,
  192. 0.29,
  193. 0.3
  194. ]
  195. }
  196. ],
  197. options: {
  198. colors: [
  199. '#6a6ba5',
  200. '#f9a867',
  201. '#2a6b9b',
  202. '#6c98b7',
  203. '#abc4d6',
  204. '#d5e2eb'
  205. ],
  206. chart: {
  207. height: '350',
  208. width: '90%',
  209. type: 'line',
  210. stacked: 'true',
  211. zoom: {
  212. enabled: true,
  213. type: 'x'
  214. }
  215. },
  216. tooltip: {
  217. followCursor: true,
  218. shared: false
  219. },
  220. responsive: [
  221. {
  222. breakpoint: 480
  223. }
  224. ],
  225. markers: {
  226. size: 0,
  227. fillOpacity: 0,
  228. strokeOpacity: 0
  229. },
  230. stroke: {
  231. width: 2
  232. },
  233. xaxis: {
  234. categories: [
  235. 1,
  236. 2,
  237. 3,
  238. 4,
  239. 5,
  240. 6,
  241. 7,
  242. 8,
  243. 9,
  244. 10,
  245. 11,
  246. 12,
  247. 13,
  248. 14,
  249. 15,
  250. 16,
  251. 17,
  252. 18,
  253. 19,
  254. 20,
  255. 21,
  256. 22,
  257. 23,
  258. 24,
  259. 25
  260. ],
  261. type: 'numeric',
  262. tickPlacement: 'on',
  263. tickAmount: 'dataPoints',
  264. labels: {
  265. showDuplicates: false,
  266. formatter: function(value) {
  267. return value.toFixed(0)
  268. }
  269. }
  270. },
  271. yaxis: [
  272. {
  273. seriesName: 'Line',
  274. opposite: true
  275. },
  276. {
  277. seriesName: 'Bar1'
  278. },
  279. {
  280. seriesName: 'Bar1',
  281. show: false
  282. },
  283. {
  284. seriesName: 'Bar1',
  285. show: false
  286. },
  287. {
  288. seriesName: 'Bar1',
  289. show: false
  290. }
  291. ],
  292. legend: {
  293. showForSingleSeries: true
  294. },
  295. fill: {
  296. opacity: 1
  297. }
  298. },
  299. };
  300. }
  301. render() {
  302. return (
  303. <div>
  304. <div id="chart">
  305. <ReactApexChart options={this.state.options} series={this.state.series} type="line" />
  306. </div>
  307. <div id="html-dist"></div>
  308. </div>
  309. );
  310. }
  311. }
  312. const domContainer = document.querySelector('#app');
  313. ReactDOM.render(React.createElement(ApexChart), domContainer);
  314. </script>
  315. </body>
  316. </html>