@oanda/labs-currency-strength-widget 1.0.14 → 1.0.16

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 +132 -0
  2. package/dist/main/CurrencyStrengthWidget/ChartsWithData.js +3 -2
  3. package/dist/main/CurrencyStrengthWidget/ChartsWithData.js.map +1 -1
  4. package/dist/main/CurrencyStrengthWidget/components/Chart/constants.js +3 -1
  5. package/dist/main/CurrencyStrengthWidget/components/Chart/constants.js.map +1 -1
  6. package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js +9 -1
  7. package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -1
  8. package/dist/main/CurrencyStrengthWidget/components/Chart/getOption.js +4 -0
  9. package/dist/main/CurrencyStrengthWidget/components/Chart/getOption.js.map +1 -1
  10. package/dist/module/CurrencyStrengthWidget/ChartsWithData.js +3 -2
  11. package/dist/module/CurrencyStrengthWidget/ChartsWithData.js.map +1 -1
  12. package/dist/module/CurrencyStrengthWidget/components/Chart/constants.js +2 -0
  13. package/dist/module/CurrencyStrengthWidget/components/Chart/constants.js.map +1 -1
  14. package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js +7 -0
  15. package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -1
  16. package/dist/module/CurrencyStrengthWidget/components/Chart/getOption.js +4 -0
  17. package/dist/module/CurrencyStrengthWidget/components/Chart/getOption.js.map +1 -1
  18. package/dist/types/CurrencyStrengthWidget/components/Chart/constants.d.ts +2 -0
  19. package/dist/types/CurrencyStrengthWidget/components/Chart/formatters.d.ts +2 -0
  20. package/dist/types/CurrencyStrengthWidget/components/Chart/getOption.d.ts +4 -0
  21. package/package.json +3 -3
  22. package/src/CurrencyStrengthWidget/ChartsWithData.tsx +2 -1
  23. package/src/CurrencyStrengthWidget/components/Chart/constants.tsx +12 -0
  24. package/src/CurrencyStrengthWidget/components/Chart/formatters.ts +16 -0
  25. package/src/CurrencyStrengthWidget/components/Chart/getOption.ts +4 -0
  26. package/test/sortData.test.ts +73 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,138 @@
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.16 (2024-03-07)
7
+
8
+
9
+
10
+ ## 1.0.97 (2024-03-06)
11
+
12
+
13
+
14
+ ## 1.0.96 (2024-03-06)
15
+
16
+
17
+
18
+ ## 1.0.95 (2024-03-04)
19
+
20
+
21
+
22
+ ## 1.0.94 (2024-02-29)
23
+
24
+
25
+
26
+ ## 1.0.93 (2024-02-28)
27
+
28
+
29
+
30
+ ## 1.0.92 (2024-02-28)
31
+
32
+
33
+
34
+ ## 1.0.91 (2024-02-23)
35
+
36
+
37
+
38
+ ## 1.0.90 (2024-02-23)
39
+
40
+
41
+
42
+ ## 1.0.89 (2024-02-21)
43
+
44
+
45
+
46
+ ## 1.0.88 (2024-02-21)
47
+
48
+
49
+
50
+ ## 1.0.87 (2024-02-20)
51
+
52
+
53
+
54
+ ## 1.0.86 (2024-02-20)
55
+
56
+
57
+
58
+ ## 1.0.85 (2024-02-13)
59
+
60
+
61
+
62
+ ## 1.0.84 (2024-02-13)
63
+
64
+
65
+
66
+ ## 1.0.83 (2024-02-09)
67
+
68
+ **Note:** Version bump only for package @oanda/labs-currency-strength-widget
69
+
70
+
71
+
72
+
73
+
74
+ ## 1.0.15 (2024-03-06)
75
+
76
+
77
+
78
+ ## 1.0.96 (2024-03-06)
79
+
80
+
81
+
82
+ ## 1.0.95 (2024-03-04)
83
+
84
+
85
+
86
+ ## 1.0.94 (2024-02-29)
87
+
88
+
89
+
90
+ ## 1.0.93 (2024-02-28)
91
+
92
+
93
+
94
+ ## 1.0.92 (2024-02-28)
95
+
96
+
97
+
98
+ ## 1.0.91 (2024-02-23)
99
+
100
+
101
+
102
+ ## 1.0.90 (2024-02-23)
103
+
104
+
105
+
106
+ ## 1.0.89 (2024-02-21)
107
+
108
+
109
+
110
+ ## 1.0.88 (2024-02-21)
111
+
112
+
113
+
114
+ ## 1.0.87 (2024-02-20)
115
+
116
+
117
+
118
+ ## 1.0.86 (2024-02-20)
119
+
120
+
121
+
122
+ ## 1.0.85 (2024-02-13)
123
+
124
+
125
+
126
+ ## 1.0.84 (2024-02-13)
127
+
128
+
129
+
130
+ ## 1.0.83 (2024-02-09)
131
+
132
+ **Note:** Version bump only for package @oanda/labs-currency-strength-widget
133
+
134
+
135
+
136
+
137
+
6
138
  ## 1.0.14 (2024-03-06)
7
139
 
8
140
 
@@ -10,11 +10,12 @@ var _labsWidgetCommon = require("@oanda/labs-widget-common");
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _getCurrencyStrength = require("../gql/getCurrencyStrength");
12
12
  var _Chart = require("./components/Chart");
13
+ var _formatters = require("./components/Chart/formatters");
13
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
17
  const ChartWithData = () => {
17
- var _data$currencyStrengt, _data$currencyStrengt2, _data$currencyStrengt3;
18
+ var _data$currencyStrengt, _data$currencyStrengt2, _sortData$currencyStr;
18
19
  const {
19
20
  size
20
21
  } = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
@@ -38,7 +39,7 @@ const ChartWithData = () => {
38
39
  'lw-grid-cols-3 ': isDesktop,
39
40
  'lw-grid-cols-1': !isDesktop
40
41
  })
41
- }, (_data$currencyStrengt3 = data.currencyStrength) === null || _data$currencyStrengt3 === void 0 ? void 0 : _data$currencyStrengt3.map(item => _react.default.createElement("div", {
42
+ }, (_sortData$currencyStr = (0, _formatters.sortData)(data).currencyStrength) === null || _sortData$currencyStr === void 0 ? void 0 : _sortData$currencyStr.map(item => _react.default.createElement("div", {
42
43
  key: item.currency,
43
44
  className: "lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center"
44
45
  }, _react.default.createElement(_Chart.Chart, {
@@ -1 +1 @@
1
- {"version":3,"file":"ChartsWithData.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_classnames","_interopRequireDefault","_getCurrencyStrength","_Chart","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ChartWithData","_data$currencyStrengt","_data$currencyStrengt2","_data$currencyStrengt3","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","loading","data","error","useQuery","getCurrencyStrength","fetchPolicy","showChart","currencyStrength","length","showError","createElement","Fragment","className","Spinner","SpinnerSize","lg","classnames","map","item","key","currency","Chart","values","strengthRelation","ChartError","exports"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\n\nconst ChartWithData = () => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop,\n 'lw-grid-cols-1': !isDesktop,\n })}\n >\n {data.currencyStrength?.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart currency={item.currency} values={item.strengthRelation!} />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAIA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AAA2C,SAAAI,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAZ,wBAAAY,CA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AI,CAACE,QAAS;IAACE,MAAM,EAAEJ,IAAI,CAACK;EAAkB,CAAE,CAC9D,CACN,CACE,CACN,EACA,CAACvB,OAAO,IAAIS,SAAS,IACpBlD,MAAA,CAAAW,OAAA,CAAAwC,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChHrD,MAAA,CAAAW,OAAA,CAAAwC,aAAA,CAAC/C,iBAAA,CAAA6D,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAACC,OAAA,CAAAnC,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"ChartsWithData.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_classnames","_interopRequireDefault","_getCurrencyStrength","_Chart","_formatters","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","ChartWithData","_data$currencyStrengt","_data$currencyStrengt2","_sortData$currencyStr","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","loading","data","error","useQuery","getCurrencyStrength","fetchPolicy","showChart","currencyStrength","length","showError","createElement","Fragment","className","Spinner","SpinnerSize","lg","classnames","sortData","map","item","key","currency","Chart","values","strengthRelation","ChartError","exports"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { sortData } from './components/Chart/formatters';\n\nconst ChartWithData = () => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop,\n 'lw-grid-cols-1': !isDesktop,\n })}\n >\n {sortData(data).currencyStrength?.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart currency={item.currency} values={item.strengthRelation!} />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAIA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAAyD,SAAAI,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAb,wBAAAa,CAAA,EAAAE,CAAA,SAAAA,CAAA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,CAACE,QAAS;IAACE,MAAM,EAAEJ,IAAI,CAACK;EAAkB,CAAE,CAC9D,CACN,CACE,CACN,EACA,CAACxB,OAAO,IAAIS,SAAS,IACpBnD,MAAA,CAAAY,OAAA,CAAAwC,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChHtD,MAAA,CAAAY,OAAA,CAAAwC,aAAA,CAAChD,iBAAA,CAAA+D,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAACC,OAAA,CAAApC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -3,8 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.lightBarColors = exports.darkBarColors = exports.Y_LABEL_SIZE = exports.X_LABEL_SIZE = exports.CHART_WIDTH = exports.CHART_HEIGHT = void 0;
6
+ exports.lightBarColors = exports.instrumentsConfig = exports.darkBarColors = exports.Y_LABEL_SIZE = exports.X_LABEL_SIZE = exports.CHART_WIDTH = exports.CHART_HEIGHT = void 0;
7
7
  var _labsWidgetCommon = require("@oanda/labs-widget-common");
8
+ var _graphql = require("../../../gql/types/graphql");
8
9
  const X_LABEL_SIZE = exports.X_LABEL_SIZE = 24;
9
10
  const Y_LABEL_SIZE = exports.Y_LABEL_SIZE = 30;
10
11
  const CHART_WIDTH = exports.CHART_WIDTH = 9999;
@@ -19,4 +20,5 @@ const lightBarColors = exports.lightBarColors = {
19
20
  negative: _labsWidgetCommon.colorPalette.raspberryDark,
20
21
  zero: _labsWidgetCommon.colorPalette.disabledGray
21
22
  };
23
+ const instrumentsConfig = exports.instrumentsConfig = [_graphql.CurrencyName.Usd, _graphql.CurrencyName.Eur, _graphql.CurrencyName.Jpy, _graphql.CurrencyName.Gbp, _graphql.CurrencyName.Aud, _graphql.CurrencyName.Cad, _graphql.CurrencyName.Chf, _graphql.CurrencyName.Nzd];
22
24
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","X_LABEL_SIZE","exports","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","darkBarColors","positive","colorPalette","bottleGreenLight","negative","orange","zero","disabledGray","lightBarColors","raspberryDark"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\n\nexport const X_LABEL_SIZE = 24;\nexport const Y_LABEL_SIZE = 30;\nexport const CHART_WIDTH = 9999;\nexport const CHART_HEIGHT = 135;\n\nexport const darkBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.orange,\n zero: colorPalette.disabledGray,\n};\n\nexport const lightBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.raspberryDark,\n zero: colorPalette.disabledGray,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEO,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,EAAE;AACvB,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAAF,OAAA,CAAAE,WAAA,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,GAAG;AAExB,MAAMC,aAAa,GAAAJ,OAAA,CAAAI,aAAA,GAAG;EAC3BC,QAAQ,EAAEC,8BAAY,CAACC,gBAAgB;EACvCC,QAAQ,EAAEF,8BAAY,CAACG,MAAM;EAC7BC,IAAI,EAAEJ,8BAAY,CAACK;AACrB,CAAC;AAEM,MAAMC,cAAc,GAAAZ,OAAA,CAAAY,cAAA,GAAG;EAC5BP,QAAQ,EAAEC,8BAAY,CAACC,gBAAgB;EACvCC,QAAQ,EAAEF,8BAAY,CAACO,aAAa;EACpCH,IAAI,EAAEJ,8BAAY,CAACK;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","_graphql","X_LABEL_SIZE","exports","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","darkBarColors","positive","colorPalette","bottleGreenLight","negative","orange","zero","disabledGray","lightBarColors","raspberryDark","instrumentsConfig","CurrencyName","Usd","Eur","Jpy","Gbp","Aud","Cad","Chf","Nzd"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport { CurrencyName } from '../../../gql/types/graphql';\n\nexport const X_LABEL_SIZE = 24;\nexport const Y_LABEL_SIZE = 30;\nexport const CHART_WIDTH = 9999;\nexport const CHART_HEIGHT = 135;\n\nexport const darkBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.orange,\n zero: colorPalette.disabledGray,\n};\n\nexport const lightBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.raspberryDark,\n zero: colorPalette.disabledGray,\n};\n\nexport const instrumentsConfig = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Jpy,\n CurrencyName.Gbp,\n CurrencyName.Aud,\n CurrencyName.Cad,\n CurrencyName.Chf,\n CurrencyName.Nzd,\n];\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,EAAE;AACvB,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAAF,OAAA,CAAAE,WAAA,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,GAAG;AAExB,MAAMC,aAAa,GAAAJ,OAAA,CAAAI,aAAA,GAAG;EAC3BC,QAAQ,EAAEC,8BAAY,CAACC,gBAAgB;EACvCC,QAAQ,EAAEF,8BAAY,CAACG,MAAM;EAC7BC,IAAI,EAAEJ,8BAAY,CAACK;AACrB,CAAC;AAEM,MAAMC,cAAc,GAAAZ,OAAA,CAAAY,cAAA,GAAG;EAC5BP,QAAQ,EAAEC,8BAAY,CAACC,gBAAgB;EACvCC,QAAQ,EAAEF,8BAAY,CAACO,aAAa;EACpCH,IAAI,EAAEJ,8BAAY,CAACK;AACrB,CAAC;AAEM,MAAMG,iBAAiB,GAAAd,OAAA,CAAAc,iBAAA,GAAG,CAC/BC,qBAAY,CAACC,GAAG,EAChBD,qBAAY,CAACE,GAAG,EAChBF,qBAAY,CAACG,GAAG,EAChBH,qBAAY,CAACI,GAAG,EAChBJ,qBAAY,CAACK,GAAG,EAChBL,qBAAY,CAACM,GAAG,EAChBN,qBAAY,CAACO,GAAG,EAChBP,qBAAY,CAACQ,GAAG,CACjB","ignoreList":[]}
@@ -3,7 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.tooltipFormatter = void 0;
6
+ exports.tooltipFormatter = exports.sortData = void 0;
7
+ var _constants = require("./constants");
7
8
  const tooltipFormatter = _ref => {
8
9
  let {
9
10
  marker,
@@ -15,4 +16,11 @@ const tooltipFormatter = _ref => {
15
16
  return "\n<div>\n <div style=\"margin-bottom:5px;\">".concat(currency, " ").concat(lang('vs'), " ").concat(name, "</div>\n <div style=\"display:flex;align-items:center;\">").concat(marker, " ").concat(value, "%</div>\n</div>");
16
17
  };
17
18
  exports.tooltipFormatter = tooltipFormatter;
19
+ const sortData = data => ({
20
+ currencyStrength: data.currencyStrength && [...data.currencyStrength].sort((a, b) => _constants.instrumentsConfig.indexOf(a.currency) - _constants.instrumentsConfig.indexOf(b.currency)).map(item => ({
21
+ currency: item.currency,
22
+ strengthRelation: item.strengthRelation && [...item.strengthRelation].sort((a, b) => _constants.instrumentsConfig.indexOf(a.currency) - _constants.instrumentsConfig.indexOf(b.currency))
23
+ }))
24
+ });
25
+ exports.sortData = sortData;
18
26
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":["tooltipFormatter","_ref","marker","name","value","currency","lang","concat","exports"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { TooltipFormatterParams } from './types';\n\nexport const tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IAC/BC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D;AAACI,OAAA,CAAAR,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"file":"formatters.js","names":["_constants","require","tooltipFormatter","_ref","marker","name","value","currency","lang","concat","exports","sortData","data","currencyStrength","sort","a","b","instrumentsConfig","indexOf","map","item","strengthRelation"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';\nimport { instrumentsConfig } from './constants';\nimport { TooltipFormatterParams } from './types';\n\nexport const tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n\nexport const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery = (\n data,\n) => ({\n currencyStrength: data.currencyStrength\n && [...data.currencyStrength].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ).map((item) => ({\n currency: item.currency,\n strengthRelation: item.strengthRelation && [...item.strengthRelation].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ),\n })),\n});\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAGO,MAAMC,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IAC/BC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D;AAACI,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AAED,MAAMS,QAAsE,GACjFC,IAAI,KACA;EACJC,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IACpC,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACC,IAAI,CAChC,CAACC,CAAC,EAAEC,CAAC,KAAKC,4BAAiB,CAACC,OAAO,CAACH,CAAC,CAACR,QAAQ,CAAC,GAAGU,4BAAiB,CAACC,OAAO,CAACF,CAAC,CAACT,QAAQ,CACxF,CAAC,CAACY,GAAG,CAAEC,IAAI,KAAM;IACfb,QAAQ,EAAEa,IAAI,CAACb,QAAQ;IACvBc,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IAAI,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACP,IAAI,CACxE,CAACC,CAAC,EAAEC,CAAC,KAAKC,4BAAiB,CAACC,OAAO,CAACH,CAAC,CAACR,QAAQ,CAAC,GAAGU,4BAAiB,CAACC,OAAO,CAACF,CAAC,CAACT,QAAQ,CACxF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC;AAACG,OAAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -100,7 +100,11 @@ const getOption = _ref => {
100
100
  series: [{
101
101
  data: percentages,
102
102
  type: 'bar',
103
+ emphasis: {
104
+ disabled: true
105
+ },
103
106
  itemStyle: {
107
+ opacity: 1,
104
108
  color: _ref3 => {
105
109
  let {
106
110
  data
@@ -1 +1 @@
1
- {"version":3,"file":"getOption.js","names":["_labsWidgetCommon","require","_constants","_formatters","getOption","_ref","values","currency","isDark","lang","currencies","map","item","percentages","percentage","barColors","darkBarColors","lightBarColors","gridLines","getGridLines","chartWidth","CHART_WIDTH","chartHeight","CHART_HEIGHT","xLabelsSize","yLabelSize","animation","title","left","text","concat","textStyle","fontSize","lineHeight","fontWeight","grid","name","top","right","Y_LABEL_SIZE","bottom","X_LABEL_SIZE","graphic","tooltip","trigger","formatter","_ref2","marker","value","tooltipFormatter","axisPointer","axis","extraCssText","xAxis","type","data","axisTick","show","axisLine","splitLine","axisLabel","yAxis","position","min","Math","floor","max","ceil","interval","series","itemStyle","color","_ref3","positive","negative","zero","exports"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/getOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n X_LABEL_SIZE,\n Y_LABEL_SIZE,\n darkBarColors,\n lightBarColors,\n} from './constants';\nimport { GetOptionProps } from './types';\nimport { tooltipFormatter } from './formatters';\n\nexport const getOption = ({\n values, currency, isDark, lang,\n}: GetOptionProps) => {\n const currencies = values.map((item) => item.currency);\n const percentages = values.map((item) => item.percentage);\n const barColors = isDark ? darkBarColors : lightBarColors;\n\n const gridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: -2,\n yLabelSize: -3,\n });\n\n return {\n animation: false,\n title: {\n left: 'center',\n text: `${currency} vs`,\n textStyle: {\n fontSize: 12,\n lineHeight: 20,\n fontWeight: 400,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '30px',\n right: '0px',\n left: `${Y_LABEL_SIZE}px`,\n bottom: `${X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...gridLines,\n ],\n tooltip: {\n trigger: 'axis',\n formatter: (\n [{ marker, name, value }]\n : { marker: string, name: string, value: number }[],\n ) => tooltipFormatter({\n lang,\n currency,\n marker,\n name,\n value,\n }),\n axisPointer: {\n axis: 'x',\n },\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n data: currencies,\n axisTick: { show: false },\n axisLine: { show: false },\n splitLine: { show: false },\n axisLabel: {\n fontSize: 10,\n },\n },\n yAxis: {\n type: 'value',\n position: 'left',\n min: Math.floor(Math.min(...percentages)),\n max: Math.ceil(Math.max(...percentages)),\n interval: 1,\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n formatter: '{value}%',\n fontSize: 10,\n },\n },\n series: [\n {\n data: percentages,\n type: 'bar',\n itemStyle: {\n color: ({ data } : { data: number }) => {\n if (data > 0) {\n return barColors.positive;\n }\n if (data < 0) {\n return barColors.negative;\n }\n return barColors.zero;\n },\n },\n },\n ],\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AASA,IAAAE,WAAA,GAAAF,OAAA;AAEO,MAAMG,SAAS,GAAGC,IAAA,IAEH;EAAA,IAFI;IACxBC,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EACZ,CAAC,GAAAJ,IAAA;EACf,MAAMK,UAAU,GAAGJ,MAAM,CAACK,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACL,QAAQ,CAAC;EACtD,MAAMM,WAAW,GAAGP,MAAM,CAACK,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACE,UAAU,CAAC;EACzD,MAAMC,SAAS,GAAGP,MAAM,GAAGQ,wBAAa,GAAGC,yBAAc;EAEzD,MAAMC,SAAS,GAAG,IAAAC,8BAAY,EAAC;IAC7BX,MAAM;IACNY,UAAU,EAAEC,sBAAW;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AAE,OAAO;MACbQ,QAAQ,EAAE,MAAM;MAChBC,GAAG,EAAEC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACD,GAAG,CAAC,GAAGlD,WAAW,CAAC,CAAC;MACzCqD,GAAG,EAAEF,IAAI,CAACG,IAAI,CAACH,IAAI,CAACE,GAAG,CAAC,GAAGrD,WAAW,CAAC,CAAC;MACxCuD,QAAQ,EAAE,CAAC;MACXV,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBD,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAM,CAAC;MACzBG,SAAS,EAAE;QACTf,SAAS,EAAE,UAAU;QACrBb,QAAQ,EAAE;MACZ;IACF,CAAC;IACDqC,MAAM,EAAE,CACN;MACEd,IAAI,EAAE1C,WAAW;MACjByC,IAAI,EAAE,KAAK;MACXgB,SAAS,EAAE;QACTC,KAAK,EAAEC,KAAA,IAAiC;UAAA,IAAhC;YAAEjB;UAAwB,CAAC,GAAAiB,KAAA;UACjC,IAAIjB,IAAI,GAAG,CAAC,EAAE;YACZ,OAAOxC,SAAS,CAAC0D,QAAQ;UAC3B;UACA,IAAIlB,IAAI,GAAG,CAAC,EAAE;YACZ,OAAOxC,SAAS,CAAC2D,QAAQ;UAC3B;UACA,OAAO3D,SAAS,CAAC4D,IAAI;QACvB;MACF;IACF,CAAC;EAEL,CAAC;AACH,CAAC;AAACC,OAAA,CAAAxE,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"getOption.js","names":["_labsWidgetCommon","require","_constants","_formatters","getOption","_ref","values","currency","isDark","lang","currencies","map","item","percentages","percentage","barColors","darkBarColors","lightBarColors","gridLines","getGridLines","chartWidth","CHART_WIDTH","chartHeight","CHART_HEIGHT","xLabelsSize","yLabelSize","animation","title","left","text","concat","textStyle","fontSize","lineHeight","fontWeight","grid","name","top","right","Y_LABEL_SIZE","bottom","X_LABEL_SIZE","graphic","tooltip","trigger","formatter","_ref2","marker","value","tooltipFormatter","axisPointer","axis","extraCssText","xAxis","type","data","axisTick","show","axisLine","splitLine","axisLabel","yAxis","position","min","Math","floor","max","ceil","interval","series","emphasis","disabled","itemStyle","opacity","color","_ref3","positive","negative","zero","exports"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/getOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n X_LABEL_SIZE,\n Y_LABEL_SIZE,\n darkBarColors,\n lightBarColors,\n} from './constants';\nimport { GetOptionProps } from './types';\nimport { tooltipFormatter } from './formatters';\n\nexport const getOption = ({\n values, currency, isDark, lang,\n}: GetOptionProps) => {\n const currencies = values.map((item) => item.currency);\n const percentages = values.map((item) => item.percentage);\n const barColors = isDark ? darkBarColors : lightBarColors;\n\n const gridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: -2,\n yLabelSize: -3,\n });\n\n return {\n animation: false,\n title: {\n left: 'center',\n text: `${currency} vs`,\n textStyle: {\n fontSize: 12,\n lineHeight: 20,\n fontWeight: 400,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '30px',\n right: '0px',\n left: `${Y_LABEL_SIZE}px`,\n bottom: `${X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...gridLines,\n ],\n tooltip: {\n trigger: 'axis',\n formatter: (\n [{ marker, name, value }]\n : { marker: string, name: string, value: number }[],\n ) => tooltipFormatter({\n lang,\n currency,\n marker,\n name,\n value,\n }),\n axisPointer: {\n axis: 'x',\n },\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n data: currencies,\n axisTick: { show: false },\n axisLine: { show: false },\n splitLine: { show: false },\n axisLabel: {\n fontSize: 10,\n },\n },\n yAxis: {\n type: 'value',\n position: 'left',\n min: Math.floor(Math.min(...percentages)),\n max: Math.ceil(Math.max(...percentages)),\n interval: 1,\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n formatter: '{value}%',\n fontSize: 10,\n },\n },\n series: [\n {\n data: percentages,\n type: 'bar',\n emphasis: {\n disabled: true,\n },\n itemStyle: {\n opacity: 1,\n color: ({ data } : { data: number }) => {\n if (data > 0) {\n return barColors.positive;\n }\n if (data < 0) {\n return barColors.negative;\n }\n return barColors.zero;\n },\n },\n },\n ],\n };\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AASA,IAAAE,WAAA,GAAAF,OAAA;AAEO,MAAMG,SAAS,GAAGC,IAAA,IAEH;EAAA,IAFI;IACxBC,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EACZ,CAAC,GAAAJ,IAAA;EACf,MAAMK,UAAU,GAAGJ,MAAM,CAACK,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACL,QAAQ,CAAC;EACtD,MAAMM,WAAW,GAAGP,MAAM,CAACK,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACE,UAAU,CAAC;EACzD,MAAMC,SAAS,GAAGP,MAAM,GAAGQ,wBAAa,GAAGC,yBAAc;EAEzD,MAAMC,SAAS,GAAG,IAAAC,8BAAY,EAAC;IAC7BX,MAAM;IACNY,UAAU,EAAEC,sBAAW;IACvBC,WAAW,EAAEC,uBAAY;IACzBC,WAAW,EAAE,CAAC,CAAC;IACfC,UAAU,EAAE,CAAC;EACf,CAAC,CAAC;EAEF,OAAO;IACLC,SAAS,EAAE,KAAK;IAChBC,KAAK,EAAE;MACLC,IAAI,EAAE,QAAQ;MACdC,IAAI,KAAAC,MAAA,CAAKvB,QAAQ,QAAK;MACtBwB,SAAS,EAAE;QACTC,QAAQ,EAAE,EAAE;QACZC,UAAU,EAAE,EAAE;QACdC,UAAU,EAAE;MACd;IACF,CAAC;IACDC,IAAI,EAAE,CACJ;MACEC,IAAI,EAAE,WAAW;MACjBC,GAAG,EAAE,MAAM;MACXC,KAAK,EAAE,KAAK;MACZV,IAAI,KAAAE,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AM,EAAE,CACN;MACEd,IAAI,EAAE1C,WAAW;MACjByC,IAAI,EAAE,KAAK;MACXgB,QAAQ,EAAE;QACRC,QAAQ,EAAE;MACZ,CAAC;MACDC,SAAS,EAAE;QACTC,OAAO,EAAE,CAAC;QACVC,KAAK,EAAEC,KAAA,IAAiC;UAAA,IAAhC;YAAEpB;UAAwB,CAAC,GAAAoB,KAAA;UACjC,IAAIpB,IAAI,GAAG,CAAC,EAAE;YACZ,OAAOxC,SAAS,CAAC6D,QAAQ;UAC3B;UACA,IAAIrB,IAAI,GAAG,CAAC,EAAE;YACZ,OAAOxC,SAAS,CAAC8D,QAAQ;UAC3B;UACA,OAAO9D,SAAS,CAAC+D,IAAI;QACvB;MACF;IACF,CAAC;EAEL,CAAC;AACH,CAAC;AAACC,OAAA,CAAA3E,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -4,8 +4,9 @@ import { ChartError, Size, Spinner, SpinnerSize, ThemeContext } from '@oanda/lab
4
4
  import classnames from 'classnames';
5
5
  import { getCurrencyStrength } from '../gql/getCurrencyStrength';
6
6
  import { Chart } from './components/Chart';
7
+ import { sortData } from './components/Chart/formatters';
7
8
  const ChartWithData = () => {
8
- var _data$currencyStrengt, _data$currencyStrengt2, _data$currencyStrengt3;
9
+ var _data$currencyStrengt, _data$currencyStrengt2, _sortData$currencyStr;
9
10
  const {
10
11
  size
11
12
  } = useContext(ThemeContext);
@@ -29,7 +30,7 @@ const ChartWithData = () => {
29
30
  'lw-grid-cols-3 ': isDesktop,
30
31
  'lw-grid-cols-1': !isDesktop
31
32
  })
32
- }, (_data$currencyStrengt3 = data.currencyStrength) === null || _data$currencyStrengt3 === void 0 ? void 0 : _data$currencyStrengt3.map(item => React.createElement("div", {
33
+ }, (_sortData$currencyStr = sortData(data).currencyStrength) === null || _sortData$currencyStr === void 0 ? void 0 : _sortData$currencyStr.map(item => React.createElement("div", {
33
34
  key: item.currency,
34
35
  className: "lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center"
35
36
  }, React.createElement(Chart, {
@@ -1 +1 @@
1
- {"version":3,"file":"ChartsWithData.js","names":["React","useContext","useQuery","ChartError","Size","Spinner","SpinnerSize","ThemeContext","classnames","getCurrencyStrength","Chart","ChartWithData","_data$currencyStrengt","_data$currencyStrengt2","_data$currencyStrengt3","size","isDesktop","DESKTOP","loading","data","error","fetchPolicy","showChart","currencyStrength","length","showError","createElement","Fragment","className","lg","map","item","key","currency","values","strengthRelation"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\n\nconst ChartWithData = () => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop,\n 'lw-grid-cols-1': !isDesktop,\n })}\n >\n {data.currencyStrength?.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart currency={item.currency} values={item.strengthRelation!} />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[425px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AChH5B,KAAA,CAAA0B,aAAA,CAACrB,OAAO;IAACU,IAAI,EAAET,WAAW,CAACuB;EAAG,CAAE,CAC7B,CACN,EACA,CAACX,OAAO,IAAII,SAAS,IACpBtB,KAAA,CAAA0B,aAAA;IACE,eAAY,iCAAiC;IAC7CE,SAAS,EAAEpB,UAAU,CAAC,0CAA0C,EAAE;MAChE,iBAAiB,EAAEQ,SAAS;MAC5B,gBAAgB,EAAE,CAACA;IACrB,CAAC;EAAE,IAAAF,sBAAA,GAEFK,IAAI,CAACI,gBAAgB,cAAAT,sBAAA,uBAArBA,sBAAA,CAAuBgB,GAAG,CAAEC,IAAI,IAC/B/B,KAAA,CAAA0B,aAAA;IAAKM,GAAG,EAAED,IAAI,CAACE,QAAS;IAACL,SAAS,EAAC;EAAkE,GACnG5B,KAAA,CAAA0B,aAAA,CAAChB,KAAK;IAACuB,QAAQ,EAAEF,IAAI,CAACE,QAAS;IAACC,MAAM,EAAEH,IAAI,CAACI;EAAkB,CAAE,CAC9D,CACN,CACE,CACN,EACA,CAACjB,OAAO,IAAIO,SAAS,IACpBzB,KAAA,CAAA0B,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChH5B,KAAA,CAAA0B,aAAA,CAACvB,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAED,SAASQ,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"ChartsWithData.js","names":["React","useContext","useQuery","ChartError","Size","Spinner","SpinnerSize","ThemeContext","classnames","getCurrencyStrength","Chart","sortData","ChartWithData","_data$currencyStrengt","_data$currencyStrengt2","_sortData$currencyStr","size","isDesktop","DESKTOP","loading","data","error","fetchPolicy","showChart","currencyStrength","length","showError","createElement","Fragment","className","lg","map","item","key","currency","values","strengthRelation"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { sortData } from './components/Chart/formatters';\n\nconst ChartWithData = () => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop,\n 'lw-grid-cols-1': !isDesktop,\n })}\n >\n {sortData(data).currencyStrength?.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart currency={item.currency} values={item.strengthRelation!} />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,UAAU,EAAEC,IAAI,EAAEC,OAAO,EAAEC,WAAW,EACtCC,YAAY,QACP,2BAA2B;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,mBAAmB,QAAQ,4BAA4B;AAEhE,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,QAAQ,QAAQ,+BAA+B;AA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AA/BA,qBAAA,CAAiCgB,GAAG,CAAEC,IAAI,IACzChC,KAAA,CAAA2B,aAAA;IAAKM,GAAG,EAAED,IAAI,CAACE,QAAS;IAACL,SAAS,EAAC;EAAkE,GACnG7B,KAAA,CAAA2B,aAAA,CAACjB,KAAK;IAACwB,QAAQ,EAAEF,IAAI,CAACE,QAAS;IAACC,MAAM,EAAEH,IAAI,CAACI;EAAkB,CAAE,CAC9D,CACN,CACE,CACN,EACA,CAACjB,OAAO,IAAIO,SAAS,IACpB1B,KAAA,CAAA2B,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChH7B,KAAA,CAAA2B,aAAA,CAACxB,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAED,SAASS,aAAa","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import { colorPalette } from '@oanda/labs-widget-common';
2
+ import { CurrencyName } from '../../../gql/types/graphql';
2
3
  export const X_LABEL_SIZE = 24;
3
4
  export const Y_LABEL_SIZE = 30;
4
5
  export const CHART_WIDTH = 9999;
@@ -13,4 +14,5 @@ export const lightBarColors = {
13
14
  negative: colorPalette.raspberryDark,
14
15
  zero: colorPalette.disabledGray
15
16
  };
17
+ export const instrumentsConfig = [CurrencyName.Usd, CurrencyName.Eur, CurrencyName.Jpy, CurrencyName.Gbp, CurrencyName.Aud, CurrencyName.Cad, CurrencyName.Chf, CurrencyName.Nzd];
16
18
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["colorPalette","X_LABEL_SIZE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","darkBarColors","positive","bottleGreenLight","negative","orange","zero","disabledGray","lightBarColors","raspberryDark"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\n\nexport const X_LABEL_SIZE = 24;\nexport const Y_LABEL_SIZE = 30;\nexport const CHART_WIDTH = 9999;\nexport const CHART_HEIGHT = 135;\n\nexport const darkBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.orange,\n zero: colorPalette.disabledGray,\n};\n\nexport const lightBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.raspberryDark,\n zero: colorPalette.disabledGray,\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAExD,OAAO,MAAMC,YAAY,GAAG,EAAE;AAC9B,OAAO,MAAMC,YAAY,GAAG,EAAE;AAC9B,OAAO,MAAMC,WAAW,GAAG,IAAI;AAC/B,OAAO,MAAMC,YAAY,GAAG,GAAG;AAE/B,OAAO,MAAMC,aAAa,GAAG;EAC3BC,QAAQ,EAAEN,YAAY,CAACO,gBAAgB;EACvCC,QAAQ,EAAER,YAAY,CAACS,MAAM;EAC7BC,IAAI,EAAEV,YAAY,CAACW;AACrB,CAAC;AAED,OAAO,MAAMC,cAAc,GAAG;EAC5BN,QAAQ,EAAEN,YAAY,CAACO,gBAAgB;EACvCC,QAAQ,EAAER,YAAY,CAACa,aAAa;EACpCH,IAAI,EAAEV,YAAY,CAACW;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","names":["colorPalette","CurrencyName","X_LABEL_SIZE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","darkBarColors","positive","bottleGreenLight","negative","orange","zero","disabledGray","lightBarColors","raspberryDark","instrumentsConfig","Usd","Eur","Jpy","Gbp","Aud","Cad","Chf","Nzd"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport { CurrencyName } from '../../../gql/types/graphql';\n\nexport const X_LABEL_SIZE = 24;\nexport const Y_LABEL_SIZE = 30;\nexport const CHART_WIDTH = 9999;\nexport const CHART_HEIGHT = 135;\n\nexport const darkBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.orange,\n zero: colorPalette.disabledGray,\n};\n\nexport const lightBarColors = {\n positive: colorPalette.bottleGreenLight,\n negative: colorPalette.raspberryDark,\n zero: colorPalette.disabledGray,\n};\n\nexport const instrumentsConfig = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Jpy,\n CurrencyName.Gbp,\n CurrencyName.Aud,\n CurrencyName.Cad,\n CurrencyName.Chf,\n CurrencyName.Nzd,\n];\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SAASC,YAAY,QAAQ,4BAA4B;AAEzD,OAAO,MAAMC,YAAY,GAAG,EAAE;AAC9B,OAAO,MAAMC,YAAY,GAAG,EAAE;AAC9B,OAAO,MAAMC,WAAW,GAAG,IAAI;AAC/B,OAAO,MAAMC,YAAY,GAAG,GAAG;AAE/B,OAAO,MAAMC,aAAa,GAAG;EAC3BC,QAAQ,EAAEP,YAAY,CAACQ,gBAAgB;EACvCC,QAAQ,EAAET,YAAY,CAACU,MAAM;EAC7BC,IAAI,EAAEX,YAAY,CAACY;AACrB,CAAC;AAED,OAAO,MAAMC,cAAc,GAAG;EAC5BN,QAAQ,EAAEP,YAAY,CAACQ,gBAAgB;EACvCC,QAAQ,EAAET,YAAY,CAACc,aAAa;EACpCH,IAAI,EAAEX,YAAY,CAACY;AACrB,CAAC;AAED,OAAO,MAAMG,iBAAiB,GAAG,CAC/Bd,YAAY,CAACe,GAAG,EAChBf,YAAY,CAACgB,GAAG,EAChBhB,YAAY,CAACiB,GAAG,EAChBjB,YAAY,CAACkB,GAAG,EAChBlB,YAAY,CAACmB,GAAG,EAChBnB,YAAY,CAACoB,GAAG,EAChBpB,YAAY,CAACqB,GAAG,EAChBrB,YAAY,CAACsB,GAAG,CACjB","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ import { instrumentsConfig } from './constants';
1
2
  export const tooltipFormatter = _ref => {
2
3
  let {
3
4
  marker,
@@ -8,4 +9,10 @@ export const tooltipFormatter = _ref => {
8
9
  } = _ref;
9
10
  return "\n<div>\n <div style=\"margin-bottom:5px;\">".concat(currency, " ").concat(lang('vs'), " ").concat(name, "</div>\n <div style=\"display:flex;align-items:center;\">").concat(marker, " ").concat(value, "%</div>\n</div>");
10
11
  };
12
+ export const sortData = data => ({
13
+ currencyStrength: data.currencyStrength && [...data.currencyStrength].sort((a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency)).map(item => ({
14
+ currency: item.currency,
15
+ strengthRelation: item.strengthRelation && [...item.strengthRelation].sort((a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency))
16
+ }))
17
+ });
11
18
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":["tooltipFormatter","_ref","marker","name","value","currency","lang","concat"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { TooltipFormatterParams } from './types';\n\nexport const tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IAC/BC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D","ignoreList":[]}
1
+ {"version":3,"file":"formatters.js","names":["instrumentsConfig","tooltipFormatter","_ref","marker","name","value","currency","lang","concat","sortData","data","currencyStrength","sort","a","b","indexOf","map","item","strengthRelation"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';\nimport { instrumentsConfig } from './constants';\nimport { TooltipFormatterParams } from './types';\n\nexport const tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n\nexport const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery = (\n data,\n) => ({\n currencyStrength: data.currencyStrength\n && [...data.currencyStrength].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ).map((item) => ({\n currency: item.currency,\n strengthRelation: item.strengthRelation && [...item.strengthRelation].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ),\n })),\n});\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,aAAa;AAG/C,OAAO,MAAMC,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IAC/BC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D;AAEP,OAAO,MAAMI,QAAsE,GACjFC,IAAI,KACA;EACJC,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IACpC,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACC,IAAI,CAChC,CAACC,CAAC,EAAEC,CAAC,KAAKd,iBAAiB,CAACe,OAAO,CAACF,CAAC,CAACP,QAAQ,CAAC,GAAGN,iBAAiB,CAACe,OAAO,CAACD,CAAC,CAACR,QAAQ,CACxF,CAAC,CAACU,GAAG,CAAEC,IAAI,KAAM;IACfX,QAAQ,EAAEW,IAAI,CAACX,QAAQ;IACvBY,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IAAI,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACN,IAAI,CACxE,CAACC,CAAC,EAAEC,CAAC,KAAKd,iBAAiB,CAACe,OAAO,CAACF,CAAC,CAACP,QAAQ,CAAC,GAAGN,iBAAiB,CAACe,OAAO,CAACD,CAAC,CAACR,QAAQ,CACxF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -94,7 +94,11 @@ export const getOption = _ref => {
94
94
  series: [{
95
95
  data: percentages,
96
96
  type: 'bar',
97
+ emphasis: {
98
+ disabled: true
99
+ },
97
100
  itemStyle: {
101
+ opacity: 1,
98
102
  color: _ref3 => {
99
103
  let {
100
104
  data
@@ -1 +1 @@
1
- {"version":3,"file":"getOption.js","names":["getGridLines","CHART_HEIGHT","CHART_WIDTH","X_LABEL_SIZE","Y_LABEL_SIZE","darkBarColors","lightBarColors","tooltipFormatter","getOption","_ref","values","currency","isDark","lang","currencies","map","item","percentages","percentage","barColors","gridLines","chartWidth","chartHeight","xLabelsSize","yLabelSize","animation","title","left","text","concat","textStyle","fontSize","lineHeight","fontWeight","grid","name","top","right","bottom","graphic","tooltip","trigger","formatter","_ref2","marker","value","axisPointer","axis","extraCssText","xAxis","type","data","axisTick","show","axisLine","splitLine","axisLabel","yAxis","position","min","Math","floor","max","ceil","interval","series","itemStyle","color","_ref3","positive","negative","zero"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/getOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n X_LABEL_SIZE,\n Y_LABEL_SIZE,\n darkBarColors,\n lightBarColors,\n} from './constants';\nimport { GetOptionProps } from './types';\nimport { tooltipFormatter } from './formatters';\n\nexport const getOption = ({\n values, currency, isDark, lang,\n}: GetOptionProps) => {\n const currencies = values.map((item) => item.currency);\n const percentages = values.map((item) => item.percentage);\n const barColors = isDark ? darkBarColors : lightBarColors;\n\n const gridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: -2,\n yLabelSize: -3,\n });\n\n return {\n animation: false,\n title: {\n left: 'center',\n text: `${currency} vs`,\n textStyle: {\n fontSize: 12,\n lineHeight: 20,\n fontWeight: 400,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '30px',\n right: '0px',\n left: `${Y_LABEL_SIZE}px`,\n bottom: `${X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...gridLines,\n ],\n tooltip: {\n trigger: 'axis',\n formatter: (\n [{ marker, name, value }]\n : { marker: string, name: string, value: number }[],\n ) => tooltipFormatter({\n lang,\n currency,\n marker,\n name,\n value,\n }),\n axisPointer: {\n axis: 'x',\n },\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n data: currencies,\n axisTick: { show: false },\n axisLine: { show: false },\n splitLine: { show: false },\n axisLabel: {\n fontSize: 10,\n },\n },\n yAxis: {\n type: 'value',\n position: 'left',\n min: Math.floor(Math.min(...percentages)),\n max: Math.ceil(Math.max(...percentages)),\n interval: 1,\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n formatter: '{value}%',\n fontSize: 10,\n },\n },\n series: [\n {\n data: percentages,\n type: 'bar',\n itemStyle: {\n color: ({ data } : { data: number }) => {\n if (data > 0) {\n return barColors.positive;\n }\n if (data < 0) {\n return barColors.negative;\n }\n return barColors.zero;\n },\n },\n },\n ],\n };\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SACEC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,aAAa,EACbC,cAAc,QACT,aAAa;AAEpB,SAASC,gBAAgB,QAAQ,cAAc;AAE/C,OAAO,MAAMC,SAAS,GAAGC,IAAA,IAEH;EAAA,IAFI;IACxBC,MAAM;IAAEC,QAAQ;IAAEC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"file":"getOption.js","names":["getGridLines","CHART_HEIGHT","CHART_WIDTH","X_LABEL_SIZE","Y_LABEL_SIZE","darkBarColors","lightBarColors","tooltipFormatter","getOption","_ref","values","currency","isDark","lang","currencies","map","item","percentages","percentage","barColors","gridLines","chartWidth","chartHeight","xLabelsSize","yLabelSize","animation","title","left","text","concat","textStyle","fontSize","lineHeight","fontWeight","grid","name","top","right","bottom","graphic","tooltip","trigger","formatter","_ref2","marker","value","axisPointer","axis","extraCssText","xAxis","type","data","axisTick","show","axisLine","splitLine","axisLabel","yAxis","position","min","Math","floor","max","ceil","interval","series","emphasis","disabled","itemStyle","opacity","color","_ref3","positive","negative","zero"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/getOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n X_LABEL_SIZE,\n Y_LABEL_SIZE,\n darkBarColors,\n lightBarColors,\n} from './constants';\nimport { GetOptionProps } from './types';\nimport { tooltipFormatter } from './formatters';\n\nexport const getOption = ({\n values, currency, isDark, lang,\n}: GetOptionProps) => {\n const currencies = values.map((item) => item.currency);\n const percentages = values.map((item) => item.percentage);\n const barColors = isDark ? darkBarColors : lightBarColors;\n\n const gridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: -2,\n yLabelSize: -3,\n });\n\n return {\n animation: false,\n title: {\n left: 'center',\n text: `${currency} vs`,\n textStyle: {\n fontSize: 12,\n lineHeight: 20,\n fontWeight: 400,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '30px',\n right: '0px',\n left: `${Y_LABEL_SIZE}px`,\n bottom: `${X_LABEL_SIZE}px`,\n },\n ],\n graphic: [\n ...gridLines,\n ],\n tooltip: {\n trigger: 'axis',\n formatter: (\n [{ marker, name, value }]\n : { marker: string, name: string, value: number }[],\n ) => tooltipFormatter({\n lang,\n currency,\n marker,\n name,\n value,\n }),\n axisPointer: {\n axis: 'x',\n },\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n data: currencies,\n axisTick: { show: false },\n axisLine: { show: false },\n splitLine: { show: false },\n axisLabel: {\n fontSize: 10,\n },\n },\n yAxis: {\n type: 'value',\n position: 'left',\n min: Math.floor(Math.min(...percentages)),\n max: Math.ceil(Math.max(...percentages)),\n interval: 1,\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n formatter: '{value}%',\n fontSize: 10,\n },\n },\n series: [\n {\n data: percentages,\n type: 'bar',\n emphasis: {\n disabled: true,\n },\n itemStyle: {\n opacity: 1,\n color: ({ data } : { data: number }) => {\n if (data > 0) {\n return barColors.positive;\n }\n if (data < 0) {\n return barColors.negative;\n }\n return barColors.zero;\n },\n },\n },\n ],\n };\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SACEC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,YAAY,EACZC,aAAa,EACbC,cAAc,QACT,aAAa;AAEpB,SAASC,gBAAgB,QAAQ,cAAc;AAE/C,OAAO,MAAMC,SAAS,GAAGC,IAAA,IAEH;EAAA,IAFI;IACxBC,MAAM;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EACZ,CAAC,GAAAJ,IAAA;EACf,MAAMK,UAAU,GAAGJ,MAAM,CAACK,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACL,QAAQ,CAAC;EACtD,MAAMM,WAAW,GAAGP,MAAM,CAACK,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACE,UAAU,CAAC;EACzD,MAAMC,SAAS,GAAGP,MAAM,GAAGP,aAAa,GAAGC,cAAc;EAEzD,MAAMc,SAAS,GAAGpB,YAAY,CAAC;IAC7BY,MAAM;IACNS,UAAU,EAAEnB,WAAW;IACvBoB,WAAW,EAAErB,YAAY;IACzBsB,WAAW,EAAE,CAAC,CAAC;IACfC,UAAU,EAAE,CAAC;EACf,CAAC,CAAC;EAEF,OAAO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AW,CAAC,CAAC;MACzC6C,GAAG,EAAEF,IAAI,CAACG,IAAI,CAACH,IAAI,CAACE,GAAG,CAAC,GAAG7C,WAAW,CAAC,CAAC;MACxC+C,QAAQ,EAAE,CAAC;MACXV,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBD,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAM,CAAC;MACzBG,SAAS,EAAE;QACTd,SAAS,EAAE,UAAU;QACrBX,QAAQ,EAAE;MACZ;IACF,CAAC;IACDkC,MAAM,EAAE,CACN;MACEd,IAAI,EAAElC,WAAW;MACjBiC,IAAI,EAAE,KAAK;MACXgB,QAAQ,EAAE;QACRC,QAAQ,EAAE;MACZ,CAAC;MACDC,SAAS,EAAE;QACTC,OAAO,EAAE,CAAC;QACVC,KAAK,EAAEC,KAAA,IAAiC;UAAA,IAAhC;YAAEpB;UAAwB,CAAC,GAAAoB,KAAA;UACjC,IAAIpB,IAAI,GAAG,CAAC,EAAE;YACZ,OAAOhC,SAAS,CAACqD,QAAQ;UAC3B;UACA,IAAIrB,IAAI,GAAG,CAAC,EAAE;YACZ,OAAOhC,SAAS,CAACsD,QAAQ;UAC3B;UACA,OAAOtD,SAAS,CAACuD,IAAI;QACvB;MACF;IACF,CAAC;EAEL,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ import { CurrencyName } from '../../../gql/types/graphql';
1
2
  export declare const X_LABEL_SIZE = 24;
2
3
  export declare const Y_LABEL_SIZE = 30;
3
4
  export declare const CHART_WIDTH = 9999;
@@ -12,3 +13,4 @@ export declare const lightBarColors: {
12
13
  negative: string;
13
14
  zero: string;
14
15
  };
16
+ export declare const instrumentsConfig: CurrencyName[];
@@ -1,2 +1,4 @@
1
+ import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';
1
2
  import { TooltipFormatterParams } from './types';
2
3
  export declare const tooltipFormatter: ({ marker, name, value, currency, lang, }: TooltipFormatterParams) => string;
4
+ export declare const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery;
@@ -160,7 +160,11 @@ export declare const getOption: ({ values, currency, isDark, lang, }: GetOptionP
160
160
  series: {
161
161
  data: number[];
162
162
  type: string;
163
+ emphasis: {
164
+ disabled: boolean;
165
+ };
163
166
  itemStyle: {
167
+ opacity: number;
164
168
  color: ({ data }: {
165
169
  data: number;
166
170
  }) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-strength-widget",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Labs Currency Strength 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.96",
16
+ "@oanda/labs-widget-common": "^1.0.98",
17
17
  "@oanda/mono-i18n": "9.0.0",
18
18
  "classnames": "2.3.2",
19
19
  "echarts": "5.5.0",
@@ -25,5 +25,5 @@
25
25
  "@graphql-codegen/client-preset": "4.1.0",
26
26
  "@graphql-codegen/typescript": "4.0.1"
27
27
  },
28
- "gitHead": "3e142032b1e3d871eda110681caea11a1c87e238"
28
+ "gitHead": "6122902e4027d79f8317c4f1a201adb0279f2b6d"
29
29
  }
@@ -8,6 +8,7 @@ import classnames from 'classnames';
8
8
  import { getCurrencyStrength } from '../gql/getCurrencyStrength';
9
9
  import { GetCurrencyStrengthQuery } from '../gql/types/graphql';
10
10
  import { Chart } from './components/Chart';
11
+ import { sortData } from './components/Chart/formatters';
11
12
 
12
13
  const ChartWithData = () => {
13
14
  const { size } = useContext(ThemeContext);
@@ -35,7 +36,7 @@ const ChartWithData = () => {
35
36
  'lw-grid-cols-1': !isDesktop,
36
37
  })}
37
38
  >
38
- {data.currencyStrength?.map((item) => (
39
+ {sortData(data).currencyStrength?.map((item) => (
39
40
  <div key={item.currency} className="lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center">
40
41
  <Chart currency={item.currency} values={item.strengthRelation!} />
41
42
  </div>
@@ -1,4 +1,5 @@
1
1
  import { colorPalette } from '@oanda/labs-widget-common';
2
+ import { CurrencyName } from '../../../gql/types/graphql';
2
3
 
3
4
  export const X_LABEL_SIZE = 24;
4
5
  export const Y_LABEL_SIZE = 30;
@@ -16,3 +17,14 @@ export const lightBarColors = {
16
17
  negative: colorPalette.raspberryDark,
17
18
  zero: colorPalette.disabledGray,
18
19
  };
20
+
21
+ export const instrumentsConfig = [
22
+ CurrencyName.Usd,
23
+ CurrencyName.Eur,
24
+ CurrencyName.Jpy,
25
+ CurrencyName.Gbp,
26
+ CurrencyName.Aud,
27
+ CurrencyName.Cad,
28
+ CurrencyName.Chf,
29
+ CurrencyName.Nzd,
30
+ ];
@@ -1,3 +1,5 @@
1
+ import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';
2
+ import { instrumentsConfig } from './constants';
1
3
  import { TooltipFormatterParams } from './types';
2
4
 
3
5
  export const tooltipFormatter = ({
@@ -11,3 +13,17 @@ export const tooltipFormatter = ({
11
13
  <div style="margin-bottom:5px;">${currency} ${lang('vs')} ${name}</div>
12
14
  <div style="display:flex;align-items:center;">${marker} ${value}%</div>
13
15
  </div>`;
16
+
17
+ export const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery = (
18
+ data,
19
+ ) => ({
20
+ currencyStrength: data.currencyStrength
21
+ && [...data.currencyStrength].sort(
22
+ (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),
23
+ ).map((item) => ({
24
+ currency: item.currency,
25
+ strengthRelation: item.strengthRelation && [...item.strengthRelation].sort(
26
+ (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),
27
+ ),
28
+ })),
29
+ });
@@ -92,7 +92,11 @@ export const getOption = ({
92
92
  {
93
93
  data: percentages,
94
94
  type: 'bar',
95
+ emphasis: {
96
+ disabled: true,
97
+ },
95
98
  itemStyle: {
99
+ opacity: 1,
96
100
  color: ({ data } : { data: number }) => {
97
101
  if (data > 0) {
98
102
  return barColors.positive;
@@ -0,0 +1,73 @@
1
+ import { sortData } from '../src/CurrencyStrengthWidget/components/Chart/formatters';
2
+ import { CurrencyName, GetCurrencyStrengthQuery } from '../src/gql/types/graphql';
3
+
4
+ const topLevelData: GetCurrencyStrengthQuery = {
5
+ currencyStrength: [
6
+ { currency: CurrencyName.Aud },
7
+ { currency: CurrencyName.Gbp },
8
+ { currency: CurrencyName.Jpy },
9
+ { currency: CurrencyName.Chf },
10
+ { currency: CurrencyName.Cad },
11
+ { currency: CurrencyName.Nzd },
12
+ { currency: CurrencyName.Usd },
13
+ { currency: CurrencyName.Eur },
14
+ ],
15
+ };
16
+
17
+ const nestedData: GetCurrencyStrengthQuery = {
18
+ currencyStrength: [
19
+ {
20
+ currency: CurrencyName.Aud,
21
+ strengthRelation: [
22
+ { currency: CurrencyName.Gbp, percentage: 0.1 },
23
+ { currency: CurrencyName.Eur, percentage: 0.2 },
24
+ { currency: CurrencyName.Aud, percentage: 0.3 },
25
+ { currency: CurrencyName.Jpy, percentage: 0.4 },
26
+ { currency: CurrencyName.Nzd, percentage: 0.5 },
27
+ { currency: CurrencyName.Chf, percentage: 0.6 },
28
+ { currency: CurrencyName.Usd, percentage: 0.7 },
29
+ { currency: CurrencyName.Cad, percentage: 0.8 },
30
+ ],
31
+ },
32
+ ],
33
+ };
34
+
35
+ describe('sortData', () => {
36
+ it('should sort top level values', () => {
37
+ expect(sortData(topLevelData)).toEqual(
38
+ {
39
+ currencyStrength: [
40
+ { currency: CurrencyName.Usd },
41
+ { currency: CurrencyName.Eur },
42
+ { currency: CurrencyName.Jpy },
43
+ { currency: CurrencyName.Gbp },
44
+ { currency: CurrencyName.Aud },
45
+ { currency: CurrencyName.Cad },
46
+ { currency: CurrencyName.Chf },
47
+ { currency: CurrencyName.Nzd },
48
+ ],
49
+ },
50
+ );
51
+ });
52
+ it('should sort nested values currencies', () => {
53
+ expect(sortData(nestedData)).toEqual(
54
+ {
55
+ currencyStrength: [
56
+ {
57
+ currency: CurrencyName.Aud,
58
+ strengthRelation: [
59
+ { currency: CurrencyName.Usd, percentage: 0.7 },
60
+ { currency: CurrencyName.Eur, percentage: 0.2 },
61
+ { currency: CurrencyName.Jpy, percentage: 0.4 },
62
+ { currency: CurrencyName.Gbp, percentage: 0.1 },
63
+ { currency: CurrencyName.Aud, percentage: 0.3 },
64
+ { currency: CurrencyName.Cad, percentage: 0.8 },
65
+ { currency: CurrencyName.Chf, percentage: 0.6 },
66
+ { currency: CurrencyName.Nzd, percentage: 0.5 },
67
+ ],
68
+ },
69
+ ],
70
+ },
71
+ );
72
+ });
73
+ });