@elliemae/ds-dataviz 3.80.0-next.67 → 3.80.0-next.71
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,25 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { utcFormat, format } from "d3";
|
|
3
|
+
import { TIME_INTERVALS } from "../../constants.js";
|
|
4
|
+
import { formatTimeTick } from "../helpers/timeTicks.js";
|
|
3
5
|
const AXIS_TYPE = {
|
|
4
6
|
BAND: "BAND",
|
|
5
7
|
LINEAR: "LINEAR",
|
|
6
8
|
DATETIME: "DATETIME",
|
|
7
9
|
LOG: "LOG"
|
|
8
10
|
};
|
|
9
|
-
const getInterval = (interval) =>
|
|
10
|
-
switch (interval) {
|
|
11
|
-
case "DAY":
|
|
12
|
-
return utcDay;
|
|
13
|
-
case "MONTH":
|
|
14
|
-
return utcMonth;
|
|
15
|
-
case "WEEK":
|
|
16
|
-
return utcWeek;
|
|
17
|
-
case "YEAR":
|
|
18
|
-
return utcYear;
|
|
19
|
-
default:
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
11
|
+
const getInterval = (interval) => interval && interval in TIME_INTERVALS ? TIME_INTERVALS[interval] : null;
|
|
23
12
|
class Scale {
|
|
24
13
|
scale;
|
|
25
14
|
type;
|
|
@@ -61,16 +50,23 @@ class BandScale extends Scale {
|
|
|
61
50
|
getBandwidth() {
|
|
62
51
|
return this.scale.bandwidth();
|
|
63
52
|
}
|
|
53
|
+
// the distance from the start of a band to the start of the next one: the band and the padding after it
|
|
54
|
+
getStep() {
|
|
55
|
+
return this.scale.step();
|
|
56
|
+
}
|
|
64
57
|
}
|
|
65
58
|
class LinearScale extends Scale {
|
|
66
59
|
type;
|
|
67
60
|
scale;
|
|
68
61
|
axisProps;
|
|
69
|
-
|
|
62
|
+
// the ticks of an axis aligned with another one (see getAlignedTicks), instead of the ones of its own count
|
|
63
|
+
alignedTicks;
|
|
64
|
+
constructor(scale, axisProps, alignedTicks = null) {
|
|
70
65
|
super(scale);
|
|
71
66
|
this.scale = scale;
|
|
72
67
|
this.type = "LINEAR";
|
|
73
68
|
this.axisProps = axisProps;
|
|
69
|
+
this.alignedTicks = alignedTicks;
|
|
74
70
|
}
|
|
75
71
|
get(value) {
|
|
76
72
|
if (typeof value !== "number") return 0;
|
|
@@ -86,8 +82,15 @@ class LinearScale extends Scale {
|
|
|
86
82
|
}
|
|
87
83
|
return t.toString();
|
|
88
84
|
}
|
|
85
|
+
getTickCount(dimension) {
|
|
86
|
+
return this.axisProps?.tick?.tickCount ?? Math.ceil(dimension / 80);
|
|
87
|
+
}
|
|
89
88
|
getTicks(dimension) {
|
|
90
|
-
|
|
89
|
+
if (this.alignedTicks) return this.withTickValues([...this.alignedTicks]);
|
|
90
|
+
return this.withTickValues(this.scale.ticks?.(this.getTickCount(dimension)));
|
|
91
|
+
}
|
|
92
|
+
// the ticks given through tick.tickValues: instead of the computed ones with overwriteTicks, added to them otherwise
|
|
93
|
+
withTickValues(ticks) {
|
|
91
94
|
if (this.axisProps?.tick?.tickValues) {
|
|
92
95
|
if (this.axisProps?.tick?.overwriteTicks) return this.axisProps?.tick?.tickValues;
|
|
93
96
|
this.axisProps?.tick?.tickValues.forEach((t) => {
|
|
@@ -104,6 +107,7 @@ class LinearScale extends Scale {
|
|
|
104
107
|
return ticks.map((t) => typeof t === "number" ? this.get(t) : 0);
|
|
105
108
|
}
|
|
106
109
|
}
|
|
110
|
+
const LOG_TICK_DIGITS = [[1], [1, 2, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9]];
|
|
107
111
|
class LogScale extends LinearScale {
|
|
108
112
|
type;
|
|
109
113
|
scale;
|
|
@@ -114,6 +118,18 @@ class LogScale extends LinearScale {
|
|
|
114
118
|
this.type = "LOG";
|
|
115
119
|
this.axisProps = axisProps;
|
|
116
120
|
}
|
|
121
|
+
// When the domain spans few powers of ten, d3 places a tick on every 1 to 9 of each one, and on a regular axis their
|
|
122
|
+
// labels overlap. Of those ticks, the axis keeps the densest set that fits its tick count: the powers of ten, then 1,
|
|
123
|
+
// 2 and 5 of each power, then all of them. A domain that holds no power of ten keeps 1, 2 and 5 of its own.
|
|
124
|
+
getTicks(dimension) {
|
|
125
|
+
const count = Math.max(1, this.getTickCount(dimension));
|
|
126
|
+
const candidates = this.scale.ticks();
|
|
127
|
+
const leadingDigit = (tick) => Math.round(Math.abs(tick) / 10 ** Math.floor(Math.log10(Math.abs(tick))));
|
|
128
|
+
const tickSets = LOG_TICK_DIGITS.map((digits) => candidates.filter((tick) => digits.includes(leadingDigit(tick))));
|
|
129
|
+
const fitting = tickSets.filter((ticks2) => ticks2.length > 0 && ticks2.length <= count);
|
|
130
|
+
const ticks = fitting[fitting.length - 1] ?? tickSets.find((set) => set.length > 0) ?? candidates;
|
|
131
|
+
return this.withTickValues([...ticks]);
|
|
132
|
+
}
|
|
117
133
|
getTickFormatted(t) {
|
|
118
134
|
if (typeof t !== "number") return t.toString();
|
|
119
135
|
if (typeof this.axisProps?.tick?.tickFormat === "function") {
|
|
@@ -129,11 +145,14 @@ class TimeLinearScale extends Scale {
|
|
|
129
145
|
type;
|
|
130
146
|
scale;
|
|
131
147
|
axisProps;
|
|
132
|
-
|
|
148
|
+
// the smallest step between the dates of the axis, in milliseconds (see getMinTimeStep), 0 when unknown
|
|
149
|
+
minTimeStep;
|
|
150
|
+
constructor(scale, axisProps, minTimeStep = 0) {
|
|
133
151
|
super(scale);
|
|
134
152
|
this.scale = scale;
|
|
135
153
|
this.type = "DATETIME";
|
|
136
154
|
this.axisProps = axisProps;
|
|
155
|
+
this.minTimeStep = minTimeStep;
|
|
137
156
|
}
|
|
138
157
|
get(value) {
|
|
139
158
|
if (typeof value !== "object") return 0;
|
|
@@ -145,13 +164,24 @@ class TimeLinearScale extends Scale {
|
|
|
145
164
|
return this.axisProps?.tick?.tickFormat(t);
|
|
146
165
|
}
|
|
147
166
|
if (typeof this.axisProps?.tick?.tickFormat === "string") {
|
|
148
|
-
return
|
|
167
|
+
return utcFormat(this.axisProps?.tick?.tickFormat)(t);
|
|
149
168
|
}
|
|
150
|
-
return t
|
|
169
|
+
return formatTimeTick(t);
|
|
170
|
+
}
|
|
171
|
+
// Without intervalType, a tick about every 80px of the plot: the plot grows with the zoom, so zooming in turns the
|
|
172
|
+
// ticks from months to weeks, days and hours. They are never closer than the dates of the data, so a daily series
|
|
173
|
+
// gets no ticks on the hours between its days; a tickCount the consumer sets is kept as it is.
|
|
174
|
+
getTickCount(dimension) {
|
|
175
|
+
const { tickCount } = this.axisProps?.tick ?? {};
|
|
176
|
+
if (tickCount !== void 0) return tickCount;
|
|
177
|
+
const count = Math.ceil(dimension / 80);
|
|
178
|
+
const [start, end] = this.scale.domain();
|
|
179
|
+
if (!this.minTimeStep || !start || !end) return count;
|
|
180
|
+
return Math.max(1, Math.min(count, Math.floor((+end - +start) / this.minTimeStep)));
|
|
151
181
|
}
|
|
152
182
|
getTicks(dimension, intervalType) {
|
|
153
183
|
const interval = getInterval(intervalType);
|
|
154
|
-
const finalTickConfig = interval ||
|
|
184
|
+
const finalTickConfig = interval || this.getTickCount(dimension);
|
|
155
185
|
const ticks = this.scale.ticks?.(finalTickConfig);
|
|
156
186
|
const ticksValues = this.axisProps?.tick?.tickValues;
|
|
157
187
|
if (ticksValues) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/scales/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-classes-per-file */\n/* eslint-disable max-lines */\nimport type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleTime } from 'd3';\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-classes-per-file */\n/* eslint-disable max-lines */\nimport type { ScaleBand, ScaleLinear, ScaleLogarithmic, ScaleTime } from 'd3';\nimport { utcFormat, format } from 'd3';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\nimport { TIME_INTERVALS } from '../../constants.js';\nimport { formatTimeTick } from '../helpers/timeTicks.js';\n\nexport const AXIS_TYPE = {\n BAND: 'BAND',\n LINEAR: 'LINEAR',\n DATETIME: 'DATETIME',\n LOG: 'LOG',\n} as const;\n\nconst getInterval = (interval?: string) =>\n interval && interval in TIME_INTERVALS ? TIME_INTERVALS[interval as DSChartT.IntervalT] : null;\n\nexport class Scale {\n scale: ScaleBand<string> | ScaleLinear<number, number, never> | ScaleTime<number, number, never>;\n\n type: string;\n\n constructor(scale: ScaleBand<string> | ScaleLinear<number, number, never> | ScaleTime<number, number, never>) {\n this.type = '';\n this.scale = scale;\n }\n\n getBandwidth() {\n return 0;\n }\n}\nexport class BandScale extends Scale {\n type: keyof typeof AXIS_TYPE;\n\n scale: ScaleBand<string>;\n\n axisProps: DSChartT.AxisT;\n\n constructor(scale: ScaleBand<string>, axisProps: DSChartT.AxisT) {\n super(scale);\n this.scale = scale;\n this.type = 'BAND';\n this.axisProps = axisProps;\n }\n\n get(value: string) {\n if (typeof value !== 'string') return 0;\n return this.scale(value);\n }\n\n getTicks() {\n return this.scale.domain();\n }\n\n getTickFormatted(t: number | string | Date) {\n if (typeof t !== 'string') return t;\n if (typeof this.axisProps?.tick?.tickFormat === 'function') {\n return this.axisProps?.tick?.tickFormat(t);\n }\n return t;\n }\n\n getTicksScaled() {\n return this.scale.domain().map((d) => (this.get(d) ?? 0) + this.getBandwidth() / 2);\n }\n\n getBandwidth() {\n return this.scale.bandwidth();\n }\n\n // the distance from the start of a band to the start of the next one: the band and the padding after it\n getStep() {\n return this.scale.step();\n }\n}\n\nexport class LinearScale extends Scale {\n type: keyof typeof AXIS_TYPE;\n\n scale: ScaleLinear<number, number, never>;\n\n axisProps: DSChartT.AxisT;\n\n // the ticks of an axis aligned with another one (see getAlignedTicks), instead of the ones of its own count\n alignedTicks: number[] | null;\n\n constructor(\n scale: ScaleLinear<number, number, never>,\n axisProps: DSChartT.AxisT,\n alignedTicks: number[] | null = null,\n ) {\n super(scale);\n this.scale = scale;\n this.type = 'LINEAR';\n this.axisProps = axisProps;\n this.alignedTicks = alignedTicks;\n }\n\n get(value: number) {\n if (typeof value !== 'number') return 0;\n return this.scale(value);\n }\n\n getTickFormatted(t: number | string | Date) {\n if (typeof t !== 'number') return t.toString();\n if (typeof this.axisProps?.tick?.tickFormat === 'function') {\n return this.axisProps?.tick?.tickFormat(t);\n }\n if (typeof this.axisProps?.tick?.tickFormat === 'string') {\n return format(this.axisProps?.tick?.tickFormat)(t);\n }\n return t.toString();\n }\n\n getTickCount(dimension: number) {\n return this.axisProps?.tick?.tickCount ?? Math.ceil(dimension / 80);\n }\n\n getTicks(dimension: number) {\n if (this.alignedTicks) return this.withTickValues([...this.alignedTicks]);\n return this.withTickValues(this.scale.ticks?.(this.getTickCount(dimension)));\n }\n\n // the ticks given through tick.tickValues: instead of the computed ones with overwriteTicks, added to them otherwise\n withTickValues(ticks: number[]) {\n if (this.axisProps?.tick?.tickValues) {\n if (this.axisProps?.tick?.overwriteTicks) return this.axisProps?.tick?.tickValues;\n this.axisProps?.tick?.tickValues.forEach((t) => {\n if (typeof t !== 'number') return;\n const isTickAlreadyPresent = ticks.find((tick) => tick === t);\n if (isTickAlreadyPresent) return;\n ticks.push(t);\n });\n }\n return ticks;\n }\n\n getTicksScaled(dimension: number) {\n const ticks = this.getTicks(dimension);\n return ticks.map((t) => (typeof t === 'number' ? this.get(t) : 0));\n }\n}\n\n// the leading digits of the ticks a log axis can keep, from the sparsest set to the densest\nconst LOG_TICK_DIGITS = [[1], [1, 2, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9]];\n\nexport class LogScale extends LinearScale {\n type: keyof typeof AXIS_TYPE;\n\n scale: ScaleLogarithmic<number, number, never>;\n\n axisProps: DSChartT.AxisT;\n\n constructor(scale: ScaleLogarithmic<number, number, never>, axisProps: DSChartT.AxisT) {\n super(scale, axisProps);\n this.scale = scale;\n this.type = 'LOG';\n this.axisProps = axisProps;\n }\n\n // When the domain spans few powers of ten, d3 places a tick on every 1 to 9 of each one, and on a regular axis their\n // labels overlap. Of those ticks, the axis keeps the densest set that fits its tick count: the powers of ten, then 1,\n // 2 and 5 of each power, then all of them. A domain that holds no power of ten keeps 1, 2 and 5 of its own.\n getTicks(dimension: number) {\n const count = Math.max(1, this.getTickCount(dimension));\n const candidates = this.scale.ticks();\n const leadingDigit = (tick: number) => Math.round(Math.abs(tick) / 10 ** Math.floor(Math.log10(Math.abs(tick))));\n const tickSets = LOG_TICK_DIGITS.map((digits) => candidates.filter((tick) => digits.includes(leadingDigit(tick))));\n const fitting = tickSets.filter((ticks) => ticks.length > 0 && ticks.length <= count);\n const ticks = fitting[fitting.length - 1] ?? tickSets.find((set) => set.length > 0) ?? candidates;\n return this.withTickValues([...ticks]);\n }\n\n getTickFormatted(t: number | string | Date) {\n if (typeof t !== 'number') return t.toString();\n if (typeof this.axisProps?.tick?.tickFormat === 'function') {\n return this.axisProps?.tick?.tickFormat(t);\n }\n if (typeof this.axisProps?.tick?.tickFormat === 'string') {\n return format(this.axisProps?.tick?.tickFormat)(t);\n }\n return format('~s')(t);\n }\n}\n\nexport class TimeLinearScale extends Scale {\n type: keyof typeof AXIS_TYPE;\n\n scale: ScaleTime<number, number, never>;\n\n axisProps: DSChartT.AxisT;\n\n // the smallest step between the dates of the axis, in milliseconds (see getMinTimeStep), 0 when unknown\n minTimeStep: number;\n\n constructor(scale: ScaleTime<number, number, never>, axisProps: DSChartT.AxisT, minTimeStep = 0) {\n super(scale);\n this.scale = scale;\n this.type = 'DATETIME';\n this.axisProps = axisProps;\n this.minTimeStep = minTimeStep;\n }\n\n get(value: Date) {\n if (typeof value !== 'object') return 0;\n return this.scale(value);\n }\n\n getTickFormatted(t: number | string | Date) {\n if (typeof t !== 'object') return t.toString();\n if (typeof this.axisProps?.tick?.tickFormat === 'function') {\n return this.axisProps?.tick?.tickFormat(t);\n }\n // The ticks of a time axis sit on UTC boundaries (scaleUtc), so they are formatted in UTC as well: in local time a\n // tick at 00:00 UTC read as the day before west of UTC, and every timezone showed different labels (PUI-16334).\n // Without a format, each tick reads the coarsest unit it starts (see formatTimeTick)\n if (typeof this.axisProps?.tick?.tickFormat === 'string') {\n return utcFormat(this.axisProps?.tick?.tickFormat)(t);\n }\n return formatTimeTick(t);\n }\n\n // Without intervalType, a tick about every 80px of the plot: the plot grows with the zoom, so zooming in turns the\n // ticks from months to weeks, days and hours. They are never closer than the dates of the data, so a daily series\n // gets no ticks on the hours between its days; a tickCount the consumer sets is kept as it is.\n getTickCount(dimension: number) {\n const { tickCount } = this.axisProps?.tick ?? {};\n if (tickCount !== undefined) return tickCount;\n const count = Math.ceil(dimension / 80);\n const [start, end] = this.scale.domain();\n if (!this.minTimeStep || !start || !end) return count;\n return Math.max(1, Math.min(count, Math.floor((+end - +start) / this.minTimeStep)));\n }\n\n getTicks(dimension: number, intervalType?: string) {\n const interval = getInterval(intervalType);\n const finalTickConfig = interval || this.getTickCount(dimension);\n const ticks = this.scale.ticks?.(finalTickConfig as number);\n const ticksValues = this.axisProps?.tick?.tickValues;\n if (ticksValues) {\n if (this.axisProps?.tick?.overwriteTicks) return ticksValues;\n const newTicks = [] as Date[];\n ticks.forEach((t) => {\n if (typeof t !== 'object') return;\n const exists = ticksValues.some(\n (tickValue) => typeof tickValue === 'object' && tickValue.getTime() === t.getTime(),\n );\n if (!exists) newTicks.push(t);\n });\n return [...newTicks, ...ticksValues];\n }\n return ticks;\n }\n\n getTicksScaled(dimension: number, intervalType?: string) {\n const ticks = this.getTicks(dimension, intervalType);\n return ticks.map((t) => (typeof t === 'object' ? this.get(t) : 0));\n }\n}\n\nexport type ScaleT = BandScale | LinearScale | TimeLinearScale;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,WAAW,cAAc;AAElC,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAExB,MAAM,YAAY;AAA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C;AAAA,EACpF;AAAA,EAEA,SAAS,WAAmB,cAAuB;AACjD,UAAM,WAAW,YAAY,YAAY;AACzC,UAAM,kBAAkB,YAAY,KAAK,aAAa,SAAS;AAC/D,UAAM,QAAQ,KAAK,MAAM,QAAQ,eAAyB;AAC1D,UAAM,cAAc,KAAK,WAAW,MAAM;AAC1C,QAAI,aAAa;AACf,UAAI,KAAK,WAAW,MAAM,eAAgB,QAAO;AACjD,YAAM,WAAW,CAAC;AAClB,YAAM,QAAQ,CAAC,MAAM;AACnB,YAAI,OAAO,MAAM,SAAU;AAC3B,cAAM,SAAS,YAAY;AAAA,UACzB,CAAC,cAAc,OAAO,cAAc,YAAY,UAAU,QAAQ,MAAM,EAAE,QAAQ;AAAA,QACpF;AACA,YAAI,CAAC,OAAQ,UAAS,KAAK,CAAC;AAAA,MAC9B,CAAC;AACD,aAAO,CAAC,GAAG,UAAU,GAAG,WAAW;AAAA,IACrC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,eAAe,WAAmB,cAAuB;AACvD,UAAM,QAAQ,KAAK,SAAS,WAAW,YAAY;AACnD,WAAO,MAAM,IAAI,CAAC,MAAO,OAAO,MAAM,WAAW,KAAK,IAAI,CAAC,IAAI,CAAE;AAAA,EACnE;AACF;",
|
|
6
|
+
"names": ["ticks"]
|
|
7
7
|
}
|
|
@@ -5,31 +5,98 @@ import { area, line } from "d3";
|
|
|
5
5
|
import { StyledArea } from "../styles.js";
|
|
6
6
|
import { ChartContext } from "../ChartContext.js";
|
|
7
7
|
import { getStackedData } from "../helpers/index.js";
|
|
8
|
+
import { getZeroLinePosition } from "../helpers/zeroLine.js";
|
|
9
|
+
import { LinearScale, LogScale } from "../scales/index.js";
|
|
8
10
|
import { Points } from "./Points.js";
|
|
9
|
-
import {
|
|
11
|
+
import { TrendHighlight } from "../parts/TrendHighlight.js";
|
|
12
|
+
import { useSerieDimming } from "../helpers/useSerieDimming.js";
|
|
13
|
+
import { LINE, MARKS, curveStyleMap } from "../../constants.js";
|
|
10
14
|
const Area = ({ serie }) => {
|
|
11
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
xScale,
|
|
17
|
+
yScale,
|
|
18
|
+
y2Scale,
|
|
19
|
+
getXScaleValue,
|
|
20
|
+
getY2ScaleValue,
|
|
21
|
+
getYScaleValue,
|
|
22
|
+
innerHeight,
|
|
23
|
+
colorScale,
|
|
24
|
+
stackedData,
|
|
25
|
+
getOwnerProps,
|
|
26
|
+
chartId
|
|
27
|
+
} = useContext(ChartContext);
|
|
12
28
|
const finalYScale = serie.scale === "y2" ? getY2ScaleValue : getYScaleValue;
|
|
29
|
+
const valueScale = serie.scale === "y2" && y2Scale ? y2Scale : yScale;
|
|
30
|
+
const baseline = useMemo(() => {
|
|
31
|
+
if (!(valueScale instanceof LinearScale) || valueScale instanceof LogScale) return innerHeight;
|
|
32
|
+
const [start, end] = valueScale.scale.domain();
|
|
33
|
+
const closestToZero = Math.min(Math.max(0, Math.min(start, end)), Math.max(start, end));
|
|
34
|
+
const position = valueScale.get(closestToZero);
|
|
35
|
+
return Number.isFinite(position) ? position : innerHeight;
|
|
36
|
+
}, [innerHeight, valueScale]);
|
|
37
|
+
const zeroLinePosition = getZeroLinePosition(valueScale);
|
|
13
38
|
const curveStyle = useMemo(() => curveStyleMap[serie.curveStyle ?? LINE.CURVE_STYLE.LINEAR], [serie.curveStyle]);
|
|
14
39
|
const areaD3 = useMemo(() => {
|
|
15
40
|
const serieWithStackedValues = getStackedData(stackedData, serie);
|
|
16
41
|
if (serieWithStackedValues) {
|
|
17
42
|
return area().x((_, i) => getXScaleValue(serie.data[i])).y0(([, y2]) => finalYScale(y2)).y1(([y1]) => finalYScale(y1)).curve(curveStyle)(serieWithStackedValues);
|
|
18
43
|
}
|
|
19
|
-
return area().x((_, i) => getXScaleValue(serie.data[i])).y0(
|
|
20
|
-
}, [stackedData, serie,
|
|
44
|
+
return area().x((_, i) => getXScaleValue(serie.data[i])).y0(baseline).y1((_, i) => finalYScale(serie.data[i])).curve(curveStyle)(serie.data);
|
|
45
|
+
}, [stackedData, serie, baseline, curveStyle, getXScaleValue, finalYScale]);
|
|
21
46
|
const lineD3 = useMemo(() => {
|
|
22
47
|
const serieWithStackedValues = getStackedData(stackedData, serie);
|
|
23
48
|
if (serieWithStackedValues) {
|
|
24
49
|
return line().x((_, i) => getXScaleValue(serie.data[i])).y(([, y2]) => finalYScale(y2)).curve(curveStyle)(serieWithStackedValues);
|
|
25
50
|
}
|
|
26
|
-
return line().x((_, i) => getXScaleValue(serie.data[i])).y((_, i) =>
|
|
27
|
-
}, [stackedData, serie, curveStyle, getXScaleValue, finalYScale
|
|
51
|
+
return line().x((_, i) => getXScaleValue(serie.data[i])).y((_, i) => finalYScale(serie.data[i])).curve(curveStyle)(serie.data);
|
|
52
|
+
}, [stackedData, serie, curveStyle, getXScaleValue, finalYScale]);
|
|
28
53
|
const xTranslate = (xScale?.getBandwidth() ?? 0) / 2;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
const color = colorScale(serie.name);
|
|
55
|
+
const gradientId = `area-gradient-${chartId}-${serie.key.replace(/[^\w-]/g, "_")}`;
|
|
56
|
+
const dimmedStyle = useSerieDimming(serie.name);
|
|
57
|
+
return /* @__PURE__ */ jsx("g", { style: dimmedStyle, children: /* @__PURE__ */ jsxs("g", { transform: `translate(${xTranslate}, 0)`, children: [
|
|
58
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs(
|
|
59
|
+
"linearGradient",
|
|
60
|
+
{
|
|
61
|
+
id: gradientId,
|
|
62
|
+
x1: "0",
|
|
63
|
+
x2: "0",
|
|
64
|
+
...zeroLinePosition !== null ? {
|
|
65
|
+
gradientUnits: "userSpaceOnUse",
|
|
66
|
+
// from the far end of the plot: the top, or the bottom when the zero is at the top
|
|
67
|
+
y1: zeroLinePosition > 0 ? 0 : innerHeight,
|
|
68
|
+
y2: zeroLinePosition,
|
|
69
|
+
spreadMethod: "reflect"
|
|
70
|
+
} : { y1: "0", y2: "1" },
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: color, stopOpacity: MARKS.AREA_TOP_OPACITY }),
|
|
73
|
+
/* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: color, stopOpacity: MARKS.AREA_BOTTOM_OPACITY })
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
) }),
|
|
77
|
+
/* @__PURE__ */ jsx(
|
|
78
|
+
StyledArea,
|
|
79
|
+
{
|
|
80
|
+
d: areaD3 ?? "",
|
|
81
|
+
fill: `url(#${gradientId})`,
|
|
82
|
+
getOwnerProps,
|
|
83
|
+
getOwnerPropsArguments: () => ({ serie })
|
|
84
|
+
}
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
"path",
|
|
88
|
+
{
|
|
89
|
+
d: lineD3 ?? "",
|
|
90
|
+
fill: "none",
|
|
91
|
+
strokeWidth: 2,
|
|
92
|
+
strokeLinecap: "round",
|
|
93
|
+
strokeLinejoin: "round",
|
|
94
|
+
stroke: color,
|
|
95
|
+
vectorEffect: "non-scaling-stroke"
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ jsx(TrendHighlight, { serie, linePath: lineD3 }),
|
|
99
|
+
/* @__PURE__ */ jsx(Points, { serie })
|
|
33
100
|
] }) });
|
|
34
101
|
};
|
|
35
102
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Area.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { area, line } from 'd3';\nimport { StyledArea } from '../styles.js';\nimport { ChartContext } from '../ChartContext.js';\nimport { getStackedData } from '../helpers/index.js';\nimport { Points } from './Points.js';\nimport { LINE, curveStyleMap } from '../../constants.js';\nimport type { DSChartT } from '
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { area, line } from 'd3';\nimport { StyledArea } from '../styles.js';\nimport { ChartContext } from '../ChartContext.js';\nimport { getStackedData } from '../helpers/index.js';\nimport { getZeroLinePosition } from '../helpers/zeroLine.js';\nimport { LinearScale, LogScale } from '../scales/index.js';\nimport { Points } from './Points.js';\nimport { TrendHighlight } from '../parts/TrendHighlight.js';\nimport { useSerieDimming } from '../helpers/useSerieDimming.js';\nimport { LINE, MARKS, curveStyleMap } from '../../constants.js';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\n\nexport const Area: React.ComponentType<DSChartT.SerieComponentT> = ({ serie }) => {\n const {\n xScale,\n yScale,\n y2Scale,\n getXScaleValue,\n getY2ScaleValue,\n getYScaleValue,\n innerHeight,\n colorScale,\n stackedData,\n getOwnerProps,\n chartId,\n } = useContext(ChartContext);\n\n const finalYScale = serie.scale === 'y2' ? getY2ScaleValue : getYScaleValue;\n const valueScale = serie.scale === 'y2' && y2Scale ? y2Scale : yScale;\n\n // An area without a stack used to fill from the bottom of the plot, so below zero it filled the wrong side: from the\n // negative values down instead of up to zero. It fills from its zero when the axis holds it, and from the end of the\n // axis closest to zero otherwise (the bottom when every value is positive). A log axis has no zero: its bottom.\n const baseline = useMemo(() => {\n if (!(valueScale instanceof LinearScale) || valueScale instanceof LogScale) return innerHeight;\n const [start, end] = valueScale.scale.domain();\n const closestToZero = Math.min(Math.max(0, Math.min(start, end)), Math.max(start, end));\n const position = valueScale.get(closestToZero);\n return Number.isFinite(position) ? position : innerHeight;\n }, [innerHeight, valueScale]);\n // with the zero inside the plot the wash fades toward the zero from both sides, so a value and its negative weigh the\n // same; otherwise it fades from the top of the area to its base\n const zeroLinePosition = getZeroLinePosition(valueScale);\n\n const curveStyle = useMemo(() => curveStyleMap[serie.curveStyle ?? LINE.CURVE_STYLE.LINEAR], [serie.curveStyle]);\n const areaD3 = useMemo(() => {\n const serieWithStackedValues = getStackedData(stackedData, serie);\n if (serieWithStackedValues) {\n return area()\n .x((_, i) => getXScaleValue(serie.data[i]))\n .y0(([, y2]) => finalYScale(y2))\n .y1(([y1]) => finalYScale(y1))\n .curve(curveStyle)(serieWithStackedValues as [number, number][]);\n }\n return area()\n .x((_, i) => getXScaleValue(serie.data[i]))\n .y0(baseline)\n .y1((_, i) => finalYScale(serie.data[i]))\n .curve(curveStyle)(serie.data as unknown as [number, number][]);\n }, [stackedData, serie, baseline, curveStyle, getXScaleValue, finalYScale]);\n\n const lineD3 = useMemo(() => {\n const serieWithStackedValues = getStackedData(stackedData, serie);\n if (serieWithStackedValues) {\n return line()\n .x((_, i) => getXScaleValue(serie.data[i]))\n .y(([, y2]) => finalYScale(y2))\n .curve(curveStyle)(serieWithStackedValues as unknown as [number, number][]);\n }\n return line()\n .x((_, i) => getXScaleValue(serie.data[i]))\n .y((_, i) => finalYScale(serie.data[i]))\n .curve(curveStyle)(serie.data as unknown as [number, number][]);\n }, [stackedData, serie, curveStyle, getXScaleValue, finalYScale]);\n\n const xTranslate = (xScale?.getBandwidth() ?? 0) / 2;\n const color = colorScale(serie.name) as string;\n // the area fades from the series color at its top to almost nothing at its base\n const gradientId = `area-gradient-${chartId}-${serie.key.replace(/[^\\w-]/g, '_')}`;\n\n const dimmedStyle = useSerieDimming(serie.name);\n return (\n <g style={dimmedStyle}>\n <g transform={`translate(${xTranslate}, 0)`}>\n <defs>\n <linearGradient\n id={gradientId}\n x1=\"0\"\n x2=\"0\"\n {...(zeroLinePosition !== null\n ? {\n gradientUnits: 'userSpaceOnUse',\n // from the far end of the plot: the top, or the bottom when the zero is at the top\n y1: zeroLinePosition > 0 ? 0 : innerHeight,\n y2: zeroLinePosition,\n spreadMethod: 'reflect',\n }\n : { y1: '0', y2: '1' })}\n >\n <stop offset=\"0%\" stopColor={color} stopOpacity={MARKS.AREA_TOP_OPACITY} />\n <stop offset=\"100%\" stopColor={color} stopOpacity={MARKS.AREA_BOTTOM_OPACITY} />\n </linearGradient>\n </defs>\n {/* the wash first, then its outline, and the markers on top */}\n <StyledArea\n d={areaD3 ?? ''}\n fill={`url(#${gradientId})`}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={() => ({ serie })}\n />\n <path\n d={lineD3 ?? ''}\n fill=\"none\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n stroke={color}\n // the width stays the same while a transform scales the line (see useValueAxisTransition)\n vectorEffect=\"non-scaling-stroke\"\n />\n <TrendHighlight serie={serie} linePath={lineD3} />\n <Points serie={serie} />\n </g>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACsFb,SAcE,KAdF;AAtFV,SAAgB,YAAY,eAAe;AAC3C,SAAS,MAAM,YAAY;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,aAAa,gBAAgB;AACtC,SAAS,cAAc;AACvB,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,MAAM,OAAO,qBAAqB;AAGpC,MAAM,OAAsD,CAAC,EAAE,MAAM,MAAM;AAChF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,cAAc,MAAM,UAAU,OAAO,kBAAkB;AAC7D,QAAM,aAAa,MAAM,UAAU,QAAQ,UAAU,UAAU;AAK/D,QAAM,WAAW,QAAQ,MAAM;AAC7B,QAAI,EAAE,sBAAsB,gBAAgB,sBAAsB,SAAU,QAAO;AACnF,UAAM,CAAC,OAAO,GAAG,IAAI,WAAW,MAAM,OAAO;AAC7C,U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ACb,eAAc;AAAA,QACd,gBAAe;AAAA,QACf,QAAQ;AAAA,QAER,cAAa;AAAA;AAAA,IACf;AAAA,IACA,oBAAC,kBAAe,OAAc,UAAU,QAAQ;AAAA,IAChD,oBAAC,UAAO,OAAc;AAAA,KACxB,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,6 +12,7 @@ const Bars = ({ serie }) => {
|
|
|
12
12
|
getYScaleValue,
|
|
13
13
|
getY2ScaleValue,
|
|
14
14
|
subGroupScale,
|
|
15
|
+
getBandwidth,
|
|
15
16
|
colorScale,
|
|
16
17
|
getXValue,
|
|
17
18
|
getYValue,
|
|
@@ -33,7 +34,8 @@ const Bars = ({ serie }) => {
|
|
|
33
34
|
const yScaled = finalYScale(bar) ?? 0;
|
|
34
35
|
const width = subGroupScale?.bandwidth() ?? 0;
|
|
35
36
|
const height = y > 0 ? positiveSize - yScaled : yScaled - finalYScale(0);
|
|
36
|
-
const
|
|
37
|
+
const slotStart = xScale?.type !== "BAND" ? xScaled - getBandwidth() / 2 : xScaled;
|
|
38
|
+
const transformX = slotStart + ((subGroupScale && subGroupScale(serie.name)) ?? 0);
|
|
37
39
|
const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);
|
|
38
40
|
return /* @__PURE__ */ jsx("g", { id: `${chartId}-${serie.name}-rects-${bar.key}`, transform: `translate(${transformX},0)`, children: /* @__PURE__ */ jsx(
|
|
39
41
|
Rect,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/Bars.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport { Rect } from './Rect.js';\nimport { ChartContext } from '../ChartContext.js';\nimport { A11yRegion } from '../parts/A11yRegion.js';\nimport type { DSChartT } from '
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext } from 'react';\nimport { Rect } from './Rect.js';\nimport { ChartContext } from '../ChartContext.js';\nimport { A11yRegion } from '../parts/A11yRegion.js';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\n\nexport const Bars: React.ComponentType<DSChartT.SerieComponentT> = ({ serie }) => {\n const {\n innerHeight,\n xScale,\n getXScaleValue,\n getYScaleValue,\n getY2ScaleValue,\n subGroupScale,\n getBandwidth,\n colorScale,\n getXValue,\n getYValue,\n chartId,\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? getY2ScaleValue : getYScaleValue;\n\n const negativeSize = innerHeight - finalYScale(0);\n const positiveSize = innerHeight - negativeSize;\n\n return (\n <A11yRegion\n serieName={serie.name}\n clipPath={`url(#rect-focus-ring-${chartId})`}\n fill={colorScale(serie.name) as string}\n >\n {serie.data.map((bar) => {\n const x = getXValue(bar) as number;\n const y = getYValue(bar) as number;\n const xScaled = getXScaleValue(bar) ?? 0;\n const yScaled = finalYScale(bar) ?? 0;\n const width = subGroupScale?.bandwidth() ?? 0;\n const height = y > 0 ? positiveSize - yScaled : yScaled - finalYScale(0);\n // On a band axis the slot of a category starts at its position; on a linear or a time axis it is centered on the\n // value. Each series takes its place in the slot, so the bars of several series on one date sit side by side\n // instead of on top of each other (a single series stays centered on its value)\n const slotStart = xScale?.type !== 'BAND' ? xScaled - getBandwidth() / 2 : xScaled;\n const transformX = slotStart + ((subGroupScale && subGroupScale(serie.name)) ?? 0);\n\n const transformY = y > 0 ? finalYScale(0) - height : finalYScale(0);\n\n return (\n <g id={`${chartId}-${serie.name}-rects-${bar.key}`} key={bar.key} transform={`translate(${transformX},0)`}>\n <Rect\n name={serie.name}\n xValue={x}\n yValue={y}\n width={width}\n height={height}\n id={bar.key}\n y={transformY}\n isNegative={y < 0}\n datum={bar}\n />\n </g>\n );\n })}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,QAAQ;AAAA,YACR;AAAA,YACA;AAAA,YACA,IAAI,IAAI;AAAA,YACR,GAAG;AAAA,YACH,YAAY,IAAI;AAAA,YAChB,OAAO;AAAA;AAAA,QACT,KAXuD,IAAI,GAY7D;AAAA,MAEJ,CAAC;AAAA;AAAA,EACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useContext, useMemo } from "react";
|
|
4
4
|
import { Rect } from "./Rect.js";
|
|
5
5
|
import { ChartContext } from "../ChartContext.js";
|
|
6
|
+
import { useSerieDimming } from "../helpers/useSerieDimming.js";
|
|
6
7
|
const HorizontalBars = ({ serie }) => {
|
|
7
8
|
const {
|
|
8
9
|
innerWidth,
|
|
@@ -18,8 +19,9 @@ const HorizontalBars = ({ serie }) => {
|
|
|
18
19
|
const finalYScale = serie.scale === "y2" ? getY2ScaleValue : getYScaleValue;
|
|
19
20
|
const negativeSize = innerWidth - getXScaleValue(0);
|
|
20
21
|
const positiveSize = innerWidth - negativeSize;
|
|
22
|
+
const dimmedStyle = useSerieDimming(serie.name);
|
|
21
23
|
return useMemo(
|
|
22
|
-
() => /* @__PURE__ */ jsx("g", { fill: colorScale(serie.name), clipPath: `url(#rect-focus-ring-${chartId})`, children: serie.data.map((bar) => {
|
|
24
|
+
() => /* @__PURE__ */ jsx("g", { fill: colorScale(serie.name), clipPath: `url(#rect-focus-ring-${chartId})`, style: dimmedStyle, children: serie.data.map((bar) => {
|
|
23
25
|
const x = getXValue(bar);
|
|
24
26
|
const y = getYValue(bar);
|
|
25
27
|
const xScaled = getXScaleValue(bar) ?? 0;
|
|
@@ -44,6 +46,7 @@ const HorizontalBars = ({ serie }) => {
|
|
|
44
46
|
[
|
|
45
47
|
chartId,
|
|
46
48
|
colorScale,
|
|
49
|
+
dimmedStyle,
|
|
47
50
|
finalYScale,
|
|
48
51
|
getXScaleValue,
|
|
49
52
|
getXValue,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/HorizontalBars.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext, useMemo } from 'react';\nimport { Rect } from './Rect.js';\nimport { ChartContext } from '../ChartContext.js';\nimport type { DSChartT } from '
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useContext, useMemo } from 'react';\nimport { Rect } from './Rect.js';\nimport { ChartContext } from '../ChartContext.js';\nimport { useSerieDimming } from '../helpers/useSerieDimming.js';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\n\nexport const HorizontalBars = ({ serie }: DSChartT.SerieComponentT) => {\n const {\n innerWidth,\n subGroupScale,\n getYScaleValue,\n getY2ScaleValue,\n getXScaleValue,\n colorScale,\n getXValue,\n getYValue,\n chartId,\n } = useContext(ChartContext);\n const finalYScale = serie.scale === 'y2' ? getY2ScaleValue : getYScaleValue;\n const negativeSize = innerWidth - getXScaleValue(0);\n const positiveSize = innerWidth - negativeSize;\n\n const dimmedStyle = useSerieDimming(serie.name);\n return useMemo(\n () => (\n <g fill={colorScale(serie.name) as string} clipPath={`url(#rect-focus-ring-${chartId})`} style={dimmedStyle}>\n {serie.data.map((bar) => {\n const x = getXValue(bar) as number;\n const y = getYValue(bar) as number;\n const xScaled = getXScaleValue(bar) ?? 0;\n const width = x < 0 ? positiveSize - xScaled : xScaled - getXScaleValue(0);\n const height = subGroupScale?.bandwidth() ?? 0;\n const transformX = x < 0 ? getXScaleValue(0) - width : getXScaleValue(0);\n const transformY = ((subGroupScale && subGroupScale(serie.name)) ?? 0) + finalYScale(y);\n\n return (\n <g key={bar.key} transform={`translate(${transformX},${transformY})`}>\n <Rect\n datum={bar}\n name={serie.name}\n width={width}\n height={height}\n id={bar.key}\n x={0}\n xValue={x}\n yValue={y}\n />\n </g>\n );\n })}\n </g>\n ),\n [\n chartId,\n colorScale,\n dimmedStyle,\n finalYScale,\n getXScaleValue,\n getXValue,\n getYValue,\n positiveSize,\n serie.data,\n serie.name,\n subGroupScale,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACsCT;AArCd,SAAgB,YAAY,eAAe;AAC3C,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAGzB,MAAM,iBAAiB,CAAC,EAAE,MAAM,MAAgC;AACrE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAC3B,QAAM,cAAc,MAAM,UAAU,OAAO,kBAAkB;AAC7D,QAAM,eAAe,aAAa,eAAe,CAAC;AAClD,QAAM,eAAe,aAAa;AAElC,QAAM,cAAc,gBAAgB,MAAM,IAAI;AAC9C,SAAO;AAAA,IACL,MACE,oBAAC,OAAE,MAAM,WAAW,MAAM,IAAI,GAAa,UAAU,wBAAwB,OAAO,KAAK,OAAO,aAC7F,gBAAM,KAAK,IAAI,CAAC,QAAQ;AACvB,YAAM,IAAI,UAAU,GAAG;AACvB,YAAM,IAAI,UAAU,GAAG;AACvB,YAAM,UAAU,eAAe,GAAG,KAAK;AACvC,YAAM,QAAQ,IAAI,IAAI,eAAe,UAAU,UAAU,eAAe,CAAC;AACzE,YAAM,SAAS,eAAe,UAAU,KAAK;AAC7C,YAAM,aAAa,IAAI,IAAI,eAAe,CAAC,IAAI,QAAQ,eAAe,CAAC;AACvE,YAAM,eAAe,iBAAiB,cAAc,MAAM,IAAI,MAAM,KAAK,YAAY,CAAC;AAEtF,aACE,oBAAC,OAAgB,WAAW,aAAa,UAAU,IAAI,UAAU,KAC/D;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,UACP,MAAM,MAAM;AAAA,UACZ;AAAA,UACA;AAAA,UACA,IAAI,IAAI;AAAA,UACR,GAAG;AAAA,UACH,QAAQ;AAAA,UACR,QAAQ;AAAA;AAAA,MACV,KAVM,IAAI,GAWZ;AAAA,IAEJ,CAAC,GACH;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,MAAM;AAAA,MACN;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,9 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useContext, useMemo } from "react";
|
|
4
4
|
import { Rect } from "./Rect.js";
|
|
5
5
|
import { ChartContext } from "../ChartContext.js";
|
|
6
|
-
import {
|
|
6
|
+
import { useSerieDimming } from "../helpers/useSerieDimming.js";
|
|
7
|
+
import { getStackedData, getStackedIndex, isStackedSegmentEdge } from "../helpers/index.js";
|
|
8
|
+
import { MARKS } from "../../constants.js";
|
|
7
9
|
const HorizontalStackedBars = ({ serie }) => {
|
|
8
10
|
const {
|
|
9
11
|
props: { groups },
|
|
@@ -17,17 +19,20 @@ const HorizontalStackedBars = ({ serie }) => {
|
|
|
17
19
|
} = useContext(ChartContext);
|
|
18
20
|
const serieWithStackedValues = getStackedData(stackedData, serie);
|
|
19
21
|
const stackIndex = getStackedIndex(groups, serie.name);
|
|
22
|
+
const dimmedStyle = useSerieDimming(serie.name);
|
|
20
23
|
return useMemo(
|
|
21
|
-
() => /* @__PURE__ */ jsx("g", { children: serie.data.map((bar, i) => {
|
|
24
|
+
() => /* @__PURE__ */ jsx("g", { style: dimmedStyle, children: serie.data.map((bar, i) => {
|
|
22
25
|
const sequence = serieWithStackedValues ? serieWithStackedValues[bar.position] : [0, 0];
|
|
23
26
|
const sequence0 = getXScaleValue(sequence[0]);
|
|
24
27
|
const sequence1 = getXScaleValue(sequence[1]);
|
|
25
|
-
const
|
|
28
|
+
const isNegativeSegment = sequence[0] < 0;
|
|
29
|
+
const gapLeft = !isNegativeSegment && sequence[0] > 0 ? MARKS.STACK_GAP : 0;
|
|
30
|
+
const gapRight = isNegativeSegment && sequence[1] < 0 ? MARKS.STACK_GAP : 0;
|
|
26
31
|
const xValue = sequence[1] - sequence[0];
|
|
27
32
|
const yValue = getYValue(serie.data[i]);
|
|
28
|
-
const width = sequence1 - sequence0 -
|
|
33
|
+
const width = sequence1 - sequence0 - gapLeft - gapRight;
|
|
29
34
|
const height = subGroupScale?.bandwidth() ?? 0;
|
|
30
|
-
const transformX = sequence0 +
|
|
35
|
+
const transformX = sequence0 + gapLeft;
|
|
31
36
|
const transformY = (subGroupScale ? subGroupScale(`stacked-data-${stackIndex}`) ?? 0 : 0) + (yScale?.get(yValue) ?? 0);
|
|
32
37
|
return /* @__PURE__ */ jsx("g", { clipPath: `url(#rect-focus-ring-${chartId})`, children: /* @__PURE__ */ jsx("g", { fill: colorScale(serie.name), transform: `translate(0, ${transformY})`, children: /* @__PURE__ */ jsx(
|
|
33
38
|
Rect,
|
|
@@ -39,18 +44,20 @@ const HorizontalStackedBars = ({ serie }) => {
|
|
|
39
44
|
yValue,
|
|
40
45
|
id: serie.data[i]?.key,
|
|
41
46
|
name: serie.name,
|
|
42
|
-
datum: serie.data[i]
|
|
47
|
+
datum: serie.data[i],
|
|
48
|
+
isStackEdge: isStackedSegmentEdge(stackedData, serie, serie.data[i]?.position)
|
|
43
49
|
}
|
|
44
50
|
) }) }, serie.data[i]?.key);
|
|
45
51
|
}) }),
|
|
46
52
|
[
|
|
47
53
|
chartId,
|
|
48
54
|
colorScale,
|
|
55
|
+
dimmedStyle,
|
|
49
56
|
getXScaleValue,
|
|
50
57
|
getYValue,
|
|
51
|
-
serie.data,
|
|
52
|
-
serie.name,
|
|
53
58
|
serieWithStackedValues,
|
|
59
|
+
stackedData,
|
|
60
|
+
serie,
|
|
54
61
|
stackIndex,
|
|
55
62
|
subGroupScale,
|
|
56
63
|
yScale
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/series/HorizontalStackedBars.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* prettier-ignore */\nimport React, { useContext, useMemo } from 'react';\nimport { Rect } from './Rect.js';\nimport { ChartContext } from '../ChartContext.js';\nimport { getStackedData, getStackedIndex } from '../helpers/index.js';\nimport type { DSChartT } from '
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* prettier-ignore */\nimport React, { useContext, useMemo } from 'react';\nimport { Rect } from './Rect.js';\nimport { ChartContext } from '../ChartContext.js';\nimport { useSerieDimming } from '../helpers/useSerieDimming.js';\nimport { getStackedData, getStackedIndex, isStackedSegmentEdge } from '../helpers/index.js';\nimport { MARKS } from '../../constants.js';\nimport type { DSChartT } from '../../../react-desc-prop-types.js';\n\nexport const HorizontalStackedBars = ({ serie }: DSChartT.SerieComponentT) => {\n const {\n props: { groups },\n yScale,\n stackedData,\n subGroupScale,\n colorScale,\n chartId,\n getXScaleValue,\n getYValue,\n } = useContext(ChartContext);\n const serieWithStackedValues = getStackedData(stackedData, serie);\n const stackIndex = getStackedIndex(groups, serie.name);\n\n const dimmedStyle = useSerieDimming(serie.name);\n return useMemo(\n () => (\n <g style={dimmedStyle}>\n {serie.data.map((bar, i) => {\n const sequence = serieWithStackedValues ? serieWithStackedValues[bar.position] : [0, 0];\n const sequence0 = getXScaleValue(sequence[0]);\n const sequence1 = getXScaleValue(sequence[1]);\n // the surface gap sits on the side of the previous segment: left of a positive one, right of a negative one\n const isNegativeSegment = sequence[0] < 0;\n const gapLeft = !isNegativeSegment && sequence[0] > 0 ? MARKS.STACK_GAP : 0;\n const gapRight = isNegativeSegment && sequence[1] < 0 ? MARKS.STACK_GAP : 0;\n const xValue = sequence[1] - sequence[0];\n const yValue = getYValue(serie.data[i]) as number;\n\n const width = sequence1 - sequence0 - gapLeft - gapRight;\n\n const height = subGroupScale?.bandwidth() ?? 0;\n const transformX = sequence0 + gapLeft;\n const transformY =\n (subGroupScale ? (subGroupScale(`stacked-data-${stackIndex}`) ?? 0) : 0) +\n (yScale?.get(yValue as never) ?? 0);\n return (\n <g key={serie.data[i]?.key} clipPath={`url(#rect-focus-ring-${chartId})`}>\n <g fill={colorScale(serie.name) as string} transform={`translate(0, ${transformY})`}>\n <Rect\n width={width}\n height={height}\n x={transformX}\n xValue={xValue}\n yValue={yValue}\n id={serie.data[i]?.key}\n name={serie.name}\n datum={serie.data[i]}\n isStackEdge={isStackedSegmentEdge(stackedData, serie, serie.data[i]?.position)}\n />\n </g>\n </g>\n );\n })}\n </g>\n ),\n [\n chartId,\n colorScale,\n dimmedStyle,\n getXScaleValue,\n getYValue,\n serieWithStackedValues,\n stackedData,\n serie,\n stackIndex,\n subGroupScale,\n yScale,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACiDP;AA/ChB,SAAgB,YAAY,eAAe;AAC3C,SAAS,YAAY;AACrB,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,iBAAiB,4BAA4B;AACtE,SAAS,aAAa;AAGf,MAAM,wBAAwB,CAAC,EAAE,MAAM,MAAgC;AAC5E,QAAM;AAAA,IACJ,OAAO,EAAE,OAAO;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAC3B,QAAM,yBAAyB,eAAe,aAAa,KAAK;AAChE,QAAM,aAAa,gBAAgB,QAAQ,MAAM,IAAI;AAErD,QAAM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A;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
|
}
|
|
@@ -5,31 +5,33 @@ import { line, select } from "d3";
|
|
|
5
5
|
import { Points } from "./Points.js";
|
|
6
6
|
import { ChartContext } from "../ChartContext.js";
|
|
7
7
|
import { LINE, curveStyleMap } from "../../constants.js";
|
|
8
|
-
import { DataVizDataTestIds } from "../DataTestIds.js";
|
|
9
8
|
import { A11yRegion } from "../parts/A11yRegion.js";
|
|
9
|
+
import { TrendHighlight } from "../parts/TrendHighlight.js";
|
|
10
|
+
import { StyledLineGroup } from "../styles.js";
|
|
10
11
|
const Line = ({ serie }) => {
|
|
11
|
-
const { xScale, colorScale, getYScaleValue, getY2ScaleValue, getXScaleValue, getXValue, getYValue } = useContext(ChartContext);
|
|
12
|
+
const { xScale, colorScale, getYScaleValue, getY2ScaleValue, getXScaleValue, getXValue, getYValue, getOwnerProps } = useContext(ChartContext);
|
|
12
13
|
const ref = useRef(null);
|
|
13
14
|
const curveStyle = useMemo(() => curveStyleMap[serie.curveStyle ?? LINE.CURVE_STYLE.LINEAR], [serie.curveStyle]);
|
|
14
15
|
const currentYScale = useMemo(
|
|
15
16
|
() => serie.scale === "y2" ? getY2ScaleValue : getYScaleValue,
|
|
16
17
|
[getY2ScaleValue, getYScaleValue, serie.scale]
|
|
17
18
|
);
|
|
18
|
-
const
|
|
19
|
-
() => line().x((_, i) => getXScaleValue(serie.data[i])).y((_, i) => currentYScale(serie.data[i])).curve(curveStyle),
|
|
19
|
+
const linePath = useMemo(
|
|
20
|
+
() => line().x((_, i) => getXScaleValue(serie.data[i])).y((_, i) => currentYScale(serie.data[i])).curve(curveStyle)(serie.data),
|
|
20
21
|
[curveStyle, getXScaleValue, currentYScale, serie.data]
|
|
21
22
|
);
|
|
22
23
|
useEffect(() => {
|
|
23
24
|
if (!ref.current) return;
|
|
24
25
|
const groupContent = select(ref?.current);
|
|
25
26
|
groupContent.selectAll("*").remove();
|
|
26
|
-
const path = groupContent.append("path").
|
|
27
|
+
const path = groupContent.append("path").attr("fill", "none").attr("stroke", colorScale(serie.name)).attr("stroke-linejoin", "round").attr("stroke-linecap", "round").attr("stroke-width", 2).attr("vector-effect", "non-scaling-stroke").attr("d", linePath ?? "");
|
|
27
28
|
if (serie.dashStyle)
|
|
28
29
|
path.attr("stroke-dasharray", LINE.DASH_STYLE_VALUES[serie.dashStyle]);
|
|
29
|
-
}, [colorScale, getXValue, getYValue,
|
|
30
|
+
}, [colorScale, getXValue, getYValue, linePath, serie, xScale]);
|
|
30
31
|
const xTranslate = useMemo(() => (xScale?.getBandwidth?.() ?? 0) / 2, [xScale]);
|
|
31
32
|
return /* @__PURE__ */ jsxs(A11yRegion, { serieName: serie.name, transform: `translate(${xTranslate}, 0)`, children: [
|
|
32
|
-
/* @__PURE__ */ jsx(
|
|
33
|
+
/* @__PURE__ */ jsx(StyledLineGroup, { innerRef: ref, getOwnerProps, getOwnerPropsArguments: () => ({ serie }) }),
|
|
34
|
+
/* @__PURE__ */ jsx(TrendHighlight, { serie, linePath }),
|
|
33
35
|
/* @__PURE__ */ jsx(Points, { serie })
|
|
34
36
|
] });
|
|
35
37
|
};
|