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

Gradient line and area blinking with pointerConfig #849

Closed CavalcanteLeo closed 1 month ago

CavalcanteLeo commented 2 months ago

Description

https://github.com/user-attachments/assets/c88e0b36-b552-4bb8-bc10-a4b9e1a2abf1

Steps to reproduce


const spacing = Dimensions.get('window').width / (chartData.length ?? 1);

<LineChart
          scrollRef={chartScrollRef}
          rulesColor="#333333"
          showDataPointOnFocus
          curved
          data={chartData}
          disableScroll
          noOfSections={4}
          lineGradientStartColor="#14B4E3"
          lineGradientEndColor="#04252F"
          gradientDirection="toBottom"
          maxValue={100}
          dashWidth={1}
          isAnimated
          lineGradient
          spacing={spacing}
          thickness={3}
          height={250}
          yAxisSide={1}
          pointerConfig={{
            pointerColor: '#14B4E300',
            stripBehindBars: true,

            pointerStripUptoDataPoint: false,
            pointerStripColor: 'lightgray',
            pointerStripWidth: 2,
            strokeDashArray: [2, 5],
            autoAdjustPointerLabelPosition: true,
            radius: 4,
            pointerLabelWidth: 140,
            shiftPointerLabelY: 60,
            stripOverPointer: false,

            //
            // pointerStripHeight: 210,
            pointerLabelComponent: (items: any[]) => (
              <PopularTimesTooltip
                hour={items[0].label}
                percentage={items[0].value}
              />
            ),
          }}
          hideYAxisText
          showXAxisIndices
          xAxisIndicesHeight={6}
          xAxisIndicesWidth={1}
          xAxisIndicesColor="#303030"
          curveType={0}
          xAxisLabelsVerticalShift={12}
          animateOnDataChange
          animationDuration={1000}
          onDataChangeAnimationDuration={250}
          areaChart
          areaGradientId="bgGradientColor"
          areaGradientComponent={() => {
            return (
              <LinearGradient id="bgGradientColor" x1="1" y1="0" x2="1" y2="1">
                <Stop offset="0" stopOpacity={0.3} stopColor={'#14B4E3'} />
                <Stop offset="1" stopOpacity={0.1} stopColor={'#04252F'} />
              </LinearGradient>
            );
          }}
        />

ps, even if I remove the pointerLabelComponent, it still happens

it seems it was generated by these:

lineGradient
lineGradientStartColor="#14B4E3"
lineGradientEndColor="#04252F"
Abhinandan-Kushwaha commented 2 months ago

@CavalcanteLeo The blink is due to the animateOnDataChange prop. You can remove it if it is not needed. Meanwhile, I am trying to fix it.

CavalcanteLeo commented 2 months ago

thanks for the heads up, I'm quite busy here, but I will try to debug ur code and see if I can find a solution too

Abhinandan-Kushwaha commented 1 month ago

Hi @CavalcanteLeo I have fixed this issue in the latest release. Now the chart won't blink even when using the animateOnDataChange prop, It has been fixed from versions 1.4.42 onwards. 🎉

Please use the latest version of the library.