@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
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { TooltipParam } from '../../../../src/CrowdViewWidget/components/Chart/types';
|
|
2
1
|
import {
|
|
3
2
|
formatXAxisLabel,
|
|
4
3
|
getLabelData,
|
|
5
4
|
getRectColor,
|
|
6
|
-
getTimeSpanForGranularity,
|
|
7
5
|
getTooltipFormatter,
|
|
8
6
|
isDifferenceGreaterThanTwoWeeks,
|
|
9
|
-
} from '../../../../src/CrowdViewWidget/components/Chart/
|
|
7
|
+
} from '../../../../src/CrowdViewWidget/components/Chart/chartUtils';
|
|
8
|
+
import { getTimeSpanForGranularity } from '../../../../src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity';
|
|
9
|
+
import type { TooltipParam } from '../../../../src/CrowdViewWidget/components/Chart/types';
|
|
10
10
|
import { COLOR_MAP } from '../../../../src/CrowdViewWidget/constants';
|
|
11
11
|
import {
|
|
12
12
|
BookType,
|
|
@@ -138,7 +138,7 @@ describe('chartUtils', () => {
|
|
|
138
138
|
});
|
|
139
139
|
// First change happens between 1st and 2nd
|
|
140
140
|
expect(labels.length).toBeGreaterThanOrEqual(2);
|
|
141
|
-
expect(labels[0]).
|
|
141
|
+
expect(labels[0]).toBe('2025-03-02T00:00:00Z');
|
|
142
142
|
});
|
|
143
143
|
|
|
144
144
|
it('emits label when month changes for >= two weeks case', () => {
|
|
@@ -152,7 +152,7 @@ describe('chartUtils', () => {
|
|
|
152
152
|
isGreaterThanTwoWeeks: false,
|
|
153
153
|
});
|
|
154
154
|
expect(labels.length).toBe(1);
|
|
155
|
-
expect(labels[0]).
|
|
155
|
+
expect(labels[0]).toBe('2025-02-01T00:00:00Z');
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
|
|
@@ -165,6 +165,7 @@ describe('chartUtils', () => {
|
|
|
165
165
|
seriesId: 'candlestick' as const,
|
|
166
166
|
axisValue: '2025-03-15T10:30:00Z',
|
|
167
167
|
value: [0, 1.11111, 1.22222, 1.00001, 1.33333],
|
|
168
|
+
dataIndex: 0,
|
|
168
169
|
},
|
|
169
170
|
{
|
|
170
171
|
seriesId: 'heatmap' as const,
|
|
@@ -186,6 +187,8 @@ describe('chartUtils', () => {
|
|
|
186
187
|
selectedPrice: 1.3306,
|
|
187
188
|
bookType: BookType.Order,
|
|
188
189
|
labelCallback,
|
|
190
|
+
sentimentLongs: [],
|
|
191
|
+
sentimentShorts: [],
|
|
189
192
|
});
|
|
190
193
|
expect(html).toBeDefined();
|
|
191
194
|
expect(html).toContain('candle');
|
|
@@ -205,6 +208,7 @@ describe('chartUtils', () => {
|
|
|
205
208
|
seriesId: 'candlestick' as const,
|
|
206
209
|
axisValue: '2025-03-15T10:30:00Z',
|
|
207
210
|
value: [0, 1.11111, 1.22222, 1.00001, 1.33333],
|
|
211
|
+
dataIndex: 0,
|
|
208
212
|
},
|
|
209
213
|
{
|
|
210
214
|
seriesId: 'sentiment' as const,
|
|
@@ -221,6 +225,8 @@ describe('chartUtils', () => {
|
|
|
221
225
|
selectedPrice: 1.3306,
|
|
222
226
|
bookType: BookType.Order,
|
|
223
227
|
labelCallback,
|
|
228
|
+
sentimentLongs: [30.5],
|
|
229
|
+
sentimentShorts: [69.5],
|
|
224
230
|
});
|
|
225
231
|
expect(html).toBeDefined();
|
|
226
232
|
expect(html).toContain('candle');
|
|
@@ -231,11 +237,12 @@ describe('chartUtils', () => {
|
|
|
231
237
|
expect(html).toContain('69.50');
|
|
232
238
|
});
|
|
233
239
|
|
|
234
|
-
it('returns
|
|
240
|
+
it('returns empty string when no candlestick param is provided', () => {
|
|
235
241
|
const params: TooltipParam[] = [
|
|
236
242
|
{
|
|
237
243
|
seriesId: 'heatmap' as const,
|
|
238
244
|
value: ['2025-03-15T10:30:00Z', 1.33333, 0],
|
|
245
|
+
dataIndex: 0,
|
|
239
246
|
},
|
|
240
247
|
];
|
|
241
248
|
|
|
@@ -248,11 +255,13 @@ describe('chartUtils', () => {
|
|
|
248
255
|
selectedPrice: 1.3306,
|
|
249
256
|
bookType: BookType.Order,
|
|
250
257
|
labelCallback,
|
|
258
|
+
sentimentLongs: [],
|
|
259
|
+
sentimentShorts: [],
|
|
251
260
|
});
|
|
252
|
-
expect(html).
|
|
261
|
+
expect(html).toBe('');
|
|
253
262
|
});
|
|
254
263
|
|
|
255
|
-
it('returns
|
|
264
|
+
it('returns empty string when params is empty', () => {
|
|
256
265
|
const html = getTooltipFormatter({
|
|
257
266
|
params: [],
|
|
258
267
|
buckets: [],
|
|
@@ -260,8 +269,10 @@ describe('chartUtils', () => {
|
|
|
260
269
|
selectedPrice: 1.3306,
|
|
261
270
|
bookType: BookType.Order,
|
|
262
271
|
labelCallback,
|
|
272
|
+
sentimentLongs: [],
|
|
273
|
+
sentimentShorts: [],
|
|
263
274
|
});
|
|
264
|
-
expect(html).
|
|
275
|
+
expect(html).toBe('');
|
|
265
276
|
});
|
|
266
277
|
});
|
|
267
278
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
2
|
|
|
3
|
-
import { getChartStyles } from '../../../../src/CrowdViewWidget/components/Chart/
|
|
3
|
+
import { getChartStyles } from '../../../../src/CrowdViewWidget/components/Chart/chartUtils/getChartStyles';
|
|
4
4
|
|
|
5
5
|
describe('getChartStyles', () => {
|
|
6
6
|
it('returns correct styles for dark mode', () => {
|
|
@@ -10,9 +10,9 @@ describe('getChartStyles', () => {
|
|
|
10
10
|
expect(styles.sentimentShortColor).toBe(colorPalette.darkYellow90);
|
|
11
11
|
expect(styles.candleLongColor).toBe(colorPalette.bottleGreenDark);
|
|
12
12
|
expect(styles.candleShortColor).toBe(colorPalette.orange);
|
|
13
|
-
expect(styles.
|
|
13
|
+
expect(styles.sentimentOutlineColor).toBe(colorPalette.black);
|
|
14
|
+
expect(styles.sentimentOutlineWidth).toBe(3);
|
|
14
15
|
expect(styles.tooltipLinesColor).toBe(colorPalette.orange);
|
|
15
|
-
expect(styles.sentimentLabelColor).toBe(colorPalette.white);
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
it('returns correct styles for light mode', () => {
|
|
@@ -22,9 +22,9 @@ describe('getChartStyles', () => {
|
|
|
22
22
|
expect(styles.sentimentShortColor).toBe(colorPalette.lightYellow90);
|
|
23
23
|
expect(styles.candleLongColor).toBe(colorPalette.bottleGreenLight);
|
|
24
24
|
expect(styles.candleShortColor).toBe(colorPalette.raspberryLight);
|
|
25
|
-
expect(styles.
|
|
25
|
+
expect(styles.sentimentOutlineColor).toBe(colorPalette.white);
|
|
26
|
+
expect(styles.sentimentOutlineWidth).toBe(2);
|
|
26
27
|
expect(styles.tooltipLinesColor).toBe(colorPalette.bottleGreenLight);
|
|
27
|
-
expect(styles.sentimentLabelColor).toBe(colorPalette.black);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('returns all required style properties', () => {
|
|
@@ -36,9 +36,9 @@ describe('getChartStyles', () => {
|
|
|
36
36
|
'sentimentShortColor',
|
|
37
37
|
'candleLongColor',
|
|
38
38
|
'candleShortColor',
|
|
39
|
-
'
|
|
39
|
+
'sentimentOutlineColor',
|
|
40
|
+
'sentimentOutlineWidth',
|
|
40
41
|
'tooltipLinesColor',
|
|
41
|
-
'sentimentLabelColor',
|
|
42
42
|
];
|
|
43
43
|
|
|
44
44
|
requiredProperties.forEach((prop) => {
|
|
@@ -53,12 +53,12 @@ describe('getChartStyles', () => {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it('returns different
|
|
56
|
+
it('returns different outline width values for dark and light modes', () => {
|
|
57
57
|
const darkStyles = getChartStyles(true);
|
|
58
58
|
const lightStyles = getChartStyles(false);
|
|
59
59
|
|
|
60
|
-
expect(darkStyles.
|
|
61
|
-
lightStyles.
|
|
60
|
+
expect(darkStyles.sentimentOutlineWidth).toBeGreaterThan(
|
|
61
|
+
lightStyles.sentimentOutlineWidth
|
|
62
62
|
);
|
|
63
63
|
});
|
|
64
64
|
});
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import type { EChartsType } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import { formatXAxisAdditionalLabel } from '../../../../src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel';
|
|
4
|
+
import { formatXAxisLabel } from '../../../../src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel';
|
|
5
|
+
import { getLabelData } from '../../../../src/CrowdViewWidget/components/Chart/chartUtils/getLabelData';
|
|
6
|
+
import { handleLabelUpdate } from '../../../../src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate';
|
|
7
|
+
import { isDifferenceGreaterThanTwoWeeks } from '../../../../src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks';
|
|
8
|
+
import type { ChartProps } from '../../../../src/CrowdViewWidget/components/Chart/types';
|
|
9
|
+
|
|
10
|
+
// Mock dependencies
|
|
11
|
+
jest.mock(
|
|
12
|
+
'../../../../src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel'
|
|
13
|
+
);
|
|
14
|
+
jest.mock(
|
|
15
|
+
'../../../../src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel'
|
|
16
|
+
);
|
|
17
|
+
jest.mock(
|
|
18
|
+
'../../../../src/CrowdViewWidget/components/Chart/chartUtils/getLabelData'
|
|
19
|
+
);
|
|
20
|
+
jest.mock(
|
|
21
|
+
'../../../../src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks'
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const mockFormatXAxisLabel = formatXAxisLabel as jest.MockedFunction<
|
|
25
|
+
typeof formatXAxisLabel
|
|
26
|
+
>;
|
|
27
|
+
const mockFormatXAxisAdditionalLabel =
|
|
28
|
+
formatXAxisAdditionalLabel as jest.MockedFunction<
|
|
29
|
+
typeof formatXAxisAdditionalLabel
|
|
30
|
+
>;
|
|
31
|
+
const mockGetLabelData = getLabelData as jest.MockedFunction<
|
|
32
|
+
typeof getLabelData
|
|
33
|
+
>;
|
|
34
|
+
const mockIsDifferenceGreaterThanTwoWeeks =
|
|
35
|
+
isDifferenceGreaterThanTwoWeeks as jest.MockedFunction<
|
|
36
|
+
typeof isDifferenceGreaterThanTwoWeeks
|
|
37
|
+
>;
|
|
38
|
+
|
|
39
|
+
describe('handleLabelUpdate', () => {
|
|
40
|
+
let mockInstance: jest.Mocked<EChartsType>;
|
|
41
|
+
let labelTimerRef: { current: NodeJS.Timeout | null };
|
|
42
|
+
let isGreaterThanTwoWeeksRef: { current: boolean | null };
|
|
43
|
+
let mainData: ChartProps['mainData'];
|
|
44
|
+
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
jest.useFakeTimers();
|
|
47
|
+
jest.clearAllMocks();
|
|
48
|
+
|
|
49
|
+
mockInstance = {
|
|
50
|
+
getOption: jest.fn(),
|
|
51
|
+
setOption: jest.fn(),
|
|
52
|
+
} as unknown as jest.Mocked<EChartsType>;
|
|
53
|
+
|
|
54
|
+
labelTimerRef = { current: null };
|
|
55
|
+
isGreaterThanTwoWeeksRef = { current: null };
|
|
56
|
+
|
|
57
|
+
mainData = {
|
|
58
|
+
dates: [
|
|
59
|
+
'2025-01-01T00:00:00Z',
|
|
60
|
+
'2025-01-02T00:00:00Z',
|
|
61
|
+
'2025-01-03T00:00:00Z',
|
|
62
|
+
'2025-01-04T00:00:00Z',
|
|
63
|
+
'2025-01-05T00:00:00Z',
|
|
64
|
+
],
|
|
65
|
+
candlesOpen: [1.1, 1.2, 1.3, 1.4, 1.5],
|
|
66
|
+
candlesClose: [1.15, 1.25, 1.35, 1.45, 1.55],
|
|
67
|
+
candlesLow: [1.05, 1.15, 1.25, 1.35, 1.45],
|
|
68
|
+
candlesHigh: [1.2, 1.3, 1.4, 1.5, 1.6],
|
|
69
|
+
sentimentShorts: [10, 20, 30, 40, 50],
|
|
70
|
+
sentimentLongs: [90, 80, 70, 60, 50],
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
mockFormatXAxisLabel.mockReturnValue('formatted-label');
|
|
74
|
+
mockFormatXAxisAdditionalLabel.mockReturnValue('formatted-additional');
|
|
75
|
+
mockGetLabelData.mockReturnValue([
|
|
76
|
+
'2025-01-02T00:00:00Z',
|
|
77
|
+
'2025-01-04T00:00:00Z',
|
|
78
|
+
]);
|
|
79
|
+
mockIsDifferenceGreaterThanTwoWeeks.mockReturnValue(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
afterEach(() => {
|
|
83
|
+
jest.runOnlyPendingTimers();
|
|
84
|
+
jest.useRealTimers();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('when dataZoom is invalid', () => {
|
|
88
|
+
it('should return early if dataZoom is not an array', () => {
|
|
89
|
+
mockInstance.getOption.mockReturnValue({
|
|
90
|
+
dataZoom: null,
|
|
91
|
+
xAxis: [],
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
handleLabelUpdate(
|
|
95
|
+
mockInstance,
|
|
96
|
+
mainData,
|
|
97
|
+
labelTimerRef,
|
|
98
|
+
isGreaterThanTwoWeeksRef
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
jest.advanceTimersByTime(50);
|
|
102
|
+
|
|
103
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should return early if dataZoom array is empty', () => {
|
|
107
|
+
mockInstance.getOption.mockReturnValue({
|
|
108
|
+
dataZoom: [],
|
|
109
|
+
xAxis: [],
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
handleLabelUpdate(
|
|
113
|
+
mockInstance,
|
|
114
|
+
mainData,
|
|
115
|
+
labelTimerRef,
|
|
116
|
+
isGreaterThanTwoWeeksRef
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
jest.advanceTimersByTime(50);
|
|
120
|
+
|
|
121
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('should return early if dataZoom[0] is null', () => {
|
|
125
|
+
mockInstance.getOption.mockReturnValue({
|
|
126
|
+
dataZoom: [null],
|
|
127
|
+
xAxis: [],
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
handleLabelUpdate(
|
|
131
|
+
mockInstance,
|
|
132
|
+
mainData,
|
|
133
|
+
labelTimerRef,
|
|
134
|
+
isGreaterThanTwoWeeksRef
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
jest.advanceTimersByTime(50);
|
|
138
|
+
|
|
139
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should return early if startValue is not a number', () => {
|
|
143
|
+
mockInstance.getOption.mockReturnValue({
|
|
144
|
+
dataZoom: [{ startValue: 'invalid', endValue: 3 }],
|
|
145
|
+
xAxis: [],
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
handleLabelUpdate(
|
|
149
|
+
mockInstance,
|
|
150
|
+
mainData,
|
|
151
|
+
labelTimerRef,
|
|
152
|
+
isGreaterThanTwoWeeksRef
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
jest.advanceTimersByTime(50);
|
|
156
|
+
|
|
157
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should return early if endValue is not a number', () => {
|
|
161
|
+
mockInstance.getOption.mockReturnValue({
|
|
162
|
+
dataZoom: [{ startValue: 0, endValue: 'invalid' }],
|
|
163
|
+
xAxis: [],
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
handleLabelUpdate(
|
|
167
|
+
mockInstance,
|
|
168
|
+
mainData,
|
|
169
|
+
labelTimerRef,
|
|
170
|
+
isGreaterThanTwoWeeksRef
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
jest.advanceTimersByTime(50);
|
|
174
|
+
|
|
175
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
describe('when dates are invalid', () => {
|
|
180
|
+
it('should return early if startValue date is missing', () => {
|
|
181
|
+
mockInstance.getOption.mockReturnValue({
|
|
182
|
+
dataZoom: [{ startValue: 10, endValue: 3 }],
|
|
183
|
+
xAxis: [],
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
handleLabelUpdate(
|
|
187
|
+
mockInstance,
|
|
188
|
+
mainData,
|
|
189
|
+
labelTimerRef,
|
|
190
|
+
isGreaterThanTwoWeeksRef
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
jest.advanceTimersByTime(50);
|
|
194
|
+
|
|
195
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('should return early if endValue date is missing', () => {
|
|
199
|
+
mockInstance.getOption.mockReturnValue({
|
|
200
|
+
dataZoom: [{ startValue: 0, endValue: 10 }],
|
|
201
|
+
xAxis: [],
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
handleLabelUpdate(
|
|
205
|
+
mockInstance,
|
|
206
|
+
mainData,
|
|
207
|
+
labelTimerRef,
|
|
208
|
+
isGreaterThanTwoWeeksRef
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
jest.advanceTimersByTime(50);
|
|
212
|
+
|
|
213
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe('when state changes', () => {
|
|
218
|
+
it('should update xAxis when isGreaterThanTwoWeeks changes from null to true', () => {
|
|
219
|
+
isGreaterThanTwoWeeksRef.current = null;
|
|
220
|
+
mockInstance.getOption.mockReturnValue({
|
|
221
|
+
dataZoom: [{ startValue: 0, endValue: 3 }],
|
|
222
|
+
xAxis: [],
|
|
223
|
+
});
|
|
224
|
+
mockIsDifferenceGreaterThanTwoWeeks.mockReturnValue(true);
|
|
225
|
+
|
|
226
|
+
handleLabelUpdate(
|
|
227
|
+
mockInstance,
|
|
228
|
+
mainData,
|
|
229
|
+
labelTimerRef,
|
|
230
|
+
isGreaterThanTwoWeeksRef
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
jest.advanceTimersByTime(50);
|
|
234
|
+
|
|
235
|
+
expect(mockInstance.setOption).toHaveBeenCalledWith({
|
|
236
|
+
xAxis: [
|
|
237
|
+
{
|
|
238
|
+
id: 'main-xAxis',
|
|
239
|
+
axisLabel: {
|
|
240
|
+
formatter: expect.any(Function),
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
id: 'additional-xAxis',
|
|
245
|
+
axisLabel: {
|
|
246
|
+
customValues: ['2025-01-02T00:00:00Z', '2025-01-04T00:00:00Z'],
|
|
247
|
+
formatter: expect.any(Function),
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
});
|
|
252
|
+
expect(isGreaterThanTwoWeeksRef.current).toBe(true);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('should update xAxis when isGreaterThanTwoWeeks changes from false to true', () => {
|
|
256
|
+
isGreaterThanTwoWeeksRef.current = false;
|
|
257
|
+
mockInstance.getOption.mockReturnValue({
|
|
258
|
+
dataZoom: [{ startValue: 0, endValue: 3 }],
|
|
259
|
+
xAxis: [],
|
|
260
|
+
});
|
|
261
|
+
mockIsDifferenceGreaterThanTwoWeeks.mockReturnValue(true);
|
|
262
|
+
|
|
263
|
+
handleLabelUpdate(
|
|
264
|
+
mockInstance,
|
|
265
|
+
mainData,
|
|
266
|
+
labelTimerRef,
|
|
267
|
+
isGreaterThanTwoWeeksRef
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
jest.advanceTimersByTime(50);
|
|
271
|
+
|
|
272
|
+
expect(mockInstance.setOption).toHaveBeenCalled();
|
|
273
|
+
expect(isGreaterThanTwoWeeksRef.current).toBe(true);
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('should not update xAxis when isGreaterThanTwoWeeks does not change', () => {
|
|
277
|
+
isGreaterThanTwoWeeksRef.current = false;
|
|
278
|
+
mockInstance.getOption.mockReturnValue({
|
|
279
|
+
dataZoom: [{ startValue: 0, endValue: 3 }],
|
|
280
|
+
xAxis: [],
|
|
281
|
+
});
|
|
282
|
+
mockIsDifferenceGreaterThanTwoWeeks.mockReturnValue(false);
|
|
283
|
+
|
|
284
|
+
handleLabelUpdate(
|
|
285
|
+
mockInstance,
|
|
286
|
+
mainData,
|
|
287
|
+
labelTimerRef,
|
|
288
|
+
isGreaterThanTwoWeeksRef
|
|
289
|
+
);
|
|
290
|
+
|
|
291
|
+
jest.advanceTimersByTime(50);
|
|
292
|
+
|
|
293
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
294
|
+
expect(isGreaterThanTwoWeeksRef.current).toBe(false);
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
describe('timer management', () => {
|
|
299
|
+
it('should clear existing timeout before setting new one', () => {
|
|
300
|
+
const existingTimeout = setTimeout(() => {}, 1000);
|
|
301
|
+
labelTimerRef.current = existingTimeout;
|
|
302
|
+
const clearTimeoutSpy = jest.spyOn(global, 'clearTimeout');
|
|
303
|
+
|
|
304
|
+
mockInstance.getOption.mockReturnValue({
|
|
305
|
+
dataZoom: [{ startValue: 0, endValue: 3 }],
|
|
306
|
+
xAxis: [],
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
handleLabelUpdate(
|
|
310
|
+
mockInstance,
|
|
311
|
+
mainData,
|
|
312
|
+
labelTimerRef,
|
|
313
|
+
isGreaterThanTwoWeeksRef
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
expect(clearTimeoutSpy).toHaveBeenCalledWith(existingTimeout);
|
|
317
|
+
clearTimeoutSpy.mockRestore();
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
it('should delay execution by 50ms', () => {
|
|
321
|
+
mockInstance.getOption.mockReturnValue({
|
|
322
|
+
dataZoom: [{ startValue: 0, endValue: 3 }],
|
|
323
|
+
xAxis: [],
|
|
324
|
+
});
|
|
325
|
+
mockIsDifferenceGreaterThanTwoWeeks.mockReturnValue(true);
|
|
326
|
+
isGreaterThanTwoWeeksRef.current = false;
|
|
327
|
+
|
|
328
|
+
handleLabelUpdate(
|
|
329
|
+
mockInstance,
|
|
330
|
+
mainData,
|
|
331
|
+
labelTimerRef,
|
|
332
|
+
isGreaterThanTwoWeeksRef
|
|
333
|
+
);
|
|
334
|
+
|
|
335
|
+
// Should not be called before timeout
|
|
336
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
337
|
+
|
|
338
|
+
// Fast-forward 49ms
|
|
339
|
+
jest.advanceTimersByTime(49);
|
|
340
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
341
|
+
|
|
342
|
+
// Fast-forward 1ms more
|
|
343
|
+
jest.advanceTimersByTime(1);
|
|
344
|
+
expect(mockInstance.setOption).toHaveBeenCalled();
|
|
345
|
+
});
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
describe('formatter functions', () => {
|
|
349
|
+
it('should call formatXAxisLabel with correct parameters', () => {
|
|
350
|
+
isGreaterThanTwoWeeksRef.current = false;
|
|
351
|
+
mockInstance.getOption.mockReturnValue({
|
|
352
|
+
dataZoom: [{ startValue: 0, endValue: 3 }],
|
|
353
|
+
xAxis: [],
|
|
354
|
+
});
|
|
355
|
+
mockIsDifferenceGreaterThanTwoWeeks.mockReturnValue(true);
|
|
356
|
+
|
|
357
|
+
handleLabelUpdate(
|
|
358
|
+
mockInstance,
|
|
359
|
+
mainData,
|
|
360
|
+
labelTimerRef,
|
|
361
|
+
isGreaterThanTwoWeeksRef
|
|
362
|
+
);
|
|
363
|
+
|
|
364
|
+
jest.advanceTimersByTime(50);
|
|
365
|
+
|
|
366
|
+
const setOptionCall = mockInstance.setOption.mock.calls[0][0] as {
|
|
367
|
+
xAxis: Array<{
|
|
368
|
+
id: string;
|
|
369
|
+
axisLabel: {
|
|
370
|
+
formatter: (value: string) => string;
|
|
371
|
+
};
|
|
372
|
+
}>;
|
|
373
|
+
};
|
|
374
|
+
const mainAxisFormatter = setOptionCall.xAxis[0].axisLabel.formatter;
|
|
375
|
+
mainAxisFormatter('2025-01-01T00:00:00Z');
|
|
376
|
+
|
|
377
|
+
expect(mockFormatXAxisLabel).toHaveBeenCalledWith(
|
|
378
|
+
'2025-01-01T00:00:00Z',
|
|
379
|
+
true
|
|
380
|
+
);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it('should call formatXAxisAdditionalLabel with correct parameters', () => {
|
|
384
|
+
isGreaterThanTwoWeeksRef.current = false;
|
|
385
|
+
mockInstance.getOption.mockReturnValue({
|
|
386
|
+
dataZoom: [{ startValue: 0, endValue: 3 }],
|
|
387
|
+
xAxis: [],
|
|
388
|
+
});
|
|
389
|
+
mockIsDifferenceGreaterThanTwoWeeks.mockReturnValue(true);
|
|
390
|
+
|
|
391
|
+
handleLabelUpdate(
|
|
392
|
+
mockInstance,
|
|
393
|
+
mainData,
|
|
394
|
+
labelTimerRef,
|
|
395
|
+
isGreaterThanTwoWeeksRef
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
jest.advanceTimersByTime(50);
|
|
399
|
+
|
|
400
|
+
const setOptionCall = mockInstance.setOption.mock.calls[0][0] as {
|
|
401
|
+
xAxis: Array<{
|
|
402
|
+
id: string;
|
|
403
|
+
axisLabel: {
|
|
404
|
+
formatter: (value: unknown) => string;
|
|
405
|
+
customValues?: string[];
|
|
406
|
+
};
|
|
407
|
+
}>;
|
|
408
|
+
};
|
|
409
|
+
const additionalAxisFormatter =
|
|
410
|
+
setOptionCall.xAxis[1].axisLabel.formatter;
|
|
411
|
+
additionalAxisFormatter('2025-01-02T00:00:00Z');
|
|
412
|
+
|
|
413
|
+
expect(mockFormatXAxisAdditionalLabel).toHaveBeenCalledWith(
|
|
414
|
+
'2025-01-02T00:00:00Z',
|
|
415
|
+
true
|
|
416
|
+
);
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
});
|