[EXTENSION] Fusion Charts API Extension - Create and share Charts

Discussion and support topic for Fusion Charts API Extension - Create and share Charts

Hey,

Nice extension to have! I have already added it in the Charting list here.

I have tried to test it out and read manual in ext page, created action: klientas/chart:


	public function actionChart()

	{

		Yii::app()->fusioncharts->setChartOptions( array( 'caption'=>'My Chart', 'xAxisName'=>'Months', 'yAxisName'=>'Revenue' ) );


Yii::app()->fusioncharts->addSet(array('label'=>'July', 'value'=>'680000'));

Yii::app()->fusioncharts->addSet(array('label'=>'August', 'value'=>'680000'));

Yii::app()->fusioncharts->addSet(array('label'=>'Jan', 'value'=>'680000'));


    

Yii::app()->fusioncharts->addCategory(array('label'=>'Jan'));

Yii::app()->fusioncharts->addCategory(array('label'=>'Feb'));

Yii::app()->fusioncharts->addCategory(array('label'=>'Mar'));


	}

And in the view added:


<?php




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

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

                                                              'chartAction'=>Yii::app()->urlManager->createUrl('game/chart'), // the chart action that we just generated the xml data at

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

                                                              

?>

When trying to see the view I got the following error:


PHP Error

Description


Array to string conversion

Source File


C:\wamp\www\p2b7\extensions\fusioncharts\Includes\FusionChartsLib.php(1212)


01200:                        $tempLink=str_replace($pet,$row[$v],$tempLink); 

01201:                 }

01202:               }

01203:           }

01204:          return $tempLink;

01205:      }        

01206: 

01207:      

01208:      # Conversion of semi colon(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/wink.gif' class='bbc_emoticon' alt=';)' /> separeted paramater to XML attribute

01209:      function ConvertParamToXMLAttribute($strParam, $isChartParam=false){

01210:                    

01211:          $xmlParam="";

01212: $listArray=explode($this->del,$strParam);

01213:          foreach ($listArray as $valueArray) {

01214:            $paramValue=explode("=",$valueArray);

01215:            if($this->validateParam($paramValue)==true){

01216:                # Create parameter set

01217:                if( $isChartParam==false){

01218:                  $xmlParam .= $paramValue[0] . "='" . $this->encodeSpecialChars($paramValue[1]) . "' ";

01219:                }else{

01220:                   $xmlParam .= $paramValue[0] . "=" . $this->encodeSpecialChars($paramValue[1]) . "&";

01221:                }

01222:            }

01223:         }

01224:         


Stack Trace


#0 C:\wamp\www\p2b7\extensions\fusioncharts\Includes\FusionChartsLib.php(1212): explode()

#1 unknown(0): FusionChartsLib->ConvertParamToXMLAttribute()

#2 C:\wamp\www\p2b7\extensions\fusioncharts\fusionCharts.php(752): call_user_func_array()

#3 unknown(0): fusionCharts->__call()

#4 C:\wamp\www\p2b7\extensions\fusioncharts\views\chartjs.php(6): fusionCharts->ConvertParamToXMLAttribute()

#5 C:\wamp\www\p2b7\lib\yii\web\CBaseController.php(123): require()

#6 C:\wamp\www\p2b7\lib\yii\web\CBaseController.php(88): fusionChartsWidget->renderInternal()

#7 C:\wamp\www\p2b7\lib\yii\web\widgets\CWidget.php(214): fusionChartsWidget->renderFile()

#8 C:\wamp\www\p2b7\extensions\fusioncharts\fusionChartsWidget.php(287): fusionChartsWidget->render()

#9 C:\wamp\www\p2b7\lib\yii\web\CBaseController.php(174): fusionChartsWidget->run()

#10 C:\wamp\www\p2b7\views\klientas\list.php(17): KlientasController->widget()

#11 C:\wamp\www\p2b7\lib\yii\web\CBaseController.php(119): require()

#12 C:\wamp\www\p2b7\lib\yii\web\CBaseController.php(88): KlientasController->renderInternal()

#13 C:\wamp\www\p2b7\lib\yii\web\CController.php(748): KlientasController->renderFile()

#14 C:\wamp\www\p2b7\lib\yii\web\CController.php(687): KlientasController->renderPartial()

#15 C:\wamp\www\p2b7\controllers\KlientasController.php(179): KlientasController->render()

#16 C:\wamp\www\p2b7\lib\yii\web\actions\CInlineAction.php(32): KlientasController->actionList()

#17 C:\wamp\www\p2b7\lib\yii\web\CController.php(300): CInlineAction->run()

#18 C:\wamp\www\p2b7\lib\yii\web\filters\CFilterChain.php(129): KlientasController->runAction()

#19 C:\wamp\www\p2b7\lib\yii\web\filters\CFilter.php(41): CFilterChain->run()

#20 C:\wamp\www\p2b7\lib\yii\web\CController.php(999): CAccessControlFilter->filter()

#21 C:\wamp\www\p2b7\lib\yii\web\filters\CInlineFilter.php(59): KlientasController->filterAccessControl()

#22 C:\wamp\www\p2b7\lib\yii\web\filters\CFilterChain.php(126): CInlineFilter->filter()

#23 C:\wamp\www\p2b7\lib\yii\web\CController.php(283): CFilterChain->run()

#24 C:\wamp\www\p2b7\lib\yii\web\CController.php(257): KlientasController->runActionWithFilters()

#25 C:\wamp\www\p2b7\lib\yii\web\CWebApplication.php(320): KlientasController->run()

#26 C:\wamp\www\p2b7\lib\yii\web\CWebApplication.php(120): CWebApplication->runController()

#27 C:\wamp\www\p2b7\lib\yii\base\CApplication.php(135): CWebApplication->processRequest()

#28 C:\wamp\www\p2b7\www\index.php(13): CWebApplication->run()


2010-04-24 19:25:48 Apache/2.2.11 (Win32) PHP/5.3.0 Yii Framework/1.1.2-dev

Am I doing something wrong?

Greetings

CoLT

Oh that’s my bad i fixed it and updated the downloads. One more thing is make sure that in the action you print the XML so you will need to add the following code at the end of the action:


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

Oh thanks, I missed that XML output :)

Now I get the following message in View - Chart screen:

Error in loading data.

(I use the code posted above this post)

controller/chart:


<chart caption="My Chart" xAxisName="Months" yAxisName="Revenue">

<set label="July" value="680000"/>

<set label="August" value="680000"/>

<set label="Jan" value="680000"/>

−

<categories>

<category label="Jan"/>

<category label="Feb"/>

<category label="Mar"/>

</categories>

</chart>

Greets

CoLT

Strange using the above code exactly i can see the chart on my localhost. Could you turn on the debug mode by adding


'debugMode' => true

To either the widget instance or the component in the application configuration and refresh the page then copy paste the contents of the debug mode console.

Sorry my mistake ;) Forgot to route right controller/action in the widget. Debug is a must have in these situations :slight_smile:

Am, now where do I properly register this extension to full version?

Thanks, great commercial ext!

CoLT

Well you just purchase the extension and i assume it will remove the evaluation message to the domain you register to.

I mean with Yii ext, have you tried it?:) Maybe licence number is issued or something and set as a parameter.

CoLT

Well after reading the docs, When someone purchases a license all he has to do to register is to replace the swf files located under extensions.fusioncharts.assets.Charts with the charts he will download from his client area at the fusion charts home page.

See http://www.fusioncharts.com/docs/Contents/UpgradingEval.html

Oh yeah, now its clear ;)

Clear your browser cache - very important step.

And don’t forget Assets directory clear ;)

Its now fully working ext with FusionCharts Evaluation with upgrade instructions :D

Greetings,

CoLT

There is a little problem with "setChartOptions" method.

In "fusionCharts.php" you have to change the code on line 644:


if($v)

to


if(strlen($v) >0)

otherwise you can’t set i.e.:


Yii::app()->fusioncharts->setChartOptions(array('showBorder' => '0'));

EDIT:

to make chart swf transparent add the following line in the extensions view file (located under: PATH_TO_EXTENSIONS/fusioncharts/views/chartjs.php):


myChart_{$chartID}.setTransparent('{$this->chartTransparent}');

Thank you i have updated the extension and uploaded a new version.

I’m trying to find out what the “chartNoCache” parameter exactly does. Could it be, that there is no function at this time?

What it does is that it adds the value returned from microtime in the URL that loads the chart to not save the chart in cache.

edit: the SWF file.

Sorry Vince,

but I can’t see any changes if I set this parameter to “false”.

Do you use the html version or the JS version? as this only applies to the JS version.

When chartNoCache set to true this is the url that loads the SWF file:


/yiiframeworkcoil/trunk/hangman/assets/7c7e9835/Charts/ScrollLine2D.swf?&nocache=0.37390400 1272371855

When i set that to false this is the url:


/yiiframeworkcoil/trunk/hangman/assets/7c7e9835/Charts/ScrollLine2D.swf?

Ah ok, I see. I use the JS version. Does this bring any speed in loading the chart?

the browsers caches the swf file as it caches the images, so basically you should set this to false in production. so it won’t the swf for each request but rather load it from the browser cache as it does for images.

Can’t seem to get this to work…

I have this action code in my controller (PostController.php)


	public function actionChart()

	{

		Yii::app()->fusioncharts->setChartOptions(array('caption'=>'My Chart', 'xAxisName'=>'Months', 'yAxisName'=>'Revenue'));


		Yii::app()->fusioncharts->addSet(array('label'=>'July', 'value'=>'680000'));

		Yii::app()->fusioncharts->addSet(array('label'=>'August', 'value'=>'680000'));

		Yii::app()->fusioncharts->addSet(array('label'=>'Jan', 'value'=>'680000'));

		

		Yii::app()->fusioncharts->addCategory(array('label'=>'Jan'));

		Yii::app()->fusioncharts->addCategory(array('label'=>'Feb'));

		Yii::app()->fusioncharts->addCategory(array('label'=>'Mar'));

		

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

	}

This is my view (chart.php)


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

 		'chartNoCache'=>true,

 		'chartAction'=>Yii::app()->urlManager->createUrl('post/chart'),

 		'chartId'=>'mychart'));

but all I get back is the data in xml format like this:


<chart caption="My Chart" xAxisName="Months" yAxisName="Revenue">

<set label="July" value="680000"/>

<set label="August" value="680000"/>

<set label="Jan" value="680000"/>

−

<categories>

<category label="Jan"/>

<category label="Feb"/>

<category label="Mar"/>

</categories>

</chart>

…no chart…

I’m sure I’m overlooking something…

have you tried the following?




        public function actionChart()

        {

                Yii::app()->fusioncharts->setChartOptions(array('caption'=>'My Chart', 'xAxisName'=>'Months', 'yAxisName'=>'Revenue'));


                Yii::app()->fusioncharts->addSet(array('label'=>'July', 'value'=>'680000'));

                Yii::app()->fusioncharts->addSet(array('label'=>'August', 'value'=>'680000'));

                Yii::app()->fusioncharts->addSet(array('label'=>'Jan', 'value'=>'680000'));


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

        }