@coinbase/cds-web-visualization 3.4.0-beta.2 → 3.4.0-beta.21
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 +122 -0
- package/dts/chart/CartesianChart.d.ts +56 -3
- package/dts/chart/CartesianChart.d.ts.map +1 -1
- package/dts/chart/ChartProvider.d.ts +3 -0
- package/dts/chart/ChartProvider.d.ts.map +1 -1
- package/dts/chart/Path.d.ts +64 -7
- package/dts/chart/Path.d.ts.map +1 -1
- package/dts/chart/PeriodSelector.d.ts +5 -15
- package/dts/chart/PeriodSelector.d.ts.map +1 -1
- package/dts/chart/area/Area.d.ts +50 -25
- package/dts/chart/area/Area.d.ts.map +1 -1
- package/dts/chart/area/AreaChart.d.ts +46 -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 +50 -12
- package/dts/chart/bar/Bar.d.ts.map +1 -1
- package/dts/chart/bar/BarChart.d.ts +20 -8
- package/dts/chart/bar/BarChart.d.ts.map +1 -1
- package/dts/chart/bar/BarPlot.d.ts +3 -1
- package/dts/chart/bar/BarPlot.d.ts.map +1 -1
- package/dts/chart/bar/BarStack.d.ts +41 -46
- package/dts/chart/bar/BarStack.d.ts.map +1 -1
- package/dts/chart/bar/BarStackGroup.d.ts +2 -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 +3 -1
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +21 -0
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +1 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts +7 -0
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +1 -0
- package/dts/chart/legend/Legend.d.ts +169 -0
- package/dts/chart/legend/Legend.d.ts.map +1 -0
- package/dts/chart/legend/index.d.ts +4 -0
- package/dts/chart/legend/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 +15 -3
- package/dts/chart/line/DottedLine.d.ts.map +1 -1
- package/dts/chart/line/Line.d.ts +84 -28
- package/dts/chart/line/Line.d.ts.map +1 -1
- package/dts/chart/line/LineChart.d.ts +28 -8
- package/dts/chart/line/LineChart.d.ts.map +1 -1
- package/dts/chart/line/ReferenceLine.d.ts +99 -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 +217 -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 +41 -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 +303 -70
- package/dts/chart/scrubber/Scrubber.d.ts.map +1 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +80 -0
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +1 -0
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +56 -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/bar.d.ts +34 -0
- package/dts/chart/utils/bar.d.ts.map +1 -1
- package/dts/chart/utils/chart.d.ts +45 -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 +30 -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 +40 -0
- package/dts/chart/utils/scrubber.d.ts.map +1 -0
- package/dts/chart/utils/transition.d.ts +101 -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 +170 -83
- package/esm/chart/ChartProvider.js +2 -2
- package/esm/chart/Path.js +59 -54
- package/esm/chart/PeriodSelector.js +36 -32
- package/esm/chart/area/Area.js +26 -34
- package/esm/chart/area/AreaChart.js +29 -15
- package/esm/chart/area/DottedArea.js +39 -89
- package/esm/chart/area/GradientArea.js +37 -80
- package/esm/chart/area/SolidArea.js +32 -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 +7 -1
- package/esm/chart/bar/BarChart.js +17 -32
- package/esm/chart/bar/BarPlot.js +5 -2
- package/esm/chart/bar/BarStack.js +74 -22
- package/esm/chart/bar/BarStackGroup.js +8 -18
- package/esm/chart/bar/DefaultBar.js +23 -28
- package/esm/chart/bar/DefaultBarStack.js +24 -20
- package/esm/chart/gradient/Gradient.js +104 -0
- package/esm/chart/gradient/index.js +1 -0
- package/esm/chart/index.js +3 -1
- package/esm/chart/legend/DefaultLegendEntry.css +1 -0
- package/esm/chart/legend/DefaultLegendEntry.js +50 -0
- package/esm/chart/legend/DefaultLegendShape.css +5 -0
- package/esm/chart/legend/DefaultLegendShape.js +47 -0
- package/esm/chart/legend/Legend.js +76 -0
- package/esm/chart/legend/index.js +3 -0
- package/esm/chart/line/DefaultReferenceLineLabel.js +81 -0
- package/esm/chart/line/DottedLine.js +41 -17
- package/esm/chart/line/Line.js +87 -75
- package/esm/chart/line/LineChart.js +24 -8
- package/esm/chart/line/ReferenceLine.js +45 -43
- package/esm/chart/line/SolidLine.js +39 -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} +87 -62
- package/esm/chart/point/index.js +2 -0
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +154 -0
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +57 -0
- package/esm/chart/scrubber/{ScrubberBeaconLabel.js → DefaultScrubberLabel.js} +15 -18
- package/esm/chart/scrubber/Scrubber.js +101 -392
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +174 -0
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +209 -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 +47 -31
- package/esm/chart/utils/bar.js +48 -0
- package/esm/chart/utils/chart.js +42 -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 +41 -9
- package/esm/chart/utils/point.js +99 -12
- package/esm/chart/utils/scale.js +13 -2
- package/esm/chart/utils/scrubber.js +137 -0
- package/esm/chart/utils/transition.js +133 -0
- package/esm/sparkline/__figma__/Sparkline.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +8 -4
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +1 -1
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +1 -1
- package/package.json +12 -11
- 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/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
|
});
|
package/esm/chart/axis/index.js
CHANGED
package/esm/chart/bar/Bar.js
CHANGED
|
@@ -23,6 +23,7 @@ export const Bar = /*#__PURE__*/memo(_ref => {
|
|
|
23
23
|
originY,
|
|
24
24
|
dataX,
|
|
25
25
|
dataY,
|
|
26
|
+
seriesId,
|
|
26
27
|
BarComponent = DefaultBar,
|
|
27
28
|
fill = 'var(--color-fgPrimary)',
|
|
28
29
|
fillOpacity = 1,
|
|
@@ -30,7 +31,9 @@ export const Bar = /*#__PURE__*/memo(_ref => {
|
|
|
30
31
|
strokeWidth,
|
|
31
32
|
borderRadius = 4,
|
|
32
33
|
roundTop = true,
|
|
33
|
-
roundBottom = true
|
|
34
|
+
roundBottom = true,
|
|
35
|
+
transitions,
|
|
36
|
+
transition
|
|
34
37
|
} = _ref;
|
|
35
38
|
const barPath = useMemo(() => {
|
|
36
39
|
return getBarPath(x, y, width, height, borderRadius, roundTop, roundBottom);
|
|
@@ -50,8 +53,11 @@ export const Bar = /*#__PURE__*/memo(_ref => {
|
|
|
50
53
|
originY: effectiveOriginY,
|
|
51
54
|
roundBottom: roundBottom,
|
|
52
55
|
roundTop: roundTop,
|
|
56
|
+
seriesId: seriesId,
|
|
53
57
|
stroke: stroke,
|
|
54
58
|
strokeWidth: strokeWidth,
|
|
59
|
+
transition: transition,
|
|
60
|
+
transitions: transitions,
|
|
55
61
|
width: width,
|
|
56
62
|
x: x,
|
|
57
63
|
y: y
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize"],
|
|
1
|
+
const _excluded = ["series", "stacked", "showXAxis", "showYAxis", "xAxis", "yAxis", "inset", "children", "barPadding", "BarComponent", "fillOpacity", "stroke", "strokeWidth", "borderRadius", "roundBaseline", "BarStackComponent", "stackGap", "barMinSize", "stackMinSize", "transitions", "transition"],
|
|
2
2
|
_excluded2 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range"],
|
|
3
3
|
_excluded3 = ["scaleType", "data", "categoryPadding", "domain", "domainLimit", "range", "id"];
|
|
4
4
|
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; }
|
|
@@ -22,7 +22,7 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
|
|
|
22
22
|
showYAxis,
|
|
23
23
|
xAxis,
|
|
24
24
|
yAxis,
|
|
25
|
-
inset
|
|
25
|
+
inset,
|
|
26
26
|
children,
|
|
27
27
|
barPadding,
|
|
28
28
|
BarComponent,
|
|
@@ -34,44 +34,27 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
|
|
|
34
34
|
BarStackComponent,
|
|
35
35
|
stackGap,
|
|
36
36
|
barMinSize,
|
|
37
|
-
stackMinSize
|
|
37
|
+
stackMinSize,
|
|
38
|
+
transitions,
|
|
39
|
+
transition
|
|
38
40
|
} = _ref,
|
|
39
41
|
chartProps = _objectWithoutProperties(_ref, _excluded);
|
|
40
|
-
const calculatedInset = useMemo(() => getChartInset(
|
|
41
|
-
|
|
42
|
-
// Convert BarSeries to Series for Chart context
|
|
43
|
-
const chartSeries = useMemo(() => {
|
|
44
|
-
return series === null || series === void 0 ? void 0 : series.map(s => ({
|
|
45
|
-
id: s.id,
|
|
46
|
-
data: s.data,
|
|
47
|
-
label: s.label,
|
|
48
|
-
color: s.color,
|
|
49
|
-
yAxisId: s.yAxisId,
|
|
50
|
-
stackId: s.stackId
|
|
51
|
-
}));
|
|
52
|
-
}, [series]);
|
|
42
|
+
const calculatedInset = useMemo(() => getChartInset(inset, defaultChartInset), [inset]);
|
|
53
43
|
const transformedSeries = useMemo(() => {
|
|
54
|
-
if (!stacked || !chartSeries) return chartSeries;
|
|
55
|
-
return chartSeries.map(s => {
|
|
56
|
-
var _s$stackId;
|
|
57
|
-
return _objectSpread(_objectSpread({}, s), {}, {
|
|
58
|
-
stackId: (_s$stackId = s.stackId) !== null && _s$stackId !== void 0 ? _s$stackId : defaultStackId
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
}, [chartSeries, stacked]);
|
|
62
|
-
const seriesToRender = transformedSeries !== null && transformedSeries !== void 0 ? transformedSeries : chartSeries;
|
|
63
|
-
|
|
64
|
-
// Keep the original series with bar-specific props for BarPlot
|
|
65
|
-
const barSeriesToRender = useMemo(() => {
|
|
66
44
|
if (!stacked || !series) return series;
|
|
67
45
|
return series.map(s => {
|
|
68
|
-
var _s$
|
|
46
|
+
var _s$stackId;
|
|
69
47
|
return _objectSpread(_objectSpread({}, s), {}, {
|
|
70
|
-
stackId: (_s$
|
|
48
|
+
stackId: (_s$stackId = s.stackId) !== null && _s$stackId !== void 0 ? _s$stackId : defaultStackId
|
|
71
49
|
});
|
|
72
50
|
});
|
|
73
51
|
}, [series, stacked]);
|
|
74
52
|
|
|
53
|
+
// Unlike other charts with custom props per series, we do not need to pick out
|
|
54
|
+
// the props from each series that shouldn't be passed to CartesianChart
|
|
55
|
+
const seriesToRender = transformedSeries !== null && transformedSeries !== void 0 ? transformedSeries : series;
|
|
56
|
+
const seriesIds = seriesToRender === null || seriesToRender === void 0 ? void 0 : seriesToRender.map(s => s.id);
|
|
57
|
+
|
|
75
58
|
// Split axis props into config props for Chart and visual props for axis components
|
|
76
59
|
const _ref2 = xAxis || {},
|
|
77
60
|
{
|
|
@@ -137,11 +120,13 @@ export const BarChart = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) =>
|
|
|
137
120
|
borderRadius: borderRadius,
|
|
138
121
|
fillOpacity: fillOpacity,
|
|
139
122
|
roundBaseline: roundBaseline,
|
|
140
|
-
seriesIds:
|
|
123
|
+
seriesIds: seriesIds,
|
|
141
124
|
stackGap: stackGap,
|
|
142
125
|
stackMinSize: stackMinSize,
|
|
143
126
|
stroke: stroke,
|
|
144
|
-
strokeWidth: strokeWidth
|
|
127
|
+
strokeWidth: strokeWidth,
|
|
128
|
+
transition: transition,
|
|
129
|
+
transitions: transitions
|
|
145
130
|
}), children]
|
|
146
131
|
}));
|
|
147
132
|
}));
|
package/esm/chart/bar/BarPlot.js
CHANGED
|
@@ -22,7 +22,9 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
|
|
|
22
22
|
BarStackComponent,
|
|
23
23
|
stackGap,
|
|
24
24
|
barMinSize,
|
|
25
|
-
stackMinSize
|
|
25
|
+
stackMinSize,
|
|
26
|
+
transitions,
|
|
27
|
+
transition
|
|
26
28
|
} = _ref;
|
|
27
29
|
const {
|
|
28
30
|
series: allSeries,
|
|
@@ -73,7 +75,6 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
|
|
|
73
75
|
})
|
|
74
76
|
}), /*#__PURE__*/_jsx("g", {
|
|
75
77
|
clipPath: "url(#".concat(clipPathId, ")"),
|
|
76
|
-
"data-testid": "whoa",
|
|
77
78
|
children: stackGroups.map((group, stackIndex) => /*#__PURE__*/_jsx(BarStackGroup, {
|
|
78
79
|
BarComponent: defaultBarComponent,
|
|
79
80
|
BarStackComponent: BarStackComponent,
|
|
@@ -89,6 +90,8 @@ export const BarPlot = /*#__PURE__*/memo(_ref => {
|
|
|
89
90
|
stroke: defaultStroke,
|
|
90
91
|
strokeWidth: defaultStrokeWidth,
|
|
91
92
|
totalStacks: stackGroups.length,
|
|
93
|
+
transition: transition,
|
|
94
|
+
transitions: transitions,
|
|
92
95
|
yAxisId: group.yAxisId
|
|
93
96
|
}, group.stackId))
|
|
94
97
|
})]
|