canvasJS:图表未加载

canvasJS : the chart isnt loaded

这实际上是我第一次使用 canvajs,但它确实有效 :( 有人可以检查我的代码吗

data.php

<?php 

header('Content-Type: application/json');

include './traitement.php';

$data =array();

$data=getListTemp();

$point=array();

$data_points=array();

foreach($data as $value){ foreach($value as $l){

        $s= explode( 'T', $l->date) ;

        $t=explode('-',$s[0]);

        $f=explode(':',$s[1]);

        $io=explode('+',$f[2]);

        $o=mktime($f[0],$f[1],$io[1],$t[1],$t[2],$t[0]);

        $i= date ("D M Y H:i:s U", $o);

        $point = array("x" => $i, "y" => $l->valeur);

        array_push($data_points, $point);        
}}

echo json_encode($data_points, JSON_NUMERIC_CHECK);

?>

结果:

[{"x":"Sat Jul 2017 23:20:01","y":30},{"x":"Sat Jul 2017 23:10:01","y":30}, {"x":"Sat Jul 2017 23:00:01","y":30},{"x":"Sat Jul 2017 22:50:01","y":25},{"x" :"Sat Jul 2017 22:40:01","y":30},{"x":"Sat Jul 2017 22:30:01","y":25},{"x":"Sat Jul 2017 22:20:01" ,"y":30},{"x":"Sat Jul 2017 22:10:01","y":40},{"x":"Sat Jul 2017 22:00:01","y" :23}]

curve.html

<!DOCTYPE html>
<html>


<head>
    <title></title>

    <script src="canvasjs.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script src="http://code.jquery.com/jquery-latest.js" > </script>

    <script type="text/javascript">

$(document).ready(function () {
$.getJSON("data.php", function (result) {

 var dps=[]; 
 dps = result;

     var chart = new CanvasJS.Chart("chartContainer",{
        title :{
            text: "Data "
        },
        axisX: {                        
            title: "time",

        },
        axisY: {                        
             title: "temperature",

        },
        data: [{
            type:"spline",

            dataPoints : dps
        }]
      });

     chart.render();    


});

});

    </script>
</head>
<body>

    <div id="chartContainer" style="width: 800px; height: 380px;"></div>

</body>
</html>

这就是我得到的结果!! enter image description here

用标签替换 x。根据文档和我尝试过的事情,x 应该是一个数字,然后它才会起作用,在你的情况下它是字符串 'Sat jul ..' 所以将 x 标记为标签

(以下是我上面评论的复制粘贴) 在 'x' 的位置使用 'label' 作为响应,我阅读了文档并尝试了这个 jsfiddle.net/p7w58naq 和你的响应