bar-with-images.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/apexcharts"></script>
  33. </head>
  34. <body>
  35. <div id="chart"></div>
  36. <script>
  37. var options = {
  38. series: [{
  39. name: 'coins',
  40. data: [2, 4, 3, 4, 3, 5, 5, 6.5, 6, 5, 4, 5, 8, 7, 7, 8, 8, 10, 9, 9, 12, 12,
  41. 11, 12, 13, 14, 16, 14, 15, 17, 19, 21
  42. ]
  43. }],
  44. chart: {
  45. type: 'bar',
  46. height: 410,
  47. animations: {
  48. enabled: false
  49. }
  50. },
  51. plotOptions: {
  52. bar: {
  53. horizontal: true,
  54. barHeight: '100%',
  55. },
  56. },
  57. dataLabels: {
  58. enabled: false,
  59. },
  60. stroke: {
  61. colors: ["#fff"],
  62. width: 0.2
  63. },
  64. labels: Array.apply(null, {length: 39}).map(function(el, index){
  65. return index + 1;
  66. }),
  67. yaxis: {
  68. axisBorder: {
  69. show: false
  70. },
  71. axisTicks: {
  72. show: false
  73. },
  74. labels: {
  75. show: false
  76. },
  77. title: {
  78. text: 'Weight',
  79. },
  80. },
  81. grid: {
  82. position: 'back'
  83. },
  84. title: {
  85. text: 'Paths filled by clipped image',
  86. align: 'right',
  87. offsetY: 30
  88. },
  89. fill: {
  90. type: 'image',
  91. opacity: 0.87,
  92. image: {
  93. src: ['../../assets/images/4274635880_809a4b9d0d_z.jpg'],
  94. width: 466,
  95. height: 406
  96. }
  97. },
  98. };
  99. var chart = new ApexCharts(document.querySelector("#chart"), options);
  100. chart.render();
  101. </script>
  102. </body>
  103. </html>