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
638 stars 135 forks source link

[web] Partial data loss when getting over `250px` of height #636

Open FacuM opened 1 month ago

FacuM commented 1 month ago

On the web, changing the height of the graph breaks the amount of displayed information from the data array.

This behaviour isn't observed within Expo Go on an Android device.

Here's the code for the broken component:

import { View } from "react-native";
import { useTheme } from "react-native-paper";

import { LineChart } from "react-native-gifted-charts";
import { useSafeAreaFrame } from "react-native-safe-area-context";
import { useState } from "react";

export default function Index() {
  const [ graphHeight, setGraphHeight ] = useState(0);

  console.log('graphHeight:', graphHeight);

  const { colors } = useTheme();

  const data = [
    {
      value: 50, 
      date: '20 Apr 2022',
      label: '20 Apr'
    },
    {
      value: 80,
      date: '20 Apr 2022',
      label: '20 Apr'
    },
    { value: 90 },
    { value: 70 }
  ];

  return (
    <>
      <View style={{ display: 'flex', flexGrow: 1 }} onLayout={event => setGraphHeight(event.nativeEvent.layout.height)}></View>
      <View style={{ position: 'absolute', height: graphHeight }}>
        <LineChart
          data={data}
          height={graphHeight - 52}
          initialSpacing={0}
          showXAxisIndices={true}
          adjustToWidth={true}
          textColor={colors.onBackground}
          rulesColor={colors.onBackground}
          dataPointsColor={colors.onBackground}
          stripColor={colors.onBackground}
          yAxisColor={colors.onBackground}
          xAxisColor={colors.onBackground}
          verticalLinesColor={colors.onBackground}
          showValuesAsDataPointsText={true}
          textShiftY={-12}
          textFontSize={16}
          yAxisTextStyle={{ color: colors.onBackground }}
          xAxisLabelTextStyle={{ color: colors.onBackground }}
          isAnimated={true}
          animateOnDataChange={true}
          color={colors.onBackground}
        />
      </View>
    </>
  );
}

Here's a screenshot from the web with a height of 250px:

image

And here's one when going with the full height of the container:

image

However, here's how it looks totally fine on a native device:

IMG_20240519_212815_487

Please let me know if I missed any information to help when debugging the issue.

Rouret commented 2 weeks ago

Same issue, did you find a way to fix it? @FacuM

FacuM commented 1 week ago

Same issue, did you find a way to fix it? @FacuM

Nothing so far, I've paused this project for now though, I'm not in the mood to keep it up.

Hope the owner can get it sorted out so that I can keep using this library.