@centreon/ui 25.2.2 → 25.2.4
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/package.json +1 -1
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +2 -2
- package/src/Graph/BarChart/BarGroup.tsx +19 -59
- package/src/Graph/BarChart/MemoizedGroup.tsx +123 -0
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +17 -4
- package/src/Graph/Chart/Chart.cypress.spec.tsx +13 -21
- package/src/Graph/Chart/Chart.stories.tsx +1 -1
- package/src/Graph/Chart/Chart.tsx +50 -33
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +3 -3
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +19 -6
- package/src/Graph/common/Axes/index.tsx +1 -1
- package/src/Graph/common/Axes/useAxisY.ts +8 -4
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +12 -4
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +6 -4
- package/src/Graph/common/BaseChart/useComputeYAxisMaxCharacters.ts +92 -0
- package/src/Graph/common/models.ts +7 -8
- package/src/Graph/common/timeSeries/index.test.ts +1 -1
- package/src/Graph/common/timeSeries/index.ts +1 -7
- package/src/Graph/common/utils.ts +49 -1
- package/src/Graph/mockedData/lastDayWithNullValues.json +46 -12
- package/src/Graph/mockedData/pingServiceLinesBars.json +47 -47
- package/src/components/Zoom/Zoom.tsx +1 -1
- package/src/components/Zoom/ZoomContent.tsx +140 -133
- package/src/components/Zoom/models.ts +0 -2
- package/src/Graph/common/timeSeries/index.test.ts-E +0 -622
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ForwardedRef,
|
|
3
|
+
MutableRefObject,
|
|
4
|
+
forwardRef,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState
|
|
8
|
+
} from 'react';
|
|
2
9
|
|
|
3
10
|
import { RectClipPath } from '@visx/clip-path';
|
|
4
11
|
|
|
@@ -8,11 +15,16 @@ import ReplayIcon from '@mui/icons-material/Replay';
|
|
|
8
15
|
|
|
9
16
|
import { IconButton } from '../Button';
|
|
10
17
|
|
|
18
|
+
import Minimap from './Minimap';
|
|
19
|
+
import { useZoomStyles } from './Zoom.styles';
|
|
11
20
|
import { minimapScale, radius } from './constants';
|
|
21
|
+
import {
|
|
22
|
+
type Dimension,
|
|
23
|
+
type MinimapPosition,
|
|
24
|
+
ZoomChildren,
|
|
25
|
+
type ZoomInterface
|
|
26
|
+
} from './models';
|
|
12
27
|
import { useZoom } from './useZoom';
|
|
13
|
-
import { useZoomStyles } from './Zoom.styles';
|
|
14
|
-
import Minimap from './Minimap';
|
|
15
|
-
import { ZoomChildren, type Dimension, type MinimapPosition, type ZoomInterface } from './models';
|
|
16
28
|
|
|
17
29
|
export interface Props extends Dimension, ZoomInterface, ZoomChildren {
|
|
18
30
|
id?: number | string;
|
|
@@ -22,149 +34,144 @@ export interface Props extends Dimension, ZoomInterface, ZoomChildren {
|
|
|
22
34
|
|
|
23
35
|
const ZoomContent = forwardRef(
|
|
24
36
|
(
|
|
25
|
-
{
|
|
26
|
-
zoom,
|
|
27
|
-
width,
|
|
28
|
-
height,
|
|
29
|
-
children,
|
|
30
|
-
showMinimap,
|
|
31
|
-
minimapPosition,
|
|
32
|
-
id
|
|
33
|
-
}: Props,
|
|
37
|
+
{ zoom, width, height, children, showMinimap, minimapPosition, id }: Props,
|
|
34
38
|
ref?: ForwardedRef<SVGGElement | null>
|
|
35
|
-
)
|
|
36
|
-
|
|
39
|
+
): JSX.Element => {
|
|
40
|
+
const { classes } = useZoomStyles();
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const fallbackRef = useRef<SVGGElement | null>(null);
|
|
43
|
+
const contentRef = (ref ||
|
|
44
|
+
fallbackRef) as MutableRefObject<SVGGElement | null>;
|
|
45
|
+
const minimapSvgRef = useRef<SVGSVGElement | null>(null);
|
|
46
|
+
const minimapContentRef = useRef<SVGSVGElement | null>(null);
|
|
47
|
+
const [contentClientRect, setContentClientRect] =
|
|
48
|
+
useState<Dimension | null>(null);
|
|
43
49
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
51
|
+
const contentBoundingClientRect = (
|
|
52
|
+
contentRef.current as SVGGElement
|
|
53
|
+
).getBoundingClientRect();
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
setContentClientRect({
|
|
56
|
+
height: contentBoundingClientRect.height,
|
|
57
|
+
width: contentBoundingClientRect.width
|
|
58
|
+
});
|
|
52
59
|
});
|
|
53
|
-
});
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (contentRef.current) {
|
|
63
|
+
resizeObserver.disconnect();
|
|
64
|
+
resizeObserver.observe(contentRef.current);
|
|
65
|
+
}
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
return () => {
|
|
68
|
+
resizeObserver.disconnect();
|
|
69
|
+
};
|
|
70
|
+
}, [contentRef.current]);
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
const { move, dragEnd, dragStart, isDragging } = useZoom();
|
|
67
73
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
const diffBetweenContentAndSvg = minimapSvgRef.current &&
|
|
75
|
+
minimapContentRef.current && {
|
|
76
|
+
left:
|
|
77
|
+
minimapContentRef.current.getBoundingClientRect().left -
|
|
78
|
+
minimapSvgRef.current.getBoundingClientRect().left,
|
|
79
|
+
top:
|
|
80
|
+
minimapContentRef.current.getBoundingClientRect().top -
|
|
81
|
+
minimapSvgRef.current.getBoundingClientRect().top
|
|
82
|
+
};
|
|
77
83
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
>
|
|
93
|
-
<RectClipPath
|
|
94
|
-
height={Math.max(contentClientRect?.height || 0, height)}
|
|
95
|
-
id={`zoom-clip-${id}`}
|
|
96
|
-
rx={radius}
|
|
97
|
-
width={Math.max(contentClientRect?.width || 0, width)}
|
|
98
|
-
/>
|
|
99
|
-
<g
|
|
100
|
-
data-testid="zoom-content"
|
|
101
|
-
ref={contentRef}
|
|
102
|
-
transform={zoom.toString()}
|
|
84
|
+
return (
|
|
85
|
+
<div style={{ position: 'relative' }}>
|
|
86
|
+
<svg
|
|
87
|
+
className={classes.svg}
|
|
88
|
+
data-is-grabbing={isDragging}
|
|
89
|
+
data-testid="zoom-container"
|
|
90
|
+
height={height}
|
|
91
|
+
width={width}
|
|
92
|
+
onMouseDown={dragStart(zoom)}
|
|
93
|
+
onMouseEnter={dragStart(zoom)}
|
|
94
|
+
onMouseLeave={dragEnd}
|
|
95
|
+
onMouseMove={move(zoom)}
|
|
96
|
+
onMouseUp={dragEnd}
|
|
97
|
+
onWheel={zoom.handleWheel}
|
|
103
98
|
>
|
|
104
|
-
|
|
105
|
-
contentClientRect,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
width,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{showMinimap && contentClientRect && (
|
|
115
|
-
<svg
|
|
116
|
-
className={classes.minimapContainer}
|
|
117
|
-
data-testid="minimap"
|
|
118
|
-
height={height * minimapScale}
|
|
119
|
-
ref={minimapSvgRef}
|
|
120
|
-
width={width * minimapScale}
|
|
99
|
+
<RectClipPath
|
|
100
|
+
height={Math.max(contentClientRect?.height || 0, height)}
|
|
101
|
+
id={`zoom-clip-${id}`}
|
|
102
|
+
rx={radius}
|
|
103
|
+
width={Math.max(contentClientRect?.width || 0, width)}
|
|
104
|
+
/>
|
|
105
|
+
<g
|
|
106
|
+
data-testid="zoom-content"
|
|
107
|
+
ref={contentRef}
|
|
108
|
+
transform={zoom.toString()}
|
|
121
109
|
>
|
|
122
|
-
|
|
123
|
-
contentClientRect
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
110
|
+
{children({
|
|
111
|
+
contentClientRect,
|
|
112
|
+
height,
|
|
113
|
+
transformMatrix: zoom.transformMatrix,
|
|
114
|
+
width,
|
|
115
|
+
zoom
|
|
116
|
+
})}
|
|
117
|
+
</g>
|
|
118
|
+
</svg>
|
|
119
|
+
<div className={classes.actionsAndZoom} data-position={minimapPosition}>
|
|
120
|
+
{showMinimap && contentClientRect && (
|
|
121
|
+
<svg
|
|
122
|
+
className={classes.minimapContainer}
|
|
123
|
+
data-testid="minimap"
|
|
124
|
+
height={height * minimapScale}
|
|
125
|
+
ref={minimapSvgRef}
|
|
126
|
+
width={width * minimapScale}
|
|
132
127
|
>
|
|
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
|
-
|
|
128
|
+
<Minimap
|
|
129
|
+
contentClientRect={contentClientRect}
|
|
130
|
+
diffBetweenContentAndSvg={
|
|
131
|
+
diffBetweenContentAndSvg || { left: 0, top: 0 }
|
|
132
|
+
}
|
|
133
|
+
height={height}
|
|
134
|
+
id={id}
|
|
135
|
+
isDraggingFromContainer={isDragging}
|
|
136
|
+
width={width}
|
|
137
|
+
zoom={zoom}
|
|
138
|
+
>
|
|
139
|
+
<g ref={minimapContentRef}>
|
|
140
|
+
{children({
|
|
141
|
+
contentClientRect,
|
|
142
|
+
height,
|
|
143
|
+
transformMatrix: zoom.transformMatrix,
|
|
144
|
+
width,
|
|
145
|
+
zoom
|
|
146
|
+
})}
|
|
147
|
+
</g>
|
|
148
|
+
</Minimap>
|
|
149
|
+
</svg>
|
|
150
|
+
)}
|
|
151
|
+
<div className={classes.actions}>
|
|
152
|
+
<IconButton
|
|
153
|
+
data-testid="zoom in"
|
|
154
|
+
icon={<ZoomInIcon />}
|
|
155
|
+
size="small"
|
|
156
|
+
onClick={() => zoom.scale({ scaleX: 1.2, scaleY: 1.2 })}
|
|
157
|
+
/>
|
|
158
|
+
<IconButton
|
|
159
|
+
data-testid="zoom out"
|
|
160
|
+
icon={<ZoomOutIcon />}
|
|
161
|
+
size="small"
|
|
162
|
+
onClick={() => zoom.scale({ scaleX: 0.8, scaleY: 0.8 })}
|
|
163
|
+
/>
|
|
164
|
+
<IconButton
|
|
165
|
+
data-testid="clear"
|
|
166
|
+
icon={<ReplayIcon />}
|
|
167
|
+
size="small"
|
|
168
|
+
onClick={zoom.reset}
|
|
169
|
+
/>
|
|
170
|
+
</div>
|
|
164
171
|
</div>
|
|
165
172
|
</div>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
);
|
|
169
176
|
|
|
170
177
|
export default ZoomContent;
|