@centreon/ui 24.7.0 → 24.7.2

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 (42) hide show
  1. package/package.json +66 -85
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/Graph/BarChart/BarChart.cypress.spec.tsx +85 -2
  4. package/src/Graph/BarChart/BarStack.tsx +8 -6
  5. package/src/Graph/BarChart/SingleBar.tsx +2 -2
  6. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +3 -3
  7. package/src/Graph/LineChart/Icons/Downtime.tsx +1 -1
  8. package/src/Graph/LineChart/LineChart.tsx +2 -0
  9. package/src/Graph/LineChart/helpers/index.ts +3 -0
  10. package/src/Graph/LineChart/index.tsx +2 -1
  11. package/src/Graph/LineChart/models.ts +1 -0
  12. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -4
  13. package/src/Graph/common/Axes/index.tsx +3 -5
  14. package/src/Graph/common/BaseChart/BaseChart.tsx +5 -1
  15. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +2 -2
  16. package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +7 -2
  17. package/src/Graph/index.ts +5 -0
  18. package/src/{Home.stories.mdx → Home.mdx} +41 -39
  19. package/src/Image/index.stories.tsx +101 -101
  20. package/src/RichTextEditor/index.stories.tsx +102 -102
  21. package/src/ThemeProvider/index.tsx +5 -4
  22. package/src/TimePeriods/DateTimePickerInput.tsx +1 -1
  23. package/src/TimePeriods/index.tsx +10 -2
  24. package/src/TimePeriods/models.ts +1 -0
  25. package/src/Typography/FluidTypography/index.stories.tsx +63 -63
  26. package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
  27. package/src/index.ts +0 -2
  28. package/test/setupTests.js +1 -0
  29. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +0 -60
  30. package/src/Listing/index.test.tsx +0 -234
  31. /package/{public → src}/fonts/roboto-bold-webfont.ttf +0 -0
  32. /package/{public → src}/fonts/roboto-bold-webfont.woff +0 -0
  33. /package/{public → src}/fonts/roboto-bold-webfont.woff2 +0 -0
  34. /package/{public → src}/fonts/roboto-light-webfont.ttf +0 -0
  35. /package/{public → src}/fonts/roboto-light-webfont.woff +0 -0
  36. /package/{public → src}/fonts/roboto-light-webfont.woff2 +0 -0
  37. /package/{public → src}/fonts/roboto-medium-webfont.ttf +0 -0
  38. /package/{public → src}/fonts/roboto-medium-webfont.woff +0 -0
  39. /package/{public → src}/fonts/roboto-medium-webfont.woff2 +0 -0
  40. /package/{public → src}/fonts/roboto-regular-webfont.ttf +0 -0
  41. /package/{public → src}/fonts/roboto-regular-webfont.woff +0 -0
  42. /package/{public → src}/fonts/roboto-regular-webfont.woff2 +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.7.0",
3
+ "version": "24.7.2",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -30,7 +30,7 @@
30
30
  "name": "centreon@centreon.com"
31
31
  },
32
32
  "baseCodeCoveragePercentage": 60,
33
- "license": "GPL-2.0",
33
+ "license": "MIT",
34
34
  "bugs": {
35
35
  "url": "https://github.com/centreon/centreon/issues"
36
36
  },
@@ -39,7 +39,7 @@
39
39
  "exports": {
40
40
  ".": "./src/index.ts",
41
41
  "./components": "./src/components/index.ts",
42
- "./fonts/*": "./public/fonts/*",
42
+ "./fonts/*": "./src/fonts/*",
43
43
  "./test/testRenderer": "./test/testRenderer.tsx"
44
44
  },
45
45
  "files": [
@@ -49,123 +49,104 @@
49
49
  "test/*"
50
50
  ],
51
51
  "devDependencies": {
52
- "@cypress/react": "^8.0.0",
53
- "@cypress/webpack-dev-server": "^3.7.4",
52
+ "@cypress/react": "^8.0.2",
53
+ "@cypress/webpack-dev-server": "^3.10.0",
54
54
  "@faker-js/faker": "^8.4.1",
55
55
  "@mdx-js/react": "^3.0.1",
56
- "@modern-js/prod-server": "^2.49.2",
57
- "@modern-js/storybook": "^2.49.2",
58
- "@simonsmith/cypress-image-snapshot": "^9.0.1",
59
- "@storybook/addon-a11y": "^7.0.9",
60
- "@storybook/addon-docs": "^7.0.9",
61
- "@storybook/addon-essentials": "^7.0.9",
62
- "@storybook/addon-interactions": "^7.0.9",
63
- "@storybook/addon-styling": "^1.0.6",
64
- "@storybook/blocks": "^7.0.26",
65
- "@storybook/builder-vite": "^7.6.18",
66
- "@storybook/jest": "^0.1.0",
67
- "@storybook/manager-api": "^7.0.9",
56
+ "@modern-js/prod-server": "^2.54.5",
57
+ "@modern-js/storybook": "^2.54.5",
58
+ "@simonsmith/cypress-image-snapshot": "^9.0.3",
59
+ "@storybook/addon-a11y": "^8.1.11",
60
+ "@storybook/addon-docs": "^8.1.11",
61
+ "@storybook/addon-essentials": "^8.1.11",
62
+ "@storybook/addon-interactions": "^8.1.11",
63
+ "@storybook/addon-themes": "^8.1.11",
64
+ "@storybook/blocks": "^8.1.11",
65
+ "@storybook/manager-api": "^8.1.11",
68
66
  "@storybook/mdx2-csf": "^1.1.0",
69
- "@storybook/preview-api": "^7.0.9",
70
- "@storybook/react": "^7.0.9",
71
- "@storybook/react-vite": "^7.0.9",
72
- "@storybook/test-runner": "^0.16.0",
73
- "@storybook/testing-library": "^0.1.0",
74
- "@storybook/theming": "^7.0.9",
75
- "@testing-library/cypress": "^8.0.7",
76
- "@testing-library/jest-dom": "^5.16.5",
77
- "@testing-library/react": "^13.4.0",
67
+ "@storybook/preview-api": "^8.1.11",
68
+ "@storybook/react": "^8.1.11",
69
+ "@storybook/react-vite": "^8.1.11",
70
+ "@storybook/test": "^8.1.11",
71
+ "@storybook/test-runner": "^0.19.0",
72
+ "@storybook/theming": "^8.1.11",
73
+ "@testing-library/cypress": "^10.0.2",
74
+ "@testing-library/jest-dom": "^6.4.6",
75
+ "@testing-library/react": "^16.0.0",
78
76
  "@testing-library/react-hooks": "^8.0.1",
79
77
  "@types/jest": "^29.5.12",
80
- "@types/mocha": "^10.0.6",
81
- "@types/ramda": "^0.29.9",
82
- "@types/react": "^18.2.65",
78
+ "@types/mocha": "^10.0.7",
79
+ "@types/ramda": "^0.30.0",
80
+ "@types/react": "^18.3.3",
83
81
  "@types/testing-library__jest-dom": "^6.0.0",
84
- "@vitejs/plugin-react": "^4.2.1",
85
- "@vitejs/plugin-react-swc": "^3.6.0",
82
+ "@vitejs/plugin-react": "^4.3.1",
83
+ "@vitejs/plugin-react-swc": "^3.7.0",
86
84
  "axios-mock-adapter": "^1.22.0",
87
- "cypress": "^13.7.1",
85
+ "chai": "^5.1.1",
86
+ "cypress": "^13.13.0",
88
87
  "identity-obj-proxy": "^3.0.0",
89
88
  "jest-transform-stub": "^2.0.0",
90
89
  "mochawesome": "^7.1.3",
91
- "msw": "1.3.2",
92
- "msw-storybook-addon": "^1.10.0",
93
- "puppeteer": "^13.7.0",
94
- "react": "^18.2.0",
95
- "react-dom": "^18.2.0",
96
- "react-test-renderer": "^18.2.0",
97
- "remark-gfm": "^3.0.1",
98
- "speed-measure-vite-plugin": "^0.1.2",
99
- "storybook": "^7.6.8",
100
- "storybook-addon-mock": "^4.3.0",
101
- "storybook-dark-mode": "^3.0.3",
102
- "style-dictionary": "^3.9.2",
90
+ "msw": "2.3.1",
91
+ "msw-storybook-addon": "^2.0.2",
92
+ "puppeteer": "^22.12.1",
93
+ "react": "^18.3.1",
94
+ "react-dom": "^18.3.1",
95
+ "react-test-renderer": "^18.3.1",
96
+ "remark-gfm": "^4.0.0",
97
+ "speed-measure-vite-plugin": "^1.0.1",
98
+ "storybook": "^8.1.11",
99
+ "storybook-addon-mock": "^5.0.0",
100
+ "storybook-dark-mode": "^4.0.2",
101
+ "style-dictionary": "^4.0.0",
103
102
  "ts-node": "^10.9.2",
104
103
  "use-resize-observer": "^9.1.0",
105
- "vite": "^4.3.5",
106
- "vite-plugin-istanbul": "^5.0.0",
107
- "vite-plugin-svgr": "^3.3.0",
104
+ "vite": "^5.3.3",
105
+ "vite-plugin-istanbul": "^6.0.2",
106
+ "vite-plugin-svgr": "^4.2.0",
108
107
  "vite-plugin-turbosnap": "^1.0.3"
109
108
  },
110
109
  "dependencies": {
111
- "@lexical/html": "^0.12.6",
112
- "@lexical/link": "^0.12.6",
113
- "@lexical/list": "^0.12.6",
114
- "@lexical/react": "^0.12.6",
115
- "@lexical/rich-text": "^0.12.6",
116
- "@lexical/selection": "^0.12.6",
117
- "@lexical/utils": "^0.12.6",
110
+ "@centreon/ui-context": "file:../ui-context",
111
+ "@lexical/html": "^0.16.1",
112
+ "@lexical/link": "^0.16.1",
113
+ "@lexical/list": "^0.16.1",
114
+ "@lexical/react": "^0.16.1",
115
+ "@lexical/rich-text": "^0.16.1",
116
+ "@lexical/selection": "^0.16.1",
117
+ "@lexical/utils": "^0.16.1",
118
+ "@mui/material": "^5.15.21",
118
119
  "@react-spring/web": "^9.7.3",
119
120
  "@visx/clip-path": "^3.3.0",
120
- "@visx/curve": "^2.1.0",
121
+ "@visx/curve": "^3.3.0",
121
122
  "@visx/event": "^3.3.0",
122
123
  "@visx/group": "^3.3.0",
123
124
  "@visx/hierarchy": "^3.3.0",
124
- "@visx/legend": "^3.5.0",
125
+ "@visx/legend": "^3.10.3",
125
126
  "@visx/pattern": "^3.3.0",
126
127
  "@visx/point": "^3.3.0",
127
128
  "@visx/scale": "^3.5.0",
128
- "@visx/shape": "^2.18.0",
129
+ "@visx/shape": "^3.5.0",
129
130
  "@visx/text": "^3.3.0",
130
- "@visx/threshold": "^2.12.2",
131
- "@visx/visx": "2.16.0",
131
+ "@visx/threshold": "^3.5.0",
132
+ "@visx/visx": "3.11.0",
132
133
  "@visx/zoom": "^3.3.0",
133
134
  "anylogger": "^1.0.11",
134
135
  "d3-array": "3.2.4",
135
- "humanize-duration": "^3.31.0",
136
- "lexical": "^0.12.6",
136
+ "dayjs": "^1.11.11",
137
+ "humanize-duration": "^3.32.1",
138
+ "lexical": "^0.16.1",
137
139
  "notistack": "^3.0.1",
138
140
  "numeral": "^2.0.6",
139
- "ramda": "0.29.1",
141
+ "ramda": "0.30.1",
140
142
  "react-grid-layout": "^1.4.4",
141
143
  "react-html-parser": "^2.0.2",
142
144
  "react-resizable": "^3.0.5",
145
+ "react-router-dom": "^6.24.0",
143
146
  "react-transition-group": "^4.4.5",
144
- "sanitize-html": "^2.12.1",
147
+ "sanitize-html": "^2.13.0",
145
148
  "ulog": "^2.0.0-beta.19"
146
149
  },
147
- "peerDependencies": {
148
- "@centreon/ui-context": "file:../ui-context",
149
- "@dnd-kit/core": "6.x",
150
- "@dnd-kit/sortable": "6.x",
151
- "@dnd-kit/utilities": "3.x",
152
- "@mui/icons-material": "5.x",
153
- "@mui/material": "5.x",
154
- "@mui/styles": "5.x",
155
- "@tanstack/react-query": "5.x",
156
- "axios": ">= 1.6.4",
157
- "dayjs": "1.x",
158
- "formik": "2.x",
159
- "jotai": "2.x",
160
- "numeral": "2.x",
161
- "ramda": "0.x",
162
- "react-i18next": "12.x",
163
- "react-router-dom": "6.x",
164
- "react-scale-text": "1.x",
165
- "resize-observer-polyfill": "1.x",
166
- "ts.data.json": "2.x",
167
- "tss-react": "4.x"
168
- },
169
150
  "jest-junit": {
170
151
  "suiteName": "jest tests",
171
152
  "output": "./junit.xml"
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.2.14'
11
+ const PACKAGE_VERSION = '2.3.1'
12
12
  const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
@@ -1,4 +1,5 @@
1
1
  import dayjs from 'dayjs';
2
+ import { equals } from 'ramda';
2
3
 
3
4
  import dataPingService from '../mockedData/pingService.json';
4
5
  import dataPingServiceStacked from '../mockedData/pingServiceStacked.json';
@@ -56,6 +57,16 @@ describe('Bar chart', () => {
56
57
  cy.contains('20').should('be.visible');
57
58
  cy.contains(':40 AM').should('be.visible');
58
59
 
60
+ if (equals(orientation, 'horizontal')) {
61
+ cy.findByTestId('single-bar-3-2-0.08644')
62
+ .should('have.attr', 'height')
63
+ .should('equals', '295');
64
+ } else {
65
+ cy.findByTestId('single-bar-3-2-0.08644')
66
+ .should('have.attr', 'width')
67
+ .should('equals', '863');
68
+ }
69
+
59
70
  cy.makeSnapshot();
60
71
  });
61
72
 
@@ -66,6 +77,16 @@ describe('Bar chart', () => {
66
77
  cy.contains('20').should('be.visible');
67
78
  cy.contains(':40 AM').should('be.visible');
68
79
 
80
+ if (equals(orientation, 'horizontal')) {
81
+ cy.findByTestId('single-bar-3-2-0.08644')
82
+ .should('have.attr', 'height')
83
+ .should('equals', '171');
84
+ } else {
85
+ cy.findByTestId('single-bar-3-2-0.08644')
86
+ .should('have.attr', 'width')
87
+ .should('equals', '432');
88
+ }
89
+
69
90
  cy.makeSnapshot();
70
91
  });
71
92
 
@@ -76,6 +97,16 @@ describe('Bar chart', () => {
76
97
  cy.contains('20').should('be.visible');
77
98
  cy.contains(':40 AM').should('be.visible');
78
99
 
100
+ if (equals(orientation, 'horizontal')) {
101
+ cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
102
+ .should('have.attr', 'height')
103
+ .should('equals', '187');
104
+ } else {
105
+ cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
106
+ .should('have.attr', 'width')
107
+ .should('equals', '546');
108
+ }
109
+
79
110
  cy.makeSnapshot();
80
111
  });
81
112
 
@@ -86,6 +117,16 @@ describe('Bar chart', () => {
86
117
  cy.contains('20').should('be.visible');
87
118
  cy.contains(':40 AM').should('be.visible');
88
119
 
120
+ if (equals(orientation, 'horizontal')) {
121
+ cy.findByTestId('stacked-bar-3-0-0.08644')
122
+ .should('have.attr', 'height')
123
+ .should('equals', '265');
124
+ } else {
125
+ cy.findByTestId('stacked-bar-3-0-0.08644')
126
+ .should('have.attr', 'width')
127
+ .should('equals', '773');
128
+ }
129
+
89
130
  cy.makeSnapshot();
90
131
  });
91
132
 
@@ -100,6 +141,16 @@ describe('Bar chart', () => {
100
141
  cy.contains('20').should('be.visible');
101
142
  cy.contains(':40 AM').should('be.visible');
102
143
 
144
+ if (equals(orientation, 'horizontal')) {
145
+ cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
146
+ .should('have.attr', 'height')
147
+ .should('equals', '94');
148
+ } else {
149
+ cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
150
+ .should('have.attr', 'width')
151
+ .should('equals', '273');
152
+ }
153
+
103
154
  cy.makeSnapshot();
104
155
  });
105
156
 
@@ -114,7 +165,15 @@ describe('Bar chart', () => {
114
165
  cy.contains('20').should('be.visible');
115
166
  cy.contains(':40 AM').should('be.visible');
116
167
 
117
- cy.makeSnapshot();
168
+ if (equals(orientation, 'horizontal')) {
169
+ cy.findByTestId('stacked-bar-3-0-0.08644')
170
+ .should('have.attr', 'height')
171
+ .should('equals', '133');
172
+ } else {
173
+ cy.findByTestId('stacked-bar-3-0-0.08644')
174
+ .should('have.attr', 'width')
175
+ .should('equals', '387');
176
+ }
118
177
  });
119
178
 
120
179
  it(`displays bar chart ${orientation}ly with a custom style`, () => {
@@ -128,7 +187,15 @@ describe('Bar chart', () => {
128
187
  cy.contains('20').should('be.visible');
129
188
  cy.contains(':40 AM').should('be.visible');
130
189
 
131
- cy.makeSnapshot();
190
+ if (equals(orientation, 'horizontal')) {
191
+ cy.findByTestId('stacked-bar-3-0-0.08644')
192
+ .should('have.attr', 'height')
193
+ .should('equals', '265');
194
+ } else {
195
+ cy.findByTestId('stacked-bar-3-0-0.08644')
196
+ .should('have.attr', 'width')
197
+ .should('equals', '773');
198
+ }
132
199
  });
133
200
  });
134
201
 
@@ -149,6 +216,10 @@ describe('Bar chart', () => {
149
216
  );
150
217
  cy.contains('0.11 ms').should('be.visible');
151
218
 
219
+ cy.findByTestId('single-bar-3-2-0.08644')
220
+ .should('have.attr', 'height')
221
+ .should('equals', '295');
222
+
152
223
  cy.makeSnapshot();
153
224
  });
154
225
 
@@ -170,6 +241,10 @@ describe('Bar chart', () => {
170
241
 
171
242
  cy.contains('06/19/2024').should('not.exist');
172
243
 
244
+ cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
245
+ .should('have.attr', 'height')
246
+ .should('equals', '187');
247
+
173
248
  cy.makeSnapshot();
174
249
  });
175
250
 
@@ -203,6 +278,10 @@ describe('Bar chart', () => {
203
278
  cy.contains('0.02 ms').should('be.visible');
204
279
  cy.contains('0.11 ms').should('be.visible');
205
280
 
281
+ cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
282
+ .should('have.attr', 'height')
283
+ .should('equals', '187');
284
+
206
285
  cy.makeSnapshot();
207
286
  });
208
287
 
@@ -228,6 +307,10 @@ describe('Bar chart', () => {
228
307
  );
229
308
  cy.contains('0.05 ms').should('be.visible');
230
309
 
310
+ cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
311
+ .should('have.attr', 'height')
312
+ .should('equals', '187');
313
+
231
314
  cy.makeSnapshot();
232
315
  });
233
316
  });
@@ -64,11 +64,13 @@ const BarStack = ({
64
64
  <rect
65
65
  data-testid={`stacked-bar-${bar.key}-${bar.index}-${bar.bar[1]}`}
66
66
  fill={bar.color}
67
- height={isHorizontal ? Math.abs(bar.height) : barWidth}
67
+ height={Math.ceil(
68
+ isHorizontal ? Math.abs(bar.height) : barWidth
69
+ )}
68
70
  key={`bar-stack-${barStack.index}-${bar.index}`}
69
71
  opacity={barStyle.opacity}
70
- width={isHorizontal ? barWidth : Math.abs(bar.width)}
71
- x={
72
+ width={Math.ceil(isHorizontal ? barWidth : Math.abs(bar.width))}
73
+ x={Math.ceil(
72
74
  isHorizontal
73
75
  ? barPadding
74
76
  : getPadding({
@@ -76,8 +78,8 @@ const BarStack = ({
76
78
  padding: bar.x,
77
79
  size: bar.width
78
80
  })
79
- }
80
- y={
81
+ )}
82
+ y={Math.ceil(
81
83
  isHorizontal
82
84
  ? getPadding({
83
85
  isNegativeValue,
@@ -85,7 +87,7 @@ const BarStack = ({
85
87
  size: bar.height
86
88
  })
87
89
  : barPadding
88
- }
90
+ )}
89
91
  onMouseEnter={
90
92
  isTooltipHidden
91
93
  ? undefined
@@ -35,10 +35,10 @@ const SingleBar = ({
35
35
  <rect
36
36
  data-testid={`single-bar-${bar.key}-${bar.index}-${bar.value}`}
37
37
  fill={bar.color}
38
- height={isHorizontal ? barLength : bar.height}
38
+ height={Math.ceil(isHorizontal ? barLength : bar.height)}
39
39
  opacity={barStyle.opacity}
40
40
  rx={(isHorizontal ? bar.width : bar.height) * barStyle.radius}
41
- width={isHorizontal ? bar.width : barLength}
41
+ width={Math.ceil(isHorizontal ? bar.width : barLength)}
42
42
  x={isHorizontal ? bar.x : barPadding}
43
43
  y={isHorizontal ? barPadding : bar.y}
44
44
  {...listeners}
@@ -55,14 +55,14 @@ const WrapperThresholdLines = ({
55
55
  };
56
56
 
57
57
  const thresholdLines = areaThresholdLines?.map((item, index) => {
58
- const { type } = item;
58
+ const { type, id } = item;
59
59
 
60
60
  if (equals(type, ThresholdType.basic)) {
61
61
  return [
62
62
  {
63
63
  Component: BasicThreshold,
64
64
  key: index,
65
- props: { ...commonProps, getY0, getY1 }
65
+ props: { ...commonProps, getY0, getY1, id }
66
66
  }
67
67
  ];
68
68
  }
@@ -131,7 +131,7 @@ const WrapperThresholdLines = ({
131
131
  <g>
132
132
  {filteredThresholdLines.map((element) =>
133
133
  element?.map(({ Component, props, key }) => (
134
- <Component {...props} id={key} key={key} />
134
+ <Component {...props} id={props?.id ?? key} key={key} />
135
135
  ))
136
136
  )}
137
137
  </g>
@@ -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 IconDowntime from '../../../@assets/icons/downtime.icon.svg';
4
4
 
5
5
  const Downtime = (props: SvgIconProps): JSX.Element => (
6
6
  <SvgIcon component={IconDowntime} {...props} />
@@ -123,6 +123,7 @@ const LineChart = ({
123
123
  hasSecondUnit: Boolean(secondUnit),
124
124
  height,
125
125
  legendDisplay: legend?.display,
126
+ legendHeight: legend?.height,
126
127
  legendPlacement: legend?.placement,
127
128
  width
128
129
  });
@@ -229,6 +230,7 @@ const LineChart = ({
229
230
  height={height}
230
231
  legend={{
231
232
  displayLegend,
233
+ legendHeight: legend?.height,
232
234
  mode: legend?.mode,
233
235
  placement: legend?.placement,
234
236
  renderExtraComponent: legend?.renderExtraComponent
@@ -1,5 +1,6 @@
1
1
  import dayjs from 'dayjs';
2
2
  import { gt, gte, isEmpty, isNil, prop, propEq, reject, sortBy } from 'ramda';
3
+ import durationPlugin from 'dayjs/plugin/duration';
3
4
 
4
5
  import { LinesData } from '../BasicComponents/Lines/models';
5
6
  import { dateFormat, timeFormat } from '../common';
@@ -11,6 +12,8 @@ import {
11
12
  } from '../../common/timeSeries';
12
13
  import { LineChartData } from '../../common/models';
13
14
 
15
+ dayjs.extend(durationPlugin);
16
+
14
17
  export const adjustGraphData = (graphData: LineChartData): LinesData => {
15
18
  const lines = getLineData(graphData);
16
19
  const sortedLines = sortBy(prop('name'), lines);
@@ -11,6 +11,7 @@ import utcPlugin from 'dayjs/plugin/utc';
11
11
 
12
12
  import { ParentSize } from '../..';
13
13
  import { LineChartData, Thresholds } from '../common/models';
14
+ import Loading from '../../LoadingSkeleton';
14
15
 
15
16
  import LineChart from './LineChart';
16
17
  import LoadingSkeleton from './LoadingSkeleton';
@@ -73,7 +74,7 @@ const WrapperLineChart = ({
73
74
  }
74
75
 
75
76
  if (!adjustedData) {
76
- return null;
77
+ return <Loading height={height} width={width} />;
77
78
  }
78
79
 
79
80
  return (
@@ -154,6 +154,7 @@ export interface GlobalAreaLines {
154
154
  }
155
155
  export interface LegendModel {
156
156
  display?: boolean;
157
+ height?: number;
157
158
  mode: 'grid' | 'list';
158
159
  placement: 'bottom' | 'left' | 'right';
159
160
  renderExtraComponent?: ReactNode;
@@ -72,8 +72,6 @@ describe('Pie chart', () => {
72
72
  it('renders as a pie when variant is set to "pie"', () => {
73
73
  initialize({ variant: 'pie' });
74
74
  cy.get('[data-variant="pie"]').should('exist');
75
-
76
- cy.makeSnapshot();
77
75
  });
78
76
 
79
77
  it('displays tooltip with correct information on hover', () => {
@@ -134,8 +132,6 @@ describe('Pie chart', () => {
134
132
 
135
133
  initialize({});
136
134
  cy.findByTestId('Title').should('not.exist');
137
-
138
- cy.makeSnapshot();
139
135
  });
140
136
 
141
137
  it('adjusts outer radius when chart dimensions are too small', () => {
@@ -45,12 +45,10 @@ const Axes = ({
45
45
 
46
46
  const xTickCount = Math.min(Math.ceil(width / 82), 12);
47
47
 
48
+ const [start, end] = xScale.domain();
49
+
48
50
  const tickFormat =
49
- data?.axisX?.xAxisTickFormat ??
50
- getXAxisTickFormat({
51
- start: xScale.domain()[0],
52
- start: xScale.domain()[-1]
53
- });
51
+ data?.axisX?.xAxisTickFormat ?? getXAxisTickFormat({ end, start });
54
52
 
55
53
  const formatAxisTick = (tick): string =>
56
54
  format({ date: new Date(tick), formatString: tickFormat });
@@ -27,6 +27,7 @@ interface Props {
27
27
  isHorizontal?: boolean;
28
28
  legend: {
29
29
  displayLegend: boolean;
30
+ legendHeight?: number;
30
31
  mode?: 'grid' | 'list';
31
32
  placement?: 'left' | 'right' | 'bottom';
32
33
  renderExtraComponent?: ReactNode;
@@ -112,7 +113,10 @@ const BaseChart = ({
112
113
  </Stack>
113
114
  </div>
114
115
  {legend.displayLegend && displayLegendInBottom && (
115
- <div ref={legendRef}>
116
+ <div
117
+ ref={legendRef}
118
+ style={{ height: legend?.legendHeight ?? 'undefined' }}
119
+ >
116
120
  <Legend
117
121
  base={base}
118
122
  height={height}
@@ -4,10 +4,10 @@ import { Group } from '@visx/visx';
4
4
  import { equals } from 'ramda';
5
5
 
6
6
  import { margin } from '../../LineChart/common';
7
- import Grids from '../Grids';
7
+ import { LineChartAxis } from '../../LineChart/models';
8
8
  import Axes from '../Axes';
9
+ import Grids from '../Grids';
9
10
  import { Line, TimeValue } from '../timeSeries/models';
10
- import { LineChartAxis } from '../../LineChart/models';
11
11
 
12
12
  import { extraMargin } from './useComputeBaseChartDimensions';
13
13
 
@@ -10,6 +10,7 @@ interface UseComputeBaseChartDimensionsProps {
10
10
  hasSecondUnit?: boolean;
11
11
  height: number | null;
12
12
  legendDisplay?: boolean;
13
+ legendHeight?: number;
13
14
  legendPlacement?: string;
14
15
  width: number;
15
16
  }
@@ -25,14 +26,18 @@ export const useComputeBaseChartDimensions = ({
25
26
  height,
26
27
  legendDisplay,
27
28
  legendPlacement,
28
- hasSecondUnit
29
+ hasSecondUnit,
30
+ legendHeight
29
31
  }: UseComputeBaseChartDimensionsProps): UseComputeBaseChartDimensionsState => {
30
32
  const legendRef = useRef<HTMLDivElement | null>(null);
31
33
 
34
+ const currentLegendHeight =
35
+ legendHeight ?? (legendRef.current?.getBoundingClientRect().height || 0);
36
+
32
37
  const legendBoundingHeight =
33
38
  !equals(legendDisplay, false) &&
34
39
  (isNil(legendPlacement) || equals(legendPlacement, 'bottom'))
35
- ? legendRef.current?.getBoundingClientRect().height || 0
40
+ ? currentLegendHeight
36
41
  : 0;
37
42
  const legendBoundingWidth =
38
43
  !equals(legendDisplay, false) &&
@@ -1,4 +1,6 @@
1
1
  export { default as LineChart } from './LineChart';
2
+ export { default as ThresholdLines } from './LineChart/BasicComponents/Lines/Threshold';
3
+ export { default as useLineChartData } from './LineChart/useLineChartData';
2
4
  export { default as BarChart } from './BarChart/BarChart';
3
5
  export { Gauge } from './Gauge';
4
6
  export { SingleBar } from './SingleBar';
@@ -8,3 +10,6 @@ export { HeatMap } from './HeatMap';
8
10
  export { BarStack } from './BarStack';
9
11
  export { PieChart } from './PieChart';
10
12
  export * from './Tree';
13
+ export type { LineChartData } from './common/models';
14
+ export * from './common/timeSeries';
15
+ export * from './LineChart/models';