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