* set the width of chart to auto.

This commit is contained in:
wangchunsheng
2009-12-25 09:11:16 +00:00
parent ba3f75ade4
commit 840a1e17fa
2 changed files with 5 additions and 3 deletions

View File

@@ -44,7 +44,7 @@ class index extends control
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);
$burns[$project->id] = $this->report->createJSChart('line', $dataXML, 'auto', 200);
}
$projectGroups = array_chunk($projects, 3);

View File

@@ -42,7 +42,7 @@ EOT;
}
/* 创建js输出的chart。*/
public function createJSChart($swf, $dataXML, $width = 600, $height = 500)
public function createJSChart($swf, $dataXML, $width = 'auto', $height = 500)
{
$jsRoot = $this->app->getWebRoot() . 'js/';
static $count = 0;
@@ -58,7 +58,9 @@ EOT;
$js
<div id="$divID"></div>
<script language="JavaScript">
var $chartID = new FusionCharts("$chartRoot$swfFile", "{$chartID}id", "$width", "$height");
chartWidth = "$width";
if(chartWidth == 'auto') chartWidth = $('#$divID').css('width').replace('px', '');
var $chartID = new FusionCharts("$chartRoot$swfFile", "{$chartID}id", chartWidth, "$height");
$chartID.setDataXML("$dataXML");
$chartID.render("$divID");
</script>