@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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { extent } from 'd3-array';
|
|
2
2
|
import { scaleBand, scaleLinear, scaleLog, scaleUtc } from 'd3-scale';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
|
-
import { getDefaultMaxXAxisValue, getDefaultMinXAxisValue, getDomainDataXBySeries, getEffectiveXRange, } from '../utils';
|
|
5
|
-
import { getBandSize } from '../../hooks/utils/get-band-size';
|
|
6
4
|
import { DEFAULT_AXIS_TYPE, SERIES_TYPE } from '../constants';
|
|
5
|
+
import { getDefaultMaxXAxisValue, getDefaultMinXAxisValue, getDomainDataXBySeries, getEffectiveXRange, } from '../utils';
|
|
6
|
+
import { getBandSize } from '../utils/band-size';
|
|
7
7
|
import { checkIsPointDomain, filterCategoriesByVisibleSeries, getMinMaxPropsOrState, hasOnlyMarkerSeries, validateArrayData, } from './utils';
|
|
8
8
|
const X_AXIS_ZOOM_PADDING = 0.02;
|
|
9
9
|
function calculateXAxisPadding(series) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { extent, tickStep, ticks } from 'd3-array';
|
|
2
2
|
import { scaleBand, scaleLinear, scaleLog, scaleUtc } from 'd3-scale';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
|
-
import { CHART_SERIES_WITH_VOLUME_ON_Y_AXIS, getDefaultMinYAxisValue, getDomainDataYBySeries, shouldSyncAxisWithPrimary, } from '../utils';
|
|
5
4
|
import { getTickValues } from '../../components/AxisY/utils';
|
|
6
|
-
import { getBandSize } from '../../hooks/utils/get-band-size';
|
|
7
5
|
import { SERIES_TYPE } from '../constants';
|
|
6
|
+
import { CHART_SERIES_WITH_VOLUME_ON_Y_AXIS, getDefaultMinYAxisValue, getDomainDataYBySeries, shouldSyncAxisWithPrimary, } from '../utils';
|
|
7
|
+
import { getBandSize } from '../utils/band-size';
|
|
8
8
|
import { checkIsPointDomain, filterCategoriesByVisibleSeries, getMinMaxPropsOrState, hasOnlyMarkerSeries, validateArrayData, } from './utils';
|
|
9
9
|
// axis is validated in `validation/index.ts`, so the value of `axis.type` is definitely valid.
|
|
10
10
|
// eslint-disable-next-line consistent-return
|
|
@@ -70,6 +70,34 @@ function getDomainSyncedToPrimaryTicks(args) {
|
|
|
70
70
|
}
|
|
71
71
|
return [secondaryTicks[0], secondaryTicks[secondaryTicks.length - 1]];
|
|
72
72
|
}
|
|
73
|
+
function getLogarithmicYMin(args) {
|
|
74
|
+
var _a;
|
|
75
|
+
const { axis, domain, yMinDomain, hasSeriesWithVolumeOnYAxis } = args;
|
|
76
|
+
// scaleLog cannot represent values <= 0. Pick the smallest positive value
|
|
77
|
+
// present in the domain, falling back to 1 if there is none.
|
|
78
|
+
const smallestPositive = yMinDomain > 0
|
|
79
|
+
? yMinDomain
|
|
80
|
+
: ((_a = domain.reduce((min, v) => {
|
|
81
|
+
if (typeof v === 'number' && v > 0) {
|
|
82
|
+
return min === null ? v : Math.min(min, v);
|
|
83
|
+
}
|
|
84
|
+
return min;
|
|
85
|
+
}, null)) !== null && _a !== void 0 ? _a : 1);
|
|
86
|
+
if (!hasSeriesWithVolumeOnYAxis) {
|
|
87
|
+
return smallestPositive;
|
|
88
|
+
}
|
|
89
|
+
// Volume series (bar-x, area, waterfall) draw bars from yMin up to the
|
|
90
|
+
// value, so a bar whose value equals yMin collapses to zero height. Drop
|
|
91
|
+
// the baseline one decade below to give it visible space — but only when
|
|
92
|
+
// the later `nice()` pass (triggered by startOnTick) won't supply that
|
|
93
|
+
// headroom on its own. nice() rounds down to the previous decade, which
|
|
94
|
+
// covers any value strictly between two decades; it has nothing to round
|
|
95
|
+
// when the smallest value already sits on a decade (e.g. 1, 10, 100).
|
|
96
|
+
const startOnTick = get(axis, 'startOnTick', false);
|
|
97
|
+
const isOnDecade = Number.isInteger(Math.log10(smallestPositive));
|
|
98
|
+
const needsHeadroom = !startOnTick || isOnDecade;
|
|
99
|
+
return needsHeadroom ? smallestPositive / 10 : smallestPositive;
|
|
100
|
+
}
|
|
73
101
|
function getDomainMinAlignedToStartTick(args) {
|
|
74
102
|
var _a, _b;
|
|
75
103
|
const { axis, range, scale, series } = args;
|
|
@@ -80,6 +108,9 @@ function getDomainMinAlignedToStartTick(args) {
|
|
|
80
108
|
labelLineHeight: axis.labels.lineHeight,
|
|
81
109
|
series,
|
|
82
110
|
});
|
|
111
|
+
if (tickValues.length === 0) {
|
|
112
|
+
return dMin;
|
|
113
|
+
}
|
|
83
114
|
const isStartOnTick = tickValues[0].y === range[0];
|
|
84
115
|
let dNewMin = dMin;
|
|
85
116
|
if (!isStartOnTick) {
|
|
@@ -111,6 +142,9 @@ function getDomainMaxAlignedToEndTick(args) {
|
|
|
111
142
|
labelLineHeight: axis.labels.lineHeight,
|
|
112
143
|
series,
|
|
113
144
|
});
|
|
145
|
+
if (tickValues.length === 0) {
|
|
146
|
+
return dMax;
|
|
147
|
+
}
|
|
114
148
|
let dNewMax = dMax;
|
|
115
149
|
const isEndOnTick = tickValues[tickValues.length - 1].y === range[1];
|
|
116
150
|
if (!isEndOnTick) {
|
|
@@ -155,12 +189,18 @@ export function createYScale(args) {
|
|
|
155
189
|
}
|
|
156
190
|
if (hasNumberAndNullValues) {
|
|
157
191
|
const [yMinDomain, yMaxDomain] = extent(domain);
|
|
192
|
+
const hasSeriesWithVolumeOnYAxis = series.some((s) => CHART_SERIES_WITH_VOLUME_ON_Y_AXIS.includes(s.type));
|
|
158
193
|
let yMin;
|
|
159
194
|
if (typeof yMinPropsOrState === 'number') {
|
|
160
195
|
yMin = yMinPropsOrState;
|
|
161
196
|
}
|
|
162
197
|
else if (axis.type === 'logarithmic') {
|
|
163
|
-
yMin =
|
|
198
|
+
yMin = getLogarithmicYMin({
|
|
199
|
+
axis,
|
|
200
|
+
domain,
|
|
201
|
+
yMinDomain,
|
|
202
|
+
hasSeriesWithVolumeOnYAxis,
|
|
203
|
+
});
|
|
164
204
|
}
|
|
165
205
|
else {
|
|
166
206
|
const yMinDefault = getDefaultMinYAxisValue(series);
|
|
@@ -170,8 +210,12 @@ export function createYScale(args) {
|
|
|
170
210
|
if (typeof yMaxPropsOrState === 'number') {
|
|
171
211
|
yMax = yMaxPropsOrState;
|
|
172
212
|
}
|
|
213
|
+
else if (axis.type === 'logarithmic') {
|
|
214
|
+
// scaleLog cannot represent values <= 0; ensure yMax is strictly
|
|
215
|
+
// greater than yMin so the resulting domain stays valid.
|
|
216
|
+
yMax = yMaxDomain > yMin ? yMaxDomain : yMin * 10;
|
|
217
|
+
}
|
|
173
218
|
else {
|
|
174
|
-
const hasSeriesWithVolumeOnYAxis = series.some((s) => CHART_SERIES_WITH_VOLUME_ON_Y_AXIS.includes(s.type));
|
|
175
219
|
yMax = hasSeriesWithVolumeOnYAxis ? Math.max(yMaxDomain, 0) : yMaxDomain;
|
|
176
220
|
}
|
|
177
221
|
const scaleFn = axis.type === 'logarithmic' ? scaleLog : scaleLinear;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
|
-
import { getUniqId } from '../utils';
|
|
4
3
|
import { DEFAULT_DATALABELS_STYLE, seriesRangeSliderOptionsDefaults } from '../constants';
|
|
4
|
+
import { getUniqId } from '../utils';
|
|
5
5
|
import { DEFAULT_DATALABELS_PADDING, DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
6
6
|
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
7
7
|
export const DEFAULT_LINE_WIDTH = 1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getUniqId } from '../utils';
|
|
3
2
|
import { DEFAULT_DATALABELS_STYLE, seriesRangeSliderOptionsDefaults } from '../constants';
|
|
3
|
+
import { getUniqId } from '../utils';
|
|
4
4
|
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
5
5
|
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
6
6
|
function prepareSeriesData(series) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getLabelsSize, getUniqId } from '../utils';
|
|
3
2
|
import { DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
3
|
+
import { getLabelsSize, getUniqId } from '../utils';
|
|
4
4
|
import { getFormattedValue } from '../utils/format';
|
|
5
5
|
import { getSeriesStackId, prepareLegendSymbol } from './utils';
|
|
6
6
|
const DEFAULT_LABEL_PADDING = 7;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { scaleOrdinal } from 'd3-scale';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import { getUniqId } from '../utils';
|
|
4
3
|
import { DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
4
|
+
import { getUniqId } from '../utils';
|
|
5
5
|
import { prepareLegendSymbol } from './utils';
|
|
6
6
|
export function prepareFunnelSeries(args) {
|
|
7
7
|
var _a, _b;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getUniqId } from '../utils';
|
|
3
2
|
import { DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
3
|
+
import { getUniqId } from '../utils';
|
|
4
4
|
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
5
5
|
import { prepareLegendSymbol } from './utils';
|
|
6
6
|
function prepareSeriesData(series) {
|
|
@@ -2,8 +2,8 @@ import { groupBy } from 'lodash';
|
|
|
2
2
|
import clone from 'lodash/clone';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import merge from 'lodash/merge';
|
|
5
|
-
import { getDefaultColorStops, getDomainForContinuousColorScale, getLabelsSize, getTextSizeFn, getTextWithElipsis, } from '../utils';
|
|
6
5
|
import { CONTINUOUS_LEGEND_SIZE, legendDefaults } from '../constants';
|
|
6
|
+
import { getDefaultColorStops, getDomainForContinuousColorScale, getLabelsSize, getTextSizeFn, getTextWithElipsis, } from '../utils';
|
|
7
7
|
export async function getPreparedLegend(args) {
|
|
8
8
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
9
|
const { legend, series } = args;
|
|
@@ -120,8 +120,8 @@ async function getGroupedLegendItems(args) {
|
|
|
120
120
|
}
|
|
121
121
|
resultItem.height = textHeight;
|
|
122
122
|
if (textWidth > maxTextWidth) {
|
|
123
|
+
resultItem.overflowed = true;
|
|
123
124
|
if (preparedLegend.html) {
|
|
124
|
-
resultItem.overflowed = true;
|
|
125
125
|
resultItem.textWidth = maxTextWidth;
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
|
-
import { getUniqId } from '../utils';
|
|
4
3
|
import { DASH_STYLE, DEFAULT_DATALABELS_STYLE, LineCap, LineJoin, seriesRangeSliderOptionsDefaults, } from '../constants';
|
|
4
|
+
import { getUniqId } from '../utils';
|
|
5
5
|
import { DEFAULT_DATALABELS_PADDING, DEFAULT_HALO_OPTIONS, DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
6
6
|
export const DEFAULT_LEGEND_SYMBOL_SIZE = 16;
|
|
7
7
|
export const DEFAULT_LINE_WIDTH = 1;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { scaleOrdinal } from 'd3-scale';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
|
-
import { getUniqId } from '../utils';
|
|
4
3
|
import { DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
4
|
+
import { getUniqId } from '../utils';
|
|
5
5
|
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
6
6
|
import { prepareLegendSymbol } from './utils';
|
|
7
7
|
function prepareSeriesData(series) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { scaleOrdinal } from 'd3-scale';
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import merge from 'lodash/merge';
|
|
4
|
-
import { getUniqId } from '../utils';
|
|
5
4
|
import { DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
5
|
+
import { getUniqId } from '../utils';
|
|
6
6
|
import { DEFAULT_DATALABELS_PADDING, DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS, } from './constants';
|
|
7
7
|
import { prepareLegendSymbol } from './utils';
|
|
8
8
|
export const DEFAULT_MARKER = Object.assign(Object.assign({}, DEFAULT_POINT_MARKER_OPTIONS), { enabled: true, radius: 2 });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getUniqId } from '../utils';
|
|
3
2
|
import { DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
3
|
+
import { getUniqId } from '../utils';
|
|
4
4
|
import { prepareLegendSymbol } from './utils';
|
|
5
5
|
export function prepareSankeySeries(args) {
|
|
6
6
|
const { colorScale, legend, series } = args;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
2
|
import merge from 'lodash/merge';
|
|
3
|
-
import { getSymbolType, getUniqId } from '../utils';
|
|
4
3
|
import { seriesRangeSliderOptionsDefaults } from '../constants';
|
|
4
|
+
import { getSymbolType, getUniqId } from '../utils';
|
|
5
5
|
import { DEFAULT_HALO_OPTIONS, DEFAULT_POINT_MARKER_OPTIONS } from './constants';
|
|
6
6
|
import { prepareLegendSymbol } from './utils';
|
|
7
7
|
function prepareMarker(series, seriesOptions, index) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getUniqId } from '../utils';
|
|
3
2
|
import { DEFAULT_DATALABELS_STYLE, LayoutAlgorithm } from '../constants';
|
|
3
|
+
import { getUniqId } from '../utils';
|
|
4
4
|
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
5
5
|
import { prepareLegendSymbol } from './utils';
|
|
6
6
|
export function prepareTreemap(args) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getUniqId } from '../utils';
|
|
3
2
|
import { DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
3
|
+
import { getUniqId } from '../utils';
|
|
4
4
|
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
5
5
|
import { prepareLegendSymbol } from './utils';
|
|
6
6
|
function prepareSeriesData(series) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import get from 'lodash/get';
|
|
2
|
-
import { getUniqId } from '../utils';
|
|
3
2
|
import { DASH_STYLE, DEFAULT_DATALABELS_STYLE } from '../constants';
|
|
3
|
+
import { getUniqId } from '../utils';
|
|
4
4
|
import { DEFAULT_DATALABELS_PADDING } from './constants';
|
|
5
5
|
import { prepareLegendSymbol } from './utils';
|
|
6
6
|
export function prepareXRangeSeries(args) {
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { ScaleOrdinal } from 'd3-scale';
|
|
2
|
-
import type { ChartSeries, ChartSeriesOptions } from '../../types';
|
|
2
|
+
import type { ChartData, ChartSeries, ChartSeriesOptions } from '../../types';
|
|
3
3
|
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
|
+
export declare const getPreparedSeries: ({ seriesData, seriesOptions, colors, preparedLegend, }: {
|
|
5
|
+
seriesData: ChartData["series"]["data"];
|
|
6
|
+
seriesOptions: ChartData["series"]["options"];
|
|
7
|
+
colors: string[];
|
|
8
|
+
preparedLegend?: PreparedLegend | null;
|
|
9
|
+
}) => Promise<PreparedSeries[]>;
|
|
4
10
|
export declare function prepareSeries(args: {
|
|
5
11
|
type: ChartSeries['type'];
|
|
6
12
|
series: ChartSeries[];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { group } from 'd3-array';
|
|
2
|
+
import { scaleOrdinal } from 'd3-scale';
|
|
1
3
|
import { ChartError } from '../../libs';
|
|
4
|
+
import { getSeriesNames } from '../utils';
|
|
2
5
|
import { prepareArea } from './prepare-area';
|
|
3
6
|
import { prepareBarXSeries } from './prepare-bar-x';
|
|
4
7
|
import { prepareBarYSeries } from './prepare-bar-y';
|
|
@@ -12,6 +15,34 @@ import { prepareScatterSeries } from './prepare-scatter';
|
|
|
12
15
|
import { prepareTreemap } from './prepare-treemap';
|
|
13
16
|
import { prepareWaterfallSeries } from './prepare-waterfall';
|
|
14
17
|
import { prepareXRangeSeries } from './prepare-x-range';
|
|
18
|
+
export const getPreparedSeries = async ({ seriesData, seriesOptions, colors, preparedLegend, }) => {
|
|
19
|
+
const seriesNames = getSeriesNames(seriesData);
|
|
20
|
+
const colorScale = scaleOrdinal(seriesNames, colors);
|
|
21
|
+
const groupedSeries = group(seriesData, (item, index) => {
|
|
22
|
+
if (item.type === 'line') {
|
|
23
|
+
return `${item.type}_${index}`;
|
|
24
|
+
}
|
|
25
|
+
return item.type;
|
|
26
|
+
});
|
|
27
|
+
const acc = [];
|
|
28
|
+
if (!preparedLegend) {
|
|
29
|
+
return acc;
|
|
30
|
+
}
|
|
31
|
+
const list = Array.from(groupedSeries);
|
|
32
|
+
for (let i = 0; i < list.length; i++) {
|
|
33
|
+
const [_groupId, seriesList] = list[i];
|
|
34
|
+
const seriesType = seriesList[0].type;
|
|
35
|
+
acc.push(...(await prepareSeries({
|
|
36
|
+
type: seriesType,
|
|
37
|
+
series: seriesList,
|
|
38
|
+
seriesOptions,
|
|
39
|
+
legend: preparedLegend,
|
|
40
|
+
colorScale,
|
|
41
|
+
colors,
|
|
42
|
+
})));
|
|
43
|
+
}
|
|
44
|
+
return acc;
|
|
45
|
+
};
|
|
15
46
|
export async function prepareSeries(args) {
|
|
16
47
|
const { type, series, seriesOptions, legend, colors, colorScale } = args;
|
|
17
48
|
switch (type) {
|
|
@@ -16,6 +16,11 @@ export type PreparedAnnotation = {
|
|
|
16
16
|
padding: [number, number];
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
|
+
export type AnnotationAnchor = {
|
|
20
|
+
annotation: PreparedAnnotation;
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
};
|
|
19
24
|
export type RectLegendSymbol = {
|
|
20
25
|
shape: 'rect';
|
|
21
26
|
} & Required<RectLegendSymbolOptions>;
|
|
@@ -9,3 +9,7 @@ export declare function prepareLegendSymbol(series: {
|
|
|
9
9
|
};
|
|
10
10
|
}, symbolType?: `${SymbolType}`): PreparedLegendSymbol;
|
|
11
11
|
export declare function getSeriesStackId(series: StackedSeries): string;
|
|
12
|
+
export declare const getVisibleSeries: ({ preparedSeries, activeLegendItems, }: {
|
|
13
|
+
preparedSeries: PreparedSeries[];
|
|
14
|
+
activeLegendItems: string[];
|
|
15
|
+
}) => PreparedSeries[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import memoize from 'lodash/memoize';
|
|
2
|
-
import { getSymbolBBoxWidth } from '../utils';
|
|
3
2
|
import { SymbolType } from '../constants';
|
|
3
|
+
import { getSymbolBBoxWidth } from '../utils';
|
|
4
4
|
import { getUniqId } from '../utils/misc';
|
|
5
5
|
import { DEFAULT_LEGEND_SYMBOL_PADDING, DEFAULT_LEGEND_SYMBOL_SIZE } from './constants';
|
|
6
6
|
export const getActiveLegendItems = (series) => {
|
|
@@ -35,3 +35,11 @@ export function getSeriesStackId(series) {
|
|
|
35
35
|
}
|
|
36
36
|
return stackId;
|
|
37
37
|
}
|
|
38
|
+
export const getVisibleSeries = ({ preparedSeries, activeLegendItems, }) => {
|
|
39
|
+
return preparedSeries.map((singleSeries) => {
|
|
40
|
+
if (singleSeries.legend.enabled) {
|
|
41
|
+
return Object.assign(Object.assign({}, singleSeries), { visible: activeLegendItems.includes(singleSeries.legend.groupId) });
|
|
42
|
+
}
|
|
43
|
+
return singleSeries;
|
|
44
|
+
});
|
|
45
|
+
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { Selection } from 'd3-selection';
|
|
2
|
-
import type {
|
|
3
|
-
type AnnotationAnchor = {
|
|
4
|
-
annotation: PreparedAnnotation;
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
};
|
|
8
|
-
export { type AnnotationAnchor };
|
|
2
|
+
import type { AnnotationAnchor } from '../series/types';
|
|
9
3
|
export declare function renderAnnotations(args: {
|
|
10
4
|
anchors: AnnotationAnchor[];
|
|
11
5
|
container: Selection<SVGGElement, unknown, null, undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { block } from '../../utils';
|
|
3
|
+
import { DESCENDER_RATIO } from '../utils/text';
|
|
4
4
|
const b = block('annotation');
|
|
5
5
|
const ARROW_WIDTH = 18;
|
|
6
6
|
const ARROW_HEIGHT = 9;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { PreparedAreaSeries, PreparedSeriesOptions } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { PreparedSplit } from '../../layout/split-types';
|
|
3
|
+
import type { ChartScale } from '../../scales/types';
|
|
4
|
+
import type { PreparedAreaSeries, PreparedSeriesOptions } from '../../series/types';
|
|
5
5
|
import type { PreparedAreaData } from './types';
|
|
6
6
|
export declare const prepareAreaData: (args: {
|
|
7
7
|
series: PreparedAreaSeries[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { group, min, sort } from 'd3-array';
|
|
2
2
|
import isNil from 'lodash/isNil';
|
|
3
3
|
import round from 'lodash/round';
|
|
4
|
-
import { prepareAnnotation } from '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { prepareAnnotation } from '../../series/prepare-annotation';
|
|
5
|
+
import { getXValue, getYValue } from '../../shapes/utils';
|
|
6
|
+
import { getDataCategoryValue, getLabelsSize, getTextSizeFn } from '../../utils';
|
|
7
|
+
import { getFormattedValue } from '../../utils/format';
|
|
8
8
|
function getXValues(series, xAxis, xScale) {
|
|
9
9
|
const categories = xAxis.categories || [];
|
|
10
10
|
const xValues = series.reduce((acc, s) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Dispatch } from 'd3-dispatch';
|
|
2
|
+
import type { PreparedSeriesOptions } from '../../series/types';
|
|
3
|
+
import type { PreparedAreaData } from './types';
|
|
4
|
+
export declare function renderArea(elements: {
|
|
5
|
+
plot: SVGGElement;
|
|
6
|
+
markers: SVGGElement;
|
|
7
|
+
hoverMarkers: SVGGElement;
|
|
8
|
+
annotations: SVGGElement;
|
|
9
|
+
boundsWidth: number;
|
|
10
|
+
boundsHeight: number;
|
|
11
|
+
}, preparedData: PreparedAreaData[], seriesOptions: PreparedSeriesOptions, allowOverlapDataLabels: boolean, dispatcher?: Dispatch<object>): () => void;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { color } from 'd3-color';
|
|
2
|
+
import { select } from 'd3-selection';
|
|
3
|
+
import { area as areaGenerator, line as lineGenerator } from 'd3-shape';
|
|
4
|
+
import get from 'lodash/get';
|
|
5
|
+
import { block } from '../../../utils';
|
|
6
|
+
import { filterOverlappingLabels } from '../../utils';
|
|
7
|
+
import { renderAnnotations } from '../annotation';
|
|
8
|
+
import { getMarkerHaloVisibility, getMarkerVisibility, renderMarker, selectMarkerHalo, selectMarkerSymbol, setMarker, } from '../marker';
|
|
9
|
+
import { setActiveState } from '../utils';
|
|
10
|
+
const b = block('area');
|
|
11
|
+
export function renderArea(elements, preparedData, seriesOptions, allowOverlapDataLabels, dispatcher) {
|
|
12
|
+
const plotSvgElement = select(elements.plot);
|
|
13
|
+
const markersSvgElement = select(elements.markers);
|
|
14
|
+
const hoverMarkersSvgElement = select(elements.hoverMarkers);
|
|
15
|
+
const annotationsSvgElement = select(elements.annotations);
|
|
16
|
+
const hoverOptions = get(seriesOptions, 'area.states.hover');
|
|
17
|
+
const inactiveOptions = get(seriesOptions, 'area.states.inactive');
|
|
18
|
+
const line = lineGenerator()
|
|
19
|
+
.x((d) => d.x)
|
|
20
|
+
.defined((d) => d.y !== null)
|
|
21
|
+
.y((d) => d.y);
|
|
22
|
+
plotSvgElement.selectAll('*').remove();
|
|
23
|
+
markersSvgElement.selectAll('*').remove();
|
|
24
|
+
const shapeSelection = plotSvgElement
|
|
25
|
+
.selectAll('shape')
|
|
26
|
+
.data(preparedData)
|
|
27
|
+
.join('g')
|
|
28
|
+
.attr('class', b('series'))
|
|
29
|
+
.attr('cursor', (d) => d.series.cursor);
|
|
30
|
+
shapeSelection
|
|
31
|
+
.append('path')
|
|
32
|
+
.attr('class', b('line'))
|
|
33
|
+
.attr('d', (d) => line(d.points))
|
|
34
|
+
.attr('fill', 'none')
|
|
35
|
+
.attr('stroke', (d) => d.color)
|
|
36
|
+
.attr('stroke-width', (d) => d.width)
|
|
37
|
+
.attr('stroke-linejoin', 'round')
|
|
38
|
+
.attr('stroke-linecap', 'round');
|
|
39
|
+
const area = areaGenerator()
|
|
40
|
+
.defined((d) => d.y !== null)
|
|
41
|
+
.x((d) => d.x)
|
|
42
|
+
.y0((d) => d.y0)
|
|
43
|
+
.y1((d) => d.y);
|
|
44
|
+
shapeSelection
|
|
45
|
+
.append('path')
|
|
46
|
+
.attr('class', b('region'))
|
|
47
|
+
.attr('d', (d) => area(d.points))
|
|
48
|
+
.attr('fill', (d) => d.color)
|
|
49
|
+
.attr('opacity', (d) => d.opacity);
|
|
50
|
+
let dataLabels = preparedData.reduce((acc, d) => {
|
|
51
|
+
return acc.concat(d.svgLabels);
|
|
52
|
+
}, []);
|
|
53
|
+
if (!allowOverlapDataLabels) {
|
|
54
|
+
dataLabels = filterOverlappingLabels(dataLabels);
|
|
55
|
+
}
|
|
56
|
+
const labelsSelection = plotSvgElement
|
|
57
|
+
.selectAll('text')
|
|
58
|
+
.data(dataLabels)
|
|
59
|
+
.join('text')
|
|
60
|
+
.html((d) => d.text)
|
|
61
|
+
.attr('class', b('label'))
|
|
62
|
+
.attr('x', (d) => d.x)
|
|
63
|
+
.attr('y', (d) => d.y)
|
|
64
|
+
.attr('text-anchor', (d) => d.textAnchor)
|
|
65
|
+
.style('font-size', (d) => d.style.fontSize)
|
|
66
|
+
.style('font-weight', (d) => d.style.fontWeight || null)
|
|
67
|
+
.style('fill', (d) => d.style.fontColor || null);
|
|
68
|
+
const markers = preparedData.reduce((acc, d) => acc.concat(d.markers), []);
|
|
69
|
+
const markerSelection = markersSvgElement
|
|
70
|
+
.selectAll('marker')
|
|
71
|
+
.data(markers)
|
|
72
|
+
.join('g')
|
|
73
|
+
.call(renderMarker);
|
|
74
|
+
renderAnnotations({
|
|
75
|
+
anchors: preparedData.flatMap((d) => d.annotations),
|
|
76
|
+
container: annotationsSvgElement,
|
|
77
|
+
plotHeight: elements.boundsHeight,
|
|
78
|
+
plotWidth: elements.boundsWidth,
|
|
79
|
+
});
|
|
80
|
+
const hoverEnabled = hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.enabled;
|
|
81
|
+
const inactiveEnabled = inactiveOptions === null || inactiveOptions === void 0 ? void 0 : inactiveOptions.enabled;
|
|
82
|
+
function handleShapeHover(data) {
|
|
83
|
+
const selected = (data === null || data === void 0 ? void 0 : data.filter((d) => d.series.type === 'area')) || [];
|
|
84
|
+
const selectedDataItems = selected.map((d) => d.data);
|
|
85
|
+
const selectedSeriesIds = selected.map((d) => { var _a; return (_a = d.series) === null || _a === void 0 ? void 0 : _a.id; });
|
|
86
|
+
shapeSelection.datum((d, index, list) => {
|
|
87
|
+
var _a;
|
|
88
|
+
const elementSelection = select(list[index]);
|
|
89
|
+
const hovered = Boolean(hoverEnabled && selectedSeriesIds.includes(d.id));
|
|
90
|
+
if (d.hovered !== hovered) {
|
|
91
|
+
d.hovered = hovered;
|
|
92
|
+
let strokeColor = d.color || '';
|
|
93
|
+
if (d.hovered) {
|
|
94
|
+
strokeColor =
|
|
95
|
+
((_a = color(strokeColor)) === null || _a === void 0 ? void 0 : _a.brighter(hoverOptions === null || hoverOptions === void 0 ? void 0 : hoverOptions.brightness).toString()) ||
|
|
96
|
+
strokeColor;
|
|
97
|
+
}
|
|
98
|
+
elementSelection.selectAll(`.${b('line')}`).attr('stroke', strokeColor);
|
|
99
|
+
elementSelection.selectAll(`.${b('region')}`).attr('fill', strokeColor);
|
|
100
|
+
}
|
|
101
|
+
return setActiveState({
|
|
102
|
+
element: list[index],
|
|
103
|
+
state: inactiveOptions,
|
|
104
|
+
active: Boolean(!inactiveEnabled ||
|
|
105
|
+
!selectedSeriesIds.length ||
|
|
106
|
+
selectedSeriesIds.includes(d.id)),
|
|
107
|
+
datum: d,
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
labelsSelection.datum((d, index, list) => {
|
|
111
|
+
return setActiveState({
|
|
112
|
+
element: list[index],
|
|
113
|
+
state: inactiveOptions,
|
|
114
|
+
active: Boolean(!inactiveEnabled ||
|
|
115
|
+
!selectedSeriesIds.length ||
|
|
116
|
+
selectedSeriesIds.includes(d.series.id)),
|
|
117
|
+
datum: d,
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
markerSelection.datum((d, index, list) => {
|
|
121
|
+
const elementSelection = select(list[index]);
|
|
122
|
+
const hovered = Boolean(hoverEnabled && selectedDataItems.includes(d.point.data));
|
|
123
|
+
if (d.hovered !== hovered) {
|
|
124
|
+
d.hovered = hovered;
|
|
125
|
+
elementSelection.attr('visibility', getMarkerVisibility(d));
|
|
126
|
+
selectMarkerHalo(elementSelection).attr('visibility', getMarkerHaloVisibility);
|
|
127
|
+
selectMarkerSymbol(elementSelection).call(setMarker, hovered ? 'hover' : 'normal');
|
|
128
|
+
}
|
|
129
|
+
if (d.point.series.marker.states.normal.enabled) {
|
|
130
|
+
const isActive = Boolean(!inactiveEnabled ||
|
|
131
|
+
!selectedSeriesIds.length ||
|
|
132
|
+
selectedSeriesIds.includes(d.point.series.id));
|
|
133
|
+
setActiveState({
|
|
134
|
+
element: list[index],
|
|
135
|
+
state: inactiveOptions,
|
|
136
|
+
active: isActive,
|
|
137
|
+
datum: d,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return d;
|
|
141
|
+
});
|
|
142
|
+
hoverMarkersSvgElement.selectAll('*').remove();
|
|
143
|
+
if (hoverEnabled && selected.length > 0) {
|
|
144
|
+
const hoverOnlyMarkers = [];
|
|
145
|
+
for (const chunk of selected) {
|
|
146
|
+
const seriesData = preparedData.find((pd) => pd.id === chunk.series.id);
|
|
147
|
+
if (!seriesData) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
const { series } = seriesData;
|
|
151
|
+
if (series.marker.states.normal.enabled || !series.marker.states.hover.enabled) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const point = seriesData.points.find((p) => p.data === chunk.data);
|
|
155
|
+
if (!point || point.y === null) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
hoverOnlyMarkers.push({
|
|
159
|
+
point: point,
|
|
160
|
+
active: true,
|
|
161
|
+
hovered: true,
|
|
162
|
+
clipped: false,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
if (hoverOnlyMarkers.length > 0) {
|
|
166
|
+
hoverMarkersSvgElement
|
|
167
|
+
.selectAll('g')
|
|
168
|
+
.data(hoverOnlyMarkers)
|
|
169
|
+
.join('g')
|
|
170
|
+
.call(renderMarker)
|
|
171
|
+
.each((_d, i, nodes) => {
|
|
172
|
+
selectMarkerSymbol(select(nodes[i])).call(setMarker, 'hover');
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.area', handleShapeHover);
|
|
178
|
+
return () => {
|
|
179
|
+
dispatcher === null || dispatcher === void 0 ? void 0 : dispatcher.on('hover-shape.area', null);
|
|
180
|
+
};
|
|
181
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { PreparedAnnotation } from '../../../core/series/types';
|
|
2
1
|
import type { AreaSeriesData, HtmlItem, LabelData } from '../../../types';
|
|
3
|
-
import type { PreparedAreaSeries } from '../../
|
|
4
|
-
import type { AnnotationAnchor } from '../annotation';
|
|
2
|
+
import type { AnnotationAnchor, PreparedAnnotation, PreparedAreaSeries } from '../../series/types';
|
|
5
3
|
export type PointData = {
|
|
6
4
|
y0: number;
|
|
7
5
|
x: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type { PreparedBarXSeries, PreparedSeriesOptions } from '../../
|
|
1
|
+
import type { PreparedXAxis, PreparedYAxis } from '../../axes/types';
|
|
2
|
+
import type { PreparedSplit } from '../../layout/split-types';
|
|
3
|
+
import type { ChartScale } from '../../scales/types';
|
|
4
|
+
import type { PreparedBarXSeries, PreparedSeriesOptions } from '../../series/types';
|
|
5
5
|
import type { PreparedBarXData } from './types';
|
|
6
6
|
export declare const prepareBarXData: (args: {
|
|
7
7
|
series: PreparedBarXSeries[];
|