@react-magma/charts 15.0.0 → 15.0.1-v6-next.1
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 +4 -3
- package/dist/charts.js.map +1 -1
- package/dist/charts.modern.module.js +4 -3
- package/dist/charts.modern.module.js.map +1 -1
- package/dist/charts.umd.js +456 -491
- package/dist/charts.umd.js.map +1 -1
- package/package.json +5 -5
- package/src/components/CarbonChart/CarbonChart.test.js +71 -0
- package/src/components/CarbonChart/CarbonChart.tsx +25 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-magma/charts",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.1-v6-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"identity-obj-proxy": "^3.0.0",
|
|
48
48
|
"react": "^17.0.2",
|
|
49
49
|
"react-dom": "^17.0.2",
|
|
50
|
-
"react-magma-dom": "^6.0.0",
|
|
51
|
-
"react-magma-icons": "^3.
|
|
50
|
+
"react-magma-dom": "^6.0.1-v6-next.0",
|
|
51
|
+
"react-magma-icons": "^3.3.0",
|
|
52
52
|
"rollup": "^4.52.4",
|
|
53
53
|
"rollup-plugin-postcss": "^4.0.2"
|
|
54
54
|
},
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"@emotion/styled": "^11.13.0",
|
|
58
58
|
"react": "^17.0.2",
|
|
59
59
|
"react-dom": "^17.0.2",
|
|
60
|
-
"react-magma-dom": "^6.0.0",
|
|
61
|
-
"react-magma-icons": "^3.
|
|
60
|
+
"react-magma-dom": "^6.0.1-v6-next.0",
|
|
61
|
+
"react-magma-icons": "^3.3.0"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22.14.0",
|
|
@@ -1023,6 +1023,77 @@ describe('CarbonChart', () => {
|
|
|
1023
1023
|
});
|
|
1024
1024
|
});
|
|
1025
1025
|
|
|
1026
|
+
describe('fullscreen', () => {
|
|
1027
|
+
const toolbarProps = {
|
|
1028
|
+
dataSet,
|
|
1029
|
+
options: chartOptions,
|
|
1030
|
+
type: CarbonChartType.bar,
|
|
1031
|
+
chartToolbar: {},
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
let setOptions;
|
|
1035
|
+
let createChartSpy;
|
|
1036
|
+
|
|
1037
|
+
const setFullscreenElement = element => {
|
|
1038
|
+
Object.defineProperty(document, 'fullscreenElement', {
|
|
1039
|
+
configurable: true,
|
|
1040
|
+
value: element,
|
|
1041
|
+
});
|
|
1042
|
+
act(() => {
|
|
1043
|
+
document.dispatchEvent(new Event('fullscreenchange'));
|
|
1044
|
+
});
|
|
1045
|
+
};
|
|
1046
|
+
|
|
1047
|
+
beforeEach(() => {
|
|
1048
|
+
setOptions = jest.fn();
|
|
1049
|
+
createChartSpy = jest
|
|
1050
|
+
.spyOn(SimpleBarChart.prototype, 'createChart')
|
|
1051
|
+
.mockImplementation(holder => {
|
|
1052
|
+
holder.classList.add('cds--chart-holder');
|
|
1053
|
+
holder.style.height = chartOptions.height;
|
|
1054
|
+
|
|
1055
|
+
return { model: { setOptions, setData: jest.fn() } };
|
|
1056
|
+
});
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
afterEach(() => {
|
|
1060
|
+
createChartSpy.mockRestore();
|
|
1061
|
+
delete document.fullscreenElement;
|
|
1062
|
+
});
|
|
1063
|
+
|
|
1064
|
+
it('does not update chart options when entering and exiting fullscreen', () => {
|
|
1065
|
+
const { container } = render(<CarbonChart {...toolbarProps} />);
|
|
1066
|
+
const holder = container.querySelector('.cds--chart-holder');
|
|
1067
|
+
|
|
1068
|
+
setFullscreenElement(container.firstChild);
|
|
1069
|
+
|
|
1070
|
+
expect(
|
|
1071
|
+
screen.getByRole('button', {
|
|
1072
|
+
name: `Exit ${chartOptions.title} full screen`,
|
|
1073
|
+
})
|
|
1074
|
+
).toBeInTheDocument();
|
|
1075
|
+
expect(holder.style.height).toBe('100vh');
|
|
1076
|
+
|
|
1077
|
+
setFullscreenElement(null);
|
|
1078
|
+
|
|
1079
|
+
expect(
|
|
1080
|
+
screen.getByRole('button', {
|
|
1081
|
+
name: `View ${chartOptions.title} full screen`,
|
|
1082
|
+
})
|
|
1083
|
+
).toBeInTheDocument();
|
|
1084
|
+
expect(holder.style.height).toBe(chartOptions.height);
|
|
1085
|
+
expect(setOptions).not.toHaveBeenCalled();
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
it('does not update chart options on re-render with the same props', () => {
|
|
1089
|
+
const { rerender } = render(<CarbonChart {...toolbarProps} />);
|
|
1090
|
+
|
|
1091
|
+
rerender(<CarbonChart {...toolbarProps} chartToolbar={{}} />);
|
|
1092
|
+
|
|
1093
|
+
expect(setOptions).not.toHaveBeenCalled();
|
|
1094
|
+
});
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1026
1097
|
describe('image export', () => {
|
|
1027
1098
|
const toolbarProps = {
|
|
1028
1099
|
dataSet,
|
|
@@ -1378,28 +1378,32 @@ export const CarbonChart = React.forwardRef<HTMLDivElement, CarbonChartProps>(
|
|
|
1378
1378
|
isInverse,
|
|
1379
1379
|
]);
|
|
1380
1380
|
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
...(options?.tooltip || {}),
|
|
1389
|
-
truncation: {
|
|
1390
|
-
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,
|
|
1391
1388
|
},
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
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
|
+
);
|
|
1403
1407
|
|
|
1404
1408
|
const ChartType = ALL_CHARTS[type];
|
|
1405
1409
|
|