Muchas gracias por la ayuda !!!

El domingo, 29 de enero de 2017, 5:22:23 (UTC-3), franck danard escribió:
>
> Found!!!!
>
> Champagne.... wifes....party...
>
>         dataType:"json",
>         success: function (json) {
>              
>             console.debug(json);
>             *var result = json.message;*
>             var container = document.getElementById('timeline');
>             var chart = new google.visualization.Timeline(container);
>             var dataTable = new google.visualization.DataTable(*result*);
>             
>             chart.draw(dataTable);
>         }
>
> We need to get message object
> i guess Parse doesn't work because it seems to be already parsed.
>
> Result takes the content of message.
> *Code shorter *
>
>         success: function (json) {
>              
>             console.debug(json);
>             var container = document.getElementById('timeline');
>             var chart = new google.visualization.Timeline(container);
>             var dataTable = new google.visualization.DataTable(
> *json.message*);
>             
>             chart.draw(dataTable);
>         }
>
> For resume.
>
> *For PHP - preparing datas*
>
>                     $table = array();
>                     $table['cols'] = array(array('label' => 'Room',     
> 'type' => 'string'),    
>                                            array('label' => 'Name',     
> 'type' => 'string'),
>                                            array('label' => 'Start',    
> 'type' => 'date'),
>                                            array('label' => 'End',      
> 'type' => 'date'));                
>                     foreach($_booking as $key => $value){
>                         .../...    
>                         $temp       = array();
>                         $temp[]     = array('v' => (string) $room_name); 
>                         $temp[]     = array('v' => (string) $guest_name); 
>                         $temp[]     = array('v' => (string) 
> "Date($yci,$mci,$dci)"); 
>                         $temp[]     = array('v' => (string) 
> "Date($yco,$mco,$dco)"); 
>                         $rows[]     = array('c' => $temp);
>                     }
>                     $table['rows'] = $rows;
>                     return json_encode($table, JSON_NUMERIC_CHECK);
>
>
>
> *For Javascript:*
>   google.charts.load("current", {packages:["timeline"]});
>   google.charts.setOnLoadCallback(drawChart);
>   function drawChart() {
>     $.ajax({
>         url: "ajax.php.....",
>         dataType:"json",
>         success: function (json) {
>              
>             console.debug(json);
>             var container = document.getElementById('timeline');
>             var chart = new google.visualization.Timeline(container);
>             var dataTable = new google.visualization.DataTable(json.
> message);
>             
>             chart.draw(dataTable);
>         }
>     });
>   }
>
> *Thanks at Daniel* for his graet help.
>
> Have a good day at all.
>
> Franck
>
>
>
>
>
> Le vendredi 27 janvier 2017 15:50:47 UTC+1, franck danard a écrit :
>>
>> Hi all.
>>
>> I've some problems to get some datas with JSON.
>> I've PHP function which send the value like this.
>>
>>                     $_booking        = $this->getPMSbooking("");
>>                     foreach($_booking as $key => $value){
>>                         $confirmed    = $value["confirmed"];
>>                         $conf         = "";
>>                         if($confirmed == "0")
>>                             $conf     = "*";
>>                         list($_date_ci, $time_ci)    = explode(" ",$value
>> ["date_ci"]);
>>                         list($yci, $mci, $dci)       = explode("-",
>> $_date_ci);
>>                         $mci          = strval(intval($mci)-1);
>>                         $dtci         = array($yci, $mci, $dci);
>>                         list($_date_co, $time_co)    = explode(" ",$value
>> ["date_co"]);
>>                         list($yco, $mco, $dco)       = explode("-",
>> $_date_co);
>>                         $mco          = strval(intval($mco)-1);
>>                         $dtco         = array($yci, $mci, $dco);
>>                         $_rooms       = $this->getPMS_all_rooms("id = ".
>> $value["room_id"]);
>>                         $_guest       = $this->getPMS_all_guest("id = ".
>> $value["guest_id"]);    
>>                         $room_name    = $_rooms[0]["room_name"];
>>                         $guest_name   = $_guest[0]["last_name"]." ".
>> $_guest[0]["first_name"]." ".$conf;
>>                         $data[$key]   = array($room_name, $guest_name, 
>> $dtci, $dtco );
>>                     }
>>
>>                     return json_encode($data, JSON_NUMERIC_CHECK);
>>
>> Next, i put in my page this.
>>
>>
>> <script type="text/javascript" src="
>> https://www.gstatic.com/charts/loader.js";></script>
>> <script type="text/javascript">
>>   google.charts.load("current", {packages:["timeline"]});
>>   google.charts.setOnLoadCallback(drawChart);
>>   function drawChart() {
>>     $.ajax({
>>         url: "ajax.php?module=ddd&booking=1",
>>         dataType:"json",
>>         success: function (json) {
>>       
>>             var container = document.getElementById('timeline');
>>             var chart = new google.visualization.Timeline(container);
>>             var dataTable = new google.visualization.DataTable();
>>             console.debug(json);
>>             dataTable.addColumn({ type: 'string', id: 'Term' });
>>             dataTable.addColumn({ type: 'string', id: 'Name' });
>>             dataTable.addColumn({ type: 'date', id: 'Start' });
>>             dataTable.addColumn({ type: 'date', id: 'End' });
>>
>>             dataTable.addRows(json);
>>
>>             chart.draw(dataTable);
>>         }
>>     });
>>   }
>> </script>
>>
>> But it doesn't' display anything.
>>
>> Message returns this :
>>
>> [["Room 200","Danard Franck *",[2017,0,28],[2017,0,31]],["Room 200","Danard 
>> Franck *",[2017,0,29],[2017,0,31]]]
>>
>> Sure, something is wrong in my code, but i don't know what.
>>
>> The format gave by google looks like this:
>>
>>  dataTable.addRows([ [ '1', 'George Washington', new Date(1789, 3, 30), new 
>> Date(1797, 2, 4) ], 
>>                      [ '2', 'John Adams', new Date(1797, 2, 4), new 
>> Date(1801, 2, 4) ], 
>>                      [ '3', 'Thomas Jefferson', new Date(1801, 2, 4), new 
>> Date(1809, 2, 4) ]]);
>>
>> I think that are the sames.
>>
>>
>> Could you help me please.
>>
>> Regards
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/3a53a53c-49b2-4f73-8202-775c037424ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to