@coinbase/cds-web-visualization 0.0.0 → 3.4.0-beta.1
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 +26 -0
- package/README.md +3 -0
- package/dts/chart/CartesianChart.d.ts +36 -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 +34 -0
- package/dts/chart/Path.d.ts.map +1 -0
- package/dts/chart/PeriodSelector.d.ts +61 -0
- package/dts/chart/PeriodSelector.d.ts.map +1 -0
- package/dts/chart/Point.d.ts +153 -0
- package/dts/chart/Point.d.ts.map +1 -0
- package/dts/chart/area/Area.d.ts +48 -0
- package/dts/chart/area/Area.d.ts.map +1 -0
- package/dts/chart/area/AreaChart.d.ts +52 -0
- package/dts/chart/area/AreaChart.d.ts.map +1 -0
- package/dts/chart/area/DottedArea.d.ts +68 -0
- package/dts/chart/area/DottedArea.d.ts.map +1 -0
- package/dts/chart/area/GradientArea.d.ts +30 -0
- package/dts/chart/area/GradientArea.d.ts.map +1 -0
- package/dts/chart/area/SolidArea.d.ts +8 -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 +208 -0
- package/dts/chart/axis/Axis.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 +4 -0
- package/dts/chart/axis/index.d.ts.map +1 -0
- package/dts/chart/bar/Bar.d.ts +91 -0
- package/dts/chart/bar/Bar.d.ts.map +1 -0
- package/dts/chart/bar/BarChart.d.ts +53 -0
- package/dts/chart/bar/BarChart.d.ts.map +1 -0
- package/dts/chart/bar/BarPlot.d.ts +29 -0
- package/dts/chart/bar/BarPlot.d.ts.map +1 -0
- package/dts/chart/bar/BarStack.d.ts +111 -0
- package/dts/chart/bar/BarStack.d.ts.map +1 -0
- package/dts/chart/bar/BarStackGroup.d.ts +35 -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/index.d.ts +13 -0
- package/dts/chart/index.d.ts.map +1 -0
- package/dts/chart/line/DottedLine.d.ts +14 -0
- package/dts/chart/line/DottedLine.d.ts.map +1 -0
- package/dts/chart/line/GradientLine.d.ts +42 -0
- package/dts/chart/line/GradientLine.d.ts.map +1 -0
- package/dts/chart/line/Line.d.ts +80 -0
- package/dts/chart/line/Line.d.ts.map +1 -0
- package/dts/chart/line/LineChart.d.ts +59 -0
- package/dts/chart/line/LineChart.d.ts.map +1 -0
- package/dts/chart/line/ReferenceLine.d.ts +131 -0
- package/dts/chart/line/ReferenceLine.d.ts.map +1 -0
- package/dts/chart/line/SolidLine.d.ts +14 -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/scrubber/Scrubber.d.ts +149 -0
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeacon.d.ts +93 -0
- package/dts/chart/scrubber/ScrubberBeacon.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabel.d.ts +7 -0
- package/dts/chart/scrubber/ScrubberBeaconLabel.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 +2 -0
- package/dts/chart/scrubber/index.d.ts.map +1 -0
- package/dts/chart/text/ChartText.d.ts +114 -0
- package/dts/chart/text/ChartText.d.ts.map +1 -0
- package/dts/chart/text/SmartChartTextGroup.d.ts +55 -0
- package/dts/chart/text/SmartChartTextGroup.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 +97 -0
- package/dts/chart/utils/chart.d.ts.map +1 -0
- package/dts/chart/utils/context.d.ts +95 -0
- package/dts/chart/utils/context.d.ts.map +1 -0
- package/dts/chart/utils/index.d.ts +8 -0
- package/dts/chart/utils/index.d.ts.map +1 -0
- package/dts/chart/utils/path.d.ts +107 -0
- package/dts/chart/utils/path.d.ts.map +1 -0
- package/dts/chart/utils/point.d.ts +75 -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/index.d.ts +3 -0
- package/dts/index.d.ts.map +1 -0
- package/dts/sparkline/Counter.d.ts +8 -0
- package/dts/sparkline/Counter.d.ts.map +1 -0
- package/dts/sparkline/Sparkline.d.ts +67 -0
- package/dts/sparkline/Sparkline.d.ts.map +1 -0
- package/dts/sparkline/SparklineArea.d.ts +15 -0
- package/dts/sparkline/SparklineArea.d.ts.map +1 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts +14 -0
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +1 -0
- package/dts/sparkline/SparklineGradient.d.ts +23 -0
- package/dts/sparkline/SparklineGradient.d.ts.map +1 -0
- package/dts/sparkline/SparklinePath.d.ts +12 -0
- package/dts/sparkline/SparklinePath.d.ts.map +1 -0
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +2 -0
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +1 -0
- package/dts/sparkline/generateSparklineWithId.d.ts +11 -0
- package/dts/sparkline/generateSparklineWithId.d.ts.map +1 -0
- package/dts/sparkline/index.d.ts +6 -0
- package/dts/sparkline/index.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts +13 -0
- package/dts/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +199 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +26 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +5 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts +5 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +8 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +17 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +25 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts +30 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts +18 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +31 -0
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +2 -0
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/fade.d.ts +3 -0
- package/dts/sparkline/sparkline-interactive/fade.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +13 -0
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +112 -0
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +1 -0
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +2 -0
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +1 -0
- package/esm/chart/CartesianChart.css +1 -0
- package/esm/chart/CartesianChart.js +258 -0
- package/esm/chart/ChartProvider.js +10 -0
- package/esm/chart/Path.js +89 -0
- package/esm/chart/PeriodSelector.css +1 -0
- package/esm/chart/PeriodSelector.js +126 -0
- package/esm/chart/Point.css +2 -0
- package/esm/chart/Point.js +171 -0
- package/esm/chart/area/Area.js +85 -0
- package/esm/chart/area/AreaChart.js +164 -0
- package/esm/chart/area/DottedArea.js +141 -0
- package/esm/chart/area/GradientArea.js +111 -0
- package/esm/chart/area/SolidArea.js +29 -0
- package/esm/chart/area/index.js +7 -0
- package/esm/chart/axis/Axis.js +46 -0
- package/esm/chart/axis/XAxis.css +2 -0
- package/esm/chart/axis/XAxis.js +195 -0
- package/esm/chart/axis/YAxis.css +2 -0
- package/esm/chart/axis/YAxis.js +183 -0
- package/esm/chart/axis/index.js +5 -0
- package/esm/chart/bar/Bar.js +59 -0
- package/esm/chart/bar/BarChart.js +147 -0
- package/esm/chart/bar/BarPlot.js +96 -0
- package/esm/chart/bar/BarStack.js +519 -0
- package/esm/chart/bar/BarStackGroup.js +96 -0
- package/esm/chart/bar/DefaultBar.js +64 -0
- package/esm/chart/bar/DefaultBarStack.js +60 -0
- package/esm/chart/bar/index.js +9 -0
- package/esm/chart/index.js +14 -0
- package/esm/chart/line/DottedLine.js +38 -0
- package/esm/chart/line/GradientLine.js +58 -0
- package/esm/chart/line/Line.js +159 -0
- package/esm/chart/line/LineChart.js +120 -0
- package/esm/chart/line/ReferenceLine.js +142 -0
- package/esm/chart/line/SolidLine.js +34 -0
- package/esm/chart/line/index.js +8 -0
- package/esm/chart/scrubber/Scrubber.js +483 -0
- package/esm/chart/scrubber/ScrubberBeacon.js +195 -0
- package/esm/chart/scrubber/ScrubberBeaconLabel.js +33 -0
- package/esm/chart/scrubber/ScrubberProvider.js +228 -0
- package/esm/chart/scrubber/index.js +2 -0
- package/esm/chart/text/ChartText.js +236 -0
- package/esm/chart/text/SmartChartTextGroup.js +226 -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 +229 -0
- package/esm/chart/utils/context.js +15 -0
- package/esm/chart/utils/index.js +9 -0
- package/esm/chart/utils/path.js +204 -0
- package/esm/chart/utils/point.js +118 -0
- package/esm/chart/utils/scale.js +48 -0
- package/esm/index.js +4 -0
- package/esm/sparkline/Counter.css +3 -0
- package/esm/sparkline/Counter.js +35 -0
- package/esm/sparkline/Sparkline.js +164 -0
- package/esm/sparkline/SparklineArea.js +18 -0
- package/esm/sparkline/SparklineAreaPattern.js +37 -0
- package/esm/sparkline/SparklineGradient.js +30 -0
- package/esm/sparkline/SparklinePath.js +19 -0
- package/esm/sparkline/__figma__/Sparkline.figma.js +24 -0
- package/esm/sparkline/generateSparklineWithId.js +7 -0
- package/esm/sparkline/index.js +5 -0
- package/esm/sparkline/sparkline-interactive/InnerSparklineInteractiveProvider.js +21 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +317 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +108 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.css +2 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +26 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.css +2 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverPrice.js +24 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.css +4 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +65 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.css +1 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +80 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +56 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +70 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +45 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.css +5 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubHandler.js +199 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveScrubProvider.js +39 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +92 -0
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +89 -0
- package/esm/sparkline/sparkline-interactive/fade.css +2 -0
- package/esm/sparkline/sparkline-interactive/fade.js +14 -0
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +28 -0
- package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +225 -0
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +108 -0
- package/package.json +68 -6
- package/index.js +0 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const _excluded = ["d", "fill", "fillOpacity", "yAxisId", "baseline"];
|
|
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 } from 'react';
|
|
10
|
+
import { Path } from '../Path';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
/**
|
|
13
|
+
* A customizable solid area component which uses Path.
|
|
14
|
+
*/
|
|
15
|
+
export const SolidArea = /*#__PURE__*/memo(_ref => {
|
|
16
|
+
let {
|
|
17
|
+
d,
|
|
18
|
+
fill,
|
|
19
|
+
fillOpacity = 1,
|
|
20
|
+
yAxisId,
|
|
21
|
+
baseline
|
|
22
|
+
} = _ref,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
return /*#__PURE__*/_jsx(Path, _objectSpread({
|
|
25
|
+
d: d,
|
|
26
|
+
fill: fill,
|
|
27
|
+
fillOpacity: fillOpacity
|
|
28
|
+
}, props));
|
|
29
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const axisLineStyles = "\n stroke: var(--color-fg);\n stroke-linecap: square;\n stroke-width: 1px;\n";
|
|
2
|
+
export const axisTickMarkStyles = "\n stroke: var(--color-fg);\n stroke-linecap: square;\n stroke-width: 1px;\n";
|
|
3
|
+
|
|
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
|
+
/**
|
|
27
|
+
* Animation variants for axis elements - updates (used for both grid lines and tick labels)
|
|
28
|
+
*/
|
|
29
|
+
export const axisUpdateAnimationVariants = {
|
|
30
|
+
initial: {
|
|
31
|
+
opacity: 0
|
|
32
|
+
},
|
|
33
|
+
animate: {
|
|
34
|
+
opacity: 1,
|
|
35
|
+
transition: {
|
|
36
|
+
duration: 0.15,
|
|
37
|
+
delay: 0.15 // For updates: fade out 150ms, then fade in 150ms
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
exit: {
|
|
41
|
+
opacity: 0,
|
|
42
|
+
transition: {
|
|
43
|
+
duration: 0.15
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
const _excluded = ["position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "style", "className", "styles", "classNames", "GridLineComponent", "tickMarkLabelGap", "height", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval", "tickMinStep", "tickMaxStep"];
|
|
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, useCallback, useEffect, useId, useMemo } from 'react';
|
|
10
|
+
import { cx } from '@coinbase/cds-web';
|
|
11
|
+
import { AnimatePresence, m as motion } from 'framer-motion';
|
|
12
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
13
|
+
import { DottedLine } from '../line/DottedLine';
|
|
14
|
+
import { ReferenceLine } from '../line/ReferenceLine';
|
|
15
|
+
import { SmartChartTextGroup } from '../text/SmartChartTextGroup';
|
|
16
|
+
import { getAxisTicksData, isCategoricalScale } from '../utils';
|
|
17
|
+
import { axisLineStyles, axisTickLabelsInitialAnimationVariants, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
const axisTickMarkCss = "cds-axisTickMarkCss-a6j4s2q";
|
|
20
|
+
const axisLineCss = "cds-axisLineCss-a12llxjj";
|
|
21
|
+
export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
22
|
+
let {
|
|
23
|
+
position = 'bottom',
|
|
24
|
+
showGrid,
|
|
25
|
+
requestedTickCount,
|
|
26
|
+
ticks,
|
|
27
|
+
tickLabelFormatter,
|
|
28
|
+
style,
|
|
29
|
+
className,
|
|
30
|
+
styles,
|
|
31
|
+
classNames,
|
|
32
|
+
GridLineComponent = DottedLine,
|
|
33
|
+
tickMarkLabelGap = 2,
|
|
34
|
+
height = 32,
|
|
35
|
+
minTickLabelGap = 4,
|
|
36
|
+
showTickMarks,
|
|
37
|
+
showLine,
|
|
38
|
+
tickMarkSize = 4,
|
|
39
|
+
tickInterval = 32,
|
|
40
|
+
tickMinStep = 1,
|
|
41
|
+
tickMaxStep
|
|
42
|
+
} = _ref,
|
|
43
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
44
|
+
const registrationId = useId();
|
|
45
|
+
const {
|
|
46
|
+
animate,
|
|
47
|
+
getXScale,
|
|
48
|
+
getXAxis,
|
|
49
|
+
registerAxis,
|
|
50
|
+
unregisterAxis,
|
|
51
|
+
getAxisBounds
|
|
52
|
+
} = useCartesianChartContext();
|
|
53
|
+
const xScale = getXScale();
|
|
54
|
+
const xAxis = getXAxis();
|
|
55
|
+
const axisBounds = getAxisBounds(registrationId);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
registerAxis(registrationId, position, height);
|
|
58
|
+
return () => unregisterAxis(registrationId);
|
|
59
|
+
}, [registrationId, registerAxis, unregisterAxis, position, height]);
|
|
60
|
+
const formatTick = useCallback(value => {
|
|
61
|
+
var _tickLabelFormatter;
|
|
62
|
+
// If we have string labels and no custom formatter, use the labels
|
|
63
|
+
const axisData = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
|
|
64
|
+
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
65
|
+
let finalValue = value;
|
|
66
|
+
|
|
67
|
+
// For band scales with string data, value is an index
|
|
68
|
+
if (hasStringLabels && typeof value === 'number' && axisData[value] !== undefined) {
|
|
69
|
+
finalValue = axisData[value];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Use the formatter (if provided) or the value itself
|
|
73
|
+
return (_tickLabelFormatter = tickLabelFormatter === null || tickLabelFormatter === void 0 ? void 0 : tickLabelFormatter(finalValue)) !== null && _tickLabelFormatter !== void 0 ? _tickLabelFormatter : finalValue;
|
|
74
|
+
}, [xAxis === null || xAxis === void 0 ? void 0 : xAxis.data, tickLabelFormatter]);
|
|
75
|
+
const ticksData = useMemo(() => {
|
|
76
|
+
if (!xScale) return [];
|
|
77
|
+
|
|
78
|
+
// Check if we have string labels
|
|
79
|
+
const axisData = xAxis === null || xAxis === void 0 ? void 0 : xAxis.data;
|
|
80
|
+
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
81
|
+
|
|
82
|
+
// For band scales, we need categories
|
|
83
|
+
let categories;
|
|
84
|
+
if (hasStringLabels) {
|
|
85
|
+
categories = axisData;
|
|
86
|
+
} else if (isCategoricalScale(xScale)) {
|
|
87
|
+
// For band scales without explicit string data, generate numeric categories
|
|
88
|
+
// based on the domain of the scale
|
|
89
|
+
const domain = xScale.domain();
|
|
90
|
+
categories = domain.map(String);
|
|
91
|
+
}
|
|
92
|
+
let possibleTickValues;
|
|
93
|
+
|
|
94
|
+
// If we have discrete data, we can use the indices as possible tick values
|
|
95
|
+
if (axisData && Array.isArray(axisData) && (typeof axisData[0] === 'string' || typeof axisData[0] === 'number' && isCategoricalScale(xScale))) possibleTickValues = Array.from({
|
|
96
|
+
length: axisData.length
|
|
97
|
+
}, (_, i) => i);
|
|
98
|
+
return getAxisTicksData({
|
|
99
|
+
scaleFunction: xScale,
|
|
100
|
+
ticks,
|
|
101
|
+
requestedTickCount,
|
|
102
|
+
categories,
|
|
103
|
+
possibleTickValues: axisData && Array.isArray(axisData) && typeof axisData[0] === 'string' ? Array.from({
|
|
104
|
+
length: axisData.length
|
|
105
|
+
}, (_, i) => i) : undefined,
|
|
106
|
+
tickInterval: tickInterval,
|
|
107
|
+
options: {
|
|
108
|
+
minStep: tickMinStep,
|
|
109
|
+
maxStep: tickMaxStep
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
|
|
113
|
+
const chartTextData = useMemo(() => {
|
|
114
|
+
if (!axisBounds) return null;
|
|
115
|
+
return ticksData.map(tick => {
|
|
116
|
+
const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
|
|
117
|
+
const availableSpace = axisBounds.height - tickOffset;
|
|
118
|
+
const labelOffset = availableSpace / 2;
|
|
119
|
+
const labelY = position === 'top' ? axisBounds.y + labelOffset - tickOffset : axisBounds.y + labelOffset + tickOffset;
|
|
120
|
+
return {
|
|
121
|
+
x: tick.position,
|
|
122
|
+
y: labelY,
|
|
123
|
+
label: formatTick(tick.tick),
|
|
124
|
+
chartTextProps: {
|
|
125
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel,
|
|
126
|
+
color: 'var(--color-fgMuted)',
|
|
127
|
+
verticalAlignment: 'middle',
|
|
128
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickLabel,
|
|
129
|
+
horizontalAlignment: 'center'
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
});
|
|
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;
|
|
135
|
+
return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
|
|
136
|
+
className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
137
|
+
"data-axis": "x",
|
|
138
|
+
"data-position": position,
|
|
139
|
+
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
|
|
140
|
+
}, props), {}, {
|
|
141
|
+
children: [showGrid && /*#__PURE__*/_jsx(AnimatePresence, {
|
|
142
|
+
initial: false,
|
|
143
|
+
children: ticksData.map((tick, index) => {
|
|
144
|
+
const verticalLine = /*#__PURE__*/_jsx(ReferenceLine, {
|
|
145
|
+
LineComponent: GridLineComponent,
|
|
146
|
+
dataX: tick.tick
|
|
147
|
+
});
|
|
148
|
+
return animate ? /*#__PURE__*/_jsx(motion.g, {
|
|
149
|
+
animate: "animate",
|
|
150
|
+
exit: "exit",
|
|
151
|
+
initial: "initial",
|
|
152
|
+
variants: axisUpdateAnimationVariants,
|
|
153
|
+
children: verticalLine
|
|
154
|
+
}, "grid-".concat(tick.tick, "-").concat(index)) : /*#__PURE__*/_jsx("g", {
|
|
155
|
+
children: verticalLine
|
|
156
|
+
}, "grid-".concat(tick.tick, "-").concat(index));
|
|
157
|
+
})
|
|
158
|
+
}), chartTextData && /*#__PURE__*/_jsx(AnimatePresence, {
|
|
159
|
+
children: /*#__PURE__*/_jsx(motion.g, {
|
|
160
|
+
animate: "animate",
|
|
161
|
+
exit: "exit",
|
|
162
|
+
initial: "initial",
|
|
163
|
+
variants: animate ? axisTickLabelsInitialAnimationVariants : undefined,
|
|
164
|
+
children: /*#__PURE__*/_jsx(SmartChartTextGroup, {
|
|
165
|
+
prioritizeEndLabels: true,
|
|
166
|
+
labels: chartTextData,
|
|
167
|
+
minGap: minTickLabelGap
|
|
168
|
+
})
|
|
169
|
+
})
|
|
170
|
+
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx("g", {
|
|
171
|
+
"data-testid": "tick-marks",
|
|
172
|
+
children: ticksData.map((tick, index) => {
|
|
173
|
+
const tickY = position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height;
|
|
174
|
+
const tickMarkSizePixels = tickMarkSize;
|
|
175
|
+
const tickY2 = position === 'bottom' ? axisBounds.y + tickMarkSizePixels : axisBounds.y + axisBounds.height - tickMarkSizePixels;
|
|
176
|
+
return /*#__PURE__*/_jsx("line", {
|
|
177
|
+
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
178
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark,
|
|
179
|
+
x1: tick.position,
|
|
180
|
+
x2: tick.position,
|
|
181
|
+
y1: tickY,
|
|
182
|
+
y2: tickY2
|
|
183
|
+
}, "tick-mark-".concat(tick.tick, "-").concat(index));
|
|
184
|
+
})
|
|
185
|
+
}), axisBounds && showLine && /*#__PURE__*/_jsx("line", {
|
|
186
|
+
className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
|
|
187
|
+
style: styles === null || styles === void 0 ? void 0 : styles.line,
|
|
188
|
+
x1: axisBounds.x,
|
|
189
|
+
x2: axisBounds.x + axisBounds.width,
|
|
190
|
+
y1: position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height,
|
|
191
|
+
y2: position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height
|
|
192
|
+
})]
|
|
193
|
+
}));
|
|
194
|
+
});
|
|
195
|
+
import "./XAxis.css";
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
const _excluded = ["axisId", "position", "showGrid", "requestedTickCount", "ticks", "tickLabelFormatter", "style", "className", "styles", "classNames", "GridLineComponent", "tickMarkLabelGap", "width", "minTickLabelGap", "showTickMarks", "showLine", "tickMarkSize", "tickInterval"];
|
|
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, useCallback, useEffect, useId, useMemo } from 'react';
|
|
10
|
+
import { cx } from '@coinbase/cds-web';
|
|
11
|
+
import { AnimatePresence, m as motion } from 'framer-motion';
|
|
12
|
+
import { useCartesianChartContext } from '../ChartProvider';
|
|
13
|
+
import { DottedLine } from '../line/DottedLine';
|
|
14
|
+
import { ReferenceLine } from '../line/ReferenceLine';
|
|
15
|
+
import { SmartChartTextGroup } from '../text/SmartChartTextGroup';
|
|
16
|
+
import { getAxisTicksData, isCategoricalScale } from '../utils';
|
|
17
|
+
import { axisLineStyles, axisTickLabelsInitialAnimationVariants, axisTickMarkStyles, axisUpdateAnimationVariants } from './Axis';
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
const axisTickMarkCss = "cds-axisTickMarkCss-au2toz5";
|
|
20
|
+
const axisLineCss = "cds-axisLineCss-akmofp5";
|
|
21
|
+
export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
22
|
+
let {
|
|
23
|
+
axisId,
|
|
24
|
+
position = 'right',
|
|
25
|
+
showGrid,
|
|
26
|
+
requestedTickCount,
|
|
27
|
+
ticks,
|
|
28
|
+
tickLabelFormatter,
|
|
29
|
+
style,
|
|
30
|
+
className,
|
|
31
|
+
styles,
|
|
32
|
+
classNames,
|
|
33
|
+
GridLineComponent = DottedLine,
|
|
34
|
+
tickMarkLabelGap = 8,
|
|
35
|
+
width = 44,
|
|
36
|
+
minTickLabelGap = 0,
|
|
37
|
+
showTickMarks,
|
|
38
|
+
showLine,
|
|
39
|
+
tickMarkSize = 4,
|
|
40
|
+
tickInterval
|
|
41
|
+
} = _ref,
|
|
42
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
|
+
const registrationId = useId();
|
|
44
|
+
const {
|
|
45
|
+
animate,
|
|
46
|
+
getYScale,
|
|
47
|
+
getYAxis,
|
|
48
|
+
registerAxis,
|
|
49
|
+
unregisterAxis,
|
|
50
|
+
getAxisBounds
|
|
51
|
+
} = useCartesianChartContext();
|
|
52
|
+
const yScale = getYScale(axisId);
|
|
53
|
+
const yAxis = getYAxis(axisId);
|
|
54
|
+
const axisBounds = getAxisBounds(registrationId);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
registerAxis(registrationId, position, width);
|
|
57
|
+
return () => unregisterAxis(registrationId);
|
|
58
|
+
}, [registrationId, registerAxis, unregisterAxis, position, width]);
|
|
59
|
+
const formatTick = useCallback(value => {
|
|
60
|
+
var _tickLabelFormatter;
|
|
61
|
+
// If we have string labels and no custom formatter, use the labels
|
|
62
|
+
const axisData = yAxis === null || yAxis === void 0 ? void 0 : yAxis.data;
|
|
63
|
+
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
64
|
+
if (hasStringLabels && !tickLabelFormatter && axisData[value] !== undefined) {
|
|
65
|
+
// Use the string label from the data array
|
|
66
|
+
return axisData[value];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Otherwise use the formatter (if provided) or the value itself
|
|
70
|
+
return (_tickLabelFormatter = tickLabelFormatter === null || tickLabelFormatter === void 0 ? void 0 : tickLabelFormatter(value)) !== null && _tickLabelFormatter !== void 0 ? _tickLabelFormatter : value;
|
|
71
|
+
}, [yAxis === null || yAxis === void 0 ? void 0 : yAxis.data, tickLabelFormatter]);
|
|
72
|
+
|
|
73
|
+
// Use D3 to get the ticks data
|
|
74
|
+
// Result contains each tick value and its axis position
|
|
75
|
+
const ticksData = useMemo(() => {
|
|
76
|
+
if (!yScale) return [];
|
|
77
|
+
|
|
78
|
+
// Check if we have string labels
|
|
79
|
+
const axisData = yAxis === null || yAxis === void 0 ? void 0 : yAxis.data;
|
|
80
|
+
const hasStringLabels = axisData && Array.isArray(axisData) && typeof axisData[0] === 'string';
|
|
81
|
+
|
|
82
|
+
// For band scales, we need categories
|
|
83
|
+
let categories;
|
|
84
|
+
if (hasStringLabels) {
|
|
85
|
+
categories = axisData;
|
|
86
|
+
} else if (isCategoricalScale(yScale)) {
|
|
87
|
+
// For band scales without explicit string data, generate numeric categories
|
|
88
|
+
// based on the domain of the scale
|
|
89
|
+
const domain = yScale.domain();
|
|
90
|
+
categories = domain.map(String);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// For numeric data or no explicit data, use default tick generation
|
|
94
|
+
return getAxisTicksData({
|
|
95
|
+
scaleFunction: yScale,
|
|
96
|
+
ticks,
|
|
97
|
+
requestedTickCount: tickInterval !== undefined ? undefined : requestedTickCount !== null && requestedTickCount !== void 0 ? requestedTickCount : 5,
|
|
98
|
+
categories,
|
|
99
|
+
tickInterval: tickInterval
|
|
100
|
+
});
|
|
101
|
+
}, [ticks, yScale, requestedTickCount, tickInterval, yAxis === null || yAxis === void 0 ? void 0 : yAxis.data]);
|
|
102
|
+
const chartTextData = useMemo(() => {
|
|
103
|
+
if (!axisBounds) return null;
|
|
104
|
+
return ticksData.map(tick => {
|
|
105
|
+
const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
|
|
106
|
+
const labelX = position === 'left' ? axisBounds.x + axisBounds.width - tickOffset : axisBounds.x + tickOffset;
|
|
107
|
+
return {
|
|
108
|
+
x: labelX,
|
|
109
|
+
y: tick.position,
|
|
110
|
+
label: formatTick(tick.tick),
|
|
111
|
+
chartTextProps: {
|
|
112
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.tickLabel,
|
|
113
|
+
color: 'var(--color-fgMuted)',
|
|
114
|
+
verticalAlignment: 'middle',
|
|
115
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickLabel,
|
|
116
|
+
horizontalAlignment: position === 'left' ? 'right' : 'left'
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
}, [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;
|
|
122
|
+
return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
|
|
123
|
+
className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
124
|
+
"data-axis": "y",
|
|
125
|
+
"data-position": position,
|
|
126
|
+
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
|
|
127
|
+
}, props), {}, {
|
|
128
|
+
children: [showGrid && /*#__PURE__*/_jsx(AnimatePresence, {
|
|
129
|
+
initial: false,
|
|
130
|
+
children: ticksData.map((tick, index) => {
|
|
131
|
+
const horizontalLine = /*#__PURE__*/_jsx(ReferenceLine, {
|
|
132
|
+
LineComponent: GridLineComponent,
|
|
133
|
+
dataY: tick.tick,
|
|
134
|
+
yAxisId: axisId
|
|
135
|
+
});
|
|
136
|
+
return animate ? /*#__PURE__*/_jsx(motion.g, {
|
|
137
|
+
animate: "animate",
|
|
138
|
+
exit: "exit",
|
|
139
|
+
initial: "initial",
|
|
140
|
+
variants: axisUpdateAnimationVariants,
|
|
141
|
+
children: horizontalLine
|
|
142
|
+
}, "grid-".concat(tick.tick, "-").concat(index)) : /*#__PURE__*/_jsx("g", {
|
|
143
|
+
children: horizontalLine
|
|
144
|
+
}, "grid-".concat(tick.tick, "-").concat(index));
|
|
145
|
+
})
|
|
146
|
+
}), chartTextData && /*#__PURE__*/_jsx(AnimatePresence, {
|
|
147
|
+
children: /*#__PURE__*/_jsx(motion.g, {
|
|
148
|
+
animate: "animate",
|
|
149
|
+
exit: "exit",
|
|
150
|
+
initial: "initial",
|
|
151
|
+
variants: animate ? axisTickLabelsInitialAnimationVariants : undefined,
|
|
152
|
+
children: /*#__PURE__*/_jsx(SmartChartTextGroup, {
|
|
153
|
+
prioritizeEndLabels: true,
|
|
154
|
+
labels: chartTextData,
|
|
155
|
+
minGap: minTickLabelGap
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx("g", {
|
|
159
|
+
"data-testid": "tick-marks",
|
|
160
|
+
children: ticksData.map((tick, index) => {
|
|
161
|
+
const tickX = position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x;
|
|
162
|
+
const tickMarkSizePixels = tickMarkSize;
|
|
163
|
+
const tickX2 = position === 'left' ? axisBounds.x + axisBounds.width - tickMarkSizePixels : axisBounds.x + tickMarkSizePixels;
|
|
164
|
+
return /*#__PURE__*/_jsx("line", {
|
|
165
|
+
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
166
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark,
|
|
167
|
+
x1: tickX,
|
|
168
|
+
x2: tickX2,
|
|
169
|
+
y1: tick.position,
|
|
170
|
+
y2: tick.position
|
|
171
|
+
}, "tick-mark-".concat(tick.tick, "-").concat(index));
|
|
172
|
+
})
|
|
173
|
+
}), axisBounds && showLine && /*#__PURE__*/_jsx("line", {
|
|
174
|
+
className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
|
|
175
|
+
style: styles === null || styles === void 0 ? void 0 : styles.line,
|
|
176
|
+
x1: position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x,
|
|
177
|
+
x2: position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x,
|
|
178
|
+
y1: axisBounds.y,
|
|
179
|
+
y2: axisBounds.y + axisBounds.height
|
|
180
|
+
})]
|
|
181
|
+
}));
|
|
182
|
+
});
|
|
183
|
+
import "./YAxis.css";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { getBarPath } from '../utils';
|
|
3
|
+
import { DefaultBar } from './';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
/**
|
|
6
|
+
* Simple bar component that renders a single bar at the specified position.
|
|
7
|
+
*
|
|
8
|
+
* This component is intentionally kept simple - it just renders a bar at the given
|
|
9
|
+
* x, y, width, height coordinates. Complex positioning logic (like handling stacks,
|
|
10
|
+
* groups, gaps, etc.) should be handled by parent components like BarChart or BarStack.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <Bar x={10} y={20} width={50} height={100} fill="blue" />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const Bar = /*#__PURE__*/memo(_ref => {
|
|
18
|
+
let {
|
|
19
|
+
x,
|
|
20
|
+
y,
|
|
21
|
+
width,
|
|
22
|
+
height,
|
|
23
|
+
originY,
|
|
24
|
+
dataX,
|
|
25
|
+
dataY,
|
|
26
|
+
BarComponent = DefaultBar,
|
|
27
|
+
fill = 'var(--color-fgPrimary)',
|
|
28
|
+
fillOpacity = 1,
|
|
29
|
+
stroke,
|
|
30
|
+
strokeWidth,
|
|
31
|
+
borderRadius = 4,
|
|
32
|
+
roundTop = true,
|
|
33
|
+
roundBottom = true
|
|
34
|
+
} = _ref;
|
|
35
|
+
const barPath = useMemo(() => {
|
|
36
|
+
return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
|
|
37
|
+
}, [x, y, width, height, borderRadius, roundTop, roundBottom]);
|
|
38
|
+
const effectiveOriginY = originY !== null && originY !== void 0 ? originY : y + height;
|
|
39
|
+
if (!barPath) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/_jsx(BarComponent, {
|
|
43
|
+
borderRadius: borderRadius,
|
|
44
|
+
d: barPath,
|
|
45
|
+
dataX: dataX,
|
|
46
|
+
dataY: dataY,
|
|
47
|
+
fill: fill,
|
|
48
|
+
fillOpacity: fillOpacity,
|
|
49
|
+
height: height,
|
|
50
|
+
originY: effectiveOriginY,
|
|
51
|
+
roundBottom: roundBottom,
|
|
52
|
+
roundTop: roundTop,
|
|
53
|
+
stroke: stroke,
|
|
54
|
+
strokeWidth: strokeWidth,
|
|
55
|
+
width: width,
|
|
56
|
+
x: x,
|
|
57
|
+
y: y
|
|
58
|
+
});
|
|
59
|
+
});
|