-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request #763
Comments
Is there a workaround for now as I need something like that please? |
Hi @Hadionly 👋 |
Hey @Abhinandan-Kushwaha 🙌 |
Hi @Hadionly 👋 You can now add external labels in Pie and donut charts using the below props-
type LabelLineConfig = {
length?: number; // default 10
tailLength?: number; // default 8
color?: ColorValue; // default 'black'
thickness?: number; // default 1
labelComponentWidth?: number; // default 20
labelComponentHeight?: number; // default 10
labelComponentMargin?: number; // default 4
}; Here's a simple example- const SimplePie = () => {
const pieData = [
{value: 54, color: '#177AD5', text: '54k'},
{value: 54, color: '#79D2DE', text: '30k'},
{value: 26, color: '#ED6665', text: '26k'},
];
return (
<PieChart
data={pieData}
showExternalLabels
externalLabelComponent={(item, index) => <Text>{item?.text}</Text>}
/>
);
}; The output of the above code is- This feature is available from versions |
Hey Bro @Abhinandan-Kushwaha I'm really impressed by how fast your development is, Great job 🙌👌 I tried it and everything is working fine but I'm just stuck with following issue: code snippet:
|
@Hadionly This is happening because inside
import {Text as SvgText} from 'react-native-svg'; And then use externalLabelComponent={(item) => (
<SvgText style={{ color: COLORS.white, zIndex: 10 }}>
{item?.text}
</SvgText>
)} |
Hey bro @Abhinandan-Kushwaha Thank you so much, now it's working great 👌🙌. code snipped:
|
@Hadionly You can use the |
Thank you so much you are just amazing brother @Abhinandan-Kushwaha 🙌😍 |
I am suggesting an improved label component for use with pie charts. The most effective method I’ve encountered for fitting numerous slices involves placing labels offset by a certain distance from the pie chart (aligned to the right). The Y position of each label is near the middle of the slice and adjusted to avoid overlapping with other labels, using a long stem to clearly indicate the corresponding slice. For example:
The text was updated successfully, but these errors were encountered: