我有一个包含数字的INT列和一个日期列的表。我希望能够计算每天相同日期列的数量。也就是说,每天有多少个不同的日期行。因此,例如,如果一个日期有两次或三次记录,那么它的计数应该显示在图表上,日期在X轴上并计入Y轴
示例数据:
ID date picker
1 02-Apr-2014
2 02-APR-2014
3 04-APR-2014
4 07-APR-2014
5 07-APR-2014
6 07-Apr-2014
我应该使用哪个图表来获取图表所需的输出???
我使用的PHP代码::
<?php
include("phpgraphlib/phpgraphlib.php");
include("phpgraphlib/phpgraphlib_stacked.php");
$graph=new PHPGraphLib(550,350);
$link = mysql_connect('localhost', 'root', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('ac_xamp_le') or die('Could not select database');
$dataArray=array();
//get data from database
$sql="select datepicker, count(id) from ac_member group by datepicker";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
if ($result) {
while ($row = mysql_fetch_assoc($result)) {
$date=$row["datepicker"];
$count=count('id');
//add to data areray
$dataArray[$date]=$count;
}
}
//configure graph
$graph->addData($dataArray);
$graph->setTitle("Enquires by date");
$graph->setLine(true);
$graph->setLineColor("navy");
$graph->setLineColor("255,255,0");
$graph->setLineColor("#339900");
$graph->setDataValues(true);
$graph->setGradient("blue", "navy");
$graph->setBarOutlineColor("black");
$graph->createGraph();
?>