I'm trying to create a graphic with highcharts from some data that I get with ajax
by json
.
This is my .js
:
function graficoData (data) {
$('#chart1').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Equipos por estados'
},
xAxis: {
categories: ['Activo', 'Reserva', 'En Reparación', 'Baja']
},
yAxis: {
title: {
text: 'Número de equipos'
}
},
series: data,
});
}
$(document).ready(function() {
$.ajax({
url: '/grafico-estados/',
type: 'GET',
async: true,
dataType: "json",
success: function (data) {
graficoData(data);
}
});
});
The data
that I get is:
[{"estado":"Activo","total":2},{"estado":"Baja","total":1},{"estado":"Reserva","total":1}]
How can I do it?
Thank you.