@gravity-ui/charts 1.22.0 → 1.24.0
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 +94 -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 +21 -9
- 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.d.ts +2 -2
- 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/constants/index.d.ts +1 -0
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/constants/zoom.d.ts +6 -0
- package/dist/cjs/constants/zoom.js +5 -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 +3 -3
- package/dist/cjs/hooks/useAxisScales/index.js +41 -15
- package/dist/cjs/hooks/useBrush/index.js +87 -24
- package/dist/cjs/hooks/useBrush/styles.css +1 -0
- package/dist/cjs/hooks/useBrush/types.d.ts +8 -7
- 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/chart.js +1 -82
- 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.d.ts +11 -0
- package/dist/cjs/hooks/useChartOptions/zoom.js +91 -0
- 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 +129 -0
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +42 -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 +17 -2
- package/dist/cjs/hooks/useSeries/prepare-bar-x.js +21 -9
- package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +3 -2
- package/dist/cjs/hooks/useSeries/prepare-bar-y.js +20 -7
- 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-heatmap.js +13 -1
- package/dist/cjs/hooks/useSeries/prepare-legend.js +5 -2
- package/dist/cjs/hooks/useSeries/prepare-line.js +17 -2
- package/dist/cjs/hooks/useSeries/prepare-pie.js +17 -3
- package/dist/cjs/hooks/useSeries/prepare-scatter.js +18 -1
- package/dist/cjs/hooks/useSeries/prepare-waterfall.js +18 -2
- 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 +4 -2
- package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +37 -22
- package/dist/cjs/hooks/useShapes/area/types.d.ts +5 -2
- 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 +3 -3
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +26 -15
- package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/bar-y/index.js +21 -24
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +26 -8
- package/dist/cjs/hooks/useShapes/bar-y/types.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/bar-y/utils.d.ts +3 -0
- package/dist/cjs/hooks/useShapes/bar-y/utils.js +44 -0
- 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/heatmap/prepare-data.js +7 -3
- package/dist/cjs/hooks/useShapes/index.d.ts +15 -10
- package/dist/cjs/hooks/useShapes/index.js +47 -25
- package/dist/cjs/hooks/useShapes/line/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/line/index.js +3 -2
- package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +58 -44
- package/dist/cjs/hooks/useShapes/line/types.d.ts +7 -3
- 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/pie/prepare-data.js +8 -4
- 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/scatter/prepare-data.js +1 -1
- package/dist/cjs/hooks/useShapes/styles.css +8 -0
- 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 +17 -9
- package/dist/cjs/hooks/useShapes/utils.js +66 -18
- 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/useShapes/waterfall/prepare-data.js +18 -8
- package/dist/cjs/hooks/useTooltip/index.js +8 -4
- package/dist/cjs/hooks/useZoom/index.d.ts +4 -3
- package/dist/cjs/hooks/useZoom/index.js +2 -0
- package/dist/cjs/hooks/useZoom/utils.d.ts +5 -4
- package/dist/cjs/hooks/useZoom/utils.js +4 -3
- package/dist/cjs/hooks/utils/bar-x.d.ts +2 -2
- package/dist/cjs/hooks/utils/bar-y.d.ts +10 -3
- package/dist/cjs/hooks/utils/bar-y.js +4 -0
- package/dist/cjs/i18n/keysets/en.json +2 -2
- package/dist/cjs/i18n/keysets/ru.json +2 -2
- package/dist/cjs/types/chart/area.d.ts +18 -3
- package/dist/cjs/types/chart/axis.d.ts +45 -0
- package/dist/cjs/types/chart/bar-x.d.ts +17 -4
- package/dist/cjs/types/chart/bar-y.d.ts +12 -3
- 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 +12 -3
- package/dist/cjs/types/chart/legend.d.ts +6 -0
- package/dist/cjs/types/chart/line.d.ts +18 -3
- package/dist/cjs/types/chart/pie.d.ts +12 -3
- 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 +18 -4
- 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 +12 -3
- package/dist/cjs/types/chart/zoom.d.ts +4 -6
- 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 +30 -8
- package/dist/cjs/utils/chart/index.js +3 -3
- package/dist/cjs/utils/chart/series/sorting.js +20 -7
- package/dist/cjs/utils/chart/zoom.d.ts +3 -3
- package/dist/cjs/utils/chart/zoom.js +6 -4
- package/dist/cjs/validation/index.js +6 -6
- package/dist/esm/components/AxisX/AxisX.d.ts +3 -3
- package/dist/esm/components/ChartInner/index.js +94 -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 +21 -9
- 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.d.ts +2 -2
- 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/constants/index.d.ts +1 -0
- package/dist/esm/constants/index.js +1 -0
- package/dist/esm/constants/zoom.d.ts +6 -0
- package/dist/esm/constants/zoom.js +5 -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 +3 -3
- package/dist/esm/hooks/useAxisScales/index.js +41 -15
- package/dist/esm/hooks/useBrush/index.js +87 -24
- package/dist/esm/hooks/useBrush/styles.css +1 -0
- package/dist/esm/hooks/useBrush/types.d.ts +8 -7
- 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/chart.js +1 -82
- 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.d.ts +11 -0
- package/dist/esm/hooks/useChartOptions/zoom.js +91 -0
- 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 +129 -0
- package/dist/esm/hooks/useRangeSlider/types.d.ts +42 -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 +17 -2
- package/dist/esm/hooks/useSeries/prepare-bar-x.js +21 -9
- package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +3 -2
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +20 -7
- 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-heatmap.js +13 -1
- package/dist/esm/hooks/useSeries/prepare-legend.js +5 -2
- package/dist/esm/hooks/useSeries/prepare-line.js +17 -2
- package/dist/esm/hooks/useSeries/prepare-pie.js +17 -3
- package/dist/esm/hooks/useSeries/prepare-scatter.js +18 -1
- package/dist/esm/hooks/useSeries/prepare-waterfall.js +18 -2
- 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 +4 -2
- package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useShapes/area/prepare-data.js +37 -22
- package/dist/esm/hooks/useShapes/area/types.d.ts +5 -2
- 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 +3 -3
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +26 -15
- package/dist/esm/hooks/useShapes/bar-y/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/bar-y/index.js +21 -24
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +26 -8
- package/dist/esm/hooks/useShapes/bar-y/types.d.ts +2 -2
- package/dist/esm/hooks/useShapes/bar-y/utils.d.ts +3 -0
- package/dist/esm/hooks/useShapes/bar-y/utils.js +44 -0
- 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/heatmap/prepare-data.js +7 -3
- package/dist/esm/hooks/useShapes/index.d.ts +15 -10
- package/dist/esm/hooks/useShapes/index.js +47 -25
- package/dist/esm/hooks/useShapes/line/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/line/index.js +3 -2
- package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +3 -3
- package/dist/esm/hooks/useShapes/line/prepare-data.js +58 -44
- package/dist/esm/hooks/useShapes/line/types.d.ts +7 -3
- 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/pie/prepare-data.js +8 -4
- 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/scatter/prepare-data.js +1 -1
- package/dist/esm/hooks/useShapes/styles.css +8 -0
- 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 +17 -9
- package/dist/esm/hooks/useShapes/utils.js +66 -18
- 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/useShapes/waterfall/prepare-data.js +18 -8
- package/dist/esm/hooks/useTooltip/index.js +8 -4
- package/dist/esm/hooks/useZoom/index.d.ts +4 -3
- package/dist/esm/hooks/useZoom/index.js +2 -0
- package/dist/esm/hooks/useZoom/utils.d.ts +5 -4
- package/dist/esm/hooks/useZoom/utils.js +4 -3
- package/dist/esm/hooks/utils/bar-x.d.ts +2 -2
- package/dist/esm/hooks/utils/bar-y.d.ts +10 -3
- package/dist/esm/hooks/utils/bar-y.js +4 -0
- package/dist/esm/i18n/keysets/en.json +2 -2
- package/dist/esm/i18n/keysets/ru.json +2 -2
- package/dist/esm/types/chart/area.d.ts +18 -3
- package/dist/esm/types/chart/axis.d.ts +45 -0
- package/dist/esm/types/chart/bar-x.d.ts +17 -4
- package/dist/esm/types/chart/bar-y.d.ts +12 -3
- 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 +12 -3
- package/dist/esm/types/chart/legend.d.ts +6 -0
- package/dist/esm/types/chart/line.d.ts +18 -3
- package/dist/esm/types/chart/pie.d.ts +12 -3
- 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 +18 -4
- 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 +12 -3
- package/dist/esm/types/chart/zoom.d.ts +4 -6
- 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 +30 -8
- package/dist/esm/utils/chart/index.js +3 -3
- package/dist/esm/utils/chart/series/sorting.js +20 -7
- package/dist/esm/utils/chart/zoom.d.ts +3 -3
- package/dist/esm/utils/chart/zoom.js +6 -4
- package/dist/esm/validation/index.js +6 -6
- package/package.json +1 -1
- package/dist/cjs/hooks/useChartOptions/utils.js +0 -49
- package/dist/esm/hooks/useChartOptions/utils.js +0 -49
|
@@ -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: [] };
|
|
@@ -77,6 +81,7 @@ export function useChartInnerProps(props) {
|
|
|
77
81
|
boundsHeight,
|
|
78
82
|
hasZoomX: Boolean(zoomState.x),
|
|
79
83
|
hasZoomY: Boolean(zoomState.y),
|
|
84
|
+
rangeSliderState,
|
|
80
85
|
series: preparedSeries,
|
|
81
86
|
seriesOptions: preparedSeriesOptions,
|
|
82
87
|
split: preparedSplit,
|
|
@@ -89,6 +94,7 @@ export function useChartInnerProps(props) {
|
|
|
89
94
|
const { shapes, shapesData } = useShapes({
|
|
90
95
|
boundsWidth,
|
|
91
96
|
boundsHeight,
|
|
97
|
+
clipPathBySeriesType: CLIP_PATH_BY_SERIES_TYPE,
|
|
92
98
|
dispatcher,
|
|
93
99
|
series: preparedShapesSeries,
|
|
94
100
|
seriesOptions: preparedSeriesOptions,
|
|
@@ -125,7 +131,10 @@ export function useChartInnerProps(props) {
|
|
|
125
131
|
yAxis,
|
|
126
132
|
yScale,
|
|
127
133
|
});
|
|
128
|
-
const boundsOffsetTop = chart.margin.top
|
|
134
|
+
const boundsOffsetTop = chart.margin.top +
|
|
135
|
+
((preparedLegend === null || preparedLegend === void 0 ? void 0 : preparedLegend.enabled) && preparedLegend.position === 'top'
|
|
136
|
+
? preparedLegend.height + preparedLegend.margin
|
|
137
|
+
: 0);
|
|
129
138
|
// We need to calculate the width of each left axis because the first axis can be hidden
|
|
130
139
|
const boundsOffsetLeft = chart.margin.left +
|
|
131
140
|
yAxis.reduce((acc, axis) => {
|
|
@@ -140,7 +149,7 @@ export function useChartInnerProps(props) {
|
|
|
140
149
|
}, 0);
|
|
141
150
|
const { x } = (_a = svgContainer === null || svgContainer === void 0 ? void 0 : svgContainer.getBoundingClientRect()) !== null && _a !== void 0 ? _a : {};
|
|
142
151
|
return {
|
|
143
|
-
|
|
152
|
+
allPreparedSeries,
|
|
144
153
|
boundsHeight,
|
|
145
154
|
boundsOffsetLeft,
|
|
146
155
|
boundsOffsetTop,
|
|
@@ -149,14 +158,17 @@ export function useChartInnerProps(props) {
|
|
|
149
158
|
isOutsideBounds,
|
|
150
159
|
legendConfig,
|
|
151
160
|
legendItems,
|
|
161
|
+
preparedChart: chart,
|
|
152
162
|
preparedLegend,
|
|
153
163
|
preparedSeries,
|
|
164
|
+
preparedSeriesOptions,
|
|
154
165
|
preparedSplit,
|
|
155
166
|
preparedZoom: chart.zoom,
|
|
156
167
|
prevHeight,
|
|
157
168
|
prevWidth,
|
|
158
169
|
shapes,
|
|
159
170
|
shapesData,
|
|
171
|
+
svgXPos: x,
|
|
160
172
|
title,
|
|
161
173
|
xAxis,
|
|
162
174
|
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],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChartSeriesData, ChartTooltip, ChartTooltipTotalsAggregationValue, ChartTooltipTotalsBuiltInAggregation, ChartXAxis, ChartYAxis, TooltipDataChunk, ValueFormat } from '../../../types';
|
|
2
2
|
export type HoveredValue = string | number | null | undefined;
|
|
3
|
-
export declare function getXRowData(data: ChartSeriesData, xAxis?: ChartXAxis | null): string | number | undefined;
|
|
3
|
+
export declare function getXRowData(data: ChartSeriesData, xAxis?: ChartXAxis | null): string | number | null | undefined;
|
|
4
4
|
export declare function getDefaultValueFormat({ axis, closestPointsRange, }: {
|
|
5
5
|
axis?: ChartXAxis | ChartYAxis | null;
|
|
6
6
|
closestPointsRange?: number;
|
|
@@ -14,7 +14,7 @@ export declare const getMeasureValue: ({ data, xAxis, yAxis, headerFormat, }: {
|
|
|
14
14
|
value: string | null;
|
|
15
15
|
formattedValue?: undefined;
|
|
16
16
|
} | {
|
|
17
|
-
value: string | number | undefined;
|
|
17
|
+
value: string | number | null | undefined;
|
|
18
18
|
formattedValue: string;
|
|
19
19
|
} | null;
|
|
20
20
|
export declare function getHoveredValues(args: {
|
|
@@ -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
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const SERIES_TYPE: {
|
|
2
2
|
readonly Area: "area";
|
|
3
3
|
readonly BarX: "bar-x";
|
|
4
4
|
readonly BarY: "bar-y";
|
|
@@ -10,4 +10,6 @@ export declare const SeriesType: {
|
|
|
10
10
|
readonly Sankey: "sankey";
|
|
11
11
|
readonly Radar: "radar";
|
|
12
12
|
readonly Heatmap: "heatmap";
|
|
13
|
+
readonly Funnel: "funnel";
|
|
13
14
|
};
|
|
15
|
+
export type SeriesType = (typeof SERIES_TYPE)[keyof typeof SERIES_TYPE];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const DEFAULT_BORDER_COLOR = 'var(--gcharts-brush-border-color)';
|
|
2
|
+
export const brushDefaults = {
|
|
3
|
+
borderColor: DEFAULT_BORDER_COLOR,
|
|
4
|
+
borderWidth: 1,
|
|
5
|
+
handles: {
|
|
6
|
+
borderColor: DEFAULT_BORDER_COLOR,
|
|
7
|
+
borderWidth: 1,
|
|
8
|
+
enabled: true,
|
|
9
|
+
height: 15,
|
|
10
|
+
width: 8,
|
|
11
|
+
},
|
|
12
|
+
style: {
|
|
13
|
+
fillOpacity: 1,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChartSeriesOptions } from '../../types';
|
|
1
|
+
import type { ChartSeriesOptions, ChartSeriesRangeSliderOptions } from '../../types';
|
|
2
2
|
type DefaultBarXSeriesOptions = Partial<ChartSeriesOptions['bar-x']> & {
|
|
3
3
|
'bar-x': {
|
|
4
4
|
barMaxWidth: number;
|
|
@@ -23,4 +23,5 @@ type DefaultWaterfallSeriesOptions = Partial<ChartSeriesOptions['waterfall']> &
|
|
|
23
23
|
};
|
|
24
24
|
export type SeriesOptionsDefaults = Partial<ChartSeriesOptions> & DefaultBarXSeriesOptions & DefaultBarYSeriesOptions & DefaultWaterfallSeriesOptions;
|
|
25
25
|
export declare const seriesOptionsDefaults: SeriesOptionsDefaults;
|
|
26
|
+
export declare const seriesRangeSliderOptionsDefaults: Required<ChartSeriesRangeSliderOptions>;
|
|
26
27
|
export {};
|
|
@@ -125,4 +125,15 @@ export const seriesOptionsDefaults = {
|
|
|
125
125
|
},
|
|
126
126
|
},
|
|
127
127
|
},
|
|
128
|
+
funnel: {
|
|
129
|
+
states: {
|
|
130
|
+
hover: {
|
|
131
|
+
enabled: true,
|
|
132
|
+
brightness: 0.3,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
export const seriesRangeSliderOptionsDefaults = {
|
|
138
|
+
visible: true,
|
|
128
139
|
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export * from './useAxis';
|
|
2
|
+
export * from './useAxis/types';
|
|
2
3
|
export * from './useAxisScales';
|
|
4
|
+
export * from './useBrush';
|
|
5
|
+
export * from './useBrush/types';
|
|
3
6
|
export * from './useChartDimensions';
|
|
4
7
|
export * from './useChartOptions';
|
|
5
8
|
export * from './useChartOptions/types';
|
|
6
9
|
export * from './useCrosshair';
|
|
7
10
|
export * from './useNormalizedOriginalData';
|
|
8
11
|
export * from './usePrevious';
|
|
12
|
+
export * from './useRangeSlider';
|
|
13
|
+
export * from './useRangeSlider/types';
|
|
9
14
|
export * from './useSeries';
|
|
10
15
|
export * from './useSeries/types';
|
|
11
16
|
export * from './useShapes';
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export * from './useAxis';
|
|
2
|
+
export * from './useAxis/types';
|
|
2
3
|
export * from './useAxisScales';
|
|
4
|
+
export * from './useBrush';
|
|
5
|
+
export * from './useBrush/types';
|
|
3
6
|
export * from './useChartDimensions';
|
|
4
7
|
export * from './useChartOptions';
|
|
5
8
|
export * from './useChartOptions/types';
|
|
6
9
|
export * from './useCrosshair';
|
|
7
10
|
export * from './useNormalizedOriginalData';
|
|
8
11
|
export * from './usePrevious';
|
|
12
|
+
export * from './useRangeSlider';
|
|
13
|
+
export * from './useRangeSlider/types';
|
|
9
14
|
export * from './useSeries';
|
|
10
15
|
export * from './useSeries/types';
|
|
11
16
|
export * from './useShapes';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ChartXAxis, ChartYAxis } from '../../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PreparedChart } from '../useChartOptions/types';
|
|
3
3
|
import type { PreparedLegend, PreparedSeries, PreparedSeriesOptions } from '../useSeries/types';
|
|
4
|
+
import type { PreparedXAxis, PreparedYAxis } from './types';
|
|
4
5
|
interface UseAxesProps {
|
|
5
6
|
height: number;
|
|
6
7
|
preparedChart: PreparedChart;
|
|
@@ -13,7 +14,7 @@ interface UseAxesProps {
|
|
|
13
14
|
yAxis?: ChartYAxis[];
|
|
14
15
|
}
|
|
15
16
|
export declare function useAxis(props: UseAxesProps): {
|
|
16
|
-
xAxis:
|
|
17
|
-
yAxis:
|
|
17
|
+
xAxis: PreparedXAxis | null;
|
|
18
|
+
yAxis: PreparedYAxis[];
|
|
18
19
|
};
|
|
19
20
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
|
-
import { getPreparedXAxis } from '
|
|
4
|
-
import { getPreparedYAxis } from '
|
|
3
|
+
import { getPreparedXAxis } from './x-axis';
|
|
4
|
+
import { getPreparedYAxis } from './y-axis';
|
|
5
5
|
export function useAxis(props) {
|
|
6
6
|
const { boundsHeight, height, preparedChart, preparedLegend, preparedSeries, preparedSeriesOptions, width, xAxis, yAxis, } = props;
|
|
7
7
|
const [axesState, setValue] = React.useState({ xAxis: null, yAxis: [] });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import merge from 'lodash/merge';
|
|
2
|
+
import { brushDefaults } from '../../constants';
|
|
3
|
+
const DEFAULT_RANGE_SLIDER_HEIGHT = 40;
|
|
4
|
+
const DEFAULT_RANGE_SLIDER_MARGIN = 10;
|
|
5
|
+
export function getPreparedRangeSlider({ xAxis }) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
const rangeSlider = xAxis === null || xAxis === void 0 ? void 0 : xAxis.rangeSlider;
|
|
8
|
+
const enabled = (xAxis === null || xAxis === void 0 ? void 0 : xAxis.type) === 'category' ? false : ((_a = rangeSlider === null || rangeSlider === void 0 ? void 0 : rangeSlider.enabled) !== null && _a !== void 0 ? _a : false);
|
|
9
|
+
return {
|
|
10
|
+
brush: merge({}, brushDefaults, rangeSlider === null || rangeSlider === void 0 ? void 0 : rangeSlider.brush),
|
|
11
|
+
defaultRange: rangeSlider === null || rangeSlider === void 0 ? void 0 : rangeSlider.defaultRange,
|
|
12
|
+
enabled,
|
|
13
|
+
height: (_b = rangeSlider === null || rangeSlider === void 0 ? void 0 : rangeSlider.height) !== null && _b !== void 0 ? _b : DEFAULT_RANGE_SLIDER_HEIGHT,
|
|
14
|
+
margin: (_c = rangeSlider === null || rangeSlider === void 0 ? void 0 : rangeSlider.margin) !== null && _c !== void 0 ? _c : DEFAULT_RANGE_SLIDER_MARGIN,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { DashStyle } from '../../constants';
|
|
2
|
+
import type { AxisCrosshair, AxisPlotBand, BaseTextStyle, ChartAxis, ChartAxisLabels, ChartAxisRangeSlider, ChartAxisTitleAlignment, ChartAxisType, DeepRequired, PlotLayerPlacement } from '../../types';
|
|
3
|
+
type PreparedAxisLabels = Omit<ChartAxisLabels, 'enabled' | 'padding' | 'style' | 'autoRotation'> & Required<Pick<ChartAxisLabels, 'enabled' | 'padding' | 'margin' | 'rotation' | 'html'>> & {
|
|
4
|
+
style: BaseTextStyle;
|
|
5
|
+
rotation: number;
|
|
6
|
+
height: number;
|
|
7
|
+
width: number;
|
|
8
|
+
lineHeight: number;
|
|
9
|
+
maxWidth: number;
|
|
10
|
+
};
|
|
11
|
+
export type PreparedAxisPlotBand = Required<AxisPlotBand> & {
|
|
12
|
+
label: {
|
|
13
|
+
text: string;
|
|
14
|
+
style: BaseTextStyle;
|
|
15
|
+
padding: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
type PreparedAxisCrosshair = Required<AxisCrosshair>;
|
|
19
|
+
export type PreparedAxisPlotLine = {
|
|
20
|
+
value: number;
|
|
21
|
+
color: string;
|
|
22
|
+
width: number;
|
|
23
|
+
dashStyle: DashStyle;
|
|
24
|
+
opacity: number;
|
|
25
|
+
layerPlacement: PlotLayerPlacement;
|
|
26
|
+
label: {
|
|
27
|
+
text: string;
|
|
28
|
+
style: BaseTextStyle;
|
|
29
|
+
padding: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type PreparedRangeSlider = DeepRequired<Omit<ChartAxisRangeSlider, 'defaultRange'>> & {
|
|
33
|
+
defaultRange?: ChartAxisRangeSlider['defaultRange'];
|
|
34
|
+
};
|
|
35
|
+
type PreparedBaseAxis = Omit<ChartAxis, 'type' | 'labels' | 'plotLines' | 'plotBands'> & {
|
|
36
|
+
type: ChartAxisType;
|
|
37
|
+
labels: PreparedAxisLabels;
|
|
38
|
+
title: {
|
|
39
|
+
height: number;
|
|
40
|
+
width: number;
|
|
41
|
+
text: string;
|
|
42
|
+
margin: number;
|
|
43
|
+
style: BaseTextStyle;
|
|
44
|
+
align: ChartAxisTitleAlignment;
|
|
45
|
+
maxRowCount: number;
|
|
46
|
+
};
|
|
47
|
+
min?: number;
|
|
48
|
+
grid: {
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
};
|
|
51
|
+
maxPadding: number;
|
|
52
|
+
ticks: {
|
|
53
|
+
pixelInterval?: number;
|
|
54
|
+
};
|
|
55
|
+
position: 'left' | 'right' | 'top' | 'bottom';
|
|
56
|
+
plotIndex: number;
|
|
57
|
+
plotLines: PreparedAxisPlotLine[];
|
|
58
|
+
plotBands: PreparedAxisPlotBand[];
|
|
59
|
+
crosshair: PreparedAxisCrosshair;
|
|
60
|
+
};
|
|
61
|
+
export type PreparedXAxis = PreparedBaseAxis & {
|
|
62
|
+
rangeSlider: PreparedRangeSlider;
|
|
63
|
+
};
|
|
64
|
+
export type PreparedYAxis = PreparedBaseAxis;
|
|
65
|
+
export type PreparedAxis = PreparedXAxis | PreparedYAxis;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxisPlot
|
|
1
|
+
import type { AxisPlot } from '../../types';
|
|
2
2
|
export declare function prepareAxisPlotLabel(d: AxisPlot): {
|
|
3
3
|
text: string;
|
|
4
4
|
style: {
|
|
@@ -8,4 +8,3 @@ export declare function prepareAxisPlotLabel(d: AxisPlot): {
|
|
|
8
8
|
};
|
|
9
9
|
padding: number;
|
|
10
10
|
};
|
|
11
|
-
export declare function getAxisCategories({ categories: originalCategories, max, min, order, }?: Partial<ChartAxis>): string[] | undefined;
|