stacked-bar.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 Bar Chart</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="bar" height="350" :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;bar&quot; height=&quot;350&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. name: 'Marine Sprite',
  54. data: [44, 55, 41, 37, 22, 43, 21]
  55. }, {
  56. name: 'Striking Calf',
  57. data: [53, 32, 33, 52, 13, 43, 32]
  58. }, {
  59. name: 'Tank Picture',
  60. data: [12, 17, 11, 9, 15, 11, 20]
  61. }, {
  62. name: 'Bucket Slope',
  63. data: [9, 7, 5, 8, 6, 9, 4]
  64. }, {
  65. name: 'Reborn Kid',
  66. data: [25, 12, 19, 32, 25, 24, 10]
  67. }],
  68. chartOptions: {
  69. chart: {
  70. type: 'bar',
  71. height: 350,
  72. stacked: true,
  73. },
  74. plotOptions: {
  75. bar: {
  76. horizontal: true,
  77. },
  78. },
  79. stroke: {
  80. width: 1,
  81. colors: ['#fff']
  82. },
  83. title: {
  84. text: 'Fiction Books Sales'
  85. },
  86. xaxis: {
  87. categories: [2008, 2009, 2010, 2011, 2012, 2013, 2014],
  88. labels: {
  89. formatter: function (val) {
  90. return val + "K"
  91. }
  92. }
  93. },
  94. yaxis: {
  95. title: {
  96. text: undefined
  97. },
  98. },
  99. tooltip: {
  100. y: {
  101. formatter: function (val) {
  102. return val + "K"
  103. }
  104. }
  105. },
  106. fill: {
  107. opacity: 1
  108. },
  109. legend: {
  110. position: 'top',
  111. horizontalAlign: 'left',
  112. offsetX: 40
  113. }
  114. },
  115. },
  116. })
  117. </script>
  118. </body>
  119. </html>