@gravity-ui/charts 1.8.0 → 1.10.0
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/dist/cjs/components/Axis/AxisX.d.ts +2 -1
- package/dist/cjs/components/Axis/AxisX.js +147 -141
- package/dist/cjs/components/Axis/AxisY.d.ts +2 -1
- package/dist/cjs/components/Axis/AxisY.js +118 -116
- package/dist/cjs/components/ChartInner/index.js +36 -9
- package/dist/cjs/components/ChartInner/useChartInnerHandlers.d.ts +1 -1
- package/dist/cjs/components/ChartInner/useChartInnerProps.d.ts +8 -5
- package/dist/cjs/components/ChartInner/useChartInnerProps.js +59 -10
- package/dist/cjs/components/ChartInner/utils.d.ts +3 -0
- package/dist/cjs/components/ChartInner/utils.js +28 -0
- package/dist/cjs/components/Legend/index.js +202 -191
- package/dist/cjs/components/Legend/styles.css +2 -0
- package/dist/cjs/components/Tooltip/ChartTooltipContent.d.ts +1 -1
- package/dist/cjs/components/Tooltip/DefaultContent.d.ts +1 -1
- package/dist/cjs/components/Tooltip/DefaultContent.js +1 -1
- package/dist/cjs/components/Tooltip/index.d.ts +1 -1
- package/dist/cjs/constants/chart-types.d.ts +12 -0
- package/dist/cjs/constants/chart-types.js +12 -0
- package/dist/cjs/constants/defaults/axis.d.ts +3 -1
- package/dist/cjs/constants/defaults/axis.js +10 -0
- package/dist/cjs/constants/index.d.ts +6 -47
- package/dist/cjs/constants/index.js +6 -72
- package/dist/cjs/constants/layout-algorithms.d.ts +7 -0
- package/dist/cjs/constants/layout-algorithms.js +8 -0
- package/dist/cjs/constants/line-styles.d.ts +20 -0
- package/dist/cjs/constants/line-styles.js +20 -0
- package/dist/cjs/constants/palette.d.ts +1 -0
- package/dist/cjs/constants/palette.js +22 -0
- package/dist/cjs/constants/symbol-types.d.ts +7 -0
- package/dist/cjs/constants/symbol-types.js +8 -0
- package/dist/cjs/constants/typography.d.ts +1 -0
- package/dist/cjs/constants/typography.js +1 -0
- package/dist/cjs/hooks/hooks-utils/index.d.ts +1 -0
- package/dist/cjs/hooks/hooks-utils/index.js +1 -0
- package/dist/cjs/hooks/hooks-utils/zoom.d.ts +8 -0
- package/dist/cjs/hooks/hooks-utils/zoom.js +81 -0
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/useAxisScales/index.d.ts +4 -2
- package/dist/cjs/hooks/useAxisScales/index.js +22 -8
- package/dist/cjs/hooks/useBrush/index.d.ts +3 -0
- package/dist/cjs/hooks/useBrush/index.js +70 -0
- package/dist/cjs/hooks/useBrush/styles.css +10 -0
- package/dist/cjs/hooks/useBrush/types.d.ts +24 -0
- package/dist/cjs/hooks/useBrush/types.js +1 -0
- package/dist/cjs/hooks/useChartDimensions/index.d.ts +3 -3
- package/dist/cjs/hooks/useChartDimensions/index.js +2 -2
- package/dist/cjs/hooks/useChartDimensions/utils.d.ts +2 -2
- package/dist/cjs/hooks/useChartOptions/chart.d.ts +2 -1
- package/dist/cjs/hooks/useChartOptions/chart.js +80 -1
- package/dist/cjs/hooks/useChartOptions/index.js +3 -2
- package/dist/cjs/hooks/useChartOptions/types.d.ts +6 -2
- package/dist/cjs/hooks/useChartOptions/x-axis.d.ts +3 -3
- package/dist/cjs/hooks/useChartOptions/x-axis.js +22 -13
- package/dist/cjs/hooks/useChartOptions/y-axis.d.ts +3 -3
- package/dist/cjs/hooks/useChartOptions/y-axis.js +36 -21
- package/dist/cjs/hooks/useCrosshair/index.d.ts +17 -0
- package/dist/cjs/hooks/useCrosshair/index.js +139 -0
- package/dist/cjs/hooks/useCrosshair/useCrosshairHover.d.ts +11 -0
- package/dist/cjs/hooks/useCrosshair/useCrosshairHover.js +18 -0
- package/dist/cjs/hooks/useSeries/index.d.ts +8 -6
- package/dist/cjs/hooks/useSeries/index.js +41 -22
- package/dist/cjs/hooks/useSeries/prepare-bar-y.d.ts +27 -2
- package/dist/cjs/hooks/useSeries/prepare-bar-y.js +5 -5
- package/dist/cjs/hooks/useSeries/prepare-legend.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepare-legend.js +27 -9
- package/dist/cjs/hooks/useSeries/prepare-line.d.ts +1 -2
- package/dist/cjs/hooks/useSeries/prepare-line.js +3 -3
- package/dist/cjs/hooks/useSeries/prepareSeries.d.ts +1 -1
- package/dist/cjs/hooks/useSeries/prepareSeries.js +2 -2
- package/dist/cjs/hooks/useSeries/types.d.ts +2 -1
- package/dist/cjs/hooks/useShapes/area/index.js +1 -1
- package/dist/cjs/hooks/useShapes/area/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/area/prepare-data.js +32 -16
- package/dist/cjs/hooks/useShapes/area/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/bar-x/prepare-data.js +17 -13
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/bar-y/prepare-data.js +6 -6
- package/dist/cjs/hooks/useShapes/index.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/index.js +40 -31
- package/dist/cjs/hooks/useShapes/line/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/line/prepare-data.js +14 -11
- package/dist/cjs/hooks/useShapes/line/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/marker.js +2 -2
- package/dist/cjs/hooks/useShapes/pie/index.js +3 -3
- package/dist/cjs/hooks/useShapes/pie/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/pie/prepare-data.js +15 -11
- package/dist/cjs/hooks/useShapes/radar/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/radar/prepare-data.js +6 -7
- package/dist/cjs/hooks/useShapes/radar/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/scatter/index.js +0 -1
- package/dist/cjs/hooks/useShapes/scatter/prepare-data.js +2 -0
- package/dist/cjs/hooks/useShapes/scatter/types.d.ts +1 -0
- package/dist/cjs/hooks/useShapes/treemap/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/treemap/prepare-data.js +19 -16
- package/dist/cjs/hooks/useShapes/waterfall/index.js +2 -2
- package/dist/cjs/hooks/useShapes/waterfall/prepare-data.d.ts +1 -1
- package/dist/cjs/hooks/useShapes/waterfall/prepare-data.js +8 -7
- package/dist/cjs/hooks/useZoom/index.d.ts +18 -0
- package/dist/cjs/hooks/useZoom/index.js +54 -0
- package/dist/cjs/hooks/useZoom/types.d.ts +19 -0
- package/dist/cjs/hooks/useZoom/types.js +1 -0
- package/dist/cjs/hooks/useZoom/utils.d.ts +12 -0
- package/dist/cjs/hooks/useZoom/utils.js +128 -0
- package/dist/cjs/types/chart/axis.d.ts +26 -21
- package/dist/cjs/types/chart/chart.d.ts +5 -0
- package/dist/cjs/types/chart/line.d.ts +1 -1
- package/dist/cjs/types/chart/pie.d.ts +1 -1
- package/dist/cjs/types/chart/series.d.ts +1 -1
- package/dist/cjs/types/chart/tooltip.d.ts +1 -1
- package/dist/cjs/types/chart/zoom.d.ts +36 -0
- package/dist/cjs/types/chart/zoom.js +1 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/misc.d.ts +7 -0
- package/dist/cjs/utils/chart/axis-generators/bottom.d.ts +1 -1
- package/dist/cjs/utils/chart/axis-generators/bottom.js +25 -25
- package/dist/cjs/utils/chart/axis.d.ts +2 -1
- package/dist/cjs/utils/chart/axis.js +10 -2
- package/dist/cjs/utils/chart/get-closest-data.js +1 -1
- package/dist/cjs/utils/chart/text.d.ts +7 -7
- package/dist/cjs/utils/chart/text.js +37 -29
- package/dist/cjs/utils/chart-ui/pie-center-text.d.ts +1 -1
- package/dist/cjs/utils/chart-ui/pie-center-text.js +2 -2
- package/dist/cjs/validation/index.d.ts +1 -1
- package/dist/cjs/validation/index.js +16 -16
- package/dist/esm/components/Axis/AxisX.d.ts +2 -1
- package/dist/esm/components/Axis/AxisX.js +147 -141
- package/dist/esm/components/Axis/AxisY.d.ts +2 -1
- package/dist/esm/components/Axis/AxisY.js +118 -116
- package/dist/esm/components/ChartInner/index.js +36 -9
- package/dist/esm/components/ChartInner/useChartInnerHandlers.d.ts +1 -1
- package/dist/esm/components/ChartInner/useChartInnerProps.d.ts +8 -5
- package/dist/esm/components/ChartInner/useChartInnerProps.js +59 -10
- package/dist/esm/components/ChartInner/utils.d.ts +3 -0
- package/dist/esm/components/ChartInner/utils.js +28 -0
- package/dist/esm/components/Legend/index.js +202 -191
- package/dist/esm/components/Legend/styles.css +2 -0
- package/dist/esm/components/Tooltip/ChartTooltipContent.d.ts +1 -1
- package/dist/esm/components/Tooltip/DefaultContent.d.ts +1 -1
- package/dist/esm/components/Tooltip/DefaultContent.js +1 -1
- package/dist/esm/components/Tooltip/index.d.ts +1 -1
- package/dist/esm/constants/chart-types.d.ts +12 -0
- package/dist/esm/constants/chart-types.js +12 -0
- package/dist/esm/constants/defaults/axis.d.ts +3 -1
- package/dist/esm/constants/defaults/axis.js +10 -0
- package/dist/esm/constants/index.d.ts +6 -47
- package/dist/esm/constants/index.js +6 -72
- package/dist/esm/constants/layout-algorithms.d.ts +7 -0
- package/dist/esm/constants/layout-algorithms.js +8 -0
- package/dist/esm/constants/line-styles.d.ts +20 -0
- package/dist/esm/constants/line-styles.js +20 -0
- package/dist/esm/constants/palette.d.ts +1 -0
- package/dist/esm/constants/palette.js +22 -0
- package/dist/esm/constants/symbol-types.d.ts +7 -0
- package/dist/esm/constants/symbol-types.js +8 -0
- package/dist/esm/constants/typography.d.ts +1 -0
- package/dist/esm/constants/typography.js +1 -0
- package/dist/esm/hooks/hooks-utils/index.d.ts +1 -0
- package/dist/esm/hooks/hooks-utils/index.js +1 -0
- package/dist/esm/hooks/hooks-utils/zoom.d.ts +8 -0
- package/dist/esm/hooks/hooks-utils/zoom.js +81 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/useAxisScales/index.d.ts +4 -2
- package/dist/esm/hooks/useAxisScales/index.js +22 -8
- package/dist/esm/hooks/useBrush/index.d.ts +3 -0
- package/dist/esm/hooks/useBrush/index.js +70 -0
- package/dist/esm/hooks/useBrush/styles.css +10 -0
- package/dist/esm/hooks/useBrush/types.d.ts +24 -0
- package/dist/esm/hooks/useBrush/types.js +1 -0
- package/dist/esm/hooks/useChartDimensions/index.d.ts +3 -3
- package/dist/esm/hooks/useChartDimensions/index.js +2 -2
- package/dist/esm/hooks/useChartDimensions/utils.d.ts +2 -2
- package/dist/esm/hooks/useChartOptions/chart.d.ts +2 -1
- package/dist/esm/hooks/useChartOptions/chart.js +80 -1
- package/dist/esm/hooks/useChartOptions/index.js +3 -2
- package/dist/esm/hooks/useChartOptions/types.d.ts +6 -2
- package/dist/esm/hooks/useChartOptions/x-axis.d.ts +3 -3
- package/dist/esm/hooks/useChartOptions/x-axis.js +22 -13
- package/dist/esm/hooks/useChartOptions/y-axis.d.ts +3 -3
- package/dist/esm/hooks/useChartOptions/y-axis.js +36 -21
- package/dist/esm/hooks/useCrosshair/index.d.ts +17 -0
- package/dist/esm/hooks/useCrosshair/index.js +139 -0
- package/dist/esm/hooks/useCrosshair/useCrosshairHover.d.ts +11 -0
- package/dist/esm/hooks/useCrosshair/useCrosshairHover.js +18 -0
- package/dist/esm/hooks/useSeries/index.d.ts +8 -6
- package/dist/esm/hooks/useSeries/index.js +41 -22
- package/dist/esm/hooks/useSeries/prepare-bar-y.d.ts +27 -2
- package/dist/esm/hooks/useSeries/prepare-bar-y.js +5 -5
- package/dist/esm/hooks/useSeries/prepare-legend.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepare-legend.js +27 -9
- package/dist/esm/hooks/useSeries/prepare-line.d.ts +1 -2
- package/dist/esm/hooks/useSeries/prepare-line.js +3 -3
- package/dist/esm/hooks/useSeries/prepareSeries.d.ts +1 -1
- package/dist/esm/hooks/useSeries/prepareSeries.js +2 -2
- package/dist/esm/hooks/useSeries/types.d.ts +2 -1
- package/dist/esm/hooks/useShapes/area/index.js +1 -1
- package/dist/esm/hooks/useShapes/area/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/area/prepare-data.js +32 -16
- package/dist/esm/hooks/useShapes/area/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/bar-x/prepare-data.js +17 -13
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/bar-y/prepare-data.js +6 -6
- package/dist/esm/hooks/useShapes/index.d.ts +1 -1
- package/dist/esm/hooks/useShapes/index.js +40 -31
- package/dist/esm/hooks/useShapes/line/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/line/prepare-data.js +14 -11
- package/dist/esm/hooks/useShapes/line/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/marker.js +2 -2
- package/dist/esm/hooks/useShapes/pie/index.js +3 -3
- package/dist/esm/hooks/useShapes/pie/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/pie/prepare-data.js +15 -11
- package/dist/esm/hooks/useShapes/radar/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/radar/prepare-data.js +6 -7
- package/dist/esm/hooks/useShapes/radar/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/scatter/index.js +0 -1
- package/dist/esm/hooks/useShapes/scatter/prepare-data.js +2 -0
- package/dist/esm/hooks/useShapes/scatter/types.d.ts +1 -0
- package/dist/esm/hooks/useShapes/treemap/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/treemap/prepare-data.js +19 -16
- package/dist/esm/hooks/useShapes/waterfall/index.js +2 -2
- package/dist/esm/hooks/useShapes/waterfall/prepare-data.d.ts +1 -1
- package/dist/esm/hooks/useShapes/waterfall/prepare-data.js +8 -7
- package/dist/esm/hooks/useZoom/index.d.ts +18 -0
- package/dist/esm/hooks/useZoom/index.js +54 -0
- package/dist/esm/hooks/useZoom/types.d.ts +19 -0
- package/dist/esm/hooks/useZoom/types.js +1 -0
- package/dist/esm/hooks/useZoom/utils.d.ts +12 -0
- package/dist/esm/hooks/useZoom/utils.js +128 -0
- package/dist/esm/types/chart/axis.d.ts +26 -21
- package/dist/esm/types/chart/chart.d.ts +5 -0
- package/dist/esm/types/chart/line.d.ts +1 -1
- package/dist/esm/types/chart/pie.d.ts +1 -1
- package/dist/esm/types/chart/series.d.ts +1 -1
- package/dist/esm/types/chart/tooltip.d.ts +1 -1
- package/dist/esm/types/chart/zoom.d.ts +36 -0
- package/dist/esm/types/chart/zoom.js +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/misc.d.ts +7 -0
- package/dist/esm/utils/chart/axis-generators/bottom.d.ts +1 -1
- package/dist/esm/utils/chart/axis-generators/bottom.js +25 -25
- package/dist/esm/utils/chart/axis.d.ts +2 -1
- package/dist/esm/utils/chart/axis.js +10 -2
- package/dist/esm/utils/chart/get-closest-data.js +1 -1
- package/dist/esm/utils/chart/text.d.ts +7 -7
- package/dist/esm/utils/chart/text.js +37 -29
- package/dist/esm/utils/chart-ui/pie-center-text.d.ts +1 -1
- package/dist/esm/utils/chart-ui/pie-center-text.js +2 -2
- package/dist/esm/validation/index.d.ts +1 -1
- package/dist/esm/validation/index.js +16 -16
- package/package.json +2 -1
|
@@ -7,7 +7,8 @@ type Props = {
|
|
|
7
7
|
height: number;
|
|
8
8
|
scale: ChartScale;
|
|
9
9
|
split: PreparedSplit;
|
|
10
|
-
|
|
10
|
+
plotBeforeRef?: React.MutableRefObject<SVGGElement | null>;
|
|
11
|
+
plotAfterRef?: React.MutableRefObject<SVGGElement | null>;
|
|
11
12
|
leftmostLimit?: number;
|
|
12
13
|
};
|
|
13
14
|
export declare function getTitlePosition(args: {
|
|
@@ -42,149 +42,155 @@ export function getTitlePosition(args) {
|
|
|
42
42
|
return { x, y };
|
|
43
43
|
}
|
|
44
44
|
export const AxisX = React.memo(function AxisX(props) {
|
|
45
|
-
const { axis, width, height: totalHeight, scale, split,
|
|
45
|
+
const { axis, width, height: totalHeight, scale, split, plotBeforeRef, plotAfterRef, leftmostLimit, } = props;
|
|
46
46
|
const ref = React.useRef(null);
|
|
47
47
|
React.useEffect(() => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
.append('text')
|
|
98
|
-
.attr('class', b('title'))
|
|
99
|
-
.attr('transform', () => {
|
|
100
|
-
const { x, y } = getTitlePosition({ axis, width, rowCount: titleRows.length });
|
|
101
|
-
return `translate(${x}, ${y})`;
|
|
102
|
-
})
|
|
103
|
-
.attr('font-size', axis.title.style.fontSize)
|
|
104
|
-
.attr('text-anchor', 'middle')
|
|
105
|
-
.selectAll('tspan')
|
|
106
|
-
.data(titleRows)
|
|
107
|
-
.join('tspan')
|
|
108
|
-
.attr('x', 0)
|
|
109
|
-
.attr('y', (d) => d.y)
|
|
110
|
-
.text((d) => d.text)
|
|
111
|
-
.each((_d, index, nodes) => {
|
|
112
|
-
if (index === axis.title.maxRowCount - 1) {
|
|
113
|
-
handleOverflowingText(nodes[index], width);
|
|
114
|
-
}
|
|
48
|
+
(async () => {
|
|
49
|
+
if (!ref.current) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const svgElement = select(ref.current);
|
|
53
|
+
svgElement.selectAll('*').remove();
|
|
54
|
+
const plotDataAttr = 'data-plot-x';
|
|
55
|
+
let plotBeforeContainer = null;
|
|
56
|
+
let plotAfterContainer = null;
|
|
57
|
+
if (plotBeforeRef === null || plotBeforeRef === void 0 ? void 0 : plotBeforeRef.current) {
|
|
58
|
+
plotBeforeContainer = select(plotBeforeRef.current);
|
|
59
|
+
plotBeforeContainer.selectAll(`[${plotDataAttr}]`).remove();
|
|
60
|
+
}
|
|
61
|
+
if (plotAfterRef === null || plotAfterRef === void 0 ? void 0 : plotAfterRef.current) {
|
|
62
|
+
plotAfterContainer = select(plotAfterRef.current);
|
|
63
|
+
plotAfterContainer.selectAll(`[${plotDataAttr}]`).remove();
|
|
64
|
+
}
|
|
65
|
+
if (!axis.visible) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
let tickItems = [];
|
|
69
|
+
if (axis.grid.enabled) {
|
|
70
|
+
tickItems = new Array(split.plots.length || 1).fill(null).map((_, index) => {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
const top = ((_a = split.plots[index]) === null || _a === void 0 ? void 0 : _a.top) || 0;
|
|
73
|
+
const height = ((_b = split.plots[index]) === null || _b === void 0 ? void 0 : _b.height) || totalHeight;
|
|
74
|
+
return [-top, -(top + height)];
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const axisScale = scale;
|
|
78
|
+
const xAxisGenerator = await axisBottom({
|
|
79
|
+
leftmostLimit,
|
|
80
|
+
scale: axisScale,
|
|
81
|
+
ticks: {
|
|
82
|
+
items: tickItems,
|
|
83
|
+
labelFormat: getLabelFormatter({ axis, scale }),
|
|
84
|
+
labelsPaddings: axis.labels.padding,
|
|
85
|
+
labelsMargin: axis.labels.margin,
|
|
86
|
+
labelsStyle: axis.labels.style,
|
|
87
|
+
labelsMaxWidth: axis.labels.maxWidth,
|
|
88
|
+
labelsLineHeight: axis.labels.lineHeight,
|
|
89
|
+
count: getTicksCount({ axis, range: width }),
|
|
90
|
+
maxTickCount: getMaxTickCount({ axis, width }),
|
|
91
|
+
rotation: axis.labels.rotation,
|
|
92
|
+
},
|
|
93
|
+
domain: {
|
|
94
|
+
size: width,
|
|
95
|
+
color: axis.lineColor,
|
|
96
|
+
},
|
|
115
97
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
98
|
+
svgElement.call(xAxisGenerator).attr('class', b());
|
|
99
|
+
// add an axis header if necessary
|
|
100
|
+
if (axis.title.text) {
|
|
101
|
+
const titleRows = await getAxisTitleRows({ axis, textMaxWidth: width });
|
|
102
|
+
svgElement
|
|
103
|
+
.append('text')
|
|
104
|
+
.attr('class', b('title'))
|
|
105
|
+
.attr('transform', () => {
|
|
106
|
+
const { x, y } = getTitlePosition({ axis, width, rowCount: titleRows.length });
|
|
107
|
+
return `translate(${x}, ${y})`;
|
|
108
|
+
})
|
|
109
|
+
.attr('font-size', axis.title.style.fontSize)
|
|
110
|
+
.attr('text-anchor', 'middle')
|
|
111
|
+
.selectAll('tspan')
|
|
112
|
+
.data(titleRows)
|
|
113
|
+
.join('tspan')
|
|
114
|
+
.attr('x', 0)
|
|
115
|
+
.attr('y', (d) => d.y)
|
|
116
|
+
.text((d) => d.text)
|
|
117
|
+
.each((_d, index, nodes) => {
|
|
118
|
+
if (index === axis.title.maxRowCount - 1) {
|
|
119
|
+
handleOverflowingText(nodes[index], width);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// add plot bands
|
|
124
|
+
if (axis.plotBands.length > 0) {
|
|
125
|
+
const plotBandDataAttr = 'plot-x-band';
|
|
126
|
+
const setPlotBands = (plotContainer, plotBands) => {
|
|
127
|
+
if (!plotContainer || !plotBands.length) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const plotBandsSelection = plotContainer
|
|
131
|
+
.selectAll(`[${plotBandDataAttr}]`)
|
|
132
|
+
.remove()
|
|
133
|
+
.data(plotBands)
|
|
134
|
+
.join('g')
|
|
135
|
+
.attr(plotDataAttr, 1)
|
|
136
|
+
.attr(plotBandDataAttr, 1);
|
|
137
|
+
plotBandsSelection
|
|
138
|
+
.append('rect')
|
|
139
|
+
.attr('x', (band) => {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
const { from, to } = getBandsPosition({ band, axisScale, axis: 'x' });
|
|
142
|
+
const halfBandwidth = ((_b = (_a = axisScale.bandwidth) === null || _a === void 0 ? void 0 : _a.call(axisScale)) !== null && _b !== void 0 ? _b : 0) / 2;
|
|
143
|
+
const startPos = halfBandwidth + Math.min(from, to);
|
|
144
|
+
return Math.max(0, startPos);
|
|
145
|
+
})
|
|
146
|
+
.attr('width', (band) => {
|
|
147
|
+
const { from, to } = getBandsPosition({ band, axisScale, axis: 'x' });
|
|
148
|
+
const startPos = width - Math.min(from, to);
|
|
149
|
+
const endPos = Math.min(Math.abs(to - from), startPos);
|
|
150
|
+
return Math.min(endPos, width);
|
|
151
|
+
})
|
|
152
|
+
.attr('y', 0)
|
|
153
|
+
.attr('height', totalHeight)
|
|
154
|
+
.attr('fill', (band) => band.color)
|
|
155
|
+
.attr('opacity', (band) => band.opacity);
|
|
156
|
+
};
|
|
157
|
+
setPlotBands(plotBeforeContainer, axis.plotBands.filter((d) => d.layerPlacement === 'before'));
|
|
158
|
+
setPlotBands(plotAfterContainer, axis.plotBands.filter((d) => d.layerPlacement === 'after'));
|
|
159
|
+
}
|
|
160
|
+
// add plot lines
|
|
161
|
+
if (axis.plotLines.length > 0) {
|
|
162
|
+
const plotLineDataAttr = 'plot-x-line';
|
|
163
|
+
const setPlotLines = (plotContainer, plotLines) => {
|
|
164
|
+
if (!plotContainer || !plotLines.length) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const plotLinesSelection = plotContainer
|
|
168
|
+
.selectAll(`[${plotLineDataAttr}]`)
|
|
169
|
+
.remove()
|
|
170
|
+
.data(plotLines)
|
|
171
|
+
.join('g')
|
|
172
|
+
.attr(plotDataAttr, 1)
|
|
173
|
+
.attr(plotLineDataAttr, 1);
|
|
174
|
+
const lineGenerator = line();
|
|
175
|
+
plotLinesSelection
|
|
176
|
+
.append('path')
|
|
177
|
+
.attr('d', (plotLine) => {
|
|
178
|
+
const plotLineValue = Number(axisScale(plotLine.value));
|
|
179
|
+
const points = [
|
|
180
|
+
[plotLineValue, 0],
|
|
181
|
+
[plotLineValue, totalHeight],
|
|
182
|
+
];
|
|
183
|
+
return lineGenerator(points);
|
|
184
|
+
})
|
|
185
|
+
.attr('stroke', (plotLine) => plotLine.color)
|
|
186
|
+
.attr('stroke-width', (plotLine) => plotLine.width)
|
|
187
|
+
.attr('stroke-dasharray', (plotLine) => getLineDashArray(plotLine.dashStyle, plotLine.width))
|
|
188
|
+
.attr('opacity', (plotLine) => plotLine.opacity);
|
|
189
|
+
};
|
|
190
|
+
setPlotLines(plotBeforeContainer, axis.plotLines.filter((d) => d.layerPlacement === 'before'));
|
|
191
|
+
setPlotLines(plotAfterContainer, axis.plotLines.filter((d) => d.layerPlacement === 'after'));
|
|
192
|
+
}
|
|
193
|
+
})();
|
|
194
|
+
}, [axis, width, totalHeight, scale, split, leftmostLimit, plotBeforeRef, plotAfterRef]);
|
|
189
195
|
return React.createElement("g", { ref: ref });
|
|
190
196
|
});
|
|
@@ -7,7 +7,8 @@ type Props = {
|
|
|
7
7
|
width: number;
|
|
8
8
|
height: number;
|
|
9
9
|
split: PreparedSplit;
|
|
10
|
-
|
|
10
|
+
plotBeforeRef?: React.MutableRefObject<SVGGElement | null>;
|
|
11
|
+
plotAfterRef?: React.MutableRefObject<SVGGElement | null>;
|
|
11
12
|
bottomLimit?: number;
|
|
12
13
|
};
|
|
13
14
|
export declare const AxisY: (props: Props) => React.JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { axisLeft, axisRight, line, select } from 'd3';
|
|
3
|
-
import { block, calculateCos, calculateSin, formatAxisTickLabel, getAxisHeight, getAxisTitleRows, getBandsPosition, getClosestPointsRange, getLineDashArray, getScaleTicks, getTicksCount, handleOverflowingText, parseTransformStyle, setEllipsisForOverflowTexts, wrapText, } from '../../utils';
|
|
3
|
+
import { block, calculateCos, calculateSin, formatAxisTickLabel, getAxisHeight, getAxisPlotsPosition, getAxisTitleRows, getBandsPosition, getClosestPointsRange, getLineDashArray, getScaleTicks, getTicksCount, handleOverflowingText, parseTransformStyle, setEllipsisForOverflowTexts, wrapText, } from '../../utils';
|
|
4
4
|
import './styles.css';
|
|
5
5
|
const b = block('axis');
|
|
6
6
|
function transformLabel(args) {
|
|
@@ -85,7 +85,7 @@ function getTitlePosition(args) {
|
|
|
85
85
|
return { x, y };
|
|
86
86
|
}
|
|
87
87
|
export const AxisY = (props) => {
|
|
88
|
-
const { axes: allAxes, width, height: totalHeight, scale, split,
|
|
88
|
+
const { axes: allAxes, width, height: totalHeight, scale, split, plotBeforeRef, plotAfterRef, bottomLimit = 0, } = props;
|
|
89
89
|
const height = getAxisHeight({ split, boundsHeight: totalHeight });
|
|
90
90
|
const ref = React.useRef(null);
|
|
91
91
|
const lineGenerator = line();
|
|
@@ -96,40 +96,23 @@ export const AxisY = (props) => {
|
|
|
96
96
|
const axes = allAxes.filter((a) => a.visible);
|
|
97
97
|
const svgElement = select(ref.current);
|
|
98
98
|
svgElement.selectAll('*').remove();
|
|
99
|
-
let
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
let plotBeforeContainer = null;
|
|
100
|
+
let plotAfterContainer = null;
|
|
101
|
+
const plotDataAttr = 'data-plot-y';
|
|
102
|
+
if (plotBeforeRef === null || plotBeforeRef === void 0 ? void 0 : plotBeforeRef.current) {
|
|
103
|
+
plotBeforeContainer = select(plotBeforeRef.current);
|
|
104
|
+
plotBeforeContainer.selectAll(`[${plotDataAttr}]`).remove();
|
|
105
|
+
}
|
|
106
|
+
if (plotAfterRef === null || plotAfterRef === void 0 ? void 0 : plotAfterRef.current) {
|
|
107
|
+
plotAfterContainer = select(plotAfterRef.current);
|
|
108
|
+
plotAfterContainer.selectAll(`[${plotDataAttr}]`).remove();
|
|
104
109
|
}
|
|
105
|
-
const getAxisPosition = (axis) => {
|
|
106
|
-
var _a;
|
|
107
|
-
const top = ((_a = split.plots[axis.plotIndex]) === null || _a === void 0 ? void 0 : _a.top) || 0;
|
|
108
|
-
if (axis.position === 'left') {
|
|
109
|
-
return `translate(0, ${top}px)`;
|
|
110
|
-
}
|
|
111
|
-
return `translate(${width}px, 0)`;
|
|
112
|
-
};
|
|
113
|
-
const plotLines = axes.reduce((acc, axis) => {
|
|
114
|
-
if (axis.plotLines.length) {
|
|
115
|
-
acc.push(...axis.plotLines.map((plotLine) => {
|
|
116
|
-
return Object.assign(Object.assign({}, plotLine), { transform: getAxisPosition(axis) });
|
|
117
|
-
}));
|
|
118
|
-
}
|
|
119
|
-
return acc;
|
|
120
|
-
}, []);
|
|
121
|
-
const plotBands = axes.reduce((acc, axis) => {
|
|
122
|
-
if (axis.plotBands.length) {
|
|
123
|
-
acc.push(...axis.plotBands.map((plotBand) => (Object.assign(Object.assign({}, plotBand), { transform: getAxisPosition(axis) }))));
|
|
124
|
-
}
|
|
125
|
-
return acc;
|
|
126
|
-
}, []);
|
|
127
110
|
const axisSelection = svgElement
|
|
128
111
|
.selectAll('axis')
|
|
129
112
|
.data(axes)
|
|
130
113
|
.join('g')
|
|
131
114
|
.attr('class', b())
|
|
132
|
-
.style('transform', (d) =>
|
|
115
|
+
.style('transform', (d) => getAxisPlotsPosition(d, split, width));
|
|
133
116
|
axisSelection.each((d, index, node) => {
|
|
134
117
|
const seriesScale = scale[index];
|
|
135
118
|
const axisItem = select(node[index]);
|
|
@@ -196,74 +179,74 @@ export const AxisY = (props) => {
|
|
|
196
179
|
})
|
|
197
180
|
.remove();
|
|
198
181
|
}
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
.
|
|
203
|
-
|
|
204
|
-
.join('g')
|
|
205
|
-
.attr('class', `${plotClassName} ${plotBandClassName}`)
|
|
206
|
-
.style('transform', (plotBand) => plotBand.transform);
|
|
207
|
-
plotBandsSelection
|
|
208
|
-
.append('rect')
|
|
209
|
-
.attr('x', 0)
|
|
210
|
-
.attr('width', width)
|
|
211
|
-
.attr('y', (band) => {
|
|
212
|
-
var _a, _b;
|
|
213
|
-
const { from, to } = getBandsPosition({ band, axisScale, axis: 'y' });
|
|
214
|
-
const halfBandwidth = ((_b = (_a = axisScale.bandwidth) === null || _a === void 0 ? void 0 : _a.call(axisScale)) !== null && _b !== void 0 ? _b : 0) / 2;
|
|
215
|
-
const startPos = halfBandwidth + Math.min(from, to);
|
|
216
|
-
return Math.max(0, startPos);
|
|
217
|
-
})
|
|
218
|
-
.attr('height', (band) => {
|
|
219
|
-
const { from, to } = getBandsPosition({ band, axisScale, axis: 'y' });
|
|
220
|
-
const startPos = height - Math.min(from, to);
|
|
221
|
-
const endPos = Math.min(Math.abs(to - from), startPos);
|
|
222
|
-
return Math.min(endPos, height);
|
|
223
|
-
})
|
|
224
|
-
.attr('fill', (band) => band.color)
|
|
225
|
-
.attr('opacity', (band) => band.opacity);
|
|
226
|
-
plotBandsSelection.each((plotBandData, i, nodes) => {
|
|
227
|
-
const plotLineSelection = select(nodes[i]);
|
|
228
|
-
if (plotBandData.layerPlacement === 'before') {
|
|
229
|
-
plotLineSelection.lower();
|
|
182
|
+
if (d.plotBands.length > 0) {
|
|
183
|
+
const plotBandDataAttr = `data-plot-y-band-${index}`;
|
|
184
|
+
const setPlotBands = (plotContainer, plotBands) => {
|
|
185
|
+
if (!plotContainer || !plotBands.length) {
|
|
186
|
+
return;
|
|
230
187
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
188
|
+
const plotBandsSelection = plotContainer
|
|
189
|
+
.selectAll(`[${plotBandDataAttr}]`)
|
|
190
|
+
.remove()
|
|
191
|
+
.data(plotBands)
|
|
192
|
+
.join('g')
|
|
193
|
+
.attr(plotDataAttr, 1)
|
|
194
|
+
.attr(plotBandDataAttr, 1)
|
|
195
|
+
.style('transform', getAxisPlotsPosition(d, split));
|
|
196
|
+
plotBandsSelection
|
|
197
|
+
.append('rect')
|
|
198
|
+
.attr('x', 0)
|
|
199
|
+
.attr('width', width)
|
|
200
|
+
.attr('y', (band) => {
|
|
201
|
+
var _a, _b;
|
|
202
|
+
const { from, to } = getBandsPosition({ band, axisScale, axis: 'y' });
|
|
203
|
+
const halfBandwidth = ((_b = (_a = axisScale.bandwidth) === null || _a === void 0 ? void 0 : _a.call(axisScale)) !== null && _b !== void 0 ? _b : 0) / 2;
|
|
204
|
+
const startPos = halfBandwidth + Math.min(from, to);
|
|
205
|
+
return Math.max(0, startPos);
|
|
206
|
+
})
|
|
207
|
+
.attr('height', (band) => {
|
|
208
|
+
const { from, to } = getBandsPosition({ band, axisScale, axis: 'y' });
|
|
209
|
+
const startPos = height - Math.min(from, to);
|
|
210
|
+
const endPos = Math.min(Math.abs(to - from), startPos);
|
|
211
|
+
return Math.min(endPos, height);
|
|
212
|
+
})
|
|
213
|
+
.attr('fill', (band) => band.color)
|
|
214
|
+
.attr('opacity', (band) => band.opacity);
|
|
215
|
+
};
|
|
216
|
+
setPlotBands(plotBeforeContainer, d.plotBands.filter((item) => item.layerPlacement === 'before'));
|
|
217
|
+
setPlotBands(plotAfterContainer, d.plotBands.filter((item) => item.layerPlacement === 'after'));
|
|
235
218
|
}
|
|
236
|
-
if (
|
|
237
|
-
const
|
|
238
|
-
const
|
|
239
|
-
.
|
|
240
|
-
|
|
241
|
-
.join('g')
|
|
242
|
-
.attr('class', `${plotClassName} ${plotLineClassName}`)
|
|
243
|
-
.style('transform', (plotLine) => plotLine.transform);
|
|
244
|
-
plotLinesSelection
|
|
245
|
-
.append('path')
|
|
246
|
-
.attr('d', (plotLine) => {
|
|
247
|
-
const plotLineValue = Number(axisScale(plotLine.value));
|
|
248
|
-
const points = [
|
|
249
|
-
[0, plotLineValue],
|
|
250
|
-
[width, plotLineValue],
|
|
251
|
-
];
|
|
252
|
-
return lineGenerator(points);
|
|
253
|
-
})
|
|
254
|
-
.attr('stroke', (plotLine) => plotLine.color)
|
|
255
|
-
.attr('stroke-width', (plotLine) => plotLine.width)
|
|
256
|
-
.attr('stroke-dasharray', (plotLine) => getLineDashArray(plotLine.dashStyle, plotLine.width))
|
|
257
|
-
.attr('opacity', (plotLine) => plotLine.opacity);
|
|
258
|
-
plotLinesSelection.each((plotLineData, i, nodes) => {
|
|
259
|
-
const plotLineSelection = select(nodes[i]);
|
|
260
|
-
if (plotLineData.layerPlacement === 'before') {
|
|
261
|
-
plotLineSelection.lower();
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
plotLineSelection.raise();
|
|
219
|
+
if (d.plotLines.length > 0) {
|
|
220
|
+
const plotLineDataAttr = `data-plot-y-line-${index}`;
|
|
221
|
+
const setPlotLines = (plotContainer, plotLines) => {
|
|
222
|
+
if (!plotContainer || !plotLines.length) {
|
|
223
|
+
return;
|
|
265
224
|
}
|
|
266
|
-
|
|
225
|
+
const plotLinesSelection = plotContainer
|
|
226
|
+
.selectAll(`[${plotLineDataAttr}]`)
|
|
227
|
+
.remove()
|
|
228
|
+
.data(plotLines)
|
|
229
|
+
.join('g')
|
|
230
|
+
.attr(plotDataAttr, 1)
|
|
231
|
+
.attr(plotLineDataAttr, 1)
|
|
232
|
+
.style('transform', getAxisPlotsPosition(d, split));
|
|
233
|
+
plotLinesSelection
|
|
234
|
+
.append('path')
|
|
235
|
+
.attr('d', (plotLine) => {
|
|
236
|
+
const plotLineValue = Number(axisScale(plotLine.value));
|
|
237
|
+
const points = [
|
|
238
|
+
[0, plotLineValue],
|
|
239
|
+
[width, plotLineValue],
|
|
240
|
+
];
|
|
241
|
+
return lineGenerator(points);
|
|
242
|
+
})
|
|
243
|
+
.attr('stroke', (plotLine) => plotLine.color)
|
|
244
|
+
.attr('stroke-width', (plotLine) => plotLine.width)
|
|
245
|
+
.attr('stroke-dasharray', (plotLine) => getLineDashArray(plotLine.dashStyle, plotLine.width))
|
|
246
|
+
.attr('opacity', (plotLine) => plotLine.opacity);
|
|
247
|
+
};
|
|
248
|
+
setPlotLines(plotBeforeContainer, d.plotLines.filter((item) => item.layerPlacement === 'before'));
|
|
249
|
+
setPlotLines(plotAfterContainer, d.plotLines.filter((item) => item.layerPlacement === 'after'));
|
|
267
250
|
}
|
|
268
251
|
return axisItem;
|
|
269
252
|
});
|
|
@@ -289,28 +272,47 @@ export const AxisY = (props) => {
|
|
|
289
272
|
.attr('class', b('title'))
|
|
290
273
|
.attr('text-anchor', 'middle')
|
|
291
274
|
.attr('font-size', (d) => d.title.style.fontSize)
|
|
292
|
-
.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
275
|
+
.call(async (s) => {
|
|
276
|
+
s.each(async function prepareAxisTitle(d) {
|
|
277
|
+
if (!this) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const selection = select(this);
|
|
281
|
+
const titleRows = await wrapText({
|
|
282
|
+
text: d.title.text,
|
|
283
|
+
style: d.title.style,
|
|
284
|
+
width: height,
|
|
285
|
+
});
|
|
286
|
+
const rowCount = Math.min(titleRows.length, d.title.maxRowCount);
|
|
287
|
+
const { x, y } = getTitlePosition({ axis: d, axisHeight: height, rowCount });
|
|
288
|
+
const angle = d.position === 'left' ? -90 : 90;
|
|
289
|
+
selection.attr('transform', `translate(${x}, ${y}) rotate(${angle})`);
|
|
290
|
+
const axisTitleRows = await getAxisTitleRows({ axis: d, textMaxWidth: height });
|
|
291
|
+
selection
|
|
292
|
+
.selectAll('tspan')
|
|
293
|
+
.data(axisTitleRows)
|
|
294
|
+
.join('tspan')
|
|
295
|
+
.attr('x', 0)
|
|
296
|
+
.attr('y', (titleRow) => titleRow.y)
|
|
297
|
+
.text((titleRow) => titleRow.text)
|
|
298
|
+
.each((_d, index, nodes) => {
|
|
299
|
+
if (index === nodes.length - 1) {
|
|
300
|
+
handleOverflowingText(nodes[index], height);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
297
303
|
});
|
|
298
|
-
|
|
299
|
-
const { x, y } = getTitlePosition({ axis: d, axisHeight: height, rowCount });
|
|
300
|
-
const angle = d.position === 'left' ? -90 : 90;
|
|
301
|
-
return `translate(${x}, ${y}) rotate(${angle})`;
|
|
302
|
-
})
|
|
303
|
-
.selectAll('tspan')
|
|
304
|
-
.data((d) => getAxisTitleRows({ axis: d, textMaxWidth: height }))
|
|
305
|
-
.join('tspan')
|
|
306
|
-
.attr('x', 0)
|
|
307
|
-
.attr('y', (d) => d.y)
|
|
308
|
-
.text((d) => d.text)
|
|
309
|
-
.each((_d, index, nodes) => {
|
|
310
|
-
if (index === nodes.length - 1) {
|
|
311
|
-
handleOverflowingText(nodes[index], height);
|
|
312
|
-
}
|
|
304
|
+
return s;
|
|
313
305
|
});
|
|
314
|
-
}, [
|
|
306
|
+
}, [
|
|
307
|
+
allAxes,
|
|
308
|
+
width,
|
|
309
|
+
height,
|
|
310
|
+
scale,
|
|
311
|
+
split,
|
|
312
|
+
bottomLimit,
|
|
313
|
+
lineGenerator,
|
|
314
|
+
plotBeforeRef,
|
|
315
|
+
plotAfterRef,
|
|
316
|
+
]);
|
|
315
317
|
return React.createElement("g", { ref: ref, className: b('container') });
|
|
316
318
|
};
|