@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.
- package/package.json +14 -17
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +38 -79
- package/src/Graph/BarChart/BarChart.tsx +4 -4
- package/src/Graph/BarChart/BarGroup.tsx +81 -92
- package/src/Graph/BarChart/BarStack.tsx +21 -13
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +26 -50
- package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +1 -1
- package/src/Graph/BarChart/useBarStack.ts +1 -1
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Point.tsx +1 -1
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +67 -0
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +4 -7
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/index.tsx +6 -9
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/models.ts +1 -2
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useScaleThreshold.ts +8 -20
- package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/index.tsx +64 -43
- package/src/Graph/{LineChart/LineChart.cypress.spec.tsx → Chart/Chart.cypress.spec.tsx} +272 -23
- package/src/Graph/{LineChart/index.stories.tsx → Chart/Chart.stories.tsx} +217 -24
- package/src/Graph/{LineChart/LineChart.styles.ts → Chart/Chart.styles.ts} +1 -1
- package/src/Graph/{LineChart/LineChart.tsx → Chart/Chart.tsx} +84 -100
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -1
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +6 -1
- package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +61 -0
- package/src/Graph/{LineChart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx → Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltipContent.tsx} +2 -2
- package/src/Graph/{LineChart → Chart}/InteractiveComponents/index.tsx +11 -15
- package/src/Graph/{LineChart → Chart}/Legend/Legend.styles.ts +1 -7
- package/src/Graph/{LineChart → Chart}/Legend/LegendHeader.tsx +9 -5
- package/src/Graph/{LineChart → Chart}/Legend/index.tsx +2 -1
- package/src/Graph/Chart/graphAtoms.ts +6 -0
- package/src/Graph/{LineChart → Chart}/index.tsx +10 -7
- package/src/Graph/{LineChart → Chart}/models.ts +8 -3
- package/src/Graph/common/Axes/AxisStyles.ts +11 -0
- package/src/Graph/common/Axes/UnitLabel.tsx +41 -10
- package/src/Graph/common/Axes/index.tsx +18 -12
- package/src/Graph/common/Axes/models.ts +4 -2
- package/src/Graph/common/Axes/useAxisY.ts +22 -12
- package/src/Graph/common/BaseChart/BaseChart.tsx +2 -2
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +8 -5
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +1 -1
- package/src/Graph/common/Grids/index.tsx +2 -2
- package/src/Graph/common/Thresholds/ThresholdLine.tsx +1 -1
- package/src/Graph/common/Thresholds/Thresholds.tsx +10 -15
- package/src/Graph/common/timeSeries/index.ts +109 -131
- package/src/Graph/common/timeSeries/models.ts +4 -5
- package/src/Graph/index.ts +4 -4
- package/src/Graph/mockedData/lastDayWithLotOfUnits.json +1668 -0
- package/src/Graph/mockedData/pingService.json +46 -1
- package/src/Graph/mockedData/pingServiceLinesBars.json +253 -0
- package/src/Graph/mockedData/pingServiceLinesBarsMixed.json +253 -0
- package/src/Graph/mockedData/pingServiceLinesBarsStacked.json +253 -0
- package/src/Graph/mockedData/pingServiceMixedStacked.json +46 -1
- package/src/Graph/mockedData/pingServiceStacked.json +46 -1
- package/src/Typography/EllipsisTypography.tsx +5 -2
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +16 -24
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
- package/src/components/Form/AccessRights/AccessRights.tsx +3 -3
- package/src/components/Form/index.ts +2 -2
- package/src/utils/index.ts +2 -2
- package/src/Graph/BarChart/SingleBar.tsx +0 -62
- package/src/Graph/BarChart/useSingleBar.ts +0 -199
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/useStackedLines.ts +0 -39
- package/src/Graph/LineChart/graphAtoms.ts +0 -3
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/useRegularLines.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/StackedLines/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/BasicThreshold.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/Circle.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/helpers/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useCoordinateCircle.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/GuidingLines.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/useTickGraph.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Area.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Line.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Area/Downtime.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/EventAnnotations.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Acknowledgement.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Comments.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/annotationsAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/useAnnotation.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Bar.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltipStyles.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftIcon.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/useGraphTooltip.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/index.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/useZoomPreview.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/zoomPreviewAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/InteractiveComponents/interactionWithGraphAtoms.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/LegendContent.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/models.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/Legend/useLegend.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/LoadingSkeleton.tsx +0 -0
- /package/src/Graph/{LineChart → Chart}/common/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/helpers/doc.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/helpers/index.ts +0 -0
- /package/src/Graph/{LineChart → Chart}/translatedLabels.ts +0 -0
- /package/src/Graph/{LineChart/useLineChartData.ts → Chart/useChartData.ts} +0 -0
- /package/src/Graph/{LineChart/useLineChartIntersection.ts → Chart/useChartIntersection.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.8.
|
|
3
|
+
"version": "24.8.3",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update:deps": "pnpx npm-check-updates -i --format group",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test:storybook:local": "test-storybook --url http://127.0.0.1:9001",
|
|
13
13
|
"test:ci": "jest --silent --reporter=jest-junit",
|
|
14
14
|
"cypress:ui": "cypress open --component --browser=chrome",
|
|
15
|
-
"cypress:run:
|
|
15
|
+
"cypress:run:updateSnapshots": "cypress run --component --browser=chrome --env updateSnapshots=true",
|
|
16
16
|
"cypress:run:coverage": "cypress run --component --browser=chrome --env codeCoverageTasksRegistered=true",
|
|
17
17
|
"cypress:run": "cypress run --component --browser=chrome",
|
|
18
18
|
"tokens:transform": "TS_NODE_PROJECT=tsconfig.node.json ts-node style-dictionary.transform.ts"
|
|
@@ -52,23 +52,20 @@
|
|
|
52
52
|
"@cypress/webpack-dev-server": "^3.10.0",
|
|
53
53
|
"@faker-js/faker": "^8.4.1",
|
|
54
54
|
"@mdx-js/react": "^3.0.1",
|
|
55
|
-
"@modern-js/prod-server": "^2.56.0",
|
|
56
|
-
"@modern-js/storybook": "^2.56.0",
|
|
57
55
|
"@simonsmith/cypress-image-snapshot": "^9.1.0",
|
|
58
|
-
"@storybook/addon-a11y": "^8.2.
|
|
59
|
-
"@storybook/addon-docs": "^8.2.
|
|
60
|
-
"@storybook/addon-essentials": "^8.2.
|
|
61
|
-
"@storybook/addon-
|
|
62
|
-
"@storybook/
|
|
63
|
-
"@storybook/
|
|
64
|
-
"@storybook/manager-api": "^8.2.5",
|
|
56
|
+
"@storybook/addon-a11y": "^8.2.7",
|
|
57
|
+
"@storybook/addon-docs": "^8.2.7",
|
|
58
|
+
"@storybook/addon-essentials": "^8.2.7",
|
|
59
|
+
"@storybook/addon-themes": "^8.2.7",
|
|
60
|
+
"@storybook/blocks": "^8.2.7",
|
|
61
|
+
"@storybook/manager-api": "^8.2.7",
|
|
65
62
|
"@storybook/mdx2-csf": "^1.1.0",
|
|
66
|
-
"@storybook/preview-api": "^8.2.
|
|
67
|
-
"@storybook/react": "^8.2.
|
|
68
|
-
"@storybook/react-vite": "^8.2.
|
|
69
|
-
"@storybook/test": "^8.2.
|
|
63
|
+
"@storybook/preview-api": "^8.2.7",
|
|
64
|
+
"@storybook/react": "^8.2.7",
|
|
65
|
+
"@storybook/react-vite": "^8.2.7",
|
|
66
|
+
"@storybook/test": "^8.2.7",
|
|
70
67
|
"@storybook/test-runner": "^0.19.1",
|
|
71
|
-
"@storybook/theming": "^8.2.
|
|
68
|
+
"@storybook/theming": "^8.2.7",
|
|
72
69
|
"@testing-library/cypress": "^10.0.2",
|
|
73
70
|
"@testing-library/jest-dom": "^6.4.6",
|
|
74
71
|
"@testing-library/react": "^16.0.0",
|
|
@@ -94,7 +91,7 @@
|
|
|
94
91
|
"react-test-renderer": "^18.3.1",
|
|
95
92
|
"remark-gfm": "^4.0.0",
|
|
96
93
|
"speed-measure-vite-plugin": "^1.0.1",
|
|
97
|
-
"storybook": "^8.2.
|
|
94
|
+
"storybook": "^8.2.7",
|
|
98
95
|
"storybook-addon-mock": "^5.0.0",
|
|
99
96
|
"storybook-dark-mode": "^4.0.2",
|
|
100
97
|
"style-dictionary": "^4.0.1",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react';
|
|
2
2
|
import dayjs from 'dayjs';
|
|
3
3
|
import { useAtomValue } from 'jotai';
|
|
4
|
-
import { equals } from 'ramda';
|
|
5
4
|
|
|
6
5
|
import { userAtom } from '@centreon/ui-context';
|
|
7
6
|
|
|
@@ -56,6 +55,21 @@ const initialize = ({
|
|
|
56
55
|
cy.viewport('macbook-13');
|
|
57
56
|
};
|
|
58
57
|
|
|
58
|
+
const checkWidth = (orientation): void => {
|
|
59
|
+
if (orientation === 'vertical') {
|
|
60
|
+
cy.get('g[class*="visx-rows"] > line')
|
|
61
|
+
.eq(0)
|
|
62
|
+
.should('have.attr', 'x2')
|
|
63
|
+
.and('equal', '1135');
|
|
64
|
+
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
cy.get('g[class*="visx-rows"] > line')
|
|
68
|
+
.eq(0)
|
|
69
|
+
.should('have.attr', 'x2')
|
|
70
|
+
.and('equal', '1170');
|
|
71
|
+
};
|
|
72
|
+
|
|
59
73
|
describe('Bar chart', () => {
|
|
60
74
|
['horizontal', 'vertical'].forEach((orientation) => {
|
|
61
75
|
it(`displays the bar chart ${orientation}ly`, () => {
|
|
@@ -63,19 +77,12 @@ describe('Bar chart', () => {
|
|
|
63
77
|
const userData = renderHook(() => useAtomValue(userAtom));
|
|
64
78
|
userData.result.current.locale = 'en';
|
|
65
79
|
|
|
80
|
+
checkWidth(orientation);
|
|
66
81
|
cy.contains('0 ms').should('be.visible');
|
|
67
82
|
cy.contains('20').should('be.visible');
|
|
68
83
|
cy.contains(':40 AM').should('be.visible');
|
|
69
84
|
|
|
70
|
-
|
|
71
|
-
cy.findByTestId('single-bar-3-2-0.08644')
|
|
72
|
-
.should('have.attr', 'height')
|
|
73
|
-
.should('equals', '295');
|
|
74
|
-
} else {
|
|
75
|
-
cy.findByTestId('single-bar-3-2-0.08644')
|
|
76
|
-
.should('have.attr', 'width')
|
|
77
|
-
.should('equals', '863');
|
|
78
|
-
}
|
|
85
|
+
cy.findByTestId('stacked-bar-3-0-0.08644').should('be.visible');
|
|
79
86
|
|
|
80
87
|
cy.makeSnapshot();
|
|
81
88
|
});
|
|
@@ -83,19 +90,12 @@ describe('Bar chart', () => {
|
|
|
83
90
|
it(`displays the bar chart ${orientation}ly centered in zero`, () => {
|
|
84
91
|
initialize({ axis: { isCenteredZero: true }, orientation });
|
|
85
92
|
|
|
93
|
+
checkWidth(orientation);
|
|
86
94
|
cy.contains('0 ms').should('be.visible');
|
|
87
95
|
cy.contains('20').should('be.visible');
|
|
88
96
|
cy.contains(':40 AM').should('be.visible');
|
|
89
97
|
|
|
90
|
-
|
|
91
|
-
cy.findByTestId('single-bar-3-2-0.08644')
|
|
92
|
-
.should('have.attr', 'height')
|
|
93
|
-
.should('equals', '171');
|
|
94
|
-
} else {
|
|
95
|
-
cy.findByTestId('single-bar-3-2-0.08644')
|
|
96
|
-
.should('have.attr', 'width')
|
|
97
|
-
.should('equals', '432');
|
|
98
|
-
}
|
|
98
|
+
cy.findByTestId('stacked-bar-3-0-0.08644').should('be.visible');
|
|
99
99
|
|
|
100
100
|
cy.makeSnapshot();
|
|
101
101
|
});
|
|
@@ -103,19 +103,12 @@ describe('Bar chart', () => {
|
|
|
103
103
|
it(`displays the stacked bar chart ${orientation}ly`, () => {
|
|
104
104
|
initialize({ data: dataPingServiceStacked, orientation });
|
|
105
105
|
|
|
106
|
+
checkWidth(orientation);
|
|
106
107
|
cy.contains('0 ms').should('be.visible');
|
|
107
108
|
cy.contains('20').should('be.visible');
|
|
108
109
|
cy.contains(':40 AM').should('be.visible');
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
|
|
112
|
-
.should('have.attr', 'height')
|
|
113
|
-
.should('equals', '187');
|
|
114
|
-
} else {
|
|
115
|
-
cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
|
|
116
|
-
.should('have.attr', 'width')
|
|
117
|
-
.should('equals', '546');
|
|
118
|
-
}
|
|
111
|
+
cy.findByTestId('stacked-bar-3-0-0.16196').should('be.visible');
|
|
119
112
|
|
|
120
113
|
cy.makeSnapshot();
|
|
121
114
|
});
|
|
@@ -123,19 +116,12 @@ describe('Bar chart', () => {
|
|
|
123
116
|
it(`displays bar chart ${orientation}ly with a mix of stacked and non-stacked data`, () => {
|
|
124
117
|
initialize({ data: dataPingServiceMixedStacked, orientation });
|
|
125
118
|
|
|
119
|
+
checkWidth(orientation);
|
|
126
120
|
cy.contains('0 ms').should('be.visible');
|
|
127
121
|
cy.contains('20').should('be.visible');
|
|
128
122
|
cy.contains(':40 AM').should('be.visible');
|
|
129
123
|
|
|
130
|
-
|
|
131
|
-
cy.findByTestId('stacked-bar-3-0-0.08644')
|
|
132
|
-
.should('have.attr', 'height')
|
|
133
|
-
.should('equals', '265');
|
|
134
|
-
} else {
|
|
135
|
-
cy.findByTestId('stacked-bar-3-0-0.08644')
|
|
136
|
-
.should('have.attr', 'width')
|
|
137
|
-
.should('equals', '773');
|
|
138
|
-
}
|
|
124
|
+
cy.findByTestId('stacked-bar-3-0-0.08644').should('be.visible');
|
|
139
125
|
|
|
140
126
|
cy.makeSnapshot();
|
|
141
127
|
});
|
|
@@ -147,19 +133,12 @@ describe('Bar chart', () => {
|
|
|
147
133
|
orientation
|
|
148
134
|
});
|
|
149
135
|
|
|
136
|
+
checkWidth(orientation);
|
|
150
137
|
cy.contains('0 ms').should('be.visible');
|
|
151
138
|
cy.contains('20').should('be.visible');
|
|
152
139
|
cy.contains(':40 AM').should('be.visible');
|
|
153
140
|
|
|
154
|
-
|
|
155
|
-
cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
|
|
156
|
-
.should('have.attr', 'height')
|
|
157
|
-
.should('equals', '94');
|
|
158
|
-
} else {
|
|
159
|
-
cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
|
|
160
|
-
.should('have.attr', 'width')
|
|
161
|
-
.should('equals', '273');
|
|
162
|
-
}
|
|
141
|
+
cy.findByTestId('stacked-bar-3-0-0.16196').should('be.visible');
|
|
163
142
|
|
|
164
143
|
cy.makeSnapshot();
|
|
165
144
|
});
|
|
@@ -171,19 +150,12 @@ describe('Bar chart', () => {
|
|
|
171
150
|
orientation
|
|
172
151
|
});
|
|
173
152
|
|
|
153
|
+
checkWidth(orientation);
|
|
174
154
|
cy.contains('0 ms').should('be.visible');
|
|
175
155
|
cy.contains('20').should('be.visible');
|
|
176
156
|
cy.contains(':40 AM').should('be.visible');
|
|
177
157
|
|
|
178
|
-
|
|
179
|
-
cy.findByTestId('stacked-bar-3-0-0.08644')
|
|
180
|
-
.should('have.attr', 'height')
|
|
181
|
-
.should('equals', '133');
|
|
182
|
-
} else {
|
|
183
|
-
cy.findByTestId('stacked-bar-3-0-0.08644')
|
|
184
|
-
.should('have.attr', 'width')
|
|
185
|
-
.should('equals', '387');
|
|
186
|
-
}
|
|
158
|
+
cy.findByTestId('stacked-bar-3-0-0.08644').should('be.visible');
|
|
187
159
|
});
|
|
188
160
|
|
|
189
161
|
it(`displays bar chart ${orientation}ly with a custom style`, () => {
|
|
@@ -193,19 +165,12 @@ describe('Bar chart', () => {
|
|
|
193
165
|
orientation
|
|
194
166
|
});
|
|
195
167
|
|
|
168
|
+
checkWidth(orientation);
|
|
196
169
|
cy.contains('0 ms').should('be.visible');
|
|
197
170
|
cy.contains('20').should('be.visible');
|
|
198
171
|
cy.contains(':40 AM').should('be.visible');
|
|
199
172
|
|
|
200
|
-
|
|
201
|
-
cy.findByTestId('stacked-bar-3-0-0.08644')
|
|
202
|
-
.should('have.attr', 'height')
|
|
203
|
-
.should('equals', '265');
|
|
204
|
-
} else {
|
|
205
|
-
cy.findByTestId('stacked-bar-3-0-0.08644')
|
|
206
|
-
.should('have.attr', 'width')
|
|
207
|
-
.should('equals', '773');
|
|
208
|
-
}
|
|
173
|
+
cy.findByTestId('stacked-bar-3-0-0.08644').should('be.visible');
|
|
209
174
|
});
|
|
210
175
|
});
|
|
211
176
|
|
|
@@ -214,21 +179,18 @@ describe('Bar chart', () => {
|
|
|
214
179
|
orientation: 'horizontal'
|
|
215
180
|
});
|
|
216
181
|
|
|
182
|
+
checkWidth('horizontal');
|
|
217
183
|
cy.contains('0 ms').should('be.visible');
|
|
218
184
|
cy.contains('20').should('be.visible');
|
|
219
185
|
cy.contains(':40 AM').should('be.visible');
|
|
220
186
|
|
|
221
|
-
cy.findByTestId('
|
|
187
|
+
cy.findByTestId('stacked-bar-10-0-7650.368581547736').realHover();
|
|
222
188
|
|
|
223
189
|
cy.contains('06/19/2024').should('be.visible');
|
|
224
190
|
cy.contains('Centreon-Server: Round-Trip Maximum Time').should(
|
|
225
191
|
'be.visible'
|
|
226
192
|
);
|
|
227
|
-
cy.contains('
|
|
228
|
-
|
|
229
|
-
cy.findByTestId('single-bar-3-2-0.08644')
|
|
230
|
-
.should('have.attr', 'height')
|
|
231
|
-
.should('equals', '295');
|
|
193
|
+
cy.contains('7.47 KB').should('be.visible');
|
|
232
194
|
|
|
233
195
|
cy.makeSnapshot();
|
|
234
196
|
});
|
|
@@ -243,6 +205,7 @@ describe('Bar chart', () => {
|
|
|
243
205
|
}
|
|
244
206
|
});
|
|
245
207
|
|
|
208
|
+
checkWidth('horizontal');
|
|
246
209
|
cy.contains('0 ms').should('be.visible');
|
|
247
210
|
cy.contains('20').should('be.visible');
|
|
248
211
|
cy.contains(':40 AM').should('be.visible');
|
|
@@ -251,9 +214,7 @@ describe('Bar chart', () => {
|
|
|
251
214
|
|
|
252
215
|
cy.contains('06/19/2024').should('not.exist');
|
|
253
216
|
|
|
254
|
-
cy.findByTestId('stacked-bar-3-0-0.12340000000000001')
|
|
255
|
-
.should('have.attr', 'height')
|
|
256
|
-
.should('equals', '187');
|
|
217
|
+
cy.findByTestId('stacked-bar-3-0-0.12340000000000001').should('be.visible');
|
|
257
218
|
|
|
258
219
|
cy.makeSnapshot();
|
|
259
220
|
});
|
|
@@ -268,6 +229,7 @@ describe('Bar chart', () => {
|
|
|
268
229
|
}
|
|
269
230
|
});
|
|
270
231
|
|
|
232
|
+
checkWidth('horizontal');
|
|
271
233
|
cy.contains('0 ms').should('be.visible');
|
|
272
234
|
cy.contains('20').should('be.visible');
|
|
273
235
|
cy.contains(':40 AM').should('be.visible');
|
|
@@ -288,9 +250,7 @@ describe('Bar chart', () => {
|
|
|
288
250
|
cy.contains('0.02 ms').should('be.visible');
|
|
289
251
|
cy.contains('0.11 ms').should('be.visible');
|
|
290
252
|
|
|
291
|
-
cy.findByTestId('stacked-bar-3-0-0.
|
|
292
|
-
.should('have.attr', 'height')
|
|
293
|
-
.should('equals', '187');
|
|
253
|
+
cy.findByTestId('stacked-bar-3-0-0.16196').should('be.visible');
|
|
294
254
|
|
|
295
255
|
cy.makeSnapshot();
|
|
296
256
|
});
|
|
@@ -305,6 +265,7 @@ describe('Bar chart', () => {
|
|
|
305
265
|
}
|
|
306
266
|
});
|
|
307
267
|
|
|
268
|
+
checkWidth('horizontal');
|
|
308
269
|
cy.contains('0 ms').should('be.visible');
|
|
309
270
|
cy.contains('20').should('be.visible');
|
|
310
271
|
cy.contains(':40 AM').should('be.visible');
|
|
@@ -317,9 +278,7 @@ describe('Bar chart', () => {
|
|
|
317
278
|
);
|
|
318
279
|
cy.contains('0.05 ms').should('be.visible');
|
|
319
280
|
|
|
320
|
-
cy.findByTestId('stacked-bar-3-0-0.
|
|
321
|
-
.should('have.attr', 'height')
|
|
322
|
-
.should('equals', '187');
|
|
281
|
+
cy.findByTestId('stacked-bar-3-0-0.16196').should('be.visible');
|
|
323
282
|
|
|
324
283
|
cy.makeSnapshot();
|
|
325
284
|
});
|
|
@@ -12,11 +12,11 @@ import { Provider } from 'jotai';
|
|
|
12
12
|
|
|
13
13
|
import { Box } from '@mui/material';
|
|
14
14
|
|
|
15
|
-
import { LineChartProps } from '../
|
|
15
|
+
import { LineChartProps } from '../Chart/models';
|
|
16
16
|
import { LineChartData, Thresholds } from '../common/models';
|
|
17
17
|
import { ParentSize } from '../../ParentSize';
|
|
18
|
-
import
|
|
19
|
-
import LoadingSkeleton from '../
|
|
18
|
+
import useChartData from '../Chart/useChartData';
|
|
19
|
+
import LoadingSkeleton from '../Chart/LoadingSkeleton';
|
|
20
20
|
|
|
21
21
|
import ResponsiveBarChart from './ResponsiveBarChart';
|
|
22
22
|
import { BarStyle } from './models';
|
|
@@ -59,7 +59,7 @@ const BarChart = ({
|
|
|
59
59
|
radius: 0.2
|
|
60
60
|
}
|
|
61
61
|
}: BarChartProps): JSX.Element => {
|
|
62
|
-
const { adjustedData } =
|
|
62
|
+
const { adjustedData } = useChartData({ data, end, start });
|
|
63
63
|
const lineChartRef = useRef<HTMLDivElement | null>(null);
|
|
64
64
|
|
|
65
65
|
if (loading && !adjustedData) {
|
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
import { memo, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { BarGroupHorizontal, BarGroup as VisxBarGroup } from '@visx/shape';
|
|
4
|
-
import { difference, equals,
|
|
4
|
+
import { difference, equals, keys, omit, pick, pluck, uniq } from 'ramda';
|
|
5
5
|
import { scaleBand, scaleOrdinal } from '@visx/scale';
|
|
6
6
|
import { Group } from '@visx/group';
|
|
7
|
+
import { ScaleLinear } from 'd3-scale';
|
|
7
8
|
|
|
8
9
|
import { useDeepMemo } from '../../utils';
|
|
9
10
|
import { Line, TimeValue } from '../common/timeSeries/models';
|
|
10
11
|
import {
|
|
11
12
|
getSortedStackedLines,
|
|
12
13
|
getTime,
|
|
13
|
-
getTimeSeriesForLines
|
|
14
|
+
getTimeSeriesForLines,
|
|
15
|
+
getUnits
|
|
14
16
|
} from '../common/timeSeries';
|
|
15
17
|
|
|
16
|
-
import SingleBar from './SingleBar';
|
|
17
18
|
import BarStack from './BarStack';
|
|
18
19
|
import { BarStyle } from './models';
|
|
19
20
|
|
|
20
21
|
interface Props {
|
|
21
22
|
barStyle: BarStyle;
|
|
22
|
-
isCenteredZero?: boolean;
|
|
23
23
|
isTooltipHidden: boolean;
|
|
24
|
-
leftScale;
|
|
25
24
|
lines: Array<Line>;
|
|
26
25
|
orientation: 'horizontal' | 'vertical';
|
|
27
|
-
rightScale;
|
|
28
|
-
secondUnit?: string;
|
|
29
26
|
size: number;
|
|
30
27
|
timeSeries: Array<TimeValue>;
|
|
31
28
|
xScale;
|
|
29
|
+
yScalesPerUnit: Record<string, ScaleLinear<number, number>>;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
const BarGroup = ({
|
|
@@ -37,44 +35,50 @@ const BarGroup = ({
|
|
|
37
35
|
size,
|
|
38
36
|
lines,
|
|
39
37
|
xScale,
|
|
40
|
-
|
|
41
|
-
rightScale,
|
|
42
|
-
secondUnit,
|
|
43
|
-
isCenteredZero,
|
|
38
|
+
yScalesPerUnit,
|
|
44
39
|
isTooltipHidden,
|
|
45
40
|
barStyle
|
|
46
41
|
}: Props): JSX.Element => {
|
|
47
42
|
const isHorizontal = equals(orientation, 'horizontal');
|
|
48
43
|
|
|
44
|
+
const [firstUnit] = getUnits(lines);
|
|
45
|
+
|
|
49
46
|
const BarComponent = useMemo(
|
|
50
47
|
() => (isHorizontal ? VisxBarGroup : BarGroupHorizontal),
|
|
51
48
|
[isHorizontal]
|
|
52
49
|
);
|
|
53
50
|
|
|
54
51
|
const stackedLines = getSortedStackedLines(lines);
|
|
52
|
+
const stackedUnits = uniq(pluck('unit', stackedLines));
|
|
55
53
|
const notStackedLines = difference(lines, stackedLines);
|
|
56
54
|
|
|
57
|
-
const
|
|
58
|
-
|
|
55
|
+
const stackedKeys = stackedUnits.reduce(
|
|
56
|
+
(acc, unit) => ({
|
|
57
|
+
...acc,
|
|
58
|
+
[`stacked-${unit}`]: null
|
|
59
|
+
}),
|
|
60
|
+
{}
|
|
59
61
|
);
|
|
60
|
-
const
|
|
61
|
-
(
|
|
62
|
+
const stackedLinesTimeSeriesPerUnit = stackedUnits.reduce(
|
|
63
|
+
(acc, stackedUnit) => {
|
|
64
|
+
const relatedLines = stackedLines.filter(({ unit }) =>
|
|
65
|
+
equals(unit, stackedUnit)
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
...acc,
|
|
70
|
+
[stackedUnit]: {
|
|
71
|
+
lines: relatedLines,
|
|
72
|
+
timeSeries: getTimeSeriesForLines({
|
|
73
|
+
lines: relatedLines,
|
|
74
|
+
timeSeries
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
{}
|
|
62
80
|
);
|
|
63
|
-
|
|
64
|
-
? { stackedRight: null }
|
|
65
|
-
: {};
|
|
66
|
-
const hasStackedLinesLeft = !isEmpty(stackLinesLeft)
|
|
67
|
-
? { stackedLeft: null }
|
|
68
|
-
: {};
|
|
69
|
-
|
|
70
|
-
const stackedTimeSeriesRight = getTimeSeriesForLines({
|
|
71
|
-
lines: stackLinesRight,
|
|
72
|
-
timeSeries
|
|
73
|
-
});
|
|
74
|
-
const stackedTimeSeriesLeft = getTimeSeriesForLines({
|
|
75
|
-
lines: stackLinesLeft,
|
|
76
|
-
timeSeries
|
|
77
|
-
});
|
|
81
|
+
|
|
78
82
|
const notStackedTimeSeries = getTimeSeriesForLines({
|
|
79
83
|
lines: notStackedLines,
|
|
80
84
|
timeSeries
|
|
@@ -82,8 +86,7 @@ const BarGroup = ({
|
|
|
82
86
|
|
|
83
87
|
const normalizedTimeSeries = notStackedTimeSeries.map((timeSerie) => ({
|
|
84
88
|
...timeSerie,
|
|
85
|
-
...
|
|
86
|
-
...hasStackedLinesLeft
|
|
89
|
+
...stackedKeys
|
|
87
90
|
}));
|
|
88
91
|
|
|
89
92
|
const lineKeys = useDeepMemo({
|
|
@@ -119,6 +122,8 @@ const BarGroup = ({
|
|
|
119
122
|
[...lineKeys, xScale.bandwidth()]
|
|
120
123
|
);
|
|
121
124
|
|
|
125
|
+
const placeholderScale = yScalesPerUnit[firstUnit];
|
|
126
|
+
|
|
122
127
|
const barComponentBaseProps = useMemo(
|
|
123
128
|
() =>
|
|
124
129
|
isHorizontal
|
|
@@ -126,15 +131,15 @@ const BarGroup = ({
|
|
|
126
131
|
x0: getTime,
|
|
127
132
|
x0Scale: xScale,
|
|
128
133
|
x1Scale: metricScale,
|
|
129
|
-
yScale:
|
|
134
|
+
yScale: placeholderScale
|
|
130
135
|
}
|
|
131
136
|
: {
|
|
132
|
-
xScale:
|
|
137
|
+
xScale: placeholderScale,
|
|
133
138
|
y0: getTime,
|
|
134
139
|
y0Scale: xScale,
|
|
135
140
|
y1Scale: metricScale
|
|
136
141
|
},
|
|
137
|
-
[isHorizontal,
|
|
142
|
+
[isHorizontal, placeholderScale, xScale, metricScale]
|
|
138
143
|
);
|
|
139
144
|
|
|
140
145
|
return (
|
|
@@ -152,49 +157,48 @@ const BarGroup = ({
|
|
|
152
157
|
left={barGroup.x0}
|
|
153
158
|
top={barGroup.y0}
|
|
154
159
|
>
|
|
155
|
-
{barGroup.bars.map((bar) =>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
{barGroup.bars.map((bar) => {
|
|
161
|
+
const isStackedBar = bar.key.startsWith('stacked-');
|
|
162
|
+
const linesBar = isStackedBar
|
|
163
|
+
? stackedLinesTimeSeriesPerUnit[bar.key.replace('stacked-', '')]
|
|
164
|
+
.lines
|
|
165
|
+
: (notStackedLines.find(({ metric_id }) =>
|
|
166
|
+
equals(metric_id, Number(bar.key))
|
|
167
|
+
) as Line);
|
|
168
|
+
const timeSeriesBar = isStackedBar
|
|
169
|
+
? stackedLinesTimeSeriesPerUnit[bar.key.replace('stacked-', '')]
|
|
170
|
+
.timeSeries
|
|
171
|
+
: notStackedTimeSeries.map((timeSerie) => ({
|
|
172
|
+
timeTick: timeSerie.timeTick,
|
|
173
|
+
[bar.key]: timeSerie[Number(bar.key)]
|
|
174
|
+
}));
|
|
175
|
+
|
|
176
|
+
return isStackedBar ? (
|
|
177
|
+
<BarStack
|
|
178
|
+
barIndex={barGroup.index}
|
|
179
|
+
barPadding={isHorizontal ? bar.x : bar.y}
|
|
159
180
|
barStyle={barStyle}
|
|
160
|
-
|
|
181
|
+
barWidth={isHorizontal ? bar.width : bar.height}
|
|
161
182
|
isHorizontal={isHorizontal}
|
|
162
183
|
isTooltipHidden={isTooltipHidden}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
rightScale={rightScale}
|
|
167
|
-
secondUnit={secondUnit}
|
|
168
|
-
size={size}
|
|
184
|
+
lines={linesBar}
|
|
185
|
+
timeSeries={timeSeriesBar}
|
|
186
|
+
yScale={yScalesPerUnit[bar.key.replace('stacked-', '')]}
|
|
169
187
|
/>
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
<BarStack
|
|
185
|
-
barIndex={barGroup.index}
|
|
186
|
-
barPadding={isHorizontal ? bar.x : bar.y}
|
|
187
|
-
barStyle={barStyle}
|
|
188
|
-
barWidth={isHorizontal ? bar.width : bar.height}
|
|
189
|
-
isHorizontal={isHorizontal}
|
|
190
|
-
isTooltipHidden={isTooltipHidden}
|
|
191
|
-
lines={stackLinesLeft}
|
|
192
|
-
timeSeries={stackedTimeSeriesLeft}
|
|
193
|
-
yScale={leftScale}
|
|
194
|
-
/>
|
|
195
|
-
)}
|
|
196
|
-
</>
|
|
197
|
-
))}
|
|
188
|
+
) : (
|
|
189
|
+
<BarStack
|
|
190
|
+
barIndex={barGroup.index}
|
|
191
|
+
barPadding={isHorizontal ? bar.x : bar.y}
|
|
192
|
+
barStyle={barStyle}
|
|
193
|
+
barWidth={isHorizontal ? bar.width : bar.height}
|
|
194
|
+
isHorizontal={isHorizontal}
|
|
195
|
+
isTooltipHidden={isTooltipHidden}
|
|
196
|
+
lines={[linesBar]}
|
|
197
|
+
timeSeries={timeSeriesBar}
|
|
198
|
+
yScale={yScalesPerUnit[linesBar.unit]}
|
|
199
|
+
/>
|
|
200
|
+
);
|
|
201
|
+
})}
|
|
198
202
|
</Group>
|
|
199
203
|
))
|
|
200
204
|
}
|
|
@@ -213,27 +217,13 @@ const propsToMemoize = [
|
|
|
213
217
|
];
|
|
214
218
|
|
|
215
219
|
export default memo(BarGroup, (prevProps, nextProps) => {
|
|
216
|
-
const
|
|
217
|
-
...prevProps.leftScale.domain(),
|
|
218
|
-
...prevProps.leftScale.range()
|
|
219
|
-
];
|
|
220
|
-
const prevRightScale = [
|
|
221
|
-
...prevProps.rightScale.domain(),
|
|
222
|
-
...prevProps.rightScale.range()
|
|
223
|
-
];
|
|
220
|
+
const prevYScale = prevProps.yScalesPerUnit;
|
|
224
221
|
const prevXScale = [
|
|
225
222
|
...prevProps.xScale.domain(),
|
|
226
223
|
...prevProps.xScale.range()
|
|
227
224
|
];
|
|
228
225
|
|
|
229
|
-
const
|
|
230
|
-
...nextProps.leftScale.domain(),
|
|
231
|
-
...nextProps.leftScale.range()
|
|
232
|
-
];
|
|
233
|
-
const nextRightScale = [
|
|
234
|
-
...nextProps.rightScale.domain(),
|
|
235
|
-
...nextProps.rightScale.range()
|
|
236
|
-
];
|
|
226
|
+
const nextYScale = nextProps.yScalesPerUnit;
|
|
237
227
|
const nextXScale = [
|
|
238
228
|
...nextProps.xScale.domain(),
|
|
239
229
|
...nextProps.xScale.range()
|
|
@@ -241,8 +231,7 @@ export default memo(BarGroup, (prevProps, nextProps) => {
|
|
|
241
231
|
|
|
242
232
|
return (
|
|
243
233
|
equals(pick(propsToMemoize, prevProps), pick(propsToMemoize, nextProps)) &&
|
|
244
|
-
equals(
|
|
245
|
-
equals(prevRightScale, nextRightScale) &&
|
|
234
|
+
equals(prevYScale, nextYScale) &&
|
|
246
235
|
equals(prevXScale, nextXScale)
|
|
247
236
|
);
|
|
248
237
|
});
|