@centreon/ui 23.10.18-MON-17793-create-graph-component-centreon-ui.9 → 23.10.18-MON-17793-create-graph-component-centreon-ui.11
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/Graph.tsx +16 -3
- package/src/Graph/Legend/index.tsx +6 -1
- package/src/Graph/index.tsx +5 -2
- package/src/Graph/models.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.18-MON-17793-create-graph-component-centreon-ui.
|
|
3
|
+
"version": "23.10.18-MON-17793-create-graph-component-centreon-ui.11",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
package/src/Graph/Graph.tsx
CHANGED
|
@@ -26,12 +26,19 @@ import useAnchorPoint from './IntercatifsComponents/AnchorPoint/useAnchorPoint';
|
|
|
26
26
|
import GraphTooltip from './IntercatifsComponents/Tooltip';
|
|
27
27
|
import useGraphTooltip from './IntercatifsComponents/Tooltip/useGraphTooltip';
|
|
28
28
|
import Legend from './Legend';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
Data,
|
|
31
|
+
GlobalAreaLines,
|
|
32
|
+
GraphInterval,
|
|
33
|
+
GraphProps,
|
|
34
|
+
LegendModel
|
|
35
|
+
} from './models';
|
|
30
36
|
import { getLeftScale, getRightScale, getXScale } from './timeSeries';
|
|
31
37
|
|
|
32
38
|
interface Props extends GraphProps {
|
|
33
39
|
graphData: Data;
|
|
34
40
|
graphInterval: GraphInterval;
|
|
41
|
+
legend?: LegendModel;
|
|
35
42
|
loading: boolean;
|
|
36
43
|
shapeLines?: GlobalAreaLines;
|
|
37
44
|
}
|
|
@@ -48,7 +55,8 @@ const Graph = ({
|
|
|
48
55
|
graphInterval,
|
|
49
56
|
timeShiftZones,
|
|
50
57
|
annotationEvent,
|
|
51
|
-
tooltip
|
|
58
|
+
tooltip,
|
|
59
|
+
legend
|
|
52
60
|
}: Props): JSX.Element => {
|
|
53
61
|
const graphSvgRef = useRef<SVGSVGElement | null>(null);
|
|
54
62
|
|
|
@@ -261,7 +269,12 @@ const Graph = ({
|
|
|
261
269
|
</Group.Group>
|
|
262
270
|
</svg>
|
|
263
271
|
<GraphTooltip {...tooltip} {...graphTooltipData} />
|
|
264
|
-
<Legend
|
|
272
|
+
<Legend
|
|
273
|
+
base={baseAxis}
|
|
274
|
+
lines={newLines}
|
|
275
|
+
renderExtraComponent={legend?.renderExtraComponent}
|
|
276
|
+
timeSeries={timeSeries}
|
|
277
|
+
/>
|
|
265
278
|
</div>
|
|
266
279
|
</ClickAwayListener>
|
|
267
280
|
</>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
1
3
|
import { slice } from 'ramda';
|
|
2
4
|
|
|
3
5
|
import { Box, alpha, useTheme } from '@mui/material';
|
|
@@ -20,6 +22,7 @@ interface Props {
|
|
|
20
22
|
base: number;
|
|
21
23
|
limitLegendRows?: boolean;
|
|
22
24
|
lines: Array<Line>;
|
|
25
|
+
renderExtraComponent?: ReactNode;
|
|
23
26
|
timeSeries: Array<TimeValue>;
|
|
24
27
|
toggable?: boolean;
|
|
25
28
|
}
|
|
@@ -29,7 +32,8 @@ const Legend = ({
|
|
|
29
32
|
timeSeries,
|
|
30
33
|
base,
|
|
31
34
|
toggable = true,
|
|
32
|
-
limitLegendRows = true
|
|
35
|
+
limitLegendRows = true,
|
|
36
|
+
renderExtraComponent
|
|
33
37
|
}: Props): JSX.Element => {
|
|
34
38
|
const { classes, cx } = useStyles({ limitLegendRows });
|
|
35
39
|
const theme = useTheme();
|
|
@@ -127,6 +131,7 @@ const Legend = ({
|
|
|
127
131
|
);
|
|
128
132
|
})}
|
|
129
133
|
</div>
|
|
134
|
+
{renderExtraComponent}
|
|
130
135
|
</div>
|
|
131
136
|
);
|
|
132
137
|
};
|
package/src/Graph/index.tsx
CHANGED
|
@@ -9,7 +9,7 @@ import timezonePlugin from 'dayjs/plugin/timezone';
|
|
|
9
9
|
import utcPlugin from 'dayjs/plugin/utc';
|
|
10
10
|
|
|
11
11
|
import Graph from './Graph';
|
|
12
|
-
import { GlobalAreaLines, GraphData, GraphProps } from './models';
|
|
12
|
+
import { GlobalAreaLines, GraphData, GraphProps, LegendModel } from './models';
|
|
13
13
|
import useGraphData from './useGraphData';
|
|
14
14
|
|
|
15
15
|
dayjs.extend(localizedFormat);
|
|
@@ -19,6 +19,7 @@ dayjs.extend(timezonePlugin);
|
|
|
19
19
|
interface Props extends Partial<GraphProps> {
|
|
20
20
|
data: GraphData;
|
|
21
21
|
end: string;
|
|
22
|
+
legend: LegendModel;
|
|
22
23
|
loading: boolean;
|
|
23
24
|
shapeLines?: GlobalAreaLines;
|
|
24
25
|
start: string;
|
|
@@ -37,7 +38,8 @@ const WrapperGraph = ({
|
|
|
37
38
|
loading,
|
|
38
39
|
timeShiftZones,
|
|
39
40
|
tooltip,
|
|
40
|
-
annotationEvent
|
|
41
|
+
annotationEvent,
|
|
42
|
+
legend
|
|
41
43
|
}: Props): JSX.Element | null => {
|
|
42
44
|
const { adjustedData } = useGraphData({ data, end, start });
|
|
43
45
|
|
|
@@ -59,6 +61,7 @@ const WrapperGraph = ({
|
|
|
59
61
|
graphData={{ ...adjustedData }}
|
|
60
62
|
graphInterval={{ end, start }}
|
|
61
63
|
height={height ?? responsiveHeight}
|
|
64
|
+
legend={legend}
|
|
62
65
|
loading={loading}
|
|
63
66
|
shapeLines={shapeLines}
|
|
64
67
|
timeShiftZones={timeShiftZones}
|