@centreon/ui 25.10.11 → 25.10.12
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/Chart/index.tsx +18 -8
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import dayjs from "dayjs";
|
|
2
|
-
import { memo, type RefCallback, useEffect } from "react";
|
|
2
|
+
import { memo, type RefCallback, useEffect, useRef } from "react";
|
|
3
3
|
import "dayjs/locale/en";
|
|
4
4
|
import "dayjs/locale/es";
|
|
5
5
|
import "dayjs/locale/fr";
|
|
@@ -32,7 +32,7 @@ interface Props extends Partial<LineChartProps> {
|
|
|
32
32
|
start: string;
|
|
33
33
|
thresholdUnit?: string;
|
|
34
34
|
thresholds?: Thresholds;
|
|
35
|
-
getRef?: (ref:
|
|
35
|
+
getRef?: (ref: React.RefObject<HTMLDivElement | null>) => void;
|
|
36
36
|
containerStyle?: string;
|
|
37
37
|
transformMatrix?: {
|
|
38
38
|
fx?: (pointX: number) => number;
|
|
@@ -78,15 +78,25 @@ const WrapperChart = ({
|
|
|
78
78
|
}: Props): JSX.Element | null => {
|
|
79
79
|
const { classes, cx } = useChartStyles();
|
|
80
80
|
const { adjustedData } = useChartData({ data, end, start });
|
|
81
|
+
|
|
82
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
83
|
+
|
|
81
84
|
const {
|
|
82
|
-
ref,
|
|
85
|
+
ref: resizeObserverRef,
|
|
83
86
|
width: responsiveWidth,
|
|
84
87
|
height: responsiveHeight,
|
|
85
88
|
} = useResizeObserver();
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
const combinedRef = (element: HTMLDivElement | null) => {
|
|
91
|
+
if (containerRef.current !== element) {
|
|
92
|
+
containerRef.current = element;
|
|
93
|
+
if (element) {
|
|
94
|
+
getRef?.(containerRef);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
resizeObserverRef(element);
|
|
98
|
+
};
|
|
99
|
+
|
|
90
100
|
|
|
91
101
|
if (loading && !adjustedData) {
|
|
92
102
|
return (
|
|
@@ -103,7 +113,7 @@ const WrapperChart = ({
|
|
|
103
113
|
|
|
104
114
|
return (
|
|
105
115
|
<div
|
|
106
|
-
ref={
|
|
116
|
+
ref={combinedRef}
|
|
107
117
|
className={cx(classes.wrapperContainer, rest?.containerStyle)}
|
|
108
118
|
>
|
|
109
119
|
{!responsiveHeight ? (
|
|
@@ -116,7 +126,7 @@ const WrapperChart = ({
|
|
|
116
126
|
displayAnchor={displayAnchor}
|
|
117
127
|
graphData={adjustedData}
|
|
118
128
|
graphInterval={{ end, start }}
|
|
119
|
-
graphRef={
|
|
129
|
+
graphRef={containerRef}
|
|
120
130
|
header={header}
|
|
121
131
|
height={height || responsiveHeight || 0}
|
|
122
132
|
legend={legend}
|