Ben, on 03 July 2011 - 07:19 PM, said:
I'm sorry, but for me this looks like a generic flash-related error, nothing specific to the widget. And honestly, I don't know very much about working with flash.
But may I ask what you're trying to do? Because just in case you're trying to modify what the chart displays, then the homepage of the original openfalshchart2 component might help. They have a example, where they
toggle the content of a chart, and at least to me it looks similar to what you're trying to do. The only difference is, that they pass new data to the tmp.load() method.
So, if you try the following:
<script type="text/javascript">
function reload()
{
tmp = findSWF("openFlashChart2_0");
x = tmp.load( open_flash_chart_data("someNonExisitingId") );
}
[...]
</script>
Then your graph should be replaces with an example bar graph.
Thanks Ben for your reply. I had that error, when I use ajax to reload (or load) flash chart.
I had fixed my problem.
this is my code.
in my controller:
public function actionIndex()
{
if (isset($_GET['yearFrom']))
{
Yii::app()->user->setState('yearFrom',(int)$_GET['yearFrom']);
unset($_GET['yearFrom']); // would interfere with pager and repetitive page size change
}
if (isset($_GET['yearTo']))
{
Yii::app()->user->setState('yearTo',(int)$_GET['yearTo']);
unset($_GET['yearTo']); // would interfere with pager and repetitive page size change
}
if (isset($_GET['account']))
{
Yii::app()->user->setState('yearTo',(int)$_GET['yearTo']);
unset($_GET['yearTo']); // would interfere with pager and repetitive page size change
}
OpenFlashChart2Loader::load();
$bar = new bar_filled( '#E2D66A', '#577261' );
if (isset($_POST['yearfrom']))
{
$yearfrom = (int)$_POST['yearfrom'];
$yearto = (int)$_POST['yearto'];
$chart = new open_flash_chart();
$chart->set_title( new title("General Ledger") );
$accounts=Account::model()->findAllByAttributes(array('accountcode'=>$_POST['accountcode']));
$xarray = array();
$maxvalue = 0;
$minvalue=0;
foreach($accounts as $account)
{
$connection=Yii::app()->db;
$sql = 'select sum(Debit-Credit) as currvalue from genledger where accountid = '.$account->accountid.' and year(postdate) between '.$_POST['yearfrom'].' and '.$_POST['yearto'].' group by year(postdate)';
$command=$connection->createCommand($sql);
$dataReader=$command->query();
$datas=array();
foreach($dataReader as $row)
{
if ($row['currvalue'] != null)
{
$datas[]= (float) $row['currvalue'];
}
else
$datas[]= 0;
}
if (count($datas)>0) {
$maxvalue = max($datas);
$minvalue = min($datas);
}
$bar->set_values( $datas );
$chart->add_element( $bar );
}
for($i=$yearfrom;$i<=$yearto;$i++) {
$xarray[]=(string)$i;
}
$x = new x_axis();
$x->set_labels_from_array($xarray);
$chart->set_x_axis( $x );
$y = new y_axis();
if ($minvalue < 0) {
$y->set_range( $minvalue, $maxvalue, 10);
} else {
$y->set_range( 0, $maxvalue, 10);
}
$chart->set_y_axis( $y );
echo CJSON::encode(array(
'status'=>'success',
'data'=>$chart->toPrettyString()
));
}
else {
$this->render('index',array(
'model'=>$model,
'chart'=>$chart
));
}
}
in my view:
<?php
$this->breadcrumbs=array(
'Genledgers',
);
$yearfrom=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultYearFrom']);
$yearto=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultYearTo']);
?>
<script type="text/javascript">
function findSWF(movieName) {
if (navigator.appName.indexOf("Microsoft")!= -1) {
return window[movieName];
} else {
return document[movieName];
}
}
</script>
<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array( // the dialog
'id'=>'helpdialog',
'options'=>array(
'title'=>'Help',
'autoOpen'=>false,
'modal'=>true,
'width'=>550,
'height'=>470,
),
));?>
<?php echo $this->renderPartial('_help'); ?>
<?php $this->endWidget();?>
<h1>General Ledger</h1>
<?php
$imghelp=CHtml::image(Yii::app()->request->baseUrl.'/images/help.png');
echo CHtml::link($imghelp,'#',array(
'style'=>'cursor: pointer; text-decoration: underline;',
'onclick'=>"$('#helpdialog').dialog('open');",
'title'=>Yii::t('app','help')
));?>
<?php
$this->widget(
'application.extensions.OpenFlashChart2Widget.OpenFlashChart2Widget',
array(
'chart' => $chart,
'width' => '100%',
'height' => 400,
)
);
?>
<form action="index.php?r=genledger/index" method="POST">
Year From : <?php echo CHtml::textField('yearfrom',$yearfrom,array('size'=>'5',
// change 'user-grid' to the actual id of your grid!!
)); ?>
To : <?php echo CHtml::textField('yearto',$yearto,array('size'=>'5',
// change 'user-grid' to the actual id of your grid!!
)); ?>
Account Code : <?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'accountcode',
'value'=>'',
'source'=>$this->createUrl('genledger/getaccount'),
// additional javascript options for the autocomplete plugin
'options'=>array(
'showAnim'=>'fold',
),
)); ?><br/><?php echo CHtml::ajaxSubmitButton('Submit',
array('genledger/index'),
array(
'success'=>'function(data)
{
var x = eval("(" + data + ")");
if (x.status == "success")
{
[b]tmp = findSWF("openFlashChart2_0");
tmp.load(x.data);[/b]
}
}')); ?>
</form>
<div id="message"></div>