Tengo este archivo data.php
que me genera estos datos
Cita:
datos que quiero implementar en este códigoCategorias,14/10/12 19:00,14/10/12 18:00,14/10/12 17:00,14/10/12 16:00,14/10/12 15:00,14/10/12 14:00,14/10/12 13:00,14/10/12 12:00,14/10/12 11:00,14/10/12 10:00,14/10/12 09:00,14/10/12 08:00,14/10/12 07:00,14/10/12 06:00,14/10/12 05:00,14/10/12 04:00,14/10/12 03:00,14/10/12 02:00,14/10/12 01:00,14/10/12 00:00,13/10/12 23:00,13/10/12 22:00,13/10/12 21:00,13/10/12 20:00
Rainfall,0.0,0.0,0.8,0.4,0.6,1.8,0.0,0.0,1.6,0.0,0 .0,0.0,0.0,0.0,0.0,0.4,2.2,0.8,0.0,0.0,0.0,0.0,0.0 ,0.0
Sea-Level Pressure,971.2,971.0,970.9,970.8,970.1,970.1,969.6 ,969.6,969.2,967.7,967.0,967.3,967.4,968.3,969.0,9 69.0,971.1,971.4,972.2,972.7,973.2,973.9,974.3,974 .2
Temperature,10.3,11.3,10.4,10.4,11.4,11.4,14.4,12. 6,11.7,14.5,13.7,13.5,11.2,10.2,9.7,9.7,10.4,10.7, 10.9,11.4,11.9,12.7,13.6,14.2
Rainfall,0.0,0.0,0.8,0.4,0.6,1.8,0.0,0.0,1.6,0.0,0 .0,0.0,0.0,0.0,0.0,0.4,2.2,0.8,0.0,0.0,0.0,0.0,0.0 ,0.0
Sea-Level Pressure,971.2,971.0,970.9,970.8,970.1,970.1,969.6 ,969.6,969.2,967.7,967.0,967.3,967.4,968.3,969.0,9 69.0,971.1,971.4,972.2,972.7,973.2,973.9,974.3,974 .2
Temperature,10.3,11.3,10.4,10.4,11.4,11.4,14.4,12. 6,11.7,14.5,13.7,13.5,11.2,10.2,9.7,9.7,10.4,10.7, 10.9,11.4,11.9,12.7,13.6,14.2
Código:
seguro que tengo alguna coma mal, seguro que hay errores de sintaxis que me siento incapaz de resolver.var chart; // global /** * Request data from the server, add it to the graph and set a timeout to request again */ function requestData() { $.ajax({ url: 'data.php', success: function(data) { // Split the lines var lines = data.split('\n'); $.each(lines, function(lineNo, line) { var items = line.split(','); // header line containes categories if (lineNo === 0) { $.each(items, function(itemNo, item) { if (itemNo > 0) options.xAxis.categories.push(item); }); } // the rest of the lines contain data with their name in the first position else { $.each(items, function(itemNo, item) { if (itemNo === 0) { options.series[lineNo-1].name = item; } else { options.series[lineNo-1].data.push(parseFloat(item)); } }); } }); console.log(options); var chart = new Highcharts.Chart(options); }); });
pues eso, cualquier idea me será de gran ayuda.
Gracias a todos.