distributed-columns.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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>Distributed Bar</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. #chart {
  11. max-width: 650px;
  12. margin: 35px auto;
  13. }
  14. #chart .apexcharts-xaxis-label {
  15. font-weight: bold;
  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. <script>
  39. var colors = [
  40. '#008FFB',
  41. '#00E396',
  42. '#FEB019',
  43. '#FF4560',
  44. '#775DD0',
  45. '#546E7A',
  46. '#26a69a',
  47. '#D10CE8'
  48. ]
  49. </script>
  50. </head>
  51. <body>
  52. <div id="app"></div>
  53. <div id="html">
  54. &lt;div id=&quot;chart&quot;&gt;
  55. &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;bar&quot; height={350} /&gt;
  56. &lt;/div&gt;
  57. </div>
  58. <script type="text/babel">
  59. class ApexChart extends React.Component {
  60. constructor(props) {
  61. super(props);
  62. this.state = {
  63. series: [{
  64. data: [21, 22, 10, 28, 16, 21, 13, 30]
  65. }],
  66. options: {
  67. chart: {
  68. height: 350,
  69. type: 'bar',
  70. events: {
  71. click: function(chart, w, e) {
  72. // console.log(chart, w, e)
  73. }
  74. }
  75. },
  76. colors: colors,
  77. plotOptions: {
  78. bar: {
  79. columnWidth: '45%',
  80. distributed: true
  81. }
  82. },
  83. dataLabels: {
  84. enabled: false
  85. },
  86. legend: {
  87. show: false
  88. },
  89. xaxis: {
  90. categories: [
  91. ['John', 'Doe'],
  92. ['Joe', 'Smith'],
  93. ['Jake', 'Williams'],
  94. 'Amber',
  95. ['Peter', 'Brown'],
  96. ['Mary', 'Evans'],
  97. ['David', 'Wilson'],
  98. ['Lily', 'Roberts'],
  99. ],
  100. labels: {
  101. style: {
  102. colors: colors,
  103. fontSize: '12px'
  104. }
  105. }
  106. }
  107. },
  108. };
  109. }
  110. render() {
  111. return (
  112. <div>
  113. <div id="chart">
  114. <ReactApexChart options={this.state.options} series={this.state.series} type="bar" height={350} />
  115. </div>
  116. <div id="html-dist"></div>
  117. </div>
  118. );
  119. }
  120. }
  121. const domContainer = document.querySelector('#app');
  122. ReactDOM.render(React.createElement(ApexChart), domContainer);
  123. </script>
  124. </body>
  125. </html>