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!