@oanda/labs-currency-power-balance-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 +15 -0
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +46 -0
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +28 -0
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/Main.js +12 -0
- package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/Tool.js +28 -0
- package/dist/main/CurrencyPowerBalanceWidget/Tool.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +45 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/index.js +17 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/index.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +31 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +59 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +103 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +36 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/index.js +28 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/index.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js +6 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js +6 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +53 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +46 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js +17 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js +6 -0
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/config.js +39 -0
- package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/constants.js +8 -0
- package/dist/main/CurrencyPowerBalanceWidget/constants.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/index.js +17 -0
- package/dist/main/CurrencyPowerBalanceWidget/index.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/render.js +28 -0
- package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -0
- package/dist/main/CurrencyPowerBalanceWidget/types.js +6 -0
- package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -0
- package/dist/main/gql/getCurrencyPowerBalance.js +11 -0
- package/dist/main/gql/getCurrencyPowerBalance.js.map +1 -0
- package/dist/main/gql/types/fragment-masking.js +24 -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 +171 -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/index.js +17 -0
- package/dist/main/index.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +39 -0
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +21 -0
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/Main.js +5 -0
- package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/Tool.js +20 -0
- package/dist/module/CurrencyPowerBalanceWidget/Tool.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +36 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/index.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/index.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +26 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +52 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +97 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +30 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/index.js +3 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/index.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +46 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +39 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/config.js +34 -0
- package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/constants.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/constants.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/index.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/index.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/render.js +25 -0
- package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/types.js +2 -0
- package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -0
- package/dist/module/gql/getCurrencyPowerBalance.js +5 -0
- package/dist/module/gql/getCurrencyPowerBalance.js.map +1 -0
- package/dist/module/gql/types/fragment-masking.js +16 -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 +165 -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/index.js +2 -0
- package/dist/module/index.js.map +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +4 -0
- package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +4 -0
- package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +3 -0
- package/dist/types/CurrencyPowerBalanceWidget/Tool.d.ts +3 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +4 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/index.d.ts +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +24 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +5 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +74 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.d.ts +110 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/index.d.ts +2 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/types.d.ts +5 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +5 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +4 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +4 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.d.ts +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +12 -0
- package/dist/types/CurrencyPowerBalanceWidget/config.d.ts +11 -0
- package/dist/types/CurrencyPowerBalanceWidget/constants.d.ts +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/index.d.ts +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/render.d.ts +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +12 -0
- package/dist/types/gql/getCurrencyPowerBalance.d.ts +1 -0
- package/dist/types/gql/types/fragment-masking.d.ts +15 -0
- package/dist/types/gql/types/gql.d.ts +36 -0
- package/dist/types/gql/types/graphql.d.ts +274 -0
- package/dist/types/gql/types/index.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/index.ts +1 -0
- package/package.json +27 -0
- package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +48 -0
- package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +24 -0
- package/src/CurrencyPowerBalanceWidget/Main.tsx +10 -0
- package/src/CurrencyPowerBalanceWidget/Tool.tsx +27 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +45 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/index.ts +1 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.tsx +41 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +46 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +82 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts +45 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/index.ts +2 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts +5 -0
- package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +6 -0
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +24 -0
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +58 -0
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.ts +1 -0
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +14 -0
- package/src/CurrencyPowerBalanceWidget/config.ts +30 -0
- package/src/CurrencyPowerBalanceWidget/constants.ts +1 -0
- package/src/CurrencyPowerBalanceWidget/index.ts +1 -0
- package/src/CurrencyPowerBalanceWidget/render.tsx +36 -0
- package/src/CurrencyPowerBalanceWidget/types.ts +15 -0
- package/src/gql/getCurrencyPowerBalance.ts +13 -0
- package/src/gql/types/fragment-masking.ts +66 -0
- package/src/gql/types/gql.ts +42 -0
- package/src/gql/types/graphql.ts +283 -0
- package/src/gql/types/index.ts +2 -0
- package/src/index.ts +1 -0
- package/test/Main.test.tsx +29 -0
- package/test/chartFormatters.test.ts +59 -0
- package/test/responsesMocks.ts +223 -0
- package/tsconfig.types.json +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Theme } from '@oanda/labs-widget-common';
|
|
2
|
+
import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
|
|
3
|
+
export interface CurrencyPowerBalanceConfig {
|
|
4
|
+
graphqlUrl: string;
|
|
5
|
+
theme?: Theme;
|
|
6
|
+
}
|
|
7
|
+
export interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {
|
|
8
|
+
renderElementId: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ChartWithDataProps {
|
|
11
|
+
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getCurrencyPowerBalance: import("@apollo/client").DocumentNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
import { Incremental } from './graphql';
|
|
3
|
+
export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<infer TType, any> ? [TType] extends [{
|
|
4
|
+
' $fragmentName'?: infer TKey;
|
|
5
|
+
}] ? TKey extends string ? {
|
|
6
|
+
' $fragmentRefs'?: {
|
|
7
|
+
[key in TKey]: TType;
|
|
8
|
+
};
|
|
9
|
+
} : never : never : never;
|
|
10
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>): TType;
|
|
11
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined): TType | null | undefined;
|
|
12
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>): ReadonlyArray<TType>;
|
|
13
|
+
export declare function useFragment<TType>(_documentNode: DocumentTypeDecoration<TType, any>, fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined): ReadonlyArray<TType> | null | undefined;
|
|
14
|
+
export declare function makeFragmentData<F extends DocumentTypeDecoration<any, any>, FT extends ResultOf<F>>(data: FT, _fragment: F): FragmentType<F>;
|
|
15
|
+
export declare function isFragmentReady<TQuery, TFrag>(queryNode: DocumentTypeDecoration<TQuery, any>, fragmentNode: TypedDocumentNode<TFrag>, data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined): data is FragmentType<typeof fragmentNode>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as types from './graphql';
|
|
2
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
3
|
+
/**
|
|
4
|
+
* Map of all GraphQL operations in the project.
|
|
5
|
+
*
|
|
6
|
+
* This map has several performance disadvantages:
|
|
7
|
+
* 1. It is not tree-shakeable, so it will include all operations in the project.
|
|
8
|
+
* 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.
|
|
9
|
+
* 3. It does not support dead code elimination, so it will add unused operations.
|
|
10
|
+
*
|
|
11
|
+
* Therefore it is highly recommended to use the babel or swc plugin for production.
|
|
12
|
+
*/
|
|
13
|
+
declare const documents: {
|
|
14
|
+
"\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n }\n }\n": DocumentNode<types.GetCurrencyPowerBalanceQuery, types.Exact<{
|
|
15
|
+
timeUnit: types.CurrencyPowerBalanceTimeUnit;
|
|
16
|
+
}>>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* The query argument is unknown!
|
|
28
|
+
* Please regenerate the types.
|
|
29
|
+
*/
|
|
30
|
+
export declare function graphql(source: string): unknown;
|
|
31
|
+
/**
|
|
32
|
+
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
33
|
+
*/
|
|
34
|
+
export declare function graphql(source: "\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n }\n }\n"): (typeof documents)["\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n }\n }\n"];
|
|
35
|
+
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
|
|
2
|
+
export type Maybe<T> = T | null;
|
|
3
|
+
export type InputMaybe<T> = Maybe<T>;
|
|
4
|
+
export type Exact<T extends {
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}> = {
|
|
7
|
+
[K in keyof T]: T[K];
|
|
8
|
+
};
|
|
9
|
+
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
|
|
10
|
+
[SubKey in K]?: Maybe<T[SubKey]>;
|
|
11
|
+
};
|
|
12
|
+
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
|
|
13
|
+
[SubKey in K]: Maybe<T[SubKey]>;
|
|
14
|
+
};
|
|
15
|
+
export type MakeEmpty<T extends {
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}, K extends keyof T> = {
|
|
18
|
+
[_ in K]?: never;
|
|
19
|
+
};
|
|
20
|
+
export type Incremental<T> = T | {
|
|
21
|
+
[P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
|
|
22
|
+
};
|
|
23
|
+
/** All built-in and custom scalars, mapped to their actual values */
|
|
24
|
+
export type Scalars = {
|
|
25
|
+
ID: {
|
|
26
|
+
input: string;
|
|
27
|
+
output: string;
|
|
28
|
+
};
|
|
29
|
+
String: {
|
|
30
|
+
input: string;
|
|
31
|
+
output: string;
|
|
32
|
+
};
|
|
33
|
+
Boolean: {
|
|
34
|
+
input: boolean;
|
|
35
|
+
output: boolean;
|
|
36
|
+
};
|
|
37
|
+
Int: {
|
|
38
|
+
input: number;
|
|
39
|
+
output: number;
|
|
40
|
+
};
|
|
41
|
+
Float: {
|
|
42
|
+
input: number;
|
|
43
|
+
output: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export type AssetClass = {
|
|
47
|
+
__typename?: 'AssetClass';
|
|
48
|
+
instruments?: Maybe<Array<Maybe<Instrument>>>;
|
|
49
|
+
name?: Maybe<Scalars['String']['output']>;
|
|
50
|
+
};
|
|
51
|
+
export declare enum BookType {
|
|
52
|
+
Order = "ORDER",
|
|
53
|
+
Position = "POSITION"
|
|
54
|
+
}
|
|
55
|
+
export declare enum CurrencyName {
|
|
56
|
+
Aud = "AUD",
|
|
57
|
+
Cad = "CAD",
|
|
58
|
+
Chf = "CHF",
|
|
59
|
+
Eur = "EUR",
|
|
60
|
+
Gbp = "GBP",
|
|
61
|
+
Jpy = "JPY",
|
|
62
|
+
Nzd = "NZD",
|
|
63
|
+
Usd = "USD"
|
|
64
|
+
}
|
|
65
|
+
export type CurrencyPower = {
|
|
66
|
+
__typename?: 'CurrencyPower';
|
|
67
|
+
/** UTC Timestamp */
|
|
68
|
+
point: Scalars['String']['output'];
|
|
69
|
+
price: Scalars['Float']['output'];
|
|
70
|
+
};
|
|
71
|
+
export type CurrencyPowerBalance = {
|
|
72
|
+
__typename?: 'CurrencyPowerBalance';
|
|
73
|
+
currency: CurrencyName;
|
|
74
|
+
power: Array<CurrencyPower>;
|
|
75
|
+
};
|
|
76
|
+
export declare enum CurrencyPowerBalanceTimeUnit {
|
|
77
|
+
CurrentDay = "CURRENT_DAY",
|
|
78
|
+
H4 = "H4",
|
|
79
|
+
H8 = "H8",
|
|
80
|
+
H24 = "H24",
|
|
81
|
+
M1 = "M1",
|
|
82
|
+
M3 = "M3",
|
|
83
|
+
PreviousDay = "PREVIOUS_DAY",
|
|
84
|
+
W1 = "W1"
|
|
85
|
+
}
|
|
86
|
+
export declare enum DataSource {
|
|
87
|
+
Ny4 = "NY4",
|
|
88
|
+
Ty3 = "TY3"
|
|
89
|
+
}
|
|
90
|
+
export declare enum Division {
|
|
91
|
+
Oap = "OAP",
|
|
92
|
+
Oau = "OAU",
|
|
93
|
+
Oc = "OC",
|
|
94
|
+
Ocan = "OCAN",
|
|
95
|
+
Oel = "OEL",
|
|
96
|
+
Ogm = "OGM",
|
|
97
|
+
Oj = "OJ",
|
|
98
|
+
Otms = "OTMS"
|
|
99
|
+
}
|
|
100
|
+
export type Instrument = {
|
|
101
|
+
__typename?: 'Instrument';
|
|
102
|
+
displayName?: Maybe<Scalars['String']['output']>;
|
|
103
|
+
name?: Maybe<Scalars['String']['output']>;
|
|
104
|
+
};
|
|
105
|
+
export type OrderPositionBucket = {
|
|
106
|
+
__typename?: 'OrderPositionBucket';
|
|
107
|
+
longCountPercent: Scalars['Float']['output'];
|
|
108
|
+
price: Scalars['Float']['output'];
|
|
109
|
+
shortCountPercent: Scalars['Float']['output'];
|
|
110
|
+
};
|
|
111
|
+
export type OrderPositionData = {
|
|
112
|
+
__typename?: 'OrderPositionData';
|
|
113
|
+
bucketWidth: Scalars['Float']['output'];
|
|
114
|
+
buckets: Array<Maybe<OrderPositionBucket>>;
|
|
115
|
+
dataSource?: Maybe<Scalars['String']['output']>;
|
|
116
|
+
instrument: Scalars['String']['output'];
|
|
117
|
+
price: Scalars['Float']['output'];
|
|
118
|
+
region?: Maybe<Scalars['String']['output']>;
|
|
119
|
+
time: Scalars['String']['output'];
|
|
120
|
+
unixTime: Scalars['Int']['output'];
|
|
121
|
+
};
|
|
122
|
+
export type Query = {
|
|
123
|
+
__typename?: 'Query';
|
|
124
|
+
assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
|
|
125
|
+
currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
|
|
126
|
+
orderPositionBooks: Array<Maybe<OrderPositionData>>;
|
|
127
|
+
sentiment?: Maybe<Array<SentimentInstrument>>;
|
|
128
|
+
sentimentList?: Maybe<Array<SentimentInstrument>>;
|
|
129
|
+
topicalInstruments?: Maybe<Array<TopicalInstrument>>;
|
|
130
|
+
topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
|
|
131
|
+
topicalInstrumentsTotalCount: Scalars['Int']['output'];
|
|
132
|
+
volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
|
|
133
|
+
volatilityChartAssetClasses?: Maybe<Array<VolatilityChartAssetClass>>;
|
|
134
|
+
};
|
|
135
|
+
export type QueryAssetClassesArgs = {
|
|
136
|
+
division: Division;
|
|
137
|
+
};
|
|
138
|
+
export type QueryCurrencyPowerBalanceArgs = {
|
|
139
|
+
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
140
|
+
};
|
|
141
|
+
export type QueryOrderPositionBooksArgs = {
|
|
142
|
+
bookType: BookType;
|
|
143
|
+
dataSource?: InputMaybe<DataSource>;
|
|
144
|
+
instrument: Scalars['String']['input'];
|
|
145
|
+
recentHours?: InputMaybe<Scalars['Int']['input']>;
|
|
146
|
+
region?: InputMaybe<Region>;
|
|
147
|
+
};
|
|
148
|
+
export type QuerySentimentArgs = {
|
|
149
|
+
division?: InputMaybe<Division>;
|
|
150
|
+
name: Scalars['String']['input'];
|
|
151
|
+
};
|
|
152
|
+
export type QuerySentimentListArgs = {
|
|
153
|
+
division?: InputMaybe<Division>;
|
|
154
|
+
sort?: InputMaybe<Sort>;
|
|
155
|
+
};
|
|
156
|
+
export type QueryTopicalInstrumentsArgs = {
|
|
157
|
+
count?: InputMaybe<Scalars['Int']['input']>;
|
|
158
|
+
division?: InputMaybe<Division>;
|
|
159
|
+
offset?: InputMaybe<Scalars['Int']['input']>;
|
|
160
|
+
sort: TopicalSort;
|
|
161
|
+
};
|
|
162
|
+
export type QueryTopicalInstrumentsChartsArgs = {
|
|
163
|
+
division?: InputMaybe<Division>;
|
|
164
|
+
instruments?: InputMaybe<Array<Scalars['String']['input']>>;
|
|
165
|
+
};
|
|
166
|
+
export type QueryTopicalInstrumentsTotalCountArgs = {
|
|
167
|
+
division?: InputMaybe<Division>;
|
|
168
|
+
sort: TopicalSort;
|
|
169
|
+
};
|
|
170
|
+
export type QueryVolatilityChartArgs = {
|
|
171
|
+
division?: InputMaybe<Division>;
|
|
172
|
+
instrument: Scalars['String']['input'];
|
|
173
|
+
timeSpan: VolatilityChartTimeSpan;
|
|
174
|
+
timeUnit: VolatilityChartTimeUnit;
|
|
175
|
+
};
|
|
176
|
+
export type QueryVolatilityChartAssetClassesArgs = {
|
|
177
|
+
division?: InputMaybe<Division>;
|
|
178
|
+
};
|
|
179
|
+
export declare enum Region {
|
|
180
|
+
Amer = "AMER",
|
|
181
|
+
Apac = "APAC",
|
|
182
|
+
Emea = "EMEA"
|
|
183
|
+
}
|
|
184
|
+
export type Sentiment = {
|
|
185
|
+
__typename?: 'Sentiment';
|
|
186
|
+
longPercent: Scalars['Float']['output'];
|
|
187
|
+
shortPercent: Scalars['Float']['output'];
|
|
188
|
+
};
|
|
189
|
+
export type SentimentInstrument = {
|
|
190
|
+
__typename?: 'SentimentInstrument';
|
|
191
|
+
displayName: Scalars['String']['output'];
|
|
192
|
+
name: Scalars['String']['output'];
|
|
193
|
+
sentiment: Sentiment;
|
|
194
|
+
};
|
|
195
|
+
export declare enum Sort {
|
|
196
|
+
Bearish = "BEARISH",
|
|
197
|
+
Bullish = "BULLISH"
|
|
198
|
+
}
|
|
199
|
+
export type TopicalInstrument = {
|
|
200
|
+
__typename?: 'TopicalInstrument';
|
|
201
|
+
displayName: Scalars['String']['output'];
|
|
202
|
+
name: Scalars['String']['output'];
|
|
203
|
+
sentiment: TopicalInstrumentSentiment;
|
|
204
|
+
updatedAt: Scalars['String']['output'];
|
|
205
|
+
};
|
|
206
|
+
export type TopicalInstrumentChart = {
|
|
207
|
+
__typename?: 'TopicalInstrumentChart';
|
|
208
|
+
chart?: Maybe<Array<Scalars['Float']['output']>>;
|
|
209
|
+
name: Scalars['String']['output'];
|
|
210
|
+
};
|
|
211
|
+
export type TopicalInstrumentSentiment = {
|
|
212
|
+
__typename?: 'TopicalInstrumentSentiment';
|
|
213
|
+
longPercent: Scalars['Float']['output'];
|
|
214
|
+
shortPercent: Scalars['Float']['output'];
|
|
215
|
+
};
|
|
216
|
+
export declare enum TopicalSort {
|
|
217
|
+
Bearish = "BEARISH",
|
|
218
|
+
Bullish = "BULLISH",
|
|
219
|
+
Hot = "HOT",
|
|
220
|
+
Popular = "POPULAR",
|
|
221
|
+
Volatile = "VOLATILE"
|
|
222
|
+
}
|
|
223
|
+
export type VolatilityChart = {
|
|
224
|
+
__typename?: 'VolatilityChart';
|
|
225
|
+
pips: Scalars['Float']['output'];
|
|
226
|
+
/** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
|
|
227
|
+
point: Scalars['String']['output'];
|
|
228
|
+
};
|
|
229
|
+
export type VolatilityChartAssetClass = {
|
|
230
|
+
__typename?: 'VolatilityChartAssetClass';
|
|
231
|
+
instruments: Array<VolatilityChartInstrument>;
|
|
232
|
+
name: Scalars['String']['output'];
|
|
233
|
+
};
|
|
234
|
+
export type VolatilityChartInstrument = {
|
|
235
|
+
__typename?: 'VolatilityChartInstrument';
|
|
236
|
+
displayName: Scalars['String']['output'];
|
|
237
|
+
name: Scalars['String']['output'];
|
|
238
|
+
};
|
|
239
|
+
export declare enum VolatilityChartTimeSpan {
|
|
240
|
+
D5 = "D5",
|
|
241
|
+
/** Valid for: H */
|
|
242
|
+
D10 = "D10",
|
|
243
|
+
/** Valid for: H */
|
|
244
|
+
M1 = "M1",
|
|
245
|
+
/** Valid for: D */
|
|
246
|
+
M3 = "M3",
|
|
247
|
+
/** Valid for: D */
|
|
248
|
+
W5 = "W5",
|
|
249
|
+
/** Valid for: W */
|
|
250
|
+
W10 = "W10"
|
|
251
|
+
}
|
|
252
|
+
export declare enum VolatilityChartTimeUnit {
|
|
253
|
+
D = "D",
|
|
254
|
+
H = "H",
|
|
255
|
+
W = "W"
|
|
256
|
+
}
|
|
257
|
+
export type GetCurrencyPowerBalanceQueryVariables = Exact<{
|
|
258
|
+
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
259
|
+
}>;
|
|
260
|
+
export type GetCurrencyPowerBalanceQuery = {
|
|
261
|
+
__typename?: 'Query';
|
|
262
|
+
currencyPowerBalance?: Array<{
|
|
263
|
+
__typename?: 'CurrencyPowerBalance';
|
|
264
|
+
currency: CurrencyName;
|
|
265
|
+
power: Array<{
|
|
266
|
+
__typename?: 'CurrencyPower';
|
|
267
|
+
point: string;
|
|
268
|
+
price: number;
|
|
269
|
+
}>;
|
|
270
|
+
}> | null;
|
|
271
|
+
};
|
|
272
|
+
export declare const GetCurrencyPowerBalanceDocument: DocumentNode<GetCurrencyPowerBalanceQuery, Exact<{
|
|
273
|
+
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
274
|
+
}>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CurrencyPowerBalanceWidget';
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src';
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oanda/labs-currency-power-balance-widget",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Labs Currency Power Balance Widget",
|
|
5
|
+
"main": "dist/main/index.js",
|
|
6
|
+
"module": "dist/module/index.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"codegen": "graphql-codegen --config codegen.ts"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "OANDA",
|
|
13
|
+
"license": "UNLICENSED",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@apollo/client": "3.7.17",
|
|
16
|
+
"@oanda/labs-widget-common": "^1.0.62",
|
|
17
|
+
"echarts": "5.4.3",
|
|
18
|
+
"echarts-for-react": "3.0.2",
|
|
19
|
+
"graphql": "16.7.1",
|
|
20
|
+
"usehooks-ts": "2.9.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@graphql-codegen/cli": "5.0.0",
|
|
24
|
+
"@graphql-codegen/client-preset": "4.1.0"
|
|
25
|
+
},
|
|
26
|
+
"gitHead": "0954a60e9c2d28ec2c2d4240fc15fbf132f827d2"
|
|
27
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useQuery } from '@apollo/client';
|
|
3
|
+
import {
|
|
4
|
+
ChartError, Spinner, SpinnerSize, Tooltip,
|
|
5
|
+
} from '@oanda/labs-widget-common';
|
|
6
|
+
import { useMediaQuery } from 'usehooks-ts';
|
|
7
|
+
import { Chart } from './components/Chart';
|
|
8
|
+
import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';
|
|
9
|
+
import { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';
|
|
10
|
+
import { ChartWithDataProps } from './types';
|
|
11
|
+
import { GetCurrencyPowerBalanceQuery, GetCurrencyPowerBalanceQueryVariables } from '../gql/types/graphql';
|
|
12
|
+
|
|
13
|
+
const ChartWithData = ({ timeUnit }: ChartWithDataProps) => {
|
|
14
|
+
const isDesktop = useMediaQuery('(min-width: 768px)');
|
|
15
|
+
const { loading, data, error } = useQuery<
|
|
16
|
+
GetCurrencyPowerBalanceQuery,
|
|
17
|
+
GetCurrencyPowerBalanceQueryVariables
|
|
18
|
+
>(getCurrencyPowerBalance, {
|
|
19
|
+
variables: {
|
|
20
|
+
timeUnit,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const showChart = data?.currencyPowerBalance && data?.currencyPowerBalance?.length > 0;
|
|
25
|
+
const showError = data?.currencyPowerBalance?.length === 0 || error;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
{loading
|
|
30
|
+
&& (
|
|
31
|
+
<div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
|
|
32
|
+
<Spinner size={SpinnerSize.lg} />
|
|
33
|
+
</div>
|
|
34
|
+
)}
|
|
35
|
+
{!loading && showChart && (
|
|
36
|
+
<Chart values={data?.currencyPowerBalance!} timeUnit={timeUnit} />
|
|
37
|
+
)}
|
|
38
|
+
{!loading && showError && (
|
|
39
|
+
<div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
|
|
40
|
+
<ChartError />
|
|
41
|
+
</div>
|
|
42
|
+
)}
|
|
43
|
+
{isDesktop && <Tooltip id={CURRENCY_POWER_BALANCE_TOOLTIP_ID} />}
|
|
44
|
+
</>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { ChartWithData };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
3
|
+
import { ThemeProvider } from '@oanda/labs-widget-common';
|
|
4
|
+
import { Main } from './Main';
|
|
5
|
+
import { CurrencyPowerBalanceConfig } from './types';
|
|
6
|
+
|
|
7
|
+
const CurrencyPowerBalance = ({
|
|
8
|
+
graphqlUrl, theme,
|
|
9
|
+
}: CurrencyPowerBalanceConfig) => {
|
|
10
|
+
const client = new ApolloClient({
|
|
11
|
+
uri: graphqlUrl,
|
|
12
|
+
cache: new InMemoryCache(),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<ThemeProvider theme={theme}>
|
|
17
|
+
<ApolloProvider client={client}>
|
|
18
|
+
<Main />
|
|
19
|
+
</ApolloProvider>
|
|
20
|
+
</ThemeProvider>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { CurrencyPowerBalance };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { timeUnitConfig } from './config';
|
|
3
|
+
import { TimeUnitSwitch } from './components/TimeUnitSwitch';
|
|
4
|
+
import { ChartWithData } from './ChartWithData';
|
|
5
|
+
import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
|
|
6
|
+
|
|
7
|
+
const Tool = () => {
|
|
8
|
+
const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<div
|
|
12
|
+
data-testid="currency-power-balance-wrapper"
|
|
13
|
+
className="lw-flex lw-flex-col lw-overflow-hidden lw-text-sm lw-tracking-normal"
|
|
14
|
+
>
|
|
15
|
+
<TimeUnitSwitch
|
|
16
|
+
selected={selectedTimeUnit}
|
|
17
|
+
callback={setSelectedTimeUnit}
|
|
18
|
+
options={timeUnitConfig}
|
|
19
|
+
/>
|
|
20
|
+
<ChartWithData
|
|
21
|
+
timeUnit={selectedTimeUnit}
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { Tool };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useRef, useEffect, useContext } from 'react';
|
|
2
|
+
import ReactECharts from 'echarts-for-react';
|
|
3
|
+
import { registerTheme, EChartsType } from 'echarts';
|
|
4
|
+
import { useMediaQuery } from 'usehooks-ts';
|
|
5
|
+
import { Theme, ThemeContext, getChartTheme } from '@oanda/labs-widget-common';
|
|
6
|
+
import {
|
|
7
|
+
CHART_HEIGHT,
|
|
8
|
+
} from './options/constants';
|
|
9
|
+
import { getResponsiveOption, getOption } from './options';
|
|
10
|
+
import { ChartProps } from './types';
|
|
11
|
+
|
|
12
|
+
registerTheme('dark_theme', getChartTheme(Theme.Dark));
|
|
13
|
+
registerTheme('light_theme', getChartTheme(Theme.Light));
|
|
14
|
+
|
|
15
|
+
const Chart = ({ values, timeUnit }: ChartProps) => {
|
|
16
|
+
const isDark = useContext(ThemeContext) === Theme.Dark;
|
|
17
|
+
const echartRef = useRef(null);
|
|
18
|
+
const isDesktop = useMediaQuery('(min-width: 768px)');
|
|
19
|
+
const isMobile = useMediaQuery('(max-width: 479px');
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (echartRef.current) {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
const echartInstance = echartRef.current.getEchartsInstance() as EChartsType;
|
|
25
|
+
|
|
26
|
+
echartInstance.setOption(
|
|
27
|
+
getResponsiveOption(isDesktop, isMobile, isDark),
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}, [echartRef, isDesktop, isMobile, isDark]);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<ReactECharts
|
|
34
|
+
ref={echartRef}
|
|
35
|
+
theme={isDark ? 'dark_theme' : 'light_theme'}
|
|
36
|
+
style={{
|
|
37
|
+
height: `${CHART_HEIGHT}px`,
|
|
38
|
+
width: '100%',
|
|
39
|
+
}}
|
|
40
|
+
option={getOption(values, timeUnit, isDark)}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { Chart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Chart';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
3
|
+
const X_LABEL_SIZE = 90;
|
|
4
|
+
const X_LABEL_SIZE_MOBILE = 110;
|
|
5
|
+
const Y_LABEL_SIZE_MOBILE = 35;
|
|
6
|
+
const Y_LABEL_SIZE = 45;
|
|
7
|
+
const CHART_WIDTH = 9999;
|
|
8
|
+
const CHART_HEIGHT = 425;
|
|
9
|
+
const LEGEND_HEIGHT = 50;
|
|
10
|
+
const LEGEND_HEIGHT_MOBILE = 70;
|
|
11
|
+
const VERTICAL_LINE_COUNT = 10;
|
|
12
|
+
|
|
13
|
+
const COLOR_CONFIG = {
|
|
14
|
+
AUD: colorPalette.orange,
|
|
15
|
+
JPY: colorPalette.raspberryLight,
|
|
16
|
+
USD: colorPalette.greenLight,
|
|
17
|
+
EUR: colorPalette.turquoiseLight,
|
|
18
|
+
GBP: colorPalette.violetLight,
|
|
19
|
+
CHF: colorPalette.bottleGreen75Lighter,
|
|
20
|
+
CAD: colorPalette.midnight75Lighter,
|
|
21
|
+
NZD: colorPalette.gold,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const TOOLTIP_LINE_COLOR_CONFIG = {
|
|
25
|
+
DARK: colorPalette.orange,
|
|
26
|
+
LIGHT: colorPalette.bottleGreenDark,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
X_LABEL_SIZE,
|
|
31
|
+
X_LABEL_SIZE_MOBILE,
|
|
32
|
+
Y_LABEL_SIZE_MOBILE,
|
|
33
|
+
Y_LABEL_SIZE,
|
|
34
|
+
CHART_WIDTH,
|
|
35
|
+
CHART_HEIGHT,
|
|
36
|
+
LEGEND_HEIGHT,
|
|
37
|
+
LEGEND_HEIGHT_MOBILE,
|
|
38
|
+
VERTICAL_LINE_COUNT,
|
|
39
|
+
COLOR_CONFIG,
|
|
40
|
+
TOOLTIP_LINE_COLOR_CONFIG,
|
|
41
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
|
|
2
|
+
import { TooltipFormatterParams } from './types';
|
|
3
|
+
|
|
4
|
+
const getDateAndTime = (param: string) => {
|
|
5
|
+
const dateAndTime = param.split('T');
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
date: dateAndTime[0],
|
|
9
|
+
time: dateAndTime[1].substring(0, 5),
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;
|
|
14
|
+
|
|
15
|
+
const dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;
|
|
16
|
+
|
|
17
|
+
const xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {
|
|
18
|
+
const { date, time } = getDateAndTime(label);
|
|
19
|
+
const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';
|
|
20
|
+
|
|
21
|
+
return isDateFormat ? dateFormat(date) : time;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const tooltipFormatter = (values: TooltipFormatterParams[]) => {
|
|
25
|
+
const date = dateTimeFormat(getDateAndTime(values[0].value[0]));
|
|
26
|
+
|
|
27
|
+
const row = values
|
|
28
|
+
.sort(({ value: valueA }, { value: valueB }) => Number(valueB[1]) - Number(valueA[1]))
|
|
29
|
+
.map(({ marker, seriesName, value }) => `<div style="display:flex;align-items:center;">
|
|
30
|
+
<div style="display:flex;align-items:center;width:50px;margin-right:10px;">
|
|
31
|
+
${marker}
|
|
32
|
+
<span>${seriesName}</span>
|
|
33
|
+
</div>
|
|
34
|
+
<span>${value[1]}</span>
|
|
35
|
+
</div>`);
|
|
36
|
+
|
|
37
|
+
return `<div style="display:flex; flex-direction:column;">
|
|
38
|
+
<p style="margin-bottom:5px;">${date}</p>
|
|
39
|
+
${row.join('\n')}
|
|
40
|
+
</div>`;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
tooltipFormatter,
|
|
45
|
+
xAxisLabelFormatter,
|
|
46
|
+
};
|