-
Notifications
You must be signed in to change notification settings - Fork 158
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: Icons inside BarChart and PieChart #500
Comments
Hi @georgekal2798 👋 |
Hi @georgekal2798 👋 Added 2 new props- For Bar charts, the UI element is rendered inside the bars. It is positioned at the top of the Bar by default. It can be repositioned using CSS techniques. Here's an example- const barData = [
{value: 15},
{value: 30},
{
value: 26,
barInnerComponent: (item, index) => {
return (
<View
style={{
flex: 1,
alignItems: 'center',
backgroundColor: 'green',
}}>
<View
style={{
height: 20,
width: 20,
borderRadius: 10,
backgroundColor: 'red',
}}>
<Text style={{color: 'blue', textAlign: 'center'}}>
{item.value}
</Text>
</View>
</View>
);
},
},
{value: 40},
];
return (
<BarChart
data={barData}
barInnerComponent={(item, index) => {
return (
<View
style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<View
style={{
height: 20,
width: 20,
borderRadius: 10,
backgroundColor: 'yellow',
}}>
<Text style={{color: 'blue', textAlign: 'center'}}>{item.value}</Text>
</View>
</View>
);
}}
/>
); The output of the above code is- For Pie and Donut charts, the pieInnerComponent={(item,index)=><SvgText x={0} y={0} height={20} width={40} fill={'red'} stroke={'blue'}>
{item.value}
</SvgText>} Note- Both |
WOW! Thank you for your fast response! Amazing work! Keep it up 👍 |
Hi @georgekal2798 Can you share the code? |
Hello there, i am using "react-native-gifted-charts": "^1.4.3" barInnerComponent does not work .
|
Hi @ahsan85 |
@Abhinandan-Kushwaha i want to display text in bars.. |
Hi @ahsan85 👋 For now, I can suggest you a workaround. The |
Hi @ahsan85 |
@Abhinandan-Kushwaha Thanks for your immediate response. It works now. |
Hello there!
I would like to request a feature, that was inspired by the specs of an app I am developing.
Inside the bars of a BarChart and the slices of a PieChart (in this case, donut), I need to show an icon, something like this.
I know in the PieChart it is possible to show text, but it is not as customisable as I would want to. I tried to make it work with a custom icon font, but I can't change the font family of the text.
Also, with the BarChart, I was able to show the icons using the font family and I display the respective icons as the x axis labels, but again this is not optimal, as I can't recreate the round white background.
I would really appreciate it if this could be made into a feature: either placing a custom element in the bar/slices, or being able to further customise the text and the background. Please let me know if this is possible and how much time it would take, because I have to know if I can implement it like this in the coming days. Also, if I have missed something and this is feasible using the current version, please tell me how to do it.
Thank you very much in advance!
The text was updated successfully, but these errors were encountered: