@centreon/ui 23.10.1-MON-21256-handle-range-thresholds.9 → 23.10.1-MON-20799-fe-implement-new-visualization.13

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 (48) hide show
  1. package/package.json +1 -1
  2. package/src/Graph/Gauge/AnimatedPie.tsx +20 -31
  3. package/src/Graph/Gauge/Gauge.stories.tsx +6 -97
  4. package/src/Graph/Gauge/Gauge.tsx +15 -4
  5. package/src/Graph/Gauge/PieData.tsx +24 -8
  6. package/src/Graph/Gauge/ResponsiveGauge.tsx +14 -11
  7. package/src/Graph/Gauge/Thresholds.tsx +56 -109
  8. package/src/Graph/Gauge/models.ts +3 -2
  9. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +7 -9
  10. package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/index.tsx +4 -2
  11. package/src/Graph/LineChart/InteractiveComponents/interactionWithGraphAtoms.ts +0 -1
  12. package/src/Graph/LineChart/Legend/index.tsx +4 -9
  13. package/src/Graph/LineChart/Legend/useInteractiveValues.ts +4 -13
  14. package/src/Graph/LineChart/Legend/useLegend.ts +13 -10
  15. package/src/Graph/LineChart/LineChart.tsx +8 -73
  16. package/src/Graph/LineChart/graphAtoms.ts +3 -0
  17. package/src/Graph/LineChart/index.stories.tsx +6 -101
  18. package/src/Graph/LineChart/index.tsx +3 -13
  19. package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +8 -10
  20. package/src/Graph/SingleBar/SingleBar.stories.tsx +6 -119
  21. package/src/Graph/SingleBar/Thresholds.tsx +82 -28
  22. package/src/Graph/SingleBar/models.ts +4 -2
  23. package/src/Graph/Text/Text.tsx +16 -20
  24. package/src/Graph/common/models.ts +0 -12
  25. package/src/Graph/common/timeSeries/index.ts +8 -41
  26. package/src/Graph/common/timeSeries/models.ts +1 -3
  27. package/src/Graph/common/utils.ts +6 -59
  28. package/src/Listing/ActionBar/index.tsx +14 -7
  29. package/src/Listing/Cell/DataCell.tsx +7 -7
  30. package/src/Listing/Cell/index.tsx +5 -5
  31. package/src/Listing/Header/Cell/ListingHeaderCell.styles.ts +3 -3
  32. package/src/Listing/Header/Cell/ListingHeaderCell.tsx +2 -2
  33. package/src/Listing/Header/ListingHeader.tsx +4 -4
  34. package/src/Listing/Listing.styles.ts +1 -1
  35. package/src/Listing/Row/Row.tsx +3 -3
  36. package/src/Listing/index.stories.tsx +5 -5
  37. package/src/Listing/index.tsx +15 -12
  38. package/src/Listing/tableAtoms.ts +14 -11
  39. package/src/Listing/useStyleTable.ts +8 -8
  40. package/src/SortableItems/SortableItem.tsx +2 -1
  41. package/src/api/useGraphQuery/index.ts +21 -52
  42. package/src/components/Modal/Modal.styles.ts +2 -1
  43. package/src/utils/index.ts +0 -1
  44. package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +0 -64
  45. package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +0 -77
  46. package/src/Graph/SingleBar/ThresholdLine.tsx +0 -74
  47. package/src/utils/useRefreshInterval.ts +0 -21
  48. package/src/utils/useThresholds.ts +0 -0
@@ -44,7 +44,6 @@ export const changeMousePositionAndTimeValueDerivedAtom = atom(
44
44
 
45
45
  return;
46
46
  }
47
-
48
47
  set(mousePositionAtom, position);
49
48
 
50
49
  set(timeValueAtom, timeValue);
@@ -1,4 +1,4 @@
1
- import { Dispatch, ReactNode, SetStateAction } from 'react';
1
+ import { ReactNode } from 'react';
2
2
 
3
3
  import { slice } from 'ramda';
4
4
  import { useAtomValue } from 'jotai';
@@ -28,10 +28,8 @@ interface Props {
28
28
  limitLegendRows?: boolean;
29
29
  lines: Array<Line>;
30
30
  renderExtraComponent?: ReactNode;
31
- setLinesGraph: Dispatch<SetStateAction<Array<Line> | null>>;
32
31
  timeSeries: Array<TimeValue>;
33
32
  toggable?: boolean;
34
- xScale;
35
33
  }
36
34
 
37
35
  const MainLegend = ({
@@ -41,21 +39,18 @@ const MainLegend = ({
41
39
  toggable = true,
42
40
  limitLegendRows = true,
43
41
  renderExtraComponent,
44
- displayAnchor = true,
45
- setLinesGraph,
46
- xScale
42
+ displayAnchor = true
47
43
  }: Props): JSX.Element => {
48
44
  const { classes, cx } = useStyles({ limitLegendRows });
49
45
  const theme = useTheme();
50
46
 
51
47
  const { selectMetricLine, clearHighlight, highlightLine, toggleMetricLine } =
52
- useLegend({ lines, setLinesGraph });
48
+ useLegend({ lines });
53
49
 
54
50
  const { getFormattedValue } = useInteractiveValues({
55
51
  base,
56
52
  lines,
57
- timeSeries,
58
- xScale
53
+ timeSeries
59
54
  });
60
55
 
61
56
  const displayedLines = limitLegendRows
@@ -3,12 +3,11 @@ import { useMemo } from 'react';
3
3
  import { useAtomValue } from 'jotai';
4
4
  import { equals, find, isNil } from 'ramda';
5
5
 
6
- import { mousePositionAtom } from '../InteractiveComponents/interactionWithGraphAtoms';
6
+ import { timeValueAtom } from '../InteractiveComponents/interactionWithGraphAtoms';
7
7
  import {
8
8
  formatMetricValue,
9
9
  getLineForMetric,
10
- getMetrics,
11
- getTimeValue
10
+ getMetrics
12
11
  } from '../../common/timeSeries';
13
12
  import { Line, TimeValue } from '../../common/timeSeries/models';
14
13
 
@@ -22,22 +21,14 @@ interface Props {
22
21
  base: number;
23
22
  lines: Array<Line>;
24
23
  timeSeries: Array<TimeValue>;
25
- xScale;
26
24
  }
27
25
 
28
26
  const useInteractiveValues = ({
29
27
  timeSeries,
30
28
  lines,
31
- base,
32
- xScale
29
+ base
33
30
  }: Props): InteractiveValues => {
34
- const mousePosition = useAtomValue(mousePositionAtom);
35
-
36
- const timeValue = getTimeValue({
37
- timeSeries,
38
- x: mousePosition?.[0],
39
- xScale
40
- });
31
+ const timeValue = useAtomValue(timeValueAtom);
41
32
 
42
33
  const graphTimeValue = timeSeries?.find((item) =>
43
34
  equals(item.timeTick, timeValue?.timeTick)
@@ -1,5 +1,6 @@
1
- import { Dispatch, SetStateAction, useEffect } from 'react';
1
+ import { useEffect } from 'react';
2
2
 
3
+ import { useSetAtom } from 'jotai';
3
4
  import {
4
5
  equals,
5
6
  find,
@@ -16,6 +17,7 @@ import {
16
17
  toLower
17
18
  } from 'ramda';
18
19
 
20
+ import { linesGraphAtom } from '../graphAtoms';
19
21
  import { Line } from '../../common/timeSeries/models';
20
22
 
21
23
  interface LegendActions {
@@ -27,10 +29,11 @@ interface LegendActions {
27
29
 
28
30
  interface Props {
29
31
  lines: Array<Line>;
30
- setLinesGraph: Dispatch<SetStateAction<Array<Line> | null>>;
31
32
  }
32
33
 
33
- const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
34
+ const useLegend = ({ lines }: Props): LegendActions => {
35
+ const setLines = useSetAtom(linesGraphAtom);
36
+
34
37
  const displayedLines = reject(propEq('display', false), lines);
35
38
  const getLineByMetric = (metric: string): Line =>
36
39
  find(propEq('metric', metric), lines) as Line;
@@ -38,7 +41,7 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
38
41
  const toggleMetricLine = (metric): void => {
39
42
  const line = getLineByMetric(metric);
40
43
 
41
- setLinesGraph([
44
+ setLines([
42
45
  ...reject(propEq('metric', metric), lines),
43
46
  { ...line, display: !line.display }
44
47
  ]);
@@ -53,11 +56,11 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
53
56
 
54
57
  const sortedData = sortBy(compose(toLower, prop('name')), data);
55
58
 
56
- setLinesGraph(sortedData);
59
+ setLines(sortedData);
57
60
  };
58
61
 
59
62
  const clearHighlight = (): void => {
60
- setLinesGraph(map((line) => ({ ...line, highlight: undefined }), lines));
63
+ setLines(map((line) => ({ ...line, highlight: undefined }), lines));
61
64
  };
62
65
 
63
66
  const selectMetricLine = (metric: string): void => {
@@ -68,7 +71,7 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
68
71
  equals(displayedLines.length, 1) && isLineDisplayed;
69
72
 
70
73
  if (isOnlyLineDisplayed || isEmpty(displayedLines)) {
71
- setLinesGraph(
74
+ setLines(
72
75
  map(
73
76
  (line) => ({
74
77
  ...line,
@@ -81,7 +84,7 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
81
84
  return;
82
85
  }
83
86
 
84
- setLinesGraph(
87
+ setLines(
85
88
  map(
86
89
  (line) => ({
87
90
  ...line,
@@ -102,8 +105,8 @@ const useLegend = ({ lines, setLinesGraph }: Props): LegendActions => {
102
105
  display: find(propEq('name', line.name), lines)?.display ?? true
103
106
  }));
104
107
 
105
- setLinesGraph(newLines);
106
- }, [lines]);
108
+ setLines(newLines);
109
+ }, []);
107
110
 
108
111
  return { clearHighlight, highlightLine, selectMetricLine, toggleMetricLine };
109
112
  };
@@ -1,13 +1,11 @@
1
- import { MutableRefObject, useMemo, useRef, useState } from 'react';
1
+ import { MutableRefObject, useMemo, useRef } from 'react';
2
2
 
3
- import { Group, Tooltip } from '@visx/visx';
4
- import { flatten, isNil, pluck } from 'ramda';
3
+ import { Group } from '@visx/visx';
4
+ import { isNil } from 'ramda';
5
5
 
6
- import { ClickAwayListener, Fade, Skeleton, useTheme } from '@mui/material';
6
+ import { ClickAwayListener, Skeleton } from '@mui/material';
7
7
 
8
8
  import { getLeftScale, getRightScale, getXScale } from '../common/timeSeries';
9
- import { Line } from '../common/timeSeries/models';
10
- import { Thresholds as ThresholdsModel } from '../common/models';
11
9
 
12
10
  import Axes from './BasicComponents/Axes';
13
11
  import Grids from './BasicComponents/Grids';
@@ -32,7 +30,6 @@ import {
32
30
  } from './models';
33
31
  import { useIntersection } from './useLineChartIntersection';
34
32
  import { CurveType } from './BasicComponents/Lines/models';
35
- import Thresholds from './BasicComponents/Thresholds';
36
33
 
37
34
  interface Props extends LineChartProps {
38
35
  curve: CurveType;
@@ -42,15 +39,8 @@ interface Props extends LineChartProps {
42
39
  legend?: LegendModel;
43
40
  marginBottom: number;
44
41
  shapeLines?: GlobalAreaLines;
45
- thresholdUnit?: string;
46
- thresholds?: ThresholdsModel;
47
42
  }
48
43
 
49
- const baseStyles = {
50
- ...Tooltip.defaultStyles,
51
- textAlign: 'center'
52
- };
53
-
54
44
  const LineChart = ({
55
45
  graphData,
56
46
  height = 500,
@@ -68,30 +58,15 @@ const LineChart = ({
68
58
  graphRef,
69
59
  header,
70
60
  curve,
71
- marginBottom,
72
- thresholds,
73
- thresholdUnit
61
+ marginBottom
74
62
  }: Props): JSX.Element => {
75
- const { classes } = useStyles();
76
-
77
- const theme = useTheme();
78
-
79
- const [linesGraph, setLinesGraph] = useState<Array<Line> | null>(null);
80
63
  const graphSvgRef = useRef<SVGSVGElement | null>(null);
81
64
 
65
+ const { classes } = useStyles();
82
66
  const { isInViewport } = useIntersection({ element: graphRef?.current });
83
67
 
84
68
  const legendRef = useRef<HTMLDivElement | null>(null);
85
69
 
86
- const {
87
- tooltipOpen: thresholdTooltipOpen,
88
- tooltipLeft: thresholdTooltipLeft,
89
- tooltipTop: thresholdTooltipTop,
90
- tooltipData: thresholdTooltipData,
91
- hideTooltip: hideThresholdTooltip,
92
- showTooltip: showThresholdTooltip
93
- } = Tooltip.useTooltip();
94
-
95
70
  const graphWidth = width > 0 ? width - margin.left - margin.right : 0;
96
71
  const graphHeight =
97
72
  (height || 0) > 0
@@ -104,16 +79,9 @@ const LineChart = ({
104
79
 
105
80
  const { title, timeSeries, baseAxis, lines } = graphData;
106
81
 
107
- const thresholdValues = flatten([
108
- pluck('value', thresholds?.warning || []),
109
- pluck('value', thresholds?.critical || [])
110
- ]);
111
-
112
82
  const { displayedLines, newLines } = useFilterLines({
113
83
  displayThreshold: canDisplayThreshold(shapeLines?.areaThresholdLines),
114
- lines,
115
- linesGraph,
116
- setLinesGraph
84
+ lines
117
85
  });
118
86
 
119
87
  const xScale = useMemo(
@@ -130,11 +98,9 @@ const LineChart = ({
130
98
  getLeftScale({
131
99
  dataLines: displayedLines,
132
100
  dataTimeSeries: timeSeries,
133
- thresholdUnit,
134
- thresholds: (thresholds?.enabled && thresholdValues) || [],
135
101
  valueGraphHeight: graphHeight - 35
136
102
  }),
137
- [displayedLines, timeSeries, graphHeight, thresholdValues]
103
+ [displayedLines, timeSeries, graphHeight]
138
104
  );
139
105
 
140
106
  const rightScale = useMemo(
@@ -142,8 +108,6 @@ const LineChart = ({
142
108
  getRightScale({
143
109
  dataLines: displayedLines,
144
110
  dataTimeSeries: timeSeries,
145
- thresholdUnit,
146
- thresholds: (thresholds?.enabled && thresholdValues) || [],
147
111
  valueGraphHeight: graphHeight - 35
148
112
  }),
149
113
  [timeSeries, displayedLines, graphHeight]
@@ -237,19 +201,6 @@ const LineChart = ({
237
201
  }}
238
202
  zoomData={{ ...zoomPreview }}
239
203
  />
240
-
241
- {thresholds?.enabled && (
242
- <Thresholds
243
- displayedLines={displayedLines}
244
- hideTooltip={hideThresholdTooltip}
245
- leftScale={leftScale}
246
- rightScale={rightScale}
247
- showTooltip={showThresholdTooltip}
248
- thresholdUnit={thresholdUnit}
249
- thresholds={thresholds as ThresholdsModel}
250
- width={graphWidth}
251
- />
252
- )}
253
204
  </Group.Group>
254
205
  </svg>
255
206
  {displayTooltip && (
@@ -267,20 +218,6 @@ const LineChart = ({
267
218
  xScale={xScale}
268
219
  />
269
220
  )}
270
- <Fade in={thresholdTooltipOpen}>
271
- <Tooltip.Tooltip
272
- left={thresholdTooltipLeft}
273
- style={{
274
- ...baseStyles,
275
- backgroundColor: theme.palette.background.paper,
276
- color: theme.palette.text.primary,
277
- transform: `translate(${graphWidth / 2}px, -10px)`
278
- }}
279
- top={thresholdTooltipTop}
280
- >
281
- {thresholdTooltipData}
282
- </Tooltip.Tooltip>
283
- </Fade>
284
221
  </div>
285
222
  </ClickAwayListener>
286
223
  {displayLegend && (
@@ -290,9 +227,7 @@ const LineChart = ({
290
227
  displayAnchor={displayAnchor?.displayGuidingLines ?? true}
291
228
  lines={newLines}
292
229
  renderExtraComponent={legend?.renderExtraComponent}
293
- setLinesGraph={setLinesGraph}
294
230
  timeSeries={timeSeries}
295
- xScale={xScale}
296
231
  />
297
232
  </div>
298
233
  )}
@@ -1,3 +1,6 @@
1
1
  import { atom } from 'jotai';
2
2
 
3
+ import { Line } from '../common/timeSeries/models';
4
+
5
+ export const linesGraphAtom = atom<Array<Line> | null>(null);
3
6
  export const timeTickGraphAtom = atom<Date | null>(null);
@@ -29,11 +29,10 @@ import exclusionPeriodFirstPeriod from './mockedData/exclusionPeriodFirstPeriod.
29
29
  import exclusionPeriodSecondPeriod from './mockedData/exclusionPeriodSecondPeriod.json';
30
30
  import exclusionPeriodThirdPeriod from './mockedData/exclusionPeriodThirdPeriod.json';
31
31
  import dataLastDayForword from './mockedData/lastDayForward.json';
32
- import dataLastDayThreshold from './mockedData/lastDayThreshold.json';
32
+ import dataLastDay from './mockedData/lastDayThreshold.json';
33
33
  import dataLastMonth from './mockedData/lastMonth.json';
34
34
  import dataLastWeek from './mockedData/lastWeek.json';
35
35
  import dataZoomPreview from './mockedData/zoomPreview.json';
36
- import dataLastDay from './mockedData/lastDay.json';
37
36
  import { Interval, ThresholdType, TooltipData } from './models';
38
37
 
39
38
  import WrapperLineChart from './index';
@@ -76,7 +75,7 @@ const Threshold = (args): JSX.Element => {
76
75
 
77
76
  <WrapperLineChart
78
77
  {...args}
79
- data={dataLastDayThreshold}
78
+ data={dataLastDay}
80
79
  shapeLines={{
81
80
  areaThresholdLines: [
82
81
  { type: ThresholdType.basic },
@@ -124,7 +123,7 @@ const LineChartAndCLS = (args): JSX.Element => {
124
123
  useEffect(() => {
125
124
  setTimeout(() => {
126
125
  setLoading(false);
127
- setData(dataLastDayThreshold as unknown as LineChartData);
126
+ setData(dataLastDay as unknown as LineChartData);
128
127
  }, 100000);
129
128
  }, []);
130
129
 
@@ -188,7 +187,7 @@ const LineChartAndTimePeriod = (args): JSX.Element => {
188
187
  }
189
188
 
190
189
  if (start.includes(`${defaultStart.split('T')[0]}`)) {
191
- setCurrentData(dataLastDayThreshold as unknown as LineChartData);
190
+ setCurrentData(dataLastDay as unknown as LineChartData);
192
191
 
193
192
  return;
194
193
  }
@@ -282,7 +281,7 @@ const LineChartAndExclusionPeriod = (args): JSX.Element => {
282
281
  </ButtonGroup>
283
282
  <WrapperLineChart
284
283
  {...args}
285
- data={dataLastDayThreshold as unknown as LineChartData}
284
+ data={dataLastDay as unknown as LineChartData}
286
285
  shapeLines={{
287
286
  areaThresholdLines: [
288
287
  {
@@ -304,7 +303,7 @@ const Template: Story = {
304
303
  render: (args) => (
305
304
  <WrapperLineChart
306
305
  {...args}
307
- data={dataLastDayThreshold as unknown as LineChartData}
306
+ data={dataLastDay as unknown as LineChartData}
308
307
  shapeLines={{
309
308
  areaThresholdLines: [
310
309
  {
@@ -382,97 +381,3 @@ export const withCLS: Story = {
382
381
  start: defaultStart
383
382
  }
384
383
  };
385
-
386
- export const withThresholds: Story = {
387
- argTypes,
388
- args: {
389
- ...argumentsData,
390
- thresholds: {
391
- critical: [
392
- {
393
- label: 'critical',
394
- value: 350
395
- }
396
- ],
397
- enabled: true,
398
- warning: [
399
- {
400
- label: 'warning',
401
- value: 300
402
- }
403
- ]
404
- }
405
- },
406
- render: (args) => (
407
- <WrapperLineChart
408
- {...args}
409
- data={dataLastDay as unknown as LineChartData}
410
- />
411
- )
412
- };
413
-
414
- export const withThresholdsAndUnit: Story = {
415
- argTypes,
416
- args: {
417
- ...argumentsData,
418
- thresholdUnit: '%',
419
- thresholds: {
420
- critical: [
421
- {
422
- label: 'critical',
423
- value: 79
424
- }
425
- ],
426
- enabled: true,
427
- warning: [
428
- {
429
- label: 'warning',
430
- value: 65
431
- }
432
- ]
433
- }
434
- },
435
- render: (args) => (
436
- <WrapperLineChart
437
- {...args}
438
- data={dataLastDay as unknown as LineChartData}
439
- />
440
- )
441
- };
442
-
443
- export const thresholdsRange: Story = {
444
- argTypes,
445
- args: {
446
- ...argumentsData,
447
- thresholdUnit: '%',
448
- thresholds: {
449
- critical: [
450
- {
451
- label: 'critical 1',
452
- value: 60
453
- },
454
- {
455
- label: 'critical 2',
456
- value: 79
457
- }
458
- ],
459
- enabled: true,
460
- warning: [
461
- {
462
- label: 'warning 1',
463
- value: 20
464
- },
465
- {
466
- label: 'warning 2',
467
- value: 30
468
- }
469
- ]
470
- }
471
- },
472
- render: (args) => (
473
- <WrapperLineChart
474
- {...args}
475
- data={dataLastDay as unknown as LineChartData}
476
- />
477
- )
478
- };
@@ -10,7 +10,7 @@ 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 { LineChartData, Thresholds } from '../common/models';
13
+ import { LineChartData } from '../common/models';
14
14
 
15
15
  import LineChart from './LineChart';
16
16
  import LoadingSkeleton from './LoadingSkeleton';
@@ -31,8 +31,6 @@ interface Props extends Partial<LineChartProps> {
31
31
  marginBottom?: number;
32
32
  shapeLines?: GlobalAreaLines;
33
33
  start: string;
34
- thresholdUnit?: string;
35
- thresholds?: Thresholds;
36
34
  }
37
35
 
38
36
  const WrapperLineChart = ({
@@ -52,14 +50,12 @@ const WrapperLineChart = ({
52
50
  legend,
53
51
  header,
54
52
  curve = Curve.curveLinear,
55
- marginBottom = 0,
56
- thresholds,
57
- thresholdUnit
53
+ marginBottom = 0
58
54
  }: Props): JSX.Element | null => {
59
55
  const { adjustedData } = useLineChartData({ data, end, start });
60
56
  const lineChartRef = useRef<HTMLDivElement | null>(null);
61
57
 
62
- if (loading && !adjustedData) {
58
+ if (loading || !adjustedData) {
63
59
  return (
64
60
  <LoadingSkeleton
65
61
  displayTitleSkeleton={header?.displayTitle ?? true}
@@ -68,10 +64,6 @@ const WrapperLineChart = ({
68
64
  );
69
65
  }
70
66
 
71
- if (!adjustedData) {
72
- return null;
73
- }
74
-
75
67
  return (
76
68
  <div
77
69
  ref={lineChartRef as MutableRefObject<HTMLDivElement>}
@@ -97,8 +89,6 @@ const WrapperLineChart = ({
97
89
  loading={loading}
98
90
  marginBottom={marginBottom}
99
91
  shapeLines={shapeLines}
100
- thresholdUnit={thresholdUnit}
101
- thresholds={thresholds}
102
92
  timeShiftZones={timeShiftZones}
103
93
  tooltip={tooltip}
104
94
  width={width ?? responsiveWidth}
@@ -2,7 +2,7 @@ import { useMemo, useRef } from 'react';
2
2
 
3
3
  import { Group, Tooltip } from '@visx/visx';
4
4
  import { scaleLinear } from '@visx/scale';
5
- import { flatten, head, pluck } from 'ramda';
5
+ import { head } from 'ramda';
6
6
  import { Bar } from '@visx/shape';
7
7
  import { useSpring, animated } from '@react-spring/web';
8
8
 
@@ -17,8 +17,7 @@ import { getColorFromDataAndTresholds } from '../common/utils';
17
17
  import { margins } from '../common/margins';
18
18
 
19
19
  import { SingleBarProps } from './models';
20
- import Thresholds, { groupMargin } from './Thresholds';
21
- import { barHeight, margin } from './ThresholdLine';
20
+ import Thresholds, { barHeight, groupMargin, margin } from './Thresholds';
22
21
 
23
22
  interface Props extends SingleBarProps {
24
23
  height: number;
@@ -32,21 +31,19 @@ const baseStyles = {
32
31
 
33
32
  const ResponsiveSingleBar = ({
34
33
  data,
34
+ thresholdTooltipLabels,
35
35
  thresholds,
36
36
  width,
37
- height
37
+ height,
38
+ disabledThresholds
38
39
  }: Props): JSX.Element => {
39
40
  const theme = useTheme();
40
41
 
41
42
  const metric = getMetricWithLatestData(data) as Metric;
42
43
  const latestMetricData = head(metric.data) as number;
43
- const thresholdValues = flatten([
44
- pluck('value', thresholds.warning),
45
- pluck('value', thresholds.critical)
46
- ]);
47
44
  const adaptedMaxValue = Math.max(
48
45
  metric.maximum_value || 0,
49
- Math.max(...thresholdValues) * 1.1,
46
+ Math.max(...thresholds) * 1.1,
50
47
  head(metric.data) as number
51
48
  );
52
49
 
@@ -134,10 +131,11 @@ const ResponsiveSingleBar = ({
134
131
  x={0}
135
132
  y={groupMargin + margin}
136
133
  />
137
- {thresholds.enabled && (
134
+ {!disabledThresholds && (
138
135
  <Thresholds
139
136
  hideTooltip={hideTooltip}
140
137
  showTooltip={showTooltip}
138
+ thresholdTooltipLabels={thresholdTooltipLabels}
141
139
  thresholds={thresholds}
142
140
  xScale={xScale}
143
141
  />