how to use chart.js with mysql database
$(document).ready(function(){
$.ajax({
url: "http://localhost/chartjs/data.php",
method: "GET",
success: function(data) {
console.log(data);
var player = [];
var score = [];
for(var i in data) {
player.push("Player " + data[i].playerid);
score.push(data[i].score);
}
var chartdata = {
labels: player,
datasets : [
{
label: 'Player Score',
backgroundColor: 'rgba(200, 200, 200, 0.75)',
borderColor: 'rgba(200, 200, 200, 0.75)',
hoverBackgroundColor: 'rgba(200, 200, 200, 1)',
hoverBorderColor: 'rgba(200, 200, 200, 1)',
data: score
}
]
};
var ctx = $("#mycanvas");
var barGraph = new Chart(ctx, {
type: 'bar',
data: chartdata
});
},
error: function(data) {
console.log(data);
}
});
});
Also in JavaScript:
- js detect cmd+s
- angular url parameter
- jquery get current url
- how to import npm module
- angular ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.
- facebook pixel
- Bidirectionnal model binding
- unix timestamp to date javascript yyyy-mm-dd
- json token for .ini file
- javascript convert number to string
- js convert object to string
- javascript login validation
- moment js date diff
- mvc ajax unobtrusive before submit .net core
- how to get the class name dynamically using jquery
- ssh tunnel connect to mongodb in node.js
- react hero slider
- remove a user from a reaction discord.js
- make a if in jsx
- javascript change select options dynamically
- react fragment
- javascript canvas beziercurveto
- javascript ... operator
- node require fs not found