react-native-gifted-charts icon indicating copy to clipboard operation
react-native-gifted-charts copied to clipboard

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

Open Xaeryan opened this issue 1 year ago • 1 comments

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

Xaeryan avatar Apr 17 '24 20:04 Xaeryan

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}/>;

keithorange avatar Apr 23 '24 22:04 keithorange