javascript - JSON Highcharts to draw multiple lines -


I have been completely lost with high charts! I have to draw a graph with several lines, I need a JSON output like this:

  [{"name": "2", "data": [1398333600000,1], [1398333600000,1], ....}, {"name": "16", "data": [1398333600000,1], [1398333600000,1] ...}, {.... .... }]   

... However, I get only one flawed JSON response from the PHP file. How can some altruistic soul light the way? Thank you very much in advance. Sorry, I'm a super-novice: (

My BD table Mysql:

I can not upload a picture with table BD on the post, sorry! ... I need at least 10 reputation! ... link ...

Javascript code:

  chart = new highchart. Chart ({chart: {rendereTo: 'DivStatsGrupo', plotBackgroundColor: Zero, conspiracy borderline: empty, plot shadow: false}, title: {text: titulo}, tooltip: {enable: false}}, exxis: {type: 'date time ', Date: Time Label: Format: {hour:'% H:% M ', label: {style: {width:' 200px ',' min-width ':' 100px '}, use HTML: true}}}, yAxis : {Categories: ['APAGADO', 'ACTIVO', 'ALARMA'], title: {text: 'ESTADO'}, minimum: 0}, series: [[showInLegend: true, name: data.name, type: ' Line ', data: data.data}]})}}   

and PHP code:

  need_once (' connection / conexion.php ') ; $ Sesion user = $ _SESSION ['MM_U username]]; $ SesionIdGrupo = $ _GET [' idg ']; $ sesionFechaActual = $ _GET [' fechaActual ']; /// ARREGLO FECHA RECIBIDA PARA ADAPTARLA A FORMATO DE BD YY-MM-DD $ sesionFechaActualArreglo = date_format (new date time ($ sesionFechaActual), "Y-M-D"); Mysql_select_db ($ DatabaseBase, $ Insert); $ Query_recordettabla = "Select * Where from the registrar IDUURUO = (Username =" $ sesionUser "to SELECT idUsurario) and idGrupo = '$ sesionIdGrupo' and fecha = '$ sesionFechaActualArreglo'"; $ Records tab = mysql_query ($ query_recordettabla, $ conexion) or die (mysql_error ()); $ Total Rows_RecordsetTabla = mysql_num_rows ($ Records tab); $ Arr = array (); While ($ row_RecordsetTabla = mysql_fetch_assoc ($ Records tab)) {$ idDispositivo = $ row_RecordsetTabla ['idDispositivo']; $ Fecha = $ row_RecordsetTabla ['fecha']; $ Hora = $ row_recordsetabala ['hora']; $ Isadado = $ line_records tabala ['estado']; $ Arrego Fun = Debt-Format (New DateTime ($ Fade), "Y-M-D"); $ Eriglohora = debt-format (new date time ($ hora), "h: i"); $ Eriglohora 2 = Stratetime ($ Ariglohora) * 1000; $ Arr [] = Array ($ Ariglohora 2, Floatval ($ etDo)); $ ArrDisp [] = array (floatwall ($ idDispositivo)); } $ Arr2 = array ('data' = & gt; $ arr, 'name' = & gt; $ arrDisp); Echo json_encode ($ arr2); Mysql_free_result ($ RecordsetTabla);   

I get this PHP file ...

  {"data": [[1398330000000,1], [1398332700000,1], [13 9 8331800000, 1], [13 8332700000,1]], "name": [[2], [2], [16], [16]]}   

I think I have problems with Arrays, Gracias!

You are very close I have kept the code as you like so that you can see small differences.

  $ items = array (); While ($ row_RecordsetTabla = mysql_fetch_assoc ($ Records tab)) {$ idDispositivo = $ row_RecordsetTabla ['idDispositivo']; $ Fecha = $ row_RecordsetTabla ['fecha']; $ Hora = $ row_recordsetabala ['hora']; $ Isadado = $ line_records tabala ['estado']; $ Arrego Fun = Debt-Format (New DateTime ($ Fade), "Y-M-D"); $ Eriglohora = date-format (new date time ($ horra), "h: i"); $ Eriglohora 2 = Stratotyim ($ Ariglohora) * 1000; // $ arr and $ arrDisp to $$ arr = array ($ arregloHora2, floatval ($ etdado)); $ ArrDisp = array (floatwall ($ idDispositivo)); // Name and data should be kept as part of an array $ objects [] = array ('data' = & gt; $ arr, 'name' = & gt; $ arrDisp); } // $ arr2 = array ('data' = & gt; $ arr, 'name' = & gt; $ arrDisp); Echo json_encode ($ item); Mysql_free_result ($ RecordsetTabla); Please note that I was not able to test it, but if it does not work then tell me and I will look forward to it.   

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -