@centreon/ui 24.4.1-MON-154124.7 → 24.4.1-MON-154024.0
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/HeatMap/ResponsiveHeatMap.tsx +2 -19
- package/src/Graph/HeatMap/model.ts +1 -5
- package/src/Graph/LineChart/Legend/Legend.styles.ts +16 -5
- package/src/Graph/LineChart/Legend/index.tsx +12 -5
- package/src/Graph/LineChart/LineChart.tsx +10 -9
- package/src/Graph/common/utils.ts +3 -2
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { scaleLinear } from '@visx/scale';
|
|
4
4
|
import { T, equals, gt, lt } from 'ramda';
|
|
@@ -13,7 +13,6 @@ import { useHeatMapStyles } from './HeatMap.styles';
|
|
|
13
13
|
const gap = 8;
|
|
14
14
|
const maxTileSize = 120;
|
|
15
15
|
const smallestTileSize = 44;
|
|
16
|
-
const toleratedRangeWidth = 10;
|
|
17
16
|
|
|
18
17
|
const ResponsiveHeatMap = <TData,>({
|
|
19
18
|
width,
|
|
@@ -25,7 +24,6 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
25
24
|
displayTooltipCondition = T
|
|
26
25
|
}: HeatMapProps<TData> & { width: number }): JSX.Element | null => {
|
|
27
26
|
const { classes, cx } = useHeatMapStyles();
|
|
28
|
-
const previousTileSize = useRef(0);
|
|
29
27
|
|
|
30
28
|
const tileSize = useMemo(() => {
|
|
31
29
|
const scaleWidth = scaleLinear({
|
|
@@ -41,12 +39,6 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
41
39
|
tilesLength * maxTileSize + (tilesLength - 1) * gap;
|
|
42
40
|
const theoricalTotalTilesWidth =
|
|
43
41
|
tilesLength * tileWidth + (tilesLength - 1) * gap;
|
|
44
|
-
const canUpdateTileSize =
|
|
45
|
-
Math.abs(tileWidth - previousTileSize.current) > toleratedRangeWidth;
|
|
46
|
-
|
|
47
|
-
if (!canUpdateTileSize) {
|
|
48
|
-
return previousTileSize.current;
|
|
49
|
-
}
|
|
50
42
|
|
|
51
43
|
if (lt(width, 680) && gt(maxTotalTilesWidth, width) && !tileSizeFixed) {
|
|
52
44
|
return smallestTileSize;
|
|
@@ -60,8 +52,6 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
60
52
|
}, [width, tiles]);
|
|
61
53
|
|
|
62
54
|
const isSmallestSize = equals(tileSize, smallestTileSize);
|
|
63
|
-
const isMediumSize = !isSmallestSize && lt(tileSize, 90);
|
|
64
|
-
previousTileSize.current = tileSize;
|
|
65
55
|
|
|
66
56
|
if (equals(width, 0)) {
|
|
67
57
|
return null;
|
|
@@ -102,14 +92,7 @@ const ResponsiveHeatMap = <TData,>({
|
|
|
102
92
|
position="right-start"
|
|
103
93
|
>
|
|
104
94
|
<div className={classes.heatMapTileContent}>
|
|
105
|
-
{children({
|
|
106
|
-
backgroundColor,
|
|
107
|
-
data,
|
|
108
|
-
id,
|
|
109
|
-
isMediumSize,
|
|
110
|
-
isSmallestSize,
|
|
111
|
-
tileSize
|
|
112
|
-
})}
|
|
95
|
+
{children({ backgroundColor, data, id, isSmallestSize })}
|
|
113
96
|
</div>
|
|
114
97
|
</Tooltip>
|
|
115
98
|
</Box>
|
|
@@ -10,9 +10,7 @@ interface ChildrenProps<TData> {
|
|
|
10
10
|
backgroundColor: string;
|
|
11
11
|
data: TData;
|
|
12
12
|
id: string;
|
|
13
|
-
isMediumSize?: boolean;
|
|
14
13
|
isSmallestSize: boolean;
|
|
15
|
-
tileSize?: number;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
export interface HeatMapProps<TData> {
|
|
@@ -21,9 +19,7 @@ export interface HeatMapProps<TData> {
|
|
|
21
19
|
backgroundColor,
|
|
22
20
|
id,
|
|
23
21
|
data,
|
|
24
|
-
isSmallestSize
|
|
25
|
-
tileSize,
|
|
26
|
-
isMediumSize
|
|
22
|
+
isSmallestSize
|
|
27
23
|
}: ChildrenProps<TData>) => ReactElement | boolean | null;
|
|
28
24
|
displayTooltipCondition?: (data: TData) => boolean;
|
|
29
25
|
tileSizeFixed?: boolean;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { lt } from 'ramda';
|
|
1
2
|
import { makeStyles } from 'tss-react/mui';
|
|
2
3
|
|
|
3
4
|
import { margin } from '../common';
|
|
4
5
|
|
|
5
6
|
interface MakeStylesProps {
|
|
7
|
+
height?: number | null;
|
|
6
8
|
limitLegendRows?: boolean;
|
|
7
9
|
}
|
|
8
10
|
|
|
@@ -10,8 +12,16 @@ export const legendWidth = 21;
|
|
|
10
12
|
const legendItemHeight = 5.25;
|
|
11
13
|
const legendItemHeightCompact = 2;
|
|
12
14
|
|
|
15
|
+
const getLegendMaxHeight = ({ height }): number => {
|
|
16
|
+
if (lt(height || 0, 220)) {
|
|
17
|
+
return 40;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return 90;
|
|
21
|
+
};
|
|
22
|
+
|
|
13
23
|
export const useStyles = makeStyles<MakeStylesProps>()(
|
|
14
|
-
(theme, { limitLegendRows }) => ({
|
|
24
|
+
(theme, { limitLegendRows, height = 0 }) => ({
|
|
15
25
|
highlight: {
|
|
16
26
|
color: theme.typography.body1.color
|
|
17
27
|
},
|
|
@@ -29,9 +39,6 @@ export const useStyles = makeStyles<MakeStylesProps>()(
|
|
|
29
39
|
display: 'grid',
|
|
30
40
|
gridAutoRows: theme.spacing(legendItemHeight),
|
|
31
41
|
gridTemplateColumns: `repeat(auto-fit, minmax(${theme.spacing(legendWidth)}, 1fr))`,
|
|
32
|
-
maxHeight: limitLegendRows
|
|
33
|
-
? theme.spacing(legendItemHeight * 2 + 1)
|
|
34
|
-
: 'unset',
|
|
35
42
|
overflowX: 'hidden',
|
|
36
43
|
overflowY: 'auto',
|
|
37
44
|
rowGap: theme.spacing(1),
|
|
@@ -40,7 +47,11 @@ export const useStyles = makeStyles<MakeStylesProps>()(
|
|
|
40
47
|
legend: {
|
|
41
48
|
marginLeft: margin.left,
|
|
42
49
|
marginRight: margin.right,
|
|
43
|
-
|
|
50
|
+
maxHeight: limitLegendRows
|
|
51
|
+
? theme.spacing(legendItemHeight * 2 + 1)
|
|
52
|
+
: getLegendMaxHeight({ height }),
|
|
53
|
+
overflowX: 'hidden',
|
|
54
|
+
overflowY: 'auto'
|
|
44
55
|
},
|
|
45
56
|
minMaxAvgContainer: {
|
|
46
57
|
columnGap: theme.spacing(0.5),
|
|
@@ -11,13 +11,14 @@ import { Line } from '../../common/timeSeries/models';
|
|
|
11
11
|
import { labelAvg, labelMax, labelMin } from '../translatedLabels';
|
|
12
12
|
|
|
13
13
|
import { useStyles } from './Legend.styles';
|
|
14
|
+
import LegendContent from './LegendContent';
|
|
14
15
|
import LegendHeader from './LegendHeader';
|
|
15
16
|
import { GetMetricValueProps, LegendDisplayMode } from './models';
|
|
16
17
|
import useLegend from './useLegend';
|
|
17
|
-
import LegendContent from './LegendContent';
|
|
18
18
|
|
|
19
19
|
interface Props {
|
|
20
20
|
base: number;
|
|
21
|
+
height?: number | null;
|
|
21
22
|
limitLegend?: false | number;
|
|
22
23
|
lines: Array<Line>;
|
|
23
24
|
renderExtraComponent?: ReactNode;
|
|
@@ -33,9 +34,13 @@ const MainLegend = ({
|
|
|
33
34
|
limitLegend = false,
|
|
34
35
|
renderExtraComponent,
|
|
35
36
|
setLinesGraph,
|
|
36
|
-
shouldDisplayLegendInCompactMode
|
|
37
|
+
shouldDisplayLegendInCompactMode,
|
|
38
|
+
height
|
|
37
39
|
}: Props): JSX.Element => {
|
|
38
|
-
const { classes, cx } = useStyles({
|
|
40
|
+
const { classes, cx } = useStyles({
|
|
41
|
+
height,
|
|
42
|
+
limitLegendRows: Boolean(limitLegend)
|
|
43
|
+
});
|
|
39
44
|
const theme = useTheme();
|
|
40
45
|
|
|
41
46
|
const { selectMetricLine, clearHighlight, highlightLine, toggleMetricLine } =
|
|
@@ -145,7 +150,8 @@ const Legend = (props: Props): JSX.Element => {
|
|
|
145
150
|
limitLegend,
|
|
146
151
|
lines,
|
|
147
152
|
base,
|
|
148
|
-
shouldDisplayLegendInCompactMode
|
|
153
|
+
shouldDisplayLegendInCompactMode,
|
|
154
|
+
height
|
|
149
155
|
} = props;
|
|
150
156
|
|
|
151
157
|
return useMemoComponent({
|
|
@@ -155,7 +161,8 @@ const Legend = (props: Props): JSX.Element => {
|
|
|
155
161
|
base,
|
|
156
162
|
toggable,
|
|
157
163
|
limitLegend,
|
|
158
|
-
shouldDisplayLegendInCompactMode
|
|
164
|
+
shouldDisplayLegendInCompactMode,
|
|
165
|
+
height
|
|
159
166
|
]
|
|
160
167
|
});
|
|
161
168
|
};
|
|
@@ -5,35 +5,35 @@ import { flatten, gt, isNil, lte, pluck, reduce } from 'ramda';
|
|
|
5
5
|
|
|
6
6
|
import { ClickAwayListener, Fade, Skeleton, useTheme } from '@mui/material';
|
|
7
7
|
|
|
8
|
+
import { Tooltip as MuiTooltip } from '../../components/Tooltip';
|
|
9
|
+
import { Thresholds as ThresholdsModel } from '../common/models';
|
|
8
10
|
import { getLeftScale, getRightScale, getXScale } from '../common/timeSeries';
|
|
9
11
|
import { Line } from '../common/timeSeries/models';
|
|
10
|
-
import { Thresholds as ThresholdsModel } from '../common/models';
|
|
11
|
-
import { Tooltip as MuiTooltip } from '../../components/Tooltip';
|
|
12
12
|
|
|
13
13
|
import Axes from './BasicComponents/Axes';
|
|
14
14
|
import Grids from './BasicComponents/Grids';
|
|
15
15
|
import Lines from './BasicComponents/Lines';
|
|
16
16
|
import { canDisplayThreshold } from './BasicComponents/Lines/Threshold/models';
|
|
17
|
+
import { CurveType } from './BasicComponents/Lines/models';
|
|
18
|
+
import Thresholds from './BasicComponents/Thresholds';
|
|
17
19
|
import useFilterLines from './BasicComponents/useFilterLines';
|
|
18
|
-
import { useStyles } from './LineChart.styles';
|
|
19
20
|
import Header from './Header';
|
|
20
21
|
import InteractionWithGraph from './InteractiveComponents';
|
|
22
|
+
import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphValueTooltip';
|
|
21
23
|
import GraphTooltip from './InteractiveComponents/Tooltip';
|
|
22
24
|
import useGraphTooltip from './InteractiveComponents/Tooltip/useGraphTooltip';
|
|
23
25
|
import Legend from './Legend';
|
|
26
|
+
import { legendWidth } from './Legend/Legend.styles';
|
|
27
|
+
import { useStyles } from './LineChart.styles';
|
|
24
28
|
import { margin } from './common';
|
|
25
29
|
import {
|
|
26
30
|
Data,
|
|
27
31
|
GlobalAreaLines,
|
|
28
32
|
GraphInterval,
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
LegendModel,
|
|
34
|
+
LineChartProps
|
|
31
35
|
} from './models';
|
|
32
36
|
import { useIntersection } from './useLineChartIntersection';
|
|
33
|
-
import { CurveType } from './BasicComponents/Lines/models';
|
|
34
|
-
import Thresholds from './BasicComponents/Thresholds';
|
|
35
|
-
import { legendWidth } from './Legend/Legend.styles';
|
|
36
|
-
import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphValueTooltip';
|
|
37
37
|
|
|
38
38
|
const extraMargin = 10;
|
|
39
39
|
|
|
@@ -292,6 +292,7 @@ const LineChart = ({
|
|
|
292
292
|
<div ref={legendRef}>
|
|
293
293
|
<Legend
|
|
294
294
|
base={baseAxis}
|
|
295
|
+
height={height}
|
|
295
296
|
limitLegend={limitLegend}
|
|
296
297
|
lines={newLines}
|
|
297
298
|
renderExtraComponent={legend?.renderExtraComponent}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import numeral from 'numeral';
|
|
1
2
|
import {
|
|
2
3
|
T,
|
|
3
4
|
always,
|
|
@@ -6,14 +7,14 @@ import {
|
|
|
6
7
|
gt,
|
|
7
8
|
gte,
|
|
8
9
|
head,
|
|
10
|
+
last,
|
|
9
11
|
length,
|
|
10
12
|
lt,
|
|
11
13
|
lte,
|
|
12
14
|
pluck
|
|
13
15
|
} from 'ramda';
|
|
14
|
-
import numeral from 'numeral';
|
|
15
16
|
|
|
16
|
-
import { darken, getLuminance, lighten
|
|
17
|
+
import { Theme, darken, getLuminance, lighten } from '@mui/material';
|
|
17
18
|
|
|
18
19
|
import { Thresholds } from './models';
|
|
19
20
|
|