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

Facing alignment isseu with topLabelComponent #840

Open MUZAFFAR-PURELOGICS opened 1 week ago

MUZAFFAR-PURELOGICS commented 1 week ago

Description

Some time getting alignment at the center of bar which should be display on the top of bar.

Specifications: => I am using macbook M1. => "react-native": "0.74.3", => "react-native-gifted-charts": "^1.4.32", . You can see wrong display image: image_2024_09_16T13_37_36_203Z

You can see right display image: Simulator Screenshot - iPhone 15 Pro - 2024-09-16 at 18 54 58

Steps to reproduce

Open screen where graph is displaying. Go back to another screen and then navigate to graph screen. Try this again and again quick. You will see

Snack or a link to a repository

No response

version of react-native-gifted-charts

1.4.32

React Native version

0.74.3

Platforms

iOS

Workflow

None

Abhinandan-Kushwaha commented 1 week ago

@MUZAFFAR-PURELOGICS are you using the isAnimated prop?

MUZAFFAR-PURELOGICS commented 1 week ago

Yes, I am using @Abhinandan-Kushwaha

Abhinandan-Kushwaha commented 1 week ago

Can you share the code @MUZAFFAR-PURELOGICS ?

MUZAFFAR-PURELOGICS commented 5 days ago

@Abhinandan-Kushwaha here is the graph component code:

import {BarChart} from 'react-native-gifted-charts'; import {View, Text, StyleSheet} from 'react-native'; import React from 'react'; import Theme from '../styles/Theme';

const GraphComp = ({title, graphData}) => {

let updatedData = graphData?.map(item => ({ label: 'J' + item?.x_axis, value: item?.y_axis, frontColor: Theme.colors.primary, topLabelComponent: () => {item?.y_axis.toFixed(1) + '%'}, }));

return (

{title}

); };

const styles = StyleSheet.create({ container: { flex: 1, paddingLeft: 5, paddingTop: 20, paddingBottom: 20, borderRadius: 20, borderWidth: 1, borderColor: Theme.colors.darkGreen, backgroundColor: Theme.colors.white, }, title: { textAlign: 'center', fontSize: 20, fontWeight: 'bold', marginBottom: 0, color: '#333', }, xAxisLabel: { color: '#666', fontSize: 12, marginTop: 5, }, yAxisLabel: { color: '#666', fontSize: 12, }, });

export default GraphComp;