@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.
Files changed (111) hide show
  1. package/package.json +14 -17
  2. package/src/Graph/BarChart/BarChart.cypress.spec.tsx +38 -79
  3. package/src/Graph/BarChart/BarChart.tsx +4 -4
  4. package/src/Graph/BarChart/BarGroup.tsx +81 -92
  5. package/src/Graph/BarChart/BarStack.tsx +21 -13
  6. package/src/Graph/BarChart/ResponsiveBarChart.tsx +26 -50
  7. package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +1 -1
  8. package/src/Graph/BarChart/useBarStack.ts +1 -1
  9. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Point.tsx +1 -1
  10. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +67 -0
  11. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +4 -7
  12. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/index.tsx +6 -9
  13. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/models.ts +1 -2
  14. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useScaleThreshold.ts +8 -20
  15. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/index.tsx +64 -43
  16. package/src/Graph/{LineChart/LineChart.cypress.spec.tsx → Chart/Chart.cypress.spec.tsx} +272 -23
  17. package/src/Graph/{LineChart/index.stories.tsx → Chart/Chart.stories.tsx} +217 -24
  18. package/src/Graph/{LineChart/LineChart.styles.ts → Chart/Chart.styles.ts} +1 -1
  19. package/src/Graph/{LineChart/LineChart.tsx → Chart/Chart.tsx} +84 -100
  20. package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -1
  21. package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +6 -1
  22. package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +61 -0
  23. package/src/Graph/{LineChart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx → Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltipContent.tsx} +2 -2
  24. package/src/Graph/{LineChart → Chart}/InteractiveComponents/index.tsx +11 -15
  25. package/src/Graph/{LineChart → Chart}/Legend/Legend.styles.ts +1 -7
  26. package/src/Graph/{LineChart → Chart}/Legend/LegendHeader.tsx +9 -5
  27. package/src/Graph/{LineChart → Chart}/Legend/index.tsx +2 -1
  28. package/src/Graph/Chart/graphAtoms.ts +6 -0
  29. package/src/Graph/{LineChart → Chart}/index.tsx +10 -7
  30. package/src/Graph/{LineChart → Chart}/models.ts +8 -3
  31. package/src/Graph/common/Axes/AxisStyles.ts +11 -0
  32. package/src/Graph/common/Axes/UnitLabel.tsx +41 -10
  33. package/src/Graph/common/Axes/index.tsx +18 -12
  34. package/src/Graph/common/Axes/models.ts +4 -2
  35. package/src/Graph/common/Axes/useAxisY.ts +22 -12
  36. package/src/Graph/common/BaseChart/BaseChart.tsx +2 -2
  37. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +8 -5
  38. package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +1 -1
  39. package/src/Graph/common/Grids/index.tsx +2 -2
  40. package/src/Graph/common/Thresholds/ThresholdLine.tsx +1 -1
  41. package/src/Graph/common/Thresholds/Thresholds.tsx +10 -15
  42. package/src/Graph/common/timeSeries/index.ts +109 -131
  43. package/src/Graph/common/timeSeries/models.ts +4 -5
  44. package/src/Graph/index.ts +4 -4
  45. package/src/Graph/mockedData/lastDayWithLotOfUnits.json +1668 -0
  46. package/src/Graph/mockedData/pingService.json +46 -1
  47. package/src/Graph/mockedData/pingServiceLinesBars.json +253 -0
  48. package/src/Graph/mockedData/pingServiceLinesBarsMixed.json +253 -0
  49. package/src/Graph/mockedData/pingServiceLinesBarsStacked.json +253 -0
  50. package/src/Graph/mockedData/pingServiceMixedStacked.json +46 -1
  51. package/src/Graph/mockedData/pingServiceStacked.json +46 -1
  52. package/src/Typography/EllipsisTypography.tsx +5 -2
  53. package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +16 -24
  54. package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
  55. package/src/components/Form/AccessRights/AccessRights.tsx +3 -3
  56. package/src/components/Form/index.ts +2 -2
  57. package/src/utils/index.ts +2 -2
  58. package/src/Graph/BarChart/SingleBar.tsx +0 -62
  59. package/src/Graph/BarChart/useSingleBar.ts +0 -199
  60. package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/useStackedLines.ts +0 -39
  61. package/src/Graph/LineChart/graphAtoms.ts +0 -3
  62. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/index.tsx +0 -0
  63. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/useRegularLines.ts +0 -0
  64. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/StackedLines/index.tsx +0 -0
  65. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/BasicThreshold.tsx +0 -0
  66. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/Circle.tsx +0 -0
  67. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +0 -0
  68. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/helpers/index.ts +0 -0
  69. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useCoordinateCircle.ts +0 -0
  70. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/models.ts +0 -0
  71. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/GuidingLines.tsx +0 -0
  72. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/index.tsx +0 -0
  73. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/models.ts +0 -0
  74. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/useTickGraph.ts +0 -0
  75. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Area.tsx +0 -0
  76. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Line.tsx +0 -0
  77. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/index.tsx +0 -0
  78. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Area/Downtime.tsx +0 -0
  79. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/EventAnnotations.tsx +0 -0
  80. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Acknowledgement.tsx +0 -0
  81. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Comments.tsx +0 -0
  82. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/annotationsAtoms.ts +0 -0
  83. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/index.tsx +0 -0
  84. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/models.ts +0 -0
  85. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/useAnnotation.ts +0 -0
  86. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Bar.tsx +0 -0
  87. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +0 -0
  88. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltipStyles.ts +0 -0
  89. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftIcon.tsx +0 -0
  90. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx +0 -0
  91. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/index.tsx +0 -0
  92. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/models.ts +0 -0
  93. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts +0 -0
  94. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/index.tsx +0 -0
  95. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/models.ts +0 -0
  96. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/useGraphTooltip.ts +0 -0
  97. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/index.tsx +0 -0
  98. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/models.ts +0 -0
  99. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/useZoomPreview.ts +0 -0
  100. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/zoomPreviewAtoms.ts +0 -0
  101. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/interactionWithGraphAtoms.ts +0 -0
  102. /package/src/Graph/{LineChart → Chart}/Legend/LegendContent.tsx +0 -0
  103. /package/src/Graph/{LineChart → Chart}/Legend/models.ts +0 -0
  104. /package/src/Graph/{LineChart → Chart}/Legend/useLegend.ts +0 -0
  105. /package/src/Graph/{LineChart → Chart}/LoadingSkeleton.tsx +0 -0
  106. /package/src/Graph/{LineChart → Chart}/common/index.ts +0 -0
  107. /package/src/Graph/{LineChart → Chart}/helpers/doc.ts +0 -0
  108. /package/src/Graph/{LineChart → Chart}/helpers/index.ts +0 -0
  109. /package/src/Graph/{LineChart → Chart}/translatedLabels.ts +0 -0
  110. /package/src/Graph/{LineChart/useLineChartData.ts → Chart/useChartData.ts} +0 -0
  111. /package/src/Graph/{LineChart/useLineChartIntersection.ts → Chart/useChartIntersection.ts} +0 -0
@@ -12,8 +12,7 @@ import { displayArea } from '../../helpers/index';
12
12
  import { DisplayAnchor, GlobalAreaLines } from '../../models';
13
13
  import {
14
14
  getDates,
15
- getStackedYScale,
16
- getUnits,
15
+ getTimeSeriesForLines,
17
16
  getYScale
18
17
  } from '../../../common/timeSeries';
19
18
  import { Line, TimeValue } from '../../../common/timeSeries/models';
@@ -39,14 +38,15 @@ interface Props extends GlobalAreaLines {
39
38
  dotOffset?: number;
40
39
  graphSvgRef: MutableRefObject<SVGSVGElement | null>;
41
40
  height: number;
42
- leftScale: ScaleLinear<number, number>;
43
41
  lineWidth?: number;
44
- rightScale: ScaleLinear<number, number>;
42
+ scale?: 'linear' | 'logarithmic';
43
+ scaleLogarithmicBase?: number;
45
44
  showArea?: boolean;
46
45
  showPoints?: boolean;
47
46
  timeSeries: Array<TimeValue>;
48
47
  width: number;
49
48
  xScale: ScaleLinear<number, number>;
49
+ yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
50
50
  }
51
51
 
52
52
  const Lines = ({
@@ -55,9 +55,8 @@ const Lines = ({
55
55
  graphSvgRef,
56
56
  width,
57
57
  displayAnchor,
58
- leftScale,
59
- rightScale,
60
58
  curve,
59
+ yScalesPerUnit,
61
60
  xScale,
62
61
  timeSeries,
63
62
  displayedLines,
@@ -69,7 +68,9 @@ const Lines = ({
69
68
  lineWidth,
70
69
  dotOffset,
71
70
  dashLength,
72
- dashOffset
71
+ dashOffset,
72
+ scale,
73
+ scaleLogarithmicBase
73
74
  }: Props): JSX.Element => {
74
75
  const { stackedLinesData, invertedStackedLinesData } = useStackedLines({
75
76
  lines: displayedLines,
@@ -85,11 +86,6 @@ const Lines = ({
85
86
  const displayAreaRegularLines =
86
87
  (areaRegularLines?.display ?? true) && displayArea(regularLines);
87
88
 
88
- const stackedYScale = getStackedYScale({
89
- leftScale,
90
- rightScale
91
- });
92
-
93
89
  const displayGuidingLines = displayAnchor?.displayGuidingLines ?? true;
94
90
  const commonStackedLinesProps = {
95
91
  areaTransparency,
@@ -104,8 +100,7 @@ const Lines = ({
104
100
  lineWidth,
105
101
  showArea,
106
102
  showPoints,
107
- xScale,
108
- yScale: stackedYScale
103
+ xScale
109
104
  };
110
105
 
111
106
  return (
@@ -121,20 +116,33 @@ const Lines = ({
121
116
 
122
117
  {(areaStackedLines?.display ?? true) && (
123
118
  <>
124
- {displayArea(stackedLinesData.lines) && (
125
- <StackedLines
126
- lines={stackedLinesData.lines}
127
- timeSeries={stackedLinesData.timeSeries}
128
- {...commonStackedLinesProps}
129
- />
119
+ {Object.entries(stackedLinesData).map(
120
+ ([unit, { lines, timeSeries: stackedTimeSeries }]) => (
121
+ <StackedLines
122
+ key={`stacked-${unit}`}
123
+ lines={lines}
124
+ timeSeries={stackedTimeSeries}
125
+ yScale={yScalesPerUnit[unit]}
126
+ {...commonStackedLinesProps}
127
+ />
128
+ )
130
129
  )}
131
-
132
- {displayArea(invertedStackedLinesData.lines) && (
133
- <StackedLines
134
- lines={invertedStackedLinesData.lines}
135
- timeSeries={invertedStackedLinesData.timeSeries}
136
- {...commonStackedLinesProps}
137
- />
130
+ {Object.entries(invertedStackedLinesData).map(
131
+ ([unit, { lines, timeSeries: stackedTimeSeries }]) => (
132
+ <StackedLines
133
+ key={`invert-stacked-${unit}`}
134
+ lines={lines}
135
+ timeSeries={stackedTimeSeries}
136
+ yScale={getYScale({
137
+ invert: '1',
138
+ scale,
139
+ scaleLogarithmicBase,
140
+ unit,
141
+ yScalesPerUnit
142
+ })}
143
+ {...commonStackedLinesProps}
144
+ />
145
+ )
138
146
  )}
139
147
  </>
140
148
  )}
@@ -143,11 +151,10 @@ const Lines = ({
143
151
  <WrapperThresholdLines
144
152
  areaThresholdLines={areaThresholdLines}
145
153
  graphHeight={height}
146
- leftScale={leftScale}
147
154
  lines={displayedLines}
148
- rightScale={rightScale}
149
155
  timeSeries={timeSeries}
150
156
  xScale={xScale}
157
+ yScalesPerUnit={yScalesPerUnit}
151
158
  />
152
159
  )}
153
160
 
@@ -161,18 +168,32 @@ const Lines = ({
161
168
  unit,
162
169
  highlight,
163
170
  invert,
164
- metric_id
171
+ metric_id,
172
+ ...rest
165
173
  }) => {
166
- const [, secondUnit, thirdUnit] = getUnits(
167
- regularLines as Array<Line>
168
- );
169
174
  const yScale = getYScale({
170
- hasMoreThanTwoUnits: !isNil(thirdUnit),
171
175
  invert,
172
- leftScale,
173
- rightScale,
174
- secondUnit,
175
- unit
176
+ scale,
177
+ scaleLogarithmicBase,
178
+ unit,
179
+ yScalesPerUnit
180
+ });
181
+ const relatedTimeSeries = getTimeSeriesForLines({
182
+ invert,
183
+ lines: [
184
+ {
185
+ areaColor,
186
+ filled,
187
+ highlight,
188
+ invert,
189
+ lineColor,
190
+ metric_id,
191
+ transparency,
192
+ unit,
193
+ ...rest
194
+ }
195
+ ],
196
+ timeSeries
176
197
  });
177
198
 
178
199
  return (
@@ -182,25 +203,25 @@ const Lines = ({
182
203
  areaColor={areaColor || lineColor}
183
204
  lineColor={lineColor}
184
205
  metric_id={metric_id}
185
- timeSeries={timeSeries}
206
+ timeSeries={relatedTimeSeries}
186
207
  transparency={transparency}
187
208
  xScale={xScale}
188
209
  yScale={yScale}
189
210
  />
190
211
  )}
191
212
  {showPoints &&
192
- getDates(timeSeries).map((timeTick) => (
213
+ getDates(relatedTimeSeries).map((timeTick) => (
193
214
  <Point
194
215
  key={timeTick.toString()}
195
216
  lineColor={lineColor}
196
217
  metric_id={metric_id}
197
218
  radius={getPointRadius(lineWidth)}
198
- timeSeries={timeSeries}
219
+ timeSeries={relatedTimeSeries}
199
220
  timeTick={timeTick}
200
221
  xScale={xScale}
201
222
  yPoint={getYAnchorPoint({
202
223
  metric_id,
203
- timeSeries,
224
+ timeSeries: relatedTimeSeries,
204
225
  timeTick,
205
226
  yScale
206
227
  })}
@@ -219,7 +240,7 @@ const Lines = ({
219
240
  lineColor={lineColor}
220
241
  lineWidth={lineWidth}
221
242
  metric_id={metric_id}
222
- timeSeries={timeSeries}
243
+ timeSeries={relatedTimeSeries}
223
244
  transparency={
224
245
  isNil(areaTransparency)
225
246
  ? transparency || 80