patterned-bar.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 Pattern Fill</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/apexcharts"></script>
  30. </head>
  31. <body>
  32. <div id="chart"></div>
  33. <script>
  34. var options = {
  35. series: [{
  36. name: 'Marine Sprite',
  37. data: [44, 55, 41, 37, 22, 43, 21]
  38. }, {
  39. name: 'Striking Calf',
  40. data: [53, 32, 33, 52, 13, 43, 32]
  41. }, {
  42. name: 'Tank Picture',
  43. data: [12, 17, 11, 9, 15, 11, 20]
  44. }, {
  45. name: 'Bucket Slope',
  46. data: [9, 7, 5, 8, 6, 9, 4]
  47. }],
  48. chart: {
  49. type: 'bar',
  50. height: 350,
  51. stacked: true,
  52. dropShadow: {
  53. enabled: true,
  54. blur: 1,
  55. opacity: 0.25
  56. }
  57. },
  58. plotOptions: {
  59. bar: {
  60. horizontal: true,
  61. barHeight: '60%',
  62. },
  63. },
  64. dataLabels: {
  65. enabled: false
  66. },
  67. stroke: {
  68. width: 2,
  69. },
  70. title: {
  71. text: 'Compare Sales Strategy'
  72. },
  73. xaxis: {
  74. categories: [2008, 2009, 2010, 2011, 2012, 2013, 2014],
  75. },
  76. yaxis: {
  77. title: {
  78. text: undefined
  79. },
  80. },
  81. tooltip: {
  82. shared: false,
  83. y: {
  84. formatter: function (val) {
  85. return val + "K"
  86. }
  87. }
  88. },
  89. fill: {
  90. type: 'pattern',
  91. opacity: 1,
  92. pattern: {
  93. style: ['circles', 'slantedLines', 'verticalLines', 'horizontalLines'], // string or array of strings
  94. }
  95. },
  96. states: {
  97. hover: {
  98. filter: 'none'
  99. }
  100. },
  101. legend: {
  102. position: 'right',
  103. offsetY: 40
  104. }
  105. };
  106. var chart = new ApexCharts(document.querySelector("#chart"), options);
  107. chart.render();
  108. </script>
  109. </body>
  110. </html>