@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.
Files changed (111) hide show
  1. package/package.json +14 -17
  2. package/src/Graph/BarChart/BarChart.cypress.spec.tsx +38 -79
  3. package/src/Graph/BarChart/BarChart.tsx +4 -4
  4. package/src/Graph/BarChart/BarGroup.tsx +81 -92
  5. package/src/Graph/BarChart/BarStack.tsx +21 -13
  6. package/src/Graph/BarChart/ResponsiveBarChart.tsx +26 -50
  7. package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +1 -1
  8. package/src/Graph/BarChart/useBarStack.ts +1 -1
  9. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Point.tsx +1 -1
  10. package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +67 -0
  11. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +4 -7
  12. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/index.tsx +6 -9
  13. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/models.ts +1 -2
  14. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useScaleThreshold.ts +8 -20
  15. package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/index.tsx +64 -43
  16. package/src/Graph/{LineChart/LineChart.cypress.spec.tsx → Chart/Chart.cypress.spec.tsx} +272 -23
  17. package/src/Graph/{LineChart/index.stories.tsx → Chart/Chart.stories.tsx} +217 -24
  18. package/src/Graph/{LineChart/LineChart.styles.ts → Chart/Chart.styles.ts} +1 -1
  19. package/src/Graph/{LineChart/LineChart.tsx → Chart/Chart.tsx} +84 -100
  20. package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -1
  21. package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +6 -1
  22. package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +61 -0
  23. package/src/Graph/{LineChart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx → Chart/InteractiveComponents/GraphValueTooltip/GraphValueTooltipContent.tsx} +2 -2
  24. package/src/Graph/{LineChart → Chart}/InteractiveComponents/index.tsx +11 -15
  25. package/src/Graph/{LineChart → Chart}/Legend/Legend.styles.ts +1 -7
  26. package/src/Graph/{LineChart → Chart}/Legend/LegendHeader.tsx +9 -5
  27. package/src/Graph/{LineChart → Chart}/Legend/index.tsx +2 -1
  28. package/src/Graph/Chart/graphAtoms.ts +6 -0
  29. package/src/Graph/{LineChart → Chart}/index.tsx +10 -7
  30. package/src/Graph/{LineChart → Chart}/models.ts +8 -3
  31. package/src/Graph/common/Axes/AxisStyles.ts +11 -0
  32. package/src/Graph/common/Axes/UnitLabel.tsx +41 -10
  33. package/src/Graph/common/Axes/index.tsx +18 -12
  34. package/src/Graph/common/Axes/models.ts +4 -2
  35. package/src/Graph/common/Axes/useAxisY.ts +22 -12
  36. package/src/Graph/common/BaseChart/BaseChart.tsx +2 -2
  37. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +8 -5
  38. package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +1 -1
  39. package/src/Graph/common/Grids/index.tsx +2 -2
  40. package/src/Graph/common/Thresholds/ThresholdLine.tsx +1 -1
  41. package/src/Graph/common/Thresholds/Thresholds.tsx +10 -15
  42. package/src/Graph/common/timeSeries/index.ts +109 -131
  43. package/src/Graph/common/timeSeries/models.ts +4 -5
  44. package/src/Graph/index.ts +4 -4
  45. package/src/Graph/mockedData/lastDayWithLotOfUnits.json +1668 -0
  46. package/src/Graph/mockedData/pingService.json +46 -1
  47. package/src/Graph/mockedData/pingServiceLinesBars.json +253 -0
  48. package/src/Graph/mockedData/pingServiceLinesBarsMixed.json +253 -0
  49. package/src/Graph/mockedData/pingServiceLinesBarsStacked.json +253 -0
  50. package/src/Graph/mockedData/pingServiceMixedStacked.json +46 -1
  51. package/src/Graph/mockedData/pingServiceStacked.json +46 -1
  52. package/src/Typography/EllipsisTypography.tsx +5 -2
  53. package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +16 -24
  54. package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
  55. package/src/components/Form/AccessRights/AccessRights.tsx +3 -3
  56. package/src/components/Form/index.ts +2 -2
  57. package/src/utils/index.ts +2 -2
  58. package/src/Graph/BarChart/SingleBar.tsx +0 -62
  59. package/src/Graph/BarChart/useSingleBar.ts +0 -199
  60. package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/useStackedLines.ts +0 -39
  61. package/src/Graph/LineChart/graphAtoms.ts +0 -3
  62. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/index.tsx +0 -0
  63. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/RegularLines/useRegularLines.ts +0 -0
  64. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/StackedLines/index.tsx +0 -0
  65. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/BasicThreshold.tsx +0 -0
  66. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/Circle.tsx +0 -0
  67. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +0 -0
  68. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/helpers/index.ts +0 -0
  69. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/Threshold/useCoordinateCircle.ts +0 -0
  70. /package/src/Graph/{LineChart → Chart}/BasicComponents/Lines/models.ts +0 -0
  71. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/GuidingLines.tsx +0 -0
  72. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/index.tsx +0 -0
  73. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/models.ts +0 -0
  74. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/AnchorPoint/useTickGraph.ts +0 -0
  75. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Area.tsx +0 -0
  76. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/Line.tsx +0 -0
  77. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Annotation/index.tsx +0 -0
  78. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Area/Downtime.tsx +0 -0
  79. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/EventAnnotations.tsx +0 -0
  80. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Acknowledgement.tsx +0 -0
  81. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/Line/Comments.tsx +0 -0
  82. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/annotationsAtoms.ts +0 -0
  83. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/index.tsx +0 -0
  84. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/models.ts +0 -0
  85. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Annotations/useAnnotation.ts +0 -0
  86. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Bar.tsx +0 -0
  87. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +0 -0
  88. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/GraphValueTooltip/useGraphValueTooltipStyles.ts +0 -0
  89. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftIcon.tsx +0 -0
  90. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx +0 -0
  91. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/index.tsx +0 -0
  92. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/models.ts +0 -0
  93. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts +0 -0
  94. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/index.tsx +0 -0
  95. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/models.ts +0 -0
  96. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/Tooltip/useGraphTooltip.ts +0 -0
  97. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/index.tsx +0 -0
  98. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/models.ts +0 -0
  99. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/useZoomPreview.ts +0 -0
  100. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/ZoomPreview/zoomPreviewAtoms.ts +0 -0
  101. /package/src/Graph/{LineChart → Chart}/InteractiveComponents/interactionWithGraphAtoms.ts +0 -0
  102. /package/src/Graph/{LineChart → Chart}/Legend/LegendContent.tsx +0 -0
  103. /package/src/Graph/{LineChart → Chart}/Legend/models.ts +0 -0
  104. /package/src/Graph/{LineChart → Chart}/Legend/useLegend.ts +0 -0
  105. /package/src/Graph/{LineChart → Chart}/LoadingSkeleton.tsx +0 -0
  106. /package/src/Graph/{LineChart → Chart}/common/index.ts +0 -0
  107. /package/src/Graph/{LineChart → Chart}/helpers/doc.ts +0 -0
  108. /package/src/Graph/{LineChart → Chart}/helpers/index.ts +0 -0
  109. /package/src/Graph/{LineChart → Chart}/translatedLabels.ts +0 -0
  110. /package/src/Graph/{LineChart/useLineChartData.ts → Chart/useChartData.ts} +0 -0
  111. /package/src/Graph/{LineChart/useLineChartIntersection.ts → Chart/useChartIntersection.ts} +0 -0
@@ -1,3 +1,5 @@
1
+ import { useState } from 'react';
2
+
1
3
  import { createStore, Provider } from 'jotai';
2
4
 
3
5
  import { userAtom } from '@centreon/ui-context';
@@ -7,11 +9,14 @@ import dataLastDay from '../mockedData/lastDay.json';
7
9
  import dataLastDayWithNullValues from '../mockedData/lastDayWithNullValues.json';
8
10
  import dataLastDayWithIncompleteValues from '../mockedData/lastDayWithIncompleteValues.json';
9
11
  import dataCurvesWithSameColor from '../mockedData/curvesWithSameColor.json';
12
+ import dataPingServiceLinesBars from '../mockedData/pingServiceLinesBars.json';
13
+ import dataPingServiceLinesBarsStacked from '../mockedData/pingServiceLinesBarsStacked.json';
14
+ import dataPingServiceLinesBarsMixed from '../mockedData/pingServiceLinesBarsMixed.json';
10
15
 
11
16
  import { args as argumentsData } from './helpers/doc';
12
17
  import { LineChartProps } from './models';
13
18
 
14
- import WrapperLineChart from '.';
19
+ import WrapperChart from '.';
15
20
 
16
21
  interface Props
17
22
  extends Pick<LineChartProps, 'legend' | 'tooltip' | 'axis' | 'lineStyle'> {
@@ -32,6 +37,27 @@ const checkLegendInformation = (): void => {
32
37
  cy.contains('Avg: 0.51').should('be.visible');
33
38
  };
34
39
 
40
+ const CustomUnitComponent = (props): JSX.Element => {
41
+ const [leftUnit, setLeftUnit] = useState('%');
42
+ const [rightUnit, setRightUnit] = useState('ms');
43
+
44
+ return (
45
+ <WrapperChart
46
+ {...props}
47
+ axis={{
48
+ axisYLeft: {
49
+ onUnitChange: setLeftUnit,
50
+ unit: leftUnit
51
+ },
52
+ axisYRight: {
53
+ onUnitChange: setRightUnit,
54
+ unit: rightUnit
55
+ }
56
+ }}
57
+ />
58
+ );
59
+ };
60
+
35
61
  const initialize = ({
36
62
  data = dataLastDay,
37
63
  tooltip,
@@ -52,7 +78,42 @@ const initialize = ({
52
78
  cy.mount({
53
79
  Component: (
54
80
  <Provider store={store}>
55
- <WrapperLineChart
81
+ <WrapperChart
82
+ {...argumentsData}
83
+ axis={axis}
84
+ data={data as unknown as LineChartData}
85
+ legend={legend}
86
+ lineStyle={lineStyle}
87
+ tooltip={tooltip}
88
+ />
89
+ </Provider>
90
+ )
91
+ });
92
+
93
+ cy.viewport('macbook-13');
94
+ };
95
+
96
+ const initializeCustomUnits = ({
97
+ data = dataLastDay,
98
+ tooltip,
99
+ legend,
100
+ axis,
101
+ lineStyle
102
+ }: Props): void => {
103
+ cy.adjustViewport();
104
+
105
+ const store = createStore();
106
+ store.set(userAtom, {
107
+ alias: 'admin',
108
+ locale: 'en',
109
+ name: 'admin',
110
+ timezone: 'Europe/Paris'
111
+ });
112
+
113
+ cy.mount({
114
+ Component: (
115
+ <Provider store={store}>
116
+ <CustomUnitComponent
56
117
  {...argumentsData}
57
118
  axis={axis}
58
119
  data={data as unknown as LineChartData}
@@ -67,11 +128,23 @@ const initialize = ({
67
128
  cy.viewport('macbook-13');
68
129
  };
69
130
 
131
+ const checkGraphWidth = (): void => {
132
+ cy.findByTestId('graph-interaction-zone')
133
+ .should('have.attr', 'width')
134
+ .and('equal', '1170');
135
+
136
+ cy.findByTestId('graph-interaction-zone')
137
+ .should('have.attr', 'height')
138
+ .and('equal', '393');
139
+ };
140
+
70
141
  describe('Line chart', () => {
71
142
  describe('Tooltip', () => {
72
143
  it('displays a tooltip when the graph is hovered', () => {
73
144
  initialize({});
74
145
 
146
+ checkGraphWidth();
147
+
75
148
  cy.contains('oracle-buffer-hit-ratio graph on srv-oracle-users').should(
76
149
  'be.visible'
77
150
  );
@@ -94,6 +167,8 @@ describe('Line chart', () => {
94
167
  it('displays a metric highlighted when the graph is hovered and the metric is the nearest point', () => {
95
168
  initialize({});
96
169
 
170
+ checkGraphWidth();
171
+
97
172
  cy.contains('Min: 70.31').should('be.visible');
98
173
 
99
174
  cy.findByTestId('graph-interaction-zone').realMouseMove(452, 26);
@@ -115,6 +190,8 @@ describe('Line chart', () => {
115
190
  it('does not display the tooltip when null values are hovered', () => {
116
191
  initialize({ data: dataLastDayWithNullValues });
117
192
 
193
+ checkGraphWidth();
194
+
118
195
  cy.contains('Min: 70.31').should('be.visible');
119
196
 
120
197
  cy.findByTestId('graph-interaction-zone').realMouseMove(1185, 100);
@@ -124,12 +201,14 @@ describe('Line chart', () => {
124
201
  cy.makeSnapshot();
125
202
  });
126
203
 
127
- it('displays the tooltip with defined values whent the graph is hovered', () => {
204
+ it('displays the tooltip with defined values when the graph is hovered', () => {
128
205
  initialize({ data: dataLastDayWithIncompleteValues });
129
206
 
207
+ checkGraphWidth();
208
+
130
209
  cy.contains('Min: 70.31').should('be.visible');
131
210
 
132
- cy.findByTestId('graph-interaction-zone').realMouseMove(1162, 100);
211
+ cy.findByTestId('graph-interaction-zone').realMouseMove(1152, 100);
133
212
 
134
213
  cy.get('[data-metric="querytime"]').should('be.visible');
135
214
  cy.get('[data-metric="hitratio"]').should('not.exist');
@@ -140,6 +219,8 @@ describe('Line chart', () => {
140
219
  it('displays the tooltip a single metric when the corresponding prop is set', () => {
141
220
  initialize({ tooltip: { mode: 'single', sortOrder: 'name' } });
142
221
 
222
+ checkGraphWidth();
223
+
143
224
  cy.contains('Min: 70.31').should('be.visible');
144
225
 
145
226
  cy.findByTestId('graph-interaction-zone').realMouseMove(452, 26);
@@ -157,6 +238,8 @@ describe('Line chart', () => {
157
238
  it('does not display the tooltip when the corresponding prop is set', () => {
158
239
  initialize({ tooltip: { mode: 'hidden', sortOrder: 'name' } });
159
240
 
241
+ checkGraphWidth();
242
+
160
243
  cy.contains('Min: 70.31').should('be.visible');
161
244
 
162
245
  cy.findByTestId('graph-interaction-zone').realMouseMove(452, 26);
@@ -170,6 +253,8 @@ describe('Line chart', () => {
170
253
  it('sorts metrics by their value is ascending when the corresponding prop is set', () => {
171
254
  initialize({ tooltip: { mode: 'all', sortOrder: 'ascending' } });
172
255
 
256
+ checkGraphWidth();
257
+
173
258
  cy.contains('Min: 70.31').should('be.visible');
174
259
 
175
260
  cy.findByTestId('graph-interaction-zone').realMouseMove(452, 26);
@@ -183,6 +268,8 @@ describe('Line chart', () => {
183
268
  it('sorts metrics by their value is descending when the corresponding prop is set', () => {
184
269
  initialize({ tooltip: { mode: 'all', sortOrder: 'descending' } });
185
270
 
271
+ checkGraphWidth();
272
+
186
273
  cy.contains('Min: 70.31').should('be.visible');
187
274
 
188
275
  cy.findByTestId('graph-interaction-zone').realMouseMove(452, 26);
@@ -197,6 +284,10 @@ describe('Line chart', () => {
197
284
  it('displays the curves with different shades when curves have same color', () => {
198
285
  initialize({ data: dataCurvesWithSameColor });
199
286
 
287
+ cy.findByTestId('graph-interaction-zone')
288
+ .should('have.attr', 'width')
289
+ .and('equal', '1212');
290
+
200
291
  cy.findByLabelText('Centreon-Server: Round-Trip Average Time')
201
292
  .find('[data-icon="true"]')
202
293
  .should('have.css', 'background-color', 'rgb(41, 175, 238)');
@@ -257,7 +348,7 @@ describe('Line chart', () => {
257
348
  cy.get('[data-display-side="false"]').should('exist');
258
349
  cy.get('[data-as-list="true"]').should('exist');
259
350
 
260
- cy.contains('8:00 AM').should('be.visible');
351
+ cy.contains(':00 AM').should('be.visible');
261
352
 
262
353
  cy.makeSnapshot();
263
354
  });
@@ -270,7 +361,7 @@ describe('Line chart', () => {
270
361
  cy.get('[data-display-side="true"]').should('exist');
271
362
  cy.get('[data-as-list="true"]').should('exist');
272
363
 
273
- cy.contains('8:00 AM').should('be.visible');
364
+ cy.contains(':00 AM').should('be.visible');
274
365
 
275
366
  cy.makeSnapshot();
276
367
  });
@@ -281,7 +372,7 @@ describe('Line chart', () => {
281
372
  cy.get('[data-display-side="true"]').should('exist');
282
373
  cy.get('[data-as-list="true"]').should('exist');
283
374
 
284
- cy.contains('8:00 AM').should('be.visible');
375
+ cy.contains(':00 AM').should('be.visible');
285
376
 
286
377
  cy.makeSnapshot();
287
378
  });
@@ -291,7 +382,9 @@ describe('Line chart', () => {
291
382
  it('does not display axis borders when the prop is set', () => {
292
383
  initialize({ axis: { showBorder: false } });
293
384
 
294
- cy.contains('8:00 AM').should('be.visible');
385
+ checkGraphWidth();
386
+
387
+ cy.contains(':00 AM').should('be.visible');
295
388
 
296
389
  cy.get('line[class*="visx-axis-line"]')
297
390
  .eq(0)
@@ -312,7 +405,9 @@ describe('Line chart', () => {
312
405
  it('does not display grids when the prop is set', () => {
313
406
  initialize({ axis: { showGridLines: false } });
314
407
 
315
- cy.contains('8:00 AM').should('be.visible');
408
+ checkGraphWidth();
409
+
410
+ cy.contains(':00 AM').should('be.visible');
316
411
 
317
412
  cy.get('g[class="visx-group visx-rows"]').should('not.exist');
318
413
  cy.get('g[class="visx-group visx-columns"]').should('not.exist');
@@ -323,7 +418,9 @@ describe('Line chart', () => {
323
418
  it('displays only horizontal lines when the prop is set', () => {
324
419
  initialize({ axis: { gridLinesType: 'horizontal' } });
325
420
 
326
- cy.contains('8:00 AM').should('be.visible');
421
+ checkGraphWidth();
422
+
423
+ cy.contains(':00 AM').should('be.visible');
327
424
 
328
425
  cy.get('g[class="visx-group visx-rows"]').should('be.visible');
329
426
  cy.get('g[class="visx-group visx-columns"]').should('not.exist');
@@ -334,7 +431,9 @@ describe('Line chart', () => {
334
431
  it('displays only vertical lines when the prop is set', () => {
335
432
  initialize({ axis: { gridLinesType: 'vertical' } });
336
433
 
337
- cy.contains('8:00 AM').should('be.visible');
434
+ checkGraphWidth();
435
+
436
+ cy.contains(':00 AM').should('be.visible');
338
437
 
339
438
  cy.get('g[class="visx-group visx-rows"]').should('not.exist');
340
439
  cy.get('g[class="visx-group visx-columns"]').should('be.visible');
@@ -345,9 +444,13 @@ describe('Line chart', () => {
345
444
  it('rotates the tick label when the props is set', () => {
346
445
  initialize({ axis: { yAxisTickLabelRotation: -35 } });
347
446
 
348
- cy.contains('8:00 AM').should('be.visible');
447
+ checkGraphWidth();
448
+
449
+ cy.contains(':00 AM').should('be.visible');
349
450
 
350
- cy.get('text[transform="rotate(-35, -2, 388)"]').should('be.visible');
451
+ cy.get('text[transform="rotate(-35, -2, 312.508173777963)"]').should(
452
+ 'be.visible'
453
+ );
351
454
 
352
455
  cy.makeSnapshot();
353
456
  });
@@ -355,7 +458,9 @@ describe('Line chart', () => {
355
458
  it('displays as centered to zero when the prop is set', () => {
356
459
  initialize({ axis: { isCenteredZero: true } });
357
460
 
358
- cy.contains('8:00 AM').should('be.visible');
461
+ checkGraphWidth();
462
+
463
+ cy.contains(':00 AM').should('be.visible');
359
464
 
360
465
  cy.contains('0.9').should('be.visible');
361
466
  cy.contains('-0.9').should('be.visible');
@@ -368,7 +473,9 @@ describe('Line chart', () => {
368
473
  it('displays the curve in a natural style when the prop is set', () => {
369
474
  initialize({ lineStyle: { curve: 'natural' } });
370
475
 
371
- cy.contains('8:00 AM').should('be.visible');
476
+ checkGraphWidth();
477
+
478
+ cy.contains(':00 AM').should('be.visible');
372
479
  cy.get('[data-metric="13536"]').should('be.visible');
373
480
  cy.get('[data-metric="13534"]').should('be.visible');
374
481
  cy.get('[data-metric="13535"]').should('be.visible');
@@ -379,7 +486,9 @@ describe('Line chart', () => {
379
486
  it('displays the curve in a step style when the prop is set', () => {
380
487
  initialize({ lineStyle: { curve: 'step' } });
381
488
 
382
- cy.contains('8:00 AM').should('be.visible');
489
+ checkGraphWidth();
490
+
491
+ cy.contains(':00 AM').should('be.visible');
383
492
  cy.get('[data-metric="13536"]').should('be.visible');
384
493
  cy.get('[data-metric="13534"]').should('be.visible');
385
494
  cy.get('[data-metric="13535"]').should('be.visible');
@@ -391,7 +500,9 @@ describe('Line chart', () => {
391
500
  it('shows the area when the prop is set', () => {
392
501
  initialize({ lineStyle: { showArea: true } });
393
502
 
394
- cy.contains('8:00 AM').should('be.visible');
503
+ checkGraphWidth();
504
+
505
+ cy.contains(':00 AM').should('be.visible');
395
506
  cy.get('path[fill="rgba(102, 153, 204, 0.19999999999999996)"]').should(
396
507
  'be.visible'
397
508
  );
@@ -408,16 +519,19 @@ describe('Line chart', () => {
408
519
  it('shows the area with a custom transparency when props are set', () => {
409
520
  initialize({ lineStyle: { areaTransparency: 20, showArea: true } });
410
521
 
411
- cy.contains('8:00 AM').should('be.visible');
522
+ checkGraphWidth();
523
+
524
+ cy.contains(':00 AM').should('be.visible');
412
525
  cy.get('path[fill="rgba(102, 153, 204, 0.8)"]').should('be.visible');
413
526
  });
414
527
 
415
528
  it('shows points when the prop is set', () => {
416
529
  initialize({ lineStyle: { showPoints: true } });
417
530
 
418
- cy.contains('8:00 AM').should('be.visible');
531
+ checkGraphWidth();
532
+ cy.contains(':00 AM').should('be.visible');
419
533
  cy.get('circle[cx="4.0625"]').should('be.visible');
420
- cy.get('circle[cy="163.69430856642046"]').should('be.visible');
534
+ cy.get('circle[cy="105.21757370835121"]').should('be.visible');
421
535
 
422
536
  cy.makeSnapshot();
423
537
  });
@@ -425,7 +539,9 @@ describe('Line chart', () => {
425
539
  it('displays lines with a custom line width when the prop is set', () => {
426
540
  initialize({ lineStyle: { lineWidth: 6 } });
427
541
 
428
- cy.contains('8:00 AM').should('be.visible');
542
+ checkGraphWidth();
543
+
544
+ cy.contains(':00 AM').should('be.visible');
429
545
  cy.get('path[stroke-width="6"]').should('have.length', 3);
430
546
 
431
547
  cy.makeSnapshot();
@@ -434,7 +550,9 @@ describe('Line chart', () => {
434
550
  it('displays lines with dots width when the prop is set', () => {
435
551
  initialize({ lineStyle: { dotOffset: 10, lineWidth: 4 } });
436
552
 
437
- cy.contains('8:00 AM').should('be.visible');
553
+ checkGraphWidth();
554
+
555
+ cy.contains(':00 AM').should('be.visible');
438
556
  cy.get('path[stroke-width="4"]')
439
557
  .should('have.attr', 'stroke-dasharray')
440
558
  .and('equals', '4 10');
@@ -443,10 +561,141 @@ describe('Line chart', () => {
443
561
  it('displays lines with dots width when the prop is set', () => {
444
562
  initialize({ lineStyle: { dashLength: 5, dashOffset: 8 } });
445
563
 
446
- cy.contains('8:00 AM').should('be.visible');
564
+ checkGraphWidth();
565
+
566
+ cy.contains(':00 AM').should('be.visible');
447
567
  cy.get('path[stroke-width="2"]')
448
568
  .should('have.attr', 'stroke-dasharray')
449
569
  .and('equals', '5 8');
450
570
  });
451
571
  });
452
572
  });
573
+
574
+ describe('Lines and bars', () => {
575
+ it('displays lines and bars in the same chart', () => {
576
+ initialize({
577
+ data: dataPingServiceLinesBars
578
+ });
579
+
580
+ checkGraphWidth();
581
+
582
+ cy.get('path[data-metric="1"]').should('be.visible');
583
+ cy.get('path[data-metric="3"]').should('be.visible');
584
+ cy.get('path[data-metric="3"]').should('be.visible');
585
+ cy.findByTestId('stacked-bar-10-0-7650.368581547736').should('be.visible');
586
+ cy.findByTestId('stacked-bar-2-0-10').should('be.visible');
587
+
588
+ cy.makeSnapshot();
589
+ });
590
+
591
+ it('displays stacked lines and bars in the same chart', () => {
592
+ initialize({
593
+ data: dataPingServiceLinesBarsStacked
594
+ });
595
+
596
+ checkGraphWidth();
597
+
598
+ cy.get('path[data-metric="1"]').should('be.visible');
599
+ cy.get('path[data-metric="3"]').should('be.visible');
600
+ cy.get('path[data-metric="3"]').should('be.visible');
601
+ cy.findByTestId('stacked-bar-2-0-6835').should('be.visible');
602
+ cy.findByTestId('stacked-bar-10-0-14920.328518673756').should('be.visible');
603
+
604
+ cy.makeSnapshot();
605
+ });
606
+
607
+ it('displays mixed lines and bars in the same chart', () => {
608
+ initialize({
609
+ data: dataPingServiceLinesBarsMixed
610
+ });
611
+
612
+ checkGraphWidth();
613
+
614
+ cy.get('path[data-metric="1"]').should('be.visible');
615
+ cy.get('path[data-metric="3"]').should('be.visible');
616
+ cy.get('path[data-metric="3"]').should('be.visible');
617
+ cy.findByTestId('stacked-bar-10-0-7650.368581547736').should('be.visible');
618
+ cy.findByTestId('stacked-bar-2-0-10').should('be.visible');
619
+
620
+ cy.makeSnapshot();
621
+ });
622
+
623
+ it('displays lines and bars in the same chart centered in zero', () => {
624
+ initialize({
625
+ axis: {
626
+ isCenteredZero: true
627
+ },
628
+ data: dataPingServiceLinesBars
629
+ });
630
+
631
+ checkGraphWidth();
632
+
633
+ cy.get('path[data-metric="1"]').should('be.visible');
634
+ cy.get('path[data-metric="3"]').should('be.visible');
635
+ cy.get('path[data-metric="3"]').should('be.visible');
636
+ cy.findByTestId('stacked-bar-10-0-7650.368581547736').should('be.visible');
637
+ cy.findByTestId('stacked-bar-2-0-10').should('be.visible');
638
+
639
+ cy.makeSnapshot();
640
+ });
641
+
642
+ it('displays stacked lines and bars in the same chart centered in zero', () => {
643
+ initialize({
644
+ axis: {
645
+ isCenteredZero: true
646
+ },
647
+ data: dataPingServiceLinesBarsStacked
648
+ });
649
+
650
+ checkGraphWidth();
651
+
652
+ cy.get('path[data-metric="1"]').should('be.visible');
653
+ cy.get('path[data-metric="3"]').should('be.visible');
654
+ cy.get('path[data-metric="3"]').should('be.visible');
655
+ cy.findByTestId('stacked-bar-2-0-6835').should('be.visible');
656
+ cy.findByTestId('stacked-bar-10-0-14920.328518673756').should('be.visible');
657
+
658
+ cy.makeSnapshot();
659
+ });
660
+
661
+ it('displays mixed lines and bars in the same chart centered in zero', () => {
662
+ initialize({
663
+ axis: {
664
+ isCenteredZero: true
665
+ },
666
+ data: dataPingServiceLinesBarsMixed
667
+ });
668
+
669
+ checkGraphWidth();
670
+
671
+ cy.get('path[data-metric="1"]').should('be.visible');
672
+ cy.get('path[data-metric="3"]').should('be.visible');
673
+ cy.get('path[data-metric="3"]').should('be.visible');
674
+ cy.findByTestId('stacked-bar-10-0-7650.368581547736').should('be.visible');
675
+ cy.findByTestId('stacked-bar-2-0-10').should('be.visible');
676
+
677
+ cy.makeSnapshot();
678
+ });
679
+
680
+ it('changes the unit on the left or right scales when a new unit is selected', () => {
681
+ initializeCustomUnits({
682
+ data: dataPingServiceLinesBarsMixed
683
+ });
684
+
685
+ checkGraphWidth();
686
+
687
+ cy.findAllByTestId('unit-selector').eq(0).parent().click();
688
+ cy.findByLabelText('B').click();
689
+
690
+ cy.findAllByTestId('unit-selector').eq(0).should('have.value', 'B');
691
+ cy.contains('8.79 KB').should('be.visible');
692
+
693
+ cy.findAllByTestId('unit-selector').eq(1).parent().click();
694
+ cy.findByLabelText('%').click();
695
+
696
+ cy.findAllByTestId('unit-selector').eq(1).should('have.value', '%');
697
+ cy.contains('20').should('be.visible');
698
+
699
+ cy.makeSnapshot();
700
+ });
701
+ });