@centreon/ui 24.6.0 → 24.6.2
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/Dashboard/Item.tsx +25 -8
- package/src/Dashboard/Layout.tsx +15 -1
- package/src/Dashboard/atoms.ts +3 -0
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +1 -1
- package/src/Graph/BarStack/BarStack.stories.tsx +15 -0
- package/src/Graph/BarStack/BarStack.styles.ts +5 -1
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +18 -15
- package/src/Graph/BarStack/useResponsiveBarStack.ts +4 -8
- package/src/Graph/Gauge/AnimatedPie.tsx +3 -1
- package/src/Graph/Gauge/Gauge.stories.tsx +10 -2
- package/src/Graph/Gauge/PieData.tsx +9 -4
- package/src/Graph/Gauge/ResponsiveGauge.tsx +55 -69
- package/src/Graph/Gauge/Thresholds.tsx +5 -3
- package/src/Graph/Gauge/utils.ts +4 -0
- package/src/Graph/HeatMap/HeatMap.tsx +3 -1
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +12 -4
- package/src/Graph/LineChart/Header/index.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTickGraph.ts +1 -1
- package/src/Graph/LineChart/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +5 -3
- package/src/Graph/LineChart/Legend/Legend.styles.ts +10 -3
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +3 -1
- package/src/Graph/LineChart/Legend/index.tsx +19 -3
- package/src/Graph/LineChart/LineChart.styles.ts +4 -47
- package/src/Graph/LineChart/LineChart.tsx +132 -211
- package/src/Graph/LineChart/index.stories.tsx +3 -1
- package/src/Graph/LineChart/models.ts +1 -5
- package/src/Graph/PieChart/PieChart.cypress.spec.tsx +1 -1
- package/src/Graph/PieChart/PieChart.stories.tsx +14 -0
- package/src/Graph/PieChart/ResponsivePie.tsx +15 -9
- package/src/Graph/PieChart/useResponsivePie.ts +0 -3
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +65 -68
- package/src/Graph/SingleBar/SingleBar.stories.tsx +28 -0
- package/src/Graph/SingleBar/ThresholdLine.tsx +14 -18
- package/src/Graph/SingleBar/Thresholds.tsx +9 -1
- package/src/Graph/Text/Text.stories.tsx +32 -0
- package/src/Graph/Text/Text.styles.ts +0 -1
- package/src/Graph/Text/Text.tsx +11 -7
- package/src/Graph/{LineChart/BasicComponents → common}/Axes/UnitLabel.tsx +1 -1
- package/src/Graph/{LineChart/BasicComponents → common}/Axes/index.tsx +8 -7
- package/src/Graph/{LineChart/BasicComponents → common}/Axes/models.ts +2 -2
- package/src/Graph/{LineChart/BasicComponents → common}/Axes/useAxisY.ts +2 -2
- package/src/Graph/common/BaseChart/BaseChart.tsx +114 -0
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +75 -0
- package/src/Graph/common/BaseChart/useBaseChartStyles.ts +38 -0
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +61 -0
- package/src/Graph/{LineChart/BasicComponents → common}/Grids/index.tsx +1 -1
- package/src/Graph/common/useTooltipStyles.ts +17 -0
- package/src/Graph/common/utils.ts +6 -0
- package/src/Typography/FluidTypography/index.tsx +5 -3
|
@@ -66,7 +66,6 @@ const ResponsivePie = ({
|
|
|
66
66
|
legendScale,
|
|
67
67
|
svgContainerSize,
|
|
68
68
|
svgSize,
|
|
69
|
-
svgWrapperWidth,
|
|
70
69
|
total,
|
|
71
70
|
innerRadius,
|
|
72
71
|
isContainsExactlyOneNonZeroValue
|
|
@@ -80,24 +79,27 @@ const ResponsivePie = ({
|
|
|
80
79
|
width
|
|
81
80
|
});
|
|
82
81
|
|
|
82
|
+
const isTooSmallForLegend = lt(width, 170);
|
|
83
|
+
|
|
84
|
+
const isSmall = lt(width, 130);
|
|
85
|
+
const mustDisplayLegend = isTooSmallForLegend ? false : displayLegend;
|
|
86
|
+
|
|
83
87
|
const { classes } = usePieStyles({ svgSize });
|
|
84
88
|
|
|
85
89
|
return (
|
|
86
90
|
<div
|
|
87
91
|
className={classes.container}
|
|
88
92
|
style={{
|
|
89
|
-
height
|
|
90
|
-
width
|
|
93
|
+
height
|
|
91
94
|
}}
|
|
92
95
|
>
|
|
93
96
|
<div
|
|
94
97
|
className={classes.svgWrapper}
|
|
95
98
|
style={{
|
|
96
|
-
minHeight: height
|
|
97
|
-
width: svgWrapperWidth
|
|
99
|
+
minHeight: equals(variant, 'donut') && isSmall ? 'auto' : height
|
|
98
100
|
}}
|
|
99
101
|
>
|
|
100
|
-
{equals(variant, 'pie') && title && (
|
|
102
|
+
{(equals(variant, 'pie') || isSmall) && title && (
|
|
101
103
|
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
102
104
|
{`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
|
|
103
105
|
</div>
|
|
@@ -110,7 +112,11 @@ const ResponsivePie = ({
|
|
|
110
112
|
width: svgContainerSize
|
|
111
113
|
}}
|
|
112
114
|
>
|
|
113
|
-
<svg
|
|
115
|
+
<svg
|
|
116
|
+
data-variant={variant}
|
|
117
|
+
height={Math.ceil(svgSize)}
|
|
118
|
+
width={Math.ceil(svgSize)}
|
|
119
|
+
>
|
|
114
120
|
<Group left={half} top={half}>
|
|
115
121
|
<Pie
|
|
116
122
|
cornerRadius={4}
|
|
@@ -199,7 +205,7 @@ const ResponsivePie = ({
|
|
|
199
205
|
});
|
|
200
206
|
}}
|
|
201
207
|
</Pie>
|
|
202
|
-
{equals(variant, 'donut') && title && (
|
|
208
|
+
{equals(variant, 'donut') && !isSmall && title && (
|
|
203
209
|
<>
|
|
204
210
|
<Text
|
|
205
211
|
className={classes.title}
|
|
@@ -224,7 +230,7 @@ const ResponsivePie = ({
|
|
|
224
230
|
</svg>
|
|
225
231
|
</div>
|
|
226
232
|
</div>
|
|
227
|
-
{
|
|
233
|
+
{mustDisplayLegend && (
|
|
228
234
|
<div data-testid="Legend" ref={legendRef}>
|
|
229
235
|
<Legend
|
|
230
236
|
data={data}
|
|
@@ -22,7 +22,6 @@ interface ResponsivePieState {
|
|
|
22
22
|
legendScale: LegendScale;
|
|
23
23
|
svgContainerSize: number;
|
|
24
24
|
svgSize: number;
|
|
25
|
-
svgWrapperWidth: number;
|
|
26
25
|
total: number;
|
|
27
26
|
}
|
|
28
27
|
export const useResponsivePie = ({
|
|
@@ -44,7 +43,6 @@ export const useResponsivePie = ({
|
|
|
44
43
|
height - heightOfTitle - verticalGap,
|
|
45
44
|
width - widthOfLegend - horizontalGap
|
|
46
45
|
);
|
|
47
|
-
const svgWrapperWidth = svgContainerSize;
|
|
48
46
|
|
|
49
47
|
const outerRadius = Math.min(32, svgContainerSize / 6);
|
|
50
48
|
|
|
@@ -75,7 +73,6 @@ export const useResponsivePie = ({
|
|
|
75
73
|
legendScale,
|
|
76
74
|
svgContainerSize,
|
|
77
75
|
svgSize,
|
|
78
|
-
svgWrapperWidth,
|
|
79
76
|
total
|
|
80
77
|
};
|
|
81
78
|
};
|
|
@@ -2,12 +2,13 @@ import { useMemo, useRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Group, Tooltip } from '@visx/visx';
|
|
4
4
|
import { scaleLinear } from '@visx/scale';
|
|
5
|
-
import { equals, flatten, head, pluck } from 'ramda';
|
|
5
|
+
import { equals, flatten, head, lt, pluck } from 'ramda';
|
|
6
6
|
import { Bar } from '@visx/shape';
|
|
7
7
|
import { useSpring, animated } from '@react-spring/web';
|
|
8
8
|
|
|
9
|
-
import { alpha, Box,
|
|
9
|
+
import { alpha, Box, useTheme } from '@mui/material';
|
|
10
10
|
|
|
11
|
+
import { Tooltip as MuiTooltip } from '../../components/Tooltip';
|
|
11
12
|
import {
|
|
12
13
|
formatMetricValueWithUnit,
|
|
13
14
|
getMetricWithLatestData
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
import { Metric } from '../common/timeSeries/models';
|
|
16
17
|
import { getColorFromDataAndTresholds } from '../common/utils';
|
|
17
18
|
import { margins } from '../common/margins';
|
|
19
|
+
import { useTooltipStyles } from '../common/useTooltipStyles';
|
|
18
20
|
|
|
19
21
|
import { SingleBarProps } from './models';
|
|
20
22
|
import Thresholds, { groupMargin } from './Thresholds';
|
|
@@ -25,11 +27,6 @@ interface Props extends SingleBarProps {
|
|
|
25
27
|
width: number;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
const baseStyles = {
|
|
29
|
-
...Tooltip.defaultStyles,
|
|
30
|
-
textAlign: 'center'
|
|
31
|
-
};
|
|
32
|
-
|
|
33
30
|
const ResponsiveSingleBar = ({
|
|
34
31
|
data,
|
|
35
32
|
thresholds,
|
|
@@ -40,8 +37,11 @@ const ResponsiveSingleBar = ({
|
|
|
40
37
|
size = 'medium',
|
|
41
38
|
showLabels = true
|
|
42
39
|
}: Props): JSX.Element => {
|
|
40
|
+
const { classes } = useTooltipStyles();
|
|
43
41
|
const theme = useTheme();
|
|
44
42
|
|
|
43
|
+
const isSmallHeight = lt(height, 150);
|
|
44
|
+
|
|
45
45
|
const metric = getMetricWithLatestData(data) as Metric;
|
|
46
46
|
const latestMetricData = head(metric.data) as number;
|
|
47
47
|
const thresholdValues = thresholds.enabled
|
|
@@ -57,14 +57,8 @@ const ResponsiveSingleBar = ({
|
|
|
57
57
|
head(metric.data) as number
|
|
58
58
|
);
|
|
59
59
|
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
hideTooltip,
|
|
63
|
-
tooltipOpen,
|
|
64
|
-
tooltipLeft,
|
|
65
|
-
tooltipTop,
|
|
66
|
-
tooltipData
|
|
67
|
-
} = Tooltip.useTooltip();
|
|
60
|
+
const { showTooltip, hideTooltip, tooltipOpen, tooltipData } =
|
|
61
|
+
Tooltip.useTooltip();
|
|
68
62
|
const svgRef = useRef<SVGSVGElement | null>(null);
|
|
69
63
|
|
|
70
64
|
const barColor = useMemo(
|
|
@@ -78,13 +72,11 @@ const ResponsiveSingleBar = ({
|
|
|
78
72
|
[latestMetricData, thresholds, theme]
|
|
79
73
|
);
|
|
80
74
|
|
|
81
|
-
const isSmall = equals(size, 'small');
|
|
75
|
+
const isSmall = equals(size, 'small') || isSmallHeight;
|
|
82
76
|
|
|
83
|
-
const textStyle = isSmall
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
: theme.typography.h3;
|
|
77
|
+
const textStyle = isSmall ? theme.typography.h6 : theme.typography.h4;
|
|
78
|
+
|
|
79
|
+
const textHeight = isSmall ? 46 : 27;
|
|
88
80
|
|
|
89
81
|
const text = showLabels && (
|
|
90
82
|
<text
|
|
@@ -126,6 +118,15 @@ const ResponsiveSingleBar = ({
|
|
|
126
118
|
|
|
127
119
|
const springStyle = useSpring({ width: metricBarWidth });
|
|
128
120
|
|
|
121
|
+
const barHeight = isSmallHeight ? barHeights.small : barHeights[size];
|
|
122
|
+
|
|
123
|
+
const barY = groupMargin + (isSmall ? 0 : 2 * margins.top);
|
|
124
|
+
|
|
125
|
+
const realBarHeight =
|
|
126
|
+
!isSmall && textHeight + barHeight > height
|
|
127
|
+
? height - textHeight - 2 * margins.top
|
|
128
|
+
: barHeight;
|
|
129
|
+
|
|
129
130
|
return (
|
|
130
131
|
<div
|
|
131
132
|
style={{
|
|
@@ -141,55 +142,51 @@ const ResponsiveSingleBar = ({
|
|
|
141
142
|
width: '100%'
|
|
142
143
|
}}
|
|
143
144
|
>
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
<animated.rect
|
|
148
|
-
data-testid={`${latestMetricData}-bar-${barColor}`}
|
|
149
|
-
fill={barColor}
|
|
150
|
-
height={barHeights[size]}
|
|
151
|
-
rx={4}
|
|
152
|
-
style={springStyle}
|
|
153
|
-
x={5}
|
|
154
|
-
y={groupMargin + (isSmall ? 0 : 2 * margins.top)}
|
|
155
|
-
/>
|
|
156
|
-
<Bar
|
|
157
|
-
fill="transparent"
|
|
158
|
-
height={barHeights[size]}
|
|
159
|
-
rx={4}
|
|
160
|
-
ry={4}
|
|
161
|
-
stroke={alpha(theme.palette.text.primary, 0.3)}
|
|
162
|
-
width={maxBarWidth}
|
|
163
|
-
x={5}
|
|
164
|
-
y={groupMargin + (isSmall ? 0 : 2 * margins.top)}
|
|
165
|
-
/>
|
|
166
|
-
{thresholds.enabled && (
|
|
167
|
-
<Thresholds
|
|
168
|
-
hideTooltip={hideTooltip}
|
|
169
|
-
showTooltip={showTooltip}
|
|
170
|
-
size={size}
|
|
171
|
-
thresholds={thresholds}
|
|
172
|
-
xScale={xScale}
|
|
173
|
-
/>
|
|
174
|
-
)}
|
|
175
|
-
</Group.Group>
|
|
176
|
-
</svg>
|
|
177
|
-
</Box>
|
|
178
|
-
<Fade in={tooltipOpen}>
|
|
179
|
-
<Tooltip.Tooltip
|
|
180
|
-
left={tooltipLeft}
|
|
181
|
-
style={{
|
|
182
|
-
...baseStyles,
|
|
183
|
-
backgroundColor: theme.palette.background.paper,
|
|
184
|
-
color: theme.palette.text.primary,
|
|
185
|
-
transform: `translate(-50%, ${isSmall ? -100 : -120}px)`,
|
|
186
|
-
zIndex: theme.zIndex.tooltip
|
|
145
|
+
<MuiTooltip
|
|
146
|
+
classes={{
|
|
147
|
+
tooltip: classes.tooltip
|
|
187
148
|
}}
|
|
188
|
-
|
|
149
|
+
label={tooltipData}
|
|
150
|
+
open={tooltipOpen}
|
|
151
|
+
placement="top"
|
|
189
152
|
>
|
|
190
|
-
{
|
|
191
|
-
|
|
192
|
-
|
|
153
|
+
<svg height={height} ref={svgRef} width={width}>
|
|
154
|
+
<Group.Group>
|
|
155
|
+
{text}
|
|
156
|
+
<animated.rect
|
|
157
|
+
data-testid={`${latestMetricData}-bar-${barColor}`}
|
|
158
|
+
fill={barColor}
|
|
159
|
+
height={realBarHeight}
|
|
160
|
+
rx={4}
|
|
161
|
+
style={springStyle}
|
|
162
|
+
x={5}
|
|
163
|
+
y={barY}
|
|
164
|
+
/>
|
|
165
|
+
<Bar
|
|
166
|
+
fill="transparent"
|
|
167
|
+
height={realBarHeight}
|
|
168
|
+
rx={4}
|
|
169
|
+
ry={4}
|
|
170
|
+
stroke={alpha(theme.palette.text.primary, 0.3)}
|
|
171
|
+
width={maxBarWidth}
|
|
172
|
+
x={5}
|
|
173
|
+
y={barY}
|
|
174
|
+
/>
|
|
175
|
+
{thresholds.enabled && (
|
|
176
|
+
<Thresholds
|
|
177
|
+
barHeight={realBarHeight}
|
|
178
|
+
hideTooltip={hideTooltip}
|
|
179
|
+
isSmall={isSmall}
|
|
180
|
+
showTooltip={showTooltip}
|
|
181
|
+
size={size}
|
|
182
|
+
thresholds={thresholds}
|
|
183
|
+
xScale={xScale}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
</Group.Group>
|
|
187
|
+
</svg>
|
|
188
|
+
</MuiTooltip>
|
|
189
|
+
</Box>
|
|
193
190
|
</div>
|
|
194
191
|
);
|
|
195
192
|
};
|
|
@@ -17,6 +17,12 @@ const Template = (props): JSX.Element => (
|
|
|
17
17
|
</div>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
+
const SmallTemplate = (props): JSX.Element => (
|
|
21
|
+
<div style={{ height: '130px', width: '130px' }}>
|
|
22
|
+
<SingleBar {...props} />
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
|
|
20
26
|
export const success: Story = {
|
|
21
27
|
args: {
|
|
22
28
|
data: dataLastWeek,
|
|
@@ -202,3 +208,25 @@ export const Small: Story = {
|
|
|
202
208
|
},
|
|
203
209
|
render: Template
|
|
204
210
|
};
|
|
211
|
+
|
|
212
|
+
export const smallDisplay: Story = {
|
|
213
|
+
args: {
|
|
214
|
+
data: dataLastWeek,
|
|
215
|
+
thresholds: {
|
|
216
|
+
critical: [
|
|
217
|
+
{
|
|
218
|
+
label: 'Critical',
|
|
219
|
+
value: 0.6
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
enabled: true,
|
|
223
|
+
warning: [
|
|
224
|
+
{
|
|
225
|
+
label: 'Warning',
|
|
226
|
+
value: 0.5
|
|
227
|
+
}
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
render: SmallTemplate
|
|
232
|
+
};
|
|
@@ -18,7 +18,9 @@ const lineMargins = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
interface Props {
|
|
21
|
+
barHeight: number;
|
|
21
22
|
hideTooltip: () => void;
|
|
23
|
+
isSmall: boolean;
|
|
22
24
|
label: string;
|
|
23
25
|
showTooltip: (args) => void;
|
|
24
26
|
size: 'small' | 'medium';
|
|
@@ -34,7 +36,9 @@ export const ThresholdLine = ({
|
|
|
34
36
|
thresholdType,
|
|
35
37
|
showTooltip,
|
|
36
38
|
hideTooltip,
|
|
37
|
-
size
|
|
39
|
+
size,
|
|
40
|
+
barHeight,
|
|
41
|
+
isSmall
|
|
38
42
|
}: Props): JSX.Element => {
|
|
39
43
|
const theme = useTheme();
|
|
40
44
|
|
|
@@ -42,17 +46,9 @@ export const ThresholdLine = ({
|
|
|
42
46
|
|
|
43
47
|
const lineMargin = lineMargins[size];
|
|
44
48
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const isSmall = equals(size, 'small');
|
|
48
|
-
|
|
49
|
-
const bottom = barHeights[size] + margin * 2;
|
|
50
|
-
|
|
51
|
-
const onMouseEnter = (left) => (): void =>
|
|
49
|
+
const onMouseEnter = (): void =>
|
|
52
50
|
showTooltip({
|
|
53
|
-
tooltipData: label
|
|
54
|
-
tooltipLeft: left,
|
|
55
|
-
tooltipTop: bottom
|
|
51
|
+
tooltipData: label
|
|
56
52
|
});
|
|
57
53
|
|
|
58
54
|
const lineColor = equals(thresholdType, 'warning')
|
|
@@ -70,13 +66,13 @@ export const ThresholdLine = ({
|
|
|
70
66
|
x2={scaledValue}
|
|
71
67
|
y1={
|
|
72
68
|
isSmall
|
|
73
|
-
? groupMargin - lineMargin
|
|
69
|
+
? groupMargin - lineMargin + 6
|
|
74
70
|
: groupMargin + lineMargin + margins.top
|
|
75
71
|
}
|
|
76
72
|
y2={
|
|
77
73
|
isSmall
|
|
78
|
-
?
|
|
79
|
-
:
|
|
74
|
+
? barHeight + groupMargin - lineMargin + margins.top - 2
|
|
75
|
+
: barHeight + groupMargin + lineMargin + 2 * margins.top
|
|
80
76
|
}
|
|
81
77
|
/>
|
|
82
78
|
<line
|
|
@@ -87,15 +83,15 @@ export const ThresholdLine = ({
|
|
|
87
83
|
x2={scaledValue}
|
|
88
84
|
y1={
|
|
89
85
|
isSmall
|
|
90
|
-
? groupMargin - lineMargin
|
|
86
|
+
? groupMargin - lineMargin + 5
|
|
91
87
|
: groupMargin + lineMargin + margins.top
|
|
92
88
|
}
|
|
93
89
|
y2={
|
|
94
90
|
isSmall
|
|
95
|
-
?
|
|
96
|
-
:
|
|
91
|
+
? barHeight + groupMargin - lineMargin + margins.top + 5
|
|
92
|
+
: barHeight + groupMargin + lineMargin + 2 * margins.top
|
|
97
93
|
}
|
|
98
|
-
onMouseEnter={onMouseEnter
|
|
94
|
+
onMouseEnter={onMouseEnter}
|
|
99
95
|
onMouseLeave={hideTooltip}
|
|
100
96
|
/>
|
|
101
97
|
</>
|
|
@@ -5,7 +5,9 @@ import { ThresholdLine } from './ThresholdLine';
|
|
|
5
5
|
export const groupMargin = 25;
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
|
+
barHeight: number;
|
|
8
9
|
hideTooltip: () => void;
|
|
10
|
+
isSmall: boolean;
|
|
9
11
|
showTooltip: (args) => void;
|
|
10
12
|
size: 'small' | 'medium';
|
|
11
13
|
thresholds: ThresholdsModel;
|
|
@@ -17,12 +19,16 @@ const Thresholds = ({
|
|
|
17
19
|
thresholds,
|
|
18
20
|
showTooltip,
|
|
19
21
|
hideTooltip,
|
|
20
|
-
size
|
|
22
|
+
size,
|
|
23
|
+
barHeight,
|
|
24
|
+
isSmall
|
|
21
25
|
}: Props): JSX.Element => (
|
|
22
26
|
<>
|
|
23
27
|
{thresholds.warning.map(({ value, label }) => (
|
|
24
28
|
<ThresholdLine
|
|
29
|
+
barHeight={barHeight}
|
|
25
30
|
hideTooltip={hideTooltip}
|
|
31
|
+
isSmall={isSmall}
|
|
26
32
|
key={`warning-${value.toString()}`}
|
|
27
33
|
label={label}
|
|
28
34
|
showTooltip={showTooltip}
|
|
@@ -34,7 +40,9 @@ const Thresholds = ({
|
|
|
34
40
|
))}
|
|
35
41
|
{thresholds.critical.map(({ value, label }) => (
|
|
36
42
|
<ThresholdLine
|
|
43
|
+
barHeight={barHeight}
|
|
37
44
|
hideTooltip={hideTooltip}
|
|
45
|
+
isSmall={isSmall}
|
|
38
46
|
key={`critical-${value.toString()}`}
|
|
39
47
|
label={label}
|
|
40
48
|
showTooltip={showTooltip}
|
|
@@ -17,6 +17,12 @@ const Template = (props): JSX.Element => (
|
|
|
17
17
|
</div>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
|
+
const SmallTemplate = (props): JSX.Element => (
|
|
21
|
+
<div style={{ height: '100px', width: '200px' }}>
|
|
22
|
+
<Text {...props} />
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
|
|
20
26
|
export const success: Story = {
|
|
21
27
|
args: {
|
|
22
28
|
data: dataLastWeek,
|
|
@@ -121,3 +127,29 @@ export const rawValue: Story = {
|
|
|
121
127
|
},
|
|
122
128
|
render: Template
|
|
123
129
|
};
|
|
130
|
+
|
|
131
|
+
export const smallDisplay: Story = {
|
|
132
|
+
args: {
|
|
133
|
+
data: dataLastWeek,
|
|
134
|
+
labels: {
|
|
135
|
+
critical: 'Critical',
|
|
136
|
+
warning: 'Warning'
|
|
137
|
+
},
|
|
138
|
+
thresholds: {
|
|
139
|
+
critical: [
|
|
140
|
+
{
|
|
141
|
+
label: 'Critical',
|
|
142
|
+
value: 1.5
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
enabled: true,
|
|
146
|
+
warning: [
|
|
147
|
+
{
|
|
148
|
+
label: 'Warning',
|
|
149
|
+
value: 0.5
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
render: SmallTemplate
|
|
155
|
+
};
|
package/src/Graph/Text/Text.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNil } from 'ramda';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
5
|
import FluidTypography from '../../Typography/FluidTypography';
|
|
6
6
|
import { LineChartData, Thresholds } from '../common/models';
|
|
@@ -64,15 +64,19 @@ export const Text = ({
|
|
|
64
64
|
|
|
65
65
|
return (
|
|
66
66
|
<div className={classes.graphText}>
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
<FluidTypography
|
|
68
|
+
max="40px"
|
|
69
|
+
pref={16}
|
|
70
|
+
sx={{ color, fontWeight: 'bold', textAlign: 'center' }}
|
|
71
|
+
text={
|
|
72
|
+
formatMetricValueWithUnit({
|
|
70
73
|
isRaw: displayAsRaw,
|
|
71
74
|
unit: metricUnit,
|
|
72
75
|
value: metricValue
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
}) || ''
|
|
77
|
+
}
|
|
78
|
+
variant="h2"
|
|
79
|
+
/>
|
|
76
80
|
{thresholds.enabled && (
|
|
77
81
|
<div className={classes.thresholds}>
|
|
78
82
|
<FluidTypography
|
|
@@ -4,9 +4,8 @@ import { isNil } from 'ramda';
|
|
|
4
4
|
|
|
5
5
|
import { useLocaleDateTimeFormat } from '@centreon/ui';
|
|
6
6
|
|
|
7
|
-
import { getXAxisTickFormat } from '../../helpers';
|
|
8
|
-
import {
|
|
9
|
-
import { getUnits } from '../../../common/timeSeries';
|
|
7
|
+
import { getXAxisTickFormat } from '../../LineChart/helpers';
|
|
8
|
+
import { getUnits } from '../timeSeries';
|
|
10
9
|
|
|
11
10
|
import UnitLabel from './UnitLabel';
|
|
12
11
|
import { Data } from './models';
|
|
@@ -14,7 +13,6 @@ import useAxisY from './useAxisY';
|
|
|
14
13
|
|
|
15
14
|
interface Props {
|
|
16
15
|
data: Data;
|
|
17
|
-
graphInterval: GraphInterval;
|
|
18
16
|
height: number;
|
|
19
17
|
leftScale: ScaleLinear<number, number>;
|
|
20
18
|
rightScale: ScaleLinear<number, number>;
|
|
@@ -28,8 +26,7 @@ const Axes = ({
|
|
|
28
26
|
data,
|
|
29
27
|
rightScale,
|
|
30
28
|
leftScale,
|
|
31
|
-
xScale
|
|
32
|
-
graphInterval
|
|
29
|
+
xScale
|
|
33
30
|
}: Props): JSX.Element => {
|
|
34
31
|
const { format } = useLocaleDateTimeFormat();
|
|
35
32
|
const { lines, showBorder, yAxisTickLabelRotation } = data;
|
|
@@ -41,7 +38,11 @@ const Axes = ({
|
|
|
41
38
|
const xTickCount = Math.min(Math.ceil(width / 82), 12);
|
|
42
39
|
|
|
43
40
|
const tickFormat =
|
|
44
|
-
data?.axisX?.xAxisTickFormat ??
|
|
41
|
+
data?.axisX?.xAxisTickFormat ??
|
|
42
|
+
getXAxisTickFormat({
|
|
43
|
+
start: xScale.domain()[0],
|
|
44
|
+
start: xScale.domain()[-1]
|
|
45
|
+
});
|
|
45
46
|
|
|
46
47
|
const formatAxisTick = (tick): string =>
|
|
47
48
|
format({ date: new Date(tick), formatString: tickFormat });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Line, TimeValue } from '
|
|
2
|
-
import { LineChartAxis } from '../../models';
|
|
1
|
+
import { Line, TimeValue } from '../timeSeries/models';
|
|
2
|
+
import { LineChartAxis } from '../../LineChart/models';
|
|
3
3
|
|
|
4
4
|
export interface LabelProps {
|
|
5
5
|
[x: string]: unknown;
|
|
@@ -3,8 +3,8 @@ import { Axis } from '@visx/visx';
|
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '@mui/material';
|
|
5
5
|
|
|
6
|
-
import { formatMetricValue, getUnits } from '
|
|
7
|
-
import { commonTickLabelProps } from '
|
|
6
|
+
import { formatMetricValue, getUnits } from '../timeSeries';
|
|
7
|
+
import { commonTickLabelProps } from '../utils';
|
|
8
8
|
|
|
9
9
|
import { Data, LabelProps } from './models';
|
|
10
10
|
|