donut-with-pattern.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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/react@16.12/umd/react.production.min.js"></script>
  31. <script src="https://cdn.jsdelivr.net/npm/react-dom@16.12/umd/react-dom.production.min.js"></script>
  32. <script src="https://cdn.jsdelivr.net/npm/prop-types@15.7.2/prop-types.min.js"></script>
  33. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
  34. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  35. <script src="https://cdn.jsdelivr.net/npm/react-apexcharts@1.3.6/dist/react-apexcharts.iife.min.js"></script>
  36. </head>
  37. <body>
  38. <div id="app"></div>
  39. <div id="html">
  40. &lt;div id=&quot;chart&quot;&gt;
  41. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;donut&quot; width={380} /&gt;
  42. &lt;/div&gt;
  43. </div>
  44. <script type="text/babel">
  45. class ApexChart extends React.Component {
  46. constructor(props) {
  47. super(props);
  48. this.state = {
  49. series: [44, 55, 41, 17, 15],
  50. options: {
  51. chart: {
  52. width: 380,
  53. type: 'donut',
  54. dropShadow: {
  55. enabled: true,
  56. color: '#111',
  57. top: -1,
  58. left: 3,
  59. blur: 3,
  60. opacity: 0.2
  61. }
  62. },
  63. stroke: {
  64. width: 0,
  65. },
  66. plotOptions: {
  67. pie: {
  68. donut: {
  69. labels: {
  70. show: true,
  71. total: {
  72. showAlways: true,
  73. show: true
  74. }
  75. }
  76. }
  77. }
  78. },
  79. labels: ["Comedy", "Action", "SciFi", "Drama", "Horror"],
  80. dataLabels: {
  81. dropShadow: {
  82. blur: 3,
  83. opacity: 0.8
  84. }
  85. },
  86. fill: {
  87. type: 'pattern',
  88. opacity: 1,
  89. pattern: {
  90. enabled: true,
  91. style: ['verticalLines', 'squares', 'horizontalLines', 'circles','slantedLines'],
  92. },
  93. },
  94. states: {
  95. hover: {
  96. filter: 'none'
  97. }
  98. },
  99. theme: {
  100. palette: 'palette2'
  101. },
  102. title: {
  103. text: "Favourite Movie Type"
  104. },
  105. responsive: [{
  106. breakpoint: 480,
  107. options: {
  108. chart: {
  109. width: 200
  110. },
  111. legend: {
  112. position: 'bottom'
  113. }
  114. }
  115. }]
  116. },
  117. };
  118. }
  119. render() {
  120. return (
  121. <div>
  122. <div id="chart">
  123. <ReactApexChart options={this.state.options} series={this.state.series} type="donut" width={380} />
  124. </div>
  125. <div id="html-dist"></div>
  126. </div>
  127. );
  128. }
  129. }
  130. const domContainer = document.querySelector('#app');
  131. ReactDOM.render(React.createElement(ApexChart), domContainer);
  132. </script>
  133. </body>
  134. </html>