@centreon/ui 24.8.2 → 24.8.3
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 +14 -17
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +38 -79
- package/src/Graph/BarChart/BarChart.tsx +4 -4
- package/src/Graph/BarChart/BarGroup.tsx +81 -92
- package/src/Graph/BarChart/BarStack.tsx +21 -13
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +26 -50
- package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +1 -1
- package/src/Graph/BarChart/useBarStack.ts +1 -1
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Point.tsx +1 -1
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +67 -0
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +4 -7
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/index.tsx +6 -9
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/models.ts +1 -2
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useScaleThreshold.ts +8 -20
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/index.tsx +64 -43
- package/src/Graph/{LineChart/LineChart.cypress.spec.tsx → Chart/Chart.cypress.spec.tsx} +272 -23
- package/src/Graph/{LineChart/index.stories.tsx → Chart/Chart.stories.tsx} +217 -24
- package/src/Graph/{LineChart/LineChart.styles.ts → Chart/Chart.styles.ts} +1 -1
- package/src/Graph/{LineChart/LineChart.tsx → Chart/Chart.tsx} +84 -100
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -1
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +6 -1
- package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +61 -0
- package/src/Graph/{LineChart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx → Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltipContent.tsx} +2 -2
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/index.tsx +11 -15
- package/src/Graph/{LineChart → Chart}/Legend/Legend.styles.ts +1 -7
- package/src/Graph/{LineChart → Chart}/Legend/LegendHeader.tsx +9 -5
- package/src/Graph/{LineChart → Chart}/Legend/index.tsx +2 -1
- package/src/Graph/Chart/graphAtoms.ts +6 -0
- package/src/Graph/{LineChart → Chart}/index.tsx +10 -7
- package/src/Graph/{LineChart → Chart}/models.ts +8 -3
- package/src/Graph/common/Axes/AxisStyles.ts +11 -0
- package/src/Graph/common/Axes/UnitLabel.tsx +41 -10
- package/src/Graph/common/Axes/index.tsx +18 -12
- package/src/Graph/common/Axes/models.ts +4 -2
- package/src/Graph/common/Axes/useAxisY.ts +22 -12
- package/src/Graph/common/BaseChart/BaseChart.tsx +2 -2
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +8 -5
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +1 -1
- package/src/Graph/common/Grids/index.tsx +2 -2
- package/src/Graph/common/Thresholds/ThresholdLine.tsx +1 -1
- package/src/Graph/common/Thresholds/Thresholds.tsx +10 -15
- package/src/Graph/common/timeSeries/index.ts +109 -131
- package/src/Graph/common/timeSeries/models.ts +4 -5
- package/src/Graph/index.ts +4 -4
- package/src/Graph/mockedData/lastDayWithLotOfUnits.json +1668 -0
- package/src/Graph/mockedData/pingService.json +46 -1
- package/src/Graph/mockedData/pingServiceLinesBars.json +253 -0
- package/src/Graph/mockedData/pingServiceLinesBarsMixed.json +253 -0
- package/src/Graph/mockedData/pingServiceLinesBarsStacked.json +253 -0
- package/src/Graph/mockedData/pingServiceMixedStacked.json +46 -1
- package/src/Graph/mockedData/pingServiceStacked.json +46 -1
- package/src/Typography/EllipsisTypography.tsx +5 -2
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +16 -24
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
- package/src/components/Form/AccessRights/AccessRights.tsx +3 -3
- package/src/components/Form/index.ts +2 -2
- package/src/utils/index.ts +2 -2
- package/src/Graph/BarChart/SingleBar.tsx +0 -62
- package/src/Graph/BarChart/useSingleBar.ts +0 -199
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/useStackedLines.ts +0 -39
- package/src/Graph/LineChart/graphAtoms.ts +0 -3
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/useRegularLines.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/StackedLines/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/BasicThreshold.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/Circle.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/helpers/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useCoordinateCircle.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/GuidingLines.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/useTickGraph.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Area.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Line.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Area/Downtime.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/EventAnnotations.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Acknowledgement.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Comments.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/annotationsAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/useAnnotation.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Bar.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltipStyles.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftIcon.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/useGraphTooltip.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/useZoomPreview.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/zoomPreviewAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/interactionWithGraphAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/LegendContent.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/useLegend.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/LoadingSkeleton.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/common/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/helpers/doc.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/helpers/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/translatedLabels.ts +0 -0
- /package/src/Graph/{LineChart/useLineChartData.ts → Chart/useChartData.ts} +0 -0
- /package/src/Graph/{LineChart/useLineChartIntersection.ts → Chart/useChartIntersection.ts} +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { memo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { scaleBand } from '@visx/scale';
|
|
4
|
-
import { equals, gt, pick } from 'ramda';
|
|
4
|
+
import { dec, equals, gt, pick } from 'ramda';
|
|
5
|
+
import { BarRounded } from '@visx/shape';
|
|
5
6
|
|
|
6
7
|
import { useBarStack, UseBarStackProps } from './useBarStack';
|
|
7
8
|
import { BarStyle } from './models';
|
|
@@ -37,7 +38,7 @@ const BarStack = ({
|
|
|
37
38
|
barPadding,
|
|
38
39
|
barIndex,
|
|
39
40
|
isTooltipHidden,
|
|
40
|
-
barStyle
|
|
41
|
+
barStyle = { opacity: 1, radius: 0.2 }
|
|
41
42
|
}: Props): JSX.Element => {
|
|
42
43
|
const {
|
|
43
44
|
BarStackComponent,
|
|
@@ -56,21 +57,28 @@ const BarStack = ({
|
|
|
56
57
|
{...commonBarStackProps}
|
|
57
58
|
>
|
|
58
59
|
{(barStacks) => {
|
|
59
|
-
return barStacks.map((barStack) =>
|
|
60
|
+
return barStacks.map((barStack, index) =>
|
|
60
61
|
barStack.bars.map((bar) => {
|
|
62
|
+
const shouldApplyRadiusOnBottom = equals(index, 0);
|
|
63
|
+
const shouldApplyRadiusOnTop = equals(index, dec(barStacks.length));
|
|
61
64
|
const isNegativeValue = gt(0, bar.bar[1]);
|
|
62
65
|
|
|
66
|
+
const barRoundedProps = {
|
|
67
|
+
[isHorizontal ? 'top' : 'right']: shouldApplyRadiusOnTop,
|
|
68
|
+
[isHorizontal ? 'bottom' : 'left']: shouldApplyRadiusOnBottom
|
|
69
|
+
};
|
|
70
|
+
|
|
63
71
|
return (
|
|
64
|
-
<
|
|
72
|
+
<BarRounded
|
|
73
|
+
{...barRoundedProps}
|
|
65
74
|
data-testid={`stacked-bar-${bar.key}-${bar.index}-${bar.bar[1]}`}
|
|
66
75
|
fill={bar.color}
|
|
67
|
-
height={Math.
|
|
68
|
-
isHorizontal ? Math.abs(bar.height) : barWidth
|
|
69
|
-
)}
|
|
76
|
+
height={isHorizontal ? Math.abs(bar.height) : barWidth}
|
|
70
77
|
key={`bar-stack-${barStack.index}-${bar.index}`}
|
|
71
|
-
opacity={barStyle.opacity}
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
opacity={barStyle.opacity ?? 1}
|
|
79
|
+
radius={barWidth * barStyle.radius}
|
|
80
|
+
width={isHorizontal ? barWidth : Math.abs(bar.width)}
|
|
81
|
+
x={
|
|
74
82
|
isHorizontal
|
|
75
83
|
? barPadding
|
|
76
84
|
: getPadding({
|
|
@@ -78,8 +86,8 @@ const BarStack = ({
|
|
|
78
86
|
padding: bar.x,
|
|
79
87
|
size: bar.width
|
|
80
88
|
})
|
|
81
|
-
|
|
82
|
-
y={
|
|
89
|
+
}
|
|
90
|
+
y={
|
|
83
91
|
isHorizontal
|
|
84
92
|
? getPadding({
|
|
85
93
|
isNegativeValue,
|
|
@@ -87,7 +95,7 @@ const BarStack = ({
|
|
|
87
95
|
size: bar.height
|
|
88
96
|
})
|
|
89
97
|
: barPadding
|
|
90
|
-
|
|
98
|
+
}
|
|
91
99
|
onMouseEnter={
|
|
92
100
|
isTooltipHidden
|
|
93
101
|
? undefined
|
|
@@ -5,21 +5,20 @@ import { useAtom } from 'jotai';
|
|
|
5
5
|
|
|
6
6
|
import { Skeleton } from '@mui/material';
|
|
7
7
|
|
|
8
|
-
import { Data, LineChartProps } from '../
|
|
8
|
+
import { Data, LineChartProps } from '../Chart/models';
|
|
9
9
|
import { Thresholds as ThresholdsModel } from '../common/models';
|
|
10
|
-
import { useIntersection } from '../
|
|
10
|
+
import { useIntersection } from '../Chart/useChartIntersection';
|
|
11
11
|
import { Line } from '../common/timeSeries/models';
|
|
12
12
|
import { useComputeBaseChartDimensions } from '../common/BaseChart/useComputeBaseChartDimensions';
|
|
13
13
|
import {
|
|
14
|
-
getLeftScale,
|
|
15
|
-
getRightScale,
|
|
16
14
|
getUnits,
|
|
17
|
-
getXScaleBand
|
|
15
|
+
getXScaleBand,
|
|
16
|
+
getYScalePerUnit
|
|
18
17
|
} from '../common/timeSeries';
|
|
19
18
|
import BaseChart from '../common/BaseChart/BaseChart';
|
|
20
19
|
import ChartSvgWrapper from '../common/BaseChart/ChartSvgWrapper';
|
|
21
20
|
import { useTooltipStyles } from '../common/useTooltipStyles';
|
|
22
|
-
import { margin } from '../
|
|
21
|
+
import { margin } from '../Chart/common';
|
|
23
22
|
import { Tooltip } from '../../components';
|
|
24
23
|
import Thresholds from '../common/Thresholds/Thresholds';
|
|
25
24
|
import { useDeepCompare } from '../../utils';
|
|
@@ -68,7 +67,13 @@ const ResponsiveBarChart = ({
|
|
|
68
67
|
|
|
69
68
|
const { isInViewport } = useIntersection({ element: graphRef?.current });
|
|
70
69
|
|
|
71
|
-
const
|
|
70
|
+
const displayedLines = useMemo(
|
|
71
|
+
() => linesGraph.filter(({ display }) => display),
|
|
72
|
+
[linesGraph]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const [firstUnit, secondUnit] = getUnits(displayedLines);
|
|
76
|
+
const allUnits = getUnits(lines);
|
|
72
77
|
|
|
73
78
|
const { legendRef, graphWidth, graphHeight } = useComputeBaseChartDimensions({
|
|
74
79
|
hasSecondUnit: Boolean(secondUnit),
|
|
@@ -100,10 +105,10 @@ const ResponsiveBarChart = ({
|
|
|
100
105
|
[timeSeries, graphWidth, isHorizontal, graphHeight]
|
|
101
106
|
);
|
|
102
107
|
|
|
103
|
-
const
|
|
108
|
+
const yScalesPerUnit = useMemo(
|
|
104
109
|
() =>
|
|
105
|
-
|
|
106
|
-
dataLines:
|
|
110
|
+
getYScalePerUnit({
|
|
111
|
+
dataLines: displayedLines,
|
|
107
112
|
dataTimeSeries: timeSeries,
|
|
108
113
|
isCenteredZero: axis?.isCenteredZero,
|
|
109
114
|
isHorizontal,
|
|
@@ -111,46 +116,25 @@ const ResponsiveBarChart = ({
|
|
|
111
116
|
scaleLogarithmicBase: axis?.scaleLogarithmicBase,
|
|
112
117
|
thresholdUnit,
|
|
113
118
|
thresholds: (thresholds?.enabled && thresholdValues) || [],
|
|
114
|
-
valueGraphHeight:
|
|
119
|
+
valueGraphHeight:
|
|
120
|
+
(isHorizontal ? graphHeight : graphWidth) - margin.bottom
|
|
115
121
|
}),
|
|
116
122
|
[
|
|
117
|
-
|
|
123
|
+
displayedLines,
|
|
118
124
|
timeSeries,
|
|
119
125
|
graphHeight,
|
|
120
126
|
thresholdValues,
|
|
121
|
-
axis?.isCenteredZero,
|
|
122
|
-
axis?.scale,
|
|
123
|
-
axis?.scaleLogarithmicBase,
|
|
124
127
|
graphWidth,
|
|
125
|
-
|
|
126
|
-
]
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
const rightScale = useMemo(
|
|
130
|
-
() =>
|
|
131
|
-
getRightScale({
|
|
132
|
-
dataLines: linesGraph,
|
|
133
|
-
dataTimeSeries: timeSeries,
|
|
134
|
-
isCenteredZero: axis?.isCenteredZero,
|
|
135
|
-
isHorizontal,
|
|
136
|
-
scale: axis?.scale,
|
|
137
|
-
scaleLogarithmicBase: axis?.scaleLogarithmicBase,
|
|
138
|
-
thresholdUnit,
|
|
139
|
-
thresholds: (thresholds?.enabled && thresholdValues) || [],
|
|
140
|
-
valueGraphHeight: (isHorizontal ? graphHeight : graphWidth) - 35
|
|
141
|
-
}),
|
|
142
|
-
[
|
|
143
|
-
timeSeries,
|
|
144
|
-
linesGraph,
|
|
145
|
-
graphHeight,
|
|
128
|
+
thresholds?.enabled,
|
|
146
129
|
axis?.isCenteredZero,
|
|
147
130
|
axis?.scale,
|
|
148
|
-
axis?.scaleLogarithmicBase
|
|
149
|
-
graphWidth,
|
|
150
|
-
isHorizontal
|
|
131
|
+
axis?.scaleLogarithmicBase
|
|
151
132
|
]
|
|
152
133
|
);
|
|
153
134
|
|
|
135
|
+
const leftScale = yScalesPerUnit[firstUnit];
|
|
136
|
+
const rightScale = yScalesPerUnit[secondUnit];
|
|
137
|
+
|
|
154
138
|
useEffect(
|
|
155
139
|
() => {
|
|
156
140
|
setLinesGraph(lines);
|
|
@@ -160,11 +144,6 @@ const ResponsiveBarChart = ({
|
|
|
160
144
|
|
|
161
145
|
const displayLegend = legend?.display ?? true;
|
|
162
146
|
|
|
163
|
-
const displayedLines = useMemo(
|
|
164
|
-
() => linesGraph.filter(({ display }) => display),
|
|
165
|
-
[linesGraph]
|
|
166
|
-
);
|
|
167
|
-
|
|
168
147
|
const showGridLines = useMemo(
|
|
169
148
|
() => isNil(axis?.showGridLines) || axis?.showGridLines,
|
|
170
149
|
[axis?.showGridLines]
|
|
@@ -221,6 +200,7 @@ const ResponsiveBarChart = ({
|
|
|
221
200
|
>
|
|
222
201
|
<div className={classes.tooltipChildren}>
|
|
223
202
|
<ChartSvgWrapper
|
|
203
|
+
allUnits={allUnits}
|
|
224
204
|
axis={axis}
|
|
225
205
|
base={baseAxis}
|
|
226
206
|
displayedLines={displayedLines}
|
|
@@ -238,24 +218,19 @@ const ResponsiveBarChart = ({
|
|
|
238
218
|
<>
|
|
239
219
|
<BarGroup
|
|
240
220
|
barStyle={barStyle}
|
|
241
|
-
isCenteredZero={axis?.isCenteredZero}
|
|
242
221
|
isTooltipHidden={isTooltipHidden}
|
|
243
|
-
leftScale={leftScale}
|
|
244
222
|
lines={displayedLines}
|
|
245
223
|
orientation={isHorizontal ? 'horizontal' : 'vertical'}
|
|
246
|
-
rightScale={rightScale}
|
|
247
|
-
secondUnit={secondUnit}
|
|
248
224
|
size={isHorizontal ? graphHeight - margin.top - 5 : graphWidth}
|
|
249
225
|
timeSeries={timeSeries}
|
|
250
226
|
xScale={xScale}
|
|
227
|
+
yScalesPerUnit={yScalesPerUnit}
|
|
251
228
|
/>
|
|
252
229
|
{thresholds?.enabled && (
|
|
253
230
|
<Thresholds
|
|
254
231
|
displayedLines={displayedLines}
|
|
255
232
|
hideTooltip={() => setTooltipData(null)}
|
|
256
233
|
isHorizontal={isHorizontal}
|
|
257
|
-
leftScale={leftScale}
|
|
258
|
-
rightScale={rightScale}
|
|
259
234
|
showTooltip={({ tooltipData: thresholdLabel }) =>
|
|
260
235
|
setTooltipData({
|
|
261
236
|
thresholdLabel
|
|
@@ -264,6 +239,7 @@ const ResponsiveBarChart = ({
|
|
|
264
239
|
thresholdUnit={thresholdUnit}
|
|
265
240
|
thresholds={thresholds as ThresholdsModel}
|
|
266
241
|
width={isHorizontal ? graphWidth : graphHeight - margin.top}
|
|
242
|
+
yScalesPerUnit={yScalesPerUnit}
|
|
267
243
|
/>
|
|
268
244
|
)}
|
|
269
245
|
</>
|
|
@@ -20,7 +20,7 @@ import { TimeValue } from '../../common/timeSeries/models';
|
|
|
20
20
|
import { useLocaleDateTimeFormat } from '../../../utils';
|
|
21
21
|
import { formatMetricValueWithUnit } from '../../common/timeSeries';
|
|
22
22
|
import { tooltipDataAtom } from '../atoms';
|
|
23
|
-
import { Tooltip } from '../../
|
|
23
|
+
import { Tooltip } from '../../Chart/models';
|
|
24
24
|
|
|
25
25
|
import { useBarChartTooltipStyles } from './useBarChartTooltipStyles';
|
|
26
26
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { equals, pluck, uniq } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getInvertedStackedLines,
|
|
5
|
+
getNotInvertedStackedLines,
|
|
6
|
+
getTimeSeriesForLines
|
|
7
|
+
} from '../../../../common/timeSeries';
|
|
8
|
+
import { LinesData } from '../models';
|
|
9
|
+
|
|
10
|
+
interface StackedLinesState {
|
|
11
|
+
invertedStackedLinesData: Record<string, LinesData>;
|
|
12
|
+
stackedLinesData: Record<string, LinesData>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const useStackedLines = ({ lines, timeSeries }): StackedLinesState => {
|
|
16
|
+
const regularStackedLines = getNotInvertedStackedLines(lines);
|
|
17
|
+
const regularStackedUnits = uniq(pluck('unit', regularStackedLines));
|
|
18
|
+
const regularStackedLinesTimeSeriesPerUnit = regularStackedUnits.reduce(
|
|
19
|
+
(acc, stackedUnit) => {
|
|
20
|
+
const relatedLines = regularStackedLines.filter(({ unit }) =>
|
|
21
|
+
equals(unit, stackedUnit)
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...acc,
|
|
26
|
+
[stackedUnit]: {
|
|
27
|
+
lines: relatedLines,
|
|
28
|
+
timeSeries: getTimeSeriesForLines({
|
|
29
|
+
lines: relatedLines,
|
|
30
|
+
timeSeries
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
{}
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const invertedStackedLines = getInvertedStackedLines(lines);
|
|
39
|
+
const invertedStackedUnits = uniq(pluck('unit', invertedStackedLines));
|
|
40
|
+
const invertedStackedLinesTimeSeriesPerUnit = invertedStackedUnits.reduce(
|
|
41
|
+
(acc, stackedUnit) => {
|
|
42
|
+
const relatedLines = invertedStackedLines.filter(({ unit }) =>
|
|
43
|
+
equals(unit, stackedUnit)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
...acc,
|
|
48
|
+
[stackedUnit]: {
|
|
49
|
+
lines: relatedLines,
|
|
50
|
+
timeSeries: getTimeSeriesForLines({
|
|
51
|
+
invert: true,
|
|
52
|
+
lines: relatedLines,
|
|
53
|
+
timeSeries
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
{}
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
invertedStackedLinesData: invertedStackedLinesTimeSeriesPerUnit,
|
|
63
|
+
stackedLinesData: regularStackedLinesTimeSeriesPerUnit
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default useStackedLines;
|
package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx
RENAMED
|
@@ -15,20 +15,18 @@ interface Props {
|
|
|
15
15
|
data: LineChartData;
|
|
16
16
|
graphHeight: number;
|
|
17
17
|
id: string;
|
|
18
|
-
leftScale: ScaleLinear<number, number>;
|
|
19
18
|
orientation?: Array<PatternOrientation>;
|
|
20
|
-
rightScale: ScaleLinear<number, number>;
|
|
21
19
|
xScale: ScaleLinear<number, number>;
|
|
20
|
+
yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
const ThresholdWithPatternLines = ({
|
|
25
24
|
graphHeight,
|
|
26
25
|
data,
|
|
27
26
|
orientation = ['diagonal'],
|
|
28
|
-
leftScale,
|
|
29
|
-
rightScale,
|
|
30
27
|
xScale,
|
|
31
28
|
id,
|
|
29
|
+
yScalesPerUnit,
|
|
32
30
|
curve
|
|
33
31
|
}: Props): JSX.Element | null => {
|
|
34
32
|
const theme = useTheme();
|
|
@@ -36,10 +34,9 @@ const ThresholdWithPatternLines = ({
|
|
|
36
34
|
const { lines, timeSeries } = adjustGraphData(data);
|
|
37
35
|
|
|
38
36
|
const result = useScaleThreshold({
|
|
39
|
-
leftScale,
|
|
40
37
|
lines,
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
xScale,
|
|
39
|
+
yScalesPerUnit
|
|
43
40
|
});
|
|
44
41
|
if (!result) {
|
|
45
42
|
return null;
|
|
@@ -24,19 +24,17 @@ interface Props extends WrapperThresholdLinesModel {
|
|
|
24
24
|
const WrapperThresholdLines = ({
|
|
25
25
|
areaThresholdLines,
|
|
26
26
|
graphHeight,
|
|
27
|
-
leftScale,
|
|
28
27
|
lines,
|
|
29
|
-
rightScale,
|
|
30
28
|
timeSeries,
|
|
31
29
|
xScale,
|
|
32
|
-
curve
|
|
30
|
+
curve,
|
|
31
|
+
yScalesPerUnit
|
|
33
32
|
}: Props): JSX.Element | null => {
|
|
34
33
|
const data = useScaleThreshold({
|
|
35
34
|
areaThresholdLines,
|
|
36
|
-
leftScale,
|
|
37
35
|
lines,
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
xScale,
|
|
37
|
+
yScalesPerUnit
|
|
40
38
|
});
|
|
41
39
|
|
|
42
40
|
if (!data) {
|
|
@@ -110,10 +108,9 @@ const WrapperThresholdLines = ({
|
|
|
110
108
|
data: element,
|
|
111
109
|
graphHeight,
|
|
112
110
|
key: ind,
|
|
113
|
-
leftScale,
|
|
114
111
|
orientation: dataPattern?.orientation,
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
xScale,
|
|
113
|
+
yScalesPerUnit
|
|
117
114
|
}
|
|
118
115
|
}));
|
|
119
116
|
}
|
|
@@ -59,10 +59,9 @@ export interface LinesThreshold {
|
|
|
59
59
|
|
|
60
60
|
export interface WrapperThresholdLinesModel {
|
|
61
61
|
areaThresholdLines?: GlobalAreaLines['areaThresholdLines'];
|
|
62
|
-
leftScale: ScaleLinear<number, number>;
|
|
63
62
|
lines: Array<Line>;
|
|
64
|
-
rightScale: ScaleLinear<number, number>;
|
|
65
63
|
xScale: ScaleLinear<number, number>;
|
|
64
|
+
yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
export interface ScaleVariationThreshold {
|
|
@@ -2,7 +2,7 @@ import { equals, isNil, prop } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { ThresholdType, VariationThreshold } from '../../../models';
|
|
4
4
|
import { TimeValue } from '../../../../common/timeSeries/models';
|
|
5
|
-
import { getTime,
|
|
5
|
+
import { getTime, getYScale } from '../../../../common/timeSeries';
|
|
6
6
|
import { displayArea } from '../../../helpers/index';
|
|
7
7
|
|
|
8
8
|
import { envelopeVariationFormula } from './helpers';
|
|
@@ -26,8 +26,7 @@ interface Result extends Partial<ScaleVariationThreshold> {
|
|
|
26
26
|
const useScaleThreshold = ({
|
|
27
27
|
lines,
|
|
28
28
|
areaThresholdLines,
|
|
29
|
-
|
|
30
|
-
rightScale,
|
|
29
|
+
yScalesPerUnit,
|
|
31
30
|
xScale
|
|
32
31
|
}: WrapperThresholdLinesModel): Result | null => {
|
|
33
32
|
const getLinesThreshold = (): LinesThreshold | null => {
|
|
@@ -50,8 +49,6 @@ const useScaleThreshold = ({
|
|
|
50
49
|
|
|
51
50
|
const { lineUpper, lineLower, lineOrigin } = linesThreshold;
|
|
52
51
|
|
|
53
|
-
const [, secondUnit, thirdUnit] = getUnits(lines);
|
|
54
|
-
|
|
55
52
|
const {
|
|
56
53
|
metric_id: metricY1,
|
|
57
54
|
unit: unitY1,
|
|
@@ -73,30 +70,21 @@ const useScaleThreshold = ({
|
|
|
73
70
|
} = lineOrigin;
|
|
74
71
|
|
|
75
72
|
const y1Scale = getYScale({
|
|
76
|
-
hasMoreThanTwoUnits: !isNil(thirdUnit),
|
|
77
73
|
invert: invertY1,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
secondUnit,
|
|
81
|
-
unit: unitY1
|
|
74
|
+
unit: unitY1,
|
|
75
|
+
yScalesPerUnit
|
|
82
76
|
});
|
|
83
77
|
|
|
84
78
|
const y0Scale = getYScale({
|
|
85
|
-
hasMoreThanTwoUnits: !isNil(thirdUnit),
|
|
86
79
|
invert: invertY0,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
secondUnit,
|
|
90
|
-
unit: unitY0
|
|
80
|
+
unit: unitY0,
|
|
81
|
+
yScalesPerUnit
|
|
91
82
|
});
|
|
92
83
|
|
|
93
84
|
const yScale = getYScale({
|
|
94
|
-
hasMoreThanTwoUnits: !isNil(thirdUnit),
|
|
95
85
|
invert: invertYOrigin,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
secondUnit,
|
|
99
|
-
unit: unitYOrigin
|
|
86
|
+
unit: unitYOrigin,
|
|
87
|
+
yScalesPerUnit
|
|
100
88
|
});
|
|
101
89
|
|
|
102
90
|
const getX = (timeValue: TimeValue): number => {
|