@oanda/labs-currency-power-balance-widget 1.0.105 → 1.0.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +428 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +6 -2
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -2
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +50 -6
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js +10 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -0
- package/dist/main/translations/sources/en.json +1 -0
- package/dist/main/translations/sources/es.json +1 -0
- package/dist/main/translations/sources/th.json +1 -0
- package/dist/main/translations/sources/zh_TW.json +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +7 -3
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +2 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +50 -6
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js +4 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -0
- package/dist/module/translations/sources/en.json +1 -0
- package/dist/module/translations/sources/es.json +1 -0
- package/dist/module/translations/sources/th.json +1 -0
- package/dist/module/translations/sources/zh_TW.json +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +3 -2
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +40 -4
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/utils.d.ts +2 -0
- package/package.json +3 -3
- package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +5 -2
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/{constants.tsx → constants.ts} +5 -2
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +4 -4
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +54 -4
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts +12 -0
- package/src/translations/sources/en.json +1 -0
- package/src/translations/sources/es.json +1 -0
- package/src/translations/sources/th.json +1 -0
- package/src/translations/sources/zh_TW.json +1 -0
- package/test/chartFormatters.test.ts +3 -1
- package/test/utils.test.ts +34 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,434 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 1.0.106 (2024-10-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 1.0.166 (2024-10-07)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.0.165 (2024-10-03)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 1.0.164 (2024-09-26)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.0.163 (2024-09-18)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## 1.0.162 (2024-09-12)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 1.0.161 (2024-09-11)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## 1.0.160 (2024-09-10)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## 1.0.159 (2024-09-09)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 1.0.158 (2024-09-04)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## 1.0.157 (2024-09-04)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 1.0.156 (2024-09-02)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## 1.0.155 (2024-08-29)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## 1.0.154 (2024-08-29)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## 1.0.153 (2024-08-23)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## 1.0.152 (2024-08-23)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## 1.0.151 (2024-08-20)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## 1.0.150 (2024-08-19)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## 1.0.149 (2024-08-07)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## 1.0.148 (2024-08-01)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## 1.0.147 (2024-08-01)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## 1.0.146 (2024-07-26)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## 1.0.145 (2024-07-25)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
## 1.0.144 (2024-07-22)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## 1.0.143 (2024-07-19)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## 1.0.142 (2024-07-16)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## 1.0.141 (2024-07-16)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## 1.0.140 (2024-07-12)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## 1.0.139 (2024-07-12)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## 1.0.138 (2024-07-10)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## 1.0.137 (2024-07-05)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## 1.0.136 (2024-07-03)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
## 1.0.135 (2024-07-03)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
## 1.0.134 (2024-07-03)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
## 1.0.133 (2024-06-28)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## 1.0.132 (2024-06-27)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## 1.0.131 (2024-06-27)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## 1.0.130 (2024-06-26)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## 1.0.129 (2024-06-17)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
## 1.0.128 (2024-06-17)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
## 1.0.127 (2024-06-10)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## 1.0.126 (2024-05-29)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
## 1.0.125 (2024-05-29)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
## 1.0.124 (2024-05-29)
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
## 1.0.123 (2024-05-28)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
## 1.0.122 (2024-05-27)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
## 1.0.121 (2024-05-27)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
## 1.0.120 (2024-05-24)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
## 1.0.119 (2024-05-17)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
## 1.0.118 (2024-05-09)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
## 1.0.117 (2024-05-07)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
## 1.0.116 (2024-04-23)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
## 1.0.115 (2024-04-22)
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
## 1.0.114 (2024-04-19)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
## 1.0.113 (2024-04-19)
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
## 1.0.112 (2024-04-15)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
## 1.0.111 (2024-04-11)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
## 1.0.110 (2024-04-05)
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
## 1.0.109 (2024-04-05)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
## 1.0.108 (2024-04-04)
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
## 1.0.107 (2024-04-03)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
## 1.0.106 (2024-03-29)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
## 1.0.105 (2024-03-28)
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
## 1.0.104 (2024-03-21)
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
## 1.0.103 (2024-03-20)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
## 1.0.102 (2024-03-20)
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
## 1.0.101 (2024-03-13)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
## 1.0.100 (2024-03-12)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
## 1.0.99 (2024-03-11)
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
## 1.0.98 (2024-03-07)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
## 1.0.97 (2024-03-06)
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
|
|
290
|
+
## 1.0.96 (2024-03-06)
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
## 1.0.95 (2024-03-04)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
## 1.0.94 (2024-02-29)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
## 1.0.93 (2024-02-28)
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
## 1.0.92 (2024-02-28)
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
## 1.0.91 (2024-02-23)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
## 1.0.90 (2024-02-23)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
## 1.0.89 (2024-02-21)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
## 1.0.88 (2024-02-21)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
## 1.0.87 (2024-02-20)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
## 1.0.86 (2024-02-20)
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
## 1.0.85 (2024-02-13)
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
## 1.0.84 (2024-02-13)
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
## 1.0.83 (2024-02-09)
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
## 1.0.82 (2024-02-05)
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
## 1.0.81 (2024-02-05)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
## 1.0.80 (2024-02-05)
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
## 1.0.79 (2024-02-05)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
## 1.0.78 (2024-01-30)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
## 1.0.77 (2024-01-25)
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
## 1.0.76 (2024-01-25)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
## 1.0.75 (2024-01-22)
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
## 1.0.74 (2024-01-22)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
## 1.0.73 (2024-01-22)
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
## 1.0.72 (2024-01-19)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
## 1.0.71 (2024-01-18)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
## 1.0.70 (2024-01-17)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
## 1.0.69 (2024-01-17)
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
## 1.0.68 (2024-01-15)
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
## 1.0.67 (2024-01-15)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
## 1.0.66 (2024-01-12)
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
## 1.0.65 (2024-01-11)
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
## 1.0.64 (2024-01-11)
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
## 1.0.63 (2024-01-11)
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
## 1.0.62 (2024-01-10)
|
|
427
|
+
|
|
428
|
+
**Note:** Version bump only for package @oanda/labs-currency-power-balance-widget
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
|
|
6
434
|
## 1.0.105 (2024-10-07)
|
|
7
435
|
|
|
8
436
|
|
|
@@ -11,12 +11,13 @@ var _charts = require("echarts/charts");
|
|
|
11
11
|
var _renderers = require("echarts/renderers");
|
|
12
12
|
var _components = require("echarts/components");
|
|
13
13
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
14
|
+
var _monoI18n = require("@oanda/mono-i18n");
|
|
14
15
|
var _constants = require("./options/constants");
|
|
15
16
|
var _options = require("./options");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
-
echarts.use([_components.GridSimpleComponent, _components.GraphicComponent, _components.TooltipComponent, _components.LegendPlainComponent, _charts.LineChart, _renderers.CanvasRenderer]);
|
|
20
|
+
echarts.use([_components.GridSimpleComponent, _components.GraphicComponent, _components.TooltipComponent, _components.LegendPlainComponent, _charts.LineChart, _renderers.CanvasRenderer, _components.MarkLineComponent]);
|
|
20
21
|
echarts.registerTheme('dark_theme', (0, _labsWidgetCommon.getChartTheme)(_labsWidgetCommon.Theme.Dark));
|
|
21
22
|
echarts.registerTheme('light_theme', (0, _labsWidgetCommon.getChartTheme)(_labsWidgetCommon.Theme.Light));
|
|
22
23
|
const Chart = _ref => {
|
|
@@ -25,6 +26,9 @@ const Chart = _ref => {
|
|
|
25
26
|
timeUnit,
|
|
26
27
|
currencies
|
|
27
28
|
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
lang
|
|
31
|
+
} = (0, _monoI18n.useLocale)();
|
|
28
32
|
const {
|
|
29
33
|
isDark,
|
|
30
34
|
size
|
|
@@ -52,7 +56,7 @@ const Chart = _ref => {
|
|
|
52
56
|
height: `${_constants.CHART_HEIGHT}px`,
|
|
53
57
|
width: '100%'
|
|
54
58
|
},
|
|
55
|
-
option: (0, _options.getOption)(chartData, timeUnit, isDark)
|
|
59
|
+
option: (0, _options.getOption)(chartData, timeUnit, isDark, lang)
|
|
56
60
|
});
|
|
57
61
|
};
|
|
58
62
|
exports.Chart = Chart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","names":["_react","_interopRequireWildcard","require","_core","_interopRequireDefault","echarts","_charts","_renderers","_components","_labsWidgetCommon","_constants","_options","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","use","GridSimpleComponent","GraphicComponent","TooltipComponent","LegendPlainComponent","LineChart","CanvasRenderer","registerTheme","getChartTheme","Theme","Dark","Light","Chart","_ref","values","timeUnit","currencies","isDark","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","isMobile","MOBILE","echartRef","useRef","chartData","filter","_ref2","currency","includes","useEffect","current","echartInstance","getEchartsInstance","setOption","getResponsiveOption","createElement","ref","theme","style","height","CHART_HEIGHT","width","option","getOption","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx"],"sourcesContent":["import React, { useRef, useEffect, useContext } from 'react';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport * as echarts from 'echarts/core';\nimport { LineChart } from 'echarts/charts';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent,\n} from 'echarts/components';\nimport {\n Theme, ThemeContext, getChartTheme, Size,\n} from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n} from './options/constants';\nimport { getResponsiveOption, getOption } from './options';\nimport { ChartProps } from './types';\n\necharts.use([\n GridSimpleComponent,\n GraphicComponent,\n TooltipComponent,\n LegendPlainComponent,\n LineChart,\n CanvasRenderer,\n]);\n\necharts.registerTheme('dark_theme', getChartTheme(Theme.Dark));\necharts.registerTheme('light_theme', getChartTheme(Theme.Light));\n\nconst Chart = ({ values, timeUnit, currencies }: ChartProps) => {\n const { isDark, size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const isMobile = size === Size.MOBILE;\n\n const echartRef = useRef(null);\n\n const chartData = currencies\n ? values.filter(({ currency }) => currencies.includes(currency))\n : values;\n\n useEffect(() => {\n if (echartRef.current) {\n // @ts-ignore\n const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;\n\n echartInstance.setOption(\n getResponsiveOption(isDesktop, isMobile, isDark),\n );\n }\n }, [echartRef, isDesktop, isMobile, isDark]);\n\n return (\n <ReactEChartsCore\n echarts={echarts}\n ref={echartRef}\n theme={isDark ? 'dark_theme' : 'light_theme'}\n style={{\n height: `${CHART_HEIGHT}px`,\n width: '100%',\n }}\n option={getOption(chartData, timeUnit, isDark)}\n />\n );\n};\n\nexport { Chart };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAJ,uBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAGA,IAAAO,iBAAA,GAAAP,OAAA;AAGA,IAAAQ,
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["_react","_interopRequireWildcard","require","_core","_interopRequireDefault","echarts","_charts","_renderers","_components","_labsWidgetCommon","_monoI18n","_constants","_options","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","use","GridSimpleComponent","GraphicComponent","TooltipComponent","LegendPlainComponent","LineChart","CanvasRenderer","MarkLineComponent","registerTheme","getChartTheme","Theme","Dark","Light","Chart","_ref","values","timeUnit","currencies","lang","useLocale","isDark","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","isMobile","MOBILE","echartRef","useRef","chartData","filter","_ref2","currency","includes","useEffect","current","echartInstance","getEchartsInstance","setOption","getResponsiveOption","createElement","ref","theme","style","height","CHART_HEIGHT","width","option","getOption","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx"],"sourcesContent":["import React, { useRef, useEffect, useContext } from 'react';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport * as echarts from 'echarts/core';\nimport { LineChart } from 'echarts/charts';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, MarkLineComponent,\n} from 'echarts/components';\nimport {\n Theme, ThemeContext, getChartTheme, Size,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport {\n CHART_HEIGHT,\n} from './options/constants';\nimport { getResponsiveOption, getOption } from './options';\nimport { ChartProps } from './types';\n\necharts.use([\n GridSimpleComponent,\n GraphicComponent,\n TooltipComponent,\n LegendPlainComponent,\n LineChart,\n CanvasRenderer,\n MarkLineComponent,\n]);\n\necharts.registerTheme('dark_theme', getChartTheme(Theme.Dark));\necharts.registerTheme('light_theme', getChartTheme(Theme.Light));\n\nconst Chart = ({ values, timeUnit, currencies }: ChartProps) => {\n const { lang } = useLocale();\n const { isDark, size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const isMobile = size === Size.MOBILE;\n\n const echartRef = useRef(null);\n\n const chartData = currencies\n ? values.filter(({ currency }) => currencies.includes(currency))\n : values;\n\n useEffect(() => {\n if (echartRef.current) {\n // @ts-ignore\n const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;\n\n echartInstance.setOption(\n getResponsiveOption(isDesktop, isMobile, isDark),\n );\n }\n }, [echartRef, isDesktop, isMobile, isDark]);\n\n return (\n <ReactEChartsCore\n echarts={echarts}\n ref={echartRef}\n theme={isDark ? 'dark_theme' : 'light_theme'}\n style={{\n height: `${CHART_HEIGHT}px`,\n width: '100%',\n }}\n option={getOption(chartData, timeUnit, isDark, lang)}\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;IAAS,CAAC,GAAAD,KAAA;IAAA,OAAKhB,UAAU,CAACkB,QAAQ,CAACD,QAAQ,CAAC;EAAA,EAAC,GAC9DnB,MAAM;EAEV,IAAAqB,gBAAS,EAAC,MAAM;IACd,IAAIP,SAAS,CAACQ,OAAO,EAAE;MAErB,MAAMC,cAAc,GAAGT,SAAS,CAACQ,OAAO,CAACE,kBAAkB,CAAC,CAAwB;MAEpFD,cAAc,CAACE,SAAS,CACtB,IAAAC,4BAAmB,EAACjB,SAAS,EAAEG,QAAQ,EAAEP,MAAM,CACjD,CAAC;IACH;EACF,CAAC,EAAE,CAACS,SAAS,EAAEL,SAAS,EAAEG,QAAQ,EAAEP,MAAM,CAAC,CAAC;EAE5C,OACErD,MAAA,CAAAe,OAAA,CAAA4D,aAAA,CAACxE,KAAA,CAAAY,OAAgB;IACfV,OAAO,EAAEA,OAAQ;IACjBuE,GAAG,EAAEd,SAAU;IACfe,KAAK,EAAExB,MAAM,GAAG,YAAY,GAAG,aAAc;IAC7CyB,KAAK,EAAE;MACLC,MAAM,EAAE,GAAGC,uBAAY,IAAI;MAC3BC,KAAK,EAAE;IACT,CAAE;IACFC,MAAM,EAAE,IAAAC,kBAAS,EAACnB,SAAS,EAAEf,QAAQ,EAAEI,MAAM,EAAEF,IAAI;EAAE,CACtD,CAAC;AAEN,CAAC;AAACiC,OAAA,CAAAtC,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Y_LABEL_SIZE_MOBILE = exports.Y_LABEL_SIZE = exports.X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE = exports.VERTICAL_LINE_COUNT = exports.TOOLTIP_LINE_COLOR_CONFIG = exports.LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT = exports.
|
|
6
|
+
exports.Y_LABEL_SIZE_MOBILE = exports.Y_LABEL_SIZE = exports.X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE = exports.WEEKEND_DURATION = exports.VERTICAL_LINE_COUNT = exports.TOOLTIP_LINE_COLOR_CONFIG = exports.LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT = exports.CURRENCIES_ORDER = exports.COLOR_CONFIG = exports.CHART_WIDTH = exports.CHART_HEIGHT = exports.CANDLE_NUMBER_HOUR = exports.CANDLE_MINUTE = void 0;
|
|
7
7
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
8
|
var _graphql = require("../../../../gql/types/graphql");
|
|
9
|
+
const WEEKEND_DURATION = exports.WEEKEND_DURATION = 172800000;
|
|
9
10
|
const X_LABEL_SIZE = exports.X_LABEL_SIZE = 90;
|
|
10
11
|
const X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE_MOBILE = 110;
|
|
11
12
|
const Y_LABEL_SIZE_MOBILE = exports.Y_LABEL_SIZE_MOBILE = 35;
|
|
@@ -17,7 +18,7 @@ const LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT_MOBILE = 70;
|
|
|
17
18
|
const VERTICAL_LINE_COUNT = exports.VERTICAL_LINE_COUNT = 10;
|
|
18
19
|
const CANDLE_NUMBER_HOUR = exports.CANDLE_NUMBER_HOUR = 12;
|
|
19
20
|
const CANDLE_MINUTE = exports.CANDLE_MINUTE = 5;
|
|
20
|
-
const
|
|
21
|
+
const CURRENCIES_ORDER = exports.CURRENCIES_ORDER = [_graphql.CurrencyName.Usd, _graphql.CurrencyName.Eur, _graphql.CurrencyName.Gbp, _graphql.CurrencyName.Cad, _graphql.CurrencyName.Aud, _graphql.CurrencyName.Chf, _graphql.CurrencyName.Jpy, _graphql.CurrencyName.Nzd];
|
|
21
22
|
const COLOR_CONFIG = exports.COLOR_CONFIG = {
|
|
22
23
|
USD: _labsWidgetCommon.colorPalette.greenLight,
|
|
23
24
|
EUR: _labsWidgetCommon.colorPalette.turquoiseLight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","_graphql","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","_graphql","WEEKEND_DURATION","exports","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","VERTICAL_LINE_COUNT","CANDLE_NUMBER_HOUR","CANDLE_MINUTE","CURRENCIES_ORDER","CurrencyName","Usd","Eur","Gbp","Cad","Aud","Chf","Jpy","Nzd","COLOR_CONFIG","USD","colorPalette","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreenLight75","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport { CurrencyName } from '../../../../gql/types/graphql';\n\nconst WEEKEND_DURATION = 172800000;\n\nconst X_LABEL_SIZE = 90;\nconst X_LABEL_SIZE_MOBILE = 110;\nconst Y_LABEL_SIZE_MOBILE = 35;\nconst Y_LABEL_SIZE = 45;\nconst CHART_WIDTH = 9999;\nconst CHART_HEIGHT = 425;\nconst LEGEND_HEIGHT = 50;\nconst LEGEND_HEIGHT_MOBILE = 70;\nconst VERTICAL_LINE_COUNT = 10;\nconst CANDLE_NUMBER_HOUR = 12;\nconst CANDLE_MINUTE = 5;\n\nconst CURRENCIES_ORDER: CurrencyName[] = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Gbp,\n CurrencyName.Cad,\n CurrencyName.Aud,\n CurrencyName.Chf,\n CurrencyName.Jpy,\n CurrencyName.Nzd,\n];\n\nconst COLOR_CONFIG = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreenLight75,\n AUD: colorPalette.orange,\n CAD: colorPalette.midnight75Lighter,\n NZD: colorPalette.gold,\n};\n\nconst TOOLTIP_LINE_COLOR_CONFIG = {\n DARK: colorPalette.orange,\n LIGHT: colorPalette.bottleGreenDark,\n};\n\nexport {\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n CHART_WIDTH,\n CHART_HEIGHT,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n VERTICAL_LINE_COUNT,\n COLOR_CONFIG,\n TOOLTIP_LINE_COLOR_CONFIG,\n CANDLE_NUMBER_HOUR,\n CANDLE_MINUTE,\n CURRENCIES_ORDER,\n WEEKEND_DURATION,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,SAAS;AAElC,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG,EAAE;AACvB,MAAMC,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAAH,OAAA,CAAAG,mBAAA,GAAG,EAAE;AAC9B,MAAMC,YAAY,GAAAJ,OAAA,CAAAI,YAAA,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAAL,OAAA,CAAAK,WAAA,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAAN,OAAA,CAAAM,YAAA,GAAG,GAAG;AACxB,MAAMC,aAAa,GAAAP,OAAA,CAAAO,aAAA,GAAG,EAAE;AACxB,MAAMC,oBAAoB,GAAAR,OAAA,CAAAQ,oBAAA,GAAG,EAAE;AAC/B,MAAMC,mBAAmB,GAAAT,OAAA,CAAAS,mBAAA,GAAG,EAAE;AAC9B,MAAMC,kBAAkB,GAAAV,OAAA,CAAAU,kBAAA,GAAG,EAAE;AAC7B,MAAMC,aAAa,GAAAX,OAAA,CAAAW,aAAA,GAAG,CAAC;AAEvB,MAAMC,gBAAgC,GAAAZ,OAAA,CAAAY,gBAAA,GAAG,CACvCC,qBAAY,CAACC,GAAG,EAChBD,qBAAY,CAACE,GAAG,EAChBF,qBAAY,CAACG,GAAG,EAChBH,qBAAY,CAACI,GAAG,EAChBJ,qBAAY,CAACK,GAAG,EAChBL,qBAAY,CAACM,GAAG,EAChBN,qBAAY,CAACO,GAAG,EAChBP,qBAAY,CAACQ,GAAG,CACjB;AAED,MAAMC,YAAY,GAAAtB,OAAA,CAAAsB,YAAA,GAAG;EACnBC,GAAG,EAAEC,8BAAY,CAACC,UAAU;EAC5BC,GAAG,EAAEF,8BAAY,CAACG,cAAc;EAChCC,GAAG,EAAEJ,8BAAY,CAACK,WAAW;EAC7BC,GAAG,EAAEN,8BAAY,CAACO,cAAc;EAChCC,GAAG,EAAER,8BAAY,CAACS,kBAAkB;EACpCC,GAAG,EAAEV,8BAAY,CAACW,MAAM;EACxBC,GAAG,EAAEZ,8BAAY,CAACa,iBAAiB;EACnCC,GAAG,EAAEd,8BAAY,CAACe;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAAxC,OAAA,CAAAwC,yBAAA,GAAG;EAChCC,IAAI,EAAEjB,8BAAY,CAACW,MAAM;EACzBO,KAAK,EAAElB,8BAAY,CAACmB;AACtB,CAAC","ignoreList":[]}
|
|
@@ -78,7 +78,7 @@ const formatLegendData = values => {
|
|
|
78
78
|
} = _ref5;
|
|
79
79
|
return currency;
|
|
80
80
|
});
|
|
81
|
-
const list = dataCurrencies.length === _constants.
|
|
81
|
+
const list = dataCurrencies.length === _constants.CURRENCIES_ORDER.length ? _constants.CURRENCIES_ORDER : _constants.CURRENCIES_ORDER.filter(currency => dataCurrencies.includes(currency));
|
|
82
82
|
return list.map(currency => ({
|
|
83
83
|
name: currency,
|
|
84
84
|
itemStyle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","names":["_graphql","require","_constants","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","CurrencyPowerBalanceTimeUnit","M3","M1","W1","exports","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","Math","round","VERTICAL_LINE_COUNT","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join","formatLegendData","dataCurrencies","_ref5","currency","list","length","
|
|
1
|
+
{"version":3,"file":"formatters.js","names":["_graphql","require","_constants","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","CurrencyPowerBalanceTimeUnit","M3","M1","W1","exports","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","Math","round","VERTICAL_LINE_COUNT","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join","formatLegendData","dataCurrencies","_ref5","currency","list","length","CURRENCIES_ORDER","filter","includes","name","itemStyle","color","COLOR_CONFIG"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { VERTICAL_LINE_COUNT, CURRENCIES_ORDER, COLOR_CONFIG } from './constants';\nimport { TooltipFormatterParams } from './types';\n\nconst getDateAndTime = (param: string) => {\n const dateAndTime = param.split('T');\n\n return {\n date: dateAndTime[0],\n time: dateAndTime[1].substring(0, 5),\n };\n};\n\nconst dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;\n\nconst dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;\n\nconst isMonthWeek = (\n timeUnit: CurrencyPowerBalanceTimeUnit,\n) => timeUnit === CurrencyPowerBalanceTimeUnit.M3\n || timeUnit === CurrencyPowerBalanceTimeUnit.M1\n || timeUnit === CurrencyPowerBalanceTimeUnit.W1;\n\nconst xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\n\nconst intervalFormatter = (\n dataLength: number,\n) => Math.round(dataLength / VERTICAL_LINE_COUNT);\n\nconst tooltipFormatter = (values: TooltipFormatterParams[]) => {\n const date = dateTimeFormat(getDateAndTime(values[0].value[0]));\n\n const row = values\n .sort(({ value: valueA }, { value: valueB }) => Number(valueB[1]) - Number(valueA[1]))\n .map(({ marker, seriesName, value }) => `<div style=\"display:flex;align-items:center;\">\n <div style=\"display:flex;align-items:center;width:50px;margin-right:10px;\">\n ${marker}\n <span>${seriesName}</span>\n </div>\n <span>${value[1]}</span>\n </div>`);\n\n return `<div style=\"display:flex; flex-direction:column;\">\n <span style=\"margin-bottom:5px;\">${date}</span>\n ${row.join('\\n')}\n </div>`;\n};\n\nconst formatLegendData = (values: CurrencyPowerBalance[]) => {\n const dataCurrencies = values.map(({ currency }) => currency);\n\n const list = dataCurrencies.length === CURRENCIES_ORDER.length\n ? CURRENCIES_ORDER\n : CURRENCIES_ORDER.filter((currency) => dataCurrencies.includes(currency));\n\n return list.map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n};\n\nexport {\n isMonthWeek,\n tooltipFormatter,\n xAxisLabelFormatter,\n intervalFormatter,\n formatLegendData,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGA,MAAME,cAAc,GAAIC,KAAa,IAAK;E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DC,2BAAgB,GAChBA,2BAAgB,CAACC,MAAM,CAAEJ,QAAQ,IAAKF,cAAc,CAACO,QAAQ,CAACL,QAAQ,CAAC,CAAC;EAE5E,OAAOC,IAAI,CAACT,GAAG,CAAEQ,QAAQ,KAAM;IAC7BM,IAAI,EAAEN,QAAQ;IACdO,SAAS,EAAE;MACTC,KAAK,EAAEC,uBAAY,CAACT,QAAQ;IAC9B;EACF,CAAC,CAAC,CAAC;AACL,CAAC;AAAC3B,OAAA,CAAAwB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -4,10 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getOption = void 0;
|
|
7
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
7
8
|
var _constants = require("./constants");
|
|
8
9
|
var _formatters = require("./formatters");
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
var _graphql = require("../../../../gql/types/graphql");
|
|
11
|
+
var _utils = require("./utils");
|
|
12
|
+
const getOption = (chartData, timeUnit, isDark, lang) => {
|
|
13
|
+
const currentTheme = isDark ? _labsWidgetCommon.darkTheme : _labsWidgetCommon.lightTheme;
|
|
14
|
+
const dataTimestamps = chartData[0].power.map(x => new Date(x.point).getTime());
|
|
15
|
+
const weekendsIndexes = (0, _utils.findLastIndexesBeforeWeekend)(dataTimestamps);
|
|
16
|
+
const disableWeekendsIndicator = [_graphql.CurrencyPowerBalanceTimeUnit.CurrentDay, _graphql.CurrencyPowerBalanceTimeUnit.PreviousDay, _graphql.CurrencyPowerBalanceTimeUnit.M3].includes(timeUnit) || weekendsIndexes.length === 0;
|
|
17
|
+
const weekendsMarks = weekendsIndexes.map(item => ({
|
|
18
|
+
xAxis: item,
|
|
19
|
+
label: {
|
|
20
|
+
formatter: () => lang('market_closed')
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
const seriesData = chartData.map((_ref, index) => {
|
|
11
24
|
let {
|
|
12
25
|
currency,
|
|
13
26
|
power
|
|
@@ -20,16 +33,47 @@ const getOption = (chartData, timeUnit, isDark) => {
|
|
|
20
33
|
itemStyle: {
|
|
21
34
|
color: _constants.COLOR_CONFIG[currency]
|
|
22
35
|
},
|
|
23
|
-
lineStyle: {
|
|
24
|
-
color: _constants.COLOR_CONFIG[currency]
|
|
25
|
-
},
|
|
26
36
|
data: power.map(_ref2 => {
|
|
27
37
|
let {
|
|
28
38
|
point,
|
|
29
39
|
price
|
|
30
40
|
} = _ref2;
|
|
31
41
|
return [point, price];
|
|
32
|
-
})
|
|
42
|
+
}),
|
|
43
|
+
markLine: index === chartData.length - 1 && !disableWeekendsIndicator ? {
|
|
44
|
+
label: {
|
|
45
|
+
show: false,
|
|
46
|
+
position: 'end',
|
|
47
|
+
align: 'center',
|
|
48
|
+
distance: -32,
|
|
49
|
+
padding: [8, 8],
|
|
50
|
+
fontSize: 12,
|
|
51
|
+
shadowBlur: 24,
|
|
52
|
+
shadowOffsetX: 0,
|
|
53
|
+
shadowOffsetY: 6,
|
|
54
|
+
borderWidth: 0,
|
|
55
|
+
color: currentTheme.textPrimary,
|
|
56
|
+
shadowColor: 'rgba(0,0,0,0.1)',
|
|
57
|
+
borderRadius: 4,
|
|
58
|
+
backgroundColor: isDark ? currentTheme.borderPrimary : currentTheme.backgroundSecondary
|
|
59
|
+
},
|
|
60
|
+
show: false,
|
|
61
|
+
emphasis: {
|
|
62
|
+
label: {
|
|
63
|
+
show: true
|
|
64
|
+
},
|
|
65
|
+
lineStyle: {
|
|
66
|
+
width: 1,
|
|
67
|
+
opacity: 0,
|
|
68
|
+
color: currentTheme.borderPrimary
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
symbol: ['none', 'none'],
|
|
72
|
+
itemStyle: {
|
|
73
|
+
color: currentTheme.borderPrimary
|
|
74
|
+
},
|
|
75
|
+
data: weekendsMarks
|
|
76
|
+
} : undefined
|
|
33
77
|
};
|
|
34
78
|
});
|
|
35
79
|
const legendData = (0, _formatters.formatLegendData)(chartData);
|