logarithmic-line.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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>Chart with Logarithmic Scale</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. <script>
  33. var data = [{
  34. x: 1994,
  35. y: 2543763
  36. },
  37. {
  38. x: 1995,
  39. y: 4486659
  40. },
  41. {
  42. x: 1996,
  43. y: 7758386
  44. },
  45. {
  46. x: 1997,
  47. y: 12099221
  48. },
  49. {
  50. x: 1998,
  51. y: 18850762
  52. },
  53. {
  54. x: 1999,
  55. y: 28153765
  56. },
  57. {
  58. x: 2000,
  59. y: 41479495
  60. },
  61. {
  62. x: 2001,
  63. y: 50229224
  64. },
  65. {
  66. x: 2002,
  67. y: 66506501
  68. },
  69. {
  70. x: 2003,
  71. y: 78143598
  72. },
  73. {
  74. x: 2004,
  75. y: 91332777
  76. },
  77. {
  78. x: 2005,
  79. y: 103010128
  80. },
  81. {
  82. x: 2006,
  83. y: 116291681
  84. },
  85. {
  86. x: 2007,
  87. y: 137322698
  88. },
  89. {
  90. x: 2008,
  91. y: 157506752
  92. },
  93. {
  94. x: 2009,
  95. y: 176640381
  96. },
  97. {
  98. x: 2010,
  99. y: 202320297
  100. },
  101. {
  102. x: 2011,
  103. y: 223195735
  104. },
  105. {
  106. x: 2012,
  107. y: 249473624
  108. },
  109. {
  110. x: 2013,
  111. y: 272842810
  112. },
  113. {
  114. x: 2014,
  115. y: 295638556
  116. },
  117. {
  118. x: 2015,
  119. y: 318599615
  120. },
  121. {
  122. x: 2016,
  123. y: 342497123
  124. }
  125. ]
  126. var labelFormatter = function (value) {
  127. var val = Math.abs(value)
  128. if (val >= 1000000) {
  129. val = (val / 1000000).toFixed(1) + ' M';
  130. }
  131. return val;
  132. }
  133. </script>
  134. </head>
  135. <body>
  136. <div id="app">
  137. <div id="chart">
  138. <apexchart type="line" height="350" :options="chartOptions" :series="series"></apexchart>
  139. </div>
  140. </div>
  141. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  142. <div id="html">
  143. &lt;div id=&quot;chart&quot;&gt;
  144. &lt;apexchart type=&quot;line&quot; height=&quot;350&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  145. &lt;/div&gt;
  146. </div>
  147. <script>
  148. new Vue({
  149. el: '#app',
  150. components: {
  151. apexchart: VueApexCharts,
  152. },
  153. data: {
  154. series: [{
  155. name: "Logarithmic",
  156. data: data
  157. }, {
  158. name: "Linear",
  159. data: data
  160. }],
  161. chartOptions: {
  162. chart: {
  163. height: 350,
  164. type: 'line',
  165. zoom: {
  166. enabled: false
  167. }
  168. },
  169. dataLabels: {
  170. enabled: false
  171. },
  172. stroke: {
  173. curve: 'straight'
  174. },
  175. title: {
  176. text: 'Logarithmic Scale',
  177. align: 'left'
  178. },
  179. xaxis: {
  180. type: 'datetime'
  181. },
  182. yaxis: [
  183. {
  184. min: 1000000,
  185. max: 500000000,
  186. tickAmount: 4,
  187. logarithmic: true,
  188. seriesName: 'Logarithmic',
  189. labels: {
  190. formatter: labelFormatter,
  191. style: {
  192. fontWeight: 900,
  193. colors: 'rgb(0, 143, 251)'
  194. }
  195. },
  196. title: {
  197. text: 'Logarithmic',
  198. style: {
  199. fontWeight: 900,
  200. color: 'rgb(0, 143, 251)'
  201. }
  202. }
  203. },
  204. {
  205. min: 1000000,
  206. max: 500000000,
  207. opposite: true,
  208. tickAmount: 4,
  209. seriesName: 'Linear',
  210. labels: {
  211. formatter: labelFormatter,
  212. style: {
  213. fontWeight: 900,
  214. colors: 'rgb(0, 227, 150)'
  215. }
  216. },
  217. title: {
  218. text: 'Linear',
  219. style: {
  220. fontWeight: 900,
  221. color: 'rgb(0, 227, 150)'
  222. }
  223. }
  224. }
  225. ]
  226. },
  227. },
  228. })
  229. </script>
  230. </body>
  231. </html>