0

我只想问从我的 php json_encode 返回的数据是否在我的 jquery 上直接被视为“时间”,还是我必须在我的 jquery 脚本中对其进行格式化?这里:

在此处输入图像描述

我将在我的 jchartFX 上使用这些数据,我只是想知道这是否被视为“时间”值。因为我的图表显示:“无可用数据”。我已经制作了数据格式,但它似乎不起作用。这是整个代码: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);
}

查询:

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);  
4

1 回答 1

0

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.

于 2015-05-29T03:08:46.987 回答