@centreon/ui 23.10.17 → 23.10.18-MON-17793-create-graph-component-centreon-ui.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/Graph/Axes/UnitLabel.tsx +20 -0
- package/src/Graph/Axes/index.tsx +99 -0
- package/src/Graph/Axes/models.ts +26 -0
- package/src/Graph/Axes/useAxisY.ts +100 -0
- package/src/Graph/Graph.tsx +231 -0
- package/src/Graph/Grids/index.tsx +20 -0
- package/src/Graph/Header/index.tsx +34 -0
- package/src/Graph/InteractionWithGraph/AnchorPoint/RegularAnchorPoint.tsx +88 -0
- package/src/Graph/InteractionWithGraph/AnchorPoint/StackedAnchorPoint.tsx +97 -0
- package/src/Graph/InteractionWithGraph/AnchorPoint/index.tsx +56 -0
- package/src/Graph/InteractionWithGraph/AnchorPoint/models.ts +25 -0
- package/src/Graph/InteractionWithGraph/AnchorPoint/useAnchorPoint.ts +109 -0
- package/src/Graph/InteractionWithGraph/Bar.tsx +21 -0
- package/src/Graph/InteractionWithGraph/ZoomPreview/index.tsx +38 -0
- package/src/Graph/InteractionWithGraph/ZoomPreview/models.ts +17 -0
- package/src/Graph/InteractionWithGraph/ZoomPreview/useZoomPreview.ts +101 -0
- package/src/Graph/InteractionWithGraph/ZoomPreview/zoomPreviewAtoms.ts +5 -0
- package/src/Graph/InteractionWithGraph/index.tsx +93 -0
- package/src/Graph/InteractionWithGraph/interactionWithGraphAtoms.ts +7 -0
- package/src/Graph/InteractionWithGraph/mouseTimeValueAtoms.ts +49 -0
- package/src/Graph/Lines/RegularLines/index.tsx +99 -0
- package/src/Graph/Lines/RegularLines/useRegularLines.ts +15 -0
- package/src/Graph/Lines/StackedLines/index.tsx +74 -0
- package/src/Graph/Lines/StackedLines/useStackedLines.ts +39 -0
- package/src/Graph/Lines/index.tsx +153 -0
- package/src/Graph/Lines/models.ts +32 -0
- package/src/Graph/LoadingProgress.tsx +46 -0
- package/src/Graph/common/index.ts +33 -0
- package/src/Graph/data.json +1338 -0
- package/src/Graph/helpers/doc.ts +323 -0
- package/src/Graph/helpers/index.ts +15 -0
- package/src/Graph/index.stories.tsx +30 -0
- package/src/Graph/index.tsx +66 -0
- package/src/Graph/models.ts +68 -0
- package/src/Graph/timeSeries/index.test.ts +484 -0
- package/src/Graph/timeSeries/index.ts +512 -0
- package/src/Graph/timeSeries/models.ts +119 -0
- package/src/Graph/useGraphData.ts +117 -0
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +57 -0
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +78 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/ErrorText.tsx +14 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +169 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/index.tsx +76 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +61 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +91 -0
- package/src/TimePeriods/CustomTimePeriod/index.tsx +63 -0
- package/src/TimePeriods/DateTimePickerInput.tsx +99 -0
- package/src/TimePeriods/SelectedTimePeriod.tsx +99 -0
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +497 -0
- package/src/TimePeriods/helpers/index.ts +25 -0
- package/src/TimePeriods/index.stories.tsx +74 -0
- package/src/TimePeriods/index.tsx +77 -0
- package/src/TimePeriods/models.ts +103 -0
- package/src/TimePeriods/timePeriods.styles.ts +20 -0
- package/src/TimePeriods/timePeriodsAtoms.ts +113 -0
- package/src/TimePeriods/useDateTimePickerAdapter.ts +329 -0
- package/src/TimePeriods/useSortTimePeriods.ts +24 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { memo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Curve, Shape } from '@visx/visx';
|
|
4
|
+
import { ScaleLinear, ScaleTime } from 'd3-scale';
|
|
5
|
+
import { equals, isNil, prop } from 'ramda';
|
|
6
|
+
|
|
7
|
+
import { getTime } from '../../timeSeries';
|
|
8
|
+
import { TimeValue } from '../../timeSeries/models';
|
|
9
|
+
import { getFillColor } from '../../common';
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
areaColor: string;
|
|
13
|
+
filled: boolean;
|
|
14
|
+
graphHeight: number;
|
|
15
|
+
highlight?: boolean;
|
|
16
|
+
lineColor: string;
|
|
17
|
+
metric: string;
|
|
18
|
+
shapeAreaClosed?: Record<string, unknown>;
|
|
19
|
+
shapeLinePath?: Record<string, unknown>;
|
|
20
|
+
timeSeries: Array<TimeValue>;
|
|
21
|
+
transparency: number;
|
|
22
|
+
unit: string;
|
|
23
|
+
xScale: ScaleTime<number, number>;
|
|
24
|
+
yScale: ScaleLinear<number, number>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const RegularLine = ({
|
|
28
|
+
filled,
|
|
29
|
+
timeSeries,
|
|
30
|
+
highlight,
|
|
31
|
+
metric,
|
|
32
|
+
lineColor,
|
|
33
|
+
unit,
|
|
34
|
+
yScale,
|
|
35
|
+
xScale,
|
|
36
|
+
areaColor,
|
|
37
|
+
transparency,
|
|
38
|
+
graphHeight
|
|
39
|
+
}: Props): JSX.Element => {
|
|
40
|
+
const isHighlighted = highlight ? 2 : 0.8;
|
|
41
|
+
|
|
42
|
+
const props = {
|
|
43
|
+
curve: Curve.curveLinear,
|
|
44
|
+
data: timeSeries,
|
|
45
|
+
defined: (value): boolean => !isNil(value[metric]),
|
|
46
|
+
opacity: highlight === false ? 0.3 : 1,
|
|
47
|
+
stroke: lineColor,
|
|
48
|
+
strokeWidth: isHighlighted,
|
|
49
|
+
unit,
|
|
50
|
+
x: (timeValue): number => xScale(getTime(timeValue)) as number,
|
|
51
|
+
y: (timeValue): number => yScale(prop(metric, timeValue)) ?? null
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (filled) {
|
|
55
|
+
return (
|
|
56
|
+
<Shape.AreaClosed<TimeValue>
|
|
57
|
+
fill={getFillColor({ areaColor, transparency })}
|
|
58
|
+
fillRule="nonzero"
|
|
59
|
+
key={metric}
|
|
60
|
+
y0={Math.min(yScale(0), graphHeight)}
|
|
61
|
+
yScale={yScale}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return <Shape.LinePath<TimeValue> {...props} />;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default memo(RegularLine, (prevProps, nextProps) => {
|
|
71
|
+
const {
|
|
72
|
+
timeSeries: prevTimeSeries,
|
|
73
|
+
graphHeight: prevGraphHeight,
|
|
74
|
+
highlight: prevHighlight,
|
|
75
|
+
xScale: prevXScale,
|
|
76
|
+
shapeLinePath: prevShapeLinePath,
|
|
77
|
+
shapeAreaClosed: prevShapeAreaClosed
|
|
78
|
+
} = prevProps;
|
|
79
|
+
const {
|
|
80
|
+
timeSeries: nextTimeSeries,
|
|
81
|
+
graphHeight: nextGraphHeight,
|
|
82
|
+
highlight: nextHighlight,
|
|
83
|
+
xScale: nextXScale,
|
|
84
|
+
shapeLinePath: nextShapeLinePath,
|
|
85
|
+
shapeAreaClosed: nextShapeAreaClosed
|
|
86
|
+
} = nextProps;
|
|
87
|
+
|
|
88
|
+
const prevXScaleRange = prevXScale.range();
|
|
89
|
+
const nextXScaleRange = nextXScale.range();
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
equals(prevTimeSeries, nextTimeSeries) &&
|
|
93
|
+
equals(prevGraphHeight, nextGraphHeight) &&
|
|
94
|
+
equals(prevHighlight, nextHighlight) &&
|
|
95
|
+
equals(prevXScaleRange, nextXScaleRange) &&
|
|
96
|
+
equals(prevShapeAreaClosed, nextShapeAreaClosed) &&
|
|
97
|
+
equals(prevShapeLinePath, nextShapeLinePath)
|
|
98
|
+
);
|
|
99
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { difference } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import { Line } from '../../timeSeries/models';
|
|
4
|
+
import { getSortedStackedLines } from '../../timeSeries';
|
|
5
|
+
|
|
6
|
+
interface RegularLines {
|
|
7
|
+
regularLines: Array<Line>;
|
|
8
|
+
}
|
|
9
|
+
const useRegularLines = ({ lines }): RegularLines => {
|
|
10
|
+
const stackedLines = getSortedStackedLines(lines);
|
|
11
|
+
|
|
12
|
+
return { regularLines: difference(lines, stackedLines) };
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default useRegularLines;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { map, nth, pipe, path, all, not, isNil, prop } from 'ramda';
|
|
4
|
+
import { Shape, Curve } from '@visx/visx';
|
|
5
|
+
import { ScaleLinear, ScaleTime } from 'd3-scale';
|
|
6
|
+
|
|
7
|
+
import { Line, TimeValue } from '../../timeSeries/models';
|
|
8
|
+
import { getTime } from '../../timeSeries';
|
|
9
|
+
import { getFillColor } from '../../common';
|
|
10
|
+
import { StackedAnchorPoint } from '../../InteractionWithGraph/AnchorPoint/models';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
lines: Array<Line>;
|
|
14
|
+
renderStackedAnchorPoint: (args: StackedAnchorPoint) => ReactNode;
|
|
15
|
+
timeSeries: Array<TimeValue>;
|
|
16
|
+
xScale: ScaleTime<number, number>;
|
|
17
|
+
yScale: ScaleLinear<number, number>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const StackLines = ({
|
|
21
|
+
timeSeries,
|
|
22
|
+
lines,
|
|
23
|
+
yScale,
|
|
24
|
+
xScale,
|
|
25
|
+
renderStackedAnchorPoint
|
|
26
|
+
}: Props): JSX.Element => {
|
|
27
|
+
return (
|
|
28
|
+
<Shape.AreaStack
|
|
29
|
+
curve={Curve.curveLinear}
|
|
30
|
+
data={timeSeries}
|
|
31
|
+
defined={(d): boolean => {
|
|
32
|
+
return pipe(
|
|
33
|
+
map(prop('metric')) as (lines) => Array<string>,
|
|
34
|
+
all((metric) => pipe(path(['data', metric]), isNil, not)(d))
|
|
35
|
+
)(lines);
|
|
36
|
+
}}
|
|
37
|
+
keys={map(prop('metric'), lines)}
|
|
38
|
+
x={(d): number => xScale(getTime(d.data)) ?? 0}
|
|
39
|
+
y0={(d): number => yScale(d[0]) ?? 0}
|
|
40
|
+
y1={(d): number => yScale(d[1]) ?? 0}
|
|
41
|
+
>
|
|
42
|
+
{({ stacks, path: linePath }): Array<JSX.Element> => {
|
|
43
|
+
return stacks.map((stack, index) => {
|
|
44
|
+
const { areaColor, transparency, lineColor, highlight } = nth(
|
|
45
|
+
index,
|
|
46
|
+
lines
|
|
47
|
+
) as Line;
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<g key={`stack-${prop('key', stack)}`}>
|
|
51
|
+
{renderStackedAnchorPoint?.({
|
|
52
|
+
areaColor,
|
|
53
|
+
lineColor,
|
|
54
|
+
stack,
|
|
55
|
+
transparency,
|
|
56
|
+
xScale,
|
|
57
|
+
yScale
|
|
58
|
+
})}
|
|
59
|
+
<path
|
|
60
|
+
d={linePath(stack) || ''}
|
|
61
|
+
fill={getFillColor({ areaColor, transparency })}
|
|
62
|
+
opacity={highlight === false ? 0.3 : 1}
|
|
63
|
+
stroke={lineColor}
|
|
64
|
+
strokeWidth={highlight ? 2 : 1}
|
|
65
|
+
/>
|
|
66
|
+
</g>
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
}}
|
|
70
|
+
</Shape.AreaStack>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default StackLines;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getInvertedStackedLines,
|
|
3
|
+
getNotInvertedStackedLines,
|
|
4
|
+
getTimeSeriesForLines
|
|
5
|
+
} from '../../timeSeries';
|
|
6
|
+
import { LinesData } from '../models';
|
|
7
|
+
|
|
8
|
+
interface StackedLines {
|
|
9
|
+
invertedStackedLinesData: LinesData;
|
|
10
|
+
stackedLinesData: LinesData;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const useStackedLines = ({ lines, timeSeries }): StackedLines => {
|
|
14
|
+
const regularStackedLines = getNotInvertedStackedLines(lines);
|
|
15
|
+
|
|
16
|
+
const regularStackedTimeSeries = getTimeSeriesForLines({
|
|
17
|
+
lines: regularStackedLines,
|
|
18
|
+
timeSeries
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const invertedStackedLines = getInvertedStackedLines(lines);
|
|
22
|
+
const invertedStackedTimeSeries = getTimeSeriesForLines({
|
|
23
|
+
lines: invertedStackedLines,
|
|
24
|
+
timeSeries
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
invertedStackedLinesData: {
|
|
29
|
+
lines: invertedStackedLines,
|
|
30
|
+
timeSeries: invertedStackedTimeSeries
|
|
31
|
+
},
|
|
32
|
+
stackedLinesData: {
|
|
33
|
+
lines: regularStackedLines,
|
|
34
|
+
timeSeries: regularStackedTimeSeries
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default useStackedLines;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { isEmpty, isNil } from 'ramda';
|
|
4
|
+
|
|
5
|
+
import { getStackedYScale, getUnits, getYScale } from '../timeSeries';
|
|
6
|
+
import { Line } from '../timeSeries/models';
|
|
7
|
+
import {
|
|
8
|
+
RegularLinesAnchorPoint,
|
|
9
|
+
StackedAnchorPoint
|
|
10
|
+
} from '../InteractionWithGraph/AnchorPoint/models';
|
|
11
|
+
|
|
12
|
+
import RegularLine from './RegularLines';
|
|
13
|
+
import StackedLines from './StackedLines';
|
|
14
|
+
import { Shape } from './models';
|
|
15
|
+
|
|
16
|
+
interface AnchorPoint {
|
|
17
|
+
renderRegularLinesAnchorPoint: (args: RegularLinesAnchorPoint) => ReactNode;
|
|
18
|
+
renderStackedAnchorPoint: (args: StackedAnchorPoint) => ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
anchorPoint: AnchorPoint;
|
|
23
|
+
height: number;
|
|
24
|
+
shape: Shape;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const Lines = ({ height, shape, anchorPoint }: Props): JSX.Element => {
|
|
28
|
+
const { areaRegularLines, areaStackedLines } = shape;
|
|
29
|
+
|
|
30
|
+
const { renderRegularLinesAnchorPoint, renderStackedAnchorPoint } =
|
|
31
|
+
anchorPoint;
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
lines: regularLines,
|
|
35
|
+
timeSeries: regularLinesTimeSeries,
|
|
36
|
+
display: displayAreaRegular
|
|
37
|
+
} = areaRegularLines;
|
|
38
|
+
|
|
39
|
+
const { stackedLinesData, invertedStackedLinesData } = areaStackedLines;
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
lines: regularStackedLines,
|
|
43
|
+
timeSeries: regularStackedLinesTimeSeries
|
|
44
|
+
} = stackedLinesData;
|
|
45
|
+
|
|
46
|
+
const {
|
|
47
|
+
lines: invertedStackedLines,
|
|
48
|
+
timeSeries: invertedStackedLinesTimeSeries
|
|
49
|
+
} = invertedStackedLinesData;
|
|
50
|
+
|
|
51
|
+
const displayArea = (data: unknown): boolean =>
|
|
52
|
+
!isEmpty(data) && !isNil(data);
|
|
53
|
+
|
|
54
|
+
const displayAreaStackedLines =
|
|
55
|
+
areaStackedLines.display && displayArea(regularStackedLines);
|
|
56
|
+
|
|
57
|
+
const displayAreaInvertedStackedLines =
|
|
58
|
+
areaStackedLines.display && displayArea(invertedStackedLines);
|
|
59
|
+
|
|
60
|
+
const displayAreaRegularLines =
|
|
61
|
+
displayAreaRegular && displayArea(regularLines);
|
|
62
|
+
|
|
63
|
+
const stackedYScale = getStackedYScale({
|
|
64
|
+
leftScale: areaStackedLines?.leftScale,
|
|
65
|
+
rightScale: areaStackedLines?.rightScale
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const leftScaleRegularLines = areaRegularLines?.leftScale;
|
|
69
|
+
const rightScaleRegularLines = areaRegularLines?.rightScale;
|
|
70
|
+
const xScaleRegularLines = areaRegularLines?.xScale;
|
|
71
|
+
|
|
72
|
+
const commonStackedLinesProps = {
|
|
73
|
+
xScale: areaStackedLines?.xScale,
|
|
74
|
+
yScale: stackedYScale
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<g>
|
|
79
|
+
{displayAreaStackedLines && (
|
|
80
|
+
<StackedLines
|
|
81
|
+
lines={regularStackedLines}
|
|
82
|
+
renderStackedAnchorPoint={renderStackedAnchorPoint}
|
|
83
|
+
timeSeries={regularStackedLinesTimeSeries}
|
|
84
|
+
{...commonStackedLinesProps}
|
|
85
|
+
/>
|
|
86
|
+
)}
|
|
87
|
+
{displayAreaInvertedStackedLines && (
|
|
88
|
+
<StackedLines
|
|
89
|
+
lines={invertedStackedLines}
|
|
90
|
+
renderStackedAnchorPoint={renderStackedAnchorPoint}
|
|
91
|
+
timeSeries={invertedStackedLinesTimeSeries}
|
|
92
|
+
{...commonStackedLinesProps}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
|
|
96
|
+
{displayAreaRegularLines
|
|
97
|
+
? regularLines.map(
|
|
98
|
+
({
|
|
99
|
+
metric,
|
|
100
|
+
areaColor,
|
|
101
|
+
transparency,
|
|
102
|
+
lineColor,
|
|
103
|
+
filled,
|
|
104
|
+
unit,
|
|
105
|
+
highlight,
|
|
106
|
+
invert
|
|
107
|
+
}) => {
|
|
108
|
+
const [, secondUnit, thirdUnit] = getUnits(
|
|
109
|
+
regularLines as Array<Line>
|
|
110
|
+
);
|
|
111
|
+
const yScale = getYScale({
|
|
112
|
+
hasMoreThanTwoUnits: !isNil(thirdUnit),
|
|
113
|
+
invert,
|
|
114
|
+
leftScale: leftScaleRegularLines,
|
|
115
|
+
rightScale: rightScaleRegularLines,
|
|
116
|
+
secondUnit,
|
|
117
|
+
unit
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<g key={metric}>
|
|
122
|
+
{renderRegularLinesAnchorPoint?.({
|
|
123
|
+
areaColor,
|
|
124
|
+
lineColor,
|
|
125
|
+
metric,
|
|
126
|
+
timeSeries: regularLinesTimeSeries,
|
|
127
|
+
transparency,
|
|
128
|
+
xScale: xScaleRegularLines,
|
|
129
|
+
yScale
|
|
130
|
+
})}
|
|
131
|
+
<RegularLine
|
|
132
|
+
areaColor={areaColor}
|
|
133
|
+
filled={filled}
|
|
134
|
+
graphHeight={height}
|
|
135
|
+
highlight={highlight}
|
|
136
|
+
lineColor={lineColor}
|
|
137
|
+
metric={metric}
|
|
138
|
+
timeSeries={regularLinesTimeSeries}
|
|
139
|
+
transparency={transparency}
|
|
140
|
+
unit={unit}
|
|
141
|
+
xScale={xScaleRegularLines}
|
|
142
|
+
yScale={yScale}
|
|
143
|
+
/>
|
|
144
|
+
</g>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
: null}
|
|
149
|
+
</g>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export default Lines;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ScaleLinear } from 'd3-scale';
|
|
2
|
+
|
|
3
|
+
import { Line, TimeValue } from '../timeSeries/models';
|
|
4
|
+
|
|
5
|
+
export interface ShapeGraphData {
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
display: boolean;
|
|
8
|
+
leftScale?: ScaleLinear<number, number>;
|
|
9
|
+
rightScale?: ScaleLinear<number, number>;
|
|
10
|
+
xScale?: ScaleLinear<number, number>;
|
|
11
|
+
yScale?: ScaleLinear<number, number>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface LinesData {
|
|
15
|
+
lines: Array<Line>;
|
|
16
|
+
timeSeries: Array<TimeValue>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AreaStackedLines extends ShapeGraphData {
|
|
20
|
+
invertedStackedLinesData: LinesData;
|
|
21
|
+
stackedLinesData: LinesData;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface AreaRegularLines extends ShapeGraphData {
|
|
25
|
+
lines: Array<Line>;
|
|
26
|
+
timeSeries: Array<TimeValue>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Shape {
|
|
30
|
+
areaRegularLines: AreaRegularLines;
|
|
31
|
+
areaStackedLines: AreaStackedLines;
|
|
32
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
import { CircularProgress, alpha } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
interface StyleProps {
|
|
6
|
+
height: number;
|
|
7
|
+
width: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles<StyleProps>()((theme, { height, width }) => ({
|
|
11
|
+
graphLoader: {
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
backgroundColor: alpha(theme.palette.common.white, 0.5),
|
|
14
|
+
display: 'flex',
|
|
15
|
+
height,
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
width
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
interface LoadingProgress {
|
|
23
|
+
display: boolean;
|
|
24
|
+
height: number;
|
|
25
|
+
width: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const LoadingProgress = ({
|
|
29
|
+
display,
|
|
30
|
+
height,
|
|
31
|
+
width
|
|
32
|
+
}: LoadingProgress): JSX.Element | null => {
|
|
33
|
+
const { classes } = useStyles({ height, width });
|
|
34
|
+
|
|
35
|
+
if (!display) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className={classes.graphLoader}>
|
|
41
|
+
<CircularProgress />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default LoadingProgress;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { alpha } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
const commonTickLabelProps = {
|
|
4
|
+
fontFamily: 'Roboto, sans-serif',
|
|
5
|
+
fontSize: 10,
|
|
6
|
+
textAnchor: 'middle'
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const margin = { bottom: 30, left: 45, right: 45, top: 30 };
|
|
10
|
+
|
|
11
|
+
interface FillColor {
|
|
12
|
+
areaColor: string;
|
|
13
|
+
transparency: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const getFillColor = ({
|
|
17
|
+
transparency,
|
|
18
|
+
areaColor
|
|
19
|
+
}: FillColor): string | undefined =>
|
|
20
|
+
transparency ? alpha(areaColor, 1 - transparency * 0.01) : undefined;
|
|
21
|
+
|
|
22
|
+
const dateFormat = 'L';
|
|
23
|
+
const timeFormat = 'LT';
|
|
24
|
+
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
commonTickLabelProps,
|
|
28
|
+
margin,
|
|
29
|
+
getFillColor,
|
|
30
|
+
dateFormat,
|
|
31
|
+
timeFormat,
|
|
32
|
+
dateTimeFormat
|
|
33
|
+
};
|