• 17-05-2020, 13:14:42
    #1
    Merhaba

    PHP' den gelen cevap şu şekilde.
    [{"statistics": "4010000,4010000,4010000,4010000,4010000,4010000,4010000","dates": "'10.05.2020','11.05.2020','12.05.2020','13.05.2020','14.05.2020','15.05.2020','16.05.2020'"}]
    şu şekilde veriye erişim state e kaydediyorum.
    getJson = (type,charttype,userID) => {
    return fetch(siteUrl+'/json/list.php?type='+type+'&chartType='+charttype+'&cID='+userID)
    .then((response) => response.json())
    .then((responseJson) => {
    this.setState({
    isLoading: false,
    dataChart: responseJson
    }, function() {
    });
    })
    .catch((error) => {
    console.error(error);
    });
    }
    Chart için veriyi göndermem gereken yerler şunlar.

              data={{
    labels: ["January", "February", "March", "April", "May", "June"],
    datasets: [
    {
    data: [20, 45, 28, 80, 99, 43],
    }
    ]
    }}
    statistics olan veri data: kısmına gelecek, dates olan kısım labels kısmına gelecek. this.state.dataChart[0].statistics this.state.dataChart[0].dates olarak veriyi gönderdiğimde hata veriyor.

  • 17-05-2020, 13:26:36
    #2
    hocam bence yukarıdaki kod ile hiç uğraşmayın aşağıdaki gibi yapabilirsiniz

    $.ajax({
    type : 'POST',
    url : url,
    data : data},
    dataType: 'json',
    success: function (res) {
    
    data={{
    labels: res.labels,
    datasets: [
    {
    data: res.data,
    }
    ]
    }}
    
    
    }
    })




    isterseniz ücretli yardımcı olabilirim