Abhinandan-Kushwaha / react-native-gifted-charts

The most complete library for Bar, Line, Area, Pie, Donut, Stacked Bar and Population Pyramid charts in React Native. Allows 2D, 3D, gradient, animations and live data updates.
https://www.npmjs.com/package/react-native-gifted-charts
MIT License
791 stars 152 forks source link

renderTooltip not Working #908

Open atlas-itrc opened 4 days ago

atlas-itrc commented 4 days ago

Description

renderTooltip is not working as expected even though i have added the required prop:

` <BarChart data={barData} barWidth={20} yAxisTextStyle={{ color: 'gray' }} noOfSections={4} maxValue={400} width={500} // Adjust width for landscape view labelWidth={80} isAnimated renderTooltip={(item, index) => { console.log(item); return ( <View style={ { // marginBottom: 20, // // marginLeft: -6, // backgroundColor: '#ffcefe', // // paddingHorizontal: 6, // paddingVertical: 4, // // borderRadius: 4, } }>

{item.value}
              </View>
            );
          }}
        />

        the console is showing the log for the item, but i am expecting the item value to show on the top of the bar.

`

Steps to reproduce

I have tried using the same exact example from the documentation. but it is still not working.

Snack or a link to a repository

https://snack.expo.dev/3ouoGiXPdTpeRR7GAjx_R

version of react-native-gifted-charts

1.4.47

React Native version

0.74.5

Platforms

Android

Workflow

Expo Dev Client

onyx-flame commented 12 hours ago

The problem is caused by default tooltip offset configured here

You can compensate it by setting top: 60 or bottom: -60 to render your tooltip right above the bar. Here is a link to snack with a fix: click!