stacked-column-with-line.html 7.3 KB

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