@oanda/labs-currency-power-balance-widget 1.0.104 → 1.0.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +852 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +6 -2
  3. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -2
  5. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +1 -1
  7. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +50 -6
  9. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  10. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js +10 -0
  11. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -0
  12. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +1 -0
  13. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  14. package/dist/main/translations/sources/en.json +2 -0
  15. package/dist/main/translations/sources/es.json +2 -0
  16. package/dist/main/translations/sources/th.json +2 -0
  17. package/dist/main/translations/sources/zh_TW.json +2 -0
  18. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +7 -3
  19. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  20. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -2
  21. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  22. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +2 -2
  23. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  24. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +50 -6
  25. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  26. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js +4 -0
  27. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -0
  28. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +1 -0
  29. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  30. package/dist/module/translations/sources/en.json +2 -0
  31. package/dist/module/translations/sources/es.json +2 -0
  32. package/dist/module/translations/sources/th.json +2 -0
  33. package/dist/module/translations/sources/zh_TW.json +2 -0
  34. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +3 -2
  35. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +40 -4
  36. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/utils.d.ts +2 -0
  37. package/package.json +3 -3
  38. package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +5 -2
  39. package/src/CurrencyPowerBalanceWidget/components/Chart/options/{constants.tsx → constants.ts} +5 -2
  40. package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +4 -4
  41. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +54 -4
  42. package/src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts +12 -0
  43. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +1 -0
  44. package/src/translations/sources/en.json +2 -0
  45. package/src/translations/sources/es.json +2 -0
  46. package/src/translations/sources/th.json +2 -0
  47. package/src/translations/sources/zh_TW.json +2 -0
  48. package/test/chartFormatters.test.ts +3 -1
  49. package/test/utils.test.ts +34 -0
@@ -1,7 +1,20 @@
1
+ import { darkTheme, lightTheme } from '@oanda/labs-widget-common';
1
2
  import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
2
3
  import { intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData } from './formatters';
3
- const getOption = (chartData, timeUnit, isDark) => {
4
- const seriesData = chartData.map(_ref => {
4
+ import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
5
+ import { findLastIndexesBeforeWeekend } from './utils';
6
+ const getOption = (chartData, timeUnit, isDark, lang) => {
7
+ const currentTheme = isDark ? darkTheme : lightTheme;
8
+ const dataTimestamps = chartData[0].power.map(x => new Date(x.point).getTime());
9
+ const weekendsIndexes = findLastIndexesBeforeWeekend(dataTimestamps);
10
+ const disableWeekendsIndicator = [CurrencyPowerBalanceTimeUnit.CurrentDay, CurrencyPowerBalanceTimeUnit.PreviousDay, CurrencyPowerBalanceTimeUnit.M3].includes(timeUnit) || weekendsIndexes.length === 0;
11
+ const weekendsMarks = weekendsIndexes.map(item => ({
12
+ xAxis: item,
13
+ label: {
14
+ formatter: () => lang('market_closed')
15
+ }
16
+ }));
17
+ const seriesData = chartData.map((_ref, index) => {
5
18
  let {
6
19
  currency,
7
20
  power
@@ -14,16 +27,47 @@ const getOption = (chartData, timeUnit, isDark) => {
14
27
  itemStyle: {
15
28
  color: COLOR_CONFIG[currency]
16
29
  },
17
- lineStyle: {
18
- color: COLOR_CONFIG[currency]
19
- },
20
30
  data: power.map(_ref2 => {
21
31
  let {
22
32
  point,
23
33
  price
24
34
  } = _ref2;
25
35
  return [point, price];
26
- })
36
+ }),
37
+ markLine: index === chartData.length - 1 && !disableWeekendsIndicator ? {
38
+ label: {
39
+ show: false,
40
+ position: 'end',
41
+ align: 'center',
42
+ distance: -32,
43
+ padding: [8, 8],
44
+ fontSize: 12,
45
+ shadowBlur: 24,
46
+ shadowOffsetX: 0,
47
+ shadowOffsetY: 6,
48
+ borderWidth: 0,
49
+ color: currentTheme.textPrimary,
50
+ shadowColor: 'rgba(0,0,0,0.1)',
51
+ borderRadius: 4,
52
+ backgroundColor: isDark ? currentTheme.borderPrimary : currentTheme.backgroundSecondary
53
+ },
54
+ show: false,
55
+ emphasis: {
56
+ label: {
57
+ show: true
58
+ },
59
+ lineStyle: {
60
+ width: 1,
61
+ opacity: 0,
62
+ color: currentTheme.borderPrimary
63
+ }
64
+ },
65
+ symbol: ['none', 'none'],
66
+ itemStyle: {
67
+ color: currentTheme.borderPrimary
68
+ },
69
+ data: weekendsMarks
70
+ } : undefined
27
71
  };
28
72
  });
29
73
  const legendData = formatLegendData(chartData);
@@ -1 +1 @@
1
- {"version":3,"file":"getOption.js","names":["COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","intervalFormatter","tooltipFormatter","xAxisLabelFormatter","formatLegendData","getOption","chartData","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","lineStyle","data","_ref2","point","price","legendData","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 {\n intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData,\n} from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n chartData: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = chartData.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 = formatLegendData(chartData);\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),\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,SACEC,iBAAiB,EAAEC,gBAAgB,EAAEC,mBAAmB,EAAEC,gBAAgB,QACrE,cAAc;AAGrB,MAAMC,SAAS,GAAGA,CAChBC,SAAiC,EACjCC,QAAsC,EACtCC,MAAe,KACZ;EACH,MAAMC,UAAU,GAAGH,SAAS,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAF,IAAA;IAAA,OAAM;MACzDG,IAAI,EAAEF,QAAQ;MACdG,IAAI,EAAE,MAAM;MACZC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAE,KAAK;MACjBC,SAAS,EAAE;QACTC,KAAK,EAAEpB,YAAY,CAACa,QAAQ;MAC9B,CAAC;MACDQ,SAAS,EAAE;QACT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AQ;MACnE;IACF,CAAC;IACD6C,KAAK,EAAE;MACLrC,IAAI,EAAE,OAAO;MACbsC,QAAQ,EAAE,OAAO;MACjBC,WAAW,EAAE,CAAC;MACdZ,QAAQ,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,EAAEjD;EACV,CAAC;AACH,CAAC;AAED,SAASJ,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"getOption.js","names":["darkTheme","lightTheme","COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","intervalFormatter","tooltipFormatter","xAxisLabelFormatter","formatLegendData","CurrencyPowerBalanceTimeUnit","findLastIndexesBeforeWeekend","getOption","chartData","timeUnit","isDark","lang","currentTheme","dataTimestamps","power","map","x","Date","point","getTime","weekendsIndexes","disableWeekendsIndicator","CurrentDay","PreviousDay","M3","includes","length","weekendsMarks","item","xAxis","label","formatter","seriesData","_ref","index","currency","name","type","symbol","showSymbol","itemStyle","color","data","_ref2","price","markLine","show","position","align","distance","padding","fontSize","shadowBlur","shadowOffsetX","shadowOffsetY","borderWidth","textPrimary","shadowColor","borderRadius","backgroundColor","borderPrimary","backgroundSecondary","emphasis","lineStyle","width","opacity","undefined","legendData","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","DARK","LIGHT","extraCssText","axisTick","axisLine","splitLine","axisLabel","margin","rotate","interval","yAxis","splitNumber","boundaryGap","showMaxLabel","showMinLabel","series"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { darkTheme, lightTheme } from '@oanda/labs-widget-common';\nimport { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';\nimport {\n intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData,\n} from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { findLastIndexesBeforeWeekend } from './utils';\n\nconst getOption = (\n chartData: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n lang: (key: string) => string,\n) => {\n const currentTheme = isDark ? darkTheme : lightTheme;\n const dataTimestamps = chartData[0].power.map((x) => new Date(x.point).getTime());\n const weekendsIndexes = findLastIndexesBeforeWeekend(dataTimestamps);\n const disableWeekendsIndicator = [\n CurrencyPowerBalanceTimeUnit.CurrentDay,\n CurrencyPowerBalanceTimeUnit.PreviousDay,\n CurrencyPowerBalanceTimeUnit.M3,\n ].includes(timeUnit) || weekendsIndexes.length === 0;\n\n const weekendsMarks = weekendsIndexes.map((item) => ({\n xAxis: item,\n label: {\n formatter: () => lang('market_closed'),\n },\n }));\n\n const seriesData = chartData.map(({ currency, power }, index) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n markLine: index === chartData.length - 1 && !disableWeekendsIndicator ? {\n label: {\n show: false,\n position: 'end',\n align: 'center',\n distance: -32,\n padding: [8, 8],\n fontSize: 12,\n shadowBlur: 24,\n shadowOffsetX: 0,\n shadowOffsetY: 6,\n borderWidth: 0,\n color: currentTheme.textPrimary,\n shadowColor: 'rgba(0,0,0,0.1)',\n borderRadius: 4,\n backgroundColor: isDark ? currentTheme.borderPrimary : currentTheme.backgroundSecondary,\n },\n show: false,\n emphasis: {\n label: {\n show: true,\n },\n lineStyle: {\n width: 1,\n opacity: 0,\n color: currentTheme.borderPrimary,\n },\n },\n symbol: ['none', 'none'],\n itemStyle: {\n color: currentTheme.borderPrimary,\n },\n data: weekendsMarks,\n } : undefined,\n }));\n\n const legendData = formatLegendData(chartData);\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),\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,SAAS,EAAEC,UAAU,QAAQ,2BAA2B;AACjE,SAASC,YAAY,EAAEC,yBAAyB,QAAQ,aAAa;AACrE,SACEC,iBAAiB,EAAEC,gBAAgB,EAAEC,mBAAmB,EAAEC,gBAAgB,QACrE,cAAc;AACrB,SAA+BC,4BAA4B,QAAQ,+BAA+B;AAClG,SAASC,4BAA4B,QAAQ,SAAS;AAEtD,MAAMC,SAAS,GAAGA,CAChBC,SAAiC,EACjCC,QAAsC,EACtCC,MAAe,EACfC,IAA6B,KAC1B;EACH,MAAMC,YAAY,GAAGF,MAAM,GAAGb,SAAS,GAAGC,UAAU;EACpD,MAAMe,cAAc,GAAGL,SAAS,CAAC,CAAC,CAAC,CAACM,KAAK,CAACC,GAAG,CAAEC,CAAC,IAAK,IAAIC,IAAI,CAACD,CAAC,CAACE,KAAK,CAAC,CAACC,OAAO,CAAC,CAAC,CAAC;EACjF,MAAMC,eAAe,GAAGd,4BAA4B,CAACO,cAAc,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AAEnC,IAAI,EAAE;MAAM,CAAC;MACzBoC,SAAS,EAAE;QACTpC,IAAI,EAAE;MACR,CAAC;MACDqC,SAAS,EAAE;QACTjC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACrBF,KAAK,EAAE,MAAM;QACboC,MAAM,EAAE,EAAE;QACVC,MAAM,EAAE,CAAC,EAAE;QACXC,QAAQ,EAAErF,iBAAiB,CAAC+B,UAAU,CAAC,CAAC,CAAC,CAACU,IAAI,CAAChB,MAAM,CAAC;QACtDK,SAAS,EAAGD,KAAa,IAAK3B,mBAAmB,CAAC2B,KAAK,EAAErB,QAAQ;MACnE;IACF,CAAC;IACD8E,KAAK,EAAE;MACLlD,IAAI,EAAE,OAAO;MACbU,QAAQ,EAAE,OAAO;MACjByC,WAAW,EAAE,CAAC;MACdP,QAAQ,EAAE;QAAEnC,IAAI,EAAE;MAAM,CAAC;MACzBkC,QAAQ,EAAE;QAAElC,IAAI,EAAE;MAAM,CAAC;MACzB2C,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;MAC3BN,SAAS,EAAE;QACTO,YAAY,EAAE,KAAK;QACnBC,YAAY,EAAE;MAChB;IACF,CAAC;IACDC,MAAM,EAAE5D;EACV,CAAC;AACH,CAAC;AAED,SAASzB,SAAS","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import { WEEKEND_DURATION } from './constants';
2
+ const findLastIndexesBeforeWeekend = timestamps => timestamps.reduce((acc, timestamp, index) => timestamps.length - 1 !== index && timestamps[index + 1] - timestamp >= WEEKEND_DURATION ? [...acc, index] : acc, []);
3
+ export { findLastIndexesBeforeWeekend };
4
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["WEEKEND_DURATION","findLastIndexesBeforeWeekend","timestamps","reduce","acc","timestamp","index","length"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts"],"sourcesContent":["import { WEEKEND_DURATION } from './constants';\n\nconst findLastIndexesBeforeWeekend = (timestamps: number[]) => timestamps\n .reduce((acc, timestamp, index) => (\n timestamps.length - 1 !== index && timestamps[index + 1] - timestamp >= WEEKEND_DURATION\n ? [...acc, index]\n : acc\n ), [] as number[]);\n\nexport {\n findLastIndexesBeforeWeekend,\n};\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAa;AAE9C,MAAMC,4BAA4B,GAAIC,UAAoB,IAAKA,UAAU,CACtEC,MAAM,CAAC,CAACC,GAAG,EAAEC,SAAS,EAAEC,KAAK,KAC5BJ,UAAU,CAACK,MAAM,GAAG,CAAC,KAAKD,KAAK,IAAIJ,UAAU,CAACI,KAAK,GAAG,CAAC,CAAC,GAAGD,SAAS,IAAIL,gBAAgB,GACpF,CAAC,GAAGI,GAAG,EAAEE,KAAK,CAAC,GACfF,GACL,EAAE,EAAc,CAAC;AAEpB,SACEH,4BAA4B","ignoreList":[]}
@@ -35,6 +35,7 @@ const TimeUnitSelect = _ref => {
35
35
  "data-testid": "time-unit-select",
36
36
  className: "lw-mb-6 lw-w-full"
37
37
  }, React.createElement(Select, {
38
+ searchPlaceholder: lang('search'),
38
39
  options: selectOptions,
39
40
  selectedOption: {
40
41
  id: selected,
@@ -1 +1 @@
1
- {"version":3,"file":"TimeUnitSelect.js","names":["React","Select","useLocale","TimeUnitSelect","_ref","selected","options","callback","lang","selectOptions","map","_ref2","value","id","label","tooltipLabel","translationKey","count","selectedLabel","filter","_ref3","createElement","className","selectedOption","setSelectedOption","_ref4"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { Select } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nconst TimeUnitSelect = ({\n selected, options, callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const selectOptions = options\n .map(({ value: id, label, tooltipLabel }) => ({\n id,\n label: tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : lang(label),\n }));\n const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);\n\n return (\n <div data-testid=\"time-unit-select\" className=\"lw-mb-6 lw-w-full\">\n <Select\n options={selectOptions}\n selectedOption={{ id: selected, label: selectedLabel }}\n setSelectedOption={({ id }) => callback(id as CurrencyPowerBalanceTimeUnit)}\n />\n </div>\n );\n};\n\nexport { TimeUnitSelect };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,2BAA2B;AAClD,SAASC,SAAS,QAAQ,kBAAkB;AAI5C,MAAMC,cAAc,GAAGC,IAAA,IAEI;EAAA,IAFH;IACtBC,QAAQ;IAAEC,OAAO;IAAEC;EACA,CAAC,GAAAH,IAAA;EACpB,MAAM;IAAEI;EAAK,CAAC,GAAGN,SAAS,CAAC,CAAC;EAC5B,MAAMO,aAAa,GAAGH,OAAO,CAC1BI,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,KAAK,EAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAAJ,KAAA;IAAA,OAAM;MAC5CE,EAAE;MACFC,KAAK,EAAEC,YAAY,GACfP,IAAI,CAACO,YAAY,CAACC,cAAc,EAAE;QAAEC,KAAK,EAAEF,YAAY,CAACE;MAAM,CAAC,CAAC,GAChET,IAAI,CAACM,KAAK;IAChB,CAAC;EAAA,CAAC,CAAC;EACL,MAAM,CAAC;IAAEA,KAAK,EAAEI;EAAc,CAAC,CAAC,GAAGT,aAAa,CAACU,MAAM,CAACC,KAAA;IAAA,IAAC;MAAEP;IAAG,CAAC,GAAAO,KAAA;IAAA,OAAKP,EAAE,KAAKR,QAAQ;EAAA,EAAC;EAEpF,OACEL,KAAA,CAAAqB,aAAA;IAAK,eAAY,kBAAkB;IAACC,SAAS,EAAC;EAAmB,GAC/DtB,KAAA,CAAAqB,aAAA,CAACpB,MAAM;IACLK,OAAO,EAAEG,aAAc;IACvBc,cAAc,EAAE;MAAEV,EAAE,EAAER,QAAQ;MAAES,KAAK,EAAEI;IAAc,CAAE;IACvDM,iBAAiB,EAAEC,KAAA;MAAA,IAAC;QAAEZ;MAAG,CAAC,GAAAY,KAAA;MAAA,OAAKlB,QAAQ,CAACM,EAAkC,CAAC;IAAA;EAAC,CAC7E,CACE,CAAC;AAEV,CAAC;AAED,SAASV,cAAc","ignoreList":[]}
1
+ {"version":3,"file":"TimeUnitSelect.js","names":["React","Select","useLocale","TimeUnitSelect","_ref","selected","options","callback","lang","selectOptions","map","_ref2","value","id","label","tooltipLabel","translationKey","count","selectedLabel","filter","_ref3","createElement","className","searchPlaceholder","selectedOption","setSelectedOption","_ref4"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { Select } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nconst TimeUnitSelect = ({\n selected, options, callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const selectOptions = options\n .map(({ value: id, label, tooltipLabel }) => ({\n id,\n label: tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : lang(label),\n }));\n const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);\n\n return (\n <div data-testid=\"time-unit-select\" className=\"lw-mb-6 lw-w-full\">\n <Select\n searchPlaceholder={lang('search')}\n options={selectOptions}\n selectedOption={{ id: selected, label: selectedLabel }}\n setSelectedOption={({ id }) => callback(id as CurrencyPowerBalanceTimeUnit)}\n />\n </div>\n );\n};\n\nexport { TimeUnitSelect };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB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@@
10
10
  "hour": "{{count}} Hour",
11
11
  "hour_plural": "{{count}} Hours",
12
12
  "last_updated": "Last updated",
13
+ "market_closed": "market closed",
13
14
  "month": "{{count}} Month",
14
15
  "month_plural": "{{count}} Months",
15
16
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
16
17
  "previous_business_day": "Previous Business Day",
18
+ "search": "Search",
17
19
  "today": "Today",
18
20
  "week": "{{count}} Week",
19
21
  "week_plural": "{{count}} Weeks"
@@ -10,10 +10,12 @@
10
10
  "hour": "{{count}} Hora",
11
11
  "hour_plural": "{{count}} Horas",
12
12
  "last_updated": "Última actualización",
13
+ "market_closed": "mercado cerrado",
13
14
  "month": "{{count}} Mes",
14
15
  "month_plural": "{{count}} Meses",
15
16
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} de {{itemCount}} entradas",
16
17
  "previous_business_day": "Día laborable anterior",
18
+ "search": "Buscar",
17
19
  "today": "Hoy",
18
20
  "week": "{{count}} Semana",
19
21
  "week_plural": "{{count}} Semanas"
@@ -9,9 +9,11 @@
9
9
  "data_unavailable": "ข้อมูลไม่พร้อมใช้งาน",
10
10
  "hour_0": "{{count}} ชั่วโมง",
11
11
  "last_updated": "ปรับปรุงล่าสุด",
12
+ "market_closed": "ตลาดปิดทำการ",
12
13
  "month_0": "{{count}} เดือน",
13
14
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} จาก {{itemCount}} รายการ",
14
15
  "previous_business_day": "วันทำการก่อนหน้า",
16
+ "search": "ค้นหา",
15
17
  "today": "วันนี้",
16
18
  "week_0": "{{count}} สัปดาห์"
17
19
  }
@@ -9,9 +9,11 @@
9
9
  "data_unavailable": "沒有數據",
10
10
  "hour_0": "{{count}} 時",
11
11
  "last_updated": "最後更新",
12
+ "market_closed": "市場已收盤",
12
13
  "month_0": "{{count}} 月",
13
14
  "pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
14
15
  "previous_business_day": "前一營業日",
16
+ "search": "搜尋",
15
17
  "today": "今日",
16
18
  "week_0": "{{count}} 週"
17
19
  }
@@ -1,4 +1,5 @@
1
1
  import { CurrencyName } from '../../../../gql/types/graphql';
2
+ declare const WEEKEND_DURATION = 172800000;
2
3
  declare const X_LABEL_SIZE = 90;
3
4
  declare const X_LABEL_SIZE_MOBILE = 110;
4
5
  declare const Y_LABEL_SIZE_MOBILE = 35;
@@ -10,7 +11,7 @@ declare const LEGEND_HEIGHT_MOBILE = 70;
10
11
  declare const VERTICAL_LINE_COUNT = 10;
11
12
  declare const CANDLE_NUMBER_HOUR = 12;
12
13
  declare const CANDLE_MINUTE = 5;
13
- declare const CURENCIES_ORDER: CurrencyName[];
14
+ declare const CURRENCIES_ORDER: CurrencyName[];
14
15
  declare const COLOR_CONFIG: {
15
16
  USD: string;
16
17
  EUR: string;
@@ -25,4 +26,4 @@ declare const TOOLTIP_LINE_COLOR_CONFIG: {
25
26
  DARK: string;
26
27
  LIGHT: string;
27
28
  };
28
- 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, CURENCIES_ORDER, };
29
+ 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, CURRENCIES_ORDER, WEEKEND_DURATION, };
@@ -1,5 +1,5 @@
1
1
  import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
- declare const getOption: (chartData: CurrencyPowerBalance[], timeUnit: CurrencyPowerBalanceTimeUnit, isDark: boolean) => {
2
+ declare const getOption: (chartData: CurrencyPowerBalance[], timeUnit: CurrencyPowerBalanceTimeUnit, isDark: boolean, lang: (key: string) => string) => {
3
3
  animation: boolean;
4
4
  legend: {
5
5
  data: {
@@ -67,10 +67,46 @@ declare const getOption: (chartData: CurrencyPowerBalance[], timeUnit: CurrencyP
67
67
  itemStyle: {
68
68
  color: string;
69
69
  };
70
- lineStyle: {
71
- color: string;
72
- };
73
70
  data: (string | number)[][];
71
+ markLine: {
72
+ label: {
73
+ show: boolean;
74
+ position: string;
75
+ align: string;
76
+ distance: number;
77
+ padding: number[];
78
+ fontSize: number;
79
+ shadowBlur: number;
80
+ shadowOffsetX: number;
81
+ shadowOffsetY: number;
82
+ borderWidth: number;
83
+ color: string;
84
+ shadowColor: string;
85
+ borderRadius: number;
86
+ backgroundColor: string;
87
+ };
88
+ show: boolean;
89
+ emphasis: {
90
+ label: {
91
+ show: boolean;
92
+ };
93
+ lineStyle: {
94
+ width: number;
95
+ opacity: number;
96
+ color: string;
97
+ };
98
+ };
99
+ symbol: string[];
100
+ itemStyle: {
101
+ color: string;
102
+ };
103
+ data: {
104
+ xAxis: number;
105
+ label: {
106
+ formatter: () => string;
107
+ };
108
+ }[];
109
+ } | undefined;
74
110
  }[];
75
111
  };
76
112
  export { getOption };
@@ -0,0 +1,2 @@
1
+ declare const findLastIndexesBeforeWeekend: (timestamps: number[]) => number[];
2
+ export { findLastIndexesBeforeWeekend, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-power-balance-widget",
3
- "version": "1.0.104",
3
+ "version": "1.0.106",
4
4
  "description": "Labs Currency Power Balance Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -12,7 +12,7 @@
12
12
  "author": "OANDA",
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
- "@oanda/labs-widget-common": "^1.0.165",
15
+ "@oanda/labs-widget-common": "^1.0.167",
16
16
  "@oanda/mono-i18n": "10.0.1",
17
17
  "echarts": "5.5.0",
18
18
  "echarts-for-react": "3.0.2",
@@ -22,5 +22,5 @@
22
22
  "@graphql-codegen/cli": "5.0.0",
23
23
  "@graphql-codegen/client-preset": "4.1.0"
24
24
  },
25
- "gitHead": "5d12e200d67282a9030f1a918e13081e0e9d4c16"
25
+ "gitHead": "5659b2a7351c578a3514e1d465d61c2bd3f8fb7f"
26
26
  }
@@ -4,11 +4,12 @@ import * as echarts from 'echarts/core';
4
4
  import { LineChart } from 'echarts/charts';
5
5
  import { CanvasRenderer } from 'echarts/renderers';
6
6
  import {
7
- GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent,
7
+ GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, MarkLineComponent,
8
8
  } from 'echarts/components';
9
9
  import {
10
10
  Theme, ThemeContext, getChartTheme, Size,
11
11
  } from '@oanda/labs-widget-common';
12
+ import { useLocale } from '@oanda/mono-i18n';
12
13
  import {
13
14
  CHART_HEIGHT,
14
15
  } from './options/constants';
@@ -22,12 +23,14 @@ echarts.use([
22
23
  LegendPlainComponent,
23
24
  LineChart,
24
25
  CanvasRenderer,
26
+ MarkLineComponent,
25
27
  ]);
26
28
 
27
29
  echarts.registerTheme('dark_theme', getChartTheme(Theme.Dark));
28
30
  echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
29
31
 
30
32
  const Chart = ({ values, timeUnit, currencies }: ChartProps) => {
33
+ const { lang } = useLocale();
31
34
  const { isDark, size } = useContext(ThemeContext);
32
35
  const isDesktop = size === Size.DESKTOP;
33
36
  const isMobile = size === Size.MOBILE;
@@ -58,7 +61,7 @@ const Chart = ({ values, timeUnit, currencies }: ChartProps) => {
58
61
  height: `${CHART_HEIGHT}px`,
59
62
  width: '100%',
60
63
  }}
61
- option={getOption(chartData, timeUnit, isDark)}
64
+ option={getOption(chartData, timeUnit, isDark, lang)}
62
65
  />
63
66
  );
64
67
  };
@@ -1,6 +1,8 @@
1
1
  import { colorPalette } from '@oanda/labs-widget-common';
2
2
  import { CurrencyName } from '../../../../gql/types/graphql';
3
3
 
4
+ const WEEKEND_DURATION = 172800000;
5
+
4
6
  const X_LABEL_SIZE = 90;
5
7
  const X_LABEL_SIZE_MOBILE = 110;
6
8
  const Y_LABEL_SIZE_MOBILE = 35;
@@ -13,7 +15,7 @@ const VERTICAL_LINE_COUNT = 10;
13
15
  const CANDLE_NUMBER_HOUR = 12;
14
16
  const CANDLE_MINUTE = 5;
15
17
 
16
- const CURENCIES_ORDER: CurrencyName[] = [
18
+ const CURRENCIES_ORDER: CurrencyName[] = [
17
19
  CurrencyName.Usd,
18
20
  CurrencyName.Eur,
19
21
  CurrencyName.Gbp,
@@ -54,5 +56,6 @@ export {
54
56
  TOOLTIP_LINE_COLOR_CONFIG,
55
57
  CANDLE_NUMBER_HOUR,
56
58
  CANDLE_MINUTE,
57
- CURENCIES_ORDER,
59
+ CURRENCIES_ORDER,
60
+ WEEKEND_DURATION,
58
61
  };
@@ -1,5 +1,5 @@
1
1
  import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
- import { VERTICAL_LINE_COUNT, CURENCIES_ORDER, COLOR_CONFIG } from './constants';
2
+ import { VERTICAL_LINE_COUNT, CURRENCIES_ORDER, COLOR_CONFIG } from './constants';
3
3
  import { TooltipFormatterParams } from './types';
4
4
 
5
5
  const getDateAndTime = (param: string) => {
@@ -54,9 +54,9 @@ const tooltipFormatter = (values: TooltipFormatterParams[]) => {
54
54
  const formatLegendData = (values: CurrencyPowerBalance[]) => {
55
55
  const dataCurrencies = values.map(({ currency }) => currency);
56
56
 
57
- const list = dataCurrencies.length === CURENCIES_ORDER.length
58
- ? CURENCIES_ORDER
59
- : CURENCIES_ORDER.filter((currency) => dataCurrencies.includes(currency));
57
+ const list = dataCurrencies.length === CURRENCIES_ORDER.length
58
+ ? CURRENCIES_ORDER
59
+ : CURRENCIES_ORDER.filter((currency) => dataCurrencies.includes(currency));
60
60
 
61
61
  return list.map((currency) => ({
62
62
  name: currency,
@@ -1,15 +1,34 @@
1
+ import { darkTheme, lightTheme } from '@oanda/labs-widget-common';
1
2
  import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
2
3
  import {
3
4
  intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData,
4
5
  } from './formatters';
5
6
  import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
7
+ import { findLastIndexesBeforeWeekend } from './utils';
6
8
 
7
9
  const getOption = (
8
10
  chartData: CurrencyPowerBalance[],
9
11
  timeUnit: CurrencyPowerBalanceTimeUnit,
10
12
  isDark: boolean,
13
+ lang: (key: string) => string,
11
14
  ) => {
12
- const seriesData = chartData.map(({ currency, power }) => ({
15
+ const currentTheme = isDark ? darkTheme : lightTheme;
16
+ const dataTimestamps = chartData[0].power.map((x) => new Date(x.point).getTime());
17
+ const weekendsIndexes = findLastIndexesBeforeWeekend(dataTimestamps);
18
+ const disableWeekendsIndicator = [
19
+ CurrencyPowerBalanceTimeUnit.CurrentDay,
20
+ CurrencyPowerBalanceTimeUnit.PreviousDay,
21
+ CurrencyPowerBalanceTimeUnit.M3,
22
+ ].includes(timeUnit) || weekendsIndexes.length === 0;
23
+
24
+ const weekendsMarks = weekendsIndexes.map((item) => ({
25
+ xAxis: item,
26
+ label: {
27
+ formatter: () => lang('market_closed'),
28
+ },
29
+ }));
30
+
31
+ const seriesData = chartData.map(({ currency, power }, index) => ({
13
32
  name: currency,
14
33
  type: 'line',
15
34
  symbol: 'circle',
@@ -17,10 +36,41 @@ const getOption = (
17
36
  itemStyle: {
18
37
  color: COLOR_CONFIG[currency],
19
38
  },
20
- lineStyle: {
21
- color: COLOR_CONFIG[currency],
22
- },
23
39
  data: power.map(({ point, price }) => [point, price]),
40
+ markLine: index === chartData.length - 1 && !disableWeekendsIndicator ? {
41
+ label: {
42
+ show: false,
43
+ position: 'end',
44
+ align: 'center',
45
+ distance: -32,
46
+ padding: [8, 8],
47
+ fontSize: 12,
48
+ shadowBlur: 24,
49
+ shadowOffsetX: 0,
50
+ shadowOffsetY: 6,
51
+ borderWidth: 0,
52
+ color: currentTheme.textPrimary,
53
+ shadowColor: 'rgba(0,0,0,0.1)',
54
+ borderRadius: 4,
55
+ backgroundColor: isDark ? currentTheme.borderPrimary : currentTheme.backgroundSecondary,
56
+ },
57
+ show: false,
58
+ emphasis: {
59
+ label: {
60
+ show: true,
61
+ },
62
+ lineStyle: {
63
+ width: 1,
64
+ opacity: 0,
65
+ color: currentTheme.borderPrimary,
66
+ },
67
+ },
68
+ symbol: ['none', 'none'],
69
+ itemStyle: {
70
+ color: currentTheme.borderPrimary,
71
+ },
72
+ data: weekendsMarks,
73
+ } : undefined,
24
74
  }));
25
75
 
26
76
  const legendData = formatLegendData(chartData);
@@ -0,0 +1,12 @@
1
+ import { WEEKEND_DURATION } from './constants';
2
+
3
+ const findLastIndexesBeforeWeekend = (timestamps: number[]) => timestamps
4
+ .reduce((acc, timestamp, index) => (
5
+ timestamps.length - 1 !== index && timestamps[index + 1] - timestamp >= WEEKEND_DURATION
6
+ ? [...acc, index]
7
+ : acc
8
+ ), [] as number[]);
9
+
10
+ export {
11
+ findLastIndexesBeforeWeekend,
12
+ };
@@ -20,6 +20,7 @@ const TimeUnitSelect = ({
20
20
  return (
21
21
  <div data-testid="time-unit-select" className="lw-mb-6 lw-w-full">
22
22
  <Select
23
+ searchPlaceholder={lang('search')}
23
24
  options={selectOptions}
24
25
  selectedOption={{ id: selected, label: selectedLabel }}
25
26
  setSelectedOption={({ id }) => callback(id as CurrencyPowerBalanceTimeUnit)}
@@ -10,10 +10,12 @@
10
10
  "hour": "{{count}} Hour",
11
11
  "hour_plural": "{{count}} Hours",
12
12
  "last_updated": "Last updated",
13
+ "market_closed": "market closed",
13
14
  "month": "{{count}} Month",
14
15
  "month_plural": "{{count}} Months",
15
16
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
16
17
  "previous_business_day": "Previous Business Day",
18
+ "search": "Search",
17
19
  "today": "Today",
18
20
  "week": "{{count}} Week",
19
21
  "week_plural": "{{count}} Weeks"
@@ -10,10 +10,12 @@
10
10
  "hour": "{{count}} Hora",
11
11
  "hour_plural": "{{count}} Horas",
12
12
  "last_updated": "Última actualización",
13
+ "market_closed": "mercado cerrado",
13
14
  "month": "{{count}} Mes",
14
15
  "month_plural": "{{count}} Meses",
15
16
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} de {{itemCount}} entradas",
16
17
  "previous_business_day": "Día laborable anterior",
18
+ "search": "Buscar",
17
19
  "today": "Hoy",
18
20
  "week": "{{count}} Semana",
19
21
  "week_plural": "{{count}} Semanas"
@@ -9,9 +9,11 @@
9
9
  "data_unavailable": "ข้อมูลไม่พร้อมใช้งาน",
10
10
  "hour_0": "{{count}} ชั่วโมง",
11
11
  "last_updated": "ปรับปรุงล่าสุด",
12
+ "market_closed": "ตลาดปิดทำการ",
12
13
  "month_0": "{{count}} เดือน",
13
14
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} จาก {{itemCount}} รายการ",
14
15
  "previous_business_day": "วันทำการก่อนหน้า",
16
+ "search": "ค้นหา",
15
17
  "today": "วันนี้",
16
18
  "week_0": "{{count}} สัปดาห์"
17
19
  }
@@ -9,9 +9,11 @@
9
9
  "data_unavailable": "沒有數據",
10
10
  "hour_0": "{{count}} 時",
11
11
  "last_updated": "最後更新",
12
+ "market_closed": "市場已收盤",
12
13
  "month_0": "{{count}} 月",
13
14
  "pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
14
15
  "previous_business_day": "前一營業日",
16
+ "search": "搜尋",
15
17
  "today": "今日",
16
18
  "week_0": "{{count}} 週"
17
19
  }
@@ -2,7 +2,9 @@
2
2
  * @jest-environment jsdom
3
3
  */
4
4
 
5
- import { intervalFormatter, xAxisLabelFormatter, tooltipFormatter } from '../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters';
5
+ import {
6
+ intervalFormatter, xAxisLabelFormatter, tooltipFormatter,
7
+ } from '../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters';
6
8
  import { CurrencyPowerBalanceTimeUnit } from '../src/gql/types/graphql';
7
9
 
8
10
  describe('intervalFormatter', () => {
@@ -0,0 +1,34 @@
1
+ import { findLastIndexesBeforeWeekend } from '../src/CurrencyPowerBalanceWidget/components/Chart/options/utils';
2
+
3
+ describe('findLastIndexesBeforeWeekend', () => {
4
+ it('should return an empty array if there are no weekends', () => {
5
+ const timestamps = [
6
+ 1679952000000, // Monday
7
+ 1680038400000, // Tuesday
8
+ 1680124800000, // Wednesday
9
+ 1680211200000, // Thursday
10
+ 1680297600000, // Friday
11
+ ];
12
+ const expected: number[] = [];
13
+ expect(findLastIndexesBeforeWeekend(timestamps)).toEqual(expected);
14
+ });
15
+
16
+ it('should return an array of weekend indexes', () => {
17
+ const timestamps = [
18
+ 1679952000000, // Monday
19
+ 1680038400000, // Tuesday
20
+ 1680124800000, // Wednesday
21
+ 1680211200000, // Thursday
22
+ 1680297600000, // Friday
23
+ 1680556800000, // Monday
24
+ 1680643200000, // Tuesday
25
+ 1680729600000, // Wednesday
26
+ 1680816000000, // Thursday
27
+ 1680902400000, // Friday
28
+ 1681161600000, // Monday
29
+
30
+ ];
31
+ const expected = [4, 9];
32
+ expect(findLastIndexesBeforeWeekend(timestamps)).toEqual(expected);
33
+ });
34
+ });