@centreon/ui 24.7.0 → 24.7.1
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/LineChart/BasicComponents/Lines/Threshold/index.tsx +3 -3
- package/src/Graph/LineChart/LineChart.tsx +2 -0
- package/src/Graph/LineChart/index.tsx +2 -1
- package/src/Graph/LineChart/models.ts +1 -0
- package/src/Graph/common/Axes/index.tsx +3 -5
- package/src/Graph/common/BaseChart/BaseChart.tsx +5 -1
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +2 -2
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +7 -2
- package/src/Graph/index.ts +5 -0
- package/src/TimePeriods/index.tsx +10 -2
- package/src/TimePeriods/models.ts +1 -0
- package/src/index.ts +0 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +0 -60
package/package.json
CHANGED
|
@@ -55,14 +55,14 @@ const WrapperThresholdLines = ({
|
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
const thresholdLines = areaThresholdLines?.map((item, index) => {
|
|
58
|
-
const { type } = item;
|
|
58
|
+
const { type, id } = item;
|
|
59
59
|
|
|
60
60
|
if (equals(type, ThresholdType.basic)) {
|
|
61
61
|
return [
|
|
62
62
|
{
|
|
63
63
|
Component: BasicThreshold,
|
|
64
64
|
key: index,
|
|
65
|
-
props: { ...commonProps, getY0, getY1 }
|
|
65
|
+
props: { ...commonProps, getY0, getY1, id }
|
|
66
66
|
}
|
|
67
67
|
];
|
|
68
68
|
}
|
|
@@ -131,7 +131,7 @@ const WrapperThresholdLines = ({
|
|
|
131
131
|
<g>
|
|
132
132
|
{filteredThresholdLines.map((element) =>
|
|
133
133
|
element?.map(({ Component, props, key }) => (
|
|
134
|
-
<Component {...props} id={key} key={key} />
|
|
134
|
+
<Component {...props} id={props?.id ?? key} key={key} />
|
|
135
135
|
))
|
|
136
136
|
)}
|
|
137
137
|
</g>
|
|
@@ -123,6 +123,7 @@ const LineChart = ({
|
|
|
123
123
|
hasSecondUnit: Boolean(secondUnit),
|
|
124
124
|
height,
|
|
125
125
|
legendDisplay: legend?.display,
|
|
126
|
+
legendHeight: legend?.height,
|
|
126
127
|
legendPlacement: legend?.placement,
|
|
127
128
|
width
|
|
128
129
|
});
|
|
@@ -229,6 +230,7 @@ const LineChart = ({
|
|
|
229
230
|
height={height}
|
|
230
231
|
legend={{
|
|
231
232
|
displayLegend,
|
|
233
|
+
legendHeight: legend?.height,
|
|
232
234
|
mode: legend?.mode,
|
|
233
235
|
placement: legend?.placement,
|
|
234
236
|
renderExtraComponent: legend?.renderExtraComponent
|
|
@@ -11,6 +11,7 @@ import utcPlugin from 'dayjs/plugin/utc';
|
|
|
11
11
|
|
|
12
12
|
import { ParentSize } from '../..';
|
|
13
13
|
import { LineChartData, Thresholds } from '../common/models';
|
|
14
|
+
import Loading from '../../LoadingSkeleton';
|
|
14
15
|
|
|
15
16
|
import LineChart from './LineChart';
|
|
16
17
|
import LoadingSkeleton from './LoadingSkeleton';
|
|
@@ -73,7 +74,7 @@ const WrapperLineChart = ({
|
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
if (!adjustedData) {
|
|
76
|
-
return
|
|
77
|
+
return <Loading height={height} width={width} />;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
return (
|
|
@@ -45,12 +45,10 @@ const Axes = ({
|
|
|
45
45
|
|
|
46
46
|
const xTickCount = Math.min(Math.ceil(width / 82), 12);
|
|
47
47
|
|
|
48
|
+
const [start, end] = xScale.domain();
|
|
49
|
+
|
|
48
50
|
const tickFormat =
|
|
49
|
-
data?.axisX?.xAxisTickFormat ??
|
|
50
|
-
getXAxisTickFormat({
|
|
51
|
-
start: xScale.domain()[0],
|
|
52
|
-
start: xScale.domain()[-1]
|
|
53
|
-
});
|
|
51
|
+
data?.axisX?.xAxisTickFormat ?? getXAxisTickFormat({ end, start });
|
|
54
52
|
|
|
55
53
|
const formatAxisTick = (tick): string =>
|
|
56
54
|
format({ date: new Date(tick), formatString: tickFormat });
|
|
@@ -27,6 +27,7 @@ interface Props {
|
|
|
27
27
|
isHorizontal?: boolean;
|
|
28
28
|
legend: {
|
|
29
29
|
displayLegend: boolean;
|
|
30
|
+
legendHeight?: number;
|
|
30
31
|
mode?: 'grid' | 'list';
|
|
31
32
|
placement?: 'left' | 'right' | 'bottom';
|
|
32
33
|
renderExtraComponent?: ReactNode;
|
|
@@ -112,7 +113,10 @@ const BaseChart = ({
|
|
|
112
113
|
</Stack>
|
|
113
114
|
</div>
|
|
114
115
|
{legend.displayLegend && displayLegendInBottom && (
|
|
115
|
-
<div
|
|
116
|
+
<div
|
|
117
|
+
ref={legendRef}
|
|
118
|
+
style={{ height: legend?.legendHeight ?? 'undefined' }}
|
|
119
|
+
>
|
|
116
120
|
<Legend
|
|
117
121
|
base={base}
|
|
118
122
|
height={height}
|
|
@@ -4,10 +4,10 @@ import { Group } from '@visx/visx';
|
|
|
4
4
|
import { equals } from 'ramda';
|
|
5
5
|
|
|
6
6
|
import { margin } from '../../LineChart/common';
|
|
7
|
-
import
|
|
7
|
+
import { LineChartAxis } from '../../LineChart/models';
|
|
8
8
|
import Axes from '../Axes';
|
|
9
|
+
import Grids from '../Grids';
|
|
9
10
|
import { Line, TimeValue } from '../timeSeries/models';
|
|
10
|
-
import { LineChartAxis } from '../../LineChart/models';
|
|
11
11
|
|
|
12
12
|
import { extraMargin } from './useComputeBaseChartDimensions';
|
|
13
13
|
|
|
@@ -10,6 +10,7 @@ interface UseComputeBaseChartDimensionsProps {
|
|
|
10
10
|
hasSecondUnit?: boolean;
|
|
11
11
|
height: number | null;
|
|
12
12
|
legendDisplay?: boolean;
|
|
13
|
+
legendHeight?: number;
|
|
13
14
|
legendPlacement?: string;
|
|
14
15
|
width: number;
|
|
15
16
|
}
|
|
@@ -25,14 +26,18 @@ export const useComputeBaseChartDimensions = ({
|
|
|
25
26
|
height,
|
|
26
27
|
legendDisplay,
|
|
27
28
|
legendPlacement,
|
|
28
|
-
hasSecondUnit
|
|
29
|
+
hasSecondUnit,
|
|
30
|
+
legendHeight
|
|
29
31
|
}: UseComputeBaseChartDimensionsProps): UseComputeBaseChartDimensionsState => {
|
|
30
32
|
const legendRef = useRef<HTMLDivElement | null>(null);
|
|
31
33
|
|
|
34
|
+
const currentLegendHeight =
|
|
35
|
+
legendHeight ?? (legendRef.current?.getBoundingClientRect().height || 0);
|
|
36
|
+
|
|
32
37
|
const legendBoundingHeight =
|
|
33
38
|
!equals(legendDisplay, false) &&
|
|
34
39
|
(isNil(legendPlacement) || equals(legendPlacement, 'bottom'))
|
|
35
|
-
?
|
|
40
|
+
? currentLegendHeight
|
|
36
41
|
: 0;
|
|
37
42
|
const legendBoundingWidth =
|
|
38
43
|
!equals(legendDisplay, false) &&
|
package/src/Graph/index.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as LineChart } from './LineChart';
|
|
2
|
+
export { default as ThresholdLines } from './LineChart/BasicComponents/Lines/Threshold';
|
|
3
|
+
export { default as useLineChartData } from './LineChart/useLineChartData';
|
|
2
4
|
export { default as BarChart } from './BarChart/BarChart';
|
|
3
5
|
export { Gauge } from './Gauge';
|
|
4
6
|
export { SingleBar } from './SingleBar';
|
|
@@ -8,3 +10,6 @@ export { HeatMap } from './HeatMap';
|
|
|
8
10
|
export { BarStack } from './BarStack';
|
|
9
11
|
export { PieChart } from './PieChart';
|
|
10
12
|
export * from './Tree';
|
|
13
|
+
export type { LineChartData } from './common/models';
|
|
14
|
+
export * from './common/timeSeries';
|
|
15
|
+
export * from './LineChart/models';
|
|
@@ -9,6 +9,7 @@ import timezonePlugin from 'dayjs/plugin/timezone';
|
|
|
9
9
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
10
10
|
|
|
11
11
|
import { ParentSize } from '..';
|
|
12
|
+
import LoadingSkeleton from '../LoadingSkeleton';
|
|
12
13
|
|
|
13
14
|
import { WrapperTimePeriodProps } from './models';
|
|
14
15
|
import TimePeriods from './TimePeriods';
|
|
@@ -18,10 +19,17 @@ dayjs.extend(utcPlugin);
|
|
|
18
19
|
dayjs.extend(timezonePlugin);
|
|
19
20
|
dayjs.extend(duration);
|
|
20
21
|
|
|
21
|
-
const WrapperTimePeriods = (
|
|
22
|
+
const WrapperTimePeriods = ({
|
|
23
|
+
skeletonHeight = 38,
|
|
24
|
+
...rest
|
|
25
|
+
}: WrapperTimePeriodProps): JSX.Element => (
|
|
22
26
|
<ParentSize>
|
|
23
27
|
{({ width }): JSX.Element => {
|
|
24
|
-
return
|
|
28
|
+
return !width ? (
|
|
29
|
+
<LoadingSkeleton height={skeletonHeight} variant="rectangular" />
|
|
30
|
+
) : (
|
|
31
|
+
<TimePeriods width={width} {...rest} />
|
|
32
|
+
);
|
|
25
33
|
}}
|
|
26
34
|
</ParentSize>
|
|
27
35
|
);
|
package/src/index.ts
CHANGED
|
@@ -158,8 +158,6 @@ export { default as FluidTypography } from './Typography/FluidTypography';
|
|
|
158
158
|
export { default as EllipsisTypography } from './Typography/EllipsisTypography';
|
|
159
159
|
export * from './Dashboard';
|
|
160
160
|
export * from './Graph';
|
|
161
|
-
export type { LineChartData } from './Graph/common/models';
|
|
162
|
-
export * from './Graph/common/timeSeries';
|
|
163
161
|
|
|
164
162
|
export { default as TimePeriods } from './TimePeriods';
|
|
165
163
|
export { default as SimpleCustomTimePeriod } from './TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Dispatch, SetStateAction, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
import { equals, propEq, reject } from 'ramda';
|
|
4
|
-
|
|
5
|
-
import { Line } from '../../common/timeSeries/models';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
findLineOfOriginMetricThreshold,
|
|
9
|
-
lowerLineName,
|
|
10
|
-
upperLineName
|
|
11
|
-
} from './Lines/Threshold/models';
|
|
12
|
-
|
|
13
|
-
interface UseFilterLines {
|
|
14
|
-
displayThreshold?: boolean;
|
|
15
|
-
lines: Array<Line>;
|
|
16
|
-
linesGraph: Array<Line> | null;
|
|
17
|
-
setLinesGraph: Dispatch<SetStateAction<Array<Line> | null>>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface Result {
|
|
21
|
-
displayedLines: Array<Line>;
|
|
22
|
-
newLines: Array<Line>;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const useFilterLines = ({
|
|
26
|
-
displayThreshold = false,
|
|
27
|
-
lines,
|
|
28
|
-
linesGraph,
|
|
29
|
-
setLinesGraph
|
|
30
|
-
}: UseFilterLines): Result => {
|
|
31
|
-
const displayedLines = reject(propEq(false, 'display'), linesGraph ?? lines);
|
|
32
|
-
const filterLines = (): Array<Line> => {
|
|
33
|
-
const lineOriginMetric = findLineOfOriginMetricThreshold(lines);
|
|
34
|
-
|
|
35
|
-
const findLinesUpperLower = lines.map((line) =>
|
|
36
|
-
equals(line.name, lowerLineName) || equals(line.name, upperLineName)
|
|
37
|
-
? line
|
|
38
|
-
: null
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
const linesUpperLower = reject((element) => !element, findLinesUpperLower);
|
|
42
|
-
|
|
43
|
-
return [...lineOriginMetric, ...linesUpperLower] as Array<Line>;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
const filteredLines = filterLines();
|
|
48
|
-
if (!lines || !displayThreshold) {
|
|
49
|
-
setLinesGraph(lines);
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
setLinesGraph(filteredLines);
|
|
55
|
-
}, [lines, displayThreshold]);
|
|
56
|
-
|
|
57
|
-
return { displayedLines, newLines: linesGraph ?? lines };
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default useFilterLines;
|