@centreon/ui 24.10.19 → 24.10.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/package.json +2 -2
- package/src/Graph/Chart/index.tsx +40 -29
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.10.
|
|
3
|
+
"version": "24.10.21",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update:deps": "pnpx npm-check-updates -i --format group",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"vite-plugin-turbosnap": "^1.0.3"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@centreon/ui-context": "
|
|
108
|
+
"@centreon/ui-context": "workspace:*"
|
|
109
109
|
},
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"@lexical/html": "^0.17.0",
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import dayjs
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import Loading from
|
|
12
|
-
import type { LineChartData, Thresholds } from
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import type { GlobalAreaLines, LineChartProps } from './models';
|
|
19
|
-
import useChartData from './useChartData';
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { memo, useRef } from "react";
|
|
3
|
+
import "dayjs/locale/en";
|
|
4
|
+
import "dayjs/locale/es";
|
|
5
|
+
import "dayjs/locale/fr";
|
|
6
|
+
import "dayjs/locale/pt";
|
|
7
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
8
|
+
import timezonePlugin from "dayjs/plugin/timezone";
|
|
9
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
10
|
+
import useResizeObserver from "use-resize-observer";
|
|
11
|
+
import Loading from "../../LoadingSkeleton";
|
|
12
|
+
import type { LineChartData, Thresholds } from "../common/models";
|
|
13
|
+
import Chart from "./Chart";
|
|
14
|
+
import { useChartStyles } from "./Chart.styles";
|
|
15
|
+
import LoadingSkeleton from "./LoadingSkeleton";
|
|
16
|
+
import type { GlobalAreaLines, LineChartProps } from "./models";
|
|
17
|
+
import useChartData from "./useChartData";
|
|
20
18
|
|
|
21
19
|
dayjs.extend(localizedFormat);
|
|
22
20
|
dayjs.extend(utcPlugin);
|
|
@@ -31,7 +29,7 @@ interface Props extends Partial<LineChartProps> {
|
|
|
31
29
|
start: string;
|
|
32
30
|
thresholdUnit?: string;
|
|
33
31
|
thresholds?: Thresholds;
|
|
34
|
-
getRef?: (ref:
|
|
32
|
+
getRef?: (ref: React.RefObject<HTMLDivElement | null>) => void;
|
|
35
33
|
containerStyle?: string;
|
|
36
34
|
}
|
|
37
35
|
|
|
@@ -48,8 +46,8 @@ const WrapperChart = ({
|
|
|
48
46
|
loading,
|
|
49
47
|
timeShiftZones,
|
|
50
48
|
tooltip = {
|
|
51
|
-
mode:
|
|
52
|
-
sortOrder:
|
|
49
|
+
mode: "all",
|
|
50
|
+
sortOrder: "name",
|
|
53
51
|
},
|
|
54
52
|
annotationEvent,
|
|
55
53
|
legend = {
|
|
@@ -70,12 +68,25 @@ const WrapperChart = ({
|
|
|
70
68
|
const ref = useRef<HTMLDivElement | null>(null);
|
|
71
69
|
|
|
72
70
|
const { adjustedData } = useChartData({ data, end, start });
|
|
73
|
-
const { width: responsiveWidth, height: responsiveHeight } =
|
|
74
|
-
useResizeObserver({ ref });
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
73
|
+
|
|
74
|
+
const {
|
|
75
|
+
ref: resizeObserverRef,
|
|
76
|
+
width: responsiveWidth,
|
|
77
|
+
height: responsiveHeight,
|
|
78
|
+
} = useResizeObserver();
|
|
79
|
+
|
|
80
|
+
const combinedRef = (element: HTMLDivElement | null) => {
|
|
81
|
+
if (containerRef.current !== element) {
|
|
82
|
+
containerRef.current = element;
|
|
83
|
+
if (element) {
|
|
84
|
+
getRef?.(containerRef);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
resizeObserverRef(element);
|
|
88
|
+
};
|
|
89
|
+
|
|
79
90
|
|
|
80
91
|
if (loading && !adjustedData) {
|
|
81
92
|
return (
|
|
@@ -88,7 +99,7 @@ const WrapperChart = ({
|
|
|
88
99
|
|
|
89
100
|
return (
|
|
90
101
|
<div
|
|
91
|
-
ref={
|
|
102
|
+
ref={combinedRef}
|
|
92
103
|
className={cx(classes.wrapperContainer, rest?.containerStyle)}
|
|
93
104
|
>
|
|
94
105
|
{!responsiveHeight || !data ? (
|
|
@@ -101,7 +112,7 @@ const WrapperChart = ({
|
|
|
101
112
|
displayAnchor={displayAnchor}
|
|
102
113
|
graphData={adjustedData}
|
|
103
114
|
graphInterval={{ end, start }}
|
|
104
|
-
graphRef={
|
|
115
|
+
graphRef={containerRef}
|
|
105
116
|
header={header}
|
|
106
117
|
height={height || responsiveHeight}
|
|
107
118
|
legend={legend}
|