@oanda/labs-crowd-view-widget 1.0.53 → 1.0.55
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 +444 -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 +41 -83
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +23 -17
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +24 -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 +30 -49
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +159 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +47 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +83 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +68 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +60 -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 +57 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +66 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +127 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- 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 +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 +23 -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 +120 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- 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 +116 -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/getMultiplayerForTimeSpan.js +19 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.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 +19 -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 +115 -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/types.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +15 -12
- 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 +15 -16
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +20 -14
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/CrowdViewWidget/selectConfig.js +0 -6
- package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/main/translations/sources/en.json +3 -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 +43 -84
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +22 -16
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +17 -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 +30 -49
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +151 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +39 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +76 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +61 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +53 -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 +50 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +59 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +12 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- 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 +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 +16 -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 +113 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- 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 +11 -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/getMultiplayerForTimeSpan.js +12 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.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/dataUtils/index.js +8 -0
- 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 +108 -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/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/Legend/Legend.js +15 -12
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +15 -16
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +18 -13
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/CrowdViewWidget/selectConfig.js +0 -6
- package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/module/translations/sources/en.json +3 -1
- package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridLines.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.d.ts +8 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +8 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +12 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +8 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +18 -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 +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +11 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.d.ts +1 -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 +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getRectColor.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +12 -0
- 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 +10 -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/getMultiplayerForTimeSpan.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.d.ts +3 -2
- package/dist/types/CrowdViewWidget/components/Chart/index.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +5 -0
- 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 +13 -9
- package/package.json +3 -3
- package/src/CrowdViewWidget/Main.tsx +3 -2
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +76 -109
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +33 -28
- package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +22 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +29 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +126 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.ts +191 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +44 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +103 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +72 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +74 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.ts +32 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +68 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +60 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +11 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.ts +13 -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 +18 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getRectColor.ts +27 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +212 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.ts +75 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.ts +37 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +10 -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/getMultiplayerForTimeSpan.ts +13 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.ts +14 -0
- package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.ts +3 -2
- package/src/CrowdViewWidget/components/Chart/getOption.ts +138 -0
- package/src/CrowdViewWidget/components/Chart/index.ts +1 -1
- package/src/CrowdViewWidget/components/Chart/types.ts +5 -0
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +14 -7
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +24 -22
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +29 -26
- package/src/CrowdViewWidget/constants.ts +30 -19
- package/src/CrowdViewWidget/selectConfig.ts +0 -8
- package/src/translations/sources/en.json +3 -1
- package/test/components/Chart/utils/chartUtils.test.ts +20 -9
- package/test/components/Chart/utils/getChartStyles.test.ts +10 -10
- package/test/components/Chart/utils/handleLabelUpdate.test.ts +419 -0
- package/test/components/Chart/utils/handleTooltipUpdate.test.ts +140 -0
- package/test/components/Chart/utils/processSentiments.test.ts +1 -1
- package/test/components/Legend.test.tsx +15 -23
- package/test/components/LegendBar.test.tsx +45 -63
- 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 +0 -7
- 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,74 @@
|
|
|
1
|
+
import type { TooltipComponentOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import type { BookType } from '../../../../gql/types/graphql';
|
|
4
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
5
|
+
import { getTooltipFormatter } from '../chartUtils';
|
|
6
|
+
import type { Bucket, TooltipParam } from '../types';
|
|
7
|
+
|
|
8
|
+
interface GetTooltipConfigParams {
|
|
9
|
+
bookType: BookType;
|
|
10
|
+
bucketWidth: number;
|
|
11
|
+
buckets: Bucket[][];
|
|
12
|
+
displayPrecision: number;
|
|
13
|
+
labelCallback: (key: string, params?: Record<string, unknown>) => string;
|
|
14
|
+
selectedPriceRef: { current: number };
|
|
15
|
+
tooltipLinesColor: string;
|
|
16
|
+
sentimentLongs: (number | null)[];
|
|
17
|
+
sentimentShorts: (number | null)[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getTooltipConfig = ({
|
|
21
|
+
bookType,
|
|
22
|
+
bucketWidth,
|
|
23
|
+
buckets,
|
|
24
|
+
displayPrecision,
|
|
25
|
+
labelCallback,
|
|
26
|
+
selectedPriceRef,
|
|
27
|
+
tooltipLinesColor,
|
|
28
|
+
sentimentLongs,
|
|
29
|
+
sentimentShorts,
|
|
30
|
+
}: GetTooltipConfigParams): TooltipComponentOption => ({
|
|
31
|
+
trigger: 'axis' as const,
|
|
32
|
+
formatter: (params) =>
|
|
33
|
+
getTooltipFormatter({
|
|
34
|
+
bookType,
|
|
35
|
+
bucketWidth,
|
|
36
|
+
buckets,
|
|
37
|
+
labelCallback,
|
|
38
|
+
params: params as unknown as TooltipParam[],
|
|
39
|
+
selectedPrice: selectedPriceRef.current,
|
|
40
|
+
sentimentLongs,
|
|
41
|
+
sentimentShorts,
|
|
42
|
+
}),
|
|
43
|
+
hideDelay: 0,
|
|
44
|
+
axisPointer: {
|
|
45
|
+
type: 'cross' as const,
|
|
46
|
+
axis: 'x' as const,
|
|
47
|
+
lineStyle: {
|
|
48
|
+
color: tooltipLinesColor,
|
|
49
|
+
},
|
|
50
|
+
crossStyle: {
|
|
51
|
+
color: tooltipLinesColor,
|
|
52
|
+
},
|
|
53
|
+
label: {
|
|
54
|
+
padding: 0,
|
|
55
|
+
lineHeight: 24,
|
|
56
|
+
formatter: (params: {
|
|
57
|
+
axisDimension?: string;
|
|
58
|
+
axisIndex?: number;
|
|
59
|
+
value: unknown;
|
|
60
|
+
}) => {
|
|
61
|
+
if (params.axisDimension === 'y' && params.axisIndex === 0) {
|
|
62
|
+
selectedPriceRef.current = Number(params.value);
|
|
63
|
+
return ` ${Number(params.value).toFixed(displayPrecision)} `;
|
|
64
|
+
}
|
|
65
|
+
return '';
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
confine: true,
|
|
70
|
+
position: (point) => [
|
|
71
|
+
point[0] + CHART_CONFIG.TOOLTIP_OFFSET,
|
|
72
|
+
point[1] + CHART_CONFIG.TOOLTIP_OFFSET,
|
|
73
|
+
],
|
|
74
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { VisualMapComponentOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
4
|
+
|
|
5
|
+
interface GetVisualMapConfigParams {
|
|
6
|
+
sentimentLongColor: string;
|
|
7
|
+
sentimentShortColor: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getVisualMapConfig = ({
|
|
11
|
+
sentimentLongColor,
|
|
12
|
+
sentimentShortColor,
|
|
13
|
+
}: GetVisualMapConfigParams): VisualMapComponentOption => ({
|
|
14
|
+
show: false,
|
|
15
|
+
dimension: 1,
|
|
16
|
+
seriesId: 'sentiment',
|
|
17
|
+
pieces: [
|
|
18
|
+
{
|
|
19
|
+
lt: CHART_CONFIG.SENTIMENT_MAX / 2,
|
|
20
|
+
color: sentimentShortColor,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
gte: CHART_CONFIG.SENTIMENT_MAX / 2,
|
|
24
|
+
lte: CHART_CONFIG.SENTIMENT_MAX,
|
|
25
|
+
color: sentimentLongColor,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
gt: CHART_CONFIG.SENTIMENT_MAX,
|
|
29
|
+
color: sentimentLongColor,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { XAXisComponentOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
formatXAxisAdditionalLabel,
|
|
5
|
+
formatXAxisLabel,
|
|
6
|
+
getLabelData,
|
|
7
|
+
} from '../chartUtils';
|
|
8
|
+
|
|
9
|
+
interface GetXAxisConfigParams {
|
|
10
|
+
dates: string[];
|
|
11
|
+
isGreaterThanTwoWeeks: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const getXAxisConfig = ({
|
|
15
|
+
dates,
|
|
16
|
+
isGreaterThanTwoWeeks,
|
|
17
|
+
}: GetXAxisConfigParams): XAXisComponentOption[] => {
|
|
18
|
+
const labelsData = getLabelData({
|
|
19
|
+
dates,
|
|
20
|
+
isGreaterThanTwoWeeks,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
type: 'category',
|
|
26
|
+
id: 'main-xAxis',
|
|
27
|
+
name: isGreaterThanTwoWeeks
|
|
28
|
+
? 'xAxis-greater-than-two-weeks'
|
|
29
|
+
: 'xAxis-less-than-two-weeks',
|
|
30
|
+
nameTextStyle: {
|
|
31
|
+
fontSize: 0,
|
|
32
|
+
},
|
|
33
|
+
axisTick: {
|
|
34
|
+
show: false,
|
|
35
|
+
},
|
|
36
|
+
axisLabel: {
|
|
37
|
+
padding: [8, 16, 8, 16],
|
|
38
|
+
margin: 0,
|
|
39
|
+
formatter: (value: unknown) =>
|
|
40
|
+
formatXAxisLabel(value, isGreaterThanTwoWeeks),
|
|
41
|
+
},
|
|
42
|
+
boundaryGap: false,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'category',
|
|
46
|
+
id: 'additional-xAxis',
|
|
47
|
+
gridIndex: 1,
|
|
48
|
+
axisTick: {
|
|
49
|
+
show: false,
|
|
50
|
+
},
|
|
51
|
+
axisLine: {
|
|
52
|
+
show: false,
|
|
53
|
+
},
|
|
54
|
+
splitLine: {
|
|
55
|
+
show: false,
|
|
56
|
+
},
|
|
57
|
+
axisLabel: {
|
|
58
|
+
margin: 24,
|
|
59
|
+
hideOverlap: true,
|
|
60
|
+
customValues: labelsData,
|
|
61
|
+
formatter: (value: unknown) =>
|
|
62
|
+
formatXAxisAdditionalLabel(value, isGreaterThanTwoWeeks),
|
|
63
|
+
},
|
|
64
|
+
data: dates,
|
|
65
|
+
boundaryGap: false,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { YAXisComponentOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import { BUCKET_CONFIG, CHART_CONFIG } from '../../../constants';
|
|
4
|
+
|
|
5
|
+
interface GetYAxisConfigParams {
|
|
6
|
+
bucketWidth: number;
|
|
7
|
+
displayPrecision: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getYAxisConfig = ({
|
|
11
|
+
bucketWidth,
|
|
12
|
+
displayPrecision,
|
|
13
|
+
}: GetYAxisConfigParams): YAXisComponentOption[] => [
|
|
14
|
+
{
|
|
15
|
+
type: 'value',
|
|
16
|
+
gridIndex: 0,
|
|
17
|
+
position: 'right',
|
|
18
|
+
min: (val: { min: number }) =>
|
|
19
|
+
val.min - bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
|
|
20
|
+
max: (val: { max: number }) =>
|
|
21
|
+
val.max + bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
|
|
22
|
+
axisLine: { show: false },
|
|
23
|
+
axisTick: { show: false },
|
|
24
|
+
splitLine: { show: false },
|
|
25
|
+
axisLabel: {
|
|
26
|
+
lineHeight: 20,
|
|
27
|
+
margin: 4,
|
|
28
|
+
verticalAlignMinLabel: 'bottom',
|
|
29
|
+
verticalAlignMaxLabel: 'top',
|
|
30
|
+
formatter: (value: number) => value.toFixed(displayPrecision),
|
|
31
|
+
},
|
|
32
|
+
z: 30,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'value',
|
|
36
|
+
gridIndex: 1,
|
|
37
|
+
position: 'left',
|
|
38
|
+
min: CHART_CONFIG.SENTIMENT_MIN,
|
|
39
|
+
max: CHART_CONFIG.SENTIMENT_MAX,
|
|
40
|
+
axisLine: { show: false },
|
|
41
|
+
axisTick: { show: false },
|
|
42
|
+
axisPointer: { show: false },
|
|
43
|
+
splitLine: { show: false },
|
|
44
|
+
axisLabel: {
|
|
45
|
+
margin: 4,
|
|
46
|
+
lineHeight: 20,
|
|
47
|
+
verticalAlignMinLabel: 'bottom',
|
|
48
|
+
verticalAlignMaxLabel: 'middle',
|
|
49
|
+
customValues: [
|
|
50
|
+
CHART_CONFIG.SENTIMENT_MIN,
|
|
51
|
+
CHART_CONFIG.SENTIMENT_MAX / 5,
|
|
52
|
+
CHART_CONFIG.SENTIMENT_MAX / 2,
|
|
53
|
+
(CHART_CONFIG.SENTIMENT_MAX * 4) / 5,
|
|
54
|
+
CHART_CONFIG.SENTIMENT_MAX,
|
|
55
|
+
],
|
|
56
|
+
formatter: (value: number) => `${value}%`,
|
|
57
|
+
},
|
|
58
|
+
z: 30,
|
|
59
|
+
},
|
|
60
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './getDataZoomConfig';
|
|
2
|
+
export * from './getGridConfig';
|
|
3
|
+
export * from './getGridLines';
|
|
4
|
+
export * from './getLabelsConfig';
|
|
5
|
+
export * from './getSeriesCandlestickConfig';
|
|
6
|
+
export * from './getSeriesHeatmapConfig';
|
|
7
|
+
export * from './getSeriesSentimentConfig';
|
|
8
|
+
export * from './getTooltipConfig';
|
|
9
|
+
export * from './getVisualMapConfig';
|
|
10
|
+
export * from './getXAxisConfig';
|
|
11
|
+
export * from './getYAxisConfig';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const formatXAxisAdditionalLabel = (
|
|
2
|
+
value: unknown,
|
|
3
|
+
isGreaterThanTwoWeeks: boolean
|
|
4
|
+
) => {
|
|
5
|
+
const date = new Date(value as string);
|
|
6
|
+
if (isNaN(date.getTime())) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
return `${date.toLocaleDateString(undefined, {
|
|
10
|
+
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
11
|
+
day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
|
|
12
|
+
})}`;
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
2
|
+
|
|
3
|
+
export const formatXAxisLabel = (
|
|
4
|
+
value: unknown,
|
|
5
|
+
isGreaterThanTwoWeeks: boolean
|
|
6
|
+
) => {
|
|
7
|
+
const date = new Date(value as string);
|
|
8
|
+
return isGreaterThanTwoWeeks
|
|
9
|
+
? `${date.toLocaleTimeString(undefined, {
|
|
10
|
+
hour: '2-digit',
|
|
11
|
+
minute: '2-digit',
|
|
12
|
+
})}`
|
|
13
|
+
: `${CHART_CONFIG.X_AXIS_DATE_PADDING}${date.toLocaleDateString(undefined, {
|
|
14
|
+
day: 'numeric',
|
|
15
|
+
})}${CHART_CONFIG.X_AXIS_DATE_PADDING}`;
|
|
16
|
+
};
|
|
@@ -3,11 +3,11 @@ import { colorPalette } from '@oanda/labs-widget-common';
|
|
|
3
3
|
export interface ChartStyles {
|
|
4
4
|
sentimentLongColor: string;
|
|
5
5
|
sentimentShortColor: string;
|
|
6
|
+
sentimentOutlineColor: string;
|
|
6
7
|
candleLongColor: string;
|
|
7
8
|
candleShortColor: string;
|
|
8
|
-
sentimentAreaOpacity: number;
|
|
9
9
|
tooltipLinesColor: string;
|
|
10
|
-
|
|
10
|
+
sentimentOutlineWidth: number;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const getChartStyles = (isDark: boolean): ChartStyles => {
|
|
@@ -18,25 +18,28 @@ export const getChartStyles = (isDark: boolean): ChartStyles => {
|
|
|
18
18
|
? colorPalette.darkYellow90
|
|
19
19
|
: colorPalette.lightYellow90;
|
|
20
20
|
|
|
21
|
+
const sentimentOutlineColor = isDark
|
|
22
|
+
? colorPalette.black
|
|
23
|
+
: colorPalette.white;
|
|
24
|
+
const sentimentOutlineWidth = isDark ? 3 : 2;
|
|
25
|
+
|
|
21
26
|
const candleLongColor = isDark
|
|
22
27
|
? colorPalette.bottleGreenDark
|
|
23
28
|
: colorPalette.bottleGreenLight;
|
|
24
29
|
const candleShortColor = isDark
|
|
25
30
|
? colorPalette.orange
|
|
26
31
|
: colorPalette.raspberryLight;
|
|
27
|
-
const sentimentAreaOpacity = isDark ? 0.5 : 0.2;
|
|
28
32
|
const tooltipLinesColor = isDark
|
|
29
33
|
? colorPalette.orange
|
|
30
34
|
: colorPalette.bottleGreenLight;
|
|
31
|
-
const sentimentLabelColor = isDark ? colorPalette.white : colorPalette.black;
|
|
32
35
|
|
|
33
36
|
return {
|
|
34
37
|
sentimentLongColor,
|
|
35
38
|
sentimentShortColor,
|
|
39
|
+
sentimentOutlineColor,
|
|
36
40
|
candleLongColor,
|
|
37
41
|
candleShortColor,
|
|
38
|
-
sentimentAreaOpacity,
|
|
39
42
|
tooltipLinesColor,
|
|
40
|
-
|
|
43
|
+
sentimentOutlineWidth,
|
|
41
44
|
};
|
|
42
45
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import chroma from 'chroma-js';
|
|
2
|
+
|
|
3
|
+
export const getGradientColor = (
|
|
4
|
+
value: number,
|
|
5
|
+
startColor: string,
|
|
6
|
+
targetColor: string,
|
|
7
|
+
minThreshold: number,
|
|
8
|
+
maxThreshold: number
|
|
9
|
+
): string => {
|
|
10
|
+
const colorScale = chroma
|
|
11
|
+
.scale([startColor, targetColor])
|
|
12
|
+
.domain([minThreshold, maxThreshold])
|
|
13
|
+
.mode('rgb');
|
|
14
|
+
|
|
15
|
+
return colorScale(value).hex();
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GetLabelsDataProps } from '../types';
|
|
2
|
+
|
|
3
|
+
export const getLabelData = ({
|
|
4
|
+
dates,
|
|
5
|
+
isGreaterThanTwoWeeks,
|
|
6
|
+
}: GetLabelsDataProps) =>
|
|
7
|
+
dates.filter((record, index, arr) => {
|
|
8
|
+
if (index === 0) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const previousTimestamp = arr[index - 1];
|
|
12
|
+
const currentDate = new Date(record);
|
|
13
|
+
const previousDate = new Date(previousTimestamp);
|
|
14
|
+
|
|
15
|
+
return isGreaterThanTwoWeeks
|
|
16
|
+
? currentDate.getDate() !== previousDate.getDate()
|
|
17
|
+
: currentDate.getMonth() !== previousDate.getMonth();
|
|
18
|
+
});
|
|
@@ -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,212 @@
|
|
|
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 findSentimentSeriesParam = (
|
|
30
|
+
params: TooltipParam[],
|
|
31
|
+
sentimentLongs: (number | null)[],
|
|
32
|
+
sentimentShorts: (number | null)[]
|
|
33
|
+
): {
|
|
34
|
+
sentimentLong: number | null;
|
|
35
|
+
sentimentShort: number | null;
|
|
36
|
+
} => {
|
|
37
|
+
const index = params[0].dataIndex as number;
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
sentimentLong: sentimentLongs[index] ?? null,
|
|
41
|
+
sentimentShort: sentimentShorts[index] ?? null,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getSentimentOverbalanceLabel = (
|
|
46
|
+
sentiment: number,
|
|
47
|
+
bookType: BookType
|
|
48
|
+
): string => {
|
|
49
|
+
if (sentiment < 0) {
|
|
50
|
+
return bookType === BookType.Order
|
|
51
|
+
? 'sell_overbalance'
|
|
52
|
+
: 'short_overbalance';
|
|
53
|
+
}
|
|
54
|
+
return bookType === BookType.Order ? 'buy_overbalance' : 'long_overbalance';
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const formatCandleData = (
|
|
58
|
+
candleData: [number, number, number, number, number],
|
|
59
|
+
labelCallback: (key: string) => string
|
|
60
|
+
): string => {
|
|
61
|
+
const [, open, close, low, high] = candleData;
|
|
62
|
+
return `<p><b>${labelCallback('candle')}:</b></p>
|
|
63
|
+
<p>${labelCallback('open_price')}: ${open} </p>
|
|
64
|
+
<p>${labelCallback('close_price')}: ${close} </p>
|
|
65
|
+
<p>${labelCallback('low')}: ${low} </p>
|
|
66
|
+
<p>${labelCallback('high')}: ${high} </p>
|
|
67
|
+
`;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const formatBookData = ({
|
|
71
|
+
matchedBucket,
|
|
72
|
+
bucketWidth,
|
|
73
|
+
bucketDisplayPrecision,
|
|
74
|
+
bookType,
|
|
75
|
+
labelCallback,
|
|
76
|
+
}: {
|
|
77
|
+
matchedBucket: Bucket;
|
|
78
|
+
bucketWidth: number;
|
|
79
|
+
bucketDisplayPrecision: number;
|
|
80
|
+
bookType: BookType;
|
|
81
|
+
labelCallback: (key: string) => string;
|
|
82
|
+
}): string => {
|
|
83
|
+
const bookLabelKey = bookType === BookType.Order ? 'orders' : 'positions';
|
|
84
|
+
const priceRangeStart = matchedBucket.price.toFixed(bucketDisplayPrecision);
|
|
85
|
+
const priceRangeEnd = (matchedBucket.price + bucketWidth).toFixed(
|
|
86
|
+
bucketDisplayPrecision
|
|
87
|
+
);
|
|
88
|
+
const sentimentLabel = getSentimentOverbalanceLabel(
|
|
89
|
+
matchedBucket.sentiment,
|
|
90
|
+
bookType
|
|
91
|
+
);
|
|
92
|
+
const sentimentValue = Math.abs(matchedBucket.sentiment).toFixed(
|
|
93
|
+
bucketDisplayPrecision
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return `<br /><p><b>${labelCallback(bookLabelKey)}:</b></p>
|
|
97
|
+
<p>${labelCallback('price_range')}: ${priceRangeStart} - ${priceRangeEnd} </p>
|
|
98
|
+
<p>${labelCallback(sentimentLabel)}: ${sentimentValue}% </p>`;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const formatSentimentData = (
|
|
102
|
+
sentimentLong: number,
|
|
103
|
+
sentimentShort: number,
|
|
104
|
+
labelCallback: (key: string) => string
|
|
105
|
+
): string => {
|
|
106
|
+
return `<br /><p><b>${labelCallback('sentiment')}:</b></p>
|
|
107
|
+
<p>${labelCallback('long')}: ${sentimentLong.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>
|
|
108
|
+
<p>${labelCallback('short')}: ${sentimentShort.toFixed(SENTIMENT_DISPLAY_PRECISION)}% </p>`;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const hasValidCandleData = (
|
|
112
|
+
candleData: [number, number, number, number, number]
|
|
113
|
+
): boolean =>
|
|
114
|
+
!!candleData[1] && !!candleData[2] && !!candleData[3] && !!candleData[4];
|
|
115
|
+
|
|
116
|
+
const hasValidSentimentData = (
|
|
117
|
+
sentimentLong: number | null,
|
|
118
|
+
sentimentShort: number | null
|
|
119
|
+
): boolean => sentimentLong !== null && sentimentShort !== null;
|
|
120
|
+
|
|
121
|
+
const findMatchingBucket = (
|
|
122
|
+
buckets: Bucket[][],
|
|
123
|
+
bucketsIndex: number | undefined,
|
|
124
|
+
selectedPrice: number,
|
|
125
|
+
bucketWidth: number
|
|
126
|
+
): Bucket | undefined => {
|
|
127
|
+
if (bucketsIndex === undefined) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const selectedBuckets = buckets[bucketsIndex];
|
|
131
|
+
return selectedBuckets?.find(
|
|
132
|
+
({ price }) => selectedPrice >= price && selectedPrice < price + bucketWidth
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export const getTooltipFormatter = ({
|
|
137
|
+
params,
|
|
138
|
+
buckets,
|
|
139
|
+
bucketWidth,
|
|
140
|
+
selectedPrice,
|
|
141
|
+
bookType,
|
|
142
|
+
labelCallback,
|
|
143
|
+
sentimentLongs,
|
|
144
|
+
sentimentShorts,
|
|
145
|
+
}: {
|
|
146
|
+
params: TooltipParam[];
|
|
147
|
+
buckets: Bucket[][];
|
|
148
|
+
bucketWidth: number;
|
|
149
|
+
selectedPrice: number;
|
|
150
|
+
bookType: BookType;
|
|
151
|
+
labelCallback: (key: string) => string;
|
|
152
|
+
sentimentLongs: (number | null)[];
|
|
153
|
+
sentimentShorts: (number | null)[];
|
|
154
|
+
}) => {
|
|
155
|
+
if (!params || !Array.isArray(params) || params.length === 0) {
|
|
156
|
+
return '';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const candleParam = findSeriesParam(params, 'candlestick');
|
|
160
|
+
const booksParam = findSeriesParam(params, 'heatmap');
|
|
161
|
+
const { sentimentLong, sentimentShort } = findSentimentSeriesParam(
|
|
162
|
+
params,
|
|
163
|
+
sentimentLongs,
|
|
164
|
+
sentimentShorts
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
if (!candleParam) {
|
|
168
|
+
return '';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const bucketDisplayPrecision = calculateBucketDisplayPrecision(bucketWidth);
|
|
172
|
+
const time = new Date(candleParam.axisValue as string);
|
|
173
|
+
const candleData = candleParam.value;
|
|
174
|
+
const bucketsIndex = booksParam?.value[2];
|
|
175
|
+
const matchedBucket = findMatchingBucket(
|
|
176
|
+
buckets,
|
|
177
|
+
bucketsIndex,
|
|
178
|
+
selectedPrice,
|
|
179
|
+
bucketWidth
|
|
180
|
+
);
|
|
181
|
+
const showCandles = hasValidCandleData(candleData);
|
|
182
|
+
const showSentiment = hasValidSentimentData(sentimentLong, sentimentShort);
|
|
183
|
+
|
|
184
|
+
if (!showCandles && !matchedBucket) {
|
|
185
|
+
return '';
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const timeFormatted = time.toLocaleString(undefined, DATE_FORMAT_OPTIONS);
|
|
189
|
+
const candleSection = showCandles
|
|
190
|
+
? formatCandleData(candleData, labelCallback)
|
|
191
|
+
: '';
|
|
192
|
+
|
|
193
|
+
const bookSection = matchedBucket
|
|
194
|
+
? formatBookData({
|
|
195
|
+
matchedBucket,
|
|
196
|
+
bucketWidth,
|
|
197
|
+
bucketDisplayPrecision,
|
|
198
|
+
bookType,
|
|
199
|
+
labelCallback,
|
|
200
|
+
})
|
|
201
|
+
: '';
|
|
202
|
+
|
|
203
|
+
const sentimentSection =
|
|
204
|
+
showSentiment && sentimentLong && sentimentShort
|
|
205
|
+
? formatSentimentData(sentimentLong, sentimentShort, labelCallback)
|
|
206
|
+
: '';
|
|
207
|
+
|
|
208
|
+
return `<p>${timeFormatted}</p><br />
|
|
209
|
+
${candleSection}
|
|
210
|
+
${bookSection}
|
|
211
|
+
${sentimentSection}`;
|
|
212
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { EChartsType } from 'echarts';
|
|
2
|
+
import type { MutableRefObject } from 'react';
|
|
3
|
+
|
|
4
|
+
import type { ChartProps, DataZoomArray } from '../types';
|
|
5
|
+
import { formatXAxisAdditionalLabel } from './formatXAxisAdditionalLabel';
|
|
6
|
+
import { formatXAxisLabel } from './formatXAxisLabel';
|
|
7
|
+
import { getLabelData } from './getLabelData';
|
|
8
|
+
import { isDifferenceGreaterThanTwoWeeks } from './isDifferenceGreaterThanTwoWeeks';
|
|
9
|
+
|
|
10
|
+
export const handleLabelUpdate = (
|
|
11
|
+
instance: EChartsType,
|
|
12
|
+
mainData: ChartProps['mainData'],
|
|
13
|
+
labelTimerRef: MutableRefObject<NodeJS.Timeout | null>,
|
|
14
|
+
isGreaterThanTwoWeeksRef: MutableRefObject<boolean | null>
|
|
15
|
+
): void => {
|
|
16
|
+
if (labelTimerRef.current) {
|
|
17
|
+
clearTimeout(labelTimerRef.current);
|
|
18
|
+
}
|
|
19
|
+
labelTimerRef.current = setTimeout(() => {
|
|
20
|
+
const { dates } = mainData;
|
|
21
|
+
|
|
22
|
+
const { dataZoom } = instance.getOption();
|
|
23
|
+
if (
|
|
24
|
+
!Array.isArray(dataZoom) ||
|
|
25
|
+
dataZoom.length === 0 ||
|
|
26
|
+
!dataZoom[0] ||
|
|
27
|
+
typeof dataZoom[0].startValue !== 'number' ||
|
|
28
|
+
typeof dataZoom[0].endValue !== 'number'
|
|
29
|
+
) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { startValue, endValue } = dataZoom[0] as DataZoomArray[0];
|
|
34
|
+
|
|
35
|
+
if (!dates[startValue] || !dates[endValue]) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const isGreaterThanTwoWeeks = isDifferenceGreaterThanTwoWeeks(
|
|
40
|
+
dates[startValue],
|
|
41
|
+
dates[endValue]
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const wasGreaterThanTwoWeeks = isGreaterThanTwoWeeksRef.current ?? false;
|
|
45
|
+
|
|
46
|
+
if (isGreaterThanTwoWeeks !== wasGreaterThanTwoWeeks) {
|
|
47
|
+
const labelsData = getLabelData({
|
|
48
|
+
dates,
|
|
49
|
+
isGreaterThanTwoWeeks,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
instance.setOption({
|
|
53
|
+
xAxis: [
|
|
54
|
+
{
|
|
55
|
+
id: 'main-xAxis',
|
|
56
|
+
axisLabel: {
|
|
57
|
+
formatter: (value: string) =>
|
|
58
|
+
formatXAxisLabel(value, isGreaterThanTwoWeeks),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'additional-xAxis',
|
|
63
|
+
axisLabel: {
|
|
64
|
+
customValues: labelsData,
|
|
65
|
+
formatter: (value: unknown) =>
|
|
66
|
+
formatXAxisAdditionalLabel(value, isGreaterThanTwoWeeks),
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
isGreaterThanTwoWeeksRef.current = isGreaterThanTwoWeeks;
|
|
73
|
+
}
|
|
74
|
+
}, 50);
|
|
75
|
+
};
|