@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.
- package/dist/charts.js +2452 -1
- package/dist/charts.js.map +1 -1
- package/dist/charts.modern.module.js +2430 -1
- package/dist/charts.modern.module.js.map +1 -1
- package/dist/charts.umd.js +49167 -1
- package/dist/charts.umd.js.map +1 -1
- package/dist/components/CarbonChart/CarbonChart.d.ts +6 -1
- package/dist/components/CarbonChart/CarbonChartArea.stories.d.ts +310 -0
- package/dist/components/CarbonChart/CarbonChartAreaStacked.stories.d.ts +136 -0
- package/dist/components/CarbonChart/CarbonChartBar.stories.d.ts +214 -0
- package/dist/components/CarbonChart/CarbonChartBarFloating.stories.d.ts +82 -0
- package/dist/components/CarbonChart/CarbonChartBarGrouped.stories.d.ts +234 -0
- package/dist/components/CarbonChart/CarbonChartBarStacked.stories.d.ts +266 -0
- package/dist/components/CarbonChart/CarbonChartBoxplot.stories.d.ts +53 -0
- package/dist/components/CarbonChart/CarbonChartBubble.stories.d.ts +196 -0
- package/dist/components/CarbonChart/CarbonChartBullet.stories.d.ts +35 -0
- package/dist/components/CarbonChart/CarbonChartCombo.stories.d.ts +580 -0
- package/dist/components/CarbonChart/CarbonChartDonut.stories.d.ts +120 -0
- package/dist/components/CarbonChart/CarbonChartGauge.stories.d.ts +43 -0
- package/dist/components/CarbonChart/CarbonChartHistogram.stories.d.ts +89 -0
- package/dist/components/CarbonChart/CarbonChartLine.stories.d.ts +577 -0
- package/dist/components/CarbonChart/CarbonChartLollipop.stories.d.ts +55 -0
- package/dist/components/CarbonChart/CarbonChartMeter.stories.d.ts +127 -0
- package/dist/components/CarbonChart/CarbonChartPie.stories.d.ts +101 -0
- package/dist/components/CarbonChart/CarbonChartRadar.stories.d.ts +98 -0
- package/dist/components/CarbonChart/CarbonChartScatter.stories.d.ts +173 -0
- package/dist/components/CarbonChart/CarbonChartSparkline.stories.d.ts +51 -0
- package/dist/components/CarbonChart/CarbonChartStep.stories.d.ts +38 -0
- package/dist/components/LineChart/Chart.d.ts +27 -0
- package/dist/components/LineChart/ChartDataTable.d.ts +17 -0
- package/dist/components/LineChart/CustomAxisComponent.d.ts +3 -0
- package/dist/components/LineChart/CustomPointComponent.d.ts +17 -0
- package/dist/components/LineChart/DataTable.d.ts +5 -0
- package/dist/components/LineChart/GraphTooltip.d.ts +3 -0
- package/dist/components/LineChart/LegendButton.d.ts +6 -0
- package/dist/components/LineChart/LineChart.d.ts +67 -0
- package/dist/components/LineChart/LineChart.stories.d.ts +113 -0
- package/dist/components/LineChart/index.d.ts +1 -0
- package/dist/components/LineChart/magma-charts.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +28 -26
- package/src/components/CarbonChart/CarbonChart.test.js +506 -0
- package/src/components/CarbonChart/CarbonChart.tsx +63 -61
- package/src/components/CarbonChart/CarbonChartArea.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartAreaStacked.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBar.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBarFloating.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBarGrouped.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBarStacked.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBoxplot.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBubble.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartBullet.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartCombo.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartDonut.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartGauge.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartHistogram.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartLine.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartLollipop.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartMeter.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartPie.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartRadar.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartScatter.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartSparkline.stories.tsx +1 -1
- package/src/components/CarbonChart/CarbonChartStep.stories.tsx +1 -1
- package/src/components/CarbonChart/carbon-charts.css +24931 -0
- package/src/components/LineChart/Chart.tsx +241 -0
- package/src/components/LineChart/ChartDataTable.test.js +165 -0
- package/src/components/LineChart/ChartDataTable.tsx +135 -0
- package/src/components/LineChart/CustomAxisComponent.tsx +30 -0
- package/src/components/LineChart/CustomPointComponent.tsx +93 -0
- package/src/components/LineChart/DataTable.tsx +57 -0
- package/src/components/LineChart/GraphTooltip.tsx +100 -0
- package/src/components/LineChart/LegendButton.tsx +77 -0
- package/src/components/LineChart/LineChart.stories.tsx +399 -0
- package/src/components/LineChart/LineChart.test.js +501 -0
- package/src/components/LineChart/LineChart.tsx +669 -0
- package/src/components/LineChart/index.ts +1 -0
- package/src/components/LineChart/magma-charts.ts +279 -0
- package/src/components/LineChart/test/exampleChartData.js +289 -0
- package/src/index.ts +1 -0
- package/dist/components/CarbonChart/CarbonChart.test.d.ts +0 -1
- package/dist/components/CarbonChart/embeddedStyles.d.ts +0 -1
- 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
|
|
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<
|
|
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
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
335
|
+
${props => {
|
|
336
|
+
const chartColors =
|
|
337
|
+
(props.isInverse
|
|
338
|
+
? props.theme.chartColorsInverse
|
|
339
|
+
: props.theme.chartColors) || [];
|
|
337
340
|
|
|
338
|
-
|
|
339
|
-
|
|
341
|
+
return chartColors.reduce((result, color, index) => {
|
|
342
|
+
const indexNum = index + 1;
|
|
340
343
|
|
|
341
|
-
|
|
344
|
+
result += `.tooltip-${props.groupsLength}-1-${indexNum} { background-color: ${color}; }`;
|
|
342
345
|
|
|
343
|
-
|
|
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
|
-
|
|
612
|
-
|
|
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
|
-
<
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
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
|
);
|