@oanda/labs-instruments-price-chart-widget 1.0.1
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 +8 -0
- package/codegen.ts +18 -0
- package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +40 -0
- package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/Main.js +52 -0
- package/dist/main/InstrumentsPriceChartWidget/Main.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/Chart.js +39 -0
- package/dist/main/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/constants.js +12 -0
- package/dist/main/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/formatters.js +15 -0
- package/dist/main/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/getOption.js +119 -0
- package/dist/main/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/types.js +6 -0
- package/dist/main/InstrumentsPriceChartWidget/components/types.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/config.js +44 -0
- package/dist/main/InstrumentsPriceChartWidget/config.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/index.js +28 -0
- package/dist/main/InstrumentsPriceChartWidget/index.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/render.js +42 -0
- package/dist/main/InstrumentsPriceChartWidget/render.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/types.js +16 -0
- package/dist/main/InstrumentsPriceChartWidget/types.js.map +1 -0
- package/dist/main/gql/mock/getPriceCandles.js +30 -0
- package/dist/main/gql/mock/getPriceCandles.js.map +1 -0
- package/dist/main/gql/mock/handlers.js +62 -0
- package/dist/main/gql/mock/handlers.js.map +1 -0
- package/dist/main/gql/mock/schema.graphqls +59 -0
- package/dist/main/gql/types/fragment-masking.js +23 -0
- package/dist/main/gql/types/fragment-masking.js.map +1 -0
- package/dist/main/gql/types/gql.js +17 -0
- package/dist/main/gql/types/gql.js.map +1 -0
- package/dist/main/gql/types/graphql.js +438 -0
- package/dist/main/gql/types/graphql.js.map +1 -0
- package/dist/main/gql/types/index.js +28 -0
- package/dist/main/gql/types/index.js.map +1 -0
- package/dist/main/gql/validateInstruments.js +16 -0
- package/dist/main/gql/validateInstruments.js.map +1 -0
- package/dist/main/index.js +17 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/translations/index.js +27 -0
- package/dist/main/translations/index.js.map +1 -0
- package/dist/main/translations/sources/en.json +2 -0
- package/dist/main/translations/sources/es.json +2 -0
- package/dist/main/translations/sources/th.json +2 -0
- package/dist/main/translations/sources/zh_TW.json +2 -0
- package/dist/main/translations/translations.js +8 -0
- package/dist/main/translations/translations.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +33 -0
- package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/Main.js +44 -0
- package/dist/module/InstrumentsPriceChartWidget/Main.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/Chart.js +29 -0
- package/dist/module/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/constants.js +6 -0
- package/dist/module/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/formatters.js +8 -0
- package/dist/module/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/getOption.js +112 -0
- package/dist/module/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/types.js +2 -0
- package/dist/module/InstrumentsPriceChartWidget/components/types.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/config.js +39 -0
- package/dist/module/InstrumentsPriceChartWidget/config.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/index.js +3 -0
- package/dist/module/InstrumentsPriceChartWidget/index.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/render.js +39 -0
- package/dist/module/InstrumentsPriceChartWidget/render.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/types.js +10 -0
- package/dist/module/InstrumentsPriceChartWidget/types.js.map +1 -0
- package/dist/module/gql/mock/getPriceCandles.js +25 -0
- package/dist/module/gql/mock/getPriceCandles.js.map +1 -0
- package/dist/module/gql/mock/handlers.js +56 -0
- package/dist/module/gql/mock/handlers.js.map +1 -0
- package/dist/module/gql/mock/schema.graphqls +59 -0
- package/dist/module/gql/types/fragment-masking.js +15 -0
- package/dist/module/gql/types/fragment-masking.js.map +1 -0
- package/dist/module/gql/types/gql.js +9 -0
- package/dist/module/gql/types/gql.js.map +1 -0
- package/dist/module/gql/types/graphql.js +432 -0
- package/dist/module/gql/types/graphql.js.map +1 -0
- package/dist/module/gql/types/index.js +3 -0
- package/dist/module/gql/types/index.js.map +1 -0
- package/dist/module/gql/validateInstruments.js +10 -0
- package/dist/module/gql/validateInstruments.js.map +1 -0
- package/dist/module/index.js +2 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/translations/index.js +20 -0
- package/dist/module/translations/index.js.map +1 -0
- package/dist/module/translations/sources/en.json +2 -0
- package/dist/module/translations/sources/es.json +2 -0
- package/dist/module/translations/sources/th.json +2 -0
- package/dist/module/translations/sources/zh_TW.json +2 -0
- package/dist/module/translations/translations.js +2 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/types/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.d.ts +4 -0
- package/dist/types/InstrumentsPriceChartWidget/Main.d.ts +4 -0
- package/dist/types/InstrumentsPriceChartWidget/components/Chart.d.ts +3 -0
- package/dist/types/InstrumentsPriceChartWidget/components/constants.d.ts +5 -0
- package/dist/types/InstrumentsPriceChartWidget/components/formatters.d.ts +1 -0
- package/dist/types/InstrumentsPriceChartWidget/components/getOption.d.ts +2 -0
- package/dist/types/InstrumentsPriceChartWidget/components/types.d.ts +14 -0
- package/dist/types/InstrumentsPriceChartWidget/config.d.ts +10 -0
- package/dist/types/InstrumentsPriceChartWidget/index.d.ts +2 -0
- package/dist/types/InstrumentsPriceChartWidget/render.d.ts +1 -0
- package/dist/types/InstrumentsPriceChartWidget/types.d.ts +15 -0
- package/dist/types/gql/mock/getPriceCandles.d.ts +2 -0
- package/dist/types/gql/mock/handlers.d.ts +1 -0
- package/dist/types/gql/types/fragment-masking.d.ts +15 -0
- package/dist/types/gql/types/gql.d.ts +47 -0
- package/dist/types/gql/types/graphql.d.ts +468 -0
- package/dist/types/gql/types/index.d.ts +2 -0
- package/dist/types/gql/validateInstruments.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/translations/index.d.ts +4 -0
- package/dist/types/translations/translations.d.ts +1 -0
- package/index.ts +1 -0
- package/lokalise.config.json +18 -0
- package/package.json +24 -0
- package/src/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.tsx +40 -0
- package/src/InstrumentsPriceChartWidget/Main.tsx +59 -0
- package/src/InstrumentsPriceChartWidget/components/Chart.tsx +47 -0
- package/src/InstrumentsPriceChartWidget/components/constants.ts +5 -0
- package/src/InstrumentsPriceChartWidget/components/formatters.ts +7 -0
- package/src/InstrumentsPriceChartWidget/components/getOption.ts +127 -0
- package/src/InstrumentsPriceChartWidget/components/types.ts +19 -0
- package/src/InstrumentsPriceChartWidget/config.ts +47 -0
- package/src/InstrumentsPriceChartWidget/index.ts +2 -0
- package/src/InstrumentsPriceChartWidget/render.tsx +52 -0
- package/src/InstrumentsPriceChartWidget/types.ts +20 -0
- package/src/gql/mock/getPriceCandles.ts +26 -0
- package/src/gql/mock/handlers.ts +66 -0
- package/src/gql/mock/schema.graphqls +59 -0
- package/src/gql/types/fragment-masking.ts +86 -0
- package/src/gql/types/gql.ts +54 -0
- package/src/gql/types/graphql.ts +723 -0
- package/src/gql/types/index.ts +2 -0
- package/src/gql/validateInstruments.ts +10 -0
- package/src/index.ts +1 -0
- package/src/translations/index.ts +17 -0
- package/src/translations/sources/en.json +2 -0
- package/src/translations/sources/es.json +2 -0
- package/src/translations/sources/th.json +2 -0
- package/src/translations/sources/zh_TW.json +2 -0
- package/src/translations/translations.ts +1 -0
- package/test/Main.test.tsx +26 -0
- package/test/mocks/chartMock.ts +52 -0
- package/test/mocks/index.ts +1 -0
- package/tsconfig.types.json +12 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.1 (2025-07-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @oanda/labs-instruments-price-chart-widget
|
package/codegen.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CodegenConfig } from '@graphql-codegen/cli';
|
|
2
|
+
|
|
3
|
+
const config: CodegenConfig = {
|
|
4
|
+
overwrite: true,
|
|
5
|
+
schema: [
|
|
6
|
+
'https://labs-api.uat.oanda.com/graphql',
|
|
7
|
+
'src/gql/mock/schema.graphqls',
|
|
8
|
+
],
|
|
9
|
+
documents: ['src/gql/**/*.ts', 'src/**/*.ts'],
|
|
10
|
+
generates: {
|
|
11
|
+
'src/gql/types/': {
|
|
12
|
+
preset: 'client',
|
|
13
|
+
plugins: [],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default config;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InstrumentsPriceChartWidget = void 0;
|
|
7
|
+
var _client = require("@apollo/client");
|
|
8
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _translations = require("../translations");
|
|
11
|
+
var _Main = require("./Main");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const InstrumentsPriceChartWidget = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
graphqlUrl,
|
|
16
|
+
locale,
|
|
17
|
+
theme,
|
|
18
|
+
isParamError,
|
|
19
|
+
logoLink,
|
|
20
|
+
division
|
|
21
|
+
} = _ref;
|
|
22
|
+
const client = new _client.ApolloClient({
|
|
23
|
+
uri: graphqlUrl,
|
|
24
|
+
cache: new _client.InMemoryCache()
|
|
25
|
+
});
|
|
26
|
+
return _react.default.createElement(_labsWidgetCommon.WidgetProvider, {
|
|
27
|
+
client: client,
|
|
28
|
+
locale: locale,
|
|
29
|
+
theme: theme,
|
|
30
|
+
translations: _translations.translations
|
|
31
|
+
}, _react.default.createElement(_labsWidgetCommon.WidgetWrapper, {
|
|
32
|
+
isParamError: isParamError,
|
|
33
|
+
linkArea: "logo",
|
|
34
|
+
logoLink: logoLink
|
|
35
|
+
}, _react.default.createElement(_Main.Main, {
|
|
36
|
+
division: division
|
|
37
|
+
})));
|
|
38
|
+
};
|
|
39
|
+
exports.InstrumentsPriceChartWidget = InstrumentsPriceChartWidget;
|
|
40
|
+
//# sourceMappingURL=InstrumentsPriceChartWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InstrumentsPriceChartWidget.js","names":["_client","require","_labsWidgetCommon","_react","_interopRequireDefault","_translations","_Main","e","__esModule","default","InstrumentsPriceChartWidget","_ref","graphqlUrl","locale","theme","isParamError","logoLink","division","client","ApolloClient","uri","cache","InMemoryCache","createElement","WidgetProvider","translations","WidgetWrapper","linkArea","Main","exports"],"sources":["../../../src/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { translations } from '../translations';\nimport { Main } from './Main';\nimport type { InstrumentsPriceChartConfig } from './types';\n\nconst InstrumentsPriceChartWidget = ({\n graphqlUrl,\n locale,\n theme,\n isParamError,\n logoLink,\n division,\n}: InstrumentsPriceChartConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <WidgetProvider\n client={client}\n locale={locale}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper\n isParamError={isParamError}\n linkArea=\"logo\"\n logoLink={logoLink}\n >\n <Main division={division} />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { InstrumentsPriceChartWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA8B,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG9B,MAAMG,2BAA2B,GAAGC,IAAA,IAOD;EAAA,IAPE;IACnCC,UAAU;IACVC,MAAM;IACNC,KAAK;IACLC,YAAY;IACZC,QAAQ;IACRC;EAC2B,CAAC,GAAAN,IAAA;EAC5B,MAAMO,MAAM,GAAG,IAAIC,oBAAY,CAAC;IAC9BC,GAAG,EAAER,UAAU;IACfS,KAAK,EAAE,IAAIC,qBAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEnB,MAAA,CAAAM,OAAA,CAAAc,aAAA,CAACrB,iBAAA,CAAAsB,cAAc;IACbN,MAAM,EAAEA,MAAO;IACfL,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEA,KAAM;IACbW,YAAY,EAAEA;EAAa,GAE3BtB,MAAA,CAAAM,OAAA,CAAAc,aAAA,CAACrB,iBAAA,CAAAwB,aAAa;IACZX,YAAY,EAAEA,YAAa;IAC3BY,QAAQ,EAAC,MAAM;IACfX,QAAQ,EAAEA;EAAS,GAEnBb,MAAA,CAAAM,OAAA,CAAAc,aAAA,CAACjB,KAAA,CAAAsB,IAAI;IAACX,QAAQ,EAAEA;EAAS,CAAE,CACd,CACD,CAAC;AAErB,CAAC;AAACY,OAAA,CAAAnB,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Main = void 0;
|
|
7
|
+
var _client = require("@apollo/client");
|
|
8
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _getPriceCandles = require("../gql/mock/getPriceCandles");
|
|
11
|
+
var _Chart = require("./components/Chart");
|
|
12
|
+
var _config = require("./config");
|
|
13
|
+
var _types = require("./types");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
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; }
|
|
16
|
+
const Main = _ref => {
|
|
17
|
+
let {
|
|
18
|
+
division
|
|
19
|
+
} = _ref;
|
|
20
|
+
const [selectedTimeUnit, setSelectedTimeUnit] = (0, _react.useState)(_types.TimeSpanSubset.Day_1);
|
|
21
|
+
const {
|
|
22
|
+
loading,
|
|
23
|
+
data,
|
|
24
|
+
error
|
|
25
|
+
} = (0, _client.useQuery)(_getPriceCandles.getPriceCandles, {
|
|
26
|
+
variables: {
|
|
27
|
+
timeSpan: _types.TimeSpanSubset.Day_1,
|
|
28
|
+
division
|
|
29
|
+
},
|
|
30
|
+
fetchPolicy: 'cache-and-network'
|
|
31
|
+
});
|
|
32
|
+
const showError = data?.getPriceCandles.length === 0 || !data?.getPriceCandles || !!error;
|
|
33
|
+
return _react.default.createElement("div", {
|
|
34
|
+
"data-testid": "instruments-price-chart-wrapper"
|
|
35
|
+
}, loading && _react.default.createElement("div", {
|
|
36
|
+
className: "lw-mb-[50px] lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
|
|
37
|
+
}, _react.default.createElement(_labsWidgetCommon.Spinner, {
|
|
38
|
+
size: _labsWidgetCommon.SpinnerSize.lg
|
|
39
|
+
})), !loading && !showError && _react.default.createElement("div", {
|
|
40
|
+
"data-testid": "instruments-price-chart-widget"
|
|
41
|
+
}, _react.default.createElement("div", {
|
|
42
|
+
className: "lw-flex lw-pt-2"
|
|
43
|
+
}, _react.default.createElement(_labsWidgetCommon.TimeUnitSwitch, {
|
|
44
|
+
callback: setSelectedTimeUnit,
|
|
45
|
+
options: _config.timeUnitConfig,
|
|
46
|
+
selected: selectedTimeUnit
|
|
47
|
+
})), _react.default.createElement(_Chart.Chart, {
|
|
48
|
+
values: data?.getPriceCandles
|
|
49
|
+
})));
|
|
50
|
+
};
|
|
51
|
+
exports.Main = Main;
|
|
52
|
+
//# sourceMappingURL=Main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Main.js","names":["_client","require","_labsWidgetCommon","_react","_interopRequireWildcard","_getPriceCandles","_Chart","_config","_types","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","division","selectedTimeUnit","setSelectedTimeUnit","useState","TimeSpanSubset","Day_1","loading","data","error","useQuery","getPriceCandles","variables","timeSpan","fetchPolicy","showError","length","createElement","className","Spinner","size","SpinnerSize","lg","TimeUnitSwitch","callback","options","timeUnitConfig","selected","Chart","values","exports"],"sources":["../../../src/InstrumentsPriceChartWidget/Main.tsx"],"sourcesContent":["import { useQuery } from '@apollo/client';\nimport {\n Spinner,\n SpinnerSize,\n TimeUnitSwitch,\n} from '@oanda/labs-widget-common';\nimport React, { useState } from 'react';\n\nimport { getPriceCandles } from '../gql/mock/getPriceCandles';\nimport { type GetPriceCandlesQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { timeUnitConfig } from './config';\nimport { type MainProps, TimeSpanSubset } from './types';\n\nconst Main = ({ division }: MainProps) => {\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(\n TimeSpanSubset.Day_1\n );\n\n const { loading, data, error } = useQuery<GetPriceCandlesQuery>(\n getPriceCandles,\n {\n variables: {\n timeSpan: TimeSpanSubset.Day_1,\n division,\n },\n fetchPolicy: 'cache-and-network',\n }\n );\n\n const showError =\n data?.getPriceCandles.length === 0 || !data?.getPriceCandles || !!error;\n\n return (\n <div data-testid=\"instruments-price-chart-wrapper\">\n {loading && (\n <div className=\"lw-mb-[50px] lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n\n {!loading && !showError && (\n <div data-testid=\"instruments-price-chart-widget\">\n <div className=\"lw-flex lw-pt-2\">\n <TimeUnitSwitch<TimeSpanSubset>\n callback={setSelectedTimeUnit}\n options={timeUnitConfig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Ac;IACbC,QAAQ,EAAErB,mBAAoB;IAC9BsB,OAAO,EAAEC,sBAAe;IACxBC,QAAQ,EAAEzB;EAAiB,CAC5B,CACE,CAAC,EAEN7B,MAAA,CAAAY,OAAA,CAAAgC,aAAA,CAACzC,MAAA,CAAAoD,KAAK;IAACC,MAAM,EAAErB,IAAI,EAAEG;EAAgB,CAAE,CACpC,CAEJ,CAAC;AAEV,CAAC;AAACmB,OAAA,CAAA/B,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Chart = void 0;
|
|
7
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
+
var _charts = require("echarts/charts");
|
|
9
|
+
var _components = require("echarts/components");
|
|
10
|
+
var echarts = _interopRequireWildcard(require("echarts/core"));
|
|
11
|
+
var _renderers = require("echarts/renderers");
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
var _constants = require("./constants");
|
|
14
|
+
var _getOption = require("./getOption");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
echarts.use([_components.GridSimpleComponent, _components.GraphicComponent, _charts.LineChart, _components.DatasetComponent, _charts.CustomChart, _renderers.CanvasRenderer]);
|
|
19
|
+
echarts.registerTheme('dark_theme', (0, _labsWidgetCommon.getChartTheme)(_labsWidgetCommon.Theme.Dark));
|
|
20
|
+
echarts.registerTheme('light_theme', (0, _labsWidgetCommon.getChartTheme)(_labsWidgetCommon.Theme.Light));
|
|
21
|
+
const Chart = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
values
|
|
24
|
+
} = _ref;
|
|
25
|
+
const {
|
|
26
|
+
isDark
|
|
27
|
+
} = (0, _labsWidgetCommon.useLayoutProvider)();
|
|
28
|
+
return _react.default.createElement(_labsWidgetCommon.BaseChart, {
|
|
29
|
+
chartHeight: _constants.CHART_HEIGHT,
|
|
30
|
+
echarts: echarts,
|
|
31
|
+
isDark: isDark,
|
|
32
|
+
option: (0, _getOption.getOption)({
|
|
33
|
+
values,
|
|
34
|
+
isDark
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.Chart = Chart;
|
|
39
|
+
//# sourceMappingURL=Chart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["_labsWidgetCommon","require","_charts","_components","echarts","_interopRequireWildcard","_renderers","_react","_interopRequireDefault","_constants","_getOption","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","use","GridSimpleComponent","GraphicComponent","LineChart","DatasetComponent","CustomChart","CanvasRenderer","registerTheme","getChartTheme","Theme","Dark","Light","Chart","_ref","values","isDark","useLayoutProvider","createElement","BaseChart","chartHeight","CHART_HEIGHT","option","getOption","exports"],"sources":["../../../../src/InstrumentsPriceChartWidget/components/Chart.tsx"],"sourcesContent":["import {\n BaseChart,\n getChartTheme,\n Theme,\n useLayoutProvider,\n} from '@oanda/labs-widget-common';\nimport { CustomChart, LineChart } from 'echarts/charts';\nimport {\n DatasetComponent,\n GraphicComponent,\n GridSimpleComponent,\n} from 'echarts/components';\nimport * as echarts from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport React from 'react';\n\nimport { CHART_HEIGHT } from './constants';\nimport { getOption } from './getOption';\nimport type { ChartProps } from './types';\n\necharts.use([\n GridSimpleComponent,\n GraphicComponent,\n LineChart,\n DatasetComponent,\n CustomChart,\n CanvasRenderer,\n]);\n\necharts.registerTheme('dark_theme', getChartTheme(Theme.Dark));\necharts.registerTheme('light_theme', getChartTheme(Theme.Light));\n\nexport const Chart = ({ values }: ChartProps) => {\n const { isDark } = useLayoutProvider();\n\n return (\n <BaseChart\n chartHeight={CHART_HEIGHT}\n echarts={echarts}\n isDark={isDark}\n option={getOption({\n values,\n isDark,\n })}\n />\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAKA,IAAAG,OAAA,GAAAC,uBAAA,CAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAC,sBAAA,CAAAP,OAAA;AAEA,IAAAQ,UAAA,GAAAR,OAAA;AACA,IAAAS,UAAA,GAAAT,OAAA;AAAwC,SAAAO,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,S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,CAAC,GAAG,IAAAC,mCAAiB,EAAC,CAAC;EAEtC,OACExC,MAAA,CAAAM,OAAA,CAAAmC,aAAA,CAAChD,iBAAA,CAAAiD,SAAS;IACRC,WAAW,EAAEC,uBAAa;IAC1B/C,OAAO,EAAEA,OAAQ;IACjB0C,MAAM,EAAEA,MAAO;IACfM,MAAM,EAAE,IAAAC,oBAAS,EAAC;MAChBR,MAAM;MACNC;IACF,CAAC;EAAE,CACJ,CAAC;AAEN,CAAC;AAACQ,OAAA,CAAAX,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Y_LABEL_SIZE_DESKTOP = exports.X_LABEL_SIZE = exports.CHART_WIDTH = exports.CHART_INTERVAL = exports.CHART_HEIGHT = void 0;
|
|
7
|
+
const X_LABEL_SIZE = exports.X_LABEL_SIZE = 40;
|
|
8
|
+
const Y_LABEL_SIZE_DESKTOP = exports.Y_LABEL_SIZE_DESKTOP = 45;
|
|
9
|
+
const CHART_WIDTH = exports.CHART_WIDTH = 9999;
|
|
10
|
+
const CHART_HEIGHT = exports.CHART_HEIGHT = 425;
|
|
11
|
+
const CHART_INTERVAL = exports.CHART_INTERVAL = 0.01;
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":["X_LABEL_SIZE","exports","Y_LABEL_SIZE_DESKTOP","CHART_WIDTH","CHART_HEIGHT","CHART_INTERVAL"],"sources":["../../../../src/InstrumentsPriceChartWidget/components/constants.ts"],"sourcesContent":["export const X_LABEL_SIZE = 40;\nexport const Y_LABEL_SIZE_DESKTOP = 45;\nexport const CHART_WIDTH = 9999;\nexport const CHART_HEIGHT = 425;\nexport const CHART_INTERVAL = 0.01;\n"],"mappings":";;;;;;AAAO,MAAMA,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,EAAE;AACvB,MAAME,oBAAoB,GAAAD,OAAA,CAAAC,oBAAA,GAAG,EAAE;AAC/B,MAAMC,WAAW,GAAAF,OAAA,CAAAE,WAAA,GAAG,IAAI;AACxB,MAAMC,YAAY,GAAAH,OAAA,CAAAG,YAAA,GAAG,GAAG;AACxB,MAAMC,cAAc,GAAAJ,OAAA,CAAAI,cAAA,GAAG,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dailyFormatter = void 0;
|
|
7
|
+
const dailyFormatter = timestamp => {
|
|
8
|
+
const date = new Date(timestamp);
|
|
9
|
+
return date.toLocaleTimeString(undefined, {
|
|
10
|
+
hour: 'numeric',
|
|
11
|
+
hour12: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.dailyFormatter = dailyFormatter;
|
|
15
|
+
//# sourceMappingURL=formatters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.js","names":["dailyFormatter","timestamp","date","Date","toLocaleTimeString","undefined","hour","hour12","exports"],"sources":["../../../../src/InstrumentsPriceChartWidget/components/formatters.ts"],"sourcesContent":["export const dailyFormatter = (timestamp: string) => {\n const date = new Date(timestamp);\n return date.toLocaleTimeString(undefined, {\n hour: 'numeric',\n hour12: true,\n });\n};\n"],"mappings":";;;;;;AAAO,MAAMA,cAAc,GAAIC,SAAiB,IAAK;EACnD,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACF,SAAS,CAAC;EAChC,OAAOC,IAAI,CAACE,kBAAkB,CAACC,SAAS,EAAE;IACxCC,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE;EACV,CAAC,CAAC;AACJ,CAAC;AAACC,OAAA,CAAAR,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getOption = void 0;
|
|
7
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
+
var _constants = require("./constants");
|
|
9
|
+
var _formatters = require("./formatters");
|
|
10
|
+
const getOption = _ref => {
|
|
11
|
+
let {
|
|
12
|
+
values,
|
|
13
|
+
isDark
|
|
14
|
+
} = _ref;
|
|
15
|
+
const priceValues = values.map(d => d.candle.high);
|
|
16
|
+
const timestamps = values.map(d => (0, _formatters.dailyFormatter)(d.time));
|
|
17
|
+
const labelInterval = Math.max(1, Math.floor(timestamps.length / 6));
|
|
18
|
+
const gridLines = (0, _labsWidgetCommon.getGridLines)({
|
|
19
|
+
isDark,
|
|
20
|
+
chartWidth: _constants.CHART_WIDTH,
|
|
21
|
+
chartHeight: _constants.CHART_HEIGHT,
|
|
22
|
+
xLabelsSize: _constants.X_LABEL_SIZE,
|
|
23
|
+
yLabelSize: _constants.Y_LABEL_SIZE_DESKTOP,
|
|
24
|
+
bottomLeftBox: false
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
xAxis: {
|
|
28
|
+
type: 'category',
|
|
29
|
+
boundaryGap: false,
|
|
30
|
+
data: timestamps,
|
|
31
|
+
axisTick: {
|
|
32
|
+
show: false
|
|
33
|
+
},
|
|
34
|
+
axisLabel: {
|
|
35
|
+
margin: 10,
|
|
36
|
+
interval: index => index % labelInterval === 0,
|
|
37
|
+
formatter: (value, index) => index % labelInterval === 0 ? value : ''
|
|
38
|
+
},
|
|
39
|
+
splitLine: {
|
|
40
|
+
show: true,
|
|
41
|
+
interval: index => index % labelInterval === 0
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
yAxis: {
|
|
45
|
+
type: 'value',
|
|
46
|
+
position: 'right',
|
|
47
|
+
min: value => Math.floor(value.min * 100) / 100 - _constants.CHART_INTERVAL,
|
|
48
|
+
max: value => Math.ceil(value.max * 100) / 100 + _constants.CHART_INTERVAL,
|
|
49
|
+
interval: _constants.CHART_INTERVAL,
|
|
50
|
+
axisLine: {
|
|
51
|
+
show: false
|
|
52
|
+
},
|
|
53
|
+
axisTick: {
|
|
54
|
+
show: false
|
|
55
|
+
},
|
|
56
|
+
axisLabel: {
|
|
57
|
+
margin: 8,
|
|
58
|
+
formatter: value => {
|
|
59
|
+
const dataMin = Math.floor(Math.min(...priceValues) * 100) / 100;
|
|
60
|
+
const dataMax = Math.ceil(Math.max(...priceValues) * 100) / 100;
|
|
61
|
+
if (value < dataMin || value > dataMax) {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
return value.toFixed(2);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
splitLine: {
|
|
68
|
+
show: true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
series: [{
|
|
72
|
+
name: 'price-close',
|
|
73
|
+
type: 'line',
|
|
74
|
+
data: priceValues,
|
|
75
|
+
smooth: true,
|
|
76
|
+
symbol: 'none',
|
|
77
|
+
lineStyle: {
|
|
78
|
+
color: _labsWidgetCommon.colorPalette.navyBlue,
|
|
79
|
+
width: 2
|
|
80
|
+
},
|
|
81
|
+
areaStyle: {
|
|
82
|
+
color: {
|
|
83
|
+
type: 'linear',
|
|
84
|
+
x: 0,
|
|
85
|
+
y: 0,
|
|
86
|
+
x2: 0,
|
|
87
|
+
y2: 1,
|
|
88
|
+
colorStops: [{
|
|
89
|
+
offset: 0,
|
|
90
|
+
color: _labsWidgetCommon.colorPalette.brightBlue30
|
|
91
|
+
}, {
|
|
92
|
+
offset: 1,
|
|
93
|
+
color: _labsWidgetCommon.colorPalette.brightBlue
|
|
94
|
+
}]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}],
|
|
98
|
+
grid: [{
|
|
99
|
+
name: 'main-grid',
|
|
100
|
+
top: 0,
|
|
101
|
+
left: 0,
|
|
102
|
+
right: `${_constants.Y_LABEL_SIZE_DESKTOP}px`,
|
|
103
|
+
bottom: `${_constants.X_LABEL_SIZE}px`
|
|
104
|
+
}],
|
|
105
|
+
graphic: [...gridLines, {
|
|
106
|
+
...(0, _labsWidgetCommon.getLineCommons)(isDark),
|
|
107
|
+
top: 0,
|
|
108
|
+
right: 0,
|
|
109
|
+
shape: {
|
|
110
|
+
x1: 0,
|
|
111
|
+
y1: 0,
|
|
112
|
+
x2: 0,
|
|
113
|
+
y2: 0
|
|
114
|
+
}
|
|
115
|
+
}]
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
exports.getOption = getOption;
|
|
119
|
+
//# sourceMappingURL=getOption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOption.js","names":["_labsWidgetCommon","require","_constants","_formatters","getOption","_ref","values","isDark","priceValues","map","d","candle","high","timestamps","dailyFormatter","time","labelInterval","Math","max","floor","length","gridLines","getGridLines","chartWidth","CHART_WIDTH","chartHeight","CHART_HEIGHT","xLabelsSize","X_LABEL_SIZE","yLabelSize","Y_LABEL_SIZE_DESKTOP","bottomLeftBox","xAxis","type","boundaryGap","data","axisTick","show","axisLabel","margin","interval","index","formatter","value","splitLine","yAxis","position","min","CHART_INTERVAL","ceil","axisLine","dataMin","dataMax","toFixed","series","name","smooth","symbol","lineStyle","color","colorPalette","navyBlue","width","areaStyle","x","y","x2","y2","colorStops","offset","brightBlue30","brightBlue","grid","top","left","right","bottom","graphic","getLineCommons","shape","x1","y1","exports"],"sources":["../../../../src/InstrumentsPriceChartWidget/components/getOption.ts"],"sourcesContent":["import {\n colorPalette,\n getGridLines,\n getLineCommons,\n} from '@oanda/labs-widget-common';\n\nimport {\n CHART_HEIGHT,\n CHART_INTERVAL,\n CHART_WIDTH,\n X_LABEL_SIZE,\n Y_LABEL_SIZE_DESKTOP,\n} from './constants';\nimport { dailyFormatter } from './formatters';\nimport type { ChartValue, GetOptionType } from './types';\n\nexport const getOption: GetOptionType = ({ values, isDark }) => {\n const priceValues = values.map((d) => d.candle.high);\n\n const timestamps = values.map((d) => dailyFormatter(d.time));\n\n const labelInterval = Math.max(1, Math.floor(timestamps.length / 6));\n\n const gridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: X_LABEL_SIZE,\n yLabelSize: Y_LABEL_SIZE_DESKTOP,\n bottomLeftBox: false,\n });\n\n return {\n xAxis: {\n type: 'category',\n boundaryGap: false,\n data: timestamps,\n axisTick: {\n show: false,\n },\n axisLabel: {\n margin: 10,\n interval: (index: number) => index % labelInterval === 0,\n formatter: (value: string, index: number) =>\n index % labelInterval === 0 ? value : '',\n },\n splitLine: {\n show: true,\n interval: (index: number) => index % labelInterval === 0,\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n min: (value: ChartValue) =>\n Math.floor(value.min * 100) / 100 - CHART_INTERVAL,\n max: (value: ChartValue) =>\n Math.ceil(value.max * 100) / 100 + CHART_INTERVAL,\n interval: CHART_INTERVAL,\n axisLine: { show: false },\n axisTick: { show: false },\n axisLabel: {\n margin: 8,\n formatter: (value: number) => {\n const dataMin = Math.floor(Math.min(...priceValues) * 100) / 100;\n const dataMax = Math.ceil(Math.max(...priceValues) * 100) / 100;\n if (value < dataMin || value > dataMax) {\n return '';\n }\n return value.toFixed(2);\n },\n },\n splitLine: {\n show: true,\n },\n },\n series: [\n {\n name: 'price-close',\n type: 'line',\n data: priceValues,\n smooth: true,\n symbol: 'none',\n lineStyle: {\n color: colorPalette.navyBlue,\n width: 2,\n },\n areaStyle: {\n color: {\n type: 'linear',\n x: 0,\n y: 0,\n x2: 0,\n y2: 1,\n colorStops: [\n { offset: 0, color: colorPalette.brightBlue30 },\n { offset: 1, color: colorPalette.brightBlue },\n ],\n },\n },\n },\n ],\n grid: [\n {\n name: 'main-grid',\n top: 0,\n left: 0,\n right: `${Y_LABEL_SIZE_DESKT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CACN;MACEC,IAAI,EAAE,aAAa;MACnBtB,IAAI,EAAE,MAAM;MACZE,IAAI,EAAE3B,WAAW;MACjBgD,MAAM,EAAE,IAAI;MACZC,MAAM,EAAE,MAAM;MACdC,SAAS,EAAE;QACTC,KAAK,EAAEC,8BAAY,CAACC,QAAQ;QAC5BC,KAAK,EAAE;MACT,CAAC;MACDC,SAAS,EAAE;QACTJ,KAAK,EAAE;UACL1B,IAAI,EAAE,QAAQ;UACd+B,CAAC,EAAE,CAAC;UACJC,CAAC,EAAE,CAAC;UACJC,EAAE,EAAE,CAAC;UACLC,EAAE,EAAE,CAAC;UACLC,UAAU,EAAE,CACV;YAAEC,MAAM,EAAE,CAAC;YAAEV,KAAK,EAAEC,8BAAY,CAACU;UAAa,CAAC,EAC/C;YAAED,MAAM,EAAE,CAAC;YAAEV,KAAK,EAAEC,8BAAY,CAACW;UAAW,CAAC;QAEjD;MACF;IACF,CAAC,CACF;IACDC,IAAI,EAAE,CACJ;MACEjB,IAAI,EAAE,WAAW;MACjBkB,GAAG,EAAE,CAAC;MACNC,IAAI,EAAE,CAAC;MACPC,KAAK,EAAE,GAAG7C,+BAAoB,IAAI;MAClC8C,MAAM,EAAE,GAAGhD,uBAAY;IACzB,CAAC,CACF;IACDiD,OAAO,EAAE,CACP,GAAGxD,SAAS,EACZ;MACE,GAAG,IAAAyD,gCAAc,EAACvE,MAAM,CAAC;MACzBkE,GAAG,EAAE,CAAC;MACNE,KAAK,EAAE,CAAC;MACRI,KAAK,EAAE;QACLC,EAAE,EAAE,CAAC;QACLC,EAAE,EAAE,CAAC;QACLf,EAAE,EAAE,CAAC;QACLC,EAAE,EAAE;MACN;IACF,CAAC;EAEL,CAAC;AACH,CAAC;AAACe,OAAA,CAAA9E,SAAA,GAAAA,SAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../src/InstrumentsPriceChartWidget/components/types.ts"],"sourcesContent":["import type { EChartsOption } from 'echarts';\n\nimport type { CandlesData } from '../../gql/types/graphql';\n\nexport interface ChartProps {\n values: CandlesData[];\n}\n\nexport interface GetOptionProps {\n values: CandlesData[];\n isDark: boolean;\n}\n\nexport type GetOptionType = (props: GetOptionProps) => EChartsOption;\n\nexport interface ChartValue {\n min: number;\n max: number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.timeUnitConfig = void 0;
|
|
7
|
+
var _types = require("./types");
|
|
8
|
+
const timeUnitConfig = exports.timeUnitConfig = [{
|
|
9
|
+
value: _types.TimeSpanSubset.Day_1,
|
|
10
|
+
label: '1d',
|
|
11
|
+
tooltipLabel: {
|
|
12
|
+
translationKey: 'day',
|
|
13
|
+
count: 1
|
|
14
|
+
}
|
|
15
|
+
}, {
|
|
16
|
+
value: _types.TimeSpanSubset.Week_1,
|
|
17
|
+
label: '1w',
|
|
18
|
+
tooltipLabel: {
|
|
19
|
+
translationKey: 'week',
|
|
20
|
+
count: 1
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
value: _types.TimeSpanSubset.Month_1,
|
|
24
|
+
label: '1m',
|
|
25
|
+
tooltipLabel: {
|
|
26
|
+
translationKey: 'month',
|
|
27
|
+
count: 1
|
|
28
|
+
}
|
|
29
|
+
}, {
|
|
30
|
+
value: _types.TimeSpanSubset.Month_6,
|
|
31
|
+
label: '6m',
|
|
32
|
+
tooltipLabel: {
|
|
33
|
+
translationKey: 'month',
|
|
34
|
+
count: 6
|
|
35
|
+
}
|
|
36
|
+
}, {
|
|
37
|
+
value: _types.TimeSpanSubset.Year_1,
|
|
38
|
+
label: '1y',
|
|
39
|
+
tooltipLabel: {
|
|
40
|
+
translationKey: 'year',
|
|
41
|
+
count: 1
|
|
42
|
+
}
|
|
43
|
+
}];
|
|
44
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","names":["_types","require","timeUnitConfig","exports","value","TimeSpanSubset","Day_1","label","tooltipLabel","translationKey","count","Week_1","Month_1","Month_6","Year_1"],"sources":["../../../src/InstrumentsPriceChartWidget/config.ts"],"sourcesContent":["import { TimeSpanSubset } from './types';\n\nconst timeUnitConfig = [\n {\n value: TimeSpanSubset.Day_1,\n label: '1d',\n tooltipLabel: {\n translationKey: 'day',\n count: 1,\n },\n },\n {\n value: TimeSpanSubset.Week_1,\n label: '1w',\n tooltipLabel: {\n translationKey: 'week',\n count: 1,\n },\n },\n {\n value: TimeSpanSubset.Month_1,\n label: '1m',\n tooltipLabel: {\n translationKey: 'month',\n count: 1,\n },\n },\n\n {\n value: TimeSpanSubset.Month_6,\n label: '6m',\n tooltipLabel: {\n translationKey: 'month',\n count: 6,\n },\n },\n {\n value: TimeSpanSubset.Year_1,\n label: '1y',\n tooltipLabel: {\n translationKey: 'year',\n count: 1,\n },\n },\n];\n\nexport { timeUnitConfig };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,CACrB;EACEE,KAAK,EAAEC,qBAAc,CAACC,KAAK;EAC3BC,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,KAAK;IACrBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qBAAc,CAACM,MAAM;EAC5BJ,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qBAAc,CAACO,OAAO;EAC7BL,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,OAAO;IACvBC,KAAK,EAAE;EACT;AACF,CAAC,EAED;EACEN,KAAK,EAAEC,qBAAc,CAACQ,OAAO;EAC7BN,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,OAAO;IACvBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qBAAc,CAACS,MAAM;EAC5BP,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,CACF","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _InstrumentsPriceChartWidget = require("./InstrumentsPriceChartWidget");
|
|
7
|
+
Object.keys(_InstrumentsPriceChartWidget).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _InstrumentsPriceChartWidget[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _InstrumentsPriceChartWidget[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _types = require("./types");
|
|
18
|
+
Object.keys(_types).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _types[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_InstrumentsPriceChartWidget","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_types"],"sources":["../../../src/InstrumentsPriceChartWidget/index.ts"],"sourcesContent":["export * from './InstrumentsPriceChartWidget';\nexport * from './types';\n"],"mappings":";;;;;AAAA,IAAAA,4BAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,4BAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,4BAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,4BAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _client = require("react-dom/client");
|
|
6
|
+
var _graphql = require("../gql/types/graphql");
|
|
7
|
+
var _InstrumentsPriceChartWidget = require("./InstrumentsPriceChartWidget");
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
const {
|
|
10
|
+
graphqlUrl
|
|
11
|
+
} = window.widgetsConfig || {};
|
|
12
|
+
const dataInstrumentsPriceChartParamsElements = document.querySelectorAll('div[data-instruments-price-chart-params]');
|
|
13
|
+
dataInstrumentsPriceChartParamsElements.forEach(element => {
|
|
14
|
+
const root = (0, _client.createRoot)(element);
|
|
15
|
+
const params = element.getAttribute('data-instruments-price-chart-params');
|
|
16
|
+
const mode = element.getAttribute('data-mode');
|
|
17
|
+
const {
|
|
18
|
+
division,
|
|
19
|
+
locale
|
|
20
|
+
} = JSON.parse(params);
|
|
21
|
+
const isParamError = (0, _labsWidgetCommon.validateToolParams)({
|
|
22
|
+
division,
|
|
23
|
+
locale,
|
|
24
|
+
graphqlUrl
|
|
25
|
+
}, [{
|
|
26
|
+
name: 'locale',
|
|
27
|
+
valueCheck: value => (0, _labsWidgetCommon.validateLocale)(value)
|
|
28
|
+
}, {
|
|
29
|
+
name: 'division',
|
|
30
|
+
valueCheck: value => Object.values(_graphql.Division).includes(value)
|
|
31
|
+
}, {
|
|
32
|
+
name: 'graphqlUrl'
|
|
33
|
+
}]);
|
|
34
|
+
root.render(_react.default.createElement(_InstrumentsPriceChartWidget.InstrumentsPriceChartWidget, {
|
|
35
|
+
division: division,
|
|
36
|
+
graphqlUrl: graphqlUrl,
|
|
37
|
+
isParamError: isParamError,
|
|
38
|
+
locale: locale,
|
|
39
|
+
theme: mode
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","names":["_labsWidgetCommon","require","_react","_interopRequireDefault","_client","_graphql","_InstrumentsPriceChartWidget","e","__esModule","default","graphqlUrl","window","widgetsConfig","dataInstrumentsPriceChartParamsElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","division","locale","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","validateLocale","Object","values","Division","includes","render","createElement","InstrumentsPriceChartWidget","theme"],"sources":["../../../src/InstrumentsPriceChartWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Division } from '../gql/types/graphql';\nimport { InstrumentsPriceChartWidget } from './InstrumentsPriceChartWidget';\n\nconst { graphqlUrl } = window.widgetsConfig || {};\n\nconst dataInstrumentsPriceChartParamsElements = document.querySelectorAll(\n 'div[data-instruments-price-chart-params]'\n);\n\ndataInstrumentsPriceChartParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instruments-price-chart-params');\n const mode = element.getAttribute('data-mode');\n const { division, locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams(\n {\n division,\n locale,\n graphqlUrl,\n },\n [\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'division',\n valueCheck: (value: Division) =>\n Object.values(Division).includes(value),\n },\n {\n name: 'graphqlUrl',\n },\n ]\n );\n\n root.render(\n <InstrumentsPriceChartWidget\n division={division}\n graphqlUrl={graphqlUrl}\n isParamError={isParamError}\n locale={locale}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":";;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,4BAAA,GAAAL,OAAA;AAA4E,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE5E,MAAM;EAAEG;AAAW,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAEjD,MAAMC,uCAAuC,GAAGC,QAAQ,CAACC,gBAAgB,CACvE,0CACF,CAAC;AAEDF,uCAAuC,CAACG,OAAO,CAAEC,OAAO,IAAK;EAC3D,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACF,OAAO,CAAC;EAChC,MAAMG,MAAM,GAAGH,OAAO,CAACI,YAAY,CAAC,qCAAqC,CAAC;EAC1E,MAAMC,IAAI,GAAGL,OAAO,CAACI,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IAAEE,QAAQ;IAAEC;EAAO,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACN,MAAgB,CAAC;EAEzD,MAAMO,YAAY,GAAG,IAAAC,oCAAkB,EACrC;IACEL,QAAQ;IACRC,MAAM;IACNd;EACF,CAAC,EACD,CACE;IACEmB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAyB,IAAK,IAAAC,gCAAc,EAACD,KAAK;EACjE,CAAC,EACD;IACEF,IAAI,EAAE,UAAU;IAChBC,UAAU,EAAGC,KAAe,IAC1BE,MAAM,CAACC,MAAM,CAACC,iBAAQ,CAAC,CAACC,QAAQ,CAACL,KAAK;EAC1C,CAAC,EACD;IACEF,IAAI,EAAE;EACR,CAAC,CAEL,CAAC;EAEDX,IAAI,CAACmB,MAAM,CACTnC,MAAA,CAAAO,OAAA,CAAA6B,aAAA,CAAChC,4BAAA,CAAAiC,2BAA2B;IAC1BhB,QAAQ,EAAEA,QAAS;IACnBb,UAAU,EAAEA,UAAW;IACvBiB,YAAY,EAAEA,YAAa;IAC3BH,MAAM,EAAEA,MAAO;IACfgB,KAAK,EAAElB;EAAc,CACtB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TimeSpanSubset = void 0;
|
|
7
|
+
var _graphql = require("../gql/types/graphql");
|
|
8
|
+
let TimeSpanSubset = exports.TimeSpanSubset = function (TimeSpanSubset) {
|
|
9
|
+
TimeSpanSubset[TimeSpanSubset["Day_1"] = _graphql.TimeSpan.Day_1] = "Day_1";
|
|
10
|
+
TimeSpanSubset[TimeSpanSubset["Week_1"] = _graphql.TimeSpan.Week_1] = "Week_1";
|
|
11
|
+
TimeSpanSubset[TimeSpanSubset["Month_1"] = _graphql.TimeSpan.Month_1] = "Month_1";
|
|
12
|
+
TimeSpanSubset[TimeSpanSubset["Month_6"] = _graphql.TimeSpan.Month_6] = "Month_6";
|
|
13
|
+
TimeSpanSubset[TimeSpanSubset["Year_1"] = _graphql.TimeSpan.Year_1] = "Year_1";
|
|
14
|
+
return TimeSpanSubset;
|
|
15
|
+
}({});
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":["_graphql","require","TimeSpanSubset","exports","TimeSpan","Day_1","Week_1","Month_1","Month_6","Year_1"],"sources":["../../../src/InstrumentsPriceChartWidget/types.ts"],"sourcesContent":["import type { WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division } from '../gql/types/graphql';\nimport { TimeSpan } from '../gql/types/graphql';\n\nexport interface InstrumentsPriceChartConfig extends WidgetConfig {\n division: Division;\n}\n\nexport interface MainProps {\n division: Division;\n}\n\nexport enum TimeSpanSubset {\n Day_1 = TimeSpan.Day_1,\n Week_1 = TimeSpan.Week_1,\n Month_1 = TimeSpan.Month_1,\n Month_6 = TimeSpan.Month_6,\n Year_1 = TimeSpan.Year_1,\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAAgD,IAUpCC,cAAc,GAAAC,OAAA,CAAAD,cAAA,aAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc,YAChBE,iBAAQ,CAACC,KAAK;EADZH,cAAc,CAAdA,cAAc,aAEfE,iBAAQ,CAACE,MAAM;EAFdJ,cAAc,CAAdA,cAAc,cAGdE,iBAAQ,CAACG,OAAO;EAHhBL,cAAc,CAAdA,cAAc,cAIdE,iBAAQ,CAACI,OAAO;EAJhBN,cAAc,CAAdA,cAAc,aAKfE,iBAAQ,CAACK,MAAM;EAAA,OALdP,cAAc;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPriceCandles = void 0;
|
|
7
|
+
var _client = require("@apollo/client");
|
|
8
|
+
const getPriceCandles = exports.getPriceCandles = (0, _client.gql)`
|
|
9
|
+
query GetPriceCandles(
|
|
10
|
+
$division: Division
|
|
11
|
+
$instrument: String!
|
|
12
|
+
$granularity: Granularity!
|
|
13
|
+
$timeSpan: TimeSpan!
|
|
14
|
+
) {
|
|
15
|
+
getPriceCandles(
|
|
16
|
+
division: $division
|
|
17
|
+
instrument: $instrument
|
|
18
|
+
granularity: $granularity
|
|
19
|
+
timeSpan: $timeSpan
|
|
20
|
+
) {
|
|
21
|
+
time
|
|
22
|
+
unixTime
|
|
23
|
+
candle {
|
|
24
|
+
high
|
|
25
|
+
}
|
|
26
|
+
timeSpan
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
//# sourceMappingURL=getPriceCandles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPriceCandles.js","names":["_client","require","getPriceCandles","exports","gql"],"sources":["../../../../src/gql/mock/getPriceCandles.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nconst getPriceCandles = gql`\n query GetPriceCandles(\n $division: Division\n $instrument: String!\n $granularity: Granularity!\n $timeSpan: TimeSpan!\n ) {\n getPriceCandles(\n division: $division\n instrument: $instrument\n granularity: $granularity\n timeSpan: $timeSpan\n ) {\n time\n unixTime\n candle {\n high\n }\n timeSpan\n }\n }\n`;\n\nexport { getPriceCandles };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,IAAAE,WAAG;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|