@oanda/labs-crowd-view-widget 1.0.54 → 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 +452 -0
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +42 -58
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +33 -8
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +15 -9
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.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 +55 -15
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +171 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +7 -14
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +20 -2
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +13 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +51 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +30 -7
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +27 -29
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -0
- 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/getLabelData.js +1 -20
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +91 -21
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +59 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js +34 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +44 -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/getMultiplayerForTimeSpan.js +19 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -1
- 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 +41 -23
- 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/useCrowdViewData.js +7 -4
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.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/Legend.js +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +11 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +31 -10
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/CrowdViewWidget/selectConfig.js +3 -9
- package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/main/translations/sources/en.json +10 -8
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +43 -58
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +32 -7
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +15 -9
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.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 +55 -15
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +163 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +7 -14
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +20 -2
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +13 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +50 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +31 -8
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +28 -30
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -0
- 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/getLabelData.js +1 -20
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +91 -21
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +52 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js +27 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +4 -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/getMultiplayerForTimeSpan.js +12 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -1
- 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 +42 -24
- 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/useCrowdViewData.js +8 -5
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.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/Legend.js +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +11 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +31 -10
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/CrowdViewWidget/selectConfig.js +3 -9
- package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/module/translations/sources/en.json +10 -8
- package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +5 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridLines.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.d.ts +8 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +2 -3
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +6 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +1 -2
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getLabelData.d.ts +1 -16
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +6 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.d.ts +4 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.d.ts +3 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +4 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/index.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/useResizeObserver.d.ts +5 -0
- package/dist/types/CrowdViewWidget/constants.d.ts +28 -15
- package/package.json +3 -3
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +78 -80
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +51 -14
- package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +11 -2
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +34 -19
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +71 -8
- package/src/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.ts +207 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +7 -15
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +22 -1
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +13 -4
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +91 -37
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +62 -30
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +22 -33
- package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.ts +14 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +6 -4
- package/src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts +11 -35
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +157 -31
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.ts +80 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.ts +37 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +4 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.ts +3 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.ts +13 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/index.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.ts +1 -1
- package/src/CrowdViewWidget/components/Chart/getOption.ts +47 -17
- package/src/CrowdViewWidget/components/Chart/types.ts +6 -0
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +12 -5
- package/src/CrowdViewWidget/components/Chart/useResizeObserver.ts +51 -0
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +1 -1
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +18 -1
- package/src/CrowdViewWidget/constants.ts +34 -7
- package/src/CrowdViewWidget/selectConfig.ts +4 -12
- package/src/translations/sources/en.json +10 -8
- package/test/components/Chart/utils/chartUtils.test.ts +29 -6
- package/test/components/Chart/utils/handleLabelUpdate.test.ts +435 -0
- package/test/components/Chart/utils/handleTooltipUpdate.test.ts +140 -0
- package/test/components/Legend.test.tsx +3 -3
- package/test/components/LegendBar.test.tsx +22 -20
- package/test/utils/processPriceCandles.test.ts +4 -4
|
@@ -1,6 +1,9 @@
|
|
|
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';
|
|
6
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
4
7
|
import { getTooltipFormatter } from '../chartUtils';
|
|
5
8
|
import type { Bucket, TooltipParam } from '../types';
|
|
6
9
|
|
|
@@ -12,6 +15,11 @@ interface GetTooltipConfigParams {
|
|
|
12
15
|
labelCallback: (key: string, params?: Record<string, unknown>) => string;
|
|
13
16
|
selectedPriceRef: { current: number };
|
|
14
17
|
tooltipLinesColor: string;
|
|
18
|
+
sentimentLongs: (number | null)[];
|
|
19
|
+
sentimentShorts: (number | null)[];
|
|
20
|
+
isDesktop: boolean;
|
|
21
|
+
isDark: boolean;
|
|
22
|
+
locale: string;
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
export const getTooltipConfig = ({
|
|
@@ -22,42 +30,88 @@ export const getTooltipConfig = ({
|
|
|
22
30
|
labelCallback,
|
|
23
31
|
selectedPriceRef,
|
|
24
32
|
tooltipLinesColor,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
33
|
+
sentimentLongs,
|
|
34
|
+
sentimentShorts,
|
|
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,
|
|
59
86
|
},
|
|
87
|
+
crossStyle: {
|
|
88
|
+
color: tooltipLinesColor,
|
|
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];
|
|
60
115
|
},
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
});
|
|
116
|
+
};
|
|
117
|
+
};
|
|
@@ -1,43 +1,75 @@
|
|
|
1
1
|
import type { XAXisComponentOption } from 'echarts';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
formatXAxisAdditionalLabel,
|
|
5
|
+
formatXAxisLabel,
|
|
6
|
+
getLabelData,
|
|
7
|
+
} from '../chartUtils';
|
|
4
8
|
|
|
5
9
|
interface GetXAxisConfigParams {
|
|
6
10
|
dates: string[];
|
|
7
11
|
isGreaterThanTwoWeeks: boolean;
|
|
12
|
+
locale: string;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
export const getXAxisConfig = ({
|
|
11
16
|
dates,
|
|
12
17
|
isGreaterThanTwoWeeks,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
locale,
|
|
19
|
+
}: GetXAxisConfigParams): XAXisComponentOption[] => {
|
|
20
|
+
const labelsData = getLabelData({
|
|
21
|
+
dates,
|
|
22
|
+
isGreaterThanTwoWeeks,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
type: 'category',
|
|
28
|
+
id: 'main-xAxis',
|
|
29
|
+
nameTextStyle: {
|
|
30
|
+
fontSize: 0,
|
|
31
|
+
},
|
|
32
|
+
axisTick: {
|
|
33
|
+
show: false,
|
|
34
|
+
},
|
|
35
|
+
splitLine: {
|
|
36
|
+
lineStyle: {
|
|
37
|
+
opacity: 0.5,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
axisLabel: {
|
|
41
|
+
showMaxLabel: false,
|
|
42
|
+
padding: [8, 16, 8, 16],
|
|
43
|
+
margin: 0,
|
|
44
|
+
formatter: (value: unknown) =>
|
|
45
|
+
formatXAxisLabel(value, isGreaterThanTwoWeeks, locale),
|
|
46
|
+
},
|
|
47
|
+
boundaryGap: false,
|
|
48
|
+
z: 2,
|
|
37
49
|
},
|
|
38
|
-
|
|
39
|
-
|
|
50
|
+
{
|
|
51
|
+
type: 'category',
|
|
52
|
+
id: 'additional-xAxis',
|
|
53
|
+
gridIndex: 1,
|
|
54
|
+
axisTick: {
|
|
55
|
+
show: false,
|
|
56
|
+
},
|
|
57
|
+
axisLine: {
|
|
58
|
+
show: false,
|
|
59
|
+
},
|
|
60
|
+
splitLine: {
|
|
61
|
+
show: false,
|
|
62
|
+
},
|
|
63
|
+
axisLabel: {
|
|
64
|
+
margin: 24,
|
|
65
|
+
hideOverlap: true,
|
|
66
|
+
customValues: labelsData,
|
|
67
|
+
formatter: (value: unknown) =>
|
|
68
|
+
formatXAxisAdditionalLabel(value, isGreaterThanTwoWeeks, locale),
|
|
69
|
+
},
|
|
70
|
+
data: dates,
|
|
71
|
+
boundaryGap: false,
|
|
72
|
+
z: 2,
|
|
40
73
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
];
|
|
74
|
+
];
|
|
75
|
+
};
|
|
@@ -1,35 +1,41 @@
|
|
|
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
8
|
isDesktop: boolean;
|
|
9
|
-
labelCallback: (key: string, params?: Record<string, unknown>) => string;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export const getYAxisConfig = ({
|
|
13
12
|
bucketWidth,
|
|
14
13
|
displayPrecision,
|
|
15
14
|
isDesktop,
|
|
16
|
-
labelCallback,
|
|
17
15
|
}: GetYAxisConfigParams): YAXisComponentOption[] => [
|
|
18
16
|
{
|
|
19
17
|
type: 'value',
|
|
20
18
|
gridIndex: 0,
|
|
21
19
|
position: 'right',
|
|
22
|
-
min: (val: { min: number }) =>
|
|
23
|
-
val.min - bucketWidth
|
|
24
|
-
|
|
25
|
-
|
|
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
|
+
},
|
|
26
28
|
axisLine: { show: false },
|
|
27
29
|
axisTick: { show: false },
|
|
30
|
+
splitLine: { show: false },
|
|
28
31
|
axisLabel: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
lineHeight: 20,
|
|
33
|
+
margin: 4,
|
|
34
|
+
verticalAlignMinLabel: 'bottom',
|
|
35
|
+
verticalAlignMaxLabel: 'top',
|
|
36
|
+
formatter: (value: number) => value.toFixed(displayPrecision),
|
|
32
37
|
},
|
|
38
|
+
z: 30,
|
|
33
39
|
},
|
|
34
40
|
{
|
|
35
41
|
type: 'value',
|
|
@@ -39,14 +45,13 @@ export const getYAxisConfig = ({
|
|
|
39
45
|
max: CHART_CONFIG.SENTIMENT_MAX,
|
|
40
46
|
axisLine: { show: false },
|
|
41
47
|
axisTick: { show: false },
|
|
42
|
-
axisPointer: {
|
|
43
|
-
|
|
44
|
-
},
|
|
48
|
+
axisPointer: { show: false },
|
|
49
|
+
splitLine: { show: false },
|
|
45
50
|
axisLabel: {
|
|
46
|
-
margin:
|
|
51
|
+
margin: 4,
|
|
47
52
|
lineHeight: 20,
|
|
48
53
|
verticalAlignMinLabel: 'bottom',
|
|
49
|
-
verticalAlignMaxLabel: 'top',
|
|
54
|
+
verticalAlignMaxLabel: isDesktop ? 'middle' : 'top',
|
|
50
55
|
customValues: [
|
|
51
56
|
CHART_CONFIG.SENTIMENT_MIN,
|
|
52
57
|
CHART_CONFIG.SENTIMENT_MAX / 5,
|
|
@@ -54,24 +59,8 @@ export const getYAxisConfig = ({
|
|
|
54
59
|
(CHART_CONFIG.SENTIMENT_MAX * 4) / 5,
|
|
55
60
|
CHART_CONFIG.SENTIMENT_MAX,
|
|
56
61
|
],
|
|
57
|
-
formatter: (value: number) => {
|
|
58
|
-
if (value === CHART_CONFIG.SENTIMENT_MIN) {
|
|
59
|
-
return `${labelCallback('short')}`;
|
|
60
|
-
}
|
|
61
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX) {
|
|
62
|
-
return `${labelCallback('long')}`;
|
|
63
|
-
}
|
|
64
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {
|
|
65
|
-
return '50%';
|
|
66
|
-
}
|
|
67
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX / 5) {
|
|
68
|
-
return '80%';
|
|
69
|
-
}
|
|
70
|
-
if (value === (CHART_CONFIG.SENTIMENT_MAX * 4) / 5) {
|
|
71
|
-
return '20%';
|
|
72
|
-
}
|
|
73
|
-
return '';
|
|
74
|
-
},
|
|
62
|
+
formatter: (value: number) => `${value}%`,
|
|
75
63
|
},
|
|
64
|
+
z: 30,
|
|
76
65
|
},
|
|
77
66
|
];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './getDataZoomConfig';
|
|
2
2
|
export * from './getGridConfig';
|
|
3
3
|
export * from './getGridLines';
|
|
4
|
+
export * from './getLabelsConfig';
|
|
4
5
|
export * from './getSeriesCandlestickConfig';
|
|
5
6
|
export * from './getSeriesHeatmapConfig';
|
|
6
7
|
export * from './getSeriesSentimentConfig';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const formatXAxisAdditionalLabel = (
|
|
2
|
+
value: unknown,
|
|
3
|
+
isGreaterThanTwoWeeks: boolean,
|
|
4
|
+
locale: string
|
|
5
|
+
) => {
|
|
6
|
+
const date = new Date(value as string);
|
|
7
|
+
if (isNaN(date.getTime())) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
return `${date.toLocaleDateString(locale, {
|
|
11
|
+
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
12
|
+
day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
|
|
13
|
+
})}`;
|
|
14
|
+
};
|
|
@@ -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
|
};
|
|
@@ -1,42 +1,18 @@
|
|
|
1
|
-
import { CHART_CONFIG } from '../../../constants';
|
|
2
1
|
import type { GetLabelsDataProps } from '../types';
|
|
3
2
|
|
|
4
3
|
export const getLabelData = ({
|
|
5
4
|
dates,
|
|
6
5
|
isGreaterThanTwoWeeks,
|
|
7
6
|
}: GetLabelsDataProps) =>
|
|
8
|
-
dates
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const previousDate = new Date(previousTimestamp);
|
|
7
|
+
dates.filter((record, index, arr) => {
|
|
8
|
+
if (index === 0) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const previousTimestamp = arr[index - 1];
|
|
12
|
+
const currentDate = new Date(record);
|
|
13
|
+
const previousDate = new Date(previousTimestamp);
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.map(
|
|
22
|
-
(item) =>
|
|
23
|
-
({
|
|
24
|
-
name: new Date(item).toLocaleDateString(undefined, {
|
|
25
|
-
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
26
|
-
day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
|
|
27
|
-
}),
|
|
28
|
-
xAxis: item,
|
|
29
|
-
y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
|
|
30
|
-
silent: true,
|
|
31
|
-
emphasis: {
|
|
32
|
-
disabled: true,
|
|
33
|
-
},
|
|
34
|
-
label: {
|
|
35
|
-
fontFamily: 'Sofia W03',
|
|
36
|
-
fontSize: 10,
|
|
37
|
-
position: 'bottom' as const,
|
|
38
|
-
align: 'center' as const,
|
|
39
|
-
formatter: '{b}',
|
|
40
|
-
},
|
|
41
|
-
}) as const
|
|
42
|
-
);
|
|
15
|
+
return isGreaterThanTwoWeeks
|
|
16
|
+
? currentDate.getDate() !== previousDate.getDate()
|
|
17
|
+
: currentDate.getMonth() !== previousDate.getMonth();
|
|
18
|
+
});
|