reactjsreact-nativejsxreact-native-chart-kit

react-native-chart-kit Min and Max value


I really like how neat react-native-chart-kit is, however I am having a problem with how it display the data.

it use the lowest point in your data as the as the bottom and the highest as the top. There is an option to start from zero, but what if I wanted to start from 5? the same for the top, what If I wanted to display a range of 5to 90?

I was wondering if someone knew more about this graph or have used something else that can do these things?

Thanks

enter image description here


Solution

  • Add extra datasets with one value each (the min and max value you want to show)

    <LineChart
        data={{
            datasets: [
              {
                data: [3, 4, 5, 6, 7] // dataset
              },
              {
                data: [1] // min
              },
              {
                data: [10] // max
              },
            ],
          }}
    />