@centreon/ui 23.10.1-MON-21683-manual-refresh.4 → 23.10.1-MON-20803-RS-add-basic-filter.7
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/Dashboard.styles.ts +1 -6
- package/src/Dashboard/Item.tsx +1 -4
- package/src/Dashboard/Layout.tsx +1 -1
- package/src/Form/Inputs/Radio.tsx +4 -15
- package/src/Form/Inputs/models.ts +1 -1
- package/src/Graph/Gauge/Gauge.stories.tsx +0 -10
- package/src/Graph/Gauge/Gauge.tsx +1 -10
- package/src/Graph/Gauge/PieData.tsx +8 -8
- package/src/Graph/Gauge/ResponsiveGauge.tsx +24 -40
- package/src/Graph/Gauge/Thresholds.tsx +25 -2
- package/src/Graph/Gauge/models.ts +0 -1
- package/src/Graph/LineChart/BasicComponents/Axes/index.tsx +1 -1
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +8 -13
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +3 -5
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/useScaleThreshold.ts +3 -3
- package/src/Graph/LineChart/BasicComponents/Lines/index.tsx +5 -5
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -5
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/models.ts +1 -1
- package/src/Graph/LineChart/Legend/index.tsx +7 -7
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +10 -10
- package/src/Graph/LineChart/Legend/useLegend.ts +18 -16
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +24 -49
- package/src/Graph/SingleBar/SingleBar.stories.tsx +0 -46
- package/src/Graph/SingleBar/ThresholdLine.tsx +12 -41
- package/src/Graph/SingleBar/Thresholds.tsx +1 -5
- package/src/Graph/SingleBar/models.ts +0 -4
- package/src/Graph/Text/Text.stories.tsx +0 -13
- package/src/Graph/Text/Text.tsx +12 -19
- package/src/Graph/common/timeSeries/index.test.ts +26 -144
- package/src/Graph/common/timeSeries/index.ts +21 -86
- package/src/Graph/common/timeSeries/models.ts +4 -9
- package/src/Graph/common/utils.ts +2 -4
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +2 -7
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +11 -20
- package/src/InputField/Select/Autocomplete/index.tsx +1 -4
- package/src/InputField/Text/index.tsx +7 -10
- package/src/Listing/Cell/DataCell.tsx +1 -1
- package/src/Listing/Cell/index.tsx +2 -2
- package/src/RichTextEditor/ContentEditable.tsx +1 -0
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +13 -5
- package/src/RichTextEditor/RichTextEditor.tsx +2 -5
- package/src/RichTextEditor/plugins/AutoLinkPlugin/index.tsx +1 -40
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +8 -33
- package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +2 -1
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +4 -10
- package/src/ThemeProvider/index.tsx +4 -6
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +6 -9
- package/src/TimePeriods/index.stories.tsx +0 -15
- package/src/TopCounterElements/ResourceSubMenu.tsx +1 -3
- package/src/TopCounterElements/TopCounterLayout.tsx +1 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +2 -4
- package/src/api/buildListingEndpoint/index.ts +1 -1
- package/src/api/useFetchQuery/index.ts +8 -10
- package/src/api/useGraphQuery/index.ts +32 -67
- package/src/api/useGraphQuery/models.ts +8 -9
- package/src/api/useMutationQuery/index.ts +11 -16
- package/src/components/Form/Dashboard/Dashboard.resource.ts +0 -5
- package/src/components/Form/Dashboard/DashboardForm.styles.ts +2 -10
- package/src/components/Form/Dashboard/DashboardForm.tsx +1 -34
- package/src/components/Form/Dashboard/translatedLabels.ts +0 -3
- package/src/components/Modal/Modal.styles.ts +1 -3
- package/src/components/index.ts +0 -1
- package/src/index.ts +4 -4
- package/src/utils/index.ts +0 -1
- package/src/utils/useDebounce.ts +7 -2
- package/src/utils/useRefreshInterval.ts +4 -19
- package/src/TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod.tsx +0 -28
- package/src/components/Form/Dashboard/GlobalRefreshFieldOption.tsx +0 -54
- package/src/components/Inputs/Switch/Switch.stories.tsx +0 -22
- package/src/components/Inputs/Switch/Switch.styles.ts +0 -13
- package/src/components/Inputs/Switch/Switch.tsx +0 -18
- package/src/components/Inputs/index.ts +0 -1
- package/src/utils/centreonBaseURL.ts +0 -4
package/package.json
CHANGED
|
@@ -79,12 +79,7 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
79
79
|
'&:hover': {
|
|
80
80
|
backgroundColor: theme.palette.action.hover
|
|
81
81
|
},
|
|
82
|
-
'
|
|
83
|
-
cursor: 'default'
|
|
84
|
-
},
|
|
85
|
-
'&[data-canMove="true"]': {
|
|
86
|
-
cursor: 'move'
|
|
87
|
-
},
|
|
82
|
+
cursor: 'move',
|
|
88
83
|
padding: theme.spacing(0.5, 2)
|
|
89
84
|
},
|
|
90
85
|
widgetPadding: {
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import { useMemoComponent } from '../utils';
|
|
|
15
15
|
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
16
16
|
|
|
17
17
|
interface DashboardItemProps {
|
|
18
|
-
canMove?: boolean;
|
|
19
18
|
children: ReactElement;
|
|
20
19
|
className?: string;
|
|
21
20
|
disablePadding?: boolean;
|
|
@@ -38,8 +37,7 @@ const Item = forwardRef(
|
|
|
38
37
|
onMouseUp,
|
|
39
38
|
onTouchEnd,
|
|
40
39
|
id,
|
|
41
|
-
disablePadding = false
|
|
42
|
-
canMove = false
|
|
40
|
+
disablePadding = false
|
|
43
41
|
}: DashboardItemProps,
|
|
44
42
|
ref: ForwardedRef<HTMLDivElement>
|
|
45
43
|
): ReactElement => {
|
|
@@ -68,7 +66,6 @@ const Item = forwardRef(
|
|
|
68
66
|
<div
|
|
69
67
|
{...listeners}
|
|
70
68
|
className={classes.widgetHeader}
|
|
71
|
-
data-canMove={canMove}
|
|
72
69
|
data-testid={`${id}_move_panel`}
|
|
73
70
|
>
|
|
74
71
|
{header}
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormikValues, useFormikContext } from 'formik';
|
|
2
|
-
import { equals, includes, path, split
|
|
2
|
+
import { equals, includes, path, split } from 'ramda';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -73,23 +73,12 @@ const Radio = ({
|
|
|
73
73
|
disabled={disabled}
|
|
74
74
|
id={getNormalizedId(`${dataTestId}${optionLabel}`)}
|
|
75
75
|
inputProps={{
|
|
76
|
-
'aria-label':
|
|
77
|
-
(equals(type(optionLabel), 'String') &&
|
|
78
|
-
t(optionLabel as string)) ||
|
|
79
|
-
''
|
|
76
|
+
'aria-label': t(optionLabel) || ''
|
|
80
77
|
}}
|
|
81
78
|
/>
|
|
82
79
|
}
|
|
83
|
-
key={
|
|
84
|
-
|
|
85
|
-
? (optionLabel as string)
|
|
86
|
-
: `${optionValue}`
|
|
87
|
-
}
|
|
88
|
-
label={
|
|
89
|
-
equals(type(optionLabel), 'String')
|
|
90
|
-
? (t(optionLabel as string) as string)
|
|
91
|
-
: optionLabel
|
|
92
|
-
}
|
|
80
|
+
key={optionLabel}
|
|
81
|
+
label={t(optionLabel) as string}
|
|
93
82
|
value={optionValue}
|
|
94
83
|
/>
|
|
95
84
|
))}
|
|
@@ -134,13 +134,3 @@ export const withRangeThresholds: Story = {
|
|
|
134
134
|
},
|
|
135
135
|
render: Template
|
|
136
136
|
};
|
|
137
|
-
|
|
138
|
-
export const RawValue: Story = {
|
|
139
|
-
args: {
|
|
140
|
-
data: dataLastWeek,
|
|
141
|
-
displayAsRaw: true,
|
|
142
|
-
thresholdTooltipLabels: ['Warning', 'Critical'],
|
|
143
|
-
thresholds: [0.5, 0.6]
|
|
144
|
-
},
|
|
145
|
-
render: Template
|
|
146
|
-
};
|
|
@@ -7,18 +7,11 @@ import { Metric } from '../common/timeSeries/models';
|
|
|
7
7
|
import ResponsiveGauge from './ResponsiveGauge';
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
|
-
baseColor?: string;
|
|
11
10
|
data?: LineChartData;
|
|
12
|
-
displayAsRaw?: boolean;
|
|
13
11
|
thresholds: Thresholds;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
export const Gauge = ({
|
|
17
|
-
thresholds,
|
|
18
|
-
data,
|
|
19
|
-
displayAsRaw,
|
|
20
|
-
baseColor
|
|
21
|
-
}: Props): JSX.Element | null => {
|
|
14
|
+
export const Gauge = ({ thresholds, data }: Props): JSX.Element | null => {
|
|
22
15
|
if (!data) {
|
|
23
16
|
return null;
|
|
24
17
|
}
|
|
@@ -29,8 +22,6 @@ export const Gauge = ({
|
|
|
29
22
|
<Responsive.ParentSize>
|
|
30
23
|
{({ width, height }) => (
|
|
31
24
|
<ResponsiveGauge
|
|
32
|
-
baseColor={baseColor}
|
|
33
|
-
displayAsRaw={displayAsRaw}
|
|
34
25
|
height={height}
|
|
35
26
|
metric={metric}
|
|
36
27
|
thresholds={thresholds}
|
|
@@ -16,8 +16,7 @@ const PieData = ({
|
|
|
16
16
|
metric,
|
|
17
17
|
adaptedMaxValue,
|
|
18
18
|
thresholds,
|
|
19
|
-
radius
|
|
20
|
-
baseColor
|
|
19
|
+
radius
|
|
21
20
|
}: Omit<
|
|
22
21
|
GaugeProps,
|
|
23
22
|
'width' | 'height' | 'showTooltip' | 'hideTooltip' | 'thresholdTooltipLabels'
|
|
@@ -25,12 +24,13 @@ const PieData = ({
|
|
|
25
24
|
const theme = useTheme();
|
|
26
25
|
|
|
27
26
|
const pieData = [metric.data[0], adaptedMaxValue - metric.data[0]];
|
|
28
|
-
const pieColor =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const pieColor = !thresholds.enabled
|
|
28
|
+
? theme.palette.success.main
|
|
29
|
+
: getColorFromDataAndTresholds({
|
|
30
|
+
data: metric.data[0],
|
|
31
|
+
theme,
|
|
32
|
+
thresholds
|
|
33
|
+
});
|
|
34
34
|
|
|
35
35
|
const getDataColor = scaleOrdinal({
|
|
36
36
|
domain: pieData,
|
|
@@ -7,7 +7,7 @@ import { Tooltip } from '@visx/visx';
|
|
|
7
7
|
import { Box, Fade, useTheme } from '@mui/material';
|
|
8
8
|
|
|
9
9
|
import { Metric } from '../common/timeSeries/models';
|
|
10
|
-
import {
|
|
10
|
+
import { formatMetricValue } from '../common/timeSeries';
|
|
11
11
|
import { getColorFromDataAndTresholds } from '../common/utils';
|
|
12
12
|
import { margins } from '../common/margins';
|
|
13
13
|
|
|
@@ -15,8 +15,7 @@ import Thresholds from './Thresholds';
|
|
|
15
15
|
import PieData from './PieData';
|
|
16
16
|
import { GaugeProps } from './models';
|
|
17
17
|
|
|
18
|
-
interface Props extends Pick<GaugeProps, 'thresholds'
|
|
19
|
-
displayAsRaw?: boolean;
|
|
18
|
+
interface Props extends Pick<GaugeProps, 'thresholds'> {
|
|
20
19
|
height: number;
|
|
21
20
|
metric: Metric;
|
|
22
21
|
width: number;
|
|
@@ -31,9 +30,7 @@ const ResponsiveGauge = ({
|
|
|
31
30
|
width,
|
|
32
31
|
height,
|
|
33
32
|
thresholds,
|
|
34
|
-
metric
|
|
35
|
-
displayAsRaw,
|
|
36
|
-
baseColor
|
|
33
|
+
metric
|
|
37
34
|
}: Props): JSX.Element => {
|
|
38
35
|
const svgRef = useRef<SVGSVGElement>(null);
|
|
39
36
|
|
|
@@ -53,46 +50,31 @@ const ResponsiveGauge = ({
|
|
|
53
50
|
const centerY = innerHeight / 2;
|
|
54
51
|
const centerX = innerWidth / 2;
|
|
55
52
|
const radius = Math.min(innerWidth, innerHeight) / 2;
|
|
56
|
-
const thresholdValues =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
])
|
|
61
|
-
: [0];
|
|
53
|
+
const thresholdValues = flatten([
|
|
54
|
+
pluck('value', thresholds.warning),
|
|
55
|
+
pluck('value', thresholds.critical)
|
|
56
|
+
]);
|
|
62
57
|
const adaptedMaxValue = Math.max(
|
|
63
58
|
metric.maximum_value || 0,
|
|
64
59
|
Math.max(...thresholdValues) * 1.1,
|
|
65
60
|
head(metric.data) as number
|
|
66
61
|
);
|
|
67
62
|
|
|
68
|
-
const pieColor =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
const pieColor = !thresholds.enabled
|
|
64
|
+
? theme.palette.success.main
|
|
65
|
+
: getColorFromDataAndTresholds({
|
|
66
|
+
data: metric.data[0],
|
|
67
|
+
theme,
|
|
68
|
+
thresholds
|
|
69
|
+
});
|
|
74
70
|
|
|
75
71
|
const svgTop = svgRef.current?.getBoundingClientRect().top || 0;
|
|
76
72
|
const svgLeft = svgRef.current?.getBoundingClientRect().left || 0;
|
|
77
73
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const gaugeValue = formatMetricValueWithUnit({
|
|
81
|
-
base: 1000,
|
|
82
|
-
isRaw: displayAsRaw,
|
|
83
|
-
unit: metric.unit,
|
|
84
|
-
value: metric.data[0]
|
|
85
|
-
});
|
|
74
|
+
const isSmallHeight = height < 250;
|
|
86
75
|
|
|
87
76
|
return (
|
|
88
|
-
<Box
|
|
89
|
-
sx={{
|
|
90
|
-
height: '100%',
|
|
91
|
-
overflow: 'hidden',
|
|
92
|
-
position: 'relative',
|
|
93
|
-
width: '100%'
|
|
94
|
-
}}
|
|
95
|
-
>
|
|
77
|
+
<Box sx={{ position: 'relative' }}>
|
|
96
78
|
<svg height={height} ref={svgRef} width={width}>
|
|
97
79
|
<Group left={centerX + margins.left} top={centerY + height / 6}>
|
|
98
80
|
<Thresholds
|
|
@@ -105,7 +87,6 @@ const ResponsiveGauge = ({
|
|
|
105
87
|
/>
|
|
106
88
|
<PieData
|
|
107
89
|
adaptedMaxValue={adaptedMaxValue}
|
|
108
|
-
baseColor={baseColor}
|
|
109
90
|
metric={metric}
|
|
110
91
|
radius={radius}
|
|
111
92
|
thresholds={thresholds}
|
|
@@ -116,15 +97,18 @@ const ResponsiveGauge = ({
|
|
|
116
97
|
style={{
|
|
117
98
|
fill: pieColor,
|
|
118
99
|
...theme.typography.h3,
|
|
119
|
-
fontSize:
|
|
120
|
-
Math.min(width, height) / 7 -
|
|
121
|
-
(isSmallWidget ? 0 : (gaugeValue?.length || 0) * 2)
|
|
100
|
+
fontSize: Math.min(width, height) / 7
|
|
122
101
|
}}
|
|
123
102
|
textAnchor="middle"
|
|
124
103
|
x="50%"
|
|
125
|
-
y={
|
|
104
|
+
y={isSmallHeight ? 140 : 100 + Math.min(width, height) / 3}
|
|
126
105
|
>
|
|
127
|
-
{
|
|
106
|
+
{formatMetricValue({
|
|
107
|
+
base: 1000,
|
|
108
|
+
unit: metric.unit,
|
|
109
|
+
value: metric.data[0]
|
|
110
|
+
})}{' '}
|
|
111
|
+
{metric.unit}
|
|
128
112
|
</text>
|
|
129
113
|
</svg>
|
|
130
114
|
<Fade in={tooltipOpen && thresholds.enabled}>
|
|
@@ -16,7 +16,7 @@ const Thresholds = ({
|
|
|
16
16
|
showTooltip,
|
|
17
17
|
hideTooltip,
|
|
18
18
|
metric
|
|
19
|
-
}: Omit<GaugeProps, 'width' | 'height'>): JSX.Element
|
|
19
|
+
}: Omit<GaugeProps, 'width' | 'height'>): JSX.Element => {
|
|
20
20
|
const theme = useTheme();
|
|
21
21
|
|
|
22
22
|
const criticalThresholdValues = pluck('value', thresholds.critical);
|
|
@@ -65,7 +65,30 @@ const Thresholds = ({
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
if (!thresholds.enabled) {
|
|
68
|
-
return
|
|
68
|
+
return (
|
|
69
|
+
<Pie
|
|
70
|
+
data={successThresholdArc}
|
|
71
|
+
endAngle={-Math.PI / 2}
|
|
72
|
+
innerRadius={radius - thresholdThickness}
|
|
73
|
+
outerRadius={radius}
|
|
74
|
+
pieSortValues={() => -1}
|
|
75
|
+
pieValue={(d) => d.value}
|
|
76
|
+
startAngle={Math.PI / 2}
|
|
77
|
+
>
|
|
78
|
+
{(pie) => (
|
|
79
|
+
<AnimatedPie<{ name: string; value: number }>
|
|
80
|
+
{...pie}
|
|
81
|
+
animate
|
|
82
|
+
getColor={(arc) => successThresholdScaleOrdinal(arc.data.name)}
|
|
83
|
+
getKey={(arc) => `${arc.data.name}_${arc.data.value}`}
|
|
84
|
+
hideTooltip={hideTooltip}
|
|
85
|
+
metric={metric}
|
|
86
|
+
showTooltip={showTooltip}
|
|
87
|
+
thresholds={thresholds}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
</Pie>
|
|
91
|
+
);
|
|
69
92
|
}
|
|
70
93
|
|
|
71
94
|
const arcs = [
|
|
@@ -38,7 +38,7 @@ const Axes = ({
|
|
|
38
38
|
|
|
39
39
|
const [firstUnit, secondUnit, thirdUnit] = getUnits(lines);
|
|
40
40
|
|
|
41
|
-
const xTickCount = Math.
|
|
41
|
+
const xTickCount = Math.ceil(width / 82);
|
|
42
42
|
|
|
43
43
|
const tickFormat =
|
|
44
44
|
data?.axisX?.xAxisTickFormat ?? getXAxisTickFormat(graphInterval);
|
|
@@ -16,7 +16,7 @@ interface Props {
|
|
|
16
16
|
graphHeight: number;
|
|
17
17
|
highlight?: boolean;
|
|
18
18
|
lineColor: string;
|
|
19
|
-
|
|
19
|
+
metric: string;
|
|
20
20
|
shapeAreaClosed?: Record<string, unknown>;
|
|
21
21
|
shapeLinePath?: Record<string, unknown>;
|
|
22
22
|
timeSeries: Array<TimeValue>;
|
|
@@ -30,7 +30,7 @@ const RegularLine = ({
|
|
|
30
30
|
filled,
|
|
31
31
|
timeSeries,
|
|
32
32
|
highlight,
|
|
33
|
-
|
|
33
|
+
metric,
|
|
34
34
|
lineColor,
|
|
35
35
|
unit,
|
|
36
36
|
yScale,
|
|
@@ -43,13 +43,13 @@ const RegularLine = ({
|
|
|
43
43
|
const props = {
|
|
44
44
|
curve,
|
|
45
45
|
data: timeSeries,
|
|
46
|
-
defined: (value): boolean => !isNil(value[
|
|
46
|
+
defined: (value): boolean => !isNil(value[metric]),
|
|
47
47
|
opacity: 1,
|
|
48
48
|
stroke: lineColor,
|
|
49
49
|
strokeWidth: !highlight ? 1 : 2,
|
|
50
50
|
unit,
|
|
51
51
|
x: (timeValue): number => xScale(getTime(timeValue)) as number,
|
|
52
|
-
y: (timeValue): number => yScale(prop(
|
|
52
|
+
y: (timeValue): number => yScale(prop(metric, timeValue)) ?? null
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
if (filled) {
|
|
@@ -57,7 +57,7 @@ const RegularLine = ({
|
|
|
57
57
|
<Shape.AreaClosed<TimeValue>
|
|
58
58
|
fill={getFillColor({ areaColor, transparency })}
|
|
59
59
|
fillRule="nonzero"
|
|
60
|
-
key={
|
|
60
|
+
key={metric}
|
|
61
61
|
y0={Math.min(yScale(0), graphHeight)}
|
|
62
62
|
yScale={yScale}
|
|
63
63
|
{...props}
|
|
@@ -73,27 +73,22 @@ export default memo(RegularLine, (prevProps, nextProps) => {
|
|
|
73
73
|
timeSeries: prevTimeSeries,
|
|
74
74
|
graphHeight: prevGraphHeight,
|
|
75
75
|
highlight: prevHighlight,
|
|
76
|
-
xScale: prevXScale
|
|
77
|
-
yScale: prevYScale
|
|
76
|
+
xScale: prevXScale
|
|
78
77
|
} = prevProps;
|
|
79
78
|
const {
|
|
80
79
|
timeSeries: nextTimeSeries,
|
|
81
80
|
graphHeight: nextGraphHeight,
|
|
82
81
|
highlight: nextHighlight,
|
|
83
|
-
xScale: nextXScale
|
|
84
|
-
yScale: nextYScale
|
|
82
|
+
xScale: nextXScale
|
|
85
83
|
} = nextProps;
|
|
86
84
|
|
|
87
85
|
const prevXScaleRange = prevXScale.range();
|
|
88
86
|
const nextXScaleRange = nextXScale.range();
|
|
89
|
-
const prevYScaleDomain = prevYScale.domain();
|
|
90
|
-
const nextYScaleDomain = nextYScale.domain();
|
|
91
87
|
|
|
92
88
|
return (
|
|
93
89
|
equals(prevTimeSeries, nextTimeSeries) &&
|
|
94
90
|
equals(prevGraphHeight, nextGraphHeight) &&
|
|
95
91
|
equals(prevHighlight, nextHighlight) &&
|
|
96
|
-
equals(prevXScaleRange, nextXScaleRange)
|
|
97
|
-
equals(prevYScaleDomain, nextYScaleDomain)
|
|
92
|
+
equals(prevXScaleRange, nextXScaleRange)
|
|
98
93
|
);
|
|
99
94
|
});
|
|
@@ -32,13 +32,11 @@ const StackLines = ({
|
|
|
32
32
|
data={timeSeries}
|
|
33
33
|
defined={(d): boolean => {
|
|
34
34
|
return pipe(
|
|
35
|
-
map(prop('
|
|
36
|
-
|
|
37
|
-
) => Array<string>,
|
|
38
|
-
all((metric_id) => pipe(path(['data', metric_id]), isNil, not)(d))
|
|
35
|
+
map(prop('metric')) as unknown as (displayedLines) => Array<string>,
|
|
36
|
+
all((metric) => pipe(path(['data', metric]), isNil, not)(d))
|
|
39
37
|
)(lines);
|
|
40
38
|
}}
|
|
41
|
-
keys={map(prop('
|
|
39
|
+
keys={map(prop('metric'), lines)}
|
|
42
40
|
x={(d): number => xScale(getTime(d.data)) ?? 0}
|
|
43
41
|
y0={(d): number => yScale(d[0]) ?? 0}
|
|
44
42
|
y1={(d): number => yScale(d[1]) ?? 0}
|
|
@@ -53,21 +53,21 @@ const useScaleThreshold = ({
|
|
|
53
53
|
const [, secondUnit, thirdUnit] = getUnits(lines);
|
|
54
54
|
|
|
55
55
|
const {
|
|
56
|
-
|
|
56
|
+
metric: metricY1,
|
|
57
57
|
unit: unitY1,
|
|
58
58
|
invert: invertY1,
|
|
59
59
|
lineColor: lineColorY1
|
|
60
60
|
} = lineUpper;
|
|
61
61
|
|
|
62
62
|
const {
|
|
63
|
-
|
|
63
|
+
metric: metricY0,
|
|
64
64
|
unit: unitY0,
|
|
65
65
|
invert: invertY0,
|
|
66
66
|
lineColor: lineColorY0
|
|
67
67
|
} = lineLower;
|
|
68
68
|
|
|
69
69
|
const {
|
|
70
|
-
|
|
70
|
+
metric: metricOrigin,
|
|
71
71
|
unit: unitYOrigin,
|
|
72
72
|
invert: invertYOrigin
|
|
73
73
|
} = lineOrigin;
|
|
@@ -129,14 +129,14 @@ const Lines = ({
|
|
|
129
129
|
{displayAreaRegularLines
|
|
130
130
|
? regularLines.map(
|
|
131
131
|
({
|
|
132
|
+
metric,
|
|
132
133
|
areaColor,
|
|
133
134
|
transparency,
|
|
134
135
|
lineColor,
|
|
135
136
|
filled,
|
|
136
137
|
unit,
|
|
137
138
|
highlight,
|
|
138
|
-
invert
|
|
139
|
-
metric_id
|
|
139
|
+
invert
|
|
140
140
|
}) => {
|
|
141
141
|
const [, secondUnit, thirdUnit] = getUnits(
|
|
142
142
|
regularLines as Array<Line>
|
|
@@ -151,12 +151,12 @@ const Lines = ({
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
return (
|
|
154
|
-
<g key={
|
|
154
|
+
<g key={metric}>
|
|
155
155
|
{displayGuidingLines && (
|
|
156
156
|
<RegularAnchorPoint
|
|
157
157
|
areaColor={areaColor}
|
|
158
158
|
lineColor={lineColor}
|
|
159
|
-
|
|
159
|
+
metric={metric}
|
|
160
160
|
timeSeries={timeSeries}
|
|
161
161
|
transparency={transparency}
|
|
162
162
|
xScale={xScale}
|
|
@@ -170,7 +170,7 @@ const Lines = ({
|
|
|
170
170
|
graphHeight={height}
|
|
171
171
|
highlight={highlight}
|
|
172
172
|
lineColor={lineColor}
|
|
173
|
-
|
|
173
|
+
metric={metric}
|
|
174
174
|
timeSeries={timeSeries}
|
|
175
175
|
transparency={transparency}
|
|
176
176
|
unit={unit}
|
|
@@ -11,7 +11,7 @@ import AnchorPoint from '.';
|
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
lineColor: string;
|
|
14
|
-
|
|
14
|
+
metric: string;
|
|
15
15
|
timeSeries: Array<TimeValue>;
|
|
16
16
|
xScale: ScaleTime<number, number>;
|
|
17
17
|
yScale: ScaleLinear<number, number>;
|
|
@@ -21,18 +21,18 @@ const getYAnchorPoint = ({
|
|
|
21
21
|
timeTick,
|
|
22
22
|
timeSeries,
|
|
23
23
|
yScale,
|
|
24
|
-
|
|
24
|
+
metric
|
|
25
25
|
}: GetYAnchorPoint): number => {
|
|
26
26
|
const index = bisectDate(getDates(timeSeries), timeTick);
|
|
27
27
|
const timeValue = timeSeries[index];
|
|
28
28
|
|
|
29
|
-
return yScale(prop(
|
|
29
|
+
return yScale(prop(metric, timeValue) as number);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
const RegularAnchorPoint = ({
|
|
33
33
|
xScale,
|
|
34
34
|
yScale,
|
|
35
|
-
|
|
35
|
+
metric,
|
|
36
36
|
timeSeries,
|
|
37
37
|
lineColor
|
|
38
38
|
}: Props): JSX.Element | null => {
|
|
@@ -48,7 +48,7 @@ const RegularAnchorPoint = ({
|
|
|
48
48
|
const xAnchorPoint = xScale(timeTick);
|
|
49
49
|
|
|
50
50
|
const yAnchorPoint = getYAnchorPoint({
|
|
51
|
-
|
|
51
|
+
metric,
|
|
52
52
|
timeSeries,
|
|
53
53
|
timeTick,
|
|
54
54
|
yScale
|
|
@@ -69,25 +69,25 @@ const MainLegend = ({
|
|
|
69
69
|
value
|
|
70
70
|
}) || 'N/A';
|
|
71
71
|
|
|
72
|
-
const selectMetric = ({ event,
|
|
72
|
+
const selectMetric = ({ event, metric }): void => {
|
|
73
73
|
if (!toggable) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
if (event.ctrlKey || event.metaKey) {
|
|
78
|
-
toggleMetricLine(
|
|
78
|
+
toggleMetricLine(metric);
|
|
79
79
|
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
selectMetricLine(
|
|
83
|
+
selectMetricLine(metric);
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
87
|
<div className={classes.legend}>
|
|
88
88
|
<div className={classes.items}>
|
|
89
89
|
{displayedLines.map((line) => {
|
|
90
|
-
const { color, display,
|
|
90
|
+
const { color, name, display, metric, highlight } = line;
|
|
91
91
|
|
|
92
92
|
const markerColor = display
|
|
93
93
|
? color
|
|
@@ -119,9 +119,9 @@ const MainLegend = ({
|
|
|
119
119
|
highlight ? classes.highlight : classes.normal,
|
|
120
120
|
toggable && classes.toggable
|
|
121
121
|
)}
|
|
122
|
-
key={
|
|
123
|
-
onClick={(event): void => selectMetric({ event,
|
|
124
|
-
onMouseEnter={(): void => highlightLine(
|
|
122
|
+
key={name}
|
|
123
|
+
onClick={(event): void => selectMetric({ event, metric })}
|
|
124
|
+
onMouseEnter={(): void => highlightLine(metric)}
|
|
125
125
|
onMouseLeave={(): void => clearHighlight()}
|
|
126
126
|
>
|
|
127
127
|
<LegendMarker color={markerColor} disabled={!display} />
|
|
@@ -43,34 +43,34 @@ const useInteractiveValues = ({
|
|
|
43
43
|
equals(item.timeTick, timeValue?.timeTick)
|
|
44
44
|
);
|
|
45
45
|
|
|
46
|
-
const getMetricsToDisplay = (): Array<
|
|
46
|
+
const getMetricsToDisplay = (): Array<string> => {
|
|
47
47
|
if (isNil(graphTimeValue)) {
|
|
48
48
|
return [];
|
|
49
49
|
}
|
|
50
50
|
const metricsData = getMetrics(graphTimeValue as TimeValue);
|
|
51
51
|
|
|
52
|
-
const metricsToDisplay = metricsData.filter((
|
|
53
|
-
const line = getLineForMetric({ lines,
|
|
52
|
+
const metricsToDisplay = metricsData.filter((metric) => {
|
|
53
|
+
const line = getLineForMetric({ lines, metric });
|
|
54
54
|
|
|
55
|
-
return !isNil(graphTimeValue[
|
|
55
|
+
return !isNil(graphTimeValue[metric]) && !isNil(line);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
return metricsToDisplay
|
|
58
|
+
return metricsToDisplay;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const metrics = useMemo(() => getMetricsToDisplay(), [graphTimeValue]);
|
|
62
62
|
|
|
63
63
|
const getFormattedMetricData = (
|
|
64
|
-
|
|
64
|
+
metric: string
|
|
65
65
|
): FormattedMetricData | null => {
|
|
66
66
|
if (isNil(graphTimeValue)) {
|
|
67
67
|
return null;
|
|
68
68
|
}
|
|
69
|
-
const value = graphTimeValue[
|
|
69
|
+
const value = graphTimeValue[metric] as number;
|
|
70
70
|
|
|
71
71
|
const { color, name, unit } = getLineForMetric({
|
|
72
72
|
lines,
|
|
73
|
-
|
|
73
|
+
metric
|
|
74
74
|
}) as Line;
|
|
75
75
|
|
|
76
76
|
const formattedValue = formatMetricValue({
|
|
@@ -88,9 +88,9 @@ const useInteractiveValues = ({
|
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
const getFormattedValue = (line: Line): string | undefined | null => {
|
|
91
|
-
const
|
|
91
|
+
const metric = find(equals(line.metric), metrics);
|
|
92
92
|
|
|
93
|
-
return
|
|
93
|
+
return metric && getFormattedMetricData(metric)?.formattedValue;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
return { getFormattedValue };
|