@coinbase/cds-web-visualization 3.4.0-beta.1 → 3.4.0-beta.11
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 +53 -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 +109 -63
- 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 +2 -2
- 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 +87 -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 +91 -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 +207 -66
- 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/axis.d.ts +25 -1
- package/dts/chart/utils/axis.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 +40 -7
- package/dts/chart/utils/point.d.ts.map +1 -1
- package/dts/chart/utils/scale.d.ts +11 -0
- package/dts/chart/utils/scale.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/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +1 -1
- package/esm/chart/CartesianChart.js +140 -85
- package/esm/chart/Path.js +53 -47
- 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 -39
- package/esm/chart/axis/DefaultAxisTickLabel.js +15 -0
- package/esm/chart/axis/XAxis.js +184 -63
- package/esm/chart/axis/YAxis.js +190 -57
- 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 +41 -43
- 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 +15 -20
- package/esm/chart/text/{SmartChartTextGroup.js → ChartTextGroup.js} +4 -3
- package/esm/chart/text/index.js +1 -1
- package/esm/chart/utils/axis.js +45 -29
- 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 +99 -12
- package/esm/chart/utils/scale.js +13 -2
- package/esm/chart/utils/scrubber.js +132 -0
- package/esm/chart/utils/transition.js +111 -0
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +8 -4
- 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
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", "testID", "bandGridLinePlacement", "bandTickMarkPlacement"];
|
|
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; }
|
|
@@ -8,14 +8,18 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, 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
9
|
import { memo, useCallback, useEffect, useId, useMemo } from 'react';
|
|
10
10
|
import { cx } from '@coinbase/cds-web';
|
|
11
|
-
import {
|
|
11
|
+
import { m as motion } from 'framer-motion';
|
|
12
12
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
13
13
|
import { DottedLine } from '../line/DottedLine';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { SolidLine } from '../line/SolidLine';
|
|
15
|
+
import { ChartText } from '../text/ChartText';
|
|
16
|
+
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
17
|
+
import { getAxisTicksData, getPointOnScale, isCategoricalScale, lineToPath, toPointAnchor } from '../utils';
|
|
18
|
+
import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationTransition } from './Axis';
|
|
19
|
+
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
18
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
const AXIS_HEIGHT = 32;
|
|
22
|
+
const LABEL_SIZE = 20;
|
|
19
23
|
const axisTickMarkCss = "cds-axisTickMarkCss-a6j4s2q";
|
|
20
24
|
const axisLineCss = "cds-axisLineCss-a12llxjj";
|
|
21
25
|
export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
@@ -25,20 +29,28 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
25
29
|
requestedTickCount,
|
|
26
30
|
ticks,
|
|
27
31
|
tickLabelFormatter,
|
|
32
|
+
TickLabelComponent = DefaultAxisTickLabel,
|
|
28
33
|
style,
|
|
29
34
|
className,
|
|
30
35
|
styles,
|
|
31
36
|
classNames,
|
|
32
37
|
GridLineComponent = DottedLine,
|
|
38
|
+
LineComponent = SolidLine,
|
|
39
|
+
TickMarkLineComponent = SolidLine,
|
|
33
40
|
tickMarkLabelGap = 2,
|
|
34
|
-
height = 32,
|
|
35
41
|
minTickLabelGap = 4,
|
|
36
42
|
showTickMarks,
|
|
37
43
|
showLine,
|
|
38
44
|
tickMarkSize = 4,
|
|
39
45
|
tickInterval = 32,
|
|
40
46
|
tickMinStep = 1,
|
|
41
|
-
tickMaxStep
|
|
47
|
+
tickMaxStep,
|
|
48
|
+
label,
|
|
49
|
+
labelGap = 4,
|
|
50
|
+
height = label ? AXIS_HEIGHT + LABEL_SIZE : AXIS_HEIGHT,
|
|
51
|
+
testID = 'x-axis',
|
|
52
|
+
bandGridLinePlacement = 'edges',
|
|
53
|
+
bandTickMarkPlacement = 'middle'
|
|
42
54
|
} = _ref,
|
|
43
55
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
44
56
|
const registrationId = useId();
|
|
@@ -48,7 +60,8 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
48
60
|
getXAxis,
|
|
49
61
|
registerAxis,
|
|
50
62
|
unregisterAxis,
|
|
51
|
-
getAxisBounds
|
|
63
|
+
getAxisBounds,
|
|
64
|
+
drawingArea
|
|
52
65
|
} = useCartesianChartContext();
|
|
53
66
|
const xScale = getXScale();
|
|
54
67
|
const xAxis = getXAxis();
|
|
@@ -89,12 +102,6 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
89
102
|
const domain = xScale.domain();
|
|
90
103
|
categories = domain.map(String);
|
|
91
104
|
}
|
|
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
105
|
return getAxisTicksData({
|
|
99
106
|
scaleFunction: xScale,
|
|
100
107
|
ticks,
|
|
@@ -110,13 +117,79 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
110
117
|
}
|
|
111
118
|
});
|
|
112
119
|
}, [ticks, xScale, requestedTickCount, tickInterval, tickMinStep, tickMaxStep, xAxis === null || xAxis === void 0 ? void 0 : xAxis.data]);
|
|
120
|
+
const isBandScale = useMemo(() => {
|
|
121
|
+
if (!xScale) return false;
|
|
122
|
+
return isCategoricalScale(xScale);
|
|
123
|
+
}, [xScale]);
|
|
124
|
+
|
|
125
|
+
// Compute grid line positions (including bounds closing line for band scales)
|
|
126
|
+
const gridLinePositions = useMemo(() => {
|
|
127
|
+
if (!xScale) return [];
|
|
128
|
+
return ticksData.flatMap((tick, index) => {
|
|
129
|
+
if (!isBandScale) {
|
|
130
|
+
return [{
|
|
131
|
+
x: tick.position,
|
|
132
|
+
key: "grid-".concat(tick.tick, "-").concat(index)
|
|
133
|
+
}];
|
|
134
|
+
}
|
|
135
|
+
const bandScale = xScale;
|
|
136
|
+
const isLastTick = index === ticksData.length - 1;
|
|
137
|
+
const isEdges = bandGridLinePlacement === 'edges';
|
|
138
|
+
const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandGridLinePlacement));
|
|
139
|
+
const positions = [{
|
|
140
|
+
x: startX,
|
|
141
|
+
key: "grid-".concat(tick.tick, "-").concat(index)
|
|
142
|
+
}];
|
|
143
|
+
|
|
144
|
+
// For edges on last tick, add the closing line at stepEnd
|
|
145
|
+
if (isLastTick && isEdges) {
|
|
146
|
+
const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
147
|
+
positions.push({
|
|
148
|
+
x: endX,
|
|
149
|
+
key: "grid-".concat(tick.tick, "-").concat(index, "-end")
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return positions;
|
|
153
|
+
});
|
|
154
|
+
}, [ticksData, xScale, isBandScale, bandGridLinePlacement]);
|
|
155
|
+
|
|
156
|
+
// Compute tick mark positions (including bounds closing tick mark for band scales)
|
|
157
|
+
const tickMarkPositions = useMemo(() => {
|
|
158
|
+
if (!xScale) return [];
|
|
159
|
+
return ticksData.flatMap((tick, index) => {
|
|
160
|
+
if (!isBandScale) {
|
|
161
|
+
return [{
|
|
162
|
+
x: tick.position,
|
|
163
|
+
key: "tick-mark-".concat(tick.tick, "-").concat(index)
|
|
164
|
+
}];
|
|
165
|
+
}
|
|
166
|
+
const bandScale = xScale;
|
|
167
|
+
const isLastTick = index === ticksData.length - 1;
|
|
168
|
+
const isEdges = bandTickMarkPlacement === 'edges';
|
|
169
|
+
const startX = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandTickMarkPlacement));
|
|
170
|
+
const positions = [{
|
|
171
|
+
x: startX,
|
|
172
|
+
key: "tick-mark-".concat(tick.tick, "-").concat(index)
|
|
173
|
+
}];
|
|
174
|
+
|
|
175
|
+
// For edges on last tick, add the closing tick mark at stepEnd
|
|
176
|
+
if (isLastTick && isEdges) {
|
|
177
|
+
const endX = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
178
|
+
positions.push({
|
|
179
|
+
x: endX,
|
|
180
|
+
key: "tick-mark-".concat(tick.tick, "-").concat(index, "-end")
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return positions;
|
|
184
|
+
});
|
|
185
|
+
}, [ticksData, xScale, isBandScale, bandTickMarkPlacement]);
|
|
113
186
|
const chartTextData = useMemo(() => {
|
|
114
187
|
if (!axisBounds) return null;
|
|
115
188
|
return ticksData.map(tick => {
|
|
116
189
|
const tickOffset = tickMarkLabelGap + (showTickMarks ? tickMarkSize : 0);
|
|
117
|
-
const availableSpace =
|
|
190
|
+
const availableSpace = AXIS_HEIGHT - tickOffset;
|
|
118
191
|
const labelOffset = availableSpace / 2;
|
|
119
|
-
const labelY = position === 'top' ? axisBounds.y +
|
|
192
|
+
const labelY = position === 'top' ? axisBounds.y + axisBounds.height - tickOffset - labelOffset : axisBounds.y + labelOffset + tickOffset;
|
|
120
193
|
return {
|
|
121
194
|
x: tick.position,
|
|
122
195
|
y: labelY,
|
|
@@ -131,64 +204,112 @@ export const XAxis = /*#__PURE__*/memo(_ref => {
|
|
|
131
204
|
};
|
|
132
205
|
});
|
|
133
206
|
}, [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;
|
|
207
|
+
if (!xScale || !axisBounds || !drawingArea) return;
|
|
208
|
+
const labelX = axisBounds.x + axisBounds.width / 2;
|
|
209
|
+
const labelY = position === 'bottom' ? axisBounds.y + axisBounds.height - LABEL_SIZE / 2 : axisBounds.y + LABEL_SIZE / 2;
|
|
210
|
+
const tickYTop = axisBounds.y;
|
|
211
|
+
const tickYBottom = axisBounds.y + axisBounds.height;
|
|
212
|
+
const tickYStart = position === 'bottom' ? tickYTop : tickYBottom;
|
|
213
|
+
const tickYEnd = position === 'bottom' ? tickYTop + tickMarkSize : tickYBottom - tickMarkSize;
|
|
135
214
|
return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
|
|
136
215
|
className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
137
216
|
"data-axis": "x",
|
|
138
217
|
"data-position": position,
|
|
139
218
|
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
|
|
140
219
|
}, props), {}, {
|
|
141
|
-
children: [showGrid && /*#__PURE__*/_jsx(
|
|
142
|
-
|
|
143
|
-
children:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
220
|
+
children: [showGrid && /*#__PURE__*/_jsx("g", {
|
|
221
|
+
"data-testid": "".concat(testID, "-grid"),
|
|
222
|
+
children: gridLinePositions.map(_ref2 => {
|
|
223
|
+
let {
|
|
224
|
+
x,
|
|
225
|
+
key
|
|
226
|
+
} = _ref2;
|
|
148
227
|
return animate ? /*#__PURE__*/_jsx(motion.g, {
|
|
149
|
-
animate:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
228
|
+
animate: {
|
|
229
|
+
opacity: 1
|
|
230
|
+
},
|
|
231
|
+
initial: {
|
|
232
|
+
opacity: 0
|
|
233
|
+
},
|
|
234
|
+
transition: axisUpdateAnimationTransition,
|
|
235
|
+
children: /*#__PURE__*/_jsx(GridLineComponent, {
|
|
236
|
+
animate: false,
|
|
237
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
|
|
238
|
+
clipRect: null,
|
|
239
|
+
d: lineToPath(x, drawingArea.y, x, drawingArea.y + drawingArea.height),
|
|
240
|
+
stroke: "var(--color-bgLine)",
|
|
241
|
+
style: styles === null || styles === void 0 ? void 0 : styles.gridLine
|
|
242
|
+
})
|
|
243
|
+
}, key) : /*#__PURE__*/_jsx(GridLineComponent, {
|
|
244
|
+
animate: false,
|
|
245
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
|
|
246
|
+
clipRect: null,
|
|
247
|
+
d: lineToPath(x, drawingArea.y, x, drawingArea.y + drawingArea.height),
|
|
248
|
+
stroke: "var(--color-bgLine)",
|
|
249
|
+
style: styles === null || styles === void 0 ? void 0 : styles.gridLine
|
|
250
|
+
}, key);
|
|
169
251
|
})
|
|
252
|
+
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
253
|
+
prioritizeEndLabels: true,
|
|
254
|
+
LabelComponent: TickLabelComponent,
|
|
255
|
+
labels: chartTextData,
|
|
256
|
+
minGap: minTickLabelGap
|
|
170
257
|
}), axisBounds && showTickMarks && /*#__PURE__*/_jsx("g", {
|
|
171
|
-
"data-testid": "tick-marks",
|
|
172
|
-
children:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
258
|
+
"data-testid": "".concat(testID, "-tick-marks"),
|
|
259
|
+
children: tickMarkPositions.map(_ref3 => {
|
|
260
|
+
let {
|
|
261
|
+
x,
|
|
262
|
+
key
|
|
263
|
+
} = _ref3;
|
|
264
|
+
return animate ? /*#__PURE__*/_jsx(motion.g, {
|
|
265
|
+
animate: {
|
|
266
|
+
opacity: 1
|
|
267
|
+
},
|
|
268
|
+
initial: {
|
|
269
|
+
opacity: 0
|
|
270
|
+
},
|
|
271
|
+
transition: axisUpdateAnimationTransition,
|
|
272
|
+
children: /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
273
|
+
animate: false,
|
|
274
|
+
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
275
|
+
clipRect: null,
|
|
276
|
+
d: lineToPath(x, tickYEnd, x, tickYStart),
|
|
277
|
+
stroke: "var(--color-fg)",
|
|
278
|
+
strokeLinecap: "square",
|
|
279
|
+
strokeWidth: 1,
|
|
280
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark
|
|
281
|
+
})
|
|
282
|
+
}, key) : /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
283
|
+
animate: false,
|
|
177
284
|
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
285
|
+
clipRect: null,
|
|
286
|
+
d: lineToPath(x, tickYEnd, x, tickYStart),
|
|
287
|
+
stroke: "var(--color-fg)",
|
|
288
|
+
strokeLinecap: "square",
|
|
289
|
+
strokeWidth: 1,
|
|
290
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark
|
|
291
|
+
}, key);
|
|
184
292
|
})
|
|
185
|
-
}),
|
|
293
|
+
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
294
|
+
animate: false,
|
|
186
295
|
className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
296
|
+
clipRect: null,
|
|
297
|
+
d: lineToPath(axisBounds.x, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height, axisBounds.x + axisBounds.width, position === 'bottom' ? axisBounds.y : axisBounds.y + axisBounds.height),
|
|
298
|
+
"data-testid": "".concat(testID, "-line"),
|
|
299
|
+
stroke: "var(--color-fg)",
|
|
300
|
+
strokeLinecap: "square",
|
|
301
|
+
strokeWidth: 1,
|
|
302
|
+
style: styles === null || styles === void 0 ? void 0 : styles.line
|
|
303
|
+
}), label && /*#__PURE__*/_jsx(ChartText, {
|
|
304
|
+
disableRepositioning: true,
|
|
305
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
|
|
306
|
+
horizontalAlignment: "center",
|
|
307
|
+
style: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
308
|
+
testID: "".concat(testID, "-label"),
|
|
309
|
+
verticalAlignment: "middle",
|
|
310
|
+
x: labelX,
|
|
311
|
+
y: labelY,
|
|
312
|
+
children: label
|
|
192
313
|
})]
|
|
193
314
|
}));
|
|
194
315
|
});
|
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", "testID", "bandGridLinePlacement", "bandTickMarkPlacement"];
|
|
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; }
|
|
@@ -8,14 +8,18 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, 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
9
|
import { memo, useCallback, useEffect, useId, useMemo } from 'react';
|
|
10
10
|
import { cx } from '@coinbase/cds-web';
|
|
11
|
-
import {
|
|
11
|
+
import { m as motion } from 'framer-motion';
|
|
12
12
|
import { useCartesianChartContext } from '../ChartProvider';
|
|
13
13
|
import { DottedLine } from '../line/DottedLine';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { SolidLine } from '../line/SolidLine';
|
|
15
|
+
import { ChartText } from '../text/ChartText';
|
|
16
|
+
import { ChartTextGroup } from '../text/ChartTextGroup';
|
|
17
|
+
import { getAxisTicksData, getPointOnScale, isCategoricalScale, lineToPath, toPointAnchor } from '../utils';
|
|
18
|
+
import { axisLineStyles, axisTickMarkStyles, axisUpdateAnimationTransition } from './Axis';
|
|
19
|
+
import { DefaultAxisTickLabel } from './DefaultAxisTickLabel';
|
|
18
20
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
+
const AXIS_WIDTH = 44;
|
|
22
|
+
const LABEL_SIZE = 20;
|
|
19
23
|
const axisTickMarkCss = "cds-axisTickMarkCss-au2toz5";
|
|
20
24
|
const axisLineCss = "cds-axisLineCss-akmofp5";
|
|
21
25
|
export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
@@ -26,18 +30,26 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
26
30
|
requestedTickCount,
|
|
27
31
|
ticks,
|
|
28
32
|
tickLabelFormatter,
|
|
33
|
+
TickLabelComponent = DefaultAxisTickLabel,
|
|
29
34
|
style,
|
|
30
35
|
className,
|
|
31
36
|
styles,
|
|
32
37
|
classNames,
|
|
33
38
|
GridLineComponent = DottedLine,
|
|
39
|
+
LineComponent = SolidLine,
|
|
40
|
+
TickMarkLineComponent = SolidLine,
|
|
34
41
|
tickMarkLabelGap = 8,
|
|
35
|
-
width = 44,
|
|
36
42
|
minTickLabelGap = 0,
|
|
37
43
|
showTickMarks,
|
|
38
44
|
showLine,
|
|
39
45
|
tickMarkSize = 4,
|
|
40
|
-
tickInterval
|
|
46
|
+
tickInterval,
|
|
47
|
+
label,
|
|
48
|
+
labelGap = 4,
|
|
49
|
+
width = label ? AXIS_WIDTH + LABEL_SIZE : AXIS_WIDTH,
|
|
50
|
+
testID = 'y-axis',
|
|
51
|
+
bandGridLinePlacement = 'edges',
|
|
52
|
+
bandTickMarkPlacement = 'middle'
|
|
41
53
|
} = _ref,
|
|
42
54
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
55
|
const registrationId = useId();
|
|
@@ -47,7 +59,8 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
47
59
|
getYAxis,
|
|
48
60
|
registerAxis,
|
|
49
61
|
unregisterAxis,
|
|
50
|
-
getAxisBounds
|
|
62
|
+
getAxisBounds,
|
|
63
|
+
drawingArea
|
|
51
64
|
} = useCartesianChartContext();
|
|
52
65
|
const yScale = getYScale(axisId);
|
|
53
66
|
const yAxis = getYAxis(axisId);
|
|
@@ -99,6 +112,72 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
99
112
|
tickInterval: tickInterval
|
|
100
113
|
});
|
|
101
114
|
}, [ticks, yScale, requestedTickCount, tickInterval, yAxis === null || yAxis === void 0 ? void 0 : yAxis.data]);
|
|
115
|
+
const isBandScale = useMemo(() => {
|
|
116
|
+
if (!yScale) return false;
|
|
117
|
+
return isCategoricalScale(yScale);
|
|
118
|
+
}, [yScale]);
|
|
119
|
+
|
|
120
|
+
// Compute grid line positions (including bounds closing line for band scales)
|
|
121
|
+
const gridLinePositions = useMemo(() => {
|
|
122
|
+
if (!yScale) return [];
|
|
123
|
+
return ticksData.flatMap((tick, index) => {
|
|
124
|
+
if (!isBandScale) {
|
|
125
|
+
return [{
|
|
126
|
+
y: tick.position,
|
|
127
|
+
key: "grid-".concat(tick.tick, "-").concat(index)
|
|
128
|
+
}];
|
|
129
|
+
}
|
|
130
|
+
const bandScale = yScale;
|
|
131
|
+
const isLastTick = index === ticksData.length - 1;
|
|
132
|
+
const isEdges = bandGridLinePlacement === 'edges';
|
|
133
|
+
const startY = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandGridLinePlacement));
|
|
134
|
+
const positions = [{
|
|
135
|
+
y: startY,
|
|
136
|
+
key: "grid-".concat(tick.tick, "-").concat(index)
|
|
137
|
+
}];
|
|
138
|
+
|
|
139
|
+
// For edges on last tick, add the closing line at stepEnd
|
|
140
|
+
if (isLastTick && isEdges) {
|
|
141
|
+
const endY = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
142
|
+
positions.push({
|
|
143
|
+
y: endY,
|
|
144
|
+
key: "grid-".concat(tick.tick, "-").concat(index, "-end")
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return positions;
|
|
148
|
+
});
|
|
149
|
+
}, [ticksData, yScale, isBandScale, bandGridLinePlacement]);
|
|
150
|
+
|
|
151
|
+
// Compute tick mark positions (including bounds closing tick mark for band scales)
|
|
152
|
+
const tickMarkPositions = useMemo(() => {
|
|
153
|
+
if (!yScale) return [];
|
|
154
|
+
return ticksData.flatMap((tick, index) => {
|
|
155
|
+
if (!isBandScale) {
|
|
156
|
+
return [{
|
|
157
|
+
y: tick.position,
|
|
158
|
+
key: "tick-mark-".concat(tick.tick, "-").concat(index)
|
|
159
|
+
}];
|
|
160
|
+
}
|
|
161
|
+
const bandScale = yScale;
|
|
162
|
+
const isLastTick = index === ticksData.length - 1;
|
|
163
|
+
const isEdges = bandTickMarkPlacement === 'edges';
|
|
164
|
+
const startY = getPointOnScale(tick.tick, bandScale, toPointAnchor(bandTickMarkPlacement));
|
|
165
|
+
const positions = [{
|
|
166
|
+
y: startY,
|
|
167
|
+
key: "tick-mark-".concat(tick.tick, "-").concat(index)
|
|
168
|
+
}];
|
|
169
|
+
|
|
170
|
+
// For edges on last tick, add the closing tick mark at stepEnd
|
|
171
|
+
if (isLastTick && isEdges) {
|
|
172
|
+
const endY = getPointOnScale(tick.tick, bandScale, 'stepEnd');
|
|
173
|
+
positions.push({
|
|
174
|
+
y: endY,
|
|
175
|
+
key: "tick-mark-".concat(tick.tick, "-").concat(index, "-end")
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return positions;
|
|
179
|
+
});
|
|
180
|
+
}, [ticksData, yScale, isBandScale, bandTickMarkPlacement]);
|
|
102
181
|
const chartTextData = useMemo(() => {
|
|
103
182
|
if (!axisBounds) return null;
|
|
104
183
|
return ticksData.map(tick => {
|
|
@@ -118,65 +197,119 @@ export const YAxis = /*#__PURE__*/memo(_ref => {
|
|
|
118
197
|
};
|
|
119
198
|
});
|
|
120
199
|
}, [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;
|
|
200
|
+
if (!yScale || !axisBounds || !drawingArea) return;
|
|
201
|
+
const labelX = position === 'left' ? axisBounds.x + LABEL_SIZE / 2 : axisBounds.x + axisBounds.width - LABEL_SIZE / 2;
|
|
202
|
+
const labelY = axisBounds.y + axisBounds.height / 2;
|
|
203
|
+
const tickXLeft = axisBounds.x;
|
|
204
|
+
const tickXRight = axisBounds.x + axisBounds.width;
|
|
205
|
+
const tickXStart = position === 'left' ? tickXRight : tickXLeft;
|
|
206
|
+
const tickXEnd = position === 'left' ? tickXRight - tickMarkSize : tickXLeft + tickMarkSize;
|
|
122
207
|
return /*#__PURE__*/_jsxs("g", _objectSpread(_objectSpread({
|
|
123
208
|
className: cx(className, classNames === null || classNames === void 0 ? void 0 : classNames.root),
|
|
124
209
|
"data-axis": "y",
|
|
125
210
|
"data-position": position,
|
|
126
211
|
style: _objectSpread(_objectSpread({}, style), styles === null || styles === void 0 ? void 0 : styles.root)
|
|
127
212
|
}, props), {}, {
|
|
128
|
-
children: [showGrid && /*#__PURE__*/_jsx(
|
|
129
|
-
|
|
130
|
-
children:
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
});
|
|
213
|
+
children: [showGrid && /*#__PURE__*/_jsx("g", {
|
|
214
|
+
"data-testid": "".concat(testID, "-grid"),
|
|
215
|
+
children: gridLinePositions.map(_ref2 => {
|
|
216
|
+
let {
|
|
217
|
+
y,
|
|
218
|
+
key
|
|
219
|
+
} = _ref2;
|
|
136
220
|
return animate ? /*#__PURE__*/_jsx(motion.g, {
|
|
137
|
-
animate:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
221
|
+
animate: {
|
|
222
|
+
opacity: 1
|
|
223
|
+
},
|
|
224
|
+
initial: {
|
|
225
|
+
opacity: 0
|
|
226
|
+
},
|
|
227
|
+
transition: axisUpdateAnimationTransition,
|
|
228
|
+
children: /*#__PURE__*/_jsx(GridLineComponent, {
|
|
229
|
+
animate: false,
|
|
230
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
|
|
231
|
+
clipRect: null,
|
|
232
|
+
d: lineToPath(drawingArea.x, y, drawingArea.x + drawingArea.width, y),
|
|
233
|
+
stroke: "var(--color-bgLine)",
|
|
234
|
+
style: styles === null || styles === void 0 ? void 0 : styles.gridLine
|
|
235
|
+
})
|
|
236
|
+
}, key) : /*#__PURE__*/_jsx(GridLineComponent, {
|
|
237
|
+
animate: false,
|
|
238
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.gridLine,
|
|
239
|
+
clipRect: null,
|
|
240
|
+
d: lineToPath(drawingArea.x, y, drawingArea.x + drawingArea.width, y),
|
|
241
|
+
stroke: "var(--color-bgLine)",
|
|
242
|
+
style: styles === null || styles === void 0 ? void 0 : styles.gridLine
|
|
243
|
+
}, key);
|
|
157
244
|
})
|
|
158
|
-
}),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
245
|
+
}), chartTextData && /*#__PURE__*/_jsx(ChartTextGroup, {
|
|
246
|
+
prioritizeEndLabels: true,
|
|
247
|
+
LabelComponent: TickLabelComponent,
|
|
248
|
+
labels: chartTextData,
|
|
249
|
+
minGap: minTickLabelGap
|
|
250
|
+
}), showTickMarks && /*#__PURE__*/_jsx("g", {
|
|
251
|
+
"data-testid": "".concat(testID, "-tick-marks"),
|
|
252
|
+
children: tickMarkPositions.map(_ref3 => {
|
|
253
|
+
let {
|
|
254
|
+
y,
|
|
255
|
+
key
|
|
256
|
+
} = _ref3;
|
|
257
|
+
return animate ? /*#__PURE__*/_jsx(motion.g, {
|
|
258
|
+
animate: {
|
|
259
|
+
opacity: 1
|
|
260
|
+
},
|
|
261
|
+
initial: {
|
|
262
|
+
opacity: 0
|
|
263
|
+
},
|
|
264
|
+
transition: axisUpdateAnimationTransition,
|
|
265
|
+
children: /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
266
|
+
animate: false,
|
|
267
|
+
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
268
|
+
clipRect: null,
|
|
269
|
+
d: lineToPath(tickXStart, y, tickXEnd, y),
|
|
270
|
+
stroke: "var(--color-fg)",
|
|
271
|
+
strokeLinecap: "square",
|
|
272
|
+
strokeWidth: 1,
|
|
273
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark
|
|
274
|
+
})
|
|
275
|
+
}, key) : /*#__PURE__*/_jsx(TickMarkLineComponent, {
|
|
276
|
+
animate: false,
|
|
165
277
|
className: cx(axisTickMarkCss, classNames === null || classNames === void 0 ? void 0 : classNames.tickMark),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
278
|
+
clipRect: null,
|
|
279
|
+
d: lineToPath(tickXStart, y, tickXEnd, y),
|
|
280
|
+
stroke: "var(--color-fg)",
|
|
281
|
+
strokeLinecap: "square",
|
|
282
|
+
strokeWidth: 1,
|
|
283
|
+
style: styles === null || styles === void 0 ? void 0 : styles.tickMark
|
|
284
|
+
}, key);
|
|
172
285
|
})
|
|
173
|
-
}),
|
|
286
|
+
}), showLine && /*#__PURE__*/_jsx(LineComponent, {
|
|
287
|
+
animate: false,
|
|
174
288
|
className: cx(axisLineCss, classNames === null || classNames === void 0 ? void 0 : classNames.line),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
289
|
+
clipRect: null,
|
|
290
|
+
d: lineToPath(position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y, position === 'left' ? axisBounds.x + axisBounds.width : axisBounds.x, axisBounds.y + axisBounds.height),
|
|
291
|
+
"data-testid": "".concat(testID, "-line"),
|
|
292
|
+
stroke: "var(--color-fg)",
|
|
293
|
+
strokeLinecap: "square",
|
|
294
|
+
strokeWidth: 1,
|
|
295
|
+
style: styles === null || styles === void 0 ? void 0 : styles.line
|
|
296
|
+
}), label && /*#__PURE__*/_jsx("g", {
|
|
297
|
+
"data-testid": "".concat(testID, "-label"),
|
|
298
|
+
style: {
|
|
299
|
+
transformOrigin: "".concat(labelX, "px ").concat(labelY, "px"),
|
|
300
|
+
transform: "rotate(".concat(position === 'left' ? -90 : 90, "deg)")
|
|
301
|
+
},
|
|
302
|
+
children: /*#__PURE__*/_jsx(ChartText, {
|
|
303
|
+
disableRepositioning: true,
|
|
304
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.label,
|
|
305
|
+
horizontalAlignment: "center",
|
|
306
|
+
style: styles === null || styles === void 0 ? void 0 : styles.label,
|
|
307
|
+
testID: "".concat(testID, "-label-text"),
|
|
308
|
+
verticalAlignment: "middle",
|
|
309
|
+
x: labelX,
|
|
310
|
+
y: labelY,
|
|
311
|
+
children: label
|
|
312
|
+
})
|
|
180
313
|
})]
|
|
181
314
|
}));
|
|
182
315
|
});
|