2
I am implementing graphs in my application made in PHP,using Framework Chart.js,passing the query data via JSON,to assemble the graph, but when I will render it presents the following error:
Follows code:
$(document).ready(function() {
$.ajax({
url: "http://des.ead.prodemge.gov.br/gea/develop/graficos/data.php",
method: "GET",
success: function(dados) {
console.log(dados);
var departament = [];
var acesso = [];
for( var i in dados){
departament.push("Departamento "+dados[i].department);
acesso.push(dados[i].qtdacesso);
}
var chartdado = {
labels:departament,
datasets:[
{
label: 'Departamento Acessos',
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)',
dados:acesso
}
]
};
var ctx = $("#mycanvas");
var grafico = new (ctx, {
type:'bar',
data:chartdado
});
},
error: function(dados){
console.log(dados);
}
});
});
I checked the variables datasets,I performed the date:access exchange, but it still presents the same error...following critique of the console.log "Typeerror: ({type:"bar", data:{Labels:["Department Undefined" as image above.
– Rafael Luz
I updated my post with error review. @Andréluizdegusmão..
– Rafael Luz
@Andréluizdegusmão commited code in GIT https://github.com/Rafael2016/Web...
– Rafael Luz