kline.min.js 103 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052
  1. !
  2. function(t, e) {
  3. "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = t || self).VyKline = e()
  4. } (this, (function() {
  5. "use strict";
  6. var t = function(t, e) {
  7. if (! (t instanceof e)) throw new TypeError("Cannot call a class as a function")
  8. };
  9. function e(t, e) {
  10. for (var i = 0; i < e.length; i++) {
  11. var a = e[i];
  12. a.enumerable = a.enumerable || !1,
  13. a.configurable = !0,
  14. "value" in a && (a.writable = !0),
  15. Object.defineProperty(t, a.key, a)
  16. }
  17. }
  18. var i = function(t, i, a) {
  19. return i && e(t.prototype, i),
  20. a && e(t, a),
  21. t
  22. };
  23. function a(t, e) {
  24. return t(e = {
  25. exports: {}
  26. },
  27. e.exports),
  28. e.exports
  29. }
  30. var n = a((function(t) {
  31. function e(t) {
  32. return (e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ?
  33. function(t) {
  34. return typeof t
  35. }: function(t) {
  36. return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol": typeof t
  37. })(t)
  38. }
  39. function i(a) {
  40. return "function" == typeof Symbol && "symbol" === e(Symbol.iterator) ? t.exports = i = function(t) {
  41. return e(t)
  42. }: t.exports = i = function(t) {
  43. return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol": e(t)
  44. },
  45. i(a)
  46. }
  47. t.exports = i
  48. }));
  49. var s = function(t) {
  50. if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  51. return t
  52. };
  53. var o = function(t, e) {
  54. return ! e || "object" !== n(e) && "function" != typeof e ? s(t) : e
  55. },
  56. r = a((function(t) {
  57. function e(i) {
  58. return t.exports = e = Object.setPrototypeOf ? Object.getPrototypeOf: function(t) {
  59. return t.__proto__ || Object.getPrototypeOf(t)
  60. },
  61. e(i)
  62. }
  63. t.exports = e
  64. })),
  65. l = a((function(t) {
  66. function e(i, a) {
  67. return t.exports = e = Object.setPrototypeOf ||
  68. function(t, e) {
  69. return t.__proto__ = e,
  70. t
  71. },
  72. e(i, a)
  73. }
  74. t.exports = e
  75. }));
  76. var c = function(t, e) {
  77. if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
  78. t.prototype = Object.create(e && e.prototype, {
  79. constructor: {
  80. value: t,
  81. writable: !0,
  82. configurable: !0
  83. }
  84. }),
  85. e && l(t, e)
  86. },
  87. h = {
  88. $createElement: function(t) {
  89. return document.createElement(t)
  90. },
  91. $setElementAttribute: function(t, e, i) {
  92. if ("object" === n(i)) for (var a in i) t[e][a] = i[a];
  93. else t.setAttribute(e, i)
  94. },
  95. $removeElementAttribute: function(t, e, i) {
  96. t.removeAttribute(e, i)
  97. },
  98. $getElementAttribute: function(t, e) {
  99. return t.getAttribute(e)
  100. }
  101. };
  102. function u(t, e) {
  103. var i = (t = t < 10 ? "0".concat(t) : t).length,
  104. a = e.length >= t.length ? i: e.length;
  105. return t.slice(i - a, i)
  106. }
  107. var d = {
  108. Y: function(t, e) {
  109. return u(String(t.getFullYear()), e)
  110. },
  111. M: function(t, e) {
  112. return u(String(t.getMonth() + 1), e)
  113. },
  114. D: function(t, e) {
  115. return u(String(t.getDate()), e)
  116. },
  117. H: function(t, e) {
  118. return u(String(t.getHours()), e)
  119. },
  120. m: function(t, e) {
  121. return u(String(t.getMinutes()), e)
  122. },
  123. s: function(t, e) {
  124. return u(String(t.getSeconds()), e)
  125. }
  126. },
  127. _ = new(function() {
  128. function e() {
  129. t(this, e)
  130. }
  131. return i(e, [{
  132. key: "format",
  133. value: function(t, e) {
  134. var i = t;
  135. if (! (t instanceof Date) && (i = new Date(t), "Invalid Date" === String(i))) throw new Error("Invalid Date");
  136. return e.replace(/Y{1,}|M{1,}|D{1,}|H{1,}|m{1,}|s{1,}/g, (function(t) {
  137. return d[t[0]](i, t)
  138. }))
  139. }
  140. }]),
  141. e
  142. } ()),
  143. m = {
  144. "+": function(t, e) {
  145. return t + e
  146. },
  147. "-": function(t, e) {
  148. return t - e
  149. },
  150. "*": function(t, e) {
  151. return t * e
  152. },
  153. "/": function(t, e) {
  154. return t / e
  155. }
  156. };
  157. function v(t) {
  158. for (var e, i = arguments.length,
  159. a = 1; a < i; a++) e = 1 === a ? arguments[a] : m[t](e, arguments[a]);
  160. return e
  161. }
  162. var f = {},
  163. x = function() {
  164. function e() {
  165. t(this, e)
  166. }
  167. return i(e, [{
  168. key: "emit",
  169. value: function(t) {
  170. var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null;
  171. f[t] && f[t].forEach((function(t) {
  172. t(e)
  173. }))
  174. }
  175. },
  176. {
  177. key: "on",
  178. value: function(t, e) {
  179. f[t] || (f[t] = []),
  180. f[t].push(e)
  181. }
  182. }]),
  183. e
  184. } (),
  185. $ = function() {
  186. function e(i) {
  187. var a = this,
  188. n = i.state;
  189. t(this, e),
  190. this.state = {};
  191. var s = this,
  192. o = function(t) {
  193. Object.defineProperty(a.state, t, {
  194. configurable: !1,
  195. enumerable: !0,
  196. get: function() {
  197. return n[t]
  198. },
  199. set: function(e) {
  200. void 0 !== s[t] && (n[t] = e)
  201. }
  202. })
  203. };
  204. for (var r in n) o(r)
  205. }
  206. return i(e, [{
  207. key: "commit",
  208. value: function(t, e) {
  209. this[t] = t,
  210. this.state[t] = e
  211. }
  212. }]),
  213. e
  214. } (),
  215. p = {
  216. DEFAULT_COLUMN_WIDTH: 5,
  217. DEFAULT_COLUMN_SPACE: 1,
  218. VIEW_CHANGE_TRIGGER_WAY: {
  219. SCALE: "SCALE"
  220. },
  221. CHART_TYPE: {
  222. KLINE: "KLINE",
  223. REAL_TIME: "REAL_TIME",
  224. EMPTY_KLINE: "EMPTY_KLINE"
  225. },
  226. WATCHER_EVENT: {
  227. DRAG_MOUSE_MOVING: "dragMouseMoving",
  228. MOUSE_SCALING: "mouseScaling",
  229. ONE_DATA_UPDATED: "onOneDataUpdated",
  230. MOUSE_MOVING: "mouseMoving",
  231. REAL_TIME_DATA: "onRealTimeData",
  232. HISTORY_DATA_CHANGE: "historyDataChange",
  233. SWITCHED_INTERVAL: "switchedInterval",
  234. THEME_SWITCHED: "themeSwitched"
  235. }
  236. },
  237. g = window.devicePixelRatio || 1,
  238. y = {
  239. scale_step: .2,
  240. max_scale: 6,
  241. min_scale: 1,
  242. x_axis_height: 54,
  243. y_axis_width: 54,
  244. axis_segment: 3,
  245. default_rise_color: "#53b987",
  246. default_fall_color: "#eb4d5c",
  247. column_style: "solid",
  248. init_offset_x: 100,
  249. volume_height: 100,
  250. interval_tool_bar: "30px",
  251. theme: {
  252. background_color: null,
  253. axis_text_color: null,
  254. axis_color: null,
  255. background_line_color: null,
  256. realtime_line_color: null,
  257. realtime_area_color: null
  258. },
  259. precision: 4,
  260. chart_type: p.CHART_TYPE.EMPTY_KLINE
  261. },
  262. T = {
  263. user_config: null,
  264. el: null,
  265. loadingNode: null,
  266. chart_instance: null,
  267. vy_chart: null,
  268. DEFAULT_COLUMN_WIDTH: p.DEFAULT_COLUMN_WIDTH * g,
  269. DEFAULT_COLUMN_SPACE: p.DEFAULT_COLUMN_SPACE * g,
  270. column_width: p.DEFAULT_COLUMN_WIDTH * g,
  271. column_space: p.DEFAULT_COLUMN_SPACE * g,
  272. current_interval: null,
  273. kline_data: [],
  274. all_kline_data: [],
  275. current_data: null,
  276. min: null,
  277. max: null,
  278. kline_canvas: null,
  279. current_mouse_coordinates: {
  280. x: null,
  281. y: null
  282. },
  283. current_cross_dash_line: {
  284. x: null,
  285. y: null
  286. },
  287. cross_is_in_newest_data: null,
  288. deedfeeds: null,
  289. y_axis_scale_list: [],
  290. YTag: null,
  291. realtime_tagY: null,
  292. axis_font: "".concat(12 * g, "px Arial"),
  293. current_scale: 1,
  294. no_scale_offset_x: y.init_offset_x,
  295. limit_offset_x: .25,
  296. every_data_px: null,
  297. overflow_data_num: 0,
  298. ma_Lines: [{
  299. range: 5,
  300. lineColor: "#583d7a"
  301. },
  302. {
  303. range: 10,
  304. lineColor: "#95a4c7"
  305. }],
  306. chart_type: p.CHART_TYPE.KLINE
  307. },
  308. E = {
  309. dark: {
  310. background_color: "#131722",
  311. axis_text_color: "#ccc",
  312. axis_color: "#ccc",
  313. background_line_color: "#363c4e",
  314. realtime_line_color: "#9397a4",
  315. realtime_area_color: "rgba(70, 80, 120, 0.6)"
  316. },
  317. light: {
  318. background_color: "#fff",
  319. axis_text_color: "#50535e",
  320. axis_color: "#50535e",
  321. background_line_color: "#e1ecf2",
  322. realtime_line_color: "#2196f3",
  323. realtime_area_color: "rgba(30, 150, 240, 0.2)"
  324. }
  325. };
  326. function w(t) {
  327. return JSON.parse(JSON.stringify(t))
  328. }
  329. var b = new
  330. function e() {
  331. t(this, e),
  332. this.CONSTANTS = p,
  333. this.THEME = E,
  334. this.$Od = h,
  335. this.$time = _,
  336. this.$decimal = v,
  337. this.$copyObjectUnsafe = w,
  338. this.$watcher = new x,
  339. this.$store = new $({
  340. state: Object.assign(T, y)
  341. }),
  342. this.$handleCanvasDrawValue = function(t) {
  343. return Math.round(t) + .5
  344. },
  345. this.$devicePixelRatio = window.devicePixelRatio || 1
  346. },
  347. A = function() {
  348. function e() {
  349. for (var i in t(this, e), b) this[i] = b[i]
  350. }
  351. return i(e, [{
  352. key: "_customChart",
  353. value: function(t) {
  354. var e = Object.keys(y),
  355. i = this.$store.state.user_config.theme,
  356. a = t;
  357. for (var n in a.chartType || (a.chartType = y.chart_type), E[i] || (i = a.theme || "light"), a = Object.assign({},
  358. {
  359. theme: E[i]
  360. },
  361. a)) e.includes(n) && this.$store.commit(n, a[n]);
  362. a.init_offset_x && this.$store.commit("no_scale_offset_x", a.init_offset_x),
  363. this.$store.commit("chart_type", a.chartType)
  364. }
  365. },
  366. {
  367. key: "_clearScreen",
  368. value: function(t, e, i) {
  369. t.clearRect(0, 0, e, i)
  370. }
  371. },
  372. {
  373. key: "_drawBackground",
  374. value: function(t, e, i) {
  375. t.beginPath(),
  376. t.globalAlpha = 1,
  377. t.fillStyle = this.$store.state.theme.background_color,
  378. t.fillRect(0, 0, e, i)
  379. }
  380. },
  381. {
  382. key: "_handleDevicePixelRatio",
  383. value: function(t) {
  384. var e = t.symbol,
  385. i = void 0 === e ? "*": e,
  386. a = t.value;
  387. return this.$decimal(i, a, this.$devicePixelRatio)
  388. }
  389. }]),
  390. e
  391. } (),
  392. D = new(function(e) {
  393. function a() {
  394. return t(this, a),
  395. o(this, r(a).apply(this, arguments))
  396. }
  397. return c(a, e),
  398. i(a, [{
  399. key: "draw",
  400. value: function(t) {
  401. var e = this,
  402. i = t.ctx;
  403. this._ctx = i,
  404. this.$store.state.kline_data.forEach((function(t) {
  405. var i = t.x,
  406. a = t.columnStartY,
  407. n = t.columnHeight,
  408. s = t.close,
  409. o = t.open,
  410. r = t.candleLineStartY,
  411. l = t.candleLineHeight,
  412. c = e.$store.state,
  413. h = c.column_width,
  414. u = c.default_rise_color,
  415. d = c.default_fall_color;
  416. e._ctx.strokeStyle = e._ctx.fillStyle = s >= o ? u: d,
  417. e._ctx.lineWidth = 1;
  418. var _ = e.$handleCanvasDrawValue(e.$decimal("+", i, Math.floor(h / 2)));
  419. e._ctx.beginPath(),
  420. e._ctx.moveTo(_, r),
  421. e._ctx.lineTo(_, r + l),
  422. e._ctx.lineWidth = 1,
  423. e._ctx.stroke(),
  424. e._ctx.fillRect(Math.round(i), a, h, n)
  425. }))
  426. }
  427. }]),
  428. a
  429. } (A)),
  430. C = new(function(e) {
  431. function a() {
  432. return t(this, a),
  433. o(this, r(a).apply(this, arguments))
  434. }
  435. return c(a, e),
  436. i(a, [{
  437. key: "draw",
  438. value: function(t) {
  439. var e = this,
  440. i = t.ctx,
  441. a = t.c;
  442. this._ctx = i,
  443. this.c = a,
  444. this._ctx.beginPath();
  445. var n = this.$store.state,
  446. s = n.kline_data,
  447. o = n.column_width,
  448. r = n.theme,
  449. l = r.realtime_line_color,
  450. c = r.realtime_area_color;
  451. s.forEach((function(t, i) {
  452. var a = t.x,
  453. n = t.columnStartY,
  454. s = t.columnHeight,
  455. r = t.isRise,
  456. l = e.$handleCanvasDrawValue(e.$decimal("+", a, Math.floor(o / 2))),
  457. c = r ? n: e.$decimal("+", n, s);
  458. i ? e._ctx.lineTo(l, c) : e._ctx.moveTo(l, c)
  459. }));
  460. var h = s[0],
  461. u = s[s.length - 1],
  462. d = this.$handleCanvasDrawValue(this.$decimal("+", u.x, Math.floor(o / 2))),
  463. _ = this.$handleCanvasDrawValue(this.$decimal("+", h.x, Math.floor(o / 2)));
  464. this._ctx.lineTo(d, this.c.height + 1),
  465. this._ctx.lineTo(_, this.c.height + 1),
  466. this._ctx.lineWidth = 1,
  467. this._ctx.strokeStyle = l,
  468. this._ctx.fillStyle = c,
  469. this._ctx.stroke(),
  470. this._ctx.fill()
  471. }
  472. }]),
  473. a
  474. } (A)),
  475. k = new(function(e) {
  476. function a() {
  477. return t(this, a),
  478. o(this, r(a).apply(this, arguments))
  479. }
  480. return c(a, e),
  481. i(a, [{
  482. key: "draw",
  483. value: function(t) {
  484. var e = this,
  485. i = t.ctx;
  486. this._ctx = i,
  487. this.$store.state.kline_data.forEach((function(t, i, a) {
  488. var n = t.x,
  489. s = t.columnStartY,
  490. o = t.columnHeight,
  491. r = t.close,
  492. l = (t.open, t.candleLineStartY),
  493. c = t.candleLineHeight,
  494. h = e.$store.state,
  495. u = h.column_width,
  496. d = h.default_rise_color,
  497. _ = h.default_fall_color,
  498. m = !a[i + 1] || r - a[i + 1].close >= 0;
  499. e._ctx.strokeStyle = e._ctx.fillStyle = m ? d: _,
  500. e._ctx.lineWidth = 1;
  501. var v = e.$devicePixelRatio % 2 == 0 ? .5 : 0,
  502. f = Math.round(n) + .5,
  503. x = Math.round(n) + v,
  504. $ = e.$handleCanvasDrawValue(e.$decimal("+", x, Math.floor(u / 2)));
  505. e._ctx.beginPath(),
  506. e._ctx.moveTo($, l),
  507. e._ctx.lineTo($, s),
  508. e._ctx.moveTo($, e.$decimal("+", s, o)),
  509. e._ctx.lineTo($, e.$decimal("+", l, c)),
  510. e._ctx.lineWidth = 1,
  511. e._ctx.stroke(),
  512. t.isRise ? e._ctx.strokeRect(f, s, u, o) : e._ctx.fillRect(x, s, u, o)
  513. }))
  514. }
  515. }]),
  516. a
  517. } (A));
  518. var M = function(t, e, i) {
  519. return e in t ? Object.defineProperty(t, e, {
  520. value: i,
  521. enumerable: !0,
  522. configurable: !0,
  523. writable: !0
  524. }) : t[e] = i,
  525. t
  526. };
  527. function S(t, e) {
  528. var i = Object.keys(t);
  529. if (Object.getOwnPropertySymbols) {
  530. var a = Object.getOwnPropertySymbols(t);
  531. e && (a = a.filter((function(e) {
  532. return Object.getOwnPropertyDescriptor(t, e).enumerable
  533. }))),
  534. i.push.apply(i, a)
  535. }
  536. return i
  537. }
  538. var O = function(e) {
  539. function a(e) {
  540. var i, n = e._ctx,
  541. s = e.range;
  542. return t(this, a),
  543. (i = o(this, r(a).call(this)))._ctx = n,
  544. i.range = s,
  545. i
  546. }
  547. return c(a, e),
  548. i(a, [{
  549. key: "draw",
  550. value: function() {
  551. var t = this._handleMALineData();
  552. this._drawMALine(t)
  553. }
  554. },
  555. {
  556. key: "_handleMALineData",
  557. value: function() {
  558. var t = this,
  559. e = [],
  560. i = [];
  561. return this.$store.state.all_kline_data.slice(this.$store.state.overflow_data_num, 2 * this.$store.state.kline_data.length + this.$store.state.overflow_data_num).forEach((function(a, n, s) {
  562. if (! (s.length - t.range - n < 0)) {
  563. i = s.slice(n, n + t.range);
  564. var o = function(t) {
  565. for (var e = 1; e < arguments.length; e++) {
  566. var i = null != arguments[e] ? arguments[e] : {};
  567. e % 2 ? S(i, !0).forEach((function(e) {
  568. M(t, e, i[e])
  569. })) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : S(i).forEach((function(e) {
  570. Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e))
  571. }))
  572. }
  573. return t
  574. } ({},
  575. a, {
  576. avgClose: 0
  577. }),
  578. r = 0;
  579. i.forEach((function(e) {
  580. r = t.$decimal("+", r, e.close)
  581. })),
  582. o.avgClose = t.$decimal("/", r, t.range),
  583. e.push(o),
  584. t.$store.state.kline_data[n] && (t.$store.state.kline_data[n]["MAClose".concat(t.range)] = o.avgClose),
  585. i = []
  586. }
  587. })),
  588. (e = e.slice(0, this.$store.state.kline_data.length)).forEach((function(e, i) {
  589. Object.assign(e, t.$store.state.kline_data[i])
  590. })),
  591. e
  592. }
  593. },
  594. {
  595. key: "_drawMALine",
  596. value: function(t) {
  597. var e = this;
  598. this._ctx.beginPath();
  599. var i = this.$store.state,
  600. a = i.el,
  601. n = i.x_axis_height,
  602. s = i.volume_height,
  603. o = i.min,
  604. r = i.every_data_px,
  605. l = i.column_width,
  606. c = a.offsetHeight,
  607. h = this.$decimal("-", c, n, s) * this.$devicePixelRatio;
  608. t.forEach((function(t, i, a) {
  609. var n = e.$decimal("+", t.x, l / 2),
  610. s = e.$decimal("-", h, (t.avgClose - o) * r);
  611. i ? e._ctx.lineTo(n, s) : (e._ctx.beginPath(), e._ctx.moveTo(n, s))
  612. })),
  613. this._ctx.stroke()
  614. }
  615. }]),
  616. a
  617. } (A),
  618. R = function(e) {
  619. function a() {
  620. var e;
  621. return t(this, a),
  622. (e = o(this, r(a).call(this))).c = e.$Od.$createElement("canvas"),
  623. e.c.width = e._handleDevicePixelRatio({
  624. value: e.$decimal("-", e.$store.state.el.offsetWidth, e.$store.state.y_axis_width)
  625. }),
  626. e.c.height = e._handleDevicePixelRatio({
  627. value: e.$decimal("-", e.$store.state.el.offsetHeight, e.$store.state.x_axis_height, e.$store.state.volume_height)
  628. }),
  629. e.c.style.position = "absolute",
  630. e.c.style.top = 0,
  631. e.c.style.left = 0,
  632. e.c.style.padding = "25px 0px 0px 0px ",
  633. e.c.style.width = "".concat(e._handleDevicePixelRatio({
  634. symbol: "/",
  635. value: e.c.width
  636. }), "px"),
  637. e.c.style.height = "".concat(e._handleDevicePixelRatio({
  638. symbol: "/",
  639. value: e.c.height-22
  640. }), "px"),
  641. // console.log(e.c.height,'111111'),
  642. e._ctx = e.c.getContext("2d"),
  643. e.$watcher.on(p.WATCHER_EVENT.DRAG_MOUSE_MOVING, e.dragMouseMoving.bind(s(e))),
  644. e.$watcher.on(p.WATCHER_EVENT.MOUSE_SCALING, e.mouseScaling.bind(s(e))),
  645. e.mALineInstanceList = [],
  646. e.$store.state.ma_Lines.forEach((function(t) {
  647. var i = new O({
  648. _ctx: e._ctx,
  649. range: t.range
  650. });
  651. e.mALineInstanceList.push(i)
  652. })),
  653. e
  654. }
  655. return c(a, e),
  656. i(a, [{
  657. key: "drawHistory",
  658. value: function() {
  659. var t = this,
  660. e = this.$store.state,
  661. i = e.y_axis_scale_list,
  662. a = e.chart_type,
  663. n = e.theme.background_line_color;
  664. switch (this._clearScreen(this._ctx, this.c.width, this.c.height), this._drawBackground(this._ctx, this.c.width, this.c.height), this._ctx.setLineDash([0]), i.forEach((function(e) {
  665. // t._ctx.beginPath(),
  666. // t._ctx.strokeStyle = n,
  667. // t._ctx.lineWidth = 1;
  668. // var i = Math.round(e) - .5;
  669. // t._ctx.moveTo(0, i),
  670. // console.log('后面得线'),
  671. // t._ctx.lineTo(t.c.width, i),
  672. // t._ctx.stroke()
  673. })), this._ctx.strokeStyle = this.$store.state.ma_Lines[0].lineColor, this.mALineInstanceList[0].draw(), this._ctx.strokeStyle = this.$store.state.ma_Lines[1].lineColor, this.mALineInstanceList[1].draw(), a) {
  674. case this.CONSTANTS.CHART_TYPE.KLINE:
  675. D.draw({
  676. ctx:
  677. this._ctx
  678. });
  679. break;
  680. case this.CONSTANTS.CHART_TYPE.REAL_TIME:
  681. C.draw({
  682. ctx:
  683. this._ctx,
  684. c: this.c
  685. });
  686. break;
  687. case this.CONSTANTS.CHART_TYPE.EMPTY_KLINE:
  688. k.draw({
  689. ctx:
  690. this._ctx
  691. });
  692. break;
  693. default:
  694. D.draw({
  695. ctx:
  696. this._ctx
  697. })
  698. }
  699. this.drawRealTimeLine()
  700. }
  701. },
  702. {
  703. key: "drawRealTimeLine",
  704. value: function() {
  705. var t = this.$store.state,
  706. e = t.max,
  707. i = t.min,
  708. a = t.all_kline_data,
  709. n = t.default_rise_color,
  710. s = t.default_fall_color,
  711. o = t.realtime_tagY,
  712. r = t.precision,
  713. l = a[0],
  714. c = l.close,
  715. h = l.open,
  716. u = (l.low, l.high, this.$decimal("-", e, i)),
  717. d = this.$decimal("/", this.c.height, u),
  718. _ = this.$decimal("*", d, Math.abs(this.$decimal("-", h, c))),
  719. m = Math.min(h, c),
  720. v = this.$decimal("-", this.c.height, (m - i) * d, _),
  721. f = c >= h,
  722. x = f ? n: s,
  723. $ = f ? v: this.$decimal("+", v, _);
  724. this._ctx.strokeStyle = x,
  725. this._ctx.beginPath(),
  726. this._ctx.lineWidth = 1,
  727. this._ctx.setLineDash([2]),
  728. this._ctx.moveTo(0, $),
  729. this._ctx.lineTo(this.c.width, $),
  730. this._ctx.stroke(),
  731. o.innerText = c.toFixed(r),
  732. this.$Od.$setElementAttribute(o, "style", {
  733. top: "".concat(this._handleDevicePixelRatio({
  734. symbol: "/",
  735. value: $
  736. }) - 8, "px"),
  737. backgroundColor: x
  738. })
  739. }
  740. },
  741. {
  742. key: "dragMouseMoving",
  743. value: function() {
  744. this.drawHistory()
  745. }
  746. },
  747. {
  748. key: "mouseScaling",
  749. value: function() {
  750. this.drawHistory()
  751. }
  752. }]),
  753. a
  754. } (A);
  755. var H = function(t) {
  756. if (Array.isArray(t)) {
  757. for (var e = 0,
  758. i = new Array(t.length); e < t.length; e++) i[e] = t[e];
  759. return i
  760. }
  761. };
  762. var P = function(t) {
  763. if (Symbol.iterator in Object(t) || "[object Arguments]" === Object.prototype.toString.call(t)) return Array.from(t)
  764. };
  765. var N = function() {
  766. throw new TypeError("Invalid attempt to spread non-iterable instance")
  767. };
  768. var L = function(t) {
  769. return H(t) || P(t) || N()
  770. },
  771. I = function(e) {
  772. function a() {
  773. return t(this, a),
  774. o(this, r(a).apply(this, arguments))
  775. }
  776. return c(a, e),
  777. i(a, [{
  778. key: "dealCanDrawViewData",
  779. value: function(t) {
  780. var e, i = this,
  781. a = this.$store.state,
  782. n = a.el,
  783. s = a.x_axis_height,
  784. o = a.y_axis_width,
  785. r = a.column_space,
  786. l = a.column_width,
  787. c = a.init_offset_x,
  788. h = a.volume_height,
  789. u = n.offsetWidth,
  790. d = n.offsetHeight,
  791. _ = this.$decimal("-", u, o) * this.$devicePixelRatio,
  792. m = this.$decimal("-", d, s, h) * this.$devicePixelRatio,
  793. v = this.$decimal("+", r, l),
  794. f = Math.ceil(_ / v) + 1,
  795. x = 0,
  796. $ = 0;
  797. if (c >= 0) e = this.$copyObjectUnsafe(t.slice(0, f));
  798. else {
  799. var p = Math.abs(c);
  800. $ = Math.floor(this.$decimal("/", p, v)),
  801. x = this.$decimal("-", _, -p, this.$decimal("*", $, v), l),
  802. e = this.$copyObjectUnsafe(t.slice($, $ + f))
  803. }
  804. this.$store.commit("overflow_data_num", $);
  805. var g = e.map((function(t) {
  806. return t.high
  807. })),
  808. y = e.map((function(t) {
  809. return t.low
  810. })),
  811. T = Math.max.apply(Math, L(g)),
  812. E = Math.min.apply(Math, L(y)),
  813. w = this.$decimal("-", T, E),
  814. b = this.$decimal("/", m, w);
  815. this.$store.commit("every_data_px", b);
  816. var A = e.map((function(t, e) {
  817. var a = i.$decimal("*", v, e);
  818. t.x = c >= 0 ? i.$decimal("-", _, c, a, l) : i.$decimal("-", x, a),
  819. t.candleLineHeight = Math.round(i.$decimal("*", b, i.$decimal("-", t.high, t.low))),
  820. t.candleLineStartY = Math.round(i.$decimal("-", m, (t.low - E) * b, t.candleLineHeight));
  821. var n = Math.min(t.open, t.close);
  822. return t.columnHeight = Math.round(i.$decimal("*", b, Math.abs(i.$decimal("-", t.open, t.close)))),
  823. t.columnStartY = Math.round(i.$decimal("-", m, (n - E) * b, t.columnHeight)),
  824. t.isRise = t.close >= t.open,
  825. t
  826. }));
  827. this.$store.commit("kline_data", A),
  828. this.$store.commit("max", T),
  829. this.$store.commit("min", E)
  830. }
  831. }]),
  832. a
  833. } (A),
  834. W = function(e) {
  835. function a() {
  836. var e;
  837. return t(this, a),
  838. (e = o(this, r(a).call(this))).mousemoveThrottleTimer = null,
  839. e.mousewheelThrottleTimer = null,
  840. e.c = e.$Od.$createElement("canvas"),
  841. e.c.style.position = "absolute",
  842. e.c.style.zIndex = 100,
  843. e.c.style.top = 0,
  844. e.c.style.left = 0,
  845. e.c.style.cursor = "crosshair",
  846. e.c.width = e._handleDevicePixelRatio({
  847. value: e.$decimal("-", e.$store.state.el.offsetWidth, e.$store.state.y_axis_width)
  848. }),
  849. e.c.height = e._handleDevicePixelRatio({
  850. value: e.$decimal("-", e.$store.state.el.offsetHeight, e.$store.state.x_axis_height)
  851. }),
  852. e.c.style.width = "".concat(e._handleDevicePixelRatio({
  853. symbol: "/",
  854. value: e.c.width
  855. }), "px"),
  856. e.c.style.height = "".concat(e._handleDevicePixelRatio({
  857. symbol: "/",
  858. value: e.c.height
  859. }), "px"),
  860. // console.log(e.c.height,'22222'),
  861. e._ctx = e.c.getContext("2d"),
  862. e.c.addEventListener("mousedown", e.mousedown.bind(s(e))),
  863. e.c.addEventListener("mouseup", e.mouseup.bind(s(e))),
  864. e.c.addEventListener("mousemove", e.mousemove.bind(s(e))),
  865. e.c.addEventListener("mouseleave", e.mouseleave.bind(s(e))),
  866. e.c.addEventListener("mouseenter", e.mouseenter.bind(s(e))),
  867. e.c.addEventListener("mousewheel", e.mousewheel.bind(s(e))),
  868. e.c.addEventListener("DOMMouseScroll", e.mousewheel.bind(s(e))),
  869. e.c.addEventListener("contextmenu", e.contextmenu.bind(s(e))),
  870. e.$watcher.on(p.WATCHER_EVENT.ONE_DATA_UPDATED, e.onOneDataUpdated.bind(s(e))),
  871. e.tagY = null,
  872. e.tagX = null,
  873. e.realTimeTagY = null,
  874. e.createXTag(),
  875. e.createYTag(),
  876. e.createRealTimeYTag(),
  877. e.INIT_OFFSET_X = e.$store.state.init_offset_x,
  878. e.limitOffsetX = e.$decimal("*", e.c.width, 1 - e.$store.state.limit_offset_x),
  879. e
  880. }
  881. return c(a, e),
  882. i(a, [{
  883. key: "drawCrossDottedLine",
  884. value: function(t, e) {
  885. var i = e.x,
  886. a = e.y;
  887. this.$store.commit("current_cross_dash_line", {
  888. x: i,
  889. y: a
  890. });
  891. var n = this.$store.state,
  892. s = n.max,
  893. o = n.min,
  894. r = n.kline_data,
  895. l = n.column_width,
  896. c = n.volume_height,
  897. h = r[0].x,
  898. u = h <= i && i <= this.$decimal("+", h, l);
  899. this.$store.commit("cross_is_in_newest_data", u);
  900. var d = this.$store.state.current_data.time,
  901. _ = this._handleDevicePixelRatio({
  902. value: c
  903. }),
  904. m = this.$decimal("-", s, o),
  905. v = this.$decimal("/", m, this.c.height - _),
  906. f = this.$decimal("-", this.c.height, _, a),
  907. x = this.$decimal("+", this.$decimal("*", v, f), o);
  908. a > this.c.height - _ ? this.tagY.style.display = "none": this.tagY.style.display = "block",
  909. this.tagY.innerText = x.toFixed(6),
  910. this.tagY.style.top = "".concat(this._handleDevicePixelRatio({
  911. symbol: "/",
  912. value: a
  913. }) - 8, "px"),
  914. this.tagX.innerText = this.$time.format(d, "YYYY-MM-DD HH:mm"),
  915. this.tagX.style.left = "".concat(i / this.$devicePixelRatio, "px"),
  916. this._ctx.setLineDash([5]),
  917. this._ctx.strokeStyle = "#758696",
  918. this._ctx.beginPath(),
  919. this._ctx.moveTo(0, a - .5),
  920. this._ctx.lineTo(this.c.width, a - .5),
  921. this._ctx.stroke(),
  922. this._ctx.beginPath();
  923. var $ = this.$decimal("+", i, Math.ceil(this.$store.state.column_width / 2)) - .5;
  924. this._ctx.moveTo($, 0),
  925. this._ctx.lineTo($, this.c.height),
  926. this._ctx.stroke()
  927. }
  928. },
  929. {
  930. key: "dragMousemove",
  931. value: function(t) {
  932. var e = this.$store.state,
  933. i = e.all_kline_data,
  934. a = e.current_scale,
  935. n = e.init_offset_x;
  936. this.$store.commit("no_scale_offset_x", this.$decimal("/", n, a));
  937. var s = this.$decimal("*", this.$devicePixelRatio, this.$decimal("-", this.startDragX, t.layerX)),
  938. o = this.$decimal("+", this.INIT_OFFSET_X, s);
  939. o > this.limitOffsetX && (o = this.limitOffsetX),
  940. this.$store.commit("init_offset_x", o),
  941. this.dealCanDrawViewData(i),
  942. this.$watcher.emit(p.WATCHER_EVENT.DRAG_MOUSE_MOVING)
  943. }
  944. },
  945. {
  946. key: "clearScreen",
  947. value: function() {
  948. this._clearScreen(this._ctx, this.c.width, this.c.height)
  949. }
  950. },
  951. {
  952. key: "mousemove",
  953. value: function(t) {
  954. var e = this;
  955. null === this.mousemoveThrottleTimer && (this.mousemoveThrottleTimer = window.requestAnimationFrame((function() {
  956. e.$store.commit("current_mouse_coordinates", {
  957. x: t.layerX * e.$devicePixelRatio,
  958. y: t.layerY * e.$devicePixelRatio
  959. }),
  960. e.canDragable ? e.dragMousemove(t) : e.$store.state.kline_data.every((function(i) {
  961. var a = e.$decimal("+", i.x, e.$store.state.column_width);
  962. return ! (i.x <= t.layerX * e.$devicePixelRatio && i.x <= a) || (e.$store.commit("current_data", i), e.clearScreen(), e.drawCrossDottedLine(t, {
  963. x: i.x,
  964. y: t.layerY * e.$devicePixelRatio
  965. }), !1)
  966. })),
  967. e.$watcher.emit(p.WATCHER_EVENT.MOUSE_MOVING),
  968. window.cancelAnimationFrame(e.mousemoveThrottleTimer),
  969. e.mousemoveThrottleTimer = null
  970. })))
  971. }
  972. },
  973. {
  974. key: "mousewheel",
  975. value: function(t) {
  976. var e = this;
  977. null === this.mousewheelThrottleTimer && (this.mousewheelThrottleTimer = window.requestAnimationFrame((function() {
  978. var i = e.$store.state,
  979. a = i.scale_step,
  980. n = i.max_scale,
  981. s = i.min_scale,
  982. o = i.current_scale,
  983. r = i.all_kline_data,
  984. l = i.DEFAULT_COLUMN_WIDTH,
  985. c = i.DEFAULT_COLUMN_SPACE,
  986. h = i.no_scale_offset_x,
  987. u = o;
  988. t.deltaY < 0 || t.detail < 0 ? e.$decimal("*", h, u) <= e.limitOffsetX && o < n && (u = e.$decimal("+", o, a)) : o > s && (u = e.$decimal("-", o, a)),
  989. e.$store.commit("current_scale", u);
  990. var d = e.$store.state.current_scale;
  991. e.$store.commit("init_offset_x", e.$decimal("*", h, d)),
  992. e.INIT_OFFSET_X = e.$store.state.init_offset_x,
  993. e.$store.commit("column_width", e.$decimal("*", l, d)),
  994. e.$store.commit("column_space", e.$decimal("*", c, d)),
  995. e.dealCanDrawViewData(r),
  996. e.$watcher.emit(p.WATCHER_EVENT.MOUSE_SCALING),
  997. window.cancelAnimationFrame(e.mousewheelThrottleTimer),
  998. e.mousewheelThrottleTimer = null
  999. })))
  1000. }
  1001. },
  1002. {
  1003. key: "mouseenter",
  1004. value: function() {
  1005. var t = this,
  1006. e = setTimeout((function() {
  1007. t.tagX.style.display = "block",
  1008. t.tagY.style.display = "block",
  1009. clearTimeout(e)
  1010. }), 50);
  1011. e = null
  1012. }
  1013. },
  1014. {
  1015. key: "mouseleave",
  1016. value: function() {
  1017. var t = this;
  1018. this.canDragable = !1,
  1019. this.INIT_OFFSET_X = this.$store.state.init_offset_x;
  1020. var e = setTimeout((function() {
  1021. t.tagX.style.display = "none",
  1022. t.tagY.style.display = "none",
  1023. t.$store.commit("cross_is_in_newest_data", null),
  1024. t.clearScreen(),
  1025. clearTimeout(e)
  1026. }), 50);
  1027. e = null
  1028. }
  1029. },
  1030. {
  1031. key: "mousedown",
  1032. value: function(t) {
  1033. t.button || (this.startDragX = t.layerX, this.canDragable = !0, this.$Od.$setElementAttribute(this.c, "class", "is-grabbing"))
  1034. }
  1035. },
  1036. {
  1037. key: "mouseup",
  1038. value: function(t) {
  1039. t.button || (this.canDragable = !1, this.INIT_OFFSET_X = this.$store.state.init_offset_x, this.$Od.$removeElementAttribute(this.c, "class", "is-grabbing"))
  1040. }
  1041. },
  1042. {
  1043. key: "contextmenu",
  1044. value: function(t) {
  1045. t.preventDefault()
  1046. }
  1047. },
  1048. {
  1049. key: "createRealTimeYTag",
  1050. value: function() {
  1051. this.realTimeTagY = this.$Od.$createElement("div"),
  1052. this.$Od.$setElementAttribute(this.realTimeTagY, "id", "real_time_volume"),
  1053. this.$Od.$setElementAttribute(this.realTimeTagY, "style", {
  1054. position: "absolute",
  1055. zIndex: "80",
  1056. right: 0,
  1057. width: "".concat(this.$store.state.y_axis_width, "px"),
  1058. fontSize: "12px",
  1059. textAlign: "center",
  1060. color: "#fff",
  1061. userSelect: "none"
  1062. }),
  1063. this.$store.state.vy_chart.appendChild(this.realTimeTagY),
  1064. this.$store.commit("realtime_tagY", this.realTimeTagY)
  1065. }
  1066. },
  1067. {
  1068. key: "createYTag",
  1069. value: function() {
  1070. this.tagY = this.$Od.$createElement("div"),
  1071. this.$Od.$setElementAttribute(this.tagY, "id", "volume"),
  1072. this.$Od.$setElementAttribute(this.tagY, "style", {
  1073. position: "absolute",
  1074. zIndex: "100",
  1075. right: 0,
  1076. width: "".concat(this.$store.state.y_axis_width, "px"),
  1077. fontSize: "12px",
  1078. textAlign: "center",
  1079. color: "#fff",
  1080. backgroundColor: "#585858",
  1081. userSelect: "none"
  1082. }),
  1083. this.$store.state.vy_chart.appendChild(this.tagY),
  1084. this.$store.commit("YTag", this.tagY)
  1085. }
  1086. },
  1087. {
  1088. key: "createXTag",
  1089. value: function() {
  1090. this.tagX = this.$Od.$createElement("div"),
  1091. this.$Od.$setElementAttribute(this.tagX, "id", "date-time"),
  1092. this.$Od.$setElementAttribute(this.tagX, "style", {
  1093. position: "absolute",
  1094. zIndex: "100",
  1095. bottom: "".concat(this.$store.state.x_axis_height - 44, "px"),
  1096. fontSize: "12px",
  1097. color: "#fff",
  1098. backgroundColor: "#585858",
  1099. transform: "translate(-50%, 0)",
  1100. whiteSpace: "noWrap",
  1101. userSelect: "none"
  1102. }),
  1103. this.$store.state.vy_chart.appendChild(this.tagX)
  1104. }
  1105. },
  1106. {
  1107. key: "onOneDataUpdated",
  1108. value: function(t) {
  1109. this.$store.state.cross_is_in_newest_data && (this.tagX.innerText = this.$time.format(t.time, "YYYY-MM-DD HH:mm"))
  1110. }
  1111. }]),
  1112. a
  1113. } (I),
  1114. V = function(e) {
  1115. function a() {
  1116. var e;
  1117. t(this, a);
  1118. var i = (e = o(this, r(a).call(this))).$store.state,
  1119. n = i.el,
  1120. l = i.x_axis_height,
  1121. c = i.y_axis_width,
  1122. h = i.volume_height;
  1123. return e.c = e.$Od.$createElement("canvas"),
  1124. e.c.width = e._handleDevicePixelRatio({
  1125. value: c
  1126. }),
  1127. e.c.height = e._handleDevicePixelRatio({
  1128. value: e.$decimal("-", n.offsetHeight, l, h)
  1129. }),
  1130. e.c.style.position = "absolute",
  1131. e.c.style.top = 0,
  1132. e.c.style.right = 0,
  1133. e.c.style.background = e.$store.state.background_color,
  1134. e.c.style.width = "".concat(e._handleDevicePixelRatio({
  1135. symbol: "/",
  1136. value: e.c.width
  1137. }), "px"),
  1138. e.c.style.height = "".concat(e._handleDevicePixelRatio({
  1139. symbol: "/",
  1140. value: e.c.height
  1141. }), "px"),
  1142. // console.log(e.c.height,'44444'),
  1143. e._ctx = e.c.getContext("2d"),
  1144. e.$watcher.on(p.WATCHER_EVENT.DRAG_MOUSE_MOVING, e.reDraw.bind(s(e))),
  1145. e.$watcher.on(p.WATCHER_EVENT.MOUSE_SCALING, e.reDraw.bind(s(e))),
  1146. e.$watcher.on(p.WATCHER_EVENT.REAL_TIME_DATA, e.reDraw.bind(s(e))),
  1147. e.$watcher.on(p.WATCHER_EVENT.HISTORY_DATA_CHANGE, e.reDraw.bind(s(e))),
  1148. e
  1149. }
  1150. return c(a, e),
  1151. i(a, [{
  1152. key: "draw",
  1153. value: function() {
  1154. this._drawBackground(this._ctx, this.c.width, this.c.height);
  1155. var t = this.$store.state,
  1156. e = t.theme,
  1157. i = t.min,
  1158. a = t.max,
  1159. n = t.axis_segment,
  1160. s = t.axis_font,
  1161. o = e.axis_color,
  1162. r = e.axis_text_color;
  1163. this._ctx.moveTo(.5, 0),
  1164. this._ctx.lineTo(.5, this.c.height),
  1165. this._ctx.lineWidth = 1,
  1166. this._ctx.strokeStyle = o,
  1167. this._ctx.stroke();
  1168. for (var l = v("/", this.c.height, v("-", a, i)), c = 0, h = Math.trunc(Math.log10(i)) - 1, u = Math.trunc(i / Math.pow(10, h)) * Math.pow(10, h), d = Math.ceil(Math.log10(a - i)) - 2, _ = 5 * Math.pow(10, d), m = 5 * Math.pow(10, d); _ * l < 40;) _ = this.$decimal("+", _, m);
  1169. this._ctx.strokeStyle = o,
  1170. this._ctx.fillStyle = r,
  1171. this._ctx.font = s;
  1172. for (var f = []; u + _ * c < a;) {
  1173. var x = u + _ * c;
  1174. x = x.toFixed(6);
  1175. var $ = this.c.height - l * (x - i),
  1176. p = $ - .5;
  1177. f.push(p),
  1178. this._ctx.beginPath(),
  1179. this._ctx.moveTo(0, p),
  1180. this._ctx.lineTo(n, p),
  1181. this._ctx.lineWidth = 1,
  1182. this._ctx.stroke(),
  1183. this._ctx.fillText(x, 5, $ + 4),
  1184. c++
  1185. }
  1186. this.$store.commit("y_axis_scale_list", f)
  1187. }
  1188. },
  1189. {
  1190. key: "reDraw",
  1191. value: function() {
  1192. this._ctx.clearRect(0, 0, this.c.width, this.c.height),
  1193. this.draw()
  1194. }
  1195. }]),
  1196. a
  1197. } (A),
  1198. Y = {
  1199. m: function(t) {
  1200. return {
  1201. time: Math.trunc(t.time / 6e4),
  1202. format: "HH:mm"
  1203. }
  1204. },
  1205. h: function(t) {
  1206. return {
  1207. time: Math.trunc(t.time / 36e5),
  1208. format: "DD HH:mm"
  1209. }
  1210. },
  1211. d: function(t) {
  1212. return {
  1213. time: Math.trunc(t.time / 864e5),
  1214. format: "MM-DD"
  1215. }
  1216. },
  1217. w: function(t) {
  1218. return {
  1219. time: Math.trunc(t.time / 6048e5),
  1220. format: "MM-DD"
  1221. }
  1222. },
  1223. M: function(t) {
  1224. return {
  1225. time: Math.trunc(t.time / 2592e6),
  1226. format: "YYYY-MM"
  1227. }
  1228. }
  1229. },
  1230. U = function(e) {
  1231. function a() {
  1232. var e;
  1233. t(this, a);
  1234. var i = (e = o(this, r(a).call(this))).$store.state,
  1235. n = i.el,
  1236. l = i.x_axis_height,
  1237. c = i.y_axis_width;
  1238. return e.c = e.$Od.$createElement("canvas"),
  1239. e.c.width = e._handleDevicePixelRatio({
  1240. value: e.$decimal("-", n.offsetWidth, c)
  1241. }),
  1242. e.c.height = e._handleDevicePixelRatio({
  1243. value: l
  1244. }),
  1245. e.c.style.position = "absolute",
  1246. e.c.style.bottom = 0,
  1247. e.c.style.left = 0,
  1248. e.c.style.width = "".concat(e._handleDevicePixelRatio({
  1249. symbol: "/",
  1250. value: e.c.width
  1251. }), "px"),
  1252. e.c.style.height = "".concat(e._handleDevicePixelRatio({
  1253. symbol: "/",
  1254. value: e.c.height
  1255. }), "px"),
  1256. e.c.style.background = e.$store.state.background_color,
  1257. e._ctx = e.c.getContext("2d"),
  1258. e.$watcher.on(p.WATCHER_EVENT.DRAG_MOUSE_MOVING, e.reDraw.bind(s(e))),
  1259. e.$watcher.on(p.WATCHER_EVENT.MOUSE_SCALING, e.reDraw.bind(s(e))),
  1260. e.$watcher.on(p.WATCHER_EVENT.REAL_TIME_DATA, e.reDraw.bind(s(e))),
  1261. e.$watcher.on(p.WATCHER_EVENT.HISTORY_DATA_CHANGE, e.reDraw.bind(s(e))),
  1262. e.$watcher.on(p.WATCHER_EVENT.THEME_SWITCHED, (function(t) {
  1263. e.draw()
  1264. })),
  1265. e
  1266. }
  1267. return c(a, e),
  1268. i(a, [{
  1269. key: "draw",
  1270. value: function() {
  1271. var t = this;
  1272. this._drawBackground(this._ctx, this.c.width, this.c.height);
  1273. var e = this.$store.state,
  1274. i = e.theme,
  1275. a = e.axis_font,
  1276. n = e.kline_data,
  1277. s = e.current_scale,
  1278. o = e.current_interval,
  1279. r = e.column_width,
  1280. l = e.axis_segment,
  1281. c = i.axis_text_color,
  1282. h = i.axis_color;
  1283. if (n) {
  1284. this._ctx.moveTo(0, .5),
  1285. this._ctx.lineTo(this.c.width, .5),
  1286. this._ctx.lineWidth = 1,
  1287. this._ctx.strokeStyle = h,
  1288. this._ctx.stroke(),
  1289. this._ctx.textAlign = "center";
  1290. var u = o.match(/[0-9]*$/),
  1291. d = o[0];
  1292. this._ctx.strokeStyle = h,
  1293. this._ctx.fillStyle = c,
  1294. this._ctx.font = a,
  1295. n.forEach((function(e, i) {
  1296. var a = Y[d](e),
  1297. n = a.time,
  1298. o = a.format,
  1299. c = Math.trunc(10 * u / s);
  1300. if (! (n % (c = 5 * Math.ceil(c / 5)))) {
  1301. var h = t.$decimal("+", e.x, Math.ceil(r / 2));
  1302. t._ctx.beginPath(),
  1303. t._ctx.moveTo(h - .5, 0),
  1304. t._ctx.lineTo(h - .5, l * t.$devicePixelRatio),
  1305. t._ctx.stroke();
  1306. var _ = t.$time.format(e.time, o);
  1307. t._ctx.fillText(_, h, 15 * t.$devicePixelRatio)
  1308. }
  1309. }))
  1310. }
  1311. }
  1312. },
  1313. {
  1314. key: "reDraw",
  1315. value: function() {
  1316. this._ctx.clearRect(0, 0, this.c.width, this.c.height),
  1317. this.draw()
  1318. }
  1319. }]),
  1320. a
  1321. } (A),
  1322. X = function(e) {
  1323. function a() {
  1324. var e;
  1325. t(this, a);
  1326. var i = (e = o(this, r(a).call(this))).$store.state,
  1327. n = i.el,
  1328. l = i.x_axis_height,
  1329. c = i.y_axis_width,
  1330. h = i.volume_height;
  1331. return e.c = e.$Od.$createElement("canvas"),
  1332. e.c.width = e._handleDevicePixelRatio({
  1333. value: e.$decimal("-", n.offsetWidth, c)
  1334. }),
  1335. e.c.height = e._handleDevicePixelRatio({
  1336. value: h
  1337. }),
  1338. e.c.style.position = "absolute",
  1339. e.c.style.bottom = "".concat(l, "px"),
  1340. e.c.style.left = 0,
  1341. e.c.style.width = "".concat(e._handleDevicePixelRatio({
  1342. symbol: "/",
  1343. value: e.c.width
  1344. }), "px"),
  1345. e.c.style.height = "".concat(e._handleDevicePixelRatio({
  1346. symbol: "/",
  1347. value: e.c.height
  1348. }), "px"),
  1349. e._ctx = e.c.getContext("2d"),
  1350. e.maxVolume = null,
  1351. e.minVolume = null,
  1352. e.dataGap = null,
  1353. e.everyDataPX = null,
  1354. e.YAxisStartX = e.$decimal("-", e._handleDevicePixelRatio({
  1355. value: e.c.width
  1356. }), c),
  1357. e.$watcher.on(p.WATCHER_EVENT.DRAG_MOUSE_MOVING, e.dragMouseMoving.bind(s(e))),
  1358. e.$watcher.on(p.WATCHER_EVENT.MOUSE_SCALING, e.mouseScaling.bind(s(e))),
  1359. e.$watcher.on(p.WATCHER_EVENT.REAL_TIME_DATA, e.onRealTimeData.bind(s(e))),
  1360. // console.log(e.c.height,'下面得柱形图'),
  1361. e
  1362. }
  1363. return c(a, e),
  1364. i(a, [{
  1365. key: "drawTopLine",
  1366. value: function() {
  1367. var t = this.$store.state.theme.axis_color;
  1368. this._ctx.strokeStyle = t,
  1369. this._ctx.beginPath(),
  1370. this._ctx.moveTo(0, .5),
  1371. this._ctx.lineTo(this.c.width, .5),
  1372. this._ctx.lineWidth = 1,
  1373. this._ctx.stroke()
  1374. }
  1375. },
  1376. {
  1377. key: "draw",
  1378. value: function() {
  1379. var t = this;
  1380. this._clearScreen(this._ctx, this.c.width, this.c.height),
  1381. this._drawBackground(this._ctx, this.c.width, this.c.height),
  1382. this.drawTopLine();
  1383. var e = this.$store.state,
  1384. i = e.kline_data,
  1385. a = (e.volume_height, e.current_scale, e.y_axis_width, e.column_width),
  1386. n = e.default_rise_color,
  1387. s = e.default_fall_color,
  1388. o = i.map((function(t) {
  1389. return t.volume
  1390. }));
  1391. this.maxVolume = Math.max.apply(Math, L(o)),
  1392. this.minVolume = Math.min.apply(Math, L(o)),
  1393. this.dataGap = this.$decimal("-", this.maxVolume, this.minVolume),
  1394. this.everyDataPX = this.$decimal("/", this.c.height, this.dataGap),
  1395. i.forEach((function(e) {
  1396. t._ctx.beginPath(),
  1397. t._ctx.strokeStyle = t._ctx.fillStyle = e.close >= e.open ? n: s;
  1398. var i = t.$decimal("-", e.volume, t.minVolume),
  1399. o = t.$decimal("*", t.everyDataPX, i)+8,
  1400. r = t.$decimal("-", t.c.height, o),
  1401. l = e.x - .5;
  1402. t._ctx.strokeRect(l, r, a, o),
  1403. t._ctx.globalAlpha = .6,
  1404. t._ctx.fillRect(l, r, a, o)
  1405. }))
  1406. }
  1407. },
  1408. {
  1409. key: "dragMouseMoving",
  1410. value: function() {
  1411. this._clearScreen(this._ctx, this.c.width, this.c.height),
  1412. this.draw()
  1413. }
  1414. },
  1415. {
  1416. key: "mouseScaling",
  1417. value: function() {
  1418. this._clearScreen(this._ctx, this.c.width, this.c.height),
  1419. this.draw()
  1420. }
  1421. },
  1422. {
  1423. key: "onRealTimeData",
  1424. value: function() {
  1425. this._clearScreen(this._ctx, this.c.width, this.c.height),
  1426. this.draw()
  1427. }
  1428. }]),
  1429. a
  1430. } (A),
  1431. G = function() {
  1432. function e(i, a) {
  1433. var n = a.data,
  1434. s = void 0 === n ? 0 : n,
  1435. o = a.html;
  1436. t(this, e),
  1437. this.span = i.$createElement("span"),
  1438. this.html = o,
  1439. this.data = s,
  1440. this.span.innerHTML = "".concat(o, '=<i style="color: ').concat(this.color, ';">').concat(this.data, "</i>")
  1441. }
  1442. return i(e, [{
  1443. key: "setData",
  1444. value: function(t, e, i) {
  1445. this.data = t,
  1446. this.span.innerHTML = "".concat(this.html, '=<i style="color: ').concat(e, ';">').concat(this.data, "</i>"),
  1447. this.span.style.color = i,
  1448. this.span.style.margin = '0px 10px'
  1449. }
  1450. }]),
  1451. e
  1452. } (),
  1453. F = function(e) {
  1454. function a() {
  1455. var e;
  1456. return t(this, a),
  1457. (e = o(this, r(a).call(this))).dashboardWrapper = e.$Od.$createElement("div"),
  1458. e.$Od.$setElementAttribute(e.dashboardWrapper, "id", "dashboard-wrapper"),
  1459. e.$Od.$setElementAttribute(e.dashboardWrapper, "style", {
  1460. position: "absolute",
  1461. zIndex: "50",
  1462. left: 0,
  1463. top: 0,
  1464. width:"100%",
  1465. height:"20px",
  1466. // background:"rgb(19, 23, 34)"
  1467. background:"rgb(255, 255, 255)"
  1468. }),
  1469. e.spanWrapper = e.$Od.$createElement("div"),
  1470. e.$Od.$setElementAttribute(e.spanWrapper, "id", "span-wrapper"),
  1471. e.dashboardWrapper.appendChild(e.spanWrapper),
  1472. e.openSpan = new G(e.$Od, {
  1473. html: window.kai
  1474. }),
  1475. e.highSpan = new G(e.$Od, {
  1476. html: window.gao
  1477. }),
  1478. e.lowSpan = new G(e.$Od, {
  1479. html: window.di
  1480. }),
  1481. e.closeSpan = new G(e.$Od, {
  1482. html: window.shou
  1483. }),
  1484. e.volSpan = new G(e.$Od, {
  1485. html: "Vol"
  1486. }),
  1487. e.MA5Span = new G(e.$Od, {
  1488. html: "MA5"
  1489. }),
  1490. e.MA10Span = new G(e.$Od, {
  1491. html: "MA10"
  1492. }),
  1493. e.spanWrapper.appendChild(e.openSpan.span),
  1494. e.spanWrapper.appendChild(e.highSpan.span),
  1495. e.spanWrapper.appendChild(e.lowSpan.span),
  1496. e.spanWrapper.appendChild(e.closeSpan.span),
  1497. e.spanWrapper.appendChild(e.volSpan.span),
  1498. e.spanWrapper.appendChild(e.MA5Span.span),
  1499. e.spanWrapper.appendChild(e.MA10Span.span),
  1500. e.$watcher.on(p.WATCHER_EVENT.MOUSE_MOVING, e.mouseMoving.bind(s(e))),
  1501. e.$watcher.on(p.WATCHER_EVENT.REAL_TIME_DATA, e.onRealTimeData.bind(s(e))),
  1502. e
  1503. }
  1504. return c(a, e),
  1505. i(a, [{
  1506. key: "setSpanInnerText",
  1507. value: function(t) {
  1508. var e = t.open,
  1509. i = t.high,
  1510. a = t.low,
  1511. n = t.close,
  1512. s = t.volume,
  1513. o = t.MAClose5,
  1514. r = void 0 === o ? 0 : o,
  1515. l = t.MAClose10,
  1516. c = void 0 === l ? 0 : l,
  1517. h = this.$store.state,
  1518. u = h.default_rise_color,
  1519. d = h.default_fall_color,
  1520. _ = h.axis_text_color,
  1521. m = h.ma_Lines,
  1522. v = h.precision,
  1523. f = n >= e ? u: d;
  1524. this.openSpan.setData(e.toFixed(v), f, _),
  1525. this.highSpan.setData(i.toFixed(v), f, _),
  1526. this.lowSpan.setData(a.toFixed(v), f, _),
  1527. this.closeSpan.setData(n.toFixed(v), f, _),
  1528. this.volSpan.setData(s, f, _),
  1529. this.MA5Span.setData(r.toFixed(v), m[0].lineColor, _),
  1530. this.MA10Span.setData(c.toFixed(v), m[1].lineColor, _)
  1531. }
  1532. },
  1533. {
  1534. key: "mouseMoving",
  1535. value: function() {
  1536. if (this.$store.state.current_data) {
  1537. // console.log(this.$store.state.current_data);
  1538. var t = this.$store.state.current_data,
  1539. e = t.open,
  1540. i = t.high,
  1541. a = t.low,
  1542. n = t.close,
  1543. s = t.volume,
  1544. o = t.MAClose5,
  1545. r = t.MAClose10;
  1546. this.setSpanInnerText({
  1547. open: e,
  1548. high: i,
  1549. low: a,
  1550. close: n,
  1551. volume: s,
  1552. MAClose5: o,
  1553. MAClose10: r
  1554. })
  1555. }
  1556. }
  1557. },
  1558. {
  1559. key: "onRealTimeData",
  1560. value: function() {
  1561. var t = this.$store.state,
  1562. e = t.cross_is_in_newest_data,
  1563. i = t.kline_data;
  1564. if (e || null === e) {
  1565. // console.log(i[0]);
  1566. var a = i[0],
  1567. n = a.open,
  1568. s = a.high,
  1569. o = a.low,
  1570. r = a.close,
  1571. l = a.volume,
  1572. c = a.MAClose5,
  1573. h = a.MAClose10;
  1574. this.setSpanInnerText({
  1575. open: n,
  1576. high: s,
  1577. low: o,
  1578. close: r,
  1579. volume: l,
  1580. MAClose5: c,
  1581. MAClose10: h
  1582. })
  1583. }
  1584. }
  1585. }]),
  1586. a
  1587. } (A),
  1588. j = /0{3}$/,
  1589. B = function(e) {
  1590. function a() {
  1591. var e;
  1592. t(this, a);
  1593. var i = (e = o(this, r(a).call(this))).$store.state,
  1594. n = (i.el, i.x_axis_height),
  1595. l = i.y_axis_width,
  1596. c = i.volume_height;
  1597. return e.c = e.$Od.$createElement("canvas"),
  1598. e.c.width = e._handleDevicePixelRatio({
  1599. value: l
  1600. }),
  1601. e.c.height = e._handleDevicePixelRatio({
  1602. value: e.$decimal("-", c)
  1603. }),
  1604. e.c.style.position = "absolute",
  1605. e.c.style.bottom = "".concat(e.$decimal("-", n), "px"),
  1606. e.c.style.right = 0,
  1607. e.c.style.background = e.$store.state.background_color,
  1608. e.c.style.width = "".concat(e._handleDevicePixelRatio({
  1609. symbol: "/",
  1610. value: e.c.width
  1611. }), "px"),
  1612. e.c.style.height = "".concat(e._handleDevicePixelRatio({
  1613. symbol: "/",
  1614. value: e.c.height
  1615. }), "px"),
  1616. e._ctx = e.c.getContext("2d"),
  1617. e.$watcher.on(p.WATCHER_EVENT.DRAG_MOUSE_MOVING, e.dragMouseMoving.bind(s(e))),
  1618. e.$watcher.on(p.WATCHER_EVENT.MOUSE_SCALING, e.mouseScaling.bind(s(e))),
  1619. e.$watcher.on(p.WATCHER_EVENT.REAL_TIME_DATA, e.onRealTimeData.bind(s(e))),
  1620. // console.log(e.c.height,'右边得一条柱形'),
  1621. e.$watcher.on(p.WATCHER_EVENT.THEME_SWITCHED, (function(t) {
  1622. e.draw()
  1623. })),
  1624. e
  1625. }
  1626. return c(a, e),
  1627. i(a, [{
  1628. key: "draw",
  1629. value: function() {
  1630. this._drawBackground(this._ctx, this.c.width, this.c.height);
  1631. var t = this.$store.state.theme.axis_color;
  1632. this._ctx.strokeStyle = t,
  1633. this._ctx.beginPath(),
  1634. this._ctx.moveTo(.5, 0),
  1635. this._ctx.lineTo(.5, this.c.height),
  1636. this._ctx.lineWidth = 1,
  1637. this._ctx.stroke(),
  1638. this.drawVolYAxis()
  1639. }
  1640. },
  1641. {
  1642. key: "drawVolYAxis",
  1643. value: function() {
  1644. var t = this.$store.state,
  1645. e = t.theme,
  1646. i = t.kline_data,
  1647. a = t.volume_height,
  1648. n = t.axis_segment,
  1649. s = t.axis_font,
  1650. o = e.axis_text_color,
  1651. r = i.map((function(t) {
  1652. return t.volume
  1653. }));
  1654. this.maxVolume = Math.max.apply(Math, L(r)),
  1655. this.minVolume = Math.min.apply(Math, L(r)),
  1656. this.dataGap = this.$decimal("-", this.maxVolume, this.minVolume);
  1657. var l = this._handleDevicePixelRatio({
  1658. value: a
  1659. });
  1660. this.everyDataPX = this.$decimal("/", l, this.dataGap);
  1661. for (var c = Math.trunc(Math.log10(this.dataGap)) - 1, h = Math.trunc(this.minVolume), u = 5 * Math.pow(10, c), d = u; u * this.everyDataPX < 20;) u = this.$decimal("+", u, d);
  1662. this._ctx.fillStyle = o,
  1663. this._ctx.font = s;
  1664. for (var _ = 1; h + u * _ < this.maxVolume;) {
  1665. var m = String(u * _);
  1666. j.test(m) && (m = m.replace(j, "k"));
  1667. var v = this.c.height - this.everyDataPX * u * _;
  1668. this._ctx.beginPath(),
  1669. this._ctx.moveTo(0, v - .5),
  1670. this._ctx.lineTo(n, v - .5),
  1671. this._ctx.lineWidth = 1,
  1672. this._ctx.stroke(),
  1673. this._ctx.fillText(m, 5, v + this._handleDevicePixelRatio({
  1674. value: 4
  1675. })),
  1676. _++
  1677. }
  1678. }
  1679. },
  1680. {
  1681. key: "dragMouseMoving",
  1682. value: function() {
  1683. this._ctx.clearRect(0, 0, this.c.width, this.c.height),
  1684. this.draw()
  1685. }
  1686. },
  1687. {
  1688. key: "mouseScaling",
  1689. value: function() {
  1690. this._ctx.clearRect(0, 0, this.c.width, this.c.height),
  1691. this.draw()
  1692. }
  1693. },
  1694. {
  1695. key: "onRealTimeData",
  1696. value: function() {
  1697. this._ctx.clearRect(0, 0, this.c.width, this.c.height),
  1698. this.draw()
  1699. }
  1700. }]),
  1701. a
  1702. } (A),
  1703. K = {
  1704. m: {
  1705. text: window.fen
  1706. },
  1707. h: {
  1708. text: window.xiaoshi
  1709. },
  1710. d: {
  1711. text: window.tian
  1712. },
  1713. w: {
  1714. text: window.zhou
  1715. },
  1716. M: {
  1717. text: "Mon"
  1718. }
  1719. },
  1720. z = function(e) {
  1721. function a() {
  1722. var e;
  1723. return t(this, a),
  1724. (e = o(this, r(a).call(this))).c = e.$Od.$createElement("div"),
  1725. e.throttleTimer = null,
  1726. e.$Od.$setElementAttribute(e.c, "id", "interval_tool_bar"),
  1727. e.$Od.$setElementAttribute(e.c, "style", {
  1728. height: e.$store.state.interval_tool_bar,
  1729. lineHeight: e.$store.state.interval_tool_bar,
  1730. backgroundColor: e.$store.state.background_color
  1731. }),
  1732. // console.log(e.$store.state.interval_tool_bar,'时间 '),
  1733. e.$store.state.user_config.theme && e.$Od.$setElementAttribute(e.c, "class", e.$store.state.user_config.theme),
  1734. e.createTimeShareBtn(),
  1735. e.createIntervalBtn(),
  1736. e.$watcher.on(p.WATCHER_EVENT.THEME_SWITCHED, (function(t) {
  1737. e.$Od.$setElementAttribute(e.c, "style", {
  1738. backgroundColor: e.$store.state.theme.background_color
  1739. }),
  1740. e.$Od.$setElementAttribute(e.c, "class", t)
  1741. })),
  1742. e
  1743. }
  1744. return c(a, e),
  1745. i(a, [{
  1746. key: "createIntervalBtn",
  1747. value: function() {
  1748. var t = this,
  1749. e = this.$store.state,
  1750. i = e.user_config,
  1751. a = e.chart_instance,
  1752. n = i.interval,
  1753. s = i.deedfeeds,
  1754. o = i.onTimeIntervalChanged;
  1755. n.forEach((function(e) {
  1756. var i = t.$Od.$createElement("button"),
  1757. n = e.slice(1);
  1758. i.innerText = "".concat(n, " ").concat(K[e[0]].text),
  1759. t.$Od.$setElementAttribute(i, "class", "interval-item"),
  1760. t.$Od.$setElementAttribute(i, "data-interval-item", e);
  1761. var r = t.$store.state,
  1762. l = r.current_interval,
  1763. c = r.loadingNode;
  1764. l === e && t.$Od.$setElementAttribute(i, "class", "interval-item active"),
  1765. i.onclick = function() {
  1766. if (!t.throttleTimer) {
  1767. var n = t.$store.state,
  1768. r = n.current_interval,
  1769. l = n.chart_type;
  1770. if (r === e && l === t.CONSTANTS.CHART_TYPE.KLINE) return;
  1771. t.throttleTimer = setTimeout((function() {
  1772. var kuang = document.body.clientWidth-document.getElementById('real_time_volume').clientWidth;
  1773. var kuang2 = kuang/100
  1774. if (e == 'w1' && window.SYMBOL == 'vatusdt'){
  1775. t.$store.commit("init_offset_x",kuang-(2*6)) ;
  1776. console.log(kuang2,'eeee');
  1777. }else if (e == 'd1' && window.SYMBOL == 'vatusdt'){
  1778. t.$store.commit("init_offset_x", kuang-(17*6)) ;
  1779. }else if (e == 'h4' && window.SYMBOL == 'vatusdt' ){
  1780. t.$store.commit("init_offset_x", kuang-(107*6)) ;
  1781. console.log(kuang2,'eeee');
  1782. }else{
  1783. t.$store.commit("init_offset_x", window.init_offset) ;
  1784. }
  1785. "function" == typeof o && o(e),
  1786. c.style.display = "block",
  1787. t.$store.commit("chart_type", l),
  1788. t.$store.commit("all_kline_data", []),
  1789. t.$store.commit("kline_data", []),
  1790. t.$store.commit("current_interval", e),
  1791. t.$Od.$setElementAttribute(document.getElementsByClassName("interval-item active")[0], "class", "interval-item"),
  1792. t.$Od.$setElementAttribute(i, "class", "interval-item active"),
  1793. s.intervalChanged({
  1794. interval: e,
  1795. setHistoryData: a.initHistoryData,
  1796. subscribeData: a.getRealTimeData
  1797. }),
  1798. t.throttleTimer = null;
  1799. }), 200)
  1800. }
  1801. },
  1802. t.c.appendChild(i)
  1803. }))
  1804. }
  1805. },
  1806. {
  1807. key: "createTimeShareBtn",
  1808. value: function() {
  1809. var t = this,
  1810. e = this.$store.state,
  1811. i = e.user_config,
  1812. a = e.chart_instance,
  1813. n = e.loadingNode,
  1814. s = i.deedfeeds,
  1815. o = this.$Od.$createElement("button");
  1816. o.innerText = window.fenshi,
  1817. this.$Od.$setElementAttribute(o, "class", "interval-item"),
  1818. this.$Od.$setElementAttribute(o, "data-interval-item", "time-sharing"),
  1819. o.onclick = function() {
  1820. n.style.display = "block",
  1821. t.$store.commit("chart_type", t.CONSTANTS.CHART_TYPE.REAL_TIME),
  1822. t.$store.commit("all_kline_data", []),
  1823. t.$store.commit("current_interval", "m1"),
  1824. t.$Od.$setElementAttribute(document.getElementsByClassName("interval-item active")[0], "class", "interval-item"),
  1825. t.$Od.$setElementAttribute(o, "class", "interval-item active"),
  1826. s.intervalChanged({
  1827. interval: "m1",
  1828. setHistoryData: a.initHistoryData,
  1829. subscribeData: a.getRealTimeData
  1830. })
  1831. },
  1832. this.c.appendChild(o)
  1833. }
  1834. }]),
  1835. a
  1836. } (A),
  1837. q = function(e) {
  1838. function a() {
  1839. var e;
  1840. return t(this, a),
  1841. (e = o(this, r(a).call(this))).c = e.$Od.$createElement("canvas"),
  1842. e.c.width = e._handleDevicePixelRatio({
  1843. value: e.$store.state.y_axis_width
  1844. }),
  1845. e.c.height = e._handleDevicePixelRatio({
  1846. value: e.$store.state.x_axis_height
  1847. }),
  1848. e.c.style.width = "".concat(e._handleDevicePixelRatio({
  1849. symbol: "/",
  1850. value: e.c.width
  1851. }), "px"),
  1852. e.c.style.height = "".concat(e._handleDevicePixelRatio({
  1853. symbol: "/",
  1854. value: e.c.height
  1855. }), "px"),
  1856. // console.log(e.c.height,'右边得一条柱形'),
  1857. e._ctx = e.c.getContext("2d"),
  1858. e.$Od.$setElementAttribute(e.c, "style", {
  1859. position: "absolute",
  1860. bottom: 0,
  1861. right: 0,
  1862. background: e.$store.state.theme.background_color
  1863. }),
  1864. e.draw(),
  1865. e.$watcher.on(p.WATCHER_EVENT.THEME_SWITCHED, (function() {
  1866. e.$Od.$setElementAttribute(e.c, "style", {
  1867. background: e.$store.state.theme.background_color
  1868. }),
  1869. e.draw()
  1870. })),
  1871. e
  1872. }
  1873. return c(a, e),
  1874. i(a, [{
  1875. key: "draw",
  1876. value: function() {
  1877. var t = this.$store.state.theme.axis_color;
  1878. this._ctx.moveTo(0, .5),
  1879. this._ctx.lineTo(this.c.width, .5),
  1880. this._ctx.moveTo(.5, 0),
  1881. this._ctx.lineTo(.5, this.c.height),
  1882. this._ctx.lineWidth = 1,
  1883. this._ctx.strokeStyle = t,
  1884. this._ctx.stroke()
  1885. }
  1886. }]),
  1887. a
  1888. } (A);
  1889. var J = new(function(e) {
  1890. function a() {
  1891. var e;
  1892. return t(this, a),
  1893. (e = o(this, r(a).call(this))).customChart = null,
  1894. e
  1895. }
  1896. return c(a, e),
  1897. i(a, [{
  1898. key: "bootstrap",
  1899. value: function(t) {
  1900. var e = t.container,
  1901. i = t.deedfeeds,
  1902. a = t.defaultInterval,
  1903. n = t.customChart,
  1904. s = t.showIntervalToolbar,
  1905. o = void 0 === s || s,
  1906. r = t.customLoadingEl;
  1907. this.$store.commit("user_config", t),
  1908. this.customChart = n,
  1909. this._customChart(n),
  1910. this.$store.commit("deedfeeds", i),
  1911. this.$store.commit("current_interval", a),
  1912. r ? r instanceof HTMLElement && (this.loading = r, this.$store.commit("loadingNode", this.loading), e.appendChild(this.loading)) : (this.loading = function(t, e, i) {
  1913. var a = t.$createElement("div"),
  1914. n = t.$createElement("div");
  1915. return t.$setElementAttribute(a, "id", "loading"),
  1916. t.$setElementAttribute(n, "class", "spin"),
  1917. n.innerText = "loading...",
  1918. // console.log(111111),
  1919. t.$setElementAttribute(a, "style", {
  1920. display: "block",
  1921. position: "absolute",
  1922. zIndex: "9527",
  1923. top: 0,
  1924. left: 0,
  1925. width: "100%",
  1926. height: "100%",
  1927. backgroundColor: "rgba(255,255,255, 0.6)"
  1928. }),
  1929. a.appendChild(n),
  1930. e.appendChild(a),
  1931. a
  1932. } (this.$Od, e, this.$store.state), this.$store.commit("loadingNode", this.loading)),
  1933. this.intervalToolBarInstance = new z,
  1934. e.appendChild(this.intervalToolBarInstance.c),
  1935. this.intervalToolBarInstance.c.style.display = o ? "block": "none",
  1936. this.vyChart = function(t, e, i) {
  1937. var a = t.$createElement("div");
  1938. return t.$setElementAttribute(a, "id", "vy-chart"),
  1939. t.$setElementAttribute(a, "style", {
  1940. position: "absolute",
  1941. bottom: 0,
  1942. width: "100%",
  1943. height: "calc(100% - ".concat(i.interval_tool_bar, ")")
  1944. }),
  1945. // console.log(a),
  1946. e.appendChild(a),
  1947. a
  1948. } (this.$Od, e, this.$store.state),
  1949. this.$store.commit("el", this.vyChart),
  1950. this.$store.commit("vy_chart", this.vyChart),
  1951. e.style.position = "relative",
  1952. this.container = e,
  1953. this.deedfeeds = i,
  1954. this.KlineCanvas = null,
  1955. this.YAxis = null,
  1956. this.XAxis = null,
  1957. this.Dashboard = null,
  1958. this.VolumeCanvas = null,
  1959. this.BottomRightBlock = null,
  1960. this.initHistoryData = this.initHistoryData.bind(this),
  1961. this.getRealTimeData = this.getRealTimeData.bind(this),
  1962. i.setHistoryData({
  1963. interval: a,
  1964. setHistoryData: this.initHistoryData,
  1965. subscribeData: this.getRealTimeData
  1966. })
  1967. }
  1968. },
  1969. {
  1970. key: "initHistoryData",
  1971. value: function(t) {
  1972. this.$store.commit("all_kline_data", t),
  1973. this.dealCanDrawViewData(t),
  1974. this.KlineCanvas || this.initViewOnce(),
  1975. this.KlineCanvas.drawHistory(),
  1976. this.VolumeCanvas.draw(),
  1977. this.$watcher.emit(p.WATCHER_EVENT.HISTORY_DATA_CHANGE),
  1978. this.loading.style.display = "none"
  1979. }
  1980. },
  1981. {
  1982. key: "getRealTimeData",
  1983. value: function(t) {
  1984. if (t.time) {
  1985. var e = this.$store.state.all_kline_data;
  1986. e[0] && (e[0].time === t.time ? e[0] = t: (e.unshift(t), this.$watcher.emit(p.WATCHER_EVENT.ONE_DATA_UPDATED, t)), this.$store.commit("all_kline_data", e), this.initHistoryData(this.$store.state.all_kline_data), this.$watcher.emit(p.WATCHER_EVENT.REAL_TIME_DATA))
  1987. }
  1988. }
  1989. },
  1990. {
  1991. key: "initViewOnce",
  1992. value: function() {
  1993. this.KlineCanvas = new R({
  1994. backgroundColor: "#fff"
  1995. }),
  1996. this.$store.commit("kline_canvas", this.KlineCanvas),
  1997. this.KlineMaskCanvas = new W,
  1998. this.XAxis = new U,
  1999. this.YAxis = new V,
  2000. this.VolYAxis = new B,
  2001. this.VolumeCanvas = new X,
  2002. this.Dashboard = new F,
  2003. this.BottomRightBlock = new q,
  2004. this.intervalToolBarInstance.c.style.backgroundColor = this.$store.state.background_color,
  2005. this.XAxis.draw(),
  2006. this.YAxis.draw(),
  2007. this.VolYAxis.draw(),
  2008. this.BottomRightBlock.draw(),
  2009. this.vyChart.appendChild(this.KlineCanvas.c),
  2010. this.vyChart.appendChild(this.KlineMaskCanvas.c),
  2011. this.vyChart.appendChild(this.VolumeCanvas.c),
  2012. this.vyChart.appendChild(this.XAxis.c),
  2013. this.vyChart.appendChild(this.YAxis.c),
  2014. this.vyChart.appendChild(this.VolYAxis.c),
  2015. this.vyChart.appendChild(this.Dashboard.dashboardWrapper),
  2016. this.vyChart.appendChild(this.BottomRightBlock.c)
  2017. }
  2018. },
  2019. {
  2020. key: "switchChartType",
  2021. value: function(t) {
  2022. this.$store.commit("chart_type", t),
  2023. this.initHistoryData(this.$store.state.all_kline_data)
  2024. }
  2025. },
  2026. {
  2027. key: "switchTheme",
  2028. value: function(t) {
  2029. this.$store.commit("theme", this.THEME[t]),
  2030. this.$watcher.emit(p.WATCHER_EVENT.THEME_SWITCHED, t),
  2031. this.initHistoryData(this.$store.state.all_kline_data)
  2032. }
  2033. }]),
  2034. a
  2035. } (I));
  2036. return J.$store.commit("chart_instance", J),
  2037. window.vyChart = J,
  2038. J
  2039. }));