candlestick-bar.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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>CandleStick Chart with Bar</title>
  8. <link href="../../assets/styles.css" rel="stylesheet" />
  9. <style>
  10. .chart-box {
  11. max-width: 650px;
  12. margin: 35px auto;
  13. }
  14. #chart-candlestick,
  15. #chart-bar {
  16. max-width: 640px;
  17. }
  18. #chart-bar {
  19. margin-top: -30px;
  20. }
  21. </style>
  22. <script>
  23. window.Promise ||
  24. document.write(
  25. '<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"><\/script>'
  26. )
  27. window.Promise ||
  28. document.write(
  29. '<script src="https://cdn.jsdelivr.net/npm/eligrey-classlist-js-polyfill@1.2.20171210/classList.min.js"><\/script>'
  30. )
  31. window.Promise ||
  32. document.write(
  33. '<script src="https://cdn.jsdelivr.net/npm/findindex_polyfill_mdn"><\/script>'
  34. )
  35. </script>
  36. <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.min.js"></script>
  37. <script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
  38. <script src="https://cdn.jsdelivr.net/npm/vue-apexcharts"></script>
  39. <script src="../../assets/ohlc.js"></script>
  40. </head>
  41. <body>
  42. <div id="app">
  43. <div class="chart-box">
  44. <div id="chart-candlestick">
  45. <apexchart type="candlestick" height="290" :options="chartOptions" :series="series"></apexchart>
  46. </div>
  47. <div id="chart-bar">
  48. <apexchart type="bar" height="160" :options="chartOptionsBar" :series="seriesBar"></apexchart>
  49. </div>
  50. </div>
  51. </div>
  52. <!-- Below element is just for displaying source code. it is not required. DO NOT USE -->
  53. <div id="html">
  54. &lt;div class=&quot;chart-box&quot;&gt;
  55. &lt;div id=&quot;chart-candlestick&quot;&gt;
  56. &lt;apexchart type=&quot;candlestick&quot; height=&quot;290&quot; :options=&quot;chartOptions&quot; :series=&quot;series&quot;&gt;&lt;/apexchart&gt;
  57. &lt;/div&gt;
  58. &lt;div id=&quot;chart-bar&quot;&gt;
  59. &lt;apexchart type=&quot;bar&quot; height=&quot;160&quot; :options=&quot;chartOptionsBar&quot; :series=&quot;seriesBar&quot;&gt;&lt;/apexchart&gt;
  60. &lt;/div&gt;
  61. &lt;/div&gt;
  62. </div>
  63. <script>
  64. new Vue({
  65. el: '#app',
  66. components: {
  67. apexchart: VueApexCharts,
  68. },
  69. data: {
  70. series: [{
  71. data: seriesData
  72. }],
  73. chartOptions: {
  74. chart: {
  75. type: 'candlestick',
  76. height: 290,
  77. id: 'candles',
  78. toolbar: {
  79. autoSelected: 'pan',
  80. show: false
  81. },
  82. zoom: {
  83. enabled: false
  84. },
  85. },
  86. plotOptions: {
  87. candlestick: {
  88. colors: {
  89. upward: '#3C90EB',
  90. downward: '#DF7D46'
  91. }
  92. }
  93. },
  94. xaxis: {
  95. type: 'datetime'
  96. }
  97. },
  98. seriesBar: [{
  99. name: 'volume',
  100. data: seriesDataLinear
  101. }],
  102. chartOptionsBar: {
  103. chart: {
  104. height: 160,
  105. type: 'bar',
  106. brush: {
  107. enabled: true,
  108. target: 'candles'
  109. },
  110. selection: {
  111. enabled: true,
  112. xaxis: {
  113. min: new Date('20 Jan 2017').getTime(),
  114. max: new Date('10 Dec 2017').getTime()
  115. },
  116. fill: {
  117. color: '#ccc',
  118. opacity: 0.4
  119. },
  120. stroke: {
  121. color: '#0D47A1',
  122. }
  123. },
  124. },
  125. dataLabels: {
  126. enabled: false
  127. },
  128. plotOptions: {
  129. bar: {
  130. columnWidth: '80%',
  131. colors: {
  132. ranges: [{
  133. from: -1000,
  134. to: 0,
  135. color: '#F15B46'
  136. }, {
  137. from: 1,
  138. to: 10000,
  139. color: '#FEB019'
  140. }],
  141. },
  142. }
  143. },
  144. stroke: {
  145. width: 0
  146. },
  147. xaxis: {
  148. type: 'datetime',
  149. axisBorder: {
  150. offsetX: 13
  151. }
  152. },
  153. yaxis: {
  154. labels: {
  155. show: false
  156. }
  157. }
  158. },
  159. },
  160. })
  161. </script>
  162. </body>
  163. </html>