bar-with-images.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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>Bar Chart with Images</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. #chart {
  11. max-width: 650px;
  12. margin: 35px auto;
  13. }
  14. #apexcharts-canvas {
  15. margin: 0 auto;
  16. }
  17. </style>
  18. <script>
  19. window.Promise ||
  20. document.write(
  21. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  22. )
  23. window.Promise ||
  24. document.write(
  25. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  26. )
  27. window.Promise ||
  28. document.write(
  29. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  30. )
  31. </script>
  32. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
  33. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  34. <script src="https://cdn.jsdelivr.net/npm/vue-apexcharts"></script>
  35. </head>
  36. <body>
  37. <div id="app">
  38. <div id="chart">
  39. <apexchart type="bar" height="410" :options="chartOptions" :series="series"></apexchart>
  40. </div>
  41. </div>
  42. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  43. <div id="html">
  44. &lt;div id=&quot;chart&quot;&gt;
  45. &lt;apexchart type=&quot;bar&quot; height=&quot;410&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  46. &lt;/div&gt;
  47. </div>
  48. <script>
  49. new Vue({
  50. el: '#app',
  51. components: {
  52. apexchart: VueApexCharts,
  53. },
  54. data: {
  55. series: [{
  56. name: 'coins',
  57. data: [2, 4, 3, 4, 3, 5, 5, 6.5, 6, 5, 4, 5, 8, 7, 7, 8, 8, 10, 9, 9, 12, 12,
  58. 11, 12, 13, 14, 16, 14, 15, 17, 19, 21
  59. ]
  60. }],
  61. chartOptions: {
  62. chart: {
  63. type: 'bar',
  64. height: 410,
  65. animations: {
  66. enabled: false
  67. }
  68. },
  69. plotOptions: {
  70. bar: {
  71. horizontal: true,
  72. barHeight: '100%',
  73. },
  74. },
  75. dataLabels: {
  76. enabled: false,
  77. },
  78. stroke: {
  79. colors: ["#fff"],
  80. width: 0.2
  81. },
  82. labels: Array.apply(null, {length: 39}).map(function(el, index){
  83. return index + 1;
  84. }),
  85. yaxis: {
  86. axisBorder: {
  87. show: false
  88. },
  89. axisTicks: {
  90. show: false
  91. },
  92. labels: {
  93. show: false
  94. },
  95. title: {
  96. text: 'Weight',
  97. },
  98. },
  99. grid: {
  100. position: 'back'
  101. },
  102. title: {
  103. text: 'Paths filled by clipped image',
  104. align: 'right',
  105. offsetY: 30
  106. },
  107. fill: {
  108. type: 'image',
  109. opacity: 0.87,
  110. image: {
  111. src: ['../../assets/images/4274635880_809a4b9d0d_z.jpg'],
  112. width: 466,
  113. height: 406
  114. }
  115. },
  116. },
  117. },
  118. })
  119. </script>
  120. </body>
  121. </html>