range-annotations-inverted-axis-example.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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>Inverted axis chart with Range Annotations</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. <script>
  16. window.Promise ||
  17. document.write(
  18. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  19. )
  20. window.Promise ||
  21. document.write(
  22. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  23. )
  24. window.Promise ||
  25. document.write(
  26. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  27. )
  28. </script>
  29. <script src="https://cdn.jsdelivr.net/npm/react@16.12/umd/react.production.min.js"></script>
  30. <script src="https://cdn.jsdelivr.net/npm/react-dom@16.12/umd/react-dom.production.min.js"></script>
  31. <script src="https://cdn.jsdelivr.net/npm/prop-types@15.7.2/prop-types.min.js"></script>
  32. <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.34/browser.min.js"></script>
  33. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  34. <script src="https://cdn.jsdelivr.net/npm/react-apexcharts@1.3.6/dist/react-apexcharts.iife.min.js"></script>
  35. <script src="../../assets/stock-prices.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;bar&quot; height={350} /&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: [{
  50. data: [400, 430, 448, 470, 540, 580, 690, 1100, 1200, 1380]
  51. }],
  52. options: {
  53. annotations: {
  54. yaxis: [{
  55. y: 'United Kingdom',
  56. y2: 'South Korea',
  57. borderColor: '#FEB019',
  58. label: {
  59. borderColor: '#333',
  60. style: {
  61. fontSize: '10px',
  62. color: '#333',
  63. background: '#FEB019',
  64. },
  65. text: 'Y-axis range',
  66. }
  67. }],
  68. xaxis: [{
  69. x: 400,
  70. x2: 800,
  71. borderColor: '#00E396',
  72. label: {
  73. borderColor: '#00E396',
  74. style: {
  75. fontSize: '10px',
  76. color: '#fff',
  77. background: '#00E396',
  78. },
  79. offsetY: -10,
  80. text: 'X-axis range',
  81. }
  82. }]
  83. },
  84. chart: {
  85. height: 350,
  86. type: 'bar',
  87. },
  88. plotOptions: {
  89. bar: {
  90. horizontal: true,
  91. }
  92. },
  93. dataLabels: {
  94. enabled: false
  95. },
  96. xaxis: {
  97. categories: ['South Korea', 'Canada', 'United Kingdom', 'Netherlands', 'Italy', 'France', 'Japan', 'United States', 'China', 'Germany'],
  98. }
  99. },
  100. };
  101. }
  102. render() {
  103. return (
  104. <div>
  105. <div id="chart">
  106. <ReactApexChart options={this.state.options} series={this.state.series} type="bar" height={350} />
  107. </div>
  108. <div id="html-dist"></div>
  109. </div>
  110. );
  111. }
  112. }
  113. const domContainer = document.querySelector('#app');
  114. ReactDOM.render(React.createElement(ApexChart), domContainer);
  115. </script>
  116. </body>
  117. </html>