I'm making a request to assemble a chart using Flot Js.
I'm returning a Json like this:
[{
"status": "Finalizado",
"id_status": "4",
"total_chamado": "2",
"mes": "4",
"ano": "2015"
}, {
"status": "Finalizado",
"id_status": "4",
"total_chamado": "1",
"mes": "5",
"ano": "2015"
}, {
"status": "Finalizado",
"id_status": "4",
"total_chamado": "1",
"mes": "6",
"ano": "2015"
}, {
"status": "Finalizado",
"id_status": "4",
"total_chamado": "1",
"mes": "7",
"ano": "2015"
}, {
"status": "Em Aberto",
"id_status": "1",
"total_chamado": "1",
"mes": "8",
"ano": "2015"
}, {
"status": "Finalizado",
"id_status": "4",
"total_chamado": "1",
"mes": "8",
"ano": "2015"
}, {
"status": "Em Aberto",
"id_status": "1",
"total_chamado": "3",
"mes": "9",
"ano": "2015"
}, {
"status": "Em Aberto",
"id_status": "1",
"total_chamado": "1",
"mes": "10",
"ano": "2015"
}, {
"status": "Em Aberto",
"id_status": "1",
"total_chamado": "1",
"mes": "11",
"ano": "2015"
}]
And I need it in JavaScript to look like this:
vetor = [ [mes, total], [mes, total], [mes, total], [mes, total], [mes, total], [mes, total] ];
I'm trying like this, but it's not working. The graph does not mount.
var caixa_entrada = []
$.ajax({
type: "GET",
cache: false,
url: baseURL + '/dashboard/grafico-chamado',
dataType: 'json',
success: function(data){
$.each(data, function(index, value){
caixa_entrada.push([index, value.total_chamado]);
});
}
});