@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
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useContext, useEffect, useLayoutEffect, useRef } from "react";
|
|
3
|
+
import { ChartContext } from "../ChartContext.js";
|
|
4
|
+
import { LinearScale, LogScale } from "../scales/index.js";
|
|
5
|
+
const VALUE_AXIS_TRANSITION = {
|
|
6
|
+
DURATION: 300,
|
|
7
|
+
// a quick start that settles softly, for the series and the ticks alike
|
|
8
|
+
EASING: "cubic-bezier(0.22, 1, 0.36, 1)",
|
|
9
|
+
// the attribute that marks the group of a series, and of the zero line, with the vertical axis it is read on
|
|
10
|
+
ATTRIBUTE: "data-value-axis"
|
|
11
|
+
};
|
|
12
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
13
|
+
const CLIP_OVERFLOW = 8;
|
|
14
|
+
const setTransitionClip = (seriesGroup, clipId, height) => {
|
|
15
|
+
let clipPath = seriesGroup.querySelector(`#${clipId}`);
|
|
16
|
+
if (!clipPath) {
|
|
17
|
+
clipPath = document.createElementNS(SVG_NAMESPACE, "clipPath");
|
|
18
|
+
clipPath.setAttribute("id", clipId);
|
|
19
|
+
clipPath.append(document.createElementNS(SVG_NAMESPACE, "rect"));
|
|
20
|
+
seriesGroup.prepend(clipPath);
|
|
21
|
+
}
|
|
22
|
+
const rect = clipPath.firstElementChild;
|
|
23
|
+
rect?.setAttribute("x", "-100000");
|
|
24
|
+
rect?.setAttribute("width", "200000");
|
|
25
|
+
rect?.setAttribute("y", String(-CLIP_OVERFLOW));
|
|
26
|
+
rect?.setAttribute("height", String(Math.max(0, height + CLIP_OVERFLOW * 2)));
|
|
27
|
+
seriesGroup.setAttribute("clip-path", `url(#${clipId})`);
|
|
28
|
+
};
|
|
29
|
+
const removeTransitionClip = (seriesGroup, clipId) => {
|
|
30
|
+
seriesGroup.removeAttribute("clip-path");
|
|
31
|
+
seriesGroup.querySelector(`#${clipId}`)?.remove();
|
|
32
|
+
};
|
|
33
|
+
const easeOut = (t) => 1 - (1 - t) ** 3;
|
|
34
|
+
const getAffineAt = (transition, now) => {
|
|
35
|
+
if (!transition) return [1, 0];
|
|
36
|
+
const left = 1 - easeOut(Math.min(1, (now - transition.start) / VALUE_AXIS_TRANSITION.DURATION));
|
|
37
|
+
return [1 + (transition.from[0] - 1) * left, transition.from[1] * left];
|
|
38
|
+
};
|
|
39
|
+
const getLinearMapping = (scale) => scale instanceof LinearScale && !(scale instanceof LogScale) ? { domain: scale.scale.domain(), range: scale.scale.range() } : null;
|
|
40
|
+
const isSameMapping = (a, b) => a.domain.every((value, index) => value === b.domain[index]) && a.range.every((value, index) => value === b.range[index]);
|
|
41
|
+
const getMapToPrevious = (previous, next) => {
|
|
42
|
+
const toPrevious = (value) => previous.range[0] + (value - previous.domain[0]) / (previous.domain[1] - previous.domain[0]) * (previous.range[1] - previous.range[0]);
|
|
43
|
+
const [r0, r1] = next.range;
|
|
44
|
+
const p0 = toPrevious(next.domain[0]);
|
|
45
|
+
const p1 = toPrevious(next.domain[1]);
|
|
46
|
+
const a = (p1 - p0) / (r1 - r0);
|
|
47
|
+
return [a, p0 - a * r0];
|
|
48
|
+
};
|
|
49
|
+
const useValueAxisTransition = (seriesGroup) => {
|
|
50
|
+
const { yScale, y2Scale, chartId, innerHeight } = useContext(ChartContext);
|
|
51
|
+
const clipId = `value-axis-transition-${chartId}`;
|
|
52
|
+
const previous = useRef({});
|
|
53
|
+
const running = useRef({});
|
|
54
|
+
useLayoutEffect(() => {
|
|
55
|
+
const scales = { y: yScale, y2: y2Scale };
|
|
56
|
+
const prefersReducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
57
|
+
["y", "y2"].forEach((axis) => {
|
|
58
|
+
const next = getLinearMapping(scales[axis]);
|
|
59
|
+
const before = previous.current[axis];
|
|
60
|
+
previous.current[axis] = next;
|
|
61
|
+
if (!seriesGroup || !before || !next || prefersReducedMotion) return;
|
|
62
|
+
if (isSameMapping(before, next) || before.range.some((value, index) => value !== next.range[index])) return;
|
|
63
|
+
const now = performance.now();
|
|
64
|
+
const [ta, tb] = getAffineAt(running.current[axis], now);
|
|
65
|
+
const [ma, mb] = getMapToPrevious(before, next);
|
|
66
|
+
const from = [ta * ma, ta * mb + tb];
|
|
67
|
+
cancelAnimationFrame(running.current[axis]?.frame ?? 0);
|
|
68
|
+
const getGroups = () => seriesGroup.querySelectorAll(`[${VALUE_AXIS_TRANSITION.ATTRIBUTE}="${axis}"]`);
|
|
69
|
+
const step = () => {
|
|
70
|
+
const time = performance.now();
|
|
71
|
+
const transition = running.current[axis];
|
|
72
|
+
const [a, b] = getAffineAt(transition, time);
|
|
73
|
+
const isDone = !transition || time - transition.start >= VALUE_AXIS_TRANSITION.DURATION;
|
|
74
|
+
getGroups().forEach(
|
|
75
|
+
(group) => isDone ? group.removeAttribute("transform") : group.setAttribute("transform", `matrix(1 0 0 ${a} 0 ${b})`)
|
|
76
|
+
);
|
|
77
|
+
if (isDone) delete running.current[axis];
|
|
78
|
+
else if (transition) transition.frame = requestAnimationFrame(step);
|
|
79
|
+
if (!Object.keys(running.current).length) removeTransitionClip(seriesGroup, clipId);
|
|
80
|
+
};
|
|
81
|
+
running.current[axis] = { from, start: now, frame: 0 };
|
|
82
|
+
setTransitionClip(seriesGroup, clipId, innerHeight);
|
|
83
|
+
step();
|
|
84
|
+
});
|
|
85
|
+
}, [clipId, innerHeight, seriesGroup, y2Scale, yScale]);
|
|
86
|
+
useEffect(
|
|
87
|
+
() => () => {
|
|
88
|
+
Object.values(running.current).forEach((transition) => cancelAnimationFrame(transition?.frame ?? 0));
|
|
89
|
+
if (seriesGroup) removeTransitionClip(seriesGroup, clipId);
|
|
90
|
+
},
|
|
91
|
+
[clipId, seriesGroup]
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
export {
|
|
95
|
+
VALUE_AXIS_TRANSITION,
|
|
96
|
+
useValueAxisTransition
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=useValueAxisTransition.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useValueAxisTransition.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useEffect, useLayoutEffect, useRef } from 'react';\nimport { ChartContext } from '../ChartContext.js';\nimport { LinearScale, LogScale, type ScaleT } from '../scales/index.js';\n\nexport const VALUE_AXIS_TRANSITION = {\n DURATION: 300,\n // a quick start that settles softly, for the series and the ticks alike\n EASING: 'cubic-bezier(0.22, 1, 0.36, 1)',\n // the attribute that marks the group of a series, and of the zero line, with the vertical axis it is read on\n ATTRIBUTE: 'data-value-axis',\n};\n\ntype ValueAxisT = 'y' | 'y2';\n// an affine map of the vertical position: y' = a * y + b\ntype AffineT = [number, number];\n\ninterface TransitionT {\n from: AffineT;\n start: number;\n frame: number;\n}\n\nconst SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n// how far the marks may reach out of the plot during a transition: their markers and their focus rings\nconst CLIP_OVERFLOW = 8;\n\n// While a transition draws the marks with the previous domain, the ones out of it (a series shown again from the\n// legend, with values above the previous top) would reach out of the plot, over the legend: the series are clipped to\n// the height of the plot meanwhile, with room for the markers. Not otherwise, as the markers and the focus rings at the\n// edges reach out of the plot on purpose. On the group of the series, which the transform does not move.\nconst setTransitionClip = (seriesGroup: SVGGElement, clipId: string, height: number) => {\n let clipPath = seriesGroup.querySelector(`#${clipId}`);\n if (!clipPath) {\n clipPath = document.createElementNS(SVG_NAMESPACE, 'clipPath');\n clipPath.setAttribute('id', clipId);\n clipPath.append(document.createElementNS(SVG_NAMESPACE, 'rect'));\n seriesGroup.prepend(clipPath);\n }\n const rect = clipPath.firstElementChild;\n // as wide as a scrollable plot can be: the clip is on the height only\n rect?.setAttribute('x', '-100000');\n rect?.setAttribute('width', '200000');\n rect?.setAttribute('y', String(-CLIP_OVERFLOW));\n rect?.setAttribute('height', String(Math.max(0, height + CLIP_OVERFLOW * 2)));\n seriesGroup.setAttribute('clip-path', `url(#${clipId})`);\n};\n\nconst removeTransitionClip = (seriesGroup: SVGGElement, clipId: string) => {\n seriesGroup.removeAttribute('clip-path');\n seriesGroup.querySelector(`#${clipId}`)?.remove();\n};\n\n// a quick start that settles softly\nconst easeOut = (t: number) => 1 - (1 - t) ** 3;\n\n// the transform a transition shows at a time: from its first map to none\nconst getAffineAt = (transition: TransitionT | undefined, now: number): AffineT => {\n if (!transition) return [1, 0];\n const left = 1 - easeOut(Math.min(1, (now - transition.start) / VALUE_AXIS_TRANSITION.DURATION));\n return [1 + (transition.from[0] - 1) * left, transition.from[1] * left];\n};\n\n// the domain and the range of a linear axis; a log axis does not map from one domain to another with an affine map\nconst getLinearMapping = (scale: ScaleT | null) =>\n scale instanceof LinearScale && !(scale instanceof LogScale)\n ? { domain: scale.scale.domain(), range: scale.scale.range() }\n : null;\n\ntype MappingT = NonNullable<ReturnType<typeof getLinearMapping>>;\n\nconst isSameMapping = (a: MappingT, b: MappingT) =>\n a.domain.every((value, index) => value === b.domain[index]) &&\n a.range.every((value, index) => value === b.range[index]);\n\n// the map from the position of a value with the new domain to its position with the previous one\nconst getMapToPrevious = (previous: MappingT, next: MappingT): AffineT => {\n const toPrevious = (value: number) =>\n previous.range[0] +\n ((value - previous.domain[0]) / (previous.domain[1] - previous.domain[0])) *\n (previous.range[1] - previous.range[0]);\n const [r0, r1] = next.range;\n const p0 = toPrevious(next.domain[0]);\n const p1 = toPrevious(next.domain[1]);\n const a = (p1 - p0) / (r1 - r0);\n return [a, p0 - a * r0];\n};\n\n// When the domain of a vertical axis changes (new data, a series hidden from the legend, or the view of a scrollable\n// chart, see fitToView), every mark it holds moved to its new height at once. The chart renders once with the new\n// domain; the series of the axis are then drawn where they were with the previous one, through an affine transform of\n// their groups, which eases to none (FLIP), as its ticks slide to their new places (see useTickTransition). No render\n// runs per frame: the transform attribute of a few groups. A change during a transition starts from where the marks\n// are, so nothing jumps. Skipped when the user prefers reduced motion, for a log axis, and when the size of the plot\n// changes.\nexport const useValueAxisTransition = (seriesGroup: SVGGElement | null) => {\n const { yScale, y2Scale, chartId, innerHeight } = useContext(ChartContext);\n const clipId = `value-axis-transition-${chartId}`;\n const previous = useRef<Partial<Record<ValueAxisT, MappingT | null>>>({});\n const running = useRef<Partial<Record<ValueAxisT, TransitionT>>>({});\n\n useLayoutEffect(() => {\n const scales: Record<ValueAxisT, ScaleT | null> = { y: yScale, y2: y2Scale };\n const prefersReducedMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;\n (['y', 'y2'] as const).forEach((axis) => {\n const next = getLinearMapping(scales[axis]);\n const before = previous.current[axis];\n previous.current[axis] = next;\n if (!seriesGroup || !before || !next || prefersReducedMotion) return;\n if (isSameMapping(before, next) || before.range.some((value, index) => value !== next.range[index])) return;\n const now = performance.now();\n const [ta, tb] = getAffineAt(running.current[axis], now);\n const [ma, mb] = getMapToPrevious(before, next);\n const from: AffineT = [ta * ma, ta * mb + tb];\n cancelAnimationFrame(running.current[axis]?.frame ?? 0);\n // read every frame: the groups of the series that come into the view mount during the transition\n const getGroups = () =>\n seriesGroup.querySelectorAll<SVGGElement>(`[${VALUE_AXIS_TRANSITION.ATTRIBUTE}=\"${axis}\"]`);\n const step = () => {\n const time = performance.now();\n const transition = running.current[axis];\n const [a, b] = getAffineAt(transition, time);\n const isDone = !transition || time - transition.start >= VALUE_AXIS_TRANSITION.DURATION;\n getGroups().forEach((group) =>\n isDone ? group.removeAttribute('transform') : group.setAttribute('transform', `matrix(1 0 0 ${a} 0 ${b})`),\n );\n if (isDone) delete running.current[axis];\n else if (transition) transition.frame = requestAnimationFrame(step);\n if (!Object.keys(running.current).length) removeTransitionClip(seriesGroup, clipId);\n };\n running.current[axis] = { from, start: now, frame: 0 };\n setTransitionClip(seriesGroup, clipId, innerHeight);\n // the first frame before the paint, so the marks never show at their new height first\n step();\n });\n }, [clipId, innerHeight, seriesGroup, y2Scale, yScale]);\n\n useEffect(\n () => () => {\n Object.values(running.current).forEach((transition) => cancelAnimationFrame(transition?.frame ?? 0));\n if (seriesGroup) removeTransitionClip(seriesGroup, clipId);\n },\n [clipId, seriesGroup],\n );\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useContext, useEffect, useRef } from "react";
|
|
3
|
+
import { ChartContext } from "../ChartContext.js";
|
|
4
|
+
const LINE_HEIGHT = 16;
|
|
5
|
+
const SCROLL_IDLE_DELAY = 150;
|
|
6
|
+
const getWheelDelta = (e, isHorizontal, pageSize) => {
|
|
7
|
+
let delta = 0;
|
|
8
|
+
if (isHorizontal) {
|
|
9
|
+
if (e.deltaX !== 0) delta = e.deltaX;
|
|
10
|
+
else if (e.shiftKey) delta = e.deltaY;
|
|
11
|
+
} else delta = e.deltaY;
|
|
12
|
+
if (e.deltaMode === 1) return delta * LINE_HEIGHT;
|
|
13
|
+
if (e.deltaMode === 2) return delta * pageSize;
|
|
14
|
+
return delta;
|
|
15
|
+
};
|
|
16
|
+
const useWheelScroll = () => {
|
|
17
|
+
const {
|
|
18
|
+
containerRef,
|
|
19
|
+
containerRatio,
|
|
20
|
+
innerWidth,
|
|
21
|
+
innerHeight,
|
|
22
|
+
setXScrollbarPosition,
|
|
23
|
+
interactionStore,
|
|
24
|
+
lastScrollbarPosition,
|
|
25
|
+
setScrapperPosX,
|
|
26
|
+
setScrapperPosY,
|
|
27
|
+
props: { xScroll, yScroll }
|
|
28
|
+
} = useContext(ChartContext);
|
|
29
|
+
const idleTimer = useRef();
|
|
30
|
+
useEffect(
|
|
31
|
+
() => () => {
|
|
32
|
+
clearTimeout(idleTimer.current);
|
|
33
|
+
interactionStore.setIsScrolling(false);
|
|
34
|
+
},
|
|
35
|
+
[interactionStore]
|
|
36
|
+
);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!containerRef || !(xScroll || yScroll) || containerRatio <= 1) return () => {
|
|
39
|
+
};
|
|
40
|
+
const observeTarget = containerRef;
|
|
41
|
+
const isHorizontal = Boolean(xScroll);
|
|
42
|
+
const viewportSize = isHorizontal ? innerWidth : innerHeight;
|
|
43
|
+
const maxPosition = viewportSize - viewportSize / containerRatio;
|
|
44
|
+
const handleWheel = (e) => {
|
|
45
|
+
const delta = getWheelDelta(e, isHorizontal, viewportSize);
|
|
46
|
+
if (delta === 0) return;
|
|
47
|
+
const { xScrollbarPosition } = interactionStore.getState();
|
|
48
|
+
const nextPosition = Math.min(maxPosition, Math.max(0, xScrollbarPosition + delta / containerRatio));
|
|
49
|
+
if (nextPosition === xScrollbarPosition) return;
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
setScrapperPosX(-1);
|
|
52
|
+
setScrapperPosY(-1);
|
|
53
|
+
lastScrollbarPosition.current = nextPosition;
|
|
54
|
+
setXScrollbarPosition(nextPosition);
|
|
55
|
+
interactionStore.setIsScrolling(true);
|
|
56
|
+
clearTimeout(idleTimer.current);
|
|
57
|
+
idleTimer.current = setTimeout(() => interactionStore.setIsScrolling(false), SCROLL_IDLE_DELAY);
|
|
58
|
+
};
|
|
59
|
+
observeTarget.addEventListener("wheel", handleWheel, { passive: false });
|
|
60
|
+
return () => {
|
|
61
|
+
observeTarget.removeEventListener("wheel", handleWheel);
|
|
62
|
+
};
|
|
63
|
+
}, [
|
|
64
|
+
containerRef,
|
|
65
|
+
containerRatio,
|
|
66
|
+
innerHeight,
|
|
67
|
+
innerWidth,
|
|
68
|
+
interactionStore,
|
|
69
|
+
lastScrollbarPosition,
|
|
70
|
+
setScrapperPosX,
|
|
71
|
+
setScrapperPosY,
|
|
72
|
+
setXScrollbarPosition,
|
|
73
|
+
xScroll,
|
|
74
|
+
yScroll
|
|
75
|
+
]);
|
|
76
|
+
};
|
|
77
|
+
export {
|
|
78
|
+
SCROLL_IDLE_DELAY,
|
|
79
|
+
useWheelScroll
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=useWheelScroll.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/config/useWheelScroll.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useEffect, useRef } from 'react';\nimport { ChartContext } from '../ChartContext.js';\n\n// pixels per line and per page for the wheel events that report lines (Firefox) or pages instead of pixels\nconst LINE_HEIGHT = 16;\n// how long after the last wheel event the scroll counts as stopped, and the scrapper shows again\nexport const SCROLL_IDLE_DELAY = 150;\n\nconst getWheelDelta = (e: WheelEvent, isHorizontal: boolean, pageSize: number) => {\n // a horizontally scrollable chart follows the horizontal intent only (a trackpad swipe, or Shift + wheel), so the\n // plain wheel keeps scrolling the page; a vertically scrollable chart follows the wheel\n let delta = 0;\n if (isHorizontal) {\n if (e.deltaX !== 0) delta = e.deltaX;\n else if (e.shiftKey) delta = e.deltaY;\n } else delta = e.deltaY;\n if (e.deltaMode === 1) return delta * LINE_HEIGHT;\n if (e.deltaMode === 2) return delta * pageSize;\n return delta;\n};\n\n// Scrolls a scrollable chart (xScroll / yScroll) with the mouse wheel and the trackpad. When the chart is already at\n// the start or the end in that direction, the event is left alone and the page scrolls, as with any nested scroll\n// container. A native listener because React registers onWheel as passive: from there the page would always scroll\n// along with the chart.\nexport const useWheelScroll = () => {\n const {\n containerRef,\n containerRatio,\n innerWidth,\n innerHeight,\n setXScrollbarPosition,\n interactionStore,\n lastScrollbarPosition,\n setScrapperPosX,\n setScrapperPosY,\n props: { xScroll, yScroll },\n } = useContext(ChartContext);\n\n // the scroll counts as stopped a moment after the last wheel event; the timer outlives the listener, which is added\n // again when the size of the plot changes (the axes of a scrollable chart follow the view, and their labels resize it)\n const idleTimer = useRef<ReturnType<typeof setTimeout>>();\n useEffect(\n () => () => {\n clearTimeout(idleTimer.current);\n interactionStore.setIsScrolling(false);\n },\n [interactionStore],\n );\n\n useEffect(() => {\n if (!containerRef || !(xScroll || yScroll) || containerRatio <= 1) return () => {};\n const observeTarget = containerRef;\n const isHorizontal = Boolean(xScroll);\n const viewportSize = isHorizontal ? innerWidth : innerHeight;\n // the scrollbar position is the thumb offset in the viewport; the content moves containerRatio times as much\n const maxPosition = viewportSize - viewportSize / containerRatio;\n\n const handleWheel = (e: WheelEvent) => {\n const delta = getWheelDelta(e, isHorizontal, viewportSize);\n if (delta === 0) return;\n const { xScrollbarPosition } = interactionStore.getState();\n const nextPosition = Math.min(maxPosition, Math.max(0, xScrollbarPosition + delta / containerRatio));\n if (nextPosition === xScrollbarPosition) return;\n e.preventDefault();\n // the guide line points at the value that was under the pointer before the content moved\n setScrapperPosX(-1);\n setScrapperPosY(-1);\n lastScrollbarPosition.current = nextPosition;\n setXScrollbarPosition(nextPosition);\n // the scrapper hides while the wheel scrolls: the content moving under the pointer changed it on every step\n interactionStore.setIsScrolling(true);\n clearTimeout(idleTimer.current);\n idleTimer.current = setTimeout(() => interactionStore.setIsScrolling(false), SCROLL_IDLE_DELAY);\n };\n\n observeTarget.addEventListener('wheel', handleWheel, { passive: false });\n return () => {\n observeTarget.removeEventListener('wheel', handleWheel);\n };\n }, [\n containerRef,\n containerRatio,\n innerHeight,\n innerWidth,\n interactionStore,\n lastScrollbarPosition,\n setScrapperPosX,\n setScrapperPosY,\n setXScrollbarPosition,\n xScroll,\n yScroll,\n ]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,YAAY,WAAW,cAAc;AAC9C,SAAS,oBAAoB;AAG7B,MAAM,cAAc;AAEb,MAAM,oBAAoB;AAEjC,MAAM,gBAAgB,CAAC,GAAe,cAAuB,aAAqB;AAGhF,MAAI,QAAQ;AACZ,MAAI,cAAc;AAChB,QAAI,EAAE,WAAW,EAAG,SAAQ,EAAE;AAAA,aACrB,EAAE,SAAU,SAAQ,EAAE;AAAA,EACjC,MAAO,SAAQ,EAAE;AACjB,MAAI,EAAE,cAAc,EAAG,QAAO,QAAQ;AACtC,MAAI,EAAE,cAAc,EAAG,QAAO,QAAQ;AACtC,SAAO;AACT;AAMO,MAAM,iBAAiB,MAAM;AAClC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,SAAS,QAAQ;AAAA,EAC5B,IAAI,WAAW,YAAY;AAI3B,QAAM,YAAY,OAAsC;AACxD;AAAA,IACE,MAAM,MAAM;AACV,mBAAa,UAAU,OAAO;AAC9B,uBAAiB,eAAe,KAAK;AAAA,IACvC;AAAA,IACA,CAAC,gBAAgB;AAAA,EACnB;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,gBAAgB,EAAE,WAAW,YAAY,kBAAkB,EAAG,QAAO,MAAM;AAAA,IAAC;AACjF,UAAM,gBAAgB;AACtB,UAAM,eAAe,QAAQ,OAAO;AACpC,UAAM,eAAe,eAAe,aAAa;AAEjD,UAAM,cAAc,eAAe,eAAe;AAElD,UAAM,cAAc,CAAC,MAAkB;AACrC,YAAM,QAAQ,cAAc,GAAG,cAAc,YAAY;AACzD,UAAI,UAAU,EAAG;AACjB,YAAM,EAAE,mBAAmB,IAAI,iBAAiB,SAAS;AACzD,YAAM,eAAe,KAAK,IAAI,aAAa,KAAK,IAAI,GAAG,qBAAqB,QAAQ,cAAc,CAAC;AACnG,UAAI,iBAAiB,mBAAoB;AACzC,QAAE,eAAe;AAEjB,sBAAgB,EAAE;AAClB,sBAAgB,EAAE;AAClB,4BAAsB,UAAU;AAChC,4BAAsB,YAAY;AAElC,uBAAiB,eAAe,IAAI;AACpC,mBAAa,UAAU,OAAO;AAC9B,gBAAU,UAAU,WAAW,MAAM,iBAAiB,eAAe,KAAK,GAAG,iBAAiB;AAAA,IAChG;AAEA,kBAAc,iBAAiB,SAAS,aAAa,EAAE,SAAS,MAAM,CAAC;AACvE,WAAO,MAAM;AACX,oBAAc,oBAAoB,SAAS,WAAW;AAAA,IACxD;AAAA,EACF,GAAG;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const STEP_MULTIPLES = [1, 2, 2.5, 5];
|
|
3
|
+
const SEARCHED_POWERS = 4;
|
|
4
|
+
const tickAt = (k, multiple, power) => power < 0 ? k * multiple / 10 ** -power : k * multiple * 10 ** power;
|
|
5
|
+
const getSteps = (lowest) => {
|
|
6
|
+
const firstPower = Math.floor(Math.log10(lowest));
|
|
7
|
+
const powers = Array.from({ length: SEARCHED_POWERS }, (_, index) => firstPower + index);
|
|
8
|
+
return powers.flatMap((power) => STEP_MULTIPLES.map((multiple) => ({ multiple, power }))).filter(({ multiple, power }) => multiple * 10 ** power >= lowest);
|
|
9
|
+
};
|
|
10
|
+
const isValidRange = (intervals, low, high) => intervals >= 1 && Number.isFinite(low) && Number.isFinite(high) && high > low;
|
|
11
|
+
const getAlignedTicks = (intervals, [low, high], zeroIndex) => {
|
|
12
|
+
if (!isValidRange(intervals, low, high)) return null;
|
|
13
|
+
const zero = zeroIndex !== null && zeroIndex > 0 && zeroIndex < intervals && low < 0 && high > 0 ? zeroIndex : null;
|
|
14
|
+
const lowest = zero !== null ? Math.max(-low / zero, high / (intervals - zero)) : (high - low) / intervals;
|
|
15
|
+
const firstTick = (step) => zero !== null ? -zero : Math.floor(low / step);
|
|
16
|
+
const fitting = getSteps(lowest).find(
|
|
17
|
+
({ multiple, power }) => tickAt(firstTick(multiple * 10 ** power) + intervals, multiple, power) >= high
|
|
18
|
+
);
|
|
19
|
+
if (!fitting) return null;
|
|
20
|
+
const first = firstTick(fitting.multiple * 10 ** fitting.power);
|
|
21
|
+
return Array.from({ length: intervals + 1 }, (_, index) => tickAt(first + index, fitting.multiple, fitting.power));
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
getAlignedTicks
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=alignedTicks.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/alignedTicks.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// the multiples of a power of ten an aligned axis steps by, the ones of Highcharts: 2.5 keeps an axis from doubling its\n// span when 2 is too short, at the cost of a decimal on a small axis (0, 2.5, 5, 7.5, 10)\nconst STEP_MULTIPLES = [1, 2, 2.5, 5];\nconst SEARCHED_POWERS = 4;\n\n// the tick k steps of `step` away from 0: a decimal step divides by its power of ten, so 0.1 * 3 reads 0.3\nconst tickAt = (k: number, multiple: number, power: number) =>\n power < 0 ? (k * multiple) / 10 ** -power : k * multiple * 10 ** power;\n\nconst getSteps = (lowest: number) => {\n const firstPower = Math.floor(Math.log10(lowest));\n const powers = Array.from({ length: SEARCHED_POWERS }, (_, index) => firstPower + index);\n return powers\n .flatMap((power) => STEP_MULTIPLES.map((multiple) => ({ multiple, power })))\n .filter(({ multiple, power }) => multiple * 10 ** power >= lowest);\n};\n\nconst isValidRange = (intervals: number, low: number, high: number) =>\n intervals >= 1 && Number.isFinite(low) && Number.isFinite(high) && high > low;\n\n// The ticks of an axis that spans `intervals` intervals of a nice step and holds the values from `low` to `high`, with\n// the smallest step that fits, so the axis wastes the least of the plot. When `zeroIndex` is given and the values cross\n// zero, 0 is the tick at that index: two axes that cross zero share the height of their zero. Null when no step fits.\nexport const getAlignedTicks = (\n intervals: number,\n [low, high]: [number, number],\n zeroIndex: number | null,\n): number[] | null => {\n if (!isValidRange(intervals, low, high)) return null;\n const zero = zeroIndex !== null && zeroIndex > 0 && zeroIndex < intervals && low < 0 && high > 0 ? zeroIndex : null;\n const lowest = zero !== null ? Math.max(-low / zero, high / (intervals - zero)) : (high - low) / intervals;\n const firstTick = (step: number) => (zero !== null ? -zero : Math.floor(low / step));\n const fitting = getSteps(lowest).find(\n ({ multiple, power }) => tickAt(firstTick(multiple * 10 ** power) + intervals, multiple, power) >= high,\n );\n if (!fitting) return null;\n const first = firstTick(fitting.multiple * 10 ** fitting.power);\n return Array.from({ length: intervals + 1 }, (_, index) => tickAt(first + index, fitting.multiple, fitting.power));\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEvB,MAAM,iBAAiB,CAAC,GAAG,GAAG,KAAK,CAAC;AACpC,MAAM,kBAAkB;AAGxB,MAAM,SAAS,CAAC,GAAW,UAAkB,UAC3C,QAAQ,IAAK,IAAI,WAAY,MAAM,CAAC,QAAQ,IAAI,WAAW,MAAM;AAEnE,MAAM,WAAW,CAAC,WAAmB;AACnC,QAAM,aAAa,KAAK,MAAM,KAAK,MAAM,MAAM,CAAC;AAChD,QAAM,SAAS,MAAM,KAAK,EAAE,QAAQ,gBAAgB,GAAG,CAAC,GAAG,UAAU,aAAa,KAAK;AACvF,SAAO,OACJ,QAAQ,CAAC,UAAU,eAAe,IAAI,CAAC,cAAc,EAAE,UAAU,MAAM,EAAE,CAAC,EAC1E,OAAO,CAAC,EAAE,UAAU,MAAM,MAAM,WAAW,MAAM,SAAS,MAAM;AACrE;AAEA,MAAM,eAAe,CAAC,WAAmB,KAAa,SACpD,aAAa,KAAK,OAAO,SAAS,GAAG,KAAK,OAAO,SAAS,IAAI,KAAK,OAAO;AAKrE,MAAM,kBAAkB,CAC7B,WACA,CAAC,KAAK,IAAI,GACV,cACoB;AACpB,MAAI,CAAC,aAAa,WAAW,KAAK,IAAI,EAAG,QAAO;AAChD,QAAM,OAAO,cAAc,QAAQ,YAAY,KAAK,YAAY,aAAa,MAAM,KAAK,OAAO,IAAI,YAAY;AAC/G,QAAM,SAAS,SAAS,OAAO,KAAK,IAAI,CAAC,MAAM,MAAM,QAAQ,YAAY,KAAK,KAAK,OAAO,OAAO;AACjG,QAAM,YAAY,CAAC,SAAkB,SAAS,OAAO,CAAC,OAAO,KAAK,MAAM,MAAM,IAAI;AAClF,QAAM,UAAU,SAAS,MAAM,EAAE;AAAA,IAC/B,CAAC,EAAE,UAAU,MAAM,MAAM,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI,WAAW,UAAU,KAAK,KAAK;AAAA,EACrG;AACA,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,QAAQ,UAAU,QAAQ,WAAW,MAAM,QAAQ,KAAK;AAC9D,SAAO,MAAM,KAAK,EAAE,QAAQ,YAAY,EAAE,GAAG,CAAC,GAAG,UAAU,OAAO,QAAQ,OAAO,QAAQ,UAAU,QAAQ,KAAK,CAAC;AACnH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const getBarPath = ({ x, y, width, height, radius, dataEnd }) => {
|
|
3
|
+
if (!(width > 0) || !(height > 0)) return "";
|
|
4
|
+
const right = x + width;
|
|
5
|
+
const bottom = y + height;
|
|
6
|
+
if (dataEnd === "top" || dataEnd === "bottom") {
|
|
7
|
+
const r = Math.max(0, Math.min(radius, width / 2, height));
|
|
8
|
+
if (dataEnd === "top")
|
|
9
|
+
return `M${x},${bottom}V${y + r}A${r},${r} 0 0 1 ${x + r},${y}H${right - r}A${r},${r} 0 0 1 ${right},${y + r}V${bottom}Z`;
|
|
10
|
+
return `M${x},${y}H${right}V${bottom - r}A${r},${r} 0 0 1 ${right - r},${bottom}H${x + r}A${r},${r} 0 0 1 ${x},${bottom - r}Z`;
|
|
11
|
+
}
|
|
12
|
+
if (dataEnd === "left" || dataEnd === "right") {
|
|
13
|
+
const r = Math.max(0, Math.min(radius, height / 2, width));
|
|
14
|
+
if (dataEnd === "right")
|
|
15
|
+
return `M${x},${y}H${right - r}A${r},${r} 0 0 1 ${right},${y + r}V${bottom - r}A${r},${r} 0 0 1 ${right - r},${bottom}H${x}Z`;
|
|
16
|
+
return `M${right},${y}V${bottom}H${x + r}A${r},${r} 0 0 1 ${x},${bottom - r}V${y + r}A${r},${r} 0 0 1 ${x + r},${y}Z`;
|
|
17
|
+
}
|
|
18
|
+
return `M${x},${y}H${right}V${bottom}H${x}Z`;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
getBarPath
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=barPath.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/barPath.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export type BarDataEndT = 'top' | 'bottom' | 'left' | 'right' | 'none';\n\ninterface BarGeometryT {\n x: number;\n y: number;\n width: number;\n height: number;\n radius: number;\n dataEnd: BarDataEndT;\n}\n\n// The path of a bar whose data end is rounded and whose baseline end stays square, so the bar keeps growing from\n// its axis. 'none' draws a plain rectangle (the inner segments of a stack).\nexport const getBarPath = ({ x, y, width, height, radius, dataEnd }: BarGeometryT): string => {\n if (!(width > 0) || !(height > 0)) return '';\n const right = x + width;\n const bottom = y + height;\n if (dataEnd === 'top' || dataEnd === 'bottom') {\n const r = Math.max(0, Math.min(radius, width / 2, height));\n if (dataEnd === 'top')\n return `M${x},${bottom}V${y + r}A${r},${r} 0 0 1 ${x + r},${y}H${right - r}A${r},${r} 0 0 1 ${right},${y + r}V${bottom}Z`;\n return `M${x},${y}H${right}V${bottom - r}A${r},${r} 0 0 1 ${right - r},${bottom}H${x + r}A${r},${r} 0 0 1 ${x},${bottom - r}Z`;\n }\n if (dataEnd === 'left' || dataEnd === 'right') {\n const r = Math.max(0, Math.min(radius, height / 2, width));\n if (dataEnd === 'right')\n return `M${x},${y}H${right - r}A${r},${r} 0 0 1 ${right},${y + r}V${bottom - r}A${r},${r} 0 0 1 ${right - r},${bottom}H${x}Z`;\n return `M${right},${y}V${bottom}H${x + r}A${r},${r} 0 0 1 ${x},${bottom - r}V${y + r}A${r},${r} 0 0 1 ${x + r},${y}Z`;\n }\n return `M${x},${y}H${right}V${bottom}H${x}Z`;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACahB,MAAM,aAAa,CAAC,EAAE,GAAG,GAAG,OAAO,QAAQ,QAAQ,QAAQ,MAA4B;AAC5F,MAAI,EAAE,QAAQ,MAAM,EAAE,SAAS,GAAI,QAAO;AAC1C,QAAM,QAAQ,IAAI;AAClB,QAAM,SAAS,IAAI;AACnB,MAAI,YAAY,SAAS,YAAY,UAAU;AAC7C,UAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,QAAQ,GAAG,MAAM,CAAC;AACzD,QAAI,YAAY;AACd,aAAO,IAAI,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,CAAC,IAAI,MAAM;AACxH,WAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,QAAQ,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC;AAAA,EAC7H;AACA,MAAI,YAAY,UAAU,YAAY,SAAS;AAC7C,UAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,SAAS,GAAG,KAAK,CAAC;AACzD,QAAI,YAAY;AACd,aAAO,IAAI,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,CAAC,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,QAAQ,CAAC,IAAI,MAAM,IAAI,CAAC;AAC5H,WAAO,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,CAAC;AAAA,EACpH;AACA,SAAO,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,MAAM,IAAI,CAAC;AAC3C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const fitsToView = (axis, xScroll) => Boolean(xScroll && axis && axis.fitToView !== false);
|
|
3
|
+
const getDataInView = (data, getX, [start, end]) => {
|
|
4
|
+
const positions = /* @__PURE__ */ new Set();
|
|
5
|
+
const dataInView = data.map((serie) => {
|
|
6
|
+
const xs = serie.data.map(getX);
|
|
7
|
+
const inView = xs.flatMap((x, index) => x !== void 0 && x >= start && x <= end ? [index] : []);
|
|
8
|
+
let from;
|
|
9
|
+
let to;
|
|
10
|
+
if (inView.length) {
|
|
11
|
+
from = Math.max(0, inView[0] - 1);
|
|
12
|
+
to = Math.min(xs.length - 1, inView[inView.length - 1] + 1);
|
|
13
|
+
} else {
|
|
14
|
+
const after = xs.findIndex((x) => x !== void 0 && x > end);
|
|
15
|
+
from = Math.max(0, (after === -1 ? xs.length : after) - 1);
|
|
16
|
+
to = after === -1 ? xs.length - 1 : after;
|
|
17
|
+
}
|
|
18
|
+
const points = serie.data.slice(from, to + 1);
|
|
19
|
+
points.forEach((datum) => positions.add(datum.position));
|
|
20
|
+
return { ...serie, data: points };
|
|
21
|
+
});
|
|
22
|
+
return { data: dataInView, positions };
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
fitsToView,
|
|
26
|
+
getDataInView
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=dataInView.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/dataInView.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSChartT } from '../../../react-desc-prop-types.js';\n\n// Whether a vertical axis follows the view (fitToView): on a horizontally scrollable chart, unless it sets fitToView\n// false. On by default, as a scrollable chart shows a part of its data at a time, and the domain of the whole data\n// flattened the stretches of small values.\nexport const fitsToView = (axis: DSChartT.AxisT | undefined, xScroll: boolean | undefined) =>\n Boolean(xScroll && axis && axis.fitToView !== false);\n\n// The data of a horizontally scrollable chart in view, for the vertical axes with fitToView: of each series, the\n// points between the edges of the view, and the first point out of it on each side, as the line from it crosses the\n// edge (a value out of the domain would draw the line out of the plot). The series keep the order of their points.\nexport const getDataInView = (\n data: DSChartT.InternalData,\n getX: (datum: DSChartT.InternalDatum) => number | undefined,\n [start, end]: [number, number],\n): { data: DSChartT.InternalData; positions: Set<number> } => {\n const positions = new Set<number>();\n const dataInView = data.map((serie) => {\n const xs = serie.data.map(getX);\n const inView = xs.flatMap((x, index) => (x !== undefined && x >= start && x <= end ? [index] : []));\n let from: number;\n let to: number;\n if (inView.length) {\n from = Math.max(0, inView[0] - 1);\n to = Math.min(xs.length - 1, inView[inView.length - 1] + 1);\n } else {\n // no point in view: the two points the line crosses the view between, if any\n const after = xs.findIndex((x) => x !== undefined && x > end);\n from = Math.max(0, (after === -1 ? xs.length : after) - 1);\n to = after === -1 ? xs.length - 1 : after;\n }\n const points = serie.data.slice(from, to + 1);\n points.forEach((datum) => positions.add(datum.position));\n return { ...serie, data: points };\n });\n return { data: dataInView, positions };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACKhB,MAAM,aAAa,CAAC,MAAkC,YAC3D,QAAQ,WAAW,QAAQ,KAAK,cAAc,KAAK;AAK9C,MAAM,gBAAgB,CAC3B,MACA,MACA,CAAC,OAAO,GAAG,MACiD;AAC5D,QAAM,YAAY,oBAAI,IAAY;AAClC,QAAM,aAAa,KAAK,IAAI,CAAC,UAAU;AACrC,UAAM,KAAK,MAAM,KAAK,IAAI,IAAI;AAC9B,UAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,UAAW,MAAM,UAAa,KAAK,SAAS,KAAK,MAAM,CAAC,KAAK,IAAI,CAAC,CAAE;AAClG,QAAI;AACJ,QAAI;AACJ,QAAI,OAAO,QAAQ;AACjB,aAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;AAChC,WAAK,KAAK,IAAI,GAAG,SAAS,GAAG,OAAO,OAAO,SAAS,CAAC,IAAI,CAAC;AAAA,IAC5D,OAAO;AAEL,YAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,MAAM,UAAa,IAAI,GAAG;AAC5D,aAAO,KAAK,IAAI,IAAI,UAAU,KAAK,GAAG,SAAS,SAAS,CAAC;AACzD,WAAK,UAAU,KAAK,GAAG,SAAS,IAAI;AAAA,IACtC;AACA,UAAM,SAAS,MAAM,KAAK,MAAM,MAAM,KAAK,CAAC;AAC5C,WAAO,QAAQ,CAAC,UAAU,UAAU,IAAI,MAAM,QAAQ,CAAC;AACvD,WAAO,EAAE,GAAG,OAAO,MAAM,OAAO;AAAA,EAClC,CAAC;AACD,SAAO,EAAE,MAAM,YAAY,UAAU;AACvC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -48,9 +48,43 @@ const stackData = (groupsStacked, series, hiddenSeries, isHorizontal) => {
|
|
|
48
48
|
});
|
|
49
49
|
return { stackedData: allSeriesStackedByGroups, scalesStackedDataMap };
|
|
50
50
|
};
|
|
51
|
+
const isStackedSegmentEdge = (stackedData, serie, position) => {
|
|
52
|
+
const group = stackedData?.find(
|
|
53
|
+
(stackedGroup) => stackedGroup.some((stackedSerie) => stackedSerie.key === serie.name)
|
|
54
|
+
);
|
|
55
|
+
const segment = group?.find((stackedSerie) => stackedSerie.key === serie.name)?.[position];
|
|
56
|
+
if (!group || !segment || segment[0] === segment[1]) return false;
|
|
57
|
+
const segments = group.map((stackedSerie) => stackedSerie[position]).filter((d) => d && d[0] !== d[1]);
|
|
58
|
+
const isNegative = segment[1] <= 0 && segment[0] < 0;
|
|
59
|
+
if (isNegative) return segment[0] === Math.min(...segments.map((d) => d[0]));
|
|
60
|
+
return segment[1] === Math.max(...segments.map((d) => d[1]));
|
|
61
|
+
};
|
|
62
|
+
const getSVGBoxWidth = (node) => node && typeof node.getBBox === "function" ? node.getBBox().width : 0;
|
|
63
|
+
const getDatumLabel = (parts) => parts.filter((part) => part !== void 0 && part !== null && part !== "").map(String).join(" ");
|
|
64
|
+
const getChartDefaultName = (valueLabel, categoryLabel) => {
|
|
65
|
+
if (valueLabel && categoryLabel) return `${valueLabel} by ${categoryLabel}`;
|
|
66
|
+
return valueLabel || categoryLabel || void 0;
|
|
67
|
+
};
|
|
68
|
+
const getKeyboardInstructions = ({
|
|
69
|
+
isHorizontal,
|
|
70
|
+
hasSeveralSeries,
|
|
71
|
+
canZoom
|
|
72
|
+
}) => {
|
|
73
|
+
const along = isHorizontal ? "up and down" : "left and right";
|
|
74
|
+
const across = isHorizontal ? "left and right" : "up and down";
|
|
75
|
+
const sentences = [`Use the ${along} arrow keys to move between the data points of a series.`];
|
|
76
|
+
if (hasSeveralSeries) sentences.push(`Use the ${across} arrow keys to move to the same point of another series.`);
|
|
77
|
+
if (canZoom) sentences.push("Hold Shift while moving with the arrow keys to select a range to zoom into.");
|
|
78
|
+
return sentences.join(" ");
|
|
79
|
+
};
|
|
51
80
|
export {
|
|
81
|
+
getChartDefaultName,
|
|
82
|
+
getDatumLabel,
|
|
83
|
+
getKeyboardInstructions,
|
|
84
|
+
getSVGBoxWidth,
|
|
52
85
|
getStackedData,
|
|
53
86
|
getStackedIndex,
|
|
87
|
+
isStackedSegmentEdge,
|
|
54
88
|
stackData
|
|
55
89
|
};
|
|
56
90
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport { stack, stackOffsetDiverging } from 'd3';\nimport type { DSChartT } from '
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,OAAO,4BAA4B;AAGrC,MAAM,kBAAkB,CAAC,QAAqB,UAAmB;AACtE,MAAI,CAAC,OAAQ,QAAO;AACpB,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;AACzC,aAAS,IAAI,GAAG,IAAI,OAAO,CAAC,EAAE,QAAQ,KAAK,GAAG;AAC5C,UAAI,OAAO,CAAC,EAAE,CAAC,MAAM,MAAO,QAAO;AAAA,IACrC;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAC,aAA6C,UAAkC;AAC5G,WAAS,IAAI,GAAG,IAAI,aAAa,QAAQ,KAAK,GAAG;AAC/C,UAAM,OAAO,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,MAAM,IAAI;AAC5D,QAAI,KAAM,QAAO;AAAA,EACnB;AACA,SAAO;AACT;AAOA,MAAM,mBAAmB,CAAC,QAA4B,iBAA0B;AAC9E,QAAM,SAAS,OACZ,IAAI,CAAC,UAAU,MAAM,UAAU,eAAe,MAAM,IAAI,EACxD,OAAO,CAAC,OAAO,OAAO,SAAS,KAAK,QAAQ,KAAK,MAAM,KAAK;AAC/D,MAAI,OAAO,SAAS,GAAG;AACrB,WAAO;AAAA,EACT;AACA,SAAO,OAAO,CAAC;AACjB;AAGO,MAAM,YAAY,CACvB,eACA,QACA,cACA,iBACG;AACH,QAAM,2BAA2D,CAAC;AAClE,QAAM,uBAAiC,CAAC;AACxC,MAAI,CAAC,cAAe,QAAO,EAAE,aAAa,0BAA0B,qBAAqB;AAEzF,iBAAe,QAAQ,CAAC,MAAM;AAC5B,UAAM,6BAA6B,OAAO;AAAA,MACxC,CAAC,UAAU,EAAE,SAAS,MAAM,IAAI,KAAK,CAAC,aAAa,SAAS,MAAM,IAAI;AAAA,IACxE;AACA,UAAM,cAAc,iBAAiB,4BAA4B,YAAY;AAC7E,QAAI,CAAC,YAAa;AAClB,yBAAqB,KAAK,WAAW;AACrC,UAAM,OAAO,2BAA2B,IAAI,CAAC,UAAU,MAAM,IAAI;AACjE,UAAM,cAAsD,CAAC;AAC7D,+BAA2B,QAAQ,CAAC,UAAU;AAC5C,YAAM,KAAK,QAAQ,CAAC,GAAG,MAAM;AAC3B,oBAAY,CAAC,IAAI;AAAA,UACf,GAAG,YAAY,CAAC;AAAA,UAChB,CAAC,MAAM,IAAI,GAAG,OAAO,MAAM,WAAW,IAAI,GAAG,KAAK;AAAA,QACpD;AAAA,MACF,CAAC;AAAA,IACH,CAAC;AAED,6BAAyB,KAAK,MAAM,EAAE,OAAO,oBAAoB,EAAE,KAAK,IAAI,EAAE,WAAW,CAAC;AAAA,EAC5F,CAAC;AAED,SAAO,EAAE,aAAa,0BAA0B,qBAAqB;AACvE;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nimport { stack, stackOffsetDiverging } from 'd3';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\n\nexport const getStackedIndex = (groups?: string[][], serie?: string) => {\n if (!groups) return -1;\n for (let i = 0; i < groups.length; i += 1) {\n for (let j = 0; j < groups[i].length; j += 1) {\n if (groups[i][j] === serie) return i;\n }\n }\n return -1;\n};\n\nexport const getStackedData = (stackedData: DSChartT.StackedSeriesByGroupT, serie: DSChartT.InternalSerie) => {\n for (let i = 0; i < stackedData?.length; i += 1) {\n const data = stackedData[i].find((d) => d.key === serie.name);\n if (data) return data;\n }\n return false;\n};\n\n// this function check if the series that are stacked share the same scale.\n// return the scale or false if they dont share it\n//\n// si serie.scale === undefined ... la scala es Y\n\nconst checkSharedScale = (series: DSChartT.SeriesT[], isHorizontal: boolean) => {\n const scales = series\n .map((serie) => serie.scale || (isHorizontal ? 'x' : 'y'))\n .filter((value, index, self) => self.indexOf(value) === index);\n if (scales.length > 1) {\n return false;\n }\n return scales[0];\n};\n\n// transform series grouped in stack into what d3 stack function need to read\nexport const stackData = (\n groupsStacked: string[][] | undefined,\n series: DSChartT.SeriesT[],\n hiddenSeries: string[],\n isHorizontal: boolean,\n) => {\n const allSeriesStackedByGroups: DSChartT.StackedSeriesByGroupT = [];\n const scalesStackedDataMap: string[] = [];\n if (!groupsStacked) return { stackedData: allSeriesStackedByGroups, scalesStackedDataMap };\n\n groupsStacked?.forEach((g) => {\n const seriesFilteredByStackGroup = series.filter(\n (serie) => g.includes(serie.name) && !hiddenSeries.includes(serie.name),\n );\n const sharedScale = checkSharedScale(seriesFilteredByStackGroup, isHorizontal);\n if (!sharedScale) return;\n scalesStackedDataMap.push(sharedScale);\n const keys = seriesFilteredByStackGroup.map((serie) => serie.name);\n const stackedData: Array<{ [serieName: string]: number }> = [];\n seriesFilteredByStackGroup.forEach((serie) => {\n serie.data.forEach((d, i) => {\n stackedData[i] = {\n ...stackedData[i],\n [serie.name]: typeof d === 'number' ? d : d?.y || 0,\n };\n });\n });\n\n allSeriesStackedByGroups.push(stack().offset(stackOffsetDiverging).keys(keys)(stackedData));\n });\n\n return { stackedData: allSeriesStackedByGroups, scalesStackedDataMap };\n};\n\n// Whether the segment of a serie at a position is the outer end of its stack: the highest one of the positive values,\n// or the lowest one of the negative values. Only that segment gets the rounded data end.\nexport const isStackedSegmentEdge = (\n stackedData: DSChartT.StackedSeriesByGroupT,\n serie: DSChartT.InternalSerie,\n position: number,\n) => {\n const group = stackedData?.find((stackedGroup) =>\n stackedGroup.some((stackedSerie) => stackedSerie.key === serie.name),\n );\n const segment = group?.find((stackedSerie) => stackedSerie.key === serie.name)?.[position];\n if (!group || !segment || segment[0] === segment[1]) return false;\n const segments = group.map((stackedSerie) => stackedSerie[position]).filter((d) => d && d[0] !== d[1]);\n const isNegative = segment[1] <= 0 && segment[0] < 0;\n if (isNegative) return segment[0] === Math.min(...segments.map((d) => d[0]));\n return segment[1] === Math.max(...segments.map((d) => d[1]));\n};\n\n// The width of an SVG element's bounding box, 0 where SVG layout is not available (jsdom has no getBBox)\nexport const getSVGBoxWidth = (node: SVGGraphicsElement | null | undefined) =>\n node && typeof node.getBBox === 'function' ? node.getBBox().width : 0;\n\n// The accessible name of a data point: its series, then each axis label with its value. The parts that are missing (an\n// axis without label) are left out instead of leaving double spaces.\nexport const getDatumLabel = (parts: Array<string | number | null | undefined>) =>\n parts\n .filter((part) => part !== undefined && part !== null && part !== '')\n .map(String)\n .join(' ');\n\n// The default accessible name of a chart, from its axis labels: \"<value axis> by <category axis>\". A chart without axis\n// labels gets none (consumers name it through the dsDatavizRoot slot), rather than a generic \"Chart\".\nexport const getChartDefaultName = (valueLabel?: string, categoryLabel?: string) => {\n if (valueLabel && categoryLabel) return `${valueLabel} by ${categoryLabel}`;\n return valueLabel || categoryLabel || undefined;\n};\n\n// The keyboard instructions of a chart with data: the arrows along a series follow the category axis (left and right,\n// up and down on horizontal charts), the other pair moves between series when there is more than one.\nexport const getKeyboardInstructions = ({\n isHorizontal,\n hasSeveralSeries,\n canZoom,\n}: {\n isHorizontal: boolean;\n hasSeveralSeries: boolean;\n canZoom: boolean;\n}) => {\n const along = isHorizontal ? 'up and down' : 'left and right';\n const across = isHorizontal ? 'left and right' : 'up and down';\n const sentences = [`Use the ${along} arrow keys to move between the data points of a series.`];\n if (hasSeveralSeries) sentences.push(`Use the ${across} arrow keys to move to the same point of another series.`);\n if (canZoom) sentences.push('Hold Shift while moving with the arrow keys to select a range to zoom into.');\n return sentences.join(' ');\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const isOutOfLogAxis = (value, { xAxis, yAxis, isHorizontalChart }) => {
|
|
3
|
+
if (value === null || value === void 0) return false;
|
|
4
|
+
const isNotPositive = (number) => typeof number === "number" && number <= 0;
|
|
5
|
+
if (typeof value === "number") {
|
|
6
|
+
const valueAxis = isHorizontalChart ? xAxis : yAxis;
|
|
7
|
+
return valueAxis?.type === "log" && isNotPositive(value);
|
|
8
|
+
}
|
|
9
|
+
return yAxis?.type === "log" && isNotPositive(value.y) || xAxis?.type === "log" && isNotPositive(value.x);
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
isOutOfLogAxis
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=logAxis.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/logAxis.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSChartT } from '../../../react-desc-prop-types.js';\n\ntype ValueT = DSChartT.SeriesT['data'][number];\n\n// Whether a value falls out of a log axis it is plotted on: the logarithm of zero or of a negative number does not\n// exist. The value axis is the vertical one of the series (its y2Axis for the \"y2\" scale), or the horizontal one on a\n// horizontal chart; a point with x and y is checked on both.\nexport const isOutOfLogAxis = (\n value: ValueT,\n { xAxis, yAxis, isHorizontalChart }: { xAxis: DSChartT.AxisT; yAxis: DSChartT.AxisT; isHorizontalChart: boolean },\n): boolean => {\n if (value === null || value === undefined) return false;\n const isNotPositive = (number: unknown) => typeof number === 'number' && number <= 0;\n if (typeof value === 'number') {\n const valueAxis = isHorizontalChart ? xAxis : yAxis;\n return valueAxis?.type === 'log' && isNotPositive(value);\n }\n return (yAxis?.type === 'log' && isNotPositive(value.y)) || (xAxis?.type === 'log' && isNotPositive(value.x));\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACOhB,MAAM,iBAAiB,CAC5B,OACA,EAAE,OAAO,OAAO,kBAAkB,MACtB;AACZ,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,QAAM,gBAAgB,CAAC,WAAoB,OAAO,WAAW,YAAY,UAAU;AACnF,MAAI,OAAO,UAAU,UAAU;AAC7B,UAAM,YAAY,oBAAoB,QAAQ;AAC9C,WAAO,WAAW,SAAS,SAAS,cAAc,KAAK;AAAA,EACzD;AACA,SAAQ,OAAO,SAAS,SAAS,cAAc,MAAM,CAAC,KAAO,OAAO,SAAS,SAAS,cAAc,MAAM,CAAC;AAC7G;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const LABEL_FONT_SIZE = 12;
|
|
3
|
+
const NARROW_CHARACTERS = /* @__PURE__ */ new Set([..."iljtfrI1 .,:;!|'()[]-/"]);
|
|
4
|
+
const WIDE_CHARACTERS = /* @__PURE__ */ new Set([..."mwMW%@"]);
|
|
5
|
+
const getCharacterWidth = (character) => {
|
|
6
|
+
if (NARROW_CHARACTERS.has(character)) return 0.3;
|
|
7
|
+
if (WIDE_CHARACTERS.has(character)) return 0.8;
|
|
8
|
+
if (/[A-Z]/.test(character)) return 0.64;
|
|
9
|
+
if (/\d/.test(character)) return 0.6;
|
|
10
|
+
return 0.52;
|
|
11
|
+
};
|
|
12
|
+
const getLabelWidth = (label) => [...label].reduce((width, character) => width + getCharacterWidth(character), 0) * LABEL_FONT_SIZE;
|
|
13
|
+
const LABEL_GAP = 6;
|
|
14
|
+
const AUTO_TICK_ROTATION = -45;
|
|
15
|
+
const getAutoTickRotation = (labels, positions) => {
|
|
16
|
+
const ticks = positions.map((position, index) => ({ position, width: getLabelWidth(labels[index] ?? "") })).filter(({ width }) => width > 0).sort((a, b) => a.position - b.position);
|
|
17
|
+
const overlaps = ticks.slice(1).some((tick, index) => (ticks[index].width + tick.width) / 2 + LABEL_GAP > tick.position - ticks[index].position);
|
|
18
|
+
return overlaps ? AUTO_TICK_ROTATION : 0;
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
AUTO_TICK_ROTATION,
|
|
22
|
+
getAutoTickRotation
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=tickRotation.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/tickRotation.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// The width of a tick label, estimated from its characters: the labels are 12px (the label 300 font size of the\n// theme), and each character takes its share of an em in the font of the theme. Measured against the labels of the\n// stories, the estimate is within 3px for 95% of them. An estimate, not a measure, so it is the same on the server, in\n// tests and before the web font loads.\nconst LABEL_FONT_SIZE = 12;\nconst NARROW_CHARACTERS = new Set([...\"iljtfrI1 .,:;!|'()[]-/\"]);\nconst WIDE_CHARACTERS = new Set([...'mwMW%@']);\nconst getCharacterWidth = (character: string) => {\n if (NARROW_CHARACTERS.has(character)) return 0.3;\n if (WIDE_CHARACTERS.has(character)) return 0.8;\n if (/[A-Z]/.test(character)) return 0.64;\n if (/\\d/.test(character)) return 0.6;\n return 0.52;\n};\nconst getLabelWidth = (label: string) =>\n [...label].reduce((width, character) => width + getCharacterWidth(character), 0) * LABEL_FONT_SIZE;\n\n// the room between two labels\nconst LABEL_GAP = 6;\n// the rotation of labels that do not fit side by side, the one of most charting libraries\nexport const AUTO_TICK_ROTATION = -45;\n\n// The labels of the horizontal axis lay side by side, centered on their ticks, and long ones (category names, dates\n// with their time) ran into each other. When two neighbors would overlap, the labels are rotated. An empty label (a\n// tickFormat that hides a tick) takes no space.\nexport const getAutoTickRotation = (labels: string[], positions: number[]): number => {\n const ticks = positions\n .map((position, index) => ({ position, width: getLabelWidth(labels[index] ?? '') }))\n .filter(({ width }) => width > 0)\n .sort((a, b) => a.position - b.position);\n const overlaps = ticks\n .slice(1)\n .some((tick, index) => (ticks[index].width + tick.width) / 2 + LABEL_GAP > tick.position - ticks[index].position);\n return overlaps ? AUTO_TICK_ROTATION : 0;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACIvB,MAAM,kBAAkB;AACxB,MAAM,oBAAoB,oBAAI,IAAI,CAAC,GAAG,wBAAwB,CAAC;AAC/D,MAAM,kBAAkB,oBAAI,IAAI,CAAC,GAAG,QAAQ,CAAC;AAC7C,MAAM,oBAAoB,CAAC,cAAsB;AAC/C,MAAI,kBAAkB,IAAI,SAAS,EAAG,QAAO;AAC7C,MAAI,gBAAgB,IAAI,SAAS,EAAG,QAAO;AAC3C,MAAI,QAAQ,KAAK,SAAS,EAAG,QAAO;AACpC,MAAI,KAAK,KAAK,SAAS,EAAG,QAAO;AACjC,SAAO;AACT;AACA,MAAM,gBAAgB,CAAC,UACrB,CAAC,GAAG,KAAK,EAAE,OAAO,CAAC,OAAO,cAAc,QAAQ,kBAAkB,SAAS,GAAG,CAAC,IAAI;AAGrF,MAAM,YAAY;AAEX,MAAM,qBAAqB;AAK3B,MAAM,sBAAsB,CAAC,QAAkB,cAAgC;AACpF,QAAM,QAAQ,UACX,IAAI,CAAC,UAAU,WAAW,EAAE,UAAU,OAAO,cAAc,OAAO,KAAK,KAAK,EAAE,EAAE,EAAE,EAClF,OAAO,CAAC,EAAE,MAAM,MAAM,QAAQ,CAAC,EAC/B,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AACzC,QAAM,WAAW,MACd,MAAM,CAAC,EACP,KAAK,CAAC,MAAM,WAAW,MAAM,KAAK,EAAE,QAAQ,KAAK,SAAS,IAAI,YAAY,KAAK,WAAW,MAAM,KAAK,EAAE,QAAQ;AAClH,SAAO,WAAW,qBAAqB;AACzC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { utcDay, utcFormat, utcMinute, utcMonth, utcSecond, utcYear } from "d3";
|
|
3
|
+
const formatMillisecond = utcFormat(".%L");
|
|
4
|
+
const formatSecond = utcFormat(":%S");
|
|
5
|
+
const formatTime = utcFormat("%H:%M");
|
|
6
|
+
const formatDay = utcFormat("%b %-d");
|
|
7
|
+
const formatMonth = utcFormat("%b");
|
|
8
|
+
const formatYear = utcFormat("%Y");
|
|
9
|
+
const formatTimeTick = (date) => {
|
|
10
|
+
if (utcSecond(date) < date) return formatMillisecond(date);
|
|
11
|
+
if (utcMinute(date) < date) return formatSecond(date);
|
|
12
|
+
if (utcDay(date) < date) return formatTime(date);
|
|
13
|
+
if (utcMonth(date) < date) return formatDay(date);
|
|
14
|
+
if (utcYear(date) < date) return formatMonth(date);
|
|
15
|
+
return formatYear(date);
|
|
16
|
+
};
|
|
17
|
+
const getMinTimeStep = (dates) => {
|
|
18
|
+
const sorted = [...new Set(dates)].sort((a, b) => a - b);
|
|
19
|
+
const step = sorted.slice(1).reduce((smallest, date, index) => Math.min(smallest, date - sorted[index]), Infinity);
|
|
20
|
+
return Number.isFinite(step) ? step : 0;
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
formatTimeTick,
|
|
24
|
+
getMinTimeStep
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=timeTicks.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/timeTicks.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { utcDay, utcFormat, utcMinute, utcMonth, utcSecond, utcYear } from 'd3';\n\nconst formatMillisecond = utcFormat('.%L');\nconst formatSecond = utcFormat(':%S');\nconst formatTime = utcFormat('%H:%M');\nconst formatDay = utcFormat('%b %-d');\nconst formatMonth = utcFormat('%b');\nconst formatYear = utcFormat('%Y');\n\n// The label of a tick of a time axis without tickFormat: the coarsest unit the tick starts, so the labels stay short\n// and keep their context at any zoom, as the ticks go from years to months, days and hours: \"2025\" at a new year,\n// \"Feb\" at a new month, \"Feb 8\" at a new day, \"14:00\" otherwise. In UTC, like the ticks (scaleUtc), and on a 24-hour\n// clock (the format of d3 used a 12-hour one, \"02 PM\").\nexport const formatTimeTick = (date: Date) => {\n if (utcSecond(date) < date) return formatMillisecond(date);\n if (utcMinute(date) < date) return formatSecond(date);\n if (utcDay(date) < date) return formatTime(date);\n if (utcMonth(date) < date) return formatDay(date);\n if (utcYear(date) < date) return formatMonth(date);\n return formatYear(date);\n};\n\n// The smallest step between the dates of a time axis, in milliseconds: its ticks are never closer than that, so a\n// daily series zoomed in gets a tick on each day and not on the hours between them. 0 when there are fewer than two.\nexport const getMinTimeStep = (dates: number[]) => {\n const sorted = [...new Set(dates)].sort((a, b) => a - b);\n const step = sorted.slice(1).reduce((smallest, date, index) => Math.min(smallest, date - sorted[index]), Infinity);\n return Number.isFinite(step) ? step : 0;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,QAAQ,WAAW,WAAW,UAAU,WAAW,eAAe;AAE3E,MAAM,oBAAoB,UAAU,KAAK;AACzC,MAAM,eAAe,UAAU,KAAK;AACpC,MAAM,aAAa,UAAU,OAAO;AACpC,MAAM,YAAY,UAAU,QAAQ;AACpC,MAAM,cAAc,UAAU,IAAI;AAClC,MAAM,aAAa,UAAU,IAAI;AAM1B,MAAM,iBAAiB,CAAC,SAAe;AAC5C,MAAI,UAAU,IAAI,IAAI,KAAM,QAAO,kBAAkB,IAAI;AACzD,MAAI,UAAU,IAAI,IAAI,KAAM,QAAO,aAAa,IAAI;AACpD,MAAI,OAAO,IAAI,IAAI,KAAM,QAAO,WAAW,IAAI;AAC/C,MAAI,SAAS,IAAI,IAAI,KAAM,QAAO,UAAU,IAAI;AAChD,MAAI,QAAQ,IAAI,IAAI,KAAM,QAAO,YAAY,IAAI;AACjD,SAAO,WAAW,IAAI;AACxB;AAIO,MAAM,iBAAiB,CAAC,UAAoB;AACjD,QAAM,SAAS,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,IAAI,CAAC;AACvD,QAAM,OAAO,OAAO,MAAM,CAAC,EAAE,OAAO,CAAC,UAAU,MAAM,UAAU,KAAK,IAAI,UAAU,OAAO,OAAO,KAAK,CAAC,GAAG,QAAQ;AACjH,SAAO,OAAO,SAAS,IAAI,IAAI,OAAO;AACxC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const getTrend = (previous, current, higherIsBetter = true) => {
|
|
3
|
+
if (current === previous) return "flat";
|
|
4
|
+
return current > previous === higherIsBetter ? "good" : "bad";
|
|
5
|
+
};
|
|
6
|
+
const formatChange = (change) => String(Number(Math.abs(change).toFixed(10)));
|
|
7
|
+
const getTrendLabel = (previous, current, previousXValue) => {
|
|
8
|
+
if (current === previous) return `no change from ${previousXValue}`;
|
|
9
|
+
return `${current > previous ? "up" : "down"} ${formatChange(current - previous)} from ${previousXValue}`;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
getTrend,
|
|
13
|
+
getTrendLabel
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=trend.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/trend.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// The trend of a series from one value to the next, as withTrendHighlight reads it: good or bad depending on whether a\n// rise is good for the series (higherIsBetter, true by default; false for a series such as days to close), and flat\n// when the value does not change.\nexport type TrendT = 'good' | 'bad' | 'flat';\n\nexport const getTrend = (previous: number, current: number, higherIsBetter = true): TrendT => {\n if (current === previous) return 'flat';\n return current > previous === higherIsBetter ? 'good' : 'bad';\n};\n\n// the change without the noise of floating point (6.82 - 6.79 reads 0.03, not 0.030000000000000249)\nconst formatChange = (change: number) => String(Number(Math.abs(change).toFixed(10)));\n\n// The change for a screen reader, as the highlight shows it: \"up 13 from Tuesday\", \"down 0.03 from Tuesday\" or\n// \"no change from Tuesday\".\nexport const getTrendLabel = (previous: number, current: number, previousXValue: string | number) => {\n if (current === previous) return `no change from ${previousXValue}`;\n return `${current > previous ? 'up' : 'down'} ${formatChange(current - previous)} from ${previousXValue}`;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACKhB,MAAM,WAAW,CAAC,UAAkB,SAAiB,iBAAiB,SAAiB;AAC5F,MAAI,YAAY,SAAU,QAAO;AACjC,SAAO,UAAU,aAAa,iBAAiB,SAAS;AAC1D;AAGA,MAAM,eAAe,CAAC,WAAmB,OAAO,OAAO,KAAK,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;AAI7E,MAAM,gBAAgB,CAAC,UAAkB,SAAiB,mBAAoC;AACnG,MAAI,YAAY,SAAU,QAAO,kBAAkB,cAAc;AACjE,SAAO,GAAG,UAAU,WAAW,OAAO,MAAM,IAAI,aAAa,UAAU,QAAQ,CAAC,SAAS,cAAc;AACzG;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useChartInteraction } from "../config/chartInteractionStore.js";
|
|
3
|
+
const DIMMED_OPACITY = 0.25;
|
|
4
|
+
const DIMMED_STYLE = { opacity: DIMMED_OPACITY };
|
|
5
|
+
const useSerieDimming = (serieName) => {
|
|
6
|
+
const isDimmed = useChartInteraction(
|
|
7
|
+
({ highlightedSerie }) => highlightedSerie !== null && highlightedSerie !== serieName
|
|
8
|
+
);
|
|
9
|
+
return isDimmed ? DIMMED_STYLE : void 0;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
DIMMED_OPACITY,
|
|
13
|
+
useSerieDimming
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=useSerieDimming.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/helpers/useSerieDimming.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { CSSProperties } from 'react';\nimport { useChartInteraction } from '../config/chartInteractionStore.js';\n\n// While a legend item is hovered, the other series step back so the hovered one stands out. The opacity fades in and\n// out through a transition of the root of the chart (see StyledSVGWrapper).\nexport const DIMMED_OPACITY = 0.25;\nconst DIMMED_STYLE: CSSProperties = { opacity: DIMMED_OPACITY };\n\n// The style of the root of a series: the dimmed opacity while another series is highlighted, nothing otherwise, so the\n// DOM only changes while a legend item is hovered. Each series subscribes to a boolean, so a hover re-renders the\n// series that change only.\nexport const useSerieDimming = (serieName: string): CSSProperties | undefined => {\n const isDimmed = useChartInteraction(\n ({ highlightedSerie }) => highlightedSerie !== null && highlightedSerie !== serieName,\n );\n return isDimmed ? DIMMED_STYLE : undefined;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,2BAA2B;AAI7B,MAAM,iBAAiB;AAC9B,MAAM,eAA8B,EAAE,SAAS,eAAe;AAKvD,MAAM,kBAAkB,CAAC,cAAiD;AAC/E,QAAM,WAAW;AAAA,IACf,CAAC,EAAE,iBAAiB,MAAM,qBAAqB,QAAQ,qBAAqB;AAAA,EAC9E;AACA,SAAO,WAAW,eAAe;AACnC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|