Skip to content

Commit 8390186

Browse files
feat(PieChart/DonutChart - New): expose innerRadius and outerRadius in chartConfig prop (#503)
1 parent 06f58b9 commit 8390186

File tree

7 files changed

+45
-47
lines changed

7 files changed

+45
-47
lines changed

packages/charts/src/components/DonutChart/DonutRechart.stories.tsx renamed to packages/charts/src/components/DonutChart/DonutChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ export const withCustomRadiusStory = () =>
9292
style={{ width: '50%' }}
9393
dataset={simpleDataSet}
9494
chartConfig={{
95-
innerRadius: text('innerRadius', '20%')
95+
innerRadius: text('innerRadius', '20%'),
96+
outerRadius: text('outerRadius', '90%'),
9697
}}
9798
dimension={{
9899
accessor: 'name'

packages/charts/src/components/PieChart/PieRechart.stories.tsx renamed to packages/charts/src/components/PieChart/PieChart.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const renderStory = () => {
2020
style={{ width: '50%' }}
2121
dataset={simpleDataSet}
2222
chartConfig={{
23-
innerRadius: text('innerRadius', '0%')
23+
innerRadius: text('innerRadius', '0%'),
24+
outerRadius: text('outerRadius', '80%')
2425
}}
2526
dimension={{
2627
accessor: 'name'

packages/charts/src/components/PieChart/PieChart.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import React, { CSSProperties, FC, forwardRef, Ref, useCallback, useMemo } from
77
import { Cell, Label, Legend, Pie, PieChart as PieChartLib, Tooltip } from 'recharts';
88
import { getValueByDataKey } from 'recharts/lib/util/ChartUtils';
99
import { IChartMeasure } from '../../interfaces/IChartMeasure';
10+
import { IPolarChartConfig } from "../../interfaces/IPolarChartConfig";
1011
import { RechartBaseProps } from '../../interfaces/RechartBaseProps';
1112
import { defaultFormatter } from '../../internal/defaults';
1213
import { tooltipContentStyle, tooltipFillOpacity } from '../../internal/staticProps';
@@ -35,7 +36,7 @@ interface DimensionConfig {
3536
formatter?: (value: any) => string;
3637
}
3738

38-
export interface PieChartProps extends RechartBaseProps {
39+
export interface PieChartProps extends RechartBaseProps<IPolarChartConfig> {
3940
centerLabel?: string;
4041
dimension: DimensionConfig;
4142
/**
@@ -79,6 +80,7 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
7980
legendPosition: 'bottom',
8081
legendHorizontalAlign: 'center',
8182
paddingAngle: 0,
83+
outerRadius: '80%',
8284
...props.chartConfig
8385
};
8486
}, [props.chartConfig]);
@@ -144,6 +146,7 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
144146
<PieChartLib onClick={onDataPointClickInternal} margin={chartConfig.margin}>
145147
<Pie
146148
innerRadius={chartConfig.innerRadius}
149+
outerRadius={chartConfig.outerRadius}
147150
paddingAngle={chartConfig.paddingAngle}
148151
nameKey={dimension.accessor}
149152
dataKey={measure.accessor}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export interface ICartesianChartConfig {
2+
yAxisVisible?: boolean;
3+
xAxisVisible?: boolean;
4+
5+
gridStroke?: string;
6+
gridVertical?: boolean;
7+
gridHorizontal?: boolean;
8+
9+
zoomingTool?: boolean;
10+
11+
barGap?: number;
12+
13+
14+
secondYAxis?: {
15+
dataKey: string;
16+
name?: string;
17+
color?: string;
18+
};
19+
20+
referenceLine?: {
21+
label: string;
22+
value: number;
23+
color: string;
24+
};
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export interface IPolarChartConfig {
2+
paddingAngle?: number;
3+
4+
innerRadius?: string;
5+
outerRadius?: string;
6+
7+
polarGridType?: string;
8+
}

packages/charts/src/interfaces/LabelObject.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { CommonProps } from '@ui5/webcomponents-react/interfaces/CommonProps';
2-
import { CSSProperties } from 'react';
3-
import { ChartContainerProps } from './ChartContainerProps';
2+
import { ICartesianChartConfig } from './ICartesianChartConfig';
43

5-
export interface RechartBaseProps extends CommonProps {
4+
export interface RechartBaseProps<T = ICartesianChartConfig> extends CommonProps {
65
loading?: boolean;
76
dataset?: Record<string, any>[];
87

@@ -12,40 +11,15 @@ export interface RechartBaseProps extends CommonProps {
1211

1312
noAnimation?: boolean;
1413

15-
chartConfig?: {
14+
chartConfig?: T & {
1615
margin?: {
1716
right: number;
1817
left: number;
1918
top: number;
2019
bottom: number;
2120
};
2221

23-
yAxisVisible?: boolean;
24-
xAxisVisible?: boolean;
25-
26-
gridStroke?: string;
27-
gridVertical?: boolean;
28-
gridHorizontal?: boolean;
2922
legendPosition?: string;
30-
zoomingTool?: boolean;
31-
32-
barGap?: number;
33-
34-
paddingAngle?: number;
35-
innerRadius?: string;
36-
37-
polarGridType?: string;
38-
39-
secondYAxis?: {
40-
dataKey: string;
41-
name?: string;
42-
color?: string;
43-
};
44-
45-
referenceLine?: {
46-
label: string;
47-
value: number;
48-
color: string;
49-
};
23+
legendHorizontalAlign?: string;
5024
};
5125
}

0 commit comments

Comments
 (0)