@gravity-ui/charts 1.46.0 → 1.47.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/ChartInner/index.js +1 -0
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +1 -0
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +13 -6
- package/dist/cjs/components/Legend/index.js +13 -14
- package/dist/cjs/components/Tooltip/index.js +22 -1
- package/dist/cjs/core/axes/x-axis.js +1 -1
- package/dist/cjs/core/axes/y-axis.js +1 -1
- package/dist/cjs/core/brush/index.d.ts +2 -0
- package/dist/cjs/core/brush/index.js +2 -0
- package/dist/cjs/{hooks/useBrush → core/brush}/types.d.ts +2 -2
- package/dist/cjs/{hooks/useBrush → core/brush}/utils.d.ts +1 -1
- package/dist/cjs/core/chart/index.d.ts +1 -0
- package/dist/cjs/core/chart/index.js +1 -0
- package/dist/cjs/core/chart/types.d.ts +8 -0
- package/dist/cjs/core/index.d.ts +3 -0
- package/dist/cjs/core/index.js +3 -0
- package/dist/cjs/core/layout/chart-dimensions.d.ts +1 -1
- package/dist/cjs/core/range-slider/index.d.ts +2 -0
- package/dist/cjs/core/range-slider/index.js +2 -0
- package/dist/cjs/core/range-slider/types.d.ts +4 -0
- package/dist/{esm/hooks/useRangeSlider → cjs/core/range-slider}/utils.d.ts +5 -5
- package/dist/{esm/hooks/useRangeSlider → cjs/core/range-slider}/utils.js +1 -1
- package/dist/cjs/core/scales/utils.d.ts +1 -1
- package/dist/cjs/core/scales/utils.js +1 -1
- package/dist/cjs/core/scales/x-scale.d.ts +2 -2
- package/dist/cjs/core/scales/x-scale.js +2 -2
- package/dist/cjs/core/scales/y-scale.js +69 -4
- package/dist/cjs/core/series/prepare-area.js +1 -1
- package/dist/cjs/core/series/prepare-bar-x.js +1 -1
- package/dist/cjs/core/series/prepare-bar-y.js +1 -1
- package/dist/cjs/core/series/prepare-funnel.js +1 -1
- package/dist/cjs/core/series/prepare-heatmap.js +1 -1
- package/dist/cjs/core/series/prepare-legend.d.ts +1 -1
- package/dist/cjs/core/series/prepare-legend.js +2 -2
- package/dist/cjs/core/series/prepare-line.js +1 -1
- package/dist/cjs/core/series/prepare-pie.js +1 -1
- package/dist/cjs/core/series/prepare-radar.js +1 -1
- package/dist/cjs/core/series/prepare-sankey.js +1 -1
- package/dist/cjs/core/series/prepare-scatter.js +1 -1
- package/dist/cjs/core/series/prepare-treemap.js +1 -1
- package/dist/cjs/core/series/prepare-waterfall.js +1 -1
- package/dist/cjs/core/series/prepare-x-range.js +1 -1
- package/dist/cjs/core/series/prepareSeries.d.ts +7 -1
- package/dist/cjs/core/series/prepareSeries.js +31 -0
- package/dist/cjs/core/series/types.d.ts +5 -0
- package/dist/cjs/core/series/utils.d.ts +4 -0
- package/dist/cjs/core/series/utils.js +9 -1
- package/dist/cjs/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
- package/dist/cjs/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
- package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
- package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.js +9 -4
- package/dist/cjs/core/shapes/area/renderer.d.ts +11 -0
- package/dist/cjs/core/shapes/area/renderer.js +175 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/area/types.d.ts +7 -8
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.d.ts +4 -4
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.js +6 -6
- package/dist/cjs/core/shapes/bar-x/renderer.d.ts +9 -0
- package/dist/cjs/core/shapes/bar-x/renderer.js +104 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/bar-x/types.d.ts +1 -2
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.d.ts +3 -3
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.js +3 -3
- package/dist/cjs/core/shapes/bar-y/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/bar-y/renderer.js +74 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/utils.js +1 -1
- package/dist/cjs/core/shapes/data-labels.d.ts +15 -0
- package/dist/cjs/core/shapes/data-labels.js +15 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/funnel/prepare-data.js +1 -1
- package/dist/cjs/core/shapes/funnel/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/funnel/renderer.js +74 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
- package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
- package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/prepare-data.js +3 -2
- package/dist/cjs/core/shapes/heatmap/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/heatmap/renderer.js +50 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/heatmap/types.d.ts +2 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/line/prepare-data.d.ts +4 -4
- package/dist/cjs/{hooks/useShapes → core/shapes}/line/prepare-data.js +12 -4
- package/dist/cjs/core/shapes/line/renderer.d.ts +11 -0
- package/dist/cjs/core/shapes/line/renderer.js +161 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/line/types.d.ts +7 -8
- package/dist/cjs/core/shapes/marker.d.ts +45 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/marker.js +2 -2
- package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
- package/dist/cjs/core/shapes/pie/renderer.d.ts +8 -0
- package/dist/cjs/core/shapes/pie/renderer.js +160 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/pie/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/radar/prepare-data.js +2 -2
- package/dist/cjs/core/shapes/radar/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/radar/renderer.js +122 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
- package/dist/cjs/core/shapes/sankey/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/sankey/renderer.js +44 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/sankey/types.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/scatter/prepare-data.d.ts +3 -3
- package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/prepare-data.js +2 -2
- package/dist/cjs/core/shapes/scatter/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/scatter/renderer.js +52 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/treemap/prepare-data.js +3 -3
- package/dist/cjs/core/shapes/treemap/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/treemap/renderer.js +88 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/types.d.ts +1 -1
- package/dist/cjs/core/shapes/utils.d.ts +76 -0
- package/dist/cjs/core/shapes/utils.js +186 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/waterfall/prepare-data.js +4 -4
- package/dist/cjs/core/shapes/waterfall/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/waterfall/renderer.js +109 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
- package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
- package/dist/cjs/core/shapes/x-range/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/x-range/renderer.js +88 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/types.d.ts +1 -1
- package/dist/cjs/core/types/chart/area.d.ts +0 -1
- package/dist/cjs/core/types/chart/axis.d.ts +0 -1
- package/dist/cjs/core/types/chart/base.d.ts +18 -7
- package/dist/cjs/core/types/chart/tooltip.d.ts +3 -3
- package/dist/cjs/core/types/formatter.d.ts +1 -40
- package/dist/{esm/hooks/utils/get-band-size.js → cjs/core/utils/band-size.js} +1 -1
- package/dist/cjs/{hooks → core}/utils/bar-y.d.ts +3 -3
- package/dist/{esm/hooks → cjs/core}/utils/bar-y.js +4 -4
- package/dist/cjs/core/utils/format.d.ts +2 -2
- package/dist/cjs/core/utils/get-closest-data.d.ts +1 -1
- package/dist/cjs/core/utils/get-closest-data.js +13 -8
- package/dist/cjs/core/utils/series/sorting.js +1 -1
- package/dist/cjs/core/utils/text.d.ts +0 -1
- package/dist/cjs/core/utils/text.js +0 -1
- package/dist/cjs/core/zoom/index.d.ts +2 -0
- package/dist/cjs/core/zoom/index.js +2 -0
- package/dist/{esm/hooks/useZoom → cjs/core/zoom}/utils.d.ts +3 -3
- package/dist/{esm/hooks/useZoom → cjs/core/zoom}/utils.js +1 -1
- package/dist/cjs/core/zoom/zoom.d.ts +3 -3
- package/dist/cjs/hooks/index.d.ts +3 -3
- package/dist/cjs/hooks/index.js +3 -3
- package/dist/cjs/hooks/types.d.ts +2 -8
- package/dist/cjs/hooks/useBrush/index.d.ts +1 -1
- package/dist/cjs/hooks/useBrush/index.js +1 -1
- package/dist/cjs/hooks/useRangeSlider/index.js +3 -3
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +6 -8
- package/dist/cjs/hooks/useShapes/area/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/area/index.js +13 -185
- package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/bar-x/index.js +10 -119
- package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/bar-y/index.js +5 -84
- package/dist/cjs/hooks/useShapes/funnel/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/funnel/index.js +4 -83
- package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/heatmap/index.js +4 -59
- package/dist/cjs/hooks/useShapes/index.d.ts +15 -16
- package/dist/cjs/hooks/useShapes/index.js +13 -13
- package/dist/cjs/hooks/useShapes/line/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/line/index.js +14 -172
- package/dist/cjs/hooks/useShapes/pie/index.d.ts +3 -5
- package/dist/cjs/hooks/useShapes/pie/index.js +3 -158
- package/dist/cjs/hooks/useShapes/radar/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/radar/index.js +2 -121
- package/dist/cjs/hooks/useShapes/sankey/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/sankey/index.js +2 -51
- package/dist/cjs/hooks/useShapes/scatter/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/scatter/index.js +3 -58
- package/dist/cjs/hooks/useShapes/treemap/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/treemap/index.js +2 -88
- package/dist/cjs/hooks/useShapes/utils.d.ts +3 -53
- package/dist/cjs/hooks/useShapes/utils.js +3 -140
- package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/waterfall/index.js +6 -119
- package/dist/cjs/hooks/useShapes/x-range/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/x-range/index.js +3 -98
- package/dist/cjs/hooks/useZoom/index.d.ts +1 -1
- package/dist/cjs/hooks/useZoom/index.js +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/libs/format-number/index.js +82 -14
- package/dist/cjs/libs/format-number/presets.d.ts +40 -0
- package/dist/cjs/libs/format-number/presets.js +66 -0
- package/dist/cjs/libs/format-number/types.d.ts +82 -3
- package/dist/cjs/setup-jsdom.js +7 -0
- package/dist/esm/components/ChartInner/index.js +1 -0
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +1 -0
- package/dist/esm/components/ChartInner/useChartInnerProps.js +13 -6
- package/dist/esm/components/Legend/index.js +13 -14
- package/dist/esm/components/Tooltip/index.js +22 -1
- package/dist/esm/core/axes/x-axis.js +1 -1
- package/dist/esm/core/axes/y-axis.js +1 -1
- package/dist/esm/core/brush/index.d.ts +2 -0
- package/dist/esm/core/brush/index.js +2 -0
- package/dist/esm/{hooks/useBrush → core/brush}/types.d.ts +2 -2
- package/dist/esm/{hooks/useBrush → core/brush}/utils.d.ts +1 -1
- package/dist/esm/core/chart/index.d.ts +1 -0
- package/dist/esm/core/chart/index.js +1 -0
- package/dist/esm/core/chart/types.d.ts +8 -0
- package/dist/esm/core/index.d.ts +3 -0
- package/dist/esm/core/index.js +3 -0
- package/dist/esm/core/layout/chart-dimensions.d.ts +1 -1
- package/dist/esm/core/range-slider/index.d.ts +2 -0
- package/dist/esm/core/range-slider/index.js +2 -0
- package/dist/esm/core/range-slider/types.d.ts +4 -0
- package/dist/{cjs/hooks/useRangeSlider → esm/core/range-slider}/utils.d.ts +5 -5
- package/dist/{cjs/hooks/useRangeSlider → esm/core/range-slider}/utils.js +1 -1
- package/dist/esm/core/scales/utils.d.ts +1 -1
- package/dist/esm/core/scales/utils.js +1 -1
- package/dist/esm/core/scales/x-scale.d.ts +2 -2
- package/dist/esm/core/scales/x-scale.js +2 -2
- package/dist/esm/core/scales/y-scale.js +69 -4
- package/dist/esm/core/series/prepare-area.js +1 -1
- package/dist/esm/core/series/prepare-bar-x.js +1 -1
- package/dist/esm/core/series/prepare-bar-y.js +1 -1
- package/dist/esm/core/series/prepare-funnel.js +1 -1
- package/dist/esm/core/series/prepare-heatmap.js +1 -1
- package/dist/esm/core/series/prepare-legend.d.ts +1 -1
- package/dist/esm/core/series/prepare-legend.js +2 -2
- package/dist/esm/core/series/prepare-line.js +1 -1
- package/dist/esm/core/series/prepare-pie.js +1 -1
- package/dist/esm/core/series/prepare-radar.js +1 -1
- package/dist/esm/core/series/prepare-sankey.js +1 -1
- package/dist/esm/core/series/prepare-scatter.js +1 -1
- package/dist/esm/core/series/prepare-treemap.js +1 -1
- package/dist/esm/core/series/prepare-waterfall.js +1 -1
- package/dist/esm/core/series/prepare-x-range.js +1 -1
- package/dist/esm/core/series/prepareSeries.d.ts +7 -1
- package/dist/esm/core/series/prepareSeries.js +31 -0
- package/dist/esm/core/series/types.d.ts +5 -0
- package/dist/esm/core/series/utils.d.ts +4 -0
- package/dist/esm/core/series/utils.js +9 -1
- package/dist/esm/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
- package/dist/esm/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
- package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
- package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.js +9 -4
- package/dist/esm/core/shapes/area/renderer.d.ts +11 -0
- package/dist/esm/core/shapes/area/renderer.js +175 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/area/types.d.ts +7 -8
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.d.ts +4 -4
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.js +6 -6
- package/dist/esm/core/shapes/bar-x/renderer.d.ts +9 -0
- package/dist/esm/core/shapes/bar-x/renderer.js +104 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/bar-x/types.d.ts +1 -2
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.d.ts +3 -3
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.js +3 -3
- package/dist/esm/core/shapes/bar-y/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/bar-y/renderer.js +74 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/utils.js +1 -1
- package/dist/esm/core/shapes/data-labels.d.ts +15 -0
- package/dist/esm/core/shapes/data-labels.js +15 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/funnel/prepare-data.js +1 -1
- package/dist/esm/core/shapes/funnel/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/funnel/renderer.js +74 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
- package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
- package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/prepare-data.js +3 -2
- package/dist/esm/core/shapes/heatmap/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/heatmap/renderer.js +50 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/heatmap/types.d.ts +2 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/line/prepare-data.d.ts +4 -4
- package/dist/esm/{hooks/useShapes → core/shapes}/line/prepare-data.js +12 -4
- package/dist/esm/core/shapes/line/renderer.d.ts +11 -0
- package/dist/esm/core/shapes/line/renderer.js +161 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/line/types.d.ts +7 -8
- package/dist/esm/core/shapes/marker.d.ts +45 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/marker.js +2 -2
- package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
- package/dist/esm/core/shapes/pie/renderer.d.ts +8 -0
- package/dist/esm/core/shapes/pie/renderer.js +160 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/pie/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/radar/prepare-data.js +2 -2
- package/dist/esm/core/shapes/radar/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/radar/renderer.js +122 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
- package/dist/esm/core/shapes/sankey/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/sankey/renderer.js +44 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/sankey/types.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/scatter/prepare-data.d.ts +3 -3
- package/dist/esm/{hooks/useShapes → core/shapes}/scatter/prepare-data.js +2 -2
- package/dist/esm/core/shapes/scatter/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/scatter/renderer.js +52 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/scatter/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/treemap/prepare-data.js +3 -3
- package/dist/esm/core/shapes/treemap/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/treemap/renderer.js +88 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/treemap/types.d.ts +1 -1
- package/dist/esm/core/shapes/treemap/types.js +1 -0
- package/dist/esm/core/shapes/utils.d.ts +76 -0
- package/dist/esm/core/shapes/utils.js +186 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/waterfall/prepare-data.js +4 -4
- package/dist/esm/core/shapes/waterfall/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/waterfall/renderer.js +109 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/types.d.ts +1 -1
- package/dist/esm/core/shapes/waterfall/types.js +1 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
- package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
- package/dist/esm/core/shapes/x-range/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/x-range/renderer.js +88 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/x-range/types.d.ts +1 -1
- package/dist/esm/core/shapes/x-range/types.js +1 -0
- package/dist/esm/core/types/chart/area.d.ts +0 -1
- package/dist/esm/core/types/chart/axis.d.ts +0 -1
- package/dist/esm/core/types/chart/base.d.ts +18 -7
- package/dist/esm/core/types/chart/tooltip.d.ts +3 -3
- package/dist/esm/core/types/formatter.d.ts +1 -40
- package/dist/{cjs/hooks/utils/get-band-size.js → esm/core/utils/band-size.js} +1 -1
- package/dist/esm/{hooks → core}/utils/bar-y.d.ts +3 -3
- package/dist/{cjs/hooks → esm/core}/utils/bar-y.js +4 -4
- package/dist/esm/core/utils/format.d.ts +2 -2
- package/dist/esm/core/utils/get-closest-data.d.ts +1 -1
- package/dist/esm/core/utils/get-closest-data.js +13 -8
- package/dist/esm/core/utils/series/sorting.js +1 -1
- package/dist/esm/core/utils/text.d.ts +0 -1
- package/dist/esm/core/utils/text.js +0 -1
- package/dist/esm/core/zoom/index.d.ts +2 -0
- package/dist/esm/core/zoom/index.js +2 -0
- package/dist/esm/core/zoom/types.js +1 -0
- package/dist/{cjs/hooks/useZoom → esm/core/zoom}/utils.d.ts +3 -3
- package/dist/{cjs/hooks/useZoom → esm/core/zoom}/utils.js +1 -1
- package/dist/esm/core/zoom/zoom.d.ts +3 -3
- package/dist/esm/hooks/index.d.ts +3 -3
- package/dist/esm/hooks/index.js +3 -3
- package/dist/esm/hooks/types.d.ts +2 -8
- package/dist/esm/hooks/useBrush/index.d.ts +1 -1
- package/dist/esm/hooks/useBrush/index.js +1 -1
- package/dist/esm/hooks/useRangeSlider/index.js +3 -3
- package/dist/esm/hooks/useRangeSlider/types.d.ts +6 -8
- package/dist/esm/hooks/useShapes/area/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/area/index.js +13 -185
- package/dist/esm/hooks/useShapes/bar-x/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/bar-x/index.js +10 -119
- package/dist/esm/hooks/useShapes/bar-y/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/bar-y/index.js +5 -84
- package/dist/esm/hooks/useShapes/funnel/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/funnel/index.js +4 -83
- package/dist/esm/hooks/useShapes/heatmap/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/heatmap/index.js +4 -59
- package/dist/esm/hooks/useShapes/index.d.ts +15 -16
- package/dist/esm/hooks/useShapes/index.js +13 -13
- package/dist/esm/hooks/useShapes/line/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/line/index.js +14 -172
- package/dist/esm/hooks/useShapes/pie/index.d.ts +3 -5
- package/dist/esm/hooks/useShapes/pie/index.js +3 -158
- package/dist/esm/hooks/useShapes/radar/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/radar/index.js +2 -121
- package/dist/esm/hooks/useShapes/sankey/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/sankey/index.js +2 -51
- package/dist/esm/hooks/useShapes/scatter/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/scatter/index.js +3 -58
- package/dist/esm/hooks/useShapes/treemap/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/treemap/index.js +2 -88
- package/dist/esm/hooks/useShapes/utils.d.ts +3 -53
- package/dist/esm/hooks/useShapes/utils.js +3 -140
- package/dist/esm/hooks/useShapes/waterfall/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/waterfall/index.js +6 -119
- package/dist/esm/hooks/useShapes/x-range/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/x-range/index.js +3 -98
- package/dist/esm/hooks/useZoom/index.d.ts +1 -1
- package/dist/esm/hooks/useZoom/index.js +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/libs/format-number/index.js +82 -14
- package/dist/esm/libs/format-number/presets.d.ts +40 -0
- package/dist/esm/libs/format-number/presets.js +66 -0
- package/dist/esm/libs/format-number/types.d.ts +82 -3
- package/dist/esm/setup-jsdom.js +7 -0
- package/package.json +5 -2
- package/dist/cjs/hooks/useSeries/index.d.ts +0 -12
- package/dist/cjs/hooks/useSeries/index.js +0 -40
- package/dist/cjs/hooks/useSeries/types.d.ts +0 -1
- package/dist/cjs/hooks/useSeries/types.js +0 -1
- package/dist/cjs/hooks/useSeries/utils.d.ts +0 -1
- package/dist/cjs/hooks/useSeries/utils.js +0 -1
- package/dist/cjs/hooks/useShapes/marker.d.ts +0 -15
- package/dist/cjs/hooks/utils/index.d.ts +0 -1
- package/dist/cjs/hooks/utils/index.js +0 -1
- package/dist/esm/hooks/useSeries/index.d.ts +0 -12
- package/dist/esm/hooks/useSeries/index.js +0 -40
- package/dist/esm/hooks/useSeries/types.d.ts +0 -1
- package/dist/esm/hooks/useSeries/types.js +0 -1
- package/dist/esm/hooks/useSeries/utils.d.ts +0 -1
- package/dist/esm/hooks/useSeries/utils.js +0 -1
- package/dist/esm/hooks/useShapes/marker.d.ts +0 -15
- package/dist/esm/hooks/utils/index.d.ts +0 -1
- package/dist/esm/hooks/utils/index.js +0 -1
- /package/dist/cjs/{hooks/useBrush → core/brush}/types.js +0 -0
- /package/dist/cjs/{hooks/useBrush → core/brush}/utils.js +0 -0
- /package/dist/cjs/{hooks/useShapes/area → core/chart}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/bar-x → core/range-slider}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/bar-y → core/shapes/area}/types.js +0 -0
- /package/dist/cjs/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
- /package/dist/cjs/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
- /package/dist/cjs/{hooks/useShapes/funnel → core/shapes/bar-x}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/heatmap → core/shapes/bar-y}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
- /package/dist/cjs/{hooks/useShapes/line → core/shapes/funnel}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/pie → core/shapes/heatmap}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/radar → core/shapes/line}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/sankey → core/shapes/pie}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
- /package/dist/cjs/{hooks/useShapes/scatter → core/shapes/radar}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
- /package/dist/cjs/{hooks/useShapes/treemap → core/shapes/sankey}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/waterfall → core/shapes/scatter}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/x-range → core/shapes/treemap}/types.js +0 -0
- /package/dist/cjs/{hooks/useZoom → core/shapes/waterfall}/types.js +0 -0
- /package/dist/{esm/hooks/useBrush → cjs/core/shapes/x-range}/types.js +0 -0
- /package/dist/cjs/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
- /package/dist/cjs/{hooks/useZoom → core/zoom}/types.d.ts +0 -0
- /package/dist/{esm/hooks/useShapes/area → cjs/core/zoom}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/bar-x → core/brush}/types.js +0 -0
- /package/dist/esm/{hooks/useBrush → core/brush}/utils.js +0 -0
- /package/dist/esm/{hooks/useShapes/bar-y → core/chart}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/funnel → core/range-slider}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/heatmap → core/shapes/area}/types.js +0 -0
- /package/dist/esm/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
- /package/dist/esm/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
- /package/dist/esm/{hooks/useShapes/line → core/shapes/bar-x}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/pie → core/shapes/bar-y}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
- /package/dist/esm/{hooks/useShapes/radar → core/shapes/funnel}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/sankey → core/shapes/heatmap}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/scatter → core/shapes/line}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/treemap → core/shapes/pie}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
- /package/dist/esm/{hooks/useShapes/waterfall → core/shapes/radar}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
- /package/dist/esm/{hooks/useShapes/x-range → core/shapes/sankey}/types.js +0 -0
- /package/dist/esm/{hooks/useZoom → core/shapes/scatter}/types.js +0 -0
- /package/dist/esm/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
- /package/dist/esm/{hooks/useZoom → core/zoom}/types.d.ts +0 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { path } from 'd3-path';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { getDataCategoryValue } from '../utils';
|
|
5
|
+
const ONE_POINT_DOMAIN_DATA_CAPACITY = 3;
|
|
6
|
+
export function getXValue(args) {
|
|
7
|
+
const { point, points, xAxis, xScale } = args;
|
|
8
|
+
if (xAxis.type === 'category') {
|
|
9
|
+
const xBandScale = xScale;
|
|
10
|
+
const categories = get(xAxis, 'categories', []);
|
|
11
|
+
const dataCategory = getDataCategoryValue({ axisDirection: 'x', categories, data: point });
|
|
12
|
+
return (xBandScale(dataCategory) || 0) + xBandScale.step() / 2;
|
|
13
|
+
}
|
|
14
|
+
let xLinearScale = xScale;
|
|
15
|
+
const [xMinDomain, xMaxDomain] = xLinearScale.domain();
|
|
16
|
+
if (Number(xMinDomain) === Number(xMaxDomain) &&
|
|
17
|
+
(points === null || points === void 0 ? void 0 : points.length) === ONE_POINT_DOMAIN_DATA_CAPACITY) {
|
|
18
|
+
const x1 = Number(points[0].x);
|
|
19
|
+
const xTarget = Number(points[1].x);
|
|
20
|
+
const x3 = Number(points[2].x);
|
|
21
|
+
if (!Number.isNaN(x1) && !Number.isNaN(xTarget) && !Number.isNaN(x3)) {
|
|
22
|
+
const xMin = Math.min(x1, xTarget, x3);
|
|
23
|
+
const xMax = Math.max(x1, xTarget, x3);
|
|
24
|
+
xLinearScale = xLinearScale
|
|
25
|
+
.copy()
|
|
26
|
+
.domain([xMin + (xTarget - xMin) / 2, xMax - (xMax - xTarget) / 2]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return point.x === null ? null : xLinearScale(point.x);
|
|
30
|
+
}
|
|
31
|
+
export function getYValue(args) {
|
|
32
|
+
const { point, points, yAxis, yScale } = args;
|
|
33
|
+
if (yAxis.type === 'category') {
|
|
34
|
+
const yBandScale = yScale;
|
|
35
|
+
const categories = get(yAxis, 'categories', []);
|
|
36
|
+
const dataCategory = getDataCategoryValue({ axisDirection: 'y', categories, data: point });
|
|
37
|
+
return (yBandScale(dataCategory) || 0) + yBandScale.step() / 2;
|
|
38
|
+
}
|
|
39
|
+
let yLinearScale = yScale;
|
|
40
|
+
const [yMinDomain, yMaxDomain] = yLinearScale.domain();
|
|
41
|
+
if (Number(yMinDomain) === Number(yMaxDomain) &&
|
|
42
|
+
(points === null || points === void 0 ? void 0 : points.length) === ONE_POINT_DOMAIN_DATA_CAPACITY) {
|
|
43
|
+
const y1 = Number(points[0].y);
|
|
44
|
+
const yTarget = Number(points[1].y);
|
|
45
|
+
const y3 = Number(points[2].y);
|
|
46
|
+
if (!Number.isNaN(y1) && !Number.isNaN(yTarget) && !Number.isNaN(y3)) {
|
|
47
|
+
const yMin = Math.min(y1, yTarget, y3);
|
|
48
|
+
const yMax = Math.max(y1, yTarget, y3);
|
|
49
|
+
yLinearScale = yLinearScale
|
|
50
|
+
.copy()
|
|
51
|
+
.domain([yMin + (yTarget - yMin) / 2, yMax - (yMax - yTarget) / 2]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return point.y === null ? null : yLinearScale(point.y);
|
|
55
|
+
}
|
|
56
|
+
// Slack for d3 scale rounding (a `500` edge can come back as `499.9999`).
|
|
57
|
+
// Half a pixel matches the ±0.5 of a 1px centered stroke and far exceeds any
|
|
58
|
+
// plausible float error.
|
|
59
|
+
const Y_RANGE_PIXEL_TOLERANCE = 0.5;
|
|
60
|
+
/**
|
|
61
|
+
* Hides out-of-range points from line/area path generators via `hiddenInLine`.
|
|
62
|
+
* Neighbors of in-range points are kept as anchors so the path retains its
|
|
63
|
+
* slope at the plot edges instead of stopping abruptly at the visible point.
|
|
64
|
+
*
|
|
65
|
+
* Pixel check alone is not enough: a degenerate/clamped scale domain (see the
|
|
66
|
+
* y-scale.ts guard) can map out-of-range data into the plot rectangle, leaving
|
|
67
|
+
* phantom hover targets. Pass `axisMin`/`axisMax` + `getDataY` to also reject
|
|
68
|
+
* points whose raw value is outside the user's intended range.
|
|
69
|
+
*
|
|
70
|
+
* Stacked shapes must NOT pass the data check — `point.data.y` is the unstacked
|
|
71
|
+
* value and doesn't reflect where the point actually lands on the plot.
|
|
72
|
+
*/
|
|
73
|
+
export function markHiddenPointsOutOfYRange(args) {
|
|
74
|
+
const { points, yScale, yAxisTop, axisMin, axisMax, getDataY } = args;
|
|
75
|
+
const [yRangeA, yRangeB] = yScale.range();
|
|
76
|
+
const yMinPx = yAxisTop + Math.min(yRangeA, yRangeB);
|
|
77
|
+
const yMaxPx = yAxisTop + Math.max(yRangeA, yRangeB);
|
|
78
|
+
const hasDataBoundsCheck = Boolean(getDataY) && (typeof axisMin === 'number' || typeof axisMax === 'number');
|
|
79
|
+
const isInRange = (point) => {
|
|
80
|
+
if (point.y === null) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (hasDataBoundsCheck) {
|
|
84
|
+
const dataY = getDataY === null || getDataY === void 0 ? void 0 : getDataY(point);
|
|
85
|
+
if (typeof dataY === 'number') {
|
|
86
|
+
if (typeof axisMin === 'number' && dataY < axisMin) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (typeof axisMax === 'number' && dataY > axisMax) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return (point.y >= yMinPx - Y_RANGE_PIXEL_TOLERANCE &&
|
|
95
|
+
point.y <= yMaxPx + Y_RANGE_PIXEL_TOLERANCE);
|
|
96
|
+
};
|
|
97
|
+
const inRange = points.map(isInRange);
|
|
98
|
+
for (let idx = 0; idx < points.length; idx++) {
|
|
99
|
+
if (!inRange[idx] && !inRange[idx - 1] && !inRange[idx + 1]) {
|
|
100
|
+
points[idx].hiddenInLine = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export function shapeKey(d) {
|
|
105
|
+
return d.id || -1;
|
|
106
|
+
}
|
|
107
|
+
export function setActiveState(args) {
|
|
108
|
+
const { element, datum, state, active } = args;
|
|
109
|
+
const elementSelection = select(element);
|
|
110
|
+
if (datum.active !== active) {
|
|
111
|
+
datum.active = active;
|
|
112
|
+
const opacity = datum.active ? null : state === null || state === void 0 ? void 0 : state.opacity;
|
|
113
|
+
elementSelection.attr('opacity', opacity || null);
|
|
114
|
+
}
|
|
115
|
+
return datum;
|
|
116
|
+
}
|
|
117
|
+
export function getRectPath(args) {
|
|
118
|
+
const { x, y, width, height, borderRadius = 0 } = args;
|
|
119
|
+
const borderRadiuses = typeof borderRadius === 'number' ? new Array(4).fill(borderRadius) : borderRadius;
|
|
120
|
+
const [borderRadiusTopLeft = 0, borderRadiusTopRight = 0, borderRadiusBottomRight = 0, borderRadiusBottomLeft = 0,] = borderRadiuses !== null && borderRadiuses !== void 0 ? borderRadiuses : [];
|
|
121
|
+
const p = path();
|
|
122
|
+
let startAngle = -Math.PI / 2;
|
|
123
|
+
const angle = Math.PI / 2;
|
|
124
|
+
p.moveTo(x + borderRadiusTopLeft, y);
|
|
125
|
+
p.lineTo(x + width - borderRadiusTopRight, y);
|
|
126
|
+
p.arc(x + width - borderRadiusTopRight, y + borderRadiusTopRight, borderRadiusTopRight, startAngle, startAngle + angle);
|
|
127
|
+
startAngle += angle;
|
|
128
|
+
p.lineTo(x + width, y + height - borderRadiusBottomRight);
|
|
129
|
+
p.arc(x + width - borderRadiusBottomRight, y + height - borderRadiusBottomRight, borderRadiusBottomRight, startAngle, startAngle + angle);
|
|
130
|
+
startAngle += angle;
|
|
131
|
+
p.lineTo(x + borderRadiusBottomLeft, y + height);
|
|
132
|
+
p.arc(x + borderRadiusBottomLeft, y + height - borderRadiusBottomLeft, borderRadiusBottomLeft, startAngle, startAngle + angle);
|
|
133
|
+
startAngle += angle;
|
|
134
|
+
p.lineTo(x, y + borderRadiusTopLeft);
|
|
135
|
+
p.arc(x + borderRadiusTopLeft, y + borderRadiusTopLeft, borderRadiusTopLeft, startAngle, startAngle + angle);
|
|
136
|
+
p.closePath();
|
|
137
|
+
return p;
|
|
138
|
+
}
|
|
139
|
+
export function getRectBorderPath(args) {
|
|
140
|
+
const { x, y, width, height, borderWidth, borderRadius = 0 } = args;
|
|
141
|
+
if (!borderWidth) {
|
|
142
|
+
return '';
|
|
143
|
+
}
|
|
144
|
+
const halfWidth = borderWidth / 2;
|
|
145
|
+
const expandedWidth = width + borderWidth;
|
|
146
|
+
const expandedHeight = height + borderWidth;
|
|
147
|
+
const innerWidth = width - borderWidth;
|
|
148
|
+
const innerHeight = height - borderWidth;
|
|
149
|
+
const borderRadiuses = typeof borderRadius === 'number' ? new Array(4).fill(borderRadius) : borderRadius;
|
|
150
|
+
const [borderRadiusTopLeft = 0, borderRadiusTopRight = 0, borderRadiusBottomRight = 0, borderRadiusBottomLeft = 0,] = borderRadiuses !== null && borderRadiuses !== void 0 ? borderRadiuses : [];
|
|
151
|
+
const adjustOuterRadius = (radius) => (radius ? radius + halfWidth : 0);
|
|
152
|
+
const outerBorderRadius = [
|
|
153
|
+
adjustOuterRadius(borderRadiusTopLeft),
|
|
154
|
+
adjustOuterRadius(borderRadiusTopRight),
|
|
155
|
+
adjustOuterRadius(borderRadiusBottomRight),
|
|
156
|
+
adjustOuterRadius(borderRadiusBottomLeft),
|
|
157
|
+
];
|
|
158
|
+
const outerPath = getRectPath({
|
|
159
|
+
x: x - halfWidth,
|
|
160
|
+
y: y - halfWidth,
|
|
161
|
+
width: expandedWidth,
|
|
162
|
+
height: expandedHeight,
|
|
163
|
+
borderRadius: outerBorderRadius,
|
|
164
|
+
}).toString();
|
|
165
|
+
if (innerWidth <= 0 || innerHeight <= 0) {
|
|
166
|
+
return outerPath;
|
|
167
|
+
}
|
|
168
|
+
const innerBorderRadius = [
|
|
169
|
+
Math.max(borderRadiusTopLeft - halfWidth, 0),
|
|
170
|
+
Math.max(borderRadiusTopRight - halfWidth, 0),
|
|
171
|
+
Math.max(borderRadiusBottomRight - halfWidth, 0),
|
|
172
|
+
Math.max(borderRadiusBottomLeft - halfWidth, 0),
|
|
173
|
+
];
|
|
174
|
+
const innerPath = getRectPath({
|
|
175
|
+
x: x + halfWidth,
|
|
176
|
+
y: y + halfWidth,
|
|
177
|
+
width: innerWidth,
|
|
178
|
+
height: innerHeight,
|
|
179
|
+
borderRadius: innerBorderRadius,
|
|
180
|
+
}).toString();
|
|
181
|
+
return `${outerPath} ${innerPath}`;
|
|
182
|
+
}
|
|
183
|
+
export function getClipPathIdByBounds(args) {
|
|
184
|
+
const { bounds, clipPathId } = args;
|
|
185
|
+
return bounds ? `${clipPathId}-${bounds}` : clipPathId;
|
|
186
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PreparedSeriesOptions, PreparedWaterfallSeries } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { ChartScale } from '../../scales/types';
|
|
3
|
+
import type { PreparedSeriesOptions, PreparedWaterfallSeries } from '../../series/types';
|
|
4
4
|
import type { PreparedWaterfallData } from './types';
|
|
5
5
|
export declare const prepareWaterfallData: (args: {
|
|
6
6
|
series: PreparedWaterfallSeries[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import sortBy from 'lodash/sortBy';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { MIN_BAR_GAP, MIN_BAR_WIDTH } from '../../shapes/bar-constants';
|
|
4
|
+
import { getXValue, getYValue } from '../../shapes/utils';
|
|
5
|
+
import { getLabelsSize } from '../../utils';
|
|
6
|
+
import { getFormattedValue } from '../../utils/format';
|
|
7
7
|
async function getLabelData(d, plotHeight) {
|
|
8
8
|
var _a, _b;
|
|
9
9
|
if (!d.series.dataLabels.enabled) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedWaterfallData } from './types';
|
|
4
|
+
export declare function renderWaterfall(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: PreparedWaterfallData[], seriesOptions: PreparedSeriesOptions, allowOverlapDataLabels: boolean, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { color } from 'd3-color';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import { line as lineGenerator } from 'd3-shape';
|
|
4
|
+
import get from 'lodash/get';
|
|
5
|
+
import { block } from '../../../utils';
|
|
6
|
+
import { DASH_STYLE } from '../../constants';
|
|
7
|
+
import { filterOverlappingLabels, getLineDashArray, getWaterfallPointColor } from '../../utils';
|
|
8
|
+
import { renderDataLabels } from '../data-labels';
|
|
9
|
+
const b = block('waterfall');
|
|
10
|
+
export function renderWaterfall(elements, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher) {
|
|
11
|
+
const svgElement = select(elements.plot);
|
|
12
|
+
const connectorSelector = `.${b('connector')}`;
|
|
13
|
+
const hoverOptions = get(seriesOptions, 'waterfall.states.hover');
|
|
14
|
+
const inactiveOptions = get(seriesOptions, 'waterfall.states.inactive');
|
|
15
|
+
svgElement.selectAll('*').remove();
|
|
16
|
+
const rectSelection = svgElement
|
|
17
|
+
.selectAll('allRects')
|
|
18
|
+
.data(preparedData)
|
|
19
|
+
.join('rect')
|
|
20
|
+
.attr('class', b('segment'))
|
|
21
|
+
.attr('x', (d) => d.x)
|
|
22
|
+
.attr('y', (d) => d.y)
|
|
23
|
+
.attr('height', (d) => d.height)
|
|
24
|
+
.attr('width', (d) => d.width)
|
|
25
|
+
.attr('fill', (d) => getWaterfallPointColor(d.data, d.series))
|
|
26
|
+
.attr('opacity', (d) => d.opacity)
|
|
27
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
28
|
+
let dataLabels = preparedData.map((d) => d.label).filter(Boolean);
|
|
29
|
+
if (!allowOverlapDataLabels) {
|
|
30
|
+
dataLabels = filterOverlappingLabels(dataLabels);
|
|
31
|
+
}
|
|
32
|
+
const labelSelection = renderDataLabels({
|
|
33
|
+
container: svgElement,
|
|
34
|
+
data: dataLabels,
|
|
35
|
+
className: b('label'),
|
|
36
|
+
});
|
|
37
|
+
// Add the connector line between bars
|
|
38
|
+
svgElement
|
|
39
|
+
.selectAll(connectorSelector)
|
|
40
|
+
.data(preparedData)
|
|
41
|
+
.join('path')
|
|
42
|
+
.attr('class', b('connector'))
|
|
43
|
+
.attr('d', (d, index) => {
|
|
44
|
+
const line = lineGenerator();
|
|
45
|
+
const prev = preparedData[index - 1];
|
|
46
|
+
if (!prev) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const points = [];
|
|
50
|
+
if (Number(prev.data.y) > 0) {
|
|
51
|
+
points.push([prev.x, prev.y]);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
points.push([prev.x, prev.y + prev.height]);
|
|
55
|
+
}
|
|
56
|
+
if (Number(d.data.y) > 0 && !d.data.total) {
|
|
57
|
+
points.push([d.x + d.width, d.y + d.height]);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
points.push([d.x + d.width, d.y]);
|
|
61
|
+
}
|
|
62
|
+
return line(points);
|
|
63
|
+
})
|
|
64
|
+
.attr('stroke-width', 1)
|
|
65
|
+
.attr('stroke-dasharray', () => getLineDashArray(DASH_STYLE.Dash, 1));
|
|
66
|
+
function handleShapeHover(data) {
|
|
67
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
68
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
69
|
+
if (!data) {
|
|
70
|
+
if (hoverEnabled) {
|
|
71
|
+
rectSelection.attr('fill', (d) => getWaterfallPointColor(d.data, d.series));
|
|
72
|
+
}
|
|
73
|
+
if (inactiveEnabled) {
|
|
74
|
+
rectSelection.attr('opacity', null);
|
|
75
|
+
labelSelection.attr('opacity', null);
|
|
76
|
+
}
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (hoverEnabled) {
|
|
80
|
+
const hoveredValues = data.map((d) => d.data.x);
|
|
81
|
+
rectSelection.attr('fill', (d) => {
|
|
82
|
+
var _a;
|
|
83
|
+
const fillColor = getWaterfallPointColor(d.data, d.series);
|
|
84
|
+
if (hoveredValues.includes(d.data.x)) {
|
|
85
|
+
const brightness = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness;
|
|
86
|
+
return ((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(brightness).toString()) || fillColor;
|
|
87
|
+
}
|
|
88
|
+
return fillColor;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (inactiveEnabled) {
|
|
92
|
+
const hoveredSeries = data.map((d) => d.series.id);
|
|
93
|
+
rectSelection.attr('opacity', (d) => {
|
|
94
|
+
return hoveredSeries.includes(d.series.id)
|
|
95
|
+
? null
|
|
96
|
+
: (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
97
|
+
});
|
|
98
|
+
labelSelection.attr('opacity', (d) => {
|
|
99
|
+
return hoveredSeries.includes(d.series.id)
|
|
100
|
+
? null
|
|
101
|
+
: (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.waterfall', handleShapeHover);
|
|
106
|
+
return () => {
|
|
107
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.waterfall', null);
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HtmlItem, LabelData, WaterfallSeriesData } from '../../../types';
|
|
2
|
-
import type { PreparedWaterfallSeries } from '../../
|
|
2
|
+
import type { PreparedWaterfallSeries } from '../../series/types';
|
|
3
3
|
export type PreparedWaterfallData = {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PreparedXRangeSeries } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { ChartScale } from '../../scales/types';
|
|
3
|
+
import type { PreparedXRangeSeries } from '../../series/types';
|
|
4
4
|
import type { PreparedXRangeData } from './types';
|
|
5
5
|
type PrepareXRangeDataArgs = {
|
|
6
6
|
series: PreparedXRangeSeries[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { MIN_BAR_WIDTH } from '../../shapes/bar-constants';
|
|
3
|
+
import { getDataCategoryValue, getLabelsSize, getTextSizeFn, getTextWithElipsis } from '../../utils';
|
|
4
|
+
import { getBandSize } from '../../utils/band-size';
|
|
5
|
+
import { getFormattedValue } from '../../utils/format';
|
|
6
6
|
const DEFAULT_BAR_PADDING = 0.2;
|
|
7
7
|
export async function prepareXRangeData(args) {
|
|
8
8
|
var _a;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedXRangeData } from './types';
|
|
4
|
+
export declare function renderXRange(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: PreparedXRangeData[], seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { color } from 'd3-color';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { block } from '../../../utils';
|
|
5
|
+
import { getRectPath } from '../../shapes/utils';
|
|
6
|
+
import { getLineDashArray } from '../../utils';
|
|
7
|
+
import { renderDataLabels } from '../data-labels';
|
|
8
|
+
const b = block('x-range');
|
|
9
|
+
export function renderXRange(elements, preparedData, seriesOptions, dispatcher) {
|
|
10
|
+
const svgElement = select(elements.plot);
|
|
11
|
+
svgElement.selectAll('*').remove();
|
|
12
|
+
const segmentSelection = svgElement
|
|
13
|
+
.selectAll(`path.${b('segment')}`)
|
|
14
|
+
.data(preparedData)
|
|
15
|
+
.join('path')
|
|
16
|
+
.attr('d', (d) => {
|
|
17
|
+
const borderRadius = Math.min(d.height / 2, d.width / 2, d.series.borderRadius);
|
|
18
|
+
return getRectPath({
|
|
19
|
+
x: d.x,
|
|
20
|
+
y: d.y,
|
|
21
|
+
width: d.width,
|
|
22
|
+
height: d.height,
|
|
23
|
+
borderRadius,
|
|
24
|
+
}).toString();
|
|
25
|
+
})
|
|
26
|
+
.attr('class', b('segment'))
|
|
27
|
+
.attr('fill', (d) => d.color)
|
|
28
|
+
.attr('opacity', (d) => { var _a; return (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity; })
|
|
29
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
30
|
+
svgElement
|
|
31
|
+
.selectAll(`path.${b('segment-border')}`)
|
|
32
|
+
.data(preparedData.filter((d) => d.series.borderWidth > 0))
|
|
33
|
+
.join('path')
|
|
34
|
+
.attr('d', (d) => {
|
|
35
|
+
const borderRadius = Math.min(d.height / 2, d.width / 2, d.series.borderRadius);
|
|
36
|
+
return getRectPath({
|
|
37
|
+
x: d.x,
|
|
38
|
+
y: d.y,
|
|
39
|
+
width: d.width,
|
|
40
|
+
height: d.height,
|
|
41
|
+
borderRadius,
|
|
42
|
+
}).toString();
|
|
43
|
+
})
|
|
44
|
+
.attr('class', b('segment-border'))
|
|
45
|
+
.attr('fill', 'none')
|
|
46
|
+
.attr('stroke', (d) => d.series.borderColor)
|
|
47
|
+
.attr('stroke-width', (d) => d.series.borderWidth)
|
|
48
|
+
.attr('stroke-dasharray', (d) => getLineDashArray(d.series.borderDashStyle, d.series.borderWidth))
|
|
49
|
+
.attr('opacity', (d) => { var _a; return (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity; })
|
|
50
|
+
.attr('pointer-events', 'none');
|
|
51
|
+
const svgLabels = preparedData.flatMap((d) => d.svgLabels);
|
|
52
|
+
renderDataLabels({
|
|
53
|
+
container: svgElement,
|
|
54
|
+
data: svgLabels,
|
|
55
|
+
className: b('label'),
|
|
56
|
+
})
|
|
57
|
+
.attr('dominant-baseline', 'central')
|
|
58
|
+
.attr('pointer-events', 'none');
|
|
59
|
+
const hoverOptions = get(seriesOptions, 'x-range.states.hover');
|
|
60
|
+
const inactiveOptions = get(seriesOptions, 'x-range.states.inactive');
|
|
61
|
+
function handleShapeHover(data) {
|
|
62
|
+
if (hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled) {
|
|
63
|
+
const hoveredSet = new Set(data === null || data === void 0 ? void 0 : data.map((d) => d.data));
|
|
64
|
+
segmentSelection.attr('fill', (d) => {
|
|
65
|
+
var _a;
|
|
66
|
+
const fillColor = d.color;
|
|
67
|
+
if (hoveredSet.has(d.data)) {
|
|
68
|
+
return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) || fillColor);
|
|
69
|
+
}
|
|
70
|
+
return fillColor;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled) {
|
|
74
|
+
const hoveredSeries = data === null || data === void 0 ? void 0 : data.map((d) => d.series.id);
|
|
75
|
+
segmentSelection.attr('opacity', (d) => {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
if ((hoveredSeries === null || hoveredSeries === void 0 ? void 0 : hoveredSeries.length) && !hoveredSeries.includes(d.series.id)) {
|
|
78
|
+
return inactiveOptions.opacity || null;
|
|
79
|
+
}
|
|
80
|
+
return (_b = (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity) !== null && _b !== void 0 ? _b : null;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.x-range', handleShapeHover);
|
|
85
|
+
return () => {
|
|
86
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.x-range', null);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HtmlItem, LabelData, TooltipDataChunkXRange } from '../../../types';
|
|
2
|
-
import type { PreparedXRangeSeries } from '../../
|
|
2
|
+
import type { PreparedXRangeSeries } from '../../series/types';
|
|
3
3
|
export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -87,7 +87,6 @@ export interface AreaSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
87
87
|
* - `'connect'`: Connect points across null values (skip nulls in rendering). **Not supported with `stacking`.**
|
|
88
88
|
* - `'zero'`: Treat null values as zero
|
|
89
89
|
* - `'skip'`: Omit the data point (creates gap in area)
|
|
90
|
-
*
|
|
91
90
|
* @default 'skip'
|
|
92
91
|
*/
|
|
93
92
|
nullMode?: 'connect' | 'zero' | 'skip';
|
|
@@ -298,7 +298,6 @@ export interface AxisPlotShape extends AxisPlot {
|
|
|
298
298
|
* Called with the pixel coordinates of the shape and the plot area dimensions.
|
|
299
299
|
* Must return a string of valid SVG markup that will be inserted inside a `<g>` container
|
|
300
300
|
* positioned at the shape's axis value.
|
|
301
|
-
*
|
|
302
301
|
* @example
|
|
303
302
|
* ```
|
|
304
303
|
* renderer: ({plotHeight}) =>
|
|
@@ -12,29 +12,40 @@ export type CustomFormat = {
|
|
|
12
12
|
type: 'custom';
|
|
13
13
|
formatter: (args: {
|
|
14
14
|
value: unknown;
|
|
15
|
-
formattedValue?: string;
|
|
16
15
|
}) => string;
|
|
17
16
|
};
|
|
18
17
|
/**
|
|
19
18
|
* Specifies how a value should be formatted for display.
|
|
20
19
|
*
|
|
21
20
|
* - `{ type: 'number' }` — numeric formatting with optional precision, units, percent display, etc.
|
|
22
|
-
*
|
|
23
|
-
* - `{ type: 'date' }` — date/time formatting
|
|
24
|
-
*
|
|
21
|
+
* See [FormatNumberOptions](https://gravity-ui.github.io/charts/pages/api/Utilities/interfaces/FormatNumberOptions.html) for all available options.
|
|
22
|
+
* - `{ type: 'date' }` — date/time formatting.
|
|
23
|
+
* - `{ type: 'custom' }` — user-defined formatter function. Receives the raw `value`
|
|
24
|
+
* and returns the display string. Use it when the built-in number/date formatters
|
|
25
|
+
* are not enough (e.g. bytes → KB/MB/GB, currency with locale, etc.).
|
|
25
26
|
* @example
|
|
26
27
|
* // Two decimal places, shown as percent
|
|
27
28
|
* { type: 'number', precision: 2, format: 'percent' }
|
|
28
|
-
*
|
|
29
29
|
* @example
|
|
30
30
|
* // Compact thousands: 1 500 000 → "1.5M"
|
|
31
31
|
* { type: 'number', unit: 'auto', precision: 1 }
|
|
32
|
-
*
|
|
33
32
|
* @example
|
|
34
33
|
* // Date value (Unix ms) formatted as "17 October 2025"
|
|
35
34
|
* { type: 'date', format: 'DD MMMM YYYY' }
|
|
35
|
+
* @example
|
|
36
|
+
* // Bytes → human-readable size
|
|
37
|
+
* {
|
|
38
|
+
* type: 'custom',
|
|
39
|
+
* formatter: ({value}) => {
|
|
40
|
+
* const bytes = Number(value);
|
|
41
|
+
* if (!Number.isFinite(bytes)) return String(value);
|
|
42
|
+
* const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
43
|
+
* const i = Math.min(units.length - 1, Math.floor(Math.log(Math.abs(bytes) || 1) / Math.log(1024)));
|
|
44
|
+
* return `${(bytes / 1024 ** i).toFixed(1)} ${units[i]}`;
|
|
45
|
+
* },
|
|
46
|
+
* }
|
|
36
47
|
*/
|
|
37
|
-
export type ValueFormat = NumberFormat | DateFormat;
|
|
48
|
+
export type ValueFormat = NumberFormat | DateFormat | CustomFormat;
|
|
38
49
|
export interface BaseDataLabels {
|
|
39
50
|
/**
|
|
40
51
|
* Enable or disable the data labels
|
|
@@ -5,7 +5,7 @@ import type { AreaSeries, AreaSeriesData } from './area';
|
|
|
5
5
|
import type { AxisPlotBand, AxisPlotLine, AxisPlotShape, ChartXAxis, ChartYAxis } from './axis';
|
|
6
6
|
import type { BarXSeries, BarXSeriesData } from './bar-x';
|
|
7
7
|
import type { BarYSeries, BarYSeriesData } from './bar-y';
|
|
8
|
-
import type {
|
|
8
|
+
import type { ValueFormat } from './base';
|
|
9
9
|
import type { FunnelSeries, FunnelSeriesData } from './funnel';
|
|
10
10
|
import type { HeatmapSeries, HeatmapSeriesData } from './heatmap';
|
|
11
11
|
import type { LineSeries, LineSeriesData } from './line';
|
|
@@ -107,7 +107,7 @@ export interface ChartTooltipRendererArgs<T = MeaningfulAny> {
|
|
|
107
107
|
xAxis?: ChartXAxis | null;
|
|
108
108
|
yAxis?: ChartYAxis;
|
|
109
109
|
/** Formatting settings for tooltip header row (includes computed default). */
|
|
110
|
-
headerFormat?: ValueFormat
|
|
110
|
+
headerFormat?: ValueFormat;
|
|
111
111
|
}
|
|
112
112
|
export interface ChartTooltipTotalsAggregationArgs<T = MeaningfulAny> extends ChartTooltipRendererArgs<T> {
|
|
113
113
|
}
|
|
@@ -167,7 +167,7 @@ export interface ChartTooltip<T = MeaningfulAny> {
|
|
|
167
167
|
/** Formatting settings for tooltip value. */
|
|
168
168
|
valueFormat?: ValueFormat;
|
|
169
169
|
/** Formatting settings for tooltip header row. */
|
|
170
|
-
headerFormat?: ValueFormat
|
|
170
|
+
headerFormat?: ValueFormat;
|
|
171
171
|
/** Settings for totals block in tooltip */
|
|
172
172
|
totals?: {
|
|
173
173
|
/**
|
|
@@ -1,40 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/**
|
|
3
|
-
* Number of decimal places to display.
|
|
4
|
-
* Use `'auto'` to determine precision automatically based on the value magnitude.
|
|
5
|
-
*/
|
|
6
|
-
precision?: number | 'auto';
|
|
7
|
-
/** When `true`, inserts a thousands separator (e.g. `1 500 000`). */
|
|
8
|
-
showRankDelimiter?: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* BCP 47 language tag used for locale-aware formatting (e.g. `'en'`, `'ru'`).
|
|
11
|
-
* Defaults to the application locale when omitted.
|
|
12
|
-
*/
|
|
13
|
-
lang?: string;
|
|
14
|
-
/** Internal rendering hint for axis label layout. Not intended for public use. */
|
|
15
|
-
labelMode?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface FormatNumberOptions extends FormatOptions {
|
|
18
|
-
/**
|
|
19
|
-
* Display mode for the numeric value.
|
|
20
|
-
* - `'number'` — plain number (default).
|
|
21
|
-
* - `'percent'` — value is multiplied by 100 and rendered with a `%` suffix.
|
|
22
|
-
*/
|
|
23
|
-
format?: 'number' | 'percent';
|
|
24
|
-
/** Factor applied to the value before formatting. For example, `multiplier: 1000` converts seconds to milliseconds. */
|
|
25
|
-
multiplier?: number;
|
|
26
|
-
/** String prepended to the formatted value (e.g. `'$'`). */
|
|
27
|
-
prefix?: string;
|
|
28
|
-
/** String appended to the formatted value (e.g. `' USD'`). */
|
|
29
|
-
postfix?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Compact unit suffix applied to large numbers.
|
|
32
|
-
* - `'auto'` — picks the most appropriate unit automatically (`k`, `m`, `b`, `t`).
|
|
33
|
-
* - `'k'` — thousands (÷ 1 000).
|
|
34
|
-
* - `'m'` — millions (÷ 1 000 000).
|
|
35
|
-
* - `'b'` — billions (÷ 1 000 000 000).
|
|
36
|
-
* - `'t'` — trillions (÷ 1 000 000 000 000).
|
|
37
|
-
* - `null` — no unit suffix.
|
|
38
|
-
*/
|
|
39
|
-
unit?: 'auto' | 'k' | 'm' | 'b' | 't' | null;
|
|
40
|
-
}
|
|
1
|
+
export type { FormatNumberOptions, FormatOptions, FormatUnitScale, FormatUnitScaleEntry, } from '../../libs/format-number/types';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ChartScale } from '../../core/scales/types';
|
|
2
1
|
import type { BarYSeries, BarYSeriesData } from '../../types';
|
|
3
|
-
import type { PreparedYAxis } from '../
|
|
4
|
-
import type {
|
|
2
|
+
import type { PreparedYAxis } from '../axes/types';
|
|
3
|
+
import type { ChartScale } from '../scales/types';
|
|
4
|
+
import type { PreparedBarYSeries, PreparedSeriesOptions } from '../series/types';
|
|
5
5
|
/**
|
|
6
6
|
* BarY always filters out data with null or replace null by zero.
|
|
7
7
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { max } from 'd3-array';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import {
|
|
4
|
-
import { MIN_BAR_GAP, MIN_BAR_GROUP_GAP, MIN_BAR_WIDTH } from '../constants';
|
|
5
|
-
import {
|
|
6
|
-
import { getBandSize } from './
|
|
3
|
+
import { getSeriesStackId } from '../series/utils';
|
|
4
|
+
import { MIN_BAR_GAP, MIN_BAR_GROUP_GAP, MIN_BAR_WIDTH } from '../shapes/bar-constants';
|
|
5
|
+
import { getDataCategoryValue } from '../utils';
|
|
6
|
+
import { getBandSize } from './band-size';
|
|
7
7
|
const isSeriesDataValid = (d) => d.x !== null;
|
|
8
8
|
export function groupBarYDataByYValue(series, yAxis) {
|
|
9
9
|
const data = {};
|