@oanda/labs-currency-power-balance-widget 1.0.48 → 1.0.50

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +404 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +7 -6
  3. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +6 -1
  5. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/Main.js +42 -3
  7. package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +9 -2
  9. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  10. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -1
  11. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  12. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +17 -1
  13. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  14. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +3 -8
  15. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  16. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  17. package/dist/main/CurrencyPowerBalanceWidget/render.js +5 -1
  18. package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -1
  19. package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -1
  20. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +7 -6
  21. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  22. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +6 -1
  23. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  24. package/dist/module/CurrencyPowerBalanceWidget/Main.js +43 -4
  25. package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  26. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +9 -2
  27. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  28. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -1
  29. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  30. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +17 -2
  31. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  32. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +4 -9
  33. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  34. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  35. package/dist/module/CurrencyPowerBalanceWidget/render.js +5 -1
  36. package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -1
  37. package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -1
  38. package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +1 -1
  39. package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +1 -1
  40. package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +2 -1
  41. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +1 -1
  42. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +13 -2
  43. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +8 -2
  44. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +2 -2
  45. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +1 -0
  46. package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +7 -0
  47. package/package.json +4 -4
  48. package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +5 -5
  49. package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +2 -2
  50. package/src/CurrencyPowerBalanceWidget/Main.tsx +40 -4
  51. package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +6 -2
  52. package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx +14 -1
  53. package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +18 -2
  54. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +6 -9
  55. package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +1 -0
  56. package/src/CurrencyPowerBalanceWidget/render.tsx +3 -1
  57. package/src/CurrencyPowerBalanceWidget/types.ts +8 -0
  58. package/test/Main.test.tsx +56 -2
  59. package/dist/main/CurrencyPowerBalanceWidget/Tool.js +0 -28
  60. package/dist/main/CurrencyPowerBalanceWidget/Tool.js.map +0 -1
  61. package/dist/module/CurrencyPowerBalanceWidget/Tool.js +0 -20
  62. package/dist/module/CurrencyPowerBalanceWidget/Tool.js.map +0 -1
  63. package/dist/types/CurrencyPowerBalanceWidget/Tool.d.ts +0 -3
  64. package/src/CurrencyPowerBalanceWidget/Tool.tsx +0 -27
package/CHANGELOG.md CHANGED
@@ -3,6 +3,410 @@
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.50 (2024-04-11)
7
+
8
+
9
+
10
+ ## 1.0.110 (2024-04-05)
11
+
12
+
13
+
14
+ ## 1.0.109 (2024-04-05)
15
+
16
+
17
+
18
+ ## 1.0.108 (2024-04-04)
19
+
20
+
21
+
22
+ ## 1.0.107 (2024-04-03)
23
+
24
+
25
+
26
+ ## 1.0.106 (2024-03-29)
27
+
28
+
29
+
30
+ ## 1.0.105 (2024-03-28)
31
+
32
+
33
+
34
+ ## 1.0.104 (2024-03-21)
35
+
36
+
37
+
38
+ ## 1.0.103 (2024-03-20)
39
+
40
+
41
+
42
+ ## 1.0.102 (2024-03-20)
43
+
44
+
45
+
46
+ ## 1.0.101 (2024-03-13)
47
+
48
+
49
+
50
+ ## 1.0.100 (2024-03-12)
51
+
52
+
53
+
54
+ ## 1.0.99 (2024-03-11)
55
+
56
+
57
+
58
+ ## 1.0.98 (2024-03-07)
59
+
60
+
61
+
62
+ ## 1.0.97 (2024-03-06)
63
+
64
+
65
+
66
+ ## 1.0.96 (2024-03-06)
67
+
68
+
69
+
70
+ ## 1.0.95 (2024-03-04)
71
+
72
+
73
+
74
+ ## 1.0.94 (2024-02-29)
75
+
76
+
77
+
78
+ ## 1.0.93 (2024-02-28)
79
+
80
+
81
+
82
+ ## 1.0.92 (2024-02-28)
83
+
84
+
85
+
86
+ ## 1.0.91 (2024-02-23)
87
+
88
+
89
+
90
+ ## 1.0.90 (2024-02-23)
91
+
92
+
93
+
94
+ ## 1.0.89 (2024-02-21)
95
+
96
+
97
+
98
+ ## 1.0.88 (2024-02-21)
99
+
100
+
101
+
102
+ ## 1.0.87 (2024-02-20)
103
+
104
+
105
+
106
+ ## 1.0.86 (2024-02-20)
107
+
108
+
109
+
110
+ ## 1.0.85 (2024-02-13)
111
+
112
+
113
+
114
+ ## 1.0.84 (2024-02-13)
115
+
116
+
117
+
118
+ ## 1.0.83 (2024-02-09)
119
+
120
+
121
+
122
+ ## 1.0.82 (2024-02-05)
123
+
124
+
125
+
126
+ ## 1.0.81 (2024-02-05)
127
+
128
+
129
+
130
+ ## 1.0.80 (2024-02-05)
131
+
132
+
133
+
134
+ ## 1.0.79 (2024-02-05)
135
+
136
+
137
+
138
+ ## 1.0.78 (2024-01-30)
139
+
140
+
141
+
142
+ ## 1.0.77 (2024-01-25)
143
+
144
+
145
+
146
+ ## 1.0.76 (2024-01-25)
147
+
148
+
149
+
150
+ ## 1.0.75 (2024-01-22)
151
+
152
+
153
+
154
+ ## 1.0.74 (2024-01-22)
155
+
156
+
157
+
158
+ ## 1.0.73 (2024-01-22)
159
+
160
+
161
+
162
+ ## 1.0.72 (2024-01-19)
163
+
164
+
165
+
166
+ ## 1.0.71 (2024-01-18)
167
+
168
+
169
+
170
+ ## 1.0.70 (2024-01-17)
171
+
172
+
173
+
174
+ ## 1.0.69 (2024-01-17)
175
+
176
+
177
+
178
+ ## 1.0.68 (2024-01-15)
179
+
180
+
181
+
182
+ ## 1.0.67 (2024-01-15)
183
+
184
+
185
+
186
+ ## 1.0.66 (2024-01-12)
187
+
188
+
189
+
190
+ ## 1.0.65 (2024-01-11)
191
+
192
+
193
+
194
+ ## 1.0.64 (2024-01-11)
195
+
196
+
197
+
198
+ ## 1.0.63 (2024-01-11)
199
+
200
+
201
+
202
+ ## 1.0.62 (2024-01-10)
203
+
204
+ **Note:** Version bump only for package @oanda/labs-currency-power-balance-widget
205
+
206
+
207
+
208
+
209
+
210
+ ## 1.0.49 (2024-04-05)
211
+
212
+
213
+
214
+ ## 1.0.109 (2024-04-05)
215
+
216
+
217
+
218
+ ## 1.0.108 (2024-04-04)
219
+
220
+
221
+
222
+ ## 1.0.107 (2024-04-03)
223
+
224
+
225
+
226
+ ## 1.0.106 (2024-03-29)
227
+
228
+
229
+
230
+ ## 1.0.105 (2024-03-28)
231
+
232
+
233
+
234
+ ## 1.0.104 (2024-03-21)
235
+
236
+
237
+
238
+ ## 1.0.103 (2024-03-20)
239
+
240
+
241
+
242
+ ## 1.0.102 (2024-03-20)
243
+
244
+
245
+
246
+ ## 1.0.101 (2024-03-13)
247
+
248
+
249
+
250
+ ## 1.0.100 (2024-03-12)
251
+
252
+
253
+
254
+ ## 1.0.99 (2024-03-11)
255
+
256
+
257
+
258
+ ## 1.0.98 (2024-03-07)
259
+
260
+
261
+
262
+ ## 1.0.97 (2024-03-06)
263
+
264
+
265
+
266
+ ## 1.0.96 (2024-03-06)
267
+
268
+
269
+
270
+ ## 1.0.95 (2024-03-04)
271
+
272
+
273
+
274
+ ## 1.0.94 (2024-02-29)
275
+
276
+
277
+
278
+ ## 1.0.93 (2024-02-28)
279
+
280
+
281
+
282
+ ## 1.0.92 (2024-02-28)
283
+
284
+
285
+
286
+ ## 1.0.91 (2024-02-23)
287
+
288
+
289
+
290
+ ## 1.0.90 (2024-02-23)
291
+
292
+
293
+
294
+ ## 1.0.89 (2024-02-21)
295
+
296
+
297
+
298
+ ## 1.0.88 (2024-02-21)
299
+
300
+
301
+
302
+ ## 1.0.87 (2024-02-20)
303
+
304
+
305
+
306
+ ## 1.0.86 (2024-02-20)
307
+
308
+
309
+
310
+ ## 1.0.85 (2024-02-13)
311
+
312
+
313
+
314
+ ## 1.0.84 (2024-02-13)
315
+
316
+
317
+
318
+ ## 1.0.83 (2024-02-09)
319
+
320
+
321
+
322
+ ## 1.0.82 (2024-02-05)
323
+
324
+
325
+
326
+ ## 1.0.81 (2024-02-05)
327
+
328
+
329
+
330
+ ## 1.0.80 (2024-02-05)
331
+
332
+
333
+
334
+ ## 1.0.79 (2024-02-05)
335
+
336
+
337
+
338
+ ## 1.0.78 (2024-01-30)
339
+
340
+
341
+
342
+ ## 1.0.77 (2024-01-25)
343
+
344
+
345
+
346
+ ## 1.0.76 (2024-01-25)
347
+
348
+
349
+
350
+ ## 1.0.75 (2024-01-22)
351
+
352
+
353
+
354
+ ## 1.0.74 (2024-01-22)
355
+
356
+
357
+
358
+ ## 1.0.73 (2024-01-22)
359
+
360
+
361
+
362
+ ## 1.0.72 (2024-01-19)
363
+
364
+
365
+
366
+ ## 1.0.71 (2024-01-18)
367
+
368
+
369
+
370
+ ## 1.0.70 (2024-01-17)
371
+
372
+
373
+
374
+ ## 1.0.69 (2024-01-17)
375
+
376
+
377
+
378
+ ## 1.0.68 (2024-01-15)
379
+
380
+
381
+
382
+ ## 1.0.67 (2024-01-15)
383
+
384
+
385
+
386
+ ## 1.0.66 (2024-01-12)
387
+
388
+
389
+
390
+ ## 1.0.65 (2024-01-11)
391
+
392
+
393
+
394
+ ## 1.0.64 (2024-01-11)
395
+
396
+
397
+
398
+ ## 1.0.63 (2024-01-11)
399
+
400
+
401
+
402
+ ## 1.0.62 (2024-01-10)
403
+
404
+ **Note:** Version bump only for package @oanda/labs-currency-power-balance-widget
405
+
406
+
407
+
408
+
409
+
6
410
  ## 1.0.48 (2024-04-05)
7
411
 
8
412
 
@@ -13,9 +13,10 @@ var _getCurrencyPowerBalance = require("../gql/getCurrencyPowerBalance");
13
13
  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); }
14
14
  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; }
15
15
  const ChartWithData = _ref => {
16
- var _data$currencyPowerBa, _data$currencyPowerBa2;
16
+ var _data$currencyPowerBa;
17
17
  let {
18
- timeUnit
18
+ timeUnit,
19
+ currencies
19
20
  } = _ref;
20
21
  const {
21
22
  size
@@ -31,15 +32,15 @@ const ChartWithData = _ref => {
31
32
  },
32
33
  fetchPolicy: 'cache-and-network'
33
34
  });
34
- const showChart = (data === null || data === void 0 ? void 0 : data.currencyPowerBalance) && (data === null || data === void 0 || (_data$currencyPowerBa = data.currencyPowerBalance) === null || _data$currencyPowerBa === void 0 ? void 0 : _data$currencyPowerBa.length) > 0;
35
- const showError = (data === null || data === void 0 || (_data$currencyPowerBa2 = data.currencyPowerBalance) === null || _data$currencyPowerBa2 === void 0 ? void 0 : _data$currencyPowerBa2.length) === 0 || error;
35
+ const showError = (data === null || data === void 0 || (_data$currencyPowerBa = data.currencyPowerBalance) === null || _data$currencyPowerBa === void 0 ? void 0 : _data$currencyPowerBa.length) === 0 || error || currencies && (currencies.length === 0 || currencies.length === 1);
36
36
  return _react.default.createElement(_react.default.Fragment, null, loading && _react.default.createElement("div", {
37
37
  className: "lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
38
38
  }, _react.default.createElement(_labsWidgetCommon.Spinner, {
39
39
  size: _labsWidgetCommon.SpinnerSize.lg
40
- })), !loading && showChart && _react.default.createElement(_Chart.Chart, {
40
+ })), !loading && !showError && _react.default.createElement(_Chart.Chart, {
41
41
  values: data === null || data === void 0 ? void 0 : data.currencyPowerBalance,
42
- timeUnit: timeUnit
42
+ timeUnit: timeUnit,
43
+ currencies: currencies
43
44
  }), !loading && showError && _react.default.createElement("div", {
44
45
  className: "lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
45
46
  }, _react.default.createElement(_labsWidgetCommon.ChartError, null)), isDesktop && _react.default.createElement(_labsWidgetCommon.Tooltip, {
@@ -1 +1 @@
1
- {"version":3,"file":"ChartWithData.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_Chart","_constants","_getCurrencyPowerBalance","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChartWithData","_ref","_data$currencyPowerBa","_data$currencyPowerBa2","timeUnit","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","loading","data","error","useQuery","getCurrencyPowerBalance","variables","fetchPolicy","showChart","currencyPowerBalance","length","showError","createElement","Fragment","className","Spinner","SpinnerSize","lg","Chart","values","ChartError","Tooltip","id","CURRENCY_POWER_BALANCE_TOOLTIP_ID","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/ChartWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Spinner, SpinnerSize, ThemeContext, Tooltip, Size,\n} from '@oanda/labs-widget-common';\nimport { Chart } from './components/Chart';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';\nimport { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';\nimport { ChartWithDataProps } from './types';\nimport { GetCurrencyPowerBalanceQuery, GetCurrencyPowerBalanceQueryVariables } from '../gql/types/graphql';\n\nconst ChartWithData = ({ timeUnit }: ChartWithDataProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<\n GetCurrencyPowerBalanceQuery,\n GetCurrencyPowerBalanceQueryVariables\n >(getCurrencyPowerBalance, {\n variables: {\n timeUnit,\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyPowerBalance && data?.currencyPowerBalance?.length > 0;\n const showError = data?.currencyPowerBalance?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <Chart values={data?.currencyPowerBalance!} timeUnit={timeUnit} />\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n {isDesktop && <Tooltip id={CURRENCY_POWER_BALANCE_TOOLTIP_ID} />}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAGA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,wBAAA,GAAAL,OAAA;AAAyE,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,m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HpD,MAAA,CAAAc,OAAA,CAAAoC,aAAA,CAAC9C,iBAAA,CAAAsD,UAAU,MAAE,CACV,CACN,EACAtB,SAAS,IAAIpC,MAAA,CAAAc,OAAA,CAAAoC,aAAA,CAAC9C,iBAAA,CAAAuD,OAAO;IAACC,EAAE,EAAEC;EAAkC,CAAE,CAC/D,CAAC;AAEP,CAAC;AAACC,OAAA,CAAAlC,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"ChartWithData.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_Chart","_constants","_getCurrencyPowerBalance","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChartWithData","_ref","_data$currencyPowerBa","timeUnit","currencies","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","loading","data","error","useQuery","getCurrencyPowerBalance","variables","fetchPolicy","showError","currencyPowerBalance","length","createElement","Fragment","className","Spinner","SpinnerSize","lg","Chart","values","ChartError","Tooltip","id","CURRENCY_POWER_BALANCE_TOOLTIP_ID","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/ChartWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Spinner, SpinnerSize, ThemeContext, Tooltip, Size,\n} from '@oanda/labs-widget-common';\nimport { Chart } from './components/Chart';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';\nimport { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';\nimport { ChartWithDataProps } from './types';\nimport { GetCurrencyPowerBalanceQuery, GetCurrencyPowerBalanceQueryVariables } from '../gql/types/graphql';\n\nconst ChartWithData = ({ timeUnit, currencies }: ChartWithDataProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<\n GetCurrencyPowerBalanceQuery,\n GetCurrencyPowerBalanceQueryVariables\n >(getCurrencyPowerBalance, {\n variables: {\n timeUnit,\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const showError = data?.currencyPowerBalance?.length === 0 || error\n || (currencies && (currencies.length === 0 || currencies.length === 1));\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && !showError && (\n <Chart values={data?.currencyPowerBalance!} timeUnit={timeUnit} currencies={currencies} />\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n {isDesktop && <Tooltip id={CURRENCY_POWER_BALANCE_TOOLTIP_ID} />}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAGA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,wBAAA,GAAAL,OAAA;AAAyE,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CA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CAACgB,MAAM,KAAK,CAAC,IAAIhB,UAAU,CAACgB,MAAM,KAAK,CAAC,CAAE;EAEzE,OACEhD,MAAA,CAAAc,OAAA,CAAAmC,aAAA,CAAAjD,MAAA,CAAAc,OAAA,CAAAoC,QAAA,QACGX,OAAO,IAERvC,MAAA,CAAAc,OAAA,CAAAmC,aAAA;IAAKE,SAAS,EAAC;EAAgH,GAC7HnD,MAAA,CAAAc,OAAA,CAAAmC,aAAA,CAAC7C,iBAAA,CAAAgD,OAAO;IAACnB,IAAI,EAAEoB,6BAAW,CAACC;EAAG,CAAE,CAC7B,CACJ,EACA,CAACf,OAAO,IAAI,CAACO,SAAS,IACrB9C,MAAA,CAAAc,OAAA,CAAAmC,aAAA,CAAC5C,MAAA,CAAAkD,KAAK;IAACC,MAAM,EAAEhB,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEO,oBAAsB;IAAChB,QAAQ,EAAEA,QAAS;IAACC,UAAU,EAAEA;EAAW,CAAE,CAC1F,EACA,CAACO,OAAO,IAAIO,SAAS,IACpB9C,MAAA,CAAAc,OAAA,CAAAmC,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChHnD,MAAA,CAAAc,OAAA,CAAAmC,aAAA,CAAC7C,iBAAA,CAAAqD,UAAU,MAAE,CACV,CACN,EACArB,SAAS,IAAIpC,MAAA,CAAAc,OAAA,CAAAmC,aAAA,CAAC7C,iBAAA,CAAAsD,OAAO;IAACC,EAAE,EAAEC;EAAkC,CAAE,CAC/D,CAAC;AAEP,CAAC;AAACC,OAAA,CAAAjC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -16,6 +16,8 @@ const CurrencyPowerBalance = _ref => {
16
16
  graphqlUrl,
17
17
  theme,
18
18
  locale,
19
+ timeUnit,
20
+ currencies,
19
21
  isParamError
20
22
  } = _ref;
21
23
  const client = new _client.ApolloClient({
@@ -31,7 +33,10 @@ const CurrencyPowerBalance = _ref => {
31
33
  client: client
32
34
  }, isParamError ? _react.default.createElement("div", {
33
35
  className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
34
- }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement(_Main.Main, null))));
36
+ }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement(_Main.Main, {
37
+ timeUnit: timeUnit,
38
+ currencies: currencies
39
+ }))));
35
40
  };
36
41
  exports.CurrencyPowerBalance = CurrencyPowerBalance;
37
42
  //# sourceMappingURL=CurrencyPowerBalance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyPowerBalance.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_monoI18n","_Main","_translations","obj","__esModule","default","CurrencyPowerBalance","_ref","graphqlUrl","theme","locale","isParamError","client","ApolloClient","uri","cache","InMemoryCache","createElement","ThemeProvider","LocaleProvider","getLocale","translations","ApolloProvider","className","ChartError","Main","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx"],"sourcesContent":["import React from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { Main } from './Main';\nimport { CurrencyPowerBalanceConfig } from './types';\nimport { translations } from '../translations';\n\nconst CurrencyPowerBalance = ({\n graphqlUrl, theme, locale, isParamError,\n}: CurrencyPowerBalanceConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyPowerBalance };\n"],"mappings":";;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AA","ignoreList":[]}
1
+ {"version":3,"file":"CurrencyPowerBalance.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_monoI18n","_Main","_translations","obj","__esModule","default","CurrencyPowerBalance","_ref","graphqlUrl","theme","locale","timeUnit","currencies","isParamError","client","ApolloClient","uri","cache","InMemoryCache","createElement","ThemeProvider","LocaleProvider","getLocale","translations","ApolloProvider","className","ChartError","Main","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx"],"sourcesContent":["import React from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { Main } from './Main';\nimport { CurrencyPowerBalanceConfig } from './types';\nimport { translations } from '../translations';\n\nconst CurrencyPowerBalance = ({\n graphqlUrl, theme, locale, timeUnit, currencies, isParamError,\n}: CurrencyPowerBalanceConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main timeUnit={timeUnit} currencies={currencies} />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyPowerBalance };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,aAAA,GAAAL,OAAA;AAA+C,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE/C,MAAMG,oBAAoB,GAAGC,IAAA,IAEK;EAAA,IAFJ;IAC5BC,UAAU;IAAEC,KAAK;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,UAAU;IAAEC;EACvB,CAAC,GAAAN,IAAA;EAC3B,MAAMO,MAAM,GAAG,IAAIC,oBAAY,CAAC;IAC9BC,GAAG,EAAER,UAAU;IACfS,KAAK,EAAE,IAAIC,qBAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEvB,MAAA,CAAAU,OAAA,CAAAc,aAAA,CAACpB,iBAAA,CAAAqB,aAAa;IAACX,KAAK,EAAEA;EAAM,GAC1Bd,MAAA,CAAAU,OAAA,CAAAc,aAAA,CAACnB,SAAA,CAAAqB,cAAc;IAACX,MAAM,EAAE,IAAAY,2BAAS,EAACZ,MAAM,CAAE;IAACa,YAAY,EAAEA;EAAa,GACpE5B,MAAA,CAAAU,OAAA,CAAAc,aAAA,CAACrB,OAAA,CAAA0B,cAAc;IAACV,MAAM,EAAEA;EAAO,GAC5BD,YAAY,GACXlB,MAAA,CAAAU,OAAA,CAAAc,aAAA;IAAKM,SAAS,EAAC;EAAmG,GAChH9B,MAAA,CAAAU,OAAA,CAAAc,aAAA,CAACpB,iBAAA,CAAA2B,UAAU,MAAE,CACV,CAAC,GACJ/B,MAAA,CAAAU,OAAA,CAAAc,aAAA,CAAClB,KAAA,CAAA0B,IAAI;IAAChB,QAAQ,EAAEA,QAAS;IAACC,UAAU,EAAEA;EAAW,CAAE,CACzC,CACF,CACH,CAAC;AAEpB,CAAC;AAACgB,OAAA,CAAAtB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -6,14 +6,53 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Main = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _labsWidgetCommon = require("@oanda/labs-widget-common");
9
- var _Tool = require("./Tool");
9
+ var _monoI18n = require("@oanda/mono-i18n");
10
+ var _graphql = require("../gql/types/graphql");
11
+ var _TimeUnitSwitch = require("./components/TimeUnitSwitch");
12
+ var _config = require("./config");
13
+ var _ChartWithData = require("./ChartWithData");
10
14
  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); }
11
15
  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; }
12
- const Main = () => {
16
+ const Main = _ref => {
17
+ let {
18
+ timeUnit,
19
+ currencies
20
+ } = _ref;
13
21
  const {
14
22
  size
15
23
  } = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
16
- return _react.default.createElement(_react.default.Fragment, null, size && _react.default.createElement(_Tool.Tool, null));
24
+ const {
25
+ lang
26
+ } = (0, _monoI18n.useLocale)();
27
+ const [selectedTimeUnit, setSelectedTimeUnit] = (0, _react.useState)(timeUnit || _graphql.CurrencyPowerBalanceTimeUnit.CurrentDay);
28
+ return _react.default.createElement(_react.default.Fragment, null, size && _react.default.createElement("div", {
29
+ "data-testid": "currency-power-balance-wrapper",
30
+ className: "lw-flex lw-flex-col lw-text-sm lw-tracking-normal"
31
+ }, timeUnit && currencies ? _react.default.createElement(_react.default.Fragment, null, _config.timeUnitConfig.filter(_ref2 => {
32
+ let {
33
+ value
34
+ } = _ref2;
35
+ return value === selectedTimeUnit;
36
+ }).map(_ref3 => {
37
+ let {
38
+ tooltipLabel,
39
+ label
40
+ } = _ref3;
41
+ return _react.default.createElement("div", {
42
+ "data-testid": "time-unit-label",
43
+ key: label,
44
+ className: "lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold"
45
+ }, tooltipLabel ? _react.default.createElement("span", null, "".concat(lang(tooltipLabel.translationKey, {
46
+ count: tooltipLabel.count
47
+ }))) : _react.default.createElement("span", null, "".concat(lang(label))));
48
+ })) : _react.default.createElement(_TimeUnitSwitch.TimeUnitSwitch, {
49
+ selected: selectedTimeUnit,
50
+ callback: setSelectedTimeUnit,
51
+ options: _config.timeUnitConfig
52
+ }), _react.default.createElement(_ChartWithData.ChartWithData, {
53
+ timeUnit: selectedTimeUnit,
54
+ currencies: timeUnit && currencies
55
+ })));
17
56
  };
18
57
  exports.Main = Main;
19
58
  //# sourceMappingURL=Main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_Tool","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","size","useContext","ThemeContext","createElement","Fragment","Tool","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/Main.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { Tool } from './Tool';\n\nconst Main = () => {\n const { size } = useContext(ThemeContext);\n return (\n <>\n {size && <Tool />}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAA8B,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,C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
+ {"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_monoI18n","_graphql","_TimeUnitSwitch","_config","_ChartWithData","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","timeUnit","currencies","size","useContext","ThemeContext","lang","useLocale","selectedTimeUnit","setSelectedTimeUnit","useState","CurrencyPowerBalanceTimeUnit","CurrentDay","createElement","Fragment","className","timeUnitConfig","filter","_ref2","value","map","_ref3","tooltipLabel","label","key","concat","translationKey","count","TimeUnitSwitch","selected","callback","options","ChartWithData","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/Main.tsx"],"sourcesContent":["import React, { useContext, useState } from 'react';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\nimport { TimeUnitSwitch } from './components/TimeUnitSwitch';\nimport { timeUnitConfig } from './config';\nimport { ChartWithData } from './ChartWithData';\nimport { MainProps } from './types';\n\nconst Main = ({ timeUnit, currencies }: MainProps) => {\n const { size } = useContext(ThemeContext);\n const { lang } = useLocale();\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(\n timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay,\n );\n return (\n <>\n {size && (\n <div\n data-testid=\"currency-power-balance-wrapper\"\n className=\"lw-flex lw-flex-col lw-text-sm lw-tracking-normal\"\n >\n {timeUnit && currencies ? (\n <>\n {timeUnitConfig\n .filter(({ value }) => value === selectedTimeUnit)\n .map(({ tooltipLabel, label }) => (\n <div data-testid=\"time-unit-label\" key={label} className=\"lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold\">\n {tooltipLabel ? <span>{`${lang(tooltipLabel!.translationKey, { count: tooltipLabel!.count })}`}</span> : <span>{`${lang(label)}`}</span>}\n </div>\n ))}\n </>\n ) : (\n <TimeUnitSwitch\n selected={selectedTimeUnit}\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n />\n )}\n <ChartWithData\n timeUnit={selectedTimeUnit}\n currencies={timeUnit && currencies}\n />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAAgD,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAA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R,SAAS,EAAC;IAAwE,GAC9HO,YAAY,GAAGpD,MAAA,CAAAe,OAAA,CAAA4B,aAAA,kBAAAY,MAAA,CAAUnB,IAAI,CAACgB,YAAY,CAAEI,cAAc,EAAE;MAAEC,KAAK,EAAEL,YAAY,CAAEK;IAAM,CAAC,CAAC,CAAS,CAAC,GAAGzD,MAAA,CAAAe,OAAA,CAAA4B,aAAA,kBAAAY,MAAA,CAAUnB,IAAI,CAACiB,KAAK,CAAC,CAAS,CACpI,CAAC;EAAA,CACP,CACH,CAAC,GAEHrD,MAAA,CAAAe,OAAA,CAAA4B,aAAA,CAACrC,eAAA,CAAAoD,cAAc;IACbC,QAAQ,EAAErB,gBAAiB;IAC3BsB,QAAQ,EAAErB,mBAAoB;IAC9BsB,OAAO,EAAEf;EAAe,CACzB,CACF,EACD9C,MAAA,CAAAe,OAAA,CAAA4B,aAAA,CAACnC,cAAA,CAAAsD,aAAa;IACZ/B,QAAQ,EAAEO,gBAAiB;IAC3BN,UAAU,EAAED,QAAQ,IAAIC;EAAW,CACpC,CACE,CAEP,CAAC;AAEP,CAAC;AAAC+B,OAAA,CAAAlC,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -22,7 +22,8 @@ echarts.registerTheme('light_theme', (0, _labsWidgetCommon.getChartTheme)(_labsW
22
22
  const Chart = _ref => {
23
23
  let {
24
24
  values,
25
- timeUnit
25
+ timeUnit,
26
+ currencies
26
27
  } = _ref;
27
28
  const {
28
29
  isDark,
@@ -31,6 +32,12 @@ const Chart = _ref => {
31
32
  const isDesktop = size === _labsWidgetCommon.Size.DESKTOP;
32
33
  const isMobile = size === _labsWidgetCommon.Size.MOBILE;
33
34
  const echartRef = (0, _react.useRef)(null);
35
+ const chartData = currencies ? values.filter(_ref2 => {
36
+ let {
37
+ currency
38
+ } = _ref2;
39
+ return currencies.includes(currency);
40
+ }) : values;
34
41
  (0, _react.useEffect)(() => {
35
42
  if (echartRef.current) {
36
43
  const echartInstance = echartRef.current.getEchartsInstance();
@@ -45,7 +52,7 @@ const Chart = _ref => {
45
52
  height: "".concat(_constants.CHART_HEIGHT, "px"),
46
53
  width: '100%'
47
54
  },
48
- option: (0, _options.getOption)(values, timeUnit, isDark)
55
+ option: (0, _options.getOption)(chartData, timeUnit, isDark)
49
56
  });
50
57
  };
51
58
  exports.Chart = Chart;
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.js","names":["_react","_interopRequireWildcard","require","_core","_interopRequireDefault","echarts","_charts","_renderers","_components","_labsWidgetCommon","_constants","_options","obj","__esModule","default","_getRequireWildcardCache","e","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","isDark","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","isMobile","MOBILE","echartRef","useRef","useEffect","current","echartInstance","getEchartsInstance","setOption","getResponsiveOption","createElement","ref","theme","style","height","concat","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 }: 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 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(values, 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,UAAA,GAAAR,OAAA;AAGA,IAAAS,QAAA,GAAAT,OAAA;AAA2D,SAAAE,uBAAAQ,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAf,wBAAAe,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH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A;EAC7C,MAAM;IAAEG,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,iBAAU,EAACC,8BAAY,CAAC;EACjD,MAAMC,SAAS,GAAGH,IAAI,KAAKI,sBAAI,CAACC,OAAO;EACvC,MAAMC,QAAQ,GAAGN,IAAI,KAAKI,sBAAI,CAACG,MAAM;EAErC,MAAMC,SAAS,GAAG,IAAAC,aAAM,EAAC,IAAI,CAAC;EAE9B,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIF,SAAS,CAACG,OAAO,EAAE;MAErB,MAAMC,cAAc,GAAGJ,SAAS,CAACG,OAAO,CAACE,kBAAkB,CAAC,CAAwB;MAEpFD,cAAc,CAACE,SAAS,CACtB,IAAAC,4BAAmB,EAACZ,SAAS,EAAEG,QAAQ,EAAEP,MAAM,CACjD,CAAC;IACH;EACF,CAAC,EAAE,CAACS,SAAS,EAAEL,SAAS,EAAEG,QAAQ,EAAEP,MAAM,CAAC,CAAC;EAE5C,OACEjD,MAAA,CAAAc,OAAA,CAAAoD,aAAA,CAAC/D,KAAA,CAAAW,OAAgB;IACfT,OAAO,EAAEA,OAAQ;IACjB8D,GAAG,EAAET,SAAU;IACfU,KAAK,EAAEnB,MAAM,GAAG,YAAY,GAAG,aAAc;IAC7CoB,KAAK,EAAE;MACLC,MAAM,KAAAC,MAAA,CAAKC,uBAAY,OAAI;MAC3BC,KAAK,EAAE;IACT,CAAE;IACFC,MAAM,EAAE,IAAAC,kBAAS,EAAC5B,MAAM,EAAEC,QAAQ,EAAEC,MAAM;EAAE,CAC7C,CAAC;AAEN,CAAC;AAAC2B,OAAA,CAAA/B,KAAA,GAAAA,KAAA","ignoreList":[]}
1
+ {"version":3,"file":"Chart.js","names":["_react","_interopRequireWildcard","require","_core","_interopRequireDefault","echarts","_charts","_renderers","_components","_labsWidgetCommon","_constants","_options","obj","__esModule","default","_getRequireWildcardCache","e","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","concat","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,UAAA,GAAAR,OAAA;AAGA,IAAAS,QAAA,GAAAT,OAAA;AAA2D,SAAAE,uBAAAQ,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAf,wBAAAe,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CAAA,OAAAM,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,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MAAM,CAACC,KAAA;IAAA,IAAC;MAAEC;IAAS,CAAC,GAAAD,KAAA;IAAA,OAAKd,UAAU,CAACgB,QAAQ,CAACD,QAAQ,CAAC;EAAA,EAAC,GAC9DjB,MAAM;EAEV,IAAAmB,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,OACElD,MAAA,CAAAc,OAAA,CAAA0D,aAAA,CAACrE,KAAA,CAAAW,OAAgB;IACfT,OAAO,EAAEA,OAAQ;IACjBoE,GAAG,EAAEd,SAAU;IACfe,KAAK,EAAExB,MAAM,GAAG,YAAY,GAAG,aAAc;IAC7CyB,KAAK,EAAE;MACLC,MAAM,KAAAC,MAAA,CAAKC,uBAAY,OAAI;MAC3BC,KAAK,EAAE;IACT,CAAE;IACFC,MAAM,EAAE,IAAAC,kBAAS,EAACpB,SAAS,EAAEb,QAAQ,EAAEE,MAAM;EAAE,CAChD,CAAC;AAEN,CAAC;AAACgC,OAAA,CAAArC,KAAA,GAAAA,KAAA","ignoreList":[]}
@@ -3,8 +3,9 @@
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.COLOR_CONFIG = exports.CHART_WIDTH = exports.CHART_HEIGHT = exports.CANDLE_NUMBER_HOUR = exports.CANDLE_MINUTE = void 0;
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.CURENCIES_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
+ var _graphql = require("../../../../gql/types/graphql");
8
9
  const X_LABEL_SIZE = exports.X_LABEL_SIZE = 90;
9
10
  const X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE_MOBILE = 110;
10
11
  const Y_LABEL_SIZE_MOBILE = exports.Y_LABEL_SIZE_MOBILE = 35;
@@ -16,6 +17,7 @@ const LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT_MOBILE = 70;
16
17
  const VERTICAL_LINE_COUNT = exports.VERTICAL_LINE_COUNT = 10;
17
18
  const CANDLE_NUMBER_HOUR = exports.CANDLE_NUMBER_HOUR = 12;
18
19
  const CANDLE_MINUTE = exports.CANDLE_MINUTE = 5;
20
+ const CURENCIES_ORDER = exports.CURENCIES_ORDER = [_graphql.CurrencyName.Usd, _graphql.CurrencyName.Eur, _graphql.CurrencyName.Gbp, _graphql.CurrencyName.Jpy, _graphql.CurrencyName.Chf, _graphql.CurrencyName.Aud, _graphql.CurrencyName.Cad, _graphql.CurrencyName.Nzd];
19
21
  const COLOR_CONFIG = exports.COLOR_CONFIG = {
20
22
  USD: _labsWidgetCommon.colorPalette.greenLight,
21
23
  EUR: _labsWidgetCommon.colorPalette.turquoiseLight,