@centreon/ui 24.10.20 → 24.10.22

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.10.20",
3
+ "version": "24.10.22",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -1,22 +1,23 @@
1
- import { RefCallback, memo, useEffect, useRef } from 'react';
1
+ import dayjs from "dayjs";
2
+ import "dayjs/locale/en";
3
+ import "dayjs/locale/es";
4
+ import "dayjs/locale/fr";
5
+ import "dayjs/locale/pt";
6
+ import { memo, useRef } from "react";
2
7
 
3
- import dayjs from 'dayjs';
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 useResizeObserver from 'use-resize-observer';
15
- import Chart from './Chart';
16
- import { useChartStyles } from './Chart.styles';
17
- import LoadingSkeleton from './LoadingSkeleton';
18
- import type { GlobalAreaLines, LineChartProps } from './models';
19
- import useChartData from './useChartData';
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,8 +32,12 @@ interface Props extends Partial<LineChartProps> {
31
32
  start: string;
32
33
  thresholdUnit?: string;
33
34
  thresholds?: Thresholds;
34
- getRef?: (ref: RefCallback<Element>) => void;
35
+ getRef?: (ref: React.RefObject<HTMLDivElement | null>) => void;
35
36
  containerStyle?: string;
37
+ transformMatrix?: {
38
+ fx?: (pointX: number) => number;
39
+ fy?: (pointY: number) => number;
40
+ };
36
41
  }
37
42
 
38
43
  const WrapperChart = ({
@@ -48,14 +53,14 @@ const WrapperChart = ({
48
53
  loading,
49
54
  timeShiftZones,
50
55
  tooltip = {
51
- mode: 'all',
52
- sortOrder: 'name'
56
+ mode: "all",
57
+ sortOrder: "name",
53
58
  },
54
59
  annotationEvent,
55
60
  legend = {
56
61
  display: true,
57
- mode: 'grid',
58
- placement: 'bottom'
62
+ mode: "grid",
63
+ placement: "bottom",
59
64
  },
60
65
  header,
61
66
  lineStyle,
@@ -64,18 +69,34 @@ const WrapperChart = ({
64
69
  thresholdUnit,
65
70
  limitLegend,
66
71
  getRef,
72
+ transformMatrix,
73
+ additionalLines,
74
+ min,
75
+ max,
76
+ boundariesUnit,
67
77
  ...rest
68
78
  }: Props): JSX.Element | null => {
69
79
  const { classes, cx } = useChartStyles();
70
- const ref = useRef<HTMLDivElement | null>(null);
71
-
72
80
  const { adjustedData } = useChartData({ data, end, start });
73
- const { width: responsiveWidth, height: responsiveHeight } =
74
- useResizeObserver({ ref });
75
81
 
76
- useEffect(() => {
77
- getRef?.(ref);
78
- }, [ref?.current]);
82
+ const containerRef = useRef<HTMLDivElement | null>(null);
83
+
84
+ const {
85
+ ref: resizeObserverRef,
86
+ width: responsiveWidth,
87
+ height: responsiveHeight,
88
+ } = useResizeObserver();
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
+
79
100
 
80
101
  if (loading && !adjustedData) {
81
102
  return (
@@ -86,13 +107,17 @@ const WrapperChart = ({
86
107
  );
87
108
  }
88
109
 
110
+ if (!adjustedData) {
111
+ return <NoData />;
112
+ }
113
+
89
114
  return (
90
115
  <div
91
- ref={ref}
116
+ ref={combinedRef}
92
117
  className={cx(classes.wrapperContainer, rest?.containerStyle)}
93
118
  >
94
119
  {!responsiveHeight || !data ? (
95
- <Loading height={height || '100%'} width={width} />
120
+ <Loading height={height || "100%"} width={width} />
96
121
  ) : (
97
122
  <Chart
98
123
  annotationEvent={annotationEvent}
@@ -101,7 +126,7 @@ const WrapperChart = ({
101
126
  displayAnchor={displayAnchor}
102
127
  graphData={adjustedData}
103
128
  graphInterval={{ end, start }}
104
- graphRef={ref}
129
+ graphRef={containerRef}
105
130
  header={header}
106
131
  height={height || responsiveHeight}
107
132
  legend={legend}
@@ -114,6 +139,12 @@ const WrapperChart = ({
114
139
  tooltip={tooltip}
115
140
  width={width || responsiveWidth || 0}
116
141
  zoomPreview={zoomPreview}
142
+ skipIntersectionObserver={rest.skipIntersectionObserver}
143
+ additionalLines={additionalLines}
144
+ transformMatrix={transformMatrix}
145
+ min={min}
146
+ max={max}
147
+ boundariesUnit={boundariesUnit}
117
148
  />
118
149
  )}
119
150
  </div>
@@ -7,3 +7,4 @@ export const labelDowntime = 'Downtime';
7
7
  export const labelMin = 'Min';
8
8
  export const labelMax = 'Max';
9
9
  export const labelAvg = 'Avg';
10
+ export const labelNoDataForThisPeriod = 'No data available for this period';
@@ -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;
@@ -1,20 +1,20 @@
1
- export type { ParentSizeProps } from '@visx/responsive/lib/components/ParentSize';
2
- export { default as LineChart } from './Chart';
3
- export { default as ThresholdLines } from './Chart/BasicComponents/Lines/Threshold';
4
- export { default as useLineChartData } from './Chart/useChartData';
5
- export { default as BarChart } from './BarChart/BarChart';
6
- export { Gauge } from './Gauge';
7
- export { SingleBar } from './SingleBar';
8
- export { Text as GraphText } from './Text';
9
- export { default as Header } from './common/BaseChart/Header';
10
-
11
- export { HeatMap } from './HeatMap';
12
- export { BarStack } from './BarStack';
13
- export { PieChart } from './PieChart';
14
- export { Timeline } from './Timeline';
15
- export * from './Tree';
16
- export type { LineChartData, Threshold, Thresholds } from './common/models';
17
- export * from './common/timeSeries';
18
- export type { Metric } from './common/timeSeries/models';
19
- export * from './Chart/models';
20
- export * from './PieChart/models';
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";