basic.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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</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/ohlc.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;candlestick&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: [{
  51. x: new Date(1538778600000),
  52. y: [6629.81, 6650.5, 6623.04, 6633.33]
  53. },
  54. {
  55. x: new Date(1538780400000),
  56. y: [6632.01, 6643.59, 6620, 6630.11]
  57. },
  58. {
  59. x: new Date(1538782200000),
  60. y: [6630.71, 6648.95, 6623.34, 6635.65]
  61. },
  62. {
  63. x: new Date(1538784000000),
  64. y: [6635.65, 6651, 6629.67, 6638.24]
  65. },
  66. {
  67. x: new Date(1538785800000),
  68. y: [6638.24, 6640, 6620, 6624.47]
  69. },
  70. {
  71. x: new Date(1538787600000),
  72. y: [6624.53, 6636.03, 6621.68, 6624.31]
  73. },
  74. {
  75. x: new Date(1538789400000),
  76. y: [6624.61, 6632.2, 6617, 6626.02]
  77. },
  78. {
  79. x: new Date(1538791200000),
  80. y: [6627, 6627.62, 6584.22, 6603.02]
  81. },
  82. {
  83. x: new Date(1538793000000),
  84. y: [6605, 6608.03, 6598.95, 6604.01]
  85. },
  86. {
  87. x: new Date(1538794800000),
  88. y: [6604.5, 6614.4, 6602.26, 6608.02]
  89. },
  90. {
  91. x: new Date(1538796600000),
  92. y: [6608.02, 6610.68, 6601.99, 6608.91]
  93. },
  94. {
  95. x: new Date(1538798400000),
  96. y: [6608.91, 6618.99, 6608.01, 6612]
  97. },
  98. {
  99. x: new Date(1538800200000),
  100. y: [6612, 6615.13, 6605.09, 6612]
  101. },
  102. {
  103. x: new Date(1538802000000),
  104. y: [6612, 6624.12, 6608.43, 6622.95]
  105. },
  106. {
  107. x: new Date(1538803800000),
  108. y: [6623.91, 6623.91, 6615, 6615.67]
  109. },
  110. {
  111. x: new Date(1538805600000),
  112. y: [6618.69, 6618.74, 6610, 6610.4]
  113. },
  114. {
  115. x: new Date(1538807400000),
  116. y: [6611, 6622.78, 6610.4, 6614.9]
  117. },
  118. {
  119. x: new Date(1538809200000),
  120. y: [6614.9, 6626.2, 6613.33, 6623.45]
  121. },
  122. {
  123. x: new Date(1538811000000),
  124. y: [6623.48, 6627, 6618.38, 6620.35]
  125. },
  126. {
  127. x: new Date(1538812800000),
  128. y: [6619.43, 6620.35, 6610.05, 6615.53]
  129. },
  130. {
  131. x: new Date(1538814600000),
  132. y: [6615.53, 6617.93, 6610, 6615.19]
  133. },
  134. {
  135. x: new Date(1538816400000),
  136. y: [6615.19, 6621.6, 6608.2, 6620]
  137. },
  138. {
  139. x: new Date(1538818200000),
  140. y: [6619.54, 6625.17, 6614.15, 6620]
  141. },
  142. {
  143. x: new Date(1538820000000),
  144. y: [6620.33, 6634.15, 6617.24, 6624.61]
  145. },
  146. {
  147. x: new Date(1538821800000),
  148. y: [6625.95, 6626, 6611.66, 6617.58]
  149. },
  150. {
  151. x: new Date(1538823600000),
  152. y: [6619, 6625.97, 6595.27, 6598.86]
  153. },
  154. {
  155. x: new Date(1538825400000),
  156. y: [6598.86, 6598.88, 6570, 6587.16]
  157. },
  158. {
  159. x: new Date(1538827200000),
  160. y: [6588.86, 6600, 6580, 6593.4]
  161. },
  162. {
  163. x: new Date(1538829000000),
  164. y: [6593.99, 6598.89, 6585, 6587.81]
  165. },
  166. {
  167. x: new Date(1538830800000),
  168. y: [6587.81, 6592.73, 6567.14, 6578]
  169. },
  170. {
  171. x: new Date(1538832600000),
  172. y: [6578.35, 6581.72, 6567.39, 6579]
  173. },
  174. {
  175. x: new Date(1538834400000),
  176. y: [6579.38, 6580.92, 6566.77, 6575.96]
  177. },
  178. {
  179. x: new Date(1538836200000),
  180. y: [6575.96, 6589, 6571.77, 6588.92]
  181. },
  182. {
  183. x: new Date(1538838000000),
  184. y: [6588.92, 6594, 6577.55, 6589.22]
  185. },
  186. {
  187. x: new Date(1538839800000),
  188. y: [6589.3, 6598.89, 6589.1, 6596.08]
  189. },
  190. {
  191. x: new Date(1538841600000),
  192. y: [6597.5, 6600, 6588.39, 6596.25]
  193. },
  194. {
  195. x: new Date(1538843400000),
  196. y: [6598.03, 6600, 6588.73, 6595.97]
  197. },
  198. {
  199. x: new Date(1538845200000),
  200. y: [6595.97, 6602.01, 6588.17, 6602]
  201. },
  202. {
  203. x: new Date(1538847000000),
  204. y: [6602, 6607, 6596.51, 6599.95]
  205. },
  206. {
  207. x: new Date(1538848800000),
  208. y: [6600.63, 6601.21, 6590.39, 6591.02]
  209. },
  210. {
  211. x: new Date(1538850600000),
  212. y: [6591.02, 6603.08, 6591, 6591]
  213. },
  214. {
  215. x: new Date(1538852400000),
  216. y: [6591, 6601.32, 6585, 6592]
  217. },
  218. {
  219. x: new Date(1538854200000),
  220. y: [6593.13, 6596.01, 6590, 6593.34]
  221. },
  222. {
  223. x: new Date(1538856000000),
  224. y: [6593.34, 6604.76, 6582.63, 6593.86]
  225. },
  226. {
  227. x: new Date(1538857800000),
  228. y: [6593.86, 6604.28, 6586.57, 6600.01]
  229. },
  230. {
  231. x: new Date(1538859600000),
  232. y: [6601.81, 6603.21, 6592.78, 6596.25]
  233. },
  234. {
  235. x: new Date(1538861400000),
  236. y: [6596.25, 6604.2, 6590, 6602.99]
  237. },
  238. {
  239. x: new Date(1538863200000),
  240. y: [6602.99, 6606, 6584.99, 6587.81]
  241. },
  242. {
  243. x: new Date(1538865000000),
  244. y: [6587.81, 6595, 6583.27, 6591.96]
  245. },
  246. {
  247. x: new Date(1538866800000),
  248. y: [6591.97, 6596.07, 6585, 6588.39]
  249. },
  250. {
  251. x: new Date(1538868600000),
  252. y: [6587.6, 6598.21, 6587.6, 6594.27]
  253. },
  254. {
  255. x: new Date(1538870400000),
  256. y: [6596.44, 6601, 6590, 6596.55]
  257. },
  258. {
  259. x: new Date(1538872200000),
  260. y: [6598.91, 6605, 6596.61, 6600.02]
  261. },
  262. {
  263. x: new Date(1538874000000),
  264. y: [6600.55, 6605, 6589.14, 6593.01]
  265. },
  266. {
  267. x: new Date(1538875800000),
  268. y: [6593.15, 6605, 6592, 6603.06]
  269. },
  270. {
  271. x: new Date(1538877600000),
  272. y: [6603.07, 6604.5, 6599.09, 6603.89]
  273. },
  274. {
  275. x: new Date(1538879400000),
  276. y: [6604.44, 6604.44, 6600, 6603.5]
  277. },
  278. {
  279. x: new Date(1538881200000),
  280. y: [6603.5, 6603.99, 6597.5, 6603.86]
  281. },
  282. {
  283. x: new Date(1538883000000),
  284. y: [6603.85, 6605, 6600, 6604.07]
  285. },
  286. {
  287. x: new Date(1538884800000),
  288. y: [6604.98, 6606, 6604.07, 6606]
  289. },
  290. ]
  291. }],
  292. options: {
  293. chart: {
  294. type: 'candlestick',
  295. height: 350
  296. },
  297. title: {
  298. text: 'CandleStick Chart',
  299. align: 'left'
  300. },
  301. xaxis: {
  302. type: 'datetime'
  303. },
  304. yaxis: {
  305. tooltip: {
  306. enabled: true
  307. }
  308. }
  309. },
  310. };
  311. }
  312. render() {
  313. return (
  314. <div>
  315. <div id="chart">
  316. <ReactApexChart options={this.state.options} series={this.state.series} type="candlestick" height={350} />
  317. </div>
  318. <div id="html-dist"></div>
  319. </div>
  320. );
  321. }
  322. }
  323. const domContainer = document.querySelector('#app');
  324. ReactDOM.render(React.createElement(ApexChart), domContainer);
  325. </script>
  326. </body>
  327. </html>