How can I change the chartdata with an ajax action, i.e. when I change a dropdown?
How can I change the chartdata with an ajax action, i.e. when I change a dropdown?
I had same problem, but i’m using utf8_decode() and works fine.
utf8_decode('ąčęėįšųūž')
Try it!
My two cent’s worth: it’s super important to clear the ‘assets’ folder - this isn’t covered in the FusionCharts Upgrade Instructions (well, for obvious reasons)
Hello:
I’m new to both yii as well as this extension, so forgive me if I’m making a rookie mistake somewhere along here.
I’m just trying to get any chart working, and I’m having trouble doing so.
I’ve stolen a lot of the code that has been mentioned in this thread, and as such my controller’s ‘actionChart’ looks like this:
public function actionChart()
{
Yii::app()->fusioncharts->setChartOptions( array( 'caption'=>'test', 'xAxisName'=>'testx', 'yAxisName'=>'testy'));
Yii::app()->fusioncharts->addCategory(array('label'=>'Cat1'));
Yii::app()->fusioncharts->addCategory(array('label'=>'Cat2'));
$options = array('seriesName' => 'Series1'); // must specify series anme
Yii::app()->fusioncharts->addDataSet('data_unique_key', $options);
$options = array('seriesName' => 'Series2'); // must specify series anme
Yii::app()->fusioncharts->addDataSet('data_unique_key2', $options);
$options = array('value' => 1);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key', $options);
$options = array('value' => 2);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key', $options);
$options = array('value' => 3);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key2', $options);
$options = array('value' => 4);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key2', $options);
Yii::app()->fusioncharts->useI18N = true;
Yii::app()->fusioncharts->getXMLData(true);
}
And my view’s widget instantiation looks like this:
$this->widget('ext.fusioncharts.fusionChartsWidget', array( 'debugMode' => true,
'chartNoCache'=>true, // disabling chart cache
'chartAction'=>Yii::app()->urlManager->createUrl('report/testchart'), // the chart action that we just generated the x
'chartId'=>'course_load')); // If you display more then one chart on a single page then make sure you specify and id
The result of which looks like this:
Info: Chart loaded and initialized.
Initial Width: 900
Initial Height: 300
Scale Mode: noScale
Debug Mode: Yes
Application Message Language: EN
Version: 3.1.1
Chart Type: Single Series 2D Column Chart
Chart Objects:
BACKGROUND
CANVAS
CAPTION
SUBCAPTION
YAXISNAME
XAXISNAME
DIVLINES
YAXISVALUES
HGRID
DATALABELS
DATAVALUES
TRENDLINES
TRENDVALUES
DATAPLOT
TOOLTIP
VLINES
VLINELABELS
INFO: Chart registered with external script. DOM Id of chart is chart_course_load
INFO: XML Data provided using dataURL method.
dataURL provided: /~eddie/shylock/index.php/report/testchart
dataURL invoked: /~eddie/shylock/index.php/report/testchart?FCTime=576
ERROR: An error occurred while loading data. Please check your dataURL, by clicking on the "dataURL invoked" link above, to see if it's returing valid XML data. Common causes for error are:
No URL Encoding provided for querystrings in dataURL. If your dataURL contains querystrings as parameters, you'll need to URL Encode the same. e.g., Data.asp?id=101&subId=242 should be Data%2Easp%3Fid%3D101%26subId%3D242
Different sub-domain of chart .swf and dataURL. Both need to be same owing to sandbox security.
Network error
And if I click on the dataURL invoked, I get: Unable to resolve the request "report/testchart".
Can anyone point out to me what I’m doing wrong? Do I have to build some sort of controller for report or some such?
Cheers,
-e-
Hrmm, OK, figured that much out - my basic Yii newbness biting me. My controller is called ‘Dashboard’, so the URL I need to supply is dashboard/chart. That fixed the problem, combined with changing it to an MSLine chartType.
Awesome.
Just a bit of feedback: it would be nice if there was a complete source pasting of a controller and view pair that worked in the documentation. It would be great if I could copy and paste some sample graph in my application and then start noodling with the parameters to see how the thing worked, versus having to cobble bits and pieces from this forum posting. But now that it works, I’m happy.
Cheers
Also, noticed a little bug:
In convertOptionsToXML() in fusioncharts.php:
651 /**
652 * Convert chart array options into encoded xml string
653 * @return string
654 */
655 protected function convertOptionsToXML( $options=array() )
656 {
657 $parsedXML = '';
658 if( count($options) )
659 {
660 $parsedXML = ' ';
661 foreach($options as $k => $v)
662 {
663 if($v)
664 {
665 $parsedXML .= $k . "='" . $this->_encodeSpecialChars($v) . "' ";
666 }
667 }
668 }
669
670 return $parsedXML;
671 }
The if($v) is what’s stopping me from using parameters like showValues=‘0’, and what not. I’m not sure what other problems disabling the if($v) could cause, but I’m doing it locally and haven’t noticed any problems.
Did someone manage to do that ? I just would like to do something like that: http://www.fusioncharts.com/fusioncharts23/Site_Doc/HelpDocs/Client_JS.html
Thanks
Hi guys,
Anyone know what the problem?? My view only show [b]The chart will appear within this DIV. This text will be replaced by the chart. My code below
[/b]
SiteController
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->useI18N = true;
header('Content-type: text/xml');
echo pack("C3", 0xef, 0xbb, 0xbf);
$this->render('chart');
}
view
chart.php
<?php
$this->widget('ext.fusioncharts.fusionchartsWidget', array(
'chartNoCache' => true,
'debugMode' => true,
'chartAction' => Yii::app()->urlManager->createUrl('site/chart'),
'chartId' => 'mychart'
));
?>
if you see that message you probably dont have flash.
Hi!
My company has got corporate version of Fusion Charts and I started to use it with Yii.
Unfortunately, I had got some errors using it with your extension. Some research on Fusion Charts Forum gave an answer: the name of JS variable and the name of DIV must be unequal.
So I changed chartjs.php
New version is in attachments 2753
Now it works fine for me. Thank you for the great extension.
Hi,
am new to yii and this Fusion Charts.
I am also getting the same messge "The chart will appear within this DIV. This text will be replaced by the chart. My code below".
I changed chartjs.php as per the previous comment… and flash player is also installed in my system…
Can anyone please help me?
hi thank for the extension.
well, I try every possibility in the thread but I still no luck during a week.
I use xampp on mac
my controller
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->useI18N = true;
//Yii::app()->fusioncharts->getXMLData(true);
//header('Content-type: text/xml');
echo pack("C3", 0xef, 0xbb, 0xbf);
$this->render('chart');
}
my view
<?php
$this->widget(‘ext.fusioncharts.fusionChartsWidget’, array(
'debugMode' => true,
'chartNoCache'=>true,
'chartAction'=>Yii::app()->urlManager->createUrl('site/Chart'),
'chartId'=>'mychart'));
?>
My Result:
Info: Chart loaded and initialized.
Initial Width: 900
Initial Height: 300
Scale Mode: noScale
Debug Mode: Yes
Application Message Language: EN
Version: 3.0.2
Chart Type: Multi Series 2D Column Chart
Chart Objects:
BACKGROUND
CANVAS
CAPTION
SUBCAPTION
YAXISNAME
XAXISNAME
DIVLINES
YAXISVALUES
HGRID
DATALABELS
DATAVALUES
TRENDLINES
TRENDVALUES
DATAPLOT
TOOLTIP
VLINES
LEGEND
INFO: Chart registered with external script. DOM Id of chart is chart_mychart
INFO: XML Data provided using dataURL method.
dataURL provided: /yiifile/yiigo2/index.php?r=site/Chart
dataURL invoked: /yiifile/yiigo2/index.php?r=site/Chart
XML Data: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="language" content="en" /><link rel="stylesheet" type="text/css" href="/yiifile/yiigo2/css/screen.css" media="screen, projection" /><link rel="stylesheet" type="text/css" href="/yiifile/yiigo2/css/print.css" media="print" /><link rel="stylesheet" type="text/css" href="/yiifile/yiigo2/css/main.css" /><link rel="stylesheet" type="text/css" href="/yiifile/yiigo2/css/form.css" /><script type="text/javascript" src="/yiifile/yiigo2/assets/c171bdc/jquery.js" /><script type="text/javascript" src="/yiifile/yiigo2/assets/12154a67/JSClass/FusionCharts.js" /><title>My Web Application - Chart</title></head><body><div class="container" id="page"><div id="header"><div id="logo">My Web Application</div></div><div id="mainmenu"><ul id="yw0"><li><a href="/yiifile/yiigo2/index.php?r=site/index">Home</a></li><li><a href="/yiifile/yiigo2/index.php?r=site/page&view=about">About</a></li><li><a href="/yiifile/yiigo2/index.php?r=site/contact">Contact</a></li><li><a href="/yiifile/yiigo2/index.php?r=site/login">Login</a></li></ul></div><div class="breadcrumbs"><a href="/yiifile/yiigo2/index.php">Home</a> » <span>Chart</span></div><div id="content"><div id="chart_mychart" align="center">The chart will appear within this DIV. This text will be replaced by the chart.</div><h1> Nothing display </h1></div><div class="clear" /><div id="footer">
Copyright &copy; 2012 by My Company.<br />
All Rights Reserved.<br />
Powered by <a href="http://www.yiiframework.com/" rel="external">Yii Framework</a>. </div></div><script type="text/javascript">
/**/
jQuery(function($) {
<!-- START Script Block for Chart chart_mychart -->
var myChart_chart_mychart = new FusionCharts('/yiifile/yiigo2/assets/12154a67/Charts/MSColumn2D.swf?&nocache=0.97102000 1334673833', 'chart_mychart', '900', '300', '1', '1');
myChart_chart_mychart.setDataURL('/yiifile/yiigo2/index.php?r=site/Chart');
myChart_chart_mychart.render('chart_mychart');
<!-- END Script Block for Chart chart_mychart -->
});
/**/
</script></body></html>
No Data to Display: No data was found in the XML data document provided. Possible cases can be:
There isn’t any data generated by your system. If your system generates data based on parameters passed to it using dataURL, please make sure dataURL is URL Encoded.
You might be using a Single Series Chart .swf file instead of Multi-series .swf file and providing multi-series data or vice-versa.
HOPE ANYONE WHO EXPERIENCE THIS CAN HELP ME…
THANK YOU
Im new at Yii and Im trying to use this extension:
Following the example of the extension
my code is like this:
Controller:
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' ) );
// Add two data sets
Yii::app ()->fusioncharts->addDataSet ( 'data_unique_key', $options );
Yii::app ()->fusioncharts->addDataSet ( 'data_unique_key2', $options );
Yii::app ()->fusioncharts->addTrendLine ( array ('startValue' => '700000', 'color' => '009933', 'displayvalue' => 'Target' ) );
Yii::app ()->fusioncharts->addDefinition ( array ('name' => 'CanvasAnim', 'type' => 'animation', 'param' => '_xScale', 'start' => '0', 'duration' => '1' ) );
Yii::app ()->fusioncharts->addApplication ( array ('toObject' => 'Canvas', 'styles' => 'CanvasAnim' ) );
Yii::app ()->fusioncharts->useI18N = true;
}
And the view:
<?php
// echo '<pre>';
// print_r(Yii::app ()->urlManager->createUrl ( 'file/chart' ));
// exit;
$this->widget ( 'ext.fusioncharts.fusionChartsWidget', array ('chartNoCache' => true, // disabling chart cache
'chartAction' => Yii::app ()->urlManager->createUrl ( 'file/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 I render the view I only can see "Error in loading data"
Can anybody help me??
Thanx a lot
Hello
i am working on fusion charts i wanted to show category and product wise chart but i am not getting any solution for that now i am getting category with all products with different category
i wanted to show like
category 1 with product1,product2
category 2 with product3,product4
category 3 with product5,product6
if anyone can help me out
Yii::app ()->fusioncharts->setChartOptions ( array ('caption' => 'Total Projects', 'xAxisName' => 'Product Groups', 'yAxisName' => 'Products' ) );
Yii::app()->fusioncharts->addCategory(array('label'=>'Cat1'));
Yii::app()->fusioncharts->addCategory(array('label'=>'Cat2'));
$options = array('seriesName' => 'Series1'); // must specify series anme
Yii::app()->fusioncharts->addDataSet('data_unique_key', $options);
$options = array('seriesName' => 'Series2'); // must specify series anme
Yii::app()->fusioncharts->addDataSet('data_unique_key2', $options);
$options = array('value' => 1);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key', $options);
$options = array('value' => 2);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key', $options);
$options = array('value' => 3);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key2', $options);
$options = array('value' => 4);
Yii::app()->fusioncharts->addSetToDataSet('data_unique_key2', $options);
// Add two data sets
//Yii::app ()->fusioncharts->addDataSet ( 'data_unique_key', $options );
//Yii::app ()->fusioncharts->addDataSet ( 'data_unique_key2', $options );
// Yii::app ()->fusioncharts->addTrendLine ( array ('startValue' => '1000', 'color' => '009933', 'displayvalue' => 'Target' ) );
Yii::app ()->fusioncharts->addDefinition ( array ('name' => 'CanvasAnim', 'type' => 'animation', 'param' => '_xScale', 'start' => '0', 'duration' => '1' ) );
Yii::app ()->fusioncharts->addApplication ( array ('toObject' => 'Canvas', 'styles' => 'CanvasAnim' ) );
var_dump(Yii::app()->fusioncharts->getXMLData(true));
Yii::app ()->fusioncharts->useI18N = true;
view page
<?php $this->widget('ext.fusioncharts.fusionChartsWidget', array(
'chartType'=>'MSColumn2D','chartNoCache'=>true, // disabling chart cache
'chartAction'=>Yii::app()->urlManager->createUrl('/members/reports/chart'), // the chart action that we just generated the xml data at
'chartId'=>'course_load')); // If you display more then one chart on a single page then make sure you specify and id
?>
I am trying to make a basic bar chart work, but all I get is the following:
Info: Chart loaded and initialized.
Initial Width: 900
Initial Height: 300
Scale Mode: noScale
Debug Mode: Yes
Application Message Language: EN
Version: 3.1.1
Chart Type: Single Series 2D Column Chart
Chart Objects:
BACKGROUND
CANVAS
CAPTION
SUBCAPTION
YAXISNAME
XAXISNAME
DIVLINES
YAXISVALUES
HGRID
DATALABELS
DATAVALUES
TRENDLINES
TRENDVALUES
DATAPLOT
TOOLTIP
VLINES
VLINELABELS
INFO: Chart registered with external script. DOM Id of chart is jschart_mychart
INFO: XML Data provided using dataURL method.
dataURL provided: /yii/testdrive/index.php?r=profile/chart
dataURL invoked: /yii/testdrive/index.php?r=profile/chart&FCTime=389
[color="#FF0000"]INFO: XML Data provided using dataURL method.
ERROR: Invalid XML encountered. An end-tag is encountered without a matching start-tag. Click the above "dataURL Invoked" link to see the XML in browser. [/color]
Any idea how to solve this?
Thanks,
Dieter
I created a fresh YII application and now I am getting different results. However, it still is not working:
With Yii::app()->fusioncharts->getXMLData(true); the following data are displayed:
<chart caption="My Chart" xAxisName="Months" yAxisName="Revenue"><set label="Jan" value="6700"/><set label="July" value="7800"/><set label="August" value="8900"/></chart>
With Yii::app()->fusioncharts->getXMLData(false); the following error comes up:
No Data to Display: No data was found in the XML data document provided. Possible cases can be:
There isn’t any data generated by your system. If your system generates data based on parameters passed to it using dataURL, please make sure dataURL is URL Encoded.
You might be using a Single Series Chart .swf file instead of Multi-series .swf file and providing multi-series data or vice-versa.
Any thoughts?
I am running YII and Fusion Charts on a local web server. Could this cause the problems I am experiencing?
hai everyone, i got stuck in this chart,
but i’d solve it
here is my controller
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->useI18N = true;
$chart=Yii::app()->fusioncharts->getXMLData(true);
//header('Content-type: text/xml');
echo pack("C3", 0xef, 0xbb, 0xbf);
$this->render('chart',array('model'=> $chart));
}
maybe it look the same as the post before,
but i add a render line, so i call my view index and in index i add render partial where the data provided
in my index.php
<?
echo $this->renderPartial('chart');
?>
and in my chart.php
<?php
$this->widget('ext.fusioncharts.fusionChartsWidget', array(
'debugMode' => false,
'chartNoCache'=>true, // disabling chart cache
'chartAction'=>Yii::app()->urlManager->createUrl('site/chart'), // the chart action that we just generated the x
'chartId'=>'course_load')); // If you display more then one chart on a single page then make sure you specify and id
?>
i hope it help for u all
By using ECHO I was able to make it work:
echo Yii::app()->fusioncharts->getXMLData(false);
anyone can help me ?
i get problem
my controller.php
public function actionChart()
{
Yii::app()->fusioncharts->setChartOptions( array( 'caption'=>'My Chart', 'xAxisName'=>'Months', 'yAxisName'=>'Revenue' ) );
$sets = array(
array('label'=>'July', 'value'=>'680000'),
array('label'=>'August', 'value'=>'680000'),
array('label'=>'Jan', 'value'=>'680000'),
);
Yii::app()->fusioncharts->addSets($sets);
$categories = array(
array('label'=>'July'),
array('label'=>'August'),
array('label'=>'Jan'),
);
Yii::app()->fusioncharts->addCategories($categories);
Yii::app()->fusioncharts->getXMLData(true);
Yii::app()->fusioncharts->addTrendLine(array('startValue'=>'700000', 'color'=>'009933', 'displayvalue'=>'Target'));
Yii::app()->fusioncharts->addDefinition(array('name'=>'CanvasAnim', 'type'=>'animation', 'param'=>'_xScale', 'start'=>'0', 'duration'=>'1'));
Yii::app()->fusioncharts->addApplication(array('toObject'=>'Canvas', 'styles'=>'CanvasAnim'));
}
and this is my views
<?php
$this->widget('ext.fusioncharts.fusionChartsWidget', array(
'debugMode' => true,
'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 :
[html]
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<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="July"/>
<category label="August"/>
<category label="Jan"/>
</categories>
</chart>
[/html]
somebody can help me ?