minMaxPoints.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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>Min Max Points example</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/vue/dist/vue.min.js"></script>
  30. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  31. <script src="https://cdn.jsdelivr.net/npm/vue-apexcharts"></script>
  32. <script src="../../assets/stock-prices.js"></script>
  33. </head>
  34. <body>
  35. <div id="app">
  36. <div id="chart">
  37. <apexchart type="area" height="350" :options="chartOptions" :series="series"></apexchart>
  38. </div>
  39. </div>
  40. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  41. <div id="html">
  42. &lt;div id=&quot;chart&quot;&gt;
  43. &lt;apexchart type=&quot;area&quot; height=&quot;350&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  44. &lt;/div&gt;
  45. </div>
  46. <script>
  47. new Vue({
  48. el: '#app',
  49. components: {
  50. apexchart: VueApexCharts,
  51. },
  52. data: {
  53. series: [{
  54. data: [344, 345, 333, 323, 322, 342, 383, 353, 323, 376]
  55. }],
  56. chartOptions: {
  57. chart: {
  58. height: 350,
  59. type: "area",
  60. zoom: {
  61. enabled: false
  62. },
  63. events: {
  64. mounted: function(ctx, config) {
  65. var lowest = ctx.getLowestValueInSeries(0)
  66. var highest = ctx.getHighestValueInSeries(0)
  67. ctx.addPointAnnotation({
  68. x: new Date(ctx.w.globals.seriesX[0][ctx.w.globals.series[0].indexOf(lowest)]).getTime(),
  69. y: lowest,
  70. label: {
  71. text: 'Lowest: ' + lowest,
  72. offsetY: 2
  73. },
  74. image: {
  75. path: '../../assets/images/ico-instagram.png',
  76. width: undefined,
  77. height: undefined,
  78. offsetX: 0,
  79. offsetY: -18
  80. }
  81. })
  82. ctx.addPointAnnotation({
  83. x: new Date(ctx.w.globals.seriesX[0][ctx.w.globals.series[0].indexOf(highest)]).getTime(),
  84. y: highest,
  85. label: {
  86. text: 'Highest: ' + highest,
  87. offsetY: 2
  88. },
  89. })
  90. }
  91. }
  92. },
  93. dataLabels: {
  94. enabled: false
  95. },
  96. stroke: {
  97. curve: "straight"
  98. },
  99. },
  100. },
  101. })
  102. </script>
  103. </body>
  104. </html>