@oanda/labs-currency-power-balance-widget 1.0.29 → 1.0.31

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 (26) hide show
  1. package/CHANGELOG.md +252 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -1
  3. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +24 -2
  5. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +3 -2
  7. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +1 -1
  9. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
  10. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -1
  11. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  12. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +22 -2
  13. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  14. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +5 -4
  15. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  16. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +1 -1
  17. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
  18. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +3 -1
  19. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +3 -1
  20. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +3 -2
  21. package/package.json +3 -3
  22. package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx +4 -0
  23. package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +37 -1
  24. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +5 -4
  25. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts +1 -1
  26. package/test/chartFormatters.test.ts +10 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,258 @@
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.31 (2024-02-28)
7
+
8
+
9
+
10
+ ## 1.0.91 (2024-02-23)
11
+
12
+
13
+
14
+ ## 1.0.90 (2024-02-23)
15
+
16
+
17
+
18
+ ## 1.0.89 (2024-02-21)
19
+
20
+
21
+
22
+ ## 1.0.88 (2024-02-21)
23
+
24
+
25
+
26
+ ## 1.0.87 (2024-02-20)
27
+
28
+
29
+
30
+ ## 1.0.86 (2024-02-20)
31
+
32
+
33
+
34
+ ## 1.0.85 (2024-02-13)
35
+
36
+
37
+
38
+ ## 1.0.84 (2024-02-13)
39
+
40
+
41
+
42
+ ## 1.0.83 (2024-02-09)
43
+
44
+
45
+
46
+ ## 1.0.82 (2024-02-05)
47
+
48
+
49
+
50
+ ## 1.0.81 (2024-02-05)
51
+
52
+
53
+
54
+ ## 1.0.80 (2024-02-05)
55
+
56
+
57
+
58
+ ## 1.0.79 (2024-02-05)
59
+
60
+
61
+
62
+ ## 1.0.78 (2024-01-30)
63
+
64
+
65
+
66
+ ## 1.0.77 (2024-01-25)
67
+
68
+
69
+
70
+ ## 1.0.76 (2024-01-25)
71
+
72
+
73
+
74
+ ## 1.0.75 (2024-01-22)
75
+
76
+
77
+
78
+ ## 1.0.74 (2024-01-22)
79
+
80
+
81
+
82
+ ## 1.0.73 (2024-01-22)
83
+
84
+
85
+
86
+ ## 1.0.72 (2024-01-19)
87
+
88
+
89
+
90
+ ## 1.0.71 (2024-01-18)
91
+
92
+
93
+
94
+ ## 1.0.70 (2024-01-17)
95
+
96
+
97
+
98
+ ## 1.0.69 (2024-01-17)
99
+
100
+
101
+
102
+ ## 1.0.68 (2024-01-15)
103
+
104
+
105
+
106
+ ## 1.0.67 (2024-01-15)
107
+
108
+
109
+
110
+ ## 1.0.66 (2024-01-12)
111
+
112
+
113
+
114
+ ## 1.0.65 (2024-01-11)
115
+
116
+
117
+
118
+ ## 1.0.64 (2024-01-11)
119
+
120
+
121
+
122
+ ## 1.0.63 (2024-01-11)
123
+
124
+
125
+
126
+ ## 1.0.62 (2024-01-10)
127
+
128
+ **Note:** Version bump only for package @oanda/labs-currency-power-balance-widget
129
+
130
+
131
+
132
+
133
+
134
+ ## 1.0.30 (2024-02-23)
135
+
136
+
137
+
138
+ ## 1.0.90 (2024-02-23)
139
+
140
+
141
+
142
+ ## 1.0.89 (2024-02-21)
143
+
144
+
145
+
146
+ ## 1.0.88 (2024-02-21)
147
+
148
+
149
+
150
+ ## 1.0.87 (2024-02-20)
151
+
152
+
153
+
154
+ ## 1.0.86 (2024-02-20)
155
+
156
+
157
+
158
+ ## 1.0.85 (2024-02-13)
159
+
160
+
161
+
162
+ ## 1.0.84 (2024-02-13)
163
+
164
+
165
+
166
+ ## 1.0.83 (2024-02-09)
167
+
168
+
169
+
170
+ ## 1.0.82 (2024-02-05)
171
+
172
+
173
+
174
+ ## 1.0.81 (2024-02-05)
175
+
176
+
177
+
178
+ ## 1.0.80 (2024-02-05)
179
+
180
+
181
+
182
+ ## 1.0.79 (2024-02-05)
183
+
184
+
185
+
186
+ ## 1.0.78 (2024-01-30)
187
+
188
+
189
+
190
+ ## 1.0.77 (2024-01-25)
191
+
192
+
193
+
194
+ ## 1.0.76 (2024-01-25)
195
+
196
+
197
+
198
+ ## 1.0.75 (2024-01-22)
199
+
200
+
201
+
202
+ ## 1.0.74 (2024-01-22)
203
+
204
+
205
+
206
+ ## 1.0.73 (2024-01-22)
207
+
208
+
209
+
210
+ ## 1.0.72 (2024-01-19)
211
+
212
+
213
+
214
+ ## 1.0.71 (2024-01-18)
215
+
216
+
217
+
218
+ ## 1.0.70 (2024-01-17)
219
+
220
+
221
+
222
+ ## 1.0.69 (2024-01-17)
223
+
224
+
225
+
226
+ ## 1.0.68 (2024-01-15)
227
+
228
+
229
+
230
+ ## 1.0.67 (2024-01-15)
231
+
232
+
233
+
234
+ ## 1.0.66 (2024-01-12)
235
+
236
+
237
+
238
+ ## 1.0.65 (2024-01-11)
239
+
240
+
241
+
242
+ ## 1.0.64 (2024-01-11)
243
+
244
+
245
+
246
+ ## 1.0.63 (2024-01-11)
247
+
248
+
249
+
250
+ ## 1.0.62 (2024-01-10)
251
+
252
+ **Note:** Version bump only for package @oanda/labs-currency-power-balance-widget
253
+
254
+
255
+
256
+
257
+
6
258
  ## 1.0.29 (2024-02-23)
7
259
 
8
260
 
@@ -3,7 +3,7 @@
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 = 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.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
  const X_LABEL_SIZE = exports.X_LABEL_SIZE = 90;
9
9
  const X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE_MOBILE = 110;
@@ -14,6 +14,8 @@ const CHART_HEIGHT = exports.CHART_HEIGHT = 425;
14
14
  const LEGEND_HEIGHT = exports.LEGEND_HEIGHT = 50;
15
15
  const LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT_MOBILE = 70;
16
16
  const VERTICAL_LINE_COUNT = exports.VERTICAL_LINE_COUNT = 10;
17
+ const CANDLE_NUMBER_HOUR = exports.CANDLE_NUMBER_HOUR = 12;
18
+ const CANDLE_MINUTE = exports.CANDLE_MINUTE = 5;
17
19
  const COLOR_CONFIG = exports.COLOR_CONFIG = {
18
20
  USD: _labsWidgetCommon.colorPalette.greenLight,
19
21
  EUR: _labsWidgetCommon.colorPalette.turquoiseLight,
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","X_LABEL_SIZE","exports","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","VERTICAL_LINE_COUNT","COLOR_CONFIG","USD","colorPalette","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreen75Lighter","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\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;\n\nconst COLOR_CONFIG: Record<string, string> = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreen75Lighter,\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};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,EAAE;AACvB,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG,EAAE;AAC9B,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAAJ,OAAA,CAAAI,WAAA,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAAL,OAAA,CAAAK,YAAA,GAAG,GAAG;AACxB,MAAMC,aAAa,GAAAN,OAAA,CAAAM,aAAA,GAAG,EAAE;AACxB,MAAMC,oBAAoB,GAAAP,OAAA,CAAAO,oBAAA,GAAG,EAAE;AAC/B,MAAMC,mBAAmB,GAAAR,OAAA,CAAAQ,mBAAA,GAAG,EAAE;AAE9B,MAAMC,YAAoC,GAAAT,OAAA,CAAAS,YAAA,GAAG;EAC3CC,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,oBAAoB;EACtCC,GAAG,EAAEV,8BAAY,CAACW,MAAM;EACxBC,GAAG,EAAEZ,8BAAY,CAACa,iBAAiB;EACnCC,GAAG,EAAEd,8BAAY,CAACe;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAA3B,OAAA,CAAA2B,yBAAA,GAAG;EAChCC,IAAI,EAAEjB,8BAAY,CAACW,MAAM;EACzBO,KAAK,EAAElB,8BAAY,CAACmB;AACtB,CAAC"}
1
+ {"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","X_LABEL_SIZE","exports","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","COLOR_CONFIG","USD","colorPalette","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreen75Lighter","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\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 COLOR_CONFIG: Record<string, string> = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreen75Lighter,\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};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,EAAE;AACvB,MAAME,mBAAmB,GAAAD,OAAA,CAAAC,mBAAA,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG,EAAE;AAC9B,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAAJ,OAAA,CAAAI,WAAA,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAAL,OAAA,CAAAK,YAAA,GAAG,GAAG;AACxB,MAAMC,aAAa,GAAAN,OAAA,CAAAM,aAAA,GAAG,EAAE;AACxB,MAAMC,oBAAoB,GAAAP,OAAA,CAAAO,oBAAA,GAAG,EAAE;AAC/B,MAAMC,mBAAmB,GAAAR,OAAA,CAAAQ,mBAAA,GAAG,EAAE;AAC9B,MAAMC,kBAAkB,GAAAT,OAAA,CAAAS,kBAAA,GAAG,EAAE;AAC7B,MAAMC,aAAa,GAAAV,OAAA,CAAAU,aAAA,GAAG,CAAC;AAEvB,MAAMC,YAAoC,GAAAX,OAAA,CAAAW,YAAA,GAAG;EAC3CC,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,oBAAoB;EACtCC,GAAG,EAAEV,8BAAY,CAACW,MAAM;EACxBC,GAAG,EAAEZ,8BAAY,CAACa,iBAAiB;EACnCC,GAAG,EAAEd,8BAAY,CAACe;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAA7B,OAAA,CAAA6B,yBAAA,GAAG;EAChCC,IAAI,EAAEjB,8BAAY,CAACW,MAAM;EACzBO,KAAK,EAAElB,8BAAY,CAACmB;AACtB,CAAC"}
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.xAxisLabelFormatter = exports.tooltipFormatter = void 0;
6
+ exports.xAxisLabelFormatter = exports.tooltipFormatter = exports.isMonthWeek = exports.intervalFormatter = void 0;
7
+ var _graphql = require("../../../../gql/types/graphql");
8
+ var _constants = require("./constants");
7
9
  const getDateAndTime = param => {
8
10
  const dateAndTime = param.split('T');
9
11
  return {
@@ -26,15 +28,35 @@ const dateTimeFormat = _ref => {
26
28
  day: 'numeric'
27
29
  }), ", ").concat(time, " UTC");
28
30
  };
31
+ const isMonthWeek = timeUnit => timeUnit === _graphql.CurrencyPowerBalanceTimeUnit.M3 || timeUnit === _graphql.CurrencyPowerBalanceTimeUnit.M1 || timeUnit === _graphql.CurrencyPowerBalanceTimeUnit.W1;
32
+ exports.isMonthWeek = isMonthWeek;
29
33
  const xAxisLabelFormatter = (label, timeUnit) => {
30
34
  const {
31
35
  date,
32
36
  time
33
37
  } = getDateAndTime(label);
34
- const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';
38
+ const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';
35
39
  return isDateFormat ? dateFormat(date) : time;
36
40
  };
37
41
  exports.xAxisLabelFormatter = xAxisLabelFormatter;
42
+ const intervalFormatter = (dataLength, timeUnit) => {
43
+ let offset = 0;
44
+ return isMonthWeek(timeUnit) ? Math.round(dataLength / _constants.VERTICAL_LINE_COUNT) : (index, value) => {
45
+ const everyTwoHours = index % 24 === 0 + offset;
46
+ if (timeUnit === _graphql.CurrencyPowerBalanceTimeUnit.H24 && index === 0) {
47
+ offset = _constants.CANDLE_NUMBER_HOUR - new Date(value).getMinutes() / _constants.CANDLE_MINUTE;
48
+ }
49
+ const hoursIntervalConditions = {
50
+ [_graphql.CurrencyPowerBalanceTimeUnit.H4]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),
51
+ [_graphql.CurrencyPowerBalanceTimeUnit.H8]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),
52
+ [_graphql.CurrencyPowerBalanceTimeUnit.H24]: everyTwoHours && value.endsWith(':00:00Z'),
53
+ [_graphql.CurrencyPowerBalanceTimeUnit.PreviousDay]: everyTwoHours,
54
+ [_graphql.CurrencyPowerBalanceTimeUnit.CurrentDay]: value.endsWith(':00:00Z')
55
+ };
56
+ return hoursIntervalConditions[timeUnit];
57
+ };
58
+ };
59
+ exports.intervalFormatter = intervalFormatter;
38
60
  const tooltipFormatter = values => {
39
61
  const date = dateTimeFormat(getDateAndTime(values[0].value[0]));
40
62
  const row = values.sort((_ref2, _ref3) => {
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":["getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","xAxisLabelFormatter","label","timeUnit","isDateFormat","startsWith","exports","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\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 xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\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\nexport {\n tooltipFormatter,\n xAxisLabelFormatter,\n};\n"],"mappings":";;;;;;AAGA,MAAMA,cAAc,GAAIC,KAAa,IAAK;EACxC,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAEpC,OAAO;IACLC,IAAI,EAAEF,WAAW,CAAC,CAAC,CAAC;IACpBG,IAAI,EAAEH,WAAW,CAAC,CAAC,CAAC,CAACI,SAAS,CAAC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AAA,IAAE;MAAEH,KAAK,EAAEM;IAAO,CAAC,GAAAF,KAAA;IAAA,OAAKG,MAAM,CAACD,MAAM,CAAC,CAAC,CAAC,CAAC,GAAGC,MAAM,CAACF,MAAM,CAAC,CAAC,CAAC,CAAC;EAAA,EAAC,CACrFG,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,MAAM;MAAEC,UAAU;MAAEX;IAAM,CAAC,GAAAS,KAAA;IAAA,yJAAA1B,MAAA,CAE7B2B,MAAM,sBAAA3B,MAAA,CACA4B,UAAU,yCAAA5B,MAAA,CAEZiB,KAAK,CAAC,CAAC,CAAC;EAAA,CACX,CAAC;EAEV,uGAAAjB,MAAA,CACqCJ,IAAI,mBAAAI,MAAA,CACrCkB,GAAG,CAACW,IAAI,CAAC,IAAI,CAAC;AAEpB,CAAC;AAACf,OAAA,CAAAC,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"file":"formatters.js","names":["_graphql","require","_constants","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","CurrencyPowerBalanceTimeUnit","M3","M1","W1","exports","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","offset","Math","round","VERTICAL_LINE_COUNT","index","value","everyTwoHours","H24","CANDLE_NUMBER_HOUR","getMinutes","CANDLE_MINUTE","hoursIntervalConditions","H4","endsWith","H8","PreviousDay","CurrentDay","tooltipFormatter","values","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { CANDLE_MINUTE, CANDLE_NUMBER_HOUR, VERTICAL_LINE_COUNT } 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 timeUnit: CurrencyPowerBalanceTimeUnit,\n) => {\n let offset = 0;\n\n return isMonthWeek(timeUnit)\n ? Math.round(dataLength / VERTICAL_LINE_COUNT)\n : (index: number, value: string) => {\n const everyTwoHours = index % 24 === 0 + offset;\n\n if (timeUnit === CurrencyPowerBalanceTimeUnit.H24 && index === 0) {\n offset = CANDLE_NUMBER_HOUR - new Date(value).getMinutes() / CANDLE_MINUTE;\n }\n\n const hoursIntervalConditions: Record<string, boolean> = {\n [CurrencyPowerBalanceTimeUnit.H4]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),\n [CurrencyPowerBalanceTimeUnit.H8]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),\n [CurrencyPowerBalanceTimeUnit.H24]: everyTwoHours && value.endsWith(':00:00Z'),\n [CurrencyPowerBalanceTimeUnit.PreviousDay]: everyTwoHours,\n [CurrencyPowerBalanceTimeUnit.CurrentDay]: value.endsWith(':00:00Z'),\n };\n\n return hoursIntervalConditions[timeUnit];\n };\n};\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\nexport {\n isMonthWeek,\n tooltipFormatter,\n xAxisLabelFormatter,\n intervalFormatter,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGA,MAAME,cAAc,GAAIC,KAAa,IAAK;EACxC,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAEpC,OAAO;IACLC,IAAI,EAAEF,WAAW,CAAC,CAAC,CAAC;IACpBG,IAAI,EAAEH,WAAW,CAAC,CAAC,CAAC,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC;EACrC,CAAC;AACH,CAAC;AAED,MAAMC,UAAU,GAAIH,IAAY,OAAAI,MAAA,CAAQ,IAAIC,IAAI,CAACL,IAAI,CAAC,CAACM,kBAAkB,CAACC,SAAS,EAAE;EAAEC,KAAK,EAAE,SAAS;EAAEC,GAAG,EAAE;AAAU,CAAC,CAAC,CAAE;AAE5H,MAAMC,cAAc,GAAGC,IAAA;EAAA,IAAC;IAAEX,IAAI;IAAEC;EAAqC,CAAC,GAAAU,IAAA;EAAA,UAAAP,MAAA,CAAQ,IAAIC,IAAI,CAACL,IAAI,CAAC,CAACM,kBAAkB,CAACC,SAAS,EAAE;IAAEK,IAAI,EAAE,SAAS;IAAEJ,KAAK,EAAE,SAAS;IAAEC,GAAG,EAAE;EAAU,CAAC,CAAC,QAAAL,MAAA,CAAKH,IAAI;AAAA,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AC;AAEpB,CAAC;AAACpC,OAAA,CAAAuB,gBAAA,GAAAA,gBAAA"}
@@ -69,10 +69,11 @@ const getOption = (values, timeUnit, isDark) => {
69
69
  show: true
70
70
  },
71
71
  axisLabel: {
72
+ padding: [0, 0, 0, 4],
73
+ align: 'left',
72
74
  margin: 10,
73
- showMinLabel: false,
74
75
  rotate: -45,
75
- interval: Math.round(seriesData[0].data.length / _constants.VERTICAL_LINE_COUNT),
76
+ interval: (0, _formatters.intervalFormatter)(seriesData[0].data.length, timeUnit),
76
77
  formatter: label => (0, _formatters.xAxisLabelFormatter)(label, timeUnit)
77
78
  }
78
79
  },
@@ -1 +1 @@
1
- {"version":3,"file":"getOption.js","names":["_constants","require","_formatters","getOption","values","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","COLOR_CONFIG","lineStyle","data","_ref2","point","price","legendData","Object","keys","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","formatter","tooltipFormatter","extraCssText","xAxis","axisTick","show","axisLine","splitLine","axisLabel","margin","showMinLabel","rotate","interval","Math","round","length","VERTICAL_LINE_COUNT","label","xAxisLabelFormatter","yAxis","position","splitNumber","boundaryGap","showMaxLabel","series","exports"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT } from './constants';\nimport { tooltipFormatter, xAxisLabelFormatter } from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n values: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = values.map(({ currency, power }) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n lineStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n }));\n\n const legendData = Object.keys(COLOR_CONFIG).map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n margin: 10,\n showMinLabel: false,\n rotate: -45,\n interval: Math.round(seriesData[0].data.length / VERTICAL_LINE_COUNT),\n formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n splitNumber: 5,\n axisLine: { show: false },\n axisTick: { show: false },\n boundaryGap: ['10%', '10%'],\n axisLabel: {\n showMaxLabel: false,\n showMinLabel: false,\n },\n },\n series: seriesData,\n };\n};\n\nexport { getOption };\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,MAAME,SAAS,GAAGA,CAChBC,MAA8B,EAC9BC,QAAsC,EACtCC,MAAe,KACZ;EACH,MAAMC,UAAU,GAAGH,MAAM,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAF,IAAA;IAAA,OAAM;MACtDG,IAAI,EAAEF,QAAQ;MACdG,IAAI,EAAE,MAAM;MACZC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAE,KAAK;MACjBC,SAAS,EAAE;QACTC,KAAK,EAAEC,uBAAY,CAACR,QAAQ;MAC9B,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U,CAAC,CAAC,CAAC,CAACa,IAAI,CAACkC,MAAM,GAAGC,8BAAmB,CAAC;QACrEhB,SAAS,EAAGiB,KAAa,IAAK,IAAAC,+BAAmB,EAACD,KAAK,EAAEnD,QAAQ;MACnE;IACF,CAAC;IACDqD,KAAK,EAAE;MACL7C,IAAI,EAAE,OAAO;MACb8C,QAAQ,EAAE,OAAO;MACjBC,WAAW,EAAE,CAAC;MACdf,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBD,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAM,CAAC;MACzBiB,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;MAC3Bd,SAAS,EAAE;QACTe,YAAY,EAAE,KAAK;QACnBb,YAAY,EAAE;MAChB;IACF,CAAC;IACDc,MAAM,EAAExD;EACV,CAAC;AACH,CAAC;AAACyD,OAAA,CAAA7D,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"file":"getOption.js","names":["_constants","require","_formatters","getOption","values","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","COLOR_CONFIG","lineStyle","data","_ref2","point","price","legendData","Object","keys","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","formatter","tooltipFormatter","extraCssText","xAxis","axisTick","show","axisLine","splitLine","axisLabel","padding","align","margin","rotate","interval","intervalFormatter","length","label","xAxisLabelFormatter","yAxis","position","splitNumber","boundaryGap","showMaxLabel","showMinLabel","series","exports"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';\nimport { intervalFormatter, tooltipFormatter, xAxisLabelFormatter } from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n values: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = values.map(({ currency, power }) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n lineStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n }));\n\n const legendData = Object.keys(COLOR_CONFIG).map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n padding: [0, 0, 0, 4],\n align: 'left',\n margin: 10,\n rotate: -45,\n interval: intervalFormatter(seriesData[0].data.length, timeUnit),\n formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n splitNumber: 5,\n axisLine: { show: false },\n axisTick: { show: false },\n boundaryGap: ['10%', '10%'],\n axisLabel: {\n showMaxLabel: false,\n showMinLabel: false,\n },\n },\n series: seriesData,\n };\n};\n\nexport { getOption };\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,MAAME,SAAS,GAAGA,CAChBC,MAA8B,EAC9BC,QAAsC,EACtCC,MAAe,KACZ;EACH,MAAMC,UAAU,GAAGH,MAAM,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAF,IAAA;IAAA,OAAM;MACtDG,IA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MACR,CAAC;MACDG,SAAS,EAAE;QACTC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACrBC,KAAK,EAAE,MAAM;QACbC,MAAM,EAAE,EAAE;QACVC,MAAM,EAAE,CAAC,EAAE;QACXC,QAAQ,EAAE,IAAAC,6BAAiB,EAAC9C,UAAU,CAAC,CAAC,CAAC,CAACa,IAAI,CAACkC,MAAM,EAAEjD,QAAQ,CAAC;QAChEkC,SAAS,EAAGgB,KAAa,IAAK,IAAAC,+BAAmB,EAACD,KAAK,EAAElD,QAAQ;MACnE;IACF,CAAC;IACDoD,KAAK,EAAE;MACL5C,IAAI,EAAE,OAAO;MACb6C,QAAQ,EAAE,OAAO;MACjBC,WAAW,EAAE,CAAC;MACdd,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBD,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAM,CAAC;MACzBgB,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;MAC3Bb,SAAS,EAAE;QACTc,YAAY,EAAE,KAAK;QACnBC,YAAY,EAAE;MAChB;IACF,CAAC;IACDC,MAAM,EAAExD;EACV,CAAC;AACH,CAAC;AAACyD,OAAA,CAAA7D,SAAA,GAAAA,SAAA"}
@@ -13,7 +13,7 @@ const getResponsiveOption = (isDesktop, isMobile, isDark) => {
13
13
  chartHeight: _constants.CHART_HEIGHT,
14
14
  xLabelsSize: isMobile ? _constants.X_LABEL_SIZE_MOBILE : _constants.X_LABEL_SIZE,
15
15
  yLabelSize: isMobile ? _constants.Y_LABEL_SIZE_MOBILE : _constants.Y_LABEL_SIZE,
16
- bottomLeftBox: isDesktop,
16
+ bottomLeftBox: false,
17
17
  marginBottom: isMobile ? _constants.LEGEND_HEIGHT_MOBILE : _constants.LEGEND_HEIGHT
18
18
  });
19
19
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"getResponsiveOption.js","names":["_labsWidgetCommon","require","_constants","getResponsiveOption","isDesktop","isMobile","isDark","baseGridLines","getGridLines","chartWidth","CHART_WIDTH","chartHeight","CHART_HEIGHT","xLabelsSize","X_LABEL_SIZE_MOBILE","X_LABEL_SIZE","yLabelSize","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","bottomLeftBox","marginBottom","LEGEND_HEIGHT_MOBILE","LEGEND_HEIGHT","yAxis","axisLabel","margin","grid","name","top","left","right","concat","bottom","graphic","exports"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n Y_LABEL_SIZE_MOBILE,\n} from './constants';\n\nconst getResponsiveOption = (isDesktop: boolean, isMobile: boolean, isDark: boolean) => {\n const baseGridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE,\n yLabelSize: isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE,\n bottomLeftBox: isDesktop,\n marginBottom: isMobile ? LEGEND_HEIGHT_MOBILE : LEGEND_HEIGHT,\n });\n\n return {\n yAxis: {\n axisLabel: {\n margin: isDesktop ? 8 : 6,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '0px',\n left: '0px',\n right: `${isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE}px`,\n bottom: `${isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...baseGridLines,\n ],\n };\n};\n\nexport { getResponsiveOption };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAWA,MAAME,mBAAmB,GAAGA,CAACC,SAAkB,EAAEC,QAAiB,EAAEC,MAAe,KAAK;EACtF,MAAMC,aAAa,GAAG,IAAAC,8BAAY,EAAC;IACjCF,MAAM;IACNG,UAAU,EAAEC,sBAAW;IACvBC,WAAW,EAAEC,uBAAY;IACzBC,WAAW,EAAER,QAAQ,GAAGS,8BAAmB,GAAGC,uBAAY;IAC1DC,UAAU,EAAEX,QAAQ,GAAGY,8BAAmB,GAAGC,uBAAY;IACzDC,aAAa,EAAEf,SAAS;IACxBgB,YAAY,EAAEf,QAAQ,GAAGgB,+BAAoB,GAAGC;EAClD,CAAC,CAAC;EAEF,OAAO;IACLC,KAAK,EAAE;MACLC,SAAS,EAAE;QACTC,MAAM,EAAErB,SAAS,GAAG,CAAC,GAAG;MAC1B;IACF,CAAC;IACDsB,IAAI,EAAE,CACJ;MACEC,IAAI,EAAE,WAAW;MACjBC,GAAG,EAAE,KAAK;MACVC,IAAI,EAAE,KAAK;MACXC,KAAK,KAAAC,MAAA,CAAK1B,QAAQ,GAAGY,8BAAmB,GAAGC,uBAAY,OAAI;MAC3Dc,MAAM,KAAAD,MAAA,CAAK1B,QAAQ,GAAGS,8BAAmB,GAAGC,uBAAY;IAC1D,CAAC,CACF;IACDkB,OAAO,EAAE,CACP,GAAG1B,aAAa;EAEpB,CAAC;AACH,CAAC;AAAC2B,OAAA,CAAA/B,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"file":"getResponsiveOption.js","names":["_labsWidgetCommon","require","_constants","getResponsiveOption","isDesktop","isMobile","isDark","baseGridLines","getGridLines","chartWidth","CHART_WIDTH","chartHeight","CHART_HEIGHT","xLabelsSize","X_LABEL_SIZE_MOBILE","X_LABEL_SIZE","yLabelSize","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","bottomLeftBox","marginBottom","LEGEND_HEIGHT_MOBILE","LEGEND_HEIGHT","yAxis","axisLabel","margin","grid","name","top","left","right","concat","bottom","graphic","exports"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n Y_LABEL_SIZE_MOBILE,\n} from './constants';\n\nconst getResponsiveOption = (isDesktop: boolean, isMobile: boolean, isDark: boolean) => {\n const baseGridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE,\n yLabelSize: isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE,\n bottomLeftBox: false,\n marginBottom: isMobile ? LEGEND_HEIGHT_MOBILE : LEGEND_HEIGHT,\n });\n\n return {\n yAxis: {\n axisLabel: {\n margin: isDesktop ? 8 : 6,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '0px',\n left: '0px',\n right: `${isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE}px`,\n bottom: `${isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...baseGridLines,\n ],\n };\n};\n\nexport { getResponsiveOption };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAWA,MAAME,mBAAmB,GAAGA,CAACC,SAAkB,EAAEC,QAAiB,EAAEC,MAAe,KAAK;EACtF,MAAMC,aAAa,GAAG,IAAAC,8BAAY,EAAC;IACjCF,MAAM;IACNG,UAAU,EAAEC,sBAAW;IACvBC,WAAW,EAAEC,uBAAY;IACzBC,WAAW,EAAER,QAAQ,GAAGS,8BAAmB,GAAGC,uBAAY;IAC1DC,UAAU,EAAEX,QAAQ,GAAGY,8BAAmB,GAAGC,uBAAY;IACzDC,aAAa,EAAE,KAAK;IACpBC,YAAY,EAAEf,QAAQ,GAAGgB,+BAAoB,GAAGC;EAClD,CAAC,CAAC;EAEF,OAAO;IACLC,KAAK,EAAE;MACLC,SAAS,EAAE;QACTC,MAAM,EAAErB,SAAS,GAAG,CAAC,GAAG;MAC1B;IACF,CAAC;IACDsB,IAAI,EAAE,CACJ;MACEC,IAAI,EAAE,WAAW;MACjBC,GAAG,EAAE,KAAK;MACVC,IAAI,EAAE,KAAK;MACXC,KAAK,KAAAC,MAAA,CAAK1B,QAAQ,GAAGY,8BAAmB,GAAGC,uBAAY,OAAI;MAC3Dc,MAAM,KAAAD,MAAA,CAAK1B,QAAQ,GAAGS,8BAAmB,GAAGC,uBAAY;IAC1D,CAAC,CACF;IACDkB,OAAO,EAAE,CACP,GAAG1B,aAAa;EAEpB,CAAC;AACH,CAAC;AAAC2B,OAAA,CAAA/B,mBAAA,GAAAA,mBAAA"}
@@ -8,6 +8,8 @@ const CHART_HEIGHT = 425;
8
8
  const LEGEND_HEIGHT = 50;
9
9
  const LEGEND_HEIGHT_MOBILE = 70;
10
10
  const VERTICAL_LINE_COUNT = 10;
11
+ const CANDLE_NUMBER_HOUR = 12;
12
+ const CANDLE_MINUTE = 5;
11
13
  const COLOR_CONFIG = {
12
14
  USD: colorPalette.greenLight,
13
15
  EUR: colorPalette.turquoiseLight,
@@ -22,5 +24,5 @@ const TOOLTIP_LINE_COLOR_CONFIG = {
22
24
  DARK: colorPalette.orange,
23
25
  LIGHT: colorPalette.bottleGreenDark
24
26
  };
25
- export { 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, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG };
27
+ export { 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, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, CANDLE_NUMBER_HOUR, CANDLE_MINUTE };
26
28
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["colorPalette","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","COLOR_CONFIG","USD","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreen75Lighter","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\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;\n\nconst COLOR_CONFIG: Record<string, string> = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreen75Lighter,\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};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAExD,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,mBAAmB,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAG,GAAG;AACxB,MAAMC,aAAa,GAAG,EAAE;AACxB,MAAMC,oBAAoB,GAAG,EAAE;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAE9B,MAAMC,YAAoC,GAAG;EAC3CC,GAAG,EAAEX,YAAY,CAACY,UAAU;EAC5BC,GAAG,EAAEb,YAAY,CAACc,cAAc;EAChCC,GAAG,EAAEf,YAAY,CAACgB,WAAW;EAC7BC,GAAG,EAAEjB,YAAY,CAACkB,cAAc;EAChCC,GAAG,EAAEnB,YAAY,CAACoB,oBAAoB;EACtCC,GAAG,EAAErB,YAAY,CAACsB,MAAM;EACxBC,GAAG,EAAEvB,YAAY,CAACwB,iBAAiB;EACnCC,GAAG,EAAEzB,YAAY,CAAC0B;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAG;EAChCC,IAAI,EAAE5B,YAAY,CAACsB,MAAM;EACzBO,KAAK,EAAE7B,YAAY,CAAC8B;AACtB,CAAC;AAED,SACE7B,YAAY,EACZC,mBAAmB,EACnBC,mBAAmB,EACnBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB,EACnBC,YAAY,EACZiB,yBAAyB"}
1
+ {"version":3,"file":"constants.js","names":["colorPalette","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","COLOR_CONFIG","USD","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreen75Lighter","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\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 COLOR_CONFIG: Record<string, string> = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreen75Lighter,\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};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAExD,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,mBAAmB,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAG,GAAG;AACxB,MAAMC,aAAa,GAAG,EAAE;AACxB,MAAMC,oBAAoB,GAAG,EAAE;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,aAAa,GAAG,CAAC;AAEvB,MAAMC,YAAoC,GAAG;EAC3CC,GAAG,EAAEb,YAAY,CAACc,UAAU;EAC5BC,GAAG,EAAEf,YAAY,CAACgB,cAAc;EAChCC,GAAG,EAAEjB,YAAY,CAACkB,WAAW;EAC7BC,GAAG,EAAEnB,YAAY,CAACoB,cAAc;EAChCC,GAAG,EAAErB,YAAY,CAACsB,oBAAoB;EACtCC,GAAG,EAAEvB,YAAY,CAACwB,MAAM;EACxBC,GAAG,EAAEzB,YAAY,CAAC0B,iBAAiB;EACnCC,GAAG,EAAE3B,YAAY,CAAC4B;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAG;EAChCC,IAAI,EAAE9B,YAAY,CAACwB,MAAM;EACzBO,KAAK,EAAE/B,YAAY,CAACgC;AACtB,CAAC;AAED,SACE/B,YAAY,EACZC,mBAAmB,EACnBC,mBAAmB,EACnBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB,EACnBG,YAAY,EACZiB,yBAAyB,EACzBnB,kBAAkB,EAClBC,aAAa"}
@@ -1,3 +1,5 @@
1
+ import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
+ import { CANDLE_MINUTE, CANDLE_NUMBER_HOUR, VERTICAL_LINE_COUNT } from './constants';
1
3
  const getDateAndTime = param => {
2
4
  const dateAndTime = param.split('T');
3
5
  return {
@@ -20,14 +22,32 @@ const dateTimeFormat = _ref => {
20
22
  day: 'numeric'
21
23
  }), ", ").concat(time, " UTC");
22
24
  };
25
+ const isMonthWeek = timeUnit => timeUnit === CurrencyPowerBalanceTimeUnit.M3 || timeUnit === CurrencyPowerBalanceTimeUnit.M1 || timeUnit === CurrencyPowerBalanceTimeUnit.W1;
23
26
  const xAxisLabelFormatter = (label, timeUnit) => {
24
27
  const {
25
28
  date,
26
29
  time
27
30
  } = getDateAndTime(label);
28
- const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';
31
+ const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';
29
32
  return isDateFormat ? dateFormat(date) : time;
30
33
  };
34
+ const intervalFormatter = (dataLength, timeUnit) => {
35
+ let offset = 0;
36
+ return isMonthWeek(timeUnit) ? Math.round(dataLength / VERTICAL_LINE_COUNT) : (index, value) => {
37
+ const everyTwoHours = index % 24 === 0 + offset;
38
+ if (timeUnit === CurrencyPowerBalanceTimeUnit.H24 && index === 0) {
39
+ offset = CANDLE_NUMBER_HOUR - new Date(value).getMinutes() / CANDLE_MINUTE;
40
+ }
41
+ const hoursIntervalConditions = {
42
+ [CurrencyPowerBalanceTimeUnit.H4]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),
43
+ [CurrencyPowerBalanceTimeUnit.H8]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),
44
+ [CurrencyPowerBalanceTimeUnit.H24]: everyTwoHours && value.endsWith(':00:00Z'),
45
+ [CurrencyPowerBalanceTimeUnit.PreviousDay]: everyTwoHours,
46
+ [CurrencyPowerBalanceTimeUnit.CurrentDay]: value.endsWith(':00:00Z')
47
+ };
48
+ return hoursIntervalConditions[timeUnit];
49
+ };
50
+ };
31
51
  const tooltipFormatter = values => {
32
52
  const date = dateTimeFormat(getDateAndTime(values[0].value[0]));
33
53
  const row = values.sort((_ref2, _ref3) => {
@@ -48,5 +68,5 @@ const tooltipFormatter = values => {
48
68
  });
49
69
  return "<div style=\"display:flex; flex-direction:column;\">\n <span style=\"margin-bottom:5px;\">".concat(date, "</span>\n ").concat(row.join('\n'), "\n </div>");
50
70
  };
51
- export { tooltipFormatter, xAxisLabelFormatter };
71
+ export { isMonthWeek, tooltipFormatter, xAxisLabelFormatter, intervalFormatter };
52
72
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":["getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","xAxisLabelFormatter","label","timeUnit","isDateFormat","startsWith","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\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 xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\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\nexport {\n tooltipFormatter,\n xAxisLabelFormatter,\n};\n"],"mappings":"AAGA,MAAMA,cAAc,GAAIC,KAAa,IAAK;EACxC,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAEpC,OAAO;IACLC,IAAI,EAAEF,WAAW,CAAC,CAAC,CAAC;IACpBG,IAAI,EAAEH,WAAW,CAAC,CAAC,CAAC,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC;EACrC,CAAC;AACH,CAAC;AAED,MAAMC,UAAU,GAAIH,IAAY,OAAAI,MAAA,CAAQ,IAAIC,IAAI,CAACL,IAAI,CAAC,CAACM,kBAAkB,CAACC,SAAS,EAAE;EAAEC,KAAK,EAAE,SAAS;EAAEC,GAAG,EAAE;AAAU,CAAC,CAAC,CAAE;AAE5H,MAAMC,cAAc,GAAGC,IAAA;EAAA,IAAC;IAAEX,IAAI;IAAEC;EAAqC,CAAC,GAAAU,IAAA;EAAA,UAAAP,MAAA,CAAQ,IAAIC,IAAI,CAACL,IAAI,CAAC,CAACM,kBAAkB,CAACC,SAAS,EAAE;IAAEK,IAAI,EAAE,SAAS;IAAEJ,KAAK,EAAE,SAAS;IAAEC,GAAG,EAAE;EAAU,CAAC,CAAC,QAAAL,MAAA,CAAKH,IAAI;AAAA,CAAM;AAEhM,MAAMY,mBAAmB,GAAGA,CAACC,KAAa,EAAEC,QAAsC,KAAK;EACrF,MAAM;IAAEf,IAAI;IAAEC;EAAK,CAAC,GAAGL,cAAc,CAACkB,KAAK,CAAC;EAC5C,MAAME,YAAY,GAAGD,QAAQ,CAACE,UAAU,CAAC,GAAG,CAAC,IAAIF,QAAQ,CAACE,UAAU,CAAC,GAAG,CAAC,IAAIhB,IAAI,KAAK,OAAO;EAE7F,OAAOe,YAAY,GAAGb,UAAU,CAACH,IAAI,CAAC,GAAGC,IAAI;AAC/C,CAAC;AAED,MAAMiB,gBAAgB,GAAIC,MAAgC,IAAK;EAC7D,MAAMnB,IAAI,GAAGU,cAAc,CAACd,cAAc,CAACuB,MAAM,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;EAE/D,MAAMC,GAAG,GAAGF,MAAM,CACfG,IAAI,CAAC,CAAAC,KAAA,EAAAC,KAAA;IAAA,IAAC;MAAEJ,KAAK,EAAEK;IAAO,CAAC,GAAAF,KAAA;IAAA,IAAE;MAAEH,KAAK,EAAEM;IAAO,CAAC,GAAAF,KAAA;IAAA,OAAKG,MAAM,CAACD,MAAM,CAAC,CAAC,CAAC,CAAC,GAAGC,MAAM,CAACF,MAAM,CAAC,CAAC,CAAC,CAAC;EAAA,EAAC,CACrFG,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,MAAM;MAAEC,UAAU;MAAEX;IAAM,CAAC,GAAAS,KAAA;IAAA,yJAAAzB,MAAA,CAE7B0B,MAAM,sBAAA1B,MAAA,CACA2B,UAAU,yCAAA3B,MAAA,CAEZgB,KAAK,CAAC,CAAC,CAAC;EAAA,CACX,CAAC;EAEV,uGAAAhB,MAAA,CACqCJ,IAAI,mBAAAI,MAAA,CACrCiB,GAAG,CAACW,IAAI,CAAC,IAAI,CAAC;AAEpB,CAAC;AAED,SACEd,gBAAgB,EAChBL,mBAAmB"}
1
+ {"version":3,"file":"formatters.js","names":["CurrencyPowerBalanceTimeUnit","CANDLE_MINUTE","CANDLE_NUMBER_HOUR","VERTICAL_LINE_COUNT","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","M3","M1","W1","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","offset","Math","round","index","value","everyTwoHours","H24","getMinutes","hoursIntervalConditions","H4","endsWith","H8","PreviousDay","CurrentDay","tooltipFormatter","values","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { CANDLE_MINUTE, CANDLE_NUMBER_HOUR, VERTICAL_LINE_COUNT } 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 timeUnit: CurrencyPowerBalanceTimeUnit,\n) => {\n let offset = 0;\n\n return isMonthWeek(timeUnit)\n ? Math.round(dataLength / VERTICAL_LINE_COUNT)\n : (index: number, value: string) => {\n const everyTwoHours = index % 24 === 0 + offset;\n\n if (timeUnit === CurrencyPowerBalanceTimeUnit.H24 && index === 0) {\n offset = CANDLE_NUMBER_HOUR - new Date(value).getMinutes() / CANDLE_MINUTE;\n }\n\n const hoursIntervalConditions: Record<string, boolean> = {\n [CurrencyPowerBalanceTimeUnit.H4]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),\n [CurrencyPowerBalanceTimeUnit.H8]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),\n [CurrencyPowerBalanceTimeUnit.H24]: everyTwoHours && value.endsWith(':00:00Z'),\n [CurrencyPowerBalanceTimeUnit.PreviousDay]: everyTwoHours,\n [CurrencyPowerBalanceTimeUnit.CurrentDay]: value.endsWith(':00:00Z'),\n };\n\n return hoursIntervalConditions[timeUnit];\n };\n};\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\nexport {\n isMonthWeek,\n tooltipFormatter,\n xAxisLabelFormatter,\n intervalFormatter,\n};\n"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,+BAA+B;AAC5E,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,aAAa;AAGpF,MAAMC,cAAc,GAAIC,KAAa,IAAK;EACxC,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAEpC,OAAO;IACLC,IAAI,EAAEF,WAAW,CAAC,CAAC,CAAC;IACpBG,IAAI,EAAEH,WAAW,CAAC,CAAC,CAAC,CAACI,SAAS,CAAC,CAAC,EAAE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AC,CAAC,CAAC,GAAGC,MAAM,CAACF,MAAM,CAAC,CAAC,CAAC,CAAC;EAAA,EAAC,CACrFG,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,MAAM;MAAEC,UAAU;MAAEtB;IAAM,CAAC,GAAAoB,KAAA;IAAA,yJAAA3C,MAAA,CAE7B4C,MAAM,sBAAA5C,MAAA,CACA6C,UAAU,yCAAA7C,MAAA,CAEZuB,KAAK,CAAC,CAAC,CAAC;EAAA,CACX,CAAC;EAEV,uGAAAvB,MAAA,CACqCJ,IAAI,mBAAAI,MAAA,CACrCmC,GAAG,CAACW,IAAI,CAAC,IAAI,CAAC;AAEpB,CAAC;AAED,SACErC,WAAW,EACXwB,gBAAgB,EAChBnB,mBAAmB,EACnBG,iBAAiB"}
@@ -1,5 +1,5 @@
1
- import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT } from './constants';
2
- import { tooltipFormatter, xAxisLabelFormatter } from './formatters';
1
+ import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
2
+ import { intervalFormatter, tooltipFormatter, xAxisLabelFormatter } from './formatters';
3
3
  const getOption = (values, timeUnit, isDark) => {
4
4
  const seriesData = values.map(_ref => {
5
5
  let {
@@ -63,10 +63,11 @@ const getOption = (values, timeUnit, isDark) => {
63
63
  show: true
64
64
  },
65
65
  axisLabel: {
66
+ padding: [0, 0, 0, 4],
67
+ align: 'left',
66
68
  margin: 10,
67
- showMinLabel: false,
68
69
  rotate: -45,
69
- interval: Math.round(seriesData[0].data.length / VERTICAL_LINE_COUNT),
70
+ interval: intervalFormatter(seriesData[0].data.length, timeUnit),
70
71
  formatter: label => xAxisLabelFormatter(label, timeUnit)
71
72
  }
72
73
  },
@@ -1 +1 @@
1
- {"version":3,"file":"getOption.js","names":["COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","VERTICAL_LINE_COUNT","tooltipFormatter","xAxisLabelFormatter","getOption","values","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","lineStyle","data","_ref2","point","price","legendData","Object","keys","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","DARK","LIGHT","formatter","extraCssText","xAxis","axisTick","show","axisLine","splitLine","axisLabel","margin","showMinLabel","rotate","interval","Math","round","length","label","yAxis","position","splitNumber","boundaryGap","showMaxLabel","series"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT } from './constants';\nimport { tooltipFormatter, xAxisLabelFormatter } from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n values: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = values.map(({ currency, power }) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n lineStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n }));\n\n const legendData = Object.keys(COLOR_CONFIG).map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n margin: 10,\n showMinLabel: false,\n rotate: -45,\n interval: Math.round(seriesData[0].data.length / VERTICAL_LINE_COUNT),\n formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n splitNumber: 5,\n axisLine: { show: false },\n axisTick: { show: false },\n boundaryGap: ['10%', '10%'],\n axisLabel: {\n showMaxLabel: false,\n showMinLabel: false,\n },\n },\n series: seriesData,\n };\n};\n\nexport { getOption };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,yBAAyB,EAAEC,mBAAmB,QAAQ,aAAa;AAC1F,SAASC,gBAAgB,EAAEC,mBAAmB,QAAQ,cAAc;AAGpE,MAAMC,SAAS,GAAGA,CAChBC,MAA8B,EAC9BC,QAAsC,EACtCC,MAAe,KACZ;EACH,MAAMC,UAAU,GAAGH,MAAM,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAF,IAAA;IAAA,OAAM;MACtDG,IAAI,EAAEF,QAAQ;MACdG,IAAI,EAAE,MAAM;MACZC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAE,KAAK;MACjBC,SAAS,EAAE;QACTC,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDQ,SAAS,EAAE;QACTD,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDS,IAAI,EAAER,KAAK,CAACH,GAAG,CAACY,KAAA;QAAA,IAAC;UAAEC,KAAK;UAAEC;QAAM,CAAC,GAAAF,KAAA;QAAA,OAAK,CAACC,KAAK,EAAEC,KAAK,CAAC;MAAA;IACtD,CAAC;EAAA,CAAC,CAAC;EAEH,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAAC3B,YAAY,CAAC,CAACU,GAAG,CAAEE,QAAQ,KAAM;IAC9DE,IAAI,EAAEF,QAAQ;IACdM,SAAS,EAAE;MACTC,KAAK,EAAEnB,YAAY,CAACY,QAAQ;IAC9B;EACF,CAAC,CAAC,CAAC;EAEH,OAAO;IACLgB,SAAS,EA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,EAAEnD;EACV,CAAC;AACH,CAAC;AAED,SAASJ,SAAS"}
1
+ {"version":3,"file":"getOption.js","names":["COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","intervalFormatter","tooltipFormatter","xAxisLabelFormatter","getOption","values","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","lineStyle","data","_ref2","point","price","legendData","Object","keys","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","DARK","LIGHT","formatter","extraCssText","xAxis","axisTick","show","axisLine","splitLine","axisLabel","padding","align","margin","rotate","interval","length","label","yAxis","position","splitNumber","boundaryGap","showMaxLabel","showMinLabel","series"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';\nimport { intervalFormatter, tooltipFormatter, xAxisLabelFormatter } from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n values: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = values.map(({ currency, power }) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n lineStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n }));\n\n const legendData = Object.keys(COLOR_CONFIG).map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n padding: [0, 0, 0, 4],\n align: 'left',\n margin: 10,\n rotate: -45,\n interval: intervalFormatter(seriesData[0].data.length, timeUnit),\n formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n splitNumber: 5,\n axisLine: { show: false },\n axisTick: { show: false },\n boundaryGap: ['10%', '10%'],\n axisLabel: {\n showMaxLabel: false,\n showMinLabel: false,\n },\n },\n series: seriesData,\n };\n};\n\nexport { getOption };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,yBAAyB,QAAQ,aAAa;AACrE,SAASC,iBAAiB,EAAEC,gBAAgB,EAAEC,mBAAmB,QAAQ,cAAc;AAGvF,MAAMC,SAAS,GAAGA,CAChBC,MAA8B,EAC9BC,QAAsC,EACtCC,MAAe,KACZ;EACH,MAAMC,UAAU,GAAGH,MAAM,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAF,IAAA;IAAA,OAAM;MACtDG,IAAI,EAAEF,QAAQ;MACdG,IAAI,EAAE,MAAM;MACZC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAE,KAAK;MACjBC,SAAS,EAAE;QACTC,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDQ,SAAS,EAAE;QACTD,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDS,IAAI,EAAER,KAAK,CAACH,GAAG,CAACY,KAAA;QAAA,IAAC;UAAEC,KAAK;UAAEC;QAAM,CAAC,GAAAF,KAAA;QAAA,OAAK,CAACC,KAAK,EAAEC,KAAK,CAAC;MAAA;IACtD,CAAC;EAAA,CAAC,CAAC;EAEH,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAAC3B,YAAY,CAAC,CAACU,GAA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EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBD,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAM,CAAC;MACzBc,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;MAC3BX,SAAS,EAAE;QACTY,YAAY,EAAE,KAAK;QACnBC,YAAY,EAAE;MAChB;IACF,CAAC;IACDC,MAAM,EAAEnD;EACV,CAAC;AACH,CAAC;AAED,SAASJ,SAAS"}
@@ -7,7 +7,7 @@ const getResponsiveOption = (isDesktop, isMobile, isDark) => {
7
7
  chartHeight: CHART_HEIGHT,
8
8
  xLabelsSize: isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE,
9
9
  yLabelSize: isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE,
10
- bottomLeftBox: isDesktop,
10
+ bottomLeftBox: false,
11
11
  marginBottom: isMobile ? LEGEND_HEIGHT_MOBILE : LEGEND_HEIGHT
12
12
  });
13
13
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"getResponsiveOption.js","names":["getGridLines","CHART_HEIGHT","CHART_WIDTH","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","Y_LABEL_SIZE_MOBILE","getResponsiveOption","isDesktop","isMobile","isDark","baseGridLines","chartWidth","chartHeight","xLabelsSize","yLabelSize","bottomLeftBox","marginBottom","yAxis","axisLabel","margin","grid","name","top","left","right","concat","bottom","graphic"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n Y_LABEL_SIZE_MOBILE,\n} from './constants';\n\nconst getResponsiveOption = (isDesktop: boolean, isMobile: boolean, isDark: boolean) => {\n const baseGridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE,\n yLabelSize: isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE,\n bottomLeftBox: isDesktop,\n marginBottom: isMobile ? LEGEND_HEIGHT_MOBILE : LEGEND_HEIGHT,\n });\n\n return {\n yAxis: {\n axisLabel: {\n margin: isDesktop ? 8 : 6,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '0px',\n left: '0px',\n right: `${isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE}px`,\n bottom: `${isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...baseGridLines,\n ],\n };\n};\n\nexport { getResponsiveOption };\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SACEC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,mBAAmB,EACnBC,YAAY,EACZC,mBAAmB,QACd,aAAa;AAEpB,MAAMC,mBAAmB,GAAGA,CAACC,SAAkB,EAAEC,QAAiB,EAAEC,MAAe,KAAK;EACtF,MAAMC,aAAa,GAAGb,YAAY,CAAC;IACjCY,MAAM;IACNE,UAAU,EAAEZ,WAAW;IACvBa,WAAW,EAAEd,YAAY;IACzBe,WAAW,EAAEL,QAAQ,GAAGL,mBAAmB,GAAGD,YAAY;IAC1DY,UAAU,EAAEN,QAAQ,GAAGH,mBAAmB,GAAGD,YAAY;IACzDW,aAAa,EAAER,SAAS;IACxBS,YAAY,EAAER,QAAQ,GAAGP,oBAAoB,GAAGD;EAClD,CAAC,CAAC;EAEF,OAAO;IACLiB,KAAK,EAAE;MACLC,SAAS,EAAE;QACTC,MAAM,EAAEZ,SAAS,GAAG,CAAC,GAAG;MAC1B;IACF,CAAC;IACDa,IAAI,EAAE,CACJ;MACEC,IAAI,EAAE,WAAW;MACjBC,GAAG,EAAE,KAAK;MACVC,IAAI,EAAE,KAAK;MACXC,KAAK,KAAAC,MAAA,CAAKjB,QAAQ,GAAGH,mBAAmB,GAAGD,YAAY,OAAI;MAC3DsB,MAAM,KAAAD,MAAA,CAAKjB,QAAQ,GAAGL,mBAAmB,GAAGD,YAAY;IAC1D,CAAC,CACF;IACDyB,OAAO,EAAE,CACP,GAAGjB,aAAa;EAEpB,CAAC;AACH,CAAC;AAED,SAASJ,mBAAmB"}
1
+ {"version":3,"file":"getResponsiveOption.js","names":["getGridLines","CHART_HEIGHT","CHART_WIDTH","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","Y_LABEL_SIZE_MOBILE","getResponsiveOption","isDesktop","isMobile","isDark","baseGridLines","chartWidth","chartHeight","xLabelsSize","yLabelSize","bottomLeftBox","marginBottom","yAxis","axisLabel","margin","grid","name","top","left","right","concat","bottom","graphic"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n Y_LABEL_SIZE_MOBILE,\n} from './constants';\n\nconst getResponsiveOption = (isDesktop: boolean, isMobile: boolean, isDark: boolean) => {\n const baseGridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE,\n yLabelSize: isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE,\n bottomLeftBox: false,\n marginBottom: isMobile ? LEGEND_HEIGHT_MOBILE : LEGEND_HEIGHT,\n });\n\n return {\n yAxis: {\n axisLabel: {\n margin: isDesktop ? 8 : 6,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '0px',\n left: '0px',\n right: `${isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE}px`,\n bottom: `${isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...baseGridLines,\n ],\n };\n};\n\nexport { getResponsiveOption };\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SACEC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,mBAAmB,EACnBC,YAAY,EACZC,mBAAmB,QACd,aAAa;AAEpB,MAAMC,mBAAmB,GAAGA,CAACC,SAAkB,EAAEC,QAAiB,EAAEC,MAAe,KAAK;EACtF,MAAMC,aAAa,GAAGb,YAAY,CAAC;IACjCY,MAAM;IACNE,UAAU,EAAEZ,WAAW;IACvBa,WAAW,EAAEd,YAAY;IACzBe,WAAW,EAAEL,QAAQ,GAAGL,mBAAmB,GAAGD,YAAY;IAC1DY,UAAU,EAAEN,QAAQ,GAAGH,mBAAmB,GAAGD,YAAY;IACzDW,aAAa,EAAE,KAAK;IACpBC,YAAY,EAAER,QAAQ,GAAGP,oBAAoB,GAAGD;EAClD,CAAC,CAAC;EAEF,OAAO;IACLiB,KAAK,EAAE;MACLC,SAAS,EAAE;QACTC,MAAM,EAAEZ,SAAS,GAAG,CAAC,GAAG;MAC1B;IACF,CAAC;IACDa,IAAI,EAAE,CACJ;MACEC,IAAI,EAAE,WAAW;MACjBC,GAAG,EAAE,KAAK;MACVC,IAAI,EAAE,KAAK;MACXC,KAAK,KAAAC,MAAA,CAAKjB,QAAQ,GAAGH,mBAAmB,GAAGD,YAAY,OAAI;MAC3DsB,MAAM,KAAAD,MAAA,CAAKjB,QAAQ,GAAGL,mBAAmB,GAAGD,YAAY;IAC1D,CAAC,CACF;IACDyB,OAAO,EAAE,CACP,GAAGjB,aAAa;EAEpB,CAAC;AACH,CAAC;AAED,SAASJ,mBAAmB"}
@@ -7,9 +7,11 @@ declare const CHART_HEIGHT = 425;
7
7
  declare const LEGEND_HEIGHT = 50;
8
8
  declare const LEGEND_HEIGHT_MOBILE = 70;
9
9
  declare const VERTICAL_LINE_COUNT = 10;
10
+ declare const CANDLE_NUMBER_HOUR = 12;
11
+ declare const CANDLE_MINUTE = 5;
10
12
  declare const COLOR_CONFIG: Record<string, string>;
11
13
  declare const TOOLTIP_LINE_COLOR_CONFIG: {
12
14
  DARK: string;
13
15
  LIGHT: string;
14
16
  };
15
- export { 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, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, };
17
+ export { 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, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, CANDLE_NUMBER_HOUR, CANDLE_MINUTE, };
@@ -1,5 +1,7 @@
1
1
  import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
2
  import { TooltipFormatterParams } from './types';
3
+ declare const isMonthWeek: (timeUnit: CurrencyPowerBalanceTimeUnit) => boolean;
3
4
  declare const xAxisLabelFormatter: (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => string;
5
+ declare const intervalFormatter: (dataLength: number, timeUnit: CurrencyPowerBalanceTimeUnit) => number | ((index: number, value: string) => boolean);
4
6
  declare const tooltipFormatter: (values: TooltipFormatterParams[]) => string;
5
- export { tooltipFormatter, xAxisLabelFormatter, };
7
+ export { isMonthWeek, tooltipFormatter, xAxisLabelFormatter, intervalFormatter, };
@@ -35,10 +35,11 @@ declare const getOption: (values: CurrencyPowerBalance[], timeUnit: CurrencyPowe
35
35
  show: boolean;
36
36
  };
37
37
  axisLabel: {
38
+ padding: number[];
39
+ align: string;
38
40
  margin: number;
39
- showMinLabel: boolean;
40
41
  rotate: number;
41
- interval: number;
42
+ interval: number | ((index: number, value: string) => boolean);
42
43
  formatter: (label: string) => string;
43
44
  };
44
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-power-balance-widget",
3
- "version": "1.0.29",
3
+ "version": "1.0.31",
4
4
  "description": "Labs Currency Power Balance Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -13,7 +13,7 @@
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
15
  "@apollo/client": "3.7.17",
16
- "@oanda/labs-widget-common": "^1.0.90",
16
+ "@oanda/labs-widget-common": "^1.0.92",
17
17
  "@oanda/mono-i18n": "9.0.0",
18
18
  "echarts": "5.4.3",
19
19
  "echarts-for-react": "3.0.2",
@@ -23,5 +23,5 @@
23
23
  "@graphql-codegen/cli": "5.0.0",
24
24
  "@graphql-codegen/client-preset": "4.1.0"
25
25
  },
26
- "gitHead": "7523e69532a4aaefd52cfdbff7825060ac1fe898"
26
+ "gitHead": "8b8ecedc3a0715bfc7b70be8cce9902546a489a4"
27
27
  }
@@ -9,6 +9,8 @@ const CHART_HEIGHT = 425;
9
9
  const LEGEND_HEIGHT = 50;
10
10
  const LEGEND_HEIGHT_MOBILE = 70;
11
11
  const VERTICAL_LINE_COUNT = 10;
12
+ const CANDLE_NUMBER_HOUR = 12;
13
+ const CANDLE_MINUTE = 5;
12
14
 
13
15
  const COLOR_CONFIG: Record<string, string> = {
14
16
  USD: colorPalette.greenLight,
@@ -38,4 +40,6 @@ export {
38
40
  VERTICAL_LINE_COUNT,
39
41
  COLOR_CONFIG,
40
42
  TOOLTIP_LINE_COLOR_CONFIG,
43
+ CANDLE_NUMBER_HOUR,
44
+ CANDLE_MINUTE,
41
45
  };
@@ -1,4 +1,5 @@
1
1
  import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
+ import { CANDLE_MINUTE, CANDLE_NUMBER_HOUR, VERTICAL_LINE_COUNT } from './constants';
2
3
  import { TooltipFormatterParams } from './types';
3
4
 
4
5
  const getDateAndTime = (param: string) => {
@@ -14,13 +15,46 @@ const dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefi
14
15
 
15
16
  const dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;
16
17
 
18
+ const isMonthWeek = (
19
+ timeUnit: CurrencyPowerBalanceTimeUnit,
20
+ ) => timeUnit === CurrencyPowerBalanceTimeUnit.M3
21
+ || timeUnit === CurrencyPowerBalanceTimeUnit.M1
22
+ || timeUnit === CurrencyPowerBalanceTimeUnit.W1;
23
+
17
24
  const xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {
18
25
  const { date, time } = getDateAndTime(label);
19
- const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';
26
+ const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';
20
27
 
21
28
  return isDateFormat ? dateFormat(date) : time;
22
29
  };
23
30
 
31
+ const intervalFormatter = (
32
+ dataLength: number,
33
+ timeUnit: CurrencyPowerBalanceTimeUnit,
34
+ ) => {
35
+ let offset = 0;
36
+
37
+ return isMonthWeek(timeUnit)
38
+ ? Math.round(dataLength / VERTICAL_LINE_COUNT)
39
+ : (index: number, value: string) => {
40
+ const everyTwoHours = index % 24 === 0 + offset;
41
+
42
+ if (timeUnit === CurrencyPowerBalanceTimeUnit.H24 && index === 0) {
43
+ offset = CANDLE_NUMBER_HOUR - new Date(value).getMinutes() / CANDLE_MINUTE;
44
+ }
45
+
46
+ const hoursIntervalConditions: Record<string, boolean> = {
47
+ [CurrencyPowerBalanceTimeUnit.H4]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),
48
+ [CurrencyPowerBalanceTimeUnit.H8]: value.endsWith(':00:00Z') || value.endsWith(':30:00Z'),
49
+ [CurrencyPowerBalanceTimeUnit.H24]: everyTwoHours && value.endsWith(':00:00Z'),
50
+ [CurrencyPowerBalanceTimeUnit.PreviousDay]: everyTwoHours,
51
+ [CurrencyPowerBalanceTimeUnit.CurrentDay]: value.endsWith(':00:00Z'),
52
+ };
53
+
54
+ return hoursIntervalConditions[timeUnit];
55
+ };
56
+ };
57
+
24
58
  const tooltipFormatter = (values: TooltipFormatterParams[]) => {
25
59
  const date = dateTimeFormat(getDateAndTime(values[0].value[0]));
26
60
 
@@ -41,6 +75,8 @@ const tooltipFormatter = (values: TooltipFormatterParams[]) => {
41
75
  };
42
76
 
43
77
  export {
78
+ isMonthWeek,
44
79
  tooltipFormatter,
45
80
  xAxisLabelFormatter,
81
+ intervalFormatter,
46
82
  };
@@ -1,5 +1,5 @@
1
- import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT } from './constants';
2
- import { tooltipFormatter, xAxisLabelFormatter } from './formatters';
1
+ import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
2
+ import { intervalFormatter, tooltipFormatter, xAxisLabelFormatter } from './formatters';
3
3
  import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
4
4
 
5
5
  const getOption = (
@@ -57,10 +57,11 @@ const getOption = (
57
57
  show: true,
58
58
  },
59
59
  axisLabel: {
60
+ padding: [0, 0, 0, 4],
61
+ align: 'left',
60
62
  margin: 10,
61
- showMinLabel: false,
62
63
  rotate: -45,
63
- interval: Math.round(seriesData[0].data.length / VERTICAL_LINE_COUNT),
64
+ interval: intervalFormatter(seriesData[0].data.length, timeUnit),
64
65
  formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),
65
66
  },
66
67
  },
@@ -17,7 +17,7 @@ const getResponsiveOption = (isDesktop: boolean, isMobile: boolean, isDark: bool
17
17
  chartHeight: CHART_HEIGHT,
18
18
  xLabelsSize: isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE,
19
19
  yLabelSize: isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE,
20
- bottomLeftBox: isDesktop,
20
+ bottomLeftBox: false,
21
21
  marginBottom: isMobile ? LEGEND_HEIGHT_MOBILE : LEGEND_HEIGHT,
22
22
  });
23
23
 
@@ -2,9 +2,18 @@
2
2
  * @jest-environment jsdom
3
3
  */
4
4
 
5
- import { xAxisLabelFormatter, tooltipFormatter } from '../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters';
5
+ import { intervalFormatter, xAxisLabelFormatter, tooltipFormatter } from '../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters';
6
6
  import { CurrencyPowerBalanceTimeUnit } from '../src/gql/types/graphql';
7
7
 
8
+ describe('intervalFormatter', () => {
9
+ it('should return number of intervals for timeUnit equal to 3 months', () => {
10
+ expect(intervalFormatter(30, CurrencyPowerBalanceTimeUnit.M3)).toEqual(3);
11
+ });
12
+ it('should return function timeUnit equal to 24 hours', () => {
13
+ expect(intervalFormatter(30, CurrencyPowerBalanceTimeUnit.H24)).toEqual(expect.any(Function));
14
+ });
15
+ });
16
+
8
17
  describe('tooltipFormatter', () => {
9
18
  it('should sort & format tooltip content', () => {
10
19
  const values = [{