touched up the commits-per-month graph

This commit is contained in:
hyung-hwan 2015-02-06 15:52:55 +00:00
parent f86c4dcabe
commit d12de4e0cf

View File

@ -791,9 +791,12 @@ class Code extends Controller
$file = $this->subversion->getHistory ($projectid, $path, SVN_REVISION_HEAD);
if ($file === FALSE)
{
header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
return;
//header($_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error');
//return;
$stats = array ('no-data' => 0);
}
else
{
$history = $file['history'];
$history_count = count($history);
@ -823,11 +826,13 @@ class Code extends Controller
$min_year = substr($k, 0, 4);
$min_month = substr($k, 5, 2);
}
else if ($idx == $stats_count)
if ($idx == $stats_count)
{
$max_year = substr($k, 0, 4);
$max_month = substr($k, 5, 2);
}
$idx++;
}
@ -836,7 +841,7 @@ class Code extends Controller
$month = ($year == $min_year)? $min_month: 1;
$month_end = ($year == $max_year)? $max_month: 12;
while ($month < $month_end)
while ($month <= $month_end)
{
$date = sprintf ("%04d-%02d", $year, $month);
@ -849,10 +854,11 @@ class Code extends Controller
$month++;
}
}
}
ksort ($stats);
$stats_count = count($stats);
$graph_width = $stats_count * 5;
if ($graph_width < 400) $graph_width = 400;
$this->load->library ('PHPGraphLib', array ('width' => $graph_width, 'height' => 150), 'graph');
@ -864,8 +870,19 @@ class Code extends Controller
$this->graph->setLineColor("red");
$this->graph->setBars(FALSE);
$this->graph->setXValues(TRUE);
$this->graph->setXValuesInterval(12);
$this->graph->setXValuesHorizontal(TRUE);
if ($stats_count < 12)
{
if ($stats_count <= 1)
{
$this->graph->setDataPoints(TRUE);
$this->graph->setDataPointColor("red");
}
}
else
{
$this->graph->setXValuesInterval(11);
}
$this->graph->setGrid(FALSE);
$this->graph->createGraph();
}