column-with-data-labels.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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>Column with Data Labels</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: 'Inflation',
  54. data: [2.3, 3.1, 4.0, 10.1, 4.0, 3.6, 3.2, 2.3, 1.4, 0.8, 0.5, 0.2]
  55. }],
  56. chartOptions: {
  57. chart: {
  58. height: 350,
  59. type: 'bar',
  60. },
  61. plotOptions: {
  62. bar: {
  63. dataLabels: {
  64. position: 'top', // top, center, bottom
  65. },
  66. }
  67. },
  68. dataLabels: {
  69. enabled: true,
  70. formatter: function (val) {
  71. return val + "%";
  72. },
  73. offsetY: -20,
  74. style: {
  75. fontSize: '12px',
  76. colors: ["#304758"]
  77. }
  78. },
  79. xaxis: {
  80. categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
  81. position: 'top',
  82. axisBorder: {
  83. show: false
  84. },
  85. axisTicks: {
  86. show: false
  87. },
  88. crosshairs: {
  89. fill: {
  90. type: 'gradient',
  91. gradient: {
  92. colorFrom: '#D8E3F0',
  93. colorTo: '#BED1E6',
  94. stops: [0, 100],
  95. opacityFrom: 0.4,
  96. opacityTo: 0.5,
  97. }
  98. }
  99. },
  100. tooltip: {
  101. enabled: true,
  102. }
  103. },
  104. yaxis: {
  105. axisBorder: {
  106. show: false
  107. },
  108. axisTicks: {
  109. show: false,
  110. },
  111. labels: {
  112. show: false,
  113. formatter: function (val) {
  114. return val + "%";
  115. }
  116. }
  117. },
  118. title: {
  119. text: 'Monthly Inflation in Argentina, 2002',
  120. floating: true,
  121. offsetY: 330,
  122. align: 'center',
  123. style: {
  124. color: '#444'
  125. }
  126. }
  127. },
  128. },
  129. })
  130. </script>
  131. </body>
  132. </html>