@gravity-ui/charts 1.51.0 → 1.51.3
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/AxisY/utils.js +16 -4
- package/dist/cjs/components/index.js +25 -17
- package/dist/cjs/core/series/plugin.d.ts +14 -0
- package/dist/cjs/core/series/plugin.js +1 -0
- package/dist/cjs/core/series/prepareSeries.d.ts +3 -10
- package/dist/cjs/core/series/prepareSeries.js +3 -126
- package/dist/cjs/core/series/seriesRegistry.d.ts +3 -0
- package/dist/cjs/core/series/seriesRegistry.js +12 -0
- package/dist/cjs/core/shapes/area/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/area/get-tooltip-data.js +19 -0
- package/dist/cjs/core/shapes/area/types.d.ts +3 -3
- package/dist/cjs/core/shapes/bar-x/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/bar-x/get-tooltip-data.js +20 -0
- package/dist/cjs/core/shapes/bar-x/types.d.ts +3 -3
- package/dist/cjs/core/shapes/bar-y/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/bar-y/get-tooltip-data.js +32 -0
- package/dist/cjs/core/shapes/bar-y/prepare-data.js +6 -6
- package/dist/cjs/core/shapes/bar-y/types.d.ts +3 -3
- package/dist/cjs/core/shapes/funnel/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/funnel/get-tooltip-data.js +21 -0
- package/dist/cjs/core/shapes/funnel/prepare-data.js +6 -4
- package/dist/cjs/core/shapes/funnel/types.d.ts +3 -3
- package/dist/cjs/core/shapes/heatmap/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/heatmap/get-tooltip-data.js +21 -0
- package/dist/cjs/core/shapes/heatmap/prepare-data.js +1 -1
- package/dist/cjs/core/shapes/heatmap/types.d.ts +3 -3
- package/dist/cjs/core/shapes/line/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/line/get-tooltip-data.js +18 -0
- package/dist/cjs/core/shapes/line/types.d.ts +3 -3
- package/dist/cjs/core/shapes/pie/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/pie/get-tooltip-data.js +27 -0
- package/dist/cjs/core/shapes/pie/types.d.ts +3 -3
- package/dist/cjs/core/shapes/radar/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/radar/get-tooltip-data.js +35 -0
- package/dist/cjs/core/shapes/radar/types.d.ts +3 -3
- package/dist/cjs/core/shapes/sankey/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/sankey/get-tooltip-data.js +32 -0
- package/dist/cjs/core/shapes/sankey/prepare-data.js +2 -2
- package/dist/cjs/core/shapes/sankey/types.d.ts +3 -3
- package/dist/cjs/core/shapes/scatter/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/scatter/get-tooltip-data.js +19 -0
- package/dist/cjs/core/shapes/scatter/types.d.ts +2 -2
- package/dist/cjs/core/shapes/treemap/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/treemap/get-tooltip-data.js +18 -0
- package/dist/cjs/core/shapes/treemap/prepare-data.js +3 -3
- package/dist/cjs/core/shapes/treemap/types.d.ts +3 -3
- package/dist/cjs/core/shapes/types.d.ts +4 -0
- package/dist/cjs/core/shapes/types.js +1 -0
- package/dist/cjs/core/shapes/waterfall/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/waterfall/get-tooltip-data.js +15 -0
- package/dist/cjs/core/shapes/waterfall/prepare-data.js +1 -1
- package/dist/cjs/core/shapes/waterfall/types.d.ts +3 -3
- package/dist/cjs/core/shapes/x-range/get-tooltip-data.d.ts +3 -0
- package/dist/cjs/core/shapes/x-range/get-tooltip-data.js +22 -0
- package/dist/cjs/core/shapes/x-range/types.d.ts +3 -3
- package/dist/cjs/core/types/chart/funnel.d.ts +9 -4
- package/dist/cjs/core/utils/axis/x-axis.js +16 -4
- package/dist/cjs/core/utils/get-closest-data.d.ts +2 -11
- package/dist/cjs/core/utils/get-closest-data.js +47 -326
- package/dist/cjs/core/utils/tooltip-helpers.d.ts +43 -0
- package/dist/cjs/core/utils/tooltip-helpers.js +72 -0
- package/dist/cjs/hooks/useShapes/bar-y/index.js +1 -1
- package/dist/cjs/hooks/useShapes/heatmap/index.js +1 -1
- package/dist/cjs/hooks/useShapes/sankey/index.js +1 -1
- package/dist/cjs/hooks/useShapes/treemap/index.js +1 -1
- package/dist/cjs/hooks/useShapes/waterfall/index.js +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/plugins/area/index.d.ts +3 -0
- package/dist/cjs/plugins/area/index.js +5 -0
- package/dist/cjs/{core/series/prepare-area.d.ts → plugins/area/prepare.d.ts} +2 -2
- package/dist/cjs/{core/series/prepare-area.js → plugins/area/prepare.js} +4 -4
- package/dist/cjs/plugins/bar-x/index.d.ts +3 -0
- package/dist/cjs/plugins/bar-x/index.js +5 -0
- package/dist/{esm/core/series/prepare-bar-x.d.ts → cjs/plugins/bar-x/prepare.d.ts} +1 -1
- package/dist/{esm/core/series/prepare-bar-x.js → cjs/plugins/bar-x/prepare.js} +4 -4
- package/dist/cjs/plugins/bar-y/index.d.ts +3 -0
- package/dist/cjs/plugins/bar-y/index.js +5 -0
- package/dist/cjs/{core/series/prepare-bar-y.d.ts → plugins/bar-y/prepare.d.ts} +2 -2
- package/dist/cjs/{core/series/prepare-bar-y.js → plugins/bar-y/prepare.js} +4 -4
- package/dist/cjs/plugins/funnel/index.d.ts +3 -0
- package/dist/cjs/plugins/funnel/index.js +5 -0
- package/dist/cjs/{core/series/prepare-funnel.d.ts → plugins/funnel/prepare.d.ts} +2 -2
- package/dist/{esm/core/series/prepare-funnel.js → cjs/plugins/funnel/prepare.js} +15 -9
- package/dist/cjs/plugins/heatmap/index.d.ts +3 -0
- package/dist/cjs/plugins/heatmap/index.js +10 -0
- package/dist/{esm/core/series/prepare-heatmap.d.ts → cjs/plugins/heatmap/prepare.d.ts} +1 -1
- package/dist/{esm/core/series/prepare-heatmap.js → cjs/plugins/heatmap/prepare.js} +4 -4
- package/dist/cjs/plugins/index.d.ts +1 -0
- package/dist/cjs/plugins/index.js +27 -0
- package/dist/cjs/plugins/line/index.d.ts +3 -0
- package/dist/cjs/plugins/line/index.js +5 -0
- package/dist/cjs/{core/series/prepare-line.d.ts → plugins/line/prepare.d.ts} +2 -2
- package/dist/cjs/{core/series/prepare-line.js → plugins/line/prepare.js} +3 -3
- package/dist/cjs/plugins/pie/index.d.ts +3 -0
- package/dist/cjs/plugins/pie/index.js +5 -0
- package/dist/cjs/{core/series/prepare-pie.d.ts → plugins/pie/prepare.d.ts} +2 -2
- package/dist/cjs/plugins/pie/prepare.js +84 -0
- package/dist/cjs/plugins/radar/index.d.ts +3 -0
- package/dist/cjs/plugins/radar/index.js +5 -0
- package/dist/cjs/{core/series/prepare-radar.d.ts → plugins/radar/prepare.d.ts} +2 -2
- package/dist/cjs/{core/series/prepare-radar.js → plugins/radar/prepare.js} +4 -4
- package/dist/cjs/plugins/sankey/index.d.ts +3 -0
- package/dist/cjs/plugins/sankey/index.js +5 -0
- package/dist/cjs/{core/series/prepare-sankey.d.ts → plugins/sankey/prepare.d.ts} +1 -1
- package/dist/cjs/{core/series/prepare-sankey.js → plugins/sankey/prepare.js} +3 -3
- package/dist/cjs/plugins/scatter/index.d.ts +3 -0
- package/dist/cjs/plugins/scatter/index.js +10 -0
- package/dist/cjs/{core/series/prepare-scatter.d.ts → plugins/scatter/prepare.d.ts} +1 -1
- package/dist/{esm/core/series/prepare-scatter.js → cjs/plugins/scatter/prepare.js} +4 -4
- package/dist/cjs/plugins/treemap/index.d.ts +3 -0
- package/dist/cjs/plugins/treemap/index.js +5 -0
- package/dist/{esm/core/series/prepare-treemap.d.ts → cjs/plugins/treemap/prepare.d.ts} +1 -1
- package/dist/cjs/{core/series/prepare-treemap.js → plugins/treemap/prepare.js} +4 -4
- package/dist/cjs/plugins/waterfall/index.d.ts +3 -0
- package/dist/cjs/plugins/waterfall/index.js +5 -0
- package/dist/cjs/{core/series/prepare-waterfall.d.ts → plugins/waterfall/prepare.d.ts} +1 -1
- package/dist/{esm/core/series/prepare-waterfall.js → cjs/plugins/waterfall/prepare.js} +4 -4
- package/dist/cjs/plugins/x-range/index.d.ts +3 -0
- package/dist/cjs/plugins/x-range/index.js +5 -0
- package/dist/cjs/{core/series/prepare-x-range.d.ts → plugins/x-range/prepare.d.ts} +1 -1
- package/dist/cjs/{core/series/prepare-x-range.js → plugins/x-range/prepare.js} +4 -4
- package/dist/cjs/setup-jsdom.d.ts +1 -0
- package/dist/cjs/setup-jsdom.js +30 -4
- package/dist/esm/components/AxisY/utils.js +16 -4
- package/dist/esm/components/index.js +25 -17
- package/dist/esm/core/series/plugin.d.ts +14 -0
- package/dist/esm/core/series/plugin.js +1 -0
- package/dist/esm/core/series/prepareSeries.d.ts +3 -10
- package/dist/esm/core/series/prepareSeries.js +3 -126
- package/dist/esm/core/series/seriesRegistry.d.ts +3 -0
- package/dist/esm/core/series/seriesRegistry.js +12 -0
- package/dist/esm/core/shapes/area/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/area/get-tooltip-data.js +19 -0
- package/dist/esm/core/shapes/area/types.d.ts +3 -3
- package/dist/esm/core/shapes/bar-x/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/bar-x/get-tooltip-data.js +20 -0
- package/dist/esm/core/shapes/bar-x/types.d.ts +3 -3
- package/dist/esm/core/shapes/bar-y/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/bar-y/get-tooltip-data.js +32 -0
- package/dist/esm/core/shapes/bar-y/prepare-data.js +6 -6
- package/dist/esm/core/shapes/bar-y/types.d.ts +3 -3
- package/dist/esm/core/shapes/funnel/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/funnel/get-tooltip-data.js +21 -0
- package/dist/esm/core/shapes/funnel/prepare-data.js +6 -4
- package/dist/esm/core/shapes/funnel/types.d.ts +3 -3
- package/dist/esm/core/shapes/heatmap/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/heatmap/get-tooltip-data.js +21 -0
- package/dist/esm/core/shapes/heatmap/prepare-data.js +1 -1
- package/dist/esm/core/shapes/heatmap/types.d.ts +3 -3
- package/dist/esm/core/shapes/line/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/line/get-tooltip-data.js +18 -0
- package/dist/esm/core/shapes/line/types.d.ts +3 -3
- package/dist/esm/core/shapes/pie/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/pie/get-tooltip-data.js +27 -0
- package/dist/esm/core/shapes/pie/types.d.ts +3 -3
- package/dist/esm/core/shapes/radar/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/radar/get-tooltip-data.js +35 -0
- package/dist/esm/core/shapes/radar/types.d.ts +3 -3
- package/dist/esm/core/shapes/sankey/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/sankey/get-tooltip-data.js +32 -0
- package/dist/esm/core/shapes/sankey/prepare-data.js +2 -2
- package/dist/esm/core/shapes/sankey/types.d.ts +3 -3
- package/dist/esm/core/shapes/scatter/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/scatter/get-tooltip-data.js +19 -0
- package/dist/esm/core/shapes/scatter/types.d.ts +2 -2
- package/dist/esm/core/shapes/treemap/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/treemap/get-tooltip-data.js +18 -0
- package/dist/esm/core/shapes/treemap/prepare-data.js +3 -3
- package/dist/esm/core/shapes/treemap/types.d.ts +3 -3
- package/dist/esm/core/shapes/types.d.ts +4 -0
- package/dist/esm/core/shapes/types.js +1 -0
- package/dist/esm/core/shapes/waterfall/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/waterfall/get-tooltip-data.js +15 -0
- package/dist/esm/core/shapes/waterfall/prepare-data.js +1 -1
- package/dist/esm/core/shapes/waterfall/types.d.ts +3 -3
- package/dist/esm/core/shapes/x-range/get-tooltip-data.d.ts +3 -0
- package/dist/esm/core/shapes/x-range/get-tooltip-data.js +22 -0
- package/dist/esm/core/shapes/x-range/types.d.ts +3 -3
- package/dist/esm/core/types/chart/funnel.d.ts +9 -4
- package/dist/esm/core/utils/axis/x-axis.js +16 -4
- package/dist/esm/core/utils/get-closest-data.d.ts +2 -11
- package/dist/esm/core/utils/get-closest-data.js +47 -326
- package/dist/esm/core/utils/tooltip-helpers.d.ts +43 -0
- package/dist/esm/core/utils/tooltip-helpers.js +72 -0
- package/dist/esm/hooks/useShapes/bar-y/index.js +1 -1
- package/dist/esm/hooks/useShapes/heatmap/index.js +1 -1
- package/dist/esm/hooks/useShapes/sankey/index.js +1 -1
- package/dist/esm/hooks/useShapes/treemap/index.js +1 -1
- package/dist/esm/hooks/useShapes/waterfall/index.js +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/plugins/area/index.d.ts +3 -0
- package/dist/esm/plugins/area/index.js +5 -0
- package/dist/esm/{core/series/prepare-area.d.ts → plugins/area/prepare.d.ts} +2 -2
- package/dist/esm/{core/series/prepare-area.js → plugins/area/prepare.js} +4 -4
- package/dist/esm/plugins/bar-x/index.d.ts +3 -0
- package/dist/esm/plugins/bar-x/index.js +5 -0
- package/dist/{cjs/core/series/prepare-bar-x.d.ts → esm/plugins/bar-x/prepare.d.ts} +1 -1
- package/dist/{cjs/core/series/prepare-bar-x.js → esm/plugins/bar-x/prepare.js} +4 -4
- package/dist/esm/plugins/bar-y/index.d.ts +3 -0
- package/dist/esm/plugins/bar-y/index.js +5 -0
- package/dist/esm/{core/series/prepare-bar-y.d.ts → plugins/bar-y/prepare.d.ts} +5 -5
- package/dist/esm/{core/series/prepare-bar-y.js → plugins/bar-y/prepare.js} +4 -4
- package/dist/esm/plugins/funnel/index.d.ts +3 -0
- package/dist/esm/plugins/funnel/index.js +5 -0
- package/dist/esm/{core/series/prepare-funnel.d.ts → plugins/funnel/prepare.d.ts} +2 -2
- package/dist/{cjs/core/series/prepare-funnel.js → esm/plugins/funnel/prepare.js} +15 -9
- package/dist/esm/plugins/heatmap/index.d.ts +3 -0
- package/dist/esm/plugins/heatmap/index.js +10 -0
- package/dist/{cjs/core/series/prepare-heatmap.d.ts → esm/plugins/heatmap/prepare.d.ts} +1 -1
- package/dist/{cjs/core/series/prepare-heatmap.js → esm/plugins/heatmap/prepare.js} +4 -4
- package/dist/esm/plugins/index.d.ts +1 -0
- package/dist/esm/plugins/index.js +27 -0
- package/dist/esm/plugins/line/index.d.ts +3 -0
- package/dist/esm/plugins/line/index.js +5 -0
- package/dist/esm/{core/series/prepare-line.d.ts → plugins/line/prepare.d.ts} +2 -2
- package/dist/esm/{core/series/prepare-line.js → plugins/line/prepare.js} +3 -3
- package/dist/esm/plugins/pie/index.d.ts +3 -0
- package/dist/esm/plugins/pie/index.js +5 -0
- package/dist/esm/{core/series/prepare-pie.d.ts → plugins/pie/prepare.d.ts} +2 -2
- package/dist/esm/plugins/pie/prepare.js +84 -0
- package/dist/esm/plugins/radar/index.d.ts +3 -0
- package/dist/esm/plugins/radar/index.js +5 -0
- package/dist/esm/{core/series/prepare-radar.d.ts → plugins/radar/prepare.d.ts} +2 -2
- package/dist/esm/{core/series/prepare-radar.js → plugins/radar/prepare.js} +4 -4
- package/dist/esm/plugins/sankey/index.d.ts +3 -0
- package/dist/esm/plugins/sankey/index.js +5 -0
- package/dist/esm/{core/series/prepare-sankey.d.ts → plugins/sankey/prepare.d.ts} +1 -1
- package/dist/esm/{core/series/prepare-sankey.js → plugins/sankey/prepare.js} +3 -3
- package/dist/esm/plugins/scatter/index.d.ts +3 -0
- package/dist/esm/plugins/scatter/index.js +10 -0
- package/dist/esm/{core/series/prepare-scatter.d.ts → plugins/scatter/prepare.d.ts} +1 -1
- package/dist/{cjs/core/series/prepare-scatter.js → esm/plugins/scatter/prepare.js} +4 -4
- package/dist/esm/plugins/treemap/index.d.ts +3 -0
- package/dist/esm/plugins/treemap/index.js +5 -0
- package/dist/{cjs/core/series/prepare-treemap.d.ts → esm/plugins/treemap/prepare.d.ts} +1 -1
- package/dist/esm/{core/series/prepare-treemap.js → plugins/treemap/prepare.js} +4 -4
- package/dist/esm/plugins/waterfall/index.d.ts +3 -0
- package/dist/esm/plugins/waterfall/index.js +5 -0
- package/dist/esm/{core/series/prepare-waterfall.d.ts → plugins/waterfall/prepare.d.ts} +1 -1
- package/dist/{cjs/core/series/prepare-waterfall.js → esm/plugins/waterfall/prepare.js} +4 -4
- package/dist/esm/plugins/x-range/index.d.ts +3 -0
- package/dist/esm/plugins/x-range/index.js +5 -0
- package/dist/esm/{core/series/prepare-x-range.d.ts → plugins/x-range/prepare.d.ts} +1 -1
- package/dist/esm/{core/series/prepare-x-range.js → plugins/x-range/prepare.js} +4 -4
- package/dist/esm/setup-jsdom.d.ts +1 -0
- package/dist/esm/setup-jsdom.js +30 -4
- package/package.json +3 -2
- package/dist/cjs/core/series/prepare-pie.js +0 -83
- package/dist/esm/core/series/prepare-pie.js +0 -83
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LabelData, LineSeriesData, LineSeriesLineBaseStyle } from '../../../types';
|
|
2
2
|
import type { DashStyle, LineCap, LineJoin } from '../../constants';
|
|
3
3
|
import type { AnnotationAnchor, PreparedAnnotation, PreparedLineSeries } from '../../series/types';
|
|
4
|
+
import type { SeriesShapeData } from '../types';
|
|
4
5
|
export type PointData = {
|
|
5
6
|
annotation?: PreparedAnnotation;
|
|
6
7
|
color?: string;
|
|
@@ -29,9 +30,8 @@ export type PreparedLineData = {
|
|
|
29
30
|
hovered: boolean;
|
|
30
31
|
active: boolean;
|
|
31
32
|
svgLabels: LabelData[];
|
|
32
|
-
htmlLabels: HtmlItem[];
|
|
33
33
|
color: string;
|
|
34
34
|
dashStyle: DashStyle;
|
|
35
35
|
linecap: LineCap;
|
|
36
36
|
linejoin: LineJoin;
|
|
37
|
-
} & Required<LineSeriesLineBaseStyle
|
|
37
|
+
} & Required<LineSeriesLineBaseStyle> & SeriesShapeData;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getRadius } from '../../utils/tooltip-helpers';
|
|
2
|
+
export function getTooltipData(args) {
|
|
3
|
+
const { data, position } = args;
|
|
4
|
+
const [pointerX, pointerY] = position;
|
|
5
|
+
const points = data.flatMap((d) => d.segments);
|
|
6
|
+
const closestPoint = points.find((p) => {
|
|
7
|
+
const { center } = p.data.pie;
|
|
8
|
+
const x = pointerX - center[0];
|
|
9
|
+
const y = pointerY - center[1];
|
|
10
|
+
let angle = Math.atan2(y, x) + 0.5 * Math.PI;
|
|
11
|
+
angle = angle < 0 ? Math.PI * 2 + angle : angle;
|
|
12
|
+
const polarRadius = getRadius({ center, pointer: [pointerX, pointerY] });
|
|
13
|
+
return angle >= p.startAngle && angle <= p.endAngle && polarRadius < p.data.radius;
|
|
14
|
+
});
|
|
15
|
+
if (!closestPoint) {
|
|
16
|
+
return { chunks: [] };
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
chunks: [
|
|
20
|
+
{
|
|
21
|
+
data: closestPoint.data.series.data,
|
|
22
|
+
series: closestPoint.data.series,
|
|
23
|
+
closest: true,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PieArcDatum } from 'd3-shape';
|
|
2
|
-
import type { ConnectorCurve,
|
|
2
|
+
import type { ConnectorCurve, LabelData } from '../../../types';
|
|
3
3
|
import type { PreparedPieSeries } from '../../series/types';
|
|
4
|
+
import type { SeriesShapeData } from '../types';
|
|
4
5
|
export type SegmentData = {
|
|
5
6
|
value: number;
|
|
6
7
|
color: string;
|
|
@@ -37,5 +38,4 @@ export type PreparedPieData = {
|
|
|
37
38
|
opacity: number;
|
|
38
39
|
size: number;
|
|
39
40
|
};
|
|
40
|
-
|
|
41
|
-
};
|
|
41
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Delaunay } from 'd3-delaunay';
|
|
2
|
+
import { getRadius, isInsidePath } from '../../utils/tooltip-helpers';
|
|
3
|
+
export function getTooltipData(args) {
|
|
4
|
+
const { data, position, boundsWidth, boundsHeight } = args;
|
|
5
|
+
const [pointerX, pointerY] = position;
|
|
6
|
+
const [radarData] = data;
|
|
7
|
+
if (!radarData) {
|
|
8
|
+
return { chunks: [] };
|
|
9
|
+
}
|
|
10
|
+
const radius = getRadius({ center: radarData.center, pointer: [pointerX, pointerY] });
|
|
11
|
+
if (radius > radarData.radius) {
|
|
12
|
+
return { chunks: [] };
|
|
13
|
+
}
|
|
14
|
+
const radarShapes = radarData.shapes.filter((shape) => isInsidePath({
|
|
15
|
+
path: shape.path,
|
|
16
|
+
point: [pointerX, pointerY],
|
|
17
|
+
width: boundsWidth,
|
|
18
|
+
height: boundsHeight,
|
|
19
|
+
strokeWidth: shape.borderWidth,
|
|
20
|
+
}));
|
|
21
|
+
const points = radarShapes.flatMap((shape) => shape.points);
|
|
22
|
+
const delaunay = Delaunay.from(points, (d) => d.position[0], (d) => d.position[1]);
|
|
23
|
+
const closestPoint = points[delaunay.find(pointerX, pointerY)];
|
|
24
|
+
if (!closestPoint) {
|
|
25
|
+
return { chunks: [] };
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
chunks: radarData.shapes.map((shape) => ({
|
|
29
|
+
data: shape.points[closestPoint.index].data,
|
|
30
|
+
series: shape.series,
|
|
31
|
+
category: shape.series.categories[closestPoint.index],
|
|
32
|
+
closest: shape.series === closestPoint.series,
|
|
33
|
+
})),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LabelData, RadarSeriesData } from '../../../types';
|
|
2
2
|
import type { PreparedRadarSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type RadarLabelData = LabelData & {
|
|
4
5
|
maxWidth: number;
|
|
5
6
|
};
|
|
@@ -54,6 +55,5 @@ export type PreparedRadarData = {
|
|
|
54
55
|
grid: RadarGridData[];
|
|
55
56
|
center: [number, number];
|
|
56
57
|
radius: number;
|
|
57
|
-
htmlLabels: HtmlItem[];
|
|
58
58
|
cursor: string | null;
|
|
59
|
-
};
|
|
59
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isInsidePath } from '../../utils/tooltip-helpers';
|
|
2
|
+
export function getTooltipData(args) {
|
|
3
|
+
const { data, position, boundsWidth, boundsHeight } = args;
|
|
4
|
+
const [pointerX, pointerY] = position;
|
|
5
|
+
const [sankeyData] = data;
|
|
6
|
+
if (!sankeyData) {
|
|
7
|
+
return { chunks: [] };
|
|
8
|
+
}
|
|
9
|
+
const closestLink = sankeyData.links.find((d) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return isInsidePath({
|
|
12
|
+
path: (_a = d.path) !== null && _a !== void 0 ? _a : '',
|
|
13
|
+
strokeWidth: d.strokeWidth,
|
|
14
|
+
point: [pointerX, pointerY],
|
|
15
|
+
width: boundsWidth,
|
|
16
|
+
height: boundsHeight,
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
if (!closestLink) {
|
|
20
|
+
return { chunks: [] };
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
chunks: [
|
|
24
|
+
{
|
|
25
|
+
data: closestLink.source,
|
|
26
|
+
target: closestLink.target,
|
|
27
|
+
series: sankeyData.series,
|
|
28
|
+
closest: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -2,7 +2,7 @@ import { getFormattedValue } from '../../utils/format';
|
|
|
2
2
|
import { sankey, sankeyLinkHorizontal } from './sankey-layout';
|
|
3
3
|
export function prepareSankeyData(args) {
|
|
4
4
|
const { series, width, height } = args;
|
|
5
|
-
const
|
|
5
|
+
const htmlLabels = [];
|
|
6
6
|
const sankeyGenerator = sankey()
|
|
7
7
|
.nodeId((d) => d.name)
|
|
8
8
|
.nodeSort((a, b) => { var _a, _b; return ((_a = a.index) !== null && _a !== void 0 ? _a : 0) - ((_b = b.index) !== null && _b !== void 0 ? _b : 0); })
|
|
@@ -70,5 +70,5 @@ export function prepareSankeyData(args) {
|
|
|
70
70
|
});
|
|
71
71
|
dataLabels.push(...labels);
|
|
72
72
|
}
|
|
73
|
-
return { series, nodes: sankeyNodes, links: sankeyLinks,
|
|
73
|
+
return { series, nodes: sankeyNodes, links: sankeyLinks, htmlLabels, labels: dataLabels };
|
|
74
74
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { BaseTextStyle,
|
|
1
|
+
import type { BaseTextStyle, SankeySeriesData } from '../../../types';
|
|
2
2
|
import type { PreparedSankeySeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type SankeyDataLabel = {
|
|
4
5
|
text: string;
|
|
5
6
|
x: number;
|
|
@@ -26,8 +27,7 @@ export type SankeyLink = {
|
|
|
26
27
|
};
|
|
27
28
|
export type PreparedSankeyData = {
|
|
28
29
|
series: PreparedSankeySeries;
|
|
29
|
-
htmlElements: HtmlItem[];
|
|
30
30
|
nodes: SankeyNode[];
|
|
31
31
|
links: SankeyLink[];
|
|
32
32
|
labels: SankeyDataLabel[];
|
|
33
|
-
};
|
|
33
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Delaunay } from 'd3-delaunay';
|
|
2
|
+
export function getTooltipData(args) {
|
|
3
|
+
const { data, position } = args;
|
|
4
|
+
const [pointerX, pointerY] = position;
|
|
5
|
+
const delaunay = Delaunay.from(data, (d) => d.point.x, (d) => d.point.y);
|
|
6
|
+
const closestPoint = data[delaunay.find(pointerX, pointerY)];
|
|
7
|
+
if (!closestPoint) {
|
|
8
|
+
return { chunks: [] };
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
chunks: [
|
|
12
|
+
{
|
|
13
|
+
data: closestPoint.point.data,
|
|
14
|
+
series: closestPoint.point.series,
|
|
15
|
+
closest: true,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { HtmlItem, LabelData, ScatterSeriesData } from '../../../types';
|
|
2
2
|
import type { PreparedScatterSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
type PointData = {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
@@ -19,6 +20,5 @@ export type PreparedScatterData = MarkerData;
|
|
|
19
20
|
export type PreparedScatterShapeData = {
|
|
20
21
|
markers: PreparedScatterData[];
|
|
21
22
|
svgLabels: LabelData[];
|
|
22
|
-
|
|
23
|
-
};
|
|
23
|
+
} & SeriesShapeData;
|
|
24
24
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function getTooltipData(args) {
|
|
2
|
+
var _a;
|
|
3
|
+
const { data, position } = args;
|
|
4
|
+
const [pointerX, pointerY] = position;
|
|
5
|
+
const closestPoint = (_a = data[0]) === null || _a === void 0 ? void 0 : _a.leaves.find((l) => pointerX >= l.x0 && pointerX <= l.x1 && pointerY >= l.y0 && pointerY <= l.y1);
|
|
6
|
+
if (!closestPoint) {
|
|
7
|
+
return { chunks: [] };
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
chunks: [
|
|
11
|
+
{
|
|
12
|
+
data: closestPoint.data,
|
|
13
|
+
series: data[0].series,
|
|
14
|
+
closest: true,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -148,17 +148,17 @@ export async function prepareTreemapData(args) {
|
|
|
148
148
|
})(hierarchy);
|
|
149
149
|
const leaves = root.leaves();
|
|
150
150
|
let labelData = [];
|
|
151
|
-
const
|
|
151
|
+
const htmlLabels = [];
|
|
152
152
|
if ((_a = series.dataLabels) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
153
153
|
const { html, style: dataLabelsStyle } = series.dataLabels;
|
|
154
154
|
const labels = await getLabels({ data: leaves, options: series.dataLabels });
|
|
155
155
|
if (html) {
|
|
156
156
|
const htmlItems = labels.map((l) => (Object.assign({ style: Object.assign(Object.assign({}, dataLabelsStyle), { maxWidth: l.size.width, maxHeight: l.size.height, overflow: 'hidden' }) }, l)));
|
|
157
|
-
|
|
157
|
+
htmlLabels.push(...htmlItems);
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
160
160
|
labelData = labels;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
-
return { labelData, leaves, series,
|
|
163
|
+
return { labelData, leaves, series, htmlLabels };
|
|
164
164
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HierarchyRectangularNode } from 'd3-hierarchy';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TreemapSeriesData } from '../../../types';
|
|
3
3
|
import type { PreparedTreemapSeries } from '../../series/types';
|
|
4
|
+
import type { SeriesShapeData } from '../types';
|
|
4
5
|
export type TreemapLabelData = {
|
|
5
6
|
text: string;
|
|
6
7
|
x: number;
|
|
@@ -11,5 +12,4 @@ export type PreparedTreemapData = {
|
|
|
11
12
|
labelData: TreemapLabelData[];
|
|
12
13
|
leaves: HierarchyRectangularNode<TreemapSeriesData<any>>[];
|
|
13
14
|
series: PreparedTreemapSeries;
|
|
14
|
-
|
|
15
|
-
};
|
|
15
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { getClosestPointsByXValue } from '../../utils/tooltip-helpers';
|
|
2
|
+
export function getTooltipData(args) {
|
|
3
|
+
const { data, position } = args;
|
|
4
|
+
const [pointerX, pointerY] = position;
|
|
5
|
+
const points = data.map((d) => ({
|
|
6
|
+
data: d.data,
|
|
7
|
+
series: d.series,
|
|
8
|
+
x: d.x + d.width / 2,
|
|
9
|
+
y0: d.y,
|
|
10
|
+
y1: d.y + d.height,
|
|
11
|
+
subTotal: d.subTotal,
|
|
12
|
+
}));
|
|
13
|
+
const chunks = getClosestPointsByXValue(pointerX, pointerY, points);
|
|
14
|
+
return { chunks };
|
|
15
|
+
}
|
|
@@ -144,7 +144,7 @@ export const prepareWaterfallData = async (args) => {
|
|
|
144
144
|
data: item.data,
|
|
145
145
|
series: item.series,
|
|
146
146
|
subTotal: totalValue,
|
|
147
|
-
|
|
147
|
+
htmlLabels: [],
|
|
148
148
|
};
|
|
149
149
|
preparedData.label = await getLabelData(preparedData, plotHeight);
|
|
150
150
|
result.push(preparedData);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LabelData, WaterfallSeriesData } from '../../../types';
|
|
2
2
|
import type { PreparedWaterfallSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type PreparedWaterfallData = {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
@@ -10,5 +11,4 @@ export type PreparedWaterfallData = {
|
|
|
10
11
|
data: WaterfallSeriesData;
|
|
11
12
|
label?: LabelData;
|
|
12
13
|
subTotal: number;
|
|
13
|
-
|
|
14
|
-
};
|
|
14
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { sort } from 'd3-array';
|
|
2
|
+
export function getTooltipData(args) {
|
|
3
|
+
const { data, position } = args;
|
|
4
|
+
const [pointerX, pointerY] = position;
|
|
5
|
+
const pointsInRange = data.filter((d) => pointerX >= d.x &&
|
|
6
|
+
pointerX <= d.x + d.width &&
|
|
7
|
+
pointerY >= d.y &&
|
|
8
|
+
pointerY <= d.y + d.height);
|
|
9
|
+
if (pointsInRange.length === 0) {
|
|
10
|
+
return { chunks: [] };
|
|
11
|
+
}
|
|
12
|
+
const closestByX = pointsInRange.length === 1
|
|
13
|
+
? pointsInRange[0]
|
|
14
|
+
: sort(pointsInRange, (d) => Math.abs(d.x + d.width / 2 - pointerX))[0];
|
|
15
|
+
return {
|
|
16
|
+
chunks: pointsInRange.map((d) => ({
|
|
17
|
+
data: d.data,
|
|
18
|
+
series: d.series,
|
|
19
|
+
closest: d === closestByX,
|
|
20
|
+
})),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LabelData, TooltipDataChunkXRange } from '../../../types';
|
|
2
2
|
import type { PreparedXRangeSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
@@ -8,5 +9,4 @@ export type PreparedXRangeData = Omit<TooltipDataChunkXRange, 'series'> & {
|
|
|
8
9
|
color: string;
|
|
9
10
|
series: PreparedXRangeSeries;
|
|
10
11
|
svgLabels: LabelData[];
|
|
11
|
-
|
|
12
|
-
};
|
|
12
|
+
} & SeriesShapeData;
|
|
@@ -34,18 +34,23 @@ export interface FunnelSeries<T = MeaningfulAny> extends Omit<BaseSeries, 'dataL
|
|
|
34
34
|
* width alone, exaggerating differences between large and small values. Use only for
|
|
35
35
|
* decorative purposes or when visual familiarity with the funnel metaphor is more
|
|
36
36
|
* important than analytical precision.
|
|
37
|
-
*
|
|
38
37
|
* @default 'rectangle'
|
|
39
38
|
*/
|
|
40
39
|
shape?: 'rectangle' | 'trapezoid';
|
|
41
40
|
/** Lines or areas connecting the funnel segments. */
|
|
42
41
|
connectors?: {
|
|
43
42
|
enabled?: boolean;
|
|
44
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The height of the connector area between funnel segments.
|
|
45
|
+
* Accepts a pixel number, a pixel string (e.g. `'10px'`), or a percentage string
|
|
46
|
+
* (e.g. `'25%'`) relative to the segment band height.
|
|
47
|
+
*
|
|
48
|
+
* Defaults to `0` for `'trapezoid'` and `'25%'` for `'rectangle'`.
|
|
49
|
+
*/
|
|
45
50
|
height?: string | number;
|
|
46
51
|
/** Option for line stroke style */
|
|
47
52
|
lineDashStyle?: DashStyle;
|
|
48
|
-
/** Opacity for the connector line. */
|
|
53
|
+
/** Opacity for the connector line. Defaults to `0` for `'trapezoid'`, `1` for `'rectangle'`. */
|
|
49
54
|
lineOpacity?: number;
|
|
50
55
|
/** Connector line color. */
|
|
51
56
|
lineColor?: string;
|
|
@@ -53,7 +58,7 @@ export interface FunnelSeries<T = MeaningfulAny> extends Omit<BaseSeries, 'dataL
|
|
|
53
58
|
lineWidth?: number;
|
|
54
59
|
/** Connector area color. */
|
|
55
60
|
areaColor?: string;
|
|
56
|
-
/** Opacity for the connector area. */
|
|
61
|
+
/** Opacity for the connector area fill. Defaults to `0` for `'trapezoid'`, `0.25` for `'rectangle'`. */
|
|
57
62
|
areaOpacity?: number;
|
|
58
63
|
};
|
|
59
64
|
dataLabels?: Omit<BaseDataLabels, 'allowOverlap'> & {
|
|
@@ -55,8 +55,13 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
|
|
|
55
55
|
let result = originalTickValues;
|
|
56
56
|
let availableSpaceForLabel = getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
|
|
57
57
|
let ticksCount = result.length - 1;
|
|
58
|
+
let lastMultiTickResult = result;
|
|
59
|
+
const triedCounts = new Set();
|
|
58
60
|
while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
|
|
59
61
|
ticksCount = ticksCount ? ticksCount - 1 : result.length - 1;
|
|
62
|
+
if (triedCounts.has(ticksCount))
|
|
63
|
+
break;
|
|
64
|
+
triedCounts.add(ticksCount);
|
|
60
65
|
const newScaleTicks = getScaleTicks({ scale, ticksCount, dateTimeLabelFormats });
|
|
61
66
|
result = newScaleTicks.map((t) => ({
|
|
62
67
|
x: scale(t),
|
|
@@ -64,16 +69,23 @@ export function getXAxisTickValues({ axis, labelLineHeight, scale, series, }) {
|
|
|
64
69
|
}));
|
|
65
70
|
availableSpaceForLabel =
|
|
66
71
|
getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
|
|
72
|
+
if (result.length > 1) {
|
|
73
|
+
lastMultiTickResult = result;
|
|
74
|
+
}
|
|
67
75
|
}
|
|
68
76
|
// when this is not possible (for example, such values cannot be selected for the logarithmic axis with a small range)
|
|
69
|
-
// just thin out the
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
// just thin out the last result that had multiple ticks
|
|
78
|
+
// For log scales, 1 tick is also a failure: d3 only places ticks at powers of the base,
|
|
79
|
+
// so a sub-decade range legitimately yields 1 tick despite having room for more.
|
|
80
|
+
// For linear scales, 1 tick is a valid result meaning the chart is simply too small.
|
|
81
|
+
const isLogScale = axis.type === 'logarithmic';
|
|
82
|
+
if ((isLogScale ? result.length <= 1 : !result.length) && lastMultiTickResult.length > 1) {
|
|
83
|
+
result = lastMultiTickResult;
|
|
72
84
|
availableSpaceForLabel =
|
|
73
85
|
getMinSpaceBetween(result, (d) => d.x) - axis.labels.padding * 2;
|
|
74
86
|
let delta = 2;
|
|
75
87
|
while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
|
|
76
|
-
result = thinOut(
|
|
88
|
+
result = thinOut(lastMultiTickResult, delta);
|
|
77
89
|
if (result.length > 1) {
|
|
78
90
|
delta += 1;
|
|
79
91
|
availableSpaceForLabel =
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
import type { ShapeData } from '../../hooks/useShapes';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TooltipDataChunk } from '../../types';
|
|
3
3
|
type GetClosestPointsArgs = {
|
|
4
4
|
position: [number, number];
|
|
5
5
|
shapesData: ShapeData[];
|
|
6
6
|
boundsHeight: number;
|
|
7
7
|
boundsWidth: number;
|
|
8
8
|
};
|
|
9
|
-
export type ShapePoint
|
|
10
|
-
x: number;
|
|
11
|
-
y0: number;
|
|
12
|
-
y1: number;
|
|
13
|
-
data: ChartSeriesData;
|
|
14
|
-
series: ChartSeries;
|
|
15
|
-
subTotal?: number;
|
|
16
|
-
sourceX?: number;
|
|
17
|
-
};
|
|
9
|
+
export type { ShapePoint } from './tooltip-helpers';
|
|
18
10
|
export declare function getClosestPoints(args: GetClosestPointsArgs): TooltipDataChunk[];
|
|
19
|
-
export {};
|