diff --git a/trunk/module/index/control.php b/trunk/module/index/control.php
index 0adb79615e..ec4b10ee8b 100644
--- a/trunk/module/index/control.php
+++ b/trunk/module/index/control.php
@@ -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);
diff --git a/trunk/module/project/control.php b/trunk/module/project/control.php
index ff332fefec..64a3cc0e42 100644
--- a/trunk/module/project/control.php
+++ b/trunk/module/project/control.php
@@ -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));
}
/* 创建一个项目。*/
diff --git a/trunk/module/project/model.php b/trunk/module/project/model.php
index 1fef7ac27a..09c3bd64c7 100644
--- a/trunk/module/project/model.php
+++ b/trunk/module/project/model.php
@@ -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;
+ }
}
diff --git a/trunk/module/report/model.php b/trunk/module/report/model.php
index ddb975e841..d2a574379f 100644
--- a/trunk/module/report/model.php
+++ b/trunk/module/report/model.php
@@ -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 = "";
+ return <<
+
+EOT;
+ }
+
/* 生成single系列的xml数据。。 */
function createSingleXML($sets, $chartOptions = array())
{
$data = pack("CCC", 0xef, 0xbb, 0xbf);
- $data .='' . "\n";
+ $data .="";
$data .= ' $value) $data .= " $key='$value'";
- $data .= ">\n";
- foreach($sets as $set) $data .= "\n";
+ $data .= ">";
+ foreach($sets as $set) $data .= "";
$data .= "";
- die($data);
+ return $data;
}
}