@oanda/labs-crowd-view-widget 1.0.55 → 1.0.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +228 -0
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +8 -5
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +15 -3
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +28 -14
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js +19 -7
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +20 -8
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +44 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +14 -6
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +11 -4
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +2 -2
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +6 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +72 -14
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +3 -3
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js +9 -3
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useResizeObserver.js +47 -0
- package/dist/main/CrowdViewWidget/components/Chart/useResizeObserver.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +20 -7
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/CrowdViewWidget/selectConfig.js +3 -3
- package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/main/translations/sources/en.json +10 -9
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +9 -6
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +15 -3
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +28 -14
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js +19 -7
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +20 -8
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +43 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +14 -6
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +12 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +2 -2
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +6 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +72 -14
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +3 -3
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js +4 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js +9 -3
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useResizeObserver.js +40 -0
- package/dist/module/CrowdViewWidget/components/Chart/useResizeObserver.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +20 -7
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/CrowdViewWidget/selectConfig.js +3 -3
- package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/module/translations/sources/en.json +10 -9
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +4 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +4 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/useResizeObserver.d.ts +5 -0
- package/dist/types/CrowdViewWidget/constants.d.ts +24 -19
- package/package.json +3 -3
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +12 -5
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +22 -3
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +34 -19
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +27 -6
- package/src/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.ts +26 -10
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +86 -43
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +12 -5
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +12 -6
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.ts +3 -2
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +6 -4
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +119 -22
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.ts +8 -3
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/normalizeLocale.ts +3 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.ts +1 -1
- package/src/CrowdViewWidget/components/Chart/getOption.ts +6 -0
- package/src/CrowdViewWidget/components/Chart/types.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/useResizeObserver.ts +51 -0
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +3 -2
- package/src/CrowdViewWidget/constants.ts +24 -5
- package/src/CrowdViewWidget/selectConfig.ts +4 -4
- package/src/translations/sources/en.json +10 -9
- package/test/components/Chart/utils/chartUtils.test.ts +16 -4
- package/test/components/Chart/utils/handleLabelUpdate.test.ts +32 -16
- package/test/utils/processPriceCandles.test.ts +4 -4
|
@@ -26,7 +26,8 @@ const getLabelsConfig = _ref => {
|
|
|
26
26
|
const priceEstimatedWidth = 10 * priceText.length * 0.65;
|
|
27
27
|
const sentimentVerticalOffset = sentimentEstimatedWidth / 2;
|
|
28
28
|
const priceVerticalOffset = priceEstimatedWidth / 2;
|
|
29
|
-
const topMargin = isDesktop ? _constants.CHART_CONFIG.TOP_MARGIN_DESKTOP : _constants.CHART_CONFIG.TOP_MARGIN_MOBILE;
|
|
29
|
+
const topMargin = isDesktop ? _constants.CHART_CONFIG.TOP_MARGIN_DESKTOP : _constants.CHART_CONFIG.TOP_MARGIN_MOBILE + _constants.CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT;
|
|
30
|
+
const mainHeight = isDesktop ? _constants.CHART_CONFIG.MAIN_HEIGHT_DESKTOP : _constants.CHART_CONFIG.MAIN_HEIGHT_MOBILE;
|
|
30
31
|
return [{
|
|
31
32
|
type: 'group',
|
|
32
33
|
left: "".concat(ySentimentLabelSize + 5, "px'"),
|
|
@@ -66,7 +67,7 @@ const getLabelsConfig = _ref => {
|
|
|
66
67
|
}, {
|
|
67
68
|
type: 'group',
|
|
68
69
|
left: "".concat(ySentimentLabelSize + 5, "px'"),
|
|
69
|
-
top: "".concat(
|
|
70
|
+
top: "".concat(topMargin + mainHeight - 24 - 5, "px"),
|
|
70
71
|
silent: true,
|
|
71
72
|
children: [{
|
|
72
73
|
type: 'rect',
|
|
@@ -104,7 +105,7 @@ const getLabelsConfig = _ref => {
|
|
|
104
105
|
z: 30,
|
|
105
106
|
rotation: isDesktop ? Math.PI / 2 : 0,
|
|
106
107
|
left: "5px",
|
|
107
|
-
top: isDesktop ? "".concat(topMargin +
|
|
108
|
+
top: isDesktop ? "".concat(topMargin + mainHeight / 2 - sentimentVerticalOffset, "px") : "".concat(topMargin - 16, "px"),
|
|
108
109
|
silent: true,
|
|
109
110
|
style: {
|
|
110
111
|
fontSize: 10,
|
|
@@ -118,7 +119,7 @@ const getLabelsConfig = _ref => {
|
|
|
118
119
|
z: 30,
|
|
119
120
|
rotation: isDesktop ? -Math.PI / 2 : 0,
|
|
120
121
|
right: "5px",
|
|
121
|
-
top: isDesktop ? "".concat(topMargin +
|
|
122
|
+
top: isDesktop ? "".concat(topMargin + mainHeight / 2 - priceVerticalOffset, "px") : "".concat(topMargin - 16, "px"),
|
|
122
123
|
silent: true,
|
|
123
124
|
style: {
|
|
124
125
|
fontSize: 10,
|
|
@@ -131,10 +132,10 @@ const getLabelsConfig = _ref => {
|
|
|
131
132
|
type: 'rect',
|
|
132
133
|
z: 20,
|
|
133
134
|
right: '0px',
|
|
134
|
-
top:
|
|
135
|
+
top: "".concat(topMargin, "px"),
|
|
135
136
|
shape: {
|
|
136
137
|
width: yMainLabelSize,
|
|
137
|
-
height:
|
|
138
|
+
height: mainHeight
|
|
138
139
|
},
|
|
139
140
|
silent: true,
|
|
140
141
|
style: {
|
|
@@ -144,15 +145,26 @@ const getLabelsConfig = _ref => {
|
|
|
144
145
|
type: 'rect',
|
|
145
146
|
z: 20,
|
|
146
147
|
left: '0px',
|
|
147
|
-
top:
|
|
148
|
+
top: "".concat(topMargin, "px"),
|
|
148
149
|
shape: {
|
|
149
150
|
width: ySentimentLabelSize,
|
|
150
|
-
height:
|
|
151
|
+
height: mainHeight
|
|
151
152
|
},
|
|
152
153
|
silent: true,
|
|
153
154
|
style: {
|
|
154
155
|
fill: backgroundColor
|
|
155
156
|
}
|
|
157
|
+
}, {
|
|
158
|
+
type: 'text',
|
|
159
|
+
z: 20,
|
|
160
|
+
left: 'center',
|
|
161
|
+
top: _constants.CHART_CONFIG.MOBILE_TOOLTIP_HEIGHT / 2 - 5,
|
|
162
|
+
silent: true,
|
|
163
|
+
style: {
|
|
164
|
+
fontSize: isDesktop ? 0 : 11,
|
|
165
|
+
fill: textColor,
|
|
166
|
+
text: isDesktop ? '' : labelCallback('tap_chart_to_see_more_details')
|
|
167
|
+
}
|
|
156
168
|
}];
|
|
157
169
|
};
|
|
158
170
|
exports.getLabelsConfig = getLabelsConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLabelsConfig.js","names":["_labsWidgetCommon","require","_chromaJs","_interopRequireDefault","_constants","e","__esModule","default","getLabelsConfig","_ref","isDark","isDesktop","labelCallback","ySentimentLabelSize","CHART_CONFIG","Y_SENTIMENT_LABEL_DESKTOP_SIZE","Y_SENTIMENT_LABEL_MOBILE_SIZE","yMainLabelSize","Y_LABEL_SIZE_DESKTOP","Y_LABEL_SIZE_MOBILE","textColor","colorPalette","white","black","labelBackgroundColor","darkGray","backgroundColor","shadowColor","chroma","alpha","hex","sentimentText","toUpperCase","priceText","sentimentEstimatedWidth","length","priceEstimatedWidth","sentimentVerticalOffset","priceVerticalOffset","topMargin","TOP_MARGIN_DESKTOP","TOP_MARGIN_MOBILE","type","left","concat","top","silent","children","z","right","shape","width","height","style","fill","shadowBlur","shadowOffsetX","shadowOffsetY","fontSize","fontFamily","fontWeight","text","MAIN_HEIGHT","rotation","Math","PI","exports"],"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;\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: `${CHART_CONFIG.MAIN_HEIGHT - 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 + CHART_CONFIG.MAIN_HEIGHT / 2 - sentimentVerticalOffset}px`\n : `${topMargin - 18}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 + CHART_CONFIG.MAIN_HEIGHT / 2 - priceVerticalOffset}px`\n : `${topMargin - 18}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: '0px',\n shape: {\n width: yMainLabelSize,\n height: CHART_CONFIG.MAIN_HEIGHT,\n },\n silent: true,\n style: {\n fill: backgroundColor,\n },\n },\n {\n type: 'rect',\n z: 20,\n left: '0px',\n top: '0px',\n shape: {\n width: ySentimentLabelSize,\n height: CHART_CONFIG.MAIN_HEIGHT,\n },\n silent: true,\n style: {\n fill: backgroundColor,\n },\n },\n ];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AAAkD,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAQ3C,MAAMG,eAAe,GAAGC,IAAA,IAIwB;EAAA,IAJvB;IAC9BC,MAAM;IACNC,SAAS;IACTC;EACqB,CAAC,GAAAH,IA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K,EAAE;MACLK,QAAQ,EAAE,EAAE;MACZC,UAAU,EAAE,WAAW;MACvBC,UAAU,EAAE,GAAG;MACfN,IAAI,EAAElC,SAAS;MACfyC,IAAI,EAAE5B;IACR;EACF,CAAC,EACD;IACES,IAAI,EAAE,MAAM;IACZM,CAAC,EAAE,EAAE;IACLC,KAAK,EAAE,KAAK;IACZJ,GAAG,EAAE,KAAK;IACVK,KAAK,EAAE;MACLC,KAAK,EAAElC,cAAc;MACrBmC,MAAM,EAAEtC,uBAAY,CAACgD;IACvB,CAAC;IACDhB,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLC,IAAI,EAAE5B;IACR;EACF,CAAC,EACD;IACEgB,IAAI,EAAE,MAAM;IACZM,CAAC,EAAE,EAAE;IACLL,IAAI,EAAE,KAAK;IACXE,GAAG,EAAE,KAAK;IACVK,KAAK,EAAE;MACLC,KAAK,EAAEtC,mBAAmB;MAC1BuC,MAAM,EAAEtC,uBAAY,CAACgD;IACvB,CAAC;IACDhB,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLC,IAAI,EAAE5B;IACR;EACF,CAAC,CACF;AACH,CAAC;AAACwC,OAAA,CAAA1D,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"getLabelsConfig.js","names":["_labsWidgetCommon","require","_chromaJs","_interopRequireDefault","_constants","e","__esModule","default","getLabelsConfig","_ref","isDark","isDesktop","labelCallback","ySentimentLabelSize","CHART_CONFIG","Y_SENTIMENT_LABEL_DESKTOP_SIZE","Y_SENTIMENT_LABEL_MOBILE_SIZE","yMainLabelSize","Y_LABEL_SIZE_DESKTOP","Y_LABEL_SIZE_MOBILE","textColor","colorPalette","white","black","labelBackgroundColor","darkGray","backgroundColor","shadowColor","chroma","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","exports"],"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,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AAAkD,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAQ3C,MAAMG,eAAe,GAAGC,IAAA,IAIwB;EAAA,IAJvB;IAC9BC,MAAM;IACNC,SAAS;IACTC;EACqB,CAAC,GAAAH,IAAA;EACtB,MAAMI,mBAAmB,GAAGF,SAAS,GACjCG,uBAAY,CAACC,8BAA8B,GAC3CD,uBAAY,CAACE,6BAA6B;EAE9C,MAAMC,cAAc,GAAGN,SAAS,GAC5BG,uBAAY,CAACI,oBAAoB,GACjCJ,uBAAY,CAACK,mBAAmB;EAEpC,MAAMC,SAAS,GAAGV,MAAM,GAAGW,8BAAY,CAACC,KAAK,G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,IAAI,EAAE,MAAM;IACZM,CAAC,EAAE,EAAE;IACLC,KAAK,EAAE,KAAK;IACZJ,GAAG,KAAAD,MAAA,CAAKT,SAAS,OAAI;IACrBe,KAAK,EAAE;MACLC,KAAK,EAAEtC,cAAc;MACrBuC,MAAM,EAAEb;IACV,CAAC;IACDO,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLC,IAAI,EAAEhC;IACR;EACF,CAAC,EACD;IACEoB,IAAI,EAAE,MAAM;IACZM,CAAC,EAAE,EAAE;IACLL,IAAI,EAAE,KAAK;IACXE,GAAG,KAAAD,MAAA,CAAKT,SAAS,OAAI;IACrBe,KAAK,EAAE;MACLC,KAAK,EAAE1C,mBAAmB;MAC1B2C,MAAM,EAAEb;IACV,CAAC;IACDO,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLC,IAAI,EAAEhC;IACR;EACF,CAAC,EACD;IACEoB,IAAI,EAAE,MAAM;IACZM,CAAC,EAAE,EAAE;IACLL,IAAI,EAAE,QAAQ;IACdE,GAAG,EAAEnC,uBAAY,CAAC4B,qBAAqB,GAAG,CAAC,GAAG,CAAC;IAC/CQ,MAAM,EAAE,IAAI;IACZO,KAAK,EAAE;MACLK,QAAQ,EAAEnD,SAAS,GAAG,CAAC,GAAG,EAAE;MAC5B+C,IAAI,EAAEtC,SAAS;MACf6C,IAAI,EAAEtD,SAAS,GAAG,EAAE,GAAGC,aAAa,CAAC,+BAA+B;IACtE;EACF,CAAC,CACF;AACH,CAAC;AAACyD,OAAA,CAAA7D,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -4,8 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getTooltipConfig = void 0;
|
|
7
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
+
var _chromaJs = _interopRequireDefault(require("chroma-js"));
|
|
7
9
|
var _constants = require("../../../constants");
|
|
8
10
|
var _chartUtils = require("../chartUtils");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
16
|
+
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); }
|
|
9
17
|
const getTooltipConfig = _ref => {
|
|
10
18
|
let {
|
|
11
19
|
bookType,
|
|
@@ -16,9 +24,32 @@ const getTooltipConfig = _ref => {
|
|
|
16
24
|
selectedPriceRef,
|
|
17
25
|
tooltipLinesColor,
|
|
18
26
|
sentimentLongs,
|
|
19
|
-
sentimentShorts
|
|
27
|
+
sentimentShorts,
|
|
28
|
+
isDesktop,
|
|
29
|
+
isDark,
|
|
30
|
+
locale
|
|
20
31
|
} = _ref;
|
|
21
|
-
|
|
32
|
+
const styles = isDesktop ? {
|
|
33
|
+
backgroundColor: isDark ? (0, _chromaJs.default)(_labsWidgetCommon.colorPalette.darkGray).alpha(0.95).hex() : (0, _chromaJs.default)(_labsWidgetCommon.colorPalette.darkWhite).alpha(0.95).hex(),
|
|
34
|
+
shadowColor: _labsWidgetCommon.colorPalette.black10,
|
|
35
|
+
extraCssText: 'z-index: 5;',
|
|
36
|
+
padding: 8,
|
|
37
|
+
alwaysShowContent: false,
|
|
38
|
+
textStyle: {
|
|
39
|
+
fontSize: 11
|
|
40
|
+
}
|
|
41
|
+
} : {
|
|
42
|
+
backgroundColor: 'transparent',
|
|
43
|
+
shadowColor: 'transparent',
|
|
44
|
+
extraCssText: 'width: 100%; z-index: 5;',
|
|
45
|
+
padding: 4,
|
|
46
|
+
alwaysShowContent: true,
|
|
47
|
+
textStyle: {
|
|
48
|
+
fontSize: 10,
|
|
49
|
+
lineHeight: 12
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return _objectSpread(_objectSpread({}, styles), {}, {
|
|
22
53
|
trigger: 'axis',
|
|
23
54
|
formatter: params => (0, _chartUtils.getTooltipFormatter)({
|
|
24
55
|
bookType,
|
|
@@ -28,7 +59,10 @@ const getTooltipConfig = _ref => {
|
|
|
28
59
|
params: params,
|
|
29
60
|
selectedPrice: selectedPriceRef.current,
|
|
30
61
|
sentimentLongs,
|
|
31
|
-
sentimentShorts
|
|
62
|
+
sentimentShorts,
|
|
63
|
+
isDesktop,
|
|
64
|
+
locale,
|
|
65
|
+
isDark
|
|
32
66
|
}),
|
|
33
67
|
hideDelay: 0,
|
|
34
68
|
axisPointer: {
|
|
@@ -53,8 +87,13 @@ const getTooltipConfig = _ref => {
|
|
|
53
87
|
}
|
|
54
88
|
},
|
|
55
89
|
confine: true,
|
|
56
|
-
position: point =>
|
|
57
|
-
|
|
90
|
+
position: point => {
|
|
91
|
+
if (isDesktop) {
|
|
92
|
+
return [point[0] + _constants.CHART_CONFIG.TOOLTIP_OFFSET, point[1] + _constants.CHART_CONFIG.TOOLTIP_OFFSET];
|
|
93
|
+
}
|
|
94
|
+
return [0, 0];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
58
97
|
};
|
|
59
98
|
exports.getTooltipConfig = getTooltipConfig;
|
|
60
99
|
//# sourceMappingURL=getTooltipConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTooltipConfig.js","names":["
|
|
1
|
+
{"version":3,"file":"getTooltipConfig.js","names":["_labsWidgetCommon","require","_chromaJs","_interopRequireDefault","_constants","_chartUtils","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","getTooltipConfig","_ref","bookType","bucketWidth","buckets","displayPrecision","labelCallback","selectedPriceRef","tooltipLinesColor","sentimentLongs","sentimentShorts","isDesktop","isDark","locale","styles","backgroundColor","chroma","colorPalette","darkGray","alpha","hex","darkWhite","shadowColor","black10","extraCssText","padding","alwaysShowContent","textStyle","fontSize","lineHeight","trigger","formatter","params","getTooltipFormatter","selectedPrice","current","hideDelay","axisPointer","type","axis","lineStyle","color","crossStyle","label","axisDimension","axisIndex","concat","toFixed","confine","position","point","CHART_CONFIG","TOOLTIP_OFFSET","exports"],"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.TOOL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AACiC,MAAM,CAAC3C,KAAK,CAAC;YAC/C,WAAAyD,MAAA,CAAW/C,MAAM,CAACiC,MAAM,CAAC3C,KAAK,CAAC,CAAC0D,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,GAAGC,uBAAY,CAACC,cAAc,EACtCF,KAAK,CAAC,CAAC,CAAC,GAAGC,uBAAY,CAACC,cAAc,CACvC;MACH;MACA,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACf;EAAC;AAEL,CAAC;AAACC,OAAA,CAAArD,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -8,7 +8,8 @@ var _chartUtils = require("../chartUtils");
|
|
|
8
8
|
const getXAxisConfig = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
dates,
|
|
11
|
-
isGreaterThanTwoWeeks
|
|
11
|
+
isGreaterThanTwoWeeks,
|
|
12
|
+
locale
|
|
12
13
|
} = _ref;
|
|
13
14
|
const labelsData = (0, _chartUtils.getLabelData)({
|
|
14
15
|
dates,
|
|
@@ -17,19 +18,25 @@ const getXAxisConfig = _ref => {
|
|
|
17
18
|
return [{
|
|
18
19
|
type: 'category',
|
|
19
20
|
id: 'main-xAxis',
|
|
20
|
-
name: isGreaterThanTwoWeeks ? 'xAxis-greater-than-two-weeks' : 'xAxis-less-than-two-weeks',
|
|
21
21
|
nameTextStyle: {
|
|
22
22
|
fontSize: 0
|
|
23
23
|
},
|
|
24
24
|
axisTick: {
|
|
25
25
|
show: false
|
|
26
26
|
},
|
|
27
|
+
splitLine: {
|
|
28
|
+
lineStyle: {
|
|
29
|
+
opacity: 0.5
|
|
30
|
+
}
|
|
31
|
+
},
|
|
27
32
|
axisLabel: {
|
|
33
|
+
showMaxLabel: false,
|
|
28
34
|
padding: [8, 16, 8, 16],
|
|
29
35
|
margin: 0,
|
|
30
|
-
formatter: value => (0, _chartUtils.formatXAxisLabel)(value, isGreaterThanTwoWeeks)
|
|
36
|
+
formatter: value => (0, _chartUtils.formatXAxisLabel)(value, isGreaterThanTwoWeeks, locale)
|
|
31
37
|
},
|
|
32
|
-
boundaryGap: false
|
|
38
|
+
boundaryGap: false,
|
|
39
|
+
z: 2
|
|
33
40
|
}, {
|
|
34
41
|
type: 'category',
|
|
35
42
|
id: 'additional-xAxis',
|
|
@@ -47,10 +54,11 @@ const getXAxisConfig = _ref => {
|
|
|
47
54
|
margin: 24,
|
|
48
55
|
hideOverlap: true,
|
|
49
56
|
customValues: labelsData,
|
|
50
|
-
formatter: value => (0, _chartUtils.formatXAxisAdditionalLabel)(value, isGreaterThanTwoWeeks)
|
|
57
|
+
formatter: value => (0, _chartUtils.formatXAxisAdditionalLabel)(value, isGreaterThanTwoWeeks, locale)
|
|
51
58
|
},
|
|
52
59
|
data: dates,
|
|
53
|
-
boundaryGap: false
|
|
60
|
+
boundaryGap: false,
|
|
61
|
+
z: 2
|
|
54
62
|
}];
|
|
55
63
|
};
|
|
56
64
|
exports.getXAxisConfig = getXAxisConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getXAxisConfig.js","names":["_chartUtils","require","getXAxisConfig","_ref","dates","isGreaterThanTwoWeeks","labelsData","getLabelData","type","id","
|
|
1
|
+
{"version":3,"file":"getXAxisConfig.js","names":["_chartUtils","require","getXAxisConfig","_ref","dates","isGreaterThanTwoWeeks","locale","labelsData","getLabelData","type","id","nameTextStyle","fontSize","axisTick","show","splitLine","lineStyle","opacity","axisLabel","showMaxLabel","padding","margin","formatter","value","formatXAxisLabel","boundaryGap","z","gridIndex","axisLine","hideOverlap","customValues","formatXAxisAdditionalLabel","data","exports"],"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, isGreaterThanTwoWeeks, locale),\n },\n data: dates,\n boundaryGap: false,\n z: 2,\n },\n ];\n};\n"],"mappings":";;;;;;AAEA,IAAAA,WAAA,GAAAC,OAAA;AAYO,MAAMC,cAAc,GAAGC,IAAA,IAIsB;EAAA,IAJrB;IAC7BC,KAAK;IACLC,qBAAqB;IACrBC;EACoB,CAAC,GAAAH,IAAA;EACrB,MAAMI,UAAU,GAAG,IAAAC,wBAAY,EAAC;IAC9BJ,KAAK;IACLC;EACF,CAAC,CAAC;EAEF,OAAO,CACL;IACEI,IAAI,EAAE,UAAU;IAChBC,EAAE,EAAE,YAAY;IAChBC,aAAa,EAAE;MACbC,QAAQ,EAAE;IACZ,CAAC;IACDC,QAAQ,EAAE;MACRC,IAAI,EAAE;IACR,CAAC;IACDC,SAAS,EAAE;MACTC,SAAS,EAAE;QACTC,OAAO,EAAE;MACX;IACF,CAAC;IACDC,SAAS,EAAE;MACTC,YAAY,EAAE,KAAK;MACnBC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;MACvBC,MAAM,EAAE,CAAC;MACTC,SAAS,EAAGC,KAAc,IACxB,IAAAC,4BAAgB,EAACD,KAAK,EAAElB,qBAAqB,EAAEC,MAAM;IACzD,CAAC;IACDmB,WAAW,EAAE,KAAK;IAClBC,CAAC,EAAE;EACL,CAAC,EACD;IACEjB,IAAI,EAAE,UAAU;IAChBC,EAAE,EAAE,kBAAkB;IACtBiB,SAAS,EAAE,CAAC;IACZd,QAAQ,EAAE;MACRC,IAAI,EAAE;IACR,CAAC;IACDc,QAAQ,EAAE;MACRd,IAAI,EAAE;IACR,CAAC;IACDC,SAAS,EAAE;MACTD,IAAI,EAAE;IACR,CAAC;IACDI,SAAS,EAAE;MACTG,MAAM,EAAE,EAAE;MACVQ,WAAW,EAAE,IAAI;MACjBC,YAAY,EAAEvB,UAAU;MACxBe,SAAS,EAAGC,KAAc,IACxB,IAAAQ,sCAA0B,EAACR,KAAK,EAAElB,qBAAqB,EAAEC,MAAM;IACnE,CAAC;IACD0B,IAAI,EAAE5B,KAAK;IACXqB,WAAW,EAAE,KAAK;IAClBC,CAAC,EAAE;EACL,CAAC,CACF;AACH,CAAC;AAACO,OAAA,CAAA/B,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -8,14 +8,21 @@ var _constants = require("../../../constants");
|
|
|
8
8
|
const getYAxisConfig = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
bucketWidth,
|
|
11
|
-
displayPrecision
|
|
11
|
+
displayPrecision,
|
|
12
|
+
isDesktop
|
|
12
13
|
} = _ref;
|
|
13
14
|
return [{
|
|
14
15
|
type: 'value',
|
|
15
16
|
gridIndex: 0,
|
|
16
17
|
position: 'right',
|
|
17
|
-
min: val =>
|
|
18
|
-
|
|
18
|
+
min: val => {
|
|
19
|
+
const adjustedMin = val.min - bucketWidth;
|
|
20
|
+
return Math.floor(adjustedMin / bucketWidth) * bucketWidth;
|
|
21
|
+
},
|
|
22
|
+
max: val => {
|
|
23
|
+
const adjustedMax = val.max + bucketWidth;
|
|
24
|
+
return Math.ceil(adjustedMax / bucketWidth) * bucketWidth;
|
|
25
|
+
},
|
|
19
26
|
axisLine: {
|
|
20
27
|
show: false
|
|
21
28
|
},
|
|
@@ -55,7 +62,7 @@ const getYAxisConfig = _ref => {
|
|
|
55
62
|
margin: 4,
|
|
56
63
|
lineHeight: 20,
|
|
57
64
|
verticalAlignMinLabel: 'bottom',
|
|
58
|
-
verticalAlignMaxLabel: 'middle',
|
|
65
|
+
verticalAlignMaxLabel: isDesktop ? 'middle' : 'top',
|
|
59
66
|
customValues: [_constants.CHART_CONFIG.SENTIMENT_MIN, _constants.CHART_CONFIG.SENTIMENT_MAX / 5, _constants.CHART_CONFIG.SENTIMENT_MAX / 2, _constants.CHART_CONFIG.SENTIMENT_MAX * 4 / 5, _constants.CHART_CONFIG.SENTIMENT_MAX],
|
|
60
67
|
formatter: value => "".concat(value, "%")
|
|
61
68
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getYAxisConfig.js","names":["_constants","require","getYAxisConfig","_ref","bucketWidth","displayPrecision","type","gridIndex","position","min","val","
|
|
1
|
+
{"version":3,"file":"getYAxisConfig.js","names":["_constants","require","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","CHART_CONFIG","SENTIMENT_MIN","SENTIMENT_MAX","axisPointer","customValues","concat","exports"],"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_MAX * 4) / 5,\n CHART_CONFIG.SENTIMENT_MAX,\n ],\n formatter: (value: number) => `${value}%`,\n },\n z: 30,\n },\n];\n"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAQO,MAAMC,cAAc,GAAGC,IAAA;EAAA,IAAC;IAC7BC,WAAW;IACXC,gBAAgB;IAChBC;EACoB,CAAC,GAAAH,IAAA;EAAA,OAA6B,CAClD;IACEI,IAAI,EAAE,O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U,EAAE,EAAE;MACdE,qBAAqB,EAAE,QAAQ;MAC/BC,qBAAqB,EAAEpB,SAAS,GAAG,QAAQ,GAAG,KAAK;MACnD6B,YAAY,EAAE,CACZJ,uBAAY,CAACC,aAAa,EAC1BD,uBAAY,CAACE,aAAa,GAAG,CAAC,EAC9BF,uBAAY,CAACE,aAAa,GAAG,CAAC,EAC7BF,uBAAY,CAACE,aAAa,GAAG,CAAC,GAAI,CAAC,EACpCF,uBAAY,CAACE,aAAa,CAC3B;MACDN,SAAS,EAAGC,KAAa,OAAAQ,MAAA,CAAQR,KAAK;IACxC,CAAC;IACDE,CAAC,EAAE;EACL,CAAC,CACF;AAAA;AAACO,OAAA,CAAAnC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.formatXAxisAdditionalLabel = void 0;
|
|
7
|
-
const formatXAxisAdditionalLabel = (value, isGreaterThanTwoWeeks) => {
|
|
7
|
+
const formatXAxisAdditionalLabel = (value, isGreaterThanTwoWeeks, locale) => {
|
|
8
8
|
const date = new Date(value);
|
|
9
9
|
if (isNaN(date.getTime())) {
|
|
10
10
|
return '';
|
|
11
11
|
}
|
|
12
|
-
return "".concat(date.toLocaleDateString(
|
|
12
|
+
return "".concat(date.toLocaleDateString(locale, {
|
|
13
13
|
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
14
14
|
day: isGreaterThanTwoWeeks ? 'numeric' : undefined
|
|
15
15
|
}));
|
package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatXAxisAdditionalLabel.js","names":["formatXAxisAdditionalLabel","value","isGreaterThanTwoWeeks","date","Date","isNaN","getTime","concat","toLocaleDateString","
|
|
1
|
+
{"version":3,"file":"formatXAxisAdditionalLabel.js","names":["formatXAxisAdditionalLabel","value","isGreaterThanTwoWeeks","locale","date","Date","isNaN","getTime","concat","toLocaleDateString","month","day","undefined","exports"],"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":";;;;;;AAAO,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;AAACC,OAAA,CAAAb,0BAAA,GAAAA,0BAAA","ignoreList":[]}
|
|
@@ -5,12 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.formatXAxisLabel = void 0;
|
|
7
7
|
var _constants = require("../../../constants");
|
|
8
|
-
const formatXAxisLabel = (value, isGreaterThanTwoWeeks) => {
|
|
8
|
+
const formatXAxisLabel = (value, isGreaterThanTwoWeeks, locale) => {
|
|
9
9
|
const date = new Date(value);
|
|
10
|
-
return isGreaterThanTwoWeeks ? "".concat(date.toLocaleTimeString(
|
|
11
|
-
hour: '
|
|
12
|
-
minute: '2-digit'
|
|
13
|
-
|
|
10
|
+
return isGreaterThanTwoWeeks ? "".concat(date.toLocaleTimeString(locale, {
|
|
11
|
+
hour: 'numeric',
|
|
12
|
+
minute: '2-digit',
|
|
13
|
+
hour12: false
|
|
14
|
+
})) : "".concat(_constants.CHART_CONFIG.X_AXIS_DATE_PADDING).concat(date.toLocaleDateString(locale, {
|
|
14
15
|
day: 'numeric'
|
|
15
16
|
})).concat(_constants.CHART_CONFIG.X_AXIS_DATE_PADDING);
|
|
16
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatXAxisLabel.js","names":["_constants","require","formatXAxisLabel","value","isGreaterThanTwoWeeks","date","Date","concat","toLocaleTimeString","
|
|
1
|
+
{"version":3,"file":"formatXAxisLabel.js","names":["_constants","require","formatXAxisLabel","value","isGreaterThanTwoWeeks","locale","date","Date","concat","toLocaleTimeString","hour","minute","hour12","CHART_CONFIG","X_AXIS_DATE_PADDING","toLocaleDateString","day","exports"],"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,IAAAA,UAAA,GAAAC,OAAA;AAEO,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,CACCK,uBAAY,CAACC,mBAAmB,EAAAN,MAAA,CAAGF,IAAI,CAACS,kBAAkB,CAACV,MAAM,EAAE;IACpEW,GAAG,EAAE;EACP,CAAC,CAAC,EAAAR,MAAA,CAAGK,uBAAY,CAACC,mBAAmB,CAAE;AAC7C,CAAC;AAACG,OAAA,CAAAf,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -4,16 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getTooltipFormatter = void 0;
|
|
7
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
7
8
|
var _graphql = require("../../../../gql/types/graphql");
|
|
8
9
|
const DATE_FORMAT_OPTIONS = {
|
|
9
|
-
hour: '2-digit',
|
|
10
|
-
minute: '2-digit',
|
|
11
|
-
year: 'numeric',
|
|
12
10
|
day: 'numeric',
|
|
13
11
|
month: 'numeric',
|
|
14
|
-
|
|
12
|
+
year: 'numeric',
|
|
13
|
+
hour: 'numeric',
|
|
14
|
+
minute: '2-digit',
|
|
15
|
+
hour12: false,
|
|
16
|
+
timeZoneName: 'shortOffset'
|
|
15
17
|
};
|
|
16
18
|
const SENTIMENT_DISPLAY_PRECISION = 2;
|
|
19
|
+
const TOOLTIP_STYLES = {
|
|
20
|
+
MOBILE_COLUMN_WIDTH: '33.3%',
|
|
21
|
+
PADDING_BOTTOM: '4px',
|
|
22
|
+
FULL_WIDTH: '100%'
|
|
23
|
+
};
|
|
17
24
|
const calculateBucketDisplayPrecision = bucketWidth => {
|
|
18
25
|
var _bucketWidth$toString;
|
|
19
26
|
return ((_bucketWidth$toString = bucketWidth.toString().split('.')[1]) === null || _bucketWidth$toString === void 0 ? void 0 : _bucketWidth$toString.length) || 0;
|
|
@@ -37,7 +44,12 @@ const getSentimentOverbalanceLabel = (sentiment, bookType) => {
|
|
|
37
44
|
};
|
|
38
45
|
const formatCandleData = (candleData, labelCallback) => {
|
|
39
46
|
const [, open, close, low, high] = candleData;
|
|
40
|
-
|
|
47
|
+
const candleLabel = labelCallback('candle');
|
|
48
|
+
const openLabel = labelCallback('open');
|
|
49
|
+
const closeLabel = labelCallback('close');
|
|
50
|
+
const lowLabel = labelCallback('low');
|
|
51
|
+
const highLabel = labelCallback('high');
|
|
52
|
+
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");
|
|
41
53
|
};
|
|
42
54
|
const formatBookData = _ref => {
|
|
43
55
|
let {
|
|
@@ -45,17 +57,18 @@ const formatBookData = _ref => {
|
|
|
45
57
|
bucketWidth,
|
|
46
58
|
bucketDisplayPrecision,
|
|
47
59
|
bookType,
|
|
48
|
-
labelCallback
|
|
60
|
+
labelCallback,
|
|
61
|
+
isDesktop
|
|
49
62
|
} = _ref;
|
|
50
|
-
const bookLabelKey = bookType === _graphql.BookType.Order ? 'orders' : '
|
|
63
|
+
const bookLabelKey = bookType === _graphql.BookType.Order ? 'orders' : 'trades';
|
|
51
64
|
const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);
|
|
52
65
|
const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(bucketDisplayPrecision);
|
|
53
66
|
const sentimentLabel = getSentimentOverbalanceLabel(matchedBucket.sentiment, bookType);
|
|
54
|
-
const sentimentValue = Math.abs(matchedBucket.sentiment)
|
|
55
|
-
return "<
|
|
67
|
+
const sentimentValue = Math.abs(matchedBucket.sentiment);
|
|
68
|
+
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>");
|
|
56
69
|
};
|
|
57
70
|
const formatSentimentData = (sentimentLong, sentimentShort, labelCallback) => {
|
|
58
|
-
return "<
|
|
71
|
+
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>");
|
|
59
72
|
};
|
|
60
73
|
const hasValidCandleData = candleData => !!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[4];
|
|
61
74
|
const hasValidSentimentData = (sentimentLong, sentimentShort) => sentimentLong !== null && sentimentShort !== null;
|
|
@@ -80,7 +93,10 @@ const getTooltipFormatter = _ref3 => {
|
|
|
80
93
|
bookType,
|
|
81
94
|
labelCallback,
|
|
82
95
|
sentimentLongs,
|
|
83
|
-
sentimentShorts
|
|
96
|
+
sentimentShorts,
|
|
97
|
+
isDesktop,
|
|
98
|
+
locale,
|
|
99
|
+
isDark
|
|
84
100
|
} = _ref3;
|
|
85
101
|
if (!params || !Array.isArray(params) || params.length === 0) {
|
|
86
102
|
return '';
|
|
@@ -104,17 +120,59 @@ const getTooltipFormatter = _ref3 => {
|
|
|
104
120
|
if (!showCandles && !matchedBucket) {
|
|
105
121
|
return '';
|
|
106
122
|
}
|
|
107
|
-
const timeFormatted = time.toLocaleString(
|
|
123
|
+
const timeFormatted = time.toLocaleString(locale, DATE_FORMAT_OPTIONS).replace(/\//g, '.');
|
|
108
124
|
const candleSection = showCandles ? formatCandleData(candleData, labelCallback) : '';
|
|
109
125
|
const bookSection = matchedBucket ? formatBookData({
|
|
110
126
|
matchedBucket,
|
|
111
127
|
bucketWidth,
|
|
112
128
|
bucketDisplayPrecision,
|
|
113
129
|
bookType,
|
|
114
|
-
labelCallback
|
|
130
|
+
labelCallback,
|
|
131
|
+
isDesktop
|
|
115
132
|
}) : '';
|
|
116
133
|
const sentimentSection = showSentiment && sentimentLong && sentimentShort ? formatSentimentData(sentimentLong, sentimentShort, labelCallback) : '';
|
|
117
|
-
|
|
134
|
+
if (isDesktop) {
|
|
135
|
+
return buildDesktopTooltip({
|
|
136
|
+
timeFormatted,
|
|
137
|
+
candleSection,
|
|
138
|
+
sentimentSection,
|
|
139
|
+
bookSection,
|
|
140
|
+
hasMatchedBucket: !!matchedBucket
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return buildMobileTooltip({
|
|
144
|
+
timeFormatted,
|
|
145
|
+
candleSection,
|
|
146
|
+
sentimentSection,
|
|
147
|
+
bookSection,
|
|
148
|
+
isDark
|
|
149
|
+
});
|
|
118
150
|
};
|
|
119
151
|
exports.getTooltipFormatter = getTooltipFormatter;
|
|
152
|
+
const buildDesktopTooltip = _ref4 => {
|
|
153
|
+
let {
|
|
154
|
+
timeFormatted,
|
|
155
|
+
candleSection,
|
|
156
|
+
sentimentSection,
|
|
157
|
+
bookSection,
|
|
158
|
+
hasMatchedBucket
|
|
159
|
+
} = _ref4;
|
|
160
|
+
const padding = TOOLTIP_STYLES.PADDING_BOTTOM;
|
|
161
|
+
const sentimentPadding = hasMatchedBucket ? padding : '0px';
|
|
162
|
+
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");
|
|
163
|
+
};
|
|
164
|
+
const buildMobileTooltip = _ref5 => {
|
|
165
|
+
let {
|
|
166
|
+
timeFormatted,
|
|
167
|
+
candleSection,
|
|
168
|
+
sentimentSection,
|
|
169
|
+
bookSection,
|
|
170
|
+
isDark
|
|
171
|
+
} = _ref5;
|
|
172
|
+
const backgroundColor = isDark ? _labsWidgetCommon.colorPalette.black : _labsWidgetCommon.colorPalette.white;
|
|
173
|
+
const columnWidth = TOOLTIP_STYLES.MOBILE_COLUMN_WIDTH;
|
|
174
|
+
const fullWidth = TOOLTIP_STYLES.FULL_WIDTH;
|
|
175
|
+
const padding = TOOLTIP_STYLES.PADDING_BOTTOM;
|
|
176
|
+
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>");
|
|
177
|
+
};
|
|
120
178
|
//# sourceMappingURL=getTooltipFormatter.js.map
|