pie chart overlap fix

This commit is contained in:
Hassan Azmi
2022-04-06 12:20:01 -04:00
parent 93d21ab90d
commit 1f6b548240

View File

@@ -31,18 +31,24 @@ const MyPieChart = ({ chartData, title, loading, chartTextColor }) => {
/> />
); );
const renderLabel = ({ name, x, y, cx }) => ( const renderLabel = ({ name, x, y, cx, index, percent }) => {
const label = (
<text <text
x={x} x={x}
y={y} y={y}
fill={chartTextColor} fill={chartTextColor}
dominantBaseline="central" dominantBaseline="central"
textAnchor={x > cx ? 'start' : 'end'} textAnchor={x > cx ? 'start' : 'end'}
style={{ fontSize: '12px' }} style={{ fontSize: '14px' }}
> >
{name} {name}
</text> </text>
); );
if (activeIndex) {
return activeIndex === index ? label : null;
}
return percent > 0.05 ? label : null;
};
return ( return (
<Card title={title}> <Card title={title}>
@@ -54,6 +60,7 @@ const MyPieChart = ({ chartData, title, loading, chartTextColor }) => {
dataKey="value" dataKey="value"
data={pieData} data={pieData}
label={renderLabel} label={renderLabel}
labelLine={false}
activeIndex={activeIndex} activeIndex={activeIndex}
onMouseOver={onMouseOver} onMouseOver={onMouseOver}
onMouseLeave={onMouseLeave} onMouseLeave={onMouseLeave}