@elliemae/ds-dataviz 3.80.0-next.67 → 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,56 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useContext, useState } from "react";
|
|
4
|
+
import { ThemeContext } from "@elliemae/ds-system";
|
|
5
|
+
import { ChartContext } from "../ChartContext.js";
|
|
6
|
+
import { useChartInteraction } from "../config/chartInteractionStore.js";
|
|
7
|
+
import { BandScale } from "../scales/index.js";
|
|
8
|
+
const HoverBand = () => {
|
|
9
|
+
const {
|
|
10
|
+
xScale,
|
|
11
|
+
yScale,
|
|
12
|
+
getXScaleValue,
|
|
13
|
+
getYScaleValue,
|
|
14
|
+
innerWidth,
|
|
15
|
+
innerHeight,
|
|
16
|
+
props: { scrapper }
|
|
17
|
+
} = useContext(ChartContext);
|
|
18
|
+
const theme = useContext(ThemeContext);
|
|
19
|
+
const activePoint = useChartInteraction((state) => state.activePoint);
|
|
20
|
+
const [hoveredStart, setHoveredStart] = useState(null);
|
|
21
|
+
const isVertical = xScale instanceof BandScale;
|
|
22
|
+
const bandScale = isVertical ? xScale : yScale;
|
|
23
|
+
if (!(bandScale instanceof BandScale)) return null;
|
|
24
|
+
const bandwidth = bandScale.getBandwidth();
|
|
25
|
+
const step = bandScale.scale.step();
|
|
26
|
+
const padding = Math.min(8, bandwidth * 0.1);
|
|
27
|
+
const pointerStart = activePoint ? (isVertical ? getXScaleValue : getYScaleValue)(activePoint) : null;
|
|
28
|
+
const activeStart = pointerStart ?? hoveredStart;
|
|
29
|
+
const starts = bandScale.getTicks().map((category) => bandScale.get(category) ?? 0);
|
|
30
|
+
const bandRect = (start, size, offset) => isVertical ? { x: start - offset, y: 0, width: size, height: innerHeight } : { x: 0, y: start - offset, width: innerWidth, height: size };
|
|
31
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
32
|
+
activeStart !== null ? /* @__PURE__ */ jsx(
|
|
33
|
+
"rect",
|
|
34
|
+
{
|
|
35
|
+
...bandRect(activeStart, bandwidth + padding * 2, padding),
|
|
36
|
+
rx: 4,
|
|
37
|
+
fill: theme?.colors?.neutral?.["050"] ?? "#F6F7F9",
|
|
38
|
+
pointerEvents: "none"
|
|
39
|
+
}
|
|
40
|
+
) : null,
|
|
41
|
+
!scrapper ? starts.map((start) => /* @__PURE__ */ jsx(
|
|
42
|
+
"rect",
|
|
43
|
+
{
|
|
44
|
+
...bandRect(start, step, (step - bandwidth) / 2),
|
|
45
|
+
fill: "transparent",
|
|
46
|
+
onMouseEnter: () => setHoveredStart(start),
|
|
47
|
+
onMouseLeave: () => setHoveredStart(null)
|
|
48
|
+
},
|
|
49
|
+
start
|
|
50
|
+
)) : null
|
|
51
|
+
] });
|
|
52
|
+
};
|
|
53
|
+
export {
|
|
54
|
+
HoverBand
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=HoverBand.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/graphs/Chart/parts/HoverBand.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useState } from 'react';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { ChartContext } from '../ChartContext.js';\nimport { useChartInteraction } from '../config/chartInteractionStore.js';\nimport { BandScale } from '../scales/index.js';\n\n// A light band behind the category under the pointer (or of the data point focused with the keyboard) on a band axis,\n// so the whole group responds, not only the hovered bar. Drawn under the series.\n//\n// The band follows the category, not the bar: every category has a transparent hover area as wide as its whole step,\n// gaps between its bars included. Moving from a bar to the gap next to it, or to another bar of the same category,\n// hands the hover from one element to the other in the same event, so the band never blinks. Charts with a scrapper\n// have their own guide line and keep only the keyboard band.\nexport const HoverBand = () => {\n const {\n xScale,\n yScale,\n getXScaleValue,\n getYScaleValue,\n innerWidth,\n innerHeight,\n props: { scrapper },\n } = useContext(ChartContext);\n const theme = useContext(ThemeContext);\n const activePoint = useChartInteraction((state) => state.activePoint);\n // start of the category whose hover area is under the pointer\n const [hoveredStart, setHoveredStart] = useState<number | null>(null);\n\n const isVertical = xScale instanceof BandScale;\n const bandScale = isVertical ? xScale : yScale;\n if (!(bandScale instanceof BandScale)) return null;\n\n const bandwidth = bandScale.getBandwidth();\n const step = bandScale.scale.step();\n const padding = Math.min(8, bandwidth * 0.1);\n const pointerStart = activePoint ? (isVertical ? getXScaleValue : getYScaleValue)(activePoint) : null;\n const activeStart = pointerStart ?? hoveredStart;\n const starts = bandScale.getTicks().map((category) => bandScale.get(category) ?? 0);\n\n // a rectangle along the band axis, across the whole plot on the other one\n const bandRect = (start: number, size: number, offset: number) =>\n isVertical\n ? { x: start - offset, y: 0, width: size, height: innerHeight }\n : { x: 0, y: start - offset, width: innerWidth, height: size };\n\n return (\n <g>\n {activeStart !== null ? (\n <rect\n {...bandRect(activeStart, bandwidth + padding * 2, padding)}\n rx={4}\n fill={theme?.colors?.neutral?.['050'] ?? '#F6F7F9'}\n pointerEvents=\"none\"\n />\n ) : null}\n {!scrapper\n ? starts.map((start) => (\n <rect\n key={start}\n {...bandRect(start, step, (step - bandwidth) / 2)}\n fill=\"transparent\"\n onMouseEnter={() => setHoveredStart(start)}\n onMouseLeave={() => setHoveredStart(null)}\n />\n ))\n : null}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC8CnB,SAEI,KAFJ;AA9CJ,SAAgB,YAAY,gBAAgB;AAC5C,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,2BAA2B;AACpC,SAAS,iBAAiB;AASnB,MAAM,YAAY,MAAM;AAC7B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,SAAS;AAAA,EACpB,IAAI,WAAW,YAAY;AAC3B,QAAM,QAAQ,WAAW,YAAY;AACrC,QAAM,cAAc,oBAAoB,CAAC,UAAU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|
|
3
3
|
import React2 from "react";
|
|
4
4
|
import { StyledAxisLabel } from "../../styles.js";
|
|
5
|
-
const Label = React2.memo(
|
|
5
|
+
const Label = React2.memo(
|
|
6
|
+
({ innerRef, x, y, label, rotateDegrees = 0, axis, getOwnerProps }) => /* @__PURE__ */ jsx("g", { ref: innerRef, children: /* @__PURE__ */ jsx("g", { transform: `translate(${x},${y}) rotate(${rotateDegrees})`, children: /* @__PURE__ */ jsx(
|
|
7
|
+
StyledAxisLabel,
|
|
8
|
+
{
|
|
9
|
+
className: "axis-label",
|
|
10
|
+
textAnchor: "middle",
|
|
11
|
+
getOwnerProps,
|
|
12
|
+
getOwnerPropsArguments: () => ({ axis }),
|
|
13
|
+
children: label
|
|
14
|
+
}
|
|
15
|
+
) }) })
|
|
16
|
+
);
|
|
6
17
|
export {
|
|
7
18
|
Label
|
|
8
19
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Labels/Label.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport type { SetStateAction, Dispatch } from 'react';\nimport { StyledAxisLabel } from '../../styles.js';\n\nexport interface LabelT {\n x: number;\n y: number;\n rotateDegrees?: number;\n label: string;\n innerRef: Dispatch<SetStateAction<SVGGElement | null>>;\n}\n\nexport const Label: React.ComponentType<LabelT> = React.memo(({ innerRef, x, y, label, rotateDegrees = 0 }) => (\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport type { SetStateAction, Dispatch } from 'react';\nimport { StyledAxisLabel } from '../../styles.js';\nimport type { DSChartT } from '../../../../react-desc-prop-types.js';\n\nexport interface LabelT {\n x: number;\n y: number;\n rotateDegrees?: number;\n label: string;\n innerRef: Dispatch<SetStateAction<SVGGElement | null>>;\n axis: 'x' | 'y' | 'y2';\n getOwnerProps: () => DSChartT.Props;\n}\n\nexport const Label: React.ComponentType<LabelT> = React.memo(\n ({ innerRef, x, y, label, rotateDegrees = 0, axis, getOwnerProps }) => (\n <g ref={innerRef}>\n <g transform={`translate(${x},${y}) rotate(${rotateDegrees})`}>\n <StyledAxisLabel\n className=\"axis-label\"\n textAnchor=\"middle\"\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={() => ({ axis })}\n >\n {label}\n </StyledAxisLabel>\n </g>\n </g>\n ),\n);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACmBf;AAnBR,OAAOA,YAAW;AAElB,SAAS,uBAAuB;AAazB,MAAM,QAAqCA,OAAM;AAAA,EACtD,CAAC,EAAE,UAAU,GAAG,GAAG,OAAO,gBAAgB,GAAG,MAAM,cAAc,MAC/D,oBAAC,OAAE,KAAK,UACN,8BAAC,OAAE,WAAW,aAAa,CAAC,IAAI,CAAC,YAAY,aAAa,KACxD;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,YAAW;AAAA,MACX;AAAA,MACA,wBAAwB,OAAO,EAAE,KAAK;AAAA,MAErC;AAAA;AAAA,EACH,GACF,GACF;AAEJ;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -15,7 +15,8 @@ const Labels = () => {
|
|
|
15
15
|
leftLabelWidth,
|
|
16
16
|
axisBottomHeight,
|
|
17
17
|
axisRightWidth,
|
|
18
|
-
props: { xAxis, y2Axis, yAxis }
|
|
18
|
+
props: { xAxis, y2Axis, yAxis },
|
|
19
|
+
getOwnerProps
|
|
19
20
|
} = useContext(ChartContext);
|
|
20
21
|
const { label: xLabel } = xAxis || {};
|
|
21
22
|
const { label: yLabel } = yAxis || {};
|
|
@@ -29,7 +30,9 @@ const Labels = () => {
|
|
|
29
30
|
x: innerWidth + internalMargin.left + axisRightWidth,
|
|
30
31
|
y: innerHeight / 2 + internalMargin.top,
|
|
31
32
|
label: y2Label,
|
|
32
|
-
rotateDegrees: 90
|
|
33
|
+
rotateDegrees: 90,
|
|
34
|
+
axis: "y2",
|
|
35
|
+
getOwnerProps
|
|
33
36
|
}
|
|
34
37
|
) : null,
|
|
35
38
|
yLabel ? /* @__PURE__ */ jsx(
|
|
@@ -39,7 +42,9 @@ const Labels = () => {
|
|
|
39
42
|
x: leftLegendWidth + leftLabelWidth,
|
|
40
43
|
y: innerHeight / 2 + internalMargin.top,
|
|
41
44
|
label: yLabel,
|
|
42
|
-
rotateDegrees: -90
|
|
45
|
+
rotateDegrees: -90,
|
|
46
|
+
axis: "y",
|
|
47
|
+
getOwnerProps
|
|
43
48
|
}
|
|
44
49
|
) : null,
|
|
45
50
|
xLabel ? /* @__PURE__ */ jsx(
|
|
@@ -48,13 +53,16 @@ const Labels = () => {
|
|
|
48
53
|
innerRef: setBottomLabel,
|
|
49
54
|
x: innerWidth / 2 + internalMargin.left,
|
|
50
55
|
y: innerHeight + axisBottomHeight + internalMargin.top,
|
|
51
|
-
label: xLabel
|
|
56
|
+
label: xLabel,
|
|
57
|
+
axis: "x",
|
|
58
|
+
getOwnerProps
|
|
52
59
|
}
|
|
53
60
|
) : null
|
|
54
61
|
] }),
|
|
55
62
|
[
|
|
56
63
|
axisBottomHeight,
|
|
57
64
|
axisRightWidth,
|
|
65
|
+
getOwnerProps,
|
|
58
66
|
innerHeight,
|
|
59
67
|
innerWidth,
|
|
60
68
|
internalMargin.left,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Labels/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../../ChartContext.js';\nimport { Label } from './Label.js';\n\nexport const Labels = () => {\n const {\n setBottomLabel,\n setLeftLabel,\n setRightLabel,\n internalMargin,\n innerHeight,\n innerWidth,\n leftLegendWidth,\n leftLabelWidth,\n axisBottomHeight,\n axisRightWidth,\n props: { xAxis, y2Axis, yAxis },\n } = useContext(ChartContext);\n\n const { label: xLabel } = xAxis || {};\n const { label: yLabel } = yAxis || {};\n const { label: y2Label } = y2Axis || {};\n\n return useMemo(\n () => (\n <g className=\"labels\">\n {y2Label ? (\n <Label\n innerRef={setRightLabel}\n x={innerWidth + internalMargin.left + axisRightWidth}\n y={innerHeight / 2 + internalMargin.top}\n label={y2Label}\n rotateDegrees={90}\n />\n ) : null}\n {yLabel ? (\n <Label\n innerRef={setLeftLabel}\n x={leftLegendWidth + leftLabelWidth}\n y={innerHeight / 2 + internalMargin.top}\n label={yLabel}\n rotateDegrees={-90}\n />\n ) : null}\n {xLabel ? (\n <Label\n innerRef={setBottomLabel}\n x={innerWidth / 2 + internalMargin.left}\n y={innerHeight + axisBottomHeight + internalMargin.top}\n label={xLabel}\n />\n ) : null}\n </g>\n ),\n [\n axisBottomHeight,\n axisRightWidth,\n innerHeight,\n innerWidth,\n internalMargin.left,\n internalMargin.top,\n leftLabelWidth,\n leftLegendWidth,\n setBottomLabel,\n setLeftLabel,\n setRightLabel,\n xLabel,\n y2Label,\n yLabel,\n ],\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { ChartContext } from '../../ChartContext.js';\nimport { Label } from './Label.js';\n\nexport const Labels = () => {\n const {\n setBottomLabel,\n setLeftLabel,\n setRightLabel,\n internalMargin,\n innerHeight,\n innerWidth,\n leftLegendWidth,\n leftLabelWidth,\n axisBottomHeight,\n axisRightWidth,\n props: { xAxis, y2Axis, yAxis },\n getOwnerProps,\n } = useContext(ChartContext);\n\n const { label: xLabel } = xAxis || {};\n const { label: yLabel } = yAxis || {};\n const { label: y2Label } = y2Axis || {};\n\n return useMemo(\n () => (\n <g className=\"labels\">\n {y2Label ? (\n <Label\n innerRef={setRightLabel}\n x={innerWidth + internalMargin.left + axisRightWidth}\n y={innerHeight / 2 + internalMargin.top}\n label={y2Label}\n rotateDegrees={90}\n axis=\"y2\"\n getOwnerProps={getOwnerProps}\n />\n ) : null}\n {yLabel ? (\n <Label\n innerRef={setLeftLabel}\n x={leftLegendWidth + leftLabelWidth}\n y={innerHeight / 2 + internalMargin.top}\n label={yLabel}\n rotateDegrees={-90}\n axis=\"y\"\n getOwnerProps={getOwnerProps}\n />\n ) : null}\n {xLabel ? (\n <Label\n innerRef={setBottomLabel}\n x={innerWidth / 2 + internalMargin.left}\n y={innerHeight + axisBottomHeight + internalMargin.top}\n label={xLabel}\n axis=\"x\"\n getOwnerProps={getOwnerProps}\n />\n ) : null}\n </g>\n ),\n [\n axisBottomHeight,\n axisRightWidth,\n getOwnerProps,\n innerHeight,\n innerWidth,\n internalMargin.left,\n internalMargin.top,\n leftLabelWidth,\n leftLegendWidth,\n setBottomLabel,\n setLeftLabel,\n setRightLabel,\n xLabel,\n y2Label,\n yLabel,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0BjB,SAEI,KAFJ;AA1BN,SAAgB,YAAY,eAAe;AAC3C,SAAS,oBAAoB;AAC7B,SAAS,aAAa;AAEf,MAAM,SAAS,MAAM;AAC1B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,EAAE,OAAO,QAAQ,MAAM;AAAA,IAC9B;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,EAAE,OAAO,OAAO,IAAI,SAAS,CAAC;AACpC,QAAM,EAAE,OAAO,OAAO,IAAI,SAAS,CAAC;AACpC,QAAM,EAAE,OAAO,QAAQ,IAAI,UAAU,CAAC;AAEtC,SAAO;AAAA,IACL,MACE,qBAAC,OAAE,WAAU,UACV;AAAA,gBACC;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UACV,GAAG,aAAa,eAAe,OAAO;AAAA,UACtC,GAAG,cAAc,IAAI,eAAe;AAAA,UACpC,OAAO;AAAA,UACP,eAAe;AAAA,UACf,MAAK;AAAA,UACL;AAAA;AAAA,MACF,IACE;AAAA,MACH,SACC;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UACV,GAAG,kBAAkB;AAAA,UACrB,GAAG,cAAc,IAAI,eAAe;AAAA,UACpC,OAAO;AAAA,UACP,eAAe;AAAA,UACf,MAAK;AAAA,UACL;AAAA;AAAA,MACF,IACE;AAAA,MACH,SACC;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UACV,GAAG,aAAa,IAAI,eAAe;AAAA,UACnC,GAAG,cAAc,mBAAmB,eAAe;AAAA,UACnD,OAAO;AAAA,UACP,MAAK;AAAA,UACL;AAAA;AAAA,MACF,IACE;AAAA,OACN;AAAA,IAEF;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe;AAAA,MACf,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useContext, useMemo,
|
|
3
|
+
import { useContext, useMemo, useLayoutEffect, useState } from "react";
|
|
4
4
|
import { select } from "d3";
|
|
5
5
|
import { ChartContext } from "../../ChartContext.js";
|
|
6
6
|
import { LegendItem } from "./LegendItem.js";
|
|
7
|
+
import { getSVGBoxWidth } from "../../helpers/index.js";
|
|
7
8
|
const BottomLegend = () => {
|
|
8
9
|
const {
|
|
9
10
|
colorScale,
|
|
@@ -20,7 +21,7 @@ const BottomLegend = () => {
|
|
|
20
21
|
setBottomLegend
|
|
21
22
|
} = useContext(ChartContext);
|
|
22
23
|
const [xTransform, setXTransform] = useState(0);
|
|
23
|
-
|
|
24
|
+
useLayoutEffect(() => {
|
|
24
25
|
if (!bottomLegend) return;
|
|
25
26
|
const cells = select(bottomLegend).selectAll(".cell");
|
|
26
27
|
const padding = 25;
|
|
@@ -30,8 +31,8 @@ const BottomLegend = () => {
|
|
|
30
31
|
if (cells.nodes()[i - 1]) {
|
|
31
32
|
const lastCell = select(cells.nodes()[i - 1]);
|
|
32
33
|
const d3sel = select(cells.nodes()[i]);
|
|
33
|
-
const
|
|
34
|
-
const lastCellWidth = lastCell.node()
|
|
34
|
+
const currentCellWidth = getSVGBoxWidth(d3sel.node());
|
|
35
|
+
const lastCellWidth = getSVGBoxWidth(lastCell.node());
|
|
35
36
|
if (offset + lastCellWidth + padding + currentCellWidth + 10 > graphWidth) {
|
|
36
37
|
offset = 0;
|
|
37
38
|
verticalOffset += 20;
|
|
@@ -47,6 +48,8 @@ const BottomLegend = () => {
|
|
|
47
48
|
() => /* @__PURE__ */ jsx(
|
|
48
49
|
"g",
|
|
49
50
|
{
|
|
51
|
+
role: "group",
|
|
52
|
+
"aria-label": "Legend",
|
|
50
53
|
ref: setBottomLegend,
|
|
51
54
|
transform: `translate(${xTransform}, ${innerHeight + bottomLabelHeight + axisBottomHeight + internalMargin.top})`,
|
|
52
55
|
className: "bottom-legend",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/BottomLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo,
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useLayoutEffect, useState } from 'react';\nimport { select } from 'd3';\nimport { ChartContext } from '../../ChartContext.js';\nimport { LegendItem } from './LegendItem.js';\nimport { getSVGBoxWidth } from '../../helpers/index.js';\n\nexport const BottomLegend = () => {\n const {\n colorScale,\n bottomLegendWidth,\n bottomLegend,\n axisBottomHeight,\n axisLeftWidth,\n innerWidth,\n innerHeight,\n bottomLabelHeight,\n internalMargin,\n currentData,\n width: graphWidth,\n setBottomLegend,\n } = useContext(ChartContext);\n\n const [xTransform, setXTransform] = useState(0);\n\n // a layout effect, so the items are placed before the browser paints instead of jumping on the next frame\n useLayoutEffect(() => {\n if (!bottomLegend) return;\n const cells = select(bottomLegend).selectAll('.cell');\n const padding = 25;\n let offset = 0;\n let verticalOffset = 0;\n\n currentData.forEach((_, i) => {\n if (cells.nodes()[i - 1]) {\n const lastCell = select(cells.nodes()[i - 1] as SVGGElement);\n const d3sel = select(cells.nodes()[i] as SVGGElement);\n const currentCellWidth = getSVGBoxWidth(d3sel.node());\n\n const lastCellWidth = getSVGBoxWidth(lastCell.node());\n\n if (offset + lastCellWidth + padding + currentCellWidth + 10 > graphWidth) {\n offset = 0;\n verticalOffset += 20;\n } else {\n offset += lastCellWidth + padding;\n }\n\n d3sel.attr('transform', `translate(${offset}, ${verticalOffset})`);\n }\n });\n\n setXTransform(innerWidth / 2 + internalMargin.left - bottomLegendWidth / 2);\n }, [bottomLegend, currentData, bottomLegendWidth, axisLeftWidth, innerWidth, internalMargin.left, graphWidth]);\n\n return useMemo(\n () => (\n <g\n role=\"group\"\n aria-label=\"Legend\"\n ref={setBottomLegend}\n transform={`translate(${xTransform}, ${\n innerHeight + bottomLabelHeight + axisBottomHeight + internalMargin.top\n })`}\n className=\"bottom-legend\"\n >\n {colorScale.domain().map((domainValue) => (\n <LegendItem domainValue={domainValue} key={domainValue} />\n ))}\n </g>\n ),\n\n [axisBottomHeight, bottomLabelHeight, colorScale, innerHeight, internalMargin.top, setBottomLegend, xTransform],\n );\n};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AO;AAAA,IACL,MACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL,cAAW;AAAA,QACX,KAAK;AAAA,QACL,WAAW,aAAa,UAAU,KAChC,cAAc,oBAAoB,mBAAmB,eAAe,GACtE;AAAA,QACA,WAAU;AAAA,QAET,qBAAW,OAAO,EAAE,IAAI,CAAC,gBACxB,oBAAC,cAAW,eAA+B,WAAa,CACzD;AAAA;AAAA,IACH;AAAA,IAGF,CAAC,kBAAkB,mBAAmB,YAAY,aAAa,eAAe,KAAK,iBAAiB,UAAU;AAAA,EAChH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useContext
|
|
3
|
+
import { useContext } from "react";
|
|
4
4
|
import { ChartContext } from "../../ChartContext.js";
|
|
5
5
|
import { LegendItem } from "./LegendItem.js";
|
|
6
6
|
const LeftLegend = () => {
|
|
@@ -9,14 +9,10 @@ const LeftLegend = () => {
|
|
|
9
9
|
leftLegendHeight,
|
|
10
10
|
innerHeight,
|
|
11
11
|
internalMargin,
|
|
12
|
-
leftLegend,
|
|
13
12
|
setLeftLegend
|
|
14
13
|
} = useContext(ChartContext);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
setYTransform(innerHeight / 2 + internalMargin.top - leftLegendHeight / 2);
|
|
18
|
-
}, [innerHeight, internalMargin.top, leftLegend, leftLegendHeight]);
|
|
19
|
-
return /* @__PURE__ */ jsx("g", { transform: `translate(8,${yTransform})`, ref: setLeftLegend, children: series.map((serie, i) => /* @__PURE__ */ jsx("g", { className: "tick", transform: `translate(0,${i * 30})`, children: /* @__PURE__ */ jsx(LegendItem, { domainValue: serie.name }, serie.name) }, serie.name)) });
|
|
14
|
+
const yTransform = innerHeight / 2 + internalMargin.top - leftLegendHeight / 2;
|
|
15
|
+
return /* @__PURE__ */ jsx("g", { transform: `translate(8,${yTransform})`, ref: setLeftLegend, role: "group", "aria-label": "Legend", children: series.map((serie, i) => /* @__PURE__ */ jsx("g", { className: "tick", transform: `translate(0,${i * 30})`, children: /* @__PURE__ */ jsx(LegendItem, { domainValue: serie.name }, serie.name) }, serie.name)) });
|
|
20
16
|
};
|
|
21
17
|
export {
|
|
22
18
|
LeftLegend
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/LeftLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { ChartContext } from '../../ChartContext.js';\nimport { LegendItem } from './LegendItem.js';\n\nexport const LeftLegend = () => {\n const {\n originalSeries: series,\n leftLegendHeight,\n innerHeight,\n internalMargin,\n setLeftLegend,\n } = useContext(ChartContext);\n\n // centered on the plot, derived on render so it is right on the first frame\n const yTransform = innerHeight / 2 + internalMargin.top - leftLegendHeight / 2;\n\n return (\n <g transform={`translate(8,${yTransform})`} ref={setLeftLegend} role=\"group\" aria-label=\"Legend\">\n {series.map((serie, i) => (\n <g className=\"tick\" transform={`translate(0,${i * 30})`} key={serie.name}>\n <LegendItem key={serie.name} domainValue={serie.name} />\n </g>\n ))}\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoBb;AApBV,SAAgB,kBAAkB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,aAAa,MAAM;AAC9B,QAAM;AAAA,IACJ,gBAAgB;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,YAAY;AAG3B,QAAM,aAAa,cAAc,IAAI,eAAe,MAAM,mBAAmB;AAE7E,SACE,oBAAC,OAAE,WAAW,eAAe,UAAU,KAAK,KAAK,eAAe,MAAK,SAAQ,cAAW,UACrF,iBAAO,IAAI,CAAC,OAAO,MAClB,oBAAC,OAAE,WAAU,QAAO,WAAW,eAAe,IAAI,EAAE,KAClD,8BAAC,cAA4B,aAAa,MAAM,QAA/B,MAAM,IAA+B,KADM,MAAM,IAEpE,CACD,GACH;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,50 +1,132 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useContext, useMemo, useCallback } from "react";
|
|
4
|
+
import { ThemeContext } from "@elliemae/ds-system";
|
|
4
5
|
import { LINE } from "../../../constants.js";
|
|
5
6
|
import { ChartContext } from "../../ChartContext.js";
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const LegendItemLine = ({ fill, dashStyle }) => /* @__PURE__ */ jsx(
|
|
8
|
+
"line",
|
|
9
|
+
{
|
|
10
|
+
x1: -7,
|
|
11
|
+
x2: 7,
|
|
12
|
+
y1: 0,
|
|
13
|
+
y2: 0,
|
|
14
|
+
stroke: fill,
|
|
15
|
+
strokeWidth: 2,
|
|
16
|
+
strokeLinecap: dashStyle ? "butt" : "round",
|
|
17
|
+
strokeDasharray: dashStyle ? LINE.DASH_STYLE_VALUES[dashStyle]?.join(" ") : void 0
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
const LegendItemCircle = ({ fill }) => /* @__PURE__ */ jsx("circle", { r: 5, fill });
|
|
21
|
+
const LegendItemSquare = ({ fill }) => /* @__PURE__ */ jsx("rect", { x: -5, y: -5, width: 10, height: 10, rx: 2, fill });
|
|
22
|
+
const LegendItemDiamond = ({ fill }) => /* @__PURE__ */ jsx("g", { transform: "rotate(45)", children: /* @__PURE__ */ jsx("rect", { x: -4, y: -4, width: 8, height: 8, rx: 1, fill }) });
|
|
9
23
|
const LegendItemsMap = {
|
|
10
24
|
[LINE.POINT_STYLE.CIRCLE]: LegendItemCircle,
|
|
11
25
|
[LINE.POINT_STYLE.SQUARE]: LegendItemSquare,
|
|
12
26
|
[LINE.POINT_STYLE.DIAMOND]: LegendItemDiamond
|
|
13
27
|
};
|
|
28
|
+
const getLegendIcon = (serie, types) => {
|
|
29
|
+
if (serie?.pointStyle && serie.pointStyle in LegendItemsMap) return LegendItemsMap[serie.pointStyle];
|
|
30
|
+
if (serie?.type === "line") return LegendItemLine;
|
|
31
|
+
if (serie?.type === "point" || types === "scatter" && !serie?.type) return LegendItemCircle;
|
|
32
|
+
return LegendItemSquare;
|
|
33
|
+
};
|
|
14
34
|
const LegendItem = (props) => {
|
|
15
35
|
const {
|
|
16
36
|
colorScale,
|
|
17
37
|
setHiddenSeries,
|
|
18
38
|
hiddenSeries,
|
|
39
|
+
interactionStore,
|
|
40
|
+
setActivePoint,
|
|
19
41
|
originalSeries: series,
|
|
20
42
|
props: { types, legend }
|
|
21
43
|
} = useContext(ChartContext);
|
|
22
44
|
const { domainValue } = props;
|
|
23
45
|
const serieData = series.find((serie) => serie.name === domainValue);
|
|
24
|
-
const LegendIcon =
|
|
46
|
+
const LegendIcon = getLegendIcon(serieData, types);
|
|
47
|
+
const theme = useContext(ThemeContext);
|
|
48
|
+
const isHidden = hiddenSeries.includes(domainValue);
|
|
49
|
+
const { setHighlightedSerie, releaseHighlightedSerie } = interactionStore;
|
|
50
|
+
const handleMouseEnter = useCallback(() => {
|
|
51
|
+
if (!isHidden) setHighlightedSerie(domainValue);
|
|
52
|
+
}, [domainValue, isHidden, setHighlightedSerie]);
|
|
53
|
+
const handleMouseLeave = useCallback(() => releaseHighlightedSerie(), [releaseHighlightedSerie]);
|
|
54
|
+
const canToggle = !legend?.preventFilterAction;
|
|
55
|
+
const isOnlyVisibleSerie = !isHidden && hiddenSeries.length + 1 === series.length;
|
|
25
56
|
const handleOnClick = useCallback(() => {
|
|
26
57
|
if (legend?.preventFilterAction) return;
|
|
58
|
+
const willHide = !isHidden && hiddenSeries.length + 1 !== series.length;
|
|
27
59
|
setHiddenSeries((prev) => {
|
|
28
60
|
if (prev.includes(domainValue)) return prev.filter((serie) => serie !== domainValue);
|
|
29
61
|
if (prev.length + 1 !== series.length) return [...prev, domainValue];
|
|
30
62
|
return prev;
|
|
31
63
|
});
|
|
32
|
-
|
|
64
|
+
setHighlightedSerie(willHide ? null : domainValue);
|
|
65
|
+
}, [
|
|
66
|
+
domainValue,
|
|
67
|
+
hiddenSeries.length,
|
|
68
|
+
isHidden,
|
|
69
|
+
legend?.preventFilterAction,
|
|
70
|
+
series.length,
|
|
71
|
+
setHiddenSeries,
|
|
72
|
+
setHighlightedSerie
|
|
73
|
+
]);
|
|
74
|
+
const handleFocus = useCallback(() => {
|
|
75
|
+
setActivePoint(null);
|
|
76
|
+
if (!isHidden) setHighlightedSerie(domainValue);
|
|
77
|
+
}, [domainValue, isHidden, setActivePoint, setHighlightedSerie]);
|
|
78
|
+
const handleKeyDown = useCallback(
|
|
79
|
+
(event) => {
|
|
80
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
event.stopPropagation();
|
|
83
|
+
handleOnClick();
|
|
84
|
+
},
|
|
85
|
+
[handleOnClick]
|
|
86
|
+
);
|
|
87
|
+
const buttonProps = useMemo(
|
|
88
|
+
() => canToggle ? {
|
|
89
|
+
role: "button",
|
|
90
|
+
tabIndex: 0,
|
|
91
|
+
"aria-label": domainValue,
|
|
92
|
+
"aria-pressed": !isHidden,
|
|
93
|
+
"aria-disabled": isOnlyVisibleSerie || void 0,
|
|
94
|
+
onKeyDown: handleKeyDown,
|
|
95
|
+
onFocus: handleFocus,
|
|
96
|
+
onBlur: handleMouseLeave
|
|
97
|
+
} : {},
|
|
98
|
+
[canToggle, domainValue, handleFocus, handleKeyDown, handleMouseLeave, isHidden, isOnlyVisibleSerie]
|
|
99
|
+
);
|
|
33
100
|
return useMemo(
|
|
34
101
|
() => /* @__PURE__ */ jsxs(
|
|
35
102
|
"g",
|
|
36
103
|
{
|
|
37
104
|
onClick: handleOnClick,
|
|
105
|
+
onMouseEnter: handleMouseEnter,
|
|
106
|
+
onMouseLeave: handleMouseLeave,
|
|
38
107
|
className: "cell",
|
|
39
|
-
style:
|
|
108
|
+
style: isHidden ? { opacity: 0.2, cursor: "pointer" } : { cursor: "pointer" },
|
|
109
|
+
...buttonProps,
|
|
40
110
|
children: [
|
|
41
|
-
/* @__PURE__ */ jsx(
|
|
42
|
-
/* @__PURE__ */ jsx(
|
|
111
|
+
/* @__PURE__ */ jsx("rect", { x: -5, y: -5, width: 21, height: 8, fill: "transparent" }),
|
|
112
|
+
/* @__PURE__ */ jsx(LegendIcon, { fill: colorScale(domainValue), dashStyle: serieData?.dashStyle }),
|
|
113
|
+
/* @__PURE__ */ jsx("text", { x: 16, dy: ".32em", fill: theme?.colors?.neutral?.["700"] ?? "#353C46", children: domainValue })
|
|
43
114
|
]
|
|
44
115
|
},
|
|
45
116
|
domainValue
|
|
46
117
|
),
|
|
47
|
-
[
|
|
118
|
+
[
|
|
119
|
+
LegendIcon,
|
|
120
|
+
colorScale,
|
|
121
|
+
domainValue,
|
|
122
|
+
handleMouseEnter,
|
|
123
|
+
handleMouseLeave,
|
|
124
|
+
handleOnClick,
|
|
125
|
+
isHidden,
|
|
126
|
+
serieData,
|
|
127
|
+
theme,
|
|
128
|
+
buttonProps
|
|
129
|
+
]
|
|
48
130
|
);
|
|
49
131
|
};
|
|
50
132
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/LegendItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useCallback } from 'react';\nimport { LINE } from '../../../constants.js';\nimport { ChartContext } from '../../ChartContext.js';\n\ninterface LegendItemGraphicProps {\n fill: string;\n}\n\ninterface LegendItemProps {\n domainValue: string;\n}\n\n//
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useCallback } from 'react';\nimport { ThemeContext } from '@elliemae/ds-system';\nimport { LINE } from '../../../constants.js';\nimport { ChartContext } from '../../ChartContext.js';\n\ninterface LegendItemGraphicProps {\n fill: string;\n}\n\ninterface LegendItemLineProps extends LegendItemGraphicProps {\n dashStyle?: string;\n}\n\ninterface LegendItemProps {\n domainValue: string;\n}\n\n// the swatch mirrors the mark of the series: a rounded square for bars and areas, a short stroke for lines,\n// a dot for points; every swatch is centered on the text baseline and 14px wide at most\nconst LegendItemLine = ({ fill, dashStyle }: LegendItemLineProps) => (\n <line\n x1={-7}\n x2={7}\n y1={0}\n y2={0}\n stroke={fill}\n strokeWidth={2}\n strokeLinecap={dashStyle ? 'butt' : 'round'}\n // a dashed line has a dashed swatch, so a forecast reads apart from the actual line of the same color\n strokeDasharray={\n dashStyle ? LINE.DASH_STYLE_VALUES[dashStyle as keyof typeof LINE.DASH_STYLE_VALUES]?.join(' ') : undefined\n }\n />\n);\nconst LegendItemCircle = ({ fill }: LegendItemGraphicProps) => <circle r={5} fill={fill} />;\nconst LegendItemSquare = ({ fill }: LegendItemGraphicProps) => (\n <rect x={-5} y={-5} width={10} height={10} rx={2} fill={fill} />\n);\nconst LegendItemDiamond = ({ fill }: LegendItemGraphicProps) => (\n <g transform=\"rotate(45)\">\n <rect x={-4} y={-4} width={8} height={8} rx={1} fill={fill} />\n </g>\n);\n\nconst LegendItemsMap = {\n [LINE.POINT_STYLE.CIRCLE]: LegendItemCircle,\n [LINE.POINT_STYLE.SQUARE]: LegendItemSquare,\n [LINE.POINT_STYLE.DIAMOND]: LegendItemDiamond,\n};\n\nconst getLegendIcon = (\n serie: { type?: string; pointStyle?: string; dashStyle?: string } | undefined,\n types?: string,\n): React.ComponentType<LegendItemLineProps> => {\n if (serie?.pointStyle && serie.pointStyle in LegendItemsMap) return LegendItemsMap[serie.pointStyle];\n if (serie?.type === 'line') return LegendItemLine;\n if (serie?.type === 'point' || (types === 'scatter' && !serie?.type)) return LegendItemCircle;\n return LegendItemSquare;\n};\n\nexport const LegendItem = (props: LegendItemProps) => {\n const {\n colorScale,\n setHiddenSeries,\n hiddenSeries,\n interactionStore,\n setActivePoint,\n originalSeries: series,\n props: { types, legend },\n } = useContext(ChartContext);\n\n const { domainValue } = props;\n const serieData = series.find((serie) => serie.name === domainValue);\n const LegendIcon = getLegendIcon(serieData, types);\n const theme = useContext(ThemeContext);\n\n const isHidden = hiddenSeries.includes(domainValue);\n\n // hovering an item highlights its series: the others step back (see useSerieDimming). A hidden series has nothing to\n // highlight. Leaving the item releases the highlight a moment later, so moving to the next item does not flash it\n const { setHighlightedSerie, releaseHighlightedSerie } = interactionStore;\n const handleMouseEnter = useCallback(() => {\n if (!isHidden) setHighlightedSerie(domainValue);\n }, [domainValue, isHidden, setHighlightedSerie]);\n const handleMouseLeave = useCallback(() => releaseHighlightedSerie(), [releaseHighlightedSerie]);\n\n const canToggle = !legend?.preventFilterAction;\n // the last visible series cannot be hidden\n const isOnlyVisibleSerie = !isHidden && hiddenSeries.length + 1 === series.length;\n\n const handleOnClick = useCallback(() => {\n if (legend?.preventFilterAction) return;\n const willHide = !isHidden && hiddenSeries.length + 1 !== series.length;\n setHiddenSeries((prev) => {\n if (prev.includes(domainValue)) return prev.filter((serie) => serie !== domainValue);\n if (prev.length + 1 !== series.length) return [...prev, domainValue];\n return prev;\n });\n // a series hidden from under the pointer is not highlighted anymore, and one shown again is\n setHighlightedSerie(willHide ? null : domainValue);\n }, [\n domainValue,\n hiddenSeries.length,\n isHidden,\n legend?.preventFilterAction,\n series.length,\n setHiddenSeries,\n setHighlightedSerie,\n ]);\n\n // With the keyboard, an item is a toggle button: pressed while its series is shown, Enter or Space shows or hides\n // it. Reaching the legend closes the active data point and its tooltip, and highlights the series like a hover. The\n // keys an item handles stop there: the chart navigates its data points with them\n const handleFocus = useCallback(() => {\n setActivePoint(null);\n if (!isHidden) setHighlightedSerie(domainValue);\n }, [domainValue, isHidden, setActivePoint, setHighlightedSerie]);\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<SVGGElement>) => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n event.stopPropagation();\n handleOnClick();\n },\n [handleOnClick],\n );\n const buttonProps = useMemo(\n () =>\n canToggle\n ? {\n role: 'button',\n tabIndex: 0,\n 'aria-label': domainValue,\n 'aria-pressed': !isHidden,\n 'aria-disabled': isOnlyVisibleSerie || undefined,\n onKeyDown: handleKeyDown,\n onFocus: handleFocus,\n onBlur: handleMouseLeave,\n }\n : {},\n [canToggle, domainValue, handleFocus, handleKeyDown, handleMouseLeave, isHidden, isOnlyVisibleSerie],\n );\n\n return useMemo(\n () => (\n <g\n onClick={handleOnClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n key={domainValue}\n className=\"cell\"\n style={isHidden ? { opacity: 0.2, cursor: 'pointer' } : { cursor: 'pointer' }}\n {...buttonProps}\n >\n {/* the gap between the swatch and the name is part of the item too; inside the box the item already has, so\n the legends that lay the items out from their size are not affected */}\n <rect x={-5} y={-5} width={21} height={8} fill=\"transparent\" />\n <LegendIcon fill={colorScale(domainValue) as string} dashStyle={serieData?.dashStyle} />\n <text x={16} dy=\".32em\" fill={theme?.colors?.neutral?.['700'] ?? '#353C46'}>\n {domainValue}\n </text>\n </g>\n ),\n\n [\n LegendIcon,\n colorScale,\n domainValue,\n handleMouseEnter,\n handleMouseLeave,\n handleOnClick,\n isHidden,\n serieData,\n theme,\n buttonProps,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoBrB,cA6HI,YA7HJ;AApBF,SAAgB,YAAY,SAAS,mBAAmB;AACxD,SAAS,oBAAoB;A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{ useContext
|
|
3
|
+
import { useContext } from "react";
|
|
4
4
|
import { ChartContext } from "../../ChartContext.js";
|
|
5
5
|
import { LegendItem } from "./LegendItem.js";
|
|
6
6
|
const RightLegend = () => {
|
|
@@ -14,13 +14,12 @@ const RightLegend = () => {
|
|
|
14
14
|
setRightLegend,
|
|
15
15
|
originalSeries: series
|
|
16
16
|
} = useContext(ChartContext);
|
|
17
|
-
const
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
setYTransform(innerHeight / 2 + internalMargin.top - rightLegendHeight / 2);
|
|
20
|
-
}, [innerHeight, internalMargin.top, rightLegendHeight]);
|
|
17
|
+
const yTransform = innerHeight / 2 + internalMargin.top - rightLegendHeight / 2;
|
|
21
18
|
return /* @__PURE__ */ jsxs(
|
|
22
19
|
"g",
|
|
23
20
|
{
|
|
21
|
+
role: "group",
|
|
22
|
+
"aria-label": "Legend",
|
|
24
23
|
ref: setRightLegend,
|
|
25
24
|
transform: `translate(${innerWidth + internalMargin.left + axisRightWidth + rightLabelWidth},${yTransform})`,
|
|
26
25
|
children: [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/RightLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { ChartContext } from '../../ChartContext.js';\nimport { LegendItem } from './LegendItem.js';\n\nexport const RightLegend = () => {\n const {\n innerWidth,\n innerHeight,\n rightLabelWidth,\n axisRightWidth,\n internalMargin,\n rightLegendHeight,\n setRightLegend,\n originalSeries: series,\n } = useContext(ChartContext);\n\n // centered on the plot, derived on render so it is right on the first frame\n const yTransform = innerHeight / 2 + internalMargin.top - rightLegendHeight / 2;\n\n return (\n <g\n role=\"group\"\n aria-label=\"Legend\"\n ref={setRightLegend}\n transform={`translate(${innerWidth + internalMargin.left + axisRightWidth + rightLabelWidth},${yTransform})`}\n >\n <rect width=\"20\" height={1} fill=\"transparent\" />\n <g transform=\"translate(0,0)\">\n {series.map((serie, i) => (\n <g className=\"tick\" transform={`translate(30,${i * 30})`} key={serie.name}>\n <LegendItem domainValue={serie.name} />\n </g>\n ))}\n </g>\n </g>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACoBnB,SAME,KANF;AApBJ,SAAgB,kBAAkB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,cAAc,MAAM;AAC/B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,EAClB,IAAI,WAAW,YAAY;AAG3B,QAAM,aAAa,cAAc,IAAI,eAAe,MAAM,oBAAoB;AAE9E,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAW;AAAA,MACX,KAAK;AAAA,MACL,WAAW,aAAa,aAAa,eAAe,OAAO,iBAAiB,eAAe,IAAI,UAAU;AAAA,MAEzG;AAAA,4BAAC,UAAK,OAAM,MAAK,QAAQ,GAAG,MAAK,eAAc;AAAA,QAC/C,oBAAC,OAAE,WAAU,kBACV,iBAAO,IAAI,CAAC,OAAO,MAClB,oBAAC,OAAE,WAAU,QAAO,WAAW,gBAAgB,IAAI,EAAE,KACnD,8BAAC,cAAW,aAAa,MAAM,MAAM,KADwB,MAAM,IAErE,CACD,GACH;AAAA;AAAA;AAAA,EACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useContext, useMemo,
|
|
3
|
+
import { useContext, useMemo, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { select } from "d3";
|
|
5
5
|
import { ChartContext } from "../../ChartContext.js";
|
|
6
6
|
import { LegendItem } from "./LegendItem.js";
|
|
7
|
+
import { getSVGBoxWidth } from "../../helpers/index.js";
|
|
7
8
|
const TopLegend = () => {
|
|
8
9
|
const {
|
|
9
10
|
colorScale,
|
|
@@ -11,11 +12,12 @@ const TopLegend = () => {
|
|
|
11
12
|
internalMargin,
|
|
12
13
|
innerWidth,
|
|
13
14
|
setTopLegend,
|
|
14
|
-
width: graphWidth
|
|
15
|
+
width: graphWidth,
|
|
16
|
+
topLegendWidth
|
|
15
17
|
} = useContext(ChartContext);
|
|
16
18
|
const ref = useRef(null);
|
|
17
19
|
const [xTransform, setXTransform] = useState(innerWidth / 2 + internalMargin.left);
|
|
18
|
-
|
|
20
|
+
useLayoutEffect(() => {
|
|
19
21
|
if (ref.current) {
|
|
20
22
|
const cells = select(ref.current).selectAll(".cell");
|
|
21
23
|
const padding = 30;
|
|
@@ -25,8 +27,8 @@ const TopLegend = () => {
|
|
|
25
27
|
if (cells.nodes()[i - 1]) {
|
|
26
28
|
const lastCell = select(cells.nodes()[i - 1]);
|
|
27
29
|
const d3sel = select(cells.nodes()[i]);
|
|
28
|
-
const
|
|
29
|
-
const lastCellWidth = lastCell.node()
|
|
30
|
+
const currentCellWidth = getSVGBoxWidth(d3sel.node());
|
|
31
|
+
const lastCellWidth = getSVGBoxWidth(lastCell.node());
|
|
30
32
|
if (offset + lastCellWidth + padding + currentCellWidth + 10 > graphWidth) {
|
|
31
33
|
offset = 0;
|
|
32
34
|
verticalOffset += 20;
|
|
@@ -39,9 +41,9 @@ const TopLegend = () => {
|
|
|
39
41
|
const bounds = ref.current.getBoundingClientRect();
|
|
40
42
|
setXTransform(innerWidth / 2 + internalMargin.left - bounds.width / 2);
|
|
41
43
|
}
|
|
42
|
-
}, [currentData, graphWidth, innerWidth, internalMargin.left]);
|
|
44
|
+
}, [currentData, graphWidth, innerWidth, internalMargin.left, topLegendWidth]);
|
|
43
45
|
return useMemo(
|
|
44
|
-
() => /* @__PURE__ */ jsx("g", { ref, transform: `translate(${xTransform},10)`, children: /* @__PURE__ */ jsx("g", { ref: setTopLegend, children: colorScale.domain().map((domainValue) => /* @__PURE__ */ jsx(LegendItem, { domainValue }, domainValue)) }) }),
|
|
46
|
+
() => /* @__PURE__ */ jsx("g", { ref, transform: `translate(${xTransform},10)`, role: "group", "aria-label": "Legend", children: /* @__PURE__ */ jsx("g", { ref: setTopLegend, children: colorScale.domain().map((domainValue) => /* @__PURE__ */ jsx(LegendItem, { domainValue }, domainValue)) }) }),
|
|
45
47
|
[xTransform, setTopLegend, colorScale]
|
|
46
48
|
);
|
|
47
49
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../../src/graphs/Chart/parts/Legend/TopLegend.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo,
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useLayoutEffect, useRef, useState } from 'react';\nimport { select } from 'd3';\nimport { ChartContext } from '../../ChartContext.js';\nimport { LegendItem } from './LegendItem.js';\nimport { getSVGBoxWidth } from '../../helpers/index.js';\n\nexport const TopLegend = () => {\n const {\n colorScale,\n currentData,\n internalMargin,\n innerWidth,\n setTopLegend,\n width: graphWidth,\n topLegendWidth,\n } = useContext(ChartContext);\n\n const ref = useRef<SVGGElement>(null);\n\n const [xTransform, setXTransform] = useState(innerWidth / 2 + internalMargin.left);\n\n // a layout effect, so the items are placed before the browser paints instead of jumping on the next frame\n useLayoutEffect(() => {\n if (ref.current) {\n const cells = select(ref.current).selectAll('.cell');\n const padding = 30;\n let offset = 0;\n let verticalOffset = 0;\n\n currentData.forEach((_, i) => {\n if (cells.nodes()[i - 1]) {\n const lastCell = select(cells.nodes()[i - 1] as SVGGElement);\n const d3sel = select(cells.nodes()[i] as SVGGElement);\n const currentCellWidth = getSVGBoxWidth(d3sel.node());\n\n const lastCellWidth = getSVGBoxWidth(lastCell.node());\n\n if (offset + lastCellWidth + padding + currentCellWidth + 10 > graphWidth) {\n offset = 0;\n verticalOffset += 20;\n } else {\n offset += lastCellWidth + padding;\n }\n\n d3sel.attr('transform', `translate(${offset}, ${verticalOffset})`);\n }\n });\n const bounds = ref.current.getBoundingClientRect();\n setXTransform(innerWidth / 2 + internalMargin.left - bounds.width / 2);\n }\n // topLegendWidth is the measured width of the items: it changes when their text does (e.g. a web font loading\n // after the first render), and the items are placed again with the new widths\n }, [currentData, graphWidth, innerWidth, internalMargin.left, topLegendWidth]);\n return useMemo(\n () => (\n <g ref={ref} transform={`translate(${xTransform},10)`} role=\"group\" aria-label=\"Legend\">\n <g ref={setTopLegend}>\n {colorScale.domain().map((domainValue) => (\n <LegendItem key={domainValue} domainValue={domainValue} />\n ))}\n </g>\n </g>\n ),\n\n [xTransform, setTopLegend, colorScale],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC0DX;AA1DZ,SAAgB,YAAY,SAAS,iBAAiB,QAAQ,gBAAgB;AAC9E,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAExB,MAAM,YAAY,MAAM;AAC7B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EACF,IAAI,WAAW,YAAY;AAE3B,QAAM,MAAM,OAAoB,IAAI;AAEpC,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,aAAa,IAAI,eAAe,IAAI;AAGjF,kBAAgB,MAAM;AACpB,QAAI,IAAI,SAAS;AACf,YAAM,QAAQ,OAAO,IA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