Skip to content

Commit 25197fe

Browse files
committed
Update PieChart.tsx
1 parent 5b60031 commit 25197fe

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
7373

7474
const chartConfig = useMemo(() => {
7575
return {
76+
margin: { right: 30, left: 30, bottom: 30, top: 30, ...(props.chartConfig?.margin ?? {}) },
7677
legendPosition: 'bottom',
7778
paddingAngle: 0,
7879
...props.chartConfig
@@ -116,7 +117,6 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
116117
[onDataPointClick]
117118
);
118119

119-
const marginChart = chartConfig?.margin ?? { right: 30, left: 30, bottom: 30, top: 30 };
120120
const label = useMemo(() => {
121121
return {
122122
position: 'outside',
@@ -136,7 +136,7 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
136136
tooltip={tooltip}
137137
slot={slot}
138138
>
139-
<PieChartLib margin={marginChart}>
139+
<PieChartLib margin={chartConfig.margin}>
140140
<Pie
141141
innerRadius={chartConfig.innerRadius}
142142
paddingAngle={chartConfig.paddingAngle}
@@ -148,16 +148,16 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
148148
>
149149
{centerLabel && <Label position={'center'}>{centerLabel}</Label>}
150150
{dataset &&
151-
dataset.map((data, index) => (
152-
<Cell
153-
key={index}
154-
name={dimension.formatter(getValueByDataKey(data, dimension.accessor, ''))}
155-
fill={measure.colors?.[index] ?? `var(--sapChart_OrderedColor_${(index % 11) + 1})`}
156-
/>
157-
))}
151+
dataset.map((data, index) => (
152+
<Cell
153+
key={index}
154+
name={dimension.formatter(getValueByDataKey(data, dimension.accessor, ''))}
155+
fill={measure.colors?.[index] ?? `var(--sapChart_OrderedColor_${(index % 11) + 1})`}
156+
/>
157+
))}
158158
</Pie>
159-
<Tooltip cursor={tooltipFillOpacity} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle} />
160-
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition} onClick={onItemLegendClick} />}
159+
<Tooltip cursor={tooltipFillOpacity} formatter={tooltipValueFormatter} contentStyle={tooltipContentStyle}/>
160+
{!noLegend && <Legend verticalAlign={chartConfig.legendPosition} onClick={onItemLegendClick}/>}
161161
</PieChartLib>
162162
</ChartContainer>
163163
);

0 commit comments

Comments
 (0)