Fusioncharts And Model

I follow the instructions as showed in documentation section and everything’s is fine but when I want to create a dynamic xml data through a model with some get variable, I get the message: Error in loading data. What am I doing wrong?

The actions in the controller file is:


public function actionStats($id){

		

		$this->render('stats',array(

			'model'=>$this->loadModel($id),

		));

	}


public function actionChart($id){

		

		$stats=Reports::model()->findAll(array(

		'select'=>'SUM(value) as value,period_year',

		'condition'=>"node_id = $id",

		'group'=>'period_year',

		'order'=>'period_year asc',

		));

		

		Yii::app()->fusioncharts->setChartOptions( array( 'caption'=>'Downloads', 'xAxisName'=>'Years', 'yAxisName'=>'Downloads' ) );

		

		foreach ($stats as $s){

			Yii::app()->fusioncharts->addSet(array('label'=>$s->period_year, 'value'=>$s->value));		

		}

		

		Yii::app()->fusioncharts->getXMLData(true);

		

	}

And the view:


this->widget('ext.fusioncharts.fusionChartsWidget', array(

'chartType'=>'Line', 

'chartNoCache'=>true, // disabling chart cache

'chartAction'=>Yii::app()->urlManager->createUrl("nodes/chart",array("id"=>$model->id)), // the chart action that we just generated the xml data at

'chartId'=>'ACS')); // If you display more then one chart on a single page then make sure you specify and id

When I go to the urlmysite/index.php?r=nodes/chart&id=45. I see the xml data:


<chart caption="Downloads" xAxisName="Years" yAxisName="Downloads">

<set label="2004" value="1540"/>

<set label="2005" value="857"/>

<set label="2006" value="338"/>

<set label="2007" value="401"/>

<set label="2008" value="356"/>

<set label="2009" value="657"/>

<set label="2010" value="470"/>

<set label="2011" value="335"/>

<set label="2012" value="119"/>

</chart>

If I leave it like this it works :blink:


public function actionChart(){

		

		$stats=ReportAcs::model()->findAll(array(

		'select'=>'SUM(value) as value,period_year',

		'condition'=>"type = 'ft_total' AND node_id = 5",

		'group'=>'period_year',

		'order'=>'period_year asc',

		));