@centreon/ui 23.10.57 → 23.10.58

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.
Files changed (121) hide show
  1. package/package.json +3 -1
  2. package/src/Graph/Gauge/AnimatedPie.tsx +87 -0
  3. package/src/Graph/Gauge/Gauge.stories.tsx +45 -0
  4. package/src/Graph/Gauge/Gauge.tsx +44 -0
  5. package/src/Graph/Gauge/PieData.tsx +79 -0
  6. package/src/Graph/Gauge/ResponsiveGauge.tsx +135 -0
  7. package/src/Graph/Gauge/Thresholds.tsx +87 -0
  8. package/src/Graph/Gauge/index.ts +1 -0
  9. package/src/Graph/Gauge/models.ts +20 -0
  10. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Axes/index.tsx +1 -1
  11. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Axes/models.ts +1 -1
  12. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Axes/useAxisY.ts +1 -1
  13. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/RegularLines/index.tsx +2 -2
  14. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/RegularLines/useRegularLines.ts +2 -2
  15. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/StackedLines/index.tsx +2 -2
  16. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/StackedLines/useStackedLines.ts +1 -1
  17. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/BasicThreshold.tsx +1 -1
  18. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/ThresholdWithPatternLines.tsx +3 -2
  19. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/ThresholdWithVariation.tsx +1 -1
  20. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/index.tsx +1 -1
  21. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/models.ts +1 -1
  22. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/useScaleThreshold.ts +2 -2
  23. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/index.tsx +6 -2
  24. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/models.ts +3 -3
  25. package/src/Graph/{BasicComponents → LineChart/BasicComponents}/useFilterLines.ts +1 -1
  26. package/src/Graph/{Header → LineChart/Header}/index.tsx +4 -4
  27. package/src/Graph/{Icons → LineChart/Icons}/Downtime.tsx +1 -1
  28. package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/RegularAnchorPoint.tsx +2 -2
  29. package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/StackedAnchorPoint.tsx +2 -2
  30. package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/models.ts +1 -1
  31. package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/useTickGraph.ts +2 -2
  32. package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Tooltip/useGraphTooltip.ts +1 -1
  33. package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/index.tsx +2 -2
  34. package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/interactionWithGraphAtoms.ts +1 -1
  35. package/src/Graph/{Legend → LineChart/Legend}/LegendHeader.tsx +1 -1
  36. package/src/Graph/{Legend → LineChart/Legend}/index.tsx +2 -2
  37. package/src/Graph/{Legend → LineChart/Legend}/useInteractiveValues.ts +6 -2
  38. package/src/Graph/{Legend → LineChart/Legend}/useLegend.ts +1 -1
  39. package/src/Graph/{Graph.tsx → LineChart/LineChart.tsx} +8 -7
  40. package/src/Graph/{graphAtoms.ts → LineChart/graphAtoms.ts} +1 -1
  41. package/src/Graph/{helpers → LineChart/helpers}/index.ts +9 -4
  42. package/src/Graph/{index.stories.tsx → LineChart/index.stories.tsx} +39 -38
  43. package/src/Graph/{index.tsx → LineChart/index.tsx} +14 -12
  44. package/src/Graph/{models.ts → LineChart/models.ts} +8 -12
  45. package/src/Graph/{useGraphData.ts → LineChart/useLineChartData.ts} +5 -3
  46. package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +163 -0
  47. package/src/Graph/SingleBar/SingleBar.stories.tsx +45 -0
  48. package/src/Graph/SingleBar/SingleBar.tsx +25 -0
  49. package/src/Graph/SingleBar/Thresholds.tsx +100 -0
  50. package/src/Graph/SingleBar/index.ts +1 -0
  51. package/src/Graph/SingleBar/models.ts +8 -0
  52. package/src/Graph/Text/Text.stories.tsx +54 -0
  53. package/src/Graph/Text/Text.styles.ts +17 -0
  54. package/src/Graph/Text/Text.tsx +80 -0
  55. package/src/Graph/Text/index.ts +1 -0
  56. package/src/Graph/common/margins.ts +1 -0
  57. package/src/Graph/common/models.ts +7 -0
  58. package/src/Graph/{timeSeries → common/timeSeries}/index.test.ts +2 -2
  59. package/src/Graph/{timeSeries → common/timeSeries}/index.ts +22 -6
  60. package/src/Graph/{timeSeries → common/timeSeries}/models.ts +2 -0
  61. package/src/Graph/common/utils.ts +20 -0
  62. package/src/Graph/index.ts +4 -0
  63. package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +10 -6
  64. package/src/api/useGraphQuery/index.ts +7 -4
  65. package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +1 -0
  66. package/src/index.ts +3 -2
  67. /package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Axes/UnitLabel.tsx +0 -0
  68. /package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Grids/index.tsx +0 -0
  69. /package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/Circle.tsx +0 -0
  70. /package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/helpers/index.ts +0 -0
  71. /package/src/Graph/{BasicComponents → LineChart/BasicComponents}/Lines/Threshold/useCoordinateCircle.ts +0 -0
  72. /package/src/Graph/{BasicComponents → LineChart/BasicComponents}/LoadingProgress.tsx +0 -0
  73. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/GuidingLines.tsx +0 -0
  74. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/TooltipAnchorPoint.tsx +0 -0
  75. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/index.tsx +0 -0
  76. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/AnchorPoint/useTooltipAnchorPoint.ts +0 -0
  77. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/Annotation/Area.tsx +0 -0
  78. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/Annotation/Line.tsx +0 -0
  79. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/Annotation/index.tsx +0 -0
  80. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/Area/Downtime.tsx +0 -0
  81. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/EventAnnotations.tsx +0 -0
  82. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/Line/Acknowledgement.tsx +0 -0
  83. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/Line/Comments.tsx +0 -0
  84. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/annotationsAtoms.ts +0 -0
  85. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/index.tsx +0 -0
  86. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/models.ts +0 -0
  87. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Annotations/useAnnotation.ts +0 -0
  88. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Bar.tsx +0 -0
  89. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/TimeShiftZones/TimeShiftIcon.tsx +0 -0
  90. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/TimeShiftZones/TimeShiftZone.tsx +0 -0
  91. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/TimeShiftZones/index.tsx +0 -0
  92. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/TimeShiftZones/models.ts +0 -0
  93. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/TimeShiftZones/useTimeShiftZones.ts +0 -0
  94. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Tooltip/index.tsx +0 -0
  95. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/Tooltip/models.ts +0 -0
  96. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/ZoomPreview/index.tsx +0 -0
  97. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/ZoomPreview/models.ts +0 -0
  98. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/ZoomPreview/useZoomPreview.ts +0 -0
  99. /package/src/Graph/{InteractiveComponents → LineChart/InteractiveComponents}/ZoomPreview/zoomPreviewAtoms.ts +0 -0
  100. /package/src/Graph/{Legend → LineChart/Legend}/InteractiveValue.tsx +0 -0
  101. /package/src/Graph/{Legend → LineChart/Legend}/Legend.styles.ts +0 -0
  102. /package/src/Graph/{Legend → LineChart/Legend}/LegendContent.tsx +0 -0
  103. /package/src/Graph/{Legend → LineChart/Legend}/Marker.tsx +0 -0
  104. /package/src/Graph/{Legend → LineChart/Legend}/models.ts +0 -0
  105. /package/src/Graph/{Graph.styles.ts → LineChart/LineChart.styles.ts} +0 -0
  106. /package/src/Graph/{LoadingSkeleton.tsx → LineChart/LoadingSkeleton.tsx} +0 -0
  107. /package/src/Graph/{common → LineChart/common}/index.ts +0 -0
  108. /package/src/Graph/{helpers → LineChart/helpers}/doc.ts +0 -0
  109. /package/src/Graph/{mockedData → LineChart/mockedData}/annotationData.json +0 -0
  110. /package/src/Graph/{mockedData → LineChart/mockedData}/exclusionPeriodFirstPeriod.json +0 -0
  111. /package/src/Graph/{mockedData → LineChart/mockedData}/exclusionPeriodSecondPeriod.json +0 -0
  112. /package/src/Graph/{mockedData → LineChart/mockedData}/exclusionPeriodThirdPeriod.json +0 -0
  113. /package/src/Graph/{mockedData → LineChart/mockedData}/lastDay.json +0 -0
  114. /package/src/Graph/{mockedData → LineChart/mockedData}/lastDayAreaStack.json +0 -0
  115. /package/src/Graph/{mockedData → LineChart/mockedData}/lastDayForward.json +0 -0
  116. /package/src/Graph/{mockedData → LineChart/mockedData}/lastDayThreshold.json +0 -0
  117. /package/src/Graph/{mockedData → LineChart/mockedData}/lastMonth.json +0 -0
  118. /package/src/Graph/{mockedData → LineChart/mockedData}/lastWeek.json +0 -0
  119. /package/src/Graph/{mockedData → LineChart/mockedData}/zoomPreview.json +0 -0
  120. /package/src/Graph/{translatedLabels.ts → LineChart/translatedLabels.ts} +0 -0
  121. /package/src/Graph/{useGraphIntersection.ts → LineChart/useLineChartIntersection.ts} +0 -0
@@ -7,8 +7,12 @@ import GuidingLines from '../../InteractiveComponents/AnchorPoint/GuidingLines';
7
7
  import RegularAnchorPoint from '../../InteractiveComponents/AnchorPoint/RegularAnchorPoint';
8
8
  import { displayArea } from '../../helpers/index';
9
9
  import { DisplayAnchor, GlobalAreaLines } from '../../models';
10
- import { getStackedYScale, getUnits, getYScale } from '../../timeSeries';
11
- import { Line, TimeValue } from '../../timeSeries/models';
10
+ import {
11
+ getStackedYScale,
12
+ getUnits,
13
+ getYScale
14
+ } from '../../../common/timeSeries';
15
+ import { Line, TimeValue } from '../../../common/timeSeries/models';
12
16
 
13
17
  import RegularLine from './RegularLines';
14
18
  import useRegularLines from './RegularLines/useRegularLines';
@@ -1,8 +1,8 @@
1
1
  import { ScaleLinear } from 'd3-scale';
2
2
  import { curveBasis } from '@visx/curve';
3
3
 
4
- import { GraphData } from '../../models';
5
- import { Line, TimeValue } from '../../timeSeries/models';
4
+ import { Line, TimeValue } from '../../../common/timeSeries/models';
5
+ import { LineChartData } from '../../../common/models';
6
6
 
7
7
  import { FactorsVariation } from './Threshold/models';
8
8
 
@@ -31,7 +31,7 @@ export interface AreaRegularLines extends ShapeGraphData {
31
31
  }
32
32
 
33
33
  export interface AreaThreshold extends AreaRegularLines {
34
- dataExclusionPeriods?: Array<GraphData>;
34
+ dataExclusionPeriods?: Array<LineChartData>;
35
35
  factors?: FactorsVariation;
36
36
  getCountDisplayedCircles?: (value: number) => void;
37
37
  }
@@ -4,7 +4,7 @@ import { useAtom } from 'jotai';
4
4
  import { compose, equals, prop, propEq, reject, sortBy, toLower } from 'ramda';
5
5
 
6
6
  import { linesGraphAtom } from '../graphAtoms';
7
- import { Line } from '../timeSeries/models';
7
+ import { Line } from '../../common/timeSeries/models';
8
8
 
9
9
  import {
10
10
  findLineOfOriginMetricThreshold,
@@ -5,14 +5,14 @@ import Typography from '@mui/material/Typography';
5
5
 
6
6
  import { useLocaleDateTimeFormat, useMemoComponent } from '@centreon/ui';
7
7
 
8
- import { useStyles } from '../Graph.styles';
8
+ import { useStyles } from '../LineChart.styles';
9
9
  import useTickGraph from '../InteractiveComponents/AnchorPoint/useTickGraph';
10
- import { GraphHeader } from '../models';
11
- import { TimeValue } from '../timeSeries/models';
10
+ import { LineChartHeader } from '../models';
11
+ import { TimeValue } from '../../common/timeSeries/models';
12
12
 
13
13
  interface Props {
14
14
  displayTimeTick?: boolean;
15
- header?: GraphHeader;
15
+ header?: LineChartHeader;
16
16
  timeSeries: Array<TimeValue>;
17
17
  title: string;
18
18
  xScale: ScaleLinear<number, number>;
@@ -1,6 +1,6 @@
1
1
  import { SvgIcon, SvgIconProps } from '@mui/material';
2
2
 
3
- import { ReactComponent as IconDowntime } from '../../@assets/icons/downtime.icon.svg';
3
+ import { ReactComponent as IconDowntime } from '../../../@assets/icons/downtime.icon.svg';
4
4
 
5
5
  const Downtime = (props: SvgIconProps): JSX.Element => (
6
6
  <SvgIcon component={IconDowntime} {...props} />
@@ -1,8 +1,8 @@
1
1
  import { ScaleLinear, ScaleTime } from 'd3-scale';
2
2
  import { isNil, prop } from 'ramda';
3
3
 
4
- import { bisectDate, getDates } from '../../timeSeries';
5
- import { TimeValue } from '../../timeSeries/models';
4
+ import { bisectDate, getDates } from '../../../common/timeSeries';
5
+ import { TimeValue } from '../../../common/timeSeries/models';
6
6
 
7
7
  import useTickGraph from './useTickGraph';
8
8
  import { GetYAnchorPoint } from './models';
@@ -1,8 +1,8 @@
1
1
  import { ScaleLinear, ScaleTime } from 'd3-scale';
2
2
  import { isNil, map, pipe } from 'ramda';
3
3
 
4
- import { bisectDate } from '../../timeSeries';
5
- import { TimeValue } from '../../timeSeries/models';
4
+ import { bisectDate } from '../../../common/timeSeries';
5
+ import { TimeValue } from '../../../common/timeSeries/models';
6
6
 
7
7
  import { StackValue } from './models';
8
8
  import useTickGraph from './useTickGraph';
@@ -1,6 +1,6 @@
1
1
  import { ScaleLinear, ScaleTime } from 'd3-scale';
2
2
 
3
- import { Line, TimeValue } from '../../timeSeries/models';
3
+ import { Line, TimeValue } from '../../../common/timeSeries/models';
4
4
 
5
5
  interface AnchorPoint {
6
6
  areaColor: string;
@@ -6,8 +6,8 @@ import { isEmpty, isNil, not } from 'ramda';
6
6
 
7
7
  import useAxisY from '../../BasicComponents/Axes/useAxisY';
8
8
  import { margin } from '../../common';
9
- import { getMetrics, getTimeValue } from '../../timeSeries';
10
- import { Line, TimeValue } from '../../timeSeries/models';
9
+ import { getMetrics, getTimeValue } from '../../../common/timeSeries';
10
+ import { Line, TimeValue } from '../../../common/timeSeries/models';
11
11
  import { mousePositionAtom, timeValueAtom } from '../interactionWithGraphAtoms';
12
12
 
13
13
  interface AnchorPointResult {
@@ -5,7 +5,7 @@ import { ScaleLinear } from 'd3-scale';
5
5
  import { useAtomValue } from 'jotai';
6
6
 
7
7
  import { getDate } from '../../helpers/index';
8
- import { TimeValue } from '../../timeSeries/models';
8
+ import { TimeValue } from '../../../common/timeSeries/models';
9
9
  import { applyingZoomAtomAtom } from '../ZoomPreview/zoomPreviewAtoms';
10
10
  import { eventMouseUpAtom } from '../interactionWithGraphAtoms';
11
11
 
@@ -12,8 +12,8 @@ import {
12
12
  InteractedZone,
13
13
  InteractedZone as ZoomPreviewModel
14
14
  } from '../models';
15
- import { getTimeValue } from '../timeSeries';
16
- import { TimeValue } from '../timeSeries/models';
15
+ import { getTimeValue } from '../../common/timeSeries';
16
+ import { TimeValue } from '../../common/timeSeries/models';
17
17
 
18
18
  import Annotations from './Annotations';
19
19
  import { TimelineEvent } from './Annotations/models';
@@ -1,7 +1,7 @@
1
1
  import { atom } from 'jotai';
2
2
  import { not, isNil } from 'ramda';
3
3
 
4
- import { TimeValue } from '../timeSeries/models';
4
+ import { TimeValue } from '../../common/timeSeries/models';
5
5
 
6
6
  export const eventMouseDownAtom = atom<null | MouseEvent>(null);
7
7
  export const eventMouseUpAtom = atom<null | MouseEvent>(null);
@@ -2,7 +2,7 @@ import { includes, isEmpty, split } from 'ramda';
2
2
 
3
3
  import { Tooltip, Typography } from '@mui/material';
4
4
 
5
- import { Line } from '../timeSeries/models';
5
+ import { Line } from '../../common/timeSeries/models';
6
6
 
7
7
  import { useStyles } from './Legend.styles';
8
8
 
@@ -8,8 +8,8 @@ import { Box, alpha, useTheme } from '@mui/material';
8
8
  import { useMemoComponent } from '@centreon/ui';
9
9
 
10
10
  import { maxLinesDisplayedLegend } from '../common';
11
- import { formatMetricValue } from '../timeSeries';
12
- import { Line, TimeValue } from '../timeSeries/models';
11
+ import { formatMetricValue } from '../../common/timeSeries';
12
+ import { Line, TimeValue } from '../../common/timeSeries/models';
13
13
  import { labelAvg, labelMax, labelMin } from '../translatedLabels';
14
14
  import { timeValueAtom } from '../InteractiveComponents/interactionWithGraphAtoms';
15
15
 
@@ -4,8 +4,12 @@ import { useAtomValue } from 'jotai';
4
4
  import { equals, find, isNil } from 'ramda';
5
5
 
6
6
  import { timeValueAtom } from '../InteractiveComponents/interactionWithGraphAtoms';
7
- import { formatMetricValue, getLineForMetric, getMetrics } from '../timeSeries';
8
- import { Line, TimeValue } from '../timeSeries/models';
7
+ import {
8
+ formatMetricValue,
9
+ getLineForMetric,
10
+ getMetrics
11
+ } from '../../common/timeSeries';
12
+ import { Line, TimeValue } from '../../common/timeSeries/models';
9
13
 
10
14
  import { FormattedMetricData } from './models';
11
15
 
@@ -18,7 +18,7 @@ import {
18
18
  } from 'ramda';
19
19
 
20
20
  import { linesGraphAtom } from '../graphAtoms';
21
- import { Line } from '../timeSeries/models';
21
+ import { Line } from '../../common/timeSeries/models';
22
22
 
23
23
  interface LegendActions {
24
24
  clearHighlight: () => void;
@@ -5,13 +5,15 @@ import { isNil } from 'ramda';
5
5
 
6
6
  import { ClickAwayListener, Skeleton } from '@mui/material';
7
7
 
8
+ import { getLeftScale, getRightScale, getXScale } from '../common/timeSeries';
9
+
8
10
  import Axes from './BasicComponents/Axes';
9
11
  import Grids from './BasicComponents/Grids';
10
12
  import Lines from './BasicComponents/Lines';
11
13
  import { canDisplayThreshold } from './BasicComponents/Lines/Threshold/models';
12
14
  import LoadingProgress from './BasicComponents/LoadingProgress';
13
15
  import useFilterLines from './BasicComponents/useFilterLines';
14
- import { useStyles } from './Graph.styles';
16
+ import { useStyles } from './LineChart.styles';
15
17
  import Header from './Header';
16
18
  import InteractionWithGraph from './InteractiveComponents';
17
19
  import TooltipAnchorPoint from './InteractiveComponents/AnchorPoint/TooltipAnchorPoint';
@@ -23,14 +25,13 @@ import {
23
25
  Data,
24
26
  GlobalAreaLines,
25
27
  GraphInterval,
26
- GraphProps,
28
+ LineChartProps,
27
29
  LegendModel
28
30
  } from './models';
29
- import { getLeftScale, getRightScale, getXScale } from './timeSeries';
30
- import { useIntersection } from './useGraphIntersection';
31
+ import { useIntersection } from './useLineChartIntersection';
31
32
  import { CurveType } from './BasicComponents/Lines/models';
32
33
 
33
- interface Props extends GraphProps {
34
+ interface Props extends LineChartProps {
34
35
  curve: CurveType;
35
36
  graphData: Data;
36
37
  graphInterval: GraphInterval;
@@ -40,7 +41,7 @@ interface Props extends GraphProps {
40
41
  shapeLines?: GlobalAreaLines;
41
42
  }
42
43
 
43
- const Graph = ({
44
+ const LineChart = ({
44
45
  graphData,
45
46
  height = 500,
46
47
  width,
@@ -234,4 +235,4 @@ const Graph = ({
234
235
  );
235
236
  };
236
237
 
237
- export default Graph;
238
+ export default LineChart;
@@ -1,6 +1,6 @@
1
1
  import { atom } from 'jotai';
2
2
 
3
- import { Line } from './timeSeries/models';
3
+ import { Line } from '../common/timeSeries/models';
4
4
 
5
5
  export const linesGraphAtom = atom<Array<Line> | null>(null);
6
6
  export const timeTickGraphAtom = atom<Date | null>(null);
@@ -3,10 +3,15 @@ import { gt, gte, isEmpty, isNil, prop, propEq, reject, sortBy } from 'ramda';
3
3
 
4
4
  import { LinesData } from '../BasicComponents/Lines/models';
5
5
  import { dateFormat, timeFormat } from '../common';
6
- import { GetDate, GraphData, GraphInterval } from '../models';
7
- import { getLineData, getTimeSeries, getTimeValue } from '../timeSeries';
8
-
9
- export const adjustGraphData = (graphData: GraphData): LinesData => {
6
+ import { GetDate, GraphInterval } from '../models';
7
+ import {
8
+ getLineData,
9
+ getTimeSeries,
10
+ getTimeValue
11
+ } from '../../common/timeSeries';
12
+ import { LineChartData } from '../../common/models';
13
+
14
+ export const adjustGraphData = (graphData: LineChartData): LinesData => {
10
15
  const lines = getLineData(graphData);
11
16
  const sortedLines = sortBy(prop('name'), lines);
12
17
  const displayedLines = reject(propEq('display', false), sortedLines);
@@ -10,7 +10,8 @@ import Tooltip from '@mui/material/Tooltip';
10
10
 
11
11
  import { useLocaleDateTimeFormat } from '@centreon/ui';
12
12
 
13
- import TimePeriod from '../TimePeriods';
13
+ import TimePeriod from '../../TimePeriods';
14
+ import { LineChartData } from '../common/models';
14
15
 
15
16
  import { dateTimeFormat } from './common';
16
17
  import {
@@ -32,17 +33,17 @@ import dataLastDay from './mockedData/lastDayThreshold.json';
32
33
  import dataLastMonth from './mockedData/lastMonth.json';
33
34
  import dataLastWeek from './mockedData/lastWeek.json';
34
35
  import dataZoomPreview from './mockedData/zoomPreview.json';
35
- import { GraphData, Interval, ThresholdType, TooltipData } from './models';
36
+ import { Interval, ThresholdType, TooltipData } from './models';
36
37
 
37
- import WrapperGraph from './index';
38
+ import WrapperLineChart from './index';
38
39
 
39
- const meta: Meta<typeof WrapperGraph> = {
40
- component: WrapperGraph,
40
+ const meta: Meta<typeof WrapperLineChart> = {
41
+ component: WrapperLineChart,
41
42
  tags: ['autodocs']
42
43
  };
43
44
  export default meta;
44
45
 
45
- type Story = StoryObj<typeof WrapperGraph>;
46
+ type Story = StoryObj<typeof WrapperLineChart>;
46
47
 
47
48
  interface Random {
48
49
  max: number;
@@ -72,7 +73,7 @@ const Threshold = (args): JSX.Element => {
72
73
  <Button onClick={handleClick}>change envelope size randomly</Button>
73
74
  </Tooltip>
74
75
 
75
- <WrapperGraph
76
+ <WrapperLineChart
76
77
  {...args}
77
78
  data={dataLastDay}
78
79
  shapeLines={{
@@ -115,19 +116,19 @@ const ExternalComponent = (tooltipData): JSX.Element => {
115
116
  );
116
117
  };
117
118
 
118
- const GraphAndCLS = (args): JSX.Element => {
119
- const [data, setData] = useState<GraphData | null>(null);
119
+ const LineChartAndCLS = (args): JSX.Element => {
120
+ const [data, setData] = useState<LineChartData | null>(null);
120
121
  const [loading, setLoading] = useState(true);
121
122
 
122
123
  useEffect(() => {
123
124
  setTimeout(() => {
124
125
  setLoading(false);
125
- setData(dataLastDay as unknown as GraphData);
126
+ setData(dataLastDay as unknown as LineChartData);
126
127
  }, 100000);
127
128
  }, []);
128
129
 
129
130
  return (
130
- <WrapperGraph
131
+ <WrapperLineChart
131
132
  {...args}
132
133
  data={data}
133
134
  loading={loading}
@@ -162,8 +163,8 @@ const TimePeriodSwitch = ({
162
163
  );
163
164
  };
164
165
 
165
- const GraphAndTimePeriod = (args): JSX.Element => {
166
- const [currentData, setCurrentData] = useState<GraphData>();
166
+ const LineChartAndTimePeriod = (args): JSX.Element => {
167
+ const [currentData, setCurrentData] = useState<LineChartData>();
167
168
  const [start, setStart] = useState<string>();
168
169
  const [end, setEnd] = useState<string>();
169
170
  const [displayAnnotation, setDisplayAnnotation] = useState();
@@ -180,28 +181,28 @@ const GraphAndTimePeriod = (args): JSX.Element => {
180
181
  return;
181
182
  }
182
183
  if (start.includes(lastDayForwardDate)) {
183
- setCurrentData(dataLastDayForword as unknown as GraphData);
184
+ setCurrentData(dataLastDayForword as unknown as LineChartData);
184
185
 
185
186
  return;
186
187
  }
187
188
 
188
189
  if (start.includes(`${defaultStart.split('T')[0]}`)) {
189
- setCurrentData(dataLastDay as unknown as GraphData);
190
+ setCurrentData(dataLastDay as unknown as LineChartData);
190
191
 
191
192
  return;
192
193
  }
193
194
  if (start.includes(defaultLast7days.split('T')[0])) {
194
- setCurrentData(dataLastWeek as unknown as GraphData);
195
+ setCurrentData(dataLastWeek as unknown as LineChartData);
195
196
 
196
197
  return;
197
198
  }
198
199
  if (start.includes(defaultLastMonth.split('T')[0])) {
199
- setCurrentData(dataLastMonth as unknown as GraphData);
200
+ setCurrentData(dataLastMonth as unknown as LineChartData);
200
201
 
201
202
  return;
202
203
  }
203
204
  if (start.includes(zoomPreviewDate)) {
204
- setCurrentData(dataZoomPreview as unknown as GraphData);
205
+ setCurrentData(dataZoomPreview as unknown as LineChartData);
205
206
  }
206
207
  }, [start, end, adjustedTimePeriodInterval]);
207
208
 
@@ -226,7 +227,7 @@ const GraphAndTimePeriod = (args): JSX.Element => {
226
227
  <TimePeriodSwitch getDataSwitch={getDataSwitch} />
227
228
  }
228
229
  />
229
- <WrapperGraph
230
+ <WrapperLineChart
230
231
  data={currentData}
231
232
  {...args}
232
233
  annotationEvent={annotationEventData}
@@ -255,10 +256,10 @@ const GraphAndTimePeriod = (args): JSX.Element => {
255
256
  );
256
257
  };
257
258
 
258
- const GraphAndExclusionPeriod = (args): JSX.Element => {
259
+ const LineChartAndExclusionPeriod = (args): JSX.Element => {
259
260
  const [dataExclusionPeriods, setDataExclusionPeriods] = useState<
260
- Array<GraphData>
261
- >([exclusionPeriodFirstPeriod as unknown as GraphData]);
261
+ Array<LineChartData>
262
+ >([exclusionPeriodFirstPeriod as unknown as LineChartData]);
262
263
 
263
264
  const handleClick = (data): void => {
264
265
  setDataExclusionPeriods([...dataExclusionPeriods, data]);
@@ -278,9 +279,9 @@ const GraphAndExclusionPeriod = (args): JSX.Element => {
278
279
  second
279
280
  </Button>
280
281
  </ButtonGroup>
281
- <WrapperGraph
282
+ <WrapperLineChart
282
283
  {...args}
283
- data={dataLastDay as unknown as GraphData}
284
+ data={dataLastDay as unknown as LineChartData}
284
285
  shapeLines={{
285
286
  areaThresholdLines: [
286
287
  {
@@ -300,9 +301,9 @@ const GraphAndExclusionPeriod = (args): JSX.Element => {
300
301
 
301
302
  const Template: Story = {
302
303
  render: (args) => (
303
- <WrapperGraph
304
+ <WrapperLineChart
304
305
  {...args}
305
- data={dataLastDay as unknown as GraphData}
306
+ data={dataLastDay as unknown as LineChartData}
306
307
  shapeLines={{
307
308
  areaThresholdLines: [
308
309
  {
@@ -315,28 +316,28 @@ const Template: Story = {
315
316
  };
316
317
 
317
318
  const WithTimePeriod = {
318
- render: (args): JSX.Element => <GraphAndTimePeriod {...args} />
319
+ render: (args): JSX.Element => <LineChartAndTimePeriod {...args} />
319
320
  };
320
321
 
321
- const GraphWithExclusionPeriod: Story = {
322
- render: (args) => <GraphAndExclusionPeriod {...args} />
322
+ const LineChartWithExclusionPeriod: Story = {
323
+ render: (args) => <LineChartAndExclusionPeriod {...args} />
323
324
  };
324
325
 
325
- const GraphWithEnvelopVariation: Story = {
326
+ const LineChartWithEnvelopVariation: Story = {
326
327
  render: (args) => <Threshold {...args} />
327
328
  };
328
329
 
329
- const GraphWithCLS: Story = {
330
- render: (args) => <GraphAndCLS {...args} />
330
+ const LineChartWithCLS: Story = {
331
+ render: (args) => <LineChartAndCLS {...args} />
331
332
  };
332
333
 
333
- export const Graph: Story = {
334
+ export const LineChart: Story = {
334
335
  ...Template,
335
336
  argTypes,
336
337
  args: argumentsData
337
338
  };
338
339
 
339
- export const GraphWithStepCurve: Story = {
340
+ export const LineChartWithStepCurve: Story = {
340
341
  ...Template,
341
342
  argTypes,
342
343
  args: {
@@ -345,7 +346,7 @@ export const GraphWithStepCurve: Story = {
345
346
  }
346
347
  };
347
348
 
348
- export const GraphWithTimePeriod: Story = {
349
+ export const LineChartWithTimePeriod: Story = {
349
350
  ...WithTimePeriod,
350
351
  args: {
351
352
  end: defaultEnd,
@@ -355,7 +356,7 @@ export const GraphWithTimePeriod: Story = {
355
356
  };
356
357
 
357
358
  export const WithEnvelopVariation: Story = {
358
- ...GraphWithEnvelopVariation,
359
+ ...LineChartWithEnvelopVariation,
359
360
  args: {
360
361
  end: defaultEnd,
361
362
  height: 500,
@@ -364,7 +365,7 @@ export const WithEnvelopVariation: Story = {
364
365
  };
365
366
 
366
367
  export const withExclusionPeriods: Story = {
367
- ...GraphWithExclusionPeriod,
368
+ ...LineChartWithExclusionPeriod,
368
369
  args: {
369
370
  end: defaultEnd,
370
371
  height: 500,
@@ -373,7 +374,7 @@ export const withExclusionPeriods: Story = {
373
374
  };
374
375
 
375
376
  export const withCLS: Story = {
376
- ...GraphWithCLS,
377
+ ...LineChartWithCLS,
377
378
  args: {
378
379
  end: defaultEnd,
379
380
  height: 500,
@@ -10,19 +10,21 @@ import localizedFormat from 'dayjs/plugin/localizedFormat';
10
10
  import timezonePlugin from 'dayjs/plugin/timezone';
11
11
  import utcPlugin from 'dayjs/plugin/utc';
12
12
 
13
- import Graph from './Graph';
13
+ import { LineChartData } from '../common/models';
14
+
15
+ import LineChart from './LineChart';
14
16
  import LoadingSkeleton from './LoadingSkeleton';
15
- import { GlobalAreaLines, GraphData, GraphProps, LegendModel } from './models';
16
- import useGraphData from './useGraphData';
17
+ import { GlobalAreaLines, LineChartProps, LegendModel } from './models';
18
+ import useLineChartData from './useLineChartData';
17
19
  import { CurveType } from './BasicComponents/Lines/models';
18
20
 
19
21
  dayjs.extend(localizedFormat);
20
22
  dayjs.extend(utcPlugin);
21
23
  dayjs.extend(timezonePlugin);
22
24
 
23
- interface Props extends Partial<GraphProps> {
25
+ interface Props extends Partial<LineChartProps> {
24
26
  curve?: CurveType;
25
- data?: GraphData;
27
+ data?: LineChartData;
26
28
  end: string;
27
29
  legend: LegendModel;
28
30
  loading: boolean;
@@ -31,7 +33,7 @@ interface Props extends Partial<GraphProps> {
31
33
  start: string;
32
34
  }
33
35
 
34
- const WrapperGraph = ({
36
+ const WrapperLineChart = ({
35
37
  end,
36
38
  start,
37
39
  height = 500,
@@ -50,8 +52,8 @@ const WrapperGraph = ({
50
52
  curve = Curve.curveLinear,
51
53
  marginBottom = 0
52
54
  }: Props): JSX.Element | null => {
53
- const { adjustedData } = useGraphData({ data, end, start });
54
- const graphRef = useRef<HTMLDivElement | null>(null);
55
+ const { adjustedData } = useLineChartData({ data, end, start });
56
+ const lineChartRef = useRef<HTMLDivElement | null>(null);
55
57
 
56
58
  if (loading || !adjustedData) {
57
59
  return (
@@ -64,7 +66,7 @@ const WrapperGraph = ({
64
66
 
65
67
  return (
66
68
  <div
67
- ref={graphRef as MutableRefObject<HTMLDivElement>}
69
+ ref={lineChartRef as MutableRefObject<HTMLDivElement>}
68
70
  style={{ height: '100%', width: '100%' }}
69
71
  >
70
72
  <Responsive.ParentSize>
@@ -73,14 +75,14 @@ const WrapperGraph = ({
73
75
  width: responsiveWidth
74
76
  }): JSX.Element => {
75
77
  return (
76
- <Graph
78
+ <LineChart
77
79
  annotationEvent={annotationEvent}
78
80
  axis={axis}
79
81
  curve={curve}
80
82
  displayAnchor={displayAnchor}
81
83
  graphData={adjustedData}
82
84
  graphInterval={{ end, start }}
83
- graphRef={graphRef}
85
+ graphRef={lineChartRef}
84
86
  header={header}
85
87
  height={height || responsiveHeight}
86
88
  legend={legend}
@@ -99,4 +101,4 @@ const WrapperGraph = ({
99
101
  );
100
102
  };
101
103
 
102
- export default WrapperGraph;
104
+ export default WrapperLineChart;
@@ -2,7 +2,9 @@ import { ReactNode } from 'react';
2
2
 
3
3
  import { ScaleLinear } from 'd3-scale';
4
4
 
5
- import { Line, Metric, TimeValue } from './timeSeries/models';
5
+ import { Line, TimeValue } from '../common/timeSeries/models';
6
+ import { LineChartData } from '../common/models';
7
+
6
8
  import {
7
9
  AxisX,
8
10
  Axis as AxisYLeft,
@@ -15,13 +17,7 @@ import {
15
17
  import { TimelineEvent } from './InteractiveComponents/Annotations/models';
16
18
  import { FactorsVariation } from './BasicComponents/Lines/Threshold/models';
17
19
 
18
- export interface GraphData {
19
- global;
20
- metrics: Array<Metric>;
21
- times: Array<string>;
22
- }
23
-
24
- export interface GraphEndpoint {
20
+ export interface LineChartEndpoint {
25
21
  baseUrl: string;
26
22
  queryParameters: GraphInterval;
27
23
  }
@@ -76,7 +72,7 @@ export interface AnnotationEvent {
76
72
  data?: Array<TimelineEvent>;
77
73
  }
78
74
 
79
- export interface GraphHeader {
75
+ export interface LineChartHeader {
80
76
  displayTitle?: boolean;
81
77
  extraComponent?: ReactNode;
82
78
  }
@@ -86,11 +82,11 @@ export interface DisplayAnchor {
86
82
  displayTooltipsGuidingLines?: boolean;
87
83
  }
88
84
 
89
- export interface GraphProps {
85
+ export interface LineChartProps {
90
86
  annotationEvent?: AnnotationEvent;
91
87
  axis?: Axis;
92
88
  displayAnchor?: DisplayAnchor;
93
- header?: GraphHeader;
89
+ header?: LineChartHeader;
94
90
  height?: number | null;
95
91
  loading: boolean;
96
92
  timeShiftZones?: InteractedZone;
@@ -116,7 +112,7 @@ export enum ThresholdType {
116
112
  }
117
113
 
118
114
  export interface PatternThreshold {
119
- data: Array<GraphData>;
115
+ data: Array<LineChartData>;
120
116
  orientation?: Array<PatternOrientation>;
121
117
  type: ThresholdType.pattern;
122
118
  }