@coinbase/cds-web-visualization 3.4.0-beta.4 → 3.4.0-beta.6
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 +38 -2
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +27 -7
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +0 -4
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +54 -24
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +33 -6
- package/dts/chart/area/AreaChart.d.ts.map +1 -1
- package/dts/chart/area/DottedArea.d.ts +21 -44
- package/dts/chart/area/DottedArea.d.ts.map +1 -1
- package/dts/chart/area/GradientArea.d.ts +21 -12
- package/dts/chart/area/GradientArea.d.ts.map +1 -1
- package/dts/chart/area/SolidArea.d.ts +16 -1
- package/dts/chart/area/SolidArea.d.ts.map +1 -1
- package/dts/chart/axis/Axis.d.ts +89 -43
- package/dts/chart/axis/Axis.d.ts.map +1 -1
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +8 -0
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +1 -0
- package/dts/chart/axis/XAxis.d.ts +1 -1
- package/dts/chart/axis/XAxis.d.ts.map +1 -1
- package/dts/chart/axis/YAxis.d.ts +1 -1
- package/dts/chart/axis/YAxis.d.ts.map +1 -1
- package/dts/chart/axis/index.d.ts +1 -0
- package/dts/chart/axis/index.d.ts.map +1 -1
- package/dts/chart/bar/Bar.d.ts +16 -13
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +17 -8
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +2 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +40 -48
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +1 -0
- 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 +35 -0
- package/dts/chart/gradient/Gradient.d.ts.map +1 -0
- package/dts/chart/gradient/index.d.ts +2 -0
- package/dts/chart/gradient/index.d.ts.map +1 -0
- package/dts/chart/index.d.ts +2 -1
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +9 -0
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +15 -3
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +70 -28
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +26 -8
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +85 -44
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -1
- package/dts/chart/line/SolidLine.d.ts +14 -3
- package/dts/chart/line/SolidLine.d.ts.map +1 -1
- package/dts/chart/line/index.d.ts +1 -1
- package/dts/chart/line/index.d.ts.map +1 -1
- package/dts/chart/point/DefaultPointLabel.d.ts +10 -0
- package/dts/chart/point/DefaultPointLabel.d.ts.map +1 -0
- package/dts/chart/point/Point.d.ts +201 -0
- package/dts/chart/point/Point.d.ts.map +1 -0
- package/dts/chart/point/index.d.ts +3 -0
- package/dts/chart/point/index.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +24 -0
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +12 -0
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +10 -0
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +1 -0
- package/dts/chart/scrubber/Scrubber.d.ts +203 -64
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +70 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +32 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/index.d.ts +3 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -1
- package/dts/chart/text/ChartText.d.ts +46 -43
- package/dts/chart/text/ChartText.d.ts.map +1 -1
- package/dts/chart/text/{SmartChartTextGroup.d.ts → ChartTextGroup.d.ts} +9 -3
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +1 -1
- package/dts/chart/text/index.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +27 -7
- package/dts/chart/utils/chart.d.ts.map +1 -1
- package/dts/chart/utils/context.d.ts +6 -0
- package/dts/chart/utils/context.d.ts.map +1 -1
- package/dts/chart/utils/gradient.d.ts +104 -0
- package/dts/chart/utils/gradient.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +4 -0
- package/dts/chart/utils/index.d.ts.map +1 -1
- package/dts/chart/utils/interpolate.d.ts +112 -0
- package/dts/chart/utils/interpolate.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +24 -1
- package/dts/chart/utils/path.d.ts.map +1 -1
- package/dts/chart/utils/point.d.ts +29 -0
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scrubber.d.ts +39 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +65 -0
- package/dts/chart/utils/transition.d.ts.map +1 -0
- package/esm/chart/CartesianChart.js +140 -85
- package/esm/chart/Path.js +51 -46
- package/esm/chart/PeriodSelector.js +4 -18
- package/esm/chart/area/Area.js +24 -34
- package/esm/chart/area/AreaChart.js +24 -15
- package/esm/chart/area/DottedArea.js +35 -89
- package/esm/chart/area/GradientArea.js +34 -80
- package/esm/chart/area/SolidArea.js +29 -11
- package/esm/chart/axis/Axis.js +4 -25
- package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
- package/esm/chart/axis/XAxis.js +53 -36
- package/esm/chart/axis/YAxis.js +55 -32
- package/esm/chart/axis/index.js +1 -0
- package/esm/chart/bar/Bar.js +3 -1
- package/esm/chart/bar/BarChart.js +15 -32
- package/esm/chart/bar/BarPlot.js +3 -2
- package/esm/chart/bar/BarStack.js +65 -23
- package/esm/chart/bar/BarStackGroup.js +7 -17
- package/esm/chart/bar/DefaultBar.js +4 -7
- package/esm/chart/bar/DefaultBarStack.js +5 -7
- package/esm/chart/gradient/Gradient.js +104 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +2 -1
- package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
- package/esm/chart/line/DottedLine.js +38 -17
- package/esm/chart/line/Line.js +96 -70
- package/esm/chart/line/LineChart.js +18 -6
- package/esm/chart/line/ReferenceLine.js +34 -41
- package/esm/chart/line/SolidLine.js +36 -15
- package/esm/chart/line/index.js +1 -1
- package/esm/chart/{line/GradientLine.js → point/DefaultPointLabel.js} +31 -45
- package/esm/chart/point/Point.css +2 -0
- package/esm/chart/{Point.js → point/Point.js} +66 -57
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
- package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberBeaconLabel.js} +23 -10
- package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
- package/esm/chart/scrubber/Scrubber.js +98 -392
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
- package/esm/chart/scrubber/index.js +3 -1
- package/esm/chart/text/ChartText.js +13 -19
- package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
- package/esm/chart/text/index.js +1 -1
- package/esm/chart/utils/chart.js +29 -3
- package/esm/chart/utils/gradient.js +257 -0
- package/esm/chart/utils/index.js +4 -0
- package/esm/chart/utils/interpolate.js +644 -0
- package/esm/chart/utils/path.js +32 -9
- package/esm/chart/utils/point.js +69 -0
- package/esm/chart/utils/scrubber.js +132 -0
- package/esm/chart/utils/transition.js +111 -0
- package/package.json +9 -9
- package/dts/chart/Point.d.ts +0 -153
- package/dts/chart/Point.d.ts.map +0 -1
- package/dts/chart/line/GradientLine.d.ts +0 -42
- package/dts/chart/line/GradientLine.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeacon.d.ts +0 -93
- package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +0 -7
- package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts.map +0 -1
- package/dts/chart/text/SmartChartTextGroup.d.ts.map +0 -1
- package/esm/chart/Point.css +0 -2
- package/esm/chart/scrubber/ScrubberBeacon.js +0 -195
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "fillOpacity", "
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "peakOpacity", "baselineOpacity", "baseline", "yAxisId", "gradient", "animate", "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; }
|
|
@@ -6,106 +6,60 @@ 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, useId } from 'react';
|
|
9
|
+
import { memo, useId, useMemo } from 'react';
|
|
10
10
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
11
|
+
import { Gradient } from '../gradient';
|
|
11
12
|
import { Path } from '../Path';
|
|
13
|
+
import { createGradient, getBaseline } from '../utils';
|
|
12
14
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
15
|
/**
|
|
14
|
-
* A customizable gradient area component which uses Path.
|
|
16
|
+
* A customizable gradient area component which uses Path with SVG linearGradient.
|
|
17
|
+
*
|
|
18
|
+
* When no gradient is provided, automatically creates an appropriate gradient:
|
|
19
|
+
* - For data crossing zero: Creates a diverging gradient with peak opacity at both extremes
|
|
20
|
+
* and baseline opacity at zero (or the specified baseline).
|
|
21
|
+
* - For all-positive or all-negative data: Creates a simple gradient from baseline to peak.
|
|
15
22
|
*/
|
|
16
23
|
export const GradientArea = /*#__PURE__*/memo(_ref => {
|
|
17
24
|
let {
|
|
18
25
|
d,
|
|
19
26
|
fill = 'var(--color-fgPrimary)',
|
|
20
27
|
fillOpacity = 1,
|
|
21
|
-
peakColor,
|
|
22
|
-
baselineColor,
|
|
23
28
|
peakOpacity = 0.3,
|
|
24
29
|
baselineOpacity = 0,
|
|
25
30
|
baseline,
|
|
26
|
-
yAxisId
|
|
31
|
+
yAxisId,
|
|
32
|
+
gradient: gradientProp,
|
|
33
|
+
animate,
|
|
34
|
+
transition
|
|
27
35
|
} = _ref,
|
|
28
36
|
pathProps = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
-
const
|
|
37
|
+
const {
|
|
38
|
+
getYAxis
|
|
39
|
+
} = useCartesianChartContext();
|
|
30
40
|
const patternId = useId();
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const useUserSpaceUnits = yRange !== undefined;
|
|
39
|
-
const gradientY1 = useUserSpaceUnits ? yRange[1] : '0%';
|
|
40
|
-
const gradientY2 = useUserSpaceUnits ? yRange[0] : '100%';
|
|
41
|
-
|
|
42
|
-
// Auto-calculate baseline position based on domain
|
|
43
|
-
let baselinePosition;
|
|
44
|
-
let baselinePercentage;
|
|
45
|
-
if (yScale && yDomain) {
|
|
46
|
-
const [minValue, maxValue] = yDomain;
|
|
47
|
-
let dataBaseline;
|
|
48
|
-
if (minValue >= 0) {
|
|
49
|
-
// All positive: baseline at min
|
|
50
|
-
dataBaseline = minValue;
|
|
51
|
-
} else if (maxValue <= 0) {
|
|
52
|
-
// All negative: baseline at max
|
|
53
|
-
dataBaseline = maxValue;
|
|
54
|
-
} else {
|
|
55
|
-
// Crosses zero: baseline at 0
|
|
56
|
-
dataBaseline = 0;
|
|
57
|
-
}
|
|
58
|
-
if (useUserSpaceUnits) {
|
|
59
|
-
// Get the actual y coordinate for the baseline
|
|
60
|
-
const scaledValue = yScale(baseline !== null && baseline !== void 0 ? baseline : dataBaseline);
|
|
61
|
-
if (typeof scaledValue === 'number') {
|
|
62
|
-
baselinePosition = scaledValue;
|
|
63
|
-
}
|
|
64
|
-
} else {
|
|
65
|
-
// Calculate percentage position
|
|
66
|
-
baselinePercentage = "".concat((maxValue - (baseline !== null && baseline !== void 0 ? baseline : dataBaseline)) / (maxValue - minValue) * 100, "%");
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const effectivePeakColor = peakColor !== null && peakColor !== void 0 ? peakColor : fill;
|
|
70
|
-
const effectiveBaselineColor = baselineColor !== null && baselineColor !== void 0 ? baselineColor : fill;
|
|
41
|
+
const yAxisConfig = getYAxis(yAxisId);
|
|
42
|
+
const gradient = useMemo(() => {
|
|
43
|
+
if (gradientProp) return gradientProp;
|
|
44
|
+
if (!yAxisConfig) return;
|
|
45
|
+
const baselineValue = getBaseline(yAxisConfig.domain, baseline);
|
|
46
|
+
return createGradient(yAxisConfig.domain, baselineValue, fill, peakOpacity, baselineOpacity);
|
|
47
|
+
}, [gradientProp, yAxisConfig, fill, baseline, peakOpacity, baselineOpacity]);
|
|
71
48
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
72
|
-
children: [/*#__PURE__*/_jsx("defs", {
|
|
73
|
-
children: /*#__PURE__*/_jsx(
|
|
74
|
-
|
|
49
|
+
children: [gradient && /*#__PURE__*/_jsx("defs", {
|
|
50
|
+
children: /*#__PURE__*/_jsx(Gradient, {
|
|
51
|
+
animate: animate,
|
|
52
|
+
gradient: gradient,
|
|
75
53
|
id: patternId,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
y1: gradientY1,
|
|
79
|
-
y2: gradientY2,
|
|
80
|
-
children: baselinePosition !== undefined || baselinePercentage !== undefined ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
81
|
-
children: [/*#__PURE__*/_jsx("stop", {
|
|
82
|
-
offset: "0%",
|
|
83
|
-
stopColor: effectivePeakColor,
|
|
84
|
-
stopOpacity: peakOpacity
|
|
85
|
-
}), /*#__PURE__*/_jsx("stop", {
|
|
86
|
-
offset: baselinePercentage !== null && baselinePercentage !== void 0 ? baselinePercentage : "".concat((baselinePosition - yRange[1]) / (yRange[0] - yRange[1]) * 100, "%"),
|
|
87
|
-
stopColor: effectiveBaselineColor,
|
|
88
|
-
stopOpacity: baselineOpacity
|
|
89
|
-
}), /*#__PURE__*/_jsx("stop", {
|
|
90
|
-
offset: "100%",
|
|
91
|
-
stopColor: effectivePeakColor,
|
|
92
|
-
stopOpacity: peakOpacity
|
|
93
|
-
})]
|
|
94
|
-
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
95
|
-
children: [/*#__PURE__*/_jsx("stop", {
|
|
96
|
-
offset: "0%",
|
|
97
|
-
stopColor: effectivePeakColor,
|
|
98
|
-
stopOpacity: peakOpacity
|
|
99
|
-
}), /*#__PURE__*/_jsx("stop", {
|
|
100
|
-
offset: "100%",
|
|
101
|
-
stopColor: effectiveBaselineColor,
|
|
102
|
-
stopOpacity: baselineOpacity
|
|
103
|
-
})]
|
|
104
|
-
})
|
|
54
|
+
transition: transition,
|
|
55
|
+
yAxisId: yAxisId
|
|
105
56
|
})
|
|
106
57
|
}), /*#__PURE__*/_jsx(Path, _objectSpread({
|
|
58
|
+
animate: animate,
|
|
107
59
|
d: d,
|
|
108
|
-
fill: "url(#".concat(patternId, ")")
|
|
60
|
+
fill: gradient ? "url(#".concat(patternId, ")") : fill,
|
|
61
|
+
fillOpacity: fillOpacity,
|
|
62
|
+
transition: transition
|
|
109
63
|
}, pathProps))]
|
|
110
64
|
});
|
|
111
65
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "animate", "transition", "gradient"];
|
|
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,24 +6,42 @@ 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, useId } from 'react';
|
|
10
|
+
import { Gradient } from '../gradient';
|
|
10
11
|
import { Path } from '../Path';
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
13
|
/**
|
|
13
14
|
* A customizable solid area component which uses Path.
|
|
15
|
+
* When a gradient is provided, renders with gradient fill.
|
|
16
|
+
* Otherwise, renders with solid fill.
|
|
14
17
|
*/
|
|
15
18
|
export const SolidArea = /*#__PURE__*/memo(_ref => {
|
|
16
19
|
let {
|
|
17
20
|
d,
|
|
18
|
-
fill,
|
|
21
|
+
fill = 'var(--color-fgPrimary)',
|
|
19
22
|
fillOpacity = 1,
|
|
20
23
|
yAxisId,
|
|
21
|
-
|
|
24
|
+
animate,
|
|
25
|
+
transition,
|
|
26
|
+
gradient
|
|
22
27
|
} = _ref,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
pathProps = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
const patternId = useId();
|
|
30
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
31
|
+
children: [gradient && /*#__PURE__*/_jsx("defs", {
|
|
32
|
+
children: /*#__PURE__*/_jsx(Gradient, {
|
|
33
|
+
animate: animate,
|
|
34
|
+
gradient: gradient,
|
|
35
|
+
id: patternId,
|
|
36
|
+
transition: transition,
|
|
37
|
+
yAxisId: yAxisId
|
|
38
|
+
})
|
|
39
|
+
}), /*#__PURE__*/_jsx(Path, _objectSpread({
|
|
40
|
+
animate: animate,
|
|
41
|
+
d: d,
|
|
42
|
+
fill: gradient ? "url(#".concat(patternId, ")") : fill,
|
|
43
|
+
fillOpacity: fillOpacity,
|
|
44
|
+
transition: transition
|
|
45
|
+
}, pathProps))]
|
|
46
|
+
});
|
|
29
47
|
});
|
package/esm/chart/axis/Axis.js
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
|
+
import { accessoryFadeTransitionDuration } from '../utils';
|
|
1
2
|
export const axisLineStyles = "\n stroke: var(--color-fg);\n stroke-linecap: square;\n stroke-width: 1px;\n";
|
|
2
3
|
export const axisTickMarkStyles = "\n stroke: var(--color-fg);\n stroke-linecap: square;\n stroke-width: 1px;\n";
|
|
3
4
|
|
|
4
|
-
/**
|
|
5
|
-
* Animation variants for grouped axis tick labels - initial mount
|
|
6
|
-
*/
|
|
7
|
-
export const axisTickLabelsInitialAnimationVariants = {
|
|
8
|
-
initial: {
|
|
9
|
-
opacity: 0
|
|
10
|
-
},
|
|
11
|
-
animate: {
|
|
12
|
-
opacity: 1,
|
|
13
|
-
transition: {
|
|
14
|
-
duration: 0.15,
|
|
15
|
-
delay: 0.85 // Initial animation: wait 850ms then fade in over 150ms
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
exit: {
|
|
19
|
-
opacity: 0,
|
|
20
|
-
transition: {
|
|
21
|
-
duration: 0.15
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
5
|
/**
|
|
27
6
|
* Animation variants for axis elements - updates (used for both grid lines and tick labels)
|
|
28
7
|
*/
|
|
@@ -33,14 +12,14 @@ export const axisUpdateAnimationVariants = {
|
|
|
33
12
|
animate: {
|
|
34
13
|
opacity: 1,
|
|
35
14
|
transition: {
|
|
36
|
-
duration:
|
|
37
|
-
delay:
|
|
15
|
+
duration: accessoryFadeTransitionDuration,
|
|
16
|
+
delay: accessoryFadeTransitionDuration
|
|
38
17
|
}
|
|
39
18
|
},
|
|
40
19
|
exit: {
|
|
41
20
|
opacity: 0,
|
|
42
21
|
transition: {
|
|
43
|
-
duration:
|
|
22
|
+
duration: accessoryFadeTransitionDuration
|
|
44
23
|
}
|
|
45
24
|
}
|
|
46
25
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
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; }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
5
|
+
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); }
|
|
6
|
+
import { memo } from 'react';
|
|
7
|
+
import { ChartText } from '../text';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* DefaultAxisTickLabel is the default label component for axis tick labels.
|
|
11
|
+
* Provides standard styling for both X and Y axis tick labels.
|
|
12
|
+
*/
|
|
13
|
+
export const DefaultAxisTickLabel = /*#__PURE__*/memo(props => {
|
|
14
|
+
return /*#__PURE__*/_jsx(ChartText, _objectSpread({}, props));
|
|
15
|
+
});
|
package/esm/chart/axis/XAxis.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "style", "className", "styles", "classNames", "GridLineComponent", "
|
|
1
|
+
const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "style", "className", "styles", "classNames", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep", "label", "labelGap", "height"];
|
|
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; }
|
|
@@ -12,10 +12,15 @@ import { AnimatePresence, m as motion } from 'framer-motion';
|
|
|
12
12
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
13
13
|
import { DottedLine } from '../line/DottedLine';
|
|
14
14
|
import { ReferenceLine } from '../line/ReferenceLine';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
15
|
+
import { SolidLine } from '../line/SolidLine';
|
|
16
|
+
import { ChartText } from '../text/ChartText';
|
|
17
|
+
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
18
|
+
import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
|
|
19
|
+
import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
|
|
20
|
+
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
18
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
const AXIS_HEIGHT = 32;
|
|
23
|
+
const LABEL_SIZE = 20;
|
|
19
24
|
const axisTickMarkCss = "cds-axisTickMarkCss-a6j4s2q";
|
|
20
25
|
const axisLineCss = "cds-axisLineCss-a12llxjj";
|
|
21
26
|
export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
@@ -25,20 +30,25 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
25
30
|
requestedTickCount,
|
|
26
31
|
ticks,
|
|
27
32
|
tickLabelFormatter,
|
|
33
|
+
TickLabelComponent = DefaultAxisTickLabel,
|
|
28
34
|
style,
|
|
29
35
|
className,
|
|
30
36
|
styles,
|
|
31
37
|
classNames,
|
|
32
38
|
GridLineComponent = DottedLine,
|
|
39
|
+
LineComponent = SolidLine,
|
|
40
|
+
TickMarkLineComponent = SolidLine,
|
|
33
41
|
tickMarkLabelGap = 2,
|
|
34
|
-
height = 32,
|
|
35
42
|
minTickLabelGap = 4,
|
|
36
43
|
showTickMarks,
|
|
37
44
|
showLine,
|
|
38
45
|
tickMarkSize = 4,
|
|
39
46
|
tickInterval = 32,
|
|
40
47
|
tickMinStep = 1,
|
|
41
|
-
tickMaxStep
|
|
48
|
+
tickMaxStep,
|
|
49
|
+
label,
|
|
50
|
+
labelGap = 4,
|
|
51
|
+
height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT
|
|
42
52
|
} = _ref,
|
|
43
53
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
44
54
|
const registrationId = useId();
|
|
@@ -114,9 +124,10 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
114
124
|
if (!axisBounds) return null;
|
|
115
125
|
return ticksData.map(tick => {
|
|
116
126
|
const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
|
|
117
|
-
const availableSpace =
|
|
127
|
+
const availableSpace = AXIS_HEIGHT - tickOffset;
|
|
118
128
|
const labelOffset = availableSpace / 2;
|
|
119
|
-
const
|
|
129
|
+
const baseY = position === 'top' && label ? axisBounds.y + LABEL_SIZE : axisBounds.y;
|
|
130
|
+
const labelY = position === 'top' ? baseY + labelOffset - tickOffset : baseY + labelOffset + tickOffset;
|
|
120
131
|
return {
|
|
121
132
|
x: tick.position,
|
|
122
133
|
y: labelY,
|
|
@@ -130,8 +141,10 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
130
141
|
}
|
|
131
142
|
};
|
|
132
143
|
});
|
|
133
|
-
}, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel, styles === null || styles === void 0 ? void 0 : styles.tickLabel]);
|
|
134
|
-
if (!xScale) return;
|
|
144
|
+
}, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel, styles === null || styles === void 0 ? void 0 : styles.tickLabel, label]);
|
|
145
|
+
if (!xScale || !axisBounds) return;
|
|
146
|
+
const labelX = axisBounds.x + axisBounds.width / 2;
|
|
147
|
+
const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
|
|
135
148
|
return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
|
|
136
149
|
className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
137
150
|
"data-axis": "x",
|
|
@@ -155,40 +168,44 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
155
168
|
children: verticalLine
|
|
156
169
|
}, "grid-".concat(tick.tick, "-").concat(index));
|
|
157
170
|
})
|
|
158
|
-
}), chartTextData && /*#__PURE__*/_jsx(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
variants: animate ? axisTickLabelsInitialAnimationVariants : undefined,
|
|
164
|
-
children: /*#__PURE__*/_jsx(SmartChartTextGroup, {
|
|
165
|
-
prioritizeEndLabels: true,
|
|
166
|
-
labels: chartTextData,
|
|
167
|
-
minGap: minTickLabelGap
|
|
168
|
-
})
|
|
169
|
-
})
|
|
171
|
+
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
172
|
+
prioritizeEndLabels: true,
|
|
173
|
+
LabelComponent: TickLabelComponent,
|
|
174
|
+
labels: chartTextData,
|
|
175
|
+
minGap: minTickLabelGap
|
|
170
176
|
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx("g", {
|
|
171
177
|
"data-testid": "tick-marks",
|
|
172
178
|
children: ticksData.map((tick, index) => {
|
|
173
179
|
const tickY = position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height;
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
const tickY2 = position === 'bottom' ? tickY + tickMarkSize : tickY - tickMarkSize;
|
|
181
|
+
return /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
182
|
+
animate: false,
|
|
177
183
|
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
clipRect: null,
|
|
185
|
+
d: lineToPath(tick.position, tickY2, tick.position, tickY),
|
|
186
|
+
stroke: "var(--color-fg)",
|
|
187
|
+
strokeLinecap: "square",
|
|
188
|
+
strokeWidth: 1,
|
|
189
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark
|
|
183
190
|
}, "tick-mark-".concat(tick.tick, "-").concat(index));
|
|
184
191
|
})
|
|
185
|
-
}),
|
|
192
|
+
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
193
|
+
animate: false,
|
|
186
194
|
className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
195
|
+
d: lineToPath(axisBounds.x, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height, axisBounds.x + axisBounds.width, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height),
|
|
196
|
+
stroke: "var(--color-fg)",
|
|
197
|
+
strokeLinecap: "square",
|
|
198
|
+
strokeWidth: 1,
|
|
199
|
+
style: styles === null || styles === void 0 ? void 0 : styles.line
|
|
200
|
+
}), label && /*#__PURE__*/_jsx(ChartText, {
|
|
201
|
+
disableRepositioning: true,
|
|
202
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
|
|
203
|
+
horizontalAlignment: "center",
|
|
204
|
+
style: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
205
|
+
verticalAlignment: "middle",
|
|
206
|
+
x: labelX,
|
|
207
|
+
y: labelY,
|
|
208
|
+
children: label
|
|
192
209
|
})]
|
|
193
210
|
}));
|
|
194
211
|
});
|
package/esm/chart/axis/YAxis.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "style", "className", "styles", "classNames", "GridLineComponent", "
|
|
1
|
+
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "TickLabelComponent", "style", "className", "styles", "classNames", "GridLineComponent", "LineComponent", "TickMarkLineComponent", "tickMarkLabelGap", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "label", "labelGap", "width"];
|
|
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; }
|
|
@@ -12,10 +12,15 @@ import { AnimatePresence, m as motion } from 'framer-motion';
|
|
|
12
12
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
13
13
|
import { DottedLine } from '../line/DottedLine';
|
|
14
14
|
import { ReferenceLine } from '../line/ReferenceLine';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
15
|
+
import { SolidLine } from '../line/SolidLine';
|
|
16
|
+
import { ChartText } from '../text/ChartText';
|
|
17
|
+
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
18
|
+
import { getAxisTicksData, isCategoricalScale, lineToPath } from '../utils';
|
|
19
|
+
import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
|
|
20
|
+
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
18
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
const AXIS_WIDTH = 44;
|
|
23
|
+
const LABEL_SIZE = 20;
|
|
19
24
|
const axisTickMarkCss = "cds-axisTickMarkCss-au2toz5";
|
|
20
25
|
const axisLineCss = "cds-axisLineCss-akmofp5";
|
|
21
26
|
export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
@@ -26,18 +31,23 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
26
31
|
requestedTickCount,
|
|
27
32
|
ticks,
|
|
28
33
|
tickLabelFormatter,
|
|
34
|
+
TickLabelComponent = DefaultAxisTickLabel,
|
|
29
35
|
style,
|
|
30
36
|
className,
|
|
31
37
|
styles,
|
|
32
38
|
classNames,
|
|
33
39
|
GridLineComponent = DottedLine,
|
|
40
|
+
LineComponent = SolidLine,
|
|
41
|
+
TickMarkLineComponent = SolidLine,
|
|
34
42
|
tickMarkLabelGap = 8,
|
|
35
|
-
width = 44,
|
|
36
43
|
minTickLabelGap = 0,
|
|
37
44
|
showTickMarks,
|
|
38
45
|
showLine,
|
|
39
46
|
tickMarkSize = 4,
|
|
40
|
-
tickInterval
|
|
47
|
+
tickInterval,
|
|
48
|
+
label,
|
|
49
|
+
labelGap = 4,
|
|
50
|
+
width = label ? AXIS_WIDTH + LABEL_SIZE : AXIS_WIDTH
|
|
41
51
|
} = _ref,
|
|
42
52
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
53
|
const registrationId = useId();
|
|
@@ -118,7 +128,9 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
118
128
|
};
|
|
119
129
|
});
|
|
120
130
|
}, [axisBounds, ticksData, tickMarkLabelGap, showTickMarks, tickMarkSize, position, formatTick, classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel, styles === null || styles === void 0 ? void 0 : styles.tickLabel]);
|
|
121
|
-
if (!yScale) return;
|
|
131
|
+
if (!yScale || !axisBounds) return;
|
|
132
|
+
const labelX = position === 'left' ? axisBounds.x + LABEL_SIZE / 2 : axisBounds.x + axisBounds.width - LABEL_SIZE / 2;
|
|
133
|
+
const labelY = axisBounds.y + axisBounds.height / 2;
|
|
122
134
|
return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
|
|
123
135
|
className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
124
136
|
"data-axis": "y",
|
|
@@ -143,40 +155,51 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
143
155
|
children: horizontalLine
|
|
144
156
|
}, "grid-".concat(tick.tick, "-").concat(index));
|
|
145
157
|
})
|
|
146
|
-
}), chartTextData && /*#__PURE__*/_jsx(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
children: /*#__PURE__*/_jsx(SmartChartTextGroup, {
|
|
153
|
-
prioritizeEndLabels: true,
|
|
154
|
-
labels: chartTextData,
|
|
155
|
-
minGap: minTickLabelGap
|
|
156
|
-
})
|
|
157
|
-
})
|
|
158
|
-
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx("g", {
|
|
158
|
+
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
159
|
+
prioritizeEndLabels: true,
|
|
160
|
+
LabelComponent: TickLabelComponent,
|
|
161
|
+
labels: chartTextData,
|
|
162
|
+
minGap: minTickLabelGap
|
|
163
|
+
}), showTickMarks && /*#__PURE__*/_jsx("g", {
|
|
159
164
|
"data-testid": "tick-marks",
|
|
160
165
|
children: ticksData.map((tick, index) => {
|
|
161
166
|
const tickX = position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x;
|
|
162
167
|
const tickMarkSizePixels = tickMarkSize;
|
|
163
168
|
const tickX2 = position === 'left' ? axisBounds.x + axisBounds.width - tickMarkSizePixels : axisBounds.x + tickMarkSizePixels;
|
|
164
|
-
return /*#__PURE__*/_jsx(
|
|
169
|
+
return /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
170
|
+
animate: false,
|
|
165
171
|
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
clipRect: null,
|
|
173
|
+
d: lineToPath(tickX, tick.position, tickX2, tick.position),
|
|
174
|
+
stroke: "var(--color-fg)",
|
|
175
|
+
strokeLinecap: "square",
|
|
176
|
+
strokeWidth: 1,
|
|
177
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark
|
|
171
178
|
}, "tick-mark-".concat(tick.tick, "-").concat(index));
|
|
172
179
|
})
|
|
173
|
-
}),
|
|
180
|
+
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
181
|
+
animate: false,
|
|
174
182
|
className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
d: lineToPath(position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y, position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y + axisBounds.height),
|
|
184
|
+
stroke: "var(--color-fg)",
|
|
185
|
+
strokeLinecap: "square",
|
|
186
|
+
strokeWidth: 1,
|
|
187
|
+
style: styles === null || styles === void 0 ? void 0 : styles.line
|
|
188
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
189
|
+
style: {
|
|
190
|
+
transformOrigin: "".concat(labelX, "px ").concat(labelY, "px"),
|
|
191
|
+
transform: "rotate(".concat(position === 'left' ? -90 : 90, "deg)")
|
|
192
|
+
},
|
|
193
|
+
children: /*#__PURE__*/_jsx(ChartText, {
|
|
194
|
+
disableRepositioning: true,
|
|
195
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
|
|
196
|
+
horizontalAlignment: "center",
|
|
197
|
+
style: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
198
|
+
verticalAlignment: "middle",
|
|
199
|
+
x: labelX,
|
|
200
|
+
y: labelY,
|
|
201
|
+
children: label
|
|
202
|
+
})
|
|
180
203
|
})]
|
|
181
204
|
}));
|
|
182
205
|
});
|
package/esm/chart/axis/index.js
CHANGED
package/esm/chart/bar/Bar.js
CHANGED
|
@@ -30,7 +30,8 @@ export const Bar = /*#__PURE__*/memo(_ref => {
|
|
|
30
30
|
strokeWidth,
|
|
31
31
|
borderRadius = 4,
|
|
32
32
|
roundTop = true,
|
|
33
|
-
roundBottom = true
|
|
33
|
+
roundBottom = true,
|
|
34
|
+
transition
|
|
34
35
|
} = _ref;
|
|
35
36
|
const barPath = useMemo(() => {
|
|
36
37
|
return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
|
|
@@ -52,6 +53,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
|
|
|
52
53
|
roundTop: roundTop,
|
|
53
54
|
stroke: stroke,
|
|
54
55
|
strokeWidth: strokeWidth,
|
|
56
|
+
transition: transition,
|
|
55
57
|
width: width,
|
|
56
58
|
x: x,
|
|
57
59
|
y: y
|