You must be logged in to post your query.
Home › Forums › Chart Support › drawing canvas JS charts using fetch
Tagged: javascript
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) });
@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
You must be logged in to reply to this topic. Login/Register