React-native-chart-kit: <LineChart> null value are displayed as 0

Created on 3 Aug 2020  路  3Comments  路  Source: indiespirit/react-native-chart-kit

null values are still displayed as 0, but I would expect nothing to be shown instead.
In my case I have two lines to compare, the first dataset relative to the past year, the second one describing this year data; so showing 0 for values not yet occurred is just not right.
Is there a workaround?

const data = {
  datasets: [
    {data: [20, 45, 28, 80, ..., 99, 43, 65]}
    {data: [12, 54, 23, 45, ..., null, null, null]}
    legend: [2010, 2019],
  ],
};

Screenshot_20200803-025342

Most helpful comment

Hey, you found any solution for this? I have a graph and I want to skip the null values and just connect the dots from the previous to the next one.

All 3 comments

Hey, you found any solution for this? I have a graph and I want to skip the null values and just connect the dots from the previous to the next one.

Unfortunately, I haven't found a clear answer either, but what I did find for my purposes I was able to do:

 getDotColor={(datapoint) => {
    if (datapoint === null) {
        return 'transparent';
    }
}}

@brandonin This solution worked well for me, though it shows a type error since it isn't necessarily returning anything, so I just changed it to:

 getDotColor={(datapoint) => {
    if (datapoint === null) {
        return 'transparent';
    }
    return 'black';
}}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Danjavia picture Danjavia  路  5Comments

bailih picture bailih  路  4Comments

Ivanrs297 picture Ivanrs297  路  6Comments

carlojesuscponti picture carlojesuscponti  路  6Comments

SyedShahbazHussain picture SyedShahbazHussain  路  4Comments