echarts报错的问题?

clipboard.png
代码如下,到底是哪里的问题呢
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>动态</title>
<script src="echarts.min.js"></script>
</head>
<body>
<div id="demo" style="width:640px;height:480px;"></div>
<script>
var myChart=echarts.init(document.getElementById("demo"));
option = {

title:{
    text:'疲劳状态'
},
tooltip:{
    trigger:'axis',        
},
xAxis:[
{
    type:'category',
    name:'时间',
    boundaryGap:false,
    data:(function(){
        var now = new Date();
        var res = [];
        var len = 10;
        while(len--){
            res.unshift(now.toLocaleTimeString().replace(/^\D*/,''));
            now = new Date(now - 2000);
        }
        return res;
    })()
}],
yaxis:[
    {
        type:'category',
        name:'疲劳状态',
        boundaryGap:false,
        data:['低风险','普通','高风险']

}
],
series:[
    {
        name:'疲劳状态',
        type:'line',
        data:(function(){
            var res = [];
            var len = 10;
            while(len--){
                res.push(Math.round(Math.random()*3))
            }
        return res;
        })()
    }
],    

};
setInterval(function(){

axisData = (new Date()).toLocaleTimeString().replace(/^\D*/,'');

var data = option.series[0].data;
//console.log(data)
data.shift();
data.push(Math.round(Math.random()*3));

option.xAxis[0].data.shift();
option.xAxis[0].data.push(axisData);
myChart.setOption(option);

},2000);
</script>

</body>
</html>

阅读 2k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进