@oanda/labs-crowd-view-widget 1.0.52 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +436 -0
- package/dist/main/CrowdViewWidget/Main.js +4 -6
- package/dist/main/CrowdViewWidget/Main.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +18 -31
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +7 -5
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +30 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +5 -52
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +54 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +65 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +60 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +53 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +31 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +42 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +75 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +116 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +14 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +42 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +14 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +108 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +83 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +15 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
- package/dist/main/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/index.js +8 -41
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js +65 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +65 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js +43 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +8 -2
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js +103 -0
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/index.js +11 -11
- package/dist/main/CrowdViewWidget/components/Chart/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +53 -30
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js +15 -13
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +12 -18
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/gql/getOrderPositionBooks.js +1 -1
- package/dist/main/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/main/gql/getPriceCandles.js +1 -1
- package/dist/main/gql/getPriceCandles.js.map +1 -1
- package/dist/main/gql/types/gql.js +2 -2
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +111 -18
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/translations/sources/en.json +2 -1
- package/dist/module/CrowdViewWidget/Main.js +3 -5
- package/dist/module/CrowdViewWidget/Main.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +20 -33
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +7 -5
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +23 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → chartOptions}/getGridLines.js +5 -52
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +46 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +58 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +53 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +46 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js +24 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +35 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +68 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.js +4 -4
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getChartStyles.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js +6 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +35 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js +7 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getRectColor.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +101 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +8 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js +8 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.js.map +1 -0
- package/dist/module/CrowdViewWidget/{utils/instrumentUtils.js → components/Chart/dataUtils/getInstrumentConfigForDivision.js} +3 -3
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getInstrumentConfigForDivision.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js +7 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js +58 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js +58 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js +36 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/processSentiments.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.js +8 -2
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/validateData.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js +96 -0
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/index.js +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +50 -27
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js +15 -13
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +5 -16
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +10 -17
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/gql/getOrderPositionBooks.js +1 -1
- package/dist/module/gql/getOrderPositionBooks.js.map +1 -1
- package/dist/module/gql/getPriceCandles.js +1 -1
- package/dist/module/gql/getPriceCandles.js.map +1 -1
- package/dist/module/gql/types/gql.js +2 -2
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +111 -18
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/translations/sources/en.json +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridLines.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +9 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +11 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +16 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +9 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +10 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.d.ts +2 -2
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getLabelData.d.ts +17 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getRectColor.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +10 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +7 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.d.ts +1 -0
- package/dist/types/CrowdViewWidget/{utils/instrumentUtils.d.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.d.ts} +2 -2
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/index.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.d.ts +11 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.d.ts +12 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/processSentiments.d.ts +6 -0
- package/dist/types/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/index.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +28 -11
- 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 +4 -12
- package/dist/types/gql/types/gql.d.ts +6 -4
- package/dist/types/gql/types/graphql.d.ts +30 -11
- package/package.json +3 -3
- package/src/CrowdViewWidget/Main.tsx +3 -4
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +25 -40
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +8 -4
- package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +13 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +29 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +84 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +52 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +82 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +63 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +63 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getVisualMapConfig.ts +32 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +43 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +77 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +10 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisLabel.ts +16 -0
- package/src/CrowdViewWidget/components/Chart/{utils → chartUtils}/getChartStyles.ts +9 -6
- package/src/CrowdViewWidget/components/Chart/chartUtils/getGradientColor.ts +16 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts +42 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getRectColor.ts +27 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +183 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +7 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/isDifferenceGreaterThanTwoWeeks.ts +13 -0
- package/src/CrowdViewWidget/{utils/instrumentUtils.ts → components/Chart/dataUtils/getInstrumentConfigForDivision.ts} +2 -2
- package/src/CrowdViewWidget/components/Chart/dataUtils/getTimeSpanForGranularity.ts +14 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/index.ts +6 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processOrderPositionBooks.ts +92 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processPriceCandles.ts +67 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/processSentiments.ts +55 -0
- package/src/CrowdViewWidget/components/Chart/{utils → dataUtils}/validateData.ts +10 -2
- package/src/CrowdViewWidget/components/Chart/getOption.ts +114 -0
- package/src/CrowdViewWidget/components/Chart/index.ts +1 -1
- package/src/CrowdViewWidget/components/Chart/types.ts +30 -19
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +84 -67
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +24 -23
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +13 -26
- package/src/CrowdViewWidget/constants.ts +21 -23
- package/src/gql/getOrderPositionBooks.ts +13 -5
- package/src/gql/getPriceCandles.ts +1 -0
- package/src/gql/types/gql.ts +6 -6
- package/src/gql/types/graphql.ts +98 -16
- package/src/translations/sources/en.json +2 -1
- package/test/components/Chart/utils/chartUtils.test.ts +39 -21
- package/test/components/Chart/utils/getChartStyles.test.ts +10 -10
- package/test/components/Chart/utils/processSentiments.test.ts +138 -30
- package/test/components/Legend.test.tsx +13 -21
- package/test/components/LegendBar.test.tsx +31 -51
- package/test/utils/instrumentUtils.test.ts +1 -1
- package/test/utils/processOrderPositionBooks.test.ts +201 -84
- package/test/utils/processPriceCandles.test.ts +93 -67
- package/test/utils/validateData.test.ts +136 -38
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +0 -359
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js +0 -37
- package/dist/main/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -127
- 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/getTargetBucketWidth.js +0 -14
- package/dist/main/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processBuckets.js +0 -29
- package/dist/main/CrowdViewWidget/components/Chart/utils/processBuckets.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +0 -23
- package/dist/main/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +0 -43
- package/dist/main/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/processSentiments.js +0 -28
- 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 -351
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js +0 -29
- package/dist/module/CrowdViewWidget/components/Chart/utils/aggregateBuckets.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +0 -114
- 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/getTargetBucketWidth.js +0 -7
- package/dist/module/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/index.js +0 -10
- package/dist/module/CrowdViewWidget/components/Chart/utils/index.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processBuckets.js +0 -22
- package/dist/module/CrowdViewWidget/components/Chart/utils/processBuckets.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js +0 -16
- package/dist/module/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js +0 -36
- package/dist/module/CrowdViewWidget/components/Chart/utils/processPriceCandles.js.map +0 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/processSentiments.js +0 -21
- 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/aggregateBuckets.d.ts +0 -2
- package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +0 -31
- package/dist/types/CrowdViewWidget/components/Chart/utils/getGridLines.d.ts +0 -97
- package/dist/types/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.d.ts +0 -3
- package/dist/types/CrowdViewWidget/components/Chart/utils/index.d.ts +0 -9
- package/dist/types/CrowdViewWidget/components/Chart/utils/processBuckets.d.ts +0 -3
- package/dist/types/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.d.ts +0 -8
- package/dist/types/CrowdViewWidget/components/Chart/utils/processPriceCandles.d.ts +0 -27
- package/dist/types/CrowdViewWidget/components/Chart/utils/processSentiments.d.ts +0 -3
- package/src/CrowdViewWidget/components/Chart/chartOptions.ts +0 -401
- package/src/CrowdViewWidget/components/Chart/utils/aggregateBuckets.ts +0 -44
- package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +0 -216
- package/src/CrowdViewWidget/components/Chart/utils/getGridLines.ts +0 -148
- package/src/CrowdViewWidget/components/Chart/utils/getTargetBucketWidth.ts +0 -13
- package/src/CrowdViewWidget/components/Chart/utils/index.ts +0 -9
- package/src/CrowdViewWidget/components/Chart/utils/processBuckets.ts +0 -43
- package/src/CrowdViewWidget/components/Chart/utils/processOrderPositionBooks.ts +0 -30
- package/src/CrowdViewWidget/components/Chart/utils/processPriceCandles.ts +0 -53
- package/src/CrowdViewWidget/components/Chart/utils/processSentiments.ts +0 -42
- package/test/utils/aggregateBuckets.test.ts +0 -82
- package/test/utils/getTargetBucketWidth.test.ts +0 -37
- package/test/utils/processBuckets.test.ts +0 -153
- /package/dist/types/CrowdViewWidget/components/Chart/{chartOptions.d.ts → getOption.d.ts} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GridComponentOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
4
|
+
|
|
5
|
+
interface GetGridConfigParams {
|
|
6
|
+
isDesktop: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const getGridConfig = ({
|
|
10
|
+
isDesktop,
|
|
11
|
+
}: GetGridConfigParams): GridComponentOption[] => [
|
|
12
|
+
{
|
|
13
|
+
id: 'main-grid',
|
|
14
|
+
name: 'main-grid',
|
|
15
|
+
left: `${CHART_CONFIG.Y_SENTIMENT_LABEL_SIZE}px`,
|
|
16
|
+
right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
|
|
17
|
+
top: '0px',
|
|
18
|
+
bottom: `${CHART_CONFIG.X_LABEL_SIZE}px`,
|
|
19
|
+
height: `${CHART_CONFIG.MAIN_HEIGHT}px`,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'sentiment-grid',
|
|
23
|
+
name: 'sentiment-grid',
|
|
24
|
+
left: `${CHART_CONFIG.Y_SENTIMENT_LABEL_SIZE}px`,
|
|
25
|
+
right: `${isDesktop ? CHART_CONFIG.Y_LABEL_SIZE_DESKTOP : CHART_CONFIG.Y_LABEL_SIZE_MOBILE}px`,
|
|
26
|
+
top: `0px`,
|
|
27
|
+
height: `${CHART_CONFIG.MAIN_HEIGHT}px`,
|
|
28
|
+
},
|
|
29
|
+
];
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { getLineCommons } from '@oanda/labs-widget-common';
|
|
2
|
+
import type { GraphicComponentOption } from 'echarts';
|
|
3
|
+
|
|
4
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
5
|
+
|
|
6
|
+
interface GetGridLinesParams {
|
|
7
|
+
isDark: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getGridLines = ({
|
|
11
|
+
isDark,
|
|
12
|
+
}: GetGridLinesParams): GraphicComponentOption[] => {
|
|
13
|
+
const { WIDTH, MAIN_HEIGHT, X_LABEL_SIZE, Y_SENTIMENT_LABEL_SIZE } =
|
|
14
|
+
CHART_CONFIG;
|
|
15
|
+
return [
|
|
16
|
+
// Top
|
|
17
|
+
{
|
|
18
|
+
...getLineCommons(isDark),
|
|
19
|
+
top: -2,
|
|
20
|
+
shape: {
|
|
21
|
+
x1: 0,
|
|
22
|
+
y1: 0,
|
|
23
|
+
x2: WIDTH,
|
|
24
|
+
y2: 0,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
// Right
|
|
28
|
+
{
|
|
29
|
+
...getLineCommons(isDark),
|
|
30
|
+
right: -2,
|
|
31
|
+
shape: {
|
|
32
|
+
x1: 0,
|
|
33
|
+
y1: 0,
|
|
34
|
+
x2: 0,
|
|
35
|
+
y2: MAIN_HEIGHT + X_LABEL_SIZE + 2,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
// Bottom
|
|
39
|
+
{
|
|
40
|
+
...getLineCommons(isDark),
|
|
41
|
+
bottom: -2,
|
|
42
|
+
shape: {
|
|
43
|
+
x1: 0,
|
|
44
|
+
y1: 0,
|
|
45
|
+
x2: WIDTH,
|
|
46
|
+
y2: 0,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
// Left
|
|
50
|
+
{
|
|
51
|
+
...getLineCommons(isDark),
|
|
52
|
+
left: -2,
|
|
53
|
+
shape: {
|
|
54
|
+
x1: 0,
|
|
55
|
+
y1: 0,
|
|
56
|
+
x2: 0,
|
|
57
|
+
y2: MAIN_HEIGHT + X_LABEL_SIZE + 2,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
// Y Sentiment Label
|
|
61
|
+
{
|
|
62
|
+
...getLineCommons(isDark),
|
|
63
|
+
left: Y_SENTIMENT_LABEL_SIZE - 2,
|
|
64
|
+
top: -2,
|
|
65
|
+
shape: {
|
|
66
|
+
x1: 0,
|
|
67
|
+
y1: 0,
|
|
68
|
+
x2: 0,
|
|
69
|
+
y2: MAIN_HEIGHT,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
// X Label
|
|
73
|
+
{
|
|
74
|
+
...getLineCommons(isDark),
|
|
75
|
+
top: MAIN_HEIGHT - 2,
|
|
76
|
+
shape: {
|
|
77
|
+
x1: 0,
|
|
78
|
+
y1: 0,
|
|
79
|
+
x2: WIDTH,
|
|
80
|
+
y2: 0,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import chroma from 'chroma-js';
|
|
2
|
+
import type { CandlestickSeriesOption } from 'echarts';
|
|
3
|
+
|
|
4
|
+
import { getLabelData } from '../chartUtils';
|
|
5
|
+
import type { ChartStyles } from '../chartUtils/getChartStyles';
|
|
6
|
+
|
|
7
|
+
interface GetSeriesCandlestickConfigParams {
|
|
8
|
+
dates: string[];
|
|
9
|
+
isGreaterThanTwoWeeks: boolean;
|
|
10
|
+
styles: ChartStyles;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const getSeriesCandlestickConfig = ({
|
|
14
|
+
dates,
|
|
15
|
+
isGreaterThanTwoWeeks,
|
|
16
|
+
styles,
|
|
17
|
+
}: GetSeriesCandlestickConfigParams): CandlestickSeriesOption => {
|
|
18
|
+
const { candleLongColor, candleShortColor } = styles;
|
|
19
|
+
const labelsData = getLabelData({
|
|
20
|
+
dates,
|
|
21
|
+
isGreaterThanTwoWeeks,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
type: 'candlestick',
|
|
26
|
+
id: 'candlestick',
|
|
27
|
+
xAxisIndex: 0,
|
|
28
|
+
yAxisIndex: 0,
|
|
29
|
+
encode: {
|
|
30
|
+
x: 'dates',
|
|
31
|
+
y: ['open', 'close', 'low', 'high'],
|
|
32
|
+
},
|
|
33
|
+
itemStyle: {
|
|
34
|
+
color: chroma(candleLongColor).desaturate().css(),
|
|
35
|
+
color0: chroma(candleShortColor).desaturate().css(),
|
|
36
|
+
borderColor: candleLongColor,
|
|
37
|
+
borderColor0: candleShortColor,
|
|
38
|
+
},
|
|
39
|
+
emphasis: {
|
|
40
|
+
itemStyle: {
|
|
41
|
+
color: candleLongColor,
|
|
42
|
+
color0: candleShortColor,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
markPoint: {
|
|
46
|
+
data: labelsData,
|
|
47
|
+
symbol: 'circle',
|
|
48
|
+
symbolSize: 0,
|
|
49
|
+
},
|
|
50
|
+
z: 2,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomSeriesOption,
|
|
3
|
+
CustomSeriesRenderItemAPI,
|
|
4
|
+
CustomSeriesRenderItemParams,
|
|
5
|
+
} from 'echarts';
|
|
6
|
+
|
|
7
|
+
import { getRectColor } from '../chartUtils';
|
|
8
|
+
import type { Bucket } from '../types';
|
|
9
|
+
|
|
10
|
+
interface GetSeriesHeatmapConfigParams {
|
|
11
|
+
bucketWidth: number;
|
|
12
|
+
buckets: Bucket[][];
|
|
13
|
+
isDark: boolean;
|
|
14
|
+
sentimentThresholdMax: number;
|
|
15
|
+
sentimentThresholdMin: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const getSeriesHeatmapConfig = ({
|
|
19
|
+
bucketWidth,
|
|
20
|
+
buckets,
|
|
21
|
+
isDark,
|
|
22
|
+
sentimentThresholdMax,
|
|
23
|
+
sentimentThresholdMin,
|
|
24
|
+
}: GetSeriesHeatmapConfigParams): CustomSeriesOption => {
|
|
25
|
+
return {
|
|
26
|
+
type: 'custom',
|
|
27
|
+
id: 'heatmap',
|
|
28
|
+
name: 'heatmap',
|
|
29
|
+
xAxisIndex: 0,
|
|
30
|
+
yAxisIndex: 0,
|
|
31
|
+
encode: {
|
|
32
|
+
x: 'dates',
|
|
33
|
+
y: 'bookPrices',
|
|
34
|
+
},
|
|
35
|
+
dimensions: ['dates', 'bookPrices', 'bookIndexes'],
|
|
36
|
+
clip: true,
|
|
37
|
+
renderItem: (
|
|
38
|
+
_params: CustomSeriesRenderItemParams,
|
|
39
|
+
api: CustomSeriesRenderItemAPI
|
|
40
|
+
) => {
|
|
41
|
+
const xVal = api.value(0);
|
|
42
|
+
const bucketIndex = api.value(2) as number;
|
|
43
|
+
|
|
44
|
+
if (bucketIndex == null) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const metaValues = buckets[bucketIndex];
|
|
49
|
+
|
|
50
|
+
const [rectWidth, rectHeight] = api.size!([0, bucketWidth]) as number[];
|
|
51
|
+
|
|
52
|
+
const items = metaValues.map(({ price, sentiment }: Bucket) => {
|
|
53
|
+
const start = api.coord([xVal, price]);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
shape: {
|
|
57
|
+
height: rectHeight,
|
|
58
|
+
width: rectWidth + 1,
|
|
59
|
+
x: start[0] - rectWidth / 2,
|
|
60
|
+
y: start[1] - rectHeight,
|
|
61
|
+
},
|
|
62
|
+
style: {
|
|
63
|
+
fill: getRectColor(
|
|
64
|
+
sentiment,
|
|
65
|
+
isDark,
|
|
66
|
+
sentimentThresholdMin,
|
|
67
|
+
sentimentThresholdMax
|
|
68
|
+
),
|
|
69
|
+
},
|
|
70
|
+
type: 'rect' as const,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
children: items,
|
|
76
|
+
emphasisDisabled: true,
|
|
77
|
+
type: 'group' as const,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
z: 1,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
|
+
import type { LineSeriesOption } from 'echarts';
|
|
3
|
+
|
|
4
|
+
import type { ChartStyles } from '../chartUtils';
|
|
5
|
+
|
|
6
|
+
interface GetSeriesSentimentConfigParams {
|
|
7
|
+
styles: ChartStyles;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getSeriesSentimentConfig = ({
|
|
11
|
+
styles,
|
|
12
|
+
}: GetSeriesSentimentConfigParams): LineSeriesOption => {
|
|
13
|
+
return {
|
|
14
|
+
type: 'line',
|
|
15
|
+
id: 'sentiment',
|
|
16
|
+
name: 'sentiment',
|
|
17
|
+
xAxisIndex: 1,
|
|
18
|
+
yAxisIndex: 1,
|
|
19
|
+
encode: {
|
|
20
|
+
x: 'dates',
|
|
21
|
+
y: 'sentimentShorts',
|
|
22
|
+
},
|
|
23
|
+
dimensions: ['dates', 'sentimentShorts', 'sentimentLongs'],
|
|
24
|
+
lineStyle: {
|
|
25
|
+
width: styles.sentimentOutlineWidth,
|
|
26
|
+
opacity: 1,
|
|
27
|
+
shadowColor: styles.sentimentOutlineColor,
|
|
28
|
+
shadowBlur: 3,
|
|
29
|
+
},
|
|
30
|
+
emphasis: {
|
|
31
|
+
disabled: true,
|
|
32
|
+
},
|
|
33
|
+
markLine: {
|
|
34
|
+
silent: true,
|
|
35
|
+
symbol: ['none', 'none'],
|
|
36
|
+
label: {
|
|
37
|
+
show: false,
|
|
38
|
+
},
|
|
39
|
+
lineStyle: {
|
|
40
|
+
color: colorPalette.grayLight,
|
|
41
|
+
width: 1,
|
|
42
|
+
},
|
|
43
|
+
data: [
|
|
44
|
+
{
|
|
45
|
+
yAxis: 20,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
yAxis: 50,
|
|
49
|
+
lineStyle: {
|
|
50
|
+
width: 1,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
yAxis: 80,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
stack: 'sentiment',
|
|
59
|
+
showSymbol: false,
|
|
60
|
+
symbol: 'none',
|
|
61
|
+
z: 3,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { TooltipComponentOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import type { BookType } from '../../../../gql/types/graphql';
|
|
4
|
+
import { getTooltipFormatter } from '../chartUtils';
|
|
5
|
+
import type { Bucket, TooltipParam } from '../types';
|
|
6
|
+
|
|
7
|
+
interface GetTooltipConfigParams {
|
|
8
|
+
bookType: BookType;
|
|
9
|
+
bucketWidth: number;
|
|
10
|
+
buckets: Bucket[][];
|
|
11
|
+
displayPrecision: number;
|
|
12
|
+
labelCallback: (key: string, params?: Record<string, unknown>) => string;
|
|
13
|
+
selectedPriceRef: { current: number };
|
|
14
|
+
tooltipLinesColor: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const getTooltipConfig = ({
|
|
18
|
+
bookType,
|
|
19
|
+
bucketWidth,
|
|
20
|
+
buckets,
|
|
21
|
+
displayPrecision,
|
|
22
|
+
labelCallback,
|
|
23
|
+
selectedPriceRef,
|
|
24
|
+
tooltipLinesColor,
|
|
25
|
+
}: GetTooltipConfigParams): TooltipComponentOption => ({
|
|
26
|
+
trigger: 'axis' as const,
|
|
27
|
+
formatter: (params) =>
|
|
28
|
+
getTooltipFormatter({
|
|
29
|
+
bookType,
|
|
30
|
+
bucketWidth,
|
|
31
|
+
buckets,
|
|
32
|
+
labelCallback,
|
|
33
|
+
params: params as unknown as TooltipParam[],
|
|
34
|
+
selectedPrice: selectedPriceRef.current,
|
|
35
|
+
}),
|
|
36
|
+
|
|
37
|
+
axisPointer: {
|
|
38
|
+
type: 'cross' as const,
|
|
39
|
+
axis: 'x' as const,
|
|
40
|
+
lineStyle: {
|
|
41
|
+
color: tooltipLinesColor,
|
|
42
|
+
},
|
|
43
|
+
crossStyle: {
|
|
44
|
+
color: tooltipLinesColor,
|
|
45
|
+
},
|
|
46
|
+
label: {
|
|
47
|
+
padding: 0,
|
|
48
|
+
lineHeight: 24,
|
|
49
|
+
formatter: (params: {
|
|
50
|
+
axisDimension?: string;
|
|
51
|
+
axisIndex?: number;
|
|
52
|
+
value: unknown;
|
|
53
|
+
}) => {
|
|
54
|
+
if (params.axisDimension === 'y' && params.axisIndex === 0) {
|
|
55
|
+
selectedPriceRef.current = Number(params.value);
|
|
56
|
+
return ` ${Number(params.value).toFixed(displayPrecision)} `;
|
|
57
|
+
}
|
|
58
|
+
return '';
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
confine: true,
|
|
63
|
+
});
|
|
@@ -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,43 @@
|
|
|
1
|
+
import type { XAXisComponentOption } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import { formatXAxisLabel } from '../chartUtils';
|
|
4
|
+
|
|
5
|
+
interface GetXAxisConfigParams {
|
|
6
|
+
dates: string[];
|
|
7
|
+
isGreaterThanTwoWeeks: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getXAxisConfig = ({
|
|
11
|
+
dates,
|
|
12
|
+
isGreaterThanTwoWeeks,
|
|
13
|
+
}: GetXAxisConfigParams): XAXisComponentOption[] => [
|
|
14
|
+
{
|
|
15
|
+
type: 'category',
|
|
16
|
+
id: 'main-xAxis',
|
|
17
|
+
name: 'xAxis-less-than-two-weeks',
|
|
18
|
+
nameTextStyle: {
|
|
19
|
+
fontSize: 0,
|
|
20
|
+
},
|
|
21
|
+
axisTick: {
|
|
22
|
+
show: false,
|
|
23
|
+
},
|
|
24
|
+
axisLabel: {
|
|
25
|
+
padding: [8, 16, 8, 16],
|
|
26
|
+
margin: 0,
|
|
27
|
+
formatter: (value: unknown) =>
|
|
28
|
+
formatXAxisLabel(value, isGreaterThanTwoWeeks),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'category',
|
|
33
|
+
gridIndex: 1,
|
|
34
|
+
show: false,
|
|
35
|
+
axisTick: {
|
|
36
|
+
show: false,
|
|
37
|
+
},
|
|
38
|
+
axisLabel: {
|
|
39
|
+
show: false,
|
|
40
|
+
},
|
|
41
|
+
data: dates,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
isDesktop: boolean;
|
|
9
|
+
labelCallback: (key: string, params?: Record<string, unknown>) => string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const getYAxisConfig = ({
|
|
13
|
+
bucketWidth,
|
|
14
|
+
displayPrecision,
|
|
15
|
+
isDesktop,
|
|
16
|
+
labelCallback,
|
|
17
|
+
}: GetYAxisConfigParams): YAXisComponentOption[] => [
|
|
18
|
+
{
|
|
19
|
+
type: 'value',
|
|
20
|
+
gridIndex: 0,
|
|
21
|
+
position: 'right',
|
|
22
|
+
min: (val: { min: number }) =>
|
|
23
|
+
val.min - bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
|
|
24
|
+
max: (val: { max: number }) =>
|
|
25
|
+
val.max + bucketWidth * BUCKET_CONFIG.PRICE_MARGIN_MULTIPLIER,
|
|
26
|
+
axisLine: { show: false },
|
|
27
|
+
axisTick: { show: false },
|
|
28
|
+
axisLabel: {
|
|
29
|
+
showMinLabel: false,
|
|
30
|
+
showMaxLabel: false,
|
|
31
|
+
formatter: (value: number) => value.toFixed(displayPrecision - 1),
|
|
32
|
+
},
|
|
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: {
|
|
43
|
+
show: false,
|
|
44
|
+
},
|
|
45
|
+
axisLabel: {
|
|
46
|
+
margin: isDesktop ? 4 : 2,
|
|
47
|
+
lineHeight: 20,
|
|
48
|
+
verticalAlignMinLabel: 'bottom',
|
|
49
|
+
verticalAlignMaxLabel: 'top',
|
|
50
|
+
customValues: [
|
|
51
|
+
CHART_CONFIG.SENTIMENT_MIN,
|
|
52
|
+
CHART_CONFIG.SENTIMENT_MAX / 5,
|
|
53
|
+
CHART_CONFIG.SENTIMENT_MAX / 2,
|
|
54
|
+
(CHART_CONFIG.SENTIMENT_MAX * 4) / 5,
|
|
55
|
+
CHART_CONFIG.SENTIMENT_MAX,
|
|
56
|
+
],
|
|
57
|
+
formatter: (value: number) => {
|
|
58
|
+
if (value === CHART_CONFIG.SENTIMENT_MIN) {
|
|
59
|
+
return `${labelCallback('short')}`;
|
|
60
|
+
}
|
|
61
|
+
if (value === CHART_CONFIG.SENTIMENT_MAX) {
|
|
62
|
+
return `${labelCallback('long')}`;
|
|
63
|
+
}
|
|
64
|
+
if (value === CHART_CONFIG.SENTIMENT_MAX / 2) {
|
|
65
|
+
return '50%';
|
|
66
|
+
}
|
|
67
|
+
if (value === CHART_CONFIG.SENTIMENT_MAX / 5) {
|
|
68
|
+
return '80%';
|
|
69
|
+
}
|
|
70
|
+
if (value === (CHART_CONFIG.SENTIMENT_MAX * 4) / 5) {
|
|
71
|
+
return '20%';
|
|
72
|
+
}
|
|
73
|
+
return '';
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './getDataZoomConfig';
|
|
2
|
+
export * from './getGridConfig';
|
|
3
|
+
export * from './getGridLines';
|
|
4
|
+
export * from './getSeriesCandlestickConfig';
|
|
5
|
+
export * from './getSeriesHeatmapConfig';
|
|
6
|
+
export * from './getSeriesSentimentConfig';
|
|
7
|
+
export * from './getTooltipConfig';
|
|
8
|
+
export * from './getVisualMapConfig';
|
|
9
|
+
export * from './getXAxisConfig';
|
|
10
|
+
export * from './getYAxisConfig';
|
|
@@ -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,42 @@
|
|
|
1
|
+
import { CHART_CONFIG } from '../../../constants';
|
|
2
|
+
import type { GetLabelsDataProps } from '../types';
|
|
3
|
+
|
|
4
|
+
export const getLabelData = ({
|
|
5
|
+
dates,
|
|
6
|
+
isGreaterThanTwoWeeks,
|
|
7
|
+
}: GetLabelsDataProps) =>
|
|
8
|
+
dates
|
|
9
|
+
.filter((record, index, arr) => {
|
|
10
|
+
if (index === 0) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
const previousTimestamp = arr[index - 1];
|
|
14
|
+
const currentDate = new Date(record);
|
|
15
|
+
const previousDate = new Date(previousTimestamp);
|
|
16
|
+
|
|
17
|
+
return isGreaterThanTwoWeeks
|
|
18
|
+
? currentDate.getDate() !== previousDate.getDate()
|
|
19
|
+
: currentDate.getMonth() !== previousDate.getMonth();
|
|
20
|
+
})
|
|
21
|
+
.map(
|
|
22
|
+
(item) =>
|
|
23
|
+
({
|
|
24
|
+
name: new Date(item).toLocaleDateString(undefined, {
|
|
25
|
+
month: isGreaterThanTwoWeeks ? 'short' : 'long',
|
|
26
|
+
day: isGreaterThanTwoWeeks ? 'numeric' : undefined,
|
|
27
|
+
}),
|
|
28
|
+
xAxis: item,
|
|
29
|
+
y: CHART_CONFIG.MAIN_HEIGHT + CHART_CONFIG.X_LABEL_SIZE - 22,
|
|
30
|
+
silent: true,
|
|
31
|
+
emphasis: {
|
|
32
|
+
disabled: true,
|
|
33
|
+
},
|
|
34
|
+
label: {
|
|
35
|
+
fontFamily: 'Sofia W03',
|
|
36
|
+
fontSize: 10,
|
|
37
|
+
position: 'bottom' as const,
|
|
38
|
+
align: 'center' as const,
|
|
39
|
+
formatter: '{b}',
|
|
40
|
+
},
|
|
41
|
+
}) as const
|
|
42
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { COLOR_MAP } from '../../../constants';
|
|
2
|
+
import { getGradientColor } from './getGradientColor';
|
|
3
|
+
|
|
4
|
+
export const getRectColor = (
|
|
5
|
+
sentiment: number,
|
|
6
|
+
isDark: boolean,
|
|
7
|
+
minThreshold: number,
|
|
8
|
+
maxThreshold: number
|
|
9
|
+
) => {
|
|
10
|
+
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
11
|
+
|
|
12
|
+
return sentiment < 0
|
|
13
|
+
? getGradientColor(
|
|
14
|
+
sentiment * -1,
|
|
15
|
+
colorPalette.short[0],
|
|
16
|
+
colorPalette.short[1],
|
|
17
|
+
minThreshold,
|
|
18
|
+
maxThreshold
|
|
19
|
+
)
|
|
20
|
+
: getGradientColor(
|
|
21
|
+
sentiment,
|
|
22
|
+
colorPalette.long[0],
|
|
23
|
+
colorPalette.long[1],
|
|
24
|
+
minThreshold,
|
|
25
|
+
maxThreshold
|
|
26
|
+
);
|
|
27
|
+
};
|