mirror of
https://github.com/Telecominfraproject/wlan-cloud-ui-library.git
synced 2025-11-02 19:58:13 +00:00
Merge pull request #342 from Telecominfraproject/bugfix/NOJIRA-label-overlap-fix
NOJIRA: Pie Chart Overlap Fix
This commit is contained in:
@@ -31,18 +31,24 @@ const MyPieChart = ({ chartData, title, loading, chartTextColor }) => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
const renderLabel = ({ name, x, y, cx }) => (
|
const renderLabel = ({ name, x, y, cx, index, percent }) => {
|
||||||
<text
|
const label = (
|
||||||
x={x}
|
<text
|
||||||
y={y}
|
x={x}
|
||||||
fill={chartTextColor}
|
y={y}
|
||||||
dominantBaseline="central"
|
fill={chartTextColor}
|
||||||
textAnchor={x > cx ? 'start' : 'end'}
|
dominantBaseline="central"
|
||||||
style={{ fontSize: '12px' }}
|
textAnchor={x > cx ? 'start' : 'end'}
|
||||||
>
|
style={{ fontSize: '14px' }}
|
||||||
{name}
|
>
|
||||||
</text>
|
{name}
|
||||||
);
|
</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}
|
||||||
|
|||||||
Reference in New Issue
Block a user