@coinbase/cds-web-visualization 3.3.2 → 3.4.0-beta.10
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 +50 -2
- package/dts/chart/CartesianChart.d.ts +72 -0
- package/dts/chart/CartesianChart.d.ts.map +1 -0
- package/dts/chart/ChartProvider.d.ts +6 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -0
- package/dts/chart/Path.d.ts +54 -0
- package/dts/chart/Path.d.ts.map +1 -0
- package/dts/chart/PeriodSelector.d.ts +57 -0
- package/dts/chart/PeriodSelector.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +78 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +79 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +45 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +39 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +23 -0
- package/dts/chart/area/SolidArea.d.ts.map +1 -0
- package/dts/chart/area/index.d.ts +6 -0
- package/dts/chart/area/index.d.ts.map +1 -0
- package/dts/chart/axis/Axis.d.ts +255 -0
- package/dts/chart/axis/Axis.d.ts.map +1 -0
- 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 +16 -0
- package/dts/chart/axis/XAxis.d.ts.map +1 -0
- package/dts/chart/axis/YAxis.d.ts +21 -0
- package/dts/chart/axis/YAxis.d.ts.map +1 -0
- package/dts/chart/axis/index.d.ts +5 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +94 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +62 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +30 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +103 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +36 -0
- package/dts/chart/bar/BarStackGroup.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBar.d.ts +17 -0
- package/dts/chart/bar/DefaultBar.d.ts.map +1 -0
- package/dts/chart/bar/DefaultBarStack.d.ts +16 -0
- package/dts/chart/bar/DefaultBarStack.d.ts.map +1 -0
- package/dts/chart/bar/index.d.ts +8 -0
- package/dts/chart/bar/index.d.ts.map +1 -0
- 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 +14 -0
- package/dts/chart/index.d.ts.map +1 -0
- 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 +26 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +122 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +77 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +178 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +25 -0
- package/dts/chart/line/SolidLine.d.ts.map +1 -0
- package/dts/chart/line/index.d.ts +7 -0
- package/dts/chart/line/index.d.ts.map +1 -0
- 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 +290 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- 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/ScrubberProvider.d.ts +17 -0
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +1 -0
- package/dts/chart/scrubber/index.d.ts +5 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +117 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/ChartTextGroup.d.ts +61 -0
- package/dts/chart/text/ChartTextGroup.d.ts.map +1 -0
- package/dts/chart/text/index.d.ts +3 -0
- package/dts/chart/text/index.d.ts.map +1 -0
- package/dts/chart/utils/axis.d.ts +342 -0
- package/dts/chart/utils/axis.d.ts.map +1 -0
- package/dts/chart/utils/bar.d.ts +20 -0
- package/dts/chart/utils/bar.d.ts.map +1 -0
- package/dts/chart/utils/chart.d.ts +117 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +101 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- 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 +12 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- 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 +130 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +104 -0
- package/dts/chart/utils/point.d.ts.map +1 -0
- package/dts/chart/utils/scale.d.ts +43 -0
- package/dts/chart/utils/scale.d.ts.map +1 -0
- 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/dts/index.d.ts +1 -0
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/Sparkline.d.ts +44 -9
- package/dts/sparkline/Sparkline.d.ts.map +1 -1
- package/dts/sparkline/SparklineArea.d.ts +4 -0
- package/dts/sparkline/SparklineArea.d.ts.map +1 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +5 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -1
- package/dts/sparkline/SparklineGradient.d.ts +5 -0
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +1 -0
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +9 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +3 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +2 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -1
- package/esm/chart/CartesianChart.css +1 -0
- package/esm/chart/CartesianChart.js +313 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +95 -0
- package/esm/chart/PeriodSelector.css +1 -0
- package/esm/chart/PeriodSelector.js +112 -0
- package/esm/chart/area/Area.js +75 -0
- package/esm/chart/area/AreaChart.js +173 -0
- package/esm/chart/area/DottedArea.js +87 -0
- package/esm/chart/area/GradientArea.js +65 -0
- package/esm/chart/area/SolidArea.js +47 -0
- package/esm/chart/area/index.js +7 -0
- package/esm/chart/axis/Axis.js +25 -0
- package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
- package/esm/chart/axis/XAxis.css +2 -0
- package/esm/chart/axis/XAxis.js +219 -0
- package/esm/chart/axis/YAxis.css +2 -0
- package/esm/chart/axis/YAxis.js +214 -0
- package/esm/chart/axis/index.js +6 -0
- package/esm/chart/bar/Bar.js +61 -0
- package/esm/chart/bar/BarChart.js +130 -0
- package/esm/chart/bar/BarPlot.js +97 -0
- package/esm/chart/bar/BarStack.js +561 -0
- package/esm/chart/bar/BarStackGroup.js +86 -0
- package/esm/chart/bar/DefaultBar.js +61 -0
- package/esm/chart/bar/DefaultBarStack.js +58 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/gradient/Gradient.js +104 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +15 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
- package/esm/chart/line/DottedLine.js +59 -0
- package/esm/chart/line/Line.js +185 -0
- package/esm/chart/line/LineChart.js +132 -0
- package/esm/chart/line/ReferenceLine.js +140 -0
- package/esm/chart/line/SolidLine.js +55 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/point/DefaultPointLabel.js +44 -0
- package/esm/chart/point/Point.css +2 -0
- package/esm/chart/point/Point.js +180 -0
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +155 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +46 -0
- package/esm/chart/scrubber/DefaultScrubberLabel.js +30 -0
- package/esm/chart/scrubber/Scrubber.js +189 -0
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +166 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +186 -0
- package/esm/chart/scrubber/ScrubberProvider.js +228 -0
- package/esm/chart/scrubber/index.js +4 -0
- package/esm/chart/text/ChartText.js +230 -0
- package/esm/chart/text/ChartTextGroup.js +227 -0
- package/esm/chart/text/index.js +4 -0
- package/esm/chart/utils/axis.js +593 -0
- package/esm/chart/utils/bar.js +24 -0
- package/esm/chart/utils/chart.js +255 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/gradient.js +257 -0
- package/esm/chart/utils/index.js +13 -0
- package/esm/chart/utils/interpolate.js +644 -0
- package/esm/chart/utils/path.js +227 -0
- package/esm/chart/utils/point.js +187 -0
- package/esm/chart/utils/scale.js +48 -0
- package/esm/chart/utils/scrubber.js +132 -0
- package/esm/chart/utils/transition.js +111 -0
- package/esm/index.js +4 -1
- package/esm/sparkline/Sparkline.js +129 -15
- package/esm/sparkline/SparklineArea.js +7 -2
- package/esm/sparkline/SparklineAreaPattern.js +4 -2
- package/esm/sparkline/SparklineGradient.js +16 -58
- package/esm/sparkline/generateSparklineWithId.js +3 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +5 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +5 -2
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +1 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +4 -0
- package/package.json +13 -9
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const _excluded = ["x", "width", "borderRadius", "roundTop", "roundBottom", "originY", "d", "fill", "fillOpacity", "dataX", "dataY", "transition"];
|
|
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
|
+
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
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
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
|
+
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
|
+
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 React, { memo, useMemo } from 'react';
|
|
10
|
+
import { m as motion } from 'framer-motion';
|
|
11
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
12
|
+
import { getBarPath } from '../utils';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
* Default bar component that renders a solid bar with animation.
|
|
16
|
+
*/
|
|
17
|
+
export const DefaultBar = /*#__PURE__*/memo(_ref => {
|
|
18
|
+
let {
|
|
19
|
+
x,
|
|
20
|
+
width,
|
|
21
|
+
borderRadius = 4,
|
|
22
|
+
roundTop,
|
|
23
|
+
roundBottom,
|
|
24
|
+
originY,
|
|
25
|
+
d,
|
|
26
|
+
fill = 'var(--color-fgPrimary)',
|
|
27
|
+
fillOpacity = 1,
|
|
28
|
+
dataX,
|
|
29
|
+
dataY,
|
|
30
|
+
transition
|
|
31
|
+
} = _ref,
|
|
32
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
+
const {
|
|
34
|
+
animate
|
|
35
|
+
} = useCartesianChartContext();
|
|
36
|
+
const initialPath = useMemo(() => {
|
|
37
|
+
if (!animate) return undefined;
|
|
38
|
+
// Need a minimum height to allow for animation
|
|
39
|
+
const minHeight = 1;
|
|
40
|
+
const initialY = (originY !== null && originY !== void 0 ? originY : 0) - minHeight;
|
|
41
|
+
return getBarPath(x, initialY, width, minHeight, borderRadius, !!roundTop, !!roundBottom);
|
|
42
|
+
}, [animate, x, originY, width, borderRadius, roundTop, roundBottom]);
|
|
43
|
+
if (animate && initialPath) {
|
|
44
|
+
return /*#__PURE__*/_jsx(motion.path, _objectSpread(_objectSpread({}, props), {}, {
|
|
45
|
+
animate: {
|
|
46
|
+
d
|
|
47
|
+
},
|
|
48
|
+
fill: fill,
|
|
49
|
+
fillOpacity: fillOpacity,
|
|
50
|
+
initial: {
|
|
51
|
+
d: initialPath
|
|
52
|
+
},
|
|
53
|
+
transition: transition
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
return /*#__PURE__*/_jsx("path", _objectSpread(_objectSpread({}, props), {}, {
|
|
57
|
+
d: d,
|
|
58
|
+
fill: fill,
|
|
59
|
+
fillOpacity: fillOpacity
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { memo, useId, useMemo } from 'react';
|
|
2
|
+
import { m as motion } from 'framer-motion';
|
|
3
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
4
|
+
import { getBarPath } from '../utils';
|
|
5
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
/**
|
|
7
|
+
* Default stack component that renders children in a group with animated clip path.
|
|
8
|
+
*/
|
|
9
|
+
export const DefaultBarStack = /*#__PURE__*/memo(_ref => {
|
|
10
|
+
let {
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
style,
|
|
14
|
+
width,
|
|
15
|
+
height,
|
|
16
|
+
x,
|
|
17
|
+
y,
|
|
18
|
+
borderRadius = 4,
|
|
19
|
+
roundTop = true,
|
|
20
|
+
roundBottom = true,
|
|
21
|
+
yOrigin,
|
|
22
|
+
transition
|
|
23
|
+
} = _ref;
|
|
24
|
+
const {
|
|
25
|
+
animate
|
|
26
|
+
} = useCartesianChartContext();
|
|
27
|
+
const clipPathId = useId();
|
|
28
|
+
const clipPathData = useMemo(() => {
|
|
29
|
+
return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
|
|
30
|
+
}, [x, y, width, height, borderRadius, roundTop, roundBottom]);
|
|
31
|
+
const initialClipPathData = useMemo(() => {
|
|
32
|
+
if (!animate) return undefined;
|
|
33
|
+
return getBarPath(x, yOrigin !== null && yOrigin !== void 0 ? yOrigin : y + height, width, 1, borderRadius, roundTop, roundBottom);
|
|
34
|
+
}, [animate, x, yOrigin, y, height, width, borderRadius, roundTop, roundBottom]);
|
|
35
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
36
|
+
children: [/*#__PURE__*/_jsx("defs", {
|
|
37
|
+
children: /*#__PURE__*/_jsx("clipPath", {
|
|
38
|
+
id: clipPathId,
|
|
39
|
+
children: animate ? /*#__PURE__*/_jsx(motion.path, {
|
|
40
|
+
animate: {
|
|
41
|
+
d: clipPathData
|
|
42
|
+
},
|
|
43
|
+
initial: {
|
|
44
|
+
d: initialClipPathData
|
|
45
|
+
},
|
|
46
|
+
transition: transition
|
|
47
|
+
}) : /*#__PURE__*/_jsx("path", {
|
|
48
|
+
d: clipPathData
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
}), /*#__PURE__*/_jsx("g", {
|
|
52
|
+
className: className,
|
|
53
|
+
clipPath: "url(#".concat(clipPathId, ")"),
|
|
54
|
+
style: style,
|
|
55
|
+
children: children
|
|
56
|
+
})]
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// codegen:start {preset: barrel, include: ./*.tsx, exclude: ./__stories__/*.tsx}
|
|
2
|
+
export * from './Bar';
|
|
3
|
+
export * from './BarChart';
|
|
4
|
+
export * from './BarPlot';
|
|
5
|
+
export * from './BarStack';
|
|
6
|
+
export * from './BarStackGroup';
|
|
7
|
+
export * from './DefaultBar';
|
|
8
|
+
export * from './DefaultBarStack';
|
|
9
|
+
// codegen:end
|
|
@@ -0,0 +1,104 @@
|
|
|
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, useMemo } from 'react';
|
|
7
|
+
import { m as motion } from 'framer-motion';
|
|
8
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
9
|
+
import { getGradientConfig } from '../utils/gradient';
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
/**
|
|
12
|
+
* Renders an SVG linearGradient element based on a GradientDefinition.
|
|
13
|
+
* The gradient can be referenced via `fill="url(#${id})"` or `stroke="url(#${id})"`.
|
|
14
|
+
*/
|
|
15
|
+
export const Gradient = /*#__PURE__*/memo(_ref => {
|
|
16
|
+
var _gradient$axis;
|
|
17
|
+
let {
|
|
18
|
+
id,
|
|
19
|
+
gradient,
|
|
20
|
+
yAxisId,
|
|
21
|
+
animate: animateProp,
|
|
22
|
+
transition
|
|
23
|
+
} = _ref;
|
|
24
|
+
const context = useCartesianChartContext();
|
|
25
|
+
const animate = animateProp !== null && animateProp !== void 0 ? animateProp : context.animate;
|
|
26
|
+
const xScale = context.getXScale();
|
|
27
|
+
const yScale = context.getYScale(yAxisId);
|
|
28
|
+
|
|
29
|
+
// Process gradient definition into stops
|
|
30
|
+
const stops = useMemo(() => {
|
|
31
|
+
if (!xScale || !yScale) return;
|
|
32
|
+
return getGradientConfig(gradient, xScale, yScale);
|
|
33
|
+
}, [gradient, xScale, yScale]);
|
|
34
|
+
const drawingArea = context.drawingArea;
|
|
35
|
+
const yAxis = context.getYAxis(yAxisId);
|
|
36
|
+
const xAxis = context.getXAxis();
|
|
37
|
+
|
|
38
|
+
// If gradient processing failed, don't render
|
|
39
|
+
if (!stops) return null;
|
|
40
|
+
const axis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
|
|
41
|
+
let coordinates;
|
|
42
|
+
if (axis === 'y') {
|
|
43
|
+
const yRange = yAxis === null || yAxis === void 0 ? void 0 : yAxis.range;
|
|
44
|
+
if (yRange) {
|
|
45
|
+
coordinates = {
|
|
46
|
+
x1: drawingArea.x,
|
|
47
|
+
y1: yRange.max,
|
|
48
|
+
x2: drawingArea.x,
|
|
49
|
+
y2: yRange.min
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
coordinates = {
|
|
53
|
+
x1: drawingArea.x,
|
|
54
|
+
y1: drawingArea.y + drawingArea.height,
|
|
55
|
+
x2: drawingArea.x,
|
|
56
|
+
y2: drawingArea.y
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
const xRange = xAxis === null || xAxis === void 0 ? void 0 : xAxis.range;
|
|
61
|
+
if (xRange) {
|
|
62
|
+
coordinates = {
|
|
63
|
+
x1: xRange.min,
|
|
64
|
+
y1: drawingArea.y,
|
|
65
|
+
x2: xRange.max,
|
|
66
|
+
y2: drawingArea.y
|
|
67
|
+
};
|
|
68
|
+
} else {
|
|
69
|
+
coordinates = {
|
|
70
|
+
x1: drawingArea.x,
|
|
71
|
+
y1: drawingArea.y,
|
|
72
|
+
x2: drawingArea.x + drawingArea.width,
|
|
73
|
+
y2: drawingArea.y
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return /*#__PURE__*/_jsx("linearGradient", _objectSpread(_objectSpread({
|
|
78
|
+
gradientUnits: "userSpaceOnUse",
|
|
79
|
+
id: id
|
|
80
|
+
}, coordinates), {}, {
|
|
81
|
+
children: stops.map((stop, index) => {
|
|
82
|
+
const offset = "".concat(stop.offset * 100, "%");
|
|
83
|
+
const opacity = stop.opacity;
|
|
84
|
+
if (!animate) {
|
|
85
|
+
return /*#__PURE__*/_jsx("stop", {
|
|
86
|
+
offset: offset,
|
|
87
|
+
stopColor: stop.color,
|
|
88
|
+
stopOpacity: opacity !== null && opacity !== void 0 ? opacity : 1
|
|
89
|
+
}, "".concat(id, "-stop-").concat(index));
|
|
90
|
+
}
|
|
91
|
+
return /*#__PURE__*/_jsx(motion.stop, {
|
|
92
|
+
animate: {
|
|
93
|
+
offset
|
|
94
|
+
},
|
|
95
|
+
initial: {
|
|
96
|
+
offset
|
|
97
|
+
},
|
|
98
|
+
stopColor: stop.color,
|
|
99
|
+
stopOpacity: opacity !== null && opacity !== void 0 ? opacity : 1,
|
|
100
|
+
transition: transition
|
|
101
|
+
}, "".concat(id, "-stop-").concat(index));
|
|
102
|
+
})
|
|
103
|
+
}));
|
|
104
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Gradient } from './Gradient';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// codegen:start {preset: barrel, include: [./*.tsx, ./*/index.ts]}
|
|
2
|
+
export * from './area/index';
|
|
3
|
+
export * from './axis/index';
|
|
4
|
+
export * from './bar/index';
|
|
5
|
+
export * from './CartesianChart';
|
|
6
|
+
export * from './ChartProvider';
|
|
7
|
+
export * from './gradient/index';
|
|
8
|
+
export * from './line/index';
|
|
9
|
+
export * from './Path';
|
|
10
|
+
export * from './PeriodSelector';
|
|
11
|
+
export * from './point/index';
|
|
12
|
+
export * from './scrubber/index';
|
|
13
|
+
export * from './text/index';
|
|
14
|
+
export * from './utils/index';
|
|
15
|
+
// codegen:end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const _excluded = ["color", "elevated", "borderRadius", "inset", "boundsInset", "className", "classNames", "style", "styles"];
|
|
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
|
+
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
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
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
|
+
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
|
+
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, useMemo } from 'react';
|
|
10
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
11
|
+
import { ChartText } from '../text';
|
|
12
|
+
import { getChartInset } from '../utils';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
const elevatedInset = {
|
|
15
|
+
top: 8,
|
|
16
|
+
bottom: 8,
|
|
17
|
+
left: 12,
|
|
18
|
+
right: 12
|
|
19
|
+
};
|
|
20
|
+
const elevatedBorderRadius = 4;
|
|
21
|
+
// Default bounds inset when elevated to prevent shadow clipping
|
|
22
|
+
const elevatedBoundsInset = {
|
|
23
|
+
top: 4,
|
|
24
|
+
bottom: 20,
|
|
25
|
+
left: 12,
|
|
26
|
+
right: 12
|
|
27
|
+
};
|
|
28
|
+
const nonElevatedBoundsInset = {
|
|
29
|
+
top: 0,
|
|
30
|
+
bottom: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
right: 0
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* DefaultReferenceLineLabel is the default label component for ReferenceLine.
|
|
37
|
+
* Provides standard styling with elevation, inset, and color defaults.
|
|
38
|
+
* When elevated, automatically adds bounds to prevent shadow cutoff at chart edges.
|
|
39
|
+
*/
|
|
40
|
+
export const DefaultReferenceLineLabel = /*#__PURE__*/memo(_ref => {
|
|
41
|
+
let {
|
|
42
|
+
color = 'var(--color-fgMuted)',
|
|
43
|
+
elevated,
|
|
44
|
+
borderRadius = elevated ? elevatedBorderRadius : undefined,
|
|
45
|
+
inset = elevated ? elevatedInset : undefined,
|
|
46
|
+
boundsInset: boundsInsetProp,
|
|
47
|
+
className,
|
|
48
|
+
classNames,
|
|
49
|
+
style,
|
|
50
|
+
styles
|
|
51
|
+
} = _ref,
|
|
52
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
53
|
+
const {
|
|
54
|
+
width: chartWidth,
|
|
55
|
+
height: chartHeight
|
|
56
|
+
} = useCartesianChartContext();
|
|
57
|
+
const bounds = useMemo(() => {
|
|
58
|
+
const boundsInset = getChartInset(boundsInsetProp, elevated ? elevatedBoundsInset : nonElevatedBoundsInset);
|
|
59
|
+
return {
|
|
60
|
+
x: boundsInset.left,
|
|
61
|
+
y: boundsInset.top,
|
|
62
|
+
width: chartWidth - boundsInset.left - boundsInset.right,
|
|
63
|
+
height: chartHeight - boundsInset.top - boundsInset.bottom
|
|
64
|
+
};
|
|
65
|
+
}, [elevated, boundsInsetProp, chartWidth, chartHeight]);
|
|
66
|
+
const mergedClassNames = useMemo(() => _objectSpread(_objectSpread({}, className && {
|
|
67
|
+
text: className
|
|
68
|
+
}), classNames), [className, classNames]);
|
|
69
|
+
const mergedStyles = useMemo(() => _objectSpread(_objectSpread({}, style && {
|
|
70
|
+
text: style
|
|
71
|
+
}), styles), [style, styles]);
|
|
72
|
+
return /*#__PURE__*/_jsx(ChartText, _objectSpread({
|
|
73
|
+
borderRadius: borderRadius,
|
|
74
|
+
bounds: bounds,
|
|
75
|
+
classNames: mergedClassNames,
|
|
76
|
+
color: color,
|
|
77
|
+
elevated: elevated,
|
|
78
|
+
inset: inset,
|
|
79
|
+
styles: mergedStyles
|
|
80
|
+
}, props));
|
|
81
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const _excluded = ["fill", "stroke", "strokeDasharray", "strokeLinecap", "strokeLinejoin", "strokeOpacity", "strokeWidth", "vectorEffect", "gradient", "yAxisId", "animate", "transition", "d"];
|
|
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
|
+
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
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
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
|
+
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
|
+
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';
|
|
10
|
+
import { Gradient } from '../gradient';
|
|
11
|
+
import { Path } from '../Path';
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
/**
|
|
14
|
+
* A customizable dotted line component.
|
|
15
|
+
* Supports gradient for gradient effects on the dots.
|
|
16
|
+
*/
|
|
17
|
+
export const DottedLine = /*#__PURE__*/memo(_ref => {
|
|
18
|
+
let {
|
|
19
|
+
fill = 'none',
|
|
20
|
+
stroke = 'var(--color-fgPrimary)',
|
|
21
|
+
strokeDasharray = '0 4',
|
|
22
|
+
strokeLinecap = 'round',
|
|
23
|
+
strokeLinejoin = 'round',
|
|
24
|
+
strokeOpacity = 1,
|
|
25
|
+
strokeWidth = 2,
|
|
26
|
+
vectorEffect = 'non-scaling-stroke',
|
|
27
|
+
gradient,
|
|
28
|
+
yAxisId,
|
|
29
|
+
animate,
|
|
30
|
+
transition,
|
|
31
|
+
d
|
|
32
|
+
} = _ref,
|
|
33
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
+
const gradientId = useId();
|
|
35
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
36
|
+
children: [gradient && /*#__PURE__*/_jsx("defs", {
|
|
37
|
+
children: /*#__PURE__*/_jsx(Gradient, {
|
|
38
|
+
animate: animate,
|
|
39
|
+
gradient: gradient,
|
|
40
|
+
id: gradientId,
|
|
41
|
+
transition: transition,
|
|
42
|
+
yAxisId: yAxisId
|
|
43
|
+
})
|
|
44
|
+
}), /*#__PURE__*/_jsx(Path, _objectSpread({
|
|
45
|
+
animate: animate,
|
|
46
|
+
clipOffset: strokeWidth,
|
|
47
|
+
d: d,
|
|
48
|
+
fill: fill,
|
|
49
|
+
stroke: gradient ? "url(#".concat(gradientId, ")") : stroke,
|
|
50
|
+
strokeDasharray: strokeDasharray,
|
|
51
|
+
strokeLinecap: strokeLinecap,
|
|
52
|
+
strokeLinejoin: strokeLinejoin,
|
|
53
|
+
strokeOpacity: strokeOpacity,
|
|
54
|
+
strokeWidth: strokeWidth,
|
|
55
|
+
transition: transition,
|
|
56
|
+
vectorEffect: vectorEffect
|
|
57
|
+
}, props))]
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
const _excluded = ["seriesId", "curve", "type", "areaType", "areaBaseline", "stroke", "strokeOpacity", "onPointClick", "showArea", "LineComponent", "AreaComponent", "opacity", "points", "connectNulls", "transition", "gradient"];
|
|
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
|
+
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
|
+
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; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
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
|
+
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
|
+
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 React, { memo, useMemo } from 'react';
|
|
10
|
+
import { m as motion } from 'framer-motion';
|
|
11
|
+
import { Area } from '../area/Area';
|
|
12
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
13
|
+
import { Point } from '../point';
|
|
14
|
+
import { accessoryFadeTransitionDelay, accessoryFadeTransitionDuration, evaluateGradientAtValue, getGradientConfig, getLineData, getLinePath } from '../utils';
|
|
15
|
+
import { DottedLine } from './DottedLine';
|
|
16
|
+
import { SolidLine } from './SolidLine';
|
|
17
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
export const Line = /*#__PURE__*/memo(_ref => {
|
|
19
|
+
var _ref2;
|
|
20
|
+
let {
|
|
21
|
+
seriesId,
|
|
22
|
+
curve = 'bump',
|
|
23
|
+
type = 'solid',
|
|
24
|
+
areaType = 'gradient',
|
|
25
|
+
areaBaseline,
|
|
26
|
+
stroke: strokeProp,
|
|
27
|
+
strokeOpacity,
|
|
28
|
+
onPointClick,
|
|
29
|
+
showArea = false,
|
|
30
|
+
LineComponent: SelectedLineComponent,
|
|
31
|
+
AreaComponent,
|
|
32
|
+
opacity = 1,
|
|
33
|
+
points,
|
|
34
|
+
connectNulls,
|
|
35
|
+
transition,
|
|
36
|
+
gradient: gradientProp
|
|
37
|
+
} = _ref,
|
|
38
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
39
|
+
const {
|
|
40
|
+
animate,
|
|
41
|
+
getSeries,
|
|
42
|
+
getSeriesData,
|
|
43
|
+
getXScale,
|
|
44
|
+
getYScale,
|
|
45
|
+
getXAxis,
|
|
46
|
+
getYAxis
|
|
47
|
+
} = useCartesianChartContext();
|
|
48
|
+
const matchedSeries = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
|
|
49
|
+
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
|
+
const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
|
|
51
|
+
const xAxis = useMemo(() => getXAxis(), [getXAxis]);
|
|
52
|
+
const xScale = useMemo(() => getXScale(), [getXScale]);
|
|
53
|
+
const yScale = useMemo(() => getYScale(matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId), [getYScale, matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId]);
|
|
54
|
+
|
|
55
|
+
// Convert sourceData to number array (line only supports numbers, not tuples)
|
|
56
|
+
const chartData = useMemo(() => getLineData(sourceData), [sourceData]);
|
|
57
|
+
const path = useMemo(() => {
|
|
58
|
+
if (!xScale || !yScale || chartData.length === 0) return '';
|
|
59
|
+
|
|
60
|
+
// Get numeric x-axis data if available
|
|
61
|
+
const xData = xAxis !== null && xAxis !== void 0 && xAxis.data && Array.isArray(xAxis.data) && typeof xAxis.data[0] === 'number' ? xAxis.data : undefined;
|
|
62
|
+
return getLinePath({
|
|
63
|
+
data: chartData,
|
|
64
|
+
xScale,
|
|
65
|
+
yScale,
|
|
66
|
+
curve,
|
|
67
|
+
xData,
|
|
68
|
+
connectNulls
|
|
69
|
+
});
|
|
70
|
+
}, [chartData, xScale, yScale, curve, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, connectNulls]);
|
|
71
|
+
const LineComponent = useMemo(() => {
|
|
72
|
+
if (SelectedLineComponent) {
|
|
73
|
+
return SelectedLineComponent;
|
|
74
|
+
}
|
|
75
|
+
switch (type) {
|
|
76
|
+
case 'dotted':
|
|
77
|
+
return DottedLine;
|
|
78
|
+
default:
|
|
79
|
+
return SolidLine;
|
|
80
|
+
}
|
|
81
|
+
}, [SelectedLineComponent, type]);
|
|
82
|
+
|
|
83
|
+
// Get series color for stroke
|
|
84
|
+
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 xData = useMemo(() => {
|
|
86
|
+
const data = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
|
|
87
|
+
return data && Array.isArray(data) && data.length > 0 && typeof data[0] === 'number' ? data : null;
|
|
88
|
+
}, [xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
|
|
89
|
+
const gradientConfig = useMemo(() => {
|
|
90
|
+
if (!gradient || !xScale || !yScale) return;
|
|
91
|
+
const gradientScale = gradient.axis === 'x' ? xScale : yScale;
|
|
92
|
+
const stops = getGradientConfig(gradient, xScale, yScale);
|
|
93
|
+
if (!stops) return;
|
|
94
|
+
return {
|
|
95
|
+
scale: gradientScale,
|
|
96
|
+
stops
|
|
97
|
+
};
|
|
98
|
+
}, [gradient, xScale, yScale]);
|
|
99
|
+
if (!xScale || !yScale || !path) return;
|
|
100
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
101
|
+
children: [showArea && /*#__PURE__*/_jsx(Area, {
|
|
102
|
+
AreaComponent: AreaComponent,
|
|
103
|
+
baseline: areaBaseline,
|
|
104
|
+
connectNulls: connectNulls,
|
|
105
|
+
curve: curve,
|
|
106
|
+
fill: stroke,
|
|
107
|
+
fillOpacity: opacity,
|
|
108
|
+
gradient: gradient,
|
|
109
|
+
seriesId: seriesId,
|
|
110
|
+
transition: transition,
|
|
111
|
+
type: areaType
|
|
112
|
+
}), /*#__PURE__*/_jsx(LineComponent, _objectSpread({
|
|
113
|
+
d: path,
|
|
114
|
+
gradient: gradient,
|
|
115
|
+
stroke: stroke,
|
|
116
|
+
strokeOpacity: strokeOpacity !== null && strokeOpacity !== void 0 ? strokeOpacity : opacity,
|
|
117
|
+
transition: transition,
|
|
118
|
+
yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId
|
|
119
|
+
}, props)), points && /*#__PURE__*/_jsx(motion.g, _objectSpread(_objectSpread({
|
|
120
|
+
"data-component": "line-points-group"
|
|
121
|
+
}, animate ? {
|
|
122
|
+
animate: {
|
|
123
|
+
opacity: 1,
|
|
124
|
+
transition: {
|
|
125
|
+
duration: accessoryFadeTransitionDuration,
|
|
126
|
+
delay: accessoryFadeTransitionDelay
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
exit: {
|
|
130
|
+
opacity: 0,
|
|
131
|
+
transition: {
|
|
132
|
+
duration: accessoryFadeTransitionDuration
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
initial: {
|
|
136
|
+
opacity: 0
|
|
137
|
+
}
|
|
138
|
+
} : {}), {}, {
|
|
139
|
+
children: chartData.map((value, index) => {
|
|
140
|
+
var _pointConfig$onClick;
|
|
141
|
+
if (value === null) return;
|
|
142
|
+
const xValue = xData && xData[index] !== undefined ? xData[index] : index;
|
|
143
|
+
let pointFill = stroke;
|
|
144
|
+
if (gradientConfig && gradient) {
|
|
145
|
+
var _gradient$axis;
|
|
146
|
+
// Use the appropriate data value based on gradient axis
|
|
147
|
+
const axis = (_gradient$axis = gradient.axis) !== null && _gradient$axis !== void 0 ? _gradient$axis : 'y';
|
|
148
|
+
const dataValue = axis === 'x' ? xValue : value;
|
|
149
|
+
const evaluatedColor = evaluateGradientAtValue(gradientConfig.stops, dataValue, gradientConfig.scale);
|
|
150
|
+
if (evaluatedColor) {
|
|
151
|
+
// Apply gradient color to fill if not explicitly set
|
|
152
|
+
pointFill = evaluatedColor;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Build defaults that would be passed to Point
|
|
157
|
+
const defaults = {
|
|
158
|
+
dataX: xValue,
|
|
159
|
+
dataY: value,
|
|
160
|
+
fill: pointFill,
|
|
161
|
+
yAxisId: matchedSeries === null || matchedSeries === void 0 ? void 0 : matchedSeries.yAxisId,
|
|
162
|
+
opacity,
|
|
163
|
+
testID: undefined
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// If points is true, render with defaults
|
|
167
|
+
if (points === true) {
|
|
168
|
+
return /*#__PURE__*/_jsx(Point, _objectSpread({
|
|
169
|
+
onClick: onPointClick,
|
|
170
|
+
transition: transition
|
|
171
|
+
}, defaults), "".concat(seriesId, "-").concat(index));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Call the function with defaults
|
|
175
|
+
const result = points(defaults);
|
|
176
|
+
if (!result) return;
|
|
177
|
+
const pointConfig = result === true ? {} : result;
|
|
178
|
+
return /*#__PURE__*/_jsx(Point, _objectSpread(_objectSpread({
|
|
179
|
+
onClick: (_pointConfig$onClick = pointConfig.onClick) !== null && _pointConfig$onClick !== void 0 ? _pointConfig$onClick : onPointClick,
|
|
180
|
+
transition: transition
|
|
181
|
+
}, defaults), pointConfig), "".concat(seriesId, "-").concat(index));
|
|
182
|
+
})
|
|
183
|
+
}))]
|
|
184
|
+
});
|
|
185
|
+
});
|