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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/apexcharts"></script>
  30. <script src="../../assets/stock-prices.js"></script>
  31. </head>
  32. <body>
  33. <div id="chart"></div>
  34. <script>
  35. var options = {
  36. series: [{
  37. data: [400, 430, 448, 470, 540, 580, 690, 1100, 1200, 1380]
  38. }],
  39. annotations: {
  40. yaxis: [{
  41. y: 'United Kingdom',
  42. y2: 'South Korea',
  43. borderColor: '#FEB019',
  44. label: {
  45. borderColor: '#333',
  46. style: {
  47. fontSize: '10px',
  48. color: '#333',
  49. background: '#FEB019',
  50. },
  51. text: 'Y-axis range',
  52. }
  53. }],
  54. xaxis: [{
  55. x: 400,
  56. x2: 800,
  57. borderColor: '#00E396',
  58. label: {
  59. borderColor: '#00E396',
  60. style: {
  61. fontSize: '10px',
  62. color: '#fff',
  63. background: '#00E396',
  64. },
  65. offsetY: -10,
  66. text: 'X-axis range',
  67. }
  68. }]
  69. },
  70. chart: {
  71. height: 350,
  72. type: 'bar',
  73. },
  74. plotOptions: {
  75. bar: {
  76. horizontal: true,
  77. }
  78. },
  79. dataLabels: {
  80. enabled: false
  81. },
  82. xaxis: {
  83. categories: ['South Korea', 'Canada', 'United Kingdom', 'Netherlands', 'Italy', 'France', 'Japan', 'United States', 'China', 'Germany'],
  84. }
  85. };
  86. var chart = new ApexCharts(document.querySelector("#chart"), options);
  87. chart.render();
  88. </script>
  89. </body>
  90. </html>