中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

jquer 獲取json數據,并且用 highcharts 實現展現

發布時間:2020-06-29 01:34:24 來源:網絡 閱讀:1005 作者:tianshuai369 欄目:web開發

json數據格式如下:

{

   "value": [
        23,
        4,
	24,
	95,
	27,
	35,
	93,
	63,
	75,
	17,
	13,
	93,
	54,
	71,
	61,
	14,
	13,
        14,
        29
    ]

  

}

需要highcharts的dark-blue.js文件

html文件格式如下:

<!doctype html>
<html lang="en">
<head>
  <script type="text/javascript" src="http://cdn.hcharts.cn/jquery/jquery-1.8.3.min.js"></script>
  <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/highcharts.js"></script>
  <script type="text/javascript" src="http://cdn.hcharts.cn/highcharts/exporting.js"></script>
  <script type="text/javascript" src="dark-blue.js"></script>
  <script>
  $(document).ready(function() {
    $.getJSON('http://1.1.1.1:800/1.json', { }, function (json_data) {
    //左側Javascript代碼
 $(function () {                                                                     
    $(document).ready(function() {                                                  
        Highcharts.setOptions({                                                     
            global: {                                                               
                useUTC: false                                                       
            }                                                                       
        });                                                                         
                                                                                    
        var chart;                                                                  
        $('#container').highcharts({                                                
            chart: {                                                                
                type: 'spline',                                                     
                animation: Highcharts.svg,             
                marginRight: 10,                                                    
                events: {                                                           
                                                                           
                }                                                                   
            },                                                                      
            title: {                                                                
                text: '流量圖'                                            
            },                                                                      
            xAxis: {   
    title: {                                                            
                    text: '時間'                                                   
                },
                type: 'datetime',                                                   
                tickPixelInterval: 150                                              
            },
   credits: {          
    enabled:false
   },  
            yAxis: {                                                                
                title: {                                                            
                    text: '單位/M'                                                   
                },                                                                  
                plotLines: [{                                                       
                    value: 0,                                                       
                    width: 1,                                                       
                    color: '#808080'                                                
                }]                                                                  
            },                                                                      
            tooltip: {                                                              
                formatter: function() {                                             
                        return '<b>'+ this.series.name +'</b><br/>'+                
                        Highcharts.dateFormat("時間:"+ '%m-%d %H:%M:%S', this.x) +'<br/>'+
                        "數據:" + Highcharts.numberFormat(this.y, 2);                         
                }                                                                   
            },   
   
            legend: {                                                               
                enabled: false                                                      
            },                                                                      
            exporting: {                                                            
                enabled: false                                                      
            },                                                                      
            series: [{                                                              
                name: '實時數據',                                                
                data: (function() {  
                    // generate an array of random data                             
                    var data = [],                                                  
                        time = (new Date()).getTime(),                            
                      length=((json_data.value).length)+1;
      
     $.each(json_data.value, function(i, value) {      
         data.push({                                                 
                            x: time - length * 1000, 
                            y: value                                       
                        }); 
      length--;      
     });                                                                  
                    return data;                                                    
                })()                                                                
            }]                                                                      
        });                                                                         
    });                                                                             
                                                                                    
});  
}); 
});                                                                                    
  </script>
</head>
<body>
  <div id="container" ></div>
</body>
</html>

最終展現效果如下:

jquer 獲取json數據,并且用 highcharts 實現展現

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

武宁县| 彭水| 文化| 温泉县| 五河县| 钦州市| 茶陵县| 黄冈市| 郯城县| 龙岩市| 布尔津县| 汉沽区| 华蓥市| 准格尔旗| 南投市| 南城县| 天峨县| 鄂托克前旗| 襄城县| 阿克陶县| 朝阳市| 青阳县| 漳平市| 全椒县| 团风县| 六安市| 土默特左旗| 高阳县| 尚义县| 尖扎县| 和平县| 多伦县| 玛多县| 崇仁县| 平遥县| 镇远县| 黄浦区| 白河县| 太仓市| 韩城市| 运城市|