@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
|
@@ -31,8 +31,13 @@ export function getTickValues({ scale, axis, labelLineHeight, series, }) {
|
|
|
31
31
|
let result = originalTickValues;
|
|
32
32
|
let availableSpaceForLabel = getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
|
|
33
33
|
let ticksCount = result.length - 1;
|
|
34
|
+
let lastMultiTickResult = result;
|
|
35
|
+
const triedCounts = new Set();
|
|
34
36
|
while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
|
|
35
37
|
ticksCount = ticksCount ? ticksCount - 1 : result.length - 1;
|
|
38
|
+
if (triedCounts.has(ticksCount))
|
|
39
|
+
break;
|
|
40
|
+
triedCounts.add(ticksCount);
|
|
36
41
|
const newScaleTicks = scale.ticks(ticksCount);
|
|
37
42
|
result = newScaleTicks.map((t) => ({
|
|
38
43
|
y: scale(t),
|
|
@@ -40,16 +45,23 @@ export function getTickValues({ scale, axis, labelLineHeight, series, }) {
|
|
|
40
45
|
}));
|
|
41
46
|
availableSpaceForLabel =
|
|
42
47
|
getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
|
|
48
|
+
if (result.length > 1) {
|
|
49
|
+
lastMultiTickResult = result;
|
|
50
|
+
}
|
|
43
51
|
}
|
|
44
52
|
// when this is not possible (for example, such values cannot be selected for the logarithmic axis with a small range)
|
|
45
|
-
// just thin out the
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
// just thin out the last result that had multiple ticks
|
|
54
|
+
// For log scales, 1 tick is also a failure: d3 only places ticks at powers of the base,
|
|
55
|
+
// so a sub-decade range legitimately yields 1 tick despite having room for more.
|
|
56
|
+
// For linear scales, 1 tick is a valid result meaning the chart is simply too small.
|
|
57
|
+
const isLogScale = axis.type === 'logarithmic';
|
|
58
|
+
if ((isLogScale ? result.length <= 1 : !result.length) && lastMultiTickResult.length > 1) {
|
|
59
|
+
result = lastMultiTickResult;
|
|
48
60
|
availableSpaceForLabel =
|
|
49
61
|
getMinSpaceBetween(result, (d) => d.y) - axis.labels.padding * 2;
|
|
50
62
|
let delta = 2;
|
|
51
63
|
while (availableSpaceForLabel < labelLineHeight && result.length > 1) {
|
|
52
|
-
result = thinOut(
|
|
64
|
+
result = thinOut(lastMultiTickResult, delta);
|
|
53
65
|
if (result.length > 1) {
|
|
54
66
|
delta += 1;
|
|
55
67
|
availableSpaceForLabel =
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { select } from 'd3-selection';
|
|
3
2
|
import debounce from 'lodash/debounce';
|
|
4
3
|
import { i18nFactory } from '../core/i18n';
|
|
5
|
-
import { getUniqId } from '../core/utils';
|
|
6
4
|
import { validateData } from '../core/validation';
|
|
7
5
|
import { ChartInner } from './ChartInner';
|
|
8
6
|
export * from './Tooltip/ChartTooltipContent';
|
|
@@ -17,11 +15,22 @@ export const Chart = React.forwardRef(function Chart(props, forwardedRef) {
|
|
|
17
15
|
validateData(data);
|
|
18
16
|
validatedData.current = data;
|
|
19
17
|
}
|
|
20
|
-
const handleResize = React.useCallback(() => {
|
|
18
|
+
const handleResize = React.useCallback((options) => {
|
|
21
19
|
var _a;
|
|
22
20
|
const parentElement = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
23
21
|
if (parentElement) {
|
|
24
|
-
|
|
22
|
+
const nextDimensions = {
|
|
23
|
+
width: parentElement.clientWidth,
|
|
24
|
+
height: parentElement.clientHeight,
|
|
25
|
+
};
|
|
26
|
+
setDimensions((currentDimensions) => {
|
|
27
|
+
if (!(options === null || options === void 0 ? void 0 : options.force) &&
|
|
28
|
+
(currentDimensions === null || currentDimensions === void 0 ? void 0 : currentDimensions.width) === nextDimensions.width &&
|
|
29
|
+
currentDimensions.height === nextDimensions.height) {
|
|
30
|
+
return currentDimensions;
|
|
31
|
+
}
|
|
32
|
+
return nextDimensions;
|
|
33
|
+
});
|
|
25
34
|
}
|
|
26
35
|
}, []);
|
|
27
36
|
const debuncedHandleResize = React.useMemo(() => {
|
|
@@ -33,10 +42,10 @@ export const Chart = React.forwardRef(function Chart(props, forwardedRef) {
|
|
|
33
42
|
React.useImperativeHandle(forwardedRef, () => ({
|
|
34
43
|
reflow(options) {
|
|
35
44
|
if (options === null || options === void 0 ? void 0 : options.immediate) {
|
|
36
|
-
handleResize();
|
|
45
|
+
handleResize({ force: true });
|
|
37
46
|
}
|
|
38
47
|
else {
|
|
39
|
-
debuncedHandleResize();
|
|
48
|
+
debuncedHandleResize({ force: true });
|
|
40
49
|
}
|
|
41
50
|
},
|
|
42
51
|
}), [debuncedHandleResize, handleResize]);
|
|
@@ -45,19 +54,18 @@ export const Chart = React.forwardRef(function Chart(props, forwardedRef) {
|
|
|
45
54
|
handleResize();
|
|
46
55
|
}, [handleResize]);
|
|
47
56
|
React.useEffect(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
var _a;
|
|
58
|
+
const parentElement = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
59
|
+
if (!parentElement) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const observer = new ResizeObserver(() => debuncedHandleResize());
|
|
63
|
+
observer.observe(parentElement);
|
|
54
64
|
return () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
window.removeEventListener('transitionend', handleResize, { capture: true });
|
|
58
|
-
window.removeEventListener('animationend', handleResize, { capture: true });
|
|
65
|
+
observer.disconnect();
|
|
66
|
+
debuncedHandleResize.cancel();
|
|
59
67
|
};
|
|
60
|
-
}, [debuncedHandleResize
|
|
68
|
+
}, [debuncedHandleResize]);
|
|
61
69
|
React.useEffect(() => {
|
|
62
70
|
if (typeof onResize === 'function') {
|
|
63
71
|
onResize({ dimensions });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ScaleOrdinal } from 'd3-scale';
|
|
2
|
+
import type { ChartSeries, ChartSeriesOptions } from '../../types';
|
|
3
|
+
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
|
+
export interface PrepareSeriesArgs {
|
|
5
|
+
series: ChartSeries[];
|
|
6
|
+
seriesOptions?: ChartSeriesOptions;
|
|
7
|
+
legend: PreparedLegend;
|
|
8
|
+
colorScale: ScaleOrdinal<string, string>;
|
|
9
|
+
colors: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface SeriesPlugin<T extends ChartSeries = ChartSeries> {
|
|
12
|
+
type: T['type'];
|
|
13
|
+
prepareSeries(args: PrepareSeriesArgs): PreparedSeries[] | Promise<PreparedSeries[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { ChartData } from '../../types';
|
|
2
|
+
import type { PrepareSeriesArgs } from './plugin';
|
|
3
3
|
import type { PreparedLegend, PreparedSeries } from './types';
|
|
4
4
|
export declare const getPreparedSeries: ({ seriesData, seriesOptions, colors, preparedLegend, }: {
|
|
5
5
|
seriesData: ChartData["series"]["data"];
|
|
@@ -7,11 +7,4 @@ export declare const getPreparedSeries: ({ seriesData, seriesOptions, colors, pr
|
|
|
7
7
|
colors: string[];
|
|
8
8
|
preparedLegend?: PreparedLegend | null;
|
|
9
9
|
}) => Promise<PreparedSeries[]>;
|
|
10
|
-
export declare function prepareSeries(args:
|
|
11
|
-
type: ChartSeries['type'];
|
|
12
|
-
series: ChartSeries[];
|
|
13
|
-
seriesOptions?: ChartSeriesOptions;
|
|
14
|
-
legend: PreparedLegend;
|
|
15
|
-
colors: string[];
|
|
16
|
-
colorScale: ScaleOrdinal<string, string>;
|
|
17
|
-
}): Promise<PreparedSeries[]>;
|
|
10
|
+
export declare function prepareSeries(args: PrepareSeriesArgs): Promise<PreparedSeries[]>;
|
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { group } from 'd3-array';
|
|
2
2
|
import { scaleOrdinal } from 'd3-scale';
|
|
3
|
-
import { ChartError } from '../../libs';
|
|
4
3
|
import { getSeriesNames } from '../utils';
|
|
5
|
-
import {
|
|
6
|
-
import { prepareBarXSeries } from './prepare-bar-x';
|
|
7
|
-
import { prepareBarYSeries } from './prepare-bar-y';
|
|
8
|
-
import { prepareFunnelSeries } from './prepare-funnel';
|
|
9
|
-
import { prepareHeatmapSeries } from './prepare-heatmap';
|
|
10
|
-
import { prepareLineSeries } from './prepare-line';
|
|
11
|
-
import { preparePieSeries } from './prepare-pie';
|
|
12
|
-
import { prepareRadarSeries } from './prepare-radar';
|
|
13
|
-
import { prepareSankeySeries } from './prepare-sankey';
|
|
14
|
-
import { prepareScatterSeries } from './prepare-scatter';
|
|
15
|
-
import { prepareTreemap } from './prepare-treemap';
|
|
16
|
-
import { prepareWaterfallSeries } from './prepare-waterfall';
|
|
17
|
-
import { prepareXRangeSeries } from './prepare-x-range';
|
|
4
|
+
import { getSeriesPlugin } from './seriesRegistry';
|
|
18
5
|
export const getPreparedSeries = async ({ seriesData, seriesOptions, colors, preparedLegend, }) => {
|
|
19
6
|
const seriesNames = getSeriesNames(seriesData);
|
|
20
7
|
const colorScale = scaleOrdinal(seriesNames, colors);
|
|
@@ -31,9 +18,7 @@ export const getPreparedSeries = async ({ seriesData, seriesOptions, colors, pre
|
|
|
31
18
|
const list = Array.from(groupedSeries);
|
|
32
19
|
for (let i = 0; i < list.length; i++) {
|
|
33
20
|
const [_groupId, seriesList] = list[i];
|
|
34
|
-
const seriesType = seriesList[0].type;
|
|
35
21
|
acc.push(...(await prepareSeries({
|
|
36
|
-
type: seriesType,
|
|
37
22
|
series: seriesList,
|
|
38
23
|
seriesOptions,
|
|
39
24
|
legend: preparedLegend,
|
|
@@ -44,114 +29,6 @@ export const getPreparedSeries = async ({ seriesData, seriesOptions, colors, pre
|
|
|
44
29
|
return acc;
|
|
45
30
|
};
|
|
46
31
|
export async function prepareSeries(args) {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
case 'pie': {
|
|
50
|
-
return series.reduce((acc, singleSeries) => {
|
|
51
|
-
acc.push(...preparePieSeries({
|
|
52
|
-
series: singleSeries,
|
|
53
|
-
seriesOptions,
|
|
54
|
-
legend,
|
|
55
|
-
colors,
|
|
56
|
-
}));
|
|
57
|
-
return acc;
|
|
58
|
-
}, []);
|
|
59
|
-
}
|
|
60
|
-
case 'bar-x': {
|
|
61
|
-
return prepareBarXSeries({
|
|
62
|
-
series: series,
|
|
63
|
-
legend,
|
|
64
|
-
colorScale,
|
|
65
|
-
seriesOptions,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
case 'bar-y': {
|
|
69
|
-
return await prepareBarYSeries({
|
|
70
|
-
series: series,
|
|
71
|
-
legend,
|
|
72
|
-
colorScale,
|
|
73
|
-
seriesOptions,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
case 'scatter': {
|
|
77
|
-
return prepareScatterSeries({ series: series, legend, colorScale });
|
|
78
|
-
}
|
|
79
|
-
case 'line': {
|
|
80
|
-
return prepareLineSeries({
|
|
81
|
-
series: series,
|
|
82
|
-
seriesOptions,
|
|
83
|
-
legend,
|
|
84
|
-
colorScale,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
case 'area': {
|
|
88
|
-
return prepareArea({
|
|
89
|
-
series: series,
|
|
90
|
-
seriesOptions,
|
|
91
|
-
legend,
|
|
92
|
-
colorScale,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
case 'treemap': {
|
|
96
|
-
return prepareTreemap({
|
|
97
|
-
series: series,
|
|
98
|
-
seriesOptions,
|
|
99
|
-
legend,
|
|
100
|
-
colorScale,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
case 'waterfall': {
|
|
104
|
-
return prepareWaterfallSeries({
|
|
105
|
-
series: series,
|
|
106
|
-
legend,
|
|
107
|
-
colorScale,
|
|
108
|
-
colors,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
case 'sankey': {
|
|
112
|
-
return prepareSankeySeries({
|
|
113
|
-
series: series,
|
|
114
|
-
seriesOptions,
|
|
115
|
-
colorScale,
|
|
116
|
-
legend,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
case 'radar': {
|
|
120
|
-
return prepareRadarSeries({
|
|
121
|
-
series: series,
|
|
122
|
-
seriesOptions,
|
|
123
|
-
legend,
|
|
124
|
-
colors,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
case 'heatmap': {
|
|
128
|
-
return await prepareHeatmapSeries({
|
|
129
|
-
series: series,
|
|
130
|
-
legend,
|
|
131
|
-
colorScale,
|
|
132
|
-
seriesOptions,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
case 'funnel': {
|
|
136
|
-
return prepareFunnelSeries({
|
|
137
|
-
series: series[0],
|
|
138
|
-
seriesOptions,
|
|
139
|
-
legend,
|
|
140
|
-
colors,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
case 'x-range': {
|
|
144
|
-
return prepareXRangeSeries({
|
|
145
|
-
series: series,
|
|
146
|
-
seriesOptions,
|
|
147
|
-
legend,
|
|
148
|
-
colorScale,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
default: {
|
|
152
|
-
throw new ChartError({
|
|
153
|
-
message: `Series type "${type}" does not support data preparation for series that do not support the presence of axes`,
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
32
|
+
const plugin = getSeriesPlugin(args.series[0].type);
|
|
33
|
+
return plugin.prepareSeries(args);
|
|
157
34
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChartError } from '../../libs';
|
|
2
|
+
const registry = new Map();
|
|
3
|
+
export function registerSeriesPlugin(plugin) {
|
|
4
|
+
registry.set(plugin.type, plugin);
|
|
5
|
+
}
|
|
6
|
+
export function getSeriesPlugin(type) {
|
|
7
|
+
const plugin = registry.get(type);
|
|
8
|
+
if (!plugin) {
|
|
9
|
+
throw new ChartError({ message: `Unknown series type: "${type}"` });
|
|
10
|
+
}
|
|
11
|
+
return plugin;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function getTooltipData(args) {
|
|
2
|
+
const { data } = args;
|
|
3
|
+
const xLookupPoints = data.reduce((acc, d) => {
|
|
4
|
+
for (const p of d.points) {
|
|
5
|
+
if (p.y === null || p.hiddenInLine) {
|
|
6
|
+
continue;
|
|
7
|
+
}
|
|
8
|
+
acc.push({
|
|
9
|
+
data: p.data,
|
|
10
|
+
series: p.series,
|
|
11
|
+
x: p.x,
|
|
12
|
+
y0: p.y0,
|
|
13
|
+
y1: p.y,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return acc;
|
|
17
|
+
}, []);
|
|
18
|
+
return { chunks: [], xLookupPoints };
|
|
19
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { AreaSeriesData,
|
|
1
|
+
import type { AreaSeriesData, LabelData } from '../../../types';
|
|
2
2
|
import type { AnnotationAnchor, PreparedAnnotation, PreparedAreaSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type PointData = {
|
|
4
5
|
annotation?: PreparedAnnotation;
|
|
5
6
|
color?: string;
|
|
@@ -31,5 +32,4 @@ export type PreparedAreaData = {
|
|
|
31
32
|
hovered: boolean;
|
|
32
33
|
active: boolean;
|
|
33
34
|
svgLabels: LabelData[];
|
|
34
|
-
|
|
35
|
-
};
|
|
35
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import groupBy from 'lodash/groupBy';
|
|
2
|
+
export function getTooltipData(args) {
|
|
3
|
+
const { data } = args;
|
|
4
|
+
const barXGroups = groupBy(data, (d) => String(d.data.x));
|
|
5
|
+
const xLookupPoints = [];
|
|
6
|
+
for (const group of Object.values(barXGroups)) {
|
|
7
|
+
const groupCenterX = group.reduce((sum, d) => sum + d.x + d.width / 2, 0) / group.length;
|
|
8
|
+
for (const d of group) {
|
|
9
|
+
xLookupPoints.push({
|
|
10
|
+
data: d.data,
|
|
11
|
+
series: d.series,
|
|
12
|
+
x: groupCenterX,
|
|
13
|
+
y0: d.y,
|
|
14
|
+
y1: d.y + d.height,
|
|
15
|
+
sourceX: d.x + d.width / 2,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return { chunks: [], xLookupPoints };
|
|
20
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LabelData, TooltipDataChunkBarX } from '../../../types';
|
|
2
2
|
import type { PreparedAnnotation, PreparedBarXSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
|
|
4
5
|
annotation?: PreparedAnnotation;
|
|
5
6
|
x: number;
|
|
@@ -9,11 +10,10 @@ export type PreparedBarXData = Omit<TooltipDataChunkBarX, 'series'> & {
|
|
|
9
10
|
opacity: number | null;
|
|
10
11
|
series: PreparedBarXSeries;
|
|
11
12
|
svgLabels: LabelData[];
|
|
12
|
-
htmlLabels: HtmlItem[];
|
|
13
13
|
isLastStackItem: boolean;
|
|
14
14
|
/**
|
|
15
15
|
* the utility field for storing the original height (for recalculations, etc.)
|
|
16
16
|
* should not be used for displaying
|
|
17
17
|
*/
|
|
18
18
|
_height: number;
|
|
19
|
-
};
|
|
19
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { bisector, sort } from 'd3-array';
|
|
2
|
+
export function getTooltipData(args) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
const { data, position } = args;
|
|
5
|
+
const [pointerX, pointerY] = position;
|
|
6
|
+
const sorted = sort(data, (p) => p.y);
|
|
7
|
+
const closestYIndex = bisector((p) => p.y + p.height / 2).center(sorted, pointerY);
|
|
8
|
+
const closestYPoint = sorted[closestYIndex];
|
|
9
|
+
if (!closestYPoint) {
|
|
10
|
+
return { chunks: [] };
|
|
11
|
+
}
|
|
12
|
+
const selectedPoints = data.filter((p) => p.data.y === closestYPoint.data.y);
|
|
13
|
+
const closestPoints = sort(selectedPoints.filter((p) => p.y === closestYPoint.y), (p) => p.x);
|
|
14
|
+
let closestPointXValue;
|
|
15
|
+
const lastPoint = closestPoints[closestPoints.length - 1];
|
|
16
|
+
if (pointerX < ((_a = closestPoints[0]) === null || _a === void 0 ? void 0 : _a.x)) {
|
|
17
|
+
closestPointXValue = closestPoints[0].x;
|
|
18
|
+
}
|
|
19
|
+
else if (lastPoint && pointerX > lastPoint.x + lastPoint.width) {
|
|
20
|
+
closestPointXValue = lastPoint.x;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
closestPointXValue = (_b = closestPoints.find((p) => pointerX > p.x && pointerX < p.x + p.width)) === null || _b === void 0 ? void 0 : _b.x;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
chunks: selectedPoints.map((p) => ({
|
|
27
|
+
data: p.data,
|
|
28
|
+
series: p.series,
|
|
29
|
+
closest: p.x === closestPointXValue && p.y === closestYPoint.y,
|
|
30
|
+
})),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -13,7 +13,7 @@ export async function prepareBarYData(args) {
|
|
|
13
13
|
return {
|
|
14
14
|
shapes: [],
|
|
15
15
|
labels: [],
|
|
16
|
-
|
|
16
|
+
htmlLabels: [],
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
const sortingOptions = get(seriesOptions, 'bar-y.dataSorting');
|
|
@@ -134,7 +134,7 @@ export async function prepareBarYData(args) {
|
|
|
134
134
|
});
|
|
135
135
|
});
|
|
136
136
|
let labels = [];
|
|
137
|
-
let
|
|
137
|
+
let htmlLabels = [];
|
|
138
138
|
const map = new Map();
|
|
139
139
|
for (let i = 0; i < result.length; i++) {
|
|
140
140
|
const prepared = result[i];
|
|
@@ -160,7 +160,7 @@ export async function prepareBarYData(args) {
|
|
|
160
160
|
x,
|
|
161
161
|
y: y - height / 2,
|
|
162
162
|
});
|
|
163
|
-
|
|
163
|
+
htmlLabels.push({
|
|
164
164
|
content,
|
|
165
165
|
size: { width, height },
|
|
166
166
|
style: dataLabels.style,
|
|
@@ -202,12 +202,12 @@ export async function prepareBarYData(args) {
|
|
|
202
202
|
if (labels.length && !allowOverlap) {
|
|
203
203
|
labels = filterOverlappingLabels(labels);
|
|
204
204
|
}
|
|
205
|
-
else if (
|
|
206
|
-
|
|
205
|
+
else if (htmlLabels.length && !allowOverlap) {
|
|
206
|
+
htmlLabels = filterOverlappingLabels(htmlLabels);
|
|
207
207
|
}
|
|
208
208
|
return {
|
|
209
209
|
shapes: result,
|
|
210
210
|
labels,
|
|
211
|
-
|
|
211
|
+
htmlLabels,
|
|
212
212
|
};
|
|
213
213
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LabelData, TooltipDataChunkBarY } from '../../../types';
|
|
2
2
|
import type { PreparedBarYSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type PreparedBarYData = Omit<TooltipDataChunkBarY, 'series'> & {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
@@ -15,5 +16,4 @@ export type PreparedBarYData = Omit<TooltipDataChunkBarY, 'series'> & {
|
|
|
15
16
|
export type BarYShapesArgs = {
|
|
16
17
|
shapes: PreparedBarYData[];
|
|
17
18
|
labels: LabelData[];
|
|
18
|
-
|
|
19
|
-
};
|
|
19
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,21 @@
|
|
|
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.items.find((item) => pointerX >= item.x &&
|
|
6
|
+
pointerX <= item.x + item.width &&
|
|
7
|
+
pointerY >= item.y &&
|
|
8
|
+
pointerY <= item.y + item.height);
|
|
9
|
+
if (!closestPoint) {
|
|
10
|
+
return { chunks: [] };
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
chunks: [
|
|
14
|
+
{
|
|
15
|
+
data: closestPoint.data,
|
|
16
|
+
series: closestPoint.series,
|
|
17
|
+
closest: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -128,11 +128,13 @@ export async function prepareFunnelData(args) {
|
|
|
128
128
|
const prevSeries = series[index - 1];
|
|
129
129
|
const prevItem = items[index - 1];
|
|
130
130
|
if (prevSeries && prevItem && ((_e = prevSeries.connectors) === null || _e === void 0 ? void 0 : _e.enabled)) {
|
|
131
|
+
// Use the actual bottom corners of the previous segment (points[3]/[2]) so that
|
|
132
|
+
// trapezoid segments (whose bottom edge differs from the top edge) are handled correctly.
|
|
131
133
|
const connectorPoints = [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
prevItem.points[3],
|
|
135
|
+
prevItem.points[2],
|
|
136
|
+
funnelSegment.points[1],
|
|
137
|
+
funnelSegment.points[0],
|
|
136
138
|
];
|
|
137
139
|
connectors.push({
|
|
138
140
|
linePath: getLineConnectorPaths({ points: connectorPoints }),
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Path } from 'd3-path';
|
|
2
|
-
import type { FunnelSeriesData,
|
|
2
|
+
import type { FunnelSeriesData, LabelData } from '../../../types';
|
|
3
3
|
import type { DashStyle } from '../../constants';
|
|
4
4
|
import type { PreparedFunnelSeries } from '../../series/types';
|
|
5
|
+
import type { SeriesShapeData } from '../types';
|
|
5
6
|
export type FunnelItemData = {
|
|
6
7
|
x: number;
|
|
7
8
|
y: number;
|
|
@@ -30,5 +31,4 @@ export type PreparedFunnelData = {
|
|
|
30
31
|
items: FunnelItemData[];
|
|
31
32
|
connectors: FunnelConnectorData[];
|
|
32
33
|
svgLabels: LabelData[];
|
|
33
|
-
|
|
34
|
-
};
|
|
34
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,21 @@
|
|
|
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.items.find((cell) => pointerX >= cell.x &&
|
|
6
|
+
pointerX <= cell.x + cell.width &&
|
|
7
|
+
pointerY >= cell.y &&
|
|
8
|
+
pointerY <= cell.y + cell.height);
|
|
9
|
+
if (!closestPoint) {
|
|
10
|
+
return { chunks: [] };
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
chunks: [
|
|
14
|
+
{
|
|
15
|
+
data: closestPoint.data,
|
|
16
|
+
series: data[0].series,
|
|
17
|
+
closest: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { BaseTextStyle, HeatmapSeriesData
|
|
1
|
+
import type { BaseTextStyle, HeatmapSeriesData } from '../../../types';
|
|
2
2
|
import type { PreparedHeatmapSeries } from '../../series/types';
|
|
3
|
+
import type { SeriesShapeData } from '../types';
|
|
3
4
|
export type HeatmapItem = {
|
|
4
5
|
x: number;
|
|
5
6
|
y: number;
|
|
@@ -20,6 +21,5 @@ export type HeatmapLabel = {
|
|
|
20
21
|
export type PreparedHeatmapData = {
|
|
21
22
|
series: PreparedHeatmapSeries;
|
|
22
23
|
items: HeatmapItem[];
|
|
23
|
-
htmlElements: HtmlItem[];
|
|
24
24
|
labels: HeatmapLabel[];
|
|
25
|
-
};
|
|
25
|
+
} & SeriesShapeData;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function getTooltipData(args) {
|
|
2
|
+
const { data } = args;
|
|
3
|
+
const xLookupPoints = data.reduce((acc, d) => {
|
|
4
|
+
for (const p of d.points) {
|
|
5
|
+
if (p.y !== null && p.x !== null && !p.hiddenInLine) {
|
|
6
|
+
acc.push({
|
|
7
|
+
data: p.data,
|
|
8
|
+
series: p.series,
|
|
9
|
+
x: p.x,
|
|
10
|
+
y0: p.y,
|
|
11
|
+
y1: p.y,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return acc;
|
|
16
|
+
}, []);
|
|
17
|
+
return { chunks: [], xLookupPoints };
|
|
18
|
+
}
|