json Time (hh:mm:ss) value return from php json_encode

173 views Asked by At

I just want to ask if the returned data from my php json_encode is directly treated as "time" on my jquery, or do I have to format it in my jquery script ? Here:

enter image description here

I will be using this data on my jchartFX, I just wonder if this has been treated as "time" values or not . Because my chart displays: "No Data Available".I already made a data format but it seemed like not working. Here's the entire code: PHP

public function get_sample_data(){



   $data = $this->queries->query("SELECT DATE_FORMAT(a.datetimeRequested,'%M %d') AS `Date`,
                            SEC_TO_TIME(AVG(TIME_TO_SEC(c.request_startckit))) AS `AVG CT`, 
                               SEC_TO_TIME(SUM(TIME_TO_SEC(c.request_startckit))) AS `SUM CT`        
                        FROM request a
                        JOIN ckit b ON b.idRequest = a.idRequest
                        JOIN cycle_time c ON c.idCkit = b.idCKIT
                                ");
     echo json_encode($data,JSON_PRETTY_PRINT);
}

Jquery:

chart1 = new cfx.Chart();
chart1.getData().setSeries(2);

var xaxis = chart1.getAxisX();
xaxis.getLabelsFormat().setFormat(cfx.AxisFormat.Date);

var yaxis = chart1.getAxisY();
yaxis.getLabelsFormat().setFormat(cfx.AxisFormat.DateTime);
yaxis.getDataFormat().setCustomFormat("hh:mm:ss");
chart1.getDataGrid().setVisible(true);          
var series1 = chart1.getSeries().getItem(0);
var series2 = chart1.getSeries().getItem(1);
series1.setGallery(cfx.Gallery.Bar);
series2.setGallery(cfx.Gallery.Bar);

            $.ajax({
                url: $("#base_url").val() + "ajax/get_sample_data",
                dataType: "json",
                success: function(data){    

                   chart1.setDataSource(data);
                },
                error: function(){
                    alert("an error occured");
                } 
            });

 var divHolder = document.getElementById('ChartDiv');
 chart1.create(divHolder);  
1

There are 1 answers

2
stigma On

I think it would be better if you gave an example on how you will be using those values, that way we could see if you would need any kind of parsing. To answer your question, in your JSON response both of them are being treated as strings.