@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
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ChartScale,
|
|
2
|
+
import type { ChartScale, PreparedSplit, PreparedXAxis } from '../../hooks';
|
|
3
3
|
import './styles.css';
|
|
4
4
|
type Props = {
|
|
5
|
-
axis:
|
|
5
|
+
axis: PreparedXAxis;
|
|
6
6
|
boundsOffsetLeft: number;
|
|
7
7
|
boundsOffsetTop: number;
|
|
8
8
|
height: number;
|
|
@@ -15,7 +15,7 @@ type Props = {
|
|
|
15
15
|
plotAfterRef?: React.MutableRefObject<SVGGElement | null>;
|
|
16
16
|
};
|
|
17
17
|
export declare function getTitlePosition(args: {
|
|
18
|
-
axis:
|
|
18
|
+
axis: PreparedXAxis;
|
|
19
19
|
width: number;
|
|
20
20
|
rowCount: number;
|
|
21
21
|
}): {
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { duration } from '@gravity-ui/date-utils';
|
|
2
3
|
import { ArrowRotateLeft } from '@gravity-ui/icons';
|
|
3
4
|
import { Button, ButtonIcon, useUniqId } from '@gravity-ui/uikit';
|
|
4
5
|
import { useCrosshair } from '../../hooks';
|
|
6
|
+
import { getPreparedRangeSlider } from '../../hooks/useAxis/range-slider';
|
|
5
7
|
import { getPreparedTooltip } from '../../hooks/useChartOptions/tooltip';
|
|
6
|
-
import { EventType, block, getDispatcher } from '../../utils';
|
|
8
|
+
import { EventType, block, getDispatcher, isBandScale, isTimeScale } from '../../utils';
|
|
7
9
|
import { AxisX } from '../AxisX/AxisX';
|
|
8
10
|
import { AxisY } from '../AxisY/AxisY';
|
|
9
11
|
import { prepareAxisData } from '../AxisY/prepare-axis-data';
|
|
10
12
|
import { Legend } from '../Legend';
|
|
11
13
|
import { PlotTitle } from '../PlotTitle';
|
|
14
|
+
import { RangeSlider } from '../RangeSlider';
|
|
12
15
|
import { Title } from '../Title';
|
|
13
16
|
import { Tooltip } from '../Tooltip';
|
|
14
17
|
import { useChartInnerHandlers } from './useChartInnerHandlers';
|
|
15
18
|
import { useChartInnerProps } from './useChartInnerProps';
|
|
16
19
|
import { useChartInnerState } from './useChartInnerState';
|
|
17
|
-
import { getResetZoomButtonStyle, useAsyncState } from './utils';
|
|
20
|
+
import { getResetZoomButtonStyle, useAsyncState, useDebouncedValue } from './utils';
|
|
18
21
|
import './styles.css';
|
|
19
22
|
const b = block('chart');
|
|
23
|
+
const DEBOUNCED_VALUE_DELAY = 10;
|
|
20
24
|
export const ChartInner = (props) => {
|
|
21
|
-
var _a, _b, _c, _d;
|
|
25
|
+
var _a, _b, _c, _d, _e;
|
|
22
26
|
const { width, height, data } = props;
|
|
23
27
|
const svgRef = React.useRef(null);
|
|
24
28
|
const resetZoomButtonRef = React.useRef(null);
|
|
@@ -36,14 +40,30 @@ export const ChartInner = (props) => {
|
|
|
36
40
|
xAxis: data.xAxis,
|
|
37
41
|
});
|
|
38
42
|
}, [data.series.data, data.tooltip, data.yAxis, data.xAxis]);
|
|
39
|
-
const
|
|
43
|
+
const preparedRangeSlider = React.useMemo(() => {
|
|
44
|
+
return getPreparedRangeSlider({ xAxis: data.xAxis });
|
|
45
|
+
}, [data.xAxis]);
|
|
46
|
+
const { initialized, setInitialized, tooltipPinned, togglePinTooltip, unpinTooltip, rangeSliderState, updateRangeSliderState, updateZoomState, zoomState, } = useChartInnerState({
|
|
40
47
|
dispatcher,
|
|
41
48
|
tooltip: preparedTooltip,
|
|
49
|
+
preparedRangeSlider,
|
|
42
50
|
});
|
|
43
|
-
const { boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, isOutsideBounds, legendConfig, legendItems, preparedSeries,
|
|
51
|
+
const { allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, isOutsideBounds, legendConfig, legendItems, preparedChart, preparedLegend, preparedSeries, preparedSeriesOptions, preparedSplit, preparedZoom, prevHeight, prevWidth, shapes, shapesData, svgXPos, title, xAxis, xScale, yAxis, yScale, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
|
|
44
52
|
dispatcher,
|
|
45
|
-
htmlLayout, plotNode: plotRef.current, svgContainer: svgRef.current, updateZoomState,
|
|
53
|
+
htmlLayout, plotNode: plotRef.current, rangeSliderState, svgContainer: svgRef.current, updateZoomState,
|
|
46
54
|
zoomState }));
|
|
55
|
+
const debouncedBoundsWidth = useDebouncedValue({
|
|
56
|
+
value: boundsWidth,
|
|
57
|
+
delay: DEBOUNCED_VALUE_DELAY,
|
|
58
|
+
});
|
|
59
|
+
const debouncedOffsetLeft = useDebouncedValue({
|
|
60
|
+
value: boundsOffsetLeft,
|
|
61
|
+
delay: DEBOUNCED_VALUE_DELAY,
|
|
62
|
+
});
|
|
63
|
+
const debouncedAllPreparedSeries = useDebouncedValue({
|
|
64
|
+
value: allPreparedSeries,
|
|
65
|
+
delay: DEBOUNCED_VALUE_DELAY,
|
|
66
|
+
});
|
|
47
67
|
const { handleChartClick, handleMouseLeave, throttledHandleMouseMove, throttledHandleTouchMove } = useChartInnerHandlers({
|
|
48
68
|
boundsHeight,
|
|
49
69
|
boundsOffsetLeft,
|
|
@@ -116,31 +136,79 @@ export const ChartInner = (props) => {
|
|
|
116
136
|
return items;
|
|
117
137
|
}, [boundsHeight, boundsOffsetTop, boundsWidth, preparedSeries, preparedSplit, yAxis, yScale]);
|
|
118
138
|
const yAxisDataItems = useAsyncState([], setYAxisDataItems);
|
|
139
|
+
React.useEffect(() => {
|
|
140
|
+
if (!initialized && xScale) {
|
|
141
|
+
const defaultRange = preparedRangeSlider.defaultRange;
|
|
142
|
+
if (isBandScale(xScale)) {
|
|
143
|
+
setInitialized(true);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (isTimeScale(xScale)) {
|
|
147
|
+
const domain = xScale.domain();
|
|
148
|
+
const minDomainMs = domain[0].valueOf();
|
|
149
|
+
const maxDomainMs = domain[1].valueOf();
|
|
150
|
+
let minRangeMs = minDomainMs;
|
|
151
|
+
try {
|
|
152
|
+
if (defaultRange === null || defaultRange === void 0 ? void 0 : defaultRange.size) {
|
|
153
|
+
const durationMs = duration(defaultRange.size).asMilliseconds();
|
|
154
|
+
const minDefaultRangeMs = maxDomainMs - durationMs;
|
|
155
|
+
if (minDefaultRangeMs < maxDomainMs) {
|
|
156
|
+
minRangeMs = minDefaultRangeMs;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (_a) { }
|
|
161
|
+
updateRangeSliderState({ min: minRangeMs, max: maxDomainMs });
|
|
162
|
+
setInitialized(true);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const [minDomain, maxDomain] = xScale.domain();
|
|
166
|
+
let minRange = minDomain;
|
|
167
|
+
if (typeof (defaultRange === null || defaultRange === void 0 ? void 0 : defaultRange.size) === 'number') {
|
|
168
|
+
const minDefaultRange = maxDomain - defaultRange.size;
|
|
169
|
+
if (minDefaultRange < maxDomain) {
|
|
170
|
+
minRange = minDefaultRange;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
updateRangeSliderState({ min: minRange, max: maxDomain });
|
|
174
|
+
setInitialized(true);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}, [
|
|
178
|
+
initialized,
|
|
179
|
+
preparedRangeSlider.defaultRange,
|
|
180
|
+
preparedSeries,
|
|
181
|
+
setInitialized,
|
|
182
|
+
updateRangeSliderState,
|
|
183
|
+
xScale,
|
|
184
|
+
]);
|
|
185
|
+
const chartContent = (React.createElement(React.Fragment, null,
|
|
186
|
+
React.createElement("defs", null,
|
|
187
|
+
React.createElement("clipPath", { id: clipPathId },
|
|
188
|
+
React.createElement("rect", { x: 0, y: 0, width: boundsWidth, height: boundsHeight }))),
|
|
189
|
+
title && React.createElement(Title, Object.assign({}, title, { chartWidth: width })),
|
|
190
|
+
React.createElement("g", { transform: `translate(0, ${boundsOffsetTop})` }, preparedSplit.plots.map((plot, index) => {
|
|
191
|
+
return React.createElement(PlotTitle, { key: `plot-${index}`, title: plot.title });
|
|
192
|
+
})),
|
|
193
|
+
React.createElement("g", { width: boundsWidth, height: boundsHeight, transform: `translate(${[boundsOffsetLeft, boundsOffsetTop].join(',')})`, ref: plotRef },
|
|
194
|
+
xScale && xAxis && (React.createElement("g", { transform: `translate(0, ${boundsHeight})` },
|
|
195
|
+
React.createElement(AxisX, { axis: xAxis, boundsOffsetLeft: boundsOffsetLeft, boundsOffsetTop: boundsOffsetTop, height: boundsHeight, htmlLayout: htmlLayout, leftmostLimit: svgXPos, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, scale: xScale, split: preparedSplit, width: boundsWidth }))),
|
|
196
|
+
Boolean(yAxisDataItems.length) && (React.createElement(React.Fragment, null, yAxisDataItems.map((axisData, index) => {
|
|
197
|
+
if (!axisData) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
return (React.createElement(AxisY, { key: index, htmlLayout: htmlLayout, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, preparedAxisData: axisData }));
|
|
201
|
+
}))),
|
|
202
|
+
React.createElement("g", { ref: plotBeforeRef }),
|
|
203
|
+
shapes,
|
|
204
|
+
React.createElement("g", { ref: plotAfterRef })),
|
|
205
|
+
((_e = xAxis === null || xAxis === void 0 ? void 0 : xAxis.rangeSlider) === null || _e === void 0 ? void 0 : _e.enabled) && (React.createElement(RangeSlider, { boundsOffsetLeft: debouncedOffsetLeft, boundsWidth: debouncedBoundsWidth, height: height, htmlLayout: htmlLayout, onUpdate: updateRangeSliderState, preparedChart: preparedChart, preparedLegend: preparedLegend, preparedSeries: debouncedAllPreparedSeries, preparedSeriesOptions: preparedSeriesOptions, preparedRangeSlider: xAxis.rangeSlider, rangeSliderState: rangeSliderState, width: width, xAxis: data.xAxis, yAxis: data.yAxis, zoomState: zoomState })),
|
|
206
|
+
(preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && legendConfig && (React.createElement(Legend, { chartSeries: preparedSeries, legend: preparedLegend, items: legendItems, config: legendConfig, onItemClick: handleLegendItemClick, onUpdate: unpinTooltip, htmlLayout: htmlLayout }))));
|
|
119
207
|
return (React.createElement("div", { className: b() },
|
|
120
208
|
React.createElement("svg", { ref: svgRef, width: width, height: height,
|
|
121
209
|
// We use onPointerMove here because onMouseMove works incorrectly when the zoom setting is enabled:
|
|
122
210
|
// when starting to select an area, the tooltip remains in the position where the selection began
|
|
123
|
-
onPointerMove: throttledHandleMouseMove, onMouseLeave: handleMouseLeave, onTouchStart: throttledHandleTouchMove, onTouchMove: throttledHandleTouchMove, onClick: handleChartClick },
|
|
124
|
-
React.createElement("defs", null,
|
|
125
|
-
React.createElement("clipPath", { id: clipPathId },
|
|
126
|
-
React.createElement("rect", { x: 0, y: 0, width: boundsWidth, height: boundsHeight }))),
|
|
127
|
-
title && React.createElement(Title, Object.assign({}, title, { chartWidth: width })),
|
|
128
|
-
React.createElement("g", { transform: `translate(0, ${boundsOffsetTop})` }, preparedSplit.plots.map((plot, index) => {
|
|
129
|
-
return React.createElement(PlotTitle, { key: `plot-${index}`, title: plot.title });
|
|
130
|
-
})),
|
|
131
|
-
React.createElement("g", { width: boundsWidth, height: boundsHeight, transform: `translate(${[boundsOffsetLeft, boundsOffsetTop].join(',')})`, ref: plotRef },
|
|
132
|
-
xScale && xAxis && (React.createElement("g", { transform: `translate(0, ${boundsHeight})` },
|
|
133
|
-
React.createElement(AxisX, { axis: xAxis, boundsOffsetLeft: boundsOffsetLeft, boundsOffsetTop: boundsOffsetTop, height: boundsHeight, htmlLayout: htmlLayout, leftmostLimit: svgXPos, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, scale: xScale, split: preparedSplit, width: boundsWidth }))),
|
|
134
|
-
Boolean(yAxisDataItems.length) && (React.createElement(React.Fragment, null, yAxisDataItems.map((axisData, index) => {
|
|
135
|
-
if (!axisData) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
return (React.createElement(AxisY, { key: index, htmlLayout: htmlLayout, plotAfterRef: plotAfterRef, plotBeforeRef: plotBeforeRef, preparedAxisData: axisData }));
|
|
139
|
-
}))),
|
|
140
|
-
React.createElement("g", { ref: plotBeforeRef }),
|
|
141
|
-
shapes,
|
|
142
|
-
React.createElement("g", { ref: plotAfterRef })),
|
|
143
|
-
(preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && legendConfig && (React.createElement(Legend, { chartSeries: preparedSeries, legend: preparedLegend, items: legendItems, config: legendConfig, onItemClick: handleLegendItemClick, onUpdate: unpinTooltip, htmlLayout: htmlLayout }))),
|
|
211
|
+
onPointerMove: throttledHandleMouseMove, onMouseLeave: handleMouseLeave, onTouchStart: throttledHandleTouchMove, onTouchMove: throttledHandleTouchMove, onClick: handleChartClick }, initialized ? chartContent : null),
|
|
144
212
|
React.createElement("div", { className: b('html-layer'), ref: setHtmlLayout, style: {
|
|
145
213
|
'--g-html-layout-transform': `translate(${boundsOffsetLeft}px, ${boundsOffsetTop}px)`,
|
|
146
214
|
} }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PreparedXAxis, PreparedYAxis, ShapeData } from '../../hooks';
|
|
4
4
|
import type { useChartInnerState } from './useChartInnerState';
|
|
5
5
|
type ChartInnerState = ReturnType<typeof useChartInnerState>;
|
|
6
6
|
type Props = {
|
|
@@ -14,8 +14,8 @@ type Props = {
|
|
|
14
14
|
togglePinTooltip: ChartInnerState['togglePinTooltip'];
|
|
15
15
|
tooltipPinned: boolean;
|
|
16
16
|
unpinTooltip: ChartInnerState['unpinTooltip'];
|
|
17
|
-
xAxis:
|
|
18
|
-
yAxis:
|
|
17
|
+
xAxis: PreparedXAxis | null;
|
|
18
|
+
yAxis: PreparedYAxis[];
|
|
19
19
|
tooltipThrottle: number;
|
|
20
20
|
isOutsideBounds: (x: number, y: number) => boolean;
|
|
21
21
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3';
|
|
3
|
-
import type { ZoomState } from '../../hooks
|
|
3
|
+
import type { RangeSliderState, ZoomState } from '../../hooks';
|
|
4
4
|
import type { ChartInnerProps } from './types';
|
|
5
5
|
type Props = ChartInnerProps & {
|
|
6
6
|
clipPathId: string;
|
|
@@ -10,9 +10,10 @@ type Props = ChartInnerProps & {
|
|
|
10
10
|
svgContainer: SVGGElement | null;
|
|
11
11
|
updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
|
|
12
12
|
zoomState: Partial<ZoomState>;
|
|
13
|
+
rangeSliderState?: RangeSliderState;
|
|
13
14
|
};
|
|
14
15
|
export declare function useChartInnerProps(props: Props): {
|
|
15
|
-
|
|
16
|
+
allPreparedSeries: import("../../hooks").PreparedSeries[];
|
|
16
17
|
boundsHeight: number;
|
|
17
18
|
boundsOffsetLeft: number;
|
|
18
19
|
boundsOffsetTop: number;
|
|
@@ -33,35 +34,55 @@ export declare function useChartInnerProps(props: Props): {
|
|
|
33
34
|
maxWidth: number;
|
|
34
35
|
} | undefined;
|
|
35
36
|
legendItems: never[] | import("../../hooks").LegendItem[][];
|
|
37
|
+
preparedChart: import("../../hooks").PreparedChart;
|
|
36
38
|
preparedLegend: import("../../hooks").PreparedLegend | null;
|
|
37
39
|
preparedSeries: import("../../hooks").PreparedSeries[];
|
|
40
|
+
preparedSeriesOptions: import("../../constants").SeriesOptionsDefaults;
|
|
38
41
|
preparedSplit: import("../../hooks").PreparedSplit;
|
|
39
|
-
preparedZoom:
|
|
40
|
-
type?: import("../../constants").ZoomType | undefined;
|
|
41
|
-
brush?: Required<{
|
|
42
|
-
style?: Required<{
|
|
43
|
-
fillOpacity?: number | undefined;
|
|
44
|
-
} | undefined>;
|
|
45
|
-
} | undefined>;
|
|
46
|
-
resetButton?: Required<{
|
|
47
|
-
align?: ("bottom-left" | "bottom-right" | "top-left" | "top-right") | undefined;
|
|
48
|
-
offset?: Required<{
|
|
49
|
-
x?: number | undefined;
|
|
50
|
-
y?: number | undefined;
|
|
51
|
-
} | undefined>;
|
|
52
|
-
relativeTo?: ("chart-box" | "plot-box") | undefined;
|
|
53
|
-
} | undefined>;
|
|
54
|
-
}> | null;
|
|
42
|
+
preparedZoom: import("../../hooks").PreparedZoom | null;
|
|
55
43
|
prevHeight: number | undefined;
|
|
56
44
|
prevWidth: number | undefined;
|
|
57
45
|
shapes: React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
|
|
58
46
|
shapesData: import("../../hooks").ShapeData[];
|
|
47
|
+
svgXPos: number | undefined;
|
|
59
48
|
title: (import("../..").ChartTitle & {
|
|
60
49
|
height: number;
|
|
61
50
|
}) | undefined;
|
|
62
|
-
xAxis: import("../../hooks").
|
|
51
|
+
xAxis: import("../../hooks").PreparedXAxis | null;
|
|
63
52
|
xScale: import("../../hooks").ChartScale | undefined;
|
|
64
|
-
yAxis: import("
|
|
53
|
+
yAxis: (Omit<import("../..").ChartAxis, "type" | "labels" | "plotLines" | "plotBands"> & {
|
|
54
|
+
type: import("../..").ChartAxisType;
|
|
55
|
+
labels: Omit<import("../..").ChartAxisLabels, "enabled" | "style" | "padding" | "autoRotation"> & Required<Pick<import("../..").ChartAxisLabels, "enabled" | "html" | "padding" | "margin" | "rotation">> & {
|
|
56
|
+
style: import("../..").BaseTextStyle;
|
|
57
|
+
rotation: number;
|
|
58
|
+
height: number;
|
|
59
|
+
width: number;
|
|
60
|
+
lineHeight: number;
|
|
61
|
+
maxWidth: number;
|
|
62
|
+
};
|
|
63
|
+
title: {
|
|
64
|
+
height: number;
|
|
65
|
+
width: number;
|
|
66
|
+
text: string;
|
|
67
|
+
margin: number;
|
|
68
|
+
style: import("../..").BaseTextStyle;
|
|
69
|
+
align: import("../..").ChartAxisTitleAlignment;
|
|
70
|
+
maxRowCount: number;
|
|
71
|
+
};
|
|
72
|
+
min?: number;
|
|
73
|
+
grid: {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
};
|
|
76
|
+
maxPadding: number;
|
|
77
|
+
ticks: {
|
|
78
|
+
pixelInterval?: number;
|
|
79
|
+
};
|
|
80
|
+
position: "left" | "right" | "top" | "bottom";
|
|
81
|
+
plotIndex: number;
|
|
82
|
+
plotLines: import("../../hooks").PreparedAxisPlotLine[];
|
|
83
|
+
plotBands: import("../../hooks").PreparedAxisPlotBand[];
|
|
84
|
+
crosshair: Required<import("../..").AxisCrosshair>;
|
|
85
|
+
})[];
|
|
65
86
|
yScale: (import("../../hooks").ChartScale | undefined)[] | undefined;
|
|
66
87
|
};
|
|
67
88
|
export {};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { SERIES_TYPE } from '../../constants';
|
|
3
|
+
import { useAxis, useAxisScales, useChartDimensions, useChartOptions, useNormalizedOriginalData, usePrevious, useSeries, useShapes, useSplit, useZoom, } from '../../hooks';
|
|
3
4
|
import { getYAxisWidth } from '../../hooks/useChartDimensions/utils';
|
|
4
5
|
import { getLegendComponents } from '../../hooks/useSeries/prepare-legend';
|
|
5
6
|
import { getPreparedOptions } from '../../hooks/useSeries/prepare-options';
|
|
6
|
-
import { useZoom } from '../../hooks/useZoom';
|
|
7
7
|
import { getZoomedSeriesData } from '../../utils';
|
|
8
8
|
import { hasAtLeastOneSeriesDataPerPlot } from './utils';
|
|
9
|
+
const CLIP_PATH_BY_SERIES_TYPE = {
|
|
10
|
+
[SERIES_TYPE.Scatter]: false,
|
|
11
|
+
};
|
|
9
12
|
export function useChartInnerProps(props) {
|
|
10
13
|
var _a;
|
|
11
|
-
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, svgContainer, width, updateZoomState, zoomState, } = props;
|
|
14
|
+
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, rangeSliderState, svgContainer, width, updateZoomState, zoomState, } = props;
|
|
12
15
|
const prevWidth = usePrevious(width);
|
|
13
16
|
const prevHeight = usePrevious(height);
|
|
14
17
|
const { normalizedSeriesData, normalizedXAxis, normalizedYAxis } = useNormalizedOriginalData({
|
|
@@ -16,16 +19,17 @@ export function useChartInnerProps(props) {
|
|
|
16
19
|
xAxis: data.xAxis,
|
|
17
20
|
yAxis: data.yAxis,
|
|
18
21
|
});
|
|
19
|
-
const { chart,
|
|
22
|
+
const { chart, colors, title } = useChartOptions({
|
|
20
23
|
chart: data.chart,
|
|
21
24
|
colors: data.colors,
|
|
22
25
|
seriesData: normalizedSeriesData,
|
|
23
26
|
title: data.title,
|
|
27
|
+
xAxis: data.xAxis,
|
|
24
28
|
});
|
|
25
29
|
const preparedSeriesOptions = React.useMemo(() => {
|
|
26
30
|
return getPreparedOptions(data.series.options);
|
|
27
31
|
}, [data.series.options]);
|
|
28
|
-
const { preparedSeries:
|
|
32
|
+
const { preparedSeries: allPreparedSeries, preparedLegend, handleLegendItemClick, } = useSeries({
|
|
29
33
|
colors,
|
|
30
34
|
legend: data.legend,
|
|
31
35
|
originalSeriesData: normalizedSeriesData,
|
|
@@ -34,12 +38,12 @@ export function useChartInnerProps(props) {
|
|
|
34
38
|
});
|
|
35
39
|
const { preparedSeries, preparedShapesSeries } = React.useMemo(() => {
|
|
36
40
|
return getZoomedSeriesData({
|
|
37
|
-
seriesData:
|
|
41
|
+
seriesData: allPreparedSeries,
|
|
38
42
|
xAxis: normalizedXAxis,
|
|
39
43
|
yAxis: normalizedYAxis,
|
|
40
44
|
zoomState,
|
|
41
45
|
});
|
|
42
|
-
}, [
|
|
46
|
+
}, [allPreparedSeries, normalizedXAxis, normalizedYAxis, zoomState]);
|
|
43
47
|
const { legendConfig, legendItems } = React.useMemo(() => {
|
|
44
48
|
if (!preparedLegend) {
|
|
45
49
|
return { legendConfig: undefined, legendItems: [] };
|
|
@@ -75,13 +79,13 @@ export function useChartInnerProps(props) {
|
|
|
75
79
|
const { xScale, yScale } = useAxisScales({
|
|
76
80
|
boundsWidth,
|
|
77
81
|
boundsHeight,
|
|
78
|
-
|
|
79
|
-
hasZoomY: Boolean(zoomState.y),
|
|
82
|
+
rangeSliderState,
|
|
80
83
|
series: preparedSeries,
|
|
81
84
|
seriesOptions: preparedSeriesOptions,
|
|
82
85
|
split: preparedSplit,
|
|
83
86
|
xAxis,
|
|
84
87
|
yAxis,
|
|
88
|
+
zoomState,
|
|
85
89
|
});
|
|
86
90
|
const isOutsideBounds = React.useCallback((x, y) => {
|
|
87
91
|
return x < 0 || x > boundsWidth || y < 0 || y > boundsHeight;
|
|
@@ -89,6 +93,7 @@ export function useChartInnerProps(props) {
|
|
|
89
93
|
const { shapes, shapesData } = useShapes({
|
|
90
94
|
boundsWidth,
|
|
91
95
|
boundsHeight,
|
|
96
|
+
clipPathBySeriesType: CLIP_PATH_BY_SERIES_TYPE,
|
|
92
97
|
dispatcher,
|
|
93
98
|
series: preparedShapesSeries,
|
|
94
99
|
seriesOptions: preparedSeriesOptions,
|
|
@@ -125,7 +130,10 @@ export function useChartInnerProps(props) {
|
|
|
125
130
|
yAxis,
|
|
126
131
|
yScale,
|
|
127
132
|
});
|
|
128
|
-
const boundsOffsetTop = chart.margin.top
|
|
133
|
+
const boundsOffsetTop = chart.margin.top +
|
|
134
|
+
((preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && preparedLegend.position === 'top'
|
|
135
|
+
? preparedLegend.height + preparedLegend.margin
|
|
136
|
+
: 0);
|
|
129
137
|
// We need to calculate the width of each left axis because the first axis can be hidden
|
|
130
138
|
const boundsOffsetLeft = chart.margin.left +
|
|
131
139
|
yAxis.reduce((acc, axis) => {
|
|
@@ -140,7 +148,7 @@ export function useChartInnerProps(props) {
|
|
|
140
148
|
}, 0);
|
|
141
149
|
const { x } = (_a = svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) !== null && _a !== void 0 ? _a : {};
|
|
142
150
|
return {
|
|
143
|
-
|
|
151
|
+
allPreparedSeries,
|
|
144
152
|
boundsHeight,
|
|
145
153
|
boundsOffsetLeft,
|
|
146
154
|
boundsOffsetTop,
|
|
@@ -149,14 +157,17 @@ export function useChartInnerProps(props) {
|
|
|
149
157
|
isOutsideBounds,
|
|
150
158
|
legendConfig,
|
|
151
159
|
legendItems,
|
|
160
|
+
preparedChart: chart,
|
|
152
161
|
preparedLegend,
|
|
153
162
|
preparedSeries,
|
|
163
|
+
preparedSeriesOptions,
|
|
154
164
|
preparedSplit,
|
|
155
165
|
preparedZoom: chart.zoom,
|
|
156
166
|
prevHeight,
|
|
157
167
|
prevWidth,
|
|
158
168
|
shapes,
|
|
159
169
|
shapesData,
|
|
170
|
+
svgXPos: x,
|
|
160
171
|
title,
|
|
161
172
|
xAxis,
|
|
162
173
|
xScale,
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3';
|
|
3
|
-
import type { PreparedTooltip, ZoomState } from '../../hooks';
|
|
3
|
+
import type { PreparedRangeSlider, PreparedTooltip, RangeSliderState, ZoomState } from '../../hooks';
|
|
4
4
|
type Props = {
|
|
5
5
|
dispatcher: Dispatch<object>;
|
|
6
|
+
preparedRangeSlider: PreparedRangeSlider;
|
|
6
7
|
tooltip?: PreparedTooltip;
|
|
7
8
|
};
|
|
8
9
|
export declare function useChartInnerState(props: Props): {
|
|
10
|
+
initialized: boolean;
|
|
11
|
+
rangeSliderState: RangeSliderState | undefined;
|
|
12
|
+
setInitialized: React.Dispatch<React.SetStateAction<boolean>>;
|
|
9
13
|
tooltipPinned: boolean;
|
|
10
14
|
togglePinTooltip: ((value: boolean, event: React.MouseEvent) => void) | undefined;
|
|
11
15
|
unpinTooltip: (() => void) | undefined;
|
|
16
|
+
updateRangeSliderState: (nextRangeSliderState?: RangeSliderState) => void;
|
|
12
17
|
updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
|
|
13
18
|
zoomState: Partial<ZoomState>;
|
|
14
19
|
};
|
|
@@ -3,9 +3,11 @@ import isEqual from 'lodash/isEqual';
|
|
|
3
3
|
import { EventType, isMacintosh } from '../../utils';
|
|
4
4
|
export function useChartInnerState(props) {
|
|
5
5
|
var _a, _b;
|
|
6
|
-
const { dispatcher, tooltip } = props;
|
|
6
|
+
const { dispatcher, preparedRangeSlider, tooltip } = props;
|
|
7
7
|
const [tooltipPinned, setTooltipPinned] = React.useState(false);
|
|
8
8
|
const [zoomState, setZoomState] = React.useState({});
|
|
9
|
+
const [rangeSliderState, setRangeSliderState] = React.useState();
|
|
10
|
+
const [initialized, setInitialized] = React.useState(!preparedRangeSlider.enabled);
|
|
9
11
|
const tooltipEnabled = tooltip === null || tooltip === void 0 ? void 0 : tooltip.enabled;
|
|
10
12
|
const tooltipPinEnabled = (_a = tooltip === null || tooltip === void 0 ? void 0 : tooltip.pin) === null || _a === void 0 ? void 0 : _a.enabled;
|
|
11
13
|
const modifierKey = (_b = tooltip === null || tooltip === void 0 ? void 0 : tooltip.pin) === null || _b === void 0 ? void 0 : _b.modifierKey;
|
|
@@ -33,10 +35,24 @@ export function useChartInnerState(props) {
|
|
|
33
35
|
setZoomState(nextZoomState);
|
|
34
36
|
}
|
|
35
37
|
}, [zoomState]);
|
|
38
|
+
const updateRangeSliderState = React.useCallback((nextRangeSliderState) => {
|
|
39
|
+
if (!isEqual(rangeSliderState, nextRangeSliderState)) {
|
|
40
|
+
setRangeSliderState(nextRangeSliderState
|
|
41
|
+
? {
|
|
42
|
+
max: nextRangeSliderState.max,
|
|
43
|
+
min: nextRangeSliderState.min,
|
|
44
|
+
}
|
|
45
|
+
: undefined);
|
|
46
|
+
}
|
|
47
|
+
}, [rangeSliderState]);
|
|
36
48
|
return {
|
|
49
|
+
initialized,
|
|
50
|
+
rangeSliderState,
|
|
51
|
+
setInitialized,
|
|
37
52
|
tooltipPinned,
|
|
38
53
|
togglePinTooltip: tooltipEnabled && tooltipPinEnabled ? togglePinTooltip : undefined,
|
|
39
54
|
unpinTooltip: tooltipEnabled && tooltipPinEnabled ? unpinTooltip : undefined,
|
|
55
|
+
updateRangeSliderState,
|
|
40
56
|
updateZoomState,
|
|
41
57
|
zoomState,
|
|
42
58
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { PreparedSeries } from '../../hooks';
|
|
3
|
-
import type { PreparedAxis, PreparedZoom } from '../../hooks/useChartOptions/types';
|
|
2
|
+
import type { PreparedAxis, PreparedSeries, PreparedZoom } from '../../hooks';
|
|
4
3
|
export declare function hasAtLeastOneSeriesDataPerPlot(seriesData: PreparedSeries[], yAxes?: PreparedAxis[]): boolean;
|
|
5
4
|
export declare function useAsyncState<T>(value: T, setState: () => Promise<T>): T;
|
|
6
5
|
export declare function getResetZoomButtonStyle(args: {
|
|
@@ -11,3 +10,7 @@ export declare function getResetZoomButtonStyle(args: {
|
|
|
11
10
|
node: HTMLElement | null;
|
|
12
11
|
titleHeight?: number;
|
|
13
12
|
} & PreparedZoom['resetButton']): React.CSSProperties;
|
|
13
|
+
export declare function useDebouncedValue<T>(props: {
|
|
14
|
+
value: T;
|
|
15
|
+
delay?: number;
|
|
16
|
+
}): T;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import debounce from 'lodash/debounce';
|
|
2
3
|
import isEqual from 'lodash/isEqual';
|
|
3
4
|
export function hasAtLeastOneSeriesDataPerPlot(seriesData, yAxes = []) {
|
|
4
5
|
const hasDataMap = new Map();
|
|
@@ -107,3 +108,15 @@ export function getResetZoomButtonStyle(args) {
|
|
|
107
108
|
}
|
|
108
109
|
return style;
|
|
109
110
|
}
|
|
111
|
+
export function useDebouncedValue(props) {
|
|
112
|
+
const { value: propsValue, delay = 0 } = props;
|
|
113
|
+
const [value, setValue] = React.useState(propsValue);
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
const debouncedSetValue = debounce(setValue, delay);
|
|
116
|
+
debouncedSetValue(propsValue);
|
|
117
|
+
return () => {
|
|
118
|
+
debouncedSetValue.cancel();
|
|
119
|
+
};
|
|
120
|
+
}, [propsValue, delay]);
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RangeSliderProps } from '../../hooks';
|
|
3
|
+
import './styles.css';
|
|
4
|
+
declare function RangeSliderComponent(props: RangeSliderProps): React.JSX.Element;
|
|
5
|
+
export declare const RangeSlider: React.MemoExoticComponent<typeof RangeSliderComponent>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useUniqId } from '@gravity-ui/uikit';
|
|
3
|
+
import { useBrush, useRangeSlider } from '../../hooks';
|
|
4
|
+
import { block } from '../../utils';
|
|
5
|
+
import { getFramedPath } from './utils';
|
|
6
|
+
import './styles.css';
|
|
7
|
+
const b = block('range-slider');
|
|
8
|
+
function RangeSliderComponent(props) {
|
|
9
|
+
const clipPathId = useUniqId();
|
|
10
|
+
const { brush, height, onBrushEnd, onOverlayClick, offsetLeft, offsetTop, preparedXAxis, preparedYAxis, selection, shapes, width, } = useRangeSlider(Object.assign(Object.assign({}, props), { clipPathId }));
|
|
11
|
+
const ref = React.useRef(null);
|
|
12
|
+
const areas = React.useMemo(() => {
|
|
13
|
+
if (!preparedXAxis || !(preparedYAxis === null || preparedYAxis === void 0 ? void 0 : preparedYAxis.length)) {
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
extent: [
|
|
19
|
+
[0, 0],
|
|
20
|
+
[width, height],
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
}, [height, preparedXAxis, preparedYAxis, width]);
|
|
25
|
+
useBrush({
|
|
26
|
+
areas,
|
|
27
|
+
brushOptions: brush,
|
|
28
|
+
node: ref.current,
|
|
29
|
+
onBrushEnd,
|
|
30
|
+
selection,
|
|
31
|
+
type: 'x',
|
|
32
|
+
});
|
|
33
|
+
return (React.createElement("g", { className: b(), transform: `translate(${offsetLeft}, ${offsetTop})`, width: width, height: height, ref: ref },
|
|
34
|
+
React.createElement("defs", null,
|
|
35
|
+
React.createElement("clipPath", { id: clipPathId },
|
|
36
|
+
React.createElement("rect", { x: 0, y: 0, width: width, height: height }))),
|
|
37
|
+
React.createElement("path", { d: getFramedPath({ height, strokeWidth: 1, width }), fill: "var(--g-color-line-generic)" }),
|
|
38
|
+
React.createElement("g", { className: b('shapes') }, shapes),
|
|
39
|
+
React.createElement("rect", { height: height, className: b('clickable-overlay'), onClick: onOverlayClick, width: width, x: 0, y: 0 })));
|
|
40
|
+
}
|
|
41
|
+
export const RangeSlider = React.memo(RangeSliderComponent);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { path } from 'd3';
|
|
2
|
+
export function getFramedPath(args) {
|
|
3
|
+
const { height, strokeWidth, width } = args;
|
|
4
|
+
const p = path();
|
|
5
|
+
// Outer rectangle
|
|
6
|
+
p.moveTo(0, 0);
|
|
7
|
+
p.lineTo(width, 0);
|
|
8
|
+
p.lineTo(width, height);
|
|
9
|
+
p.lineTo(0, height);
|
|
10
|
+
p.closePath();
|
|
11
|
+
// Inner rectangle (cutout)
|
|
12
|
+
p.moveTo(strokeWidth, strokeWidth);
|
|
13
|
+
p.lineTo(strokeWidth, height - strokeWidth);
|
|
14
|
+
p.lineTo(width - strokeWidth, height - strokeWidth);
|
|
15
|
+
p.lineTo(width - strokeWidth, strokeWidth);
|
|
16
|
+
p.closePath();
|
|
17
|
+
return p.toString();
|
|
18
|
+
}
|
|
@@ -151,7 +151,8 @@ export const DefaultTooltipContent = ({ hovered, pinned, rowRenderer, totals, va
|
|
|
151
151
|
}
|
|
152
152
|
case 'pie':
|
|
153
153
|
case 'heatmap':
|
|
154
|
-
case 'treemap':
|
|
154
|
+
case 'treemap':
|
|
155
|
+
case 'funnel': {
|
|
155
156
|
const seriesData = data;
|
|
156
157
|
const formattedValue = getFormattedValue({
|
|
157
158
|
value: hoveredValues[i],
|
|
@@ -39,7 +39,7 @@ export function getDefaultValueFormat({ axis, closestPointsRange, }) {
|
|
|
39
39
|
}
|
|
40
40
|
export const getMeasureValue = ({ data, xAxis, yAxis, headerFormat, }) => {
|
|
41
41
|
var _a, _b, _c, _d, _e, _f;
|
|
42
|
-
if (data.every((item) => ['pie', 'treemap', 'waterfall', 'sankey', 'heatmap'].includes(item.series.type))) {
|
|
42
|
+
if (data.every((item) => ['pie', 'treemap', 'waterfall', 'sankey', 'heatmap', 'funnel'].includes(item.series.type))) {
|
|
43
43
|
return null;
|
|
44
44
|
}
|
|
45
45
|
if (data.some((item) => item.series.type === 'radar')) {
|
|
@@ -79,7 +79,8 @@ export function getHoveredValues(args) {
|
|
|
79
79
|
case 'pie':
|
|
80
80
|
case 'radar':
|
|
81
81
|
case 'heatmap':
|
|
82
|
-
case 'treemap':
|
|
82
|
+
case 'treemap':
|
|
83
|
+
case 'funnel': {
|
|
83
84
|
const seriesData = data;
|
|
84
85
|
return seriesData.value;
|
|
85
86
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Dispatch } from 'd3';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PreparedTooltip, PreparedXAxis, PreparedYAxis } from '../../hooks';
|
|
4
4
|
import './styles.css';
|
|
5
5
|
type TooltipProps = {
|
|
6
6
|
dispatcher: Dispatch<object>;
|
|
7
7
|
tooltip: PreparedTooltip;
|
|
8
8
|
svgContainer: SVGSVGElement | null;
|
|
9
|
-
xAxis:
|
|
10
|
-
yAxis:
|
|
9
|
+
xAxis: PreparedXAxis | null;
|
|
10
|
+
yAxis: PreparedYAxis;
|
|
11
11
|
tooltipPinned: boolean;
|
|
12
12
|
onOutsideClick?: () => void;
|
|
13
13
|
};
|