@gravity-ui/charts 1.46.0 → 1.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ChartInner/index.js +1 -0
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +1 -0
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +13 -6
- package/dist/cjs/components/Legend/index.js +13 -14
- package/dist/cjs/components/Tooltip/index.js +22 -1
- package/dist/cjs/core/axes/x-axis.js +1 -1
- package/dist/cjs/core/axes/y-axis.js +1 -1
- package/dist/cjs/core/brush/index.d.ts +2 -0
- package/dist/cjs/core/brush/index.js +2 -0
- package/dist/cjs/{hooks/useBrush → core/brush}/types.d.ts +2 -2
- package/dist/cjs/{hooks/useBrush → core/brush}/utils.d.ts +1 -1
- package/dist/cjs/core/chart/index.d.ts +1 -0
- package/dist/cjs/core/chart/index.js +1 -0
- package/dist/cjs/core/chart/types.d.ts +8 -0
- package/dist/cjs/core/index.d.ts +3 -0
- package/dist/cjs/core/index.js +3 -0
- package/dist/cjs/core/layout/chart-dimensions.d.ts +1 -1
- package/dist/cjs/core/range-slider/index.d.ts +2 -0
- package/dist/cjs/core/range-slider/index.js +2 -0
- package/dist/cjs/core/range-slider/types.d.ts +4 -0
- package/dist/{esm/hooks/useRangeSlider → cjs/core/range-slider}/utils.d.ts +5 -5
- package/dist/{esm/hooks/useRangeSlider → cjs/core/range-slider}/utils.js +1 -1
- package/dist/cjs/core/scales/utils.d.ts +1 -1
- package/dist/cjs/core/scales/utils.js +1 -1
- package/dist/cjs/core/scales/x-scale.d.ts +2 -2
- package/dist/cjs/core/scales/x-scale.js +2 -2
- package/dist/cjs/core/scales/y-scale.js +69 -4
- package/dist/cjs/core/series/prepare-area.js +1 -1
- package/dist/cjs/core/series/prepare-bar-x.js +1 -1
- package/dist/cjs/core/series/prepare-bar-y.js +1 -1
- package/dist/cjs/core/series/prepare-funnel.js +1 -1
- package/dist/cjs/core/series/prepare-heatmap.js +1 -1
- package/dist/cjs/core/series/prepare-legend.d.ts +1 -1
- package/dist/cjs/core/series/prepare-legend.js +2 -2
- package/dist/cjs/core/series/prepare-line.js +1 -1
- package/dist/cjs/core/series/prepare-pie.js +1 -1
- package/dist/cjs/core/series/prepare-radar.js +1 -1
- package/dist/cjs/core/series/prepare-sankey.js +1 -1
- package/dist/cjs/core/series/prepare-scatter.js +1 -1
- package/dist/cjs/core/series/prepare-treemap.js +1 -1
- package/dist/cjs/core/series/prepare-waterfall.js +1 -1
- package/dist/cjs/core/series/prepare-x-range.js +1 -1
- package/dist/cjs/core/series/prepareSeries.d.ts +7 -1
- package/dist/cjs/core/series/prepareSeries.js +31 -0
- package/dist/cjs/core/series/types.d.ts +5 -0
- package/dist/cjs/core/series/utils.d.ts +4 -0
- package/dist/cjs/core/series/utils.js +9 -1
- package/dist/cjs/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
- package/dist/cjs/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
- package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
- package/dist/cjs/{hooks/useShapes → core/shapes}/area/prepare-data.js +9 -4
- package/dist/cjs/core/shapes/area/renderer.d.ts +11 -0
- package/dist/cjs/core/shapes/area/renderer.js +175 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/area/types.d.ts +7 -8
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.d.ts +4 -4
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-x/prepare-data.js +6 -6
- package/dist/cjs/core/shapes/bar-x/renderer.d.ts +9 -0
- package/dist/cjs/core/shapes/bar-x/renderer.js +104 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/bar-x/types.d.ts +1 -2
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.d.ts +3 -3
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/bar-y/prepare-data.js +3 -3
- package/dist/cjs/core/shapes/bar-y/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/bar-y/renderer.js +74 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/utils.js +1 -1
- package/dist/cjs/core/shapes/data-labels.d.ts +15 -0
- package/dist/cjs/core/shapes/data-labels.js +15 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/funnel/prepare-data.js +1 -1
- package/dist/cjs/core/shapes/funnel/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/funnel/renderer.js +74 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
- package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
- package/dist/cjs/{hooks/useShapes → core/shapes}/heatmap/prepare-data.js +3 -2
- package/dist/cjs/core/shapes/heatmap/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/heatmap/renderer.js +50 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/heatmap/types.d.ts +2 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/line/prepare-data.d.ts +4 -4
- package/dist/cjs/{hooks/useShapes → core/shapes}/line/prepare-data.js +12 -4
- package/dist/cjs/core/shapes/line/renderer.d.ts +11 -0
- package/dist/cjs/core/shapes/line/renderer.js +161 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/line/types.d.ts +7 -8
- package/dist/cjs/core/shapes/marker.d.ts +45 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/marker.js +2 -2
- package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
- package/dist/cjs/core/shapes/pie/renderer.d.ts +8 -0
- package/dist/cjs/core/shapes/pie/renderer.js +160 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/pie/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/radar/prepare-data.js +2 -2
- package/dist/cjs/core/shapes/radar/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/radar/renderer.js +122 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
- package/dist/cjs/core/shapes/sankey/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/sankey/renderer.js +44 -0
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/sankey/types.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/scatter/prepare-data.d.ts +3 -3
- package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/prepare-data.js +2 -2
- package/dist/cjs/core/shapes/scatter/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/scatter/renderer.js +52 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/scatter/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/treemap/prepare-data.js +3 -3
- package/dist/cjs/core/shapes/treemap/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/treemap/renderer.js +88 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/treemap/types.d.ts +1 -1
- package/dist/cjs/core/shapes/utils.d.ts +76 -0
- package/dist/cjs/core/shapes/utils.js +186 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
- package/dist/{esm/hooks/useShapes → cjs/core/shapes}/waterfall/prepare-data.js +4 -4
- package/dist/cjs/core/shapes/waterfall/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/waterfall/renderer.js +109 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/waterfall/types.d.ts +1 -1
- package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
- package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
- package/dist/cjs/core/shapes/x-range/renderer.d.ts +6 -0
- package/dist/cjs/core/shapes/x-range/renderer.js +88 -0
- package/dist/cjs/{hooks/useShapes → core/shapes}/x-range/types.d.ts +1 -1
- package/dist/cjs/core/types/chart/area.d.ts +0 -1
- package/dist/cjs/core/types/chart/axis.d.ts +0 -1
- package/dist/cjs/core/types/chart/base.d.ts +18 -7
- package/dist/cjs/core/types/chart/tooltip.d.ts +3 -3
- package/dist/cjs/core/types/formatter.d.ts +1 -40
- package/dist/{esm/hooks/utils/get-band-size.js → cjs/core/utils/band-size.js} +1 -1
- package/dist/cjs/{hooks → core}/utils/bar-y.d.ts +3 -3
- package/dist/{esm/hooks → cjs/core}/utils/bar-y.js +4 -4
- package/dist/cjs/core/utils/format.d.ts +2 -2
- package/dist/cjs/core/utils/get-closest-data.d.ts +1 -1
- package/dist/cjs/core/utils/get-closest-data.js +13 -8
- package/dist/cjs/core/utils/series/sorting.js +1 -1
- package/dist/cjs/core/utils/text.d.ts +0 -1
- package/dist/cjs/core/utils/text.js +0 -1
- package/dist/cjs/core/zoom/index.d.ts +2 -0
- package/dist/cjs/core/zoom/index.js +2 -0
- package/dist/{esm/hooks/useZoom → cjs/core/zoom}/utils.d.ts +3 -3
- package/dist/{esm/hooks/useZoom → cjs/core/zoom}/utils.js +1 -1
- package/dist/cjs/core/zoom/zoom.d.ts +3 -3
- package/dist/cjs/hooks/index.d.ts +3 -3
- package/dist/cjs/hooks/index.js +3 -3
- package/dist/cjs/hooks/types.d.ts +2 -8
- package/dist/cjs/hooks/useBrush/index.d.ts +1 -1
- package/dist/cjs/hooks/useBrush/index.js +1 -1
- package/dist/cjs/hooks/useRangeSlider/index.js +3 -3
- package/dist/cjs/hooks/useRangeSlider/types.d.ts +6 -8
- package/dist/cjs/hooks/useShapes/area/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/area/index.js +13 -185
- package/dist/cjs/hooks/useShapes/bar-x/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/bar-x/index.js +10 -119
- package/dist/cjs/hooks/useShapes/bar-y/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/bar-y/index.js +5 -84
- package/dist/cjs/hooks/useShapes/funnel/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/funnel/index.js +4 -83
- package/dist/cjs/hooks/useShapes/heatmap/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/heatmap/index.js +4 -59
- package/dist/cjs/hooks/useShapes/index.d.ts +15 -16
- package/dist/cjs/hooks/useShapes/index.js +13 -13
- package/dist/cjs/hooks/useShapes/line/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/line/index.js +14 -172
- package/dist/cjs/hooks/useShapes/pie/index.d.ts +3 -5
- package/dist/cjs/hooks/useShapes/pie/index.js +3 -158
- package/dist/cjs/hooks/useShapes/radar/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/radar/index.js +2 -121
- package/dist/cjs/hooks/useShapes/sankey/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/sankey/index.js +2 -51
- package/dist/cjs/hooks/useShapes/scatter/index.d.ts +3 -3
- package/dist/cjs/hooks/useShapes/scatter/index.js +3 -58
- package/dist/cjs/hooks/useShapes/treemap/index.d.ts +2 -2
- package/dist/cjs/hooks/useShapes/treemap/index.js +2 -88
- package/dist/cjs/hooks/useShapes/utils.d.ts +3 -53
- package/dist/cjs/hooks/useShapes/utils.js +3 -140
- package/dist/cjs/hooks/useShapes/waterfall/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/waterfall/index.js +6 -119
- package/dist/cjs/hooks/useShapes/x-range/index.d.ts +4 -4
- package/dist/cjs/hooks/useShapes/x-range/index.js +3 -98
- package/dist/cjs/hooks/useZoom/index.d.ts +1 -1
- package/dist/cjs/hooks/useZoom/index.js +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/libs/format-number/index.js +82 -14
- package/dist/cjs/libs/format-number/presets.d.ts +40 -0
- package/dist/cjs/libs/format-number/presets.js +66 -0
- package/dist/cjs/libs/format-number/types.d.ts +82 -3
- package/dist/cjs/setup-jsdom.js +7 -0
- package/dist/esm/components/ChartInner/index.js +1 -0
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +1 -0
- package/dist/esm/components/ChartInner/useChartInnerProps.js +13 -6
- package/dist/esm/components/Legend/index.js +13 -14
- package/dist/esm/components/Tooltip/index.js +22 -1
- package/dist/esm/core/axes/x-axis.js +1 -1
- package/dist/esm/core/axes/y-axis.js +1 -1
- package/dist/esm/core/brush/index.d.ts +2 -0
- package/dist/esm/core/brush/index.js +2 -0
- package/dist/esm/{hooks/useBrush → core/brush}/types.d.ts +2 -2
- package/dist/esm/{hooks/useBrush → core/brush}/utils.d.ts +1 -1
- package/dist/esm/core/chart/index.d.ts +1 -0
- package/dist/esm/core/chart/index.js +1 -0
- package/dist/esm/core/chart/types.d.ts +8 -0
- package/dist/esm/core/index.d.ts +3 -0
- package/dist/esm/core/index.js +3 -0
- package/dist/esm/core/layout/chart-dimensions.d.ts +1 -1
- package/dist/esm/core/range-slider/index.d.ts +2 -0
- package/dist/esm/core/range-slider/index.js +2 -0
- package/dist/esm/core/range-slider/types.d.ts +4 -0
- package/dist/{cjs/hooks/useRangeSlider → esm/core/range-slider}/utils.d.ts +5 -5
- package/dist/{cjs/hooks/useRangeSlider → esm/core/range-slider}/utils.js +1 -1
- package/dist/esm/core/scales/utils.d.ts +1 -1
- package/dist/esm/core/scales/utils.js +1 -1
- package/dist/esm/core/scales/x-scale.d.ts +2 -2
- package/dist/esm/core/scales/x-scale.js +2 -2
- package/dist/esm/core/scales/y-scale.js +69 -4
- package/dist/esm/core/series/prepare-area.js +1 -1
- package/dist/esm/core/series/prepare-bar-x.js +1 -1
- package/dist/esm/core/series/prepare-bar-y.js +1 -1
- package/dist/esm/core/series/prepare-funnel.js +1 -1
- package/dist/esm/core/series/prepare-heatmap.js +1 -1
- package/dist/esm/core/series/prepare-legend.d.ts +1 -1
- package/dist/esm/core/series/prepare-legend.js +2 -2
- package/dist/esm/core/series/prepare-line.js +1 -1
- package/dist/esm/core/series/prepare-pie.js +1 -1
- package/dist/esm/core/series/prepare-radar.js +1 -1
- package/dist/esm/core/series/prepare-sankey.js +1 -1
- package/dist/esm/core/series/prepare-scatter.js +1 -1
- package/dist/esm/core/series/prepare-treemap.js +1 -1
- package/dist/esm/core/series/prepare-waterfall.js +1 -1
- package/dist/esm/core/series/prepare-x-range.js +1 -1
- package/dist/esm/core/series/prepareSeries.d.ts +7 -1
- package/dist/esm/core/series/prepareSeries.js +31 -0
- package/dist/esm/core/series/types.d.ts +5 -0
- package/dist/esm/core/series/utils.d.ts +4 -0
- package/dist/esm/core/series/utils.js +9 -1
- package/dist/esm/{hooks/useShapes/annotation/index.d.ts → core/shapes/annotation.d.ts} +1 -7
- package/dist/esm/{hooks/useShapes/annotation/index.js → core/shapes/annotation.js} +2 -2
- package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.d.ts +4 -4
- package/dist/esm/{hooks/useShapes → core/shapes}/area/prepare-data.js +9 -4
- package/dist/esm/core/shapes/area/renderer.d.ts +11 -0
- package/dist/esm/core/shapes/area/renderer.js +175 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/area/types.d.ts +7 -8
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.d.ts +4 -4
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-x/prepare-data.js +6 -6
- package/dist/esm/core/shapes/bar-x/renderer.d.ts +9 -0
- package/dist/esm/core/shapes/bar-x/renderer.js +104 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/bar-x/types.d.ts +1 -2
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.d.ts +3 -3
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/bar-y/prepare-data.js +3 -3
- package/dist/esm/core/shapes/bar-y/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/bar-y/renderer.js +74 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/utils.js +1 -1
- package/dist/esm/core/shapes/data-labels.d.ts +15 -0
- package/dist/esm/core/shapes/data-labels.js +15 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/funnel/prepare-data.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/funnel/prepare-data.js +1 -1
- package/dist/esm/core/shapes/funnel/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/funnel/renderer.js +74 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/funnel/types.d.ts +2 -2
- package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/prepare-data.d.ts +3 -3
- package/dist/esm/{hooks/useShapes → core/shapes}/heatmap/prepare-data.js +3 -2
- package/dist/esm/core/shapes/heatmap/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/heatmap/renderer.js +50 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/heatmap/types.d.ts +2 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/line/prepare-data.d.ts +4 -4
- package/dist/esm/{hooks/useShapes → core/shapes}/line/prepare-data.js +12 -4
- package/dist/esm/core/shapes/line/renderer.d.ts +11 -0
- package/dist/esm/core/shapes/line/renderer.js +161 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/line/types.d.ts +7 -8
- package/dist/esm/core/shapes/marker.d.ts +45 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/marker.js +2 -2
- package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/pie/prepare-data.js +3 -3
- package/dist/esm/core/shapes/pie/renderer.d.ts +8 -0
- package/dist/esm/core/shapes/pie/renderer.js +160 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/pie/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/radar/prepare-data.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/radar/prepare-data.js +2 -2
- package/dist/esm/core/shapes/radar/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/radar/renderer.js +122 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/radar/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/sankey/prepare-data.js +1 -1
- package/dist/esm/core/shapes/sankey/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/sankey/renderer.js +44 -0
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/sankey/types.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/scatter/prepare-data.d.ts +3 -3
- package/dist/esm/{hooks/useShapes → core/shapes}/scatter/prepare-data.js +2 -2
- package/dist/esm/core/shapes/scatter/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/scatter/renderer.js +52 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/scatter/types.d.ts +1 -1
- package/dist/esm/{hooks/useShapes → core/shapes}/treemap/prepare-data.d.ts +1 -1
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/treemap/prepare-data.js +3 -3
- package/dist/esm/core/shapes/treemap/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/treemap/renderer.js +88 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/treemap/types.d.ts +1 -1
- package/dist/esm/core/shapes/treemap/types.js +1 -0
- package/dist/esm/core/shapes/utils.d.ts +76 -0
- package/dist/esm/core/shapes/utils.js +186 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/prepare-data.d.ts +3 -3
- package/dist/{cjs/hooks/useShapes → esm/core/shapes}/waterfall/prepare-data.js +4 -4
- package/dist/esm/core/shapes/waterfall/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/waterfall/renderer.js +109 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/waterfall/types.d.ts +1 -1
- package/dist/esm/core/shapes/waterfall/types.js +1 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.d.ts +3 -3
- package/dist/esm/{hooks/useShapes → core/shapes}/x-range/prepare-data.js +4 -4
- package/dist/esm/core/shapes/x-range/renderer.d.ts +6 -0
- package/dist/esm/core/shapes/x-range/renderer.js +88 -0
- package/dist/esm/{hooks/useShapes → core/shapes}/x-range/types.d.ts +1 -1
- package/dist/esm/core/shapes/x-range/types.js +1 -0
- package/dist/esm/core/types/chart/area.d.ts +0 -1
- package/dist/esm/core/types/chart/axis.d.ts +0 -1
- package/dist/esm/core/types/chart/base.d.ts +18 -7
- package/dist/esm/core/types/chart/tooltip.d.ts +3 -3
- package/dist/esm/core/types/formatter.d.ts +1 -40
- package/dist/{cjs/hooks/utils/get-band-size.js → esm/core/utils/band-size.js} +1 -1
- package/dist/esm/{hooks → core}/utils/bar-y.d.ts +3 -3
- package/dist/{cjs/hooks → esm/core}/utils/bar-y.js +4 -4
- package/dist/esm/core/utils/format.d.ts +2 -2
- package/dist/esm/core/utils/get-closest-data.d.ts +1 -1
- package/dist/esm/core/utils/get-closest-data.js +13 -8
- package/dist/esm/core/utils/series/sorting.js +1 -1
- package/dist/esm/core/utils/text.d.ts +0 -1
- package/dist/esm/core/utils/text.js +0 -1
- package/dist/esm/core/zoom/index.d.ts +2 -0
- package/dist/esm/core/zoom/index.js +2 -0
- package/dist/esm/core/zoom/types.js +1 -0
- package/dist/{cjs/hooks/useZoom → esm/core/zoom}/utils.d.ts +3 -3
- package/dist/{cjs/hooks/useZoom → esm/core/zoom}/utils.js +1 -1
- package/dist/esm/core/zoom/zoom.d.ts +3 -3
- package/dist/esm/hooks/index.d.ts +3 -3
- package/dist/esm/hooks/index.js +3 -3
- package/dist/esm/hooks/types.d.ts +2 -8
- package/dist/esm/hooks/useBrush/index.d.ts +1 -1
- package/dist/esm/hooks/useBrush/index.js +1 -1
- package/dist/esm/hooks/useRangeSlider/index.js +3 -3
- package/dist/esm/hooks/useRangeSlider/types.d.ts +6 -8
- package/dist/esm/hooks/useShapes/area/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/area/index.js +13 -185
- package/dist/esm/hooks/useShapes/bar-x/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/bar-x/index.js +10 -119
- package/dist/esm/hooks/useShapes/bar-y/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/bar-y/index.js +5 -84
- package/dist/esm/hooks/useShapes/funnel/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/funnel/index.js +4 -83
- package/dist/esm/hooks/useShapes/heatmap/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/heatmap/index.js +4 -59
- package/dist/esm/hooks/useShapes/index.d.ts +15 -16
- package/dist/esm/hooks/useShapes/index.js +13 -13
- package/dist/esm/hooks/useShapes/line/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/line/index.js +14 -172
- package/dist/esm/hooks/useShapes/pie/index.d.ts +3 -5
- package/dist/esm/hooks/useShapes/pie/index.js +3 -158
- package/dist/esm/hooks/useShapes/radar/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/radar/index.js +2 -121
- package/dist/esm/hooks/useShapes/sankey/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/sankey/index.js +2 -51
- package/dist/esm/hooks/useShapes/scatter/index.d.ts +3 -3
- package/dist/esm/hooks/useShapes/scatter/index.js +3 -58
- package/dist/esm/hooks/useShapes/treemap/index.d.ts +2 -2
- package/dist/esm/hooks/useShapes/treemap/index.js +2 -88
- package/dist/esm/hooks/useShapes/utils.d.ts +3 -53
- package/dist/esm/hooks/useShapes/utils.js +3 -140
- package/dist/esm/hooks/useShapes/waterfall/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/waterfall/index.js +6 -119
- package/dist/esm/hooks/useShapes/x-range/index.d.ts +4 -4
- package/dist/esm/hooks/useShapes/x-range/index.js +3 -98
- package/dist/esm/hooks/useZoom/index.d.ts +1 -1
- package/dist/esm/hooks/useZoom/index.js +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/libs/format-number/index.js +82 -14
- package/dist/esm/libs/format-number/presets.d.ts +40 -0
- package/dist/esm/libs/format-number/presets.js +66 -0
- package/dist/esm/libs/format-number/types.d.ts +82 -3
- package/dist/esm/setup-jsdom.js +7 -0
- package/package.json +5 -2
- package/dist/cjs/hooks/useSeries/index.d.ts +0 -12
- package/dist/cjs/hooks/useSeries/index.js +0 -40
- package/dist/cjs/hooks/useSeries/types.d.ts +0 -1
- package/dist/cjs/hooks/useSeries/types.js +0 -1
- package/dist/cjs/hooks/useSeries/utils.d.ts +0 -1
- package/dist/cjs/hooks/useSeries/utils.js +0 -1
- package/dist/cjs/hooks/useShapes/marker.d.ts +0 -15
- package/dist/cjs/hooks/utils/index.d.ts +0 -1
- package/dist/cjs/hooks/utils/index.js +0 -1
- package/dist/esm/hooks/useSeries/index.d.ts +0 -12
- package/dist/esm/hooks/useSeries/index.js +0 -40
- package/dist/esm/hooks/useSeries/types.d.ts +0 -1
- package/dist/esm/hooks/useSeries/types.js +0 -1
- package/dist/esm/hooks/useSeries/utils.d.ts +0 -1
- package/dist/esm/hooks/useSeries/utils.js +0 -1
- package/dist/esm/hooks/useShapes/marker.d.ts +0 -15
- package/dist/esm/hooks/utils/index.d.ts +0 -1
- package/dist/esm/hooks/utils/index.js +0 -1
- /package/dist/cjs/{hooks/useBrush → core/brush}/types.js +0 -0
- /package/dist/cjs/{hooks/useBrush → core/brush}/utils.js +0 -0
- /package/dist/cjs/{hooks/useShapes/area → core/chart}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/bar-x → core/range-slider}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/bar-y → core/shapes/area}/types.js +0 -0
- /package/dist/cjs/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
- /package/dist/cjs/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
- /package/dist/cjs/{hooks/useShapes/funnel → core/shapes/bar-x}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/heatmap → core/shapes/bar-y}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
- /package/dist/cjs/{hooks/useShapes/line → core/shapes/funnel}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/pie → core/shapes/heatmap}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/radar → core/shapes/line}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/sankey → core/shapes/pie}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
- /package/dist/cjs/{hooks/useShapes/scatter → core/shapes/radar}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
- /package/dist/cjs/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
- /package/dist/cjs/{hooks/useShapes/treemap → core/shapes/sankey}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/waterfall → core/shapes/scatter}/types.js +0 -0
- /package/dist/cjs/{hooks/useShapes/x-range → core/shapes/treemap}/types.js +0 -0
- /package/dist/cjs/{hooks/useZoom → core/shapes/waterfall}/types.js +0 -0
- /package/dist/{esm/hooks/useBrush → cjs/core/shapes/x-range}/types.js +0 -0
- /package/dist/cjs/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
- /package/dist/cjs/{hooks/useZoom → core/zoom}/types.d.ts +0 -0
- /package/dist/{esm/hooks/useShapes/area → cjs/core/zoom}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/bar-x → core/brush}/types.js +0 -0
- /package/dist/esm/{hooks/useBrush → core/brush}/utils.js +0 -0
- /package/dist/esm/{hooks/useShapes/bar-y → core/chart}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/funnel → core/range-slider}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/heatmap → core/shapes/area}/types.js +0 -0
- /package/dist/esm/{hooks/constants.d.ts → core/shapes/bar-constants.d.ts} +0 -0
- /package/dist/esm/{hooks/constants.js → core/shapes/bar-constants.js} +0 -0
- /package/dist/esm/{hooks/useShapes/line → core/shapes/bar-x}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/pie → core/shapes/bar-y}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/bar-y/utils.d.ts +0 -0
- /package/dist/esm/{hooks/useShapes/radar → core/shapes/funnel}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/sankey → core/shapes/heatmap}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/scatter → core/shapes/line}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes/treemap → core/shapes/pie}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.d.ts +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/pie/utils.js +0 -0
- /package/dist/esm/{hooks/useShapes/waterfall → core/shapes/radar}/types.js +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.d.ts +0 -0
- /package/dist/esm/{hooks/useShapes → core/shapes}/sankey/sankey-layout.js +0 -0
- /package/dist/esm/{hooks/useShapes/x-range → core/shapes/sankey}/types.js +0 -0
- /package/dist/esm/{hooks/useZoom → core/shapes/scatter}/types.js +0 -0
- /package/dist/esm/{hooks/utils/get-band-size.d.ts → core/utils/band-size.d.ts} +0 -0
- /package/dist/esm/{hooks/useZoom → core/zoom}/types.d.ts +0 -0
|
@@ -1,112 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { select } from 'd3-selection';
|
|
4
|
-
import get from 'lodash/get';
|
|
5
|
-
import { getLineDashArray } from '../../../core/utils';
|
|
2
|
+
import { renderXRange } from '../../../core/shapes/x-range/renderer';
|
|
6
3
|
import { block } from '../../../utils';
|
|
7
4
|
import { HtmlLayer } from '../HtmlLayer';
|
|
8
|
-
|
|
9
|
-
export { prepareXRangeData } from './prepare-data';
|
|
5
|
+
export { prepareXRangeData } from '../../../core/shapes/x-range/prepare-data';
|
|
10
6
|
const b = block('x-range');
|
|
11
7
|
export function XRangeSeriesShapes(args) {
|
|
12
8
|
const { dispatcher, preparedData, seriesOptions, htmlLayout, clipPathId } = args;
|
|
13
|
-
const hoveredDataRef = React.useRef(null);
|
|
14
9
|
const ref = React.useRef(null);
|
|
15
10
|
React.useEffect(() => {
|
|
16
|
-
var _a;
|
|
17
11
|
if (!ref.current) {
|
|
18
12
|
return () => { };
|
|
19
13
|
}
|
|
20
|
-
|
|
21
|
-
svgElement.selectAll('*').remove();
|
|
22
|
-
const segmentSelection = svgElement
|
|
23
|
-
.selectAll(`path.${b('segment')}`)
|
|
24
|
-
.data(preparedData)
|
|
25
|
-
.join('path')
|
|
26
|
-
.attr('d', (d) => {
|
|
27
|
-
const borderRadius = Math.min(d.height / 2, d.width / 2, d.series.borderRadius);
|
|
28
|
-
return getRectPath({
|
|
29
|
-
x: d.x,
|
|
30
|
-
y: d.y,
|
|
31
|
-
width: d.width,
|
|
32
|
-
height: d.height,
|
|
33
|
-
borderRadius,
|
|
34
|
-
}).toString();
|
|
35
|
-
})
|
|
36
|
-
.attr('class', b('segment'))
|
|
37
|
-
.attr('fill', (d) => d.color)
|
|
38
|
-
.attr('opacity', (d) => { var _a; return (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity; })
|
|
39
|
-
.attr('cursor', (d) => d.series.cursor);
|
|
40
|
-
svgElement
|
|
41
|
-
.selectAll(`path.${b('segment-border')}`)
|
|
42
|
-
.data(preparedData.filter((d) => d.series.borderWidth > 0))
|
|
43
|
-
.join('path')
|
|
44
|
-
.attr('d', (d) => {
|
|
45
|
-
const borderRadius = Math.min(d.height / 2, d.width / 2, d.series.borderRadius);
|
|
46
|
-
return getRectPath({
|
|
47
|
-
x: d.x,
|
|
48
|
-
y: d.y,
|
|
49
|
-
width: d.width,
|
|
50
|
-
height: d.height,
|
|
51
|
-
borderRadius,
|
|
52
|
-
}).toString();
|
|
53
|
-
})
|
|
54
|
-
.attr('class', b('segment-border'))
|
|
55
|
-
.attr('fill', 'none')
|
|
56
|
-
.attr('stroke', (d) => d.series.borderColor)
|
|
57
|
-
.attr('stroke-width', (d) => d.series.borderWidth)
|
|
58
|
-
.attr('stroke-dasharray', (d) => getLineDashArray(d.series.borderDashStyle, d.series.borderWidth))
|
|
59
|
-
.attr('opacity', (d) => { var _a; return (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity; })
|
|
60
|
-
.attr('pointer-events', 'none');
|
|
61
|
-
const svgLabels = preparedData.flatMap((d) => d.svgLabels);
|
|
62
|
-
svgElement
|
|
63
|
-
.selectAll(`text.${b('label')}`)
|
|
64
|
-
.data(svgLabels)
|
|
65
|
-
.join('text')
|
|
66
|
-
.attr('class', b('label'))
|
|
67
|
-
.attr('x', (d) => d.x)
|
|
68
|
-
.attr('y', (d) => d.y)
|
|
69
|
-
.attr('text-anchor', (d) => d.textAnchor)
|
|
70
|
-
.attr('dominant-baseline', 'central')
|
|
71
|
-
.attr('pointer-events', 'none')
|
|
72
|
-
.style('font-size', (d) => d.style.fontSize)
|
|
73
|
-
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
74
|
-
.style('fill', (d) => d.style.fontColor || null)
|
|
75
|
-
.html((d) => d.text);
|
|
76
|
-
const hoverOptions = get(seriesOptions, 'x-range.states.hover');
|
|
77
|
-
const inactiveOptions = get(seriesOptions, 'x-range.states.inactive');
|
|
78
|
-
function handleShapeHover(data) {
|
|
79
|
-
hoveredDataRef.current = data;
|
|
80
|
-
if (hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled) {
|
|
81
|
-
const hoveredSet = new Set(data === null || data === void 0 ? void 0 : data.map((d) => d.data));
|
|
82
|
-
segmentSelection.attr('fill', (d) => {
|
|
83
|
-
var _a;
|
|
84
|
-
const fillColor = d.color;
|
|
85
|
-
if (hoveredSet.has(d.data)) {
|
|
86
|
-
return (((_a = color(fillColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions.brightness).toString()) ||
|
|
87
|
-
fillColor);
|
|
88
|
-
}
|
|
89
|
-
return fillColor;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
if (inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled) {
|
|
93
|
-
const hoveredSeries = data === null || data === void 0 ? void 0 : data.map((d) => d.series.id);
|
|
94
|
-
segmentSelection.attr('opacity', (d) => {
|
|
95
|
-
var _a, _b;
|
|
96
|
-
if ((hoveredSeries === null || hoveredSeries === void 0 ? void 0 : hoveredSeries.length) && !hoveredSeries.includes(d.series.id)) {
|
|
97
|
-
return inactiveOptions.opacity || null;
|
|
98
|
-
}
|
|
99
|
-
return (_b = (_a = d.data.opacity) !== null && _a !== void 0 ? _a : d.series.opacity) !== null && _b !== void 0 ? _b : null;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (hoveredDataRef.current !== null) {
|
|
104
|
-
handleShapeHover((_a = hoveredDataRef.current) !== null && _a !== void 0 ? _a : undefined);
|
|
105
|
-
}
|
|
106
|
-
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.x-range', handleShapeHover);
|
|
107
|
-
return () => {
|
|
108
|
-
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.x-range', null);
|
|
109
|
-
};
|
|
14
|
+
return renderXRange({ plot: ref.current }, preparedData, seriesOptions, dispatcher);
|
|
110
15
|
}, [dispatcher, preparedData, seriesOptions]);
|
|
111
16
|
const htmlLayerData = React.useMemo(() => ({ htmlElements: preparedData.flatMap((d) => d.htmlLabels) }), [preparedData]);
|
|
112
17
|
return (React.createElement(React.Fragment, null,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PreparedSplit } from '../../core/layout/split-types';
|
|
2
2
|
import type { ChartScale } from '../../core/scales/types';
|
|
3
|
+
import type { ZoomState } from '../../core/zoom/types';
|
|
3
4
|
import type { PreparedZoom } from '../types';
|
|
4
5
|
import type { PreparedXAxis, PreparedYAxis } from '../useAxis/types';
|
|
5
|
-
import type { ZoomState } from './types';
|
|
6
6
|
interface UseZoomProps {
|
|
7
7
|
node: SVGGElement | null;
|
|
8
8
|
onUpdate: (zoomState: Partial<ZoomState>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { select } from 'd3-selection';
|
|
3
|
+
import { selectionToZoomBounds } from '../../core/zoom/utils';
|
|
3
4
|
import { useBrush } from '../useBrush';
|
|
4
|
-
import { selectionToZoomBounds } from './utils';
|
|
5
5
|
export function useZoom(props) {
|
|
6
6
|
const { node, onUpdate, plotContainerHeight, plotContainerWidth, preparedSplit, preparedZoom, rangeSliderDomain, xAxis, xScale, yAxis, yScale, } = props;
|
|
7
7
|
const isBrushDisabled = Boolean(!xAxis || !yAxis || !xScale || !yScale);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { CustomShapeRenderer } from './utils';
|
|
2
2
|
export { getFormattedValue } from './core/utils';
|
|
3
3
|
export { getDefaultTooltipHeaderFormat } from './core/utils/tooltip';
|
|
4
|
+
export { FORMAT_UNITS_BITS, FORMAT_UNITS_BYTES, FORMAT_UNITS_NUMBERS, } from './libs/format-number/presets';
|
|
4
5
|
export * from './components';
|
|
5
6
|
export * from './types';
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { CustomShapeRenderer } from './utils';
|
|
2
2
|
export { getFormattedValue } from './core/utils';
|
|
3
3
|
export { getDefaultTooltipHeaderFormat } from './core/utils/tooltip';
|
|
4
|
+
export { FORMAT_UNITS_BITS, FORMAT_UNITS_BYTES, FORMAT_UNITS_NUMBERS, } from './libs/format-number/presets';
|
|
4
5
|
export * from './components';
|
|
5
6
|
export * from './types';
|
|
@@ -11,26 +11,30 @@ function getUnitRate(value, exponent, unitsI18nKeys) {
|
|
|
11
11
|
}
|
|
12
12
|
return resultUnitRate - 1;
|
|
13
13
|
}
|
|
14
|
+
const formatScaledNumber = (value, options) => {
|
|
15
|
+
const { precision, showRankDelimiter = true, lang } = options;
|
|
16
|
+
let result = value;
|
|
17
|
+
if (typeof precision === 'number') {
|
|
18
|
+
result = Number(result.toFixed(precision));
|
|
19
|
+
}
|
|
20
|
+
else if (precision === 'auto' && result % 1 !== 0) {
|
|
21
|
+
result = Number(result.toFixed(Math.abs(result) > 1 ? 2 : 4));
|
|
22
|
+
}
|
|
23
|
+
return new Intl.NumberFormat(lang !== null && lang !== void 0 ? lang : i18nInstance.lang, {
|
|
24
|
+
minimumFractionDigits: typeof precision === 'number' ? precision : 0,
|
|
25
|
+
maximumFractionDigits: 20,
|
|
26
|
+
useGrouping: showRankDelimiter,
|
|
27
|
+
}).format(result);
|
|
28
|
+
};
|
|
14
29
|
const unitFormatter = ({ exponent, unitsI18nKeys, unitDelimiterI18nKey, }) => {
|
|
15
30
|
return function formatUnit(value, options = {}) {
|
|
16
|
-
const {
|
|
31
|
+
const { unitRate, lang } = options;
|
|
17
32
|
const i18nLang = i18nInstance.lang;
|
|
18
33
|
if (lang) {
|
|
19
34
|
i18nInstance.setLang(lang);
|
|
20
35
|
}
|
|
21
36
|
const resultUnitRate = typeof unitRate === 'number' ? unitRate : getUnitRate(value, exponent, unitsI18nKeys);
|
|
22
|
-
|
|
23
|
-
if (typeof precision === 'number') {
|
|
24
|
-
result = Number(result.toFixed(precision));
|
|
25
|
-
}
|
|
26
|
-
else if (precision === 'auto' && result % 1 !== 0) {
|
|
27
|
-
result = Number(result.toFixed(Math.abs(result) > 1 ? 2 : 4));
|
|
28
|
-
}
|
|
29
|
-
result = new Intl.NumberFormat(lang !== null && lang !== void 0 ? lang : i18nLang, {
|
|
30
|
-
minimumFractionDigits: typeof precision === 'number' ? precision : 0,
|
|
31
|
-
maximumFractionDigits: 20,
|
|
32
|
-
useGrouping: showRankDelimiter,
|
|
33
|
-
}).format(result);
|
|
37
|
+
const result = formatScaledNumber(value / Math.pow(exponent, resultUnitRate), options);
|
|
34
38
|
const unit = i18n(unitsI18nKeys[resultUnitRate]);
|
|
35
39
|
const delimiter = i18n(unitDelimiterI18nKey);
|
|
36
40
|
i18nInstance.setLang(i18nLang);
|
|
@@ -59,6 +63,65 @@ const baseFormatNumber = unitFormatter({
|
|
|
59
63
|
unitDelimiterI18nKey: 'value_number-delimiter',
|
|
60
64
|
unitsI18nKeys: BASE_NUMBER_FORMAT_UNIT_KEYS,
|
|
61
65
|
});
|
|
66
|
+
const resolvePostfix = (postfix, lang) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
if (typeof postfix === 'string') {
|
|
69
|
+
return postfix;
|
|
70
|
+
}
|
|
71
|
+
return (_b = (_a = postfix[lang]) !== null && _a !== void 0 ? _a : postfix.en) !== null && _b !== void 0 ? _b : '';
|
|
72
|
+
};
|
|
73
|
+
const FALLBACK_UNIT_ENTRY = { factor: 1, postfix: '' };
|
|
74
|
+
const normalizedUnitsCache = new WeakMap();
|
|
75
|
+
const normalizeUnits = (units) => {
|
|
76
|
+
const cached = normalizedUnitsCache.get(units);
|
|
77
|
+
if (cached) {
|
|
78
|
+
return cached;
|
|
79
|
+
}
|
|
80
|
+
const { scale } = units;
|
|
81
|
+
const rawEntries = Array.isArray(scale)
|
|
82
|
+
? scale.map((e) => ({ factor: e.factor, postfix: e.postfix }))
|
|
83
|
+
: scale.postfixes.map((postfix, i) => ({ factor: Math.pow(scale.base, i), postfix }));
|
|
84
|
+
const valid = rawEntries.filter((e) => Number.isFinite(e.factor) && e.factor > 0);
|
|
85
|
+
valid.sort((a, b) => a.factor - b.factor);
|
|
86
|
+
const deduped = [];
|
|
87
|
+
for (const e of valid) {
|
|
88
|
+
if (deduped.length === 0 || deduped[deduped.length - 1].factor !== e.factor) {
|
|
89
|
+
deduped.push(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const result = deduped.length > 0 ? deduped : [FALLBACK_UNIT_ENTRY];
|
|
93
|
+
normalizedUnitsCache.set(units, result);
|
|
94
|
+
return result;
|
|
95
|
+
};
|
|
96
|
+
const pickUnitEntry = (value, scale) => {
|
|
97
|
+
const av = Math.abs(value);
|
|
98
|
+
let chosen = scale[0];
|
|
99
|
+
for (const e of scale) {
|
|
100
|
+
if (av / e.factor >= 1) {
|
|
101
|
+
chosen = e;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return chosen;
|
|
108
|
+
};
|
|
109
|
+
const customUnitFormatter = (value, units, options) => {
|
|
110
|
+
const { lang } = options;
|
|
111
|
+
const i18nLang = i18nInstance.lang;
|
|
112
|
+
if (lang) {
|
|
113
|
+
i18nInstance.setLang(lang);
|
|
114
|
+
}
|
|
115
|
+
const normalizedScale = normalizeUnits(units);
|
|
116
|
+
const entry = pickUnitEntry(value, normalizedScale);
|
|
117
|
+
const result = formatScaledNumber(value / entry.factor, options);
|
|
118
|
+
const effectiveLang = lang !== null && lang !== void 0 ? lang : i18nLang;
|
|
119
|
+
const resolvedPostfix = resolvePostfix(entry.postfix, effectiveLang);
|
|
120
|
+
const resolvedDelimiter = typeof units.delimiter === 'string' ? units.delimiter : ' ';
|
|
121
|
+
const delimiter = resolvedPostfix ? resolvedDelimiter : '';
|
|
122
|
+
i18nInstance.setLang(i18nLang);
|
|
123
|
+
return `${result}${delimiter}${resolvedPostfix}`;
|
|
124
|
+
};
|
|
62
125
|
const NUMBER_UNIT_RATE_BY_UNIT = {
|
|
63
126
|
default: 0,
|
|
64
127
|
auto: undefined,
|
|
@@ -77,7 +140,7 @@ export const formatNumber = (value, options = {}) => {
|
|
|
77
140
|
if (Number.isNaN(value) || Number.isNaN(Number(value))) {
|
|
78
141
|
return new Intl.NumberFormat('en').format(Number(value));
|
|
79
142
|
}
|
|
80
|
-
const { format = 'number', multiplier = 1, prefix = '', postfix = '', unit, labelMode } = options;
|
|
143
|
+
const { format = 'number', multiplier = 1, prefix = '', postfix = '', unit, units, labelMode, } = options;
|
|
81
144
|
let changedMultiplier = multiplier;
|
|
82
145
|
let prePostfix = '';
|
|
83
146
|
if (format === 'percent') {
|
|
@@ -87,6 +150,11 @@ export const formatNumber = (value, options = {}) => {
|
|
|
87
150
|
if (labelMode === 'percent') {
|
|
88
151
|
prePostfix = '%';
|
|
89
152
|
}
|
|
153
|
+
if (units) {
|
|
154
|
+
const unitScale = 'scale' in units ? units : { scale: [units] };
|
|
155
|
+
const formattedValue = customUnitFormatter(Number(value) * changedMultiplier, unitScale, options);
|
|
156
|
+
return `${prefix}${formattedValue}${prePostfix}${postfix}`;
|
|
157
|
+
}
|
|
90
158
|
const formattedValue = baseFormatNumber(Number(value) * changedMultiplier, Object.assign(Object.assign({}, options), { unitRate: NUMBER_UNIT_RATE_BY_UNIT[unit !== null && unit !== void 0 ? unit : 'default'] }));
|
|
91
159
|
return `${prefix}${formattedValue}${prePostfix}${postfix}`;
|
|
92
160
|
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FormatUnitScale } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Byte scale with binary base (`1024`) and localized postfixes.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* tooltip: {
|
|
8
|
+
* valueFormat: {type: 'number', units: FORMAT_UNITS_BYTES, precision: 1},
|
|
9
|
+
* }
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare const FORMAT_UNITS_BYTES: FormatUnitScale;
|
|
13
|
+
/**
|
|
14
|
+
* Short number scale with decimal base (`1000`). Renders large numbers
|
|
15
|
+
* compactly as `K/M/B/T`. Postfixes are plain Latin letters and stay the
|
|
16
|
+
* same regardless of language. The first entry has an empty postfix, so
|
|
17
|
+
* values below `1000` render as plain numbers without a delimiter.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* tooltip: {
|
|
22
|
+
* valueFormat: {type: 'number', units: FORMAT_UNITS_NUMBERS, precision: 1},
|
|
23
|
+
* }
|
|
24
|
+
* // 300 → "300"
|
|
25
|
+
* // 1_500 → "1.5 K"
|
|
26
|
+
* // 1_500_000 → "1.5 M"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const FORMAT_UNITS_NUMBERS: FormatUnitScale;
|
|
30
|
+
/**
|
|
31
|
+
* Bit scale with decimal base (`1000`) and localized postfixes.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* tooltip: {
|
|
36
|
+
* valueFormat: {type: 'number', units: FORMAT_UNITS_BITS, precision: 1},
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const FORMAT_UNITS_BITS: FormatUnitScale;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Byte scale with binary base (`1024`) and localized postfixes.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* tooltip: {
|
|
7
|
+
* valueFormat: {type: 'number', units: FORMAT_UNITS_BYTES, precision: 1},
|
|
8
|
+
* }
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export const FORMAT_UNITS_BYTES = {
|
|
12
|
+
scale: {
|
|
13
|
+
base: 1024,
|
|
14
|
+
postfixes: [
|
|
15
|
+
{ en: 'B', ru: 'Б' },
|
|
16
|
+
{ en: 'KB', ru: 'КБ' },
|
|
17
|
+
{ en: 'MB', ru: 'МБ' },
|
|
18
|
+
{ en: 'GB', ru: 'ГБ' },
|
|
19
|
+
{ en: 'TB', ru: 'ТБ' },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Short number scale with decimal base (`1000`). Renders large numbers
|
|
25
|
+
* compactly as `K/M/B/T`. Postfixes are plain Latin letters and stay the
|
|
26
|
+
* same regardless of language. The first entry has an empty postfix, so
|
|
27
|
+
* values below `1000` render as plain numbers without a delimiter.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* tooltip: {
|
|
32
|
+
* valueFormat: {type: 'number', units: FORMAT_UNITS_NUMBERS, precision: 1},
|
|
33
|
+
* }
|
|
34
|
+
* // 300 → "300"
|
|
35
|
+
* // 1_500 → "1.5 K"
|
|
36
|
+
* // 1_500_000 → "1.5 M"
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export const FORMAT_UNITS_NUMBERS = {
|
|
40
|
+
scale: {
|
|
41
|
+
base: 1000,
|
|
42
|
+
postfixes: ['', 'K', 'M', 'B', 'T'],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Bit scale with decimal base (`1000`) and localized postfixes.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* tooltip: {
|
|
51
|
+
* valueFormat: {type: 'number', units: FORMAT_UNITS_BITS, precision: 1},
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export const FORMAT_UNITS_BITS = {
|
|
56
|
+
scale: {
|
|
57
|
+
base: 1000,
|
|
58
|
+
postfixes: [
|
|
59
|
+
{ en: 'bit', ru: 'бит' },
|
|
60
|
+
{ en: 'Kbit', ru: 'Кбит' },
|
|
61
|
+
{ en: 'Mbit', ru: 'Мбит' },
|
|
62
|
+
{ en: 'Gbit', ru: 'Гбит' },
|
|
63
|
+
{ en: 'Tbit', ru: 'Тбит' },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
@@ -1,13 +1,92 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface FormatOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Number of decimal places to display.
|
|
4
|
+
* Use `'auto'` to determine precision automatically based on the value magnitude.
|
|
5
|
+
*/
|
|
2
6
|
precision?: number | 'auto';
|
|
7
|
+
/** When `true`, inserts a thousands separator (e.g. `1 500 000`). */
|
|
3
8
|
showRankDelimiter?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* BCP 47 language tag used for locale-aware formatting (e.g. `'en'`, `'ru'`).
|
|
11
|
+
* Defaults to the application locale when omitted.
|
|
12
|
+
*/
|
|
4
13
|
lang?: string;
|
|
14
|
+
/** Internal rendering hint for axis label layout. Not intended for public use. */
|
|
5
15
|
labelMode?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Plain string or a per-language dictionary of strings.
|
|
19
|
+
* When a dictionary is used, the lookup chain is:
|
|
20
|
+
* current `lang` → `en` → empty string.
|
|
21
|
+
*/
|
|
22
|
+
export type FormatI18nString = string | Partial<Record<string, string>>;
|
|
23
|
+
/** Single entry of a custom unit scale. */
|
|
24
|
+
export type FormatUnitScaleEntry = {
|
|
25
|
+
/** Positive multiplier applied to the value. The entry wins when `|value| / factor >= 1`. */
|
|
26
|
+
factor: number;
|
|
27
|
+
/**
|
|
28
|
+
* String appended after the scaled value (e.g. `'KB'`).
|
|
29
|
+
* Use an empty string to suppress the suffix and the delimiter.
|
|
30
|
+
* Pass a `{lang: string}` dictionary to localize the postfix — resolution falls back to `en`, then to empty.
|
|
31
|
+
*/
|
|
32
|
+
postfix: FormatI18nString;
|
|
6
33
|
};
|
|
7
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Custom unit scale for numeric formatting.
|
|
36
|
+
*
|
|
37
|
+
* `scale` describes the unit table in one of two forms:
|
|
38
|
+
* - `{base, postfixes}` — geometric progression: `postfixes[i]` is bound to `factor = base^i` (e.g. `{base: 1024, postfixes: ['B','KB','MB']}`).
|
|
39
|
+
* - `FormatUnitScaleEntry[]` — arbitrary factors; required for non-linear scales (e.g. `[{factor:1,postfix:'s'},{factor:60,postfix:'min'},{factor:3600,postfix:'h'}]`).
|
|
40
|
+
*
|
|
41
|
+
* `delimiter` is the shared string placed between the scaled value and the
|
|
42
|
+
* postfix. Defaults to a locale-aware space; pass `''` to suppress it.
|
|
43
|
+
*
|
|
44
|
+
* The normalized scale is cached by object identity, so for best performance
|
|
45
|
+
* reuse the same `units` object across `formatNumber` calls instead of
|
|
46
|
+
* creating a new inline literal on every render.
|
|
47
|
+
*/
|
|
48
|
+
export type FormatUnitScale = {
|
|
49
|
+
scale: {
|
|
50
|
+
base: number;
|
|
51
|
+
postfixes: FormatI18nString[];
|
|
52
|
+
} | FormatUnitScaleEntry[];
|
|
53
|
+
delimiter?: string;
|
|
54
|
+
};
|
|
55
|
+
export interface FormatNumberOptions extends FormatOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Display mode for the numeric value.
|
|
58
|
+
* - `'number'` — plain number (default).
|
|
59
|
+
* - `'percent'` — value is multiplied by 100 and rendered with a `%` suffix.
|
|
60
|
+
*
|
|
61
|
+
* Combining `'percent'` with `units` is not meaningful and should be avoided.
|
|
62
|
+
*/
|
|
8
63
|
format?: 'number' | 'percent';
|
|
64
|
+
/** Factor applied to the value before formatting. For example, `multiplier: 1000` converts seconds to milliseconds. */
|
|
9
65
|
multiplier?: number;
|
|
66
|
+
/** String prepended to the formatted value (e.g. `'$'`). */
|
|
10
67
|
prefix?: string;
|
|
68
|
+
/** String appended to the formatted value (e.g. `' USD'`). */
|
|
11
69
|
postfix?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Compact unit suffix applied to large numbers.
|
|
72
|
+
* - `'auto'` — picks the most appropriate unit automatically (`k`, `m`, `b`, `t`).
|
|
73
|
+
* - `'k'` — thousands (÷ 1 000).
|
|
74
|
+
* - `'m'` — millions (÷ 1 000 000).
|
|
75
|
+
* - `'b'` — billions (÷ 1 000 000 000).
|
|
76
|
+
* - `'t'` — trillions (÷ 1 000 000 000 000).
|
|
77
|
+
* - `null` — no unit suffix.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Use `units` for custom scales. This option is fully ignored when `units` is set.
|
|
80
|
+
*/
|
|
12
81
|
unit?: 'auto' | 'k' | 'm' | 'b' | 't' | null;
|
|
13
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Custom unit scale, or a single `FormatUnitScaleEntry` as sugar for
|
|
84
|
+
* locking every value to one unit (equivalent to the legacy `unit: 'k'`).
|
|
85
|
+
* When set, fully overrides `unit`.
|
|
86
|
+
*
|
|
87
|
+
* Unit selection is always automatic: the entry with the largest `factor`
|
|
88
|
+
* such that `|value| / factor >= 1`, clamped to the smallest entry for
|
|
89
|
+
* very small values.
|
|
90
|
+
*/
|
|
91
|
+
units?: FormatUnitScale | FormatUnitScaleEntry;
|
|
92
|
+
}
|
package/dist/cjs/setup-jsdom.js
CHANGED
|
@@ -10,6 +10,13 @@ if (typeof document !== 'undefined') {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
if (typeof ResizeObserver === 'undefined') {
|
|
14
|
+
global.ResizeObserver = class ResizeObserver {
|
|
15
|
+
observe() { }
|
|
16
|
+
unobserve() { }
|
|
17
|
+
disconnect() { }
|
|
18
|
+
};
|
|
19
|
+
}
|
|
13
20
|
if (typeof HTMLCanvasElement !== 'undefined') {
|
|
14
21
|
// jsdom does not implement HTMLCanvasElement.prototype.getContext (used for text measurement)
|
|
15
22
|
HTMLCanvasElement.prototype.getContext = (() => ({
|
|
@@ -55,6 +55,7 @@ export const ChartInner = (props) => {
|
|
|
55
55
|
const { activeLegendItems, allPreparedSeries, boundsHeight, boundsOffsetLeft, boundsOffsetTop, boundsWidth, handleLegendItemClick, legendConfig, legendItems, preparedLegend, preparedSeries, preparedSeriesOptions, preparedSplit, shapes, shapesData, shapesReady, xAxis, xScale, yAxis, yScale, preparedTitle, preparedChart, } = useChartInnerProps(Object.assign(Object.assign({}, props), { clipPathId,
|
|
56
56
|
dispatcher,
|
|
57
57
|
htmlLayout, plotNode: plotRef.current, rangeSliderState,
|
|
58
|
+
updateRangeSliderState,
|
|
58
59
|
updateZoomState,
|
|
59
60
|
zoomState }));
|
|
60
61
|
const prevWidth = usePrevious(width);
|
|
@@ -9,6 +9,7 @@ type Props = ChartInnerProps & {
|
|
|
9
9
|
dispatcher: Dispatch<object>;
|
|
10
10
|
htmlLayout: HTMLElement | null;
|
|
11
11
|
plotNode: SVGGElement | null;
|
|
12
|
+
updateRangeSliderState: (nextState?: RangeSliderState) => void;
|
|
12
13
|
updateZoomState: (nextZoomState: Partial<ZoomState>) => void;
|
|
13
14
|
zoomState: Partial<ZoomState>;
|
|
14
15
|
rangeSliderState?: RangeSliderState;
|
|
@@ -3,9 +3,9 @@ import isEqual from 'lodash/isEqual';
|
|
|
3
3
|
import { DEFAULT_PALETTE, SERIES_TYPE } from '../../core/constants';
|
|
4
4
|
import { getLegendComponents, getPreparedLegend } from '../../core/series/prepare-legend';
|
|
5
5
|
import { getPreparedOptions } from '../../core/series/prepare-options';
|
|
6
|
+
import { getActiveLegendItems, getAllLegendItems } from '../../core/series/utils';
|
|
6
7
|
import { getChartDimensions, getEffectiveXRange, getSortedSeriesData, getYAxisWidth, getZoomedSeriesData, isAxisRelatedSeries, } from '../../core/utils';
|
|
7
8
|
import { createScales, getAxes, getPreparedSeries, getShapes, getSplit, getVisibleSeries, useZoom, } from '../../hooks';
|
|
8
|
-
import { getActiveLegendItems, getAllLegendItems } from '../../hooks/useSeries/utils';
|
|
9
9
|
import { getNormalizedXAxis, getNormalizedYAxis, getPreparedChart, getPreparedTitle, recalculateYAxisLabelsWidth, } from './utils';
|
|
10
10
|
import { hasAtLeastOneSeriesDataPerPlot } from './utils/common';
|
|
11
11
|
const CLIP_PATH_BY_SERIES_TYPE = {
|
|
@@ -38,7 +38,7 @@ function getBoundsOffsetLeft(args) {
|
|
|
38
38
|
}
|
|
39
39
|
export function useChartInnerProps(props) {
|
|
40
40
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
41
|
-
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, rangeSliderState, width, updateZoomState, zoomState, } = props;
|
|
41
|
+
const { clipPathId, data, dispatcher, height, htmlLayout, plotNode, rangeSliderState, width, updateRangeSliderState, updateZoomState, zoomState, } = props;
|
|
42
42
|
const [selectedLegendItems, setSelectedLegendItems] = React.useState(null);
|
|
43
43
|
const [chartState, setState] = React.useState(null);
|
|
44
44
|
const prevStateValue = React.useRef(chartState);
|
|
@@ -48,20 +48,26 @@ export function useChartInnerProps(props) {
|
|
|
48
48
|
currentRunRef.current++;
|
|
49
49
|
const currentRun = currentRunRef.current;
|
|
50
50
|
(async function () {
|
|
51
|
-
var _a, _b, _c, _d;
|
|
51
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
52
52
|
const chartDataChanged = !(previousChartData.current && isEqual(previousChartData.current, data));
|
|
53
|
+
const axisTypeChanged = ((_b = (_a = previousChartData.current) === null || _a === void 0 ? void 0 : _a.xAxis) === null || _b === void 0 ? void 0 : _b.type) !== undefined &&
|
|
54
|
+
previousChartData.current.xAxis.type !== ((_c = data.xAxis) === null || _c === void 0 ? void 0 : _c.type);
|
|
55
|
+
if (axisTypeChanged && rangeSliderState !== undefined) {
|
|
56
|
+
updateRangeSliderState(undefined);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
53
59
|
const preparedTitle = await getPreparedTitle({
|
|
54
60
|
title: data.title,
|
|
55
61
|
chartWidth: width,
|
|
56
62
|
chartHeight: height,
|
|
57
|
-
chartMargin: (
|
|
63
|
+
chartMargin: (_d = data.chart) === null || _d === void 0 ? void 0 : _d.margin,
|
|
58
64
|
});
|
|
59
65
|
const preparedChart = getPreparedChart({
|
|
60
66
|
chart: data.chart,
|
|
61
67
|
seriesData: data.series.data,
|
|
62
68
|
preparedTitle,
|
|
63
69
|
});
|
|
64
|
-
const colors = (
|
|
70
|
+
const colors = (_e = data.colors) !== null && _e !== void 0 ? _e : DEFAULT_PALETTE;
|
|
65
71
|
const normalizedSeriesData = getSortedSeriesData({
|
|
66
72
|
seriesData: data.series.data,
|
|
67
73
|
xAxis: data.xAxis,
|
|
@@ -84,7 +90,7 @@ export function useChartInnerProps(props) {
|
|
|
84
90
|
});
|
|
85
91
|
}
|
|
86
92
|
else {
|
|
87
|
-
allPreparedSeries = (
|
|
93
|
+
allPreparedSeries = (_g = (_f = prevStateValue.current) === null || _f === void 0 ? void 0 : _f.allPreparedSeries) !== null && _g !== void 0 ? _g : [];
|
|
88
94
|
}
|
|
89
95
|
const activeLegendItems = selectedLegendItems !== null && selectedLegendItems !== void 0 ? selectedLegendItems : getActiveLegendItems(allPreparedSeries);
|
|
90
96
|
const visiblePreparedSeries = getVisibleSeries({
|
|
@@ -243,6 +249,7 @@ export function useChartInnerProps(props) {
|
|
|
243
249
|
rangeSliderState,
|
|
244
250
|
dispatcher,
|
|
245
251
|
htmlLayout,
|
|
252
|
+
updateRangeSliderState,
|
|
246
253
|
clipPathId,
|
|
247
254
|
]);
|
|
248
255
|
// additional start
|
|
@@ -24,11 +24,16 @@ const getLegendPosition = (args) => {
|
|
|
24
24
|
const { offsetLeft, offsetTop, contentWidth, width } = args;
|
|
25
25
|
return { top: offsetTop, left: offsetLeft + width / 2 - contentWidth / 2 };
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
async function appendPaginator(args) {
|
|
28
28
|
const { container, pageIndex, legend, transform, pages, onArrowClick } = args;
|
|
29
29
|
const paginationLine = container.append('g').attr('class', b('pagination'));
|
|
30
30
|
const maxPage = pages.length;
|
|
31
|
-
|
|
31
|
+
const paginationCounterText = `${pageIndex + 1}/${maxPage}`;
|
|
32
|
+
const getTextSize = getTextSizeFn({ style: legend.itemStyle });
|
|
33
|
+
const [arrowIcon, counter] = await Promise.all([
|
|
34
|
+
getTextSize('▲'),
|
|
35
|
+
getTextSize(paginationCounterText),
|
|
36
|
+
]);
|
|
32
37
|
paginationLine
|
|
33
38
|
.append('text')
|
|
34
39
|
.text('▲')
|
|
@@ -36,9 +41,6 @@ const appendPaginator = (args) => {
|
|
|
36
41
|
return b('pagination-arrow', { inactive: pageIndex === 0 });
|
|
37
42
|
})
|
|
38
43
|
.style('font-size', legend.itemStyle.fontSize)
|
|
39
|
-
.each(function () {
|
|
40
|
-
computedWidth += this.getComputedTextLength();
|
|
41
|
-
})
|
|
42
44
|
.on('click', function () {
|
|
43
45
|
if (pageIndex - 1 >= 0) {
|
|
44
46
|
onArrowClick(pageIndex - 1);
|
|
@@ -46,20 +48,17 @@ const appendPaginator = (args) => {
|
|
|
46
48
|
});
|
|
47
49
|
paginationLine
|
|
48
50
|
.append('text')
|
|
49
|
-
.text(
|
|
51
|
+
.text(paginationCounterText)
|
|
50
52
|
.attr('class', b('pagination-counter'))
|
|
51
|
-
.attr('x',
|
|
52
|
-
.style('font-size', legend.itemStyle.fontSize)
|
|
53
|
-
.each(function () {
|
|
54
|
-
computedWidth += this.getComputedTextLength();
|
|
55
|
-
});
|
|
53
|
+
.attr('x', arrowIcon.width)
|
|
54
|
+
.style('font-size', legend.itemStyle.fontSize);
|
|
56
55
|
paginationLine
|
|
57
56
|
.append('text')
|
|
58
57
|
.text('▼')
|
|
59
58
|
.attr('class', function () {
|
|
60
59
|
return b('pagination-arrow', { inactive: pageIndex === maxPage - 1 });
|
|
61
60
|
})
|
|
62
|
-
.attr('x',
|
|
61
|
+
.attr('x', arrowIcon.width + counter.width)
|
|
63
62
|
.style('font-size', legend.itemStyle.fontSize)
|
|
64
63
|
.on('click', function () {
|
|
65
64
|
if (pageIndex + 1 < maxPage) {
|
|
@@ -67,7 +66,7 @@ const appendPaginator = (args) => {
|
|
|
67
66
|
}
|
|
68
67
|
});
|
|
69
68
|
paginationLine.attr('transform', transform);
|
|
70
|
-
}
|
|
69
|
+
}
|
|
71
70
|
function renderLegendSymbol(args) {
|
|
72
71
|
const { selection, legend, legendLineHeight } = args;
|
|
73
72
|
const line = selection.data();
|
|
@@ -277,7 +276,7 @@ export const Legend = (props) => {
|
|
|
277
276
|
});
|
|
278
277
|
if (config.pagination) {
|
|
279
278
|
const transform = `translate(${[0, legend.height - legend.lineHeight / 2].join(',')})`;
|
|
280
|
-
appendPaginator({
|
|
279
|
+
await appendPaginator({
|
|
281
280
|
container: svgElement,
|
|
282
281
|
pageIndex: pageIndex,
|
|
283
282
|
legend,
|