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
732 stars 149 forks source link

WHEN using dataSet property THEN some points/lines are not drawn #606

Open Xaeryan opened 5 months ago

Xaeryan commented 5 months ago

I'm using the dataSet property and noticing in some cases points/lines are either being cutoff or not drawn. Take the following code:

import React from 'react';
import { View } from 'react-native';
import { LineChart } from "react-native-gifted-charts";

export default function TestComponenet1 () {
    const dataSet = [
            {   
                data: [{value: 12},{value: 22},{value: 33}], 
                color: 'orange', 
                dataPointsColor: 'orange' 
            },
            {   
                data: [{value: 15}, {value: 30}, {value: 26}, {value: 40}, {value: 33}],
                color: 'blue', 
                dataPointsColor: 'blue' 
            },
        ];

  return (
    <View style={{flex: 1, backgroundColor: 'white'}}>
      <LineChart dataSet={dataSet} backgroundColor={'gray'} 
       yAxisOffset={0}
       maxValue={50} 
       width={280}
       spacing={55}
        />
    </View>
  );
}

It results in the following. Note the BLUE line is missing the last point (4 instead of 5):

Simulator Screenshot - iPhone 15 Pro - 2024-04-17 at 16 12 00

Now if we just add another point to the ORANGE line, the missing BLUE line/point shows up:

import React from 'react';
import { View } from 'react-native';
import { LineChart } from "react-native-gifted-charts";

export default function TestComponenet1 () {
    const dataSet = [
            {   
                data: [{value: 12},{value: 22},{value: 33},{value: 27}], 
                color: 'orange', 
                dataPointsColor: 'orange' 
            },
            {   
                data: [{value: 15}, {value: 30}, {value: 26}, {value: 40}, {value: 33}],
                color: 'blue', 
                dataPointsColor: 'blue' 
            },
        ];

  return (
    <View style={{flex: 1, backgroundColor: 'white'}}>
      <LineChart dataSet={dataSet} backgroundColor={'gray'} 
       yAxisOffset={0}
       maxValue={50} 
       width={280}
       spacing={55}
        />
    </View>
  );
}

Results in this (correct):

Simulator Screenshot - iPhone 15 Pro - 2024-04-17 at 16 16 12

keithorange commented 4 months ago

Same issue! I think its to do with line charts. I am getting it cutoff too! Screenshot 2024-04-23 at 6 22 58 PM

  // take just roi for each as {value: roi}
  const lineChartData = trades.map(trade => ({
    value: trade.roi
  }));

<LineChart data={lineChartData}/>;