area-with-negative.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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>Area with Negative - Stacked</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. name: 'north',
  37. data: [{
  38. x: 1996,
  39. y: 322
  40. },
  41. {
  42. x: 1997,
  43. y: 324
  44. },
  45. {
  46. x: 1998,
  47. y: 329
  48. },
  49. {
  50. x: 1999,
  51. y: 342
  52. },
  53. {
  54. x: 2000,
  55. y: 348
  56. },
  57. {
  58. x: 2001,
  59. y: 334
  60. },
  61. {
  62. x: 2002,
  63. y: 325
  64. },
  65. {
  66. x: 2003,
  67. y: 316
  68. },
  69. {
  70. x: 2004,
  71. y: 318
  72. },
  73. {
  74. x: 2005,
  75. y: 330
  76. },
  77. {
  78. x: 2006,
  79. y: 355
  80. },
  81. {
  82. x: 2007,
  83. y: 366
  84. },
  85. {
  86. x: 2008,
  87. y: 337
  88. },
  89. {
  90. x: 2009,
  91. y: 352
  92. },
  93. {
  94. x: 2010,
  95. y: 377
  96. },
  97. {
  98. x: 2011,
  99. y: 383
  100. },
  101. {
  102. x: 2012,
  103. y: 344
  104. },
  105. {
  106. x: 2013,
  107. y: 366
  108. },
  109. {
  110. x: 2014,
  111. y: 389
  112. },
  113. {
  114. x: 2015,
  115. y: 334
  116. }
  117. ]
  118. }, {
  119. name: 'south',
  120. data: [
  121. {
  122. x: 1996,
  123. y: 162
  124. },
  125. {
  126. x: 1997,
  127. y: 90
  128. },
  129. {
  130. x: 1998,
  131. y: 50
  132. },
  133. {
  134. x: 1999,
  135. y: 77
  136. },
  137. {
  138. x: 2000,
  139. y: 35
  140. },
  141. {
  142. x: 2001,
  143. y: -45
  144. },
  145. {
  146. x: 2002,
  147. y: -88
  148. },
  149. {
  150. x: 2003,
  151. y: -120
  152. },
  153. {
  154. x: 2004,
  155. y: -156
  156. },
  157. {
  158. x: 2005,
  159. y: -123
  160. },
  161. {
  162. x: 2006,
  163. y: -88
  164. },
  165. {
  166. x: 2007,
  167. y: -66
  168. },
  169. {
  170. x: 2008,
  171. y: -45
  172. },
  173. {
  174. x: 2009,
  175. y: -29
  176. },
  177. {
  178. x: 2010,
  179. y: -45
  180. },
  181. {
  182. x: 2011,
  183. y: -88
  184. },
  185. {
  186. x: 2012,
  187. y: -132
  188. },
  189. {
  190. x: 2013,
  191. y: -146
  192. },
  193. {
  194. x: 2014,
  195. y: -169
  196. },
  197. {
  198. x: 2015,
  199. y: -184
  200. }
  201. ]
  202. }],
  203. chart: {
  204. type: 'area',
  205. height: 350
  206. },
  207. dataLabels: {
  208. enabled: false
  209. },
  210. stroke: {
  211. curve: 'straight'
  212. },
  213. title: {
  214. text: 'Area with Negative Values',
  215. align: 'left',
  216. style: {
  217. fontSize: '14px'
  218. }
  219. },
  220. xaxis: {
  221. type: 'datetime',
  222. axisBorder: {
  223. show: false
  224. },
  225. axisTicks: {
  226. show: false
  227. }
  228. },
  229. yaxis: {
  230. tickAmount: 4,
  231. floating: false,
  232. labels: {
  233. style: {
  234. colors: '#8e8da4',
  235. },
  236. offsetY: -7,
  237. offsetX: 0,
  238. },
  239. axisBorder: {
  240. show: false,
  241. },
  242. axisTicks: {
  243. show: false
  244. }
  245. },
  246. fill: {
  247. opacity: 0.5
  248. },
  249. tooltip: {
  250. x: {
  251. format: "yyyy",
  252. },
  253. fixed: {
  254. enabled: false,
  255. position: 'topRight'
  256. }
  257. },
  258. grid: {
  259. yaxis: {
  260. lines: {
  261. offsetX: -30
  262. }
  263. },
  264. padding: {
  265. left: 20
  266. }
  267. }
  268. };
  269. var chart = new ApexCharts(document.querySelector("#chart"), options);
  270. chart.render();
  271. </script>
  272. </body>
  273. </html>