带有日期范围过滤的高图表

时间:2014-11-05 12:52:52

标签: php sql charts highcharts

任何人都可以为高图表编码范围日期过滤。我不知道如何编码

我的图表从sql dabase获取数据,我希望用户可以选择查看图表的日期

图表是我项目的最后一个功能请帮助我

http://postimg.org/image/kp0ukinzp/

这是我的代码

 <?php
$monthx = array(); 
$y2556 = array(); 

$sql = "SELECT count(month) as month FROM line group by month";
$sql1 = "SELECT month as month FROM line group by month";

$result = mysql_query($sql);
$result1 = mysql_query($sql1);


while($row=mysql_fetch_array($result)) {
array_push($y2556,$row['month']);
}

while($row1=mysql_fetch_array($result1)) {
array_push($monthx,$row1['month']);


}
?>

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>

<script src="scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script src="scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
    <script src="highcharts.js"></script>
<script src="exporting.js"></script>

<script>
$(function () {
$('#container').highcharts({
chart: {
type: 'column' //รูปแบบของ แผนภูมิ ในที่นี้ให้เป็น line
},
title: {
text: 'จำนวนคนไข้' //
},
subtitle: {
text: ''
},
xAxis: {
categories: ['<?= implode("','", $monthx); //นำตัวแปร array แกน x มาใส่ ในที่นี้คือ เดือน?>']
},
yAxis: {
title: {
text: 'จำนวนคนไข้ (ราย)'
}
},
plotOptions: {
column: {
dataLabels: {
enabled: true
},
enableMouseTracking: true
}
},
series: [{
name: 'จำนวนคนไข้',
data: [<?= implode(',', $y2556) // ข้อมูล array แกน y ?>]
}]
});
});
</script>
</head>
<body>

<div id="container" style="min-width: 320px; height: 380px;"></div>
<form name="myform1" method="post" action="chartpan.php">

From <input name="date1" type="text" id="date1" size="15" /> TO <input name="date2" type="text" id="date2" size="15" />
 <input class="button" name="submit" id="submit" tabindex="5" value="ตกลง" type="submit"> 


 </form>
</head> 

</body>

</html>

1 个答案:

答案 0 :(得分:0)

Unfortunatley我们没有开发自定义代码,但是如果你需要过滤数据,你可以调用任何请求到服务器(通过ajax)然后返回json并在任何系列上使用setData