timeline.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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>Timeline Bar Chart</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. </head>
  16. <body>
  17. <div id="app"></div>
  18. <div id="html">
  19. &lt;div id=&quot;chart&quot;&gt;&#10; &lt;ReactApexChart options={this.state.options} series={this.state.series} type=&quot;rangeBar&quot; height=&quot;350&quot; /&gt;&#10; &lt;/div&gt;
  20. </div>
  21. <script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
  22. <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
  23. <script src="https://unpkg.com/prop-types@15.6.2/prop-types.min.js">
  24. </script>
  25. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
  26. <script src="https://cdn.jsdelivr.net/npm/apexcharts@latest"></script>
  27. <script src="https://unpkg.com/react-apexcharts@1.1.0/dist/react-apexcharts.iife.min.js"></script>
  28. <script type="text/babel">
  29. class BarChart extends React.Component {
  30. constructor(props) {
  31. super(props);
  32. this.state = {
  33. options: {
  34. plotOptions: {
  35. bar: {
  36. horizontal: true,
  37. }
  38. },
  39. yaxis: {
  40. min: new Date('2019-03-01').getTime(),
  41. max: new Date('2019-03-14').getTime()
  42. },
  43. xaxis: {
  44. type: 'datetime'
  45. },
  46. fill: {
  47. type: 'gradient',
  48. gradient: {
  49. shade: 'light',
  50. type: "vertical",
  51. shadeIntensity: 0.25,
  52. gradientToColors: undefined,
  53. inverseColors: true,
  54. opacityFrom: 1,
  55. opacityTo: 1,
  56. stops: [50, 0, 100, 100]
  57. }
  58. }
  59. },
  60. series: [
  61. {
  62. name: 'Bob',
  63. data: [{
  64. x: 'Design',
  65. y: [new Date('2019-03-02').getTime(), new Date('2019-03-03').getTime()]
  66. }, {
  67. x: 'Code',
  68. y: [new Date('2019-03-02').getTime(), new Date('2019-03-04').getTime()]
  69. }, {
  70. x: 'Test',
  71. y: [new Date('2019-03-04').getTime(), new Date('2019-03-07').getTime()]
  72. }, {
  73. x: 'Deployment',
  74. y: [new Date('2019-03-11').getTime(), new Date('2019-03-12').getTime()]
  75. }]
  76. }, {
  77. name: 'Joe',
  78. data: [{
  79. x: 'Design',
  80. y: [new Date('2019-03-01').getTime(), new Date('2019-03-02').getTime()]
  81. }, {
  82. x: 'Code',
  83. y: [new Date('2019-03-03').getTime(), new Date('2019-03-07').getTime()]
  84. }, {
  85. x: 'Test',
  86. y: [new Date('2019-03-06').getTime(), new Date('2019-03-09').getTime()]
  87. }, {
  88. x: 'Deployment',
  89. y: [new Date('2019-03-10').getTime(), new Date('2019-03-11').getTime()]
  90. }]
  91. }
  92. ],
  93. }
  94. }
  95. render() {
  96. return (
  97. <div>
  98. <div id="chart">
  99. <ReactApexChart options={this.state.options} series={this.state.series} type="rangeBar" height="350" />
  100. </div>
  101. <div id="html-dist">
  102. </div>
  103. </div>
  104. );
  105. }
  106. }
  107. const domContainer = document.querySelector('#app');
  108. ReactDOM.render(React.createElement(BarChart), domContainer);
  109. </script>
  110. </body>
  111. </html>