Estoy tratando de actualizar los gráficos altos en la carga de la página y en seleccionar el menú de cambio con la llamada JQUERY AJAX. Se están devolviendo datos en formato [[10,1228800000], [10,1228800000]]. El gráfico está en blanco y no grafica ninguno de los datos.Cargar datos en Highcharts con Ajax
Probé varias soluciones publicadas aquí pero ninguna funcionó.
var chart;
$(document).ready(function() {
var options = {
chart: {
renderTo: 'stats',
defaultSeriesType: 'spline'
},
title: {text:''},
xAxis: {
type: 'datetime'
},
yAxis: {},
series: []
};
var month = 'July';
$.ajax({
type: "POST",
data: "month="+month,
url: "update_visits_chart",
success: function (data) {
options.series.push(data);
chart = new Highcharts.Chart(options);
}
});
¿Algún error? gracias por adelantado. EDIT:
CÓDIGO DE ÚLTIMO aún no funciona:
var options = {
chart: {
renderTo: 'stats',
type: 'spline'
},
title: {
text: ''
},
xAxis: {
type:'datetime',
tickInterval: 30 * 24 * 3600 * 1000,
dateTimeLabelFormats: {
day: '%b %e'
},
labels: {
rotation: -45,
align: 'right'
}
},
yAxis: {
title: {
text: 'Number of visits'
},
min: 0
},
tooltip: {
formatter: function() {
return Highcharts.dateFormat('%b %e', this.x) +'<br />'+this.y+' visit(s)';
}
},
legend: {
enabled: true
},
credits: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'Number of Visits',
data: []
}]
};
var month = 'July';
$.ajax({
type: "POST",
url: "update_visits_chart",
data: "month="+month,
success: function(data){
options.series[0].data = data;
chart = new Highcharts.Chart(options);
}
});
No pensé que tenía que hacer eso. gracias por señalarlo. –
¿Por qué tiene que hacerlo? no está siendo creado dinámicamente. –
alternativamente, creo que también puedes usar $ .getJSON. Ref http://api.jquery.com/jQuery.getJSON/ –