React native 纯图表负值不绘制

React native pure chart negative value is not drawing

我正在使用折线图显示数据。它工作得很好,但如果我的数据在那种情况下有负值,我的图表就会从底部开始切割。

你可以在上图中看到我的错误,用红色标记。

我使用了 react-native-pure-chart - 下面 link :-

https://www.npmjs.com/package/react-native-pure-chart

<PureChart type={'line'}
  numberOfYAxisGuideLine={0}
  data={this.state.sampleData}
  width={'100%'}
  height={72}
  backgroundColor={'#2c3554'}
  color={'#2c3554'}
  />

我的数据是[10,-2​​,6]

请帮帮我。提前谢谢你

我找到了解决方案。

使用 react-native-svg-chart(折线图)。

它将解决问题。

下面是我的代码:-

 import { LineChart } from 'react-native-svg-charts'

 <LineChart
      style={{ flex: 1, marginLeft: 4 }}
      data={this.state.sampleData}
      svg={{ stroke: 'rgb(211, 234, 250,0.7)' }}
      contentInset={contentInset}
      />