@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,51 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
interface UseResizeObserverOptions {
|
|
4
|
+
debounceDelay?: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const useResizeObserver = (
|
|
8
|
+
options: UseResizeObserverOptions = {}
|
|
9
|
+
): [React.RefObject<HTMLDivElement>, boolean] => {
|
|
10
|
+
const { debounceDelay = 150 } = options;
|
|
11
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
12
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
13
|
+
const resizeTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const container = containerRef.current;
|
|
17
|
+
if (!container) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
22
|
+
console.warn('ResizeObserver is not supported in this browser');
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
27
|
+
setIsResizing(true);
|
|
28
|
+
|
|
29
|
+
if (resizeTimeoutRef.current) {
|
|
30
|
+
clearTimeout(resizeTimeoutRef.current);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
resizeTimeoutRef.current = setTimeout(() => {
|
|
34
|
+
setIsResizing(false);
|
|
35
|
+
resizeTimeoutRef.current = null;
|
|
36
|
+
}, debounceDelay);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
resizeObserver.observe(container);
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
resizeObserver.disconnect();
|
|
43
|
+
if (resizeTimeoutRef.current) {
|
|
44
|
+
clearTimeout(resizeTimeoutRef.current);
|
|
45
|
+
resizeTimeoutRef.current = null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, [debounceDelay]);
|
|
49
|
+
|
|
50
|
+
return [containerRef, isResizing];
|
|
51
|
+
};
|
|
@@ -17,7 +17,7 @@ export const Legend = ({ bookType }: LegendProps) => {
|
|
|
17
17
|
<div className="lw-my-4 lw-w-full">
|
|
18
18
|
<div className="lw-mb-1 lw-flex lw-w-full lw-flex-row lw-justify-between">
|
|
19
19
|
<LegendBar isDark={isDark} type="long" />
|
|
20
|
-
<div className="lw-w-[
|
|
20
|
+
<div className="lw-w-[200px]" />
|
|
21
21
|
<LegendBar isDark={isDark} type="short" />
|
|
22
22
|
</div>
|
|
23
23
|
<div className="lw-flex lw-w-full lw-flex-row lw-justify-between lw-pb-2 lw-font-sans lw-text-xs lw-text-text-primary">
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cn } from '@oanda/labs-widget-common';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
|
|
3
4
|
import { COLOR_MAP } from '../../constants';
|
|
@@ -11,13 +12,22 @@ interface LegendBarProps {
|
|
|
11
12
|
|
|
12
13
|
export const LegendBar = ({ type, isDark }: LegendBarProps) => {
|
|
13
14
|
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
15
|
+
|
|
14
16
|
const startColor =
|
|
15
17
|
type === 'long' ? colorPalette.long[1] : colorPalette.short[0];
|
|
16
18
|
const endColor =
|
|
17
19
|
type === 'long' ? colorPalette.long[0] : colorPalette.short[1];
|
|
20
|
+
const endGradient =
|
|
21
|
+
type === 'long'
|
|
22
|
+
? `linear-gradient(90deg,${endColor} 0%, ${colorPalette.backgroundColor} 100%)`
|
|
23
|
+
: `linear-gradient(270deg,${startColor} 0%, ${colorPalette.backgroundColor} 100%)`;
|
|
18
24
|
|
|
19
25
|
return (
|
|
20
|
-
<div
|
|
26
|
+
<div
|
|
27
|
+
className={cn('lw-flex lw-h-2 lw-w-full lw-overflow-hidden', {
|
|
28
|
+
'lw-flex-row-reverse': type === 'short',
|
|
29
|
+
})}
|
|
30
|
+
>
|
|
21
31
|
<div
|
|
22
32
|
className="lw-h-full lw-flex-1"
|
|
23
33
|
data-testid="legend-bar-segment"
|
|
@@ -25,6 +35,13 @@ export const LegendBar = ({ type, isDark }: LegendBarProps) => {
|
|
|
25
35
|
background: `linear-gradient(90deg,${startColor} 0%, ${endColor} 100%)`,
|
|
26
36
|
}}
|
|
27
37
|
/>
|
|
38
|
+
<div
|
|
39
|
+
className="lw-h-full lw-w-[10px]"
|
|
40
|
+
data-testid="legend-bar-segment"
|
|
41
|
+
style={{
|
|
42
|
+
background: endGradient,
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
28
45
|
</div>
|
|
29
46
|
);
|
|
30
47
|
};
|
|
@@ -4,7 +4,10 @@ import chroma from 'chroma-js';
|
|
|
4
4
|
import { InstrumentId } from './types';
|
|
5
5
|
|
|
6
6
|
export const BUCKET_CONFIG = {
|
|
7
|
-
|
|
7
|
+
MULTIPLIER_5M: 1,
|
|
8
|
+
MULTIPLIER_15M: 1,
|
|
9
|
+
MULTIPLIER_1H: 2,
|
|
10
|
+
MULTIPLIER_4H: 4,
|
|
8
11
|
PRICE_MARGIN_MULTIPLIER: 2,
|
|
9
12
|
} as const;
|
|
10
13
|
|
|
@@ -12,21 +15,43 @@ export const TIME_THRESHOLDS = {
|
|
|
12
15
|
TWO_WEEKS_MS: 14 * 24 * 60 * 60 * 1000,
|
|
13
16
|
} as const;
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const CHART_CONFIG_STATIC = {
|
|
19
|
+
MAIN_HEIGHT_DESKTOP: 410,
|
|
20
|
+
MAIN_HEIGHT_MOBILE: 330,
|
|
18
21
|
MARGIN_BETWEEN: 50,
|
|
19
22
|
SENTIMENT_HEIGHT: 120,
|
|
20
23
|
WIDTH: 9999,
|
|
21
24
|
X_LABEL_SIZE: 40,
|
|
22
|
-
Y_LABEL_SIZE_DESKTOP:
|
|
25
|
+
Y_LABEL_SIZE_DESKTOP: 50,
|
|
23
26
|
Y_LABEL_SIZE_MOBILE: 40,
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
Y_SENTIMENT_LABEL_DESKTOP_SIZE: 40,
|
|
28
|
+
Y_SENTIMENT_LABEL_MOBILE_SIZE: 30,
|
|
29
|
+
INITIAL_START_ZOOM_DESKTOP: 70,
|
|
30
|
+
INITIAL_START_ZOOM_MOBILE: 85,
|
|
26
31
|
INITIAL_END_ZOOM: 100,
|
|
27
32
|
X_AXIS_DATE_PADDING: ' ',
|
|
28
33
|
SENTIMENT_MIN: 0,
|
|
29
34
|
SENTIMENT_MAX: 100,
|
|
35
|
+
TOP_MARGIN_DESKTOP: 0,
|
|
36
|
+
TOP_MARGIN_MOBILE: 24,
|
|
37
|
+
MOBILE_TOOLTIP_HEIGHT: 85,
|
|
38
|
+
TOOLTIP_OFFSET: 8,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const CHART_CONFIG_CALCULATED = {
|
|
42
|
+
HEIGHT_DESKTOP:
|
|
43
|
+
CHART_CONFIG_STATIC.MAIN_HEIGHT_DESKTOP +
|
|
44
|
+
CHART_CONFIG_STATIC.TOP_MARGIN_DESKTOP +
|
|
45
|
+
CHART_CONFIG_STATIC.X_LABEL_SIZE,
|
|
46
|
+
HEIGHT_MOBILE:
|
|
47
|
+
CHART_CONFIG_STATIC.MAIN_HEIGHT_MOBILE +
|
|
48
|
+
CHART_CONFIG_STATIC.X_LABEL_SIZE +
|
|
49
|
+
CHART_CONFIG_STATIC.TOP_MARGIN_MOBILE +
|
|
50
|
+
CHART_CONFIG_STATIC.MOBILE_TOOLTIP_HEIGHT,
|
|
51
|
+
};
|
|
52
|
+
export const CHART_CONFIG = {
|
|
53
|
+
...CHART_CONFIG_STATIC,
|
|
54
|
+
...CHART_CONFIG_CALCULATED,
|
|
30
55
|
} as const;
|
|
31
56
|
|
|
32
57
|
export const COLOR_MAP = {
|
|
@@ -39,6 +64,7 @@ export const COLOR_MAP = {
|
|
|
39
64
|
chroma(colorPalette.darkYellow10).shade(0.5).hex(),
|
|
40
65
|
chroma(colorPalette.darkYellow90).shade(0.5).hex(),
|
|
41
66
|
],
|
|
67
|
+
backgroundColor: colorPalette.black,
|
|
42
68
|
},
|
|
43
69
|
light: {
|
|
44
70
|
long: [
|
|
@@ -49,6 +75,7 @@ export const COLOR_MAP = {
|
|
|
49
75
|
chroma(colorPalette.lightYellow10).tint(0.5).hex(),
|
|
50
76
|
chroma(colorPalette.lightYellow90).tint(0.5).hex(),
|
|
51
77
|
],
|
|
78
|
+
backgroundColor: colorPalette.white,
|
|
52
79
|
},
|
|
53
80
|
} as const;
|
|
54
81
|
|
|
@@ -13,6 +13,10 @@ const navigationConfig = [
|
|
|
13
13
|
];
|
|
14
14
|
|
|
15
15
|
const instrumentSelectConfigOC = [
|
|
16
|
+
{
|
|
17
|
+
id: InstrumentId.EUR_USD,
|
|
18
|
+
label: 'EUR/USD',
|
|
19
|
+
},
|
|
16
20
|
{
|
|
17
21
|
id: InstrumentId.EUR_AUD,
|
|
18
22
|
label: 'EUR/AUD',
|
|
@@ -25,10 +29,6 @@ const instrumentSelectConfigOC = [
|
|
|
25
29
|
id: InstrumentId.EUR_JPY,
|
|
26
30
|
label: 'EUR/JPY',
|
|
27
31
|
},
|
|
28
|
-
{
|
|
29
|
-
id: InstrumentId.EUR_USD,
|
|
30
|
-
label: 'EUR/USD',
|
|
31
|
-
},
|
|
32
32
|
{
|
|
33
33
|
id: InstrumentId.EUR_CHF,
|
|
34
34
|
label: 'EUR/CHF',
|
|
@@ -92,14 +92,6 @@ const granularitySelectConfig = [
|
|
|
92
92
|
id: Granularity.H4,
|
|
93
93
|
label: '4_hours',
|
|
94
94
|
},
|
|
95
|
-
{
|
|
96
|
-
id: Granularity.M5,
|
|
97
|
-
label: '5_minutes',
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
id: Granularity.M15,
|
|
101
|
-
label: '15_minutes',
|
|
102
|
-
},
|
|
103
95
|
];
|
|
104
96
|
|
|
105
97
|
export {
|
|
@@ -3,30 +3,32 @@
|
|
|
3
3
|
"15_minutes": "15 minutes",
|
|
4
4
|
"4_hours": "4 hours",
|
|
5
5
|
"5_minutes": "5 minutes",
|
|
6
|
-
"buy_overbalance": "Buy overbalance",
|
|
7
6
|
"buy": "Buy",
|
|
7
|
+
"buy_overbalance": "Buy overbalance",
|
|
8
8
|
"candle": "Candle",
|
|
9
|
-
"
|
|
9
|
+
"close": "Close",
|
|
10
10
|
"data_unavailable": "Data unavailable",
|
|
11
|
+
"even_market_demand": "Even market demand",
|
|
11
12
|
"granularity": "Granularity",
|
|
12
13
|
"high": "High",
|
|
13
14
|
"instrument": "Instrument",
|
|
14
|
-
"long_overbalance": "Long overbalance",
|
|
15
15
|
"long": "Long",
|
|
16
|
+
"long_overbalance": "Long overbalance",
|
|
16
17
|
"low": "Low",
|
|
17
18
|
"no_matching_results": "No matching results",
|
|
18
|
-
"
|
|
19
|
+
"open": "Open",
|
|
19
20
|
"order_book": "Order book",
|
|
20
21
|
"orders": "Orders",
|
|
21
22
|
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
|
|
22
23
|
"position_book": "Position book",
|
|
23
|
-
"
|
|
24
|
+
"price": "Price",
|
|
24
25
|
"price_range": "Price range",
|
|
25
26
|
"search": "Search",
|
|
26
|
-
"sell_overbalance": "Sell overbalance",
|
|
27
27
|
"sell": "Sell",
|
|
28
|
+
"sell_overbalance": "Sell overbalance",
|
|
28
29
|
"sentiment": "Sentiment",
|
|
29
|
-
"short_overbalance": "Short overbalance",
|
|
30
30
|
"short": "Short",
|
|
31
|
-
"
|
|
31
|
+
"short_overbalance": "Short overbalance",
|
|
32
|
+
"tap_chart_to_see_more_details": "Tap chart to see more details",
|
|
33
|
+
"trades": "Trades"
|
|
32
34
|
}
|
|
@@ -110,13 +110,13 @@ describe('chartUtils', () => {
|
|
|
110
110
|
const sampleIso = '2025-03-15T10:30:00Z';
|
|
111
111
|
|
|
112
112
|
it('formats time when flag is true', () => {
|
|
113
|
-
const result = formatXAxisLabel(sampleIso, true);
|
|
113
|
+
const result = formatXAxisLabel(sampleIso, true, 'en-US');
|
|
114
114
|
expect(typeof result).toBe('string');
|
|
115
115
|
expect(result).toContain(':');
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
it('formats day when flag is false', () => {
|
|
119
|
-
const result = formatXAxisLabel(sampleIso, false);
|
|
119
|
+
const result = formatXAxisLabel(sampleIso, false, 'en-US');
|
|
120
120
|
expect(typeof result).toBe('string');
|
|
121
121
|
// Contains day of month (15) with surrounding spaces per implementation
|
|
122
122
|
expect(result).toMatch(/\s15\s/);
|
|
@@ -138,7 +138,7 @@ describe('chartUtils', () => {
|
|
|
138
138
|
});
|
|
139
139
|
// First change happens between 1st and 2nd
|
|
140
140
|
expect(labels.length).toBeGreaterThanOrEqual(2);
|
|
141
|
-
expect(labels[0]).
|
|
141
|
+
expect(labels[0]).toBe('2025-03-02T00:00:00Z');
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
it('emits label when month changes for >= two weeks case', () => {
|
|
@@ -152,7 +152,7 @@ describe('chartUtils', () => {
|
|
|
152
152
|
isGreaterThanTwoWeeks: false,
|
|
153
153
|
});
|
|
154
154
|
expect(labels.length).toBe(1);
|
|
155
|
-
expect(labels[0]).
|
|
155
|
+
expect(labels[0]).toBe('2025-02-01T00:00:00Z');
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
|
|
@@ -165,6 +165,7 @@ describe('chartUtils', () => {
|
|
|
165
165
|
seriesId: 'candlestick' as const,
|
|
166
166
|
axisValue: '2025-03-15T10:30:00Z',
|
|
167
167
|
value: [0, 1.11111, 1.22222, 1.00001, 1.33333],
|
|
168
|
+
dataIndex: 0,
|
|
168
169
|
},
|
|
169
170
|
{
|
|
170
171
|
seriesId: 'heatmap' as const,
|
|
@@ -186,11 +187,16 @@ describe('chartUtils', () => {
|
|
|
186
187
|
selectedPrice: 1.3306,
|
|
187
188
|
bookType: BookType.Order,
|
|
188
189
|
labelCallback,
|
|
190
|
+
sentimentLongs: [],
|
|
191
|
+
sentimentShorts: [],
|
|
192
|
+
isDesktop: true,
|
|
193
|
+
locale: 'en-US',
|
|
194
|
+
isDark: false,
|
|
189
195
|
});
|
|
190
196
|
expect(html).toBeDefined();
|
|
191
197
|
expect(html).toContain('candle');
|
|
192
|
-
expect(html).toContain('
|
|
193
|
-
expect(html).toContain('
|
|
198
|
+
expect(html).toContain('open');
|
|
199
|
+
expect(html).toContain('close');
|
|
194
200
|
expect(html).toContain('low');
|
|
195
201
|
expect(html).toContain('high');
|
|
196
202
|
expect(html).toContain('orders');
|
|
@@ -205,6 +211,7 @@ describe('chartUtils', () => {
|
|
|
205
211
|
seriesId: 'candlestick' as const,
|
|
206
212
|
axisValue: '2025-03-15T10:30:00Z',
|
|
207
213
|
value: [0, 1.11111, 1.22222, 1.00001, 1.33333],
|
|
214
|
+
dataIndex: 0,
|
|
208
215
|
},
|
|
209
216
|
{
|
|
210
217
|
seriesId: 'sentiment' as const,
|
|
@@ -221,6 +228,11 @@ describe('chartUtils', () => {
|
|
|
221
228
|
selectedPrice: 1.3306,
|
|
222
229
|
bookType: BookType.Order,
|
|
223
230
|
labelCallback,
|
|
231
|
+
sentimentLongs: [30.5],
|
|
232
|
+
sentimentShorts: [69.5],
|
|
233
|
+
isDesktop: true,
|
|
234
|
+
locale: 'en-US',
|
|
235
|
+
isDark: false,
|
|
224
236
|
});
|
|
225
237
|
expect(html).toBeDefined();
|
|
226
238
|
expect(html).toContain('candle');
|
|
@@ -236,6 +248,7 @@ describe('chartUtils', () => {
|
|
|
236
248
|
{
|
|
237
249
|
seriesId: 'heatmap' as const,
|
|
238
250
|
value: ['2025-03-15T10:30:00Z', 1.33333, 0],
|
|
251
|
+
dataIndex: 0,
|
|
239
252
|
},
|
|
240
253
|
];
|
|
241
254
|
|
|
@@ -248,6 +261,11 @@ describe('chartUtils', () => {
|
|
|
248
261
|
selectedPrice: 1.3306,
|
|
249
262
|
bookType: BookType.Order,
|
|
250
263
|
labelCallback,
|
|
264
|
+
sentimentLongs: [],
|
|
265
|
+
sentimentShorts: [],
|
|
266
|
+
isDesktop: true,
|
|
267
|
+
locale: 'en-US',
|
|
268
|
+
isDark: false,
|
|
251
269
|
});
|
|
252
270
|
expect(html).toBe('');
|
|
253
271
|
});
|
|
@@ -260,6 +278,11 @@ describe('chartUtils', () => {
|
|
|
260
278
|
selectedPrice: 1.3306,
|
|
261
279
|
bookType: BookType.Order,
|
|
262
280
|
labelCallback,
|
|
281
|
+
sentimentLongs: [],
|
|
282
|
+
sentimentShorts: [],
|
|
283
|
+
isDesktop: true,
|
|
284
|
+
locale: 'en-US',
|
|
285
|
+
isDark: false,
|
|
263
286
|
});
|
|
264
287
|
expect(html).toBe('');
|
|
265
288
|
});
|