2016-09-30 85 views
0

我想繪製兩個自定義日期範圍之間的歷史浮動圖表,用戶將選擇日期範圍並根據選擇我將檢索我的數據庫中的數據並繪製浮動圖表。基於選擇從數據庫中檢索數據已完成,但將這些數據繪製在條形圖中不會導致結果。下面是我的代碼,我想要繪製繪製兩個自定義日期範圍之間的歷史浮動圖表

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
 

 
<html> 
 
<head>  
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
 
<title>Flot Examples: Real-time updates</title>  
 
<script data-require="[email protected]" data-semver="2.1.3" src="https://code.jquery.com/jquery-2.1.3.min.js"></script> 
 
<script data-require="[email protected]" data-semver="0.8.2" src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js"></script> 
 
<script data-require="[email protected]" data-semver="0.8.2" src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.time.min.js"></script> 
 
<link href="style.css" rel="stylesheet" type="text/css" /> 
 
<script type="text/javascript"> 
 

 
    
 
$(function() 
 
{ 
 
function GetData() 
 
{ 
 
var data = []; 
 
var now = new Date().getTime(); 
 
var res;  
 
data.shift(); //to remove first item of array 
 
var str = [[1475210230423,64.51024424527357],[1475210232423,26.131426274344072]]; 
 
data.push(str); 
 
$.plot($("#placeholder"), [data], {series: {  
 
lines: {  
 
show: true,   
 
lineWidth: 1.2,   
 
fill: true 
 
    } 
 
    },   
 
yaxis: {   
 
min: 0,   
 
max: 100  
 
},  
 
xaxis: { 
 
mode: "time", minTickSize: [1, "day"] 
 
} 
 
}  
 
);} 
 
GetData(); 
 
}); 
 

 
    
 
</script> 
 
</head> 
 
<body>  
 
<div id="header">  
 
<h2>HISTORICAL CHART</h2>  
 
</div> 
 
<div id="content">  
 
<div class="demo-container">   
 
<div id="placeholder" class="demo-placeholder"></div>  
 
</div>   </div>  
 
<div id="footer"> \t 
 
\t Copyright © 2007 - 2014 IOLA and Ole Laursen \t 
 
</div> 
 
</body> 
 
</html>

+1

改變這一點 - $ .plot($( 「#佔位符」),[數據] {系列:{本 - $ .plot($(「#placeholder」),data,{series:{...從數據中刪除[]我必須將高度設置爲佔位符div -

+0

@ T.Shah您可以將其作爲回答? – Blake

回答

1
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 

    <html> 
    <head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
    <title>Flot Examples: Real-time updates</title>  
    <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js"></script> 
    <script src="//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.time.min.js"></script> 
    <link href="style.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript"> 


    $(function() 
    { 
    function GetData() 
    { 
    var data = []; 
    var now = new Date().getTime(); 
    var res;  
    data.shift(); //to remove first item of array 
    var str = [[1475210230423,64.51024424527357],[1475210232423,26.131426274344072]]; 

    data.push(str); 
    $.plot($("#placeholder"), data, {series: {  
    lines: {  
    show: true,   
    lineWidth: 1.2,   
    fill: true 
     } 
     },   
    yaxis: {   
    min: 0,   
    max: 100  
    },  
    xaxis: { 
    mode: "time", minTickSize: [1, "day"] 
    } 
    }  
    );} 
    GetData(); 
    }); 


    </script> 
    </head> 
    <body>  
    <div id="header">  
    <h2>HISTORICAL CHART</h2>  
    </div> 
    <div id="content">  
    <div class="demo-container">   
    <div id="placeholder" class="demo-placeholder" style="height:300px;"></div>  
    </div>   </div>  
    <div id="footer"> 
      Copyright © 2007 - 2014 IOLA and Ole Laursen  
    </div> 

    </body> 
    </html> 
相關問題