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
730 stars 149 forks source link

Horizontal bar tooltip not rotated #672

Closed paramasivam-workhall closed 2 months ago

paramasivam-workhall commented 2 months ago

HI,

I have implemented a horizontal chart and added a tooltip, but the tooltip is displayed perpendicular to each bar. I need it to be displayed along the bar's axis, on top of it.

 <View style={{padding: 20, alignItems: 'center', marginBottom:60, marginTop:-15}}>
        <BarChart
            horizontal
            data={data}
            barWidth={25}
            initialSpacing={10}
            noOfSections={5}
            // spacing={30}
            height={225}
            xAxisLabelsVerticalShift={35}

            //  rotateLabel
            // endSpacing={1000}
            formatYLabel = {(label) => {
                let labelVal = Number(label);
                return formatNumber(labelVal);
            }}
            yAxisExtraHeight={0}
            // leftShiftForTooltip={250}
            xAxisLabelTextStyle={{width:100,color: '#333', textAlign: 'top',marginTop: -20,paddingRight:10}}
            renderTooltip={(item, index) => { 
            const TooltipLabel = isEmpty(item.label) ? data[index-1].label : item.label;

                return (
                    <View style={{ backgroundColor: 'white', padding: 10, borderRadius: 5,   transform: [{rotateZ: '270deg'},  { translateX: -50 }, 
                    { translateY: -90 }],}}>
                        <Text style={{ color: 'black' }}>{setTextEllipsis(TooltipLabel, 15)} : {item.value}</Text>
                    </View>
                );
            }}

        />
        </View>
Abhinandan-Kushwaha commented 2 months ago

Hi @paramasivam-workhall 👋 Thanks for reporting this issue. It has been fixed in versions 1.4.17 onwards. 🎉

Please use the latest version of the library.