miloschuman / yii-highcharts

Highcharts Adapter for Yii Framework

Home Page:http://www.yiiframework.com/extension/highcharts/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Highcharts not displaying on rendering view using renderPartial() for ajax request

sadiq-mc opened this issue · comments

Thank you for the widget..

I have an issue rendering the chart using renderPartial().

  1. If I provide the widget in a separate view and called renderPartial() in the main view, the chart displayed as expected.
  2. If I return the view containing the widget as renderPartial() with $processOutput as true for an ajax request of dropDownList, the chart is displayed on the navigation menu of the page.
  3. For the above version, if I add 'id' : 'some_id' to chart option, it displays as expected. Now if I change the dropdownList, the chart is not displayed, which means the chart is displayed only for the first dropdown selection.

Please find below the code snippets:

index.php

<div class="dashboard bg-white box-shadow brnr mrl mvl">
	<label class="color-ash ptl plxm">Details</label>
	<div class="pam mbm">
		<div class="row">
			<div class="col-xs-8 col-xs-offset-3">
				<label class="color-ash">Select Label</label>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-8 col-xs-offset-3">				
				<?php echo CHtml::dropDownList('ev_id', $model, 
		              CHtml::listData(EvTbl::model()->findAll(), 'ev_id', 'ev_title'),
		              array('empty' => '-- Select --', 'options' => array($model->ev_id=>array('selected'=>true)), 
		              	'ajax' => array(
					        'type'=>'POST', 
					        'url'=>$this->createUrl('dash/evreg'), 
					        'update'=>'#evChart', 
					        'data'=>array('ev_id' => 'js:$(\'#ev_id\').val()'),					        
					      )
		              ));  
		            ?>
			</div>
		</div>
	</div>
	
	<div id="evChart" class="paxm">		
	</div>
</div>

_chart.php

<div class="paxm">
	<div class="mbm">
		<label class="color-ash">Header</label>
	</div>
	<div class="box-shadow-around">
		<?php
			$this->Widget('ext.highcharts.HighchartsWidget', array(
				   'id' => 'evChart',   <---- If commented, chart displays on navigation menu
				   'options' => array(
				      'title' => array('text' => ''),
				      'xAxis' => array(
				         'categories' => array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'),
				      	 'labels' => array('enabled' => false),
				      	 'title' => array(
				      		'text' => 'Days', 
				      		'margin' => 40
				      	 )
				      ),
				      'yAxis' => array(
				         'title' => array('text' => '')
				      ),
				      'legend' => array('enabled' => false),
				      'plotOptions' => array(
				         'line' => array(
				            'dataLabels' => array('enabled' => true),
				            'enableMouseTracking' => true
				         )
				      ),
				      'credits' => array('enabled' => false),
				      'series' => array(
				         array('name' => 'John', 'data' => array(10, 0, 42, 12, 99, 69, 2, 12, 32, 10, 9, 55, 10, 0, 42, 12, 99, 69, 2, 12, 32, 10, 9, 55)),
				      )
				   )
				));
		?>
	</div>
</div>

DashCottroller.php

...
public function actionEvReg()
{
	if (Yii::app()->request->isAjaxRequest && isset($_POST['ev_id'])) {
		$this->renderPartial('_chart', [], false, true);  <--- If $processOutput is false, then the chart is not displayed.

		Yii::app()->end();
	}
}
...

Am I missing anything to obtain this issue.??

Got it solved by giving 'renderTo'...