@elliemae/ds-dataviz 3.80.0-next.65 → 3.80.0-next.69
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/dist/cjs/constants/index.js +73 -0
- package/dist/cjs/constants/index.js.map +7 -0
- package/dist/cjs/graphs/Chart/Chart.js +6 -1
- package/dist/cjs/graphs/Chart/Chart.js.map +2 -2
- package/dist/cjs/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/cjs/graphs/Chart/SingleStackedBar/SingleStackedBar.js +36 -24
- package/dist/cjs/graphs/Chart/SingleStackedBar/SingleStackedBar.js.map +3 -3
- package/dist/cjs/graphs/Chart/SingleStackedBar/styles.js +12 -5
- package/dist/cjs/graphs/Chart/SingleStackedBar/styles.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/chartInteractionStore.js +98 -0
- package/dist/cjs/graphs/Chart/config/chartInteractionStore.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useChart.js +56 -40
- package/dist/cjs/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useChartDescription.js +62 -0
- package/dist/cjs/graphs/Chart/config/useChartDescription.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useEntranceAnimation.js +141 -0
- package/dist/cjs/graphs/Chart/config/useEntranceAnimation.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useGetters.js +10 -0
- package/dist/cjs/graphs/Chart/config/useGetters.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js +25 -5
- package/dist/cjs/graphs/Chart/config/useInternalMargins.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js +35 -51
- package/dist/cjs/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useScales.js +200 -67
- package/dist/cjs/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useValidateProps.js +53 -4
- package/dist/cjs/graphs/Chart/config/useValidateProps.js.map +2 -2
- package/dist/cjs/graphs/Chart/config/useValueAxisTransition.js +128 -0
- package/dist/cjs/graphs/Chart/config/useValueAxisTransition.js.map +7 -0
- package/dist/cjs/graphs/Chart/config/useWheelScroll.js +111 -0
- package/dist/cjs/graphs/Chart/config/useWheelScroll.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/alignedTicks.js +56 -0
- package/dist/cjs/graphs/Chart/helpers/alignedTicks.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/barPath.js +53 -0
- package/dist/cjs/graphs/Chart/helpers/barPath.js.map +7 -0
- package/dist/cjs/graphs/Chart/{react-desc-prop-types.js → helpers/dataInView.js} +26 -27
- package/dist/cjs/graphs/Chart/helpers/dataInView.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/index.js +34 -0
- package/dist/cjs/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/cjs/graphs/Chart/{SingleStackedBar/exported-related/theming.js → helpers/logAxis.js} +13 -9
- package/dist/cjs/graphs/Chart/helpers/logAxis.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/tickRotation.js +54 -0
- package/dist/cjs/graphs/Chart/helpers/tickRotation.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/timeTicks.js +56 -0
- package/dist/cjs/graphs/Chart/helpers/timeTicks.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/trend.js +45 -0
- package/dist/cjs/graphs/Chart/helpers/trend.js.map +7 -0
- package/dist/cjs/graphs/Chart/{SingleStackedBar/exported-related/index.js → helpers/useSerieDimming.js} +20 -6
- package/dist/cjs/graphs/Chart/helpers/useSerieDimming.js.map +7 -0
- package/dist/cjs/graphs/Chart/helpers/useUniqueData.js +15 -18
- package/dist/cjs/graphs/Chart/helpers/useUniqueData.js.map +2 -2
- package/dist/cjs/graphs/Chart/helpers/useVirtualizedSeries.js +12 -5
- package/dist/cjs/graphs/Chart/helpers/useVirtualizedSeries.js.map +2 -2
- package/dist/cjs/graphs/Chart/{DataTestIds.js → helpers/zeroLine.js} +12 -9
- package/dist/cjs/graphs/Chart/helpers/zeroLine.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/A11yRegion.js +8 -2
- package/dist/cjs/graphs/Chart/parts/A11yRegion.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/Axis.js +40 -4
- package/dist/cjs/graphs/Chart/parts/Axis/Axis.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js +18 -4
- package/dist/cjs/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js +14 -6
- package/dist/cjs/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js +14 -4
- package/dist/cjs/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/GridLine.js +15 -1
- package/dist/cjs/graphs/Chart/parts/Axis/GridLine.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/Tick.js +10 -4
- package/dist/cjs/graphs/Chart/parts/Axis/Tick.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Axis/useTickTransition.js +170 -0
- package/dist/cjs/graphs/Chart/parts/Axis/useTickTransition.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js +41 -19
- package/dist/cjs/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.js +6 -3
- package/dist/cjs/graphs/Chart/parts/FocusableRegion.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/HoverBand.js +86 -0
- package/dist/cjs/graphs/Chart/parts/HoverBand.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Labels/Label.js +12 -1
- package/dist/cjs/graphs/Chart/parts/Labels/Label.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Labels/index.js +12 -4
- package/dist/cjs/graphs/Chart/parts/Labels/index.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js +6 -3
- package/dist/cjs/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js +2 -6
- package/dist/cjs/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js +91 -9
- package/dist/cjs/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js +3 -4
- package/dist/cjs/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js +8 -6
- package/dist/cjs/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js +29 -3
- package/dist/cjs/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js +82 -55
- package/dist/cjs/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +3 -3
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js +14 -6
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +67 -43
- package/dist/cjs/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
- package/dist/cjs/graphs/Chart/{SingleStackedBar/exported-related/data-test-ids.js → parts/ScreenReaderText.js} +17 -7
- package/dist/cjs/graphs/Chart/parts/ScreenReaderText.js.map +7 -0
- package/dist/cjs/graphs/Chart/parts/Scroller/BlurMask.js +14 -9
- package/dist/cjs/graphs/Chart/parts/Scroller/BlurMask.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js +152 -49
- package/dist/cjs/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarX.js +22 -6
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarY.js +13 -6
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollBarY.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js +42 -35
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerY.js +9 -4
- package/dist/cjs/graphs/Chart/parts/Scroller/ScrollableContainerY.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js +39 -30
- package/dist/cjs/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/TrendHighlight.js +57 -19
- package/dist/cjs/graphs/Chart/parts/TrendHighlight.js.map +2 -2
- package/dist/cjs/graphs/Chart/parts/ZeroLine.js +66 -0
- package/dist/cjs/graphs/Chart/parts/ZeroLine.js.map +7 -0
- package/dist/cjs/graphs/Chart/scales/index.js +50 -20
- package/dist/cjs/graphs/Chart/scales/index.js.map +3 -3
- package/dist/cjs/graphs/Chart/series/Area.js +76 -9
- package/dist/cjs/graphs/Chart/series/Area.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Bars.js +3 -1
- package/dist/cjs/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js +4 -1
- package/dist/cjs/graphs/Chart/series/HorizontalBars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js +14 -7
- package/dist/cjs/graphs/Chart/series/HorizontalStackedBars.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Line.js +9 -7
- package/dist/cjs/graphs/Chart/series/Line.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Point.js +114 -128
- package/dist/cjs/graphs/Chart/series/Point.js.map +3 -3
- package/dist/cjs/graphs/Chart/series/Points.js +8 -2
- package/dist/cjs/graphs/Chart/series/Points.js.map +2 -2
- package/dist/cjs/graphs/Chart/series/Rect.js +133 -122
- package/dist/cjs/graphs/Chart/series/Rect.js.map +3 -3
- package/dist/cjs/graphs/Chart/series/StackedBar.js +14 -6
- package/dist/cjs/graphs/Chart/series/StackedBar.js.map +2 -2
- package/dist/cjs/graphs/Chart/styles.js +65 -34
- package/dist/cjs/graphs/Chart/styles.js.map +2 -2
- package/dist/cjs/graphs/constants.js +24 -9
- package/dist/cjs/graphs/constants.js.map +2 -2
- package/dist/cjs/index.js +17 -6
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/react-desc-prop-types.js +150 -0
- package/dist/cjs/react-desc-prop-types.js.map +7 -0
- package/dist/cjs/typescript-testing/slot-props.js +69 -0
- package/dist/cjs/typescript-testing/slot-props.js.map +7 -0
- package/dist/cjs/typescript-testing/typescript-data-viz-valid.js +34 -2
- package/dist/cjs/typescript-testing/typescript-data-viz-valid.js.map +2 -2
- package/dist/cjs/typescript-testing/typescript-single-stacked-bar-valid.js +93 -0
- package/dist/cjs/typescript-testing/typescript-single-stacked-bar-valid.js.map +7 -0
- package/dist/esm/constants/index.js +43 -0
- package/dist/esm/constants/index.js.map +7 -0
- package/dist/esm/graphs/Chart/Chart.js +6 -1
- package/dist/esm/graphs/Chart/Chart.js.map +2 -2
- package/dist/esm/graphs/Chart/ChartContext.js.map +2 -2
- package/dist/esm/graphs/Chart/SingleStackedBar/SingleStackedBar.js +40 -23
- package/dist/esm/graphs/Chart/SingleStackedBar/SingleStackedBar.js.map +2 -2
- package/dist/esm/graphs/Chart/SingleStackedBar/styles.js +12 -5
- package/dist/esm/graphs/Chart/SingleStackedBar/styles.js.map +2 -2
- package/dist/esm/graphs/Chart/config/chartInteractionStore.js +68 -0
- package/dist/esm/graphs/Chart/config/chartInteractionStore.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useChart.js +58 -42
- package/dist/esm/graphs/Chart/config/useChart.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useChartDescription.js +32 -0
- package/dist/esm/graphs/Chart/config/useChartDescription.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useEntranceAnimation.js +111 -0
- package/dist/esm/graphs/Chart/config/useEntranceAnimation.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useGetters.js +10 -0
- package/dist/esm/graphs/Chart/config/useGetters.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useInternalMargins.js +26 -6
- package/dist/esm/graphs/Chart/config/useInternalMargins.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js +35 -51
- package/dist/esm/graphs/Chart/config/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useScales.js +202 -69
- package/dist/esm/graphs/Chart/config/useScales.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useValidateProps.js +53 -4
- package/dist/esm/graphs/Chart/config/useValidateProps.js.map +2 -2
- package/dist/esm/graphs/Chart/config/useValueAxisTransition.js +98 -0
- package/dist/esm/graphs/Chart/config/useValueAxisTransition.js.map +7 -0
- package/dist/esm/graphs/Chart/config/useWheelScroll.js +81 -0
- package/dist/esm/graphs/Chart/config/useWheelScroll.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/alignedTicks.js +26 -0
- package/dist/esm/graphs/Chart/helpers/alignedTicks.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/barPath.js +23 -0
- package/dist/esm/graphs/Chart/helpers/barPath.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/dataInView.js +28 -0
- package/dist/esm/graphs/Chart/helpers/dataInView.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/index.js +34 -0
- package/dist/esm/graphs/Chart/helpers/index.js.map +2 -2
- package/dist/esm/graphs/Chart/helpers/logAxis.js +14 -0
- package/dist/esm/graphs/Chart/helpers/logAxis.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/tickRotation.js +24 -0
- package/dist/esm/graphs/Chart/helpers/tickRotation.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/timeTicks.js +26 -0
- package/dist/esm/graphs/Chart/helpers/timeTicks.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/trend.js +15 -0
- package/dist/esm/graphs/Chart/helpers/trend.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/useSerieDimming.js +15 -0
- package/dist/esm/graphs/Chart/helpers/useSerieDimming.js.map +7 -0
- package/dist/esm/graphs/Chart/helpers/useUniqueData.js +15 -18
- package/dist/esm/graphs/Chart/helpers/useUniqueData.js.map +2 -2
- package/dist/esm/graphs/Chart/helpers/useVirtualizedSeries.js +12 -5
- package/dist/esm/graphs/Chart/helpers/useVirtualizedSeries.js.map +2 -2
- package/dist/esm/graphs/Chart/helpers/zeroLine.js +13 -0
- package/dist/esm/graphs/Chart/helpers/zeroLine.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/A11yRegion.js +7 -1
- package/dist/esm/graphs/Chart/parts/A11yRegion.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/Axis.js +40 -4
- package/dist/esm/graphs/Chart/parts/Axis/Axis.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js +18 -4
- package/dist/esm/graphs/Chart/parts/Axis/AxisBottom.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js +14 -6
- package/dist/esm/graphs/Chart/parts/Axis/AxisLeft.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js +14 -4
- package/dist/esm/graphs/Chart/parts/Axis/AxisRight.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/GridLine.js +16 -2
- package/dist/esm/graphs/Chart/parts/Axis/GridLine.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/Tick.js +11 -5
- package/dist/esm/graphs/Chart/parts/Axis/Tick.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Axis/useTickTransition.js +140 -0
- package/dist/esm/graphs/Chart/parts/Axis/useTickTransition.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/ChartContainer.js +41 -19
- package/dist/esm/graphs/Chart/parts/ChartContainer.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/FocusableRegion.js +7 -4
- package/dist/esm/graphs/Chart/parts/FocusableRegion.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/HoverBand.js +56 -0
- package/dist/esm/graphs/Chart/parts/HoverBand.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Labels/Label.js +12 -1
- package/dist/esm/graphs/Chart/parts/Labels/Label.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Labels/index.js +12 -4
- package/dist/esm/graphs/Chart/parts/Labels/index.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js +7 -4
- package/dist/esm/graphs/Chart/parts/Legend/BottomLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js +3 -7
- package/dist/esm/graphs/Chart/parts/Legend/LeftLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js +91 -9
- package/dist/esm/graphs/Chart/parts/Legend/LegendItem.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js +4 -5
- package/dist/esm/graphs/Chart/parts/Legend/RightLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js +9 -7
- package/dist/esm/graphs/Chart/parts/Legend/TopLegend.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js +29 -3
- package/dist/esm/graphs/Chart/parts/Scrapper/Scrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js +83 -56
- package/dist/esm/graphs/Chart/parts/Scrapper/ScrapperLine.js.map +3 -3
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js +14 -6
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapper.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js +68 -44
- package/dist/esm/graphs/Chart/parts/Scrapper/VerticalScrapperLine.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ScreenReaderText.js +18 -0
- package/dist/esm/graphs/Chart/parts/ScreenReaderText.js.map +7 -0
- package/dist/esm/graphs/Chart/parts/Scroller/BlurMask.js +14 -9
- package/dist/esm/graphs/Chart/parts/Scroller/BlurMask.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js +154 -51
- package/dist/esm/graphs/Chart/parts/Scroller/Controllers.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarX.js +22 -6
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarY.js +13 -6
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollBarY.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js +43 -36
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerX.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerY.js +10 -5
- package/dist/esm/graphs/Chart/parts/Scroller/ScrollableContainerY.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js +40 -31
- package/dist/esm/graphs/Chart/parts/SeriesFactory.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/TrendHighlight.js +58 -20
- package/dist/esm/graphs/Chart/parts/TrendHighlight.js.map +2 -2
- package/dist/esm/graphs/Chart/parts/ZeroLine.js +36 -0
- package/dist/esm/graphs/Chart/parts/ZeroLine.js.map +7 -0
- package/dist/esm/graphs/Chart/scales/index.js +51 -21
- package/dist/esm/graphs/Chart/scales/index.js.map +3 -3
- package/dist/esm/graphs/Chart/series/Area.js +77 -10
- package/dist/esm/graphs/Chart/series/Area.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Bars.js +3 -1
- package/dist/esm/graphs/Chart/series/Bars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/HorizontalBars.js +4 -1
- package/dist/esm/graphs/Chart/series/HorizontalBars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js +15 -8
- package/dist/esm/graphs/Chart/series/HorizontalStackedBars.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Line.js +9 -7
- package/dist/esm/graphs/Chart/series/Line.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Point.js +120 -130
- package/dist/esm/graphs/Chart/series/Point.js.map +3 -3
- package/dist/esm/graphs/Chart/series/Points.js +8 -2
- package/dist/esm/graphs/Chart/series/Points.js.map +2 -2
- package/dist/esm/graphs/Chart/series/Rect.js +134 -123
- package/dist/esm/graphs/Chart/series/Rect.js.map +3 -3
- package/dist/esm/graphs/Chart/series/StackedBar.js +15 -7
- package/dist/esm/graphs/Chart/series/StackedBar.js.map +2 -2
- package/dist/esm/graphs/Chart/styles.js +66 -35
- package/dist/esm/graphs/Chart/styles.js.map +2 -2
- package/dist/esm/graphs/constants.js +25 -10
- package/dist/esm/graphs/constants.js.map +2 -2
- package/dist/esm/index.js +19 -7
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +125 -0
- package/dist/esm/react-desc-prop-types.js.map +7 -0
- package/dist/esm/typescript-testing/slot-props.js +46 -0
- package/dist/esm/typescript-testing/slot-props.js.map +7 -0
- package/dist/esm/typescript-testing/typescript-data-viz-valid.js +35 -3
- package/dist/esm/typescript-testing/typescript-data-viz-valid.js.map +2 -2
- package/dist/esm/typescript-testing/typescript-single-stacked-bar-valid.js +70 -0
- package/dist/esm/typescript-testing/typescript-single-stacked-bar-valid.js.map +7 -0
- package/dist/types/constants/index.d.ts +42 -0
- package/dist/types/graphs/Chart/Chart.d.ts +4 -2
- package/dist/types/graphs/Chart/ChartContext.d.ts +9 -11
- package/dist/types/graphs/Chart/SingleStackedBar/SingleStackedBar.d.ts +1 -1
- package/dist/types/graphs/Chart/config/chartInteractionStore.d.ts +32 -0
- package/dist/types/graphs/Chart/config/useChart.d.ts +9 -11
- package/dist/types/graphs/Chart/config/useChartDescription.d.ts +5 -0
- package/dist/types/graphs/Chart/config/useEntranceAnimation.d.ts +16 -0
- package/dist/types/graphs/Chart/config/useGetters.d.ts +1 -1
- package/dist/types/graphs/Chart/config/useInternalMargins.d.ts +4 -1
- package/dist/types/graphs/Chart/config/useKeyboardNavigation.d.ts +1 -1
- package/dist/types/graphs/Chart/config/useScales.d.ts +8 -2
- package/dist/types/graphs/Chart/config/useValidateProps.d.ts +7 -1
- package/dist/types/graphs/Chart/config/useValueAxisTransition.d.ts +6 -0
- package/dist/types/graphs/Chart/config/useWheelScroll.d.ts +2 -0
- package/dist/types/graphs/Chart/helpers/alignedTicks.d.ts +1 -0
- package/dist/types/graphs/Chart/helpers/barPath.d.ts +11 -0
- package/dist/types/graphs/Chart/helpers/dataInView.d.ts +6 -0
- package/dist/types/graphs/Chart/helpers/index.d.ts +10 -1
- package/dist/types/graphs/Chart/helpers/logAxis.d.ts +8 -0
- package/dist/types/graphs/Chart/helpers/tickRotation.d.ts +2 -0
- package/dist/types/graphs/Chart/helpers/timeTicks.d.ts +2 -0
- package/dist/types/graphs/Chart/helpers/trend.d.ts +3 -0
- package/dist/types/graphs/Chart/helpers/useSerieDimming.d.ts +3 -0
- package/dist/types/graphs/Chart/helpers/useUniqueData.d.ts +1 -1
- package/dist/types/graphs/Chart/helpers/useVirtualizedSeries.d.ts +1 -1
- package/dist/types/graphs/Chart/helpers/zeroLine.d.ts +2 -0
- package/dist/types/graphs/Chart/parts/Axis/Axis.d.ts +4 -1
- package/dist/types/graphs/Chart/parts/Axis/Tick.d.ts +1 -0
- package/dist/types/graphs/Chart/parts/Axis/useTickTransition.d.ts +24 -0
- package/dist/types/graphs/Chart/parts/HoverBand.d.ts +2 -0
- package/dist/types/graphs/Chart/parts/Labels/Label.d.ts +3 -0
- package/dist/types/graphs/Chart/parts/Scrapper/ScrapperLine.d.ts +11 -1
- package/dist/types/graphs/Chart/parts/Scrapper/VerticalScrapperLine.d.ts +6 -7
- package/dist/types/graphs/Chart/parts/ScreenReaderText.d.ts +5 -0
- package/dist/types/graphs/Chart/parts/TrendHighlight.d.ts +3 -2
- package/dist/types/graphs/Chart/parts/ZeroLine.d.ts +2 -0
- package/dist/types/graphs/Chart/scales/index.d.ts +10 -3
- package/dist/types/graphs/Chart/series/Area.d.ts +1 -1
- package/dist/types/graphs/Chart/series/Bars.d.ts +1 -1
- package/dist/types/graphs/Chart/series/HorizontalBars.d.ts +1 -1
- package/dist/types/graphs/Chart/series/HorizontalStackedBars.d.ts +1 -1
- package/dist/types/graphs/Chart/series/Line.d.ts +1 -1
- package/dist/types/graphs/Chart/series/Point.d.ts +3 -2
- package/dist/types/graphs/Chart/series/Points.d.ts +1 -1
- package/dist/types/graphs/Chart/series/Rect.d.ts +3 -2
- package/dist/types/graphs/Chart/series/StackedBar.d.ts +1 -1
- package/dist/types/graphs/Chart/styles.d.ts +18 -5
- package/dist/types/graphs/constants.d.ts +13 -1
- package/dist/types/index.d.ts +6 -1
- package/dist/types/react-desc-prop-types.d.ts +228 -0
- package/package.json +8 -7
- package/dist/cjs/graphs/Chart/DataTestIds.js.map +0 -7
- package/dist/cjs/graphs/Chart/SingleStackedBar/exported-related/data-test-ids.js.map +0 -7
- package/dist/cjs/graphs/Chart/SingleStackedBar/exported-related/index.js.map +0 -7
- package/dist/cjs/graphs/Chart/SingleStackedBar/exported-related/theming.js.map +0 -7
- package/dist/cjs/graphs/Chart/SingleStackedBar/index.js +0 -31
- package/dist/cjs/graphs/Chart/SingleStackedBar/index.js.map +0 -7
- package/dist/cjs/graphs/Chart/SingleStackedBar/react-desc-prop-types.js +0 -51
- package/dist/cjs/graphs/Chart/SingleStackedBar/react-desc-prop-types.js.map +0 -7
- package/dist/cjs/graphs/Chart/index.js +0 -33
- package/dist/cjs/graphs/Chart/index.js.map +0 -7
- package/dist/cjs/graphs/Chart/react-desc-prop-types.js.map +0 -7
- package/dist/cjs/graphs/index.js +0 -31
- package/dist/cjs/graphs/index.js.map +0 -7
- package/dist/esm/graphs/Chart/DataTestIds.js +0 -10
- package/dist/esm/graphs/Chart/DataTestIds.js.map +0 -7
- package/dist/esm/graphs/Chart/SingleStackedBar/exported-related/data-test-ids.js +0 -8
- package/dist/esm/graphs/Chart/SingleStackedBar/exported-related/data-test-ids.js.map +0 -7
- package/dist/esm/graphs/Chart/SingleStackedBar/exported-related/index.js +0 -4
- package/dist/esm/graphs/Chart/SingleStackedBar/exported-related/index.js.map +0 -7
- package/dist/esm/graphs/Chart/SingleStackedBar/exported-related/theming.js +0 -10
- package/dist/esm/graphs/Chart/SingleStackedBar/exported-related/theming.js.map +0 -7
- package/dist/esm/graphs/Chart/SingleStackedBar/index.js +0 -4
- package/dist/esm/graphs/Chart/SingleStackedBar/index.js.map +0 -7
- package/dist/esm/graphs/Chart/SingleStackedBar/react-desc-prop-types.js +0 -21
- package/dist/esm/graphs/Chart/SingleStackedBar/react-desc-prop-types.js.map +0 -7
- package/dist/esm/graphs/Chart/index.js +0 -6
- package/dist/esm/graphs/Chart/index.js.map +0 -7
- package/dist/esm/graphs/Chart/react-desc-prop-types.js +0 -29
- package/dist/esm/graphs/Chart/react-desc-prop-types.js.map +0 -7
- package/dist/esm/graphs/index.js +0 -4
- package/dist/esm/graphs/index.js.map +0 -7
- package/dist/types/graphs/Chart/DataTestIds.d.ts +0 -5
- package/dist/types/graphs/Chart/SingleStackedBar/exported-related/data-test-ids.d.ts +0 -3
- package/dist/types/graphs/Chart/SingleStackedBar/exported-related/index.d.ts +0 -2
- package/dist/types/graphs/Chart/SingleStackedBar/exported-related/theming.d.ts +0 -4
- package/dist/types/graphs/Chart/SingleStackedBar/index.d.ts +0 -3
- package/dist/types/graphs/Chart/SingleStackedBar/react-desc-prop-types.d.ts +0 -44
- package/dist/types/graphs/Chart/index.d.ts +0 -4
- package/dist/types/graphs/Chart/react-desc-prop-types.d.ts +0 -510
- package/dist/types/graphs/index.d.ts +0 -2
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useMemo, useState, useEffect, useRef } from "react";
|
|
2
|
+
import { useMemo, useState, useEffect, useLayoutEffect, useRef } from "react";
|
|
3
3
|
import { uid } from "uid";
|
|
4
4
|
import { debounce } from "lodash-es";
|
|
5
5
|
import ResizeObserver from "resize-observer-polyfill";
|
|
6
|
-
import {
|
|
6
|
+
import { useOwnerProps } from "@elliemae/ds-props-helpers";
|
|
7
|
+
import { createChartInteractionStore } from "./chartInteractionStore.js";
|
|
7
8
|
import { useScales } from "./useScales.js";
|
|
8
9
|
import { stackData } from "../helpers/index.js";
|
|
9
10
|
import { useInternalMargins } from "./useInternalMargins.js";
|
|
10
11
|
import { useGetters } from "./useGetters.js";
|
|
11
|
-
import { useValidateProps } from "./useValidateProps.js";
|
|
12
|
+
import { useValidateAxisEnds, useValidateProps } from "./useValidateProps.js";
|
|
12
13
|
import { COLOR_PALLET } from "../helpers/colorPallet.js";
|
|
14
|
+
import { isOutOfLogAxis } from "../helpers/logAxis.js";
|
|
15
|
+
import { fitsToView } from "../helpers/dataInView.js";
|
|
16
|
+
const getContentBoxWidth = (node) => {
|
|
17
|
+
const style = getComputedStyle(node);
|
|
18
|
+
const width = parseFloat(style.width);
|
|
19
|
+
if (Number.isNaN(width)) return 0;
|
|
20
|
+
if (style.boxSizing !== "border-box") return width;
|
|
21
|
+
const horizontalPaddingAndBorder = [
|
|
22
|
+
style.paddingLeft,
|
|
23
|
+
style.paddingRight,
|
|
24
|
+
style.borderLeftWidth,
|
|
25
|
+
style.borderRightWidth
|
|
26
|
+
].reduce((total, value) => total + (parseFloat(value) || 0), 0);
|
|
27
|
+
return width - horizontalPaddingAndBorder;
|
|
28
|
+
};
|
|
13
29
|
const useResizeObserver = (ref) => {
|
|
14
30
|
const [dimensions, setDimensions] = useState(0);
|
|
15
|
-
|
|
31
|
+
useLayoutEffect(() => {
|
|
16
32
|
if (ref) {
|
|
17
33
|
const observeTarget = ref;
|
|
34
|
+
setDimensions(Math.ceil(getContentBoxWidth(observeTarget)));
|
|
18
35
|
const resizeObserver = new ResizeObserver(
|
|
19
36
|
debounce((entries) => {
|
|
20
37
|
entries.forEach((entry) => {
|
|
@@ -34,31 +51,25 @@ const useResizeObserver = (ref) => {
|
|
|
34
51
|
};
|
|
35
52
|
const useChart = (props) => {
|
|
36
53
|
useValidateProps(props);
|
|
37
|
-
const { series, yAxis, xAxis, width: userWidth, height: userHeight, groups: groupsStacked } = props;
|
|
54
|
+
const { series, yAxis, xAxis, y2Axis, width: userWidth, height: userHeight, groups: groupsStacked } = props;
|
|
38
55
|
const userRatio = useMemo(
|
|
39
56
|
() => props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1,
|
|
40
57
|
[props?.xAxis.advanced?.pointSpacing?.value, props?.yAxis.advanced?.pointSpacing?.value]
|
|
41
58
|
);
|
|
42
59
|
const originalSeries = useMemo(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}, [series]);
|
|
60
|
+
const seriesOrEmpty = series ?? [];
|
|
61
|
+
if (y2Axis) return seriesOrEmpty;
|
|
62
|
+
return seriesOrEmpty.map((serie) => serie.scale === "y2" ? { ...serie, scale: void 0 } : serie);
|
|
63
|
+
}, [series, y2Axis]);
|
|
48
64
|
const [containerRef, setContainerRef] = useState(null);
|
|
49
65
|
const dimensionWidth = useResizeObserver(containerRef);
|
|
50
66
|
const width = useMemo(() => userWidth ?? dimensionWidth ?? 0, [dimensionWidth, userWidth]);
|
|
51
67
|
const height = useMemo(() => userHeight ?? 500, [userHeight]);
|
|
52
68
|
const [isGrabbed, setIsGrabbed] = useState(false);
|
|
53
69
|
const [startPosition, setStartPosition] = useState(0);
|
|
54
|
-
const [
|
|
55
|
-
const
|
|
56
|
-
const [movingPosition, setMovingPosition] = useState(0);
|
|
57
|
-
const [activePoint, setActivePoint] = useState(null);
|
|
70
|
+
const [interactionStore] = useState(createChartInteractionStore);
|
|
71
|
+
const { setActivePoint, setScrapperPosX, setScrapperPosY, setXScrollbarPosition } = interactionStore;
|
|
58
72
|
const [activeSerie, setActiveSerie] = useState("");
|
|
59
|
-
const [scrapperPosY, setScrapperPosY] = useState(-1);
|
|
60
|
-
const [scrapperPosX, setScrapperPosX] = useState(-1);
|
|
61
|
-
const [xScrollbarPosition, setXScrollbarPosition] = useState(0);
|
|
62
73
|
const [isScrollbarVisible, setIsScrollbarVisible] = useState(false);
|
|
63
74
|
const [containerRatio, setContainerRatio] = useState(userRatio);
|
|
64
75
|
const lastScrollbarPosition = useRef(0);
|
|
@@ -76,7 +87,7 @@ const useChart = (props) => {
|
|
|
76
87
|
useEffect(() => {
|
|
77
88
|
lastScrollbarPosition.current = 0;
|
|
78
89
|
setXScrollbarPosition(0);
|
|
79
|
-
}, [dimensionWidth]);
|
|
90
|
+
}, [dimensionWidth, setXScrollbarPosition]);
|
|
80
91
|
useEffect(() => {
|
|
81
92
|
setContainerRatio(userRatio);
|
|
82
93
|
}, [userRatio]);
|
|
@@ -94,6 +105,7 @@ const useChart = (props) => {
|
|
|
94
105
|
leftLabelWidth,
|
|
95
106
|
axisLeftWidth,
|
|
96
107
|
topLegendHeight,
|
|
108
|
+
topLegendWidth,
|
|
97
109
|
leftLegendHeight
|
|
98
110
|
} = useInternalMargins({
|
|
99
111
|
axisLeftRef,
|
|
@@ -106,7 +118,10 @@ const useChart = (props) => {
|
|
|
106
118
|
bottomLegend,
|
|
107
119
|
rightLabel,
|
|
108
120
|
bottomLabel,
|
|
109
|
-
toolbarRef
|
|
121
|
+
toolbarRef,
|
|
122
|
+
// the vertical axes that follow the view keep their width while it scrolls (see useWidthThatDoesNotShrink)
|
|
123
|
+
keepLeftAxisWidth: containerRatio > 1 && fitsToView(yAxis, props.xScroll),
|
|
124
|
+
keepRightAxisWidth: containerRatio > 1 && fitsToView(y2Axis, props.xScroll)
|
|
110
125
|
});
|
|
111
126
|
const innerWidth = useMemo(
|
|
112
127
|
() => width - internalMargin.left - internalMargin.right,
|
|
@@ -127,6 +142,7 @@ const useChart = (props) => {
|
|
|
127
142
|
return "y";
|
|
128
143
|
}, [xAxis.type, yAxis.type]);
|
|
129
144
|
const [currentDataWithNullValues, currentData] = useMemo(() => {
|
|
145
|
+
const isHorizontalChart = yAxis?.type === "band";
|
|
130
146
|
const baseData = originalSeries.filter((serie) => !hiddenSeries.includes(serie.name)).map((d, i) => ({
|
|
131
147
|
...d,
|
|
132
148
|
// we set a default on the scale if the user do not pass it
|
|
@@ -134,7 +150,9 @@ const useChart = (props) => {
|
|
|
134
150
|
key: `${d.name}-${i}`,
|
|
135
151
|
data: d.data.map((value, index) => ({
|
|
136
152
|
key: `${d.name}-${i}-${index}`,
|
|
137
|
-
value,
|
|
153
|
+
// a log axis has no place for zero or a negative value: such a value is a gap in the series, like a missing
|
|
154
|
+
// one, instead of a NaN that breaks the whole chart (useValidateProps warns about it)
|
|
155
|
+
value: isOutOfLogAxis(value, { xAxis, yAxis: d.scale === "y2" && y2Axis ? y2Axis : yAxis, isHorizontalChart }) ? null : value,
|
|
138
156
|
position: index,
|
|
139
157
|
serie: d.name,
|
|
140
158
|
scale: d.scale,
|
|
@@ -146,14 +164,14 @@ const useChart = (props) => {
|
|
|
146
164
|
data: data.data.filter((datum) => datum.value !== null && datum.value !== void 0)
|
|
147
165
|
}));
|
|
148
166
|
return [baseData, currentDataWithoutNulls];
|
|
149
|
-
}, [defaultScale, hiddenSeries, originalSeries]);
|
|
167
|
+
}, [defaultScale, hiddenSeries, originalSeries, xAxis, y2Axis, yAxis]);
|
|
150
168
|
const isHorizontal = useMemo(() => yAxis?.type === "band", [yAxis]);
|
|
151
169
|
const { stackedData, scalesStackedDataMap } = useMemo(
|
|
152
170
|
() => stackData(groupsStacked, originalSeries, hiddenSeries, isHorizontal),
|
|
153
171
|
[groupsStacked, originalSeries, hiddenSeries, isHorizontal]
|
|
154
172
|
);
|
|
155
173
|
const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);
|
|
156
|
-
const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth } = useScales({
|
|
174
|
+
const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth, fullDataTicks } = useScales({
|
|
157
175
|
props,
|
|
158
176
|
originalSeries,
|
|
159
177
|
innerHeight,
|
|
@@ -162,8 +180,10 @@ const useChart = (props) => {
|
|
|
162
180
|
stackedData,
|
|
163
181
|
scalesStackedDataMap,
|
|
164
182
|
currentData,
|
|
165
|
-
containerRatio
|
|
183
|
+
containerRatio,
|
|
184
|
+
interactionStore
|
|
166
185
|
});
|
|
186
|
+
useValidateAxisEnds(props, { xScale, yScale, y2Scale });
|
|
167
187
|
const {
|
|
168
188
|
getXValue,
|
|
169
189
|
getY2ScaleValue,
|
|
@@ -181,16 +201,11 @@ const useChart = (props) => {
|
|
|
181
201
|
y2Scale
|
|
182
202
|
});
|
|
183
203
|
const chartId = useMemo(() => uid(6), []);
|
|
204
|
+
const { getOwnerProps } = useOwnerProps(props);
|
|
184
205
|
return useMemo(
|
|
185
206
|
() => ({
|
|
186
207
|
props,
|
|
187
208
|
originalSeries,
|
|
188
|
-
isZooming,
|
|
189
|
-
setIsZooming,
|
|
190
|
-
zoomStartingPosition,
|
|
191
|
-
setZoomStartingPosition,
|
|
192
|
-
setMovingPosition,
|
|
193
|
-
movingPosition,
|
|
194
209
|
innerHeight,
|
|
195
210
|
innerWidth,
|
|
196
211
|
groups,
|
|
@@ -201,17 +216,15 @@ const useChart = (props) => {
|
|
|
201
216
|
xScale,
|
|
202
217
|
yScale,
|
|
203
218
|
y2Scale,
|
|
219
|
+
fullDataTicks,
|
|
204
220
|
containerRef,
|
|
205
221
|
getBandwidth,
|
|
206
|
-
|
|
222
|
+
interactionStore,
|
|
207
223
|
setScrapperPosY,
|
|
208
|
-
scrapperPosX,
|
|
209
224
|
setScrapperPosX,
|
|
210
|
-
activePoint,
|
|
211
225
|
setActivePoint,
|
|
212
226
|
activeSerie,
|
|
213
227
|
setActiveSerie,
|
|
214
|
-
xScrollbarPosition,
|
|
215
228
|
setXScrollbarPosition,
|
|
216
229
|
isGrabbed,
|
|
217
230
|
setIsGrabbed,
|
|
@@ -265,15 +278,14 @@ const useChart = (props) => {
|
|
|
265
278
|
leftLabelWidth,
|
|
266
279
|
axisLeftWidth,
|
|
267
280
|
topLegendHeight,
|
|
281
|
+
topLegendWidth,
|
|
268
282
|
leftLegendHeight,
|
|
269
|
-
currentDataWithNullValues
|
|
283
|
+
currentDataWithNullValues,
|
|
284
|
+
getOwnerProps
|
|
270
285
|
}),
|
|
271
286
|
[
|
|
272
287
|
props,
|
|
273
288
|
originalSeries,
|
|
274
|
-
isZooming,
|
|
275
|
-
zoomStartingPosition,
|
|
276
|
-
movingPosition,
|
|
277
289
|
innerHeight,
|
|
278
290
|
innerWidth,
|
|
279
291
|
groups,
|
|
@@ -284,14 +296,16 @@ const useChart = (props) => {
|
|
|
284
296
|
xScale,
|
|
285
297
|
yScale,
|
|
286
298
|
y2Scale,
|
|
299
|
+
fullDataTicks,
|
|
287
300
|
containerRef,
|
|
288
301
|
getBandwidth,
|
|
289
|
-
|
|
302
|
+
interactionStore,
|
|
290
303
|
getY2ScaleValue,
|
|
291
|
-
|
|
292
|
-
|
|
304
|
+
setActivePoint,
|
|
305
|
+
setScrapperPosX,
|
|
306
|
+
setScrapperPosY,
|
|
293
307
|
activeSerie,
|
|
294
|
-
|
|
308
|
+
setXScrollbarPosition,
|
|
295
309
|
isGrabbed,
|
|
296
310
|
startPosition,
|
|
297
311
|
isScrollbarVisible,
|
|
@@ -325,8 +339,10 @@ const useChart = (props) => {
|
|
|
325
339
|
leftLabelWidth,
|
|
326
340
|
axisLeftWidth,
|
|
327
341
|
topLegendHeight,
|
|
342
|
+
topLegendWidth,
|
|
328
343
|
leftLegendHeight,
|
|
329
|
-
currentDataWithNullValues
|
|
344
|
+
currentDataWithNullValues,
|
|
345
|
+
getOwnerProps
|
|
330
346
|
]
|
|
331
347
|
);
|
|
332
348
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useChart.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-nested-callbacks */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo, useState, useEffect, useRef } from 'react';\nimport { uid } from 'uid';\nimport { debounce } from 'lodash-es';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport type { DSChartT } from '../react-desc-prop-types.js';\nimport { defaultProps } from '../react-desc-prop-types.js';\nimport { useScales } from './useScales.js';\nimport { stackData } from '../helpers/index.js';\nimport { useInternalMargins } from './useInternalMargins.js';\nimport { useGetters } from './useGetters.js';\nimport { useValidateProps } from './useValidateProps.js';\nimport { COLOR_PALLET } from '../helpers/colorPallet.js';\ntype ResizeObserverConstructorEntries = Parameters<ConstructorParameters<typeof ResizeObserver>[0]>[0];\n\nconst useResizeObserver = (ref: HTMLElement | null | undefined) => {\n const [dimensions, setDimensions] = useState<number>(0);\n\n useEffect(() => {\n if (ref) {\n const observeTarget = ref;\n const resizeObserver = new ResizeObserver(\n debounce((entries: ResizeObserverConstructorEntries) => {\n entries.forEach((entry) => {\n setDimensions(Math.ceil(entry.contentRect.width));\n });\n }, 200),\n );\n resizeObserver.observe(observeTarget);\n\n return () => {\n resizeObserver.unobserve(observeTarget);\n };\n }\n return () => {};\n }, [ref]);\n return dimensions;\n};\n\nexport const useChart = (props: DSChartT.Props) => {\n useValidateProps(props);\n\n // const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n const { series, yAxis, xAxis, width: userWidth, height: userHeight, groups: groupsStacked } = props;\n const userRatio = useMemo(\n () => props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1,\n [props?.xAxis.advanced?.pointSpacing?.value, props?.yAxis.advanced?.pointSpacing?.value],\n );\n const originalSeries = useMemo(() => {\n if (series.length === 0) {\n return defaultProps.series;\n }\n return series;\n }, [series]);\n const [containerRef, setContainerRef] = useState<HTMLDivElement | null>(null);\n\n const dimensionWidth = useResizeObserver(containerRef);\n\n const width = useMemo(() => userWidth ?? dimensionWidth ?? 0, [dimensionWidth, userWidth]);\n\n const height = useMemo(() => userHeight ?? 500, [userHeight]);\n\n const [isGrabbed, setIsGrabbed] = useState(false);\n const [startPosition, setStartPosition] = useState(0);\n\n // zoom\n\n const [isZooming, setIsZooming] = useState(false);\n const [zoomStartingPosition, setZoomStartingPosition] = useState(0);\n const [movingPosition, setMovingPosition] = useState(0);\n\n //\n\n const [activePoint, setActivePoint] = useState<DSChartT.InternalDatum | null>(null);\n const [activeSerie, setActiveSerie] = useState('');\n const [scrapperPosY, setScrapperPosY] = useState(-1);\n const [scrapperPosX, setScrapperPosX] = useState(-1);\n const [xScrollbarPosition, setXScrollbarPosition] = useState(0);\n const [isScrollbarVisible, setIsScrollbarVisible] = useState(false);\n const [containerRatio, setContainerRatio] = useState(userRatio);\n\n const lastScrollbarPosition = useRef(0);\n\n const [axisLeftRef, setAxisLeftRef] = useState<SVGGElement | null>(null);\n const [axisBottomRef, setAxisBottomRef] = useState<SVGGElement | null>(null);\n const [axisRightRef, setAxisRightRef] = useState<SVGGElement | null>(null);\n\n const [leftLegend, setLeftLegend] = useState<SVGGElement | null>(null);\n const [rightLegend, setRightLegend] = useState<SVGGElement | null>(null);\n const [topLegend, setTopLegend] = useState<SVGGElement | null>(null);\n const [bottomLegend, setBottomLegend] = useState<SVGGElement | null>(null);\n\n const [rightLabel, setRightLabel] = useState<SVGGElement | null>(null);\n const [leftLabel, setLeftLabel] = useState<SVGGElement | null>(null);\n const [bottomLabel, setBottomLabel] = useState<SVGGElement | null>(null);\n\n const [toolbarRef, setToolbarRef] = useState<SVGGElement | null>(null);\n\n // we reset the scrollbar position when the chart resize\n useEffect(() => {\n lastScrollbarPosition.current = 0;\n setXScrollbarPosition(0);\n }, [dimensionWidth]);\n\n useEffect(() => {\n setContainerRatio(userRatio);\n }, [userRatio]);\n\n const {\n toolbarHeight,\n axisBottomHeight,\n axisRightWidth,\n bottomLabelHeight,\n internalMargin,\n leftLegendWidth,\n rightLabelWidth,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n leftLegendHeight,\n } = useInternalMargins({\n axisLeftRef,\n axisBottomRef,\n axisRightRef,\n leftLabel,\n leftLegend,\n rightLegend,\n topLegend,\n bottomLegend,\n rightLabel,\n bottomLabel,\n toolbarRef,\n });\n\n const innerWidth = useMemo(\n () => width - internalMargin.left - internalMargin.right,\n [internalMargin.left, internalMargin.right, width],\n );\n const innerHeight = useMemo(\n () => height - internalMargin.top - internalMargin.bottom,\n [internalMargin.top, internalMargin.bottom, height],\n );\n\n const [hiddenSeries, setHiddenSeries] = useState<string[]>([]);\n\n const defaultScale = useMemo(() => {\n if (yAxis.type === 'band') {\n return 'x';\n }\n\n if ([undefined, 'band'].includes(xAxis.type)) {\n return 'y';\n }\n\n return 'y';\n }, [xAxis.type, yAxis.type]);\n\n const [currentDataWithNullValues, currentData] = useMemo(() => {\n const baseData = originalSeries\n .filter((serie) => !hiddenSeries.includes(serie.name))\n .map((d, i) => ({\n ...d,\n // we set a default on the scale if the user do not pass it\n scale: d.scale || defaultScale,\n key: `${d.name}-${i}`,\n data: d.data.map((value, index) => ({\n key: `${d.name}-${i}-${index}`,\n value,\n position: index,\n serie: d.name,\n scale: d.scale,\n color: COLOR_PALLET[d.color as keyof typeof COLOR_PALLET] ?? d.color,\n })),\n })) as DSChartT.InternalData;\n\n const currentDataWithoutNulls = baseData.map((data) => ({\n ...data,\n data: data.data.filter((datum) => datum.value !== null && datum.value !== undefined),\n }));\n\n return [baseData, currentDataWithoutNulls];\n }, [defaultScale, hiddenSeries, originalSeries]);\n\n const isHorizontal = useMemo(() => yAxis?.type === 'band', [yAxis]);\n\n const { stackedData, scalesStackedDataMap } = useMemo(\n () => stackData(groupsStacked, originalSeries, hiddenSeries, isHorizontal),\n [groupsStacked, originalSeries, hiddenSeries, isHorizontal],\n );\n\n // @TODO we need to create a logic to get this from both axis\n // const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1;\n\n const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);\n\n const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth } = useScales({\n props,\n originalSeries,\n innerHeight,\n innerWidth,\n groups,\n stackedData,\n scalesStackedDataMap,\n currentData,\n containerRatio,\n });\n\n const {\n getXValue,\n getY2ScaleValue,\n getYValue,\n getXScaleValue,\n getYScaleValue,\n getYValueFormatted,\n getXValueFormatted,\n } = useGetters({\n xAxis,\n yAxis,\n isHorizontal,\n xScale,\n yScale,\n y2Scale,\n });\n const chartId = useMemo(() => uid(6), []);\n\n return useMemo(\n () => ({\n props,\n originalSeries,\n isZooming,\n setIsZooming,\n zoomStartingPosition,\n setZoomStartingPosition,\n setMovingPosition,\n movingPosition,\n innerHeight,\n innerWidth,\n groups,\n currentData,\n colorScale,\n stackedData,\n subGroupScale,\n xScale,\n yScale,\n y2Scale,\n containerRef,\n getBandwidth,\n scrapperPosY,\n setScrapperPosY,\n scrapperPosX,\n setScrapperPosX,\n activePoint,\n setActivePoint,\n activeSerie,\n setActiveSerie,\n xScrollbarPosition,\n setXScrollbarPosition,\n isGrabbed,\n setIsGrabbed,\n setContainerRef,\n startPosition,\n setStartPosition,\n isScrollbarVisible,\n setIsScrollbarVisible,\n lastScrollbarPosition,\n containerRatio,\n internalMargin,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n setAxisLeftRef,\n setLeftLegend,\n setRightLegend,\n rightLegend,\n setTopLegend,\n setBottomLegend,\n setAxisBottomRef,\n axisBottomHeight,\n setAxisRightRef,\n setRightLabel,\n setBottomLabel,\n getXScaleValue,\n getYScaleValue,\n getY2ScaleValue,\n getYValueFormatted,\n getXValueFormatted,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n setLeftLabel,\n leftLabel,\n chartId,\n hiddenSeries,\n setHiddenSeries,\n height,\n width,\n setContainerRatio,\n toolbarHeight,\n setToolbarRef,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n bottomLegend,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n leftLegendHeight,\n currentDataWithNullValues,\n }),\n [\n props,\n originalSeries,\n isZooming,\n zoomStartingPosition,\n movingPosition,\n innerHeight,\n innerWidth,\n groups,\n currentData,\n colorScale,\n stackedData,\n subGroupScale,\n xScale,\n yScale,\n y2Scale,\n containerRef,\n getBandwidth,\n scrapperPosY,\n getY2ScaleValue,\n scrapperPosX,\n activePoint,\n activeSerie,\n xScrollbarPosition,\n isGrabbed,\n startPosition,\n isScrollbarVisible,\n containerRatio,\n internalMargin,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n rightLegend,\n axisBottomHeight,\n getXScaleValue,\n getYScaleValue,\n getYValueFormatted,\n getXValueFormatted,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n leftLabel,\n chartId,\n hiddenSeries,\n height,\n width,\n toolbarHeight,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n bottomLegend,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n leftLegendHeight,\n currentDataWithNullValues,\n ],\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,UAAU,WAAW,cAAc;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-nested-callbacks */\n/* eslint-disable max-statements */\n/* eslint-disable indent */\nimport { useMemo, useState, useEffect, useLayoutEffect, useRef } from 'react';\nimport { uid } from 'uid';\nimport { debounce } from 'lodash-es';\nimport ResizeObserver from 'resize-observer-polyfill';\nimport { useOwnerProps } from '@elliemae/ds-props-helpers';\nimport { createChartInteractionStore } from './chartInteractionStore.js';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\nimport { useScales } from './useScales.js';\nimport { stackData } from '../helpers/index.js';\nimport { useInternalMargins } from './useInternalMargins.js';\nimport { useGetters } from './useGetters.js';\nimport { useValidateAxisEnds, useValidateProps } from './useValidateProps.js';\nimport { COLOR_PALLET } from '../helpers/colorPallet.js';\nimport { isOutOfLogAxis } from '../helpers/logAxis.js';\nimport { fitsToView } from '../helpers/dataInView.js';\ntype ResizeObserverConstructorEntries = Parameters<ConstructorParameters<typeof ResizeObserver>[0]>[0];\n\n// the width the ResizeObserver reports: the content box, without padding or border\nconst getContentBoxWidth = (node: HTMLElement) => {\n const style = getComputedStyle(node);\n const width = parseFloat(style.width);\n if (Number.isNaN(width)) return 0;\n if (style.boxSizing !== 'border-box') return width;\n const horizontalPaddingAndBorder = [\n style.paddingLeft,\n style.paddingRight,\n style.borderLeftWidth,\n style.borderRightWidth,\n ].reduce((total, value) => total + (parseFloat(value) || 0), 0);\n return width - horizontalPaddingAndBorder;\n};\n\nconst useResizeObserver = (ref: HTMLElement | null | undefined) => {\n const [dimensions, setDimensions] = useState<number>(0);\n\n // a layout effect, so the first width is applied before the browser paints: the chart draws at its width on its\n // first frame instead of after the debounce, which only applies to the resizes that follow\n useLayoutEffect(() => {\n if (ref) {\n const observeTarget = ref;\n setDimensions(Math.ceil(getContentBoxWidth(observeTarget)));\n const resizeObserver = new ResizeObserver(\n debounce((entries: ResizeObserverConstructorEntries) => {\n entries.forEach((entry) => {\n setDimensions(Math.ceil(entry.contentRect.width));\n });\n }, 200),\n );\n resizeObserver.observe(observeTarget);\n\n return () => {\n resizeObserver.unobserve(observeTarget);\n };\n }\n return () => {};\n }, [ref]);\n return dimensions;\n};\n\nexport const useChart = (props: DSChartT.Props) => {\n useValidateProps(props);\n\n // const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);\n const { series, yAxis, xAxis, y2Axis, width: userWidth, height: userHeight, groups: groupsStacked } = props;\n const userRatio = useMemo(\n () => props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1,\n [props?.xAxis.advanced?.pointSpacing?.value, props?.yAxis.advanced?.pointSpacing?.value],\n );\n // No series is a valid state (data still loading, a filter with no match): the chart renders its axes with no data.\n // A series on the secondary scale needs y2Axis: without it, it is plotted on the main scale (useValidateProps warns).\n const originalSeries = useMemo(() => {\n const seriesOrEmpty = series ?? [];\n if (y2Axis) return seriesOrEmpty;\n return seriesOrEmpty.map((serie) => (serie.scale === 'y2' ? { ...serie, scale: undefined } : serie));\n }, [series, y2Axis]);\n const [containerRef, setContainerRef] = useState<HTMLDivElement | null>(null);\n\n const dimensionWidth = useResizeObserver(containerRef);\n\n const width = useMemo(() => userWidth ?? dimensionWidth ?? 0, [dimensionWidth, userWidth]);\n\n const height = useMemo(() => userHeight ?? 500, [userHeight]);\n\n const [isGrabbed, setIsGrabbed] = useState(false);\n const [startPosition, setStartPosition] = useState(0);\n\n // the hover and scroll state (active point, scrapper positions, scroll position) lives in a store, so a hover or a\n // scroll step does not change this context\n const [interactionStore] = useState(createChartInteractionStore);\n const { setActivePoint, setScrapperPosX, setScrapperPosY, setXScrollbarPosition } = interactionStore;\n const [activeSerie, setActiveSerie] = useState('');\n const [isScrollbarVisible, setIsScrollbarVisible] = useState(false);\n const [containerRatio, setContainerRatio] = useState(userRatio);\n\n const lastScrollbarPosition = useRef(0);\n\n const [axisLeftRef, setAxisLeftRef] = useState<SVGGElement | null>(null);\n const [axisBottomRef, setAxisBottomRef] = useState<SVGGElement | null>(null);\n const [axisRightRef, setAxisRightRef] = useState<SVGGElement | null>(null);\n\n const [leftLegend, setLeftLegend] = useState<SVGGElement | null>(null);\n const [rightLegend, setRightLegend] = useState<SVGGElement | null>(null);\n const [topLegend, setTopLegend] = useState<SVGGElement | null>(null);\n const [bottomLegend, setBottomLegend] = useState<SVGGElement | null>(null);\n\n const [rightLabel, setRightLabel] = useState<SVGGElement | null>(null);\n const [leftLabel, setLeftLabel] = useState<SVGGElement | null>(null);\n const [bottomLabel, setBottomLabel] = useState<SVGGElement | null>(null);\n\n const [toolbarRef, setToolbarRef] = useState<SVGGElement | null>(null);\n\n // we reset the scrollbar position when the chart resize\n useEffect(() => {\n lastScrollbarPosition.current = 0;\n setXScrollbarPosition(0);\n // the store setter is stable: this still runs when the width changes only\n }, [dimensionWidth, setXScrollbarPosition]);\n\n useEffect(() => {\n setContainerRatio(userRatio);\n }, [userRatio]);\n\n const {\n toolbarHeight,\n axisBottomHeight,\n axisRightWidth,\n bottomLabelHeight,\n internalMargin,\n leftLegendWidth,\n rightLabelWidth,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n topLegendWidth,\n leftLegendHeight,\n } = useInternalMargins({\n axisLeftRef,\n axisBottomRef,\n axisRightRef,\n leftLabel,\n leftLegend,\n rightLegend,\n topLegend,\n bottomLegend,\n rightLabel,\n bottomLabel,\n toolbarRef,\n // the vertical axes that follow the view keep their width while it scrolls (see useWidthThatDoesNotShrink)\n keepLeftAxisWidth: containerRatio > 1 && fitsToView(yAxis, props.xScroll),\n keepRightAxisWidth: containerRatio > 1 && fitsToView(y2Axis, props.xScroll),\n });\n\n const innerWidth = useMemo(\n () => width - internalMargin.left - internalMargin.right,\n [internalMargin.left, internalMargin.right, width],\n );\n const innerHeight = useMemo(\n () => height - internalMargin.top - internalMargin.bottom,\n [internalMargin.top, internalMargin.bottom, height],\n );\n\n const [hiddenSeries, setHiddenSeries] = useState<string[]>([]);\n\n const defaultScale = useMemo(() => {\n if (yAxis.type === 'band') {\n return 'x';\n }\n\n if ([undefined, 'band'].includes(xAxis.type)) {\n return 'y';\n }\n\n return 'y';\n }, [xAxis.type, yAxis.type]);\n\n const [currentDataWithNullValues, currentData] = useMemo(() => {\n const isHorizontalChart = yAxis?.type === 'band';\n const baseData = originalSeries\n .filter((serie) => !hiddenSeries.includes(serie.name))\n .map((d, i) => ({\n ...d,\n // we set a default on the scale if the user do not pass it\n scale: d.scale || defaultScale,\n key: `${d.name}-${i}`,\n data: d.data.map((value, index) => ({\n key: `${d.name}-${i}-${index}`,\n // a log axis has no place for zero or a negative value: such a value is a gap in the series, like a missing\n // one, instead of a NaN that breaks the whole chart (useValidateProps warns about it)\n value: isOutOfLogAxis(value, { xAxis, yAxis: d.scale === 'y2' && y2Axis ? y2Axis : yAxis, isHorizontalChart })\n ? null\n : value,\n position: index,\n serie: d.name,\n scale: d.scale,\n color: COLOR_PALLET[d.color as keyof typeof COLOR_PALLET] ?? d.color,\n })),\n })) as DSChartT.InternalData;\n\n const currentDataWithoutNulls = baseData.map((data) => ({\n ...data,\n data: data.data.filter((datum) => datum.value !== null && datum.value !== undefined),\n }));\n\n return [baseData, currentDataWithoutNulls];\n }, [defaultScale, hiddenSeries, originalSeries, xAxis, y2Axis, yAxis]);\n\n const isHorizontal = useMemo(() => yAxis?.type === 'band', [yAxis]);\n\n const { stackedData, scalesStackedDataMap } = useMemo(\n () => stackData(groupsStacked, originalSeries, hiddenSeries, isHorizontal),\n [groupsStacked, originalSeries, hiddenSeries, isHorizontal],\n );\n\n // @TODO we need to create a logic to get this from both axis\n // const containerRatio = props?.xAxis.advanced?.pointSpacing?.value ?? props?.yAxis.advanced?.pointSpacing?.value ?? 1;\n\n const groups = useMemo(() => currentData.map((serie) => serie.name), [currentData]);\n\n const { xScale, yScale, y2Scale, subGroupScale, colorScale, getBandwidth, fullDataTicks } = useScales({\n props,\n originalSeries,\n innerHeight,\n innerWidth,\n groups,\n stackedData,\n scalesStackedDataMap,\n currentData,\n containerRatio,\n interactionStore,\n });\n useValidateAxisEnds(props, { xScale, yScale, y2Scale });\n\n const {\n getXValue,\n getY2ScaleValue,\n getYValue,\n getXScaleValue,\n getYScaleValue,\n getYValueFormatted,\n getXValueFormatted,\n } = useGetters({\n xAxis,\n yAxis,\n isHorizontal,\n xScale,\n yScale,\n y2Scale,\n });\n const chartId = useMemo(() => uid(6), []);\n\n // every slot of the chart reads the consumer slot props through the context\n const { getOwnerProps } = useOwnerProps(props);\n\n return useMemo(\n () => ({\n props,\n originalSeries,\n innerHeight,\n innerWidth,\n groups,\n currentData,\n colorScale,\n stackedData,\n subGroupScale,\n xScale,\n yScale,\n y2Scale,\n fullDataTicks,\n containerRef,\n getBandwidth,\n interactionStore,\n setScrapperPosY,\n setScrapperPosX,\n setActivePoint,\n activeSerie,\n setActiveSerie,\n setXScrollbarPosition,\n isGrabbed,\n setIsGrabbed,\n setContainerRef,\n startPosition,\n setStartPosition,\n isScrollbarVisible,\n setIsScrollbarVisible,\n lastScrollbarPosition,\n containerRatio,\n internalMargin,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n setAxisLeftRef,\n setLeftLegend,\n setRightLegend,\n rightLegend,\n setTopLegend,\n setBottomLegend,\n setAxisBottomRef,\n axisBottomHeight,\n setAxisRightRef,\n setRightLabel,\n setBottomLabel,\n getXScaleValue,\n getYScaleValue,\n getY2ScaleValue,\n getYValueFormatted,\n getXValueFormatted,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n setLeftLabel,\n leftLabel,\n chartId,\n hiddenSeries,\n setHiddenSeries,\n height,\n width,\n setContainerRatio,\n toolbarHeight,\n setToolbarRef,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n bottomLegend,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n topLegendWidth,\n leftLegendHeight,\n currentDataWithNullValues,\n getOwnerProps,\n }),\n [\n props,\n originalSeries,\n innerHeight,\n innerWidth,\n groups,\n currentData,\n colorScale,\n stackedData,\n subGroupScale,\n xScale,\n yScale,\n y2Scale,\n fullDataTicks,\n containerRef,\n getBandwidth,\n interactionStore,\n getY2ScaleValue,\n setActivePoint,\n setScrapperPosX,\n setScrapperPosY,\n activeSerie,\n setXScrollbarPosition,\n isGrabbed,\n startPosition,\n isScrollbarVisible,\n containerRatio,\n internalMargin,\n axisLeftRef,\n leftLegendWidth,\n leftLegend,\n rightLegend,\n axisBottomHeight,\n getXScaleValue,\n getYScaleValue,\n getYValueFormatted,\n getXValueFormatted,\n bottomLabelHeight,\n rightLabelWidth,\n axisRightWidth,\n getXValue,\n getYValue,\n isHorizontal,\n leftLabel,\n chartId,\n hiddenSeries,\n height,\n width,\n toolbarHeight,\n leftLabelHeight,\n rightLegendHeight,\n bottomLegendWidth,\n bottomLegend,\n leftLabelWidth,\n axisLeftWidth,\n topLegendHeight,\n topLegendWidth,\n leftLegendHeight,\n currentDataWithNullValues,\n getOwnerProps,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,UAAU,WAAW,iBAAiB,cAAc;AACtE,SAAS,WAAW;AACpB,SAAS,gBAAgB;AACzB,OAAO,oBAAoB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,mCAAmC;AAE5C,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB,wBAAwB;AACtD,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,kBAAkB;AAI3B,MAAM,qBAAqB,CAAC,SAAsB;AAChD,QAAM,QAAQ,iBAAiB,IAAI;AACnC,QAAM,QAAQ,WAAW,MAAM,KAAK;AACpC,MAAI,OAAO,MAAM,KAAK,EAAG,QAAO;AAChC,MAAI,MAAM,cAAc,aAAc,QAAO;AAC7C,QAAM,6BAA6B;AAAA,IACjC,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,IACN,MAAM;AAAA,EACR,EAAE,OAAO,CAAC,OAAO,UAAU,SAAS,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AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useContext, useMemo } from "react";
|
|
3
|
+
import { ChartContext } from "../ChartContext.js";
|
|
4
|
+
import { getChartDefaultName, getKeyboardInstructions } from "../helpers/index.js";
|
|
5
|
+
const useChartDescription = () => {
|
|
6
|
+
const {
|
|
7
|
+
props: { xAxis, yAxis, xScroll },
|
|
8
|
+
isHorizontal,
|
|
9
|
+
xScale,
|
|
10
|
+
chartId,
|
|
11
|
+
currentData
|
|
12
|
+
} = useContext(ChartContext);
|
|
13
|
+
const hasData = currentData.length > 0;
|
|
14
|
+
const name = getChartDefaultName(isHorizontal ? xAxis.label : yAxis.label, isHorizontal ? yAxis.label : xAxis.label);
|
|
15
|
+
const instructions = useMemo(
|
|
16
|
+
() => getKeyboardInstructions({
|
|
17
|
+
isHorizontal,
|
|
18
|
+
hasSeveralSeries: currentData.length > 1,
|
|
19
|
+
canZoom: Boolean(xScroll) && xScale?.type !== "BAND"
|
|
20
|
+
}),
|
|
21
|
+
[currentData.length, isHorizontal, xScale?.type, xScroll]
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
name,
|
|
25
|
+
instructionsId: hasData ? `ds-dataviz-instructions-${chartId}` : void 0,
|
|
26
|
+
instructions: hasData ? instructions : null
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
useChartDescription
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useChartDescription.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useChartDescription.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useMemo } from 'react';\nimport { ChartContext } from '../ChartContext.js';\nimport { getChartDefaultName, getKeyboardInstructions } from '../helpers/index.js';\n\n// What the chart root tells a screen reader: a default name after its axis labels (consumers name it through the\n// dsDatavizRoot slot), and, while it has data to navigate, its keyboard instructions as description.\nexport const useChartDescription = () => {\n const {\n props: { xAxis, yAxis, xScroll },\n isHorizontal,\n xScale,\n chartId,\n currentData,\n } = useContext(ChartContext);\n const hasData = currentData.length > 0;\n\n const name = getChartDefaultName(isHorizontal ? xAxis.label : yAxis.label, isHorizontal ? yAxis.label : xAxis.label);\n const instructions = useMemo(\n () =>\n getKeyboardInstructions({\n isHorizontal,\n hasSeveralSeries: currentData.length > 1,\n canZoom: Boolean(xScroll) && xScale?.type !== 'BAND',\n }),\n [currentData.length, isHorizontal, xScale?.type, xScroll],\n );\n\n return {\n name,\n instructionsId: hasData ? `ds-dataviz-instructions-${chartId}` : undefined,\n instructions: hasData ? instructions : null,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,YAAY,eAAe;AACpC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB,+BAA+B;AAItD,MAAM,sBAAsB,MAAM;AACvC,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO,OAAO,QAAQ;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAC3B,QAAM,UAAU,YAAY,SAAS;AAErC,QAAM,OAAO,oBAAoB,eAAe,MAAM,QAAQ,MAAM,OAAO,eAAe,MAAM,QAAQ,MAAM,KAAK;AACnH,QAAM,eAAe;AAAA,IACnB,MACE,wBAAwB;AAAA,MACtB;AAAA,MACA,kBAAkB,YAAY,SAAS;AAAA,MACvC,SAAS,QAAQ,OAAO,KAAK,QAAQ,SAAS;AAAA,IAChD,CAAC;AAAA,IACH,CAAC,YAAY,QAAQ,cAAc,QAAQ,MAAM,OAAO;AAAA,EAC1D;AAEA,SAAO;AAAA,IACL;AAAA,IACA,gBAAgB,UAAU,2BAA2B,OAAO,KAAK;AAAA,IACjE,cAAc,UAAU,eAAe;AAAA,EACzC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useContext, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
import { ChartContext } from "../ChartContext.js";
|
|
4
|
+
import { LinearScale, LogScale } from "../scales/index.js";
|
|
5
|
+
const ENTRANCE_ANIMATION = {
|
|
6
|
+
DEFAULT_DURATION: 700,
|
|
7
|
+
// bars: a quick start that settles softly
|
|
8
|
+
EASING: "cubic-bezier(0.22, 1, 0.36, 1)",
|
|
9
|
+
// lines: an even pace, so their segments show up one after the other
|
|
10
|
+
REVEAL_EASING: "cubic-bezier(0.37, 0, 0.63, 1)",
|
|
11
|
+
// how far the reveal of a line reaches out of the plot, so its stroke and its markers are not cut at the edges
|
|
12
|
+
REVEAL_OVERFLOW: 12
|
|
13
|
+
};
|
|
14
|
+
const getSerieEntrance = (serie) => serie.type === "line" || serie.type === "area" ? "reveal" : "grow";
|
|
15
|
+
const ENTRANCE_ATTRIBUTE = "data-entrance-animation";
|
|
16
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
17
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
18
|
+
const getBaseline = (valueScale, edge, size) => {
|
|
19
|
+
if (!(valueScale instanceof LinearScale) || valueScale instanceof LogScale) return edge;
|
|
20
|
+
const zero = valueScale.get(0);
|
|
21
|
+
return Number.isFinite(zero) ? clamp(zero, 0, size) : edge;
|
|
22
|
+
};
|
|
23
|
+
const setRevealSize = (rect, innerWidth, innerHeight) => {
|
|
24
|
+
const overflow = ENTRANCE_ANIMATION.REVEAL_OVERFLOW;
|
|
25
|
+
rect.setAttribute("x", String(-overflow));
|
|
26
|
+
rect.setAttribute("y", String(-overflow));
|
|
27
|
+
rect.setAttribute("width", String(Math.max(0, innerWidth + overflow * 2)));
|
|
28
|
+
rect.setAttribute("height", String(Math.max(0, innerHeight + overflow * 2)));
|
|
29
|
+
};
|
|
30
|
+
const getDuration = (animationDuration) => (
|
|
31
|
+
// a negative or non numeric duration would make the Web Animation throw
|
|
32
|
+
Number.isFinite(animationDuration) ? Math.max(0, animationDuration) : ENTRANCE_ANIMATION.DEFAULT_DURATION
|
|
33
|
+
);
|
|
34
|
+
const getSeriesThatEnter = (seriesGroup, entrance) => Array.from(seriesGroup.querySelectorAll(`:scope > [${ENTRANCE_ATTRIBUTE}="${entrance}"]`));
|
|
35
|
+
const startReveal = (seriesGroup, drawn, {
|
|
36
|
+
clipId,
|
|
37
|
+
innerWidth,
|
|
38
|
+
innerHeight,
|
|
39
|
+
timing
|
|
40
|
+
}) => {
|
|
41
|
+
const clipPath = document.createElementNS(SVG_NAMESPACE, "clipPath");
|
|
42
|
+
clipPath.setAttribute("id", clipId);
|
|
43
|
+
const rect = document.createElementNS(SVG_NAMESPACE, "rect");
|
|
44
|
+
setRevealSize(rect, innerWidth, innerHeight);
|
|
45
|
+
clipPath.append(rect);
|
|
46
|
+
seriesGroup.prepend(clipPath);
|
|
47
|
+
drawn.forEach((serie) => serie.setAttribute("clip-path", `url(#${clipId})`));
|
|
48
|
+
const animation = rect.animate([{ transform: "scale(0, 1)" }, { transform: "scale(1, 1)" }], timing);
|
|
49
|
+
const remove = () => {
|
|
50
|
+
drawn.forEach((serie) => serie.removeAttribute("clip-path"));
|
|
51
|
+
clipPath.remove();
|
|
52
|
+
};
|
|
53
|
+
return { rect, animation, remove };
|
|
54
|
+
};
|
|
55
|
+
const useEntranceAnimation = () => {
|
|
56
|
+
const {
|
|
57
|
+
props: { withAnimation, animationDuration = ENTRANCE_ANIMATION.DEFAULT_DURATION },
|
|
58
|
+
chartId,
|
|
59
|
+
isHorizontal,
|
|
60
|
+
xScale,
|
|
61
|
+
yScale,
|
|
62
|
+
innerWidth,
|
|
63
|
+
innerHeight
|
|
64
|
+
} = useContext(ChartContext);
|
|
65
|
+
const [seriesGroup, setSeriesGroup] = useState(null);
|
|
66
|
+
const revealRef = useRef(null);
|
|
67
|
+
const transformOrigin = isHorizontal ? `${getBaseline(xScale, 0, innerWidth)}px 0px` : `0px ${getBaseline(yScale, innerHeight, innerHeight)}px`;
|
|
68
|
+
useLayoutEffect(() => {
|
|
69
|
+
if (!withAnimation || !seriesGroup || typeof seriesGroup.animate !== "function") return () => {
|
|
70
|
+
};
|
|
71
|
+
if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return () => {
|
|
72
|
+
};
|
|
73
|
+
const timing = { duration: getDuration(animationDuration), easing: ENTRANCE_ANIMATION.EASING };
|
|
74
|
+
const collapsed = isHorizontal ? "scale(0, 1)" : "scale(1, 0)";
|
|
75
|
+
const animations = getSeriesThatEnter(seriesGroup, "grow").map(
|
|
76
|
+
(serie) => serie.animate([{ transform: collapsed }, { transform: "scale(1, 1)" }], timing)
|
|
77
|
+
);
|
|
78
|
+
const drawn = getSeriesThatEnter(seriesGroup, "reveal");
|
|
79
|
+
const reveal = drawn.length ? startReveal(seriesGroup, drawn, {
|
|
80
|
+
clipId: `ds-dataviz-reveal-${chartId}`,
|
|
81
|
+
innerWidth,
|
|
82
|
+
innerHeight,
|
|
83
|
+
timing: { ...timing, easing: ENTRANCE_ANIMATION.REVEAL_EASING }
|
|
84
|
+
}) : null;
|
|
85
|
+
const removeReveal = () => {
|
|
86
|
+
reveal?.remove();
|
|
87
|
+
revealRef.current = null;
|
|
88
|
+
};
|
|
89
|
+
if (reveal) {
|
|
90
|
+
revealRef.current = reveal.rect;
|
|
91
|
+
animations.push(reveal.animation);
|
|
92
|
+
reveal.animation.finished?.then(removeReveal, () => {
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return () => {
|
|
96
|
+
animations.forEach((animation) => animation.cancel());
|
|
97
|
+
removeReveal();
|
|
98
|
+
};
|
|
99
|
+
}, [seriesGroup]);
|
|
100
|
+
useLayoutEffect(() => {
|
|
101
|
+
if (revealRef.current) setRevealSize(revealRef.current, innerWidth, innerHeight);
|
|
102
|
+
});
|
|
103
|
+
return { setSeriesGroup, seriesGroup, withAnimation: Boolean(withAnimation), transformOrigin };
|
|
104
|
+
};
|
|
105
|
+
export {
|
|
106
|
+
ENTRANCE_ANIMATION,
|
|
107
|
+
ENTRANCE_ATTRIBUTE,
|
|
108
|
+
getSerieEntrance,
|
|
109
|
+
useEntranceAnimation
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=useEntranceAnimation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useEntranceAnimation.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useLayoutEffect, useRef, useState } from 'react';\nimport { ChartContext } from '../ChartContext.js';\nimport { LinearScale, LogScale, type ScaleT } from '../scales/index.js';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\n\nexport const ENTRANCE_ANIMATION = {\n DEFAULT_DURATION: 700,\n // bars: a quick start that settles softly\n EASING: 'cubic-bezier(0.22, 1, 0.36, 1)',\n // lines: an even pace, so their segments show up one after the other\n REVEAL_EASING: 'cubic-bezier(0.37, 0, 0.63, 1)',\n // how far the reveal of a line reaches out of the plot, so its stroke and its markers are not cut at the edges\n REVEAL_OVERFLOW: 12,\n};\n\n// How a series enters: bars and scatter points grow from the baseline, lines and areas are drawn from left to right\nexport type EntranceT = 'grow' | 'reveal';\nexport const getSerieEntrance = (serie: DSChartT.InternalSerie): EntranceT =>\n serie.type === 'line' || serie.type === 'area' ? 'reveal' : 'grow';\n\n// the attribute that marks the group of a series with the way it enters\nexport const ENTRANCE_ATTRIBUTE = 'data-entrance-animation';\n\nconst SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\n// Where the marks grow from along the value axis: its zero, or the edge of the plot when zero is not on the axis (a log\n// axis, or a domain that does not reach it).\nconst getBaseline = (valueScale: ScaleT | null, edge: number, size: number) => {\n if (!(valueScale instanceof LinearScale) || valueScale instanceof LogScale) return edge;\n const zero = valueScale.get(0);\n return Number.isFinite(zero) ? clamp(zero, 0, size) : edge;\n};\n\nconst setRevealSize = (rect: SVGRectElement, innerWidth: number, innerHeight: number) => {\n const overflow = ENTRANCE_ANIMATION.REVEAL_OVERFLOW;\n rect.setAttribute('x', String(-overflow));\n rect.setAttribute('y', String(-overflow));\n rect.setAttribute('width', String(Math.max(0, innerWidth + overflow * 2)));\n rect.setAttribute('height', String(Math.max(0, innerHeight + overflow * 2)));\n};\n\nconst getDuration = (animationDuration: number) =>\n // a negative or non numeric duration would make the Web Animation throw\n Number.isFinite(animationDuration) ? Math.max(0, animationDuration) : ENTRANCE_ANIMATION.DEFAULT_DURATION;\n\nconst getSeriesThatEnter = (seriesGroup: SVGGElement, entrance: EntranceT) =>\n Array.from(seriesGroup.querySelectorAll<SVGGElement>(`:scope > [${ENTRANCE_ATTRIBUTE}=\"${entrance}\"]`));\n\n// Draws the series from left to right through a clip path that grows with the animation. Returns the rect of the clip,\n// so it can follow the size of the plot, the animation, and the cleanup that removes the clip path.\nconst startReveal = (\n seriesGroup: SVGGElement,\n drawn: SVGGElement[],\n {\n clipId,\n innerWidth,\n innerHeight,\n timing,\n }: { clipId: string; innerWidth: number; innerHeight: number; timing: KeyframeAnimationOptions },\n) => {\n const clipPath = document.createElementNS(SVG_NAMESPACE, 'clipPath');\n clipPath.setAttribute('id', clipId);\n const rect = document.createElementNS(SVG_NAMESPACE, 'rect');\n setRevealSize(rect, innerWidth, innerHeight);\n clipPath.append(rect);\n seriesGroup.prepend(clipPath);\n drawn.forEach((serie) => serie.setAttribute('clip-path', `url(#${clipId})`));\n const animation = rect.animate([{ transform: 'scale(0, 1)' }, { transform: 'scale(1, 1)' }], timing);\n const remove = () => {\n drawn.forEach((serie) => serie.removeAttribute('clip-path'));\n clipPath.remove();\n };\n return { rect, animation, remove };\n};\n\n// With withAnimation, the series enter when the chart mounts: bars and stacks grow from the baseline (they extend from it\n// on a horizontal chart) and scatter points rise from it, while lines and areas, with their points, are drawn from left\n// to right. Web Animations on the group of each series, so no render runs per frame. They run when the chart mounts\n// only: a new size, new data, a scroll step or a series shown again from the legend does not replay them. Skipped when\n// the user prefers reduced motion.\n//\n// The baseline is the transform origin of the groups that grow, a style that follows every render: the margins of the\n// chart are measured right after it mounts, and the baseline moves with them. Without a transform the origin has no\n// effect. The lines are drawn through a clip path that only exists while they are drawn, and that follows the size of\n// the plot in the same way.\nexport const useEntranceAnimation = () => {\n const {\n props: { withAnimation, animationDuration = ENTRANCE_ANIMATION.DEFAULT_DURATION },\n chartId,\n isHorizontal,\n xScale,\n yScale,\n innerWidth,\n innerHeight,\n } = useContext(ChartContext);\n const [seriesGroup, setSeriesGroup] = useState<SVGGElement | null>(null);\n const revealRef = useRef<SVGRectElement | null>(null);\n\n const transformOrigin = isHorizontal\n ? `${getBaseline(xScale, 0, innerWidth)}px 0px`\n : `0px ${getBaseline(yScale, innerHeight, innerHeight)}px`;\n\n useLayoutEffect(() => {\n if (!withAnimation || !seriesGroup || typeof seriesGroup.animate !== 'function') return () => {};\n if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return () => {};\n\n const timing = { duration: getDuration(animationDuration), easing: ENTRANCE_ANIMATION.EASING };\n const collapsed = isHorizontal ? 'scale(0, 1)' : 'scale(1, 0)';\n const animations = getSeriesThatEnter(seriesGroup, 'grow').map((serie) =>\n serie.animate([{ transform: collapsed }, { transform: 'scale(1, 1)' }], timing),\n );\n\n const drawn = getSeriesThatEnter(seriesGroup, 'reveal');\n const reveal = drawn.length\n ? startReveal(seriesGroup, drawn, {\n clipId: `ds-dataviz-reveal-${chartId}`,\n innerWidth,\n innerHeight,\n timing: { ...timing, easing: ENTRANCE_ANIMATION.REVEAL_EASING },\n })\n : null;\n const removeReveal = () => {\n reveal?.remove();\n revealRef.current = null;\n };\n if (reveal) {\n revealRef.current = reveal.rect;\n animations.push(reveal.animation);\n // the clip path is gone once the lines are drawn; a cancelled animation rejects, and the cleanup removes it then\n reveal.animation.finished?.then(removeReveal, () => {});\n }\n\n return () => {\n animations.forEach((animation) => animation.cancel());\n removeReveal();\n };\n // the group mounting is what starts them\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [seriesGroup]);\n\n // the reveal follows the size of the plot while the lines are drawn\n useLayoutEffect(() => {\n if (revealRef.current) setRevealSize(revealRef.current, innerWidth, innerHeight);\n });\n\n return { setSeriesGroup, seriesGroup, withAnimation: Boolean(withAnimation), transformOrigin };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,YAAY,iBAAiB,QAAQ,gBAAgB;AAC9D,SAAS,oBAAo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AAAA,MAAI,CAAC,UAC9D,MAAM,QAAQ,CAAC,EAAE,WAAW,UAAU,GAAG,EAAE,WAAW,cAAc,CAAC,GAAG,MAAM;AAAA,IAChF;AAEA,UAAM,QAAQ,mBAAmB,aAAa,QAAQ;AACtD,UAAM,SAAS,MAAM,SACjB,YAAY,aAAa,OAAO;AAAA,MAC9B,QAAQ,qBAAqB,OAAO;AAAA,MACpC;AAAA,MACA;AAAA,MACA,QAAQ,EAAE,GAAG,QAAQ,QAAQ,mBAAmB,cAAc;AAAA,IAChE,CAAC,IACD;AACJ,UAAM,eAAe,MAAM;AACzB,cAAQ,OAAO;AACf,gBAAU,UAAU;AAAA,IACtB;AACA,QAAI,QAAQ;AACV,gBAAU,UAAU,OAAO;AAC3B,iBAAW,KAAK,OAAO,SAAS;AAEhC,aAAO,UAAU,UAAU,KAAK,cAAc,MAAM;AAAA,MAAC,CAAC;AAAA,IACxD;AAEA,WAAO,MAAM;AACX,iBAAW,QAAQ,CAAC,cAAc,UAAU,OAAO,CAAC;AACpD,mBAAa;AAAA,IACf;AAAA,EAGF,GAAG,CAAC,WAAW,CAAC;AAGhB,kBAAgB,MAAM;AACpB,QAAI,UAAU,QAAS,eAAc,UAAU,SAAS,YAAY,WAAW;AAAA,EACjF,CAAC;AAED,SAAO,EAAE,gBAAgB,aAAa,eAAe,QAAQ,aAAa,GAAG,gBAAgB;AAC/F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useCallback, useMemo } from "react";
|
|
3
|
+
const formatDateInUtc = (date) => {
|
|
4
|
+
const hasTime = date.getUTCHours() !== 0 || date.getUTCMinutes() !== 0;
|
|
5
|
+
return date.toLocaleString("en-US", {
|
|
6
|
+
timeZone: "UTC",
|
|
7
|
+
dateStyle: "medium",
|
|
8
|
+
...hasTime ? { timeStyle: "short" } : {}
|
|
9
|
+
});
|
|
10
|
+
};
|
|
3
11
|
function isLinear(scale) {
|
|
4
12
|
return scale.type !== "LINEAR";
|
|
5
13
|
}
|
|
@@ -107,6 +115,8 @@ const useGetters = ({ xAxis, isHorizontal, yAxis, xScale, yScale, y2Scale }) =>
|
|
|
107
115
|
if (!datum) return null;
|
|
108
116
|
const value = getXValue(datum);
|
|
109
117
|
if (typeof xAxis.tick?.tickFormat === "function") return xAxis.tick.tickFormat(value);
|
|
118
|
+
const rawValue = value;
|
|
119
|
+
if (rawValue instanceof Date) return formatDateInUtc(rawValue);
|
|
110
120
|
return value;
|
|
111
121
|
},
|
|
112
122
|
[getXValue, xAxis.tick]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useGetters.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useMemo } from 'react';\nimport type { DSChartT } from '
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,eAAe;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useCallback, useMemo } from 'react';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\nimport type { TimeLinearScale, LinearScale, BandScale } from '../scales/index.js';\n\nconst formatDateInUtc = (date: Date) => {\n const hasTime = date.getUTCHours() !== 0 || date.getUTCMinutes() !== 0;\n return date.toLocaleString('en-US', {\n timeZone: 'UTC',\n dateStyle: 'medium',\n ...(hasTime ? { timeStyle: 'short' } : {}),\n });\n};\ninterface UseGettersT {\n xAxis: DSChartT.AxisT;\n yAxis: DSChartT.AxisT;\n isHorizontal: boolean;\n xScale: TimeLinearScale | LinearScale | BandScale | null;\n yScale: TimeLinearScale | LinearScale | BandScale | null;\n y2Scale: TimeLinearScale | LinearScale | BandScale | null;\n}\n\ntype ValueT = number | string | Date;\n\nfunction isLinear(scale: TimeLinearScale | LinearScale | BandScale | null): scale is LinearScale {\n return (scale as LinearScale).type !== 'LINEAR';\n}\n\nfunction isBand(scale: TimeLinearScale | LinearScale | BandScale | null): scale is BandScale {\n return (scale as BandScale).type !== 'BAND';\n}\n\nfunction isTime(scale: TimeLinearScale | LinearScale | BandScale | null): scale is TimeLinearScale {\n return (scale as TimeLinearScale).type !== 'DATETIME';\n}\n\nfunction isValueT(value: DSChartT.InternalDatum | ValueT): value is ValueT {\n return typeof value === 'number' || typeof value === 'string' || value instanceof Date;\n}\n\nexport const useGetters = ({ xAxis, isHorizontal, yAxis, xScale, yScale, y2Scale }: UseGettersT) => {\n const getXValue = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (!datum) return null;\n if (!isHorizontal) {\n if (xAxis?.cols?.[datum.position]) {\n return xAxis?.cols?.[datum.position];\n }\n if (typeof datum.value === 'object') return datum.value?.x;\n return datum.position.toString();\n }\n if (typeof datum.value === 'number') {\n return datum.value;\n }\n return datum.value?.x;\n },\n [isHorizontal, xAxis?.cols],\n );\n\n const getYValue = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (!datum) return null;\n\n if (!isHorizontal) {\n if (typeof datum.value === 'number') {\n return datum.value;\n }\n return datum.value?.y;\n }\n if (yAxis?.cols?.[datum.position]) {\n return yAxis?.cols?.[datum.position];\n }\n if (typeof datum.value === 'object') return datum.value?.y;\n return datum.position.toString();\n },\n [isHorizontal, yAxis?.cols],\n );\n\n const getXScaleValue = useCallback(\n (datum: DSChartT.InternalDatum | ValueT) => {\n if (isLinear(xScale)) {\n if (isValueT(datum)) return xScale?.get(datum as number);\n return xScale?.get(getXValue(datum) as number);\n }\n if (isBand(xScale)) {\n if (isValueT(datum)) return xScale?.get(datum as string) ?? 0;\n return xScale?.get(getXValue(datum) as string) ?? 0;\n }\n if (isTime(xScale)) {\n if (isValueT(datum)) return xScale?.get(datum as Date);\n return xScale?.get(new Date(getXValue(datum) as string));\n }\n return 0;\n },\n [getXValue, xScale],\n );\n\n const getYScaleValue = useCallback(\n (datum: DSChartT.InternalDatum | ValueT) => {\n if (isLinear(yScale)) {\n if (isValueT(datum)) return yScale?.get(datum as number);\n return yScale.get(getYValue(datum) as number);\n }\n if (isBand(yScale)) {\n if (isValueT(datum)) return yScale?.get(datum as string) ?? 0;\n return yScale?.get(getYValue(datum) as string) ?? 0;\n }\n return 0;\n },\n [getYValue, yScale],\n );\n\n const getY2ScaleValue = useCallback(\n (datum: DSChartT.InternalDatum | ValueT) => {\n if (isLinear(y2Scale)) {\n if (isValueT(datum)) return y2Scale?.get(datum as number);\n return y2Scale.get(getYValue(datum) as number);\n }\n if (isBand(y2Scale)) {\n if (isValueT(datum)) return y2Scale?.get(datum as string) ?? 0;\n return y2Scale?.get(getYValue(datum) as string) ?? 0;\n }\n return 0;\n },\n [getYValue, y2Scale],\n );\n\n const getYValueFormatted = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (!datum) return null;\n\n const value = getYValue(datum);\n if (typeof yAxis.tick?.tickFormat === 'function') return yAxis.tick.tickFormat(value as number);\n return value;\n },\n [getYValue, yAxis.tick],\n );\n\n const getXValueFormatted = useCallback(\n (datum: DSChartT.InternalDatum) => {\n if (!datum) return null;\n\n const value = getXValue(datum);\n if (typeof xAxis.tick?.tickFormat === 'function') return xAxis.tick.tickFormat(value as number);\n // a date reads in UTC, like the ticks of the axis, and in full: the day, and the time when it is not midnight\n // (getXValue is typed without Date, but a time axis gives one)\n const rawValue: unknown = value;\n if (rawValue instanceof Date) return formatDateInUtc(rawValue);\n return value;\n },\n [getXValue, xAxis.tick],\n );\n\n return useMemo(\n () => ({\n getYValue,\n getY2ScaleValue,\n getXValue,\n getXScaleValue,\n getYScaleValue,\n getYValueFormatted,\n getXValueFormatted,\n }),\n [getYValue, getXValue, getY2ScaleValue, getXScaleValue, getYScaleValue, getYValueFormatted, getXValueFormatted],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,aAAa,eAAe;AAIrC,MAAM,kBAAkB,CAAC,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