@centreon/ui 25.2.3 → 25.2.4

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.
@@ -17,7 +17,9 @@ import {
17
17
 
18
18
  import { Theme, darken, getLuminance, lighten } from '@mui/material';
19
19
 
20
- import { Thresholds } from './models';
20
+ import { Threshold, Thresholds } from './models';
21
+ import { formatMetricValue } from './timeSeries';
22
+ import { Line, TimeValue } from './timeSeries/models';
21
23
 
22
24
  interface GetColorFromDataAndThresholdsProps {
23
25
  baseColor?: string;
@@ -179,3 +181,49 @@ export const commonTickLabelProps = {
179
181
  fontSize: 10,
180
182
  textAnchor: 'middle'
181
183
  };
184
+
185
+ interface GetFormattedAxisValuesProps {
186
+ thresholdUnit?: string;
187
+ axisUnit: string;
188
+ base?: number;
189
+ timeSeries: Array<TimeValue>;
190
+ threshold: Array<Threshold>;
191
+ lines: Array<Line>;
192
+ }
193
+
194
+ export const getFormattedAxisValues = ({
195
+ thresholdUnit,
196
+ axisUnit,
197
+ timeSeries,
198
+ base = 1000,
199
+ lines,
200
+ threshold
201
+ }: GetFormattedAxisValuesProps): Array<string> => {
202
+ const metricId = (lines.find(({ unit }) => equals(unit, axisUnit)) as Line)
203
+ ?.metric_id;
204
+
205
+ if (isNil(metricId)) {
206
+ return [];
207
+ }
208
+ const formattedData = timeSeries.map((data) =>
209
+ formatMetricValue({
210
+ value: data[metricId],
211
+ unit: axisUnit,
212
+ base
213
+ })
214
+ );
215
+
216
+ const formattedThresholdValues = equals(thresholdUnit, axisUnit)
217
+ ? threshold.map(({ value }) =>
218
+ formatMetricValue({
219
+ value,
220
+ unit: axisUnit,
221
+ base
222
+ })
223
+ ) || []
224
+ : [];
225
+
226
+ return formattedData
227
+ .concat(formattedThresholdValues)
228
+ .filter((v) => v) as Array<string>;
229
+ };
@@ -329,7 +329,20 @@
329
329
  0.32339333333,
330
330
  null
331
331
  ],
332
- "prints": [["Last:0.32"], ["Min:0.03"], ["Max:0.97"], ["Average:0.51"]],
332
+ "prints": [
333
+ [
334
+ "Last:0.32"
335
+ ],
336
+ [
337
+ "Min:0.03"
338
+ ],
339
+ [
340
+ "Max:0.97"
341
+ ],
342
+ [
343
+ "Average:0.51"
344
+ ]
345
+ ],
333
346
  "last_value": 0.32,
334
347
  "minimum_value": 0.03,
335
348
  "maximum_value": 0.97,
@@ -654,10 +667,18 @@
654
667
  null
655
668
  ],
656
669
  "prints": [
657
- ["Last:87.27"],
658
- ["Min:70.31"],
659
- ["Max:88.03"],
660
- ["Average:78.07"]
670
+ [
671
+ "Last:87.27"
672
+ ],
673
+ [
674
+ "Min:70.31"
675
+ ],
676
+ [
677
+ "Max:88.03"
678
+ ],
679
+ [
680
+ "Average:78.07"
681
+ ]
661
682
  ],
662
683
  "last_value": 87.27,
663
684
  "minimum_value": 70.31,
@@ -974,15 +995,28 @@
974
995
  0.32092,
975
996
  0.23609333333,
976
997
  0.45102333333,
977
- 0.75873,
978
- 0.23588666667,
979
- 0.41906666667,
980
- 0.357,
981
- 0.32246333333,
982
- 0.64624666667,
998
+ null,
999
+ null,
1000
+ null,
1001
+ null,
1002
+ null,
1003
+ null,
983
1004
  null
984
1005
  ],
985
- "prints": [["Last:0.65"], ["Min:0.03"], ["Max:0.98"], ["Average:0.50"]],
1006
+ "prints": [
1007
+ [
1008
+ "Last:0.65"
1009
+ ],
1010
+ [
1011
+ "Min:0.03"
1012
+ ],
1013
+ [
1014
+ "Max:0.98"
1015
+ ],
1016
+ [
1017
+ "Average:0.50"
1018
+ ]
1019
+ ],
986
1020
  "last_value": 0.65,
987
1021
  "minimum_value": 0.03,
988
1022
  "maximum_value": 0.98,