@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,28 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
2
2
|
export const getYAxisConfig = _ref => {
|
|
3
3
|
let {
|
|
4
4
|
bucketWidth,
|
|
5
5
|
displayPrecision,
|
|
6
|
-
isDesktop
|
|
7
|
-
labelCallback
|
|
6
|
+
isDesktop
|
|
8
7
|
} = _ref;
|
|
9
8
|
return [{
|
|
10
9
|
type: 'value',
|
|
11
10
|
gridIndex: 0,
|
|
12
11
|
position: 'right',
|
|
13
|
-
min: val =>
|
|
14
|
-
|
|
12
|
+
min: val => {
|
|
13
|
+
const adjustedMin = val.min - bucketWidth;
|
|
14
|
+
return Math.floor(adjustedMin / bucketWidth) * bucketWidth;
|
|
15
|
+
},
|
|
16
|
+
max: val => {
|
|
17
|
+
const adjustedMax = val.max + bucketWidth;
|
|
18
|
+
return Math.ceil(adjustedMax / bucketWidth) * bucketWidth;
|
|
19
|
+
},
|
|
15
20
|
axisLine: {
|
|
16
21
|
show: false
|
|
17
22
|
},
|
|
18
23
|
axisTick: {
|
|
19
24
|
show: false
|
|
20
25
|
},
|
|
26
|
+
splitLine: {
|
|
27
|
+
show: false
|
|
28
|
+
},
|
|
21
29
|
axisLabel: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
lineHeight: 20,
|
|
31
|
+
margin: 4,
|
|
32
|
+
verticalAlignMinLabel: 'bottom',
|
|
33
|
+
verticalAlignMaxLabel: 'top',
|
|
34
|
+
formatter: value => value.toFixed(displayPrecision)
|
|
35
|
+
},
|
|
36
|
+
z: 30
|
|
26
37
|
}, {
|
|
27
38
|
type: 'value',
|
|
28
39
|
gridIndex: 1,
|
|
@@ -38,31 +49,18 @@ export const getYAxisConfig = _ref => {
|
|
|
38
49
|
axisPointer: {
|
|
39
50
|
show: false
|
|
40
51
|
},
|
|
52
|
+
splitLine: {
|
|
53
|
+
show: false
|
|
54
|
+
},
|
|
41
55
|
axisLabel: {
|
|
42
|
-
margin:
|
|
56
|
+
margin: 4,
|
|
43
57
|
lineHeight: 20,
|
|
44
58
|
verticalAlignMinLabel: 'bottom',
|
|
45
|
-
verticalAlignMaxLabel: 'top',
|
|
59
|
+
verticalAlignMaxLabel: isDesktop ? 'middle' : 'top',
|
|
46
60
|
customValues: [CHART_CONFIG.SENTIMENT_MIN, CHART_CONFIG.SENTIMENT_MAX / 5, CHART_CONFIG.SENTIMENT_MAX / 2, CHART_CONFIG.SENTIMENT_MAX * 4 / 5, CHART_CONFIG.SENTIMENT_MAX],
|
|
47
|
-
formatter: value =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX) {
|
|
52
|
-
return "".concat(labelCallback('long'));
|
|
53
|
-
}
|
|
54
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {
|
|
55
|
-
return '50%';
|
|
56
|
-
}
|
|
57
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX / 5) {
|
|
58
|
-
return '80%';
|
|
59
|
-
}
|
|
60
|
-
if (value === CHART_CONFIG.SENTIMENT_MAX * 4 / 5) {
|
|
61
|
-
return '20%';
|
|
62
|
-
}
|
|
63
|
-
return '';
|
|
64
|
-
}
|
|
65
|
-
}
|
|
61
|
+
formatter: value => "".concat(value, "%")
|
|
62
|
+
},
|
|
63
|
+
z: 30
|
|
66
64
|
}];
|
|
67
65
|
};
|
|
68
66
|
//# sourceMappingURL=getYAxisConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getYAxisConfig.js","names":["
|
|
1
|
+
{"version":3,"file":"getYAxisConfig.js","names":["CHART_CONFIG","getYAxisConfig","_ref","bucketWidth","displayPrecision","isDesktop","type","gridIndex","position","min","val","adjustedMin","Math","floor","max","adjustedMax","ceil","axisLine","show","axisTick","splitLine","axisLabel","lineHeight","margin","verticalAlignMinLabel","verticalAlignMaxLabel","formatter","value","toFixed","z","SENTIMENT_MIN","SENTIMENT_MAX","axisPointer","customValues","concat"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts"],"sourcesContent":["import type { YAXisComponentOption } from 'echarts';\n\nimport { CHART_CONFIG } from '../../../constants';\n\ninterface GetYAxisConfigParams {\n bucketWidth: number;\n displayPrecision: number;\n isDesktop: boolean;\n}\n\nexport const getYAxisConfig = ({\n bucketWidth,\n displayPrecision,\n isDesktop,\n}: GetYAxisConfigParams): YAXisComponentOption[] => [\n {\n type: 'value',\n gridIndex: 0,\n position: 'right',\n min: (val: { min: number }) => {\n const adjustedMin = val.min - bucketWidth;\n return Math.floor(adjustedMin / bucketWidth) * bucketWidth;\n },\n max: (val: { max: number }) => {\n const adjustedMax = val.max + bucketWidth;\n return Math.ceil(adjustedMax / bucketWidth) * bucketWidth;\n },\n axisLine: { show: false },\n axisTick: { show: false },\n splitLine: { show: false },\n axisLabel: {\n lineHeight: 20,\n margin: 4,\n verticalAlignMinLabel: 'bottom',\n verticalAlignMaxLabel: 'top',\n formatter: (value: number) => value.toFixed(displayPrecision),\n },\n z: 30,\n },\n {\n type: 'value',\n gridIndex: 1,\n position: 'left',\n min: CHART_CONFIG.SENTIMENT_MIN,\n max: CHART_CONFIG.SENTIMENT_MAX,\n axisLine: { show: false },\n axisTick: { show: false },\n axisPointer: { show: false },\n splitLine: { show: false },\n axisLabel: {\n margin: 4,\n lineHeight: 20,\n verticalAlignMinLabel: 'bottom',\n verticalAlignMaxLabel: isDesktop ? 'middle' : 'top',\n customValues: [\n CHART_CONFIG.SENTIMENT_MIN,\n CHART_CONFIG.SENTIMENT_MAX / 5,\n CHART_CONFIG.SENTIMENT_MAX / 2,\n (CHART_CONFIG.SENTIMENT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AEd,YAAY,CAAC+B,aAAa;IAC/Bd,QAAQ,EAAE;MAAEC,IAAI,EAAE;IAAM,CAAC;IACzBC,QAAQ,EAAE;MAAED,IAAI,EAAE;IAAM,CAAC;IACzBc,WAAW,EAAE;MAAEd,IAAI,EAAE;IAAM,CAAC;IAC5BE,SAAS,EAAE;MAAEF,IAAI,EAAE;IAAM,CAAC;IAC1BG,SAAS,EAAE;MACTE,MAAM,EAAE,CAAC;MACTD,UAAU,EAAE,EAAE;MACdE,qBAAqB,EAAE,QAAQ;MAC/BC,qBAAqB,EAAEpB,SAAS,GAAG,QAAQ,GAAG,KAAK;MACnD4B,YAAY,EAAE,CACZjC,YAAY,CAAC8B,aAAa,EAC1B9B,YAAY,CAAC+B,aAAa,GAAG,CAAC,EAC9B/B,YAAY,CAAC+B,aAAa,GAAG,CAAC,EAC7B/B,YAAY,CAAC+B,aAAa,GAAG,CAAC,GAAI,CAAC,EACpC/B,YAAY,CAAC+B,aAAa,CAC3B;MACDL,SAAS,EAAGC,KAAa,OAAAO,MAAA,CAAQP,KAAK;IACxC,CAAC;IACDE,CAAC,EAAE;EACL,CAAC,CACF;AAAA","ignoreList":[]}
|
|
@@ -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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/index.ts"],"sourcesContent":["export * from './getDataZoomConfig';\nexport * from './getGridConfig';\nexport * from './getGridLines';\nexport * from './getSeriesCandlestickConfig';\nexport * from './getSeriesHeatmapConfig';\nexport * from './getSeriesSentimentConfig';\nexport * from './getTooltipConfig';\nexport * from './getVisualMapConfig';\nexport * from './getXAxisConfig';\nexport * from './getYAxisConfig';\n"],"mappings":"AAAA,cAAc,qBAAqB;AACnC,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,8BAA8B;AAC5C,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,oBAAoB;AAClC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/index.ts"],"sourcesContent":["export * from './getDataZoomConfig';\nexport * from './getGridConfig';\nexport * from './getGridLines';\nexport * from './getLabelsConfig';\nexport * from './getSeriesCandlestickConfig';\nexport * from './getSeriesHeatmapConfig';\nexport * from './getSeriesSentimentConfig';\nexport * from './getTooltipConfig';\nexport * from './getVisualMapConfig';\nexport * from './getXAxisConfig';\nexport * from './getYAxisConfig';\n"],"mappings":"AAAA,cAAc,qBAAqB;AACnC,cAAc,iBAAiB;AAC/B,cAAc,gBAAgB;AAC9B,cAAc,mBAAmB;AACjC,cAAc,8BAA8B;AAC5C,cAAc,0BAA0B;AACxC,cAAc,4BAA4B;AAC1C,cAAc,oBAAoB;AAClC,cAAc,sBAAsB;AACpC,cAAc,kBAAkB;AAChC,cAAc,kBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const formatXAxisAdditionalLabel = (value, isGreaterThanTwoWeeks, locale) => {
|
|
2
|
+
const date = new Date(value);
|
|
3
|
+
if (isNaN(date.getTime())) {
|
|
4
|
+
return '';
|
|
5
|
+
}
|
|
6
|
+
return "".concat(date.toLocaleDateString(locale, {
|
|
7
|
+
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
8
|
+
day: isGreaterThanTwoWeeks ? 'numeric' : undefined
|
|
9
|
+
}));
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=formatXAxisAdditionalLabel.js.map
|
package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatXAxisAdditionalLabel.js","names":["formatXAxisAdditionalLabel","value","isGreaterThanTwoWeeks","locale","date","Date","isNaN","getTime","concat","toLocaleDateString","month","day","undefined"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.ts"],"sourcesContent":["export const formatXAxisAdditionalLabel = (\n value: unknown,\n isGreaterThanTwoWeeks: boolean,\n locale: string\n) => {\n const date = new Date(value as string);\n if (isNaN(date.getTime())) {\n return '';\n }\n return `${date.toLocaleDateString(locale, {\n month: isGreaterThanTwoWeeks ? 'short' : 'long',\n day: isGreaterThanTwoWeeks ? 'numeric' : undefined,\n })}`;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,0BAA0B,GAAGA,CACxCC,KAAc,EACdC,qBAA8B,EAC9BC,MAAc,KACX;EACH,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACJ,KAAe,CAAC;EACtC,IAAIK,KAAK,CAACF,IAAI,CAACG,OAAO,CAAC,CAAC,CAAC,EAAE;IACzB,OAAO,EAAE;EACX;EACA,UAAAC,MAAA,CAAUJ,IAAI,CAACK,kBAAkB,CAACN,MAAM,EAAE;IACxCO,KAAK,EAAER,qBAAqB,GAAG,OAAO,GAAG,MAAM;IAC/CS,GAAG,EAAET,qBAAqB,GAAG,SAAS,GAAGU;EAC3C,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CHART_CONFIG } from '../../../constants';
|
|
2
|
-
export const formatXAxisLabel = (value, isGreaterThanTwoWeeks) => {
|
|
2
|
+
export const formatXAxisLabel = (value, isGreaterThanTwoWeeks, locale) => {
|
|
3
3
|
const date = new Date(value);
|
|
4
|
-
return isGreaterThanTwoWeeks ? "".concat(date.toLocaleTimeString(
|
|
5
|
-
hour: '
|
|
6
|
-
minute: '2-digit'
|
|
7
|
-
|
|
4
|
+
return isGreaterThanTwoWeeks ? "".concat(date.toLocaleTimeString(locale, {
|
|
5
|
+
hour: 'numeric',
|
|
6
|
+
minute: '2-digit',
|
|
7
|
+
hour12: false
|
|
8
|
+
})) : "".concat(CHART_CONFIG.X_AXIS_DATE_PADDING).concat(date.toLocaleDateString(locale, {
|
|
8
9
|
day: 'numeric'
|
|
9
10
|
})).concat(CHART_CONFIG.X_AXIS_DATE_PADDING);
|
|
10
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatXAxisLabel.js","names":["CHART_CONFIG","formatXAxisLabel","value","isGreaterThanTwoWeeks","date","Date","concat","toLocaleTimeString","
|
|
1
|
+
{"version":3,"file":"formatXAxisLabel.js","names":["CHART_CONFIG","formatXAxisLabel","value","isGreaterThanTwoWeeks","locale","date","Date","concat","toLocaleTimeString","hour","minute","hour12","X_AXIS_DATE_PADDING","toLocaleDateString","day"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts"],"sourcesContent":["import { CHART_CONFIG } from '../../../constants';\n\nexport const formatXAxisLabel = (\n value: unknown,\n isGreaterThanTwoWeeks: boolean,\n locale: string\n) => {\n const date = new Date(value as string);\n return isGreaterThanTwoWeeks\n ? `${date.toLocaleTimeString(locale, {\n hour: 'numeric',\n minute: '2-digit',\n hour12: false,\n })}`\n : `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(locale, {\n day: 'numeric',\n })}${CHART_CONFIG.X_AXIS_DATE_PADDING}`;\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,oBAAoB;AAEjD,OAAO,MAAMC,gBAAgB,GAAGA,CAC9BC,KAAc,EACdC,qBAA8B,EAC9BC,MAAc,KACX;EACH,MAAMC,IAAI,GAAG,IAAIC,IAAI,CAACJ,KAAe,CAAC;EACtC,OAAOC,qBAAqB,MAAAI,MAAA,CACrBF,IAAI,CAACG,kBAAkB,CAACJ,MAAM,EAAE;IACjCK,IAAI,EAAE,SAAS;IACfC,MAAM,EAAE,SAAS;IACjBC,MAAM,EAAE;EACV,CAAC,CAAC,OAAAJ,MAAA,CACCP,YAAY,CAACY,mBAAmB,EAAAL,MAAA,CAAGF,IAAI,CAACQ,kBAAkB,CAACT,MAAM,EAAE;IACpEU,GAAG,EAAE;EACP,CAAC,CAAC,EAAAP,MAAA,CAAGP,YAAY,CAACY,mBAAmB,CAAE;AAC7C,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { CHART_CONFIG } from '../../../constants';
|
|
2
1
|
export const getLabelData = _ref => {
|
|
3
2
|
let {
|
|
4
3
|
dates,
|
|
@@ -12,24 +11,6 @@ export const getLabelData = _ref => {
|
|
|
12
11
|
const currentDate = new Date(record);
|
|
13
12
|
const previousDate = new Date(previousTimestamp);
|
|
14
13
|
return isGreaterThanTwoWeeks ? currentDate.getDate() !== previousDate.getDate() : currentDate.getMonth() !== previousDate.getMonth();
|
|
15
|
-
})
|
|
16
|
-
name: new Date(item).toLocaleDateString(undefined, {
|
|
17
|
-
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
18
|
-
day: isGreaterThanTwoWeeks ? 'numeric' : undefined
|
|
19
|
-
}),
|
|
20
|
-
xAxis: item,
|
|
21
|
-
y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
|
|
22
|
-
silent: true,
|
|
23
|
-
emphasis: {
|
|
24
|
-
disabled: true
|
|
25
|
-
},
|
|
26
|
-
label: {
|
|
27
|
-
fontFamily: 'Sofia W03',
|
|
28
|
-
fontSize: 10,
|
|
29
|
-
position: 'bottom',
|
|
30
|
-
align: 'center',
|
|
31
|
-
formatter: '{b}'
|
|
32
|
-
}
|
|
33
|
-
}));
|
|
14
|
+
});
|
|
34
15
|
};
|
|
35
16
|
//# sourceMappingURL=getLabelData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLabelData.js","names":["
|
|
1
|
+
{"version":3,"file":"getLabelData.js","names":["getLabelData","_ref","dates","isGreaterThanTwoWeeks","filter","record","index","arr","previousTimestamp","currentDate","Date","previousDate","getDate","getMonth"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts"],"sourcesContent":["import type { GetLabelsDataProps } from '../types';\n\nexport const getLabelData = ({\n dates,\n isGreaterThanTwoWeeks,\n}: GetLabelsDataProps) =>\n dates.filter((record, index, arr) => {\n if (index === 0) {\n return false;\n }\n const previousTimestamp = arr[index - 1];\n const currentDate = new Date(record);\n const previousDate = new Date(previousTimestamp);\n\n return isGreaterThanTwoWeeks\n ? currentDate.getDate() !== previousDate.getDate()\n : currentDate.getMonth() !== previousDate.getMonth();\n });\n"],"mappings":"AAEA,OAAO,MAAMA,YAAY,GAAGC,IAAA;EAAA,IAAC;IAC3BC,KAAK;IACLC;EACkB,CAAC,GAAAF,IAAA;EAAA,OACnBC,KAAK,CAACE,MAAM,CAAC,CAACC,MAAM,EAAEC,KAAK,EAAEC,GAAG,KAAK;IACnC,IAAID,KAAK,KAAK,CAAC,EAAE;MACf,OAAO,KAAK;IACd;IACA,MAAME,iBAAiB,GAAGD,GAAG,CAACD,KAAK,GAAG,CAAC,CAAC;IACxC,MAAMG,WAAW,GAAG,IAAIC,IAAI,CAACL,MAAM,CAAC;IACpC,MAAMM,YAAY,GAAG,IAAID,IAAI,CAACF,iBAAiB,CAAC;IAEhD,OAAOL,qBAAqB,GACxBM,WAAW,CAACG,OAAO,CAAC,CAAC,KAAKD,YAAY,CAACC,OAAO,CAAC,CAAC,GAChDH,WAAW,CAACI,QAAQ,CAAC,CAAC,KAAKF,YAAY,CAACE,QAAQ,CAAC,CAAC;EACxD,CAAC,CAAC;AAAA","ignoreList":[]}
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
1
2
|
import { BookType } from '../../../../gql/types/graphql';
|
|
2
3
|
const DATE_FORMAT_OPTIONS = {
|
|
3
|
-
hour: '2-digit',
|
|
4
|
-
minute: '2-digit',
|
|
5
|
-
year: 'numeric',
|
|
6
4
|
day: 'numeric',
|
|
7
5
|
month: 'numeric',
|
|
8
|
-
|
|
6
|
+
year: 'numeric',
|
|
7
|
+
hour: 'numeric',
|
|
8
|
+
minute: '2-digit',
|
|
9
|
+
hour12: false,
|
|
10
|
+
timeZoneName: 'shortOffset'
|
|
9
11
|
};
|
|
10
12
|
const SENTIMENT_DISPLAY_PRECISION = 2;
|
|
13
|
+
const TOOLTIP_STYLES = {
|
|
14
|
+
MOBILE_COLUMN_WIDTH: '33.3%',
|
|
15
|
+
PADDING_BOTTOM: '4px',
|
|
16
|
+
FULL_WIDTH: '100%'
|
|
17
|
+
};
|
|
11
18
|
const calculateBucketDisplayPrecision = bucketWidth => {
|
|
12
19
|
var _bucketWidth$toString;
|
|
13
20
|
return ((_bucketWidth$toString = bucketWidth.toString().split('.')[1]) === null || _bucketWidth$toString === void 0 ? void 0 : _bucketWidth$toString.length) || 0;
|
|
@@ -15,6 +22,14 @@ const calculateBucketDisplayPrecision = bucketWidth => {
|
|
|
15
22
|
const findSeriesParam = (params, seriesId) => {
|
|
16
23
|
return params.find(series => series.seriesId === seriesId);
|
|
17
24
|
};
|
|
25
|
+
const findSentimentSeriesParam = (params, sentimentLongs, sentimentShorts) => {
|
|
26
|
+
var _sentimentLongs$index, _sentimentShorts$inde;
|
|
27
|
+
const index = params[0].dataIndex;
|
|
28
|
+
return {
|
|
29
|
+
sentimentLong: (_sentimentLongs$index = sentimentLongs[index]) !== null && _sentimentLongs$index !== void 0 ? _sentimentLongs$index : null,
|
|
30
|
+
sentimentShort: (_sentimentShorts$inde = sentimentShorts[index]) !== null && _sentimentShorts$inde !== void 0 ? _sentimentShorts$inde : null
|
|
31
|
+
};
|
|
32
|
+
};
|
|
18
33
|
const getSentimentOverbalanceLabel = (sentiment, bookType) => {
|
|
19
34
|
if (sentiment < 0) {
|
|
20
35
|
return bookType === BookType.Order ? 'sell_overbalance' : 'short_overbalance';
|
|
@@ -23,7 +38,12 @@ const getSentimentOverbalanceLabel = (sentiment, bookType) => {
|
|
|
23
38
|
};
|
|
24
39
|
const formatCandleData = (candleData, labelCallback) => {
|
|
25
40
|
const [, open, close, low, high] = candleData;
|
|
26
|
-
|
|
41
|
+
const candleLabel = labelCallback('candle');
|
|
42
|
+
const openLabel = labelCallback('open');
|
|
43
|
+
const closeLabel = labelCallback('close');
|
|
44
|
+
const lowLabel = labelCallback('low');
|
|
45
|
+
const highLabel = labelCallback('high');
|
|
46
|
+
return "<div><b>".concat(candleLabel, ":</b></div>\n<div>").concat(openLabel, ": ").concat(open, " </div>\n<div>").concat(closeLabel, ": ").concat(close, " </div>\n<div>").concat(lowLabel, ": ").concat(low, " </div>\n<div>").concat(highLabel, ": ").concat(high, " </div>\n");
|
|
27
47
|
};
|
|
28
48
|
const formatBookData = _ref => {
|
|
29
49
|
let {
|
|
@@ -31,21 +51,21 @@ const formatBookData = _ref => {
|
|
|
31
51
|
bucketWidth,
|
|
32
52
|
bucketDisplayPrecision,
|
|
33
53
|
bookType,
|
|
34
|
-
labelCallback
|
|
54
|
+
labelCallback,
|
|
55
|
+
isDesktop
|
|
35
56
|
} = _ref;
|
|
36
|
-
const bookLabelKey = bookType === BookType.Order ? 'orders' : '
|
|
57
|
+
const bookLabelKey = bookType === BookType.Order ? 'orders' : 'trades';
|
|
37
58
|
const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);
|
|
38
59
|
const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(bucketDisplayPrecision);
|
|
39
60
|
const sentimentLabel = getSentimentOverbalanceLabel(matchedBucket.sentiment, bookType);
|
|
40
|
-
const sentimentValue = Math.abs(matchedBucket.sentiment)
|
|
41
|
-
return "<
|
|
61
|
+
const sentimentValue = Math.abs(matchedBucket.sentiment);
|
|
62
|
+
return isDesktop ? "<div><b>".concat(labelCallback(bookLabelKey), ":</b></div>\n<div>").concat(labelCallback('price_range'), ": ").concat(priceRangeStart, " - ").concat(priceRangeEnd, " </div>\n<div>").concat(labelCallback(sentimentLabel), ": ").concat(sentimentValue, "% </div>") : "<div><b>".concat(labelCallback(bookLabelKey), ":</b></div>\n<div>").concat(labelCallback('price_range'), ":</div>\n<div>").concat(priceRangeStart, " - ").concat(priceRangeEnd, " </div>\n<div>").concat(labelCallback(sentimentLabel), ":</div>\n<div>").concat(sentimentValue, "% </div>");
|
|
42
63
|
};
|
|
43
|
-
const formatSentimentData = (
|
|
44
|
-
|
|
45
|
-
return "<br /><p><b>".concat(labelCallback('sentiment'), ":</b></p>\n<p>").concat(labelCallback('long'), ": ").concat(longPercent.toFixed(SENTIMENT_DISPLAY_PRECISION), "% </p>\n<p>").concat(labelCallback('short'), ": ").concat(shortPercent.toFixed(SENTIMENT_DISPLAY_PRECISION), "% </p>");
|
|
64
|
+
const formatSentimentData = (sentimentLong, sentimentShort, labelCallback) => {
|
|
65
|
+
return "<div><b>".concat(labelCallback('sentiment'), ":</b></div>\n<div>").concat(labelCallback('long'), ": ").concat(sentimentLong.toFixed(SENTIMENT_DISPLAY_PRECISION), "% </div>\n<div>").concat(labelCallback('short'), ": ").concat(sentimentShort.toFixed(SENTIMENT_DISPLAY_PRECISION), "% </div>");
|
|
46
66
|
};
|
|
47
|
-
const hasValidCandleData = candleData => !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[
|
|
48
|
-
const hasValidSentimentData =
|
|
67
|
+
const hasValidCandleData = candleData => !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[4];
|
|
68
|
+
const hasValidSentimentData = (sentimentLong, sentimentShort) => sentimentLong !== null && sentimentShort !== null;
|
|
49
69
|
const findMatchingBucket = (buckets, bucketsIndex, selectedPrice, bucketWidth) => {
|
|
50
70
|
if (bucketsIndex === undefined) {
|
|
51
71
|
return undefined;
|
|
@@ -65,14 +85,22 @@ export const getTooltipFormatter = _ref3 => {
|
|
|
65
85
|
bucketWidth,
|
|
66
86
|
selectedPrice,
|
|
67
87
|
bookType,
|
|
68
|
-
labelCallback
|
|
88
|
+
labelCallback,
|
|
89
|
+
sentimentLongs,
|
|
90
|
+
sentimentShorts,
|
|
91
|
+
isDesktop,
|
|
92
|
+
locale,
|
|
93
|
+
isDark
|
|
69
94
|
} = _ref3;
|
|
70
95
|
if (!params || !Array.isArray(params) || params.length === 0) {
|
|
71
96
|
return '';
|
|
72
97
|
}
|
|
73
98
|
const candleParam = findSeriesParam(params, 'candlestick');
|
|
74
99
|
const booksParam = findSeriesParam(params, 'heatmap');
|
|
75
|
-
const
|
|
100
|
+
const {
|
|
101
|
+
sentimentLong,
|
|
102
|
+
sentimentShort
|
|
103
|
+
} = findSentimentSeriesParam(params, sentimentLongs, sentimentShorts);
|
|
76
104
|
if (!candleParam) {
|
|
77
105
|
return '';
|
|
78
106
|
}
|
|
@@ -82,20 +110,62 @@ export const getTooltipFormatter = _ref3 => {
|
|
|
82
110
|
const bucketsIndex = booksParam === null || booksParam === void 0 ? void 0 : booksParam.value[2];
|
|
83
111
|
const matchedBucket = findMatchingBucket(buckets, bucketsIndex, selectedPrice, bucketWidth);
|
|
84
112
|
const showCandles = hasValidCandleData(candleData);
|
|
85
|
-
const showSentiment = hasValidSentimentData(
|
|
113
|
+
const showSentiment = hasValidSentimentData(sentimentLong, sentimentShort);
|
|
86
114
|
if (!showCandles && !matchedBucket) {
|
|
87
115
|
return '';
|
|
88
116
|
}
|
|
89
|
-
const timeFormatted = time.toLocaleString(
|
|
117
|
+
const timeFormatted = time.toLocaleString(locale, DATE_FORMAT_OPTIONS).replace(/\//g, '.');
|
|
90
118
|
const candleSection = showCandles ? formatCandleData(candleData, labelCallback) : '';
|
|
91
119
|
const bookSection = matchedBucket ? formatBookData({
|
|
92
120
|
matchedBucket,
|
|
93
121
|
bucketWidth,
|
|
94
122
|
bucketDisplayPrecision,
|
|
95
123
|
bookType,
|
|
96
|
-
labelCallback
|
|
124
|
+
labelCallback,
|
|
125
|
+
isDesktop
|
|
97
126
|
}) : '';
|
|
98
|
-
const sentimentSection = showSentiment &&
|
|
99
|
-
|
|
127
|
+
const sentimentSection = showSentiment && sentimentLong && sentimentShort ? formatSentimentData(sentimentLong, sentimentShort, labelCallback) : '';
|
|
128
|
+
if (isDesktop) {
|
|
129
|
+
return buildDesktopTooltip({
|
|
130
|
+
timeFormatted,
|
|
131
|
+
candleSection,
|
|
132
|
+
sentimentSection,
|
|
133
|
+
bookSection,
|
|
134
|
+
hasMatchedBucket: !!matchedBucket
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return buildMobileTooltip({
|
|
138
|
+
timeFormatted,
|
|
139
|
+
candleSection,
|
|
140
|
+
sentimentSection,
|
|
141
|
+
bookSection,
|
|
142
|
+
isDark
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
const buildDesktopTooltip = _ref4 => {
|
|
146
|
+
let {
|
|
147
|
+
timeFormatted,
|
|
148
|
+
candleSection,
|
|
149
|
+
sentimentSection,
|
|
150
|
+
bookSection,
|
|
151
|
+
hasMatchedBucket
|
|
152
|
+
} = _ref4;
|
|
153
|
+
const padding = TOOLTIP_STYLES.PADDING_BOTTOM;
|
|
154
|
+
const sentimentPadding = hasMatchedBucket ? padding : '0px';
|
|
155
|
+
return "<div style=\"padding-bottom: ".concat(padding, ";\">").concat(timeFormatted, "</div>\n<div style=\"padding-bottom: ").concat(padding, ";\">").concat(candleSection, "</div>\n<div style=\"padding-bottom: ").concat(sentimentPadding, ";\">").concat(sentimentSection, "</div>\n<div>").concat(bookSection, "</div>\n");
|
|
156
|
+
};
|
|
157
|
+
const buildMobileTooltip = _ref5 => {
|
|
158
|
+
let {
|
|
159
|
+
timeFormatted,
|
|
160
|
+
candleSection,
|
|
161
|
+
sentimentSection,
|
|
162
|
+
bookSection,
|
|
163
|
+
isDark
|
|
164
|
+
} = _ref5;
|
|
165
|
+
const backgroundColor = isDark ? colorPalette.black : colorPalette.white;
|
|
166
|
+
const columnWidth = TOOLTIP_STYLES.MOBILE_COLUMN_WIDTH;
|
|
167
|
+
const fullWidth = TOOLTIP_STYLES.FULL_WIDTH;
|
|
168
|
+
const padding = TOOLTIP_STYLES.PADDING_BOTTOM;
|
|
169
|
+
return "<div style=\"width: ".concat(fullWidth, "; background-color: ").concat(backgroundColor, ";\">\n <div style=\"padding-bottom: ").concat(padding, ";\">").concat(timeFormatted, "</div>\n <div style=\"width: ").concat(fullWidth, "; display: flex; justify-content: space-between;\">\n <div style=\"width: ").concat(columnWidth, ";\">\n").concat(candleSection, "\n</div>\n<div style=\"width: ").concat(columnWidth, ";\">\n").concat(sentimentSection, "\n</div>\n<div style=\"width: ").concat(columnWidth, ";\">\n").concat(bookSection, "\n</div>\n</div>\n</div>");
|
|
100
170
|
};
|
|
101
171
|
//# sourceMappingURL=getTooltipFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTooltipFormatter.js","names":["BookType","DATE_FORMAT_OPTIONS","hour","minute","year","day","month","timeZoneName","SENTIMENT_DISPLAY_PRECISION","calculateBucketDisplayPrecision","bucketWidth","_bucketWidth$toString","toString","split","length","findSeriesParam","params","seriesId","find","series","getSentimentOverbalanceLabel","sentiment","bookType","Order","formatCandleData","candleData","labelCallback","open","close","low","high","concat","formatBookData","_ref","matchedBucket","bucketDisplayPrecision","bookLabelKey","priceRangeStart","price","toFixed","priceRangeEnd","sentimentLabel","sentimentValue","Math","abs","formatSentimentData","sentimentParam","shortPercent","longPercent","value","hasValidCandleData","hasValidSentimentData","findMatchingBucket","buckets","bucketsIndex","selectedPrice","undefined","selectedBuckets","_ref2","getTooltipFormatter","_ref3","Array","isArray","candleParam","booksParam","time","Date","axisValue","showCandles","showSentiment","timeFormatted","toLocaleString","candleSection","bookSection","sentimentSection"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts"],"sourcesContent":["import { BookType } from '../../../../gql/types/graphql';\nimport type { Bucket, TooltipParam } from '../types';\n\nconst DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {\n hour: '2-digit',\n minute: '2-digit',\n year: 'numeric',\n day: 'numeric',\n month: 'numeric',\n timeZoneName: 'short',\n};\n\nconst SENTIMENT_DISPLAY_PRECISION = 2;\n\nconst calculateBucketDisplayPrecision = (bucketWidth: number): number => {\n return bucketWidth.toString().split('.')[1]?.length || 0;\n};\n\nconst findSeriesParam = <T extends TooltipParam['seriesId']>(\n params: TooltipParam[],\n seriesId: T\n): Extract<TooltipParam, { seriesId: T }> | undefined => {\n return params.find(\n (series): series is Extract<TooltipParam, { seriesId: T }> =>\n series.seriesId === seriesId\n );\n};\n\nconst getSentimentOverbalanceLabel = (\n sentiment: number,\n bookType: BookType\n): string => {\n if (sentiment < 0) {\n return bookType === BookType.Order\n ? 'sell_overbalance'\n : 'short_overbalance';\n }\n return bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance';\n};\n\nconst formatCandleData = (\n candleData: [number, number, number, number, number],\n labelCallback: (key: string) => string\n): string => {\n const [, open, close, low, high] = candleData;\n return `<p><b>${labelCallback('candle')}:</b></p>\n<p>${labelCallback('open_price')}: ${open} </p>\n<p>${labelCallback('close_price')}: ${close} </p>\n<p>${labelCallback('low')}: ${low} </p>\n<p>${labelCallback('high')}: ${high} </p>\n`;\n};\n\nconst formatBookData = ({\n matchedBucket,\n bucketWidth,\n bucketDisplayPrecision,\n bookType,\n labelCallback,\n}: {\n matchedBucket: Bucket;\n bucketWidth: number;\n bucketDisplayPrecision: number;\n bookType: BookType;\n labelCallback: (key: string) => string;\n}): string => {\n const bookLabelKey = bookType === BookType.Order ? 'orders' : 'positions';\n const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);\n const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(\n bucketDisplayPrecision\n );\n const sentimentLabel = getSentimentOverbalanceLabel(\n matchedBucket.sentiment,\n bookType\n );\n const sentimentValue = Math.abs(matchedBucket.sentiment).toFixed(\n bucketDisplayPrecision\n );\n\n return `<br /><p><b>${labelCallback(bookLabelKey)}:</b></p>\n<p>${labelCallback('price_range')}: ${priceRangeStart} - ${priceRangeEnd} </p>\n<p>${labelCallback(sentimentLabel)}: ${sentimentValue}% </p>`;\n};\n\nconst formatSentimentData = (\n sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }>,\n labelCallback: (key: string) => string\n): string => {\n const [, shortPercent, longPercent] = sentimentParam.value;\n return `<br /><p><b>${labelCallback('sentiment')}:</b></p>\n<p>${labelCallback('long')}: ${longPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>\n<p>${labelCallback('short')}: ${shortPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>`;\n};\n\nconst hasValidCandleData = (\n candleData: [number, number, number, number, number]\n): boolean =>\n !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[3];\nconst hasValidSentimentData = (\n sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }> | undefined\n): boolean => !!sentimentParam?.value[1] && !!sentimentParam?.value[2];\nconst findMatchingBucket = (\n buckets: Bucket[][],\n bucketsIndex: number | undefined,\n selectedPrice: number,\n bucketWidth: number\n): Bucket | undefined => {\n if (bucketsIndex === undefined) {\n return undefined;\n }\n const selectedBuckets = buckets[bucketsIndex];\n return selectedBuckets?.find(\n ({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth\n );\n};\n\nexport const getTooltipFormatter = ({\n params,\n buckets,\n bucketWidth,\n selectedPrice,\n bookType,\n labelCallback,\n}: {\n params: TooltipParam[];\n buckets: Bucket[][];\n bucketWidth: number;\n selectedPrice: number;\n bookType: BookType;\n labelCallback: (key: string) => string;\n}) => {\n if (!params || !Array.isArray(params) || params.length === 0) {\n return '';\n }\n\n const candleParam = findSeriesParam(params, 'candlestick');\n const booksParam = findSeriesParam(params, 'heatmap');\n const sentimentParam = findSeriesParam(params, 'sentiment');\n\n if (!candleParam) {\n return '';\n }\n\n const bucketDisplayPrecision = calculateBucketDisplayPrecision(bucketWidth);\n const time = new Date(candleParam.axisValue as string);\n const candleData = candleParam.value;\n const bucketsIndex = booksParam?.value[2];\n const matchedBucket = findMatchingBucket(\n buckets,\n bucketsIndex,\n selectedPrice,\n bucketWidth\n );\n const showCandles = hasValidCandleData(candleData);\n const showSentiment = hasValidSentimentData(sentimentParam);\n\n if (!showCandles && !matchedBucket) {\n return '';\n }\n\n const timeFormatted = time.toLocaleString(undefined, DATE_FORMAT_OPTIONS);\n const candleSection = showCandles\n ? formatCandleData(candleData, labelCallback)\n : '';\n const bookSection = matchedBucket\n ? formatBookData({\n matchedBucket,\n bucketWidth,\n bucketDisplayPrecision,\n bookType,\n labelCallback,\n })\n : '';\n const sentimentSection =\n showSentiment && sentimentParam\n ? formatSentimentData(sentimentParam, labelCallback)\n : '';\n\n return `<p>${timeFormatted}</p><br />\n${candleSection}\n${bookSection}\n${sentimentSection}`;\n};\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,+BAA+B;AAGxD,MAAMC,mBAA+C,GAAG;EACtDC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE,SAAS;EACjBC,IAAI,EAAE,SAAS;EACfC,GAAG,EAAE,SAAS;EACdC,KAAK,EAAE,SAAS;EAChBC,YAAY,EAAE;AAChB,CAAC;AAED,MAAMC,2BAA2B,GAAG,CAAC;AAErC,MAAMC,+BAA+B,GAAIC,WAAmB,IAAa;EAAA,IAAAC,qBAAA;EACvE,OAAO,EAAAA,qBAAA,GAAAD,WAAW,CAACE,QAAQ,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,cAAAF,qBAAA,uBAApCA,qBAAA,CAAsCG,MAAM,KAAI,CAAC;AAC1D,CAAC;AAED,MAAMC,eAAe,GAAGA,CACtBC,MAAsB,EACtBC,QAAW,KAC4C;EACvD,OAAOD,MAAM,CAACE,IAAI,CACfC,MAAM,IACLA,MAAM,CAACF,QAAQ,KAAKA,Q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U,CAAEf,KAAK,CAAC,CAAC,CAAC;EACzC,MAAMf,aAAa,GAAGkB,kBAAkB,CACtCC,OAAO,EACPC,YAAY,EACZC,aAAa,EACb7C,WACF,CAAC;EACD,MAAM0D,WAAW,GAAGlB,kBAAkB,CAACzB,UAAU,CAAC;EAClD,MAAM4C,aAAa,GAAGlB,qBAAqB,CAACL,cAAc,CAAC;EAE3D,IAAI,CAACsB,WAAW,IAAI,CAAClC,aAAa,EAAE;IAClC,OAAO,EAAE;EACX;EAEA,MAAMoC,aAAa,GAAGL,IAAI,CAACM,cAAc,CAACf,SAAS,EAAEvD,mBAAmB,CAAC;EACzE,MAAMuE,aAAa,GAAGJ,WAAW,GAC7B5C,gBAAgB,CAACC,UAAU,EAAEC,aAAa,CAAC,GAC3C,EAAE;EACN,MAAM+C,WAAW,GAAGvC,aAAa,GAC7BF,cAAc,CAAC;IACbE,aAAa;IACbxB,WAAW;IACXyB,sBAAsB;IACtBb,QAAQ;IACRI;EACF,CAAC,CAAC,GACF,EAAE;EACN,MAAMgD,gBAAgB,GACpBL,aAAa,IAAIvB,cAAc,GAC3BD,mBAAmB,CAACC,cAAc,EAAEpB,aAAa,CAAC,GAClD,EAAE;EAER,aAAAK,MAAA,CAAauC,aAAa,kBAAAvC,MAAA,CAC1ByC,aAAa,QAAAzC,MAAA,CACb0C,WAAW,QAAA1C,MAAA,CACX2C,gBAAgB;AAClB,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"getTooltipFormatter.js","names":["colorPalette","BookType","DATE_FORMAT_OPTIONS","day","month","year","hour","minute","hour12","timeZoneName","SENTIMENT_DISPLAY_PRECISION","TOOLTIP_STYLES","MOBILE_COLUMN_WIDTH","PADDING_BOTTOM","FULL_WIDTH","calculateBucketDisplayPrecision","bucketWidth","_bucketWidth$toString","toString","split","length","findSeriesParam","params","seriesId","find","series","findSentimentSeriesParam","sentimentLongs","sentimentShorts","_sentimentLongs$index","_sentimentShorts$inde","index","dataIndex","sentimentLong","sentimentShort","getSentimentOverbalanceLabel","sentiment","bookType","Order","formatCandleData","candleData","labelCallback","open","close","low","high","candleLabel","openLabel","closeLabel","lowLabel","highLabel","concat","formatBookData","_ref","matchedBucket","bucketDisplayPrecision","isDesktop","bookLabelKey","priceRangeStart","price","toFixed","priceRangeEnd","sentimentLabel","sentimentValue","Math","abs","formatSentimentData","hasValidCandleData","hasValidSentimentData","findMatchingBucket","buckets","bucketsIndex","selectedPrice","undefined","selectedBuckets","_ref2","getTooltipFormatter","_ref3","locale","isDark","Array","isArray","candleParam","booksParam","time","Date","axisValue","value","showCandles","showSentiment","timeFormatted","toLocaleString","replace","candleSection","bookSection","sentimentSection","buildDesktopTooltip","hasMatchedBucket","buildMobileTooltip","_ref4","padding","sentimentPadding","_ref5","backgroundColor","black","white","columnWidth","fullWidth"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\n\nimport { BookType } from '../../../../gql/types/graphql';\nimport type { Bucket, TooltipParam } from '../types';\n\nconst DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {\n day: 'numeric',\n month: 'numeric',\n year: 'numeric',\n\n hour: 'numeric',\n minute: '2-digit',\n hour12: false,\n\n timeZoneName: 'shortOffset',\n};\n\nconst SENTIMENT_DISPLAY_PRECISION = 2;\n\nconst TOOLTIP_STYLES = {\n MOBILE_COLUMN_WIDTH: '33.3%',\n PADDING_BOTTOM: '4px',\n FULL_WIDTH: '100%',\n} as const;\n\nconst calculateBucketDisplayPrecision = (bucketWidth: number): number => {\n return bucketWidth.toString().split('.')[1]?.length || 0;\n};\n\nconst findSeriesParam = <T extends TooltipParam['seriesId']>(\n params: TooltipParam[],\n seriesId: T\n): Extract<TooltipParam, { seriesId: T }> | undefined => {\n return params.find(\n (series): series is Extract<TooltipParam, { seriesId: T }> =>\n series.seriesId === seriesId\n );\n};\n\nconst findSentimentSeriesParam = (\n params: TooltipParam[],\n sentimentLongs: (number | null)[],\n sentimentShorts: (number | null)[]\n): {\n sentimentLong: number | null;\n sentimentShort: number | null;\n} => {\n const index = params[0].dataIndex as number;\n\n return {\n sentimentLong: sentimentLongs[index] ?? null,\n sentimentShort: sentimentShorts[index] ?? null,\n };\n};\n\nconst getSentimentOverbalanceLabel = (\n sentiment: number,\n bookType: BookType\n): string => {\n if (sentiment < 0) {\n return bookType === BookType.Order\n ? 'sell_overbalance'\n : 'short_overbalance';\n }\n return bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance';\n};\n\nconst formatCandleData = (\n candleData: [number, number, number, number, number],\n labelCallback: (key: string) => string\n): string => {\n const [, open, close, low, high] = candleData;\n const candleLabel = labelCallback('candle');\n const openLabel = labelCallback('open');\n const closeLabel = labelCallback('close');\n const lowLabel = labelCallback('low');\n const highLabel = labelCallback('high');\n\n return `<div><b>${candleLabel}:</b></div>\n<div>${openLabel}: ${open} </div>\n<div>${closeLabel}: ${close} </div>\n<div>${lowLabel}: ${low} </div>\n<div>${highLabel}: ${high} </div>\n`;\n};\n\nconst formatBookData = ({\n matchedBucket,\n bucketWidth,\n bucketDisplayPrecision,\n bookType,\n labelCallback,\n isDesktop,\n}: {\n matchedBucket: Bucket;\n bucketWidth: number;\n bucketDisplayPrecision: number;\n bookType: BookType;\n labelCallback: (key: string) => string;\n isDesktop: boolean;\n}): string => {\n const bookLabelKey = bookType === BookType.Order ? 'orders' : 'trades';\n const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);\n const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(\n bucketDisplayPrecision\n );\n const sentimentLabel = getSentimentOverbalanceLabel(\n matchedBucket.sentiment,\n bookType\n );\n const sentimentValue = Math.abs(matchedBucket.sentiment);\n\n return isDesktop\n ? `<div><b>${labelCallback(bookLabelKey)}:</b></div>\n<div>${labelCallback('price_range')}: ${priceRangeStart} - ${priceRangeEnd} </div>\n<div>${labelCallback(sentimentLabel)}: ${sentimentValue}% </div>`\n : `<div><b>${labelCallback(bookLabelKey)}:</b></div>\n<div>${labelCallback('price_range')}:</div>\n<div>${priceRangeStart} - ${priceRangeEnd} </div>\n<div>${labelCallback(sentimentLabel)}:</div>\n<div>${sentimentValue}% </div>`;\n};\n\nconst formatSentimentData = (\n sentimentLong: number,\n sentimentShort: number,\n labelCallback: (key: string) => string\n): string => {\n return `<div><b>${labelCallback('sentiment')}:</b></div>\n<div>${labelCallback('long')}: ${sentimentLong.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </div>\n<div>${labelCallback('short')}: ${sentimentShort.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </div>`;\n};\n\nconst hasValidCandleData = (\n candleData: [number, number, number, number, number]\n): boolean =>\n !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[4];\n\nconst hasValidSentimentData = (\n sentimentLong: number | null,\n sentimentShort: number | null\n): boolean => sentimentLong !== null && sentimentShort !== null;\n\nconst findMatchingBucket = (\n buckets: Bucket[][],\n bucketsIndex: number | undefined,\n selectedPrice: number,\n bucketWidth: number\n): Bucket | undefined => {\n if (bucketsIndex === undefined) {\n return undefined;\n }\n const selectedBuckets = buckets[bucketsIndex];\n return selectedBuckets?.find(\n ({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth\n );\n};\n\nexport const getTooltipFormatter = ({\n params,\n buckets,\n bucketWidth,\n selectedPrice,\n bookType,\n labelCallback,\n sentimentLongs,\n sentimentShorts,\n isDesktop,\n locale,\n isDark,\n}: {\n params: TooltipParam[];\n buckets: Bucket[][];\n bucketWidth: number;\n selectedPrice: number;\n bookType: BookType;\n labelCallback: (key: string) => string;\n sentimentLongs: (number | null)[];\n sentimentShorts: (number | null)[];\n isDesktop: boolean;\n locale: string;\n isDark: boolean;\n}) => {\n if (!params || !Array.isArray(params) || params.length === 0) {\n return '';\n }\n\n const candleParam = findSeriesParam(params, 'candlestick');\n const booksParam = findSeriesParam(params, 'heatmap');\n const { sentimentLong, sentimentShort } = findSentimentSeriesParam(\n params,\n sentimentLongs,\n sentimentShorts\n );\n\n if (!candleParam) {\n return '';\n }\n\n const bucketDisplayPrecision = calculateBucketDisplayPrecision(bucketWidth);\n const time = new Date(candleParam.axisValue as string);\n const candleData = candleParam.value;\n const bucketsIndex = booksParam?.value[2];\n const matchedBucket = findMatchingBucket(\n buckets,\n bucketsIndex,\n selectedPrice,\n bucketWidth\n );\n const showCandles = hasValidCandleData(candleData);\n const showSentiment = hasValidSentimentData(sentimentLong, sentimentShort);\n\n if (!showCandles && !matchedBucket) {\n return '';\n }\n\n const timeFormatted = time\n .toLocaleString(locale, DATE_FORMAT_OPTIONS)\n .replace(/\\//g, '.');\n const candleSection = showCandles\n ? formatCandleData(candleData, labelCallback)\n : '';\n\n const bookSection = matchedBucket\n ? formatBookData({\n matchedBucket,\n bucketWidth,\n bucketDisplayPrecision,\n bookType,\n labelCallback,\n isDesktop,\n })\n : '';\n\n const sentimentSection =\n showSentiment && sentimentLong && sentimentShort\n ? formatSentimentData(sentimentLong, sentimentShort, labelCallback)\n : '';\n\n if (isDesktop) {\n return buildDesktopTooltip({\n timeFormatted,\n candleSection,\n sentimentSection,\n bookSection,\n hasMatchedBucket: !!matchedBucket,\n });\n }\n\n return buildMobileTooltip({\n timeFormatted,\n candleSection,\n sentimentSection,\n bookSection,\n isDark,\n });\n};\n\ninterface TooltipSections {\n timeFormatted: string;\n candleSection: string;\n sentimentSection: string;\n bookSection: string;\n}\n\nconst buildDesktopTooltip = ({\n timeFormatted,\n candleSection,\n sentimentSection,\n bookSection,\n hasMatchedBucket,\n}: TooltipSections & { hasMatchedBucket: boolean }): string => {\n const padding = TOOLTIP_STYLES.PADDING_BOTTOM;\n const sentimentPadding = hasMatchedBucket ? padding : '0px';\n\n return `<div style=\"padding-bottom: ${padding};\">${timeFormatted}</div>\n<div style=\"padding-bottom: ${padding};\">${candleSection}</div>\n<div style=\"padding-bottom: ${sentimentPadding};\">${sentimentSection}</div>\n<div>${bookSection}</div>\n`;\n};\n\nconst buildMobileTooltip = ({\n timeFormatted,\n candleSection,\n sentimentSection,\n bookSection,\n isDark,\n}: TooltipSections & { isDark: boolean }): string => {\n const backgroundColor = isDark ? colorPalette.black : colorPalette.white;\n const columnWidth = TOOLTIP_STYLES.MOBILE_COLUMN_WIDTH;\n const fullWidth = TOOLTIP_STYLES.FULL_WIDTH;\n const padding = TOOLTIP_STYLES.PADDING_BOTTOM;\n\n return `<div style=\"width: ${fullWidth}; background-color: ${backgroundColor};\">\n <div style=\"padding-bottom: ${padding};\">${timeFormatted}</div>\n <div style=\"width: ${fullWidth}; display: flex; justify-content: space-between;\">\n <div style=\"width: ${columnWidth};\">\n${candleSection}\n</div>\n<div style=\"width: ${columnWidth};\">\n${sentimentSection}\n</div>\n<div style=\"width: ${columnWidth};\">\n${bookSection}\n</div>\n</div>\n</div>`;\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAExD,SAASC,QAAQ,QAAQ,+BAA+B;AAGxD,MAAMC,mBAA+C,GAAG;EACtDC,GAAG,EAAE,SAAS;EACdC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE,SAAS;EAEfC,IAAI,EAAE,SAAS;EACfC,MAAM,EAAE,SAAS;EACjBC,MAAM,EAAE,KAAK;EAEbC,YAAY,EAAE;AAChB,CAAC;AAED,MAAMC,2BAA2B,GAAG,CAAC;AAErC,MAAMC,cAAc,GAAG;EACrBC,mBAAmB,EAAE,OAAO;EAC5BC,cAAc,EAAE,KAAK;EACrBC,UAAU,EAAE;AACd,CAAU;AAEV,MAAMC,+BAA+B,GAAIC,WAAmB,IAAa;EAAA,IAAAC,qBAAA;EACvE,OAAO,EAAAA,qBAAA,GAAAD,WAAW,CAACE,QAAQ,CAAC,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,cAAAF,qBAAA,uBAApCA,qBAAA,CAAsCG,MAAM,KAAI,CAAC;AAC1D,CAAC;AAED,MAAMC,eAAe,GAAGA,CACtBC,MAAsB,EAC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AAC;AAED,MAAMI,kBAAkB,GAAGI,KAAA,IAM0B;EAAA,IANzB;IAC1BZ,aAAa;IACbG,aAAa;IACbE,gBAAgB;IAChBD,WAAW;IACXf;EACqC,CAAC,GAAAuB,KAAA;EACtC,MAAMC,eAAe,GAAGxB,MAAM,GAAG/E,YAAY,CAACwG,KAAK,GAAGxG,YAAY,CAACyG,KAAK;EACxE,MAAMC,WAAW,GAAG/F,cAAc,CAACC,mBAAmB;EACtD,MAAM+F,SAAS,GAAGhG,cAAc,CAACG,UAAU;EAC3C,MAAMsF,OAAO,GAAGzF,cAAc,CAACE,cAAc;EAE7C,8BAAAsC,MAAA,CAA6BwD,SAAS,0BAAAxD,MAAA,CAAuBoD,eAAe,2CAAApD,MAAA,CAC9CiD,OAAO,UAAAjD,MAAA,CAAMuC,aAAa,oCAAAvC,MAAA,CACnCwD,SAAS,iFAAAxD,MAAA,CACTuD,WAAW,YAAAvD,MAAA,CAChC0C,aAAa,oCAAA1C,MAAA,CAEMuD,WAAW,YAAAvD,MAAA,CAC9B4C,gBAAgB,oCAAA5C,MAAA,CAEGuD,WAAW,YAAAvD,MAAA,CAC9B2C,WAAW;AAIb,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { formatXAxisAdditionalLabel } from './formatXAxisAdditionalLabel';
|
|
2
|
+
import { formatXAxisLabel } from './formatXAxisLabel';
|
|
3
|
+
import { getLabelData } from './getLabelData';
|
|
4
|
+
import { isDifferenceGreaterThanTwoWeeks } from './isDifferenceGreaterThanTwoWeeks';
|
|
5
|
+
export const handleLabelUpdate = (instance, mainData, labelTimerRef, isGreaterThanTwoWeeksRef, locale) => {
|
|
6
|
+
if (labelTimerRef.current) {
|
|
7
|
+
clearTimeout(labelTimerRef.current);
|
|
8
|
+
}
|
|
9
|
+
labelTimerRef.current = setTimeout(() => {
|
|
10
|
+
var _isGreaterThanTwoWeek;
|
|
11
|
+
const {
|
|
12
|
+
dates
|
|
13
|
+
} = mainData;
|
|
14
|
+
const {
|
|
15
|
+
dataZoom
|
|
16
|
+
} = instance.getOption();
|
|
17
|
+
if (!Array.isArray(dataZoom) || dataZoom.length === 0 || !dataZoom[0] || typeof dataZoom[0].startValue !== 'number' || typeof dataZoom[0].endValue !== 'number') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const {
|
|
21
|
+
startValue,
|
|
22
|
+
endValue
|
|
23
|
+
} = dataZoom[0];
|
|
24
|
+
if (!dates[startValue] || !dates[endValue]) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const isGreaterThanTwoWeeks = isDifferenceGreaterThanTwoWeeks(dates[startValue], dates[endValue]);
|
|
28
|
+
const wasGreaterThanTwoWeeks = (_isGreaterThanTwoWeek = isGreaterThanTwoWeeksRef.current) !== null && _isGreaterThanTwoWeek !== void 0 ? _isGreaterThanTwoWeek : false;
|
|
29
|
+
if (isGreaterThanTwoWeeks !== wasGreaterThanTwoWeeks) {
|
|
30
|
+
const labelsData = getLabelData({
|
|
31
|
+
dates,
|
|
32
|
+
isGreaterThanTwoWeeks
|
|
33
|
+
});
|
|
34
|
+
instance.setOption({
|
|
35
|
+
xAxis: [{
|
|
36
|
+
id: 'main-xAxis',
|
|
37
|
+
axisLabel: {
|
|
38
|
+
formatter: value => formatXAxisLabel(value, isGreaterThanTwoWeeks, locale)
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
id: 'additional-xAxis',
|
|
42
|
+
axisLabel: {
|
|
43
|
+
customValues: labelsData,
|
|
44
|
+
formatter: value => formatXAxisAdditionalLabel(value, isGreaterThanTwoWeeks, locale)
|
|
45
|
+
}
|
|
46
|
+
}]
|
|
47
|
+
});
|
|
48
|
+
isGreaterThanTwoWeeksRef.current = isGreaterThanTwoWeeks;
|
|
49
|
+
}
|
|
50
|
+
}, 50);
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=handleLabelUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleLabelUpdate.js","names":["formatXAxisAdditionalLabel","formatXAxisLabel","getLabelData","isDifferenceGreaterThanTwoWeeks","handleLabelUpdate","instance","mainData","labelTimerRef","isGreaterThanTwoWeeksRef","locale","current","clearTimeout","setTimeout","_isGreaterThanTwoWeek","dates","dataZoom","getOption","Array","isArray","length","startValue","endValue","isGreaterThanTwoWeeks","wasGreaterThanTwoWeeks","labelsData","setOption","xAxis","id","axisLabel","formatter","value","customValues"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.ts"],"sourcesContent":["import type { EChartsType } from 'echarts';\nimport type { MutableRefObject } from 'react';\n\nimport type { ChartProps, DataZoomArray } from '../types';\nimport { formatXAxisAdditionalLabel } from './formatXAxisAdditionalLabel';\nimport { formatXAxisLabel } from './formatXAxisLabel';\nimport { getLabelData } from './getLabelData';\nimport { isDifferenceGreaterThanTwoWeeks } from './isDifferenceGreaterThanTwoWeeks';\n\nexport const handleLabelUpdate = (\n instance: EChartsType,\n mainData: ChartProps['mainData'],\n labelTimerRef: MutableRefObject<NodeJS.Timeout | null>,\n isGreaterThanTwoWeeksRef: MutableRefObject<boolean | null>,\n locale: string\n): void => {\n if (labelTimerRef.current) {\n clearTimeout(labelTimerRef.current);\n }\n labelTimerRef.current = setTimeout(() => {\n const { dates } = mainData;\n\n const { dataZoom } = instance.getOption();\n if (\n !Array.isArray(dataZoom) ||\n dataZoom.length === 0 ||\n !dataZoom[0] ||\n typeof dataZoom[0].startValue !== 'number' ||\n typeof dataZoom[0].endValue !== 'number'\n ) {\n return;\n }\n\n const { startValue, endValue } = dataZoom[0] as DataZoomArray[0];\n\n if (!dates[startValue] || !dates[endValue]) {\n return;\n }\n\n const isGreaterThanTwoWeeks = isDifferenceGreaterThanTwoWeeks(\n dates[startValue],\n dates[endValue]\n );\n\n const wasGreaterThanTwoWeeks = isGreaterThanTwoWeeksRef.current ?? false;\n\n if (isGreaterThanTwoWeeks !== wasGreaterThanTwoWeeks) {\n const labelsData = getLabelData({\n dates,\n isGreaterThanTwoWeeks,\n });\n\n instance.setOption({\n xAxis: [\n {\n id: 'main-xAxis',\n axisLabel: {\n formatter: (value: string) =>\n formatXAxisLabel(value, isGreaterThanTwoWeeks, locale),\n },\n },\n {\n id: 'additional-xAxis',\n axisLabel: {\n customValues: labelsData,\n formatter: (value: unknown) =>\n formatXAxisAdditionalLabel(\n value,\n isGreaterThanTwoWeeks,\n locale\n ),\n },\n },\n ],\n });\n\n isGreaterThanTwoWeeksRef.current = isGreaterThanTwoWeeks;\n }\n }, 50);\n};\n"],"mappings":"AAIA,SAASA,0BAA0B,QAAQ,8BAA8B;AACzE,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,+BAA+B,QAAQ,mCAAmC;AAEnF,OAAO,MAAMC,iBAAiB,GAAGA,CAC/BC,QAAqB,EACrBC,QAAgC,EAChCC,aAAsD,EACtDC,wBAA0D,EAC1DC,MAAc,KACL;EACT,IAAIF,aAAa,CAACG,OAAO,EAAE;IACzBC,YAAY,CAACJ,aAAa,CAACG,OAAO,CAAC;EACrC;EACAH,aAAa,CAACG,OAAO,GAAGE,UAAU,CAAC,MAAM;IAAA,IAAAC,qBAAA;IACvC,MAAM;MAAEC;IAAM,CAAC,GAAGR,QAAQ;IAE1B,MAAM;MAAES;IAAS,CAAC,GAAGV,QAAQ,CAACW,SAAS,CAAC,CAAC;IACzC,IACE,CAACC,KAAK,CAACC,OAAO,CAACH,QAAQ,CAAC,IACxBA,QAAQ,CAACI,MAAM,KAAK,CAAC,IACrB,CAACJ,QAAQ,CAAC,CAAC,CAAC,IACZ,OAAOA,QAAQ,CAAC,CAAC,CAAC,CAACK,UAAU,KAAK,QAAQ,IAC1C,OAAOL,QAAQ,CAAC,CAAC,CAAC,CAACM,QAAQ,KAAK,QAAQ,EACxC;MACA;IACF;IAEA,MAAM;MAAED,UAAU;MAAEC;IAAS,CAAC,GAAGN,QAAQ,CAAC,CAAC,CAAqB;IAEhE,IAAI,CAACD,KAAK,CAACM,UAAU,CAAC,IAAI,CAACN,KAAK,CAACO,QAAQ,CAAC,EAAE;MAC1C;IACF;IAEA,MAAMC,qBAAqB,GAAGnB,+BAA+B,CAC3DW,KAAK,CAACM,UAAU,CAAC,EACjBN,KAAK,CAACO,QAAQ,CAChB,CAAC;IAED,MAAME,sBAAsB,IAAAV,qBAAA,GAAGL,wBAAwB,CAACE,OAAO,cAAAG,qBAAA,cAAAA,qBAAA,GAAI,KAAK;IAExE,IAAIS,qBAAqB,KAAKC,sBAAsB,EAAE;MACpD,MAAMC,UAAU,GAAGtB,YAAY,CAAC;QAC9BY,KAAK;QACLQ;MACF,CAAC,CAAC;MAEFjB,QAAQ,CAACoB,SAAS,CAAC;QACjBC,KAAK,EAAE,CACL;UACEC,EAAE,EAAE,YAAY;UAChBC,SAAS,EAAE;YACTC,SAAS,EAAGC,KAAa,IACvB7B,gBAAgB,CAAC6B,KAAK,EAAER,qBAAqB,EAAEb,MAAM;UACzD;QACF,CAAC,EACD;UACEkB,EAAE,EAAE,kBAAkB;UACtBC,SAAS,EAAE;YACTG,YAAY,EAAEP,UAAU;YACxBK,SAAS,EAAGC,KAAc,IACxB9B,0BAA0B,CACxB8B,KAAK,EACLR,qBAAqB,EACrBb,MACF;UACJ;QACF,CAAC;MAEL,CAAC,CAAC;MAEFD,wBAAwB,CAACE,OAAO,GAAGY,qBAAqB;IAC1D;EACF,CAAC,EAAE,EAAE,CAAC;AACR,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const handleTooltipUpdate = (instance, zoomTimerRef, tooltipVisibleRef, canHover) => {
|
|
2
|
+
if (!canHover) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
if (tooltipVisibleRef.current) {
|
|
6
|
+
instance.setOption({
|
|
7
|
+
tooltip: {
|
|
8
|
+
show: false
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
tooltipVisibleRef.current = false;
|
|
12
|
+
}
|
|
13
|
+
if (zoomTimerRef.current) {
|
|
14
|
+
clearTimeout(zoomTimerRef.current);
|
|
15
|
+
}
|
|
16
|
+
zoomTimerRef.current = setTimeout(() => {
|
|
17
|
+
if (!tooltipVisibleRef.current) {
|
|
18
|
+
instance.setOption({
|
|
19
|
+
tooltip: {
|
|
20
|
+
show: true
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
tooltipVisibleRef.current = true;
|
|
24
|
+
}
|
|
25
|
+
}, 100);
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=handleTooltipUpdate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handleTooltipUpdate.js","names":["handleTooltipUpdate","instance","zoomTimerRef","tooltipVisibleRef","canHover","current","setOption","tooltip","show","clearTimeout","setTimeout"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.ts"],"sourcesContent":["import type { EChartsType } from 'echarts';\nimport type { MutableRefObject } from 'react';\n\nexport const handleTooltipUpdate = (\n instance: EChartsType,\n zoomTimerRef: MutableRefObject<NodeJS.Timeout | null>,\n tooltipVisibleRef: MutableRefObject<boolean>,\n canHover: boolean\n): void => {\n if (!canHover) {\n return;\n }\n\n if (tooltipVisibleRef.current) {\n instance.setOption({\n tooltip: {\n show: false,\n },\n });\n tooltipVisibleRef.current = false;\n }\n\n if (zoomTimerRef.current) {\n clearTimeout(zoomTimerRef.current);\n }\n\n zoomTimerRef.current = setTimeout(() => {\n if (!tooltipVisibleRef.current) {\n instance.setOption({\n tooltip: {\n show: true,\n },\n });\n tooltipVisibleRef.current = true;\n }\n }, 100);\n};\n"],"mappings":"AAGA,OAAO,MAAMA,mBAAmB,GAAGA,CACjCC,QAAqB,EACrBC,YAAqD,EACrDC,iBAA4C,EAC5CC,QAAiB,KACR;EACT,IAAI,CAACA,QAAQ,EAAE;IACb;EACF;EAEA,IAAID,iBAAiB,CAACE,OAAO,EAAE;IAC7BJ,QAAQ,CAACK,SAAS,CAAC;MACjBC,OAAO,EAAE;QACPC,IAAI,EAAE;MACR;IACF,CAAC,CAAC;IACFL,iBAAiB,CAACE,OAAO,GAAG,KAAK;EACnC;EAEA,IAAIH,YAAY,CAACG,OAAO,EAAE;IACxBI,YAAY,CAACP,YAAY,CAACG,OAAO,CAAC;EACpC;EAEAH,YAAY,CAACG,OAAO,GAAGK,UAAU,CAAC,MAAM;IACtC,IAAI,CAACP,iBAAiB,CAACE,OAAO,EAAE;MAC9BJ,QAAQ,CAACK,SAAS,CAAC;QACjBC,OAAO,EAAE;UACPC,IAAI,EAAE;QACR;MACF,CAAC,CAAC;MACFL,iBAAiB,CAACE,OAAO,GAAG,IAAI;IAClC;EACF,CAAC,EAAE,GAAG,CAAC;AACT,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
export * from './formatXAxisAdditionalLabel';
|
|
1
2
|
export * from './formatXAxisLabel';
|
|
2
3
|
export * from './getChartStyles';
|
|
3
4
|
export * from './getGradientColor';
|
|
4
5
|
export * from './getLabelData';
|
|
5
6
|
export * from './getRectColor';
|
|
6
7
|
export * from './getTooltipFormatter';
|
|
8
|
+
export * from './handleLabelUpdate';
|
|
9
|
+
export * from './handleTooltipUpdate';
|
|
7
10
|
export * from './isDifferenceGreaterThanTwoWeeks';
|
|
11
|
+
export * from './normalizeLocale';
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/index.ts"],"sourcesContent":["export * from './formatXAxisLabel';\nexport * from './getChartStyles';\nexport * from './getGradientColor';\nexport * from './getLabelData';\nexport * from './getRectColor';\nexport * from './getTooltipFormatter';\nexport * from './isDifferenceGreaterThanTwoWeeks';\n"],"mappings":"AAAA,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB;AACrC,cAAc,mCAAmC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/index.ts"],"sourcesContent":["export * from './formatXAxisAdditionalLabel';\nexport * from './formatXAxisLabel';\nexport * from './getChartStyles';\nexport * from './getGradientColor';\nexport * from './getLabelData';\nexport * from './getRectColor';\nexport * from './getTooltipFormatter';\nexport * from './handleLabelUpdate';\nexport * from './handleTooltipUpdate';\nexport * from './isDifferenceGreaterThanTwoWeeks';\nexport * from './normalizeLocale';\n"],"mappings":"AAAA,cAAc,8BAA8B;AAC5C,cAAc,oBAAoB;AAClC,cAAc,kBAAkB;AAChC,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAC9B,cAAc,gBAAgB;AAC9B,cAAc,uBAAuB;AACrC,cAAc,qBAAqB;AACnC,cAAc,uBAAuB;AACrC,cAAc,mCAAmC;AACjD,cAAc,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeLocale.js","names":["normalizeLocale","locale"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.ts"],"sourcesContent":["export const normalizeLocale = (locale: string): string => {\n return locale === 'en' ? 'en-GB' : locale;\n};\n"],"mappings":"AAAA,OAAO,MAAMA,eAAe,GAAIC,MAAc,IAAa;EACzD,OAAOA,MAAM,KAAK,IAAI,GAAG,OAAO,GAAGA,MAAM;AAC3C,CAAC","ignoreList":[]}
|