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
714 stars 148 forks source link

Focused Donut not work #297

Open Angros23 opened 1 year ago

Angros23 commented 1 year ago

When change the prop focused from true to false in the data, not chance in Donut focused.

anniewey commented 1 year ago

Had the same problem, also happened when setting state from [] to [{..}]. Can reproduce with simple example below. The pie is showing but the focused section isn't reflecting.

const [data, setData] = useState<any>([]); //if assign newData here, will reflect the focused section

useEffect(() => {
    const newData = [
      {
        "color": "#AED137",
        "focused": true,
        "gradientCenterColor": "#E6F1C2",
        "title": "Amazing",
        "value": 3
      },
      {
        "color": "#1EB8EB",
        "gradientCenterColor": "#BBE9F9",
        "title": "Great",
        "value": 3
      },
    ];

    setData(newData);
  }, []);

return (
<PieChart
          data={data}
          donut
          showGradient
          sectionAutoFocus
          radius={90}
          innerRadius={60}
          innerCircleColor={Colour.DarkGrey}
          centerLabelComponent={() => {
            return (
                <Text style={styles.textPieValue}>
                  {`${data[0]?.value}%`}
                </Text>
            );
          }}
        />
)
agonselimi commented 8 months ago

I have version "^1.3.28", and on Android, the focusOnPress is not working correctly, it is not focusing when I'm pressing it but rarely, and glitchy, but that's not my main concern. My main concern is that when I'm using donut, the press gesture does not work on all of the chart sections, but on some random places in them. Can the library owner take a look at that?