@gravity-ui/charts 1.45.0 → 1.46.1
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 +2 -2
- package/dist/cjs/components/ChartInner/styles.css +2 -2
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +2 -2
- package/dist/cjs/components/ChartInner/utils/title.d.ts +2 -1
- package/dist/cjs/components/ChartInner/utils/title.js +51 -14
- package/dist/cjs/components/Legend/index.js +13 -14
- package/dist/cjs/components/Title/index.d.ts +4 -2
- package/dist/cjs/components/Title/index.js +9 -2
- 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/scales/utils.d.ts +1 -1
- package/dist/cjs/core/scales/utils.js +1 -1
- package/dist/cjs/core/scales/x-scale.js +2 -2
- package/dist/cjs/core/scales/y-scale.js +48 -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.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 +4 -4
- package/dist/cjs/core/shapes/area/renderer.d.ts +11 -0
- package/dist/cjs/core/shapes/area/renderer.js +181 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/area/types.d.ts +1 -3
- 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 +110 -0
- package/dist/{esm/hooks/useShapes → cjs/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 +80 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/utils.js +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → 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 +79 -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/{esm/hooks/useShapes → cjs/core/shapes}/heatmap/prepare-data.js +2 -2
- package/dist/cjs/core/shapes/heatmap/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/heatmap/renderer.js +55 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/heatmap/types.d.ts +1 -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 +3 -3
- package/dist/cjs/core/shapes/line/renderer.d.ts +11 -0
- package/dist/cjs/core/shapes/line/renderer.js +167 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/line/types.d.ts +2 -4
- 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/{esm/hooks/useShapes → cjs/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 +126 -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 +50 -0
- package/dist/cjs/{hooks/useShapes → 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/{esm/hooks/useShapes → cjs/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/{esm/hooks/useShapes → cjs/core/shapes}/scatter/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → 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/{esm/hooks/useShapes → cjs/core/shapes}/treemap/types.d.ts +1 -1
- package/dist/cjs/core/shapes/utils.d.ts +52 -0
- package/dist/cjs/core/shapes/utils.js +138 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
- package/dist/cjs/{hooks/useShapes → 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 +115 -0
- package/dist/{esm/hooks/useShapes → cjs/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 +94 -0
- package/dist/{esm/hooks/useShapes → cjs/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 +1 -4
- package/dist/cjs/core/types/chart/title.d.ts +18 -0
- package/dist/cjs/{hooks/utils/get-band-size.js → core/utils/band-size.js} +1 -1
- package/dist/{esm/hooks → cjs/core}/utils/bar-y.d.ts +3 -3
- package/dist/cjs/{hooks → core}/utils/bar-y.js +4 -4
- package/dist/cjs/core/utils/get-closest-data.d.ts +1 -1
- 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/hooks/index.d.ts +1 -1
- package/dist/cjs/hooks/index.js +1 -1
- package/dist/cjs/hooks/types.d.ts +6 -3
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/cjs/hooks/useRangeSlider/utils.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/HtmlLayer.js +4 -3
- 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 +14 -15
- 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 +2 -52
- 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/setup-jsdom.js +7 -0
- package/dist/cjs/types/chart-ui.d.ts +2 -0
- package/dist/esm/components/ChartInner/index.js +2 -2
- package/dist/esm/components/ChartInner/styles.css +2 -2
- package/dist/esm/components/ChartInner/useChartInnerProps.js +2 -2
- package/dist/esm/components/ChartInner/utils/title.d.ts +2 -1
- package/dist/esm/components/ChartInner/utils/title.js +51 -14
- package/dist/esm/components/Legend/index.js +13 -14
- package/dist/esm/components/Title/index.d.ts +4 -2
- package/dist/esm/components/Title/index.js +9 -2
- 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/scales/utils.d.ts +1 -1
- package/dist/esm/core/scales/utils.js +1 -1
- package/dist/esm/core/scales/x-scale.js +2 -2
- package/dist/esm/core/scales/y-scale.js +48 -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.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 +4 -4
- package/dist/esm/core/shapes/area/renderer.d.ts +11 -0
- package/dist/esm/core/shapes/area/renderer.js +181 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/area/types.d.ts +1 -3
- 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 +110 -0
- package/dist/{cjs/hooks/useShapes → esm/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 +80 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/utils.js +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → 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 +79 -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/{cjs/hooks/useShapes → esm/core/shapes}/heatmap/prepare-data.js +2 -2
- package/dist/esm/core/shapes/heatmap/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/heatmap/renderer.js +55 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/heatmap/types.d.ts +1 -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 +3 -3
- package/dist/esm/core/shapes/line/renderer.d.ts +11 -0
- package/dist/esm/core/shapes/line/renderer.js +167 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/line/types.d.ts +2 -4
- 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/{cjs/hooks/useShapes → esm/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 +126 -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 +50 -0
- package/dist/esm/{hooks/useShapes → 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/{cjs/hooks/useShapes → esm/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/{cjs/hooks/useShapes → esm/core/shapes}/scatter/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → 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/{cjs/hooks/useShapes → esm/core/shapes}/treemap/types.d.ts +1 -1
- package/dist/esm/core/shapes/utils.d.ts +52 -0
- package/dist/esm/core/shapes/utils.js +138 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
- package/dist/esm/{hooks/useShapes → 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 +115 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/waterfall/types.d.ts +1 -1
- 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 +94 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/x-range/types.d.ts +1 -1
- 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 +1 -4
- package/dist/esm/core/types/chart/title.d.ts +18 -0
- package/dist/esm/{hooks/utils/get-band-size.js → core/utils/band-size.js} +1 -1
- package/dist/{cjs/hooks → esm/core}/utils/bar-y.d.ts +3 -3
- package/dist/esm/{hooks → core}/utils/bar-y.js +4 -4
- package/dist/esm/core/utils/get-closest-data.d.ts +1 -1
- 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/hooks/index.d.ts +1 -1
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/types.d.ts +6 -3
- package/dist/esm/hooks/useRangeSlider/types.d.ts +1 -1
- package/dist/esm/hooks/useRangeSlider/utils.d.ts +1 -1
- package/dist/esm/hooks/useShapes/HtmlLayer.js +4 -3
- 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 +14 -15
- 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 +2 -52
- 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/setup-jsdom.js +7 -0
- package/dist/esm/types/chart-ui.d.ts +2 -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/useShapes → 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 → core/shapes}/bar-x/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → 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 → core/shapes}/funnel/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/line/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → 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 → 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 → core/shapes}/sankey/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → 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/esm/{hooks/useShapes → 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 → core/shapes}/bar-x/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → 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 → core/shapes}/funnel/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/line/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → 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 → 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 → core/shapes}/sankey/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/scatter/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/treemap/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/x-range/types.js +0 -0
- /package/dist/esm/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { path } from 'd3-path';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { getDataCategoryValue } from '../utils';
|
|
5
|
+
const ONE_POINT_DOMAIN_DATA_CAPACITY = 3;
|
|
6
|
+
export function getXValue(args) {
|
|
7
|
+
const { point, points, xAxis, xScale } = args;
|
|
8
|
+
if (xAxis.type === 'category') {
|
|
9
|
+
const xBandScale = xScale;
|
|
10
|
+
const categories = get(xAxis, 'categories', []);
|
|
11
|
+
const dataCategory = getDataCategoryValue({ axisDirection: 'x', categories, data: point });
|
|
12
|
+
return (xBandScale(dataCategory) || 0) + xBandScale.step() / 2;
|
|
13
|
+
}
|
|
14
|
+
let xLinearScale = xScale;
|
|
15
|
+
const [xMinDomain, xMaxDomain] = xLinearScale.domain();
|
|
16
|
+
if (Number(xMinDomain) === Number(xMaxDomain) &&
|
|
17
|
+
(points === null || points === void 0 ? void 0 : points.length) === ONE_POINT_DOMAIN_DATA_CAPACITY) {
|
|
18
|
+
const x1 = Number(points[0].x);
|
|
19
|
+
const xTarget = Number(points[1].x);
|
|
20
|
+
const x3 = Number(points[2].x);
|
|
21
|
+
if (!Number.isNaN(x1) && !Number.isNaN(xTarget) && !Number.isNaN(x3)) {
|
|
22
|
+
const xMin = Math.min(x1, xTarget, x3);
|
|
23
|
+
const xMax = Math.max(x1, xTarget, x3);
|
|
24
|
+
xLinearScale = xLinearScale
|
|
25
|
+
.copy()
|
|
26
|
+
.domain([xMin + (xTarget - xMin) / 2, xMax - (xMax - xTarget) / 2]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return point.x === null ? null : xLinearScale(point.x);
|
|
30
|
+
}
|
|
31
|
+
export function getYValue(args) {
|
|
32
|
+
const { point, points, yAxis, yScale } = args;
|
|
33
|
+
if (yAxis.type === 'category') {
|
|
34
|
+
const yBandScale = yScale;
|
|
35
|
+
const categories = get(yAxis, 'categories', []);
|
|
36
|
+
const dataCategory = getDataCategoryValue({ axisDirection: 'y', categories, data: point });
|
|
37
|
+
return (yBandScale(dataCategory) || 0) + yBandScale.step() / 2;
|
|
38
|
+
}
|
|
39
|
+
let yLinearScale = yScale;
|
|
40
|
+
const [yMinDomain, yMaxDomain] = yLinearScale.domain();
|
|
41
|
+
if (Number(yMinDomain) === Number(yMaxDomain) &&
|
|
42
|
+
(points === null || points === void 0 ? void 0 : points.length) === ONE_POINT_DOMAIN_DATA_CAPACITY) {
|
|
43
|
+
const y1 = Number(points[0].y);
|
|
44
|
+
const yTarget = Number(points[1].y);
|
|
45
|
+
const y3 = Number(points[2].y);
|
|
46
|
+
if (!Number.isNaN(y1) && !Number.isNaN(yTarget) && !Number.isNaN(y3)) {
|
|
47
|
+
const yMin = Math.min(y1, yTarget, y3);
|
|
48
|
+
const yMax = Math.max(y1, yTarget, y3);
|
|
49
|
+
yLinearScale = yLinearScale
|
|
50
|
+
.copy()
|
|
51
|
+
.domain([yMin + (yTarget - yMin) / 2, yMax - (yMax - yTarget) / 2]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return point.y === null ? null : yLinearScale(point.y);
|
|
55
|
+
}
|
|
56
|
+
export function shapeKey(d) {
|
|
57
|
+
return d.id || -1;
|
|
58
|
+
}
|
|
59
|
+
export function setActiveState(args) {
|
|
60
|
+
const { element, datum, state, active } = args;
|
|
61
|
+
const elementSelection = select(element);
|
|
62
|
+
if (datum.active !== active) {
|
|
63
|
+
datum.active = active;
|
|
64
|
+
const opacity = datum.active ? null : state === null || state === void 0 ? void 0 : state.opacity;
|
|
65
|
+
elementSelection.attr('opacity', opacity || null);
|
|
66
|
+
}
|
|
67
|
+
return datum;
|
|
68
|
+
}
|
|
69
|
+
export function getRectPath(args) {
|
|
70
|
+
const { x, y, width, height, borderRadius = 0 } = args;
|
|
71
|
+
const borderRadiuses = typeof borderRadius === 'number' ? new Array(4).fill(borderRadius) : borderRadius;
|
|
72
|
+
const [borderRadiusTopLeft = 0, borderRadiusTopRight = 0, borderRadiusBottomRight = 0, borderRadiusBottomLeft = 0,] = borderRadiuses !== null && borderRadiuses !== void 0 ? borderRadiuses : [];
|
|
73
|
+
const p = path();
|
|
74
|
+
let startAngle = -Math.PI / 2;
|
|
75
|
+
const angle = Math.PI / 2;
|
|
76
|
+
p.moveTo(x + borderRadiusTopLeft, y);
|
|
77
|
+
p.lineTo(x + width - borderRadiusTopRight, y);
|
|
78
|
+
p.arc(x + width - borderRadiusTopRight, y + borderRadiusTopRight, borderRadiusTopRight, startAngle, startAngle + angle);
|
|
79
|
+
startAngle += angle;
|
|
80
|
+
p.lineTo(x + width, y + height - borderRadiusBottomRight);
|
|
81
|
+
p.arc(x + width - borderRadiusBottomRight, y + height - borderRadiusBottomRight, borderRadiusBottomRight, startAngle, startAngle + angle);
|
|
82
|
+
startAngle += angle;
|
|
83
|
+
p.lineTo(x + borderRadiusBottomLeft, y + height);
|
|
84
|
+
p.arc(x + borderRadiusBottomLeft, y + height - borderRadiusBottomLeft, borderRadiusBottomLeft, startAngle, startAngle + angle);
|
|
85
|
+
startAngle += angle;
|
|
86
|
+
p.lineTo(x, y + borderRadiusTopLeft);
|
|
87
|
+
p.arc(x + borderRadiusTopLeft, y + borderRadiusTopLeft, borderRadiusTopLeft, startAngle, startAngle + angle);
|
|
88
|
+
p.closePath();
|
|
89
|
+
return p;
|
|
90
|
+
}
|
|
91
|
+
export function getRectBorderPath(args) {
|
|
92
|
+
const { x, y, width, height, borderWidth, borderRadius = 0 } = args;
|
|
93
|
+
if (!borderWidth) {
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
const halfWidth = borderWidth / 2;
|
|
97
|
+
const expandedWidth = width + borderWidth;
|
|
98
|
+
const expandedHeight = height + borderWidth;
|
|
99
|
+
const innerWidth = width - borderWidth;
|
|
100
|
+
const innerHeight = height - borderWidth;
|
|
101
|
+
const borderRadiuses = typeof borderRadius === 'number' ? new Array(4).fill(borderRadius) : borderRadius;
|
|
102
|
+
const [borderRadiusTopLeft = 0, borderRadiusTopRight = 0, borderRadiusBottomRight = 0, borderRadiusBottomLeft = 0,] = borderRadiuses !== null && borderRadiuses !== void 0 ? borderRadiuses : [];
|
|
103
|
+
const adjustOuterRadius = (radius) => (radius ? radius + halfWidth : 0);
|
|
104
|
+
const outerBorderRadius = [
|
|
105
|
+
adjustOuterRadius(borderRadiusTopLeft),
|
|
106
|
+
adjustOuterRadius(borderRadiusTopRight),
|
|
107
|
+
adjustOuterRadius(borderRadiusBottomRight),
|
|
108
|
+
adjustOuterRadius(borderRadiusBottomLeft),
|
|
109
|
+
];
|
|
110
|
+
const outerPath = getRectPath({
|
|
111
|
+
x: x - halfWidth,
|
|
112
|
+
y: y - halfWidth,
|
|
113
|
+
width: expandedWidth,
|
|
114
|
+
height: expandedHeight,
|
|
115
|
+
borderRadius: outerBorderRadius,
|
|
116
|
+
}).toString();
|
|
117
|
+
if (innerWidth <= 0 || innerHeight <= 0) {
|
|
118
|
+
return outerPath;
|
|
119
|
+
}
|
|
120
|
+
const innerBorderRadius = [
|
|
121
|
+
Math.max(borderRadiusTopLeft - halfWidth, 0),
|
|
122
|
+
Math.max(borderRadiusTopRight - halfWidth, 0),
|
|
123
|
+
Math.max(borderRadiusBottomRight - halfWidth, 0),
|
|
124
|
+
Math.max(borderRadiusBottomLeft - halfWidth, 0),
|
|
125
|
+
];
|
|
126
|
+
const innerPath = getRectPath({
|
|
127
|
+
x: x + halfWidth,
|
|
128
|
+
y: y + halfWidth,
|
|
129
|
+
width: innerWidth,
|
|
130
|
+
height: innerHeight,
|
|
131
|
+
borderRadius: innerBorderRadius,
|
|
132
|
+
}).toString();
|
|
133
|
+
return `${outerPath} ${innerPath}`;
|
|
134
|
+
}
|
|
135
|
+
export function getClipPathIdByBounds(args) {
|
|
136
|
+
const { bounds, clipPathId } = args;
|
|
137
|
+
return bounds ? `${clipPathId}-${bounds}` : clipPathId;
|
|
138
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PreparedSeriesOptions, PreparedWaterfallSeries } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { ChartScale } from '../../scales/types';
|
|
3
|
+
import type { PreparedSeriesOptions, PreparedWaterfallSeries } from '../../series/types';
|
|
4
4
|
import type { PreparedWaterfallData } from './types';
|
|
5
5
|
export declare const prepareWaterfallData: (args: {
|
|
6
6
|
series: PreparedWaterfallSeries[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import sortBy from 'lodash/sortBy';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { MIN_BAR_GAP, MIN_BAR_WIDTH } from '../../shapes/bar-constants';
|
|
4
|
+
import { getXValue, getYValue } from '../../shapes/utils';
|
|
5
|
+
import { getLabelsSize } from '../../utils';
|
|
6
|
+
import { getFormattedValue } from '../../utils/format';
|
|
7
7
|
async function getLabelData(d, plotHeight) {
|
|
8
8
|
var _a, _b;
|
|
9
9
|
if (!d.series.dataLabels.enabled) {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedWaterfallData } from './types';
|
|
4
|
+
export declare function renderWaterfall(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: PreparedWaterfallData[], seriesOptions: PreparedSeriesOptions, allowOverlapDataLabels: boolean, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { color } from 'd3-color';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import { line as lineGenerator } from 'd3-shape';
|
|
4
|
+
import get from 'lodash/get';
|
|
5
|
+
import { block } from '../../../utils';
|
|
6
|
+
import { DASH_STYLE } from '../../constants';
|
|
7
|
+
import { filterOverlappingLabels, getLineDashArray, getWaterfallPointColor } from '../../utils';
|
|
8
|
+
const b = block('waterfall');
|
|
9
|
+
export function renderWaterfall(elements, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher) {
|
|
10
|
+
const svgElement = select(elements.plot);
|
|
11
|
+
const connectorSelector = `.${b('connector')}`;
|
|
12
|
+
const hoverOptions = get(seriesOptions, 'waterfall.states.hover');
|
|
13
|
+
const inactiveOptions = get(seriesOptions, 'waterfall.states.inactive');
|
|
14
|
+
svgElement.selectAll('*').remove();
|
|
15
|
+
const rectSelection = svgElement
|
|
16
|
+
.selectAll('allRects')
|
|
17
|
+
.data(preparedData)
|
|
18
|
+
.join('rect')
|
|
19
|
+
.attr('class', b('segment'))
|
|
20
|
+
.attr('x', (d) => d.x)
|
|
21
|
+
.attr('y', (d) => d.y)
|
|
22
|
+
.attr('height', (d) => d.height)
|
|
23
|
+
.attr('width', (d) => d.width)
|
|
24
|
+
.attr('fill', (d) => getWaterfallPointColor(d.data, d.series))
|
|
25
|
+
.attr('opacity', (d) => d.opacity)
|
|
26
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
27
|
+
let dataLabels = preparedData.map((d) => d.label).filter(Boolean);
|
|
28
|
+
if (!allowOverlapDataLabels) {
|
|
29
|
+
dataLabels = filterOverlappingLabels(dataLabels);
|
|
30
|
+
}
|
|
31
|
+
const labelSelection = svgElement
|
|
32
|
+
.selectAll('text')
|
|
33
|
+
.data(dataLabels)
|
|
34
|
+
.join('text')
|
|
35
|
+
.html((d) => d.text)
|
|
36
|
+
.attr('class', b('label'))
|
|
37
|
+
.attr('x', (d) => d.x)
|
|
38
|
+
.attr('y', (d) => d.y)
|
|
39
|
+
.attr('text-anchor', (d) => d.textAnchor)
|
|
40
|
+
.style('font-size', (d) => d.style.fontSize)
|
|
41
|
+
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
42
|
+
.style('fill', (d) => d.style.fontColor || null);
|
|
43
|
+
// Add the connector line between bars
|
|
44
|
+
svgElement
|
|
45
|
+
.selectAll(connectorSelector)
|
|
46
|
+
.data(preparedData)
|
|
47
|
+
.join('path')
|
|
48
|
+
.attr('class', b('connector'))
|
|
49
|
+
.attr('d', (d, index) => {
|
|
50
|
+
const line = lineGenerator();
|
|
51
|
+
const prev = preparedData[index - 1];
|
|
52
|
+
if (!prev) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
const points = [];
|
|
56
|
+
if (Number(prev.data.y) > 0) {
|
|
57
|
+
points.push([prev.x, prev.y]);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
points.push([prev.x, prev.y + prev.height]);
|
|
61
|
+
}
|
|
62
|
+
if (Number(d.data.y) > 0 && !d.data.total) {
|
|
63
|
+
points.push([d.x + d.width, d.y + d.height]);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
points.push([d.x + d.width, d.y]);
|
|
67
|
+
}
|
|
68
|
+
return line(points);
|
|
69
|
+
})
|
|
70
|
+
.attr('stroke-width', 1)
|
|
71
|
+
.attr('stroke-dasharray', () => getLineDashArray(DASH_STYLE.Dash, 1));
|
|
72
|
+
function handleShapeHover(data) {
|
|
73
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
74
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
75
|
+
if (!data) {
|
|
76
|
+
if (hoverEnabled) {
|
|
77
|
+
rectSelection.attr('fill', (d) => getWaterfallPointColor(d.data, d.series));
|
|
78
|
+
}
|
|
79
|
+
if (inactiveEnabled) {
|
|
80
|
+
rectSelection.attr('opacity', null);
|
|
81
|
+
labelSelection.attr('opacity', null);
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (hoverEnabled) {
|
|
86
|
+
const hoveredValues = data.map((d) => d.data.x);
|
|
87
|
+
rectSelection.attr('fill', (d) => {
|
|
88
|
+
var _a;
|
|
89
|
+
const fillColor = getWaterfallPointColor(d.data, d.series);
|
|
90
|
+
if (hoveredValues.includes(d.data.x)) {
|
|
91
|
+
const brightness = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness;
|
|
92
|
+
return ((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(brightness).toString()) || fillColor;
|
|
93
|
+
}
|
|
94
|
+
return fillColor;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (inactiveEnabled) {
|
|
98
|
+
const hoveredSeries = data.map((d) => d.series.id);
|
|
99
|
+
rectSelection.attr('opacity', (d) => {
|
|
100
|
+
return hoveredSeries.includes(d.series.id)
|
|
101
|
+
? null
|
|
102
|
+
: (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
103
|
+
});
|
|
104
|
+
labelSelection.attr('opacity', (d) => {
|
|
105
|
+
return hoveredSeries.includes(d.series.id)
|
|
106
|
+
? null
|
|
107
|
+
: (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.opacity) || null;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.waterfall', handleShapeHover);
|
|
112
|
+
return () => {
|
|
113
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.waterfall', null);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HtmlItem, LabelData, WaterfallSeriesData } from '../../../types';
|
|
2
|
-
import type { PreparedWaterfallSeries } from '../../
|
|
2
|
+
import type { PreparedWaterfallSeries } from '../../series/types';
|
|
3
3
|
export type PreparedWaterfallData = {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PreparedXRangeSeries } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { ChartScale } from '../../scales/types';
|
|
3
|
+
import type { PreparedXRangeSeries } from '../../series/types';
|
|
4
4
|
import type { PreparedXRangeData } from './types';
|
|
5
5
|
type PrepareXRangeDataArgs = {
|
|
6
6
|
series: PreparedXRangeSeries[];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { MIN_BAR_WIDTH } from '../../shapes/bar-constants';
|
|
3
|
+
import { getDataCategoryValue, getLabelsSize, getTextSizeFn, getTextWithElipsis } from '../../utils';
|
|
4
|
+
import { getBandSize } from '../../utils/band-size';
|
|
5
|
+
import { getFormattedValue } from '../../utils/format';
|
|
6
6
|
const DEFAULT_BAR_PADDING = 0.2;
|
|
7
7
|
export async function prepareXRangeData(args) {
|
|
8
8
|
var _a;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedXRangeData } from './types';
|
|
4
|
+
export declare function renderXRange(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
}, preparedData: PreparedXRangeData[], seriesOptions: PreparedSeriesOptions, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { color } from 'd3-color';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { block } from '../../../utils';
|
|
5
|
+
import { getRectPath } from '../../shapes/utils';
|
|
6
|
+
import { getLineDashArray } from '../../utils';
|
|
7
|
+
const b = block('x-range');
|
|
8
|
+
export function renderXRange(elements, preparedData, seriesOptions, dispatcher) {
|
|
9
|
+
const svgElement = select(elements.plot);
|
|
10
|
+
svgElement.selectAll('*').remove();
|
|
11
|
+
const segmentSelection = svgElement
|
|
12
|
+
.selectAll(`path.${b('segment')}`)
|
|
13
|
+
.data(preparedData)
|
|
14
|
+
.join('path')
|
|
15
|
+
.attr('d', (d) => {
|
|
16
|
+
const borderRadius = Math.min(d.height / 2, d.width / 2, d.series.borderRadius);
|
|
17
|
+
return getRectPath({
|
|
18
|
+
x: d.x,
|
|
19
|
+
y: d.y,
|
|
20
|
+
width: d.width,
|
|
21
|
+
height: d.height,
|
|
22
|
+
borderRadius,
|
|
23
|
+
}).toString();
|
|
24
|
+
})
|
|
25
|
+
.attr('class', b('segment'))
|
|
26
|
+
.attr('fill', (d) => d.color)
|
|
27
|
+
.attr('opacity', (d) => { var _a; return (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity; })
|
|
28
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
29
|
+
svgElement
|
|
30
|
+
.selectAll(`path.${b('segment-border')}`)
|
|
31
|
+
.data(preparedData.filter((d) => d.series.borderWidth > 0))
|
|
32
|
+
.join('path')
|
|
33
|
+
.attr('d', (d) => {
|
|
34
|
+
const borderRadius = Math.min(d.height / 2, d.width / 2, d.series.borderRadius);
|
|
35
|
+
return getRectPath({
|
|
36
|
+
x: d.x,
|
|
37
|
+
y: d.y,
|
|
38
|
+
width: d.width,
|
|
39
|
+
height: d.height,
|
|
40
|
+
borderRadius,
|
|
41
|
+
}).toString();
|
|
42
|
+
})
|
|
43
|
+
.attr('class', b('segment-border'))
|
|
44
|
+
.attr('fill', 'none')
|
|
45
|
+
.attr('stroke', (d) => d.series.borderColor)
|
|
46
|
+
.attr('stroke-width', (d) => d.series.borderWidth)
|
|
47
|
+
.attr('stroke-dasharray', (d) => getLineDashArray(d.series.borderDashStyle, d.series.borderWidth))
|
|
48
|
+
.attr('opacity', (d) => { var _a; return (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity; })
|
|
49
|
+
.attr('pointer-events', 'none');
|
|
50
|
+
const svgLabels = preparedData.flatMap((d) => d.svgLabels);
|
|
51
|
+
svgElement
|
|
52
|
+
.selectAll(`text.${b('label')}`)
|
|
53
|
+
.data(svgLabels)
|
|
54
|
+
.join('text')
|
|
55
|
+
.attr('class', b('label'))
|
|
56
|
+
.attr('x', (d) => d.x)
|
|
57
|
+
.attr('y', (d) => d.y)
|
|
58
|
+
.attr('text-anchor', (d) => d.textAnchor)
|
|
59
|
+
.attr('dominant-baseline', 'central')
|
|
60
|
+
.attr('pointer-events', 'none')
|
|
61
|
+
.style('font-size', (d) => d.style.fontSize)
|
|
62
|
+
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
63
|
+
.style('fill', (d) => d.style.fontColor || null)
|
|
64
|
+
.html((d) => d.text);
|
|
65
|
+
const hoverOptions = get(seriesOptions, 'x-range.states.hover');
|
|
66
|
+
const inactiveOptions = get(seriesOptions, 'x-range.states.inactive');
|
|
67
|
+
function handleShapeHover(data) {
|
|
68
|
+
if (hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled) {
|
|
69
|
+
const hoveredSet = new Set(data === null || data === void 0 ? void 0 : data.map((d) => d.data));
|
|
70
|
+
segmentSelection.attr('fill', (d) => {
|
|
71
|
+
var _a;
|
|
72
|
+
const fillColor = d.color;
|
|
73
|
+
if (hoveredSet.has(d.data)) {
|
|
74
|
+
return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) || fillColor);
|
|
75
|
+
}
|
|
76
|
+
return fillColor;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled) {
|
|
80
|
+
const hoveredSeries = data === null || data === void 0 ? void 0 : data.map((d) => d.series.id);
|
|
81
|
+
segmentSelection.attr('opacity', (d) => {
|
|
82
|
+
var _a, _b;
|
|
83
|
+
if ((hoveredSeries === null || hoveredSeries === void 0 ? void 0 : hoveredSeries.length) && !hoveredSeries.includes(d.series.id)) {
|
|
84
|
+
return inactiveOptions.opacity || null;
|
|
85
|
+
}
|
|
86
|
+
return (_b = (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity) !== null && _b !== void 0 ? _b : null;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.x-range', handleShapeHover);
|
|
91
|
+
return () => {
|
|
92
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.x-range', null);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HtmlItem, LabelData, TooltipDataChunkXRange } from '../../../types';
|
|
2
|
-
import type { PreparedXRangeSeries } from '../../
|
|
2
|
+
import type { PreparedXRangeSeries } from '../../series/types';
|
|
3
3
|
export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
@@ -87,7 +87,6 @@ export interface AreaSeries<T = MeaningfulAny> extends BaseSeries {
|
|
|
87
87
|
* - `'connect'`: Connect points across null values (skip nulls in rendering). **Not supported with `stacking`.**
|
|
88
88
|
* - `'zero'`: Treat null values as zero
|
|
89
89
|
* - `'skip'`: Omit the data point (creates gap in area)
|
|
90
|
-
*
|
|
91
90
|
* @default 'skip'
|
|
92
91
|
*/
|
|
93
92
|
nullMode?: 'connect' | 'zero' | 'skip';
|
|
@@ -298,7 +298,6 @@ export interface AxisPlotShape extends AxisPlot {
|
|
|
298
298
|
* Called with the pixel coordinates of the shape and the plot area dimensions.
|
|
299
299
|
* Must return a string of valid SVG markup that will be inserted inside a `<g>` container
|
|
300
300
|
* positioned at the shape's axis value.
|
|
301
|
-
*
|
|
302
301
|
* @example
|
|
303
302
|
* ```
|
|
304
303
|
* renderer: ({plotHeight}) =>
|
|
@@ -19,17 +19,14 @@ export type CustomFormat = {
|
|
|
19
19
|
* Specifies how a value should be formatted for display.
|
|
20
20
|
*
|
|
21
21
|
* - `{ type: 'number' }` — numeric formatting with optional precision, units, percent display, etc.
|
|
22
|
-
*
|
|
22
|
+
* See [FormatNumberOptions](https://gravity-ui.github.io/charts/pages/api/Utilities/interfaces/FormatNumberOptions.html) for all available options.
|
|
23
23
|
* - `{ type: 'date' }` — date/time formatting
|
|
24
|
-
*
|
|
25
24
|
* @example
|
|
26
25
|
* // Two decimal places, shown as percent
|
|
27
26
|
* { type: 'number', precision: 2, format: 'percent' }
|
|
28
|
-
*
|
|
29
27
|
* @example
|
|
30
28
|
* // Compact thousands: 1 500 000 → "1.5M"
|
|
31
29
|
* { type: 'number', unit: 'auto', precision: 1 }
|
|
32
|
-
*
|
|
33
30
|
* @example
|
|
34
31
|
* // Date value (Unix ms) formatted as "17 October 2025"
|
|
35
32
|
* { type: 'date', format: 'DD MMMM YYYY' }
|
|
@@ -5,6 +5,7 @@ export interface ChartTitle {
|
|
|
5
5
|
/**
|
|
6
6
|
* Maximum number of text rows. If the text exceeds this limit, it is truncated with an ellipsis.
|
|
7
7
|
* Default: 1
|
|
8
|
+
* Not applicable when `html: true` — HTML content manages its own layout.
|
|
8
9
|
*/
|
|
9
10
|
maxRowCount?: number;
|
|
10
11
|
/**
|
|
@@ -17,4 +18,21 @@ export interface ChartTitle {
|
|
|
17
18
|
* It is assigned as a data-qa attribute to an element.
|
|
18
19
|
*/
|
|
19
20
|
qa?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Enables HTML rendering for the chart title.
|
|
23
|
+
* When true, the title is rendered as an HTML element on top of the SVG
|
|
24
|
+
* instead of an SVG text node. This allows using arbitrary HTML tags
|
|
25
|
+
* (e.g. links, styled spans) that cannot be embedded in SVG.
|
|
26
|
+
* The element will be displayed outside the box of the SVG element.
|
|
27
|
+
*/
|
|
28
|
+
html?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Maximum height of the title area. Accepts a pixel value (`number` or `"100px"`)
|
|
31
|
+
* or a percentage string (`"50%"`) relative to the full chart height.
|
|
32
|
+
* When the title content exceeds this height, it is clipped.
|
|
33
|
+
* Only applicable when `html: true`.
|
|
34
|
+
*
|
|
35
|
+
* Default: 50%
|
|
36
|
+
*/
|
|
37
|
+
maxHeight?: string | number;
|
|
20
38
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { ChartScale } from '../../core/scales/types';
|
|
2
1
|
import type { BarYSeries, BarYSeriesData } from '../../types';
|
|
3
|
-
import type { PreparedYAxis } from '../
|
|
4
|
-
import type {
|
|
2
|
+
import type { PreparedYAxis } from '../axes/types';
|
|
3
|
+
import type { ChartScale } from '../scales/types';
|
|
4
|
+
import type { PreparedBarYSeries, PreparedSeriesOptions } from '../series/types';
|
|
5
5
|
/**
|
|
6
6
|
* BarY always filters out data with null or replace null by zero.
|
|
7
7
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { max } from 'd3-array';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import {
|
|
4
|
-
import { MIN_BAR_GAP, MIN_BAR_GROUP_GAP, MIN_BAR_WIDTH } from '../constants';
|
|
5
|
-
import {
|
|
6
|
-
import { getBandSize } from './
|
|
3
|
+
import { getSeriesStackId } from '../series/utils';
|
|
4
|
+
import { MIN_BAR_GAP, MIN_BAR_GROUP_GAP, MIN_BAR_WIDTH } from '../shapes/bar-constants';
|
|
5
|
+
import { getDataCategoryValue } from '../utils';
|
|
6
|
+
import { getBandSize } from './band-size';
|
|
7
7
|
const isSeriesDataValid = (d) => d.x !== null;
|
|
8
8
|
export function groupBarYDataByYValue(series, yAxis) {
|
|
9
9
|
const data = {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { sort } from 'd3-array';
|
|
2
2
|
import { isEmpty } from 'lodash';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
|
-
import { getAxisCategories } from '../../utils';
|
|
5
4
|
import { SERIES_TYPE } from '../../constants';
|
|
5
|
+
import { getAxisCategories } from '../../utils';
|
|
6
6
|
function applyAxisCategoriesOrder({ series, axis, key, }) {
|
|
7
7
|
var _a, _b;
|
|
8
8
|
const originalCategories = (_a = axis === null || axis === void 0 ? void 0 : axis.categories) !== null && _a !== void 0 ? _a : [];
|
|
@@ -4,7 +4,6 @@ import type { BaseTextStyle, MeaningfulAny } from '../../types';
|
|
|
4
4
|
* Approximate ratio of descenders relative to the full font em height.
|
|
5
5
|
* Based on the Chromium hanging baseline algorithm where hanging offset ≈ ascent × 0.2.
|
|
6
6
|
* This means ascent ≈ 80% of em height, descenders ≈ 20%.
|
|
7
|
-
*
|
|
8
7
|
* @see https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/canvas/text_metrics.cc;l=32
|
|
9
8
|
*/
|
|
10
9
|
export declare const DESCENDER_RATIO = 0.2;
|
|
@@ -5,7 +5,6 @@ const b = block('chart');
|
|
|
5
5
|
* Approximate ratio of descenders relative to the full font em height.
|
|
6
6
|
* Based on the Chromium hanging baseline algorithm where hanging offset ≈ ascent × 0.2.
|
|
7
7
|
* This means ascent ≈ 80% of em height, descenders ≈ 20%.
|
|
8
|
-
*
|
|
9
8
|
* @see https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/canvas/text_metrics.cc;l=32
|
|
10
9
|
*/
|
|
11
10
|
export const DESCENDER_RATIO = 0.2;
|
|
@@ -8,7 +8,7 @@ export * from './useCrosshair';
|
|
|
8
8
|
export * from './usePrevious';
|
|
9
9
|
export * from './useRangeSlider';
|
|
10
10
|
export * from './useRangeSlider/types';
|
|
11
|
-
export
|
|
11
|
+
export { getPreparedSeries, getVisibleSeries } from '../core/series';
|
|
12
12
|
export * from '../core/series/types';
|
|
13
13
|
export * from './useShapes';
|
|
14
14
|
export * from '../core/layout/split';
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export * from './useCrosshair';
|
|
|
8
8
|
export * from './usePrevious';
|
|
9
9
|
export * from './useRangeSlider';
|
|
10
10
|
export * from './useRangeSlider/types';
|
|
11
|
-
export
|
|
11
|
+
export { getPreparedSeries, getVisibleSeries } from '../core/series';
|
|
12
12
|
export * from '../core/series/types';
|
|
13
13
|
export * from './useShapes';
|
|
14
14
|
export * from '../core/layout/split';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TextRowData } from '../components/types';
|
|
2
|
-
import type { ChartBrush, ChartData, ChartMargin, ChartTitle, ChartZoom, DeepRequired } from '../types';
|
|
2
|
+
import type { BaseTextStyle, ChartBrush, ChartData, ChartMargin, ChartTitle, ChartZoom, DeepRequired } from '../types';
|
|
3
|
+
import type { HtmlItem } from '../types/chart-ui';
|
|
3
4
|
export type PreparedZoom = DeepRequired<Omit<ChartZoom, 'enabled' | 'brush'>> & DeepRequired<{
|
|
4
5
|
brush: ChartBrush;
|
|
5
6
|
}>;
|
|
@@ -7,10 +8,12 @@ export type PreparedChart = {
|
|
|
7
8
|
margin: ChartMargin;
|
|
8
9
|
zoom: PreparedZoom | null;
|
|
9
10
|
};
|
|
10
|
-
export type PreparedTitle = Omit<ChartTitle, 'margin'> & {
|
|
11
|
+
export type PreparedTitle = Omit<ChartTitle, 'margin' | 'style'> & {
|
|
11
12
|
height: number;
|
|
12
13
|
margin: number;
|
|
13
|
-
|
|
14
|
+
style: BaseTextStyle;
|
|
15
|
+
contentRows?: TextRowData[];
|
|
16
|
+
htmlElements?: HtmlItem[];
|
|
14
17
|
};
|
|
15
18
|
export type PreparedTooltip = ChartData['tooltip'] & {
|
|
16
19
|
enabled: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ChartScale } from '../../core/scales/types';
|
|
2
|
+
import type { PreparedLegend, PreparedSeries, PreparedSeriesOptions } from '../../core/series/types';
|
|
2
3
|
import type { ChartXAxis, ChartYAxis, LegendConfig } from '../../types';
|
|
3
4
|
import type { PreparedChart } from '../types';
|
|
4
5
|
import type { PreparedRangeSlider, PreparedXAxis, PreparedYAxis } from '../useAxis/types';
|
|
5
6
|
import type { BrushSelection, UseBrushProps } from '../useBrush/types';
|
|
6
|
-
import type { PreparedLegend, PreparedSeries, PreparedSeriesOptions } from '../useSeries/types';
|
|
7
7
|
export type RangeSliderState = {
|
|
8
8
|
max: number;
|
|
9
9
|
min: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ChartScale } from '../../core/scales/types';
|
|
2
|
+
import type { PreparedLegend } from '../../core/series/types';
|
|
2
3
|
import type { PreparedChart } from '../types';
|
|
3
4
|
import type { PreparedRangeSlider } from '../useAxis/types';
|
|
4
5
|
import type { BrushSelection } from '../useBrush/types';
|
|
5
|
-
import type { PreparedLegend } from '../useSeries/types';
|
|
6
6
|
import type { RangeSliderState } from './types';
|
|
7
7
|
export declare function getRangeSliderOffsetTop(args: {
|
|
8
8
|
height: number;
|