Skip to content
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

show value on top of bar chart #99

Closed
duc562000 opened this issue Mar 1, 2022 · 8 comments
Closed

show value on top of bar chart #99

duc562000 opened this issue Mar 1, 2022 · 8 comments

Comments

@duc562000
Copy link

How to show value on top of bar chart ?

@Abhinandan-Kushwaha
Copy link
Owner

Hi @duc562000 👋

You can use the topLabelComponent property inside data objects.

Here's an example-

const data = [
    {value: 20},
    {value: 30},
    {value: 50, topLabelComponent: () => <Text style={{color:'red',fontSize:18,marginBottom:6}}>50</Text>},
    {value: 40},
    {value: 30},
  ];
  return (
    <View style={{flex:1,justifyContent:'center',alignItems:'center'}}>
      <BarChart width={300} data={data} />
    </View>
  );

Screenshot 2022-03-02 at 1 13 15 AM

Hope it helps🤗

@duc562000
Copy link
Author

okey Thanks

@kholusoft
Copy link

Any option to show value directly as topLabelComponent.

@Abhinandan-Kushwaha
Copy link
Owner

Hi @kholusoft 👋
From version 1.3.23 onwards we can show values directly as topLabelComponent, using the showValuesAsTopLabel prop.

I have added the props- showValuesAsTopLabel, topLabelContainerStyle and topLabelTextStyle to Bar charts.

Here's an example-

topLabel

The code for the above chart is-

const data = [{value: 6}, {value: 8}, {value: 5}, {value: 5}, {value: 8}]

return <BarChart
  data={data}
  showValuesAsTopLabel
  topLabelTextStyle={{color:'brown', fontWeight:'bold'}}
/>

@kholusoft
Copy link

kholusoft commented Nov 26, 2023 via email

@kholusoft
Copy link

kholusoft commented Nov 26, 2023 via email

@kholusoft
Copy link

kholusoft commented Nov 29, 2023 via email

@Abhinandan-Kushwaha
Copy link
Owner

Abhinandan-Kushwaha commented Dec 8, 2023

Thanks a lot. Is there any way to reduce bottom margin below bar chart. I find high margin below charts

On Sat, Nov 25, 2023 at 4:44 AM Abhinandan Kushwaha < @.***> wrote: Hi @kholusoft https://github.com/kholusoft 👋 From version 1.3.23 onwards we can show values directly as topLabelComponent, using the showValuesAsTopLabel prop. I have added the props- showValuesAsTopLabel, topLabelContainerStyle and topLabelTextStyle to Bar charts. Here's an example- topLabel.png (view on web) https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/assets/20596944/1de7294a-31e7-46ff-996a-cadb17bee4e9 The code for the above chart is- const data = [{value: 6}, {value: 8}, {value: 5}, {value: 5}, {value: 8}] return <BarChart data={data} showValuesAsTopLabel topLabelTextStyle={{color:'brown', fontWeight:'bold'}}/> — Reply to this email directly, view it on GitHub <#99 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIBDHHSJK3P4REIORYNCIDYGES6VAVCNFSM5PUS62LKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBSGYYTGMRVG44A . You are receiving this because you were mentioned.Message ID: </issues/99/1826132578@ github.com>

@kholusoft Are you still facing this issue (margin bottom below the bar) in the latest version 1.3.24 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants