@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getUniqId } from '../utils';
|
|
3
2
|
import { DASH_STYLE, DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
3
|
+
import { getUniqId } from '../utils';
|
|
4
4
|
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
5
5
|
import { prepareLegendSymbol } from './utils';
|
|
6
6
|
export function prepareXRangeSeries(args) {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ScaleOrdinal } from 'd3-scale';
|
|
2
|
-
import type { ChartSeries, ChartSeriesOptions } from '../../types';
|
|
2
|
+
import type { ChartData, ChartSeries, ChartSeriesOptions } from '../../types';
|
|
3
3
|
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
|
+
export declare const getPreparedSeries: ({ seriesData, seriesOptions, colors, preparedLegend, }: {
|
|
5
|
+
seriesData: ChartData["series"]["data"];
|
|
6
|
+
seriesOptions: ChartData["series"]["options"];
|
|
7
|
+
colors: string[];
|
|
8
|
+
preparedLegend?: PreparedLegend | null;
|
|
9
|
+
}) => Promise<PreparedSeries[]>;
|
|
4
10
|
export declare function prepareSeries(args: {
|
|
5
11
|
type: ChartSeries['type'];
|
|
6
12
|
series: ChartSeries[];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { group } from 'd3-array';
|
|
2
|
+
import { scaleOrdinal } from 'd3-scale';
|
|
1
3
|
import { ChartError } from '../../libs';
|
|
4
|
+
import { getSeriesNames } from '../utils';
|
|
2
5
|
import { prepareArea } from './prepare-area';
|
|
3
6
|
import { prepareBarXSeries } from './prepare-bar-x';
|
|
4
7
|
import { prepareBarYSeries } from './prepare-bar-y';
|
|
@@ -12,6 +15,34 @@ import { prepareScatterSeries } from './prepare-scatter';
|
|
|
12
15
|
import { prepareTreemap } from './prepare-treemap';
|
|
13
16
|
import { prepareWaterfallSeries } from './prepare-waterfall';
|
|
14
17
|
import { prepareXRangeSeries } from './prepare-x-range';
|
|
18
|
+
export const getPreparedSeries = async ({ seriesData, seriesOptions, colors, preparedLegend, }) => {
|
|
19
|
+
const seriesNames = getSeriesNames(seriesData);
|
|
20
|
+
const colorScale = scaleOrdinal(seriesNames, colors);
|
|
21
|
+
const groupedSeries = group(seriesData, (item, index) => {
|
|
22
|
+
if (item.type === 'line') {
|
|
23
|
+
return `${item.type}_${index}`;
|
|
24
|
+
}
|
|
25
|
+
return item.type;
|
|
26
|
+
});
|
|
27
|
+
const acc = [];
|
|
28
|
+
if (!preparedLegend) {
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
31
|
+
const list = Array.from(groupedSeries);
|
|
32
|
+
for (let i = 0; i < list.length; i++) {
|
|
33
|
+
const [_groupId, seriesList] = list[i];
|
|
34
|
+
const seriesType = seriesList[0].type;
|
|
35
|
+
acc.push(...(await prepareSeries({
|
|
36
|
+
type: seriesType,
|
|
37
|
+
series: seriesList,
|
|
38
|
+
seriesOptions,
|
|
39
|
+
legend: preparedLegend,
|
|
40
|
+
colorScale,
|
|
41
|
+
colors,
|
|
42
|
+
})));
|
|
43
|
+
}
|
|
44
|
+
return acc;
|
|
45
|
+
};
|
|
15
46
|
export async function prepareSeries(args) {
|
|
16
47
|
const { type, series, seriesOptions, legend, colors, colorScale } = args;
|
|
17
48
|
switch (type) {
|
|
@@ -16,6 +16,11 @@ export type PreparedAnnotation = {
|
|
|
16
16
|
padding: [number, number];
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
+
export type AnnotationAnchor = {
|
|
20
|
+
annotation: PreparedAnnotation;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
19
24
|
export type RectLegendSymbol = {
|
|
20
25
|
shape: 'rect';
|
|
21
26
|
} & Required<RectLegendSymbolOptions>;
|
|
@@ -9,3 +9,7 @@ export declare function prepareLegendSymbol(series: {
|
|
|
9
9
|
};
|
|
10
10
|
}, symbolType?: `${SymbolType}`): PreparedLegendSymbol;
|
|
11
11
|
export declare function getSeriesStackId(series: StackedSeries): string;
|
|
12
|
+
export declare const getVisibleSeries: ({ preparedSeries, activeLegendItems, }: {
|
|
13
|
+
preparedSeries: PreparedSeries[];
|
|
14
|
+
activeLegendItems: string[];
|
|
15
|
+
}) => PreparedSeries[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import memoize from 'lodash/memoize';
|
|
2
|
-
import { getSymbolBBoxWidth } from '../utils';
|
|
3
2
|
import { SymbolType } from '../constants';
|
|
3
|
+
import { getSymbolBBoxWidth } from '../utils';
|
|
4
4
|
import { getUniqId } from '../utils/misc';
|
|
5
5
|
import { DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_LEGEND_SYMBOL_SIZE } from './constants';
|
|
6
6
|
export const getActiveLegendItems = (series) => {
|
|
@@ -35,3 +35,11 @@ export function getSeriesStackId(series) {
|
|
|
35
35
|
}
|
|
36
36
|
return stackId;
|
|
37
37
|
}
|
|
38
|
+
export const getVisibleSeries = ({ preparedSeries, activeLegendItems, }) => {
|
|
39
|
+
return preparedSeries.map((singleSeries) => {
|
|
40
|
+
if (singleSeries.legend.enabled) {
|
|
41
|
+
return Object.assign(Object.assign({}, singleSeries), { visible: activeLegendItems.includes(singleSeries.legend.groupId) });
|
|
42
|
+
}
|
|
43
|
+
return singleSeries;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { Selection } from 'd3-selection';
|
|
2
|
-
import type {
|
|
3
|
-
type AnnotationAnchor = {
|
|
4
|
-
annotation: PreparedAnnotation;
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
};
|
|
8
|
-
export { type AnnotationAnchor };
|
|
2
|
+
import type { AnnotationAnchor } from '../series/types';
|
|
9
3
|
export declare function renderAnnotations(args: {
|
|
10
4
|
anchors: AnnotationAnchor[];
|
|
11
5
|
container: Selection<SVGGElement, unknown, null, undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { block } from '../../utils';
|
|
3
|
+
import { DESCENDER_RATIO } from '../utils/text';
|
|
4
4
|
const b = block('annotation');
|
|
5
5
|
const ARROW_WIDTH = 18;
|
|
6
6
|
const ARROW_HEIGHT = 9;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { PreparedAreaSeries, PreparedSeriesOptions } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { PreparedSplit } from '../../layout/split-types';
|
|
3
|
+
import type { ChartScale } from '../../scales/types';
|
|
4
|
+
import type { PreparedAreaSeries, PreparedSeriesOptions } from '../../series/types';
|
|
5
5
|
import type { PreparedAreaData } from './types';
|
|
6
6
|
export declare const prepareAreaData: (args: {
|
|
7
7
|
series: PreparedAreaSeries[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { group, min, sort } from 'd3-array';
|
|
2
2
|
import isNil from 'lodash/isNil';
|
|
3
3
|
import round from 'lodash/round';
|
|
4
|
-
import { prepareAnnotation } from '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { prepareAnnotation } from '../../series/prepare-annotation';
|
|
5
|
+
import { getXValue, getYValue, markHiddenPointsOutOfYRange } from '../../shapes/utils';
|
|
6
|
+
import { getDataCategoryValue, getLabelsSize, getTextSizeFn } from '../../utils';
|
|
7
|
+
import { getFormattedValue } from '../../utils/format';
|
|
8
8
|
function getXValues(series, xAxis, xScale) {
|
|
9
9
|
const categories = xAxis.categories || [];
|
|
10
10
|
const xValues = series.reduce((acc, s) => {
|
|
@@ -315,6 +315,11 @@ export const prepareAreaData = async (args) => {
|
|
|
315
315
|
}
|
|
316
316
|
return result;
|
|
317
317
|
}, []);
|
|
318
|
+
markHiddenPointsOutOfYRange({
|
|
319
|
+
points,
|
|
320
|
+
yScale: seriesYScale,
|
|
321
|
+
yAxisTop,
|
|
322
|
+
});
|
|
318
323
|
seriesStackData.push({
|
|
319
324
|
annotations,
|
|
320
325
|
points,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedAreaData } from './types';
|
|
4
|
+
export declare function renderArea(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
markers: SVGGElement;
|
|
7
|
+
hoverMarkers: SVGGElement;
|
|
8
|
+
annotations: SVGGElement;
|
|
9
|
+
boundsWidth: number;
|
|
10
|
+
boundsHeight: number;
|
|
11
|
+
}, preparedData: PreparedAreaData[], seriesOptions: PreparedSeriesOptions, allowOverlapDataLabels: boolean, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { color } from 'd3-color';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import { area as areaGenerator, line as lineGenerator } from 'd3-shape';
|
|
4
|
+
import get from 'lodash/get';
|
|
5
|
+
import { block } from '../../../utils';
|
|
6
|
+
import { filterOverlappingLabels } from '../../utils';
|
|
7
|
+
import { renderAnnotations } from '../annotation';
|
|
8
|
+
import { renderDataLabels } from '../data-labels';
|
|
9
|
+
import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
|
|
10
|
+
import { setActiveState } from '../utils';
|
|
11
|
+
const b = block('area');
|
|
12
|
+
export function renderArea(elements, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher) {
|
|
13
|
+
const plotSvgElement = select(elements.plot);
|
|
14
|
+
const markersSvgElement = select(elements.markers);
|
|
15
|
+
const hoverMarkersSvgElement = select(elements.hoverMarkers);
|
|
16
|
+
const annotationsSvgElement = select(elements.annotations);
|
|
17
|
+
const hoverOptions = get(seriesOptions, 'area.states.hover');
|
|
18
|
+
const inactiveOptions = get(seriesOptions, 'area.states.inactive');
|
|
19
|
+
const line = lineGenerator()
|
|
20
|
+
.x((d) => d.x)
|
|
21
|
+
.defined((d) => d.y !== null && !d.hiddenInLine)
|
|
22
|
+
.y((d) => d.y);
|
|
23
|
+
plotSvgElement.selectAll('*').remove();
|
|
24
|
+
markersSvgElement.selectAll('*').remove();
|
|
25
|
+
const shapeSelection = plotSvgElement
|
|
26
|
+
.selectAll('shape')
|
|
27
|
+
.data(preparedData)
|
|
28
|
+
.join('g')
|
|
29
|
+
.attr('class', b('series'))
|
|
30
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
31
|
+
shapeSelection
|
|
32
|
+
.append('path')
|
|
33
|
+
.attr('class', b('line'))
|
|
34
|
+
.attr('d', (d) => line(d.points))
|
|
35
|
+
.attr('fill', 'none')
|
|
36
|
+
.attr('stroke', (d) => d.color)
|
|
37
|
+
.attr('stroke-width', (d) => d.width)
|
|
38
|
+
.attr('stroke-linejoin', 'round')
|
|
39
|
+
.attr('stroke-linecap', 'round');
|
|
40
|
+
const area = areaGenerator()
|
|
41
|
+
.defined((d) => d.y !== null && !d.hiddenInLine)
|
|
42
|
+
.x((d) => d.x)
|
|
43
|
+
.y0((d) => d.y0)
|
|
44
|
+
.y1((d) => d.y);
|
|
45
|
+
shapeSelection
|
|
46
|
+
.append('path')
|
|
47
|
+
.attr('class', b('region'))
|
|
48
|
+
.attr('d', (d) => area(d.points))
|
|
49
|
+
.attr('fill', (d) => d.color)
|
|
50
|
+
.attr('opacity', (d) => d.opacity);
|
|
51
|
+
let dataLabels = preparedData.reduce((acc, d) => {
|
|
52
|
+
return acc.concat(d.svgLabels);
|
|
53
|
+
}, []);
|
|
54
|
+
if (!allowOverlapDataLabels) {
|
|
55
|
+
dataLabels = filterOverlappingLabels(dataLabels);
|
|
56
|
+
}
|
|
57
|
+
const labelsSelection = renderDataLabels({
|
|
58
|
+
container: plotSvgElement,
|
|
59
|
+
data: dataLabels,
|
|
60
|
+
className: b('label'),
|
|
61
|
+
});
|
|
62
|
+
const markers = preparedData.reduce((acc, d) => acc.concat(d.markers), []);
|
|
63
|
+
const markerSelection = markersSvgElement
|
|
64
|
+
.selectAll('marker')
|
|
65
|
+
.data(markers)
|
|
66
|
+
.join('g')
|
|
67
|
+
.call(renderMarker);
|
|
68
|
+
renderAnnotations({
|
|
69
|
+
anchors: preparedData.flatMap((d) => d.annotations),
|
|
70
|
+
container: annotationsSvgElement,
|
|
71
|
+
plotHeight: elements.boundsHeight,
|
|
72
|
+
plotWidth: elements.boundsWidth,
|
|
73
|
+
});
|
|
74
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
75
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
76
|
+
function handleShapeHover(data) {
|
|
77
|
+
const selected = (data === null || data === void 0 ? void 0 : data.filter((d) => d.series.type === 'area')) || [];
|
|
78
|
+
const selectedDataItems = selected.map((d) => d.data);
|
|
79
|
+
const selectedSeriesIds = selected.map((d) => { var _a; return (_a = d.series) === null || _a === void 0 ? void 0 : _a.id; });
|
|
80
|
+
shapeSelection.datum((d, index, list) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const elementSelection = select(list[index]);
|
|
83
|
+
const hovered = Boolean(hoverEnabled && selectedSeriesIds.includes(d.id));
|
|
84
|
+
if (d.hovered !== hovered) {
|
|
85
|
+
d.hovered = hovered;
|
|
86
|
+
let strokeColor = d.color || '';
|
|
87
|
+
if (d.hovered) {
|
|
88
|
+
strokeColor =
|
|
89
|
+
((_a = color(strokeColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
|
|
90
|
+
strokeColor;
|
|
91
|
+
}
|
|
92
|
+
elementSelection.selectAll(`.${b('line')}`).attr('stroke', strokeColor);
|
|
93
|
+
elementSelection.selectAll(`.${b('region')}`).attr('fill', strokeColor);
|
|
94
|
+
}
|
|
95
|
+
return setActiveState({
|
|
96
|
+
element: list[index],
|
|
97
|
+
state: inactiveOptions,
|
|
98
|
+
active: Boolean(!inactiveEnabled ||
|
|
99
|
+
!selectedSeriesIds.length ||
|
|
100
|
+
selectedSeriesIds.includes(d.id)),
|
|
101
|
+
datum: d,
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
labelsSelection.datum((d, index, list) => {
|
|
105
|
+
return setActiveState({
|
|
106
|
+
element: list[index],
|
|
107
|
+
state: inactiveOptions,
|
|
108
|
+
active: Boolean(!inactiveEnabled ||
|
|
109
|
+
!selectedSeriesIds.length ||
|
|
110
|
+
selectedSeriesIds.includes(d.series.id)),
|
|
111
|
+
datum: d,
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
markerSelection.datum((d, index, list) => {
|
|
115
|
+
const elementSelection = select(list[index]);
|
|
116
|
+
const hovered = Boolean(hoverEnabled && selectedDataItems.includes(d.point.data));
|
|
117
|
+
if (d.hovered !== hovered) {
|
|
118
|
+
d.hovered = hovered;
|
|
119
|
+
elementSelection.attr('visibility', getMarkerVisibility(d));
|
|
120
|
+
selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
|
|
121
|
+
selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
|
|
122
|
+
}
|
|
123
|
+
if (d.point.series.marker.states.normal.enabled) {
|
|
124
|
+
const isActive = Boolean(!inactiveEnabled ||
|
|
125
|
+
!selectedSeriesIds.length ||
|
|
126
|
+
selectedSeriesIds.includes(d.point.series.id));
|
|
127
|
+
setActiveState({
|
|
128
|
+
element: list[index],
|
|
129
|
+
state: inactiveOptions,
|
|
130
|
+
active: isActive,
|
|
131
|
+
datum: d,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return d;
|
|
135
|
+
});
|
|
136
|
+
hoverMarkersSvgElement.selectAll('*').remove();
|
|
137
|
+
if (hoverEnabled && selected.length > 0) {
|
|
138
|
+
const hoverOnlyMarkers = [];
|
|
139
|
+
for (const chunk of selected) {
|
|
140
|
+
const seriesData = preparedData.find((pd) => pd.id === chunk.series.id);
|
|
141
|
+
if (!seriesData) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const { series } = seriesData;
|
|
145
|
+
if (series.marker.states.normal.enabled || !series.marker.states.hover.enabled) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const point = seriesData.points.find((p) => p.data === chunk.data);
|
|
149
|
+
if (!point || point.y === null) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
hoverOnlyMarkers.push({
|
|
153
|
+
point: point,
|
|
154
|
+
active: true,
|
|
155
|
+
hovered: true,
|
|
156
|
+
clipped: false,
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (hoverOnlyMarkers.length > 0) {
|
|
160
|
+
hoverMarkersSvgElement
|
|
161
|
+
.selectAll('g')
|
|
162
|
+
.data(hoverOnlyMarkers)
|
|
163
|
+
.join('g')
|
|
164
|
+
.call(renderMarker)
|
|
165
|
+
.each((_d, i, nodes) => {
|
|
166
|
+
selectMarkerSymbol(select(nodes[i])).call(setMarker, 'hover');
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.area', handleShapeHover);
|
|
172
|
+
return () => {
|
|
173
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.area', null);
|
|
174
|
+
};
|
|
175
|
+
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type { PreparedAnnotation } from '../../../core/series/types';
|
|
2
1
|
import type { AreaSeriesData, HtmlItem, LabelData } from '../../../types';
|
|
3
|
-
import type { PreparedAreaSeries } from '../../
|
|
4
|
-
import type { AnnotationAnchor } from '../annotation';
|
|
2
|
+
import type { AnnotationAnchor, PreparedAnnotation, PreparedAreaSeries } from '../../series/types';
|
|
5
3
|
export type PointData = {
|
|
6
|
-
y0: number;
|
|
7
|
-
x: number;
|
|
8
|
-
y: number | null;
|
|
9
|
-
data: AreaSeriesData;
|
|
10
|
-
series: PreparedAreaSeries;
|
|
11
4
|
annotation?: PreparedAnnotation;
|
|
12
5
|
color?: string;
|
|
6
|
+
data: AreaSeriesData;
|
|
7
|
+
hiddenInLine?: boolean;
|
|
8
|
+
series: PreparedAreaSeries;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number | null;
|
|
11
|
+
y0: number;
|
|
13
12
|
};
|
|
14
13
|
export type MarkerPointData = PointData & {
|
|
15
14
|
y: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { PreparedBarXSeries, PreparedSeriesOptions } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { PreparedSplit } from '../../layout/split-types';
|
|
3
|
+
import type { ChartScale } from '../../scales/types';
|
|
4
|
+
import type { PreparedBarXSeries, PreparedSeriesOptions } from '../../series/types';
|
|
5
5
|
import type { PreparedBarXData } from './types';
|
|
6
6
|
export declare const prepareBarXData: (args: {
|
|
7
7
|
series: PreparedBarXSeries[];
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ascending, descending, max, min, reverse, sort } from 'd3-array';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import { prepareAnnotation } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { prepareAnnotation } from '../../series/prepare-annotation';
|
|
4
|
+
import { getSeriesStackId } from '../../series/utils';
|
|
5
|
+
import { MIN_BAR_GAP, MIN_BAR_GROUP_GAP, MIN_BAR_WIDTH } from '../../shapes/bar-constants';
|
|
6
|
+
import { getDataCategoryValue, getLabelsSize } from '../../utils';
|
|
7
|
+
import { getBandSize } from '../../utils/band-size';
|
|
8
|
+
import { getFormattedValue } from '../../utils/format';
|
|
9
9
|
const isSeriesDataValid = (d) => d.y !== null;
|
|
10
10
|
async function getLabelData(d, xMax) {
|
|
11
11
|
var _a;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedBarXData } from './types';
|
|
4
|
+
export declare function renderBarX(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
annotations: SVGGElement;
|
|
7
|
+
boundsWidth: number;
|
|
8
|
+
boundsHeight: number;
|
|
9
|
+
}, preparedData: PreparedBarXData[], seriesOptions: PreparedSeriesOptions, allowOverlapDataLabels: boolean, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,104 @@
|
|
|
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 { filterOverlappingLabels } from '../../utils';
|
|
6
|
+
import { renderAnnotations } from '../annotation';
|
|
7
|
+
import { renderDataLabels } from '../data-labels';
|
|
8
|
+
import { getRectPath } from '../utils';
|
|
9
|
+
const b = block('bar-x');
|
|
10
|
+
export function renderBarX(elements, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher) {
|
|
11
|
+
const svgElement = select(elements.plot);
|
|
12
|
+
const annotationsSvgElement = select(elements.annotations);
|
|
13
|
+
const hoverOptions = get(seriesOptions, 'bar-x.states.hover');
|
|
14
|
+
const inactiveOptions = get(seriesOptions, 'bar-x.states.inactive');
|
|
15
|
+
svgElement.selectAll('*').remove();
|
|
16
|
+
const rectSelection = svgElement
|
|
17
|
+
.selectAll('allRects')
|
|
18
|
+
.data(preparedData)
|
|
19
|
+
.join('path')
|
|
20
|
+
.attr('d', (d) => {
|
|
21
|
+
const borderRadius = d.isLastStackItem
|
|
22
|
+
? Math.min(d.height, d.width / 2, d.series.borderRadius)
|
|
23
|
+
: 0;
|
|
24
|
+
const p = getRectPath({
|
|
25
|
+
x: d.x,
|
|
26
|
+
y: d.y,
|
|
27
|
+
width: d.width,
|
|
28
|
+
height: d.height,
|
|
29
|
+
borderRadius: [borderRadius, borderRadius, 0, 0],
|
|
30
|
+
});
|
|
31
|
+
return p.toString();
|
|
32
|
+
})
|
|
33
|
+
.attr('class', b('segment'))
|
|
34
|
+
.attr('fill', (d) => d.data.color || d.series.color)
|
|
35
|
+
.attr('opacity', (d) => d.opacity)
|
|
36
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
37
|
+
let dataLabels = preparedData.map((d) => d.svgLabels).flat();
|
|
38
|
+
if (!allowOverlapDataLabels) {
|
|
39
|
+
dataLabels = filterOverlappingLabels(dataLabels);
|
|
40
|
+
}
|
|
41
|
+
const labelSelection = renderDataLabels({
|
|
42
|
+
container: svgElement,
|
|
43
|
+
data: dataLabels,
|
|
44
|
+
className: b('label'),
|
|
45
|
+
});
|
|
46
|
+
const annotationAnchors = [];
|
|
47
|
+
for (const d of preparedData) {
|
|
48
|
+
if (d.annotation) {
|
|
49
|
+
annotationAnchors.push({
|
|
50
|
+
annotation: d.annotation,
|
|
51
|
+
x: d.x + d.width / 2,
|
|
52
|
+
y: d.y,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
renderAnnotations({
|
|
57
|
+
anchors: annotationAnchors,
|
|
58
|
+
container: annotationsSvgElement,
|
|
59
|
+
plotHeight: elements.boundsHeight,
|
|
60
|
+
plotWidth: elements.boundsWidth,
|
|
61
|
+
});
|
|
62
|
+
function handleShapeHover(data) {
|
|
63
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
64
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
65
|
+
if (!data) {
|
|
66
|
+
if (hoverEnabled) {
|
|
67
|
+
rectSelection.attr('fill', (d) => d.data.color || d.series.color);
|
|
68
|
+
}
|
|
69
|
+
if (inactiveEnabled) {
|
|
70
|
+
rectSelection.attr('opacity', null);
|
|
71
|
+
labelSelection.attr('opacity', null);
|
|
72
|
+
}
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (hoverEnabled) {
|
|
76
|
+
const hoveredValues = data.map((d) => d.data.x);
|
|
77
|
+
rectSelection.attr('fill', (d) => {
|
|
78
|
+
var _a;
|
|
79
|
+
const fillColor = d.data.color || d.series.color;
|
|
80
|
+
if (hoveredValues.includes(d.data.x)) {
|
|
81
|
+
return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) || fillColor);
|
|
82
|
+
}
|
|
83
|
+
return fillColor;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (inactiveEnabled) {
|
|
87
|
+
const hoveredSeries = data.map((d) => d.series.id);
|
|
88
|
+
rectSelection.attr('opacity', (d) => {
|
|
89
|
+
return hoveredSeries.includes(d.series.id)
|
|
90
|
+
? null
|
|
91
|
+
: (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
92
|
+
});
|
|
93
|
+
labelSelection.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
|
+
}
|
|
99
|
+
}
|
|
100
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-x', handleShapeHover);
|
|
101
|
+
return () => {
|
|
102
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-x', null);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { PreparedAnnotation } from '../../../core/series/types';
|
|
2
1
|
import type { HtmlItem, LabelData, TooltipDataChunkBarX } from '../../../types';
|
|
3
|
-
import type { PreparedBarXSeries } from '../../
|
|
2
|
+
import type { PreparedAnnotation, PreparedBarXSeries } from '../../series/types';
|
|
4
3
|
export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
|
|
5
4
|
annotation?: PreparedAnnotation;
|
|
6
5
|
x: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PreparedBarYSeries, PreparedSeriesOptions } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { ChartScale } from '../../scales/types';
|
|
3
|
+
import type { PreparedBarYSeries, PreparedSeriesOptions } from '../../series/types';
|
|
4
4
|
import type { BarYShapesArgs } from './types';
|
|
5
5
|
export declare function prepareBarYData(args: {
|
|
6
6
|
boundsHeight: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ascending, descending, sort } from 'd3-array';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import { filterOverlappingLabels, getHtmlLabelConstraintedPosition, getLabelsSize, getSvgLabelConstraintedPosition, getTextSizeFn, } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { filterOverlappingLabels, getHtmlLabelConstraintedPosition, getLabelsSize, getSvgLabelConstraintedPosition, getTextSizeFn, } from '../../utils';
|
|
4
|
+
import { getBarYLayout, groupBarYDataByYValue } from '../../utils/bar-y';
|
|
5
|
+
import { getFormattedValue } from '../../utils/format';
|
|
6
6
|
export async function prepareBarYData(args) {
|
|
7
7
|
var _a, _b;
|
|
8
8
|
const { boundsHeight, boundsWidth, series, seriesOptions, xAxis, yAxis, xScale, yScale: [yScale], } = args;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { BarYShapesArgs } from './types';
|
|
4
|
+
export declare function renderBarY(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: BarYShapesArgs, seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,74 @@
|
|
|
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 { renderDataLabels } from '../data-labels';
|
|
6
|
+
import { getAdjustedRectBorderPath, getAdjustedRectPath } from './utils';
|
|
7
|
+
const b = block('bar-y');
|
|
8
|
+
export function renderBarY(elements, preparedData, seriesOptions, dispatcher) {
|
|
9
|
+
const { shapes, labels: dataLabels } = preparedData;
|
|
10
|
+
const svgElement = select(elements.plot);
|
|
11
|
+
svgElement.selectAll('*').remove();
|
|
12
|
+
const segmentSelection = svgElement
|
|
13
|
+
.selectAll(`path.${b('segment')}`)
|
|
14
|
+
.data(shapes)
|
|
15
|
+
.join('path')
|
|
16
|
+
.attr('d', (d) => getAdjustedRectPath(d))
|
|
17
|
+
.attr('class', b('segment'))
|
|
18
|
+
.attr('x', (d) => d.x)
|
|
19
|
+
.attr('y', (d) => d.y)
|
|
20
|
+
.attr('height', (d) => d.height)
|
|
21
|
+
.attr('width', (d) => d.width)
|
|
22
|
+
.attr('fill', (d) => d.color)
|
|
23
|
+
.attr('opacity', (d) => d.data.opacity || null)
|
|
24
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
25
|
+
const borderSelection = svgElement
|
|
26
|
+
.selectAll(`path.${b('segment-border')}`)
|
|
27
|
+
.data(shapes.filter((d) => d.borderWidth > 0))
|
|
28
|
+
.join('path')
|
|
29
|
+
.attr('d', (d) => getAdjustedRectBorderPath(d))
|
|
30
|
+
.attr('class', b('segment-border'))
|
|
31
|
+
.attr('fill', (d) => d.borderColor)
|
|
32
|
+
.attr('fill-rule', 'evenodd')
|
|
33
|
+
.attr('opacity', (d) => d.data.opacity || null)
|
|
34
|
+
.attr('pointer-events', 'none');
|
|
35
|
+
const labelSelection = renderDataLabels({
|
|
36
|
+
container: svgElement,
|
|
37
|
+
data: dataLabels,
|
|
38
|
+
className: b('label'),
|
|
39
|
+
});
|
|
40
|
+
const hoverOptions = get(seriesOptions, 'bar-y.states.hover');
|
|
41
|
+
const inactiveOptions = get(seriesOptions, 'bar-y.states.inactive');
|
|
42
|
+
function handleShapeHover(data) {
|
|
43
|
+
if (hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled) {
|
|
44
|
+
const hovered = data === null || data === void 0 ? void 0 : data.reduce((acc, d) => {
|
|
45
|
+
acc.add(d.data.y);
|
|
46
|
+
return acc;
|
|
47
|
+
}, new Set());
|
|
48
|
+
segmentSelection.attr('fill', (d) => {
|
|
49
|
+
var _a;
|
|
50
|
+
const fillColor = d.color;
|
|
51
|
+
if (hovered === null || hovered === void 0 ? void 0 : hovered.has(d.data.y)) {
|
|
52
|
+
return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) || fillColor);
|
|
53
|
+
}
|
|
54
|
+
return fillColor;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled) {
|
|
58
|
+
const hoveredSeries = data === null || data === void 0 ? void 0 : data.map((d) => d.series.id);
|
|
59
|
+
const newOpacity = (d) => {
|
|
60
|
+
if ((hoveredSeries === null || hoveredSeries === void 0 ? void 0 : hoveredSeries.length) && !hoveredSeries.includes(d.series.id)) {
|
|
61
|
+
return inactiveOptions.opacity || null;
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
segmentSelection.attr('opacity', newOpacity);
|
|
66
|
+
borderSelection.attr('opacity', newOpacity);
|
|
67
|
+
labelSelection.attr('opacity', newOpacity);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-y', handleShapeHover);
|
|
71
|
+
return () => {
|
|
72
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.bar-y', null);
|
|
73
|
+
};
|
|
74
|
+
}
|