* adjust the chart.
This commit is contained in:
@@ -41,7 +41,11 @@ class index extends control
|
||||
$products = array_values($this->product->getList());
|
||||
$burns = array();
|
||||
$projects = $this->project->getList('doing');
|
||||
foreach($projects as $project) $burns[$project->id] = $this->report->createChart('line', $this->createLink('project', 'burnData', "project=$project->id", 'xml'), 200, 200);
|
||||
foreach($projects as $project)
|
||||
{
|
||||
$dataXML = $this->report->createSingleXML($this->project->getBurnData($project->id), $this->lang->project->charts->burn->graph);
|
||||
$burns[$project->id] = $this->report->createJSChart('line', $dataXML, 300, 200);
|
||||
}
|
||||
$projectGroups = array_chunk($projects, 3);
|
||||
|
||||
$this->assign('header', $header);
|
||||
|
||||
@@ -199,26 +199,8 @@ class project extends control
|
||||
public function burnData($projectID = 0)
|
||||
{
|
||||
$this->loadModel('report');
|
||||
$sets = $this->dao->select('date AS name, `left` AS value')->from(TABLE_BURN)->where('project')->eq((int)$projectID)->orderBy('date')->fetchAll('name');
|
||||
|
||||
/* 取得burn表中最大的日期和project的结束时间。*/
|
||||
end($sets);
|
||||
$current = key($sets);
|
||||
$end = $this->dao->select('end')->from(TABLE_PROJECT)->where('id')->eq((int)$projectID)->fetch('end');
|
||||
|
||||
/* 根据当前日期和项目最后结束的日期,补足后续日期。*/
|
||||
if($end != '0000-00-00' and helper::diffDate($end, $current) > 0)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
$nextDay = date('m-d', strtotime('next day', strtotime($current)));
|
||||
$current = $nextDay;
|
||||
$sets[$current]->name = $current;
|
||||
$sets[$current]->value = ''; // value为空,这样fushioncharts不会打印节点。
|
||||
if($nextDay == $end) break;
|
||||
}
|
||||
}
|
||||
return $this->report->createSingleXML($sets, $this->lang->project->charts->burn->graph);
|
||||
$sets = $this->project->getBurnData($projectID);
|
||||
die($this->report->createSingleXML($sets, $this->lang->project->charts->burn->graph));
|
||||
}
|
||||
|
||||
/* 创建一个项目。*/
|
||||
|
||||
@@ -214,4 +214,33 @@ class projectModel extends model
|
||||
$sql = "DELETE FROM " . TABLE_TEAM . " WHERE project = '$projectID' AND account = '$account'";
|
||||
return $this->dbh->exec($sql);
|
||||
}
|
||||
|
||||
/* 燃烧图所需要的数据。*/
|
||||
public function getBurnData($projectID = 0)
|
||||
{
|
||||
$sets = $this->dao->select('date AS name, `left` AS value')->from(TABLE_BURN)->where('project')->eq((int)$projectID)->orderBy('date')->fetchAll('name');
|
||||
|
||||
/* 取得burn表中最大的日期和project的结束时间。*/
|
||||
end($sets);
|
||||
$current = key($sets);
|
||||
$end = $this->dao->select('end')->from(TABLE_PROJECT)->where('id')->eq((int)$projectID)->fetch('end');
|
||||
|
||||
/* 根据当前日期和项目最后结束的日期,补足后续日期。*/
|
||||
if($end != '0000-00-00' and helper::diffDate($end, $current) > 0)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
$nextDay = date('Y-m-d', strtotime('next day', strtotime($current)));
|
||||
$current = $nextDay;
|
||||
$sets[$current]->name = $current;
|
||||
$sets[$current]->value = ''; // value为空,这样fushioncharts不会打印节点。
|
||||
if($nextDay == $end) break;
|
||||
}
|
||||
}
|
||||
foreach($sets as $set)
|
||||
{
|
||||
$set->name = substr($set->name, 5);
|
||||
}
|
||||
return $sets;
|
||||
}
|
||||
}
|
||||
|
||||
+27
-4
@@ -40,16 +40,39 @@ class reportModel extends model
|
||||
EOT;
|
||||
}
|
||||
|
||||
/* 创建js输出的chart。*/
|
||||
public function createJSChart($swf, $dataXML, $width = 600, $height = 500)
|
||||
{
|
||||
static $count = 0;
|
||||
$count ++;
|
||||
$chartRoot = $this->app->getWebRoot() . 'fusioncharts/';
|
||||
$swfFile = "fcf_$swf.swf";
|
||||
$divID = "chart{$count}div";
|
||||
$chartID = "chart{$count}";
|
||||
|
||||
$js = '';
|
||||
if($count == 1) $js = "<script language='Javascript' src='/js/misc/FusionCharts.js'></script>";
|
||||
return <<<EOT
|
||||
$js
|
||||
<div id="$divID"></div>
|
||||
<script language="JavaScript">
|
||||
var $chartID = new FusionCharts("$chartRoot$swfFile", "{$chartID}id", "$width", "$height");
|
||||
$chartID.setDataXML("$dataXML");
|
||||
$chartID.render("$divID");
|
||||
</script>
|
||||
EOT;
|
||||
}
|
||||
|
||||
/* 生成single系列的xml数据。。 */
|
||||
function createSingleXML($sets, $chartOptions = array())
|
||||
{
|
||||
$data = pack("CCC", 0xef, 0xbb, 0xbf);
|
||||
$data .='<?xml version="1.0" encoding="UTF-8"?>' . "\n";
|
||||
$data .="<?xml version='1.0' encoding='UTF-8'?>";
|
||||
$data .= '<graph';
|
||||
foreach($chartOptions as $key => $value) $data .= " $key='$value'";
|
||||
$data .= ">\n";
|
||||
foreach($sets as $set) $data .= "<set name='$set->name' value='$set->value' />\n";
|
||||
$data .= ">";
|
||||
foreach($sets as $set) $data .= "<set name='$set->name' value='$set->value' />";
|
||||
$data .= "</graph>";
|
||||
die($data);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user