@oanda/labs-crowd-view-widget 1.0.55 → 1.0.56
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 +228 -0
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +8 -5
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +15 -3
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +28 -14
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js +19 -7
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +20 -8
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +44 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +14 -6
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +11 -4
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +2 -2
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +6 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +72 -14
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +3 -3
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js +9 -3
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useResizeObserver.js +47 -0
- package/dist/main/CrowdViewWidget/components/Chart/useResizeObserver.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +20 -7
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/CrowdViewWidget/selectConfig.js +3 -3
- package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/main/translations/sources/en.json +10 -9
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +9 -6
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +15 -3
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +28 -14
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js +19 -7
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +20 -8
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +43 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +14 -6
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +12 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +2 -2
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +6 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +72 -14
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +3 -3
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js +4 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js +9 -3
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useResizeObserver.js +40 -0
- package/dist/module/CrowdViewWidget/components/Chart/useResizeObserver.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +20 -7
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/CrowdViewWidget/selectConfig.js +3 -3
- package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/module/translations/sources/en.json +10 -9
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +4 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +4 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/useResizeObserver.d.ts +5 -0
- package/dist/types/CrowdViewWidget/constants.d.ts +24 -19
- package/package.json +3 -3
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +12 -5
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +22 -3
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +34 -19
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +27 -6
- package/src/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.ts +26 -10
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +86 -43
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +12 -5
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +12 -6
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.ts +3 -2
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +6 -4
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +119 -22
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.ts +8 -3
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.ts +3 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.ts +1 -1
- package/src/CrowdViewWidget/components/Chart/getOption.ts +6 -0
- package/src/CrowdViewWidget/components/Chart/types.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/useResizeObserver.ts +51 -0
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +3 -2
- package/src/CrowdViewWidget/constants.ts +24 -5
- package/src/CrowdViewWidget/selectConfig.ts +4 -4
- package/src/translations/sources/en.json +10 -9
- package/test/components/Chart/utils/chartUtils.test.ts +16 -4
- package/test/components/Chart/utils/handleLabelUpdate.test.ts +32 -16
- package/test/utils/processPriceCandles.test.ts +4 -4
|
@@ -8,22 +8,37 @@ interface GetGridConfigParams {
|
|
|
8
8
|
|
|
9
9
|
export const getGridConfig = ({
|
|
10
10
|
isDesktop,
|
|
11
|
-
}: GetGridConfigParams): GridComponentOption[] =>
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
11
|
+
}: GetGridConfigParams): GridComponentOption[] => {
|
|
12
|
+
const {
|
|
13
|
+
Y_SENTIMENT_LABEL_DESKTOP_SIZE,
|
|
14
|
+
Y_SENTIMENT_LABEL_MOBILE_SIZE,
|
|
15
|
+
Y_LABEL_SIZE_DESKTOP,
|
|
16
|
+
Y_LABEL_SIZE_MOBILE,
|
|
17
|
+
TOP_MARGIN_DESKTOP,
|
|
18
|
+
TOP_MARGIN_MOBILE,
|
|
19
|
+
MAIN_HEIGHT_DESKTOP,
|
|
20
|
+
MAIN_HEIGHT_MOBILE,
|
|
21
|
+
MOBILE_TOOLTIP_HEIGHT,
|
|
22
|
+
} = CHART_CONFIG;
|
|
23
|
+
|
|
24
|
+
const mainHeight = isDesktop ? MAIN_HEIGHT_DESKTOP : MAIN_HEIGHT_MOBILE;
|
|
25
|
+
|
|
26
|
+
const position = {
|
|
27
|
+
left: `${isDesktop ? Y_SENTIMENT_LABEL_DESKTOP_SIZE : Y_SENTIMENT_LABEL_MOBILE_SIZE}px`,
|
|
28
|
+
right: `${isDesktop ? Y_LABEL_SIZE_DESKTOP : Y_LABEL_SIZE_MOBILE}px`,
|
|
29
|
+
top: `${isDesktop ? TOP_MARGIN_DESKTOP : TOP_MARGIN_MOBILE + MOBILE_TOOLTIP_HEIGHT}px`,
|
|
30
|
+
height: `${mainHeight}px`,
|
|
31
|
+
};
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
id: 'main-grid',
|
|
35
|
+
name: 'main-grid',
|
|
36
|
+
...position,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: 'sentiment-grid',
|
|
40
|
+
name: 'sentiment-grid',
|
|
41
|
+
...position,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
};
|
|
@@ -12,7 +12,14 @@ export const getGridLines = ({
|
|
|
12
12
|
isDark,
|
|
13
13
|
isDesktop,
|
|
14
14
|
}: GetGridLinesParams): GraphicComponentOption[] => {
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
WIDTH,
|
|
17
|
+
MAIN_HEIGHT_DESKTOP,
|
|
18
|
+
MAIN_HEIGHT_MOBILE,
|
|
19
|
+
X_LABEL_SIZE,
|
|
20
|
+
MOBILE_TOOLTIP_HEIGHT,
|
|
21
|
+
} = CHART_CONFIG;
|
|
22
|
+
const mainHeight = isDesktop ? MAIN_HEIGHT_DESKTOP : MAIN_HEIGHT_MOBILE;
|
|
16
23
|
const ySentimentLabelSize = isDesktop
|
|
17
24
|
? CHART_CONFIG.Y_SENTIMENT_LABEL_DESKTOP_SIZE
|
|
18
25
|
: CHART_CONFIG.Y_SENTIMENT_LABEL_MOBILE_SIZE;
|
|
@@ -21,7 +28,9 @@ export const getGridLines = ({
|
|
|
21
28
|
? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP
|
|
22
29
|
: CHART_CONFIG.Y_LABEL_SIZE_MOBILE;
|
|
23
30
|
|
|
24
|
-
const topMargin = isDesktop
|
|
31
|
+
const topMargin = isDesktop
|
|
32
|
+
? CHART_CONFIG.TOP_MARGIN_DESKTOP
|
|
33
|
+
: CHART_CONFIG.TOP_MARGIN_MOBILE + CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT;
|
|
25
34
|
|
|
26
35
|
return [
|
|
27
36
|
// Top
|
|
@@ -44,7 +53,7 @@ export const getGridLines = ({
|
|
|
44
53
|
x1: 0,
|
|
45
54
|
y1: 0,
|
|
46
55
|
x2: 0,
|
|
47
|
-
y2:
|
|
56
|
+
y2: mainHeight + topMargin + X_LABEL_SIZE + 2,
|
|
48
57
|
},
|
|
49
58
|
z: 30,
|
|
50
59
|
},
|
|
@@ -68,7 +77,7 @@ export const getGridLines = ({
|
|
|
68
77
|
x1: 0,
|
|
69
78
|
y1: 0,
|
|
70
79
|
x2: 0,
|
|
71
|
-
y2:
|
|
80
|
+
y2: mainHeight + X_LABEL_SIZE + topMargin + 2,
|
|
72
81
|
},
|
|
73
82
|
z: 30,
|
|
74
83
|
},
|
|
@@ -81,7 +90,7 @@ export const getGridLines = ({
|
|
|
81
90
|
x1: 0,
|
|
82
91
|
y1: 0,
|
|
83
92
|
x2: 0,
|
|
84
|
-
y2:
|
|
93
|
+
y2: mainHeight,
|
|
85
94
|
},
|
|
86
95
|
z: 30,
|
|
87
96
|
},
|
|
@@ -94,7 +103,7 @@ export const getGridLines = ({
|
|
|
94
103
|
x1: 0,
|
|
95
104
|
y1: 0,
|
|
96
105
|
x2: 0,
|
|
97
|
-
y2:
|
|
106
|
+
y2: mainHeight,
|
|
98
107
|
},
|
|
99
108
|
z: 30,
|
|
100
109
|
},
|
|
@@ -122,5 +131,17 @@ export const getGridLines = ({
|
|
|
122
131
|
},
|
|
123
132
|
z: 30,
|
|
124
133
|
},
|
|
134
|
+
// Mobile tooltip,
|
|
135
|
+
{
|
|
136
|
+
...getLineCommons(isDark),
|
|
137
|
+
top: MOBILE_TOOLTIP_HEIGHT - 2,
|
|
138
|
+
shape: {
|
|
139
|
+
x1: 0,
|
|
140
|
+
y1: 0,
|
|
141
|
+
x2: isDesktop ? 0 : WIDTH,
|
|
142
|
+
y2: 0,
|
|
143
|
+
},
|
|
144
|
+
z: 30,
|
|
145
|
+
},
|
|
125
146
|
];
|
|
126
147
|
};
|
|
@@ -41,7 +41,11 @@ export const getLabelsConfig = ({
|
|
|
41
41
|
|
|
42
42
|
const topMargin = isDesktop
|
|
43
43
|
? CHART_CONFIG.TOP_MARGIN_DESKTOP
|
|
44
|
-
: CHART_CONFIG.TOP_MARGIN_MOBILE;
|
|
44
|
+
: CHART_CONFIG.TOP_MARGIN_MOBILE + CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT;
|
|
45
|
+
|
|
46
|
+
const mainHeight = isDesktop
|
|
47
|
+
? CHART_CONFIG.MAIN_HEIGHT_DESKTOP
|
|
48
|
+
: CHART_CONFIG.MAIN_HEIGHT_MOBILE;
|
|
45
49
|
|
|
46
50
|
return [
|
|
47
51
|
{
|
|
@@ -87,7 +91,7 @@ export const getLabelsConfig = ({
|
|
|
87
91
|
{
|
|
88
92
|
type: 'group',
|
|
89
93
|
left: `${ySentimentLabelSize + 5}px'`,
|
|
90
|
-
top: `${
|
|
94
|
+
top: `${topMargin + mainHeight - 24 - 5}px`,
|
|
91
95
|
silent: true,
|
|
92
96
|
children: [
|
|
93
97
|
{
|
|
@@ -131,8 +135,8 @@ export const getLabelsConfig = ({
|
|
|
131
135
|
rotation: isDesktop ? Math.PI / 2 : 0,
|
|
132
136
|
left: `5px`,
|
|
133
137
|
top: isDesktop
|
|
134
|
-
? `${topMargin +
|
|
135
|
-
: `${topMargin -
|
|
138
|
+
? `${topMargin + mainHeight / 2 - sentimentVerticalOffset}px`
|
|
139
|
+
: `${topMargin - 16}px`,
|
|
136
140
|
silent: true,
|
|
137
141
|
style: {
|
|
138
142
|
fontSize: 10,
|
|
@@ -148,8 +152,8 @@ export const getLabelsConfig = ({
|
|
|
148
152
|
rotation: isDesktop ? -Math.PI / 2 : 0,
|
|
149
153
|
right: `5px`,
|
|
150
154
|
top: isDesktop
|
|
151
|
-
? `${topMargin +
|
|
152
|
-
: `${topMargin -
|
|
155
|
+
? `${topMargin + mainHeight / 2 - priceVerticalOffset}px`
|
|
156
|
+
: `${topMargin - 16}px`,
|
|
153
157
|
silent: true,
|
|
154
158
|
style: {
|
|
155
159
|
fontSize: 10,
|
|
@@ -163,10 +167,10 @@ export const getLabelsConfig = ({
|
|
|
163
167
|
type: 'rect',
|
|
164
168
|
z: 20,
|
|
165
169
|
right: '0px',
|
|
166
|
-
top:
|
|
170
|
+
top: `${topMargin}px`,
|
|
167
171
|
shape: {
|
|
168
172
|
width: yMainLabelSize,
|
|
169
|
-
height:
|
|
173
|
+
height: mainHeight,
|
|
170
174
|
},
|
|
171
175
|
silent: true,
|
|
172
176
|
style: {
|
|
@@ -177,15 +181,27 @@ export const getLabelsConfig = ({
|
|
|
177
181
|
type: 'rect',
|
|
178
182
|
z: 20,
|
|
179
183
|
left: '0px',
|
|
180
|
-
top:
|
|
184
|
+
top: `${topMargin}px`,
|
|
181
185
|
shape: {
|
|
182
186
|
width: ySentimentLabelSize,
|
|
183
|
-
height:
|
|
187
|
+
height: mainHeight,
|
|
184
188
|
},
|
|
185
189
|
silent: true,
|
|
186
190
|
style: {
|
|
187
191
|
fill: backgroundColor,
|
|
188
192
|
},
|
|
189
193
|
},
|
|
194
|
+
{
|
|
195
|
+
type: 'text',
|
|
196
|
+
z: 20,
|
|
197
|
+
left: 'center',
|
|
198
|
+
top: CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT / 2 - 5,
|
|
199
|
+
silent: true,
|
|
200
|
+
style: {
|
|
201
|
+
fontSize: isDesktop ? 0 : 11,
|
|
202
|
+
fill: textColor,
|
|
203
|
+
text: isDesktop ? '' : labelCallback('tap_chart_to_see_more_details'),
|
|
204
|
+
},
|
|
205
|
+
},
|
|
190
206
|
];
|
|
191
207
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
|
+
import chroma from 'chroma-js';
|
|
1
3
|
import type { TooltipComponentOption } from 'echarts';
|
|
2
4
|
|
|
3
5
|
import type { BookType } from '../../../../gql/types/graphql';
|
|
@@ -15,6 +17,9 @@ interface GetTooltipConfigParams {
|
|
|
15
17
|
tooltipLinesColor: string;
|
|
16
18
|
sentimentLongs: (number | null)[];
|
|
17
19
|
sentimentShorts: (number | null)[];
|
|
20
|
+
isDesktop: boolean;
|
|
21
|
+
isDark: boolean;
|
|
22
|
+
locale: string;
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export const getTooltipConfig = ({
|
|
@@ -27,48 +32,86 @@ export const getTooltipConfig = ({
|
|
|
27
32
|
tooltipLinesColor,
|
|
28
33
|
sentimentLongs,
|
|
29
34
|
sentimentShorts,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
35
|
+
isDesktop,
|
|
36
|
+
isDark,
|
|
37
|
+
locale,
|
|
38
|
+
}: GetTooltipConfigParams): TooltipComponentOption => {
|
|
39
|
+
const styles = isDesktop
|
|
40
|
+
? {
|
|
41
|
+
backgroundColor: isDark
|
|
42
|
+
? chroma(colorPalette.darkGray).alpha(0.95).hex()
|
|
43
|
+
: chroma(colorPalette.darkWhite).alpha(0.95).hex(),
|
|
44
|
+
shadowColor: colorPalette.black10,
|
|
45
|
+
extraCssText: 'z-index: 5;',
|
|
46
|
+
padding: 8,
|
|
47
|
+
alwaysShowContent: false,
|
|
48
|
+
textStyle: {
|
|
49
|
+
fontSize: 11,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
: {
|
|
53
|
+
backgroundColor: 'transparent',
|
|
54
|
+
shadowColor: 'transparent',
|
|
55
|
+
extraCssText: 'width: 100%; z-index: 5;',
|
|
56
|
+
padding: 4,
|
|
57
|
+
alwaysShowContent: true,
|
|
58
|
+
textStyle: {
|
|
59
|
+
fontSize: 10,
|
|
60
|
+
lineHeight: 12,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
...styles,
|
|
65
|
+
trigger: 'axis' as const,
|
|
66
|
+
formatter: (params) =>
|
|
67
|
+
getTooltipFormatter({
|
|
68
|
+
bookType,
|
|
69
|
+
bucketWidth,
|
|
70
|
+
buckets,
|
|
71
|
+
labelCallback,
|
|
72
|
+
params: params as unknown as TooltipParam[],
|
|
73
|
+
selectedPrice: selectedPriceRef.current,
|
|
74
|
+
sentimentLongs,
|
|
75
|
+
sentimentShorts,
|
|
76
|
+
isDesktop,
|
|
77
|
+
locale,
|
|
78
|
+
isDark,
|
|
79
|
+
}),
|
|
80
|
+
hideDelay: 0,
|
|
81
|
+
axisPointer: {
|
|
82
|
+
type: 'cross' as const,
|
|
83
|
+
axis: 'x' as const,
|
|
84
|
+
lineStyle: {
|
|
85
|
+
color: tooltipLinesColor,
|
|
86
|
+
},
|
|
87
|
+
crossStyle: {
|
|
88
|
+
color: tooltipLinesColor,
|
|
66
89
|
},
|
|
90
|
+
label: {
|
|
91
|
+
padding: 0,
|
|
92
|
+
lineHeight: 24,
|
|
93
|
+
formatter: (params: {
|
|
94
|
+
axisDimension?: string;
|
|
95
|
+
axisIndex?: number;
|
|
96
|
+
value: unknown;
|
|
97
|
+
}) => {
|
|
98
|
+
if (params.axisDimension === 'y' && params.axisIndex === 0) {
|
|
99
|
+
selectedPriceRef.current = Number(params.value);
|
|
100
|
+
return ` ${Number(params.value).toFixed(displayPrecision)} `;
|
|
101
|
+
}
|
|
102
|
+
return '';
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
confine: true,
|
|
107
|
+
position: (point) => {
|
|
108
|
+
if (isDesktop) {
|
|
109
|
+
return [
|
|
110
|
+
point[0] + CHART_CONFIG.TOOLTIP_OFFSET,
|
|
111
|
+
point[1] + CHART_CONFIG.TOOLTIP_OFFSET,
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
return [0, 0];
|
|
67
115
|
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
position: (point) => [
|
|
71
|
-
point[0] + CHART_CONFIG.TOOLTIP_OFFSET,
|
|
72
|
-
point[1] + CHART_CONFIG.TOOLTIP_OFFSET,
|
|
73
|
-
],
|
|
74
|
-
});
|
|
116
|
+
};
|
|
117
|
+
};
|
|
@@ -9,11 +9,13 @@ import {
|
|
|
9
9
|
interface GetXAxisConfigParams {
|
|
10
10
|
dates: string[];
|
|
11
11
|
isGreaterThanTwoWeeks: boolean;
|
|
12
|
+
locale: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export const getXAxisConfig = ({
|
|
15
16
|
dates,
|
|
16
17
|
isGreaterThanTwoWeeks,
|
|
18
|
+
locale,
|
|
17
19
|
}: GetXAxisConfigParams): XAXisComponentOption[] => {
|
|
18
20
|
const labelsData = getLabelData({
|
|
19
21
|
dates,
|
|
@@ -24,22 +26,26 @@ export const getXAxisConfig = ({
|
|
|
24
26
|
{
|
|
25
27
|
type: 'category',
|
|
26
28
|
id: 'main-xAxis',
|
|
27
|
-
name: isGreaterThanTwoWeeks
|
|
28
|
-
? 'xAxis-greater-than-two-weeks'
|
|
29
|
-
: 'xAxis-less-than-two-weeks',
|
|
30
29
|
nameTextStyle: {
|
|
31
30
|
fontSize: 0,
|
|
32
31
|
},
|
|
33
32
|
axisTick: {
|
|
34
33
|
show: false,
|
|
35
34
|
},
|
|
35
|
+
splitLine: {
|
|
36
|
+
lineStyle: {
|
|
37
|
+
opacity: 0.5,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
36
40
|
axisLabel: {
|
|
41
|
+
showMaxLabel: false,
|
|
37
42
|
padding: [8, 16, 8, 16],
|
|
38
43
|
margin: 0,
|
|
39
44
|
formatter: (value: unknown) =>
|
|
40
|
-
formatXAxisLabel(value, isGreaterThanTwoWeeks),
|
|
45
|
+
formatXAxisLabel(value, isGreaterThanTwoWeeks, locale),
|
|
41
46
|
},
|
|
42
47
|
boundaryGap: false,
|
|
48
|
+
z: 2,
|
|
43
49
|
},
|
|
44
50
|
{
|
|
45
51
|
type: 'category',
|
|
@@ -59,10 +65,11 @@ export const getXAxisConfig = ({
|
|
|
59
65
|
hideOverlap: true,
|
|
60
66
|
customValues: labelsData,
|
|
61
67
|
formatter: (value: unknown) =>
|
|
62
|
-
formatXAxisAdditionalLabel(value, isGreaterThanTwoWeeks),
|
|
68
|
+
formatXAxisAdditionalLabel(value, isGreaterThanTwoWeeks, locale),
|
|
63
69
|
},
|
|
64
70
|
data: dates,
|
|
65
71
|
boundaryGap: false,
|
|
72
|
+
z: 2,
|
|
66
73
|
},
|
|
67
74
|
];
|
|
68
75
|
};
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import type { YAXisComponentOption } from 'echarts';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
4
4
|
|
|
5
5
|
interface GetYAxisConfigParams {
|
|
6
6
|
bucketWidth: number;
|
|
7
7
|
displayPrecision: number;
|
|
8
|
+
isDesktop: boolean;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export const getYAxisConfig = ({
|
|
11
12
|
bucketWidth,
|
|
12
13
|
displayPrecision,
|
|
14
|
+
isDesktop,
|
|
13
15
|
}: GetYAxisConfigParams): YAXisComponentOption[] => [
|
|
14
16
|
{
|
|
15
17
|
type: 'value',
|
|
16
18
|
gridIndex: 0,
|
|
17
19
|
position: 'right',
|
|
18
|
-
min: (val: { min: number }) =>
|
|
19
|
-
val.min - bucketWidth
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
min: (val: { min: number }) => {
|
|
21
|
+
const adjustedMin = val.min - bucketWidth;
|
|
22
|
+
return Math.floor(adjustedMin / bucketWidth) * bucketWidth;
|
|
23
|
+
},
|
|
24
|
+
max: (val: { max: number }) => {
|
|
25
|
+
const adjustedMax = val.max + bucketWidth;
|
|
26
|
+
return Math.ceil(adjustedMax / bucketWidth) * bucketWidth;
|
|
27
|
+
},
|
|
22
28
|
axisLine: { show: false },
|
|
23
29
|
axisTick: { show: false },
|
|
24
30
|
splitLine: { show: false },
|
|
@@ -45,7 +51,7 @@ export const getYAxisConfig = ({
|
|
|
45
51
|
margin: 4,
|
|
46
52
|
lineHeight: 20,
|
|
47
53
|
verticalAlignMinLabel: 'bottom',
|
|
48
|
-
verticalAlignMaxLabel: 'middle',
|
|
54
|
+
verticalAlignMaxLabel: isDesktop ? 'middle' : 'top',
|
|
49
55
|
customValues: [
|
|
50
56
|
CHART_CONFIG.SENTIMENT_MIN,
|
|
51
57
|
CHART_CONFIG.SENTIMENT_MAX / 5,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export const formatXAxisAdditionalLabel = (
|
|
2
2
|
value: unknown,
|
|
3
|
-
isGreaterThanTwoWeeks: boolean
|
|
3
|
+
isGreaterThanTwoWeeks: boolean,
|
|
4
|
+
locale: string
|
|
4
5
|
) => {
|
|
5
6
|
const date = new Date(value as string);
|
|
6
7
|
if (isNaN(date.getTime())) {
|
|
7
8
|
return '';
|
|
8
9
|
}
|
|
9
|
-
return `${date.toLocaleDateString(
|
|
10
|
+
return `${date.toLocaleDateString(locale, {
|
|
10
11
|
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
11
12
|
day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
|
|
12
13
|
})}`;
|
|
@@ -2,15 +2,17 @@ import { CHART_CONFIG } from '../../../constants';
|
|
|
2
2
|
|
|
3
3
|
export const formatXAxisLabel = (
|
|
4
4
|
value: unknown,
|
|
5
|
-
isGreaterThanTwoWeeks: boolean
|
|
5
|
+
isGreaterThanTwoWeeks: boolean,
|
|
6
|
+
locale: string
|
|
6
7
|
) => {
|
|
7
8
|
const date = new Date(value as string);
|
|
8
9
|
return isGreaterThanTwoWeeks
|
|
9
|
-
? `${date.toLocaleTimeString(
|
|
10
|
-
hour: '
|
|
10
|
+
? `${date.toLocaleTimeString(locale, {
|
|
11
|
+
hour: 'numeric',
|
|
11
12
|
minute: '2-digit',
|
|
13
|
+
hour12: false,
|
|
12
14
|
})}`
|
|
13
|
-
: `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(
|
|
15
|
+
: `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(locale, {
|
|
14
16
|
day: 'numeric',
|
|
15
17
|
})}${CHART_CONFIG.X_AXIS_DATE_PADDING}`;
|
|
16
18
|
};
|