multiple-yaxes.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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>Multiple Y Axis Chart</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. #chart {
  11. max-width: 650px;
  12. margin: 35px auto;
  13. }
  14. .apexcharts-tooltip-title {
  15. display: none;
  16. }
  17. #chart .apexcharts-tooltip {
  18. display: flex;
  19. border: 0;
  20. box-shadow: none;
  21. }
  22. </style>
  23. <script>
  24. window.Promise ||
  25. document.write(
  26. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  27. )
  28. window.Promise ||
  29. document.write(
  30. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  31. )
  32. window.Promise ||
  33. document.write(
  34. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  35. )
  36. </script>
  37. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  38. </head>
  39. <body>
  40. <div id="chart"></div>
  41. <script>
  42. var options = {
  43. series: [{
  44. name: 'Income',
  45. type: 'column',
  46. data: [1.4, 2, 2.5, 1.5, 2.5, 2.8, 3.8, 4.6]
  47. }, {
  48. name: 'Cashflow',
  49. type: 'column',
  50. data: [1.1, 3, 3.1, 4, 4.1, 4.9, 6.5, 8.5]
  51. }, {
  52. name: 'Revenue',
  53. type: 'line',
  54. data: [20, 29, 37, 36, 44, 45, 50, 58]
  55. }],
  56. chart: {
  57. height: 350,
  58. type: 'line',
  59. stacked: false
  60. },
  61. dataLabels: {
  62. enabled: false
  63. },
  64. stroke: {
  65. width: [1, 1, 4]
  66. },
  67. title: {
  68. text: 'XYZ - Stock Analysis (2009 - 2016)',
  69. align: 'left',
  70. offsetX: 110
  71. },
  72. xaxis: {
  73. categories: [2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016],
  74. },
  75. yaxis: [
  76. {
  77. axisTicks: {
  78. show: true,
  79. },
  80. axisBorder: {
  81. show: true,
  82. color: '#008FFB'
  83. },
  84. labels: {
  85. style: {
  86. colors: '#008FFB',
  87. }
  88. },
  89. title: {
  90. text: "Income (thousand crores)",
  91. style: {
  92. color: '#008FFB',
  93. }
  94. },
  95. tooltip: {
  96. enabled: true
  97. }
  98. },
  99. {
  100. seriesName: 'Income',
  101. opposite: true,
  102. axisTicks: {
  103. show: true,
  104. },
  105. axisBorder: {
  106. show: true,
  107. color: '#00E396'
  108. },
  109. labels: {
  110. style: {
  111. colors: '#00E396',
  112. }
  113. },
  114. title: {
  115. text: "Operating Cashflow (thousand crores)",
  116. style: {
  117. color: '#00E396',
  118. }
  119. },
  120. },
  121. {
  122. seriesName: 'Revenue',
  123. opposite: true,
  124. axisTicks: {
  125. show: true,
  126. },
  127. axisBorder: {
  128. show: true,
  129. color: '#FEB019'
  130. },
  131. labels: {
  132. style: {
  133. colors: '#FEB019',
  134. },
  135. },
  136. title: {
  137. text: "Revenue (thousand crores)",
  138. style: {
  139. color: '#FEB019',
  140. }
  141. }
  142. },
  143. ],
  144. tooltip: {
  145. fixed: {
  146. enabled: true,
  147. position: 'topLeft', // topRight, topLeft, bottomRight, bottomLeft
  148. offsetY: 30,
  149. offsetX: 60
  150. },
  151. },
  152. legend: {
  153. horizontalAlign: 'left',
  154. offsetX: 40
  155. }
  156. };
  157. var chart = new ApexCharts(document.querySelector("#chart"), options);
  158. chart.render();
  159. </script>
  160. </body>
  161. </html>