@centreon/ui 25.10.10 → 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
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import { memo, type RefCallback, useEffect, useRef } from "react";
|
|
3
|
+
import "dayjs/locale/en";
|
|
4
|
+
import "dayjs/locale/es";
|
|
5
|
+
import "dayjs/locale/fr";
|
|
6
|
+
import "dayjs/locale/pt";
|
|
2
7
|
|
|
3
|
-
import
|
|
4
|
-
import 'dayjs/locale/en';
|
|
5
|
-
import 'dayjs/locale/es';
|
|
6
|
-
import 'dayjs/locale/fr';
|
|
7
|
-
import 'dayjs/locale/pt';
|
|
8
|
-
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
9
|
-
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
10
|
-
import utcPlugin from 'dayjs/plugin/utc';
|
|
11
|
-
import Loading from '../../LoadingSkeleton';
|
|
12
|
-
import type { LineChartData, Thresholds } from '../common/models';
|
|
8
|
+
import { NoData } from "@centreon/ui";
|
|
13
9
|
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
10
|
+
import localizedFormat from "dayjs/plugin/localizedFormat";
|
|
11
|
+
import timezonePlugin from "dayjs/plugin/timezone";
|
|
12
|
+
import utcPlugin from "dayjs/plugin/utc";
|
|
13
|
+
import useResizeObserver from "use-resize-observer";
|
|
14
|
+
import Loading from "../../LoadingSkeleton";
|
|
15
|
+
import type { LineChartData, Thresholds } from "../common/models";
|
|
16
|
+
import Chart from "./Chart";
|
|
17
|
+
import { useChartStyles } from "./Chart.styles";
|
|
18
|
+
import LoadingSkeleton from "./LoadingSkeleton";
|
|
19
|
+
import type { GlobalAreaLines, LineChartProps } from "./models";
|
|
20
|
+
import useChartData from "./useChartData";
|
|
20
21
|
|
|
21
22
|
dayjs.extend(localizedFormat);
|
|
22
23
|
dayjs.extend(utcPlugin);
|
|
@@ -31,7 +32,7 @@ interface Props extends Partial<LineChartProps> {
|
|
|
31
32
|
start: string;
|
|
32
33
|
thresholdUnit?: string;
|
|
33
34
|
thresholds?: Thresholds;
|
|
34
|
-
getRef?: (ref:
|
|
35
|
+
getRef?: (ref: React.RefObject<HTMLDivElement | null>) => void;
|
|
35
36
|
containerStyle?: string;
|
|
36
37
|
transformMatrix?: {
|
|
37
38
|
fx?: (pointX: number) => number;
|
|
@@ -52,14 +53,14 @@ const WrapperChart = ({
|
|
|
52
53
|
loading,
|
|
53
54
|
timeShiftZones,
|
|
54
55
|
tooltip = {
|
|
55
|
-
mode:
|
|
56
|
-
sortOrder:
|
|
56
|
+
mode: "all",
|
|
57
|
+
sortOrder: "name",
|
|
57
58
|
},
|
|
58
59
|
annotationEvent,
|
|
59
60
|
legend = {
|
|
60
61
|
display: true,
|
|
61
|
-
mode:
|
|
62
|
-
placement:
|
|
62
|
+
mode: "grid",
|
|
63
|
+
placement: "bottom",
|
|
63
64
|
},
|
|
64
65
|
header,
|
|
65
66
|
lineStyle,
|
|
@@ -76,17 +77,26 @@ const WrapperChart = ({
|
|
|
76
77
|
...rest
|
|
77
78
|
}: Props): JSX.Element | null => {
|
|
78
79
|
const { classes, cx } = useChartStyles();
|
|
79
|
-
|
|
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
|
-
height: responsiveHeight
|
|
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 (
|
|
@@ -97,13 +107,17 @@ const WrapperChart = ({
|
|
|
97
107
|
);
|
|
98
108
|
}
|
|
99
109
|
|
|
110
|
+
if (!adjustedData) {
|
|
111
|
+
return <NoData />;
|
|
112
|
+
}
|
|
113
|
+
|
|
100
114
|
return (
|
|
101
115
|
<div
|
|
102
|
-
ref={
|
|
116
|
+
ref={combinedRef}
|
|
103
117
|
className={cx(classes.wrapperContainer, rest?.containerStyle)}
|
|
104
118
|
>
|
|
105
119
|
{!responsiveHeight ? (
|
|
106
|
-
<Loading height={height ||
|
|
120
|
+
<Loading height={height || "100%"} width={width} />
|
|
107
121
|
) : (
|
|
108
122
|
<Chart
|
|
109
123
|
annotationEvent={annotationEvent}
|
|
@@ -112,7 +126,7 @@ const WrapperChart = ({
|
|
|
112
126
|
displayAnchor={displayAnchor}
|
|
113
127
|
graphData={adjustedData}
|
|
114
128
|
graphInterval={{ end, start }}
|
|
115
|
-
graphRef={
|
|
129
|
+
graphRef={containerRef}
|
|
116
130
|
header={header}
|
|
117
131
|
height={height || responsiveHeight || 0}
|
|
118
132
|
legend={legend}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Typography } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
|
|
5
|
+
import { labelNoDataForThisPeriod } from '../../Chart/translatedLabels';
|
|
6
|
+
|
|
7
|
+
const NoData = () => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
return (
|
|
10
|
+
<div className={'flex items-center justify-center h-full'}>
|
|
11
|
+
<Typography align="center" variant="body1">
|
|
12
|
+
{t(labelNoDataForThisPeriod)}
|
|
13
|
+
</Typography>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default NoData;
|
package/src/Graph/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export type { ParentSizeProps } from
|
|
2
|
-
export { default as
|
|
3
|
-
export {
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export { default as
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export * from
|
|
1
|
+
export type { ParentSizeProps } from "@visx/responsive/lib/components/ParentSize";
|
|
2
|
+
export { default as BarChart } from "./BarChart/BarChart";
|
|
3
|
+
export { BarStack } from "./BarStack";
|
|
4
|
+
export { default as LineChart } from "./Chart";
|
|
5
|
+
export { default as ThresholdLines } from "./Chart/BasicComponents/Lines/Threshold";
|
|
6
|
+
export * from "./Chart/models";
|
|
7
|
+
export { default as useLineChartData } from "./Chart/useChartData";
|
|
8
|
+
export { default as Header } from "./common/BaseChart/Header";
|
|
9
|
+
export { default as NoData } from "./common/Error/NoData";
|
|
10
|
+
export type { LineChartData, Threshold, Thresholds } from "./common/models";
|
|
11
|
+
export * from "./common/timeSeries";
|
|
12
|
+
export type { Metric } from "./common/timeSeries/models";
|
|
13
|
+
export { Gauge } from "./Gauge";
|
|
14
|
+
export { HeatMap } from "./HeatMap";
|
|
15
|
+
export { PieChart } from "./PieChart";
|
|
16
|
+
export * from "./PieChart/models";
|
|
17
|
+
export { SingleBar } from "./SingleBar";
|
|
18
|
+
export { Text as GraphText } from "./Text";
|
|
19
|
+
export { Timeline } from "./Timeline";
|
|
20
|
+
export * from "./Tree";
|