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
785 stars 153 forks source link

getPointerProps Returns Previous Selected Point Index on Release #854

Open simyxing opened 1 month ago

simyxing commented 1 month ago

Description

When using the getPointerProps function, the index updates correctly as the pointer moves across different points on the chart. However, upon releasing the pointer, the index reverts to the previously selected point instead of returning index -1.

Expected Behavior

Upon releasing the pointer, getPointerProps should return index = -1 to signify no point is selected after release.

Actual Behavior:

On release, the index reverts to the previously selected point, rather than returning -1.

Workaround:

Temporarily, I am just using pointerX = 0 to identify if it is released.

Additional Information:

image

Steps to reproduce

  1. Install library
  2. Import component
  3. add props
    getPointerProps={(item: {pointerIndex: number; pointerX: number;}) => {
    updatePoint (item.pointerX === 0 ? -1 : item.pointerIndex)
    }};

Snack or a link to a repository

No response

version of react-native-gifted-charts

1.4.34

React Native version

0.75.2

Platforms

Android, iOS

Workflow

React Native

Abhinandan-Kushwaha commented 1 month ago

Hi @simyxing Can you check again in the latest version of react-native-gifted-charts?

simyxing commented 1 month ago

@Abhinandan-Kushwaha Yes, the issue is persist in the latest version of react-native-gifted-charts (1.4.43)

jeanniton-mnr commented 1 week ago

I am using the latest version of react native gifted charts.

I have found out upon releasing the pointer on a bar chart, BarChart, the pointer index is correctly set to -1.

However, on a line chart, LineChart, upon releasing the pointer the same last point index erroneously persists.

I will look at the source code. If am able to fix that I will create a fix branch and submit a merge request.

react-native-gifted-charts is one of the best chart library I have found for react-native.

Thanks!

jeanniton-mnr commented 1 week ago

Hi @simyxing Can you check again in the latest version of react-native-gifted-charts?

Would you make it possible to create a fixed branch straight from an issue as mentioned?

To see what I mean, you can check this YouTube video

jeanniton-mnr commented 1 week ago

@Abhinandan-Kushwaha Yes, the issue is persist in the latest version of react-native-gifted-charts (1.4.43)

@Abhinandan-Kushwaha, @simyxing

https://github.com/Abhinandan-Kushwaha/react-native-gifted-charts/issues/854

The lines of code that reset the line chart pointer index to -1 upon releasing it were commented on. I have uncommented them.

Now, the pointer index is correctly set to -1 when the pointer is released.

I am asking myself why these lines of code were commented on. Was it during testing or was this in conflict with another feature / behavior?

You can directly install the (npm package) branch with the fixes / removed comments from git using:

npx npm install git+https://github.com/jeanniton-mnr/react-native-gifted-charts.git

PS: I am submitting my PR in a few.

Best & happy coding!