@react-magma/charts 13.0.1-rc.0 → 13.0.2-next.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 (83) hide show
  1. package/dist/charts.js +2452 -1
  2. package/dist/charts.js.map +1 -1
  3. package/dist/charts.modern.module.js +2430 -1
  4. package/dist/charts.modern.module.js.map +1 -1
  5. package/dist/charts.umd.js +49167 -1
  6. package/dist/charts.umd.js.map +1 -1
  7. package/dist/components/CarbonChart/CarbonChart.d.ts +6 -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 +214 -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/LineChart/Chart.d.ts +27 -0
  30. package/dist/components/LineChart/ChartDataTable.d.ts +17 -0
  31. package/dist/components/LineChart/CustomAxisComponent.d.ts +3 -0
  32. package/dist/components/LineChart/CustomPointComponent.d.ts +17 -0
  33. package/dist/components/LineChart/DataTable.d.ts +5 -0
  34. package/dist/components/LineChart/GraphTooltip.d.ts +3 -0
  35. package/dist/components/LineChart/LegendButton.d.ts +6 -0
  36. package/dist/components/LineChart/LineChart.d.ts +67 -0
  37. package/dist/components/LineChart/LineChart.stories.d.ts +113 -0
  38. package/dist/components/LineChart/index.d.ts +1 -0
  39. package/dist/components/LineChart/magma-charts.d.ts +1 -0
  40. package/dist/index.d.ts +1 -0
  41. package/package.json +28 -26
  42. package/src/components/CarbonChart/CarbonChart.test.js +506 -0
  43. package/src/components/CarbonChart/CarbonChart.tsx +63 -61
  44. package/src/components/CarbonChart/CarbonChartArea.stories.tsx +1 -1
  45. package/src/components/CarbonChart/CarbonChartAreaStacked.stories.tsx +1 -1
  46. package/src/components/CarbonChart/CarbonChartBar.stories.tsx +1 -1
  47. package/src/components/CarbonChart/CarbonChartBarFloating.stories.tsx +1 -1
  48. package/src/components/CarbonChart/CarbonChartBarGrouped.stories.tsx +1 -1
  49. package/src/components/CarbonChart/CarbonChartBarStacked.stories.tsx +1 -1
  50. package/src/components/CarbonChart/CarbonChartBoxplot.stories.tsx +1 -1
  51. package/src/components/CarbonChart/CarbonChartBubble.stories.tsx +1 -1
  52. package/src/components/CarbonChart/CarbonChartBullet.stories.tsx +1 -1
  53. package/src/components/CarbonChart/CarbonChartCombo.stories.tsx +1 -1
  54. package/src/components/CarbonChart/CarbonChartDonut.stories.tsx +1 -1
  55. package/src/components/CarbonChart/CarbonChartGauge.stories.tsx +1 -1
  56. package/src/components/CarbonChart/CarbonChartHistogram.stories.tsx +1 -1
  57. package/src/components/CarbonChart/CarbonChartLine.stories.tsx +1 -1
  58. package/src/components/CarbonChart/CarbonChartLollipop.stories.tsx +1 -1
  59. package/src/components/CarbonChart/CarbonChartMeter.stories.tsx +1 -1
  60. package/src/components/CarbonChart/CarbonChartPie.stories.tsx +1 -1
  61. package/src/components/CarbonChart/CarbonChartRadar.stories.tsx +1 -1
  62. package/src/components/CarbonChart/CarbonChartScatter.stories.tsx +1 -1
  63. package/src/components/CarbonChart/CarbonChartSparkline.stories.tsx +1 -1
  64. package/src/components/CarbonChart/CarbonChartStep.stories.tsx +1 -1
  65. package/src/components/CarbonChart/carbon-charts.css +24931 -0
  66. package/src/components/LineChart/Chart.tsx +241 -0
  67. package/src/components/LineChart/ChartDataTable.test.js +165 -0
  68. package/src/components/LineChart/ChartDataTable.tsx +135 -0
  69. package/src/components/LineChart/CustomAxisComponent.tsx +30 -0
  70. package/src/components/LineChart/CustomPointComponent.tsx +93 -0
  71. package/src/components/LineChart/DataTable.tsx +57 -0
  72. package/src/components/LineChart/GraphTooltip.tsx +100 -0
  73. package/src/components/LineChart/LegendButton.tsx +77 -0
  74. package/src/components/LineChart/LineChart.stories.tsx +399 -0
  75. package/src/components/LineChart/LineChart.test.js +501 -0
  76. package/src/components/LineChart/LineChart.tsx +669 -0
  77. package/src/components/LineChart/index.ts +1 -0
  78. package/src/components/LineChart/magma-charts.ts +279 -0
  79. package/src/components/LineChart/test/exampleChartData.js +289 -0
  80. package/src/index.ts +1 -0
  81. package/dist/components/CarbonChart/CarbonChart.test.d.ts +0 -1
  82. package/dist/components/CarbonChart/embeddedStyles.d.ts +0 -1
  83. package/src/components/CarbonChart/embeddedStyles.ts +0 -24880
@@ -21,12 +21,11 @@ import {
21
21
  ComboChart,
22
22
  ChartOptions,
23
23
  } from '@carbon/charts-react';
24
- import { Global } from '@emotion/react';
25
24
  import styled from '@emotion/styled';
26
25
  import { transparentize } from 'polished';
27
26
  import { ThemeInterface, ThemeContext, useIsInverse } from 'react-magma-dom';
28
27
 
29
- import { carbonChartStyles } from './embeddedStyles';
28
+ import './carbon-charts.css';
30
29
 
31
30
  export enum CarbonChartType {
32
31
  area = 'area',
@@ -50,7 +49,7 @@ export enum CarbonChartType {
50
49
  }
51
50
 
52
51
  export interface CarbonChartProps extends React.HTMLAttributes<HTMLDivElement> {
53
- dataSet: Array<object>;
52
+ dataSet: Array<Object>;
54
53
  isInverse?: boolean;
55
54
  /**
56
55
  * For a complete list of options, see Carbon Charts documentation
@@ -65,6 +64,10 @@ export interface CarbonChartProps extends React.HTMLAttributes<HTMLDivElement> {
65
64
  * Type of Chart: area, bar, donut, line, etc.
66
65
  */
67
66
  type: CarbonChartType;
67
+ /**
68
+ * Text for the aria-label attribute for main SVG container, if provided
69
+ */
70
+ ariaLabel?: string;
68
71
  }
69
72
 
70
73
  const CarbonChartWrapper = styled.div<{
@@ -221,33 +224,33 @@ const CarbonChartWrapper = styled.div<{
221
224
  }
222
225
  .cds--cc--scatter circle.dot {
223
226
  filter: drop-shadow(
224
- 1px 0px 0px
225
- ${props =>
226
- props.isInverse
227
- ? props.theme.colors.primary600
228
- : props.theme.colors.neutral100}
229
- )
230
- drop-shadow(
231
- -1px 0px 0px
232
- ${props =>
233
- props.isInverse
234
- ? props.theme.colors.primary600
235
- : props.theme.colors.neutral100}
236
- )
237
- drop-shadow(
238
- 0px 1px 0px
239
- ${props =>
240
- props.isInverse
241
- ? props.theme.colors.primary600
242
- : props.theme.colors.neutral100}
243
- )
244
- drop-shadow(
245
- 0px -1px 0px
246
- ${props =>
247
- props.isInverse
248
- ? props.theme.colors.primary600
249
- : props.theme.colors.neutral100}
250
- );
227
+ 1px 0px 0px
228
+ ${props =>
229
+ props.isInverse
230
+ ? props.theme.colors.primary600
231
+ : props.theme.colors.neutral100}
232
+ )
233
+ drop-shadow(
234
+ -1px 0px 0px
235
+ ${props =>
236
+ props.isInverse
237
+ ? props.theme.colors.primary600
238
+ : props.theme.colors.neutral100}
239
+ )
240
+ drop-shadow(
241
+ 0px 1px 0px
242
+ ${props =>
243
+ props.isInverse
244
+ ? props.theme.colors.primary600
245
+ : props.theme.colors.neutral100}
246
+ )
247
+ drop-shadow(
248
+ 0px -1px 0px
249
+ ${props =>
250
+ props.isInverse
251
+ ? props.theme.colors.primary600
252
+ : props.theme.colors.neutral100}
253
+ );
251
254
  }
252
255
  .cds--cc--scatter circle.dot.hovered {
253
256
  stroke-width: 0.5em;
@@ -327,22 +330,23 @@ const CarbonChartWrapper = styled.div<{
327
330
  transition: 0.1s all linear;
328
331
  stroke-width: 1.1em;
329
332
  }
330
-
333
+
331
334
  .cds--cc--tooltip {
332
- ${props => {
333
- const chartColors =
334
- (props.isInverse
335
- ? props.theme.chartColorsInverse
336
- : props.theme.chartColors) || [];
335
+ ${props => {
336
+ const chartColors =
337
+ (props.isInverse
338
+ ? props.theme.chartColorsInverse
339
+ : props.theme.chartColors) || [];
337
340
 
338
- return chartColors.reduce((result, color, index) => {
339
- const indexNum = index + 1;
341
+ return chartColors.reduce((result, color, index) => {
342
+ const indexNum = index + 1;
340
343
 
341
- result += `.tooltip-${props.groupsLength}-1-${indexNum} { background-color: ${color}; }`;
344
+ result += `.tooltip-${props.groupsLength}-1-${indexNum} { background-color: ${color}; }`;
342
345
 
343
- return result;
344
- }, '');
345
- }}
346
+ return result;
347
+ }, '');
348
+ }}
349
+ }
346
350
 
347
351
  .cds--overflow-menu-options__btn:focus {
348
352
  outline-color: ${props =>
@@ -361,7 +365,6 @@ const CarbonChartWrapper = styled.div<{
361
365
  margin: 0;
362
366
  min-width: ${props => props.theme.spaceScale.spacing13};
363
367
  overflow: hidden;
364
- padding:;
365
368
  position: relative;
366
369
  right: ${props => props.theme.spaceScale.spacing04};
367
370
  text-align: center;
@@ -539,6 +542,7 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
539
542
  type,
540
543
  dataSet,
541
544
  options,
545
+ ariaLabel,
542
546
  ...rest
543
547
  } = props;
544
548
  const theme = React.useContext(ThemeContext);
@@ -583,7 +587,6 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
583
587
  ? allInverseColors[i]
584
588
  : allColors[i]);
585
589
  }
586
-
587
590
  return {};
588
591
  });
589
592
 
@@ -608,28 +611,27 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
608
611
 
609
612
  // Adding aria-label to main SVG container
610
613
  React.useEffect(() => {
611
- document.querySelectorAll('.graph-frame ').forEach(div => {
612
- div.setAttribute('aria-label', 'Interactive chart');
613
- });
614
+ if (ariaLabel) {
615
+ document.querySelectorAll('.graph-frame ').forEach(div => {
616
+ div.setAttribute('aria-label', ariaLabel);
617
+ });
618
+ }
614
619
  });
615
620
 
616
621
  const groupsLength = Object.keys(buildColors()).length;
617
622
 
618
623
  return (
619
- <React.Fragment>
620
- <Global styles={carbonChartStyles} />
621
- <CarbonChartWrapper
622
- data-testid={testId}
623
- ref={ref}
624
- isInverse={isInverse}
625
- theme={theme}
626
- className="carbon-chart-wrapper"
627
- groupsLength={groupsLength < 6 ? groupsLength : 14}
628
- {...rest}
629
- >
630
- <ChartType data={dataSet} options={newOptions} />
631
- </CarbonChartWrapper>
632
- </React.Fragment>
624
+ <CarbonChartWrapper
625
+ data-testid={testId}
626
+ ref={ref}
627
+ isInverse={isInverse}
628
+ theme={theme}
629
+ className="carbon-chart-wrapper"
630
+ groupsLength={groupsLength < 6 ? groupsLength : 14}
631
+ {...rest}
632
+ >
633
+ <ChartType data={dataSet} options={newOptions} />
634
+ </CarbonChartWrapper>
633
635
  );
634
636
  }
635
637
  );
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { StoryFn, Meta } from '@storybook/react';
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 '.';