donut-with-pattern.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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>Donut Chart with pattern</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. #chart {
  11. padding: 0;
  12. max-width: 380px;
  13. margin: 35px auto;
  14. }
  15. </style>
  16. <script>
  17. window.Promise ||
  18. document.write(
  19. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  20. )
  21. window.Promise ||
  22. document.write(
  23. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  24. )
  25. window.Promise ||
  26. document.write(
  27. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  28. )
  29. </script>
  30. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  31. </head>
  32. <body>
  33. <div id="chart"></div>
  34. <script>
  35. var options = {
  36. series: [44, 55, 41, 17, 15],
  37. chart: {
  38. width: 380,
  39. type: 'donut',
  40. dropShadow: {
  41. enabled: true,
  42. color: '#111',
  43. top: -1,
  44. left: 3,
  45. blur: 3,
  46. opacity: 0.2
  47. }
  48. },
  49. stroke: {
  50. width: 0,
  51. },
  52. plotOptions: {
  53. pie: {
  54. donut: {
  55. labels: {
  56. show: true,
  57. total: {
  58. showAlways: true,
  59. show: true
  60. }
  61. }
  62. }
  63. }
  64. },
  65. labels: ["Comedy", "Action", "SciFi", "Drama", "Horror"],
  66. dataLabels: {
  67. dropShadow: {
  68. blur: 3,
  69. opacity: 0.8
  70. }
  71. },
  72. fill: {
  73. type: 'pattern',
  74. opacity: 1,
  75. pattern: {
  76. enabled: true,
  77. style: ['verticalLines', 'squares', 'horizontalLines', 'circles','slantedLines'],
  78. },
  79. },
  80. states: {
  81. hover: {
  82. filter: 'none'
  83. }
  84. },
  85. theme: {
  86. palette: 'palette2'
  87. },
  88. title: {
  89. text: "Favourite Movie Type"
  90. },
  91. responsive: [{
  92. breakpoint: 480,
  93. options: {
  94. chart: {
  95. width: 200
  96. },
  97. legend: {
  98. position: 'bottom'
  99. }
  100. }
  101. }]
  102. };
  103. var chart = new ApexCharts(document.querySelector("#chart"), options);
  104. chart.render();
  105. </script>
  106. </body>
  107. </html>