@centreon/ui 24.9.0 → 24.9.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/Graph/Chart/BasicComponents/Lines/Threshold/index.tsx +10 -10
- package/src/Graph/Chart/BasicComponents/Lines/Threshold/models.ts +4 -4
- package/src/Graph/Chart/BasicComponents/Lines/index.tsx +4 -4
- package/src/Graph/Chart/Chart.styles.ts +9 -1
- package/src/Graph/Chart/Chart.tsx +19 -7
- package/src/Graph/Chart/InteractiveComponents/index.tsx +7 -8
- package/src/Graph/Chart/index.tsx +17 -7
- package/src/Graph/Chart/models.ts +16 -10
- package/src/Graph/Chart/useChartData.ts +2 -2
- package/src/Graph/PieChart/PieChart.styles.ts +3 -3
- package/src/Graph/PieChart/ResponsivePie.tsx +28 -41
- package/src/Graph/PieChart/models.ts +0 -2
- package/src/TimePeriods/TimePeriods.tsx +2 -2
- package/src/TimePeriods/index.tsx +3 -2
- package/src/TimePeriods/models.ts +2 -2
- package/src/index.ts +0 -1
- package/src/utils/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { equals, isNil } from 'ramda';
|
|
2
2
|
|
|
3
|
-
import { TimeValue } from '../../../../common/timeSeries/models';
|
|
3
|
+
import type { TimeValue } from '../../../../common/timeSeries/models';
|
|
4
4
|
import { displayArea } from '../../../helpers/index';
|
|
5
5
|
import {
|
|
6
|
-
PatternThreshold,
|
|
6
|
+
type PatternThreshold,
|
|
7
7
|
ThresholdType,
|
|
8
|
-
VariationThreshold
|
|
8
|
+
type VariationThreshold
|
|
9
9
|
} from '../../../models';
|
|
10
10
|
|
|
11
11
|
import BasicThreshold from './BasicThreshold';
|
|
12
12
|
import Circle from './Circle';
|
|
13
13
|
import ThresholdWithPatternLines from './ThresholdWithPatternLines';
|
|
14
14
|
import ThresholdWithVariation from './ThresholdWithVariation';
|
|
15
|
-
import { WrapperThresholdLinesModel } from './models';
|
|
15
|
+
import type { WrapperThresholdLinesModel } from './models';
|
|
16
16
|
import useScaleThreshold from './useScaleThreshold';
|
|
17
17
|
|
|
18
18
|
interface Props extends WrapperThresholdLinesModel {
|
|
@@ -52,14 +52,14 @@ const WrapperThresholdLines = ({
|
|
|
52
52
|
timeSeries
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
const thresholdLines = areaThresholdLines?.map((item
|
|
55
|
+
const thresholdLines = areaThresholdLines?.map((item) => {
|
|
56
56
|
const { type, id } = item;
|
|
57
57
|
|
|
58
58
|
if (equals(type, ThresholdType.basic)) {
|
|
59
59
|
return [
|
|
60
60
|
{
|
|
61
61
|
Component: BasicThreshold,
|
|
62
|
-
key:
|
|
62
|
+
key: id,
|
|
63
63
|
props: { ...commonProps, getY0, getY1, id }
|
|
64
64
|
}
|
|
65
65
|
];
|
|
@@ -73,7 +73,7 @@ const WrapperThresholdLines = ({
|
|
|
73
73
|
return [
|
|
74
74
|
{
|
|
75
75
|
Component: ThresholdWithVariation,
|
|
76
|
-
key:
|
|
76
|
+
key: dataVariation.id,
|
|
77
77
|
props: {
|
|
78
78
|
factors: dataVariation.factors,
|
|
79
79
|
...commonProps,
|
|
@@ -101,13 +101,13 @@ const WrapperThresholdLines = ({
|
|
|
101
101
|
|
|
102
102
|
const { data: pattern } = dataPattern;
|
|
103
103
|
|
|
104
|
-
return pattern.map((element,
|
|
104
|
+
return pattern.map((element, index) => ({
|
|
105
105
|
Component: ThresholdWithPatternLines,
|
|
106
|
-
key:
|
|
106
|
+
key: index,
|
|
107
107
|
props: {
|
|
108
108
|
data: element,
|
|
109
109
|
graphHeight,
|
|
110
|
-
key:
|
|
110
|
+
key: index,
|
|
111
111
|
orientation: dataPattern?.orientation,
|
|
112
112
|
xScale,
|
|
113
113
|
yScalesPerUnit
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ScaleLinear } from 'd3-scale';
|
|
1
|
+
import type { ScaleLinear } from 'd3-scale';
|
|
2
2
|
import { equals, reject } from 'ramda';
|
|
3
3
|
|
|
4
|
-
import { Line, TimeValue } from '../../../../common/timeSeries/models';
|
|
5
|
-
import { GlobalAreaLines, ThresholdType } from '../../../models';
|
|
4
|
+
import type { Line, TimeValue } from '../../../../common/timeSeries/models';
|
|
5
|
+
import { type GlobalAreaLines, ThresholdType } from '../../../models';
|
|
6
6
|
|
|
7
7
|
export interface Data {
|
|
8
8
|
lineColor: string;
|
|
@@ -95,7 +95,7 @@ export const findLineOfOriginMetricThreshold = (
|
|
|
95
95
|
|
|
96
96
|
const originMetric = metrics.find((element) => element);
|
|
97
97
|
|
|
98
|
-
return reject((line: Line) => !equals(line.
|
|
98
|
+
return reject((line: Line) => !equals(line.metric, originMetric), lines);
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
export const canDisplayThreshold = (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MutableRefObject } from 'react';
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
2
|
|
|
3
|
-
import { ScaleLinear } from 'd3-scale';
|
|
3
|
+
import type { ScaleLinear } from 'd3-scale';
|
|
4
4
|
import { isNil } from 'ramda';
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -8,14 +8,14 @@ import {
|
|
|
8
8
|
getTimeSeriesForLines,
|
|
9
9
|
getYScale
|
|
10
10
|
} from '../../../common/timeSeries';
|
|
11
|
-
import { Line, TimeValue } from '../../../common/timeSeries/models';
|
|
11
|
+
import type { Line, TimeValue } from '../../../common/timeSeries/models';
|
|
12
12
|
import { getPointRadius } from '../../../common/utils';
|
|
13
13
|
import GuidingLines from '../../InteractiveComponents/AnchorPoint/GuidingLines';
|
|
14
14
|
import RegularAnchorPoint, {
|
|
15
15
|
getYAnchorPoint
|
|
16
16
|
} from '../../InteractiveComponents/AnchorPoint/RegularAnchorPoint';
|
|
17
17
|
import { displayArea } from '../../helpers/index';
|
|
18
|
-
import { DisplayAnchor, GlobalAreaLines } from '../../models';
|
|
18
|
+
import type { DisplayAnchor, GlobalAreaLines } from '../../models';
|
|
19
19
|
|
|
20
20
|
import Point from './Point';
|
|
21
21
|
import RegularLine from './RegularLines';
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { makeStyles } from 'tss-react/mui';
|
|
2
2
|
|
|
3
3
|
export const useChartStyles = makeStyles()({
|
|
4
|
-
|
|
4
|
+
baseWrapper: {
|
|
5
|
+
position: 'relative'
|
|
6
|
+
},
|
|
7
|
+
tooltipChildren: { height: '100%', width: '100%' },
|
|
8
|
+
wrapperContainer: {
|
|
9
|
+
height: '100%',
|
|
10
|
+
width: '100%',
|
|
11
|
+
overflow: 'hidden'
|
|
12
|
+
}
|
|
5
13
|
});
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type MutableRefObject,
|
|
3
|
+
useEffect,
|
|
4
|
+
useMemo,
|
|
5
|
+
useRef,
|
|
6
|
+
useState
|
|
7
|
+
} from 'react';
|
|
2
8
|
|
|
3
9
|
import { useAtom } from 'jotai';
|
|
4
10
|
import { equals, flatten, isNil, pluck, reject } from 'ramda';
|
|
@@ -11,14 +17,14 @@ import BaseChart from '../common/BaseChart/BaseChart';
|
|
|
11
17
|
import ChartSvgWrapper from '../common/BaseChart/ChartSvgWrapper';
|
|
12
18
|
import { useComputeBaseChartDimensions } from '../common/BaseChart/useComputeBaseChartDimensions';
|
|
13
19
|
import Thresholds from '../common/Thresholds/Thresholds';
|
|
14
|
-
import { Thresholds as ThresholdsModel } from '../common/models';
|
|
20
|
+
import type { Thresholds as ThresholdsModel } from '../common/models';
|
|
15
21
|
import {
|
|
16
22
|
getUnits,
|
|
17
23
|
getXScale,
|
|
18
24
|
getXScaleBand,
|
|
19
25
|
getYScalePerUnit
|
|
20
26
|
} from '../common/timeSeries';
|
|
21
|
-
import { Line } from '../common/timeSeries/models';
|
|
27
|
+
import type { Line } from '../common/timeSeries/models';
|
|
22
28
|
|
|
23
29
|
import Lines from './BasicComponents/Lines';
|
|
24
30
|
import {
|
|
@@ -34,7 +40,12 @@ import GraphTooltip from './InteractiveComponents/Tooltip';
|
|
|
34
40
|
import useGraphTooltip from './InteractiveComponents/Tooltip/useGraphTooltip';
|
|
35
41
|
import { margin } from './common';
|
|
36
42
|
import { thresholdTooltipAtom } from './graphAtoms';
|
|
37
|
-
import {
|
|
43
|
+
import type {
|
|
44
|
+
Data,
|
|
45
|
+
GlobalAreaLines,
|
|
46
|
+
GraphInterval,
|
|
47
|
+
LineChartProps
|
|
48
|
+
} from './models';
|
|
38
49
|
import { useIntersection } from './useChartIntersection';
|
|
39
50
|
|
|
40
51
|
interface Props extends LineChartProps {
|
|
@@ -95,6 +106,7 @@ const Chart = ({
|
|
|
95
106
|
const [linesGraph, setLinesGraph] = useState<Array<Line>>(
|
|
96
107
|
filterLines(lines, canDisplayThreshold(shapeLines?.areaThresholdLines))
|
|
97
108
|
);
|
|
109
|
+
|
|
98
110
|
const graphSvgRef = useRef<SVGSVGElement | null>(null);
|
|
99
111
|
|
|
100
112
|
const [thresholdTooltip, setThresholdTooltip] = useAtom(thresholdTooltipAtom);
|
|
@@ -190,7 +202,7 @@ const Chart = ({
|
|
|
190
202
|
filterLines(lines, canDisplayThreshold(shapeLines?.areaThresholdLines))
|
|
191
203
|
);
|
|
192
204
|
},
|
|
193
|
-
useDeepCompare([lines])
|
|
205
|
+
useDeepCompare([lines, shapeLines?.areaThresholdLines])
|
|
194
206
|
);
|
|
195
207
|
|
|
196
208
|
const graphTooltipData = useGraphTooltip({
|
|
@@ -219,7 +231,7 @@ const Chart = ({
|
|
|
219
231
|
|
|
220
232
|
return (
|
|
221
233
|
<ClickAwayListener onClickAway={graphTooltipData?.hideTooltip}>
|
|
222
|
-
|
|
234
|
+
<div className={classes.baseWrapper}>
|
|
223
235
|
<BaseChart
|
|
224
236
|
base={baseAxis}
|
|
225
237
|
graphWidth={graphWidth}
|
|
@@ -329,7 +341,7 @@ const Chart = ({
|
|
|
329
341
|
</GraphValueTooltip>
|
|
330
342
|
</BaseChart>
|
|
331
343
|
{displayTooltip && <GraphTooltip {...tooltip} {...graphTooltipData} />}
|
|
332
|
-
|
|
344
|
+
</div>
|
|
333
345
|
</ClickAwayListener>
|
|
334
346
|
);
|
|
335
347
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MutableRefObject } from 'react';
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Event } from '@visx/visx';
|
|
4
|
-
import { ScaleLinear, ScaleTime } from 'd3-scale';
|
|
4
|
+
import type { ScaleLinear, ScaleTime } from 'd3-scale';
|
|
5
5
|
import { useSetAtom } from 'jotai';
|
|
6
6
|
import {
|
|
7
7
|
all,
|
|
@@ -28,9 +28,9 @@ import {
|
|
|
28
28
|
getTimeValue,
|
|
29
29
|
getYScale
|
|
30
30
|
} from '../../common/timeSeries';
|
|
31
|
-
import { Line, TimeValue } from '../../common/timeSeries/models';
|
|
31
|
+
import type { Line, TimeValue } from '../../common/timeSeries/models';
|
|
32
32
|
import { margin } from '../common';
|
|
33
|
-
import {
|
|
33
|
+
import type {
|
|
34
34
|
AnnotationEvent,
|
|
35
35
|
GraphInterval,
|
|
36
36
|
InteractedZone,
|
|
@@ -38,12 +38,12 @@ import {
|
|
|
38
38
|
} from '../models';
|
|
39
39
|
|
|
40
40
|
import Annotations from './Annotations';
|
|
41
|
-
import { TimelineEvent } from './Annotations/models';
|
|
41
|
+
import type { TimelineEvent } from './Annotations/models';
|
|
42
42
|
import Bar from './Bar';
|
|
43
43
|
import TimeShiftZones from './TimeShiftZones';
|
|
44
44
|
import ZoomPreview from './ZoomPreview';
|
|
45
45
|
import {
|
|
46
|
-
MousePosition,
|
|
46
|
+
type MousePosition,
|
|
47
47
|
changeMousePositionDerivedAtom,
|
|
48
48
|
eventMouseDownAtom,
|
|
49
49
|
eventMouseLeaveAtom,
|
|
@@ -91,7 +91,6 @@ const InteractionWithGraph = ({
|
|
|
91
91
|
const setEventMouseLeave = useSetAtom(eventMouseLeaveAtom);
|
|
92
92
|
const changeMousePosition = useSetAtom(changeMousePositionDerivedAtom);
|
|
93
93
|
const setGraphTooltipData = useSetAtom(graphTooltipDataAtom);
|
|
94
|
-
|
|
95
94
|
const {
|
|
96
95
|
graphHeight,
|
|
97
96
|
graphWidth,
|
|
@@ -246,7 +245,7 @@ const InteractionWithGraph = ({
|
|
|
246
245
|
{displayEventAnnotations && (
|
|
247
246
|
<Annotations
|
|
248
247
|
data={annotationData?.data as Array<TimelineEvent>}
|
|
249
|
-
graphHeight={graphHeight}
|
|
248
|
+
graphHeight={graphHeight - margin.bottom}
|
|
250
249
|
graphSvgRef={graphSvgRef}
|
|
251
250
|
graphWidth={graphWidth}
|
|
252
251
|
xScale={xScale}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MutableRefObject, memo, useRef } from 'react';
|
|
1
|
+
import { type MutableRefObject, memo, useEffect, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import 'dayjs/locale/en';
|
|
@@ -8,15 +8,15 @@ import 'dayjs/locale/pt';
|
|
|
8
8
|
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
9
9
|
import timezonePlugin from 'dayjs/plugin/timezone';
|
|
10
10
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
11
|
-
import { equals } from 'ramda';
|
|
12
11
|
|
|
13
12
|
import { ParentSize } from '../..';
|
|
14
13
|
import Loading from '../../LoadingSkeleton';
|
|
15
|
-
import { LineChartData, Thresholds } from '../common/models';
|
|
14
|
+
import type { LineChartData, Thresholds } from '../common/models';
|
|
16
15
|
|
|
17
16
|
import Chart from './Chart';
|
|
17
|
+
import { useChartStyles } from './Chart.styles';
|
|
18
18
|
import LoadingSkeleton from './LoadingSkeleton';
|
|
19
|
-
import { GlobalAreaLines, LineChartProps } from './models';
|
|
19
|
+
import type { GlobalAreaLines, LineChartProps } from './models';
|
|
20
20
|
import useChartData from './useChartData';
|
|
21
21
|
|
|
22
22
|
dayjs.extend(localizedFormat);
|
|
@@ -32,6 +32,8 @@ interface Props extends Partial<LineChartProps> {
|
|
|
32
32
|
start: string;
|
|
33
33
|
thresholdUnit?: string;
|
|
34
34
|
thresholds?: Thresholds;
|
|
35
|
+
getRef?: (ref: MutableRefObject<HTMLDivElement | null>) => void;
|
|
36
|
+
containerStyle?: string;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
const WrapperChart = ({
|
|
@@ -61,11 +63,19 @@ const WrapperChart = ({
|
|
|
61
63
|
barStyle,
|
|
62
64
|
thresholds,
|
|
63
65
|
thresholdUnit,
|
|
64
|
-
limitLegend
|
|
66
|
+
limitLegend,
|
|
67
|
+
getRef,
|
|
68
|
+
...rest
|
|
65
69
|
}: Props): JSX.Element | null => {
|
|
70
|
+
const { classes, cx } = useChartStyles();
|
|
71
|
+
|
|
66
72
|
const { adjustedData } = useChartData({ data, end, start });
|
|
67
73
|
const lineChartRef = useRef<HTMLDivElement | null>(null);
|
|
68
74
|
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
getRef?.(lineChartRef);
|
|
77
|
+
}, [lineChartRef?.current]);
|
|
78
|
+
|
|
69
79
|
if (loading && !adjustedData) {
|
|
70
80
|
return (
|
|
71
81
|
<LoadingSkeleton
|
|
@@ -82,7 +92,7 @@ const WrapperChart = ({
|
|
|
82
92
|
return (
|
|
83
93
|
<div
|
|
84
94
|
ref={lineChartRef as MutableRefObject<HTMLDivElement>}
|
|
85
|
-
|
|
95
|
+
className={cx(classes.wrapperContainer, rest?.containerStyle)}
|
|
86
96
|
>
|
|
87
97
|
<ParentSize>
|
|
88
98
|
{({
|
|
@@ -118,4 +128,4 @@ const WrapperChart = ({
|
|
|
118
128
|
);
|
|
119
129
|
};
|
|
120
130
|
|
|
121
|
-
export default memo(WrapperChart
|
|
131
|
+
export default memo(WrapperChart);
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import { ScaleLinear } from 'd3-scale';
|
|
3
|
+
import type { ScaleLinear } from 'd3-scale';
|
|
4
4
|
|
|
5
|
-
import { BarStyle } from '../BarChart/models';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import type { BarStyle } from '../BarChart/models';
|
|
6
|
+
import type {
|
|
7
|
+
AxisX,
|
|
8
|
+
Axis as AxisYLeft,
|
|
9
|
+
AxisYRight
|
|
10
|
+
} from '../common/Axes/models';
|
|
11
|
+
import type { LineChartData } from '../common/models';
|
|
12
|
+
import type { Line, TimeValue } from '../common/timeSeries/models';
|
|
9
13
|
|
|
10
|
-
import { FactorsVariation } from './BasicComponents/Lines/Threshold/models';
|
|
11
|
-
import {
|
|
14
|
+
import type { FactorsVariation } from './BasicComponents/Lines/Threshold/models';
|
|
15
|
+
import type {
|
|
12
16
|
AreaRegularLines,
|
|
13
17
|
AreaStackedLines
|
|
14
18
|
} from './BasicComponents/Lines/models';
|
|
15
|
-
import { TimelineEvent } from './InteractiveComponents/Annotations/models';
|
|
19
|
+
import type { TimelineEvent } from './InteractiveComponents/Annotations/models';
|
|
16
20
|
|
|
17
21
|
export interface LineChartEndpoint {
|
|
18
22
|
baseUrl: string;
|
|
@@ -138,16 +142,18 @@ export interface PatternThreshold {
|
|
|
138
142
|
data: Array<LineChartData>;
|
|
139
143
|
orientation?: Array<PatternOrientation>;
|
|
140
144
|
type: ThresholdType.pattern;
|
|
145
|
+
id: string;
|
|
141
146
|
}
|
|
142
147
|
export interface VariationThreshold {
|
|
143
148
|
displayCircles?: boolean;
|
|
144
149
|
factors: FactorsVariation;
|
|
145
150
|
getCountDisplayedCircles?: (value: number) => void;
|
|
146
151
|
type: ThresholdType.variation;
|
|
152
|
+
id: string;
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
export interface BasicThreshold {
|
|
150
|
-
id
|
|
156
|
+
id: string;
|
|
151
157
|
type: ThresholdType.basic;
|
|
152
158
|
}
|
|
153
159
|
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
toLower
|
|
14
14
|
} from 'ramda';
|
|
15
15
|
|
|
16
|
-
import { LineChartData } from '../common/models';
|
|
16
|
+
import type { LineChartData } from '../common/models';
|
|
17
17
|
import { emphasizeCurveColor } from '../common/utils';
|
|
18
18
|
|
|
19
19
|
import { adjustGraphData } from './helpers';
|
|
20
|
-
import { Data } from './models';
|
|
20
|
+
import type { Data } from './models';
|
|
21
21
|
|
|
22
22
|
interface GraphDataResult {
|
|
23
23
|
adjustedData?: Data;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { lt } from 'ramda';
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
|
|
4
|
-
export const usePieStyles = makeStyles<{
|
|
5
|
-
(theme, {
|
|
4
|
+
export const usePieStyles = makeStyles<{ svgSize: number }>()(
|
|
5
|
+
(theme, { svgSize }) => ({
|
|
6
6
|
container: {
|
|
7
7
|
alignItems: 'center',
|
|
8
8
|
display: 'flex',
|
|
@@ -25,7 +25,7 @@ export const usePieStyles = makeStyles<{ reverse: boolean; svgSize: number }>()(
|
|
|
25
25
|
svgWrapper: {
|
|
26
26
|
alignItems: 'center',
|
|
27
27
|
display: 'flex',
|
|
28
|
-
flexDirection:
|
|
28
|
+
flexDirection: 'column',
|
|
29
29
|
gap: theme.spacing(1),
|
|
30
30
|
justifyContent: 'center'
|
|
31
31
|
},
|
|
@@ -42,8 +42,6 @@ const getTooltipPlacement = ({ radianX, radianY }): Placement => {
|
|
|
42
42
|
|
|
43
43
|
const ResponsivePie = ({
|
|
44
44
|
title,
|
|
45
|
-
titlePosition,
|
|
46
|
-
displayTitle = true,
|
|
47
45
|
variant = 'pie',
|
|
48
46
|
width,
|
|
49
47
|
height,
|
|
@@ -92,10 +90,7 @@ const ResponsivePie = ({
|
|
|
92
90
|
const isSmall = lt(width, 130);
|
|
93
91
|
const mustDisplayLegend = isTooSmallForLegend ? false : displayLegend;
|
|
94
92
|
|
|
95
|
-
const { classes } = usePieStyles({
|
|
96
|
-
reverse: equals(titlePosition, 'bottom'),
|
|
97
|
-
svgSize
|
|
98
|
-
});
|
|
93
|
+
const { classes } = usePieStyles({ svgSize });
|
|
99
94
|
|
|
100
95
|
return (
|
|
101
96
|
<div
|
|
@@ -110,16 +105,12 @@ const ResponsivePie = ({
|
|
|
110
105
|
minHeight: equals(variant, 'donut') && isSmall ? 'auto' : height
|
|
111
106
|
}}
|
|
112
107
|
>
|
|
113
|
-
{(equals(variant, 'pie') ||
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{`${displayTotal ? numeral(total).format('0a').toUpperCase() : ''} `}
|
|
120
|
-
{t(title)}
|
|
121
|
-
</div>
|
|
122
|
-
)}
|
|
108
|
+
{(equals(variant, 'pie') || isSmall) && title && (
|
|
109
|
+
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
110
|
+
{`${displayTotal ? numeral(total).format('0a').toUpperCase() : ''} `}
|
|
111
|
+
{t(title)}
|
|
112
|
+
</div>
|
|
113
|
+
)}
|
|
123
114
|
<div
|
|
124
115
|
className={classes.svgContainer}
|
|
125
116
|
data-testid="pieChart"
|
|
@@ -232,31 +223,27 @@ const ResponsivePie = ({
|
|
|
232
223
|
});
|
|
233
224
|
}}
|
|
234
225
|
</Pie>
|
|
235
|
-
{equals(variant, 'donut') &&
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
{t(title)}
|
|
257
|
-
</Text>
|
|
258
|
-
</>
|
|
259
|
-
)}
|
|
226
|
+
{equals(variant, 'donut') && !isSmall && title && (
|
|
227
|
+
<>
|
|
228
|
+
<Text
|
|
229
|
+
className={classes.title}
|
|
230
|
+
dy={lt(svgSize, 150) ? -10 : -15}
|
|
231
|
+
fill={theme.palette.text.primary}
|
|
232
|
+
textAnchor="middle"
|
|
233
|
+
>
|
|
234
|
+
{numeral(total).format('0a').toUpperCase()}
|
|
235
|
+
</Text>
|
|
236
|
+
<Text
|
|
237
|
+
className={classes.title}
|
|
238
|
+
data-testid="Title"
|
|
239
|
+
dy={lt(svgSize, 150) ? 10 : 15}
|
|
240
|
+
fill={theme.palette.text.primary}
|
|
241
|
+
textAnchor="middle"
|
|
242
|
+
>
|
|
243
|
+
{t(title)}
|
|
244
|
+
</Text>
|
|
245
|
+
</>
|
|
246
|
+
)}
|
|
260
247
|
</Group>
|
|
261
248
|
</svg>
|
|
262
249
|
</div>
|
|
@@ -9,7 +9,6 @@ export interface PieProps {
|
|
|
9
9
|
TooltipContent?: (arcData) => JSX.Element | boolean | null;
|
|
10
10
|
data: Array<ArcType>;
|
|
11
11
|
displayLegend?: boolean;
|
|
12
|
-
displayTitle?: boolean;
|
|
13
12
|
displayTotal?: boolean;
|
|
14
13
|
displayValues?: boolean;
|
|
15
14
|
innerRadius?: number;
|
|
@@ -19,7 +18,6 @@ export interface PieProps {
|
|
|
19
18
|
opacity: number;
|
|
20
19
|
padAngle?: number;
|
|
21
20
|
title?: string;
|
|
22
|
-
titlePosition?: 'default' | 'bottom';
|
|
23
21
|
tooltipProps?: object;
|
|
24
22
|
unit?: 'percentage' | 'number';
|
|
25
23
|
variant?: 'pie' | 'donut';
|
|
@@ -9,12 +9,12 @@ import timezonePlugin from 'dayjs/plugin/timezone';
|
|
|
9
9
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
10
10
|
import { lt } from 'ramda';
|
|
11
11
|
|
|
12
|
-
import { Paper, Theme, useMediaQuery } from '@mui/material';
|
|
12
|
+
import { Paper, type Theme, useMediaQuery } from '@mui/material';
|
|
13
13
|
|
|
14
14
|
import CustomTimePeriod from './CustomTimePeriod';
|
|
15
15
|
import SelectedTimePeriod from './SelectedTimePeriod';
|
|
16
16
|
import { useStyles } from './TimePeriods.styles';
|
|
17
|
-
import { WrapperTimePeriodProps } from './models';
|
|
17
|
+
import type { WrapperTimePeriodProps } from './models';
|
|
18
18
|
import useTimePeriod from './useTimePeriod';
|
|
19
19
|
|
|
20
20
|
dayjs.extend(isSameOrAfter);
|
|
@@ -11,8 +11,9 @@ import utcPlugin from 'dayjs/plugin/utc';
|
|
|
11
11
|
import { ParentSize } from '..';
|
|
12
12
|
import LoadingSkeleton from '../LoadingSkeleton';
|
|
13
13
|
|
|
14
|
+
import { memo } from 'react';
|
|
14
15
|
import TimePeriods from './TimePeriods';
|
|
15
|
-
import { WrapperTimePeriodProps } from './models';
|
|
16
|
+
import type { WrapperTimePeriodProps } from './models';
|
|
16
17
|
|
|
17
18
|
dayjs.extend(isSameOrAfter);
|
|
18
19
|
dayjs.extend(utcPlugin);
|
|
@@ -34,4 +35,4 @@ const WrapperTimePeriods = ({
|
|
|
34
35
|
</ParentSize>
|
|
35
36
|
);
|
|
36
37
|
|
|
37
|
-
export default WrapperTimePeriods;
|
|
38
|
+
export default memo(WrapperTimePeriods);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
|
|
@@ -98,7 +98,7 @@ export interface EndStartInterval {
|
|
|
98
98
|
start: string;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
interface Parameters extends EndStartInterval {
|
|
101
|
+
export interface Parameters extends EndStartInterval {
|
|
102
102
|
timelineEventsLimit: number;
|
|
103
103
|
}
|
|
104
104
|
|
package/src/index.ts
CHANGED
|
@@ -158,7 +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
|
-
|
|
162
161
|
export { default as TimePeriods } from './TimePeriods';
|
|
163
162
|
export { default as SimpleCustomTimePeriod } from './TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod';
|
|
164
163
|
export { default as DateTimePickerInput } from './TimePeriods/DateTimePickerInput';
|
package/src/utils/index.ts
CHANGED
|
@@ -26,4 +26,5 @@ export * from './resourcesStatusURL';
|
|
|
26
26
|
export * from '../Graph/Chart/helpers';
|
|
27
27
|
export * from '../Graph/Chart/InteractiveComponents/TimeShiftZones/useTimeShiftZones';
|
|
28
28
|
export * from '../TimePeriods/helpers';
|
|
29
|
+
export { lastDayPeriod, type Parameters } from '../TimePeriods/models';
|
|
29
30
|
export * from './useLocaleTimezoneDate/useLocaleTimezoneDate';
|