@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,122 @@
|
|
|
1
|
+
import { color } from 'd3-color';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import { line } from 'd3-shape';
|
|
4
|
+
import get from 'lodash/get';
|
|
5
|
+
import { block } from '../../../utils';
|
|
6
|
+
import { renderDataLabels } from '../../shapes/data-labels';
|
|
7
|
+
import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../../shapes/marker';
|
|
8
|
+
import { setActiveState } from '../../shapes/utils';
|
|
9
|
+
const b = block('radar');
|
|
10
|
+
export function renderRadar(elements, preparedData, seriesOptions, dispatcher) {
|
|
11
|
+
const svgElement = select(elements.plot);
|
|
12
|
+
svgElement.selectAll('*').remove();
|
|
13
|
+
const areaSelector = `.${b('area')}`;
|
|
14
|
+
const radarSelection = svgElement
|
|
15
|
+
.selectAll('radar')
|
|
16
|
+
.data(preparedData)
|
|
17
|
+
.join('g')
|
|
18
|
+
.attr('id', (radarData) => radarData.id)
|
|
19
|
+
.attr('class', b('item'))
|
|
20
|
+
.attr('cursor', (radarData) => radarData.cursor);
|
|
21
|
+
// render axes
|
|
22
|
+
radarSelection
|
|
23
|
+
.selectAll(`.${b('axis')}`)
|
|
24
|
+
.data((radarData) => radarData.axes)
|
|
25
|
+
.join('line')
|
|
26
|
+
.attr('class', b('axis'))
|
|
27
|
+
.attr('x1', (d) => d.radar.center[0])
|
|
28
|
+
.attr('y1', (d) => d.radar.center[1])
|
|
29
|
+
.attr('x2', (d) => d.point[0])
|
|
30
|
+
.attr('y2', (d) => d.point[1])
|
|
31
|
+
.attr('stroke', (d) => d.strokeColor)
|
|
32
|
+
.attr('stroke-width', (d) => d.strokeWidth);
|
|
33
|
+
// render grid lines
|
|
34
|
+
radarSelection
|
|
35
|
+
.selectAll(`.${b('grid')}`)
|
|
36
|
+
.data((radarData) => radarData.grid)
|
|
37
|
+
.join('path')
|
|
38
|
+
.attr('class', b('grid'))
|
|
39
|
+
.attr('d', (d) => `${line()(d.path)} Z`)
|
|
40
|
+
.attr('fill', 'none')
|
|
41
|
+
.attr('stroke', (d) => d.strokeColor)
|
|
42
|
+
.attr('stroke-width', (d) => d.strokeWidth);
|
|
43
|
+
// render radar area
|
|
44
|
+
const shapesSelection = radarSelection
|
|
45
|
+
.selectAll(areaSelector)
|
|
46
|
+
.data((radarData) => radarData.shapes)
|
|
47
|
+
.join('g')
|
|
48
|
+
.attr('class', b('area'));
|
|
49
|
+
shapesSelection
|
|
50
|
+
.append('path')
|
|
51
|
+
.attr('d', (d) => d.path)
|
|
52
|
+
.attr('fill', (d) => d.color)
|
|
53
|
+
.attr('fill-opacity', (d) => d.fillOpacity)
|
|
54
|
+
.attr('stroke', (d) => d.borderColor)
|
|
55
|
+
.attr('stroke-width', (d) => d.borderWidth);
|
|
56
|
+
// render markers
|
|
57
|
+
const markerSelection = shapesSelection
|
|
58
|
+
.selectAll('marker')
|
|
59
|
+
.data((radarData) => radarData.points)
|
|
60
|
+
.join('g')
|
|
61
|
+
.call(renderMarker);
|
|
62
|
+
// Render labels
|
|
63
|
+
radarSelection.each(function (radarData) {
|
|
64
|
+
renderDataLabels({
|
|
65
|
+
container: select(this),
|
|
66
|
+
data: radarData.labels,
|
|
67
|
+
className: b('label'),
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
// Handle hover events
|
|
71
|
+
const eventName = `hover-shape.radar`;
|
|
72
|
+
const hoverOptions = get(seriesOptions, 'radar.states.hover');
|
|
73
|
+
const inactiveOptions = get(seriesOptions, 'radar.states.inactive');
|
|
74
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (data) => {
|
|
75
|
+
const closest = data === null || data === void 0 ? void 0 : data.find((d) => d.closest);
|
|
76
|
+
const selectedSeries = closest === null || closest === void 0 ? void 0 : closest.series;
|
|
77
|
+
const selectedSeriesData = closest === null || closest === void 0 ? void 0 : closest.data;
|
|
78
|
+
const selectedSeriesId = selectedSeries === null || selectedSeries === void 0 ? void 0 : selectedSeries.id;
|
|
79
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
80
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
81
|
+
shapesSelection.datum((d, i, elements) => {
|
|
82
|
+
var _a;
|
|
83
|
+
const hovered = Boolean(hoverEnabled && ((_a = d.series) === null || _a === void 0 ? void 0 : _a.id) === selectedSeriesId);
|
|
84
|
+
if (d.hovered !== hovered) {
|
|
85
|
+
d.hovered = hovered;
|
|
86
|
+
select(elements[i]).attr('fill', () => {
|
|
87
|
+
var _a;
|
|
88
|
+
const initialColor = d.color;
|
|
89
|
+
if (d.hovered) {
|
|
90
|
+
return (((_a = color(initialColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
|
|
91
|
+
initialColor);
|
|
92
|
+
}
|
|
93
|
+
return initialColor;
|
|
94
|
+
});
|
|
95
|
+
if (hovered) {
|
|
96
|
+
select(elements[i]).raise();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
setActiveState({
|
|
100
|
+
element: elements[i],
|
|
101
|
+
state: inactiveOptions,
|
|
102
|
+
active: Boolean(!inactiveEnabled || !selectedSeriesId || selectedSeriesId === d.series.id),
|
|
103
|
+
datum: d,
|
|
104
|
+
});
|
|
105
|
+
markerSelection.datum((markerData, index, markers) => {
|
|
106
|
+
const hoveredState = Boolean(hoverEnabled && markerData.data === selectedSeriesData);
|
|
107
|
+
if (markerData.hovered !== hoveredState) {
|
|
108
|
+
markerData.hovered = hoveredState;
|
|
109
|
+
const elementSelection = select(markers[index]);
|
|
110
|
+
elementSelection.attr('visibility', getMarkerVisibility(markerData));
|
|
111
|
+
selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
|
|
112
|
+
selectMarkerSymbol(elementSelection).call(setMarker, hoveredState ? 'hover' : 'normal');
|
|
113
|
+
}
|
|
114
|
+
return markerData;
|
|
115
|
+
});
|
|
116
|
+
return d;
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
return () => {
|
|
120
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HtmlItem, LabelData, RadarSeriesData } from '../../../types';
|
|
2
|
-
import type { PreparedRadarSeries } from '../../
|
|
2
|
+
import type { PreparedRadarSeries } from '../../series/types';
|
|
3
3
|
export type RadarLabelData = LabelData & {
|
|
4
4
|
maxWidth: number;
|
|
5
5
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFormattedValue } from '
|
|
1
|
+
import { getFormattedValue } from '../../utils/format';
|
|
2
2
|
import { sankey, sankeyLinkHorizontal } from './sankey-layout';
|
|
3
3
|
export function prepareSankeyData(args) {
|
|
4
4
|
const { series, width, height } = args;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedSankeyData } from './types';
|
|
4
|
+
export declare function renderSankey(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: PreparedSankeyData, _seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { select } from 'd3-selection';
|
|
2
|
+
import { block } from '../../../utils';
|
|
3
|
+
import { renderDataLabels } from '../data-labels';
|
|
4
|
+
const b = block('sankey');
|
|
5
|
+
export function renderSankey(elements, preparedData, _seriesOptions, dispatcher) {
|
|
6
|
+
const svgElement = select(elements.plot);
|
|
7
|
+
svgElement.selectAll('*').remove();
|
|
8
|
+
// nodes
|
|
9
|
+
svgElement
|
|
10
|
+
.append('g')
|
|
11
|
+
.selectAll()
|
|
12
|
+
.data(preparedData.nodes)
|
|
13
|
+
.join('rect')
|
|
14
|
+
.attr('x', (d) => d.x0)
|
|
15
|
+
.attr('y', (d) => d.y0)
|
|
16
|
+
.attr('height', (d) => d.y1 - d.y0)
|
|
17
|
+
.attr('width', (d) => d.x1 - d.x0)
|
|
18
|
+
.attr('fill', (d) => d.color);
|
|
19
|
+
// links
|
|
20
|
+
svgElement
|
|
21
|
+
.append('g')
|
|
22
|
+
.attr('fill', 'none')
|
|
23
|
+
.selectAll()
|
|
24
|
+
.data(preparedData.links)
|
|
25
|
+
.join('g')
|
|
26
|
+
.append('path')
|
|
27
|
+
.attr('stroke-opacity', (d) => d.opacity)
|
|
28
|
+
.attr('d', (d) => d.path)
|
|
29
|
+
.attr('stroke', (d) => d.color)
|
|
30
|
+
.attr('stroke-width', (d) => d.strokeWidth);
|
|
31
|
+
// dataLabels
|
|
32
|
+
renderDataLabels({
|
|
33
|
+
container: svgElement.append('g'),
|
|
34
|
+
data: preparedData.labels,
|
|
35
|
+
className: b('label'),
|
|
36
|
+
}).attr('dy', '0.35em');
|
|
37
|
+
const eventName = `hover-shape.sankey`;
|
|
38
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, (_data) => {
|
|
39
|
+
// no-op hover handler
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BaseTextStyle, HtmlItem, SankeySeriesData } from '../../../types';
|
|
2
|
-
import type { PreparedSankeySeries } from '../../
|
|
2
|
+
import type { PreparedSankeySeries } from '../../series/types';
|
|
3
3
|
export type SankeyDataLabel = {
|
|
4
4
|
text: string;
|
|
5
5
|
x: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PreparedScatterSeries } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { ChartScale } from '../../scales/types';
|
|
3
|
+
import type { PreparedScatterSeries } from '../../series/types';
|
|
4
4
|
import type { PreparedScatterData } from './types';
|
|
5
5
|
export declare function prepareScatterData(args: {
|
|
6
6
|
series: PreparedScatterSeries[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { getXValue, getYValue } from '../../shapes/utils';
|
|
3
|
+
import { getDataCategoryValue } from '../../utils';
|
|
4
4
|
function getFilteredLinearScatterData(data) {
|
|
5
5
|
return data.filter((d) => typeof d.x === 'number' && typeof d.y === 'number');
|
|
6
6
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedScatterData } from './types';
|
|
4
|
+
export declare function renderScatter(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: PreparedScatterData[], seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { select } from 'd3-selection';
|
|
2
|
+
import get from 'lodash/get';
|
|
3
|
+
import { getMarkerHaloVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../../shapes/marker';
|
|
4
|
+
import { setActiveState, shapeKey } from '../../shapes/utils';
|
|
5
|
+
export function renderScatter(elements, preparedData, seriesOptions, dispatcher) {
|
|
6
|
+
const svgElement = select(elements.plot);
|
|
7
|
+
const hoverOptions = get(seriesOptions, 'scatter.states.hover');
|
|
8
|
+
const inactiveOptions = get(seriesOptions, 'scatter.states.inactive');
|
|
9
|
+
svgElement.selectAll('*').remove();
|
|
10
|
+
const selection = svgElement
|
|
11
|
+
.selectAll('path')
|
|
12
|
+
.data(preparedData, shapeKey)
|
|
13
|
+
.join('g')
|
|
14
|
+
.call(renderMarker)
|
|
15
|
+
.attr('opacity', (d) => d.point.opacity)
|
|
16
|
+
.attr('cursor', (d) => d.point.series.cursor);
|
|
17
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
18
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
19
|
+
function handleShapeHover(data) {
|
|
20
|
+
var _a;
|
|
21
|
+
const selected = data === null || data === void 0 ? void 0 : data.find((d) => d.series.type === 'scatter');
|
|
22
|
+
const selectedDataItem = selected === null || selected === void 0 ? void 0 : selected.data;
|
|
23
|
+
const selectedSeriesId = (_a = selected === null || selected === void 0 ? void 0 : selected.series) === null || _a === void 0 ? void 0 : _a.id;
|
|
24
|
+
selection.datum((d, index, list) => {
|
|
25
|
+
const elementSelection = select(list[index]);
|
|
26
|
+
const hovered = Boolean(hoverEnabled && d.point.data === selectedDataItem);
|
|
27
|
+
if (d.hovered !== hovered) {
|
|
28
|
+
d.hovered = hovered;
|
|
29
|
+
elementSelection.attr('z-index', hovered ? 999 : null);
|
|
30
|
+
selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
|
|
31
|
+
selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
|
|
32
|
+
}
|
|
33
|
+
if (hovered) {
|
|
34
|
+
elementSelection.raise();
|
|
35
|
+
}
|
|
36
|
+
if (d.point.series.marker.states.normal.enabled) {
|
|
37
|
+
const isActive = Boolean(!inactiveEnabled || !selectedSeriesId || selectedSeriesId === d.point.series.id);
|
|
38
|
+
setActiveState({
|
|
39
|
+
element: list[index],
|
|
40
|
+
state: inactiveOptions,
|
|
41
|
+
active: isActive,
|
|
42
|
+
datum: d,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return d;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', handleShapeHover);
|
|
49
|
+
return () => {
|
|
50
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.scatter', null);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PreparedTreemapSeries } from '../../
|
|
1
|
+
import type { PreparedTreemapSeries } from '../../series/types';
|
|
2
2
|
import type { PreparedTreemapData } from './types';
|
|
3
3
|
export declare function prepareTreemapData(args: {
|
|
4
4
|
series: PreparedTreemapSeries;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ascending, descending, sort } from 'd3-array';
|
|
2
2
|
import { stratify, treemap, treemapBinary, treemapDice, treemapSlice, treemapSliceDice, treemapSquarify, } from 'd3-hierarchy';
|
|
3
|
-
import { LayoutAlgorithm } from '
|
|
4
|
-
import { getLabelsSize, getTextSizeFn, getTextWithElipsis } from '
|
|
5
|
-
import { getFormattedValue } from '
|
|
3
|
+
import { LayoutAlgorithm } from '../../constants';
|
|
4
|
+
import { getLabelsSize, getTextSizeFn, getTextWithElipsis } from '../../utils';
|
|
5
|
+
import { getFormattedValue } from '../../utils/format';
|
|
6
6
|
const DEFAULT_PADDING = 1;
|
|
7
7
|
async function getLabels(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 { PreparedTreemapData } from './types';
|
|
4
|
+
export declare function renderTreemap(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: PreparedTreemapData, 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
|
+
const b = block('treemap');
|
|
6
|
+
export function renderTreemap(elements, preparedData, seriesOptions, dispatcher) {
|
|
7
|
+
const svgElement = select(elements.plot);
|
|
8
|
+
svgElement.selectAll('*').remove();
|
|
9
|
+
const { labelData, leaves, series } = preparedData;
|
|
10
|
+
const leaf = svgElement
|
|
11
|
+
.selectAll('g')
|
|
12
|
+
.data(leaves)
|
|
13
|
+
.join('g')
|
|
14
|
+
.attr('transform', (d) => `translate(${d.x0},${d.y0})`)
|
|
15
|
+
.attr('cursor', series.cursor);
|
|
16
|
+
const rectSelection = leaf
|
|
17
|
+
.append('rect')
|
|
18
|
+
.attr('id', (d) => d.id || d.name)
|
|
19
|
+
.attr('fill', (d) => {
|
|
20
|
+
var _a;
|
|
21
|
+
if (d.data.color) {
|
|
22
|
+
return d.data.color;
|
|
23
|
+
}
|
|
24
|
+
const levelOptions = (_a = series.levels) === null || _a === void 0 ? void 0 : _a.find((l) => l.index === d.depth);
|
|
25
|
+
return (levelOptions === null || levelOptions === void 0 ? void 0 : levelOptions.color) || series.color;
|
|
26
|
+
})
|
|
27
|
+
.attr('width', (d) => d.x1 - d.x0)
|
|
28
|
+
.attr('height', (d) => d.y1 - d.y0);
|
|
29
|
+
const labelSelection = svgElement
|
|
30
|
+
.selectAll('tspan')
|
|
31
|
+
.data(labelData)
|
|
32
|
+
.join('text')
|
|
33
|
+
.html((d) => d.text)
|
|
34
|
+
.attr('class', b('label'))
|
|
35
|
+
.attr('x', (d) => d.x)
|
|
36
|
+
.attr('y', (d) => d.y)
|
|
37
|
+
.style('font-size', () => series.dataLabels.style.fontSize)
|
|
38
|
+
.style('font-weight', () => { var _a; return ((_a = series.dataLabels.style) === null || _a === void 0 ? void 0 : _a.fontWeight) || null; })
|
|
39
|
+
.style('fill', () => { var _a; return ((_a = series.dataLabels.style) === null || _a === void 0 ? void 0 : _a.fontColor) || null; });
|
|
40
|
+
const eventName = `hover-shape.treemap`;
|
|
41
|
+
const hoverOptions = get(seriesOptions, 'treemap.states.hover');
|
|
42
|
+
const inactiveOptions = get(seriesOptions, 'treemap.states.inactive');
|
|
43
|
+
function handleShapeHover(data) {
|
|
44
|
+
var _a;
|
|
45
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
46
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
47
|
+
const hoveredData = (_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.data;
|
|
48
|
+
rectSelection.datum((d, index, list) => {
|
|
49
|
+
const currentRect = select(list[index]);
|
|
50
|
+
const hovered = Boolean(hoverEnabled && hoveredData === d.data);
|
|
51
|
+
const inactive = Boolean(inactiveEnabled && hoveredData && !hovered);
|
|
52
|
+
currentRect
|
|
53
|
+
.attr('fill', (currentD) => {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const levelOptions = (_a = series.levels) === null || _a === void 0 ? void 0 : _a.find((l) => l.index === currentD.depth);
|
|
56
|
+
const initialColor = (levelOptions === null || levelOptions === void 0 ? void 0 : levelOptions.color) || d.data.color || series.color;
|
|
57
|
+
if (hovered) {
|
|
58
|
+
return (((_b = color(initialColor)) === null || _b === void 0 ? void 0 : _b.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
|
|
59
|
+
initialColor);
|
|
60
|
+
}
|
|
61
|
+
return initialColor;
|
|
62
|
+
})
|
|
63
|
+
.attr('opacity', () => {
|
|
64
|
+
if (inactive) {
|
|
65
|
+
return (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
});
|
|
69
|
+
return d;
|
|
70
|
+
});
|
|
71
|
+
labelSelection.datum((d, index, list) => {
|
|
72
|
+
const currentLabel = select(list[index]);
|
|
73
|
+
const hovered = Boolean(hoverEnabled && hoveredData === d.nodeData);
|
|
74
|
+
const inactive = Boolean(inactiveEnabled && hoveredData && !hovered);
|
|
75
|
+
currentLabel.attr('opacity', () => {
|
|
76
|
+
if (inactive) {
|
|
77
|
+
return (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
});
|
|
81
|
+
return d;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, handleShapeHover);
|
|
85
|
+
return () => {
|
|
86
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on(eventName, null);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { HierarchyRectangularNode } from 'd3-hierarchy';
|
|
2
2
|
import type { HtmlItem, TreemapSeriesData } from '../../../types';
|
|
3
|
-
import type { PreparedTreemapSeries } from '../../
|
|
3
|
+
import type { PreparedTreemapSeries } from '../../series/types';
|
|
4
4
|
export type TreemapLabelData = {
|
|
5
5
|
text: string;
|
|
6
6
|
x: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { BaseType } from 'd3-selection';
|
|
2
|
+
import type { PreparedXAxis, PreparedYAxis } from '../axes/types';
|
|
3
|
+
import type { ChartScale } from '../scales/types';
|
|
4
|
+
import type { BasicInactiveState } from '../types';
|
|
5
|
+
export declare function getXValue(args: {
|
|
6
|
+
point: {
|
|
7
|
+
x?: number | string | null;
|
|
8
|
+
};
|
|
9
|
+
points?: {
|
|
10
|
+
x?: number | string | null;
|
|
11
|
+
}[];
|
|
12
|
+
xAxis: PreparedXAxis;
|
|
13
|
+
xScale: ChartScale;
|
|
14
|
+
}): number | null;
|
|
15
|
+
export declare function getYValue(args: {
|
|
16
|
+
point: {
|
|
17
|
+
y?: number | string | null;
|
|
18
|
+
};
|
|
19
|
+
points?: {
|
|
20
|
+
y?: number | string | null;
|
|
21
|
+
}[];
|
|
22
|
+
yAxis: PreparedYAxis;
|
|
23
|
+
yScale: ChartScale;
|
|
24
|
+
}): number | null;
|
|
25
|
+
/**
|
|
26
|
+
* Hides out-of-range points from line/area path generators via `hiddenInLine`.
|
|
27
|
+
* Neighbors of in-range points are kept as anchors so the path retains its
|
|
28
|
+
* slope at the plot edges instead of stopping abruptly at the visible point.
|
|
29
|
+
*
|
|
30
|
+
* Pixel check alone is not enough: a degenerate/clamped scale domain (see the
|
|
31
|
+
* y-scale.ts guard) can map out-of-range data into the plot rectangle, leaving
|
|
32
|
+
* phantom hover targets. Pass `axisMin`/`axisMax` + `getDataY` to also reject
|
|
33
|
+
* points whose raw value is outside the user's intended range.
|
|
34
|
+
*
|
|
35
|
+
* Stacked shapes must NOT pass the data check — `point.data.y` is the unstacked
|
|
36
|
+
* value and doesn't reflect where the point actually lands on the plot.
|
|
37
|
+
*/
|
|
38
|
+
export declare function markHiddenPointsOutOfYRange<P extends {
|
|
39
|
+
y: number | null;
|
|
40
|
+
hiddenInLine?: boolean;
|
|
41
|
+
}>(args: {
|
|
42
|
+
points: P[];
|
|
43
|
+
yScale: ChartScale;
|
|
44
|
+
yAxisTop: number;
|
|
45
|
+
axisMin?: number;
|
|
46
|
+
axisMax?: number;
|
|
47
|
+
getDataY?: (point: P) => unknown;
|
|
48
|
+
}): void;
|
|
49
|
+
export declare function shapeKey(d: unknown): string | number;
|
|
50
|
+
export declare function setActiveState<T extends {
|
|
51
|
+
active?: boolean;
|
|
52
|
+
}>(args: {
|
|
53
|
+
element: BaseType;
|
|
54
|
+
datum: T;
|
|
55
|
+
state: BasicInactiveState | undefined;
|
|
56
|
+
active: boolean;
|
|
57
|
+
}): T;
|
|
58
|
+
export declare function getRectPath(args: {
|
|
59
|
+
x: number;
|
|
60
|
+
y: number;
|
|
61
|
+
width: number;
|
|
62
|
+
height: number;
|
|
63
|
+
borderRadius?: number | number[];
|
|
64
|
+
}): import("d3-path").Path;
|
|
65
|
+
export declare function getRectBorderPath(args: {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
borderWidth: number;
|
|
71
|
+
borderRadius?: number | number[];
|
|
72
|
+
}): string;
|
|
73
|
+
export declare function getClipPathIdByBounds(args: {
|
|
74
|
+
clipPathId: string;
|
|
75
|
+
bounds?: 'horizontal';
|
|
76
|
+
}): string;
|