@centreon/ui 24.9.5 → 24.10.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.9.5",
3
+ "version": "24.10.0",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -4,6 +4,7 @@ import { useAtomValue } from 'jotai';
4
4
 
5
5
  import { userAtom } from '@centreon/ui-context';
6
6
 
7
+ import dataLastWeek from '../mockedData/lastWeek.json';
7
8
  import dataPingService from '../mockedData/pingService.json';
8
9
  import dataPingServiceMixedStacked from '../mockedData/pingServiceMixedStacked.json';
9
10
  import dataPingServiceStacked from '../mockedData/pingServiceStacked.json';
@@ -29,10 +30,10 @@ const initialize = ({
29
30
  tooltip,
30
31
  axis,
31
32
  orientation,
32
- barStyle
33
+ barStyle,
33
34
  }: Pick<
34
35
  BarChartProps,
35
- 'data' | 'legend' | 'axis' | 'barStyle' | 'orientation' | 'tooltip'
36
+ 'data' | 'legend' | 'axis' | 'barStyle' | 'orientation' | 'tooltip' | 'start'
36
37
  >): void => {
37
38
  cy.adjustViewport();
38
39
 
@@ -280,4 +281,14 @@ describe('Bar chart', () => {
280
281
 
281
282
  cy.makeSnapshot();
282
283
  });
284
+
285
+ it('displays the bottom axis correctly when data starts from several days ago', () => {
286
+ initialize({
287
+ data: dataLastWeek,
288
+ orientation: 'horizontal'
289
+ });
290
+
291
+ cy.contains('05/31/2023').should('be.visible');
292
+ cy.contains('06/07/2023').should('be.visible');
293
+ });
283
294
  });
@@ -1,6 +1,6 @@
1
1
  import { Axis } from '@visx/visx';
2
2
  import { ScaleLinear } from 'd3-scale';
3
- import { equals, isNil } from 'ramda';
3
+ import { equals, head, isNil, last } from 'ramda';
4
4
 
5
5
  import { useLocaleDateTimeFormat } from '@centreon/ui';
6
6
 
@@ -48,7 +48,10 @@ const Axes = ({
48
48
 
49
49
  const xTickCount = Math.min(Math.ceil(width / 82), 12);
50
50
 
51
- const [start, end] = xScale.domain();
51
+ const domain = xScale.domain();
52
+
53
+ const start = head(domain);
54
+ const end = last(domain);
52
55
 
53
56
  const tickFormat =
54
57
  data?.axisX?.xAxisTickFormat ?? getXAxisTickFormat({ end, start });