indiespirit / react-native-chart-kit

đź“ŠReact Native Chart Kit: Line Chart, Bezier Line Chart, Progress Ring, Bar chart, Pie chart, Contribution graph (heatmap)
https://expo.io/@indiespirit/react-native-chart-kit
MIT License
2.8k stars 653 forks source link

Is it a way to make Line Chart with smooth animation ? #696

Closed SBRKH closed 8 months ago

SBRKH commented 11 months ago

Hello,

I'm using the library to display line graphs but I'm not happy with the way the graph is displayed, so I tried displaying it "with animation". To do this, instead of passing my datasets like this :

data={{
      labels: ["January", "February", "March", "April", "May", "June"],
      datasets: [
        {
          data: [
            Math.random() * 100,
            Math.random() * 100,
            Math.random() * 100,
            Math.random() * 100,
            Math.random() * 100,
            Math.random() * 100
          ]
        }
      ]
    }}

I'm doing like that :

const [data, setData] = useState<number[]>([0]);

useInterval(() => {
setData(prev => ([...prev, Math.random() * 100]));
}, 250);

data={{
      labels: ["January", "February", "March", "April", "May", "June"],
      datasets: [
        {
          data
  }
      ]
    }}

It works but it's not smooth, it's like adding a dot directly onto the graphic without any fading or other animation... I can't find a way to make it more smooth, does anyone have an idea?

Thank you for your help,