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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +7 -6
  3. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +6 -1
  5. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/Main.js +42 -3
  7. package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +9 -2
  9. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  10. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -1
  11. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  12. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +17 -1
  13. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  14. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +3 -8
  15. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  16. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  17. package/dist/main/CurrencyPowerBalanceWidget/render.js +5 -1
  18. package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -1
  19. package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -1
  20. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +7 -6
  21. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  22. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +6 -1
  23. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  24. package/dist/module/CurrencyPowerBalanceWidget/Main.js +43 -4
  25. package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  26. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +9 -2
  27. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  28. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -1
  29. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  30. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +17 -2
  31. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  32. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +4 -9
  33. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  34. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  35. package/dist/module/CurrencyPowerBalanceWidget/render.js +5 -1
  36. package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -1
  37. package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -1
  38. package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +1 -1
  39. package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +1 -1
  40. package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +2 -1
  41. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +1 -1
  42. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +13 -2
  43. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +8 -2
  44. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +2 -2
  45. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +1 -0
  46. package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +7 -0
  47. package/package.json +3 -3
  48. package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +5 -5
  49. package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +2 -2
  50. package/src/CurrencyPowerBalanceWidget/Main.tsx +40 -4
  51. package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +6 -2
  52. package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx +14 -1
  53. package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +18 -2
  54. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +6 -9
  55. package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +1 -0
  56. package/src/CurrencyPowerBalanceWidget/render.tsx +3 -1
  57. package/src/CurrencyPowerBalanceWidget/types.ts +8 -0
  58. package/test/Main.test.tsx +56 -2
  59. package/dist/main/CurrencyPowerBalanceWidget/Tool.js +0 -28
  60. package/dist/main/CurrencyPowerBalanceWidget/Tool.js.map +0 -1
  61. package/dist/module/CurrencyPowerBalanceWidget/Tool.js +0 -20
  62. package/dist/module/CurrencyPowerBalanceWidget/Tool.js.map +0 -1
  63. package/dist/types/CurrencyPowerBalanceWidget/Tool.d.ts +0 -3
  64. package/src/CurrencyPowerBalanceWidget/Tool.tsx +0 -27
@@ -20,6 +20,8 @@ if (currencyPowerBalanceParamsElements.length > 0) {
20
20
  const params = element.getAttribute('data-currency-power-balance-params');
21
21
  const mode = element.getAttribute('data-mode');
22
22
  const {
23
+ timeUnit,
24
+ currencies,
23
25
  locale
24
26
  } = JSON.parse(params);
25
27
  const isParamError = (0, _labsWidgetCommon.validateToolParams)({
@@ -35,7 +37,9 @@ if (currencyPowerBalanceParamsElements.length > 0) {
35
37
  graphqlUrl: graphqlUrl,
36
38
  locale: locale,
37
39
  theme: mode,
38
- isParamError: isParamError
40
+ isParamError: isParamError,
41
+ timeUnit: timeUnit,
42
+ currencies: currencies
39
43
  }));
40
44
  });
41
45
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_CurrencyPowerBalance","obj","__esModule","default","graphqlUrl","configGraphQl","renderElementId","configRenderElementId","locale","configLocale","window","currencyPowerBalanceWidgetConfig","widgetsConfig","currencyPowerBalanceParamsElements","document","querySelectorAll","length","forEach","element","root","createRoot","params","getAttribute","mode","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","split","render","createElement","CurrencyPowerBalance","theme","container","getElementById"],"sources":["../../../src/CurrencyPowerBalanceWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalance } from './CurrencyPowerBalance';\n\nconst {\n graphqlUrl: configGraphQl,\n renderElementId: configRenderElementId,\n locale: configLocale,\n} = window.currencyPowerBalanceWidgetConfig || {};\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst currencyPowerBalanceParamsElements = document.querySelectorAll('div[data-currency-power-balance-params]');\n\nif (currencyPowerBalanceParamsElements.length > 0) {\n currencyPowerBalanceParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-power-balance-params');\n const mode = element.getAttribute('data-mode');\n const { locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n root.render(\n <CurrencyPowerBalance\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n />,\n );\n });\n} else {\n const container = document.getElementById(configRenderElementId);\n const root = createRoot(container!);\n\n root.render(\n <CurrencyPowerBalance\n locale={configLocale}\n graphqlUrl={configGraphQl}\n />,\n );\n}\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GA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OAAA,CAAA8B,aAAA,CAACjC,qBAAA,CAAAkC,oBAAoB;MACnB9B,UAAU,EAAEA,UAAW;MACvBI,MAAM,EAAEA,MAAO;MACf2B,KAAK,EAAEZ,IAAc;MACrBG,YAAY,EAAEA;IAAa,CAC5B,CACH,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,MAAM;EACL,MAAMU,SAAS,GAAGtB,QAAQ,CAACuB,cAAc,CAAC9B,qBAAqB,CAAC;EAChE,MAAMY,IAAI,GAAG,IAAAC,kBAAU,EAACgB,SAAU,CAAC;EAEnCjB,IAAI,CAACa,MAAM,CACTrC,MAAA,CAAAQ,OAAA,CAAA8B,aAAA,CAACjC,qBAAA,CAAAkC,oBAAoB;IACnB1B,MAAM,EAAEC,YAAa;IACrBL,UAAU,EAAEC;EAAc,CAC3B,CACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_CurrencyPowerBalance","obj","__esModule","default","graphqlUrl","configGraphQl","renderElementId","configRenderElementId","locale","configLocale","window","currencyPowerBalanceWidgetConfig","widgetsConfig","currencyPowerBalanceParamsElements","document","querySelectorAll","length","forEach","element","root","createRoot","params","getAttribute","mode","timeUnit","currencies","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","split","render","createElement","CurrencyPowerBalance","theme","container","getElementById"],"sources":["../../../src/CurrencyPowerBalanceWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalance } from './CurrencyPowerBalance';\n\nconst {\n graphqlUrl: configGraphQl,\n renderElementId: configRenderElementId,\n locale: configLocale,\n} = window.currencyPowerBalanceWidgetConfig || {};\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst currencyPowerBalanceParamsElements = document.querySelectorAll('div[data-currency-power-balance-params]');\n\nif (currencyPowerBalanceParamsElements.length > 0) {\n currencyPowerBalanceParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-power-balance-params');\n const mode = element.getAttribute('data-mode');\n const { timeUnit, currencies, locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n root.render(\n <CurrencyPowerBalance\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n timeUnit={timeUnit}\n currencies={currencies}\n />,\n );\n });\n} else {\n const container = document.getElementById(configRenderElementId);\n const root = createRoot(container!);\n\n root.render(\n <CurrencyPowerBalance\n locale={configLocale}\n graphqlUrl={configGraphQl}\n />,\n );\n}\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AAA8D,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE9D,MAAM;EACJG,UAAU,EAAEC,aAAa;EACzBC,eAAe,EAAEC,qBAAqB;EACtCC,MAAM,EAAEC;AACV,CAAC,GAAGC,MAAM,CAACC,gCAAgC,IAAI,CAAC,CAAC;AAEjD,MAAM;EACJP;AACF,CAAC,GAAGM,MAAM,CAACE,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,yCAAyC,CAAC;AAE/G,IAAIF,kCAAkC,CAACG,MAAM,GAAG,CAAC,EAAE;EACjDH,kCAAkC,CAACI,OAAO,CAAEC,OAAO,IAAK;IACtD,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACF,OAAO,CAAC;IAChC,MAAMG,MAAM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sources":["../../../src/CurrencyPowerBalanceWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nexport interface CurrencyPowerBalanceConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n}\n\nexport interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {\n renderElementId: string;\n locale: Locale;\n}\n\nexport interface ChartWithDataProps {\n timeUnit: CurrencyPowerBalanceTimeUnit;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyPowerBalanceWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nexport interface CurrencyPowerBalanceConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n timeUnit?: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n\nexport interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {\n renderElementId: string;\n locale: Locale;\n}\n\nexport interface MainProps {\n timeUnit?: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n\nexport interface ChartWithDataProps {\n timeUnit: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -5,9 +5,10 @@ import { Chart } from './components/Chart';
5
5
  import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';
6
6
  import { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';
7
7
  const ChartWithData = _ref => {
8
- var _data$currencyPowerBa, _data$currencyPowerBa2;
8
+ var _data$currencyPowerBa;
9
9
  let {
10
- timeUnit
10
+ timeUnit,
11
+ currencies
11
12
  } = _ref;
12
13
  const {
13
14
  size
@@ -23,15 +24,15 @@ const ChartWithData = _ref => {
23
24
  },
24
25
  fetchPolicy: 'cache-and-network'
25
26
  });
26
- const showChart = (data === null || data === void 0 ? void 0 : data.currencyPowerBalance) && (data === null || data === void 0 || (_data$currencyPowerBa = data.currencyPowerBalance) === null || _data$currencyPowerBa === void 0 ? void 0 : _data$currencyPowerBa.length) > 0;
27
- const showError = (data === null || data === void 0 || (_data$currencyPowerBa2 = data.currencyPowerBalance) === null || _data$currencyPowerBa2 === void 0 ? void 0 : _data$currencyPowerBa2.length) === 0 || error;
27
+ const showError = (data === null || data === void 0 || (_data$currencyPowerBa = data.currencyPowerBalance) === null || _data$currencyPowerBa === void 0 ? void 0 : _data$currencyPowerBa.length) === 0 || error || currencies && (currencies.length === 0 || currencies.length === 1);
28
28
  return React.createElement(React.Fragment, null, loading && React.createElement("div", {
29
29
  className: "lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
30
30
  }, React.createElement(Spinner, {
31
31
  size: SpinnerSize.lg
32
- })), !loading && showChart && React.createElement(Chart, {
32
+ })), !loading && !showError && React.createElement(Chart, {
33
33
  values: data === null || data === void 0 ? void 0 : data.currencyPowerBalance,
34
- timeUnit: timeUnit
34
+ timeUnit: timeUnit,
35
+ currencies: currencies
35
36
  }), !loading && showError && React.createElement("div", {
36
37
  className: "lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
37
38
  }, React.createElement(ChartError, null)), isDesktop && React.createElement(Tooltip, {
@@ -1 +1 @@
1
- {"version":3,"file":"ChartWithData.js","names":["React","useContext","useQuery","ChartError","Spinner","SpinnerSize","ThemeContext","Tooltip","Size","Chart","CURRENCY_POWER_BALANCE_TOOLTIP_ID","getCurrencyPowerBalance","ChartWithData","_ref","_data$currencyPowerBa","_data$currencyPowerBa2","timeUnit","size","isDesktop","DESKTOP","loading","data","error","variables","fetchPolicy","showChart","currencyPowerBalance","length","showError","createElement","Fragment","className","lg","values","id"],"sources":["../../../src/CurrencyPowerBalanceWidget/ChartWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Spinner, SpinnerSize, ThemeContext, Tooltip, Size,\n} from '@oanda/labs-widget-common';\nimport { Chart } from './components/Chart';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';\nimport { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';\nimport { ChartWithDataProps } from './types';\nimport { GetCurrencyPowerBalanceQuery, GetCurrencyPowerBalanceQueryVariables } from '../gql/types/graphql';\n\nconst ChartWithData = ({ timeUnit }: ChartWithDataProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<\n GetCurrencyPowerBalanceQuery,\n GetCurrencyPowerBalanceQueryVariables\n >(getCurrencyPowerBalance, {\n variables: {\n timeUnit,\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyPowerBalance && data?.currencyPowerBalance?.length > 0;\n const showError = data?.currencyPowerBalance?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <Chart values={data?.currencyPowerBalance!} timeUnit={timeUnit} />\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n {isDesktop && <Tooltip id={CURRENCY_POWER_BALANCE_TOOLTIP_ID} />}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,UAAU,EAAEC,OAAO,EAAEC,WAAW,EAAEC,YAAY,EAAEC,OAAO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B,KAAK;IAACwB,MAAM,EAAEZ,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEK,oBAAsB;IAACV,QAAQ,EAAEA;EAAS,CAAE,CAClE,EACA,CAACI,OAAO,IAAIQ,SAAS,IACpB5B,KAAA,CAAA6B,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChH/B,KAAA,CAAA6B,aAAA,CAAC1B,UAAU,MAAE,CACV,CACN,EACAe,SAAS,IAAIlB,KAAA,CAAA6B,aAAA,CAACtB,OAAO;IAAC2B,EAAE,EAAExB;EAAkC,CAAE,CAC/D,CAAC;AAEP,CAAC;AAED,SAASE,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"ChartWithData.js","names":["React","useContext","useQuery","ChartError","Spinner","SpinnerSize","ThemeContext","Tooltip","Size","Chart","CURRENCY_POWER_BALANCE_TOOLTIP_ID","getCurrencyPowerBalance","ChartWithData","_ref","_data$currencyPowerBa","timeUnit","currencies","size","isDesktop","DESKTOP","loading","data","error","variables","fetchPolicy","showError","currencyPowerBalance","length","createElement","Fragment","className","lg","values","id"],"sources":["../../../src/CurrencyPowerBalanceWidget/ChartWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Spinner, SpinnerSize, ThemeContext, Tooltip, Size,\n} from '@oanda/labs-widget-common';\nimport { Chart } from './components/Chart';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';\nimport { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';\nimport { ChartWithDataProps } from './types';\nimport { GetCurrencyPowerBalanceQuery, GetCurrencyPowerBalanceQueryVariables } from '../gql/types/graphql';\n\nconst ChartWithData = ({ timeUnit, currencies }: ChartWithDataProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<\n GetCurrencyPowerBalanceQuery,\n GetCurrencyPowerBalanceQueryVariables\n >(getCurrencyPowerBalance, {\n variables: {\n timeUnit,\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const showError = data?.currencyPowerBalance?.length === 0 || error\n || (currencies && (currencies.length === 0 || currencies.length === 1));\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && !showError && (\n <Chart values={data?.currencyPowerBalance!} timeUnit={timeUnit} currencies={currencies} />\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n {isDesktop && <Tooltip id={CURRENCY_POWER_BALANCE_TOOLTIP_ID} />}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,UAAU,EAAEC,OAAO,EAAEC,WAAW,EAAEC,YAAY,EAAEC,OAAO,EAAEC,IAAI,QACxD,2BAA2B;AAClC,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,iCAAiC,QAAQ,aAAa;AAC/D,SAASC,uBAAuB,QAAQ,gCAAgC;AAIxE,MAAMC,aAAa,GAAGC,IAAA,IAAkD;EAAA,IAAAC,qBAAA;EAAA,IAAjD;IAAEC,QAAQ;IAAEC;EAA+B,CAAC,GAAAH,IAAA;EACjE,MAAM;IAAEI;EAAK,CAAC,GAAGhB,UAAU,CAACK,YAAY,CAAC;EACzC,MAAMY,SAAS,GAAGD,IAAI,KAAKT,IAAI,CAACW,OAAO;EACvC,MAAM;IAAEC,OAAO;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAGpB,QAAQ,CAGvCS,uBAAuB,EAAE;IACzBY,SAAS,EAAE;MACTR;IACF,CAAC;IACDS,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,SAAS,GAAG,CAAAJ,IAAI,aAAJA,IAAI,gBAAAP,qBAAA,GAAJO,IAAI,CAAEK,oBAAoB,cAAAZ,qBAAA,uBAA1BA,qBAAA,CAA4Ba,MAAM,MAAK,CAAC,IAAIL,KAAK,IAC7DN,UAAU,KAAKA,UAAU,CAACW,MAAM,KAAK,CAAC,IAAIX,UAAU,CAACW,MAAM,KAAK,CAAC,CAAE;EAEzE,OACE3B,KAAA,CAAA4B,aAAA,CAAA5B,KAAA,CAAA6B,QAAA,QACGT,OAAO,IAERpB,KAAA,CAAA4B,aAAA;IAAKE,SAAS,EAAC;EAAgH,GAC7H9B,KAAA,CAAA4B,aAAA,CAACxB,OAAO;IAACa,IAAI,EAAEZ,WAAW,CAAC0B;EAAG,CAAE,CAC7B,CACJ,EACA,CAACX,OAAO,IAAI,CAACK,SAAS,IACrBzB,KAAA,CAAA4B,aAAA,CAACnB,KAAK;IAACuB,MAAM,EAAEX,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEK,oBAAsB;IAACX,QAAQ,EAAEA,QAAS;IAACC,UAAU,EAAEA;EAAW,CAAE,CAC1F,EACA,CAACI,OAAO,IAAIK,SAAS,IACpBzB,KAAA,CAAA4B,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChH9B,KAAA,CAAA4B,aAAA,CAACzB,UAAU,MAAE,CACV,CACN,EACAe,SAAS,IAAIlB,KAAA,CAAA4B,aAAA,CAACrB,OAAO;IAAC0B,EAAE,EAAEvB;EAAkC,CAAE,CAC/D,CAAC;AAEP,CAAC;AAED,SAASE,aAAa","ignoreList":[]}
@@ -9,6 +9,8 @@ const CurrencyPowerBalance = _ref => {
9
9
  graphqlUrl,
10
10
  theme,
11
11
  locale,
12
+ timeUnit,
13
+ currencies,
12
14
  isParamError
13
15
  } = _ref;
14
16
  const client = new ApolloClient({
@@ -24,7 +26,10 @@ const CurrencyPowerBalance = _ref => {
24
26
  client: client
25
27
  }, isParamError ? React.createElement("div", {
26
28
  className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
27
- }, React.createElement(ChartError, null)) : React.createElement(Main, null))));
29
+ }, React.createElement(ChartError, null)) : React.createElement(Main, {
30
+ timeUnit: timeUnit,
31
+ currencies: currencies
32
+ }))));
28
33
  };
29
34
  export { CurrencyPowerBalance };
30
35
  //# sourceMappingURL=CurrencyPowerBalance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyPowerBalance.js","names":["React","ApolloClient","InMemoryCache","ApolloProvider","ChartError","ThemeProvider","getLocale","LocaleProvider","Main","translations","CurrencyPowerBalance","_ref","graphqlUrl","theme","locale","isParamError","client","uri","cache","createElement","className"],"sources":["../../../src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx"],"sourcesContent":["import React from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { Main } from './Main';\nimport { CurrencyPowerBalanceConfig } from './types';\nimport { translations } from '../translations';\n\nconst CurrencyPowerBalance = ({\n graphqlUrl, theme, locale, isParamError,\n}: CurrencyPowerBalanceConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyPowerBalance };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,gBAAgB;AAC5E,SAASC,UAAU,EAAEC,aAAa,EAAEC,SAAS,QAAQ,2BAA2B;AAChF,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,oBAAoB,GAAGC,IAAA,IAEK;EAAA,IAFJ;IAC5BC,UAAU;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EACD,CAAC,GAAAJ,IAAA;EAC3B,MAAMK,MAAM,GAAG,IAAIf,YAAY,CAAC;IAC9BgB,GAAG,EAAEL,UAAU;IACfM,KAAK,EAAE,IAAIhB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEF,KAAA,CAAAmB,aAAA,CAACd,aAAa;IAACQ,KAAK,EAAEA;EAAM,GAC1Bb,KAAA,CAAAmB,aAAA,CAACZ,cAAc;IAACO,MAAM,EAAER,SAAS,CAACQ,MAAM,CAAE;IAACL,YAAY,EAAEA;EAAa,GACpET,KAAA,CAAAmB,aAAA,CAAChB,cAAc;IAACa,MAAM,EAAEA;EAAO,GAC5BD,YAAY,GACXf,KAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAAmG,GAChHpB,KAAA,CAAAmB,aAAA,CAACf,UAAU,MAAE,CACV,CAAC,GACJJ,KAAA,CAAAmB,aAAA,CAACX,IAAI,MAAE,CACG,CACF,CACH,CAAC;AAEpB,CAAC;AAED,SAASE,oBAAoB","ignoreList":[]}
1
+ {"version":3,"file":"CurrencyPowerBalance.js","names":["React","ApolloClient","InMemoryCache","ApolloProvider","ChartError","ThemeProvider","getLocale","LocaleProvider","Main","translations","CurrencyPowerBalance","_ref","graphqlUrl","theme","locale","timeUnit","currencies","isParamError","client","uri","cache","createElement","className"],"sources":["../../../src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx"],"sourcesContent":["import React from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { Main } from './Main';\nimport { CurrencyPowerBalanceConfig } from './types';\nimport { translations } from '../translations';\n\nconst CurrencyPowerBalance = ({\n graphqlUrl, theme, locale, timeUnit, currencies, isParamError,\n}: CurrencyPowerBalanceConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main timeUnit={timeUnit} currencies={currencies} />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyPowerBalance };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,gBAAgB;AAC5E,SAASC,UAAU,EAAEC,aAAa,EAAEC,SAAS,QAAQ,2BAA2B;AAChF,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,MAAMC,oBAAoB,GAAGC,IAAA,IAEK;EAAA,IAFJ;IAC5BC,UAAU;IAAEC,KAAK;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,UAAU;IAAEC;EACvB,CAAC,GAAAN,IAAA;EAC3B,MAAMO,MAAM,GAAG,IAAIjB,YAAY,CAAC;IAC9BkB,GAAG,EAAEP,UAAU;IACfQ,KAAK,EAAE,IAAIlB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEF,KAAA,CAAAqB,aAAA,CAAChB,aAAa;IAACQ,KAAK,EAAEA;EAAM,GAC1Bb,KAAA,CAAAqB,aAAA,CAACd,cAAc;IAACO,MAAM,EAAER,SAAS,CAACQ,MAAM,CAAE;IAACL,YAAY,EAAEA;EAAa,GACpET,KAAA,CAAAqB,aAAA,CAAClB,cAAc;IAACe,MAAM,EAAEA;EAAO,GAC5BD,YAAY,GACXjB,KAAA,CAAAqB,aAAA;IAAKC,SAAS,EAAC;EAAmG,GAChHtB,KAAA,CAAAqB,aAAA,CAACjB,UAAU,MAAE,CACV,CAAC,GACJJ,KAAA,CAAAqB,aAAA,CAACb,IAAI;IAACO,QAAQ,EAAEA,QAAS;IAACC,UAAU,EAAEA;EAAW,CAAE,CACzC,CACF,CACH,CAAC;AAEpB,CAAC;AAED,SAASN,oBAAoB","ignoreList":[]}
@@ -1,11 +1,50 @@
1
- import React, { useContext } from 'react';
1
+ import React, { useContext, useState } from 'react';
2
2
  import { ThemeContext } from '@oanda/labs-widget-common';
3
- import { Tool } from './Tool';
4
- const Main = () => {
3
+ import { useLocale } from '@oanda/mono-i18n';
4
+ import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
5
+ import { TimeUnitSwitch } from './components/TimeUnitSwitch';
6
+ import { timeUnitConfig } from './config';
7
+ import { ChartWithData } from './ChartWithData';
8
+ const Main = _ref => {
9
+ let {
10
+ timeUnit,
11
+ currencies
12
+ } = _ref;
5
13
  const {
6
14
  size
7
15
  } = useContext(ThemeContext);
8
- return React.createElement(React.Fragment, null, size && React.createElement(Tool, null));
16
+ const {
17
+ lang
18
+ } = useLocale();
19
+ const [selectedTimeUnit, setSelectedTimeUnit] = useState(timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay);
20
+ return React.createElement(React.Fragment, null, size && React.createElement("div", {
21
+ "data-testid": "currency-power-balance-wrapper",
22
+ className: "lw-flex lw-flex-col lw-text-sm lw-tracking-normal"
23
+ }, timeUnit && currencies ? React.createElement(React.Fragment, null, timeUnitConfig.filter(_ref2 => {
24
+ let {
25
+ value
26
+ } = _ref2;
27
+ return value === selectedTimeUnit;
28
+ }).map(_ref3 => {
29
+ let {
30
+ tooltipLabel,
31
+ label
32
+ } = _ref3;
33
+ return React.createElement("div", {
34
+ "data-testid": "time-unit-label",
35
+ key: label,
36
+ className: "lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold"
37
+ }, tooltipLabel ? React.createElement("span", null, "".concat(lang(tooltipLabel.translationKey, {
38
+ count: tooltipLabel.count
39
+ }))) : React.createElement("span", null, "".concat(lang(label))));
40
+ })) : React.createElement(TimeUnitSwitch, {
41
+ selected: selectedTimeUnit,
42
+ callback: setSelectedTimeUnit,
43
+ options: timeUnitConfig
44
+ }), React.createElement(ChartWithData, {
45
+ timeUnit: selectedTimeUnit,
46
+ currencies: timeUnit && currencies
47
+ })));
9
48
  };
10
49
  export { Main };
11
50
  //# sourceMappingURL=Main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["React","useContext","ThemeContext","Tool","Main","size","createElement","Fragment"],"sources":["../../../src/CurrencyPowerBalanceWidget/Main.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { Tool } from './Tool';\n\nconst Main = () => {\n const { size } = useContext(ThemeContext);\n return (\n <>\n {size && <Tool />}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,YAAY,QAAQ,2BAA2B;AACxD,SAASC,IAAI,QAAQ,QAAQ;AAE7B,MAAMC,IAAI,GAAGA,CAAA,KAAM;EACjB,MAAM;IAAEC;EAAK,CAAC,GAAGJ,UAAU,CAACC,YAAY,CAAC;EACzC,OACEF,KAAA,CAAAM,aAAA,CAAAN,KAAA,CAAAO,QAAA,QACGF,IAAI,IAAIL,KAAA,CAAAM,aAAA,CAACH,IAAI,MAAE,CAChB,CAAC;AAEP,CAAC;AAED,SAASC,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Main.js","names":["React","useContext","useState","ThemeContext","useLocale","CurrencyPowerBalanceTimeUnit","TimeUnitSwitch","timeUnitConfig","ChartWithData","Main","_ref","timeUnit","currencies","size","lang","selectedTimeUnit","setSelectedTimeUnit","CurrentDay","createElement","Fragment","className","filter","_ref2","value","map","_ref3","tooltipLabel","label","key","concat","translationKey","count","selected","callback","options"],"sources":["../../../src/CurrencyPowerBalanceWidget/Main.tsx"],"sourcesContent":["import React, { useContext, useState } from 'react';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\nimport { TimeUnitSwitch } from './components/TimeUnitSwitch';\nimport { timeUnitConfig } from './config';\nimport { ChartWithData } from './ChartWithData';\nimport { MainProps } from './types';\n\nconst Main = ({ timeUnit, currencies }: MainProps) => {\n const { size } = useContext(ThemeContext);\n const { lang } = useLocale();\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(\n timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay,\n );\n return (\n <>\n {size && (\n <div\n data-testid=\"currency-power-balance-wrapper\"\n className=\"lw-flex lw-flex-col lw-text-sm lw-tracking-normal\"\n >\n {timeUnit && currencies ? (\n <>\n {timeUnitConfig\n .filter(({ value }) => value === selectedTimeUnit)\n .map(({ tooltipLabel, label }) => (\n <div data-testid=\"time-unit-label\" key={label} className=\"lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold\">\n {tooltipLabel ? <span>{`${lang(tooltipLabel!.translationKey, { count: tooltipLabel!.count })}`}</span> : <span>{`${lang(label)}`}</span>}\n </div>\n ))}\n </>\n ) : (\n <TimeUnitSwitch\n selected={selectedTimeUnit}\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n />\n )}\n <ChartWithData\n timeUnit={selectedTimeUnit}\n currencies={timeUnit && currencies}\n />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,QAAQ,QAAQ,OAAO;AACnD,SAASC,YAAY,QAAQ,2BAA2B;AACxD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,4BAA4B,QAAQ,sBAAsB;AAC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CACpI,CAAC;EAAA,CACP,CACH,CAAC,GAEH3B,KAAA,CAAAkB,aAAA,CAACZ,cAAc;IACb0B,QAAQ,EAAEjB,gBAAiB;IAC3BkB,QAAQ,EAAEjB,mBAAoB;IAC9BkB,OAAO,EAAE3B;EAAe,CACzB,CACF,EACDP,KAAA,CAAAkB,aAAA,CAACV,aAAa;IACZG,QAAQ,EAAEI,gBAAiB;IAC3BH,UAAU,EAAED,QAAQ,IAAIC;EAAW,CACpC,CACE,CAEP,CAAC;AAEP,CAAC;AAED,SAASH,IAAI","ignoreList":[]}
@@ -13,7 +13,8 @@ echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
13
13
  const Chart = _ref => {
14
14
  let {
15
15
  values,
16
- timeUnit
16
+ timeUnit,
17
+ currencies
17
18
  } = _ref;
18
19
  const {
19
20
  isDark,
@@ -22,6 +23,12 @@ const Chart = _ref => {
22
23
  const isDesktop = size === Size.DESKTOP;
23
24
  const isMobile = size === Size.MOBILE;
24
25
  const echartRef = useRef(null);
26
+ const chartData = currencies ? values.filter(_ref2 => {
27
+ let {
28
+ currency
29
+ } = _ref2;
30
+ return currencies.includes(currency);
31
+ }) : values;
25
32
  useEffect(() => {
26
33
  if (echartRef.current) {
27
34
  const echartInstance = echartRef.current.getEchartsInstance();
@@ -36,7 +43,7 @@ const Chart = _ref => {
36
43
  height: "".concat(CHART_HEIGHT, "px"),
37
44
  width: '100%'
38
45
  },
39
- option: getOption(values, timeUnit, isDark)
46
+ option: getOption(chartData, timeUnit, isDark)
40
47
  });
41
48
  };
42
49
  export { Chart };
@@ -1 +1 @@
1
- {"version":3,"file":"Chart.js","names":["React","useRef","useEffect","useContext","ReactEChartsCore","echarts","LineChart","CanvasRenderer","GridSimpleComponent","GraphicComponent","TooltipComponent","LegendPlainComponent","Theme","ThemeContext","getChartTheme","Size","CHART_HEIGHT","getResponsiveOption","getOption","use","registerTheme","Dark","Light","Chart","_ref","values","timeUnit","isDark","size","isDesktop","DESKTOP","isMobile","MOBILE","echartRef","current","echartInstance","getEchartsInstance","setOption","createElement","ref","theme","style","height","concat","width","option"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx"],"sourcesContent":["import React, { useRef, useEffect, useContext } from 'react';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport * as echarts from 'echarts/core';\nimport { LineChart } from 'echarts/charts';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent,\n} from 'echarts/components';\nimport {\n Theme, ThemeContext, getChartTheme, Size,\n} from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n} from './options/constants';\nimport { getResponsiveOption, getOption } from './options';\nimport { ChartProps } from './types';\n\necharts.use([\n GridSimpleComponent,\n GraphicComponent,\n TooltipComponent,\n LegendPlainComponent,\n LineChart,\n CanvasRenderer,\n]);\n\necharts.registerTheme('dark_theme', getChartTheme(Theme.Dark));\necharts.registerTheme('light_theme', getChartTheme(Theme.Light));\n\nconst Chart = ({ values, timeUnit }: ChartProps) => {\n const { isDark, size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const isMobile = size === Size.MOBILE;\n\n const echartRef = useRef(null);\n\n useEffect(() => {\n if (echartRef.current) {\n // @ts-ignore\n const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;\n\n echartInstance.setOption(\n getResponsiveOption(isDesktop, isMobile, isDark),\n );\n }\n }, [echartRef, isDesktop, isMobile, isDark]);\n\n return (\n <ReactEChartsCore\n echarts={echarts}\n ref={echartRef}\n theme={isDark ? 'dark_theme' : 'light_theme'}\n style={{\n height: `${CHART_HEIGHT}px`,\n width: '100%',\n }}\n option={getOption(values, timeUnit, isDark)}\n />\n );\n};\n\nexport { Chart };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AAC5D,OAAOC,gBAAgB,MAAM,4BAA4B;AACzD,OAA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,EAAE,CAACM,SAAS,EAAEJ,SAAS,EAAEE,QAAQ,EAAEJ,MAAM,CAAC,CAAC;EAE5C,OACE3B,KAAA,CAAAsC,aAAA,CAAClC,gBAAgB;IACfC,OAAO,EAAEA,OAAQ;IACjBkC,GAAG,EAAEN,SAAU;IACfO,KAAK,EAAEb,MAAM,GAAG,YAAY,GAAG,aAAc;IAC7Cc,KAAK,EAAE;MACLC,MAAM,KAAAC,MAAA,CAAK3B,YAAY,OAAI;MAC3B4B,KAAK,EAAE;IACT,CAAE;IACFC,MAAM,EAAE3B,SAAS,CAACO,MAAM,EAAEC,QAAQ,EAAEC,MAAM;EAAE,CAC7C,CAAC;AAEN,CAAC;AAED,SAASJ,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Chart.js","names":["React","useRef","useEffect","useContext","ReactEChartsCore","echarts","LineChart","CanvasRenderer","GridSimpleComponent","GraphicComponent","TooltipComponent","LegendPlainComponent","Theme","ThemeContext","getChartTheme","Size","CHART_HEIGHT","getResponsiveOption","getOption","use","registerTheme","Dark","Light","Chart","_ref","values","timeUnit","currencies","isDark","size","isDesktop","DESKTOP","isMobile","MOBILE","echartRef","chartData","filter","_ref2","currency","includes","current","echartInstance","getEchartsInstance","setOption","createElement","ref","theme","style","height","concat","width","option"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx"],"sourcesContent":["import React, { useRef, useEffect, useContext } from 'react';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport * as echarts from 'echarts/core';\nimport { LineChart } from 'echarts/charts';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent,\n} from 'echarts/components';\nimport {\n Theme, ThemeContext, getChartTheme, Size,\n} from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n} from './options/constants';\nimport { getResponsiveOption, getOption } from './options';\nimport { ChartProps } from './types';\n\necharts.use([\n GridSimpleComponent,\n GraphicComponent,\n TooltipComponent,\n LegendPlainComponent,\n LineChart,\n CanvasRenderer,\n]);\n\necharts.registerTheme('dark_theme', getChartTheme(Theme.Dark));\necharts.registerTheme('light_theme', getChartTheme(Theme.Light));\n\nconst Chart = ({ values, timeUnit, currencies }: ChartProps) => {\n const { isDark, size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const isMobile = size === Size.MOBILE;\n\n const echartRef = useRef(null);\n\n const chartData = currencies\n ? values.filter(({ currency }) => currencies.includes(currency))\n : values;\n\n useEffect(() => {\n if (echartRef.current) {\n // @ts-ignore\n const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;\n\n echartInstance.setOption(\n getResponsiveOption(isDesktop, isMobile, isDark),\n );\n }\n }, [echartRef, isDesktop, isMobile, isDark]);\n\n return (\n <ReactEChartsCore\n echarts={echarts}\n ref={echartRef}\n theme={isDark ? 'dark_theme' : 'light_theme'}\n style={{\n height: `${CHART_HEIGHT}px`,\n width: '100%',\n }}\n option={getOption(chartData, timeUnit, isDark)}\n />\n );\n};\n\nexport { Chart };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AAC5D,OAAOC,gBAAgB,MAAM,4BAA4B;AACzD,OAAO,KAAKC,OAAO,MAAM,cAAc;AACvC,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SACEC,mBAAmB,EAAEC,gBAAgB,EAAEC,gBAAgB,EAAEC,oBAAoB,QACxE,oBAAoB;AAC3B,SACEC,KAAK,EAAEC,YAAY,EAAEC,aAAa,EAAEC,IAAI,QACnC,2BAA2B;AAClC,SACEC,YAAY,QACP,qBAAqB;AAC5B,SAASC,mBAAmB,EAAEC,SAAS,QAAQ,WAAW;AAG1Db,OAAO,CAACc,GAAG,CAAC,CACVX,mBAAmB,EACnBC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBL,SAAS,EACTC,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CmB,KAAK,EAAE;MACLC,MAAM,KAAAC,MAAA,CAAKjC,YAAY,OAAI;MAC3BkC,KAAK,EAAE;IACT,CAAE;IACFC,MAAM,EAAEjC,SAAS,CAACiB,SAAS,EAAET,QAAQ,EAAEE,MAAM;EAAE,CAChD,CAAC;AAEN,CAAC;AAED,SAASL,KAAK","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  import { colorPalette } from '@oanda/labs-widget-common';
2
+ import { CurrencyName } from '../../../../gql/types/graphql';
2
3
  const X_LABEL_SIZE = 90;
3
4
  const X_LABEL_SIZE_MOBILE = 110;
4
5
  const Y_LABEL_SIZE_MOBILE = 35;
@@ -10,6 +11,7 @@ const LEGEND_HEIGHT_MOBILE = 70;
10
11
  const VERTICAL_LINE_COUNT = 10;
11
12
  const CANDLE_NUMBER_HOUR = 12;
12
13
  const CANDLE_MINUTE = 5;
14
+ const CURENCIES_ORDER = [CurrencyName.Usd, CurrencyName.Eur, CurrencyName.Gbp, CurrencyName.Jpy, CurrencyName.Chf, CurrencyName.Aud, CurrencyName.Cad, CurrencyName.Nzd];
13
15
  const COLOR_CONFIG = {
14
16
  USD: colorPalette.greenLight,
15
17
  EUR: colorPalette.turquoiseLight,
@@ -24,5 +26,5 @@ const TOOLTIP_LINE_COLOR_CONFIG = {
24
26
  DARK: colorPalette.orange,
25
27
  LIGHT: colorPalette.bottleGreenDark
26
28
  };
27
- export { X_LABEL_SIZE, X_LABEL_SIZE_MOBILE, Y_LABEL_SIZE_MOBILE, Y_LABEL_SIZE, CHART_WIDTH, CHART_HEIGHT, LEGEND_HEIGHT, LEGEND_HEIGHT_MOBILE, VERTICAL_LINE_COUNT, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, CANDLE_NUMBER_HOUR, CANDLE_MINUTE };
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, CURENCIES_ORDER };
28
30
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["colorPalette","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","VERTICAL_LINE_COUNT","CANDLE_NUMBER_HOUR","CANDLE_MINUTE","COLOR_CONFIG","USD","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreen75Lighter","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\n\nconst X_LABEL_SIZE = 90;\nconst X_LABEL_SIZE_MOBILE = 110;\nconst Y_LABEL_SIZE_MOBILE = 35;\nconst Y_LABEL_SIZE = 45;\nconst CHART_WIDTH = 9999;\nconst CHART_HEIGHT = 425;\nconst LEGEND_HEIGHT = 50;\nconst LEGEND_HEIGHT_MOBILE = 70;\nconst VERTICAL_LINE_COUNT = 10;\nconst CANDLE_NUMBER_HOUR = 12;\nconst CANDLE_MINUTE = 5;\n\nconst COLOR_CONFIG: Record<string, string> = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreen75Lighter,\n AUD: colorPalette.orange,\n CAD: colorPalette.midnight75Lighter,\n NZD: colorPalette.gold,\n};\n\nconst TOOLTIP_LINE_COLOR_CONFIG = {\n DARK: colorPalette.orange,\n LIGHT: colorPalette.bottleGreen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Y,EACZC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB,EACnBG,YAAY,EACZiB,yBAAyB,EACzBnB,kBAAkB,EAClBC,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","names":["colorPalette","CurrencyName","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","VERTICAL_LINE_COUNT","CANDLE_NUMBER_HOUR","CANDLE_MINUTE","CURENCIES_ORDER","Usd","Eur","Gbp","Jpy","Chf","Aud","Cad","Nzd","COLOR_CONFIG","USD","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreen75Lighter","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport { CurrencyName } from '../../../../gql/types/graphql';\n\nconst X_LABEL_SIZE = 90;\nconst X_LABEL_SIZE_MOBILE = 110;\nconst Y_LABEL_SIZE_MOBILE = 35;\nconst Y_LABEL_SIZE = 45;\nconst CHART_WIDTH = 9999;\nconst CHART_HEIGHT = 425;\nconst LEGEND_HEIGHT = 50;\nconst LEGEND_HEIGHT_MOBILE = 70;\nconst VERTICAL_LINE_COUNT = 10;\nconst CANDLE_NUMBER_HOUR = 12;\nconst CANDLE_MINUTE = 5;\n\nconst CURENCIES_ORDER: CurrencyName[] = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Gbp,\n CurrencyName.Jpy,\n CurrencyName.Chf,\n CurrencyName.Aud,\n CurrencyName.Cad,\n CurrencyName.Nzd,\n];\n\nconst COLOR_CONFIG = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreen75Lighter,\n AUD: colorPalette.orange,\n CAD: colorPalette.midnight75Lighter,\n NZD: colorPalette.gold,\n};\n\nconst TOOLTIP_LINE_COLOR_CONFIG = {\n DARK: colorPalette.orange,\n LIGHT: colorPalette.bottleGreenDark,\n};\n\nexport {\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n CHART_WIDTH,\n CHART_HEIGHT,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n VERTICAL_LINE_COUNT,\n COLOR_CONFIG,\n TOOLTIP_LINE_COLOR_CONFIG,\n CANDLE_NUMBER_HOUR,\n CANDLE_MINUTE,\n CURENCIES_ORDER,\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SAASC,YAAY,QAAQ,+BAA+B;AAE5D,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,mBAAmB,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAG,GAAG;AACxB,MAAMC,aAAa,GAAG,EAAE;AACxB,MAAMC,oBAAoB,GAAG,EAAE;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,aAAa,GAAG,CAAC;AAEvB,MAAMC,eAA+B,GAAG,CACtCZ,YAAY,CAACa,GAAG,EAChBb,YAAY,CAACc,GAAG,EAChBd,YAAY,CAACe,GAAG,EAChBf,YAAY,CAACgB,GAAG,EAChBhB,YAAY,CAACiB,GAAG,EAChBjB,YAAY,CAACkB,GAAG,EAChBlB,YAAY,CAACmB,GAAG,EAChBnB,YAAY,CAACoB,GAAG,CACjB;AAED,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAEvB,YAAY,CAACwB,UAAU;EAC5BC,GAAG,EAAEzB,YAAY,CAAC0B,cAAc;EAChCC,GAAG,EAAE3B,YAAY,CAAC4B,WAAW;EAC7BC,GAAG,EAAE7B,YAAY,CAAC8B,cAAc;EAChCC,GAAG,EAAE/B,YAAY,CAACgC,oBAAoB;EACtCC,GAAG,EAAEjC,YAAY,CAACkC,MAAM;EACxBC,GAAG,EAAEnC,YAAY,CAACoC,iBAAiB;EACnCC,GAAG,EAAErC,YAAY,CAACsC;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAG;EAChCC,IAAI,EAAExC,YAAY,CAACkC,MAAM;EACzBO,KAAK,EAAEzC,YAAY,CAAC0C;AACtB,CAAC;AAED,SACExC,YAAY,EACZC,mBAAmB,EACnBC,mBAAmB,EACnBC,YAAY,EACZC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,oBAAoB,EACpBC,mBAAmB,EACnBY,YAAY,EACZiB,yBAAyB,EACzB5B,kBAAkB,EAClBC,aAAa,EACbC,eAAe","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
- import { VERTICAL_LINE_COUNT } from './constants';
2
+ import { VERTICAL_LINE_COUNT, CURENCIES_ORDER, COLOR_CONFIG } from './constants';
3
3
  const getDateAndTime = param => {
4
4
  const dateAndTime = param.split('T');
5
5
  return {
@@ -52,5 +52,20 @@ const tooltipFormatter = values => {
52
52
  });
53
53
  return "<div style=\"display:flex; flex-direction:column;\">\n <span style=\"margin-bottom:5px;\">".concat(date, "</span>\n ").concat(row.join('\n'), "\n </div>");
54
54
  };
55
- export { isMonthWeek, tooltipFormatter, xAxisLabelFormatter, intervalFormatter };
55
+ const formatLegendData = values => {
56
+ const dataCurrencies = values.map(_ref5 => {
57
+ let {
58
+ currency
59
+ } = _ref5;
60
+ return currency;
61
+ });
62
+ const list = dataCurrencies.length === CURENCIES_ORDER.length ? CURENCIES_ORDER : CURENCIES_ORDER.filter(currency => dataCurrencies.includes(currency));
63
+ return list.map(currency => ({
64
+ name: currency,
65
+ itemStyle: {
66
+ color: COLOR_CONFIG[currency]
67
+ }
68
+ }));
69
+ };
70
+ export { isMonthWeek, tooltipFormatter, xAxisLabelFormatter, intervalFormatter, formatLegendData };
56
71
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":["CurrencyPowerBalanceTimeUnit","VERTICAL_LINE_COUNT","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","M3","M1","W1","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","Math","round","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { VERTICAL_LINE_COUNT } from './constants';\nimport { TooltipFormatterParams } from './types';\n\nconst getDateAndTime = (param: string) => {\n const dateAndTime = param.split('T');\n\n return {\n date: dateAndTime[0],\n time: dateAndTime[1].substring(0, 5),\n };\n};\n\nconst dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;\n\nconst dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;\n\nconst isMonthWeek = (\n timeUnit: CurrencyPowerBalanceTimeUnit,\n) => timeUnit === CurrencyPowerBalanceTimeUnit.M3\n || timeUnit === CurrencyPowerBalanceTimeUnit.M1\n || timeUnit === CurrencyPowerBalanceTimeUnit.W1;\n\nconst xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\n\nconst intervalFormatter = (\n dataLength: number,\n) => Math.round(dataLength / VERTICAL_LINE_COUNT);\n\nconst tooltipFormatter = (values: TooltipFormatterParams[]) => {\n const date = dateTimeFormat(getDateAndTime(values[0].value[0]));\n\n const row = values\n .sort(({ value: valueA }, { value: valueB }) => Number(valueB[1]) - Number(valueA[1]))\n .map(({ marker, seriesName, value }) => `<div style=\"display:flex;align-items:center;\">\n <div style=\"display:flex;align-items:center;width:50px;margin-right:10px;\">\n ${marker}\n <span>${seriesName}</span>\n </div>\n <span>${value[1]}</span>\n </div>`);\n\n return `<div style=\"display:flex; flex-direction:column;\">\n <span style=\"margin-bottom:5px;\">${date}</span>\n ${row.join('\\n')}\n </div>`;\n};\n\nexport {\n isMonthWeek,\n tooltipFormatter,\n xAxisLabelFormatter,\n intervalFormatter,\n};\n"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,+BAA+B;AAC5E,SAASC,mBAAmB,QAAQ,aAAa;AAGjD,MAAMC,cAAc,GAAIC,KAAa,IAAK;EACxC,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAEpC,OAAO;IACLC,IAAI,EAAEF,WAAW,CAAC,CAAC,CAAC;IACpBG,IAAI,EAAEH,WAAW,CAAC,CAAC,CAAC,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC;EACrC,CAAC;AACH,CAAC;AAED,MAAMC,UAAU,GAAIH,IAAY,OAAAI,MAAA,CAAQ,IAAIC,IAAI,CAACL,IAAI,CAAC,CAACM,kBAAkB,CAACC,SAAS,EAAE;EAAEC,KAAK,EAAE,SAAS;EAAEC,GAAG,EAAE;AAAU,CAAC,CAAC,CAAE;AAE5H,MAAMC,cAAc,GAAGC,IAAA;EAAA,IAAC;IAAEX,IAAI;IAAEC;EAAqC,CAAC,GAAAU,IAAA;EAAA,UAAAP,MAAA,CAAQ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,CACrFG,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,MAAM;MAAEC,UAAU;MAAEX;IAAM,CAAC,GAAAS,KAAA;IAAA,yJAAAhC,MAAA,CAE7BiC,MAAM,sBAAAjC,MAAA,CACAkC,UAAU,yCAAAlC,MAAA,CAEZuB,KAAK,CAAC,CAAC,CAAC;EAAA,CACX,CAAC;EAEV,uGAAAvB,MAAA,CACqCJ,IAAI,mBAAAI,MAAA,CACrCwB,GAAG,CAACW,IAAI,CAAC,IAAI,CAAC;AAEpB,CAAC;AAED,SACE1B,WAAW,EACXY,gBAAgB,EAChBP,mBAAmB,EACnBG,iBAAiB","ignoreList":[]}
1
+ {"version":3,"file":"formatters.js","names":["CurrencyPowerBalanceTimeUnit","VERTICAL_LINE_COUNT","CURENCIES_ORDER","COLOR_CONFIG","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","M3","M1","W1","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","Math","round","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join","formatLegendData","dataCurrencies","_ref5","currency","list","length","filter","includes","name","itemStyle","color"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { VERTICAL_LINE_COUNT, CURENCIES_ORDER, COLOR_CONFIG } from './constants';\nimport { TooltipFormatterParams } from './types';\n\nconst getDateAndTime = (param: string) => {\n const dateAndTime = param.split('T');\n\n return {\n date: dateAndTime[0],\n time: dateAndTime[1].substring(0, 5),\n };\n};\n\nconst dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;\n\nconst dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;\n\nconst isMonthWeek = (\n timeUnit: CurrencyPowerBalanceTimeUnit,\n) => timeUnit === CurrencyPowerBalanceTimeUnit.M3\n || timeUnit === CurrencyPowerBalanceTimeUnit.M1\n || timeUnit === CurrencyPowerBalanceTimeUnit.W1;\n\nconst xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\n\nconst intervalFormatter = (\n dataLength: number,\n) => Math.round(dataLength / VERTICAL_LINE_COUNT);\n\nconst tooltipFormatter = (values: TooltipFormatterParams[]) => {\n const date = dateTimeFormat(getDateAndTime(values[0].value[0]));\n\n const row = values\n .sort(({ value: valueA }, { value: valueB }) => Number(valueB[1]) - Number(valueA[1]))\n .map(({ marker, seriesName, value }) => `<div style=\"display:flex;align-items:center;\">\n <div style=\"display:flex;align-items:center;width:50px;margin-right:10px;\">\n ${marker}\n <span>${seriesName}</span>\n </div>\n <span>${value[1]}</span>\n </div>`);\n\n return `<div style=\"display:flex; flex-direction:column;\">\n <span style=\"margin-bottom:5px;\">${date}</span>\n ${row.join('\\n')}\n </div>`;\n};\n\nconst formatLegendData = (values: CurrencyPowerBalance[]) => {\n const dataCurrencies = values.map(({ currency }) => currency);\n\n const list = dataCurrencies.length === CURENCIES_ORDER.length\n ? CURENCIES_ORDER\n : CURENCIES_ORDER.filter((currency) => dataCurrencies.includes(currency));\n\n return list.map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n};\n\nexport {\n isMonthWeek,\n tooltipFormatter,\n xAxisLabelFormatter,\n intervalFormatter,\n formatLegendData,\n};\n"],"mappings":"AAAA,SAA+BA,4BAA4B,QAAQ,+BAA+B;AAClG,SAASC,mBAAmB,EAAEC,eAAe,EAAEC,YAAY,QAAQ,aAAa;AAGh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QAAQ,CAAC,CAAC;EAE3E,OAAOC,IAAI,CAACT,GAAG,CAAEQ,QAAQ,KAAM;IAC7BK,IAAI,EAAEL,QAAQ;IACdM,SAAS,EAAE;MACTC,KAAK,EAAEvD,YAAY,CAACgD,QAAQ;IAC9B;EACF,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SACE9B,WAAW,EACXY,gBAAgB,EAChBP,mBAAmB,EACnBG,iBAAiB,EACjBmB,gBAAgB","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
2
- import { intervalFormatter, tooltipFormatter, xAxisLabelFormatter } from './formatters';
3
- const getOption = (values, timeUnit, isDark) => {
4
- const seriesData = values.map(_ref => {
2
+ import { intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData } from './formatters';
3
+ const getOption = (chartData, timeUnit, isDark) => {
4
+ const seriesData = chartData.map(_ref => {
5
5
  let {
6
6
  currency,
7
7
  power
@@ -26,12 +26,7 @@ const getOption = (values, timeUnit, isDark) => {
26
26
  })
27
27
  };
28
28
  });
29
- const legendData = Object.keys(COLOR_CONFIG).map(currency => ({
30
- name: currency,
31
- itemStyle: {
32
- color: COLOR_CONFIG[currency]
33
- }
34
- }));
29
+ const legendData = formatLegendData(chartData);
35
30
  return {
36
31
  animation: false,
37
32
  legend: {
@@ -1 +1 @@
1
- {"version":3,"file":"getOption.js","names":["COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","intervalFormatter","tooltipFormatter","xAxisLabelFormatter","getOption","values","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","lineStyle","data","_ref2","point","price","legendData","Object","keys","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","DARK","LIGHT","formatter","extraCssText","xAxis","axisTick","show","axisLine","splitLine","axisLabel","padding","align","margin","rotate","interval","length","label","yAxis","position","splitNumber","boundaryGap","showMaxLabel","showMinLabel","series"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';\nimport { intervalFormatter, tooltipFormatter, xAxisLabelFormatter } from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n values: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = values.map(({ currency, power }) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n lineStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n }));\n\n const legendData = Object.keys(COLOR_CONFIG).map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n padding: [0, 0, 0, 4],\n align: 'left',\n margin: 10,\n rotate: -45,\n interval: intervalFormatter(seriesData[0].data.length),\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,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GAAGP,yBAAyB,CAACoC,IAAI,GAAGpC,yBAAyB,CAACqC;QAC7E;MACF,CAAC;MACDC,SAAS,EAAEpC,gBAAgB;MAC3BqC,YAAY,EAAE;IAChB,CAAC;IACDC,KAAK,EAAE;MACL1B,IAAI,EAAE,UAAU;MAChB2B,QAAQ,EAAE;QACRC,IAAI,EAAE;MACR,CAAC;MACDC,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBE,SAAS,EAAE;QACTF,IAAI,EAAE;MACR,CAAC;MACDG,SAAS,EAAE;QACTC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACrBC,KAAK,EAAE,MAAM;QACbC,MAAM,EAAE,EAAE;QACVC,MAAM,EAAE,CAAC,EAAE;QACXC,QAAQ,EAAEjD,iBAAiB,CAACO,UAAU,CAAC,CAAC,CAAC,CAACY,IAAI,CAAC+B,MAAM,CAAC;QACtDb,SAAS,EAAGc,KAAa,IAAKjD,mBAAmB,CAACiD,KAAK,EAAE9C,QAAQ;MACnE;IACF,CAAC;IACD+C,KAAK,EAAE;MACLvC,IAAI,EAAE,OAAO;MACbwC,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,EAAEnD;EACV,CAAC;AACH,CAAC;AAED,SAASJ,SAAS","ignoreList":[]}
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;QACTD,KAAK,EAAEpB,YAAY,CAACa,QAAQ;MAC9B,CAAC;MACDS,IAAI,EAAER,KAAK,CAACH,GAAG,CAACY,KAAA;QAAA,IAAC;UAAEC,KAAK;UAAEC;QAAM,CAAC,GAAAF,KAAA;QAAA,OAAK,CAACC,KAAK,EAAEC,KAAK,CAAC;MAAA;IACtD,CAAC;EAAA,CAAC,CAAC;EAEH,MAAMC,UAAU,GAAGrB,gBAAgB,CAACE,SAAS,CAAC;EAE9C,OAAO;IACLoB,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAE;MACNN,IAAI,EAAEI,UAAU;MAChBG,MAAM,EAAE,EAAE;MACVC,IAAI,EAAE;IACR,CAAC;IACDC,OAAO,EAAE;MACPC,OAAO,EAAE,MAAM;MACfC,WAAW,EAAE;QACXC,IAAI,EAAE,GAAG;QACTC,CAAC,EAAE,CAAC;QACJd,SAAS,EAAE;UACTD,KAAK,EAAEX,MAAM,GAAGR,yBAAyB,CAACmC,IAAI,GAAGnC,yBAAyB,CAACoC;QAC7E;MACF,CAAC;MACDC,SAAS,EAAEnC,gBAAgB;MAC3BoC,YAAY,EAAE;IAChB,CAAC;IACDC,KAAK,EAAE;MACLxB,IAAI,EAAE,UAAU;MAChByB,QAAQ,EAAE;QACRC,IAAI,EAAE;MACR,CAAC;MACDC,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBE,SAAS,EAAE;QACTF,IAAI,EAAE;MACR,CAAC;MACDG,SAAS,EAAE;QACTC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACrBC,KAAK,EAAE,MAAM;QACbC,MAAM,EAAE,EAAE;QACVC,MAAM,EAAE,CAAC,EAAE;QACXC,QAAQ,EAAEhD,iBAAiB,CAACQ,UAAU,CAAC,CAAC,CAAC,CAACY,IAAI,CAAC6B,MAAM,CAAC;QACtDb,SAAS,EAAGc,KAAa,IAAKhD,mBAAmB,CAACgD,KAAK,EAAE5C,QAAQ;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 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/types.ts"],"sourcesContent":["import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface ChartProps {\n values: CurrencyPowerBalance[];\n timeUnit: CurrencyPowerBalanceTimeUnit;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/types.ts"],"sourcesContent":["import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface ChartProps {\n values: CurrencyPowerBalance[];\n timeUnit: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -17,6 +17,8 @@ if (currencyPowerBalanceParamsElements.length > 0) {
17
17
  const params = element.getAttribute('data-currency-power-balance-params');
18
18
  const mode = element.getAttribute('data-mode');
19
19
  const {
20
+ timeUnit,
21
+ currencies,
20
22
  locale
21
23
  } = JSON.parse(params);
22
24
  const isParamError = validateToolParams({
@@ -32,7 +34,9 @@ if (currencyPowerBalanceParamsElements.length > 0) {
32
34
  graphqlUrl: graphqlUrl,
33
35
  locale: locale,
34
36
  theme: mode,
35
- isParamError: isParamError
37
+ isParamError: isParamError,
38
+ timeUnit: timeUnit,
39
+ currencies: currencies
36
40
  }));
37
41
  });
38
42
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["React","createRoot","validateToolParams","CurrencyPowerBalance","graphqlUrl","configGraphQl","renderElementId","configRenderElementId","locale","configLocale","window","currencyPowerBalanceWidgetConfig","widgetsConfig","currencyPowerBalanceParamsElements","document","querySelectorAll","length","forEach","element","root","params","getAttribute","mode","JSON","parse","isParamError","name","valueCheck","value","split","render","createElement","theme","container","getElementById"],"sources":["../../../src/CurrencyPowerBalanceWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalance } from './CurrencyPowerBalance';\n\nconst {\n graphqlUrl: configGraphQl,\n renderElementId: configRenderElementId,\n locale: configLocale,\n} = window.currencyPowerBalanceWidgetConfig || {};\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst currencyPowerBalanceParamsElements = document.querySelectorAll('div[data-currency-power-balance-params]');\n\nif (currencyPowerBalanceParamsElements.length > 0) {\n currencyPowerBalanceParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-power-balance-params');\n const mode = element.getAttribute('data-mode');\n const { locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n root.render(\n <CurrencyPowerBalance\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n />,\n );\n });\n} else {\n const container = document.getElementById(configRenderElementId);\n const root = createRoot(container!);\n\n root.render(\n <CurrencyPowerBalance\n locale={configLocale}\n graphqlUrl={configGraphQl}\n />,\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAAgBC,kBAAkB,QAAQ,2BAA2B;AACrE,SAASC,oBAAoB,QAAQ,wBAAwB;AAE7D,MAAM;EACJC,UAAU,EAAEC,aAAa;EACzBC,eAAe,EAAEC,qBAAqB;EACtCC,MAAM,EAAEC;AACV,CAAC,GAAGC,MAAM,CAACC,gCAAgC,IAAI,CAAC,CAAC;AAEjD,MAAM;EACJP;AACF,CAAC,GAAGM,MAAM,CAACE,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,yCAAyC,CAAC;AAE/G,IAAIF,kCAAkC,CAACG,MAAM,GAAG,CAAC,EAAE;EACjDH,kCAAkC,CAACI,OAAO,CAAEC,OAAO,IAAK;IACtD,MAAMC,IAAI,GAAGlB,UAAU,CAACiB,OAAO,CAAC;IAChC,MAAME,MAAM,GAAGF,OAAO,CAACG,YAAY,CAAC,oCAAoC,CAAC;IACzE,MAAMC,IAAI,GAAGJ,OAAO,CAACG,YAAY,CAAC,WAAW,CAAC;IAC9C,MAAM;MAAEb;IAAO,CAAC,GAAGe,IAAI,CAACC,KAAK,CAACJ,MAAgB,CAAC;IAE/C,MAAMK,YAAY,GAAGvB,kBAAkB,CAAC;MAAEM,MAAM;MAAEJ;IAAW,CAAC,EAAE,CAC9D;MACEsB,IAAI,EAAE,QAAQ;MACdC,UAAU,EAAGC,KAAK,IAAKA,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAID,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;IACjF,CAAC,EAAE;MACDH,IAAI,EAAE;IACR,CAAC,CAAC,CAAC;IACLP,IAAI,CAACW,MAAM,CACT9B,KAAA,CAAA+B,aAAA,CAAC5B,oBAAoB;MACnBC,UAAU,EAAEA,UAAW;MACvBI,MAAM,EAAEA,MAAO;MACfwB,KAAK,EAAEV,IAAc;MACrBG,YAAY,EAAEA;IAAa,CAC5B,CACH,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,MAAM;EACL,MAAMQ,SAAS,GAAGnB,QAAQ,CAACoB,cAAc,CAAC3B,qBAAqB,CAAC;EAChE,MAAMY,IAAI,GAAGlB,UAAU,CAACgC,SAAU,CAAC;EAEnCd,IAAI,CAACW,MAAM,CACT9B,KAAA,CAAA+B,aAAA,CAAC5B,oBAAoB;IACnBK,MAAM,EAAEC,YAAa;IACrBL,UAAU,EAAEC;EAAc,CAC3B,CACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["React","createRoot","validateToolParams","CurrencyPowerBalance","graphqlUrl","configGraphQl","renderElementId","configRenderElementId","locale","configLocale","window","currencyPowerBalanceWidgetConfig","widgetsConfig","currencyPowerBalanceParamsElements","document","querySelectorAll","length","forEach","element","root","params","getAttribute","mode","timeUnit","currencies","JSON","parse","isParamError","name","valueCheck","value","split","render","createElement","theme","container","getElementById"],"sources":["../../../src/CurrencyPowerBalanceWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalance } from './CurrencyPowerBalance';\n\nconst {\n graphqlUrl: configGraphQl,\n renderElementId: configRenderElementId,\n locale: configLocale,\n} = window.currencyPowerBalanceWidgetConfig || {};\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst currencyPowerBalanceParamsElements = document.querySelectorAll('div[data-currency-power-balance-params]');\n\nif (currencyPowerBalanceParamsElements.length > 0) {\n currencyPowerBalanceParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-power-balance-params');\n const mode = element.getAttribute('data-mode');\n const { timeUnit, currencies, locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n root.render(\n <CurrencyPowerBalance\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n timeUnit={timeUnit}\n currencies={currencies}\n />,\n );\n });\n} else {\n const container = document.getElementById(configRenderElementId);\n const root = createRoot(container!);\n\n root.render(\n <CurrencyPowerBalance\n locale={configLocale}\n graphqlUrl={configGraphQl}\n />,\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAAgBC,kBAAkB,QAAQ,2BAA2B;AACrE,SAASC,oBAAoB,QAAQ,wBAAwB;AAE7D,MAAM;EACJC,UAAU,EAAEC,aAAa;EACzBC,eAAe,EAAEC,qBAAqB;EACtCC,MAAM,EAAEC;AACV,CAAC,GAAGC,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B,cAAc,CAAC7B,qBAAqB,CAAC;EAChE,MAAMY,IAAI,GAAGlB,UAAU,CAACkC,SAAU,CAAC;EAEnChB,IAAI,CAACa,MAAM,CACThC,KAAA,CAAAiC,aAAA,CAAC9B,oBAAoB;IACnBK,MAAM,EAAEC,YAAa;IACrBL,UAAU,EAAEC;EAAc,CAC3B,CACH,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyPowerBalanceWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nexport interface CurrencyPowerBalanceConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n}\n\nexport interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {\n renderElementId: string;\n locale: Locale;\n}\n\nexport interface ChartWithDataProps {\n timeUnit: CurrencyPowerBalanceTimeUnit;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyPowerBalanceWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nexport interface CurrencyPowerBalanceConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n timeUnit?: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n\nexport interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {\n renderElementId: string;\n locale: Locale;\n}\n\nexport interface MainProps {\n timeUnit?: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n\nexport interface ChartWithDataProps {\n timeUnit: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ChartWithDataProps } from './types';
3
- declare const ChartWithData: ({ timeUnit }: ChartWithDataProps) => React.JSX.Element;
3
+ declare const ChartWithData: ({ timeUnit, currencies }: ChartWithDataProps) => React.JSX.Element;
4
4
  export { ChartWithData };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CurrencyPowerBalanceConfig } from './types';
3
- declare const CurrencyPowerBalance: ({ graphqlUrl, theme, locale, isParamError, }: CurrencyPowerBalanceConfig) => React.JSX.Element;
3
+ declare const CurrencyPowerBalance: ({ graphqlUrl, theme, locale, timeUnit, currencies, isParamError, }: CurrencyPowerBalanceConfig) => React.JSX.Element;
4
4
  export { CurrencyPowerBalance };
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const Main: () => React.JSX.Element;
2
+ import { MainProps } from './types';
3
+ declare const Main: ({ timeUnit, currencies }: MainProps) => React.JSX.Element;
3
4
  export { Main };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { ChartProps } from './types';
3
- declare const Chart: ({ values, timeUnit }: ChartProps) => React.JSX.Element;
3
+ declare const Chart: ({ values, timeUnit, currencies }: ChartProps) => React.JSX.Element;
4
4
  export { Chart };
@@ -1,3 +1,4 @@
1
+ import { CurrencyName } from '../../../../gql/types/graphql';
1
2
  declare const X_LABEL_SIZE = 90;
2
3
  declare const X_LABEL_SIZE_MOBILE = 110;
3
4
  declare const Y_LABEL_SIZE_MOBILE = 35;
@@ -9,9 +10,19 @@ declare const LEGEND_HEIGHT_MOBILE = 70;
9
10
  declare const VERTICAL_LINE_COUNT = 10;
10
11
  declare const CANDLE_NUMBER_HOUR = 12;
11
12
  declare const CANDLE_MINUTE = 5;
12
- declare const COLOR_CONFIG: Record<string, string>;
13
+ declare const CURENCIES_ORDER: CurrencyName[];
14
+ declare const COLOR_CONFIG: {
15
+ USD: string;
16
+ EUR: string;
17
+ GBP: string;
18
+ JPY: string;
19
+ CHF: string;
20
+ AUD: string;
21
+ CAD: string;
22
+ NZD: string;
23
+ };
13
24
  declare const TOOLTIP_LINE_COLOR_CONFIG: {
14
25
  DARK: string;
15
26
  LIGHT: string;
16
27
  };
17
- export { X_LABEL_SIZE, X_LABEL_SIZE_MOBILE, Y_LABEL_SIZE_MOBILE, Y_LABEL_SIZE, CHART_WIDTH, CHART_HEIGHT, LEGEND_HEIGHT, LEGEND_HEIGHT_MOBILE, VERTICAL_LINE_COUNT, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, CANDLE_NUMBER_HOUR, CANDLE_MINUTE, };
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, };
@@ -1,7 +1,13 @@
1
- import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
1
+ import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
2
  import { TooltipFormatterParams } from './types';
3
3
  declare const isMonthWeek: (timeUnit: CurrencyPowerBalanceTimeUnit) => boolean;
4
4
  declare const xAxisLabelFormatter: (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => string;
5
5
  declare const intervalFormatter: (dataLength: number) => number;
6
6
  declare const tooltipFormatter: (values: TooltipFormatterParams[]) => string;
7
- export { isMonthWeek, tooltipFormatter, xAxisLabelFormatter, intervalFormatter, };
7
+ declare const formatLegendData: (values: CurrencyPowerBalance[]) => {
8
+ name: import("../../../../gql/types/graphql").CurrencyName;
9
+ itemStyle: {
10
+ color: string;
11
+ };
12
+ }[];
13
+ export { isMonthWeek, tooltipFormatter, xAxisLabelFormatter, intervalFormatter, formatLegendData, };
@@ -1,9 +1,9 @@
1
1
  import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
- declare const getOption: (values: CurrencyPowerBalance[], timeUnit: CurrencyPowerBalanceTimeUnit, isDark: boolean) => {
2
+ declare const getOption: (chartData: CurrencyPowerBalance[], timeUnit: CurrencyPowerBalanceTimeUnit, isDark: boolean) => {
3
3
  animation: boolean;
4
4
  legend: {
5
5
  data: {
6
- name: string;
6
+ name: import("../../../../gql/types/graphql").CurrencyName;
7
7
  itemStyle: {
8
8
  color: string;
9
9
  };
@@ -2,4 +2,5 @@ import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../gql
2
2
  export interface ChartProps {
3
3
  values: CurrencyPowerBalance[];
4
4
  timeUnit: CurrencyPowerBalanceTimeUnit;
5
+ currencies?: string[];
5
6
  }