@oanda/labs-currency-power-balance-widget 1.0.105 → 1.0.107
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.
- package/CHANGELOG.md +860 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +6 -2
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -2
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +50 -6
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js +10 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -0
- package/dist/main/translations/sources/en.json +1 -0
- package/dist/main/translations/sources/es.json +1 -0
- package/dist/main/translations/sources/th.json +1 -0
- package/dist/main/translations/sources/zh_TW.json +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +7 -3
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +3 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +2 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +50 -6
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js +4 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -0
- package/dist/module/translations/sources/en.json +1 -0
- package/dist/module/translations/sources/es.json +1 -0
- package/dist/module/translations/sources/th.json +1 -0
- package/dist/module/translations/sources/zh_TW.json +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +3 -2
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +40 -4
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/utils.d.ts +2 -0
- package/package.json +3 -3
- package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +5 -2
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/{constants.tsx → constants.ts} +5 -2
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +4 -4
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +54 -4
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts +12 -0
- package/src/translations/sources/en.json +1 -0
- package/src/translations/sources/es.json +1 -0
- package/src/translations/sources/th.json +1 -0
- package/src/translations/sources/zh_TW.json +1 -0
- package/test/chartFormatters.test.ts +3 -1
- package/test/utils.test.ts +34 -0
|
@@ -11,12 +11,13 @@ var _charts = require("echarts/charts");
|
|
|
11
11
|
var _renderers = require("echarts/renderers");
|
|
12
12
|
var _components = require("echarts/components");
|
|
13
13
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
14
|
+
var _monoI18n = require("@oanda/mono-i18n");
|
|
14
15
|
var _constants = require("./options/constants");
|
|
15
16
|
var _options = require("./options");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
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); }
|
|
18
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
-
echarts.use([_components.GridSimpleComponent, _components.GraphicComponent, _components.TooltipComponent, _components.LegendPlainComponent, _charts.LineChart, _renderers.CanvasRenderer]);
|
|
20
|
+
echarts.use([_components.GridSimpleComponent, _components.GraphicComponent, _components.TooltipComponent, _components.LegendPlainComponent, _charts.LineChart, _renderers.CanvasRenderer, _components.MarkLineComponent]);
|
|
20
21
|
echarts.registerTheme('dark_theme', (0, _labsWidgetCommon.getChartTheme)(_labsWidgetCommon.Theme.Dark));
|
|
21
22
|
echarts.registerTheme('light_theme', (0, _labsWidgetCommon.getChartTheme)(_labsWidgetCommon.Theme.Light));
|
|
22
23
|
const Chart = _ref => {
|
|
@@ -25,6 +26,9 @@ const Chart = _ref => {
|
|
|
25
26
|
timeUnit,
|
|
26
27
|
currencies
|
|
27
28
|
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
lang
|
|
31
|
+
} = (0, _monoI18n.useLocale)();
|
|
28
32
|
const {
|
|
29
33
|
isDark,
|
|
30
34
|
size
|
|
@@ -52,7 +56,7 @@ const Chart = _ref => {
|
|
|
52
56
|
height: `${_constants.CHART_HEIGHT}px`,
|
|
53
57
|
width: '100%'
|
|
54
58
|
},
|
|
55
|
-
option: (0, _options.getOption)(chartData, timeUnit, isDark)
|
|
59
|
+
option: (0, _options.getOption)(chartData, timeUnit, isDark, lang)
|
|
56
60
|
});
|
|
57
61
|
};
|
|
58
62
|
exports.Chart = Chart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","names":["_react","_interopRequireWildcard","require","_core","_interopRequireDefault","echarts","_charts","_renderers","_components","_labsWidgetCommon","_constants","_options","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","use","GridSimpleComponent","GraphicComponent","TooltipComponent","LegendPlainComponent","LineChart","CanvasRenderer","registerTheme","getChartTheme","Theme","Dark","Light","Chart","_ref","values","timeUnit","currencies","isDark","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","isMobile","MOBILE","echartRef","useRef","chartData","filter","_ref2","currency","includes","useEffect","current","echartInstance","getEchartsInstance","setOption","getResponsiveOption","createElement","ref","theme","style","height","CHART_HEIGHT","width","option","getOption","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx"],"sourcesContent":["import React, { useRef, useEffect, useContext } from 'react';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport * as echarts from 'echarts/core';\nimport { LineChart } from 'echarts/charts';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent,\n} from 'echarts/components';\nimport {\n Theme, ThemeContext, getChartTheme, Size,\n} from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n} from './options/constants';\nimport { getResponsiveOption, getOption } from './options';\nimport { ChartProps } from './types';\n\necharts.use([\n GridSimpleComponent,\n GraphicComponent,\n TooltipComponent,\n LegendPlainComponent,\n LineChart,\n CanvasRenderer,\n]);\n\necharts.registerTheme('dark_theme', getChartTheme(Theme.Dark));\necharts.registerTheme('light_theme', getChartTheme(Theme.Light));\n\nconst Chart = ({ values, timeUnit, currencies }: ChartProps) => {\n const { isDark, size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const isMobile = size === Size.MOBILE;\n\n const echartRef = useRef(null);\n\n const chartData = currencies\n ? values.filter(({ currency }) => currencies.includes(currency))\n : values;\n\n useEffect(() => {\n if (echartRef.current) {\n // @ts-ignore\n const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;\n\n echartInstance.setOption(\n getResponsiveOption(isDesktop, isMobile, isDark),\n );\n }\n }, [echartRef, isDesktop, isMobile, isDark]);\n\n return (\n <ReactEChartsCore\n echarts={echarts}\n ref={echartRef}\n theme={isDark ? 'dark_theme' : 'light_theme'}\n style={{\n height: `${CHART_HEIGHT}px`,\n width: '100%',\n }}\n option={getOption(chartData, timeUnit, isDark)}\n />\n );\n};\n\nexport { Chart };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAJ,uBAAA,CAAAC,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAGA,IAAAO,iBAAA,GAAAP,OAAA;AAGA,IAAAQ,
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["_react","_interopRequireWildcard","require","_core","_interopRequireDefault","echarts","_charts","_renderers","_components","_labsWidgetCommon","_monoI18n","_constants","_options","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","use","GridSimpleComponent","GraphicComponent","TooltipComponent","LegendPlainComponent","LineChart","CanvasRenderer","MarkLineComponent","registerTheme","getChartTheme","Theme","Dark","Light","Chart","_ref","values","timeUnit","currencies","lang","useLocale","isDark","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","isMobile","MOBILE","echartRef","useRef","chartData","filter","_ref2","currency","includes","useEffect","current","echartInstance","getEchartsInstance","setOption","getResponsiveOption","createElement","ref","theme","style","height","CHART_HEIGHT","width","option","getOption","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx"],"sourcesContent":["import React, { useRef, useEffect, useContext } from 'react';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport * as echarts from 'echarts/core';\nimport { LineChart } from 'echarts/charts';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport {\n GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, MarkLineComponent,\n} from 'echarts/components';\nimport {\n Theme, ThemeContext, getChartTheme, Size,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\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 MarkLineComponent,\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 { lang } = useLocale();\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, lang)}\n />\n );\n};\n\nexport { Chart };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAJ,u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AACQ,OAAO,EAAE;MAErB,MAAMC,cAAc,GAAGT,SAAS,CAACQ,OAAO,CAACE,kBAAkB,CAAC,CAAwB;MAEpFD,cAAc,CAACE,SAAS,CACtB,IAAAC,4BAAmB,EAACjB,SAAS,EAAEG,QAAQ,EAAEP,MAAM,CACjD,CAAC;IACH;EACF,CAAC,EAAE,CAACS,SAAS,EAAEL,SAAS,EAAEG,QAAQ,EAAEP,MAAM,CAAC,CAAC;EAE5C,OACErD,MAAA,CAAAe,OAAA,CAAA4D,aAAA,CAACxE,KAAA,CAAAY,OAAgB;IACfV,OAAO,EAAEA,OAAQ;IACjBuE,GAAG,EAAEd,SAAU;IACfe,KAAK,EAAExB,MAAM,GAAG,YAAY,GAAG,aAAc;IAC7CyB,KAAK,EAAE;MACLC,MAAM,EAAE,GAAGC,uBAAY,IAAI;MAC3BC,KAAK,EAAE;IACT,CAAE;IACFC,MAAM,EAAE,IAAAC,kBAAS,EAACnB,SAAS,EAAEf,QAAQ,EAAEI,MAAM,EAAEF,IAAI;EAAE,CACtD,CAAC;AAEN,CAAC;AAACiC,OAAA,CAAAtC,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Y_LABEL_SIZE_MOBILE = exports.Y_LABEL_SIZE = exports.X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE = exports.VERTICAL_LINE_COUNT = exports.TOOLTIP_LINE_COLOR_CONFIG = exports.LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT = exports.
|
|
6
|
+
exports.Y_LABEL_SIZE_MOBILE = exports.Y_LABEL_SIZE = exports.X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE = exports.WEEKEND_DURATION = exports.VERTICAL_LINE_COUNT = exports.TOOLTIP_LINE_COLOR_CONFIG = exports.LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT = exports.CURRENCIES_ORDER = exports.COLOR_CONFIG = exports.CHART_WIDTH = exports.CHART_HEIGHT = exports.CANDLE_NUMBER_HOUR = exports.CANDLE_MINUTE = void 0;
|
|
7
7
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
8
|
var _graphql = require("../../../../gql/types/graphql");
|
|
9
|
+
const WEEKEND_DURATION = exports.WEEKEND_DURATION = 172800000;
|
|
9
10
|
const X_LABEL_SIZE = exports.X_LABEL_SIZE = 90;
|
|
10
11
|
const X_LABEL_SIZE_MOBILE = exports.X_LABEL_SIZE_MOBILE = 110;
|
|
11
12
|
const Y_LABEL_SIZE_MOBILE = exports.Y_LABEL_SIZE_MOBILE = 35;
|
|
@@ -17,7 +18,7 @@ const LEGEND_HEIGHT_MOBILE = exports.LEGEND_HEIGHT_MOBILE = 70;
|
|
|
17
18
|
const VERTICAL_LINE_COUNT = exports.VERTICAL_LINE_COUNT = 10;
|
|
18
19
|
const CANDLE_NUMBER_HOUR = exports.CANDLE_NUMBER_HOUR = 12;
|
|
19
20
|
const CANDLE_MINUTE = exports.CANDLE_MINUTE = 5;
|
|
20
|
-
const
|
|
21
|
+
const CURRENCIES_ORDER = exports.CURRENCIES_ORDER = [_graphql.CurrencyName.Usd, _graphql.CurrencyName.Eur, _graphql.CurrencyName.Gbp, _graphql.CurrencyName.Cad, _graphql.CurrencyName.Aud, _graphql.CurrencyName.Chf, _graphql.CurrencyName.Jpy, _graphql.CurrencyName.Nzd];
|
|
21
22
|
const COLOR_CONFIG = exports.COLOR_CONFIG = {
|
|
22
23
|
USD: _labsWidgetCommon.colorPalette.greenLight,
|
|
23
24
|
EUR: _labsWidgetCommon.colorPalette.turquoiseLight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","_graphql","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["_labsWidgetCommon","require","_graphql","WEEKEND_DURATION","exports","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","CURRENCIES_ORDER","CurrencyName","Usd","Eur","Gbp","Cad","Aud","Chf","Jpy","Nzd","COLOR_CONFIG","USD","colorPalette","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreenLight75","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport { CurrencyName } from '../../../../gql/types/graphql';\n\nconst WEEKEND_DURATION = 172800000;\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 CURRENCIES_ORDER: CurrencyName[] = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Gbp,\n CurrencyName.Cad,\n CurrencyName.Aud,\n CurrencyName.Chf,\n CurrencyName.Jpy,\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.bottleGreenLight75,\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 CURRENCIES_ORDER,\n WEEKEND_DURATION,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,SAAS;AAElC,MAAME,YAAY,GAAAD,OAAA,CAAAC,YAAA,GAAG,EAAE;AACvB,MAAMC,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAAH,OAAA,CAAAG,mBAAA,GAAG,EAAE;AAC9B,MAAMC,YAAY,GAAAJ,OAAA,CAAAI,YAAA,GAAG,EAAE;AACvB,MAAMC,WAAW,GAAAL,OAAA,CAAAK,WAAA,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAAN,OAAA,CAAAM,YAAA,GAAG,GAAG;AACxB,MAAMC,aAAa,GAAAP,OAAA,CAAAO,aAAA,GAAG,EAAE;AACxB,MAAMC,oBAAoB,GAAAR,OAAA,CAAAQ,oBAAA,GAAG,EAAE;AAC/B,MAAMC,mBAAmB,GAAAT,OAAA,CAAAS,mBAAA,GAAG,EAAE;AAC9B,MAAMC,kBAAkB,GAAAV,OAAA,CAAAU,kBAAA,GAAG,EAAE;AAC7B,MAAMC,aAAa,GAAAX,OAAA,CAAAW,aAAA,GAAG,CAAC;AAEvB,MAAMC,gBAAgC,GAAAZ,OAAA,CAAAY,gBAAA,GAAG,CACvCC,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;AAED,MAAMC,YAAY,GAAAtB,OAAA,CAAAsB,YAAA,GAAG;EACnBC,GAAG,EAAEC,8BAAY,CAACC,UAAU;EAC5BC,GAAG,EAAEF,8BAAY,CAACG,cAAc;EAChCC,GAAG,EAAEJ,8BAAY,CAACK,WAAW;EAC7BC,GAAG,EAAEN,8BAAY,CAACO,cAAc;EAChCC,GAAG,EAAER,8BAAY,CAACS,kBAAkB;EACpCC,GAAG,EAAEV,8BAAY,CAACW,MAAM;EACxBC,GAAG,EAAEZ,8BAAY,CAACa,iBAAiB;EACnCC,GAAG,EAAEd,8BAAY,CAACe;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAAxC,OAAA,CAAAwC,yBAAA,GAAG;EAChCC,IAAI,EAAEjB,8BAAY,CAACW,MAAM;EACzBO,KAAK,EAAElB,8BAAY,CAACmB;AACtB,CAAC","ignoreList":[]}
|
|
@@ -78,7 +78,7 @@ const formatLegendData = values => {
|
|
|
78
78
|
} = _ref5;
|
|
79
79
|
return currency;
|
|
80
80
|
});
|
|
81
|
-
const list = dataCurrencies.length === _constants.
|
|
81
|
+
const list = dataCurrencies.length === _constants.CURRENCIES_ORDER.length ? _constants.CURRENCIES_ORDER : _constants.CURRENCIES_ORDER.filter(currency => dataCurrencies.includes(currency));
|
|
82
82
|
return list.map(currency => ({
|
|
83
83
|
name: currency,
|
|
84
84
|
itemStyle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","names":["_graphql","require","_constants","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","CurrencyPowerBalanceTimeUnit","M3","M1","W1","exports","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","Math","round","VERTICAL_LINE_COUNT","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join","formatLegendData","dataCurrencies","_ref5","currency","list","length","
|
|
1
|
+
{"version":3,"file":"formatters.js","names":["_graphql","require","_constants","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","CurrencyPowerBalanceTimeUnit","M3","M1","W1","exports","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","Math","round","VERTICAL_LINE_COUNT","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join","formatLegendData","dataCurrencies","_ref5","currency","list","length","CURRENCIES_ORDER","filter","includes","name","itemStyle","color","COLOR_CONFIG"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { VERTICAL_LINE_COUNT, CURRENCIES_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 === CURRENCIES_ORDER.length\n ? CURRENCIES_ORDER\n : CURRENCIES_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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAGA,MAAME,cAAc,GAAIC,KAAa,IAAK;EACxC,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAEpC,OAAO;IACLC,IAAI,EAAEF,WAAW,CAAC,CAAC,CAAC;IACpBG,IAAI,EAAEH,WAAW,CAAC,CAAC,CAAC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IAC7BM,IAAI,EAAEN,QAAQ;IACdO,SAAS,EAAE;MACTC,KAAK,EAAEC,uBAAY,CAACT,QAAQ;IAC9B;EACF,CAAC,CAAC,CAAC;AACL,CAAC;AAAC3B,OAAA,CAAAwB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -4,10 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getOption = void 0;
|
|
7
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
7
8
|
var _constants = require("./constants");
|
|
8
9
|
var _formatters = require("./formatters");
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
var _graphql = require("../../../../gql/types/graphql");
|
|
11
|
+
var _utils = require("./utils");
|
|
12
|
+
const getOption = (chartData, timeUnit, isDark, lang) => {
|
|
13
|
+
const currentTheme = isDark ? _labsWidgetCommon.darkTheme : _labsWidgetCommon.lightTheme;
|
|
14
|
+
const dataTimestamps = chartData[0].power.map(x => new Date(x.point).getTime());
|
|
15
|
+
const weekendsIndexes = (0, _utils.findLastIndexesBeforeWeekend)(dataTimestamps);
|
|
16
|
+
const disableWeekendsIndicator = [_graphql.CurrencyPowerBalanceTimeUnit.CurrentDay, _graphql.CurrencyPowerBalanceTimeUnit.PreviousDay, _graphql.CurrencyPowerBalanceTimeUnit.M3].includes(timeUnit) || weekendsIndexes.length === 0;
|
|
17
|
+
const weekendsMarks = weekendsIndexes.map(item => ({
|
|
18
|
+
xAxis: item,
|
|
19
|
+
label: {
|
|
20
|
+
formatter: () => lang('market_closed')
|
|
21
|
+
}
|
|
22
|
+
}));
|
|
23
|
+
const seriesData = chartData.map((_ref, index) => {
|
|
11
24
|
let {
|
|
12
25
|
currency,
|
|
13
26
|
power
|
|
@@ -20,16 +33,47 @@ const getOption = (chartData, timeUnit, isDark) => {
|
|
|
20
33
|
itemStyle: {
|
|
21
34
|
color: _constants.COLOR_CONFIG[currency]
|
|
22
35
|
},
|
|
23
|
-
lineStyle: {
|
|
24
|
-
color: _constants.COLOR_CONFIG[currency]
|
|
25
|
-
},
|
|
26
36
|
data: power.map(_ref2 => {
|
|
27
37
|
let {
|
|
28
38
|
point,
|
|
29
39
|
price
|
|
30
40
|
} = _ref2;
|
|
31
41
|
return [point, price];
|
|
32
|
-
})
|
|
42
|
+
}),
|
|
43
|
+
markLine: index === chartData.length - 1 && !disableWeekendsIndicator ? {
|
|
44
|
+
label: {
|
|
45
|
+
show: false,
|
|
46
|
+
position: 'end',
|
|
47
|
+
align: 'center',
|
|
48
|
+
distance: -32,
|
|
49
|
+
padding: [8, 8],
|
|
50
|
+
fontSize: 12,
|
|
51
|
+
shadowBlur: 24,
|
|
52
|
+
shadowOffsetX: 0,
|
|
53
|
+
shadowOffsetY: 6,
|
|
54
|
+
borderWidth: 0,
|
|
55
|
+
color: currentTheme.textPrimary,
|
|
56
|
+
shadowColor: 'rgba(0,0,0,0.1)',
|
|
57
|
+
borderRadius: 4,
|
|
58
|
+
backgroundColor: isDark ? currentTheme.borderPrimary : currentTheme.backgroundSecondary
|
|
59
|
+
},
|
|
60
|
+
show: false,
|
|
61
|
+
emphasis: {
|
|
62
|
+
label: {
|
|
63
|
+
show: true
|
|
64
|
+
},
|
|
65
|
+
lineStyle: {
|
|
66
|
+
width: 1,
|
|
67
|
+
opacity: 0,
|
|
68
|
+
color: currentTheme.borderPrimary
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
symbol: ['none', 'none'],
|
|
72
|
+
itemStyle: {
|
|
73
|
+
color: currentTheme.borderPrimary
|
|
74
|
+
},
|
|
75
|
+
data: weekendsMarks
|
|
76
|
+
} : undefined
|
|
33
77
|
};
|
|
34
78
|
});
|
|
35
79
|
const legendData = (0, _formatters.formatLegendData)(chartData);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOption.js","names":["
|
|
1
|
+
{"version":3,"file":"getOption.js","names":["_labsWidgetCommon","require","_constants","_formatters","_graphql","_utils","getOption","chartData","timeUnit","isDark","lang","currentTheme","darkTheme","lightTheme","dataTimestamps","power","map","x","Date","point","getTime","weekendsIndexes","findLastIndexesBeforeWeekend","disableWeekendsIndicator","CurrencyPowerBalanceTimeUnit","CurrentDay","PreviousDay","M3","includes","length","weekendsMarks","item","xAxis","label","formatter","seriesData","_ref","index","currency","name","type","symbol","showSymbol","itemStyle","color","COLOR_CONFIG","data","_ref2","price","markLine","show","position","align","distance","padding","fontSize","shadowBlur","shadowOffsetX","shadowOffsetY","borderWidth","textPrimary","shadowColor","borderRadius","backgroundColor","borderPrimary","backgroundSecondary","emphasis","lineStyle","width","opacity","undefined","legendData","formatLegendData","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","tooltipFormatter","extraCssText","axisTick","axisLine","splitLine","axisLabel","margin","rotate","interval","intervalFormatter","xAxisLabelFormatter","yAxis","splitNumber","boundaryGap","showMaxLabel","showMinLabel","series","exports"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { darkTheme, lightTheme } from '@oanda/labs-widget-common';\nimport { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';\nimport {\n intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData,\n} from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { findLastIndexesBeforeWeekend } from './utils';\n\nconst getOption = (\n chartData: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n lang: (key: string) => string,\n) => {\n const currentTheme = isDark ? darkTheme : lightTheme;\n const dataTimestamps = chartData[0].power.map((x) => new Date(x.point).getTime());\n const weekendsIndexes = findLastIndexesBeforeWeekend(dataTimestamps);\n const disableWeekendsIndicator = [\n CurrencyPowerBalanceTimeUnit.CurrentDay,\n CurrencyPowerBalanceTimeUnit.PreviousDay,\n CurrencyPowerBalanceTimeUnit.M3,\n ].includes(timeUnit) || weekendsIndexes.length === 0;\n\n const weekendsMarks = weekendsIndexes.map((item) => ({\n xAxis: item,\n label: {\n formatter: () => lang('market_closed'),\n },\n }));\n\n const seriesData = chartData.map(({ currency, power }, index) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n markLine: index === chartData.length - 1 && !disableWeekendsIndicator ? {\n label: {\n show: false,\n position: 'end',\n align: 'center',\n distance: -32,\n padding: [8, 8],\n fontSize: 12,\n shadowBlur: 24,\n shadowOffsetX: 0,\n shadowOffsetY: 6,\n borderWidth: 0,\n color: currentTheme.textPrimary,\n shadowColor: 'rgba(0,0,0,0.1)',\n borderRadius: 4,\n backgroundColor: isDark ? currentTheme.borderPrimary : currentTheme.backgroundSecondary,\n },\n show: false,\n emphasis: {\n label: {\n show: true,\n },\n lineStyle: {\n width: 1,\n opacity: 0,\n color: currentTheme.borderPrimary,\n },\n },\n symbol: ['none', 'none'],\n itemStyle: {\n color: currentTheme.borderPrimary,\n },\n data: weekendsMarks,\n } : undefined,\n }));\n\n const legendData = formatLegendData(chartData);\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n padding: [0, 0, 0, 4],\n align: 'left',\n margin: 10,\n rotate: -45,\n interval: intervalFormatter(seriesData[0].data.length),\n formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n splitNumber: 5,\n axisLine: { show: false },\n axisTick: { show: false },\n boundaryGap: ['10%', '10%'],\n axisLabel: {\n showMaxLabel: false,\n showMinLabel: false,\n },\n },\n series: seriesData,\n };\n};\n\nexport { getOption };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAGA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,GAAGA,CAChBC,SAAiC,EACjCC,QAAsC,EACtCC,MAAe,EACfC,IAA6B,KAC1B;EACH,MAAMC,YAAY,GAAGF,MAAM,GAAGG,2BAAS,GAAGC,4BAAU;EACpD,MAAMC,cAAc,GAAGP,SAAS,CAAC,CAAC,CAAC,CAACQ,KAAK,CAACC,GAAG,CAAEC,CAAC,IAAK,IAAIC,IAAI,CAACD,CAAC,CAACE,KAAK,CAAC,CAACC,OAAO,CAAC,CAAC,CAAC;EACjF,MAAMC,eAAe,GAAG,IAAAC,mCAA4B,EAACR,cAAc,CAAC;EACpE,MAAMS,wBAAwB,GAAG,CAC/BC,qCAA4B,CAACC,UAAU,EACvCD,qCAA4B,CAACE,WAAW,EACxCF,qCAA4B,CAACG,EAAE,CAChC,CAACC,QAAQ,CAACpB,QAAQ,CAAC,IAAIa,eAAe,CAACQ,MAAM,KAAK,CAAC;EAEpD,MAAMC,aAAa,GAAGT,eAAe,CAACL,GAAG,CAAEe,IAAI,KAAM;IACnDC,KAAK,EAAED,IAAI;IACXE,KAAK,EAAE;MACLC,SAAS,EAAEA,CAAA,KAAMxB,IAAI,CAAC,eAAe;IACvC;EACF,CAAC,CAAC,CAAC;EAEH,MAAMyB,UAAU,GAAG5B,SAAS,CAACS,GAAG,CAAC,CAAAoB,IAAA,EAAsBC,KAAK;IAAA,IAA1B;MAAEC,QAAQ;MAAEvB;IAAM,CAAC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AAO;MACjB8C,WAAW,EAAE,CAAC;MACdT,QAAQ,EAAE;QAAEtC,IAAI,EAAE;MAAM,CAAC;MACzBqC,QAAQ,EAAE;QAAErC,IAAI,EAAE;MAAM,CAAC;MACzBgD,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;MAC3BR,SAAS,EAAE;QACTS,YAAY,EAAE,KAAK;QACnBC,YAAY,EAAE;MAChB;IACF,CAAC;IACDC,MAAM,EAAElE;EACV,CAAC;AACH,CAAC;AAACmE,OAAA,CAAAhG,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findLastIndexesBeforeWeekend = void 0;
|
|
7
|
+
var _constants = require("./constants");
|
|
8
|
+
const findLastIndexesBeforeWeekend = timestamps => timestamps.reduce((acc, timestamp, index) => timestamps.length - 1 !== index && timestamps[index + 1] - timestamp >= _constants.WEEKEND_DURATION ? [...acc, index] : acc, []);
|
|
9
|
+
exports.findLastIndexesBeforeWeekend = findLastIndexesBeforeWeekend;
|
|
10
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_constants","require","findLastIndexesBeforeWeekend","timestamps","reduce","acc","timestamp","index","length","WEEKEND_DURATION","exports"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts"],"sourcesContent":["import { WEEKEND_DURATION } from './constants';\n\nconst findLastIndexesBeforeWeekend = (timestamps: number[]) => timestamps\n .reduce((acc, timestamp, index) => (\n timestamps.length - 1 !== index && timestamps[index + 1] - timestamp >= WEEKEND_DURATION\n ? [...acc, index]\n : acc\n ), [] as number[]);\n\nexport {\n findLastIndexesBeforeWeekend,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,MAAMC,4BAA4B,GAAIC,UAAoB,IAAKA,UAAU,CACtEC,MAAM,CAAC,CAACC,GAAG,EAAEC,SAAS,EAAEC,KAAK,KAC5BJ,UAAU,CAACK,MAAM,GAAG,CAAC,KAAKD,KAAK,IAAIJ,UAAU,CAACI,KAAK,GAAG,CAAC,CAAC,GAAGD,SAAS,IAAIG,2BAAgB,GACpF,CAAC,GAAGJ,GAAG,EAAEE,KAAK,CAAC,GACfF,GACL,EAAE,EAAc,CAAC;AAACK,OAAA,CAAAR,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"hour": "{{count}} Hour",
|
|
11
11
|
"hour_plural": "{{count}} Hours",
|
|
12
12
|
"last_updated": "Last updated",
|
|
13
|
+
"market_closed": "market closed",
|
|
13
14
|
"month": "{{count}} Month",
|
|
14
15
|
"month_plural": "{{count}} Months",
|
|
15
16
|
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"hour": "{{count}} Hora",
|
|
11
11
|
"hour_plural": "{{count}} Horas",
|
|
12
12
|
"last_updated": "Última actualización",
|
|
13
|
+
"market_closed": "mercado cerrado",
|
|
13
14
|
"month": "{{count}} Mes",
|
|
14
15
|
"month_plural": "{{count}} Meses",
|
|
15
16
|
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} de {{itemCount}} entradas",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"data_unavailable": "ข้อมูลไม่พร้อมใช้งาน",
|
|
10
10
|
"hour_0": "{{count}} ชั่วโมง",
|
|
11
11
|
"last_updated": "ปรับปรุงล่าสุด",
|
|
12
|
+
"market_closed": "ตลาดปิดทำการ",
|
|
12
13
|
"month_0": "{{count}} เดือน",
|
|
13
14
|
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} จาก {{itemCount}} รายการ",
|
|
14
15
|
"previous_business_day": "วันทำการก่อนหน้า",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"data_unavailable": "沒有數據",
|
|
10
10
|
"hour_0": "{{count}} 時",
|
|
11
11
|
"last_updated": "最後更新",
|
|
12
|
+
"market_closed": "市場已收盤",
|
|
12
13
|
"month_0": "{{count}} 月",
|
|
13
14
|
"pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
|
|
14
15
|
"previous_business_day": "前一營業日",
|
|
@@ -3,11 +3,12 @@ import ReactEChartsCore from 'echarts-for-react/lib/core';
|
|
|
3
3
|
import * as echarts from 'echarts/core';
|
|
4
4
|
import { LineChart } from 'echarts/charts';
|
|
5
5
|
import { CanvasRenderer } from 'echarts/renderers';
|
|
6
|
-
import { GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent } from 'echarts/components';
|
|
6
|
+
import { GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, MarkLineComponent } from 'echarts/components';
|
|
7
7
|
import { Theme, ThemeContext, getChartTheme, Size } from '@oanda/labs-widget-common';
|
|
8
|
+
import { useLocale } from '@oanda/mono-i18n';
|
|
8
9
|
import { CHART_HEIGHT } from './options/constants';
|
|
9
10
|
import { getResponsiveOption, getOption } from './options';
|
|
10
|
-
echarts.use([GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, LineChart, CanvasRenderer]);
|
|
11
|
+
echarts.use([GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, LineChart, CanvasRenderer, MarkLineComponent]);
|
|
11
12
|
echarts.registerTheme('dark_theme', getChartTheme(Theme.Dark));
|
|
12
13
|
echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
|
|
13
14
|
const Chart = _ref => {
|
|
@@ -16,6 +17,9 @@ const Chart = _ref => {
|
|
|
16
17
|
timeUnit,
|
|
17
18
|
currencies
|
|
18
19
|
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
lang
|
|
22
|
+
} = useLocale();
|
|
19
23
|
const {
|
|
20
24
|
isDark,
|
|
21
25
|
size
|
|
@@ -43,7 +47,7 @@ const Chart = _ref => {
|
|
|
43
47
|
height: `${CHART_HEIGHT}px`,
|
|
44
48
|
width: '100%'
|
|
45
49
|
},
|
|
46
|
-
option: getOption(chartData, timeUnit, isDark)
|
|
50
|
+
option: getOption(chartData, timeUnit, isDark, lang)
|
|
47
51
|
});
|
|
48
52
|
};
|
|
49
53
|
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","currencies","isDark","size","isDesktop","DESKTOP","isMobile","MOBILE","echartRef","chartData","filter","_ref2","currency","includes","current","echartInstance","getEchartsInstance","setOption","createElement","ref","theme","style","height","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,
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["React","useRef","useEffect","useContext","ReactEChartsCore","echarts","LineChart","CanvasRenderer","GridSimpleComponent","GraphicComponent","TooltipComponent","LegendPlainComponent","MarkLineComponent","Theme","ThemeContext","getChartTheme","Size","useLocale","CHART_HEIGHT","getResponsiveOption","getOption","use","registerTheme","Dark","Light","Chart","_ref","values","timeUnit","currencies","lang","isDark","size","isDesktop","DESKTOP","isMobile","MOBILE","echartRef","chartData","filter","_ref2","currency","includes","current","echartInstance","getEchartsInstance","setOption","createElement","ref","theme","style","height","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, MarkLineComponent,\n} from 'echarts/components';\nimport {\n Theme, ThemeContext, getChartTheme, Size,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\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 MarkLineComponent,\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 { lang } = useLocale();\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, lang)}\n />\n );\n};\n\nexport { Chart };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,OAAO;AAC5D,OAAOC,gBAAgB,MAAM,4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;MAAEC;IAAS,CAAC,GAAAD,KAAA;IAAA,OAAKX,UAAU,CAACa,QAAQ,CAACD,QAAQ,CAAC;EAAA,EAAC,GAC9Dd,MAAM;EAEVzB,SAAS,CAAC,MAAM;IACd,IAAImC,SAAS,CAACM,OAAO,EAAE;MAErB,MAAMC,cAAc,GAAGP,SAAS,CAACM,OAAO,CAACE,kBAAkB,CAAC,CAAwB;MAEpFD,cAAc,CAACE,SAAS,CACtB3B,mBAAmB,CAACc,SAAS,EAAEE,QAAQ,EAAEJ,MAAM,CACjD,CAAC;IACH;EACF,CAAC,EAAE,CAACM,SAAS,EAAEJ,SAAS,EAAEE,QAAQ,EAAEJ,MAAM,CAAC,CAAC;EAE5C,OACE/B,KAAA,CAAA+C,aAAA,CAAC3C,gBAAgB;IACfC,OAAO,EAAEA,OAAQ;IACjB2C,GAAG,EAAEX,SAAU;IACfY,KAAK,EAAElB,MAAM,GAAG,YAAY,GAAG,aAAc;IAC7CmB,KAAK,EAAE;MACLC,MAAM,EAAE,GAAGjC,YAAY,IAAI;MAC3BkC,KAAK,EAAE;IACT,CAAE;IACFC,MAAM,EAAEjC,SAAS,CAACkB,SAAS,EAAEV,QAAQ,EAAEG,MAAM,EAAED,IAAI;EAAE,CACtD,CAAC;AAEN,CAAC;AAED,SAASL,KAAK","ignoreList":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
2
|
import { CurrencyName } from '../../../../gql/types/graphql';
|
|
3
|
+
const WEEKEND_DURATION = 172800000;
|
|
3
4
|
const X_LABEL_SIZE = 90;
|
|
4
5
|
const X_LABEL_SIZE_MOBILE = 110;
|
|
5
6
|
const Y_LABEL_SIZE_MOBILE = 35;
|
|
@@ -11,7 +12,7 @@ const LEGEND_HEIGHT_MOBILE = 70;
|
|
|
11
12
|
const VERTICAL_LINE_COUNT = 10;
|
|
12
13
|
const CANDLE_NUMBER_HOUR = 12;
|
|
13
14
|
const CANDLE_MINUTE = 5;
|
|
14
|
-
const
|
|
15
|
+
const CURRENCIES_ORDER = [CurrencyName.Usd, CurrencyName.Eur, CurrencyName.Gbp, CurrencyName.Cad, CurrencyName.Aud, CurrencyName.Chf, CurrencyName.Jpy, CurrencyName.Nzd];
|
|
15
16
|
const COLOR_CONFIG = {
|
|
16
17
|
USD: colorPalette.greenLight,
|
|
17
18
|
EUR: colorPalette.turquoiseLight,
|
|
@@ -26,5 +27,5 @@ const TOOLTIP_LINE_COLOR_CONFIG = {
|
|
|
26
27
|
DARK: colorPalette.orange,
|
|
27
28
|
LIGHT: colorPalette.bottleGreenDark
|
|
28
29
|
};
|
|
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,
|
|
30
|
+
export { X_LABEL_SIZE, X_LABEL_SIZE_MOBILE, Y_LABEL_SIZE_MOBILE, Y_LABEL_SIZE, CHART_WIDTH, CHART_HEIGHT, LEGEND_HEIGHT, LEGEND_HEIGHT_MOBILE, VERTICAL_LINE_COUNT, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, CANDLE_NUMBER_HOUR, CANDLE_MINUTE, CURRENCIES_ORDER, WEEKEND_DURATION };
|
|
30
31
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
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","
|
|
1
|
+
{"version":3,"file":"constants.js","names":["colorPalette","CurrencyName","WEEKEND_DURATION","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","CURRENCIES_ORDER","Usd","Eur","Gbp","Cad","Aud","Chf","Jpy","Nzd","COLOR_CONFIG","USD","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreenLight75","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport { CurrencyName } from '../../../../gql/types/graphql';\n\nconst WEEKEND_DURATION = 172800000;\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 CURRENCIES_ORDER: CurrencyName[] = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Gbp,\n CurrencyName.Cad,\n CurrencyName.Aud,\n CurrencyName.Chf,\n CurrencyName.Jpy,\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.bottleGreenLight75,\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 CURRENCIES_ORDER,\n WEEKEND_DURATION,\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,SAASC,YAAY,QAAQ,+BAA+B;AAE5D,MAAMC,gBAAgB,GAAG,SAAS;AAElC,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,gBAAgC,GAAG,CACvCb,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,EAChBpB,YAAY,CAACqB,GAAG,CACjB;AAED,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAExB,YAAY,CAACyB,UAAU;EAC5BC,GAAG,EAAE1B,YAAY,CAAC2B,cAAc;EAChCC,GAAG,EAAE5B,YAAY,CAAC6B,WAAW;EAC7BC,GAAG,EAAE9B,YAAY,CAAC+B,cAAc;EAChCC,GAAG,EAAEhC,YAAY,CAACiC,kBAAkB;EACpCC,GAAG,EAAElC,YAAY,CAACmC,MAAM;EACxBC,GAAG,EAAEpC,YAAY,CAACqC,iBAAiB;EACnCC,GAAG,EAAEtC,YAAY,CAACuC;AACpB,CAAC;AAED,MAAMC,yBAAyB,GAAG;EAChCC,IAAI,EAAEzC,YAAY,CAACmC,MAAM;EACzBO,KAAK,EAAE1C,YAAY,CAAC2C;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,gBAAgB,EAChBZ,gBAAgB","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
|
|
2
|
-
import { VERTICAL_LINE_COUNT,
|
|
2
|
+
import { VERTICAL_LINE_COUNT, CURRENCIES_ORDER, COLOR_CONFIG } from './constants';
|
|
3
3
|
const getDateAndTime = param => {
|
|
4
4
|
const dateAndTime = param.split('T');
|
|
5
5
|
return {
|
|
@@ -68,7 +68,7 @@ const formatLegendData = values => {
|
|
|
68
68
|
} = _ref5;
|
|
69
69
|
return currency;
|
|
70
70
|
});
|
|
71
|
-
const list = dataCurrencies.length ===
|
|
71
|
+
const list = dataCurrencies.length === CURRENCIES_ORDER.length ? CURRENCIES_ORDER : CURRENCIES_ORDER.filter(currency => dataCurrencies.includes(currency));
|
|
72
72
|
return list.map(currency => ({
|
|
73
73
|
name: currency,
|
|
74
74
|
itemStyle: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","names":["CurrencyPowerBalanceTimeUnit","VERTICAL_LINE_COUNT","
|
|
1
|
+
{"version":3,"file":"formatters.js","names":["CurrencyPowerBalanceTimeUnit","VERTICAL_LINE_COUNT","CURRENCIES_ORDER","COLOR_CONFIG","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","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, CURRENCIES_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 === CURRENCIES_ORDER.length\n ? CURRENCIES_ORDER\n : CURRENCIES_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,gBAAgB,EAAEC,YAAY,QAAQ,aAAa;AAGjF,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,IAAK,GAAG,IAAII,IAAI,CAACJ,IAAI,CAAC,C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anda/labs-widget-common';
|
|
1
2
|
import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
|
|
2
3
|
import { intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData } from './formatters';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
|
|
5
|
+
import { findLastIndexesBeforeWeekend } from './utils';
|
|
6
|
+
const getOption = (chartData, timeUnit, isDark, lang) => {
|
|
7
|
+
const currentTheme = isDark ? darkTheme : lightTheme;
|
|
8
|
+
const dataTimestamps = chartData[0].power.map(x => new Date(x.point).getTime());
|
|
9
|
+
const weekendsIndexes = findLastIndexesBeforeWeekend(dataTimestamps);
|
|
10
|
+
const disableWeekendsIndicator = [CurrencyPowerBalanceTimeUnit.CurrentDay, CurrencyPowerBalanceTimeUnit.PreviousDay, CurrencyPowerBalanceTimeUnit.M3].includes(timeUnit) || weekendsIndexes.length === 0;
|
|
11
|
+
const weekendsMarks = weekendsIndexes.map(item => ({
|
|
12
|
+
xAxis: item,
|
|
13
|
+
label: {
|
|
14
|
+
formatter: () => lang('market_closed')
|
|
15
|
+
}
|
|
16
|
+
}));
|
|
17
|
+
const seriesData = chartData.map((_ref, index) => {
|
|
5
18
|
let {
|
|
6
19
|
currency,
|
|
7
20
|
power
|
|
@@ -14,16 +27,47 @@ const getOption = (chartData, timeUnit, isDark) => {
|
|
|
14
27
|
itemStyle: {
|
|
15
28
|
color: COLOR_CONFIG[currency]
|
|
16
29
|
},
|
|
17
|
-
lineStyle: {
|
|
18
|
-
color: COLOR_CONFIG[currency]
|
|
19
|
-
},
|
|
20
30
|
data: power.map(_ref2 => {
|
|
21
31
|
let {
|
|
22
32
|
point,
|
|
23
33
|
price
|
|
24
34
|
} = _ref2;
|
|
25
35
|
return [point, price];
|
|
26
|
-
})
|
|
36
|
+
}),
|
|
37
|
+
markLine: index === chartData.length - 1 && !disableWeekendsIndicator ? {
|
|
38
|
+
label: {
|
|
39
|
+
show: false,
|
|
40
|
+
position: 'end',
|
|
41
|
+
align: 'center',
|
|
42
|
+
distance: -32,
|
|
43
|
+
padding: [8, 8],
|
|
44
|
+
fontSize: 12,
|
|
45
|
+
shadowBlur: 24,
|
|
46
|
+
shadowOffsetX: 0,
|
|
47
|
+
shadowOffsetY: 6,
|
|
48
|
+
borderWidth: 0,
|
|
49
|
+
color: currentTheme.textPrimary,
|
|
50
|
+
shadowColor: 'rgba(0,0,0,0.1)',
|
|
51
|
+
borderRadius: 4,
|
|
52
|
+
backgroundColor: isDark ? currentTheme.borderPrimary : currentTheme.backgroundSecondary
|
|
53
|
+
},
|
|
54
|
+
show: false,
|
|
55
|
+
emphasis: {
|
|
56
|
+
label: {
|
|
57
|
+
show: true
|
|
58
|
+
},
|
|
59
|
+
lineStyle: {
|
|
60
|
+
width: 1,
|
|
61
|
+
opacity: 0,
|
|
62
|
+
color: currentTheme.borderPrimary
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
symbol: ['none', 'none'],
|
|
66
|
+
itemStyle: {
|
|
67
|
+
color: currentTheme.borderPrimary
|
|
68
|
+
},
|
|
69
|
+
data: weekendsMarks
|
|
70
|
+
} : undefined
|
|
27
71
|
};
|
|
28
72
|
});
|
|
29
73
|
const legendData = formatLegendData(chartData);
|