Home Forums Chart Support drawing canvas JS charts using fetch

drawing canvas JS charts using fetch

Viewing 2 posts - 1 through 2 (of 2 total)
  • #27933

    can any one assist where i made mistake!!!

    fetch(‘data.php’,{
    method:”post”,
    body:formData
    }).then(response=>response.json()).then(result=>{
    let dataPoints = [];
    const chart = new CanvasJS.Chart(“chartContainer”,
    animationEnabled:true,
    theme:”light2″,
    title:{
    text:”Attendance Chart”
    },
    axisY:{
    title:”numbers”,
    titleFontSize:”24″
    },
    data:[{
    type:”column”,
    yValueFormatString:”#,###,## numbers”,
    dataPoints:dataPoints
    }]

    })
    function (result){
    for(let i=0;i<result.data;i++){
    dataPoints.push({
    x: result[i].districts
    y: result[i].students
    })
    }
    }
    }).catch(error=>{
    $(“#fetcherror”).text(error)
    });

    #27962

    @khan-sikki,

    Please take a look at this JSFiddle for creating a chart using data received from fetch method.

    If you are still facing the issue, can you kindly create a sample project along with sample data and share it over google-drive or one-drive so that we can look into the code and understand it better and help you out?

    —-
    Manoj Mohan
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.