bar-with-images.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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/react@16.12/umd/react.production.min.js"></script>
  33. <script src="https://cdn.jsdelivr.net/npm/react-dom@16.12/umd/react-dom.production.min.js"></script>
  34. <script src="https://cdn.jsdelivr.net/npm/prop-types@15.7.2/prop-types.min.js"></script>
  35. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
  36. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  37. <script src="https://cdn.jsdelivr.net/npm/react-apexcharts@1.3.6/dist/react-apexcharts.iife.min.js"></script>
  38. </head>
  39. <body>
  40. <div id="app"></div>
  41. <div id="html">
  42. &lt;div id=&quot;chart&quot;&gt;
  43. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;bar&quot; height={410} /&gt;
  44. &lt;/div&gt;
  45. </div>
  46. <script type="text/babel">
  47. class ApexChart extends React.Component {
  48. constructor(props) {
  49. super(props);
  50. this.state = {
  51. series: [{
  52. name: 'coins',
  53. data: [2, 4, 3, 4, 3, 5, 5, 6.5, 6, 5, 4, 5, 8, 7, 7, 8, 8, 10, 9, 9, 12, 12,
  54. 11, 12, 13, 14, 16, 14, 15, 17, 19, 21
  55. ]
  56. }],
  57. options: {
  58. chart: {
  59. type: 'bar',
  60. height: 410,
  61. animations: {
  62. enabled: false
  63. }
  64. },
  65. plotOptions: {
  66. bar: {
  67. horizontal: true,
  68. barHeight: '100%',
  69. },
  70. },
  71. dataLabels: {
  72. enabled: false,
  73. },
  74. stroke: {
  75. colors: ["#fff"],
  76. width: 0.2
  77. },
  78. labels: Array.apply(null, {length: 39}).map(function(el, index){
  79. return index + 1;
  80. }),
  81. yaxis: {
  82. axisBorder: {
  83. show: false
  84. },
  85. axisTicks: {
  86. show: false
  87. },
  88. labels: {
  89. show: false
  90. },
  91. title: {
  92. text: 'Weight',
  93. },
  94. },
  95. grid: {
  96. position: 'back'
  97. },
  98. title: {
  99. text: 'Paths filled by clipped image',
  100. align: 'right',
  101. offsetY: 30
  102. },
  103. fill: {
  104. type: 'image',
  105. opacity: 0.87,
  106. image: {
  107. src: ['../../assets/images/4274635880_809a4b9d0d_z.jpg'],
  108. width: 466,
  109. height: 406
  110. }
  111. },
  112. },
  113. };
  114. }
  115. render() {
  116. return (
  117. <div>
  118. <div id="chart">
  119. <ReactApexChart options={this.state.options} series={this.state.series} type="bar" height={410} />
  120. </div>
  121. <div id="html-dist"></div>
  122. </div>
  123. );
  124. }
  125. }
  126. const domContainer = document.querySelector('#app');
  127. ReactDOM.render(React.createElement(ApexChart), domContainer);
  128. </script>
  129. </body>
  130. </html>