You must be logged in to post your query.
Home › Forums › Chart Support › Can't create chart from external api link
Tagged: #externalJson
Hello everyone! This is my first time with CanvasJs. I’m trying to create a chart from my local api link. Here is my code:
$.ajax({ type: 'GET', url: 'http://localhost:8083/json', dataType: 'json', success(data) { new CanvasJS.Chart("chartContainer", { title: { text: "User Count" }, data: [{ type: "column", dataPoints: data.map( ({ userId, numberOfusers }) => ({ label: userId, y: numberOfusers }) ) }] }).render(); } }); <script src="https://cdnjs.cloudflare.com/ajax/libs/canvasjs/1.7.0/canvasjs.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <br><br> <div id="chartContainer" style="height: 360px; width: 100%;"></div>
But it return white page. Can someone help me? Thank you very much!
@murcie96,
Can you kindly share a sample project with sample JSON data over google-drive or onedrive so that we can understand it better and help you out?
___________ Indranil Deo, Team CanvasJS
Thanks for your reply! I fixed. I need to allow origin for my server side. Then I can use localhost api link to create chart.
Glad you figured out the issue.
You must be logged in to reply to this topic. Login/Register