column-with-rotated-data-labels.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 rotate negative 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: 'Cash Flow',
  54. data: [1.45, 5.42, 5.9, -0.42, -12.6, -18.1, -18.2, -14.16, -11.1, -6.09, 0.34, 3.88, 13.07,
  55. 5.8, 2, 7.37, 8.1, 13.57, 15.75, 17.1, 19.8, -27.03, -54.4, -47.2, -43.3, -18.6, -
  56. 48.6, -41.1, -39.6, -37.6, -29.4, -21.4, -2.4
  57. ]
  58. }],
  59. chartOptions: {
  60. chart: {
  61. type: 'bar',
  62. height: 350
  63. },
  64. plotOptions: {
  65. bar: {
  66. colors: {
  67. ranges: [{
  68. from: -100,
  69. to: -46,
  70. color: '#F15B46'
  71. }, {
  72. from: -45,
  73. to: 0,
  74. color: '#FEB019'
  75. }]
  76. },
  77. columnWidth: '80%',
  78. dataLabels: {
  79. orientation: 'vertical',
  80. position: 'top' // top, center, bottom
  81. },
  82. }
  83. },
  84. dataLabels: {
  85. enabled: true,
  86. style: {
  87. fontSize: '12px',
  88. colors: ["#000000"]
  89. }
  90. },
  91. yaxis: {
  92. title: {
  93. text: 'Growth',
  94. },
  95. labels: {
  96. formatter: function (y) {
  97. return y.toFixed(0) + "%";
  98. }
  99. }
  100. },
  101. xaxis: {
  102. type: 'category',
  103. categories: [
  104. '2011-01-01', '2011-02-01', '2011-03-01', '2011-04-01', '2011-05-01', '2011-06-01',
  105. '2011-07-01', '2011-08-01', '2011-09-01', '2011-10-01', '2011-11-01', '2011-12-01',
  106. '2012-01-01', '2012-02-01', '2012-03-01', '2012-04-01', '2012-05-01', '2012-06-01',
  107. '2012-07-01', '2012-08-01', '2012-09-01', '2012-10-01', '2012-11-01', '2012-12-01',
  108. '2013-01-01', '2013-02-01', '2013-03-01', '2013-04-01', '2013-05-01', '2013-06-01',
  109. '2013-07-01', '2013-08-01', '2013-09-01'
  110. ],
  111. labels: {
  112. rotate: -90
  113. }
  114. }
  115. },
  116. },
  117. })
  118. </script>
  119. </body>
  120. </html>