@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,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { group } from 'd3';
|
|
3
|
+
import { SERIES_TYPE } from '../../constants';
|
|
3
4
|
import { ChartError } from '../../libs';
|
|
4
5
|
import { getOnlyVisibleSeries } from '../../utils';
|
|
5
6
|
import { AreaSeriesShapes } from './area';
|
|
6
7
|
import { prepareAreaData } from './area/prepare-data';
|
|
7
8
|
import { BarXSeriesShapes, prepareBarXData } from './bar-x';
|
|
8
9
|
import { BarYSeriesShapes, prepareBarYData } from './bar-y';
|
|
10
|
+
import { FunnelSeriesShapes, prepareFunnelData } from './funnel';
|
|
9
11
|
import { HeatmapSeriesShapes, prepareHeatmapData } from './heatmap';
|
|
10
12
|
import { LineSeriesShapes } from './line';
|
|
11
13
|
import { prepareLineData } from './line/prepare-data';
|
|
@@ -20,8 +22,15 @@ import { TreemapSeriesShape } from './treemap';
|
|
|
20
22
|
import { prepareTreemapData } from './treemap/prepare-data';
|
|
21
23
|
import { WaterfallSeriesShapes, prepareWaterfallData } from './waterfall';
|
|
22
24
|
import './styles.css';
|
|
25
|
+
function IS_OUTSIDE_BOUNDS() {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
function shouldUseClipPathId(seriesType, clipPathBySeriesType) {
|
|
29
|
+
var _a;
|
|
30
|
+
return (_a = clipPathBySeriesType === null || clipPathBySeriesType === void 0 ? void 0 : clipPathBySeriesType[seriesType]) !== null && _a !== void 0 ? _a : true;
|
|
31
|
+
}
|
|
23
32
|
export const useShapes = (args) => {
|
|
24
|
-
const { boundsWidth, boundsHeight,
|
|
33
|
+
const { boundsWidth, boundsHeight, clipPathId, clipPathBySeriesType, dispatcher, htmlLayout, isOutsideBounds = IS_OUTSIDE_BOUNDS, series, seriesOptions, split, xAxis, xScale, yAxis, yScale, } = args;
|
|
25
34
|
const [shapesElemens, setShapesElements] = React.useState([]);
|
|
26
35
|
const [shapesElemensData, setShapesElemensData] = React.useState([]);
|
|
27
36
|
const countedRef = React.useRef(0);
|
|
@@ -38,7 +47,7 @@ export const useShapes = (args) => {
|
|
|
38
47
|
Array.from(groupedSeries).map(async (item) => {
|
|
39
48
|
const [seriesType, chartSeries] = item;
|
|
40
49
|
switch (seriesType) {
|
|
41
|
-
case
|
|
50
|
+
case SERIES_TYPE.BarX: {
|
|
42
51
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
43
52
|
const preparedData = await prepareBarXData({
|
|
44
53
|
series: chartSeries,
|
|
@@ -49,12 +58,12 @@ export const useShapes = (args) => {
|
|
|
49
58
|
yScale,
|
|
50
59
|
boundsHeight,
|
|
51
60
|
});
|
|
52
|
-
shapes.push(React.createElement(BarXSeriesShapes, { key:
|
|
61
|
+
shapes.push(React.createElement(BarXSeriesShapes, { key: SERIES_TYPE.BarX, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
53
62
|
shapesData.push(...preparedData);
|
|
54
63
|
}
|
|
55
64
|
break;
|
|
56
65
|
}
|
|
57
|
-
case
|
|
66
|
+
case SERIES_TYPE.BarY: {
|
|
58
67
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
59
68
|
const preparedData = await prepareBarYData({
|
|
60
69
|
boundsHeight,
|
|
@@ -66,12 +75,12 @@ export const useShapes = (args) => {
|
|
|
66
75
|
yAxis,
|
|
67
76
|
yScale,
|
|
68
77
|
});
|
|
69
|
-
shapes.push(React.createElement(BarYSeriesShapes, { key:
|
|
78
|
+
shapes.push(React.createElement(BarYSeriesShapes, { key: SERIES_TYPE.BarY, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
70
79
|
shapesData.push(...preparedData.shapes);
|
|
71
80
|
}
|
|
72
81
|
break;
|
|
73
82
|
}
|
|
74
|
-
case
|
|
83
|
+
case SERIES_TYPE.Waterfall: {
|
|
75
84
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
76
85
|
const preparedData = await prepareWaterfallData({
|
|
77
86
|
series: chartSeries,
|
|
@@ -81,12 +90,12 @@ export const useShapes = (args) => {
|
|
|
81
90
|
yAxis,
|
|
82
91
|
yScale,
|
|
83
92
|
});
|
|
84
|
-
shapes.push(React.createElement(WaterfallSeriesShapes, { key:
|
|
93
|
+
shapes.push(React.createElement(WaterfallSeriesShapes, { key: SERIES_TYPE.Waterfall, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
85
94
|
shapesData.push(...preparedData);
|
|
86
95
|
}
|
|
87
96
|
break;
|
|
88
97
|
}
|
|
89
|
-
case
|
|
98
|
+
case SERIES_TYPE.Line: {
|
|
90
99
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
91
100
|
const preparedData = await prepareLineData({
|
|
92
101
|
series: chartSeries,
|
|
@@ -97,12 +106,12 @@ export const useShapes = (args) => {
|
|
|
97
106
|
split,
|
|
98
107
|
isOutsideBounds,
|
|
99
108
|
});
|
|
100
|
-
shapes.push(React.createElement(LineSeriesShapes, { key:
|
|
109
|
+
shapes.push(React.createElement(LineSeriesShapes, { key: SERIES_TYPE.Line, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
101
110
|
shapesData.push(...preparedData);
|
|
102
111
|
}
|
|
103
112
|
break;
|
|
104
113
|
}
|
|
105
|
-
case
|
|
114
|
+
case SERIES_TYPE.Area: {
|
|
106
115
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
107
116
|
const preparedData = await prepareAreaData({
|
|
108
117
|
series: chartSeries,
|
|
@@ -113,12 +122,12 @@ export const useShapes = (args) => {
|
|
|
113
122
|
boundsHeight,
|
|
114
123
|
isOutsideBounds,
|
|
115
124
|
});
|
|
116
|
-
shapes.push(React.createElement(AreaSeriesShapes, { key:
|
|
125
|
+
shapes.push(React.createElement(AreaSeriesShapes, { key: SERIES_TYPE.Area, dispatcher: dispatcher, seriesOptions: seriesOptions, preparedData: preparedData, htmlLayout: htmlLayout, clipPathId: clipPathId }));
|
|
117
126
|
shapesData.push(...preparedData);
|
|
118
127
|
}
|
|
119
128
|
break;
|
|
120
129
|
}
|
|
121
|
-
case
|
|
130
|
+
case SERIES_TYPE.Scatter: {
|
|
122
131
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale.length)) {
|
|
123
132
|
const preparedData = prepareScatterData({
|
|
124
133
|
series: chartSeries,
|
|
@@ -128,22 +137,24 @@ export const useShapes = (args) => {
|
|
|
128
137
|
yScale,
|
|
129
138
|
isOutsideBounds,
|
|
130
139
|
});
|
|
131
|
-
shapes.push(React.createElement(ScatterSeriesShape, { key:
|
|
140
|
+
shapes.push(React.createElement(ScatterSeriesShape, { key: SERIES_TYPE.Scatter, clipPathId: shouldUseClipPathId(SERIES_TYPE.Scatter, clipPathBySeriesType)
|
|
141
|
+
? clipPathId
|
|
142
|
+
: undefined, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
132
143
|
shapesData.push(...preparedData);
|
|
133
144
|
}
|
|
134
145
|
break;
|
|
135
146
|
}
|
|
136
|
-
case
|
|
147
|
+
case SERIES_TYPE.Pie: {
|
|
137
148
|
const preparedData = await preparePieData({
|
|
138
149
|
series: chartSeries,
|
|
139
150
|
boundsWidth,
|
|
140
151
|
boundsHeight,
|
|
141
152
|
});
|
|
142
|
-
shapes.push(React.createElement(PieSeriesShapes, { key:
|
|
153
|
+
shapes.push(React.createElement(PieSeriesShapes, { key: SERIES_TYPE.Pie, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
143
154
|
shapesData.push(...preparedData);
|
|
144
155
|
break;
|
|
145
156
|
}
|
|
146
|
-
case
|
|
157
|
+
case SERIES_TYPE.Treemap: {
|
|
147
158
|
const preparedData = await prepareTreemapData({
|
|
148
159
|
// We should have exactly one series with "treemap" type
|
|
149
160
|
// Otherwise data validation should emit an error
|
|
@@ -151,31 +162,31 @@ export const useShapes = (args) => {
|
|
|
151
162
|
width: boundsWidth,
|
|
152
163
|
height: boundsHeight,
|
|
153
164
|
});
|
|
154
|
-
shapes.push(React.createElement(TreemapSeriesShape, { key:
|
|
165
|
+
shapes.push(React.createElement(TreemapSeriesShape, { key: SERIES_TYPE.Treemap, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
155
166
|
shapesData.push(preparedData);
|
|
156
167
|
break;
|
|
157
168
|
}
|
|
158
|
-
case
|
|
169
|
+
case SERIES_TYPE.Sankey: {
|
|
159
170
|
const preparedData = prepareSankeyData({
|
|
160
171
|
series: chartSeries[0],
|
|
161
172
|
width: boundsWidth,
|
|
162
173
|
height: boundsHeight,
|
|
163
174
|
});
|
|
164
|
-
shapes.push(React.createElement(SankeySeriesShape, { key:
|
|
175
|
+
shapes.push(React.createElement(SankeySeriesShape, { key: SERIES_TYPE.Sankey, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
165
176
|
shapesData.push(preparedData);
|
|
166
177
|
break;
|
|
167
178
|
}
|
|
168
|
-
case
|
|
179
|
+
case SERIES_TYPE.Radar: {
|
|
169
180
|
const preparedData = await prepareRadarData({
|
|
170
181
|
series: chartSeries,
|
|
171
182
|
boundsWidth,
|
|
172
183
|
boundsHeight,
|
|
173
184
|
});
|
|
174
|
-
shapes.push(React.createElement(RadarSeriesShapes, { key:
|
|
185
|
+
shapes.push(React.createElement(RadarSeriesShapes, { key: SERIES_TYPE.Radar, dispatcher: dispatcher, series: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
175
186
|
shapesData.push(...preparedData);
|
|
176
187
|
break;
|
|
177
188
|
}
|
|
178
|
-
case
|
|
189
|
+
case SERIES_TYPE.Heatmap: {
|
|
179
190
|
if (xAxis && xScale && (yScale === null || yScale === void 0 ? void 0 : yScale[0])) {
|
|
180
191
|
const preparedData = await prepareHeatmapData({
|
|
181
192
|
series: chartSeries[0],
|
|
@@ -184,11 +195,21 @@ export const useShapes = (args) => {
|
|
|
184
195
|
yAxis: yAxis[0],
|
|
185
196
|
yScale: yScale[0],
|
|
186
197
|
});
|
|
187
|
-
shapes.push(React.createElement(HeatmapSeriesShapes, { key:
|
|
198
|
+
shapes.push(React.createElement(HeatmapSeriesShapes, { key: SERIES_TYPE.Heatmap, dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
188
199
|
shapesData.push(preparedData);
|
|
189
200
|
}
|
|
190
201
|
break;
|
|
191
202
|
}
|
|
203
|
+
case 'funnel': {
|
|
204
|
+
const preparedData = await prepareFunnelData({
|
|
205
|
+
series: chartSeries,
|
|
206
|
+
boundsWidth,
|
|
207
|
+
boundsHeight,
|
|
208
|
+
});
|
|
209
|
+
shapes.push(React.createElement(FunnelSeriesShapes, { key: "funnel", dispatcher: dispatcher, preparedData: preparedData, seriesOptions: seriesOptions, htmlLayout: htmlLayout }));
|
|
210
|
+
shapesData.push(preparedData);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
192
213
|
default: {
|
|
193
214
|
throw new ChartError({
|
|
194
215
|
message: `The display method is not defined for a series with type "${seriesType}"`,
|
|
@@ -204,8 +225,11 @@ export const useShapes = (args) => {
|
|
|
204
225
|
}, [
|
|
205
226
|
boundsHeight,
|
|
206
227
|
boundsWidth,
|
|
228
|
+
clipPathId,
|
|
229
|
+
clipPathBySeriesType,
|
|
207
230
|
dispatcher,
|
|
208
231
|
htmlLayout,
|
|
232
|
+
isOutsideBounds,
|
|
209
233
|
series,
|
|
210
234
|
seriesOptions,
|
|
211
235
|
split,
|
|
@@ -213,8 +237,6 @@ export const useShapes = (args) => {
|
|
|
213
237
|
xScale,
|
|
214
238
|
yAxis,
|
|
215
239
|
yScale,
|
|
216
|
-
clipPathId,
|
|
217
|
-
isOutsideBounds,
|
|
218
240
|
]);
|
|
219
241
|
return { shapes: shapesElemens, shapesData: shapesElemensData };
|
|
220
242
|
};
|
|
@@ -3,11 +3,11 @@ import type { Dispatch } from 'd3';
|
|
|
3
3
|
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedLineData } from './types';
|
|
5
5
|
type Args = {
|
|
6
|
-
|
|
6
|
+
clipPathId: string;
|
|
7
|
+
htmlLayout: HTMLElement | null;
|
|
7
8
|
preparedData: PreparedLineData[];
|
|
8
9
|
seriesOptions: PreparedSeriesOptions;
|
|
9
|
-
|
|
10
|
-
clipPathId: string;
|
|
10
|
+
dispatcher?: Dispatch<object>;
|
|
11
11
|
};
|
|
12
12
|
export declare const LineSeriesShapes: (args: Args) => React.JSX.Element;
|
|
13
13
|
export {};
|
|
@@ -21,6 +21,7 @@ export const LineSeriesShapes = (args) => {
|
|
|
21
21
|
const hoverOptions = get(seriesOptions, 'line.states.hover');
|
|
22
22
|
const inactiveOptions = get(seriesOptions, 'line.states.inactive');
|
|
23
23
|
const line = lineGenerator()
|
|
24
|
+
.defined((d) => d.y !== null && d.x !== null)
|
|
24
25
|
.x((d) => d.x)
|
|
25
26
|
.y((d) => d.y);
|
|
26
27
|
plotSvgElement.selectAll('*').remove();
|
|
@@ -128,9 +129,9 @@ export const LineSeriesShapes = (args) => {
|
|
|
128
129
|
if (hoveredDataRef.current !== null) {
|
|
129
130
|
handleShapeHover(hoveredDataRef.current);
|
|
130
131
|
}
|
|
131
|
-
dispatcher.on('hover-shape.line', handleShapeHover);
|
|
132
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.line', handleShapeHover);
|
|
132
133
|
return () => {
|
|
133
|
-
dispatcher.on('hover-shape.line', null);
|
|
134
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.line', null);
|
|
134
135
|
};
|
|
135
136
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
136
137
|
return (React.createElement(React.Fragment, null,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../useAxis/types';
|
|
1
2
|
import type { ChartScale } from '../../useAxisScales';
|
|
2
|
-
import type { PreparedAxis } from '../../useChartOptions/types';
|
|
3
3
|
import type { PreparedLineSeries } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedSplit } from '../../useSplit/types';
|
|
5
5
|
import type { PreparedLineData } from './types';
|
|
6
6
|
export declare const prepareLineData: (args: {
|
|
7
7
|
series: PreparedLineSeries[];
|
|
8
|
-
xAxis:
|
|
8
|
+
xAxis: PreparedXAxis;
|
|
9
9
|
xScale: ChartScale;
|
|
10
|
-
yAxis:
|
|
10
|
+
yAxis: PreparedYAxis[];
|
|
11
11
|
yScale: (ChartScale | undefined)[];
|
|
12
12
|
split: PreparedSplit;
|
|
13
13
|
isOutsideBounds: (x: number, y: number) => boolean;
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
import { getLabelsSize,
|
|
1
|
+
import { getLabelsSize, getTextSizeFn } from '../../../utils';
|
|
2
2
|
import { getFormattedValue } from '../../../utils/chart/format';
|
|
3
3
|
import { getXValue, getYValue } from '../utils';
|
|
4
|
-
async function getLabelData(point, series, xMax) {
|
|
5
|
-
const text = getFormattedValue(Object.assign({ value: point.data.label || point.data.y }, series.dataLabels));
|
|
6
|
-
const style = series.dataLabels.style;
|
|
7
|
-
const size = await getLabelsSize({ labels: [text], style });
|
|
8
|
-
const labelData = {
|
|
9
|
-
text,
|
|
10
|
-
x: point.x,
|
|
11
|
-
y: point.y - series.dataLabels.padding,
|
|
12
|
-
style,
|
|
13
|
-
size: { width: size.maxWidth, height: size.maxHeight },
|
|
14
|
-
textAnchor: 'middle',
|
|
15
|
-
series: series,
|
|
16
|
-
active: true,
|
|
17
|
-
};
|
|
18
|
-
const left = getLeftPosition(labelData);
|
|
19
|
-
if (left < 0) {
|
|
20
|
-
labelData.x = labelData.x + Math.abs(left);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
const right = left + labelData.size.width;
|
|
24
|
-
if (right > xMax) {
|
|
25
|
-
labelData.x = labelData.x - xMax - right;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return labelData;
|
|
29
|
-
}
|
|
30
4
|
async function getHtmlLabel(point, series, xMax) {
|
|
31
5
|
const content = String(point.data.label || point.data.y);
|
|
32
6
|
const size = await getLabelsSize({ labels: [content], html: true });
|
|
@@ -53,33 +27,73 @@ export const prepareLineData = async (args) => {
|
|
|
53
27
|
if (!seriesYScale) {
|
|
54
28
|
continue;
|
|
55
29
|
}
|
|
56
|
-
const points = s.data.map((d) =>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
30
|
+
const points = s.data.map((d) => {
|
|
31
|
+
const yValue = getYValue({
|
|
32
|
+
point: d,
|
|
33
|
+
points: s.data,
|
|
34
|
+
yAxis: seriesYAxis,
|
|
35
|
+
yScale: seriesYScale,
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
x: getXValue({ point: d, points: s.data, xAxis, xScale }),
|
|
39
|
+
y: yValue === null ? null : yAxisTop + yValue,
|
|
40
|
+
active: true,
|
|
41
|
+
data: d,
|
|
42
|
+
series: s,
|
|
43
|
+
};
|
|
44
|
+
});
|
|
64
45
|
const htmlElements = [];
|
|
65
|
-
|
|
46
|
+
const labels = [];
|
|
66
47
|
if (s.dataLabels.enabled) {
|
|
67
48
|
if (s.dataLabels.html) {
|
|
68
|
-
const list = await Promise.all(points.
|
|
49
|
+
const list = await Promise.all(points.reduce((result, p) => {
|
|
50
|
+
if (p.y === null) {
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
result.push(getHtmlLabel(p, s, xMax));
|
|
54
|
+
return result;
|
|
55
|
+
}, []));
|
|
69
56
|
htmlElements.push(...list);
|
|
70
57
|
}
|
|
71
58
|
else {
|
|
72
|
-
|
|
59
|
+
const getTextSize = getTextSizeFn({ style: s.dataLabels.style });
|
|
60
|
+
for (let index = 0; index < points.length; index++) {
|
|
61
|
+
const point = points[index];
|
|
62
|
+
if (point.y !== null && point.x !== null) {
|
|
63
|
+
const text = getFormattedValue(Object.assign({ value: point.data.label || point.data.y }, s.dataLabels));
|
|
64
|
+
const labelSize = await getTextSize(text);
|
|
65
|
+
const style = s.dataLabels.style;
|
|
66
|
+
const y = Math.max(yAxisTop, point.y - s.dataLabels.padding - labelSize.height);
|
|
67
|
+
const x = Math.min(xMax - labelSize.width, Math.max(0, point.x - labelSize.width / 2));
|
|
68
|
+
const labelData = {
|
|
69
|
+
text,
|
|
70
|
+
x,
|
|
71
|
+
y,
|
|
72
|
+
style,
|
|
73
|
+
size: labelSize,
|
|
74
|
+
textAnchor: 'start',
|
|
75
|
+
series: s,
|
|
76
|
+
active: true,
|
|
77
|
+
};
|
|
78
|
+
labels.push(labelData);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
let markers = [];
|
|
76
84
|
if (s.marker.states.normal.enabled || s.marker.states.hover.enabled) {
|
|
77
|
-
markers = points.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
markers = points.reduce((result, p) => {
|
|
86
|
+
if (p.y === null || p.x === null) {
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
result.push({
|
|
90
|
+
point: p,
|
|
91
|
+
active: true,
|
|
92
|
+
hovered: false,
|
|
93
|
+
clipped: isOutsideBounds(p.x, p.y),
|
|
94
|
+
});
|
|
95
|
+
return result;
|
|
96
|
+
}, []);
|
|
83
97
|
}
|
|
84
98
|
const result = {
|
|
85
99
|
points,
|
|
@@ -2,14 +2,18 @@ import type { DashStyle, LineCap } from '../../../constants';
|
|
|
2
2
|
import type { HtmlItem, LabelData, LineSeriesData } from '../../../types';
|
|
3
3
|
import type { PreparedLineSeries } from '../../useSeries/types';
|
|
4
4
|
export type PointData = {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
5
|
+
x: number | null;
|
|
6
|
+
y: number | null;
|
|
7
7
|
data: LineSeriesData;
|
|
8
8
|
series: PreparedLineSeries;
|
|
9
9
|
color?: string;
|
|
10
10
|
};
|
|
11
|
+
export type MarkerPointData = PointData & {
|
|
12
|
+
y: number;
|
|
13
|
+
x: number;
|
|
14
|
+
};
|
|
11
15
|
export type MarkerData = {
|
|
12
|
-
point:
|
|
16
|
+
point: MarkerPointData;
|
|
13
17
|
active: boolean;
|
|
14
18
|
hovered: boolean;
|
|
15
19
|
clipped: boolean;
|
|
@@ -3,10 +3,10 @@ import type { Dispatch, PieArcDatum } from 'd3';
|
|
|
3
3
|
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedPieData, SegmentData } from './types';
|
|
5
5
|
type PreparePieSeriesArgs = {
|
|
6
|
-
|
|
6
|
+
htmlLayout: HTMLElement | null;
|
|
7
7
|
preparedData: PreparedPieData[];
|
|
8
8
|
seriesOptions: PreparedSeriesOptions;
|
|
9
|
-
|
|
9
|
+
dispatcher?: Dispatch<object>;
|
|
10
10
|
};
|
|
11
11
|
export declare function getHaloVisibility(d: PieArcDatum<SegmentData>): "" | "hidden";
|
|
12
12
|
export declare function PieSeriesShapes(args: PreparePieSeriesArgs): React.JSX.Element;
|
|
@@ -112,7 +112,7 @@ export function PieSeriesShapes(args) {
|
|
|
112
112
|
const eventName = `hover-shape.pie`;
|
|
113
113
|
const hoverOptions = get(seriesOptions, 'pie.states.hover');
|
|
114
114
|
const inactiveOptions = get(seriesOptions, 'pie.states.inactive');
|
|
115
|
-
dispatcher.on(eventName, (data) => {
|
|
115
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (data) => {
|
|
116
116
|
var _a, _b;
|
|
117
117
|
const selectedSeriesId = (_b = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.series) === null || _b === void 0 ? void 0 : _b.id;
|
|
118
118
|
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
@@ -162,7 +162,7 @@ export function PieSeriesShapes(args) {
|
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
164
|
return () => {
|
|
165
|
-
dispatcher.on(eventName, null);
|
|
165
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
|
|
166
166
|
};
|
|
167
167
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
168
168
|
const htmlElements = preparedData.map((d) => d.htmlLabels).flat();
|
|
@@ -55,15 +55,18 @@ export function preparePieData(args) {
|
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
57
|
const labelMaxHeight = (_a = max(Object.values(labels).map((l) => { var _a, _b; return (_b = (_a = l.size) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0; }))) !== null && _a !== void 0 ? _a : 0;
|
|
58
|
-
const segments = items.
|
|
58
|
+
const segments = items.reduce((acc, item) => {
|
|
59
59
|
var _a;
|
|
60
|
+
if (item.value === null) {
|
|
61
|
+
return acc;
|
|
62
|
+
}
|
|
60
63
|
let maxSegmentRadius = maxRadius;
|
|
61
64
|
if (dataLabels.enabled) {
|
|
62
65
|
maxSegmentRadius -=
|
|
63
66
|
dataLabels.distance + dataLabels.connectorPadding + labelMaxHeight;
|
|
64
67
|
}
|
|
65
68
|
const segmentRadius = (_a = calculateNumericProperty({ value: item.radius, base: maxSegmentRadius })) !== null && _a !== void 0 ? _a : maxSegmentRadius;
|
|
66
|
-
|
|
69
|
+
acc.push({
|
|
67
70
|
value: item.value,
|
|
68
71
|
color: item.color,
|
|
69
72
|
opacity: item.opacity,
|
|
@@ -72,8 +75,9 @@ export function preparePieData(args) {
|
|
|
72
75
|
active: true,
|
|
73
76
|
pie: data,
|
|
74
77
|
radius: segmentRadius,
|
|
75
|
-
};
|
|
76
|
-
|
|
78
|
+
});
|
|
79
|
+
return acc;
|
|
80
|
+
}, []);
|
|
77
81
|
data.segments = pieGenerator(segments);
|
|
78
82
|
return data;
|
|
79
83
|
};
|
|
@@ -3,10 +3,10 @@ import type { Dispatch } from 'd3';
|
|
|
3
3
|
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedRadarData } from './types';
|
|
5
5
|
type PrepareRadarSeriesArgs = {
|
|
6
|
-
|
|
6
|
+
htmlLayout: HTMLElement | null;
|
|
7
7
|
series: PreparedRadarData[];
|
|
8
8
|
seriesOptions: PreparedSeriesOptions;
|
|
9
|
-
|
|
9
|
+
dispatcher?: Dispatch<object>;
|
|
10
10
|
};
|
|
11
11
|
export declare function RadarSeriesShapes(args: PrepareRadarSeriesArgs): React.JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -81,7 +81,7 @@ export function RadarSeriesShapes(args) {
|
|
|
81
81
|
const eventName = `hover-shape.radar`;
|
|
82
82
|
const hoverOptions = get(seriesOptions, 'radar.states.hover');
|
|
83
83
|
const inactiveOptions = get(seriesOptions, 'radar.states.inactive');
|
|
84
|
-
dispatcher.on(eventName, (data) => {
|
|
84
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (data) => {
|
|
85
85
|
const closest = data === null || data === void 0 ? void 0 : data.find((d) => d.closest);
|
|
86
86
|
const selectedSeries = closest === null || closest === void 0 ? void 0 : closest.series;
|
|
87
87
|
const selectedSeriesData = closest === null || closest === void 0 ? void 0 : closest.data;
|
|
@@ -126,7 +126,7 @@ export function RadarSeriesShapes(args) {
|
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
128
|
return () => {
|
|
129
|
-
dispatcher.on(eventName, null);
|
|
129
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
|
|
130
130
|
};
|
|
131
131
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
132
132
|
const htmlElements = preparedData.map((d) => d.htmlLabels).flat();
|
|
@@ -3,10 +3,10 @@ import type { Dispatch } from 'd3';
|
|
|
3
3
|
import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedSankeyData } from './types';
|
|
5
5
|
type ShapeProps = {
|
|
6
|
-
|
|
6
|
+
htmlLayout: HTMLElement | null;
|
|
7
7
|
preparedData: PreparedSankeyData;
|
|
8
8
|
seriesOptions: PreparedSeriesOptions;
|
|
9
|
-
|
|
9
|
+
dispatcher?: Dispatch<object>;
|
|
10
10
|
};
|
|
11
11
|
export declare const SankeySeriesShape: (props: ShapeProps) => React.JSX.Element;
|
|
12
12
|
export {};
|
|
@@ -56,9 +56,9 @@ export const SankeySeriesShape = (props) => {
|
|
|
56
56
|
if (hoveredDataRef.current !== null) {
|
|
57
57
|
handleShapeHover(hoveredDataRef.current);
|
|
58
58
|
}
|
|
59
|
-
dispatcher.on(eventName, handleShapeHover);
|
|
59
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, handleShapeHover);
|
|
60
60
|
return () => {
|
|
61
|
-
dispatcher.on(eventName, null);
|
|
61
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
|
|
62
62
|
};
|
|
63
63
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
64
64
|
return (React.createElement(React.Fragment, null,
|
|
@@ -4,9 +4,10 @@ import type { PreparedSeriesOptions } from '../../useSeries/types';
|
|
|
4
4
|
import type { PreparedScatterData } from './types';
|
|
5
5
|
export { prepareScatterData } from './prepare-data';
|
|
6
6
|
type ScatterSeriesShapeProps = {
|
|
7
|
-
|
|
7
|
+
htmlLayout: HTMLElement | null;
|
|
8
8
|
preparedData: PreparedScatterData[];
|
|
9
9
|
seriesOptions: PreparedSeriesOptions;
|
|
10
|
-
|
|
10
|
+
clipPathId?: string;
|
|
11
|
+
dispatcher?: Dispatch<object>;
|
|
11
12
|
};
|
|
12
13
|
export declare function ScatterSeriesShape(props: ScatterSeriesShapeProps): React.JSX.Element;
|
|
@@ -8,7 +8,7 @@ import { setActiveState, shapeKey } from '../utils';
|
|
|
8
8
|
export { prepareScatterData } from './prepare-data';
|
|
9
9
|
const b = block('scatter');
|
|
10
10
|
export function ScatterSeriesShape(props) {
|
|
11
|
-
const { dispatcher, preparedData, seriesOptions, htmlLayout } = props;
|
|
11
|
+
const { clipPathId, dispatcher, preparedData, seriesOptions, htmlLayout } = props;
|
|
12
12
|
const hoveredDataRef = React.useRef(null);
|
|
13
13
|
const ref = React.useRef(null);
|
|
14
14
|
React.useEffect(() => {
|
|
@@ -63,12 +63,12 @@ export function ScatterSeriesShape(props) {
|
|
|
63
63
|
if (hoveredDataRef.current !== null) {
|
|
64
64
|
handleShapeHover(hoveredDataRef.current);
|
|
65
65
|
}
|
|
66
|
-
dispatcher.on('hover-shape.scatter', handleShapeHover);
|
|
66
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', handleShapeHover);
|
|
67
67
|
return () => {
|
|
68
|
-
dispatcher.on('hover-shape.scatter', null);
|
|
68
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', null);
|
|
69
69
|
};
|
|
70
70
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
71
71
|
return (React.createElement(React.Fragment, null,
|
|
72
|
-
React.createElement("g", { ref: ref, className: b() }),
|
|
72
|
+
React.createElement("g", { ref: ref, className: b(), clipPath: clipPathId ? `url(#${clipPathId})` : undefined }),
|
|
73
73
|
React.createElement(HtmlLayer, { preparedData: preparedData, htmlLayout: htmlLayout })));
|
|
74
74
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../useAxis/types';
|
|
1
2
|
import type { ChartScale } from '../../useAxisScales';
|
|
2
|
-
import type { PreparedAxis } from '../../useChartOptions/types';
|
|
3
3
|
import type { PreparedScatterSeries } from '../../useSeries/types';
|
|
4
4
|
import type { PreparedScatterData } from './types';
|
|
5
5
|
export declare function prepareScatterData(args: {
|
|
6
6
|
series: PreparedScatterSeries[];
|
|
7
|
-
xAxis:
|
|
7
|
+
xAxis: PreparedXAxis;
|
|
8
8
|
xScale: ChartScale;
|
|
9
|
-
yAxis:
|
|
9
|
+
yAxis: PreparedYAxis[];
|
|
10
10
|
yScale: (ChartScale | undefined)[];
|
|
11
11
|
isOutsideBounds: (x: number, y: number) => boolean;
|
|
12
12
|
}): PreparedScatterData[];
|
|
@@ -54,7 +54,7 @@ export function prepareScatterData(args) {
|
|
|
54
54
|
var _a;
|
|
55
55
|
const x = getXValue({ point: d, xAxis, xScale });
|
|
56
56
|
const y = getYValue({ point: d, yAxis: seriesYAxis, yScale: seriesYScale });
|
|
57
|
-
if (typeof x === 'undefined' || typeof y === 'undefined') {
|
|
57
|
+
if (typeof x === 'undefined' || typeof y === 'undefined' || x === null || y === null) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
acc.push({
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
.gcharts-line__label {
|
|
2
|
+
dominant-baseline: text-before-edge;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
.gcharts-scatter__point {
|
|
2
6
|
stroke-width: 1px;
|
|
3
7
|
}
|
|
@@ -40,4 +44,8 @@
|
|
|
40
44
|
|
|
41
45
|
.gcharts-heatmap__label {
|
|
42
46
|
dominant-baseline: text-before-edge;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.gcharts-funnel__label {
|
|
50
|
+
dominant-baseline: text-before-edge;
|
|
43
51
|
}
|