react-native-chart-kit错误,而更新由RNSVGPath管理的视图的属性“ d”:

问题描述 投票:0回答:1

我正在使用react-native-chart-kit饼图。

在数据数组中,而不是在总体中写数字,而是在编写“ this.state.data”,如下所示,因为我是从API获取数字的。

const pieData1 = [
  {
    name: ': East',
    population: this.state.data,
    color: '#00664f',
    legendFontColor: 'black',
    legendFontSize: 12,
  },

]

但是出现错误“更新由RNSVGPath管理的视图的属性“ d”时出错:”。知道如何解决吗?

api react-native react-native-chart-kit
1个回答
0
投票

只需使用parseInt将您的状态转换为Integer,就可以>

const pieData1 = [
  {
    name: ': East',
    population: parseInt(this.state.data), ////
    color: '#00664f',
    legendFontColor: 'black',
    legendFontSize: 12,
  },
© www.soinside.com 2019 - 2024. All rights reserved.