@react-magma/charts 16.0.0-next.0 → 16.0.0-v6-next.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 (89) hide show
  1. package/dist/charts.js +1632 -221
  2. package/dist/charts.js.map +1 -1
  3. package/dist/charts.modern.module.js +1634 -224
  4. package/dist/charts.modern.module.js.map +1 -1
  5. package/dist/charts.umd.js +49747 -28263
  6. package/dist/charts.umd.js.map +1 -1
  7. package/dist/components/CarbonChart/CarbonChart.d.ts +1 -1
  8. package/dist/components/CarbonChart/CarbonChartArea.stories.d.ts +310 -0
  9. package/dist/components/CarbonChart/CarbonChartAreaStacked.stories.d.ts +136 -0
  10. package/dist/components/CarbonChart/CarbonChartBar.stories.d.ts +232 -0
  11. package/dist/components/CarbonChart/CarbonChartBarFloating.stories.d.ts +82 -0
  12. package/dist/components/CarbonChart/CarbonChartBarGrouped.stories.d.ts +234 -0
  13. package/dist/components/CarbonChart/CarbonChartBarStacked.stories.d.ts +266 -0
  14. package/dist/components/CarbonChart/CarbonChartBoxplot.stories.d.ts +53 -0
  15. package/dist/components/CarbonChart/CarbonChartBubble.stories.d.ts +196 -0
  16. package/dist/components/CarbonChart/CarbonChartBullet.stories.d.ts +35 -0
  17. package/dist/components/CarbonChart/CarbonChartCombo.stories.d.ts +580 -0
  18. package/dist/components/CarbonChart/CarbonChartDonut.stories.d.ts +120 -0
  19. package/dist/components/CarbonChart/CarbonChartGauge.stories.d.ts +43 -0
  20. package/dist/components/CarbonChart/CarbonChartHistogram.stories.d.ts +89 -0
  21. package/dist/components/CarbonChart/CarbonChartLine.stories.d.ts +577 -0
  22. package/dist/components/CarbonChart/CarbonChartLollipop.stories.d.ts +55 -0
  23. package/dist/components/CarbonChart/CarbonChartMeter.stories.d.ts +127 -0
  24. package/dist/components/CarbonChart/CarbonChartPie.stories.d.ts +101 -0
  25. package/dist/components/CarbonChart/CarbonChartRadar.stories.d.ts +98 -0
  26. package/dist/components/CarbonChart/CarbonChartScatter.stories.d.ts +173 -0
  27. package/dist/components/CarbonChart/CarbonChartSparkline.stories.d.ts +51 -0
  28. package/dist/components/CarbonChart/CarbonChartStep.stories.d.ts +38 -0
  29. package/dist/components/ChartTable/ChartTable.stories.d.ts +166 -0
  30. package/dist/components/LineChart/Chart.d.ts +27 -0
  31. package/dist/components/LineChart/ChartDataTable.d.ts +17 -0
  32. package/dist/components/LineChart/CustomAxisComponent.d.ts +3 -0
  33. package/dist/components/LineChart/CustomPointComponent.d.ts +17 -0
  34. package/dist/components/LineChart/DataTable.d.ts +5 -0
  35. package/dist/components/LineChart/GraphTooltip.d.ts +3 -0
  36. package/dist/components/LineChart/LegendButton.d.ts +6 -0
  37. package/dist/components/LineChart/LineChart.d.ts +67 -0
  38. package/dist/components/LineChart/LineChart.stories.d.ts +113 -0
  39. package/dist/components/LineChart/index.d.ts +1 -0
  40. package/dist/components/LineChart/magma-charts.d.ts +1 -0
  41. package/dist/index.d.ts +1 -0
  42. package/package.json +21 -24
  43. package/src/components/CarbonChart/CarbonChart.test.js +316 -188
  44. package/src/components/CarbonChart/CarbonChart.tsx +94 -84
  45. package/src/components/CarbonChart/CarbonChartArea.stories.tsx +5 -3
  46. package/src/components/CarbonChart/CarbonChartAreaStacked.stories.tsx +5 -3
  47. package/src/components/CarbonChart/CarbonChartBar.stories.tsx +5 -3
  48. package/src/components/CarbonChart/CarbonChartBarFloating.stories.tsx +5 -3
  49. package/src/components/CarbonChart/CarbonChartBarGrouped.stories.tsx +5 -3
  50. package/src/components/CarbonChart/CarbonChartBarStacked.stories.tsx +5 -3
  51. package/src/components/CarbonChart/CarbonChartBoxplot.stories.tsx +5 -3
  52. package/src/components/CarbonChart/CarbonChartBubble.stories.tsx +5 -3
  53. package/src/components/CarbonChart/CarbonChartBullet.stories.tsx +5 -3
  54. package/src/components/CarbonChart/CarbonChartCombo.stories.tsx +5 -3
  55. package/src/components/CarbonChart/CarbonChartDonut.stories.tsx +5 -3
  56. package/src/components/CarbonChart/CarbonChartGauge.stories.tsx +5 -3
  57. package/src/components/CarbonChart/CarbonChartHistogram.stories.tsx +5 -3
  58. package/src/components/CarbonChart/CarbonChartLine.stories.tsx +5 -3
  59. package/src/components/CarbonChart/CarbonChartLollipop.stories.tsx +5 -3
  60. package/src/components/CarbonChart/CarbonChartMeter.stories.tsx +5 -3
  61. package/src/components/CarbonChart/CarbonChartPie.stories.tsx +5 -3
  62. package/src/components/CarbonChart/CarbonChartRadar.stories.tsx +5 -3
  63. package/src/components/CarbonChart/CarbonChartScatter.stories.tsx +5 -3
  64. package/src/components/CarbonChart/CarbonChartSparkline.stories.tsx +5 -3
  65. package/src/components/CarbonChart/CarbonChartStep.stories.tsx +5 -3
  66. package/src/components/ChartTable/ChartDataTable.tsx +0 -3
  67. package/src/components/ChartTable/ChartFullscreenButton.tsx +7 -1
  68. package/src/components/ChartTable/ChartMoreOptionsButton.tsx +2 -1
  69. package/src/components/ChartTable/ChartTable.test.js +3 -9
  70. package/src/components/ChartTable/ChartTableButton.tsx +7 -2
  71. package/src/components/ChartTable/ChartTableModal.tsx +1 -1
  72. package/src/components/ChartTable/ChartToolbar.tsx +0 -1
  73. package/src/components/ChartTable/chartToolbarI18n.ts +1 -1
  74. package/src/components/LineChart/Chart.tsx +241 -0
  75. package/src/components/LineChart/ChartDataTable.test.js +165 -0
  76. package/src/components/LineChart/ChartDataTable.tsx +135 -0
  77. package/src/components/LineChart/CustomAxisComponent.tsx +30 -0
  78. package/src/components/LineChart/CustomPointComponent.tsx +93 -0
  79. package/src/components/LineChart/DataTable.tsx +57 -0
  80. package/src/components/LineChart/GraphTooltip.tsx +100 -0
  81. package/src/components/LineChart/LegendButton.tsx +77 -0
  82. package/src/components/LineChart/LineChart.stories.tsx +399 -0
  83. package/src/components/LineChart/LineChart.test.js +501 -0
  84. package/src/components/LineChart/LineChart.tsx +669 -0
  85. package/src/components/LineChart/index.ts +1 -0
  86. package/src/components/LineChart/magma-charts.ts +279 -0
  87. package/src/components/LineChart/test/exampleChartData.js +289 -0
  88. package/src/hooks/useCarbonModalFocusManagement.ts +0 -12
  89. package/src/index.ts +1 -0
@@ -1,3 +1,4 @@
1
+ /* eslint-disable complexity */
1
2
  import * as React from 'react';
2
3
 
3
4
  import {
@@ -131,7 +132,7 @@ export interface ChartToolbarConfig {
131
132
  }
132
133
 
133
134
  export interface CarbonChartProps extends React.HTMLAttributes<HTMLDivElement> {
134
- dataSet: Array<object>;
135
+ dataSet: Array<Object>;
135
136
  isInverse?: boolean;
136
137
  /**
137
138
  * For a complete list of options, see Carbon Charts documentation
@@ -185,7 +186,7 @@ const FullscreenRoot = styled.div<{
185
186
  &:-webkit-full-screen {
186
187
  background: ${props =>
187
188
  props.isInverse
188
- ? props.theme.colors.primary700
189
+ ? props.theme.colors.indigo700
189
190
  : props.theme.colors.neutral100};
190
191
 
191
192
  ${props =>
@@ -244,7 +245,7 @@ const CarbonChartWrapper = styled.div<{
244
245
  &:-webkit-full-screen {
245
246
  background: ${props =>
246
247
  props.isInverse
247
- ? props.theme.colors.primary700
248
+ ? props.theme.colors.indigo700
248
249
  : props.theme.colors.neutral100};
249
250
 
250
251
  .cds--chart-holder {
@@ -256,17 +257,20 @@ const CarbonChartWrapper = styled.div<{
256
257
  .cds--chart-holder.filled .cds--cc--chart-wrapper {
257
258
  background-color: ${props =>
258
259
  props.isInverse
259
- ? props.theme.colors.primary600
260
+ ? props.theme.colors.indigo600
260
261
  : props.theme.colors.neutral100};
261
262
  }
262
263
 
263
264
  .cds--data-table thead tr th {
264
265
  background: ${props =>
265
- props.isInverse ? props.theme.colors.primary700 : ''} !important;
266
+ props.isInverse ? props.theme.colors.indigo700 : ''} !important;
266
267
  }
267
268
  .cds--data-table td,
268
- .cds--data-table tbody th {
269
- color: ${props => props.theme.colors.neutral700};
269
+ .cds--data-table th {
270
+ color: ${props =>
271
+ props.isInverse
272
+ ? props.theme.colors.neutral100
273
+ : props.theme.colors.brand.navy};
270
274
  }
271
275
  .cds--data-table tbody tr,
272
276
  .cds--data-table tbody tr td,
@@ -283,7 +287,7 @@ const CarbonChartWrapper = styled.div<{
283
287
  color: ${props =>
284
288
  props.isInverse
285
289
  ? props.theme.colors.neutral100
286
- : props.theme.colors.neutral700};
290
+ : props.theme.colors.brand.navy};
287
291
  max-width: 142px;
288
292
  white-space: normal;
289
293
  }
@@ -291,10 +295,10 @@ const CarbonChartWrapper = styled.div<{
291
295
  .cds--modal-container {
292
296
  clip-path: inset(0% 0% 0% 0% round ${props => props.theme.borderRadius});
293
297
  background: ${props =>
294
- props.isInverse ? props.theme.colors.primary700 : ''};
298
+ props.isInverse ? props.theme.colors.indigo700 : ''};
295
299
  .cds--data-table th {
296
300
  background: ${props =>
297
- props.isInverse ? props.theme.colors.primary600 : ''};
301
+ props.isInverse ? props.theme.colors.indigo600 : ''};
298
302
  }
299
303
  .cds--data-table td {
300
304
  border-top: 1px solid
@@ -311,7 +315,7 @@ const CarbonChartWrapper = styled.div<{
311
315
  }
312
316
  .cds--data-table tr:hover td {
313
317
  background: ${props =>
314
- props.isInverse ? props.theme.colors.primary600 : ''};
318
+ props.isInverse ? props.theme.colors.indigo600 : ''};
315
319
  }
316
320
  }
317
321
 
@@ -319,13 +323,28 @@ const CarbonChartWrapper = styled.div<{
319
323
  .chart-holder div,
320
324
  .chart-holder text,
321
325
  .cds--cc--axes g.axis .axis-title,
322
- .cds--cc--title p.title,
323
326
  .cds--cc--axes g.axis g.tick text {
324
327
  font-family: ${props => props.theme.bodyFont} !important;
325
328
  color: ${props =>
326
329
  props.isInverse
327
330
  ? props.theme.colors.neutral100
328
- : props.theme.colors.neutral700};
331
+ : props.theme.colors.brand.navy};
332
+ }
333
+
334
+ .chart-holder text,
335
+ .cds--cc--axes g.axis .axis-title,
336
+ .cds--cc--axes g.axis g.tick text {
337
+ fill: ${props =>
338
+ props.isInverse
339
+ ? props.theme.colors.neutral100
340
+ : props.theme.colors.brand.navy} !important;
341
+ }
342
+
343
+ .cds--cc--title p.title {
344
+ color: ${props =>
345
+ props.isInverse
346
+ ? props.theme.colors.neutral100
347
+ : props.theme.colors.brand.navy} !important;
329
348
  }
330
349
 
331
350
  .cds--cc--axes {
@@ -412,28 +431,28 @@ const CarbonChartWrapper = styled.div<{
412
431
  1px 0px 0px
413
432
  ${props =>
414
433
  props.isInverse
415
- ? props.theme.colors.primary600
434
+ ? props.theme.colors.indigo600
416
435
  : props.theme.colors.neutral100}
417
436
  )
418
437
  drop-shadow(
419
438
  -1px 0px 0px
420
439
  ${props =>
421
440
  props.isInverse
422
- ? props.theme.colors.primary600
441
+ ? props.theme.colors.indigo600
423
442
  : props.theme.colors.neutral100}
424
443
  )
425
444
  drop-shadow(
426
445
  0px 1px 0px
427
446
  ${props =>
428
447
  props.isInverse
429
- ? props.theme.colors.primary600
448
+ ? props.theme.colors.indigo600
430
449
  : props.theme.colors.neutral100}
431
450
  )
432
451
  drop-shadow(
433
452
  0px -1px 0px
434
453
  ${props =>
435
454
  props.isInverse
436
- ? props.theme.colors.primary600
455
+ ? props.theme.colors.indigo600
437
456
  : props.theme.colors.neutral100}
438
457
  );
439
458
  }
@@ -444,28 +463,28 @@ const CarbonChartWrapper = styled.div<{
444
463
  1px 0px 0px
445
464
  ${props =>
446
465
  props.isInverse
447
- ? props.theme.colors.primary600
466
+ ? props.theme.colors.indigo600
448
467
  : props.theme.colors.neutral100}
449
468
  )
450
469
  drop-shadow(
451
470
  -1px 0px 0px
452
471
  ${props =>
453
472
  props.isInverse
454
- ? props.theme.colors.primary600
473
+ ? props.theme.colors.indigo600
455
474
  : props.theme.colors.neutral100}
456
475
  )
457
476
  drop-shadow(
458
477
  0px 1px 0px
459
478
  ${props =>
460
479
  props.isInverse
461
- ? props.theme.colors.primary600
480
+ ? props.theme.colors.indigo600
462
481
  : props.theme.colors.neutral100}
463
482
  )
464
483
  drop-shadow(
465
484
  0px -1px 0px
466
485
  ${props =>
467
486
  props.isInverse
468
- ? props.theme.colors.primary600
487
+ ? props.theme.colors.indigo600
469
488
  : props.theme.colors.neutral100}
470
489
  );
471
490
  }
@@ -486,28 +505,28 @@ const CarbonChartWrapper = styled.div<{
486
505
  1px 0px 0px
487
506
  ${props =>
488
507
  props.isInverse
489
- ? props.theme.colors.primary600
508
+ ? props.theme.colors.indigo600
490
509
  : props.theme.colors.neutral100}
491
510
  )
492
511
  drop-shadow(
493
512
  -1px 0px 0px
494
513
  ${props =>
495
514
  props.isInverse
496
- ? props.theme.colors.primary600
515
+ ? props.theme.colors.indigo600
497
516
  : props.theme.colors.neutral100}
498
517
  )
499
518
  drop-shadow(
500
519
  0px 1px 0px
501
520
  ${props =>
502
521
  props.isInverse
503
- ? props.theme.colors.primary600
522
+ ? props.theme.colors.indigo600
504
523
  : props.theme.colors.neutral100}
505
524
  )
506
525
  drop-shadow(
507
526
  0px -1px 0px
508
527
  ${props =>
509
528
  props.isInverse
510
- ? props.theme.colors.primary600
529
+ ? props.theme.colors.indigo600
511
530
  : props.theme.colors.neutral100}
512
531
  );
513
532
  }
@@ -525,11 +544,10 @@ const CarbonChartWrapper = styled.div<{
525
544
 
526
545
  return chartColors.reduce((result, color, index) => {
527
546
  const indexNum = index + 1;
528
- const newResult =
529
- result +
530
- `.tooltip-${props.groupsLength}-1-${indexNum} { background-color: ${color}; }`;
531
547
 
532
- return newResult;
548
+ result += `.tooltip-${props.groupsLength}-1-${indexNum} { background-color: ${color}; }`;
549
+
550
+ return result;
533
551
  }, '');
534
552
  }}
535
553
  }
@@ -564,7 +582,7 @@ const CarbonChartWrapper = styled.div<{
564
582
  .cds--btn--primary {
565
583
  background: ${props =>
566
584
  props.isInverse
567
- ? props.theme.colors.tertiary500
585
+ ? props.theme.colors.cyan500
568
586
  : props.theme.colors.primary};
569
587
  color: ${props => (props.isInverse ? props.theme.colors.neutral900 : '')};
570
588
  }
@@ -624,7 +642,7 @@ const CarbonChartWrapper = styled.div<{
624
642
  .cds--modal-header {
625
643
  background: ${props =>
626
644
  props.isInverse
627
- ? props.theme.colors.primary600
645
+ ? props.theme.colors.indigo600
628
646
  : props.theme.colors.neutral100};
629
647
  margin-bottom: 0;
630
648
  border-bottom: 1px solid
@@ -664,7 +682,7 @@ const CarbonChartWrapper = styled.div<{
664
682
  : props.theme.colors.neutral300};
665
683
  background: ${props =>
666
684
  props.isInverse
667
- ? props.theme.colors.primary600
685
+ ? props.theme.colors.indigo600
668
686
  : props.theme.colors.neutral100} !important;
669
687
  }
670
688
  .layout-child.header {
@@ -701,7 +719,10 @@ const CarbonChartWrapper = styled.div<{
701
719
 
702
720
  g.center text,
703
721
  .pie-label {
704
- fill: ${props => (props.isInverse ? props.theme.colors.neutral100 : '')};
722
+ fill: ${props =>
723
+ props.isInverse
724
+ ? props.theme.colors.neutral100
725
+ : props.theme.colors.brand.navy};
705
726
  }
706
727
 
707
728
  // Zoom responsive tweaks
@@ -738,10 +759,10 @@ interface ColorsObject {
738
759
  [key: string]: string;
739
760
  }
740
761
 
741
- type ExtendedChartOptions = ChartOptions & {
762
+ interface ExtendedChartOptions extends ChartOptions {
742
763
  title?: string;
743
764
  colors?: string[];
744
- };
765
+ }
745
766
 
746
767
  const ToolbarWrapper = styled.div<{
747
768
  isFlowLayout?: boolean;
@@ -765,22 +786,6 @@ const ToolbarWrapper = styled.div<{
765
786
  right: ${props.isFullscreen ? '2em' : '0'};
766
787
  top: ${props.isFullscreen ? '2em' : '0'};
767
788
  `}
768
-
769
- button {
770
- color: ${props =>
771
- props.isInverse
772
- ? props.theme.colors.neutral100
773
- : props.theme.colors.primary500};
774
-
775
- &:focus {
776
- outline: 2px solid
777
- ${props =>
778
- props.isInverse
779
- ? props.theme.colors.focusInverse
780
- : props.theme.colors.focus};
781
- outline-offset: 0;
782
- }
783
- }
784
789
  `;
785
790
 
786
791
  const ChartTitle = styled.h2<{
@@ -796,7 +801,7 @@ const ChartTitle = styled.h2<{
796
801
  color: ${props =>
797
802
  props.isInverse
798
803
  ? props.theme.colors.neutral100
799
- : props.theme.colors.neutral700} !important;
804
+ : props.theme.colors.brand.navy} !important;
800
805
  `;
801
806
 
802
807
  const TitleGroup = styled.div<{ theme: ThemeInterface }>`
@@ -849,11 +854,9 @@ const ToolbarActions = styled.div<{ theme: ThemeInterface }>`
849
854
 
850
855
  function sanitizeCsvValue(value: string): string {
851
856
  const trimmed = value.trimStart();
852
-
853
857
  if (/^[=+\-@\t\r]/.test(trimmed)) {
854
858
  return `'${value}`;
855
859
  }
856
-
857
860
  return value;
858
861
  }
859
862
 
@@ -866,7 +869,6 @@ function downloadCsv(dataSet: Array<Record<string, unknown>>, title: string) {
866
869
  .map(k => {
867
870
  const v = row[k];
868
871
  const s = sanitizeCsvValue(String(v ?? ''));
869
-
870
872
  return s.includes(',') || s.includes('"') || s.includes('\n')
871
873
  ? `"${s.replace(/"/g, '""')}"`
872
874
  : s;
@@ -877,7 +879,6 @@ function downloadCsv(dataSet: Array<Record<string, unknown>>, title: string) {
877
879
  const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
878
880
  const url = URL.createObjectURL(blob);
879
881
  const a = document.createElement('a');
880
-
881
882
  a.href = url;
882
883
  a.download = `${title || 'chart-data'}.csv`;
883
884
  a.click();
@@ -1099,7 +1100,7 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
1099
1100
  chartToolbar,
1100
1101
  ...rest
1101
1102
  } = props;
1102
- const theme = React.useContext(ThemeContext) as ThemeInterface;
1103
+ const theme = React.useContext(ThemeContext);
1103
1104
  const isInverse = useIsInverse(isInverseProp);
1104
1105
  const toolbarI18n = useChartToolbarI18n();
1105
1106
  const internalRef = React.useRef<HTMLDivElement | null>(null);
@@ -1139,7 +1140,6 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
1139
1140
 
1140
1141
  const onFullscreenChange = () => {
1141
1142
  const isFs = !!document.fullscreenElement;
1142
-
1143
1143
  setIsFullscreen(isFs);
1144
1144
 
1145
1145
  const chartHolder =
@@ -1154,16 +1154,13 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
1154
1154
  }
1155
1155
  }
1156
1156
  };
1157
-
1158
1157
  document.addEventListener('fullscreenchange', onFullscreenChange);
1159
-
1160
1158
  return () => {
1161
1159
  document.removeEventListener('fullscreenchange', onFullscreenChange);
1162
1160
  // Restore height if the component unmounts while in fullscreen.
1163
1161
  const chartHolder =
1164
1162
  internalRef.current?.querySelector<HTMLElement>('.cds--chart-holder');
1165
-
1166
- if (chartHolder && document.fullscreenElement) {
1163
+ if (chartHolder && document.fullscreenElement && !isFlowLayout) {
1167
1164
  chartHolder.style.height = savedHeightRef.current;
1168
1165
  }
1169
1166
  };
@@ -1366,7 +1363,6 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
1366
1363
  if (uniqueGroups.length <= allColors.length) {
1367
1364
  for (let i = 0; i < uniqueGroups.length; i++) {
1368
1365
  const group = uniqueGroups[i];
1369
-
1370
1366
  scaleColorsObj[String(group ?? 'null')] = isInverse
1371
1367
  ? allInverseColors[i]
1372
1368
  : allColors[i];
@@ -1382,31 +1378,45 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
1382
1378
  isInverse,
1383
1379
  ]);
1384
1380
 
1385
- const newOptions = {
1386
- ...options,
1387
- theme: isInverse ? ChartTheme.G100 : ChartTheme.WHITE,
1388
- color: {
1389
- scale: colorScale,
1390
- },
1391
- tooltip: {
1392
- ...(options?.tooltip || {}),
1393
- truncation: {
1394
- type: 'none',
1381
+ const hasChartToolbar = Boolean(chartToolbar);
1382
+ const newOptions = React.useMemo(
1383
+ () => ({
1384
+ ...options,
1385
+ theme: isInverse ? ChartTheme.G100 : ChartTheme.WHITE,
1386
+ color: {
1387
+ scale: colorScale,
1395
1388
  },
1396
- },
1397
- ...(chartToolbar
1398
- ? {
1399
- toolbar: { enabled: false },
1400
- title: chartTitle,
1401
- ...(options.fileDownload
1402
- ? {}
1403
- : { fileDownload: { fileName: chartTitle } }),
1404
- }
1405
- : {}),
1406
- };
1389
+ tooltip: {
1390
+ ...(options?.tooltip || {}),
1391
+ truncation: {
1392
+ type: 'none',
1393
+ },
1394
+ },
1395
+ ...(hasChartToolbar
1396
+ ? {
1397
+ toolbar: { enabled: false },
1398
+ title: chartTitle,
1399
+ ...(options.fileDownload
1400
+ ? {}
1401
+ : { fileDownload: { fileName: chartTitle } }),
1402
+ }
1403
+ : {}),
1404
+ }),
1405
+ [options, isInverse, colorScale, hasChartToolbar, chartTitle]
1406
+ );
1407
1407
 
1408
1408
  const ChartType = ALL_CHARTS[type];
1409
1409
 
1410
+ React.useEffect(() => {
1411
+ if (!ariaLabel) return;
1412
+ const rafId = requestAnimationFrame(() => {
1413
+ const svgEl = internalRef.current?.querySelector('.graph-frame');
1414
+ if (!svgEl) return;
1415
+ svgEl.setAttribute('aria-label', ariaLabel);
1416
+ });
1417
+ return () => cancelAnimationFrame(rafId);
1418
+ }, [ariaLabel]);
1419
+
1410
1420
  React.useEffect(() => {
1411
1421
  const timer = setTimeout(() => {
1412
1422
  if (internalRef.current) {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  titleLevel: {
22
24
  control: { type: 'select' },
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react-webpack5';
3
+ import { StoryFn, Meta } from '@storybook/react/types-6-0';
4
4
  import { Card } from 'react-magma-dom';
5
5
 
6
6
  import { CarbonChart, CarbonChartProps, CarbonChartType } from '.';
@@ -15,8 +15,10 @@ export default {
15
15
  },
16
16
  },
17
17
  type: {
18
- control: { type: 'select' },
19
- options: Object.values(CarbonChartType),
18
+ control: {
19
+ type: 'select',
20
+ options: CarbonChartType,
21
+ },
20
22
  },
21
23
  },
22
24
  } as Meta;