如何在更新由以下人员管理的视图的属性“d"时解决错误:RNSVGPath InvalidNumber [英] How to resolve Error while updating property 'd' of a view managed by:RNSVGPath InvalidNumber

查看:118
本文介绍了如何在更新由以下人员管理的视图的属性“d"时解决错误:RNSVGPath InvalidNumber的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 react-native-chart-kit 加载我的 sql server 数据,但是当我使用此代码时,我收到此错误:

I need to load my sql server data using react-native-chart-kit ,but when I use this code I get this error :

更新由 RNSVGPath 管理的视图的属性d"时出错空值无效号码

Error while updating property 'd' of a view managed by:RNSVGPath null InvalidNumber

import React from 'react';
import {Text,View,Dimensions} from 'react-native';
import {LineChart} from "react-native-chart-kit";
export default class Home extends React.Component {
  constructor(props) {
      super(props);
      this.state = {
         isLoading: true,
         data: {
             labels: ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"],
             datasets: [
                 {
                     data: []
                 }
             ]
         }
      }
  }

  GetData = () => {
      const self = this;

      return fetch('http://192.168.1.5:80/graph.php')
      .then((response) => response.json())
      .then((responseJson) => {

        // clone the data from the state
        const dataClone = {...self.state.data}

        const values = responseJson.map(value => value.ChiffreAffaire);

        dataClone.datasets[0].data = values;

        self.setState({
          isLoading: false,
          data: dataClone,
        });

      })
      .catch((error) =>{
        console.error(error);
      });
  }

  render() {
      return (
        <View>
        <LineChart
        data={this.state.data}
        width={Dimensions.get("window").width} // from react-native
        height={220}
        yAxisLabel={"$"}
        chartConfig={chartConfig}
        bezier
        style={{
          marginVertical: 8,
          borderRadius: 16
        }}
        />
        </View>
      );
  }
}

我从我的 php 文件中得到的数据是这样的:[{"ChiffreAffaire":"4800.00"},{"ChiffreAffaire":"12000.00"}]

The data I get from my php file is like :[{"ChiffreAffaire":"4800.00"},{"ChiffreAffaire":"12000.00"}]

<?php

$serverName="DESKTOP-T5SLVUB\SQL2008R2";
$connectionInfo=array("Database"=>"Netos_DB","UID"=>"sa","PWD"=>"123");
$conn=sqlsrv_connect($serverName,$connectionInfo);
$sql = "select  ChiffreAffaire from V502_client where Mois=2 and Annee=2020 "; 
$stmt = sqlsrv_query( $conn, $sql  );
 while( $row[] = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_NUMERIC) ){
      $Item = $row;
      $json = json_encode($Item);    
}

echo $json;
?>

我不知道是什么问题以及为什么我会收到此错误;请如果你有任何想法

I don't know what is the problem and why I m getting this error ; please if you have any Idea

推荐答案

这对我有用:

{
    this.state.loadComplete &&
        (<LineChart
            data={this.state.dt}
            width={Dimensions.get("window").width} // from react-native
            height={this.height}
            yAxisLabel=""
            yAxisSuffix="b"
            yAxisInterval={1} // optional, defaults to 1
            chartConfig={this.config}
            bezier
            style={{
                marginVertical: 8,
                borderRadius: 16
            }}
        />)
}

这篇关于如何在更新由以下人员管理的视图的属性“d"时解决错误:RNSVGPath InvalidNumber的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆