@oanda/labs-crowd-view-widget 1.0.53 → 1.0.54
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 +220 -0
- package/dist/main/CrowdViewWidget/Main.js +4 -2
- package/dist/main/CrowdViewWidget/Main.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +5 -28
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +3 -10
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +30 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +5 -52
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +54 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +65 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +60 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +53 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +31 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +42 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +75 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +116 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +14 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +42 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +14 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +108 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +83 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +15 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
- package/dist/main/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.js +8 -8
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js +103 -0
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/index.js +11 -11
- package/dist/main/CrowdViewWidget/components/Chart/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +9 -9
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js +15 -12
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +11 -13
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/translations/sources/en.json +2 -1
- package/dist/module/CrowdViewWidget/Main.js +4 -2
- package/dist/module/CrowdViewWidget/Main.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +6 -29
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +3 -10
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +23 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +5 -52
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +46 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +58 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +53 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +46 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +24 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +35 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +68 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +6 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +35 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +7 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +101 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +8 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +8 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
- package/dist/module/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.js +2 -2
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js +96 -0
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/index.js +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +2 -2
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js +15 -12
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +9 -12
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/translations/sources/en.json +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridLines.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +9 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +11 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +16 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +9 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +10 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.d.ts +2 -2
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getLabelData.d.ts +17 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getRectColor.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +10 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.d.ts +1 -0
- package/dist/types/CrowdViewWidget/{utils/instrumentUtils.d.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.d.ts} +2 -2
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.d.ts +2 -2
- package/dist/types/CrowdViewWidget/components/Chart/index.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +1 -4
- package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +1 -3
- package/dist/types/CrowdViewWidget/constants.d.ts +3 -7
- package/package.json +3 -3
- package/src/CrowdViewWidget/Main.tsx +3 -2
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +10 -34
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +2 -15
- package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +13 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +29 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +84 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +52 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +82 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +63 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +63 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.ts +32 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +43 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +77 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +10 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +16 -0
- package/src/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.ts +9 -6
- package/src/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.ts +16 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts +42 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getRectColor.ts +27 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +183 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +7 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.ts +13 -0
- package/src/CrowdViewWidget/{utils/instrumentUtils.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.ts} +2 -2
- package/src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.ts +14 -0
- package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.ts +2 -2
- package/src/CrowdViewWidget/components/Chart/getOption.ts +114 -0
- package/src/CrowdViewWidget/components/Chart/index.ts +1 -1
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +3 -3
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +24 -22
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +13 -26
- package/src/CrowdViewWidget/constants.ts +20 -17
- package/src/translations/sources/en.json +2 -1
- package/test/components/Chart/utils/chartUtils.test.ts +7 -7
- package/test/components/Chart/utils/getChartStyles.test.ts +10 -10
- package/test/components/Chart/utils/processSentiments.test.ts +1 -1
- package/test/components/Legend.test.tsx +13 -21
- package/test/components/LegendBar.test.tsx +31 -51
- package/test/utils/instrumentUtils.test.ts +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +0 -399
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -126
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/getGridLines.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
- package/dist/main/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +0 -391
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -113
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/getChartStyles.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/getGridLines.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/validateData.js.map +0 -1
- package/dist/module/CrowdViewWidget/utils/instrumentUtils.js.map +0 -1
- package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +0 -30
- package/dist/types/CrowdViewWidget/components/Chart/utils/getGridLines.d.ts +0 -97
- package/src/CrowdViewWidget/components/Chart/chartOptions.ts +0 -449
- package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +0 -228
- package/src/CrowdViewWidget/components/Chart/utils/getGridLines.ts +0 -148
- /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.js +0 -0
- /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.js +0 -0
- /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.js +0 -0
- /package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +0 -0
- /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.js +0 -0
- /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.js +0 -0
- /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.js +0 -0
- /package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +0 -0
- /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.d.ts +0 -0
- /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.d.ts +0 -0
- /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.d.ts +0 -0
- /package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.d.ts +0 -0
- /package/dist/types/CrowdViewWidget/components/Chart/{chartOptions.d.ts → getOption.d.ts} +0 -0
- /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/processOrderPositionBooks.ts +0 -0
- /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/processPriceCandles.ts +0 -0
- /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/processSentiments.ts +0 -0
- /package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.ts +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
2
|
+
import type { GetLabelsDataProps } from '../types';
|
|
3
|
+
|
|
4
|
+
export const getLabelData = ({
|
|
5
|
+
dates,
|
|
6
|
+
isGreaterThanTwoWeeks,
|
|
7
|
+
}: GetLabelsDataProps) =>
|
|
8
|
+
dates
|
|
9
|
+
.filter((record, index, arr) => {
|
|
10
|
+
if (index === 0) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const previousTimestamp = arr[index - 1];
|
|
14
|
+
const currentDate = new Date(record);
|
|
15
|
+
const previousDate = new Date(previousTimestamp);
|
|
16
|
+
|
|
17
|
+
return isGreaterThanTwoWeeks
|
|
18
|
+
? currentDate.getDate() !== previousDate.getDate()
|
|
19
|
+
: currentDate.getMonth() !== previousDate.getMonth();
|
|
20
|
+
})
|
|
21
|
+
.map(
|
|
22
|
+
(item) =>
|
|
23
|
+
({
|
|
24
|
+
name: new Date(item).toLocaleDateString(undefined, {
|
|
25
|
+
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
26
|
+
day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
|
|
27
|
+
}),
|
|
28
|
+
xAxis: item,
|
|
29
|
+
y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
|
|
30
|
+
silent: true,
|
|
31
|
+
emphasis: {
|
|
32
|
+
disabled: true,
|
|
33
|
+
},
|
|
34
|
+
label: {
|
|
35
|
+
fontFamily: 'Sofia W03',
|
|
36
|
+
fontSize: 10,
|
|
37
|
+
position: 'bottom' as const,
|
|
38
|
+
align: 'center' as const,
|
|
39
|
+
formatter: '{b}',
|
|
40
|
+
},
|
|
41
|
+
}) as const
|
|
42
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { COLOR_MAP } from '../../../constants';
|
|
2
|
+
import { getGradientColor } from './getGradientColor';
|
|
3
|
+
|
|
4
|
+
export const getRectColor = (
|
|
5
|
+
sentiment: number,
|
|
6
|
+
isDark: boolean,
|
|
7
|
+
minThreshold: number,
|
|
8
|
+
maxThreshold: number
|
|
9
|
+
) => {
|
|
10
|
+
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
11
|
+
|
|
12
|
+
return sentiment < 0
|
|
13
|
+
? getGradientColor(
|
|
14
|
+
sentiment * -1,
|
|
15
|
+
colorPalette.short[0],
|
|
16
|
+
colorPalette.short[1],
|
|
17
|
+
minThreshold,
|
|
18
|
+
maxThreshold
|
|
19
|
+
)
|
|
20
|
+
: getGradientColor(
|
|
21
|
+
sentiment,
|
|
22
|
+
colorPalette.long[0],
|
|
23
|
+
colorPalette.long[1],
|
|
24
|
+
minThreshold,
|
|
25
|
+
maxThreshold
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { BookType } from '../../../../gql/types/graphql';
|
|
2
|
+
import type { Bucket, TooltipParam } from '../types';
|
|
3
|
+
|
|
4
|
+
const DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {
|
|
5
|
+
hour: '2-digit',
|
|
6
|
+
minute: '2-digit',
|
|
7
|
+
year: 'numeric',
|
|
8
|
+
day: 'numeric',
|
|
9
|
+
month: 'numeric',
|
|
10
|
+
timeZoneName: 'short',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const SENTIMENT_DISPLAY_PRECISION = 2;
|
|
14
|
+
|
|
15
|
+
const calculateBucketDisplayPrecision = (bucketWidth: number): number => {
|
|
16
|
+
return bucketWidth.toString().split('.')[1]?.length || 0;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const findSeriesParam = <T extends TooltipParam['seriesId']>(
|
|
20
|
+
params: TooltipParam[],
|
|
21
|
+
seriesId: T
|
|
22
|
+
): Extract<TooltipParam, { seriesId: T }> | undefined => {
|
|
23
|
+
return params.find(
|
|
24
|
+
(series): series is Extract<TooltipParam, { seriesId: T }> =>
|
|
25
|
+
series.seriesId === seriesId
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getSentimentOverbalanceLabel = (
|
|
30
|
+
sentiment: number,
|
|
31
|
+
bookType: BookType
|
|
32
|
+
): string => {
|
|
33
|
+
if (sentiment < 0) {
|
|
34
|
+
return bookType === BookType.Order
|
|
35
|
+
? 'sell_overbalance'
|
|
36
|
+
: 'short_overbalance';
|
|
37
|
+
}
|
|
38
|
+
return bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance';
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const formatCandleData = (
|
|
42
|
+
candleData: [number, number, number, number, number],
|
|
43
|
+
labelCallback: (key: string) => string
|
|
44
|
+
): string => {
|
|
45
|
+
const [, open, close, low, high] = candleData;
|
|
46
|
+
return `<p><b>${labelCallback('candle')}:</b></p>
|
|
47
|
+
<p>${labelCallback('open_price')}: ${open} </p>
|
|
48
|
+
<p>${labelCallback('close_price')}: ${close} </p>
|
|
49
|
+
<p>${labelCallback('low')}: ${low} </p>
|
|
50
|
+
<p>${labelCallback('high')}: ${high} </p>
|
|
51
|
+
`;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const formatBookData = ({
|
|
55
|
+
matchedBucket,
|
|
56
|
+
bucketWidth,
|
|
57
|
+
bucketDisplayPrecision,
|
|
58
|
+
bookType,
|
|
59
|
+
labelCallback,
|
|
60
|
+
}: {
|
|
61
|
+
matchedBucket: Bucket;
|
|
62
|
+
bucketWidth: number;
|
|
63
|
+
bucketDisplayPrecision: number;
|
|
64
|
+
bookType: BookType;
|
|
65
|
+
labelCallback: (key: string) => string;
|
|
66
|
+
}): string => {
|
|
67
|
+
const bookLabelKey = bookType === BookType.Order ? 'orders' : 'positions';
|
|
68
|
+
const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);
|
|
69
|
+
const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(
|
|
70
|
+
bucketDisplayPrecision
|
|
71
|
+
);
|
|
72
|
+
const sentimentLabel = getSentimentOverbalanceLabel(
|
|
73
|
+
matchedBucket.sentiment,
|
|
74
|
+
bookType
|
|
75
|
+
);
|
|
76
|
+
const sentimentValue = Math.abs(matchedBucket.sentiment).toFixed(
|
|
77
|
+
bucketDisplayPrecision
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return `<br /><p><b>${labelCallback(bookLabelKey)}:</b></p>
|
|
81
|
+
<p>${labelCallback('price_range')}: ${priceRangeStart} - ${priceRangeEnd} </p>
|
|
82
|
+
<p>${labelCallback(sentimentLabel)}: ${sentimentValue}% </p>`;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const formatSentimentData = (
|
|
86
|
+
sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }>,
|
|
87
|
+
labelCallback: (key: string) => string
|
|
88
|
+
): string => {
|
|
89
|
+
const [, shortPercent, longPercent] = sentimentParam.value;
|
|
90
|
+
return `<br /><p><b>${labelCallback('sentiment')}:</b></p>
|
|
91
|
+
<p>${labelCallback('long')}: ${longPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>
|
|
92
|
+
<p>${labelCallback('short')}: ${shortPercent.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>`;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const hasValidCandleData = (
|
|
96
|
+
candleData: [number, number, number, number, number]
|
|
97
|
+
): boolean =>
|
|
98
|
+
!!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[3];
|
|
99
|
+
const hasValidSentimentData = (
|
|
100
|
+
sentimentParam: Extract<TooltipParam, { seriesId: 'sentiment' }> | undefined
|
|
101
|
+
): boolean => !!sentimentParam?.value[1] && !!sentimentParam?.value[2];
|
|
102
|
+
const findMatchingBucket = (
|
|
103
|
+
buckets: Bucket[][],
|
|
104
|
+
bucketsIndex: number | undefined,
|
|
105
|
+
selectedPrice: number,
|
|
106
|
+
bucketWidth: number
|
|
107
|
+
): Bucket | undefined => {
|
|
108
|
+
if (bucketsIndex === undefined) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
const selectedBuckets = buckets[bucketsIndex];
|
|
112
|
+
return selectedBuckets?.find(
|
|
113
|
+
({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const getTooltipFormatter = ({
|
|
118
|
+
params,
|
|
119
|
+
buckets,
|
|
120
|
+
bucketWidth,
|
|
121
|
+
selectedPrice,
|
|
122
|
+
bookType,
|
|
123
|
+
labelCallback,
|
|
124
|
+
}: {
|
|
125
|
+
params: TooltipParam[];
|
|
126
|
+
buckets: Bucket[][];
|
|
127
|
+
bucketWidth: number;
|
|
128
|
+
selectedPrice: number;
|
|
129
|
+
bookType: BookType;
|
|
130
|
+
labelCallback: (key: string) => string;
|
|
131
|
+
}) => {
|
|
132
|
+
if (!params || !Array.isArray(params) || params.length === 0) {
|
|
133
|
+
return '';
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const candleParam = findSeriesParam(params, 'candlestick');
|
|
137
|
+
const booksParam = findSeriesParam(params, 'heatmap');
|
|
138
|
+
const sentimentParam = findSeriesParam(params, 'sentiment');
|
|
139
|
+
|
|
140
|
+
if (!candleParam) {
|
|
141
|
+
return '';
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const bucketDisplayPrecision = calculateBucketDisplayPrecision(bucketWidth);
|
|
145
|
+
const time = new Date(candleParam.axisValue as string);
|
|
146
|
+
const candleData = candleParam.value;
|
|
147
|
+
const bucketsIndex = booksParam?.value[2];
|
|
148
|
+
const matchedBucket = findMatchingBucket(
|
|
149
|
+
buckets,
|
|
150
|
+
bucketsIndex,
|
|
151
|
+
selectedPrice,
|
|
152
|
+
bucketWidth
|
|
153
|
+
);
|
|
154
|
+
const showCandles = hasValidCandleData(candleData);
|
|
155
|
+
const showSentiment = hasValidSentimentData(sentimentParam);
|
|
156
|
+
|
|
157
|
+
if (!showCandles && !matchedBucket) {
|
|
158
|
+
return '';
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const timeFormatted = time.toLocaleString(undefined, DATE_FORMAT_OPTIONS);
|
|
162
|
+
const candleSection = showCandles
|
|
163
|
+
? formatCandleData(candleData, labelCallback)
|
|
164
|
+
: '';
|
|
165
|
+
const bookSection = matchedBucket
|
|
166
|
+
? formatBookData({
|
|
167
|
+
matchedBucket,
|
|
168
|
+
bucketWidth,
|
|
169
|
+
bucketDisplayPrecision,
|
|
170
|
+
bookType,
|
|
171
|
+
labelCallback,
|
|
172
|
+
})
|
|
173
|
+
: '';
|
|
174
|
+
const sentimentSection =
|
|
175
|
+
showSentiment && sentimentParam
|
|
176
|
+
? formatSentimentData(sentimentParam, labelCallback)
|
|
177
|
+
: '';
|
|
178
|
+
|
|
179
|
+
return `<p>${timeFormatted}</p><br />
|
|
180
|
+
${candleSection}
|
|
181
|
+
${bookSection}
|
|
182
|
+
${sentimentSection}`;
|
|
183
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './formatXAxisLabel';
|
|
2
|
+
export * from './getChartStyles';
|
|
3
|
+
export * from './getGradientColor';
|
|
4
|
+
export * from './getLabelData';
|
|
5
|
+
export * from './getRectColor';
|
|
6
|
+
export * from './getTooltipFormatter';
|
|
7
|
+
export * from './isDifferenceGreaterThanTwoWeeks';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TIME_THRESHOLDS } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
export const isDifferenceGreaterThanTwoWeeks = (
|
|
4
|
+
startDate: string,
|
|
5
|
+
endDate: string
|
|
6
|
+
) => {
|
|
7
|
+
const date1 = new Date(startDate);
|
|
8
|
+
const date2 = new Date(endDate);
|
|
9
|
+
|
|
10
|
+
const differenceInMs = Math.abs(date2.getTime() - date1.getTime());
|
|
11
|
+
|
|
12
|
+
return differenceInMs < TIME_THRESHOLDS.TWO_WEEKS_MS;
|
|
13
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Division } from '
|
|
1
|
+
import { Division } from '../../../../gql/types/graphql';
|
|
2
2
|
import {
|
|
3
3
|
instrumentSelectConfig,
|
|
4
4
|
instrumentSelectConfigOC,
|
|
5
|
-
} from '
|
|
5
|
+
} from '../../../selectConfig';
|
|
6
6
|
|
|
7
7
|
export const getInstrumentConfigForDivision = (division: Division) => {
|
|
8
8
|
return division === Division.Oc
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Granularity, TimeSpan } from '../../../../gql/types/graphql';
|
|
2
|
+
|
|
3
|
+
export const getTimeSpanForGranularity = (
|
|
4
|
+
granularity: Granularity
|
|
5
|
+
): TimeSpan => {
|
|
6
|
+
const granularityTimeSpanMap: Record<Granularity, TimeSpan> = {
|
|
7
|
+
[Granularity.M5]: TimeSpan.TwoDays,
|
|
8
|
+
[Granularity.M15]: TimeSpan.FiveDays,
|
|
9
|
+
[Granularity.H1]: TimeSpan.TwentyDays,
|
|
10
|
+
[Granularity.H4]: TimeSpan.NinetyDays,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return granularityTimeSpanMap[granularity] || TimeSpan.TwoDays;
|
|
14
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
1
|
+
export * from './getInstrumentConfigForDivision';
|
|
2
|
+
export * from './getTimeSpanForGranularity';
|
|
3
3
|
export * from './processOrderPositionBooks';
|
|
4
4
|
export * from './processPriceCandles';
|
|
5
5
|
export * from './processSentiments';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { CHART_CONFIG } from '../../constants';
|
|
2
|
+
import {
|
|
3
|
+
getDataZoomConfig,
|
|
4
|
+
getGridConfig,
|
|
5
|
+
getGridLines,
|
|
6
|
+
getSeriesCandlestickConfig,
|
|
7
|
+
getSeriesHeatmapConfig,
|
|
8
|
+
getSeriesSentimentConfig,
|
|
9
|
+
getTooltipConfig,
|
|
10
|
+
getVisualMapConfig,
|
|
11
|
+
getXAxisConfig,
|
|
12
|
+
getYAxisConfig,
|
|
13
|
+
} from './chartOptions';
|
|
14
|
+
import { isDifferenceGreaterThanTwoWeeks } from './chartUtils';
|
|
15
|
+
import { getChartStyles } from './chartUtils/getChartStyles';
|
|
16
|
+
import type { GetOptionType } from './types';
|
|
17
|
+
|
|
18
|
+
export const getOption: GetOptionType = ({
|
|
19
|
+
mainData: {
|
|
20
|
+
dates,
|
|
21
|
+
candlesOpen,
|
|
22
|
+
candlesClose,
|
|
23
|
+
candlesLow,
|
|
24
|
+
candlesHigh,
|
|
25
|
+
bookPrices,
|
|
26
|
+
bookIndexes,
|
|
27
|
+
sentimentShorts,
|
|
28
|
+
sentimentLongs,
|
|
29
|
+
},
|
|
30
|
+
additionalData: {
|
|
31
|
+
bucketWidth,
|
|
32
|
+
buckets,
|
|
33
|
+
displayPrecision,
|
|
34
|
+
bookType,
|
|
35
|
+
sentimentThresholdMin,
|
|
36
|
+
sentimentThresholdMax,
|
|
37
|
+
},
|
|
38
|
+
isDark,
|
|
39
|
+
isDesktop,
|
|
40
|
+
labelCallback,
|
|
41
|
+
}) => {
|
|
42
|
+
const styles = getChartStyles(isDark);
|
|
43
|
+
const selectedPriceRef = { current: 0 };
|
|
44
|
+
|
|
45
|
+
const visibleXAxisData = dates.slice(
|
|
46
|
+
(dates.length * CHART_CONFIG.INITIAL_START_ZOOM) / 100,
|
|
47
|
+
(dates.length * CHART_CONFIG.INITIAL_END_ZOOM) / 100
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const isGreaterThanTwoWeeks = isDifferenceGreaterThanTwoWeeks(
|
|
51
|
+
visibleXAxisData[0],
|
|
52
|
+
visibleXAxisData[visibleXAxisData.length - 1]
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
animation: false,
|
|
57
|
+
tooltip: getTooltipConfig({
|
|
58
|
+
bookType,
|
|
59
|
+
bucketWidth,
|
|
60
|
+
buckets,
|
|
61
|
+
displayPrecision,
|
|
62
|
+
labelCallback,
|
|
63
|
+
selectedPriceRef,
|
|
64
|
+
tooltipLinesColor: styles.tooltipLinesColor,
|
|
65
|
+
}),
|
|
66
|
+
grid: getGridConfig({ isDesktop }),
|
|
67
|
+
xAxis: getXAxisConfig({
|
|
68
|
+
dates,
|
|
69
|
+
isGreaterThanTwoWeeks,
|
|
70
|
+
}),
|
|
71
|
+
yAxis: getYAxisConfig({
|
|
72
|
+
bucketWidth,
|
|
73
|
+
displayPrecision,
|
|
74
|
+
isDesktop,
|
|
75
|
+
labelCallback,
|
|
76
|
+
}),
|
|
77
|
+
dataZoom: getDataZoomConfig(),
|
|
78
|
+
visualMap: getVisualMapConfig({
|
|
79
|
+
sentimentLongColor: styles.sentimentLongColor,
|
|
80
|
+
sentimentShortColor: styles.sentimentShortColor,
|
|
81
|
+
}),
|
|
82
|
+
graphic: getGridLines({ isDark }),
|
|
83
|
+
dataset: {
|
|
84
|
+
source: {
|
|
85
|
+
dates,
|
|
86
|
+
candlesOpen,
|
|
87
|
+
candlesClose,
|
|
88
|
+
candlesLow,
|
|
89
|
+
candlesHigh,
|
|
90
|
+
bookPrices: bookPrices ?? [],
|
|
91
|
+
bookIndexes: bookIndexes ?? [],
|
|
92
|
+
sentimentShorts,
|
|
93
|
+
sentimentLongs,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
series: [
|
|
97
|
+
getSeriesCandlestickConfig({
|
|
98
|
+
dates,
|
|
99
|
+
isGreaterThanTwoWeeks,
|
|
100
|
+
styles,
|
|
101
|
+
}),
|
|
102
|
+
getSeriesHeatmapConfig({
|
|
103
|
+
bucketWidth,
|
|
104
|
+
buckets,
|
|
105
|
+
isDark,
|
|
106
|
+
sentimentThresholdMax,
|
|
107
|
+
sentimentThresholdMin,
|
|
108
|
+
}),
|
|
109
|
+
getSeriesSentimentConfig({
|
|
110
|
+
styles,
|
|
111
|
+
}),
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
};
|
|
@@ -14,14 +14,14 @@ import type {
|
|
|
14
14
|
} from '../../../gql/types/graphql';
|
|
15
15
|
import { BookType, DataSource, Division } from '../../../gql/types/graphql';
|
|
16
16
|
import { BUCKET_CONFIG, INSTRUMENTS_CONFIG } from '../../constants';
|
|
17
|
-
import type { UseCrowdViewDataProps, UseCrowdViewDataReturn } from './types';
|
|
18
17
|
import {
|
|
19
18
|
getTimeSpanForGranularity,
|
|
20
19
|
processOrderPositionBooks,
|
|
21
20
|
processPriceCandles,
|
|
22
21
|
processSentiments,
|
|
23
22
|
validateData,
|
|
24
|
-
} from './
|
|
23
|
+
} from './dataUtils';
|
|
24
|
+
import type { UseCrowdViewDataProps, UseCrowdViewDataReturn } from './types';
|
|
25
25
|
|
|
26
26
|
export const useCrowdViewData = ({
|
|
27
27
|
instrument,
|
|
@@ -83,7 +83,7 @@ export const useCrowdViewData = ({
|
|
|
83
83
|
granularity,
|
|
84
84
|
maxBookPrice: maxPrice,
|
|
85
85
|
minBookPrice: minPrice,
|
|
86
|
-
bucketMultiplier:
|
|
86
|
+
bucketMultiplier: 2,
|
|
87
87
|
bucketMargin: BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
|
|
88
88
|
},
|
|
89
89
|
fetchPolicy: 'no-cache',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLayoutProvider } from '@oanda/labs-widget-common';
|
|
1
2
|
import { useLocale } from '@oanda/mono-i18n';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
|
|
@@ -5,34 +6,35 @@ import { BookType } from '../../../gql/types/graphql';
|
|
|
5
6
|
import { LegendBar } from './LegendBar';
|
|
6
7
|
|
|
7
8
|
interface LegendProps {
|
|
8
|
-
longValues: (number | undefined)[];
|
|
9
|
-
shortValues: (number | undefined)[];
|
|
10
9
|
bookType: BookType;
|
|
11
|
-
isDark: boolean;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export const Legend = ({
|
|
15
|
-
|
|
16
|
-
shortValues,
|
|
17
|
-
bookType,
|
|
18
|
-
isDark,
|
|
19
|
-
}: LegendProps) => {
|
|
12
|
+
export const Legend = ({ bookType }: LegendProps) => {
|
|
13
|
+
const { isDark } = useLayoutProvider();
|
|
20
14
|
const { lang } = useLocale();
|
|
21
15
|
|
|
22
16
|
return (
|
|
23
|
-
<div className="lw-
|
|
24
|
-
<
|
|
25
|
-
isDark={isDark}
|
|
26
|
-
|
|
27
|
-
type="
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
17
|
+
<div className="lw-my-4 lw-w-full">
|
|
18
|
+
<div className="lw-mb-1 lw-flex lw-w-full lw-flex-row lw-justify-between">
|
|
19
|
+
<LegendBar isDark={isDark} type="long" />
|
|
20
|
+
<div className="lw-w-[250px]" />
|
|
21
|
+
<LegendBar isDark={isDark} type="short" />
|
|
22
|
+
</div>
|
|
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">
|
|
24
|
+
<span>
|
|
25
|
+
{lang(
|
|
26
|
+
bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance'
|
|
27
|
+
)}
|
|
28
|
+
</span>
|
|
29
|
+
<span>{lang('even_market_demand')}</span>
|
|
30
|
+
<span>
|
|
31
|
+
{lang(
|
|
32
|
+
bookType === BookType.Order
|
|
33
|
+
? 'sell_overbalance'
|
|
34
|
+
: 'short_overbalance'
|
|
35
|
+
)}
|
|
36
|
+
</span>
|
|
37
|
+
</div>
|
|
36
38
|
</div>
|
|
37
39
|
);
|
|
38
40
|
};
|
|
@@ -5,39 +5,26 @@ import { COLOR_MAP } from '../../constants';
|
|
|
5
5
|
export type LegendType = 'long' | 'short';
|
|
6
6
|
|
|
7
7
|
interface LegendBarProps {
|
|
8
|
-
values: (number | undefined)[];
|
|
9
8
|
type: LegendType;
|
|
10
|
-
label: string;
|
|
11
9
|
isDark: boolean;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
export const LegendBar = ({
|
|
12
|
+
export const LegendBar = ({ type, isDark }: LegendBarProps) => {
|
|
15
13
|
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
16
|
-
const
|
|
14
|
+
const startColor =
|
|
15
|
+
type === 'long' ? colorPalette.long[1] : colorPalette.short[0];
|
|
16
|
+
const endColor =
|
|
17
|
+
type === 'long' ? colorPalette.long[0] : colorPalette.short[1];
|
|
17
18
|
|
|
18
19
|
return (
|
|
19
|
-
<div className="lw-flex lw-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
style={{
|
|
28
|
-
background: `linear-gradient(90deg,${colors[0]} 0%, ${colors[1]} 100%)`,
|
|
29
|
-
}}
|
|
30
|
-
/>
|
|
31
|
-
</div>
|
|
32
|
-
|
|
33
|
-
<div className="lw-flex lw-w-full lw-justify-between">
|
|
34
|
-
<span className="lw-whitespace-nowrap lw-font-sans lw-text-xs lw-text-text-primary">
|
|
35
|
-
{values[0] ? `${values[0].toFixed(2)}%` : '—'}
|
|
36
|
-
</span>
|
|
37
|
-
<span className="lw-whitespace-nowrap lw-font-sans lw-text-xs lw-text-text-primary">
|
|
38
|
-
{values[1] ? `≤ ${values[1].toFixed(2)}%` : '—'}
|
|
39
|
-
</span>
|
|
40
|
-
</div>
|
|
20
|
+
<div className="lw-flex lw-h-2 lw-w-full lw-overflow-hidden">
|
|
21
|
+
<div
|
|
22
|
+
className="lw-h-full lw-flex-1"
|
|
23
|
+
data-testid="legend-bar-segment"
|
|
24
|
+
style={{
|
|
25
|
+
background: `linear-gradient(90deg,${startColor} 0%, ${endColor} 100%)`,
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
41
28
|
</div>
|
|
42
29
|
);
|
|
43
30
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
|
+
import chroma from 'chroma-js';
|
|
2
3
|
|
|
3
4
|
import { InstrumentId } from './types';
|
|
4
5
|
|
|
@@ -12,6 +13,7 @@ export const TIME_THRESHOLDS = {
|
|
|
12
13
|
} as const;
|
|
13
14
|
|
|
14
15
|
export const CHART_CONFIG = {
|
|
16
|
+
HEIGHT: 440,
|
|
15
17
|
MAIN_HEIGHT: 400,
|
|
16
18
|
MARGIN_BETWEEN: 50,
|
|
17
19
|
SENTIMENT_HEIGHT: 120,
|
|
@@ -19,33 +21,34 @@ export const CHART_CONFIG = {
|
|
|
19
21
|
X_LABEL_SIZE: 40,
|
|
20
22
|
Y_LABEL_SIZE_DESKTOP: 60,
|
|
21
23
|
Y_LABEL_SIZE_MOBILE: 40,
|
|
22
|
-
|
|
24
|
+
Y_SENTIMENT_LABEL_SIZE: 40,
|
|
25
|
+
INITIAL_START_ZOOM: 90,
|
|
23
26
|
INITIAL_END_ZOOM: 100,
|
|
24
27
|
X_AXIS_DATE_PADDING: ' ',
|
|
25
28
|
SENTIMENT_MIN: 0,
|
|
26
29
|
SENTIMENT_MAX: 100,
|
|
27
|
-
SENTIMENT_INTERVAL: 25,
|
|
28
|
-
SENTIMENT_TEXT_OFFSET: 16,
|
|
29
30
|
} as const;
|
|
30
31
|
|
|
31
|
-
export const CHART_CONFIG_CALCULATED = {
|
|
32
|
-
FULL_HEIGHT:
|
|
33
|
-
CHART_CONFIG.MAIN_HEIGHT +
|
|
34
|
-
CHART_CONFIG.MARGIN_BETWEEN +
|
|
35
|
-
CHART_CONFIG.SENTIMENT_HEIGHT +
|
|
36
|
-
CHART_CONFIG.X_LABEL_SIZE,
|
|
37
|
-
SENTIMENT_TEXT_POSITION:
|
|
38
|
-
CHART_CONFIG.SENTIMENT_HEIGHT + CHART_CONFIG.SENTIMENT_TEXT_OFFSET,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
32
|
export const COLOR_MAP = {
|
|
42
33
|
dark: {
|
|
43
|
-
long: [
|
|
44
|
-
|
|
34
|
+
long: [
|
|
35
|
+
chroma(colorPalette.darkBlue10).shade(0.5).hex(),
|
|
36
|
+
chroma(colorPalette.darkBlue90).shade(0.5).hex(),
|
|
37
|
+
],
|
|
38
|
+
short: [
|
|
39
|
+
chroma(colorPalette.darkYellow10).shade(0.5).hex(),
|
|
40
|
+
chroma(colorPalette.darkYellow90).shade(0.5).hex(),
|
|
41
|
+
],
|
|
45
42
|
},
|
|
46
43
|
light: {
|
|
47
|
-
long: [
|
|
48
|
-
|
|
44
|
+
long: [
|
|
45
|
+
chroma(colorPalette.lightBlue10).tint(0.5).hex(),
|
|
46
|
+
chroma(colorPalette.lightBlue90).tint(0.5).hex(),
|
|
47
|
+
],
|
|
48
|
+
short: [
|
|
49
|
+
chroma(colorPalette.lightYellow10).tint(0.5).hex(),
|
|
50
|
+
chroma(colorPalette.lightYellow90).tint(0.5).hex(),
|
|
51
|
+
],
|
|
49
52
|
},
|
|
50
53
|
} as const;
|
|
51
54
|
|