@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
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
|
+
import chroma from 'chroma-js';
|
|
3
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
4
|
+
export const getLabelsConfig = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
isDark,
|
|
7
|
+
isDesktop,
|
|
8
|
+
labelCallback
|
|
9
|
+
} = _ref;
|
|
10
|
+
const ySentimentLabelSize = isDesktop ? CHART_CONFIG.Y_SENTIMENT_LABEL_DESKTOP_SIZE : CHART_CONFIG.Y_SENTIMENT_LABEL_MOBILE_SIZE;
|
|
11
|
+
const yMainLabelSize = isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE;
|
|
12
|
+
const textColor = isDark ? colorPalette.white : colorPalette.black;
|
|
13
|
+
const labelBackgroundColor = isDark ? colorPalette.darkGray : colorPalette.white;
|
|
14
|
+
const backgroundColor = isDark ? colorPalette.black : colorPalette.white;
|
|
15
|
+
const shadowColor = chroma(colorPalette.black).alpha(0.1).hex();
|
|
16
|
+
const sentimentText = labelCallback('sentiment').toUpperCase();
|
|
17
|
+
const priceText = labelCallback('price').toUpperCase();
|
|
18
|
+
const sentimentEstimatedWidth = 10 * sentimentText.length * 0.65;
|
|
19
|
+
const priceEstimatedWidth = 10 * priceText.length * 0.65;
|
|
20
|
+
const sentimentVerticalOffset = sentimentEstimatedWidth / 2;
|
|
21
|
+
const priceVerticalOffset = priceEstimatedWidth / 2;
|
|
22
|
+
const topMargin = isDesktop ? CHART_CONFIG.TOP_MARGIN_DESKTOP : CHART_CONFIG.TOP_MARGIN_MOBILE + CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT;
|
|
23
|
+
const mainHeight = isDesktop ? CHART_CONFIG.MAIN_HEIGHT_DESKTOP : CHART_CONFIG.MAIN_HEIGHT_MOBILE;
|
|
24
|
+
return [{
|
|
25
|
+
type: 'group',
|
|
26
|
+
left: "".concat(ySentimentLabelSize + 5, "px'"),
|
|
27
|
+
top: "".concat(topMargin + 5, "px"),
|
|
28
|
+
silent: true,
|
|
29
|
+
children: [{
|
|
30
|
+
type: 'rect',
|
|
31
|
+
z: 100,
|
|
32
|
+
right: 'center',
|
|
33
|
+
top: 'middle',
|
|
34
|
+
shape: {
|
|
35
|
+
width: 50,
|
|
36
|
+
height: 24
|
|
37
|
+
},
|
|
38
|
+
style: {
|
|
39
|
+
fill: labelBackgroundColor,
|
|
40
|
+
shadowBlur: 8,
|
|
41
|
+
shadowOffsetX: 0,
|
|
42
|
+
shadowOffsetY: 1,
|
|
43
|
+
shadowColor: shadowColor
|
|
44
|
+
}
|
|
45
|
+
}, {
|
|
46
|
+
type: 'text',
|
|
47
|
+
z: 100,
|
|
48
|
+
right: 'center',
|
|
49
|
+
top: 'middle',
|
|
50
|
+
style: {
|
|
51
|
+
fontSize: 11,
|
|
52
|
+
fontFamily: 'Sofia W03',
|
|
53
|
+
fontWeight: 500,
|
|
54
|
+
fill: textColor,
|
|
55
|
+
width: 70,
|
|
56
|
+
height: 30,
|
|
57
|
+
text: labelCallback('short')
|
|
58
|
+
}
|
|
59
|
+
}]
|
|
60
|
+
}, {
|
|
61
|
+
type: 'group',
|
|
62
|
+
left: "".concat(ySentimentLabelSize + 5, "px'"),
|
|
63
|
+
top: "".concat(topMargin + mainHeight - 24 - 5, "px"),
|
|
64
|
+
silent: true,
|
|
65
|
+
children: [{
|
|
66
|
+
type: 'rect',
|
|
67
|
+
z: 100,
|
|
68
|
+
right: 'center',
|
|
69
|
+
top: 'middle',
|
|
70
|
+
shape: {
|
|
71
|
+
width: 50,
|
|
72
|
+
height: 24
|
|
73
|
+
},
|
|
74
|
+
style: {
|
|
75
|
+
fill: labelBackgroundColor,
|
|
76
|
+
shadowBlur: 8,
|
|
77
|
+
shadowOffsetX: 0,
|
|
78
|
+
shadowOffsetY: 1,
|
|
79
|
+
shadowColor: shadowColor
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
type: 'text',
|
|
83
|
+
z: 100,
|
|
84
|
+
right: 'center',
|
|
85
|
+
top: 'middle',
|
|
86
|
+
style: {
|
|
87
|
+
fontSize: 11,
|
|
88
|
+
fontFamily: 'Sofia W03',
|
|
89
|
+
fontWeight: 500,
|
|
90
|
+
fill: textColor,
|
|
91
|
+
width: 70,
|
|
92
|
+
height: 30,
|
|
93
|
+
text: labelCallback('long')
|
|
94
|
+
}
|
|
95
|
+
}]
|
|
96
|
+
}, {
|
|
97
|
+
type: 'text',
|
|
98
|
+
z: 30,
|
|
99
|
+
rotation: isDesktop ? Math.PI / 2 : 0,
|
|
100
|
+
left: "5px",
|
|
101
|
+
top: isDesktop ? "".concat(topMargin + mainHeight / 2 - sentimentVerticalOffset, "px") : "".concat(topMargin - 16, "px"),
|
|
102
|
+
silent: true,
|
|
103
|
+
style: {
|
|
104
|
+
fontSize: 10,
|
|
105
|
+
fontFamily: 'Sofia W03',
|
|
106
|
+
fontWeight: 300,
|
|
107
|
+
fill: textColor,
|
|
108
|
+
text: sentimentText
|
|
109
|
+
}
|
|
110
|
+
}, {
|
|
111
|
+
type: 'text',
|
|
112
|
+
z: 30,
|
|
113
|
+
rotation: isDesktop ? -Math.PI / 2 : 0,
|
|
114
|
+
right: "5px",
|
|
115
|
+
top: isDesktop ? "".concat(topMargin + mainHeight / 2 - priceVerticalOffset, "px") : "".concat(topMargin - 16, "px"),
|
|
116
|
+
silent: true,
|
|
117
|
+
style: {
|
|
118
|
+
fontSize: 10,
|
|
119
|
+
fontFamily: 'Sofia W03',
|
|
120
|
+
fontWeight: 300,
|
|
121
|
+
fill: textColor,
|
|
122
|
+
text: priceText
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
type: 'rect',
|
|
126
|
+
z: 20,
|
|
127
|
+
right: '0px',
|
|
128
|
+
top: "".concat(topMargin, "px"),
|
|
129
|
+
shape: {
|
|
130
|
+
width: yMainLabelSize,
|
|
131
|
+
height: mainHeight
|
|
132
|
+
},
|
|
133
|
+
silent: true,
|
|
134
|
+
style: {
|
|
135
|
+
fill: backgroundColor
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
type: 'rect',
|
|
139
|
+
z: 20,
|
|
140
|
+
left: '0px',
|
|
141
|
+
top: "".concat(topMargin, "px"),
|
|
142
|
+
shape: {
|
|
143
|
+
width: ySentimentLabelSize,
|
|
144
|
+
height: mainHeight
|
|
145
|
+
},
|
|
146
|
+
silent: true,
|
|
147
|
+
style: {
|
|
148
|
+
fill: backgroundColor
|
|
149
|
+
}
|
|
150
|
+
}, {
|
|
151
|
+
type: 'text',
|
|
152
|
+
z: 20,
|
|
153
|
+
left: 'center',
|
|
154
|
+
top: CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT / 2 - 5,
|
|
155
|
+
silent: true,
|
|
156
|
+
style: {
|
|
157
|
+
fontSize: isDesktop ? 0 : 11,
|
|
158
|
+
fill: textColor,
|
|
159
|
+
text: isDesktop ? '' : labelCallback('tap_chart_to_see_more_details')
|
|
160
|
+
}
|
|
161
|
+
}];
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=getLabelsConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLabelsConfig.js","names":["colorPalette","chroma","CHART_CONFIG","getLabelsConfig","_ref","isDark","isDesktop","labelCallback","ySentimentLabelSize","Y_SENTIMENT_LABEL_DESKTOP_SIZE","Y_SENTIMENT_LABEL_MOBILE_SIZE","yMainLabelSize","Y_LABEL_SIZE_DESKTOP","Y_LABEL_SIZE_MOBILE","textColor","white","black","labelBackgroundColor","darkGray","backgroundColor","shadowColor","alpha","hex","sentimentText","toUpperCase","priceText","sentimentEstimatedWidth","length","priceEstimatedWidth","sentimentVerticalOffset","priceVerticalOffset","topMargin","TOP_MARGIN_DESKTOP","TOP_MARGIN_MOBILE","MOBILE_TOOLTIP_HEIGHT","mainHeight","MAIN_HEIGHT_DESKTOP","MAIN_HEIGHT_MOBILE","type","left","concat","top","silent","children","z","right","shape","width","height","style","fill","shadowBlur","shadowOffsetX","shadowOffsetY","fontSize","fontFamily","fontWeight","text","rotation","Math","PI"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport chroma from 'chroma-js';\nimport type { GraphicComponentOption } from 'echarts';\n\nimport { CHART_CONFIG } from '../../../constants';\n\ninterface getLabelsConfigParams {\n isDark: boolean;\n isDesktop: boolean;\n labelCallback: (key: string, params?: Record<string, unknown>) => string;\n}\n\nexport const getLabelsConfig = ({\n isDark,\n isDesktop,\n labelCallback,\n}: getLabelsConfigParams): GraphicComponentOption[] => {\n const ySentimentLabelSize = isDesktop\n ? CHART_CONFIG.Y_SENTIMENT_LABEL_DESKTOP_SIZE\n : CHART_CONFIG.Y_SENTIMENT_LABEL_MOBILE_SIZE;\n\n const yMainLabelSize = isDesktop\n ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP\n : CHART_CONFIG.Y_LABEL_SIZE_MOBILE;\n\n const textColor = isDark ? colorPalette.white : colorPalette.black;\n const labelBackgroundColor = isDark\n ? colorPalette.darkGray\n : colorPalette.white;\n const backgroundColor = isDark ? colorPalette.black : colorPalette.white;\n const shadowColor = chroma(colorPalette.black).alpha(0.1).hex();\n\n // Estimate text width for centering rotated text\n // Approximate: fontSize * characterCount * 0.65 (typical character width ratio)\n const sentimentText = labelCallback('sentiment').toUpperCase();\n const priceText = labelCallback('price').toUpperCase();\n const sentimentEstimatedWidth = 10 * sentimentText.length * 0.65;\n const priceEstimatedWidth = 10 * priceText.length * 0.65;\n const sentimentVerticalOffset = sentimentEstimatedWidth / 2;\n const priceVerticalOffset = priceEstimatedWidth / 2;\n\n const topMargin = isDesktop\n ? CHART_CONFIG.TOP_MARGIN_DESKTOP\n : CHART_CONFIG.TOP_MARGIN_MOBILE + CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT;\n\n const mainHeight = isDesktop\n ? CHART_CONFIG.MAIN_HEIGHT_DESKTOP\n : CHART_CONFIG.MAIN_HEIGHT_MOBILE;\n\n return [\n {\n type: 'group',\n left: `${ySentimentLabelSize + 5}px'`,\n top: `${topMargin + 5}px`,\n silent: true,\n children: [\n {\n type: 'rect',\n z: 100,\n right: 'center',\n top: 'middle',\n shape: {\n width: 50,\n height: 24,\n },\n style: {\n fill: labelBackgroundColor,\n shadowBlur: 8,\n shadowOffsetX: 0,\n shadowOffsetY: 1,\n shadowColor: shadowColor,\n },\n },\n {\n type: 'text',\n z: 100,\n right: 'center',\n top: 'middle',\n style: {\n fontSize: 11,\n fontFamily: 'Sofia W03',\n fontWeight: 500,\n fill: textColor,\n width: 70,\n height: 30,\n text: labelCallback('short'),\n },\n },\n ],\n },\n {\n type: 'group',\n left: `${ySentimentLabelSize + 5}px'`,\n top: `${topMargin + mainHeight - 24 - 5}px`,\n silent: true,\n children: [\n {\n type: 'rect',\n z: 100,\n right: 'center',\n top: 'middle',\n shape: {\n width: 50,\n height: 24,\n },\n style: {\n fill: labelBackgroundColor,\n shadowBlur: 8,\n shadowOffsetX: 0,\n shadowOffsetY: 1,\n shadowColor: shadowColor,\n },\n },\n {\n type: 'text',\n z: 100,\n right: 'center',\n top: 'middle',\n style: {\n fontSize: 11,\n fontFamily: 'Sofia W03',\n fontWeight: 500,\n fill: textColor,\n width: 70,\n height: 30,\n text: labelCallback('long'),\n },\n },\n ],\n },\n\n {\n type: 'text',\n z: 30,\n rotation: isDesktop ? Math.PI / 2 : 0,\n left: `5px`,\n top: isDesktop\n ? `${topMargin + mainHeight / 2 - sentimentVerticalOffset}px`\n : `${topMargin - 16}px`,\n silent: true,\n style: {\n fontSize: 10,\n fontFamily: 'Sofia W03',\n fontWeight: 300,\n fill: textColor,\n text: sentimentText,\n },\n },\n {\n type: 'text',\n z: 30,\n rotation: isDesktop ? -Math.PI / 2 : 0,\n right: `5px`,\n top: isDesktop\n ? `${topMargin + mainHeight / 2 - priceVerticalOffset}px`\n : `${topMargin - 16}px`,\n silent: true,\n style: {\n fontSize: 10,\n fontFamily: 'Sofia W03',\n fontWeight: 300,\n fill: textColor,\n text: priceText,\n },\n },\n {\n type: 'rect',\n z: 20,\n right: '0px',\n top: `${topMargin}px`,\n shape: {\n width: yMainLabelSize,\n height: mainHeight,\n },\n silent: true,\n style: {\n fill: backgroundColor,\n },\n },\n {\n type: 'rect',\n z: 20,\n left: '0px',\n top: `${topMargin}px`,\n shape: {\n width: ySentimentLabelSize,\n height: mainHeight,\n },\n silent: true,\n style: {\n fill: backgroundColor,\n },\n },\n {\n type: 'text',\n z: 20,\n left: 'center',\n top: CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT / 2 - 5,\n silent: true,\n style: {\n fontSize: isDesktop ? 0 : 11,\n fill: textColor,\n text: isDesktop ? '' : labelCallback('tap_chart_to_see_more_details'),\n },\n },\n ];\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,OAAOC,MAAM,MAAM,WAAW;AAG9B,SAASC,YAAY,QAAQ,oBAAoB;AAQjD,OAAO,MAAMC,eAAe,GAAGC,IAAA,IAIwB;EAAA,IAJvB;IAC9BC,MAAM;IACNC,SAAS;IACTC;EACqB,CAAC,GAAAH,IAAA;EACtB,MAAMI,mBAAmB,GAAGF,SAAS,GACjCJ,YAAY,CAACO,8BAA8B,GAC3CP,YAAY,CAACQ,6BAA6B;EAE9C,MAAMC,cAAc,GAAGL,SAAS,GAC5BJ,YAAY,CAACU,oBAAoB,GACjCV,YAAY,CAACW,mBAAmB;EAEpC,MAAMC,SAAS,GAAGT,MAAM,GAAGL,YAAY,CAACe,KAAK,GAAGf,YAAY,CAACgB,KAAK;EAClE,MAAMC,oBAA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AAE,KAAK;IACZJ,GAAG,KAAAD,MAAA,CAAKT,SAAS,OAAI;IACrBe,KAAK,EAAE;MACLC,KAAK,EAAEpC,cAAc;MACrBqC,MAAM,EAAEb;IACV,CAAC;IACDO,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLC,IAAI,EAAE/B;IACR;EACF,CAAC,EACD;IACEmB,IAAI,EAAE,MAAM;IACZM,CAAC,EAAE,EAAE;IACLL,IAAI,EAAE,KAAK;IACXE,GAAG,KAAAD,MAAA,CAAKT,SAAS,OAAI;IACrBe,KAAK,EAAE;MACLC,KAAK,EAAEvC,mBAAmB;MAC1BwC,MAAM,EAAEb;IACV,CAAC;IACDO,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLC,IAAI,EAAE/B;IACR;EACF,CAAC,EACD;IACEmB,IAAI,EAAE,MAAM;IACZM,CAAC,EAAE,EAAE;IACLL,IAAI,EAAE,QAAQ;IACdE,GAAG,EAAEvC,YAAY,CAACgC,qBAAqB,GAAG,CAAC,GAAG,CAAC;IAC/CQ,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLK,QAAQ,EAAEhD,SAAS,GAAG,CAAC,GAAG,EAAE;MAC5B4C,IAAI,EAAEpC,SAAS;MACf2C,IAAI,EAAEnD,SAAS,GAAG,EAAE,GAAGC,aAAa,CAAC,+BAA+B;IACtE;EACF,CAAC,CACF;AACH,CAAC","ignoreList":[]}
|
package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import chroma from 'chroma-js';
|
|
2
|
-
import { getLabelData } from '../chartUtils';
|
|
3
2
|
export const getSeriesCandlestickConfig = _ref => {
|
|
4
3
|
let {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
styles
|
|
4
|
+
styles,
|
|
5
|
+
isLoading
|
|
8
6
|
} = _ref;
|
|
9
7
|
const {
|
|
10
8
|
candleLongColor,
|
|
11
9
|
candleShortColor
|
|
12
10
|
} = styles;
|
|
13
|
-
const labelsData = getLabelData({
|
|
14
|
-
dates,
|
|
15
|
-
isGreaterThanTwoWeeks
|
|
16
|
-
});
|
|
17
11
|
return {
|
|
12
|
+
animation: isLoading,
|
|
18
13
|
type: 'candlestick',
|
|
19
14
|
id: 'candlestick',
|
|
20
15
|
xAxisIndex: 0,
|
|
21
16
|
yAxisIndex: 0,
|
|
17
|
+
silent: true,
|
|
18
|
+
clip: true,
|
|
19
|
+
large: true,
|
|
22
20
|
encode: {
|
|
23
21
|
x: 'dates',
|
|
24
22
|
y: ['open', 'close', 'low', 'high']
|
|
@@ -35,12 +33,7 @@ export const getSeriesCandlestickConfig = _ref => {
|
|
|
35
33
|
color0: candleShortColor
|
|
36
34
|
}
|
|
37
35
|
},
|
|
38
|
-
|
|
39
|
-
data: labelsData,
|
|
40
|
-
symbol: 'circle',
|
|
41
|
-
symbolSize: 0
|
|
42
|
-
},
|
|
43
|
-
z: 2
|
|
36
|
+
z: 3
|
|
44
37
|
};
|
|
45
38
|
};
|
|
46
39
|
//# sourceMappingURL=getSeriesCandlestickConfig.js.map
|
package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSeriesCandlestickConfig.js","names":["chroma","
|
|
1
|
+
{"version":3,"file":"getSeriesCandlestickConfig.js","names":["chroma","getSeriesCandlestickConfig","_ref","styles","isLoading","candleLongColor","candleShortColor","animation","type","id","xAxisIndex","yAxisIndex","silent","clip","large","encode","x","y","itemStyle","color","desaturate","css","color0","borderColor","borderColor0","emphasis","z"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts"],"sourcesContent":["import chroma from 'chroma-js';\nimport type { CandlestickSeriesOption } from 'echarts';\n\nimport type { ChartStyles } from '../chartUtils/getChartStyles';\n\ninterface GetSeriesCandlestickConfigParams {\n styles: ChartStyles;\n isLoading: boolean;\n}\n\nexport const getSeriesCandlestickConfig = ({\n styles,\n isLoading,\n}: GetSeriesCandlestickConfigParams): CandlestickSeriesOption => {\n const { candleLongColor, candleShortColor } = styles;\n\n return {\n animation: isLoading,\n type: 'candlestick',\n id: 'candlestick',\n xAxisIndex: 0,\n yAxisIndex: 0,\n silent: true,\n clip: true,\n large: true,\n encode: {\n x: 'dates',\n y: ['open', 'close', 'low', 'high'],\n },\n itemStyle: {\n color: chroma(candleLongColor).desaturate().css(),\n color0: chroma(candleShortColor).desaturate().css(),\n borderColor: candleLongColor,\n borderColor0: candleShortColor,\n },\n emphasis: {\n itemStyle: {\n color: candleLongColor,\n color0: candleShortColor,\n },\n },\n z: 3,\n };\n};\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,WAAW;AAU9B,OAAO,MAAMC,0BAA0B,GAAGC,IAAA,IAGuB;EAAA,IAHtB;IACzCC,MAAM;IACNC;EACgC,CAAC,GAAAF,IAAA;EACjC,MAAM;IAAEG,eAAe;IAAEC;EAAiB,CAAC,GAAGH,MAAM;EAEpD,OAAO;IACLI,SAAS,EAAEH,SAAS;IACpBI,IAAI,EAAE,aAAa;IACnBC,EAAE,EAAE,aAAa;IACjBC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,CAAC;IACbC,MAAM,EAAE,IAAI;IACZC,IAAI,EAAE,IAAI;IACVC,KAAK,EAAE,IAAI;IACXC,MAAM,EAAE;MACNC,CAAC,EAAE,OAAO;MACVC,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM;IACpC,CAAC;IACDC,SAAS,EAAE;MACTC,KAAK,EAAEnB,MAAM,CAACK,eAAe,CAAC,CAACe,UAAU,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC;MACjDC,MAAM,EAAEtB,MAAM,CAACM,gBAAgB,CAAC,CAACc,UAAU,CAAC,CAAC,CAACC,GAAG,CAAC,CAAC;MACnDE,WAAW,EAAElB,eAAe;MAC5BmB,YAAY,EAAElB;IAChB,CAAC;IACDmB,QAAQ,EAAE;MACRP,SAAS,EAAE;QACTC,KAAK,EAAEd,eAAe;QACtBiB,MAAM,EAAEhB;MACV;IACF,CAAC;IACDoB,CAAC,EAAE;EACL,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -5,9 +5,11 @@ export const getSeriesHeatmapConfig = _ref => {
|
|
|
5
5
|
buckets,
|
|
6
6
|
isDark,
|
|
7
7
|
sentimentThresholdMax,
|
|
8
|
-
sentimentThresholdMin
|
|
8
|
+
sentimentThresholdMin,
|
|
9
|
+
isLoading
|
|
9
10
|
} = _ref;
|
|
10
11
|
return {
|
|
12
|
+
animation: isLoading,
|
|
11
13
|
type: 'custom',
|
|
12
14
|
id: 'heatmap',
|
|
13
15
|
name: 'heatmap',
|
|
@@ -19,13 +21,17 @@ export const getSeriesHeatmapConfig = _ref => {
|
|
|
19
21
|
},
|
|
20
22
|
dimensions: ['dates', 'bookPrices', 'bookIndexes'],
|
|
21
23
|
clip: true,
|
|
22
|
-
renderItem: (
|
|
24
|
+
renderItem: (params, api) => {
|
|
25
|
+
const animationDelay = 350 * params.dataIndexInside / params.dataInsideLength;
|
|
23
26
|
const xVal = api.value(0);
|
|
24
27
|
const bucketIndex = api.value(2);
|
|
25
28
|
if (bucketIndex == null) {
|
|
26
29
|
return null;
|
|
27
30
|
}
|
|
28
31
|
const metaValues = buckets[bucketIndex];
|
|
32
|
+
if (!metaValues) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
29
35
|
const [rectWidth, rectHeight] = api.size([0, bucketWidth]);
|
|
30
36
|
const items = metaValues.map(_ref2 => {
|
|
31
37
|
let {
|
|
@@ -34,6 +40,7 @@ export const getSeriesHeatmapConfig = _ref => {
|
|
|
34
40
|
} = _ref2;
|
|
35
41
|
const start = api.coord([xVal, price]);
|
|
36
42
|
return {
|
|
43
|
+
silent: true,
|
|
37
44
|
shape: {
|
|
38
45
|
height: rectHeight,
|
|
39
46
|
width: rectWidth + 1,
|
|
@@ -43,12 +50,23 @@ export const getSeriesHeatmapConfig = _ref => {
|
|
|
43
50
|
style: {
|
|
44
51
|
fill: getRectColor(sentiment, isDark, sentimentThresholdMin, sentimentThresholdMax)
|
|
45
52
|
},
|
|
53
|
+
enterFrom: {
|
|
54
|
+
shape: {},
|
|
55
|
+
style: {
|
|
56
|
+
opacity: 0
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
enterAnimation: {
|
|
60
|
+
duration: 150,
|
|
61
|
+
delay: animationDelay
|
|
62
|
+
},
|
|
46
63
|
type: 'rect'
|
|
47
64
|
};
|
|
48
65
|
});
|
|
49
66
|
return {
|
|
50
67
|
children: items,
|
|
51
68
|
emphasisDisabled: true,
|
|
69
|
+
silent: true,
|
|
52
70
|
type: 'group'
|
|
53
71
|
};
|
|
54
72
|
},
|
package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSeriesHeatmapConfig.js","names":["getRectColor","getSeriesHeatmapConfig","_ref","bucketWidth","buckets","isDark","sentimentThresholdMax","sentimentThresholdMin","type","id","name","xAxisIndex","yAxisIndex","encode","x","y","dimensions","clip","renderItem","
|
|
1
|
+
{"version":3,"file":"getSeriesHeatmapConfig.js","names":["getRectColor","getSeriesHeatmapConfig","_ref","bucketWidth","buckets","isDark","sentimentThresholdMax","sentimentThresholdMin","isLoading","animation","type","id","name","xAxisIndex","yAxisIndex","encode","x","y","dimensions","clip","renderItem","params","api","animationDelay","dataIndexInside","dataInsideLength","xVal","value","bucketIndex","metaValues","rectWidth","rectHeight","size","items","map","_ref2","price","sentiment","start","coord","silent","shape","height","width","style","fill","enterFrom","opacity","enterAnimation","duration","delay","children","emphasisDisabled","z"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts"],"sourcesContent":["import type {\n CustomSeriesOption,\n CustomSeriesRenderItemAPI,\n CustomSeriesRenderItemParams,\n} from 'echarts';\n\nimport { getRectColor } from '../chartUtils';\nimport type { Bucket } from '../types';\n\ninterface GetSeriesHeatmapConfigParams {\n bucketWidth: number;\n buckets: Bucket[][];\n isDark: boolean;\n sentimentThresholdMax: number;\n sentimentThresholdMin: number;\n isLoading: boolean;\n}\n\nexport const getSeriesHeatmapConfig = ({\n bucketWidth,\n buckets,\n isDark,\n sentimentThresholdMax,\n sentimentThresholdMin,\n isLoading,\n}: GetSeriesHeatmapConfigParams): CustomSeriesOption => {\n return {\n animation: isLoading,\n type: 'custom',\n id: 'heatmap',\n name: 'heatmap',\n xAxisIndex: 0,\n yAxisIndex: 0,\n encode: {\n x: 'dates',\n y: 'bookPrices',\n },\n dimensions: ['dates', 'bookPrices', 'bookIndexes'],\n clip: true,\n renderItem: (\n params: CustomSeriesRenderItemParams,\n api: CustomSeriesRenderItemAPI\n ) => {\n const animationDelay =\n (350 * params.dataIndexInside) / params.dataInsideLength;\n const xVal = api.value(0);\n const bucketIndex = api.value(2) as number;\n\n if (bucketIndex == null) {\n return null;\n }\n\n const metaValues = buckets[bucketIndex];\n\n if (!metaValues) {\n return null;\n }\n\n const [rectWidth, rectHeight] = api.size!([0, bucketWidth]) as number[];\n\n const items = metaValues.map(({ price, sentiment }: Bucket) => {\n const start = api.coord([xVal, price]);\n\n return {\n silent: true,\n shape: {\n height: rectHeight,\n width: rectWidth + 1,\n x: start[0] - rectWidth / 2,\n y: start[1] - rectHeight,\n },\n style: {\n fill: getRectColor(\n sentiment,\n isDark,\n sentimentThresholdMin,\n sentimentThresholdMax\n ),\n },\n enterFrom: {\n shape: {},\n style: {\n opacity: 0,\n },\n },\n enterAnimation: {\n duration: 150,\n delay: animationDelay,\n },\n type: 'rect' as const,\n };\n });\n\n return {\n children: items,\n emphasisDisabled: true,\n silent: true,\n type: 'group' as const,\n };\n },\n z: 1,\n };\n};\n"],"mappings":"AAMA,SAASA,YAAY,QAAQ,eAAe;AAY5C,OAAO,MAAMC,sBAA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ACLI,MAAM,EAAE,IAAI;UACZC,KAAK,EAAE;YACLC,MAAM,EAAEX,UAAU;YAClBY,KAAK,EAAEb,SAAS,GAAG,CAAC;YACpBd,CAAC,EAAEsB,KAAK,CAAC,CAAC,CAAC,GAAGR,SAAS,GAAG,CAAC;YAC3Bb,CAAC,EAAEqB,KAAK,CAAC,CAAC,CAAC,GAAGP;UAChB,CAAC;UACDa,KAAK,EAAE;YACLC,IAAI,EAAE7C,YAAY,CAChBqC,SAAS,EACThC,MAAM,EACNE,qBAAqB,EACrBD,qBACF;UACF,CAAC;UACDwC,SAAS,EAAE;YACTL,KAAK,EAAE,CAAC,CAAC;YACTG,KAAK,EAAE;cACLG,OAAO,EAAE;YACX;UACF,CAAC;UACDC,cAAc,EAAE;YACdC,QAAQ,EAAE,GAAG;YACbC,KAAK,EAAE3B;UACT,CAAC;UACDb,IAAI,EAAE;QACR,CAAC;MACH,CAAC,CAAC;MAEF,OAAO;QACLyC,QAAQ,EAAElB,KAAK;QACfmB,gBAAgB,EAAE,IAAI;QACtBZ,MAAM,EAAE,IAAI;QACZ9B,IAAI,EAAE;MACR,CAAC;IACH,CAAC;IACD2C,CAAC,EAAE;EACL,CAAC;AACH,CAAC","ignoreList":[]}
|
package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
2
|
export const getSeriesSentimentConfig = _ref => {
|
|
3
3
|
let {
|
|
4
|
-
styles
|
|
4
|
+
styles,
|
|
5
|
+
isLoading
|
|
5
6
|
} = _ref;
|
|
6
7
|
return {
|
|
8
|
+
animation: isLoading,
|
|
9
|
+
animationDelay: 350,
|
|
7
10
|
type: 'line',
|
|
8
11
|
id: 'sentiment',
|
|
9
12
|
name: 'sentiment',
|
|
@@ -11,9 +14,9 @@ export const getSeriesSentimentConfig = _ref => {
|
|
|
11
14
|
yAxisIndex: 1,
|
|
12
15
|
encode: {
|
|
13
16
|
x: 'dates',
|
|
14
|
-
y: '
|
|
17
|
+
y: 'sentimentLongs'
|
|
15
18
|
},
|
|
16
|
-
dimensions: ['dates', '
|
|
19
|
+
dimensions: ['dates', 'sentimentLongs', 'sentimentShorts'],
|
|
17
20
|
lineStyle: {
|
|
18
21
|
width: styles.sentimentOutlineWidth,
|
|
19
22
|
opacity: 1,
|
|
@@ -23,7 +26,11 @@ export const getSeriesSentimentConfig = _ref => {
|
|
|
23
26
|
emphasis: {
|
|
24
27
|
disabled: true
|
|
25
28
|
},
|
|
29
|
+
tooltip: {
|
|
30
|
+
show: false
|
|
31
|
+
},
|
|
26
32
|
markLine: {
|
|
33
|
+
animation: isLoading,
|
|
27
34
|
silent: true,
|
|
28
35
|
symbol: ['none', 'none'],
|
|
29
36
|
label: {
|
|
@@ -44,10 +51,11 @@ export const getSeriesSentimentConfig = _ref => {
|
|
|
44
51
|
yAxis: 80
|
|
45
52
|
}]
|
|
46
53
|
},
|
|
47
|
-
stack: 'sentiment',
|
|
48
54
|
showSymbol: false,
|
|
49
55
|
symbol: 'none',
|
|
50
|
-
z:
|
|
56
|
+
z: 2,
|
|
57
|
+
connectNulls: true,
|
|
58
|
+
silent: true
|
|
51
59
|
};
|
|
52
60
|
};
|
|
53
61
|
//# sourceMappingURL=getSeriesSentimentConfig.js.map
|
package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSeriesSentimentConfig.js","names":["colorPalette","getSeriesSentimentConfig","_ref","styles","type","id","name","xAxisIndex","yAxisIndex","encode","x","y","dimensions","lineStyle","width","sentimentOutlineWidth","opacity","shadowColor","sentimentOutlineColor","shadowBlur","emphasis","disabled","markLine","silent","symbol","label","
|
|
1
|
+
{"version":3,"file":"getSeriesSentimentConfig.js","names":["colorPalette","getSeriesSentimentConfig","_ref","styles","isLoading","animation","animationDelay","type","id","name","xAxisIndex","yAxisIndex","encode","x","y","dimensions","lineStyle","width","sentimentOutlineWidth","opacity","shadowColor","sentimentOutlineColor","shadowBlur","emphasis","disabled","tooltip","show","markLine","silent","symbol","label","color","grayLight","data","yAxis","showSymbol","z","connectNulls"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport type { LineSeriesOption } from 'echarts';\n\nimport type { ChartStyles } from '../chartUtils';\n\ninterface GetSeriesSentimentConfigParams {\n styles: ChartStyles;\n isLoading: boolean;\n}\n\nexport const getSeriesSentimentConfig = ({\n styles,\n isLoading,\n}: GetSeriesSentimentConfigParams): LineSeriesOption => {\n return {\n animation: isLoading,\n animationDelay: 350,\n type: 'line',\n id: 'sentiment',\n name: 'sentiment',\n xAxisIndex: 1,\n yAxisIndex: 1,\n encode: {\n x: 'dates',\n y: 'sentimentLongs',\n },\n dimensions: ['dates', 'sentimentLongs', 'sentimentShorts'],\n lineStyle: {\n width: styles.sentimentOutlineWidth,\n opacity: 1,\n shadowColor: styles.sentimentOutlineColor,\n shadowBlur: 3,\n },\n emphasis: {\n disabled: true,\n },\n tooltip: {\n show: false,\n },\n markLine: {\n animation: isLoading,\n silent: true,\n symbol: ['none', 'none'],\n label: {\n show: false,\n },\n lineStyle: {\n color: colorPalette.grayLight,\n width: 1,\n },\n data: [\n {\n yAxis: 20,\n },\n {\n yAxis: 50,\n lineStyle: {\n width: 1,\n },\n },\n {\n yAxis: 80,\n },\n ],\n },\n showSymbol: false,\n symbol: 'none',\n z: 2,\n connectNulls: true,\n silent: true,\n };\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAUxD,OAAO,MAAMC,wBAAwB,GAAGC,IAAA,IAGgB;EAAA,IAHf;IACvCC,MAAM;IACNC;EAC8B,CAAC,GAAAF,IAAA;EAC/B,OAAO;IACLG,SAAS,EAAED,SAAS;IACpBE,cAAc,EAAE,GAAG;IACnBC,IAAI,EAAE,MAAM;IACZC,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,WAAW;IACjBC,UAAU,EAAE,CAAC;IACbC,UAAU,EAAE,CAAC;IACbC,MAAM,EAAE;MACNC,CAAC,EAAE,OAAO;MACVC,CAAC,EAAE;IACL,CAAC;IACDC,UAAU,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,CAAC;IAC1DC,SAAS,EAAE;MACTC,KAAK,EAAEd,MAAM,CAACe,qBAAqB;MACnCC,OAAO,EAAE,CAAC;MACVC,WAAW,EAAEjB,MAAM,CAACkB,qBAAqB;MACzCC,UAAU,EAAE;IACd,CAAC;IACDC,QAAQ,EAAE;MACRC,QAAQ,EAAE;IACZ,CAAC;IACDC,OAAO,EAAE;MACPC,IAAI,EAAE;IACR,CAAC;IACDC,QAAQ,EAAE;MACRtB,SAAS,EAAED,SAAS;MACpBwB,MAAM,EAAE,IAAI;MACZC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;MACxBC,KAAK,EAAE;QACLJ,IAAI,EAAE;MACR,CAAC;MACDV,SAAS,EAAE;QACTe,KAAK,EAAE/B,YAAY,CAACgC,SAAS;QAC7Bf,KAAK,EAAE;MACT,CAAC;MACDgB,IAAI,EAAE,CACJ;QACEC,KAAK,EAAE;MACT,CAAC,EACD;QACEA,KAAK,EAAE,EAAE;QACTlB,SAAS,EAAE;UACTC,KAAK,EAAE;QACT;MACF,CAAC,EACD;QACEiB,KAAK,EAAE;MACT,CAAC;IAEL,CAAC;IACDC,UAAU,EAAE,KAAK;IACjBN,MAAM,EAAE,MAAM;IACdO,CAAC,EAAE,CAAC;IACJC,YAAY,EAAE,IAAI;IAClBT,MAAM,EAAE;EACV,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
6
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
7
|
+
import chroma from 'chroma-js';
|
|
8
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
1
9
|
import { getTooltipFormatter } from '../chartUtils';
|
|
2
10
|
export const getTooltipConfig = _ref => {
|
|
3
11
|
let {
|
|
@@ -7,9 +15,34 @@ export const getTooltipConfig = _ref => {
|
|
|
7
15
|
displayPrecision,
|
|
8
16
|
labelCallback,
|
|
9
17
|
selectedPriceRef,
|
|
10
|
-
tooltipLinesColor
|
|
18
|
+
tooltipLinesColor,
|
|
19
|
+
sentimentLongs,
|
|
20
|
+
sentimentShorts,
|
|
21
|
+
isDesktop,
|
|
22
|
+
isDark,
|
|
23
|
+
locale
|
|
11
24
|
} = _ref;
|
|
12
|
-
|
|
25
|
+
const styles = isDesktop ? {
|
|
26
|
+
backgroundColor: isDark ? chroma(colorPalette.darkGray).alpha(0.95).hex() : chroma(colorPalette.darkWhite).alpha(0.95).hex(),
|
|
27
|
+
shadowColor: colorPalette.black10,
|
|
28
|
+
extraCssText: 'z-index: 5;',
|
|
29
|
+
padding: 8,
|
|
30
|
+
alwaysShowContent: false,
|
|
31
|
+
textStyle: {
|
|
32
|
+
fontSize: 11
|
|
33
|
+
}
|
|
34
|
+
} : {
|
|
35
|
+
backgroundColor: 'transparent',
|
|
36
|
+
shadowColor: 'transparent',
|
|
37
|
+
extraCssText: 'width: 100%; z-index: 5;',
|
|
38
|
+
padding: 4,
|
|
39
|
+
alwaysShowContent: true,
|
|
40
|
+
textStyle: {
|
|
41
|
+
fontSize: 10,
|
|
42
|
+
lineHeight: 12
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return _objectSpread(_objectSpread({}, styles), {}, {
|
|
13
46
|
trigger: 'axis',
|
|
14
47
|
formatter: params => getTooltipFormatter({
|
|
15
48
|
bookType,
|
|
@@ -17,8 +50,14 @@ export const getTooltipConfig = _ref => {
|
|
|
17
50
|
buckets,
|
|
18
51
|
labelCallback,
|
|
19
52
|
params: params,
|
|
20
|
-
selectedPrice: selectedPriceRef.current
|
|
53
|
+
selectedPrice: selectedPriceRef.current,
|
|
54
|
+
sentimentLongs,
|
|
55
|
+
sentimentShorts,
|
|
56
|
+
isDesktop,
|
|
57
|
+
locale,
|
|
58
|
+
isDark
|
|
21
59
|
}),
|
|
60
|
+
hideDelay: 0,
|
|
22
61
|
axisPointer: {
|
|
23
62
|
type: 'cross',
|
|
24
63
|
axis: 'x',
|
|
@@ -40,7 +79,13 @@ export const getTooltipConfig = _ref => {
|
|
|
40
79
|
}
|
|
41
80
|
}
|
|
42
81
|
},
|
|
43
|
-
confine: true
|
|
44
|
-
|
|
82
|
+
confine: true,
|
|
83
|
+
position: point => {
|
|
84
|
+
if (isDesktop) {
|
|
85
|
+
return [point[0] + CHART_CONFIG.TOOLTIP_OFFSET, point[1] + CHART_CONFIG.TOOLTIP_OFFSET];
|
|
86
|
+
}
|
|
87
|
+
return [0, 0];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
45
90
|
};
|
|
46
91
|
//# sourceMappingURL=getTooltipConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTooltipConfig.js","names":["getTooltipFormatter","getTooltipConfig","_ref","bookType","bucketWidth","buckets","displayPrecision","labelCallback","selectedPriceRef","tooltipLinesColor","trigger","formatter","params","selectedPrice","current","axisPointer","type","axis","lineStyle","color","crossStyle","label","
|
|
1
|
+
{"version":3,"file":"getTooltipConfig.js","names":["colorPalette","chroma","CHART_CONFIG","getTooltipFormatter","getTooltipConfig","_ref","bookType","bucketWidth","buckets","displayPrecision","labelCallback","selectedPriceRef","tooltipLinesColor","sentimentLongs","sentimentShorts","isDesktop","isDark","locale","styles","backgroundColor","darkGray","alpha","hex","darkWhite","shadowColor","black10","extraCssText","padding","alwaysShowContent","textStyle","fontSize","lineHeight","_objectSpread","trigger","formatter","params","selectedPrice","current","hideDelay","axisPointer","type","axis","lineStyle","color","crossStyle","label","axisDimension","axisIndex","Number","value","concat","toFixed","confine","position","point","TOOLTIP_OFFSET"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport chroma from 'chroma-js';\nimport type { TooltipComponentOption } from 'echarts';\n\nimport type { BookType } from '../../../../gql/types/graphql';\nimport { CHART_CONFIG } from '../../../constants';\nimport { getTooltipFormatter } from '../chartUtils';\nimport type { Bucket, TooltipParam } from '../types';\n\ninterface GetTooltipConfigParams {\n bookType: BookType;\n bucketWidth: number;\n buckets: Bucket[][];\n displayPrecision: number;\n labelCallback: (key: string, params?: Record<string, unknown>) => string;\n selectedPriceRef: { current: number };\n tooltipLinesColor: string;\n sentimentLongs: (number | null)[];\n sentimentShorts: (number | null)[];\n isDesktop: boolean;\n isDark: boolean;\n locale: string;\n}\n\nexport const getTooltipConfig = ({\n bookType,\n bucketWidth,\n buckets,\n displayPrecision,\n labelCallback,\n selectedPriceRef,\n tooltipLinesColor,\n sentimentLongs,\n sentimentShorts,\n isDesktop,\n isDark,\n locale,\n}: GetTooltipConfigParams): TooltipComponentOption => {\n const styles = isDesktop\n ? {\n backgroundColor: isDark\n ? chroma(colorPalette.darkGray).alpha(0.95).hex()\n : chroma(colorPalette.darkWhite).alpha(0.95).hex(),\n shadowColor: colorPalette.black10,\n extraCssText: 'z-index: 5;',\n padding: 8,\n alwaysShowContent: false,\n textStyle: {\n fontSize: 11,\n },\n }\n : {\n backgroundColor: 'transparent',\n shadowColor: 'transparent',\n extraCssText: 'width: 100%; z-index: 5;',\n padding: 4,\n alwaysShowContent: true,\n textStyle: {\n fontSize: 10,\n lineHeight: 12,\n },\n };\n return {\n ...styles,\n trigger: 'axis' as const,\n formatter: (params) =>\n getTooltipFormatter({\n bookType,\n bucketWidth,\n buckets,\n labelCallback,\n params: params as unknown as TooltipParam[],\n selectedPrice: selectedPriceRef.current,\n sentimentLongs,\n sentimentShorts,\n isDesktop,\n locale,\n isDark,\n }),\n hideDelay: 0,\n axisPointer: {\n type: 'cross' as const,\n axis: 'x' as const,\n lineStyle: {\n color: tooltipLinesColor,\n },\n crossStyle: {\n color: tooltipLinesColor,\n },\n label: {\n padding: 0,\n lineHeight: 24,\n formatter: (params: {\n axisDimension?: string;\n axisIndex?: number;\n value: unknown;\n }) => {\n if (params.axisDimension === 'y' && params.axisIndex === 0) {\n selectedPriceRef.current = Number(params.value);\n return ` ${Number(params.value).toFixed(displayPrecision)} `;\n }\n return '';\n },\n },\n },\n confine: true,\n position: (point) => {\n if (isDesktop) {\n return [\n point[0] + CHART_CONFIG.TOOLTIP_OFFSET,\n point[1] + CHART_CONFIG.TOOLTIP_OFFSET,\n ];\n }\n return [0, 0];\n },\n };\n};\n"],"mappings":";;;;;AAAA,SAASA,YAAY,QAAQ,2BAA2B;AACxD,OAAOC,MAAM,MAA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eAAe;MACfC,SAAS;MACTE,MAAM;MACND;IACF,CAAC,CAAC;IACJsB,SAAS,EAAE,CAAC;IACZC,WAAW,EAAE;MACXC,IAAI,EAAE,OAAgB;MACtBC,IAAI,EAAE,GAAY;MAClBC,SAAS,EAAE;QACTC,KAAK,EAAE/B;MACT,CAAC;MACDgC,UAAU,EAAE;QACVD,KAAK,EAAE/B;MACT,CAAC;MACDiC,KAAK,EAAE;QACLlB,OAAO,EAAE,CAAC;QACVI,UAAU,EAAE,EAAE;QACdG,SAAS,EAAGC,MAIX,IAAK;UACJ,IAAIA,MAAM,CAACW,aAAa,KAAK,GAAG,IAAIX,MAAM,CAACY,SAAS,KAAK,CAAC,EAAE;YAC1DpC,gBAAgB,CAAC0B,OAAO,GAAGW,MAAM,CAACb,MAAM,CAACc,KAAK,CAAC;YAC/C,WAAAC,MAAA,CAAWF,MAAM,CAACb,MAAM,CAACc,KAAK,CAAC,CAACE,OAAO,CAAC1C,gBAAgB,CAAC;UAC3D;UACA,OAAO,EAAE;QACX;MACF;IACF,CAAC;IACD2C,OAAO,EAAE,IAAI;IACbC,QAAQ,EAAGC,KAAK,IAAK;MACnB,IAAIvC,SAAS,EAAE;QACb,OAAO,CACLuC,KAAK,CAAC,CAAC,CAAC,GAAGpD,YAAY,CAACqD,cAAc,EACtCD,KAAK,CAAC,CAAC,CAAC,GAAGpD,YAAY,CAACqD,cAAc,CACvC;MACH;MACA,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACf;EAAC;AAEL,CAAC","ignoreList":[]}
|
|
@@ -1,35 +1,58 @@
|
|
|
1
|
-
import { formatXAxisLabel } from '../chartUtils';
|
|
1
|
+
import { formatXAxisAdditionalLabel, formatXAxisLabel, getLabelData } from '../chartUtils';
|
|
2
2
|
export const getXAxisConfig = _ref => {
|
|
3
3
|
let {
|
|
4
4
|
dates,
|
|
5
|
-
isGreaterThanTwoWeeks
|
|
5
|
+
isGreaterThanTwoWeeks,
|
|
6
|
+
locale
|
|
6
7
|
} = _ref;
|
|
8
|
+
const labelsData = getLabelData({
|
|
9
|
+
dates,
|
|
10
|
+
isGreaterThanTwoWeeks
|
|
11
|
+
});
|
|
7
12
|
return [{
|
|
8
13
|
type: 'category',
|
|
9
14
|
id: 'main-xAxis',
|
|
10
|
-
name: 'xAxis-less-than-two-weeks',
|
|
11
15
|
nameTextStyle: {
|
|
12
16
|
fontSize: 0
|
|
13
17
|
},
|
|
14
18
|
axisTick: {
|
|
15
19
|
show: false
|
|
16
20
|
},
|
|
21
|
+
splitLine: {
|
|
22
|
+
lineStyle: {
|
|
23
|
+
opacity: 0.5
|
|
24
|
+
}
|
|
25
|
+
},
|
|
17
26
|
axisLabel: {
|
|
27
|
+
showMaxLabel: false,
|
|
18
28
|
padding: [8, 16, 8, 16],
|
|
19
29
|
margin: 0,
|
|
20
|
-
formatter: value => formatXAxisLabel(value, isGreaterThanTwoWeeks)
|
|
21
|
-
}
|
|
30
|
+
formatter: value => formatXAxisLabel(value, isGreaterThanTwoWeeks, locale)
|
|
31
|
+
},
|
|
32
|
+
boundaryGap: false,
|
|
33
|
+
z: 2
|
|
22
34
|
}, {
|
|
23
35
|
type: 'category',
|
|
36
|
+
id: 'additional-xAxis',
|
|
24
37
|
gridIndex: 1,
|
|
25
|
-
show: false,
|
|
26
38
|
axisTick: {
|
|
27
39
|
show: false
|
|
28
40
|
},
|
|
29
|
-
|
|
41
|
+
axisLine: {
|
|
42
|
+
show: false
|
|
43
|
+
},
|
|
44
|
+
splitLine: {
|
|
30
45
|
show: false
|
|
31
46
|
},
|
|
32
|
-
|
|
47
|
+
axisLabel: {
|
|
48
|
+
margin: 24,
|
|
49
|
+
hideOverlap: true,
|
|
50
|
+
customValues: labelsData,
|
|
51
|
+
formatter: value => formatXAxisAdditionalLabel(value, isGreaterThanTwoWeeks, locale)
|
|
52
|
+
},
|
|
53
|
+
data: dates,
|
|
54
|
+
boundaryGap: false,
|
|
55
|
+
z: 2
|
|
33
56
|
}];
|
|
34
57
|
};
|
|
35
58
|
//# sourceMappingURL=getXAxisConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getXAxisConfig.js","names":["formatXAxisLabel","getXAxisConfig","_ref","dates","isGreaterThanTwoWeeks","
|
|
1
|
+
{"version":3,"file":"getXAxisConfig.js","names":["formatXAxisAdditionalLabel","formatXAxisLabel","getLabelData","getXAxisConfig","_ref","dates","isGreaterThanTwoWeeks","locale","labelsData","type","id","nameTextStyle","fontSize","axisTick","show","splitLine","lineStyle","opacity","axisLabel","showMaxLabel","padding","margin","formatter","value","boundaryGap","z","gridIndex","axisLine","hideOverlap","customValues","data"],"sources":["../../../../../../src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts"],"sourcesContent":["import type { XAXisComponentOption } from 'echarts';\n\nimport {\n formatXAxisAdditionalLabel,\n formatXAxisLabel,\n getLabelData,\n} from '../chartUtils';\n\ninterface GetXAxisConfigParams {\n dates: string[];\n isGreaterThanTwoWeeks: boolean;\n locale: string;\n}\n\nexport const getXAxisConfig = ({\n dates,\n isGreaterThanTwoWeeks,\n locale,\n}: GetXAxisConfigParams): XAXisComponentOption[] => {\n const labelsData = getLabelData({\n dates,\n isGreaterThanTwoWeeks,\n });\n\n return [\n {\n type: 'category',\n id: 'main-xAxis',\n nameTextStyle: {\n fontSize: 0,\n },\n axisTick: {\n show: false,\n },\n splitLine: {\n lineStyle: {\n opacity: 0.5,\n },\n },\n axisLabel: {\n showMaxLabel: false,\n padding: [8, 16, 8, 16],\n margin: 0,\n formatter: (value: unknown) =>\n formatXAxisLabel(value, isGreaterThanTwoWeeks, locale),\n },\n boundaryGap: false,\n z: 2,\n },\n {\n type: 'category',\n id: 'additional-xAxis',\n gridIndex: 1,\n axisTick: {\n show: false,\n },\n axisLine: {\n show: false,\n },\n splitLine: {\n show: false,\n },\n axisLabel: {\n margin: 24,\n hideOverlap: true,\n customValues: labelsData,\n formatter: (value: unknown) =>\n formatXAxisAdditionalLabel(value, isGreaterThanTw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