@coinbase/cds-web-visualization 3.4.0-beta.21 → 3.4.0-beta.23
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/CHANGELOG.md +13 -0
- package/dts/chart/CartesianChart.d.ts +23 -4
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +22 -5
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +7 -0
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +3 -3
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +10 -10
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/XAxis.d.ts +6 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +1 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +4 -3
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +25 -5
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +47 -12
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -1
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -1
- package/dts/chart/gradient/Gradient.d.ts +7 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -1
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +7 -0
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +3 -3
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +1 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/point/Point.d.ts +7 -0
- package/dts/chart/point/Point.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +2 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -1
- package/dts/chart/scrubber/Scrubber.d.ts +8 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -1
- package/dts/chart/utils/axis.d.ts +23 -8
- package/dts/chart/utils/axis.d.ts.map +1 -1
- package/dts/chart/utils/bar.d.ts +6 -5
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +13 -0
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +20 -4
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +3 -1
- package/dts/chart/utils/gradient.d.ts.map +1 -1
- package/dts/chart/utils/path.d.ts +20 -0
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +7 -0
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/transition.d.ts +3 -3
- package/dts/chart/utils/transition.d.ts.map +1 -1
- package/esm/chart/CartesianChart.js +89 -57
- package/esm/chart/Path.js +21 -6
- package/esm/chart/area/Area.js +19 -9
- package/esm/chart/area/AreaChart.js +23 -25
- package/esm/chart/area/DottedArea.js +11 -6
- package/esm/chart/area/GradientArea.js +11 -6
- package/esm/chart/area/SolidArea.js +3 -1
- package/esm/chart/axis/XAxis.js +11 -12
- package/esm/chart/axis/YAxis.js +4 -4
- package/esm/chart/bar/Bar.js +11 -5
- package/esm/chart/bar/BarChart.js +34 -31
- package/esm/chart/bar/BarPlot.js +6 -3
- package/esm/chart/bar/BarStack.js +155 -356
- package/esm/chart/bar/BarStackGroup.js +36 -27
- package/esm/chart/bar/DefaultBar.js +26 -10
- package/esm/chart/bar/DefaultBarStack.js +27 -13
- package/esm/chart/gradient/Gradient.js +3 -2
- package/esm/chart/line/DottedLine.js +3 -1
- package/esm/chart/line/Line.js +29 -16
- package/esm/chart/line/LineChart.js +12 -11
- package/esm/chart/line/SolidLine.js +3 -1
- package/esm/chart/point/Point.js +3 -2
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +3 -3
- package/esm/chart/scrubber/DefaultScrubberLabel.js +26 -8
- package/esm/chart/scrubber/Scrubber.js +36 -28
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +49 -32
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +1 -1
- package/esm/chart/scrubber/ScrubberProvider.js +44 -39
- package/esm/chart/utils/axis.js +44 -13
- package/esm/chart/utils/bar.js +6 -4
- package/esm/chart/utils/chart.js +18 -5
- package/esm/chart/utils/context.js +7 -0
- package/esm/chart/utils/gradient.js +6 -4
- package/esm/chart/utils/path.js +87 -61
- package/esm/chart/utils/point.js +30 -21
- package/esm/chart/utils/transition.js +8 -3
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["series", "yAxisId", "stackIndex", "totalStacks", "barPadding"];
|
|
1
|
+
const _excluded = ["series", "xAxisId", "yAxisId", "stackIndex", "totalStacks", "barPadding"];
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -18,6 +18,7 @@ import { BarStack } from './BarStack';
|
|
|
18
18
|
export const BarStackGroup = /*#__PURE__*/memo(_ref => {
|
|
19
19
|
let {
|
|
20
20
|
series,
|
|
21
|
+
xAxisId,
|
|
21
22
|
yAxisId,
|
|
22
23
|
stackIndex,
|
|
23
24
|
totalStacks,
|
|
@@ -25,62 +26,70 @@ export const BarStackGroup = /*#__PURE__*/memo(_ref => {
|
|
|
25
26
|
} = _ref,
|
|
26
27
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
28
|
const {
|
|
29
|
+
layout,
|
|
28
30
|
getXScale,
|
|
29
31
|
getYScale,
|
|
30
32
|
drawingArea,
|
|
31
33
|
dataLength
|
|
32
34
|
} = useCartesianChartContext();
|
|
33
|
-
const xScale = getXScale();
|
|
35
|
+
const xScale = getXScale(xAxisId);
|
|
34
36
|
const yScale = getYScale(yAxisId);
|
|
35
37
|
const stackConfigs = useMemo(() => {
|
|
36
38
|
if (!xScale || !yScale || !drawingArea || dataLength === 0) return [];
|
|
37
|
-
|
|
39
|
+
const indexScale = layout !== 'horizontal' ? xScale : yScale;
|
|
40
|
+
if (!isCategoricalScale(indexScale)) {
|
|
38
41
|
return [];
|
|
39
42
|
}
|
|
40
|
-
const categoryWidth =
|
|
43
|
+
const categoryWidth = indexScale.bandwidth();
|
|
41
44
|
|
|
42
|
-
// Calculate
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
const barWidth = categoryWidth / totalStacks - getBarSizeAdjustment(totalStacks, gapWidth);
|
|
45
|
+
// Calculate thickness for each stack within a category
|
|
46
|
+
const gapSize = totalStacks > 1 ? categoryWidth * barPadding / (totalStacks - 1) : 0;
|
|
47
|
+
const stackThickness = categoryWidth / totalStacks - getBarSizeAdjustment(totalStacks, gapSize);
|
|
46
48
|
const configs = [];
|
|
47
49
|
|
|
48
50
|
// Calculate position for each category
|
|
49
|
-
// todo: look at using xDomain for this instead of dataLength
|
|
50
51
|
for (let categoryIndex = 0; categoryIndex < dataLength; categoryIndex++) {
|
|
51
|
-
// Get
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
// Calculate
|
|
55
|
-
const
|
|
52
|
+
// Get position for this category along the index axis
|
|
53
|
+
const categoryPos = indexScale(categoryIndex);
|
|
54
|
+
if (categoryPos !== undefined) {
|
|
55
|
+
// Calculate position for this specific stack within the category
|
|
56
|
+
const stackPos = categoryPos + stackIndex * (stackThickness + gapSize);
|
|
56
57
|
configs.push({
|
|
57
58
|
categoryIndex,
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
indexPos: stackPos,
|
|
60
|
+
thickness: stackThickness
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
return configs;
|
|
64
|
-
}, [xScale, yScale, drawingArea, dataLength,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
}, [xScale, yScale, drawingArea, dataLength, layout, totalStacks, barPadding, stackIndex]);
|
|
66
|
+
const indexScaleComputed = layout !== 'horizontal' ? xScale : yScale;
|
|
67
|
+
const valueScaleComputed = layout !== 'horizontal' ? yScale : xScale;
|
|
68
|
+
if (indexScaleComputed && !isCategoricalScale(indexScaleComputed)) {
|
|
69
|
+
throw new Error("BarStackGroup requires a band scale for ".concat(layout !== 'horizontal' ? 'x-axis' : 'y-axis', ". See https://cds.coinbase.com/components/graphs/").concat(layout !== 'horizontal' ? 'XAxis' : 'YAxis', "/#scale-type"));
|
|
67
70
|
}
|
|
68
|
-
if (!
|
|
69
|
-
|
|
71
|
+
if (!indexScaleComputed || !valueScaleComputed || !drawingArea || stackConfigs.length === 0) return null;
|
|
72
|
+
|
|
73
|
+
// In horizontal layout, render stacks in reverse order so top rows (lower categoryIndex)
|
|
74
|
+
// appear on top in SVG. Otherwise bottom rows would overlap and obscure top rows during animation.
|
|
75
|
+
const orderedConfigs = layout === 'horizontal' ? [...stackConfigs].reverse() : stackConfigs;
|
|
76
|
+
return orderedConfigs.map(_ref2 => {
|
|
70
77
|
let {
|
|
71
78
|
categoryIndex,
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
indexPos,
|
|
80
|
+
thickness
|
|
74
81
|
} = _ref2;
|
|
75
82
|
return /*#__PURE__*/_createElement(BarStack, _objectSpread(_objectSpread({}, props), {}, {
|
|
76
83
|
key: "stack-".concat(stackIndex, "-category-").concat(categoryIndex),
|
|
77
84
|
categoryIndex: categoryIndex,
|
|
85
|
+
indexPos: indexPos,
|
|
86
|
+
indexScale: indexScaleComputed,
|
|
78
87
|
rect: drawingArea,
|
|
79
88
|
series: series,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
thickness: thickness,
|
|
90
|
+
valueScale: valueScaleComputed,
|
|
91
|
+
xAxisId: xAxisId,
|
|
92
|
+
yAxisId: yAxisId
|
|
84
93
|
}));
|
|
85
94
|
});
|
|
86
95
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "
|
|
1
|
+
const _excluded = ["x", "y", "width", "height", "borderRadius", "roundTop", "roundBottom", "origin", "d", "fill", "fillOpacity", "dataX", "dataY", "seriesId", "transitions", "transition"];
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -17,11 +17,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
17
17
|
export const DefaultBar = /*#__PURE__*/memo(_ref => {
|
|
18
18
|
let {
|
|
19
19
|
x,
|
|
20
|
+
y,
|
|
20
21
|
width,
|
|
22
|
+
height,
|
|
21
23
|
borderRadius = 4,
|
|
22
24
|
roundTop,
|
|
23
25
|
roundBottom,
|
|
24
|
-
|
|
26
|
+
origin,
|
|
25
27
|
d,
|
|
26
28
|
fill = 'var(--color-fgPrimary)',
|
|
27
29
|
fillOpacity = 1,
|
|
@@ -34,16 +36,30 @@ export const DefaultBar = /*#__PURE__*/memo(_ref => {
|
|
|
34
36
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
35
37
|
const {
|
|
36
38
|
animate,
|
|
37
|
-
drawingArea
|
|
39
|
+
drawingArea,
|
|
40
|
+
layout
|
|
38
41
|
} = useCartesianChartContext();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
+
|
|
43
|
+
// For vertical layout, stagger by x (category axis). For horizontal, stagger by y (category axis).
|
|
44
|
+
const normalizedStagger = useMemo(() => {
|
|
45
|
+
const barsGrowVertically = layout !== 'horizontal';
|
|
46
|
+
if (barsGrowVertically) {
|
|
47
|
+
return drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0;
|
|
48
|
+
}
|
|
49
|
+
return drawingArea.height > 0 ? (y - drawingArea.y) / drawingArea.height : 0;
|
|
50
|
+
}, [layout, x, y, drawingArea.x, drawingArea.y, drawingArea.width, drawingArea.height]);
|
|
51
|
+
const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedStagger), [transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, normalizedStagger]);
|
|
52
|
+
const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedStagger), [transitions === null || transitions === void 0 ? void 0 : transitions.update, transition, animate, normalizedStagger]);
|
|
42
53
|
const initialPath = useMemo(() => {
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
if (!animate) return undefined;
|
|
55
|
+
const minSize = 1;
|
|
56
|
+
const barsGrowVertically = layout !== 'horizontal';
|
|
57
|
+
const initialX = barsGrowVertically ? x : origin !== null && origin !== void 0 ? origin : x;
|
|
58
|
+
const initialY = barsGrowVertically ? origin !== null && origin !== void 0 ? origin : y + height : y;
|
|
59
|
+
const initialWidth = barsGrowVertically ? width : minSize;
|
|
60
|
+
const initialHeight = barsGrowVertically ? minSize : height;
|
|
61
|
+
return getBarPath(initialX, initialY, initialWidth, initialHeight, borderRadius !== null && borderRadius !== void 0 ? borderRadius : 0, !!roundTop, !!roundBottom, layout);
|
|
62
|
+
}, [animate, layout, x, y, origin, width, height, borderRadius, roundTop, roundBottom]);
|
|
47
63
|
return /*#__PURE__*/_jsx(Path, _objectSpread(_objectSpread({}, props), {}, {
|
|
48
64
|
animate: animate,
|
|
49
65
|
clipRect: null,
|
|
@@ -25,22 +25,36 @@ export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
|
|
|
25
25
|
} = _ref;
|
|
26
26
|
const {
|
|
27
27
|
animate,
|
|
28
|
-
drawingArea
|
|
28
|
+
drawingArea,
|
|
29
|
+
layout
|
|
29
30
|
} = useCartesianChartContext();
|
|
30
31
|
const clipPathId = useId();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
|
|
33
|
+
// For vertical layout, stagger by x (category axis). For horizontal, stagger by y (category axis).
|
|
34
|
+
const normalizedStagger = useMemo(() => {
|
|
35
|
+
const barsGrowVertically = layout !== 'horizontal';
|
|
36
|
+
if (barsGrowVertically) {
|
|
37
|
+
return drawingArea.width > 0 ? (x - drawingArea.x) / drawingArea.width : 0;
|
|
38
|
+
}
|
|
39
|
+
return drawingArea.height > 0 ? (y - drawingArea.y) / drawingArea.height : 0;
|
|
40
|
+
}, [layout, x, y, drawingArea.x, drawingArea.y, drawingArea.width, drawingArea.height]);
|
|
41
|
+
const enterTransition = useMemo(() => withStaggerDelayTransition(getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultBarEnterTransition), normalizedStagger), [transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, normalizedStagger]);
|
|
42
|
+
const updateTransition = useMemo(() => withStaggerDelayTransition(getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), normalizedStagger), [transitions === null || transitions === void 0 ? void 0 : transitions.update, transition, animate, normalizedStagger]);
|
|
43
|
+
const clipPathData = useMemo(() => {
|
|
44
|
+
return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom, layout);
|
|
45
|
+
}, [x, y, width, height, borderRadius, roundTop, roundBottom, layout]);
|
|
46
|
+
const initialClipPathData = useMemo(() => {
|
|
47
|
+
if (!animate) return undefined;
|
|
48
|
+
const barsGrowVertically = layout !== 'horizontal';
|
|
49
|
+
const initialX = barsGrowVertically ? x : yOrigin !== null && yOrigin !== void 0 ? yOrigin : x;
|
|
50
|
+
const initialY = barsGrowVertically ? yOrigin !== null && yOrigin !== void 0 ? yOrigin : y + height : y;
|
|
51
|
+
const initialWidth = barsGrowVertically ? width : 1;
|
|
52
|
+
const initialHeight = barsGrowVertically ? 1 : height;
|
|
53
|
+
return getBarPath(initialX, initialY, initialWidth, initialHeight, borderRadius, roundTop, roundBottom, layout);
|
|
54
|
+
}, [animate, layout, x, yOrigin, y, height, width, borderRadius, roundTop, roundBottom]);
|
|
41
55
|
const animatedClipPath = usePathTransition({
|
|
42
|
-
currentPath:
|
|
43
|
-
initialPath,
|
|
56
|
+
currentPath: clipPathData,
|
|
57
|
+
initialPath: initialClipPathData,
|
|
44
58
|
transitions: {
|
|
45
59
|
enter: enterTransition,
|
|
46
60
|
update: updateTransition
|
|
@@ -17,13 +17,14 @@ export const Gradient = /*#__PURE__*/memo(_ref => {
|
|
|
17
17
|
let {
|
|
18
18
|
id,
|
|
19
19
|
gradient,
|
|
20
|
+
xAxisId,
|
|
20
21
|
yAxisId,
|
|
21
22
|
animate: animateProp,
|
|
22
23
|
transition
|
|
23
24
|
} = _ref;
|
|
24
25
|
const context = useCartesianChartContext();
|
|
25
26
|
const animate = animateProp !== null && animateProp !== void 0 ? animateProp : context.animate;
|
|
26
|
-
const xScale = context.getXScale();
|
|
27
|
+
const xScale = context.getXScale(xAxisId);
|
|
27
28
|
const yScale = context.getYScale(yAxisId);
|
|
28
29
|
|
|
29
30
|
// Process gradient definition into stops
|
|
@@ -33,7 +34,7 @@ export const Gradient = /*#__PURE__*/memo(_ref => {
|
|
|
33
34
|
}, [gradient, xScale, yScale]);
|
|
34
35
|
const drawingArea = context.drawingArea;
|
|
35
36
|
const yAxis = context.getYAxis(yAxisId);
|
|
36
|
-
const xAxis = context.getXAxis();
|
|
37
|
+
const xAxis = context.getXAxis(xAxisId);
|
|
37
38
|
|
|
38
39
|
// If gradient processing failed, don't render
|
|
39
40
|
if (!stops) return null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect", "gradient", "yAxisId", "animate", "transitions", "transition", "d"];
|
|
1
|
+
const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect", "gradient", "xAxisId", "yAxisId", "animate", "transitions", "transition", "d"];
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -26,6 +26,7 @@ export const DottedLine = /*#__PURE__*/memo(_ref => {
|
|
|
26
26
|
strokeWidth = 2,
|
|
27
27
|
vectorEffect = 'non-scaling-stroke',
|
|
28
28
|
gradient,
|
|
29
|
+
xAxisId,
|
|
29
30
|
yAxisId,
|
|
30
31
|
animate,
|
|
31
32
|
transitions,
|
|
@@ -41,6 +42,7 @@ export const DottedLine = /*#__PURE__*/memo(_ref => {
|
|
|
41
42
|
gradient: gradient,
|
|
42
43
|
id: gradientId,
|
|
43
44
|
transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
|
|
45
|
+
xAxisId: xAxisId,
|
|
44
46
|
yAxisId: yAxisId
|
|
45
47
|
})
|
|
46
48
|
}), /*#__PURE__*/_jsx(Path, _objectSpread({
|
package/esm/chart/line/Line.js
CHANGED
|
@@ -37,6 +37,7 @@ export const Line = /*#__PURE__*/memo(_ref => {
|
|
|
37
37
|
} = _ref,
|
|
38
38
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
39
|
const {
|
|
40
|
+
layout,
|
|
40
41
|
animate,
|
|
41
42
|
getSeries,
|
|
42
43
|
getSeriesData,
|
|
@@ -48,26 +49,36 @@ export const Line = /*#__PURE__*/memo(_ref => {
|
|
|
48
49
|
const matchedSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
|
|
49
50
|
const gradient = useMemo(() => gradientProp !== null && gradientProp !== void 0 ? gradientProp : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.gradient, [gradientProp, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.gradient]);
|
|
50
51
|
const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
|
|
51
|
-
const xAxis = useMemo(() => getXAxis(), [getXAxis]);
|
|
52
|
-
const xScale = useMemo(() => getXScale(), [getXScale]);
|
|
52
|
+
const xAxis = useMemo(() => getXAxis(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId), [getXAxis, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId]);
|
|
53
|
+
const xScale = useMemo(() => getXScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId), [getXScale, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId]);
|
|
53
54
|
const yScale = useMemo(() => getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId), [getYScale, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId]);
|
|
55
|
+
const yAxis = useMemo(() => getYAxis(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId), [getYAxis, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId]);
|
|
54
56
|
|
|
55
57
|
// Convert sourceData to number array (line only supports numbers, not tuples)
|
|
56
58
|
const chartData = useMemo(() => getLineData(sourceData), [sourceData]);
|
|
59
|
+
const categoryAxisIsX = useMemo(() => {
|
|
60
|
+
return layout !== 'horizontal';
|
|
61
|
+
}, [layout]);
|
|
62
|
+
const categoryAxis = useMemo(() => {
|
|
63
|
+
return categoryAxisIsX ? xAxis : yAxis;
|
|
64
|
+
}, [categoryAxisIsX, xAxis, yAxis]);
|
|
57
65
|
const path = useMemo(() => {
|
|
58
66
|
if (!xScale || !yScale || chartData.length === 0) return '';
|
|
59
67
|
|
|
60
|
-
// Get numeric
|
|
61
|
-
const
|
|
68
|
+
// Get numeric category-axis data if available
|
|
69
|
+
const indexAxis = categoryAxis;
|
|
70
|
+
const indexData = indexAxis !== null && indexAxis !== void 0 && indexAxis.data && Array.isArray(indexAxis.data) && typeof indexAxis.data[0] === 'number' ? indexAxis.data : undefined;
|
|
62
71
|
return getLinePath({
|
|
63
72
|
data: chartData,
|
|
64
73
|
xScale,
|
|
65
74
|
yScale,
|
|
66
75
|
curve,
|
|
67
|
-
xData,
|
|
68
|
-
|
|
76
|
+
xData: categoryAxisIsX ? indexData : undefined,
|
|
77
|
+
yData: !categoryAxisIsX ? indexData : undefined,
|
|
78
|
+
connectNulls,
|
|
79
|
+
layout
|
|
69
80
|
});
|
|
70
|
-
}, [
|
|
81
|
+
}, [xScale, yScale, chartData, categoryAxis, curve, categoryAxisIsX, connectNulls, layout]);
|
|
71
82
|
const LineComponent = useMemo(() => {
|
|
72
83
|
if (SelectedLineComponent) {
|
|
73
84
|
return SelectedLineComponent;
|
|
@@ -82,10 +93,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
|
|
|
82
93
|
|
|
83
94
|
// Get series color for stroke
|
|
84
95
|
const stroke = (_ref2 = strokeProp !== null && strokeProp !== void 0 ? strokeProp : matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.color) !== null && _ref2 !== void 0 ? _ref2 : 'var(--color-fgPrimary)';
|
|
85
|
-
const
|
|
86
|
-
const data =
|
|
96
|
+
const categoryData = useMemo(() => {
|
|
97
|
+
const data = categoryAxis === null || categoryAxis === void 0 ? void 0 : categoryAxis.data;
|
|
87
98
|
return data && Array.isArray(data) && data.length > 0 && typeof data[0] === 'number' ? data : null;
|
|
88
|
-
}, [
|
|
99
|
+
}, [categoryAxis]);
|
|
89
100
|
const gradientConfig = useMemo(() => {
|
|
90
101
|
if (!gradient || !xScale || !yScale) return;
|
|
91
102
|
const gradientScale = gradient.axis === 'x' ? xScale : yScale;
|
|
@@ -117,19 +128,20 @@ export const Line = /*#__PURE__*/memo(_ref => {
|
|
|
117
128
|
strokeOpacity: strokeOpacity !== null && strokeOpacity !== void 0 ? strokeOpacity : opacity,
|
|
118
129
|
transition: transition,
|
|
119
130
|
transitions: transitions,
|
|
131
|
+
xAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId,
|
|
120
132
|
yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
|
|
121
133
|
}, props)), points && /*#__PURE__*/_jsx("g", {
|
|
122
134
|
"data-component": "line-points-group",
|
|
123
135
|
children: chartData.map((value, index) => {
|
|
124
136
|
var _pointConfig$onClick;
|
|
125
137
|
if (value === null) return;
|
|
126
|
-
const
|
|
138
|
+
const indexValue = categoryData && categoryData[index] !== undefined ? categoryData[index] : index;
|
|
127
139
|
let pointFill = stroke;
|
|
128
140
|
if (gradientConfig && gradient) {
|
|
129
141
|
var _gradient$axis;
|
|
130
|
-
//
|
|
131
|
-
const
|
|
132
|
-
const dataValue =
|
|
142
|
+
// Match gradient sampling to the chart axis roles for each layout.
|
|
143
|
+
const gradientAxis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
|
|
144
|
+
const dataValue = gradientAxis === 'x' ? categoryAxisIsX ? indexValue : value : categoryAxisIsX ? value : indexValue;
|
|
133
145
|
const evaluatedColor = evaluateGradientAtValue(gradientConfig.stops, dataValue, gradientConfig.scale);
|
|
134
146
|
if (evaluatedColor) {
|
|
135
147
|
// Apply gradient color to fill if not explicitly set
|
|
@@ -139,9 +151,10 @@ export const Line = /*#__PURE__*/memo(_ref => {
|
|
|
139
151
|
|
|
140
152
|
// Build defaults that would be passed to Point
|
|
141
153
|
const defaults = {
|
|
142
|
-
dataX:
|
|
143
|
-
dataY: value,
|
|
154
|
+
dataX: categoryAxisIsX ? indexValue : value,
|
|
155
|
+
dataY: categoryAxisIsX ? value : indexValue,
|
|
144
156
|
fill: pointFill,
|
|
157
|
+
xAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.xAxisId,
|
|
145
158
|
yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId,
|
|
146
159
|
opacity,
|
|
147
160
|
testID: undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const _excluded = ["series", "showArea", "areaType", "type", "onPointClick", "LineComponent", "AreaComponent", "curve", "points", "strokeWidth", "strokeOpacity", "connectNulls", "transitions", "transition", "opacity", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children"],
|
|
2
|
-
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
|
|
2
|
+
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
|
|
3
3
|
_excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"],
|
|
4
|
-
_excluded4 = ["id", "data", "label", "color", "yAxisId", "legendShape"];
|
|
4
|
+
_excluded4 = ["id", "data", "label", "color", "xAxisId", "yAxisId", "legendShape"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -13,7 +13,6 @@ import { forwardRef, memo, useMemo } from 'react';
|
|
|
13
13
|
import { XAxis } from '../axis/XAxis';
|
|
14
14
|
import { YAxis } from '../axis/YAxis';
|
|
15
15
|
import { CartesianChart } from '../CartesianChart';
|
|
16
|
-
import { defaultChartInset, getChartInset } from '../utils';
|
|
17
16
|
import { Line } from './Line';
|
|
18
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
18
|
export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
@@ -41,8 +40,6 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
41
40
|
children
|
|
42
41
|
} = _ref,
|
|
43
42
|
chartProps = _objectWithoutProperties(_ref, _excluded);
|
|
44
|
-
const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
|
|
45
|
-
|
|
46
43
|
// Convert LineSeries to Series for Chart context
|
|
47
44
|
const chartSeries = useMemo(() => {
|
|
48
45
|
return series === null || series === void 0 ? void 0 : series.map(s => ({
|
|
@@ -50,6 +47,7 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
50
47
|
data: s.data,
|
|
51
48
|
label: s.label,
|
|
52
49
|
color: s.color,
|
|
50
|
+
xAxisId: s.xAxisId,
|
|
53
51
|
yAxisId: s.yAxisId,
|
|
54
52
|
stackId: s.stackId,
|
|
55
53
|
gradient: s.gradient,
|
|
@@ -65,7 +63,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
65
63
|
categoryPadding: xCategoryPadding,
|
|
66
64
|
domain: xDomain,
|
|
67
65
|
domainLimit: xDomainLimit,
|
|
68
|
-
range: xRange
|
|
66
|
+
range: xRange,
|
|
67
|
+
id: xAxisId
|
|
69
68
|
} = _ref2,
|
|
70
69
|
xAxisVisualProps = _objectWithoutProperties(_ref2, _excluded2);
|
|
71
70
|
const _ref3 = yAxis || {},
|
|
@@ -97,19 +96,21 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
97
96
|
};
|
|
98
97
|
return /*#__PURE__*/_jsxs(CartesianChart, _objectSpread(_objectSpread({}, chartProps), {}, {
|
|
99
98
|
ref: ref,
|
|
100
|
-
inset:
|
|
99
|
+
inset: inset,
|
|
101
100
|
series: chartSeries,
|
|
102
101
|
xAxis: xAxisConfig,
|
|
103
102
|
yAxis: yAxisConfig,
|
|
104
|
-
children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({
|
|
103
|
+
children: [showXAxis && /*#__PURE__*/_jsx(XAxis, _objectSpread({
|
|
104
|
+
axisId: xAxisId
|
|
105
|
+
}, xAxisVisualProps)), showYAxis && /*#__PURE__*/_jsx(YAxis, _objectSpread({
|
|
105
106
|
axisId: yAxisId
|
|
106
107
|
}, yAxisVisualProps)), series === null || series === void 0 ? void 0 : series.map(_ref4 => {
|
|
107
|
-
var _linePropsFromSeries$, _linePropsFromSeries$2;
|
|
108
108
|
let {
|
|
109
109
|
id,
|
|
110
110
|
data,
|
|
111
111
|
label,
|
|
112
112
|
color,
|
|
113
|
+
xAxisId,
|
|
113
114
|
yAxisId,
|
|
114
115
|
legendShape
|
|
115
116
|
} = _ref4,
|
|
@@ -127,8 +128,8 @@ export const LineChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =
|
|
|
127
128
|
showArea: showArea,
|
|
128
129
|
strokeOpacity: strokeOpacity,
|
|
129
130
|
strokeWidth: strokeWidth,
|
|
130
|
-
transition:
|
|
131
|
-
transitions:
|
|
131
|
+
transition: transition,
|
|
132
|
+
transitions: transitions,
|
|
132
133
|
type: type
|
|
133
134
|
}, linePropsFromSeries), id);
|
|
134
135
|
}), children]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "gradient", "yAxisId", "animate", "transitions", "transition", "d"];
|
|
1
|
+
const _excluded = ["fill", "stroke", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "gradient", "xAxisId", "yAxisId", "animate", "transitions", "transition", "d"];
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -24,6 +24,7 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
|
|
|
24
24
|
strokeOpacity = 1,
|
|
25
25
|
strokeWidth = 2,
|
|
26
26
|
gradient,
|
|
27
|
+
xAxisId,
|
|
27
28
|
yAxisId,
|
|
28
29
|
animate,
|
|
29
30
|
transitions,
|
|
@@ -39,6 +40,7 @@ export const SolidLine = /*#__PURE__*/memo(_ref => {
|
|
|
39
40
|
gradient: gradient,
|
|
40
41
|
id: gradientId,
|
|
41
42
|
transition: (_transitions$update = transitions === null || transitions === void 0 ? void 0 : transitions.update) !== null && _transitions$update !== void 0 ? _transitions$update : transition,
|
|
43
|
+
xAxisId: xAxisId,
|
|
42
44
|
yAxisId: yAxisId
|
|
43
45
|
})
|
|
44
46
|
}), /*#__PURE__*/_jsx(Path, _objectSpread({
|
package/esm/chart/point/Point.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["dataX", "dataY", "yAxisId", "fill", "radius", "opacity", "onClick", "className", "style", "classNames", "styles", "stroke", "strokeWidth", "accessibilityLabel", "label", "LabelComponent", "labelPosition", "labelOffset", "labelFont", "testID", "animate", "transitions", "transition"];
|
|
1
|
+
const _excluded = ["dataX", "dataY", "xAxisId", "yAxisId", "fill", "radius", "opacity", "onClick", "className", "style", "classNames", "styles", "stroke", "strokeWidth", "accessibilityLabel", "label", "LabelComponent", "labelPosition", "labelOffset", "labelFont", "testID", "animate", "transitions", "transition"];
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -24,6 +24,7 @@ export const Point = /*#__PURE__*/memo(_ref => {
|
|
|
24
24
|
let {
|
|
25
25
|
dataX,
|
|
26
26
|
dataY,
|
|
27
|
+
xAxisId,
|
|
27
28
|
yAxisId,
|
|
28
29
|
fill = 'var(--color-fgPrimary)',
|
|
29
30
|
radius = 5,
|
|
@@ -56,7 +57,7 @@ export const Point = /*#__PURE__*/memo(_ref => {
|
|
|
56
57
|
const animate = animateProp !== null && animateProp !== void 0 ? animateProp : animationEnabled;
|
|
57
58
|
const enterTransition = useMemo(() => getTransition(transitions === null || transitions === void 0 ? void 0 : transitions.enter, animate, defaultAccessoryEnterTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.enter]);
|
|
58
59
|
const updateTransition = useMemo(() => getTransition((transitions === null || transitions === void 0 ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), [animate, transitions === null || transitions === void 0 ? void 0 : transitions.update, transition]);
|
|
59
|
-
const xScale = getXScale();
|
|
60
|
+
const xScale = getXScale(xAxisId);
|
|
60
61
|
const yScale = getYScale(yAxisId);
|
|
61
62
|
const pixelCoordinate = useMemo(() => {
|
|
62
63
|
if (!xScale || !yScale) {
|
|
@@ -49,7 +49,7 @@ export const DefaultScrubberBeacon = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((
|
|
|
49
49
|
} = useCartesianChartContext();
|
|
50
50
|
const animate = animateProp !== null && animateProp !== void 0 ? animateProp : animateContext;
|
|
51
51
|
const targetSeries = getSeries(seriesId);
|
|
52
|
-
const xScale = getXScale();
|
|
52
|
+
const xScale = getXScale(targetSeries === null || targetSeries === void 0 ? void 0 : targetSeries.xAxisId);
|
|
53
53
|
const yScale = getYScale(targetSeries === null || targetSeries === void 0 ? void 0 : targetSeries.yAxisId);
|
|
54
54
|
const color = useMemo(() => {
|
|
55
55
|
var _ref2;
|
|
@@ -132,7 +132,7 @@ export const DefaultScrubberBeacon = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((
|
|
|
132
132
|
y: pixelCoordinate.y
|
|
133
133
|
},
|
|
134
134
|
initial: false,
|
|
135
|
-
transition: updateTransition,
|
|
135
|
+
transition: updateTransition !== null && updateTransition !== void 0 ? updateTransition : instantTransition,
|
|
136
136
|
children: pulseCircle
|
|
137
137
|
}), /*#__PURE__*/_jsx(motion.circle, {
|
|
138
138
|
animate: {
|
|
@@ -148,7 +148,7 @@ export const DefaultScrubberBeacon = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((
|
|
|
148
148
|
stroke: stroke,
|
|
149
149
|
strokeWidth: strokeWidth,
|
|
150
150
|
style: style,
|
|
151
|
-
transition: updateTransition
|
|
151
|
+
transition: updateTransition !== null && updateTransition !== void 0 ? updateTransition : instantTransition
|
|
152
152
|
})]
|
|
153
153
|
});
|
|
154
154
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["
|
|
1
|
+
const _excluded = ["dx", "dy"];
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -6,25 +6,43 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
8
8
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
9
|
-
import { memo } from 'react';
|
|
9
|
+
import { memo, useMemo } from 'react';
|
|
10
10
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
11
11
|
import { DefaultReferenceLineLabel } from '../line';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
/**
|
|
14
14
|
* DefaultScrubberLabel is the default label component for the scrubber line.
|
|
15
|
-
*
|
|
15
|
+
* In vertical layout, it positions the label above the scrubber line.
|
|
16
|
+
* In horizontal layout, it centers the label in the chart's right inset.
|
|
16
17
|
*/
|
|
17
18
|
export const DefaultScrubberLabel = /*#__PURE__*/memo(_ref => {
|
|
18
19
|
let {
|
|
19
|
-
|
|
20
|
-
dy
|
|
20
|
+
dx: dxProp,
|
|
21
|
+
dy: dyProp
|
|
21
22
|
} = _ref,
|
|
22
23
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
23
24
|
const {
|
|
24
|
-
drawingArea
|
|
25
|
+
drawingArea,
|
|
26
|
+
layout,
|
|
27
|
+
width: chartWidth
|
|
25
28
|
} = useCartesianChartContext();
|
|
29
|
+
const isHorizontalLayout = layout === 'horizontal';
|
|
30
|
+
const dx = useMemo(() => {
|
|
31
|
+
if (dxProp !== undefined) return dxProp;
|
|
32
|
+
if (isHorizontalLayout) {
|
|
33
|
+
const drawingAreaEnd = drawingArea.x + drawingArea.width;
|
|
34
|
+
const rightOffset = chartWidth - drawingAreaEnd;
|
|
35
|
+
return rightOffset / 2;
|
|
36
|
+
}
|
|
37
|
+
return 0;
|
|
38
|
+
}, [drawingArea.width, drawingArea.x, dxProp, isHorizontalLayout, chartWidth]);
|
|
39
|
+
const dy = useMemo(() => {
|
|
40
|
+
if (dyProp !== undefined) return dyProp;
|
|
41
|
+
if (isHorizontalLayout) return 0;
|
|
42
|
+
return -0.5 * drawingArea.y;
|
|
43
|
+
}, [dyProp, isHorizontalLayout, drawingArea.y]);
|
|
26
44
|
return /*#__PURE__*/_jsx(DefaultReferenceLineLabel, _objectSpread({
|
|
27
|
-
|
|
28
|
-
|
|
45
|
+
dx: dx,
|
|
46
|
+
dy: dy
|
|
29
47
|
}, props));
|
|
30
48
|
});
|