stacked-column-with-line.html 6.0 KB

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