@scality/core-ui 0.162.0 → 0.164.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.
Files changed (73) hide show
  1. package/dist/components/barchartv2/Barchart.component.d.ts +9 -3
  2. package/dist/components/barchartv2/Barchart.component.d.ts.map +1 -1
  3. package/dist/components/barchartv2/Barchart.component.js +22 -5
  4. package/dist/components/barchartv2/utils.d.ts +26 -3
  5. package/dist/components/barchartv2/utils.d.ts.map +1 -1
  6. package/dist/components/barchartv2/utils.js +76 -22
  7. package/dist/components/chartlegend/ChartLegend.d.ts +8 -0
  8. package/dist/components/chartlegend/ChartLegend.d.ts.map +1 -0
  9. package/dist/components/chartlegend/ChartLegend.js +65 -0
  10. package/dist/components/chartlegend/ChartLegendWrapper.d.ts +17 -0
  11. package/dist/components/chartlegend/ChartLegendWrapper.d.ts.map +1 -0
  12. package/dist/components/chartlegend/ChartLegendWrapper.js +50 -0
  13. package/dist/components/date/FormattedDateTime.d.ts +3 -1
  14. package/dist/components/date/FormattedDateTime.d.ts.map +1 -1
  15. package/dist/components/date/FormattedDateTime.js +19 -1
  16. package/dist/components/date/FormattedDateTime.spec.js +12 -0
  17. package/dist/components/icon/Icon.component.d.ts +5 -5
  18. package/dist/components/icon/Icon.component.d.ts.map +1 -1
  19. package/dist/components/icon/Icon.component.js +33 -31
  20. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts +33 -0
  21. package/dist/components/linetimeseriechart/linetimeseriechart.component.d.ts.map +1 -0
  22. package/dist/components/linetimeseriechart/linetimeseriechart.component.js +249 -0
  23. package/dist/components/selectv2/Selectv2.component.d.ts.map +1 -1
  24. package/dist/components/selectv2/Selectv2.component.js +11 -6
  25. package/dist/components/steppers/Stepper.component.d.ts.map +1 -1
  26. package/dist/components/steppers/Stepper.component.js +9 -8
  27. package/dist/components/toast/ToastProvider.d.ts.map +1 -1
  28. package/dist/components/toast/ToastProvider.js +4 -5
  29. package/dist/components/vegachartv2/SyncedCursorCharts.d.ts.map +1 -1
  30. package/dist/components/vegachartv2/SyncedCursorCharts.js +3 -5
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +1 -0
  34. package/dist/next.d.ts +2 -0
  35. package/dist/next.d.ts.map +1 -1
  36. package/dist/next.js +2 -0
  37. package/dist/style/theme.d.ts +1 -0
  38. package/dist/style/theme.d.ts.map +1 -1
  39. package/dist/style/theme.js +28 -0
  40. package/package.json +2 -2
  41. package/src/lib/components/accordion/Accordion.test.tsx +8 -16
  42. package/src/lib/components/barchartv2/Barchart.component.test.tsx +117 -111
  43. package/src/lib/components/barchartv2/Barchart.component.tsx +54 -7
  44. package/src/lib/components/barchartv2/utils.test.ts +127 -2
  45. package/src/lib/components/barchartv2/utils.ts +103 -19
  46. package/src/lib/components/chartlegend/ChartLegend.tsx +113 -0
  47. package/src/lib/components/chartlegend/ChartLegendWrapper.tsx +85 -0
  48. package/src/lib/components/date/FormattedDateTime.spec.tsx +24 -0
  49. package/src/lib/components/date/FormattedDateTime.tsx +36 -2
  50. package/src/lib/components/healthselectorv2/HealthSelector.component.test.tsx +10 -10
  51. package/src/lib/components/icon/Icon.component.tsx +48 -60
  52. package/src/lib/components/infomessage/InfoMessageUtils.test.tsx +0 -1
  53. package/src/lib/components/inlineinput/InlineInput.test.tsx +28 -22
  54. package/src/lib/components/inputlist/InputList.test.tsx +22 -21
  55. package/src/lib/components/linetemporalchart/ChartUtil.test.ts +5 -4
  56. package/src/lib/components/linetimeseriechart/linetimeseriechart.component.tsx +502 -0
  57. package/src/lib/components/searchinput/SearchInput.test.tsx +3 -7
  58. package/src/lib/components/selectv2/Selectv2.component.tsx +13 -5
  59. package/src/lib/components/selectv2/selectv2.test.tsx +70 -61
  60. package/src/lib/components/steppers/Stepper.component.tsx +10 -8
  61. package/src/lib/components/tablev2/TableSync.test.tsx +8 -12
  62. package/src/lib/components/tablev2/TableUtils.test.ts +6 -3
  63. package/src/lib/components/tablev2/Tablev2.test.tsx +38 -40
  64. package/src/lib/components/toast/ToastProvider.tsx +14 -6
  65. package/src/lib/components/toggle/Toggle.test.tsx +1 -1
  66. package/src/lib/components/vegachartv2/SyncedCursorCharts.tsx +5 -7
  67. package/src/lib/index.ts +1 -0
  68. package/src/lib/next.ts +2 -0
  69. package/src/lib/style/theme.ts +29 -0
  70. package/stories/BarChart/barchart.stories.tsx +387 -129
  71. package/stories/format.mdx +4 -2
  72. package/stories/linetimeseriechart.stories.tsx +485 -0
  73. package/tsconfig.json +0 -1
package/src/lib/index.ts CHANGED
@@ -82,3 +82,4 @@ export { InfoMessage } from './components/infomessage/InfoMessage.component';
82
82
  export { InputList } from './components/inputlist/InputList.component';
83
83
  export { InlineInput } from './components/inlineinput/InlineInput';
84
84
  export { UnsuccessfulResult } from './components/UnsuccessfulResult.component';
85
+ export { LineTimeSerieChart } from './components/linetimeseriechart/linetimeseriechart.component';
package/src/lib/next.ts CHANGED
@@ -21,3 +21,5 @@ export {
21
21
  BarchartSortFn,
22
22
  BarchartTooltipFn,
23
23
  } from './components/barchartv2/Barchart.component';
24
+ export { ChartLegendWrapper } from './components/chartlegend/ChartLegendWrapper';
25
+ export { ChartLegend } from './components/chartlegend/ChartLegend';
@@ -1,3 +1,4 @@
1
+ import { lighten, darken } from 'polished';
1
2
  //== Colors
2
3
  export const hotPink = '#E40046';
3
4
  export const pink = '#EB4962';
@@ -291,3 +292,31 @@ export const navbarItemWidth = '4.286rem';
291
292
  //sidebar
292
293
  export const sidebarItemHeight = spacing.sp40;
293
294
  export const sidebarWidth = spacing.sp40;
295
+
296
+ // We use 8 main color from the palette and decline them (lighter/ darker) when we have more than 8 datasets
297
+ export const lineTimeSeriesColorRange = [
298
+ lineColor1,
299
+ lineColor2,
300
+ lineColor3,
301
+ lineColor4,
302
+ lineColor5,
303
+ lineColor6,
304
+ lineColor7,
305
+ lineColor8,
306
+ lighten(0.3, lineColor1),
307
+ lighten(0.3, lineColor2),
308
+ lighten(0.3, lineColor3),
309
+ lighten(0.3, lineColor4),
310
+ lighten(0.3, lineColor5),
311
+ lighten(0.3, lineColor6),
312
+ lighten(0.3, lineColor7),
313
+ lighten(0.3, lineColor8),
314
+ darken(0.2, lineColor1),
315
+ darken(0.2, lineColor2),
316
+ darken(0.2, lineColor3),
317
+ darken(0.2, lineColor4),
318
+ darken(0.3, lineColor5),
319
+ darken(0.3, lineColor6),
320
+ darken(0.3, lineColor7),
321
+ darken(0.3, lineColor8),
322
+ ];
@@ -10,13 +10,10 @@ import {
10
10
  import { Button } from '../../src/lib/components/buttonv2/Buttonv2.component';
11
11
  import { Text } from '../../src/lib/components/text/Text.component';
12
12
  import { spacing, Stack, Wrap } from '../../src/lib/spacing';
13
- import {
14
- CoreUITheme,
15
- lineColor1,
16
- lineColor2,
17
- lineColor3,
18
- } from '../../src/lib/style/theme';
13
+ import { CoreUITheme } from '../../src/lib/style/theme';
19
14
  import { Wrapper } from '../common';
15
+ import { ChartLegendWrapper } from '../../src/lib/components/chartlegend/ChartLegendWrapper';
16
+ import { ChartLegend } from '../../src/lib/components/chartlegend/ChartLegend';
20
17
 
21
18
  type Story = StoryObj<typeof Barchart>;
22
19
 
@@ -57,14 +54,17 @@ export const Playground: Story = {
57
54
  },
58
55
  ] as const;
59
56
  return (
60
- <Barchart
61
- type="category"
62
- bars={exampleData}
57
+ <ChartLegendWrapper
63
58
  colorSet={{
64
59
  Success: theme.statusHealthy,
65
60
  Failed: theme.statusCritical,
66
61
  }}
67
- />
62
+ >
63
+ <Stack direction="vertical" gap="r16">
64
+ <Barchart type="category" bars={exampleData} />
65
+ <ChartLegend shape="rectangle" direction="horizontal" />
66
+ </Stack>
67
+ </ChartLegendWrapper>
68
68
  );
69
69
  },
70
70
  };
@@ -114,27 +114,33 @@ export const Time7Days: Story = {
114
114
  render: () => {
115
115
  const theme = useTheme() as CoreUITheme;
116
116
  return (
117
- <Barchart
118
- type={{
119
- type: 'time',
120
- timeRange: {
121
- startDate: new Date(
122
- new Date(Date.now()).setHours(0, 0, 0, 0) -
123
- 7 * 24 * 60 * 60 * 1000,
124
- ),
125
- endDate: new Date(
126
- new Date(Date.now()).setHours(0, 0, 0, 0) -
127
- 1 * 24 * 60 * 60 * 1000,
128
- ),
129
- interval: 24 * 60 * 60 * 1000,
130
- },
131
- }}
132
- bars={timeData7Days}
117
+ <ChartLegendWrapper
133
118
  colorSet={{
134
119
  Success: theme.statusHealthy,
135
120
  Failed: theme.statusCritical,
136
121
  }}
137
- />
122
+ >
123
+ <Stack direction="vertical" gap="r16">
124
+ <Barchart
125
+ type={{
126
+ type: 'time',
127
+ timeRange: {
128
+ startDate: new Date(
129
+ new Date(Date.now()).setHours(0, 0, 0, 0) -
130
+ 7 * 24 * 60 * 60 * 1000,
131
+ ),
132
+ endDate: new Date(
133
+ new Date(Date.now()).setHours(0, 0, 0, 0) -
134
+ 1 * 24 * 60 * 60 * 1000,
135
+ ),
136
+ interval: 24 * 60 * 60 * 1000,
137
+ },
138
+ }}
139
+ bars={timeData7Days}
140
+ />
141
+ <ChartLegend shape="line" />
142
+ </Stack>
143
+ </ChartLegendWrapper>
138
144
  );
139
145
  },
140
146
  };
@@ -179,27 +185,30 @@ export const Time7DaysWithMissingData: Story = {
179
185
  render: () => {
180
186
  const theme = useTheme() as CoreUITheme;
181
187
  return (
182
- <Barchart
183
- type={{
184
- type: 'time',
185
- timeRange: {
186
- startDate: new Date(
187
- new Date(Date.now()).setHours(0, 0, 0, 0) -
188
- 7 * 24 * 60 * 60 * 1000,
189
- ),
190
- endDate: new Date(
191
- new Date(Date.now()).setHours(0, 0, 0, 0) -
192
- 1 * 24 * 60 * 60 * 1000,
193
- ),
194
- interval: 24 * 60 * 60 * 1000,
195
- },
196
- }}
197
- bars={timeData7DaysWithMissingData}
188
+ <ChartLegendWrapper
198
189
  colorSet={{
199
190
  Success: theme.statusHealthy,
200
191
  Failed: theme.statusCritical,
201
192
  }}
202
- />
193
+ >
194
+ <Barchart
195
+ type={{
196
+ type: 'time',
197
+ timeRange: {
198
+ startDate: new Date(
199
+ new Date(Date.now()).setHours(0, 0, 0, 0) -
200
+ 7 * 24 * 60 * 60 * 1000,
201
+ ),
202
+ endDate: new Date(
203
+ new Date(Date.now()).setHours(0, 0, 0, 0) -
204
+ 1 * 24 * 60 * 60 * 1000,
205
+ ),
206
+ interval: 24 * 60 * 60 * 1000,
207
+ },
208
+ }}
209
+ bars={timeData7DaysWithMissingData}
210
+ />
211
+ </ChartLegendWrapper>
203
212
  );
204
213
  },
205
214
  };
@@ -269,23 +278,26 @@ export const TimeLast24Hours: Story = {
269
278
  render: () => {
270
279
  const theme = useTheme() as CoreUITheme;
271
280
  return (
272
- <Barchart
273
- type={{
274
- type: 'time',
275
- timeRange: {
276
- startDate: new Date(
277
- new Date(Date.now()).setMinutes(0, 0, 0) - 24 * 60 * 60 * 1000,
278
- ),
279
- endDate: new Date(new Date(Date.now()).setMinutes(0, 0, 0)),
280
- interval: 60 * 60 * 1000,
281
- },
282
- }}
283
- bars={timeDataLast24Hours}
281
+ <ChartLegendWrapper
284
282
  colorSet={{
285
283
  Success: theme.statusHealthy,
286
284
  Failed: theme.statusCritical,
287
285
  }}
288
- />
286
+ >
287
+ <Barchart
288
+ type={{
289
+ type: 'time',
290
+ timeRange: {
291
+ startDate: new Date(
292
+ new Date(Date.now()).setMinutes(0, 0, 0) - 24 * 60 * 60 * 1000,
293
+ ),
294
+ endDate: new Date(new Date(Date.now()).setMinutes(0, 0, 0)),
295
+ interval: 60 * 60 * 1000,
296
+ },
297
+ }}
298
+ bars={timeDataLast24Hours}
299
+ />
300
+ </ChartLegendWrapper>
289
301
  );
290
302
  },
291
303
  };
@@ -313,39 +325,42 @@ export const CapacityWithUnitRange: Story = {
313
325
  render: () => {
314
326
  const theme = useTheme() as CoreUITheme;
315
327
  return (
316
- <Barchart
317
- type="category"
318
- bars={capacityDataWithUnitRange}
319
- unitRange={[
320
- {
321
- threshold: 0,
322
- label: 'B',
323
- },
324
- {
325
- threshold: 1024,
326
- label: 'KiB',
327
- },
328
- {
329
- threshold: 1024 * 1024,
330
- label: 'MiB',
331
- },
332
- {
333
- threshold: 1024 * 1024 * 1024,
334
- label: 'GiB',
335
- },
336
- ]}
328
+ <ChartLegendWrapper
337
329
  colorSet={{
338
330
  Free: theme.selectedActive,
339
331
  Used: theme.infoSecondary,
340
332
  }}
341
- />
333
+ >
334
+ <Barchart
335
+ type="category"
336
+ bars={capacityDataWithUnitRange}
337
+ unitRange={[
338
+ {
339
+ threshold: 0,
340
+ label: 'B',
341
+ },
342
+ {
343
+ threshold: 1024,
344
+ label: 'KiB',
345
+ },
346
+ {
347
+ threshold: 1024 * 1024,
348
+ label: 'MiB',
349
+ },
350
+ {
351
+ threshold: 1024 * 1024 * 1024,
352
+ label: 'GiB',
353
+ },
354
+ ]}
355
+ />
356
+ </ChartLegendWrapper>
342
357
  );
343
358
  },
344
359
  };
345
360
 
346
361
  const stackedData: BarchartProps<
347
362
  {
348
- label: 'Success' | 'Failed';
363
+ label: 'Success' | 'Failed' | 'Warning';
349
364
  data: [string, number][];
350
365
  }[]
351
366
  >['bars'] = [
@@ -360,9 +375,17 @@ const stackedData: BarchartProps<
360
375
  {
361
376
  label: 'Failed',
362
377
  data: [
363
- ['category1', 8],
364
- ['category2', 10],
365
- ['category3', 25],
378
+ ['category1', 0],
379
+ ['category2', 0],
380
+ ['category3', 0],
381
+ ],
382
+ },
383
+ {
384
+ label: 'Warning',
385
+ data: [
386
+ ['category1', 0],
387
+ ['category2', 0],
388
+ ['category3', 0],
366
389
  ],
367
390
  },
368
391
  ];
@@ -371,15 +394,18 @@ export const Stacked: Story = {
371
394
  render: () => {
372
395
  const theme = useTheme() as CoreUITheme;
373
396
  return (
374
- <Barchart
375
- type="category"
376
- bars={stackedData}
377
- stacked
397
+ <ChartLegendWrapper
378
398
  colorSet={{
379
399
  Success: theme.statusHealthy,
380
400
  Failed: theme.statusCritical,
401
+ Warning: theme.statusWarning,
381
402
  }}
382
- />
403
+ >
404
+ <Stack direction="vertical" gap="r16">
405
+ <Barchart type="category" bars={stackedData} stacked />
406
+ <ChartLegend shape="rectangle" />
407
+ </Stack>
408
+ </ChartLegendWrapper>
383
409
  );
384
410
  },
385
411
  };
@@ -420,16 +446,19 @@ export const DefaultSort: Story = {
420
446
  return totalA - totalB > 0 ? -1 : totalA - totalB < 0 ? 1 : 0; // Descending order
421
447
  };
422
448
  return (
423
- <Barchart
424
- type="category"
425
- stacked
426
- bars={defaultSortData}
427
- defaultSort={customSort}
449
+ <ChartLegendWrapper
428
450
  colorSet={{
429
451
  Success: theme.statusHealthy,
430
452
  Failed: theme.statusCritical,
431
453
  }}
432
- />
454
+ >
455
+ <Barchart
456
+ type="category"
457
+ stacked
458
+ bars={defaultSortData}
459
+ defaultSort={customSort}
460
+ />
461
+ </ChartLegendWrapper>
433
462
  );
434
463
  },
435
464
  };
@@ -494,16 +523,22 @@ export const WithCustomTooltip: Story = {
494
523
  <Text variant="Basic" color="textSecondary">
495
524
  Tooltip and sort functions defined outside with full type safety
496
525
  </Text>
497
- <Barchart
498
- type="category"
499
- bars={exampleData}
500
- tooltip={customTooltip}
501
- height={300}
526
+ <ChartLegendWrapper
502
527
  colorSet={{
503
528
  Success: theme.statusHealthy,
504
529
  Failed: theme.statusCritical,
505
530
  }}
506
- />
531
+ >
532
+ <Stack direction="vertical" gap="r16">
533
+ <Barchart
534
+ type="category"
535
+ bars={exampleData}
536
+ tooltip={customTooltip}
537
+ height={300}
538
+ />
539
+ <ChartLegend shape="line" />
540
+ </Stack>
541
+ </ChartLegendWrapper>
507
542
  </Stack>
508
543
  );
509
544
  },
@@ -558,17 +593,236 @@ export const StatusColors: Story = {
558
593
  },
559
594
  ] as const;
560
595
  return (
561
- <Barchart
562
- type="category"
563
- bars={statusData}
564
- stacked
596
+ <ChartLegendWrapper
565
597
  colorSet={{
566
598
  'Success Rate': theme.statusHealthy,
567
599
  'Failed Requests': theme.statusCritical,
568
600
  'Warning Events': theme.statusWarning,
569
601
  }}
570
- title="System Health Metrics"
571
- />
602
+ >
603
+ <Stack direction="vertical" gap="r16">
604
+ <Barchart
605
+ type="category"
606
+ bars={statusData}
607
+ stacked
608
+ title="System Health Metrics"
609
+ />
610
+ <ChartLegend shape="rectangle" />
611
+ </Stack>
612
+ </ChartLegendWrapper>
613
+ );
614
+ },
615
+ };
616
+
617
+ export const LegendShapes: Story = {
618
+ render: () => {
619
+ const theme = useTheme() as CoreUITheme;
620
+ const exampleData = [
621
+ {
622
+ label: 'Success',
623
+ data: [
624
+ ['category1', 25],
625
+ ['category2', 40],
626
+ ['category3', 35],
627
+ ],
628
+ },
629
+ {
630
+ label: 'Failed',
631
+ data: [
632
+ ['category1', 15],
633
+ ['category2', 20],
634
+ ['category3', 18],
635
+ ],
636
+ },
637
+ {
638
+ label: 'Warning',
639
+ data: [
640
+ ['category1', 8],
641
+ ['category2', 12],
642
+ ['category3', 10],
643
+ ],
644
+ },
645
+ ] as const;
646
+ return (
647
+ <Stack direction="vertical" gap="r24">
648
+ <Text variant="Large">Legend Shapes</Text>
649
+
650
+ <ChartLegendWrapper
651
+ colorSet={{
652
+ Success: theme.statusHealthy,
653
+ Failed: theme.statusCritical,
654
+ Warning: theme.statusWarning,
655
+ }}
656
+ >
657
+ <Stack direction="vertical" gap="r16">
658
+ <Barchart
659
+ type="category"
660
+ bars={exampleData}
661
+ height={200}
662
+ title="Horizontal Rectangle Legend"
663
+ />
664
+ <ChartLegend shape="rectangle" />
665
+ </Stack>
666
+ </ChartLegendWrapper>
667
+ <ChartLegendWrapper
668
+ colorSet={{
669
+ Success: theme.statusHealthy,
670
+ Failed: theme.statusCritical,
671
+ Warning: theme.statusWarning,
672
+ }}
673
+ >
674
+ <Stack direction="vertical" gap="r16">
675
+ <Barchart
676
+ type="category"
677
+ bars={exampleData}
678
+ height={200}
679
+ title="Vertical Line Legend"
680
+ />
681
+ <ChartLegend shape="line" direction="vertical" />
682
+ </Stack>
683
+ </ChartLegendWrapper>
684
+ </Stack>
685
+ );
686
+ },
687
+ };
688
+
689
+ export const BarchartsWithSingleLegend: Story = {
690
+ render: () => {
691
+ const theme = useTheme() as CoreUITheme;
692
+ const exampleData = [
693
+ {
694
+ label: 'Success',
695
+ data: [
696
+ ['category1', 25],
697
+ ['category2', 40],
698
+ ['category3', 35],
699
+ ],
700
+ },
701
+ {
702
+ label: 'Failed',
703
+ data: [
704
+ ['category1', 15],
705
+ ['category2', 20],
706
+ ['category3', 18],
707
+ ],
708
+ },
709
+ {
710
+ label: 'Warning',
711
+ data: [
712
+ ['category1', 8],
713
+ ['category2', 12],
714
+ ['category3', 10],
715
+ ],
716
+ },
717
+ ] as const;
718
+ return (
719
+ <Stack direction="vertical" gap="r24">
720
+ <Text variant="Large">Barcharts with Single Shared Legend</Text>
721
+
722
+ <ChartLegendWrapper
723
+ colorSet={{
724
+ Success: theme.statusHealthy,
725
+ Failed: theme.statusCritical,
726
+ Warning: theme.statusWarning,
727
+ }}
728
+ >
729
+ <Barchart
730
+ type="category"
731
+ bars={exampleData}
732
+ height={200}
733
+ title="Barchart 1"
734
+ />
735
+
736
+ <Barchart
737
+ type="category"
738
+ bars={exampleData}
739
+ height={200}
740
+ title="Barchart 2"
741
+ />
742
+ <ChartLegend shape="rectangle" />
743
+ </ChartLegendWrapper>
744
+ </Stack>
745
+ );
746
+ },
747
+ };
748
+
749
+ export const ErrorState: Story = {
750
+ render: () => {
751
+ const theme = useTheme() as CoreUITheme;
752
+ return (
753
+ <ChartLegendWrapper
754
+ colorSet={{
755
+ Success: theme.statusHealthy,
756
+ Failed: theme.statusCritical,
757
+ }}
758
+ >
759
+ <Barchart
760
+ type="category"
761
+ bars={[]}
762
+ isError
763
+ title="Error State"
764
+ helpTooltip="This chart data could not be loaded"
765
+ />
766
+ <ChartLegend shape="rectangle" />
767
+ </ChartLegendWrapper>
768
+ );
769
+ },
770
+ };
771
+
772
+ export const StackedBarSort: Story = {
773
+ render: () => {
774
+ const theme = useTheme() as CoreUITheme;
775
+ const [sort, setSort] = useState<'default' | 'legend'>('default');
776
+ const statusesData = [
777
+ {
778
+ label: 'Success',
779
+ data: [
780
+ ['category1', 100],
781
+ ['category2', 80],
782
+ ['category3', 50],
783
+ ],
784
+ },
785
+ {
786
+ label: 'Warning',
787
+ data: [
788
+ ['category1', 10],
789
+ ['category2', 20],
790
+ ['category3', 30],
791
+ ],
792
+ },
793
+ {
794
+ label: 'Failed',
795
+ data: [
796
+ ['category1', 30],
797
+ ['category2', 40],
798
+ ['category3', 50],
799
+ ],
800
+ },
801
+ ] as const;
802
+ return (
803
+ <ChartLegendWrapper
804
+ colorSet={{
805
+ Success: theme.statusHealthy,
806
+ Warning: theme.statusWarning,
807
+ Failed: theme.statusCritical,
808
+ }}
809
+ >
810
+ <Barchart
811
+ type="category"
812
+ bars={statusesData}
813
+ stacked
814
+ stackedBarSort={sort}
815
+ title="Stacked Bar Chart"
816
+ helpTooltip="This chart data could not be loaded"
817
+ rightTitle={
818
+ <Button
819
+ label={sort === 'default' ? 'Sort by Legend' : 'Sort by Default'}
820
+ onClick={() => setSort(sort === 'default' ? 'legend' : 'default')}
821
+ />
822
+ }
823
+ />
824
+ <ChartLegend shape="rectangle" />
825
+ </ChartLegendWrapper>
572
826
  );
573
827
  },
574
828
  };
@@ -622,33 +876,37 @@ export const CompleteExample: Story = {
622
876
  backgroundColor: theme.backgroundLevel2,
623
877
  }}
624
878
  >
625
- <Barchart
626
- type="category"
627
- title="Loading BarChart"
628
- helpTooltip="Click on the button to load or unload data"
629
- secondaryTitle={isLoading ? 'Loading...' : 'Loaded data'}
630
- rightTitle={
631
- <Button
632
- label={isLoading ? 'Load data' : 'Fake loading data'}
633
- onClick={() => {
634
- setIsLoading(!isLoading);
635
- if (isLoading) {
636
- setData(exampleData);
637
- } else {
638
- setData(undefined);
639
- }
640
- }}
641
- />
642
- }
643
- bars={data || []}
644
- tooltip={customTooltip}
645
- isLoading={isLoading}
646
- height={200}
879
+ <ChartLegendWrapper
647
880
  colorSet={{
648
881
  Success: 'lineColor1',
649
882
  Failed: 'lineColor2',
650
883
  }}
651
- />
884
+ >
885
+ <Barchart
886
+ type="category"
887
+ title="Loading BarChart"
888
+ helpTooltip="Click on the button to load or unload data"
889
+ secondaryTitle={isLoading ? 'Loading...' : 'Loaded data'}
890
+ rightTitle={
891
+ <Button
892
+ label={isLoading ? 'Load data' : 'Fake loading data'}
893
+ onClick={() => {
894
+ setIsLoading(!isLoading);
895
+ if (isLoading) {
896
+ setData(exampleData);
897
+ } else {
898
+ setData(undefined);
899
+ }
900
+ }}
901
+ />
902
+ }
903
+ bars={data}
904
+ tooltip={customTooltip}
905
+ isLoading={isLoading}
906
+ height={200}
907
+ />
908
+ <ChartLegend shape="rectangle" direction="horizontal" />
909
+ </ChartLegendWrapper>
652
910
  </div>
653
911
  );
654
912
  },
@@ -32,8 +32,10 @@ import { Meta } from '@storybook/blocks';
32
32
  | Short#1 | DD MMM | 20 Jul | 5 | Chart time axis |
33
33
  | Short#2 | DDMMM HH:mm | 20Jul 09:00 | 11 | Limited space, year not needed |
34
34
  | Short#3 | YYYY-MM-DD | 2020-07-20 | 10 | Tables |
35
- | Mid#1 | YYYY-MM-DD HH:mm | 2020-07-20 09:00 | 16 | Tables (creation/modification dates) |
36
- | Mid#2 | YYYY-MM-DD HH:mm:ss | 2020-07-20 09:00:00 | 19 | When the seconds are needed |
35
+ | Mid#1 | DD MMM HH:mm | 20 Jul 09:00 | 12 | Chart Axis ticks |
36
+ | Mid#2 | DD MMM HH:mm:ss | 20 Jul 09:00:00 | 15 | Chart Tooltip title |
37
+ | Mid#3 | YYYY-MM-DD HH:mm | 2020-07-20 09:00 | 16 | Tables (creation/modification dates) |
38
+ | Mid#4 | YYYY-MM-DD HH:mm:ss | 2020-07-20 09:00:00 | 19 | When the seconds are needed |
37
39
  | Full#1 | EEE MMM DD YYYY HH:mm:ss | Mon Jul 20 2020 09:00:00 | 24 | When a lot of space (hover) - When precision is needed |
38
40
 
39
41
  ### Remarks: