Skip to content

Commit 0aafca0

Browse files
chore(charts): remove deprecated charts (#510)
BREAKING CHANGE: replace deprecated charts with new implementation. In case your imports contain a `next` path segment, please remove this segment. Example: `import { BarChart } from '@ui5/webcomponents-react-charts/lib/next/BarChart';` becomes `import { BarChart } from '@ui5/webcomponents-react-charts/lib/BarChart';`. For further details please take a look into our [Migration Guide](https://github.com/SAP/ui5-webcomponents-react/blob/master/docs/MigrationGuide.md#095---charts-migration).
1 parent 636d507 commit 0aafca0

File tree

116 files changed

+417
-3920
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+417
-3920
lines changed

packages/charts/package.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,20 @@
1313
},
1414
"author": "SAP SE (https://www.sap.com)",
1515
"license": "Apache-2.0",
16-
"sideEffects": [
17-
"@ui5/webcomponents/dist/Label"
18-
],
16+
"sideEffects": false,
1917
"scripts": {
20-
"clean": "rimraf cjs components interfaces internal lib themes util index.esm.js index.d.ts config.d.ts hooks indexNew.d.ts",
18+
"clean": "rimraf cjs components interfaces internal lib util index.esm.js index.d.ts config.d.ts hooks",
2119
"build": "rollup -c rollup.config.js"
2220
},
2321
"dependencies": {
2422
"@babel/runtime": "7.9.6",
25-
"chart.js": "^2.9.3",
26-
"chartjs-plugin-datalabels": "^0.7.0",
27-
"get-best-contrast-color": "^0.3.1",
2823
"lodash.debounce": "^4.0.8",
29-
"lodash.merge": "^4.6.2",
30-
"react-chartjs-2": "^2.8.0",
3124
"react-content-loader": "^5.0.4",
3225
"recharts": "2.0.0-beta.6"
3326
},
34-
"devDependencies": {
35-
"@types/chart.js": "^2.9.8"
36-
},
3727
"peerDependencies": {
38-
"@ui5/webcomponents-react": "^0.9.0-rc.0",
39-
"@ui5/webcomponents-react-base": "^0.9.0-rc.0",
28+
"@ui5/webcomponents-react": "^0.9.0",
29+
"@ui5/webcomponents-react-base": "^0.9.0",
4030
"react": "^16.8.0",
4131
"react-jss": "^10.0.4"
4232
},

packages/charts/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const rollupConfigFactory = require('../../scripts/rollup/configFactory');
22

3-
const config = rollupConfigFactory('charts', ['@ui5/webcomponents', '@ui5/webcomponents-base', 'lodash', 'classnames']);
3+
const config = rollupConfigFactory('charts', ['@ui5/webcomponents', '@ui5/webcomponents-base']);
44
module.exports = config;

packages/charts/src/components/BarChart/BarRechart.stories.tsx renamed to packages/charts/src/components/BarChart/BarChart.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { action } from '@storybook/addon-actions';
22
import { boolean } from '@storybook/addon-knobs';
3-
import { BarChart } from '@ui5/webcomponents-react-charts/lib/next/BarChart';
43
import React from 'react';
4+
import { BarChart } from '../../lib/BarChart';
55
import { complexDataSet, secondaryDimensionDataSet, simpleDataSet } from '../../resources/DemoProps';
66

77
export default {
Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,50 @@
1+
import { action } from '@storybook/addon-actions';
2+
import { boolean } from '@storybook/addon-knobs';
13
import { mount } from 'enzyme';
24
import * as React from 'react';
3-
import { datasets, labels, singleDataset } from '../../resources/ChartProps';
4-
import { BarChart } from './index';
5+
import { complexDataSet } from '../../resources/DemoProps';
6+
import { BarChart } from './BarChart';
57

6-
describe('BarChart', () => {
8+
describe('BarRechart', () => {
79
test('Renders with data', () => {
8-
mount(<BarChart labels={labels} datasets={singleDataset} />);
9-
});
10-
11-
test('custom colors', () => {
12-
mount(<BarChart labels={labels} datasets={singleDataset} colors={['#f0ab00']} />);
13-
});
14-
15-
test('valueAxisFormatter', () => {
16-
mount(<BarChart labels={labels} datasets={singleDataset} valueAxisFormatter={(d) => `${d}%`} />);
17-
});
18-
19-
test('with Ref', () => {
20-
const ref = React.createRef();
21-
mount(<BarChart ref={ref} labels={labels} datasets={singleDataset} />);
22-
expect(ref.current.hasOwnProperty('chartInstance')).toBe(true);
23-
});
24-
25-
test('stacked', () => {
26-
mount(
27-
<BarChart
28-
labels={labels}
29-
datasets={datasets}
30-
options={{ scales: { yAxes: [{ stacked: true }], xAxes: [{ stacked: true }] } }}
31-
/>
32-
);
10+
expect(
11+
mount(
12+
<BarChart
13+
loading={boolean('loading', false)}
14+
onDataPointClick={action('onDataPointClick')}
15+
onLegendClick={action('onLegendClick')}
16+
dataset={complexDataSet}
17+
style={{ height: '60vh' }}
18+
dimensions={[
19+
{
20+
accessor: 'name',
21+
interval: 0
22+
}
23+
]}
24+
measures={[
25+
{
26+
accessor: 'users',
27+
label: 'Users',
28+
formatter: (val) => val.toLocaleString()
29+
},
30+
{
31+
accessor: 'sessions',
32+
label: 'Active Sessions',
33+
formatter: (val) => `${val} sessions`,
34+
hideDataLabel: true
35+
},
36+
{
37+
accessor: 'volume',
38+
label: 'Vol.'
39+
}
40+
]}
41+
/>
42+
).render()
43+
).toMatchSnapshot();
3344
});
3445

3546
test('loading placeholder', () => {
36-
const wrapper = mount(<BarChart labels={labels} datasets={[]} loading />);
47+
const wrapper = mount(<BarChart style={{ width: '30%' }} dimensions={[]} measures={[]} />);
3748
expect(wrapper.render()).toMatchSnapshot();
3849
});
3950
});

packages/charts/src/components/BarChart/BarChart.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import { ThemingParameters } from '@ui5/webcomponents-react-base/lib/ThemingPara
22
import { useConsolidatedRef } from '@ui5/webcomponents-react-base/lib/useConsolidatedRef';
33
import { enrichEventWithDetails } from '@ui5/webcomponents-react-base/lib/Utils';
44
import { BarChartPlaceholder } from '@ui5/webcomponents-react-charts/lib/BarChartPlaceholder';
5+
import { ChartContainer } from '@ui5/webcomponents-react-charts/lib/components/ChartContainer';
56
import { ChartDataLabel } from '@ui5/webcomponents-react-charts/lib/components/ChartDataLabel';
67
import { XAxisTicks } from '@ui5/webcomponents-react-charts/lib/components/XAxisTicks';
78
import { YAxisTicks } from '@ui5/webcomponents-react-charts/lib/components/YAxisTicks';
8-
import { ChartContainer } from '@ui5/webcomponents-react-charts/lib/next/ChartContainer';
99
import { useLegendItemClick } from '@ui5/webcomponents-react-charts/lib/useLegendItemClick';
1010
import React, { FC, forwardRef, Ref, useCallback, useMemo } from 'react';
1111
import {
@@ -24,9 +24,9 @@ import { useLongestYAxisLabelBar } from '../../hooks/useLongestYAxisLabelBar';
2424
import { useObserveXAxisHeights } from '../../hooks/useObserveXAxisHeights';
2525
import { usePrepareDimensionsAndMeasures } from '../../hooks/usePrepareDimensionsAndMeasures';
2626
import { useTooltipFormatter } from '../../hooks/useTooltipFormatter';
27+
import { IChartBaseProps } from '../../interfaces/IChartBaseProps';
2728
import { IChartDimension } from '../../interfaces/IChartDimension';
2829
import { IChartMeasure } from '../../interfaces/IChartMeasure';
29-
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
3030
import { defaultFormatter } from '../../internal/defaults';
3131
import { tickLineConfig, tooltipContentStyle, tooltipFillOpacity } from '../../internal/staticProps';
3232

@@ -65,7 +65,7 @@ interface DimensionConfig extends IChartDimension {
6565
interval?: number;
6666
}
6767

68-
export interface BarChartProps extends RechartBaseProps {
68+
export interface BarChartProps extends IChartBaseProps {
6969
dimensions: DimensionConfig[];
7070
/**
7171
* An array of config objects. Each object is defining one bar in the chart.
@@ -90,7 +90,7 @@ export interface BarChartProps extends RechartBaseProps {
9090
}
9191

9292
/**
93-
* <code>import { BarChart } from '@ui5/webcomponents-react-charts/lib/next/BarChart';</code>
93+
* <code>import { BarChart } from '@ui5/webcomponents-react-charts/lib/BarChart';</code>
9494
*/
9595
const BarChart: FC<BarChartProps> = forwardRef((props: BarChartProps, ref: Ref<any>) => {
9696
const {

packages/charts/src/components/BarChart/BarRechart.test.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.

packages/charts/src/components/BarChart/__snapshots__/BarChart.test.tsx.snap

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`BarChart loading placeholder 1`] = `
3+
exports[`BarRechart Renders with data 1`] = `
44
<div
5-
class="ChartContainer-chart-0 ChartContainer-chart-d5-0"
6-
style="position: relative; padding-top: 6px; width: 300px; height: 300px;"
5+
style="font-family: var(--sapFontFamily); width: 100%; height: 60vh; position: relative;"
6+
>
7+
<div
8+
class="recharts-responsive-container"
9+
id="undefined"
10+
style="width: 100%; height: 100%;"
11+
>
12+
<div />
13+
</div>
14+
</div>
15+
`;
16+
17+
exports[`BarRechart loading placeholder 1`] = `
18+
<div
19+
style="font-family: var(--sapFontFamily); width: 30%; height: 400px; position: relative;"
720
>
821
<svg
922
aria-labelledby="ARIA-LABELLED-BY"
@@ -121,8 +134,5 @@ exports[`BarChart loading placeholder 1`] = `
121134
</linearGradient>
122135
</defs>
123136
</svg>
124-
<div
125-
class="legend"
126-
/>
127137
</div>
128138
`;

packages/charts/src/components/BarChart/__snapshots__/BarRechart.test.tsx.snap

Lines changed: 0 additions & 138 deletions
This file was deleted.

0 commit comments

Comments
 (0)