@gravity-ui/charts 1.23.0 → 1.24.1
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/components/AxisX/AxisX.d.ts +3 -3
- package/dist/cjs/components/ChartInner/index.js +95 -27
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.d.ts +3 -3
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +41 -20
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +22 -11
- package/dist/cjs/components/ChartInner/useChartInnerState.d.ts +6 -1
- package/dist/cjs/components/ChartInner/useChartInnerState.js +17 -1
- package/dist/cjs/components/ChartInner/utils.d.ts +5 -2
- package/dist/cjs/components/ChartInner/utils.js +13 -0
- package/dist/cjs/components/RangeSlider/index.d.ts +6 -0
- package/dist/cjs/components/RangeSlider/index.js +41 -0
- package/dist/cjs/components/RangeSlider/styles.css +6 -0
- package/dist/cjs/components/RangeSlider/utils.d.ts +5 -0
- package/dist/cjs/components/RangeSlider/utils.js +18 -0
- package/dist/cjs/components/Tooltip/DefaultTooltipContent/index.js +2 -1
- package/dist/cjs/components/Tooltip/DefaultTooltipContent/utils.js +3 -2
- package/dist/cjs/components/Tooltip/index.d.ts +3 -3
- package/dist/cjs/constants/chart-types.d.ts +3 -1
- package/dist/cjs/constants/chart-types.js +2 -1
- package/dist/cjs/constants/defaults/brush.d.ts +2 -0
- package/dist/cjs/constants/defaults/brush.js +15 -0
- package/dist/cjs/constants/defaults/index.d.ts +1 -0
- package/dist/cjs/constants/defaults/index.js +1 -0
- package/dist/cjs/constants/defaults/series-options.d.ts +2 -1
- package/dist/cjs/constants/defaults/series-options.js +11 -0
- package/dist/cjs/hooks/index.d.ts +5 -0
- package/dist/cjs/hooks/index.js +5 -0
- package/dist/cjs/hooks/useAxis/index.d.ts +4 -3
- package/dist/cjs/hooks/useAxis/index.js +2 -2
- package/dist/cjs/hooks/useAxis/range-slider.d.ts +5 -0
- package/dist/cjs/hooks/useAxis/range-slider.js +16 -0
- package/dist/cjs/hooks/useAxis/types.d.ts +66 -0
- package/dist/cjs/hooks/useAxis/types.js +1 -0
- package/dist/cjs/hooks/{useChartOptions → useAxis}/utils.d.ts +1 -2
- package/dist/cjs/hooks/useAxis/utils.js +9 -0
- package/dist/{esm/hooks/useChartOptions → cjs/hooks/useAxis}/x-axis.d.ts +2 -2
- package/dist/{esm/hooks/useChartOptions → cjs/hooks/useAxis}/x-axis.js +5 -3
- package/dist/cjs/hooks/{useChartOptions → useAxis}/y-axis.d.ts +2 -2
- package/dist/cjs/hooks/{useChartOptions → useAxis}/y-axis.js +3 -3
- package/dist/cjs/hooks/useAxisScales/index.d.ts +6 -6
- package/dist/cjs/hooks/useAxisScales/index.js +107 -34
- package/dist/cjs/hooks/useAxisScales/utils.d.ts +19 -0
- package/dist/cjs/hooks/useAxisScales/utils.js +34 -0
- package/dist/cjs/hooks/useBrush/index.js +89 -27
- package/dist/cjs/hooks/useBrush/styles.css +1 -0
- package/dist/cjs/hooks/useBrush/types.d.ts +6 -6
- package/dist/cjs/hooks/useBrush/utils.d.ts +19 -0
- package/dist/cjs/hooks/useBrush/utils.js +172 -0
- package/dist/cjs/hooks/useChartDimensions/index.d.ts +4 -4
- package/dist/cjs/hooks/useChartDimensions/index.js +14 -4
- package/dist/cjs/hooks/useChartDimensions/utils.d.ts +4 -4
- package/dist/cjs/hooks/useChartOptions/index.d.ts +9 -3
- package/dist/cjs/hooks/useChartOptions/tooltip.js +1 -1
- package/dist/cjs/hooks/useChartOptions/types.d.ts +4 -64
- package/dist/cjs/hooks/useChartOptions/zoom.js +24 -21
- package/dist/cjs/hooks/useCrosshair/index.d.ts +3 -3
- package/dist/cjs/hooks/useNormalizedOriginalData/index.d.ts +1 -0
- package/dist/cjs/hooks/useNormalizedOriginalData/index.js +1 -2
- package/dist/cjs/hooks/useRangeSlider/index.d.ts +4 -0
- package/dist/cjs/hooks/useRangeSlider/index.js +130 -0
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +44 -0
- package/dist/cjs/hooks/useRangeSlider/types.js +1 -0
- package/dist/cjs/hooks/useRangeSlider/utils.d.ts +16 -0
- package/dist/cjs/hooks/useRangeSlider/utils.js +19 -0
- package/dist/cjs/hooks/useSeries/prepare-area.js +2 -1
- package/dist/cjs/hooks/useSeries/prepare-bar-x.js +8 -8
- package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +1 -0
- package/dist/cjs/hooks/useSeries/prepare-bar-y.js +7 -6
- package/dist/cjs/hooks/useSeries/prepare-funnel.d.ts +10 -0
- package/dist/cjs/hooks/useSeries/prepare-funnel.js +50 -0
- package/dist/cjs/hooks/useSeries/prepare-legend.js +4 -1
- package/dist/cjs/hooks/useSeries/prepare-line.js +2 -1
- package/dist/cjs/hooks/useSeries/prepare-pie.js +3 -2
- package/dist/cjs/hooks/useSeries/prepare-scatter.js +2 -0
- package/dist/cjs/hooks/useSeries/prepareSeries.js +9 -0
- package/dist/cjs/hooks/useSeries/types.d.ts +22 -6
- package/dist/cjs/hooks/useShapes/area/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/area/index.js +2 -2
- package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +5 -3
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +158 -157
- package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/bar-x/index.js +2 -2
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.d.ts +5 -3
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +102 -82
- package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/bar-y/index.js +2 -2
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +2 -3
- package/dist/cjs/hooks/useShapes/funnel/index.d.ts +13 -0
- package/dist/cjs/hooks/useShapes/funnel/index.js +95 -0
- package/dist/cjs/hooks/useShapes/funnel/prepare-data.d.ts +9 -0
- package/dist/cjs/hooks/useShapes/funnel/prepare-data.js +120 -0
- package/dist/cjs/hooks/useShapes/funnel/types.d.ts +32 -0
- package/dist/cjs/hooks/useShapes/funnel/types.js +1 -0
- package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/heatmap/index.js +2 -2
- package/dist/cjs/hooks/useShapes/heatmap/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/index.d.ts +15 -10
- package/dist/cjs/hooks/useShapes/index.js +49 -25
- package/dist/cjs/hooks/useShapes/line/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/line/index.js +2 -2
- package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +23 -34
- package/dist/cjs/hooks/useShapes/pie/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/pie/index.js +2 -2
- package/dist/cjs/hooks/useShapes/radar/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/radar/index.js +2 -2
- package/dist/cjs/hooks/useShapes/sankey/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/sankey/index.js +2 -2
- package/dist/cjs/hooks/useShapes/scatter/index.d.ts +3 -2
- package/dist/cjs/hooks/useShapes/scatter/index.js +4 -4
- package/dist/cjs/hooks/useShapes/scatter/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/styles.css +8 -8
- package/dist/cjs/hooks/useShapes/treemap/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/treemap/index.js +2 -2
- package/dist/cjs/hooks/useShapes/utils.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/waterfall/index.js +2 -2
- package/dist/cjs/hooks/useShapes/waterfall/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useZoom/index.d.ts +4 -3
- package/dist/cjs/hooks/useZoom/utils.d.ts +3 -3
- package/dist/cjs/hooks/utils/bar-x.d.ts +2 -2
- package/dist/cjs/hooks/utils/bar-y.d.ts +2 -2
- package/dist/cjs/types/chart/area.d.ts +7 -2
- package/dist/cjs/types/chart/axis.d.ts +45 -0
- package/dist/cjs/types/chart/bar-x.d.ts +7 -3
- package/dist/cjs/types/chart/bar-y.d.ts +2 -2
- package/dist/cjs/types/chart/base.d.ts +26 -25
- package/dist/cjs/types/chart/brush.d.ts +22 -0
- package/dist/cjs/types/chart/brush.js +1 -0
- package/dist/cjs/types/chart/funnel.d.ts +46 -0
- package/dist/cjs/types/chart/funnel.js +1 -0
- package/dist/cjs/types/chart/heatmap.d.ts +2 -2
- package/dist/cjs/types/chart/legend.d.ts +6 -0
- package/dist/cjs/types/chart/line.d.ts +7 -2
- package/dist/cjs/types/chart/pie.d.ts +2 -2
- package/dist/cjs/types/chart/radar.d.ts +2 -2
- package/dist/cjs/types/chart/sankey.d.ts +2 -2
- package/dist/cjs/types/chart/scatter.d.ts +7 -2
- package/dist/cjs/types/chart/series.d.ts +17 -2
- package/dist/cjs/types/chart/tooltip.d.ts +10 -2
- package/dist/cjs/types/chart/treemap.d.ts +2 -2
- package/dist/cjs/types/chart/waterfall.d.ts +2 -2
- package/dist/cjs/types/chart/zoom.d.ts +2 -5
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/cjs/types/index.js +2 -0
- package/dist/cjs/types/misc.d.ts +6 -0
- package/dist/cjs/utils/chart/axis.d.ts +5 -2
- package/dist/cjs/utils/chart/axis.js +47 -1
- package/dist/cjs/utils/chart/color.js +2 -1
- package/dist/cjs/utils/chart/get-closest-data.js +18 -1
- package/dist/cjs/utils/chart/index.js +4 -4
- package/dist/cjs/utils/chart/series/sorting.js +3 -3
- package/dist/cjs/utils/chart/zoom.d.ts +3 -3
- package/dist/cjs/utils/chart/zoom.js +2 -2
- package/dist/cjs/validation/index.js +3 -3
- package/dist/esm/components/AxisX/AxisX.d.ts +3 -3
- package/dist/esm/components/ChartInner/index.js +95 -27
- package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +3 -3
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +41 -20
- package/dist/esm/components/ChartInner/useChartInnerProps.js +22 -11
- package/dist/esm/components/ChartInner/useChartInnerState.d.ts +6 -1
- package/dist/esm/components/ChartInner/useChartInnerState.js +17 -1
- package/dist/esm/components/ChartInner/utils.d.ts +5 -2
- package/dist/esm/components/ChartInner/utils.js +13 -0
- package/dist/esm/components/RangeSlider/index.d.ts +6 -0
- package/dist/esm/components/RangeSlider/index.js +41 -0
- package/dist/esm/components/RangeSlider/styles.css +6 -0
- package/dist/esm/components/RangeSlider/utils.d.ts +5 -0
- package/dist/esm/components/RangeSlider/utils.js +18 -0
- package/dist/esm/components/Tooltip/DefaultTooltipContent/index.js +2 -1
- package/dist/esm/components/Tooltip/DefaultTooltipContent/utils.js +3 -2
- package/dist/esm/components/Tooltip/index.d.ts +3 -3
- package/dist/esm/constants/chart-types.d.ts +3 -1
- package/dist/esm/constants/chart-types.js +2 -1
- package/dist/esm/constants/defaults/brush.d.ts +2 -0
- package/dist/esm/constants/defaults/brush.js +15 -0
- package/dist/esm/constants/defaults/index.d.ts +1 -0
- package/dist/esm/constants/defaults/index.js +1 -0
- package/dist/esm/constants/defaults/series-options.d.ts +2 -1
- package/dist/esm/constants/defaults/series-options.js +11 -0
- package/dist/esm/hooks/index.d.ts +5 -0
- package/dist/esm/hooks/index.js +5 -0
- package/dist/esm/hooks/useAxis/index.d.ts +4 -3
- package/dist/esm/hooks/useAxis/index.js +2 -2
- package/dist/esm/hooks/useAxis/range-slider.d.ts +5 -0
- package/dist/esm/hooks/useAxis/range-slider.js +16 -0
- package/dist/esm/hooks/useAxis/types.d.ts +66 -0
- package/dist/esm/hooks/useAxis/types.js +1 -0
- package/dist/esm/hooks/{useChartOptions → useAxis}/utils.d.ts +1 -2
- package/dist/esm/hooks/useAxis/utils.js +9 -0
- package/dist/{cjs/hooks/useChartOptions → esm/hooks/useAxis}/x-axis.d.ts +2 -2
- package/dist/{cjs/hooks/useChartOptions → esm/hooks/useAxis}/x-axis.js +5 -3
- package/dist/esm/hooks/{useChartOptions → useAxis}/y-axis.d.ts +2 -2
- package/dist/esm/hooks/{useChartOptions → useAxis}/y-axis.js +3 -3
- package/dist/esm/hooks/useAxisScales/index.d.ts +6 -6
- package/dist/esm/hooks/useAxisScales/index.js +107 -34
- package/dist/esm/hooks/useAxisScales/utils.d.ts +19 -0
- package/dist/esm/hooks/useAxisScales/utils.js +34 -0
- package/dist/esm/hooks/useBrush/index.js +89 -27
- package/dist/esm/hooks/useBrush/styles.css +1 -0
- package/dist/esm/hooks/useBrush/types.d.ts +6 -6
- package/dist/esm/hooks/useBrush/utils.d.ts +19 -0
- package/dist/esm/hooks/useBrush/utils.js +172 -0
- package/dist/esm/hooks/useChartDimensions/index.d.ts +4 -4
- package/dist/esm/hooks/useChartDimensions/index.js +14 -4
- package/dist/esm/hooks/useChartDimensions/utils.d.ts +4 -4
- package/dist/esm/hooks/useChartOptions/index.d.ts +9 -3
- package/dist/esm/hooks/useChartOptions/tooltip.js +1 -1
- package/dist/esm/hooks/useChartOptions/types.d.ts +4 -64
- package/dist/esm/hooks/useChartOptions/zoom.js +24 -21
- package/dist/esm/hooks/useCrosshair/index.d.ts +3 -3
- package/dist/esm/hooks/useNormalizedOriginalData/index.d.ts +1 -0
- package/dist/esm/hooks/useNormalizedOriginalData/index.js +1 -2
- package/dist/esm/hooks/useRangeSlider/index.d.ts +4 -0
- package/dist/esm/hooks/useRangeSlider/index.js +130 -0
- package/dist/esm/hooks/useRangeSlider/types.d.ts +44 -0
- package/dist/esm/hooks/useRangeSlider/types.js +1 -0
- package/dist/esm/hooks/useRangeSlider/utils.d.ts +16 -0
- package/dist/esm/hooks/useRangeSlider/utils.js +19 -0
- package/dist/esm/hooks/useSeries/prepare-area.js +2 -1
- package/dist/esm/hooks/useSeries/prepare-bar-x.js +8 -8
- package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +1 -0
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +7 -6
- package/dist/esm/hooks/useSeries/prepare-funnel.d.ts +10 -0
- package/dist/esm/hooks/useSeries/prepare-funnel.js +50 -0
- package/dist/esm/hooks/useSeries/prepare-legend.js +4 -1
- package/dist/esm/hooks/useSeries/prepare-line.js +2 -1
- package/dist/esm/hooks/useSeries/prepare-pie.js +3 -2
- package/dist/esm/hooks/useSeries/prepare-scatter.js +2 -0
- package/dist/esm/hooks/useSeries/prepareSeries.js +9 -0
- package/dist/esm/hooks/useSeries/types.d.ts +22 -6
- package/dist/esm/hooks/useShapes/area/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/area/index.js +2 -2
- package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +5 -3
- package/dist/esm/hooks/useShapes/area/prepare-data.js +158 -157
- package/dist/esm/hooks/useShapes/bar-x/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/bar-x/index.js +2 -2
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.d.ts +5 -3
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +102 -82
- package/dist/esm/hooks/useShapes/bar-y/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/bar-y/index.js +2 -2
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +2 -3
- package/dist/esm/hooks/useShapes/funnel/index.d.ts +13 -0
- package/dist/esm/hooks/useShapes/funnel/index.js +95 -0
- package/dist/esm/hooks/useShapes/funnel/prepare-data.d.ts +9 -0
- package/dist/esm/hooks/useShapes/funnel/prepare-data.js +120 -0
- package/dist/esm/hooks/useShapes/funnel/types.d.ts +32 -0
- package/dist/esm/hooks/useShapes/funnel/types.js +1 -0
- package/dist/esm/hooks/useShapes/heatmap/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/heatmap/index.js +2 -2
- package/dist/esm/hooks/useShapes/heatmap/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useShapes/index.d.ts +15 -10
- package/dist/esm/hooks/useShapes/index.js +49 -25
- package/dist/esm/hooks/useShapes/line/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/line/index.js +2 -2
- package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useShapes/line/prepare-data.js +23 -34
- package/dist/esm/hooks/useShapes/pie/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/pie/index.js +2 -2
- package/dist/esm/hooks/useShapes/radar/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/radar/index.js +2 -2
- package/dist/esm/hooks/useShapes/sankey/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/sankey/index.js +2 -2
- package/dist/esm/hooks/useShapes/scatter/index.d.ts +3 -2
- package/dist/esm/hooks/useShapes/scatter/index.js +4 -4
- package/dist/esm/hooks/useShapes/scatter/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useShapes/styles.css +8 -8
- package/dist/esm/hooks/useShapes/treemap/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/treemap/index.js +2 -2
- package/dist/esm/hooks/useShapes/utils.d.ts +3 -3
- package/dist/esm/hooks/useShapes/waterfall/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/waterfall/index.js +2 -2
- package/dist/esm/hooks/useShapes/waterfall/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useZoom/index.d.ts +4 -3
- package/dist/esm/hooks/useZoom/utils.d.ts +3 -3
- package/dist/esm/hooks/utils/bar-x.d.ts +2 -2
- package/dist/esm/hooks/utils/bar-y.d.ts +2 -2
- package/dist/esm/types/chart/area.d.ts +7 -2
- package/dist/esm/types/chart/axis.d.ts +45 -0
- package/dist/esm/types/chart/bar-x.d.ts +7 -3
- package/dist/esm/types/chart/bar-y.d.ts +2 -2
- package/dist/esm/types/chart/base.d.ts +26 -25
- package/dist/esm/types/chart/brush.d.ts +22 -0
- package/dist/esm/types/chart/brush.js +1 -0
- package/dist/esm/types/chart/funnel.d.ts +46 -0
- package/dist/esm/types/chart/funnel.js +1 -0
- package/dist/esm/types/chart/heatmap.d.ts +2 -2
- package/dist/esm/types/chart/legend.d.ts +6 -0
- package/dist/esm/types/chart/line.d.ts +7 -2
- package/dist/esm/types/chart/pie.d.ts +2 -2
- package/dist/esm/types/chart/radar.d.ts +2 -2
- package/dist/esm/types/chart/sankey.d.ts +2 -2
- package/dist/esm/types/chart/scatter.d.ts +7 -2
- package/dist/esm/types/chart/series.d.ts +17 -2
- package/dist/esm/types/chart/tooltip.d.ts +10 -2
- package/dist/esm/types/chart/treemap.d.ts +2 -2
- package/dist/esm/types/chart/waterfall.d.ts +2 -2
- package/dist/esm/types/chart/zoom.d.ts +2 -5
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/index.js +2 -0
- package/dist/esm/types/misc.d.ts +6 -0
- package/dist/esm/utils/chart/axis.d.ts +5 -2
- package/dist/esm/utils/chart/axis.js +47 -1
- package/dist/esm/utils/chart/color.js +2 -1
- package/dist/esm/utils/chart/get-closest-data.js +18 -1
- package/dist/esm/utils/chart/index.js +4 -4
- package/dist/esm/utils/chart/series/sorting.js +3 -3
- package/dist/esm/utils/chart/zoom.d.ts +3 -3
- package/dist/esm/utils/chart/zoom.js +2 -2
- package/dist/esm/validation/index.js +3 -3
- package/package.json +1 -1
- package/dist/cjs/hooks/useChartOptions/utils.js +0 -49
- package/dist/esm/hooks/useChartOptions/utils.js +0 -49
|
@@ -3,7 +3,6 @@ import get from 'lodash/get';
|
|
|
3
3
|
import { filterOverlappingLabels, getHtmlLabelConstraintedPosition, getLabelsSize, getSvgLabelConstraintedPosition, getTextSizeFn, } from '../../../utils';
|
|
4
4
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
5
5
|
import { getBarYLayout, groupBarYDataByYValue } from '../../utils';
|
|
6
|
-
const DEFAULT_LABEL_PADDING = 7;
|
|
7
6
|
export async function prepareBarYData(args) {
|
|
8
7
|
var _a;
|
|
9
8
|
const { boundsHeight, boundsWidth, series, seriesOptions, yAxis, xScale, yScale: [yScale], } = args;
|
|
@@ -145,7 +144,7 @@ export async function prepareBarYData(args) {
|
|
|
145
144
|
});
|
|
146
145
|
const x = dataLabels.inside
|
|
147
146
|
? prepared.x + prepared.width / 2 - width / 2
|
|
148
|
-
: prepared.x + prepared.width +
|
|
147
|
+
: prepared.x + prepared.width + dataLabels.padding;
|
|
149
148
|
const constrainedPosition = getHtmlLabelConstraintedPosition({
|
|
150
149
|
boundsHeight,
|
|
151
150
|
boundsWidth,
|
|
@@ -170,7 +169,7 @@ export async function prepareBarYData(args) {
|
|
|
170
169
|
const { width, height } = await getTextSize(content);
|
|
171
170
|
const x = dataLabels.inside
|
|
172
171
|
? prepared.x + prepared.width / 2 - width / 2
|
|
173
|
-
: prepared.x + prepared.width +
|
|
172
|
+
: prepared.x + prepared.width + dataLabels.padding;
|
|
174
173
|
const constrainedPosition = getSvgLabelConstraintedPosition({
|
|
175
174
|
boundsHeight,
|
|
176
175
|
boundsWidth,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Dispatch } from 'd3';
|
|
3
|
+
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
|
+
import type { PreparedFunnelData } from './types';
|
|
5
|
+
export { prepareFunnelData } from './prepare-data';
|
|
6
|
+
export * from './types';
|
|
7
|
+
type Args = {
|
|
8
|
+
dispatcher?: Dispatch<object>;
|
|
9
|
+
preparedData: PreparedFunnelData;
|
|
10
|
+
seriesOptions: PreparedSeriesOptions;
|
|
11
|
+
htmlLayout: HTMLElement | null;
|
|
12
|
+
};
|
|
13
|
+
export declare const FunnelSeriesShapes: (args: Args) => React.JSX.Element;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { color, select } from 'd3';
|
|
3
|
+
import { block, getLineDashArray } from '../../../utils';
|
|
4
|
+
export { prepareFunnelData } from './prepare-data';
|
|
5
|
+
export * from './types';
|
|
6
|
+
const b = block('funnel');
|
|
7
|
+
export const FunnelSeriesShapes = (args) => {
|
|
8
|
+
const { dispatcher, preparedData, seriesOptions } = args;
|
|
9
|
+
const hoveredDataRef = React.useRef(null);
|
|
10
|
+
const ref = React.useRef(null);
|
|
11
|
+
React.useEffect(() => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
if (!ref.current) {
|
|
14
|
+
return () => { };
|
|
15
|
+
}
|
|
16
|
+
const svgElement = select(ref.current);
|
|
17
|
+
const hoverOptions = (_b = (_a = seriesOptions.funnel) === null || _a === void 0 ? void 0 : _a.states) === null || _b === void 0 ? void 0 : _b.hover;
|
|
18
|
+
svgElement.selectAll('*').remove();
|
|
19
|
+
// funnel levels
|
|
20
|
+
const cellsSelection = svgElement
|
|
21
|
+
.selectAll('rect')
|
|
22
|
+
.data(preparedData.items)
|
|
23
|
+
.join('rect')
|
|
24
|
+
.attr('x', (d) => d.x)
|
|
25
|
+
.attr('y', (d) => d.y)
|
|
26
|
+
.attr('height', (d) => d.height)
|
|
27
|
+
.attr('width', (d) => d.width)
|
|
28
|
+
.attr('fill', (d) => d.color)
|
|
29
|
+
.attr('stroke', (d) => d.borderColor)
|
|
30
|
+
.attr('stroke-width', (d) => d.borderWidth);
|
|
31
|
+
// connectors
|
|
32
|
+
const connectorAreaClassName = b('connector-area');
|
|
33
|
+
svgElement
|
|
34
|
+
.selectAll(`.${connectorAreaClassName}`)
|
|
35
|
+
.data(preparedData.connectors)
|
|
36
|
+
.join('path')
|
|
37
|
+
.attr('d', (d) => d.areaPath.toString())
|
|
38
|
+
.attr('class', connectorAreaClassName)
|
|
39
|
+
.attr('fill', (d) => d.areaColor)
|
|
40
|
+
.attr('opacity', (d) => d.areaOpacity);
|
|
41
|
+
const connectorLineClassName = b('connector-line');
|
|
42
|
+
const connectorLines = svgElement
|
|
43
|
+
.selectAll(`.${connectorLineClassName}`)
|
|
44
|
+
.data(preparedData.connectors)
|
|
45
|
+
.join('g')
|
|
46
|
+
.attr('class', connectorLineClassName)
|
|
47
|
+
.attr('stroke', (d) => d.lineColor)
|
|
48
|
+
.attr('stroke-width', (d) => d.lineWidth)
|
|
49
|
+
.attr('stroke-dasharray', (d) => getLineDashArray(d.dashStyle, d.lineWidth))
|
|
50
|
+
.attr('fill', 'none')
|
|
51
|
+
.attr('opacity', (d) => d.lineOpacity);
|
|
52
|
+
connectorLines.append('path').attr('d', (d) => d.linePath[0].toString());
|
|
53
|
+
connectorLines.append('path').attr('d', (d) => d.linePath[1].toString());
|
|
54
|
+
// dataLabels
|
|
55
|
+
svgElement
|
|
56
|
+
.selectAll('text')
|
|
57
|
+
.data(preparedData.svgLabels)
|
|
58
|
+
.join('text')
|
|
59
|
+
.text((d) => d.text)
|
|
60
|
+
.attr('class', b('label'))
|
|
61
|
+
.attr('x', (d) => d.x)
|
|
62
|
+
.attr('y', (d) => d.y)
|
|
63
|
+
.style('font-size', (d) => d.style.fontSize)
|
|
64
|
+
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
65
|
+
.style('fill', (d) => d.style.fontColor || null);
|
|
66
|
+
function handleShapeHover(data) {
|
|
67
|
+
hoveredDataRef.current = data;
|
|
68
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
69
|
+
if (hoverEnabled) {
|
|
70
|
+
const hovered = data === null || data === void 0 ? void 0 : data.reduce((acc, d) => {
|
|
71
|
+
acc.add(d.data);
|
|
72
|
+
return acc;
|
|
73
|
+
}, new Set());
|
|
74
|
+
cellsSelection.attr('fill', (d) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const fillColor = d.color;
|
|
77
|
+
if (hovered === null || hovered === void 0 ? void 0 : hovered.has(d.data)) {
|
|
78
|
+
return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) ||
|
|
79
|
+
fillColor);
|
|
80
|
+
}
|
|
81
|
+
return fillColor;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (hoveredDataRef.current !== null) {
|
|
86
|
+
handleShapeHover(hoveredDataRef.current);
|
|
87
|
+
}
|
|
88
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.funnel', handleShapeHover);
|
|
89
|
+
return () => {
|
|
90
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.funnel', null);
|
|
91
|
+
};
|
|
92
|
+
}, [dispatcher, preparedData, seriesOptions]);
|
|
93
|
+
return (React.createElement(React.Fragment, null,
|
|
94
|
+
React.createElement("g", { ref: ref, className: b() })));
|
|
95
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { PreparedFunnelSeries } from '../../useSeries/types';
|
|
2
|
+
import type { PreparedFunnelData } from './types';
|
|
3
|
+
type Args = {
|
|
4
|
+
series: PreparedFunnelSeries[];
|
|
5
|
+
boundsWidth: number;
|
|
6
|
+
boundsHeight: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function prepareFunnelData(args: Args): Promise<PreparedFunnelData>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { path } from 'd3';
|
|
2
|
+
import { calculateNumericProperty, getFormattedValue, getTextSizeFn } from '../../../utils';
|
|
3
|
+
function getLineConnectorPaths(args) {
|
|
4
|
+
const { points } = args;
|
|
5
|
+
const leftPath = path();
|
|
6
|
+
leftPath.moveTo(...points[0]);
|
|
7
|
+
leftPath.lineTo(...points[3]);
|
|
8
|
+
const rightPath = path();
|
|
9
|
+
rightPath.moveTo(...points[1]);
|
|
10
|
+
rightPath.lineTo(...points[2]);
|
|
11
|
+
return [leftPath, rightPath];
|
|
12
|
+
}
|
|
13
|
+
function getAreaConnectorPath(args) {
|
|
14
|
+
const { points } = args;
|
|
15
|
+
const p = path();
|
|
16
|
+
p.moveTo(...points[points.length - 1]);
|
|
17
|
+
points.forEach((point) => p.lineTo(...point));
|
|
18
|
+
p.closePath();
|
|
19
|
+
return p;
|
|
20
|
+
}
|
|
21
|
+
export async function prepareFunnelData(args) {
|
|
22
|
+
var _a, _b, _c, _d;
|
|
23
|
+
const { series, boundsWidth, boundsHeight } = args;
|
|
24
|
+
const items = [];
|
|
25
|
+
const svgLabels = [];
|
|
26
|
+
const connectors = [];
|
|
27
|
+
const maxValue = Math.max(...series.map((s) => s.data.value));
|
|
28
|
+
const itemBandSpace = boundsHeight / series.length;
|
|
29
|
+
const connectorHeight = (_b = calculateNumericProperty({
|
|
30
|
+
value: (_a = series[0].connectors) === null || _a === void 0 ? void 0 : _a.height,
|
|
31
|
+
base: itemBandSpace,
|
|
32
|
+
})) !== null && _b !== void 0 ? _b : 0;
|
|
33
|
+
const itemHeight = (boundsHeight - connectorHeight * (series.length - 1)) / series.length;
|
|
34
|
+
const getTextSize = getTextSizeFn({ style: series[0].dataLabels.style });
|
|
35
|
+
const getSegmentY = (index) => {
|
|
36
|
+
return index * (itemHeight + connectorHeight);
|
|
37
|
+
};
|
|
38
|
+
let segmentLeftOffset = 0;
|
|
39
|
+
let segmentRightOffset = 0;
|
|
40
|
+
for (let index = 0; index < series.length; index++) {
|
|
41
|
+
const s = series[index];
|
|
42
|
+
if (s.dataLabels.enabled) {
|
|
43
|
+
const d = s.data;
|
|
44
|
+
const labelContent = (_c = d.label) !== null && _c !== void 0 ? _c : getFormattedValue({ value: d.value, format: s.dataLabels.format });
|
|
45
|
+
const labelSize = await getTextSize(labelContent);
|
|
46
|
+
let x;
|
|
47
|
+
switch (s.dataLabels.align) {
|
|
48
|
+
case 'left': {
|
|
49
|
+
x = 0;
|
|
50
|
+
segmentLeftOffset = Math.max(segmentLeftOffset, labelSize.width);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case 'right': {
|
|
54
|
+
x = boundsWidth - labelSize.width;
|
|
55
|
+
segmentRightOffset = Math.max(segmentRightOffset, labelSize.width);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case 'center': {
|
|
59
|
+
x = boundsWidth / 2 - labelSize.width / 2;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
svgLabels.push({
|
|
64
|
+
x,
|
|
65
|
+
y: getSegmentY(index) + itemHeight / 2 - labelSize.height / 2,
|
|
66
|
+
text: labelContent,
|
|
67
|
+
style: s.dataLabels.style,
|
|
68
|
+
size: labelSize,
|
|
69
|
+
textAnchor: 'start',
|
|
70
|
+
series: s,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const segmentMaxWidth = boundsWidth - segmentLeftOffset - segmentRightOffset;
|
|
75
|
+
for (let index = 0; index < series.length; index++) {
|
|
76
|
+
const s = series[index];
|
|
77
|
+
const d = s.data;
|
|
78
|
+
const itemWidth = (segmentMaxWidth * d.value) / maxValue;
|
|
79
|
+
const funnelSegment = {
|
|
80
|
+
x: segmentLeftOffset + segmentMaxWidth / 2 - itemWidth / 2,
|
|
81
|
+
y: getSegmentY(index),
|
|
82
|
+
width: itemWidth,
|
|
83
|
+
height: itemHeight,
|
|
84
|
+
color: s.color,
|
|
85
|
+
series: s,
|
|
86
|
+
data: d,
|
|
87
|
+
borderColor: '',
|
|
88
|
+
borderWidth: 0,
|
|
89
|
+
cursor: s.cursor,
|
|
90
|
+
};
|
|
91
|
+
items.push(funnelSegment);
|
|
92
|
+
const prevSeries = series[index - 1];
|
|
93
|
+
const prevItem = items[index - 1];
|
|
94
|
+
if (prevSeries && prevItem && ((_d = prevSeries.connectors) === null || _d === void 0 ? void 0 : _d.enabled)) {
|
|
95
|
+
const connectorPoints = [
|
|
96
|
+
[prevItem.x, prevItem.y + prevItem.height],
|
|
97
|
+
[prevItem.x + prevItem.width, prevItem.y + prevItem.height],
|
|
98
|
+
[funnelSegment.x + funnelSegment.width, funnelSegment.y],
|
|
99
|
+
[funnelSegment.x, funnelSegment.y],
|
|
100
|
+
];
|
|
101
|
+
connectors.push({
|
|
102
|
+
linePath: getLineConnectorPaths({ points: connectorPoints }),
|
|
103
|
+
areaPath: getAreaConnectorPath({ points: connectorPoints }),
|
|
104
|
+
lineWidth: prevSeries.connectors.lineWidth,
|
|
105
|
+
lineColor: prevSeries.connectors.lineColor,
|
|
106
|
+
lineOpacity: prevSeries.connectors.lineOpacity,
|
|
107
|
+
areaColor: prevSeries.connectors.areaColor,
|
|
108
|
+
areaOpacity: prevSeries.connectors.areaOpacity,
|
|
109
|
+
dashStyle: prevSeries.connectors.lineDashStyle,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const data = {
|
|
114
|
+
type: 'funnel',
|
|
115
|
+
items,
|
|
116
|
+
svgLabels,
|
|
117
|
+
connectors,
|
|
118
|
+
};
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Path } from 'd3';
|
|
2
|
+
import type { DashStyle } from 'src/constants';
|
|
3
|
+
import type { FunnelSeriesData, LabelData } from '../../../types';
|
|
4
|
+
import type { PreparedFunnelSeries } from '../../useSeries/types';
|
|
5
|
+
export type FunnelItemData = {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
color: string;
|
|
11
|
+
series: PreparedFunnelSeries;
|
|
12
|
+
data: FunnelSeriesData;
|
|
13
|
+
borderColor: string;
|
|
14
|
+
borderWidth: number;
|
|
15
|
+
cursor: string | null;
|
|
16
|
+
};
|
|
17
|
+
export type FunnelConnectorData = {
|
|
18
|
+
linePath: Path[];
|
|
19
|
+
areaPath: Path;
|
|
20
|
+
lineWidth: number;
|
|
21
|
+
lineColor: string;
|
|
22
|
+
lineOpacity: number;
|
|
23
|
+
areaColor: string;
|
|
24
|
+
areaOpacity: number;
|
|
25
|
+
dashStyle: DashStyle;
|
|
26
|
+
};
|
|
27
|
+
export type PreparedFunnelData = {
|
|
28
|
+
type: 'funnel';
|
|
29
|
+
items: FunnelItemData[];
|
|
30
|
+
connectors: FunnelConnectorData[];
|
|
31
|
+
svgLabels: LabelData[];
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,9 +5,9 @@ import type { PreparedHeatmapData } from './types';
|
|
|
5
5
|
export { prepareHeatmapData } from './prepare-data';
|
|
6
6
|
export * from './types';
|
|
7
7
|
type Args = {
|
|
8
|
-
|
|
8
|
+
htmlLayout: HTMLElement | null;
|
|
9
9
|
preparedData: PreparedHeatmapData;
|
|
10
10
|
seriesOptions: PreparedSeriesOptions;
|
|
11
|
-
|
|
11
|
+
dispatcher?: Dispatch<object>;
|
|
12
12
|
};
|
|
13
13
|
export declare const HeatmapSeriesShapes: (args: Args) => React.JSX.Element;
|
|
@@ -63,9 +63,9 @@ export const HeatmapSeriesShapes = (args) => {
|
|
|
63
63
|
if (hoveredDataRef.current !== null) {
|
|
64
64
|
handleShapeHover(hoveredDataRef.current);
|
|
65
65
|
}
|
|
66
|
-
dispatcher.on('hover-shape.heatmap', handleShapeHover);
|
|
66
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.heatmap', handleShapeHover);
|
|
67
67
|
return () => {
|
|
68
|
-
dispatcher.on('hover-shape.heatmap', null);
|
|
68
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.heatmap', null);
|
|
69
69
|
};
|
|
70
70
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
71
71
|
return (React.createElement(React.Fragment, null,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../../hooks/useAxis/types';
|
|
1
2
|
import type { ChartScale } from '../../../hooks/useAxisScales';
|
|
2
|
-
import type { PreparedAxis } from '../../../hooks/useChartOptions/types';
|
|
3
3
|
import type { PreparedHeatmapSeries } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedHeatmapData } from './types';
|
|
5
5
|
type PrepareHeatmapDataArgs = {
|
|
6
6
|
series: PreparedHeatmapSeries;
|
|
7
|
-
xAxis:
|
|
8
|
-
yAxis:
|
|
7
|
+
xAxis: PreparedXAxis;
|
|
8
|
+
yAxis: PreparedYAxis;
|
|
9
9
|
xScale: ChartScale;
|
|
10
10
|
yScale: ChartScale;
|
|
11
11
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SeriesType } from '../../constants';
|
|
4
|
+
import type { PreparedXAxis, PreparedYAxis } from '../useAxis/types';
|
|
4
5
|
import type { ChartScale } from '../useAxisScales';
|
|
5
|
-
import type {
|
|
6
|
+
import type { PreparedSeries, PreparedSeriesOptions } from '../useSeries/types';
|
|
7
|
+
import type { PreparedSplit } from '../useSplit/types';
|
|
6
8
|
import type { PreparedAreaData } from './area/types';
|
|
7
9
|
import type { PreparedBarXData } from './bar-x';
|
|
8
10
|
import type { PreparedBarYData } from './bar-y/types';
|
|
11
|
+
import type { PreparedFunnelData } from './funnel';
|
|
9
12
|
import type { PreparedHeatmapData } from './heatmap';
|
|
10
13
|
import type { PreparedLineData } from './line/types';
|
|
11
14
|
import type { PreparedPieData } from './pie/types';
|
|
@@ -16,21 +19,23 @@ export type { PreparedBarXData } from './bar-x';
|
|
|
16
19
|
export type { PreparedScatterData } from './scatter/types';
|
|
17
20
|
import type { PreparedWaterfallData } from './waterfall';
|
|
18
21
|
import './styles.css';
|
|
19
|
-
export type ShapeData = PreparedBarXData | PreparedBarYData | PreparedScatterData | PreparedLineData | PreparedPieData | PreparedAreaData | PreparedWaterfallData | PreparedSankeyData | PreparedRadarData | PreparedHeatmapData;
|
|
22
|
+
export type ShapeData = PreparedBarXData | PreparedBarYData | PreparedScatterData | PreparedLineData | PreparedPieData | PreparedAreaData | PreparedWaterfallData | PreparedSankeyData | PreparedRadarData | PreparedHeatmapData | PreparedFunnelData;
|
|
23
|
+
export type ClipPathBySeriesType = Partial<Record<SeriesType, boolean>>;
|
|
20
24
|
type Args = {
|
|
21
25
|
boundsWidth: number;
|
|
22
26
|
boundsHeight: number;
|
|
23
|
-
|
|
27
|
+
clipPathId: string;
|
|
28
|
+
htmlLayout: HTMLElement | null;
|
|
24
29
|
series: PreparedSeries[];
|
|
25
30
|
seriesOptions: PreparedSeriesOptions;
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
split: PreparedSplit;
|
|
32
|
+
xAxis: PreparedXAxis | null;
|
|
33
|
+
yAxis: PreparedYAxis[];
|
|
34
|
+
clipPathBySeriesType?: ClipPathBySeriesType;
|
|
35
|
+
dispatcher?: Dispatch<object>;
|
|
36
|
+
isOutsideBounds?: (x: number, y: number) => boolean;
|
|
28
37
|
xScale?: ChartScale;
|
|
29
38
|
yScale?: (ChartScale | undefined)[];
|
|
30
|
-
split: PreparedSplit;
|
|
31
|
-
htmlLayout: HTMLElement | null;
|
|
32
|
-
clipPathId: string;
|
|
33
|
-
isOutsideBounds: (x: number, y: number) => boolean;
|
|
34
39
|
};
|
|
35
40
|
export declare const useShapes: (args: Args) => {
|
|
36
41
|
shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { group } from 'd3';
|
|
3
|
+
import { SERIES_TYPE } from '../../constants';
|
|
3
4
|
import { ChartError } from '../../libs';
|
|
4
5
|
import { getOnlyVisibleSeries } from '../../utils';
|
|
5
6
|
import { AreaSeriesShapes } from './area';
|
|
6
7
|
import { prepareAreaData } from './area/prepare-data';
|
|
7
8
|
import { BarXSeriesShapes, prepareBarXData } from './bar-x';
|
|
8
9
|
import { BarYSeriesShapes, prepareBarYData } from './bar-y';
|
|
10
|
+
import { FunnelSeriesShapes, prepareFunnelData } from './funnel';
|
|
9
11
|
import { HeatmapSeriesShapes, prepareHeatmapData } from './heatmap';
|
|
10
12
|
import { LineSeriesShapes } from './line';
|
|
11
13
|
import { prepareLineData } from './line/prepare-data';
|
|
@@ -20,8 +22,15 @@ import { TreemapSeriesShape } from './treemap';
|
|
|
20
22
|
import { prepareTreemapData } from './treemap/prepare-data';
|
|
21
23
|
import { WaterfallSeriesShapes, prepareWaterfallData } from './waterfall';
|
|
22
24
|
import './styles.css';
|
|
25
|
+
function IS_OUTSIDE_BOUNDS() {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
function shouldUseClipPathId(seriesType, clipPathBySeriesType) {
|
|
29
|
+
var _a;
|
|
30
|
+
return (_a = clipPathBySeriesType === null || clipPathBySeriesType === void 0 ? void 0 : clipPathBySeriesType[seriesType]) !== null && _a !== void 0 ? _a : true;
|
|
31
|
+
}
|
|
23
32
|
export const useShapes = (args) => {
|
|
24
|
-
const { boundsWidth, boundsHeight,
|
|
33
|
+
const { boundsWidth, boundsHeight, clipPathId, clipPathBySeriesType, dispatcher, htmlLayout, isOutsideBounds = IS_OUTSIDE_BOUNDS, series, seriesOptions, split, xAxis, xScale, yAxis, yScale, } = args;
|
|
25
34
|
const [shapesElemens, setShapesElements] = React.useState([]);
|
|
26
35
|
const [shapesElemensData, setShapesElemensData] = React.useState([]);
|
|
27
36
|
const countedRef = React.useRef(0);
|
|
@@ -38,7 +47,7 @@ export const useShapes = (args) => {
|
|
|
38
47
|
Array.from(groupedSeries).map(async (item) => {
|
|
39
48
|
const [seriesType, chartSeries] = item;
|
|
40
49
|
switch (seriesType) {
|
|
41
|
-
case
|
|
50
|
+
case SERIES_TYPE.BarX: {
|
|
42
51
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
43
52
|
const preparedData = await prepareBarXData({
|
|
44
53
|
series: chartSeries,
|
|
@@ -48,13 +57,14 @@ export const useShapes = (args) => {
|
|
|
48
57
|
yAxis,
|
|
49
58
|
yScale,
|
|
50
59
|
boundsHeight,
|
|
60
|
+
split,
|
|
51
61
|
});
|
|
52
|
-
shapes.push(React.createElement(BarXSeriesShapes, { key:
|
|
62
|
+
shapes.push(React.createElement(BarXSeriesShapes, { key: SERIES_TYPE.BarX, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
53
63
|
shapesData.push(...preparedData);
|
|
54
64
|
}
|
|
55
65
|
break;
|
|
56
66
|
}
|
|
57
|
-
case
|
|
67
|
+
case SERIES_TYPE.BarY: {
|
|
58
68
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
59
69
|
const preparedData = await prepareBarYData({
|
|
60
70
|
boundsHeight,
|
|
@@ -66,12 +76,12 @@ export const useShapes = (args) => {
|
|
|
66
76
|
yAxis,
|
|
67
77
|
yScale,
|
|
68
78
|
});
|
|
69
|
-
shapes.push(React.createElement(BarYSeriesShapes, { key:
|
|
79
|
+
shapes.push(React.createElement(BarYSeriesShapes, { key: SERIES_TYPE.BarY, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
70
80
|
shapesData.push(...preparedData.shapes);
|
|
71
81
|
}
|
|
72
82
|
break;
|
|
73
83
|
}
|
|
74
|
-
case
|
|
84
|
+
case SERIES_TYPE.Waterfall: {
|
|
75
85
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
76
86
|
const preparedData = await prepareWaterfallData({
|
|
77
87
|
series: chartSeries,
|
|
@@ -81,12 +91,12 @@ export const useShapes = (args) => {
|
|
|
81
91
|
yAxis,
|
|
82
92
|
yScale,
|
|
83
93
|
});
|
|
84
|
-
shapes.push(React.createElement(WaterfallSeriesShapes, { key:
|
|
94
|
+
shapes.push(React.createElement(WaterfallSeriesShapes, { key: SERIES_TYPE.Waterfall, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
85
95
|
shapesData.push(...preparedData);
|
|
86
96
|
}
|
|
87
97
|
break;
|
|
88
98
|
}
|
|
89
|
-
case
|
|
99
|
+
case SERIES_TYPE.Line: {
|
|
90
100
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
91
101
|
const preparedData = await prepareLineData({
|
|
92
102
|
series: chartSeries,
|
|
@@ -97,12 +107,12 @@ export const useShapes = (args) => {
|
|
|
97
107
|
split,
|
|
98
108
|
isOutsideBounds,
|
|
99
109
|
});
|
|
100
|
-
shapes.push(React.createElement(LineSeriesShapes, { key:
|
|
110
|
+
shapes.push(React.createElement(LineSeriesShapes, { key: SERIES_TYPE.Line, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
101
111
|
shapesData.push(...preparedData);
|
|
102
112
|
}
|
|
103
113
|
break;
|
|
104
114
|
}
|
|
105
|
-
case
|
|
115
|
+
case SERIES_TYPE.Area: {
|
|
106
116
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
107
117
|
const preparedData = await prepareAreaData({
|
|
108
118
|
series: chartSeries,
|
|
@@ -111,14 +121,15 @@ export const useShapes = (args) => {
|
|
|
111
121
|
yAxis,
|
|
112
122
|
yScale,
|
|
113
123
|
boundsHeight,
|
|
124
|
+
split,
|
|
114
125
|
isOutsideBounds,
|
|
115
126
|
});
|
|
116
|
-
shapes.push(React.createElement(AreaSeriesShapes, { key:
|
|
127
|
+
shapes.push(React.createElement(AreaSeriesShapes, { key: SERIES_TYPE.Area, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
117
128
|
shapesData.push(...preparedData);
|
|
118
129
|
}
|
|
119
130
|
break;
|
|
120
131
|
}
|
|
121
|
-
case
|
|
132
|
+
case SERIES_TYPE.Scatter: {
|
|
122
133
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
123
134
|
const preparedData = prepareScatterData({
|
|
124
135
|
series: chartSeries,
|
|
@@ -128,22 +139,24 @@ export const useShapes = (args) => {
|
|
|
128
139
|
yScale,
|
|
129
140
|
isOutsideBounds,
|
|
130
141
|
});
|
|
131
|
-
shapes.push(React.createElement(ScatterSeriesShape, { key:
|
|
142
|
+
shapes.push(React.createElement(ScatterSeriesShape, { key: SERIES_TYPE.Scatter, clipPathId: shouldUseClipPathId(SERIES_TYPE.Scatter, clipPathBySeriesType)
|
|
143
|
+
? clipPathId
|
|
144
|
+
: undefined, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
132
145
|
shapesData.push(...preparedData);
|
|
133
146
|
}
|
|
134
147
|
break;
|
|
135
148
|
}
|
|
136
|
-
case
|
|
149
|
+
case SERIES_TYPE.Pie: {
|
|
137
150
|
const preparedData = await preparePieData({
|
|
138
151
|
series: chartSeries,
|
|
139
152
|
boundsWidth,
|
|
140
153
|
boundsHeight,
|
|
141
154
|
});
|
|
142
|
-
shapes.push(React.createElement(PieSeriesShapes, { key:
|
|
155
|
+
shapes.push(React.createElement(PieSeriesShapes, { key: SERIES_TYPE.Pie, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
143
156
|
shapesData.push(...preparedData);
|
|
144
157
|
break;
|
|
145
158
|
}
|
|
146
|
-
case
|
|
159
|
+
case SERIES_TYPE.Treemap: {
|
|
147
160
|
const preparedData = await prepareTreemapData({
|
|
148
161
|
// We should have exactly one series with "treemap" type
|
|
149
162
|
// Otherwise data validation should emit an error
|
|
@@ -151,31 +164,31 @@ export const useShapes = (args) => {
|
|
|
151
164
|
width: boundsWidth,
|
|
152
165
|
height: boundsHeight,
|
|
153
166
|
});
|
|
154
|
-
shapes.push(React.createElement(TreemapSeriesShape, { key:
|
|
167
|
+
shapes.push(React.createElement(TreemapSeriesShape, { key: SERIES_TYPE.Treemap, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
155
168
|
shapesData.push(preparedData);
|
|
156
169
|
break;
|
|
157
170
|
}
|
|
158
|
-
case
|
|
171
|
+
case SERIES_TYPE.Sankey: {
|
|
159
172
|
const preparedData = prepareSankeyData({
|
|
160
173
|
series: chartSeries[0],
|
|
161
174
|
width: boundsWidth,
|
|
162
175
|
height: boundsHeight,
|
|
163
176
|
});
|
|
164
|
-
shapes.push(React.createElement(SankeySeriesShape, { key:
|
|
177
|
+
shapes.push(React.createElement(SankeySeriesShape, { key: SERIES_TYPE.Sankey, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
165
178
|
shapesData.push(preparedData);
|
|
166
179
|
break;
|
|
167
180
|
}
|
|
168
|
-
case
|
|
181
|
+
case SERIES_TYPE.Radar: {
|
|
169
182
|
const preparedData = await prepareRadarData({
|
|
170
183
|
series: chartSeries,
|
|
171
184
|
boundsWidth,
|
|
172
185
|
boundsHeight,
|
|
173
186
|
});
|
|
174
|
-
shapes.push(React.createElement(RadarSeriesShapes, { key:
|
|
187
|
+
shapes.push(React.createElement(RadarSeriesShapes, { key: SERIES_TYPE.Radar, dispatcher: dispatcher, series: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
175
188
|
shapesData.push(...preparedData);
|
|
176
189
|
break;
|
|
177
190
|
}
|
|
178
|
-
case
|
|
191
|
+
case SERIES_TYPE.Heatmap: {
|
|
179
192
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale[0])) {
|
|
180
193
|
const preparedData = await prepareHeatmapData({
|
|
181
194
|
series: chartSeries[0],
|
|
@@ -184,11 +197,21 @@ export const useShapes = (args) => {
|
|
|
184
197
|
yAxis: yAxis[0],
|
|
185
198
|
yScale: yScale[0],
|
|
186
199
|
});
|
|
187
|
-
shapes.push(React.createElement(HeatmapSeriesShapes, { key:
|
|
200
|
+
shapes.push(React.createElement(HeatmapSeriesShapes, { key: SERIES_TYPE.Heatmap, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
188
201
|
shapesData.push(preparedData);
|
|
189
202
|
}
|
|
190
203
|
break;
|
|
191
204
|
}
|
|
205
|
+
case 'funnel': {
|
|
206
|
+
const preparedData = await prepareFunnelData({
|
|
207
|
+
series: chartSeries,
|
|
208
|
+
boundsWidth,
|
|
209
|
+
boundsHeight,
|
|
210
|
+
});
|
|
211
|
+
shapes.push(React.createElement(FunnelSeriesShapes, { key: "funnel", dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
212
|
+
shapesData.push(preparedData);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
192
215
|
default: {
|
|
193
216
|
throw new ChartError({
|
|
194
217
|
message: `The display method is not defined for a series with type "${seriesType}"`,
|
|
@@ -204,8 +227,11 @@ export const useShapes = (args) => {
|
|
|
204
227
|
}, [
|
|
205
228
|
boundsHeight,
|
|
206
229
|
boundsWidth,
|
|
230
|
+
clipPathId,
|
|
231
|
+
clipPathBySeriesType,
|
|
207
232
|
dispatcher,
|
|
208
233
|
htmlLayout,
|
|
234
|
+
isOutsideBounds,
|
|
209
235
|
series,
|
|
210
236
|
seriesOptions,
|
|
211
237
|
split,
|
|
@@ -213,8 +239,6 @@ export const useShapes = (args) => {
|
|
|
213
239
|
xScale,
|
|
214
240
|
yAxis,
|
|
215
241
|
yScale,
|
|
216
|
-
clipPathId,
|
|
217
|
-
isOutsideBounds,
|
|
218
242
|
]);
|
|
219
243
|
return { shapes: shapesElemens, shapesData: shapesElemensData };
|
|
220
244
|
};
|
|
@@ -3,11 +3,11 @@ import type { Dispatch } from 'd3';
|
|
|
3
3
|
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedLineData } from './types';
|
|
5
5
|
type Args = {
|
|
6
|
-
|
|
6
|
+
clipPathId: string;
|
|
7
|
+
htmlLayout: HTMLElement | null;
|
|
7
8
|
preparedData: PreparedLineData[];
|
|
8
9
|
seriesOptions: PreparedSeriesOptions;
|
|
9
|
-
|
|
10
|
-
clipPathId: string;
|
|
10
|
+
dispatcher?: Dispatch<object>;
|
|
11
11
|
};
|
|
12
12
|
export declare const LineSeriesShapes: (args: Args) => React.JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -129,9 +129,9 @@ export const LineSeriesShapes = (args) => {
|
|
|
129
129
|
if (hoveredDataRef.current !== null) {
|
|
130
130
|
handleShapeHover(hoveredDataRef.current);
|
|
131
131
|
}
|
|
132
|
-
dispatcher.on('hover-shape.line', handleShapeHover);
|
|
132
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.line', handleShapeHover);
|
|
133
133
|
return () => {
|
|
134
|
-
dispatcher.on('hover-shape.line', null);
|
|
134
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.line', null);
|
|
135
135
|
};
|
|
136
136
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
137
137
|
return (React.createElement(React.Fragment, null,
|