<?php

use yii\helpers\Html;
use kartik\form\ActiveForm;
use kartik\select2\Select2;
use yii\grid\GridView;
use app\models\TKandidat;
use miloschuman\highcharts\Highcharts;
/* @var $this yii\web\View */
/* @var $model app\models\HasilVoting */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="hasil-voting-form">
	<div class="row">
		<center><h3 class="text-danger"><b>Hasil Voting <?= $voting->nama_voting;?></b></h3></center>
		<p align="right">
			<?= Html::a('<span class="glyphicon glyphicon-step-backward"></span>Kembali', ['voting/index-hasil-voting'], ['class' => 'btn btn-default']) ?>
		</p>
		
		<hr>
		<div class="col-lg-6 col-md-6 col-sm-6">
			<div class="panel panel-danger">
				  <div class="panel-heading">
				    <center><h3 class="panel-title">Grafik Persentase Voting <?= $voting->nama_voting;?></h3></center>
				  </div>
				  <div class="panel-body">
				    <?=  
				    	Highcharts::widget([
				    		'scripts' => [
			                       'highcharts-more',   // enables supplementary chart types (gauge, arearange, columnrange, etc.)
			                       'modules/exporting', // adds Exporting button/menu to chart
			                       //'themes/grid'        // applies global 'grid' theme to all charts
			                ],
                            'options' => [
								'credits' => ['enabled' =>false],
	                                'chart' =>  [
	                                    'type'  =>  'pie',
	                                   /* 'events' => ['load' => new JsExpression("persentase_retribusi")],*/
	                                ],

                                'tooltip'=> [
		                             'pointFormat'=> '{series.name}: <b>{point.percentage:.2f}%</b>'
		                        ],
                     			'plotOptions' => [
	                             	'series'=> [
		                                 'borderWidth'=> 0,
		                                 'dataLabels'=> [
		                                    'format'=> '<b>{point.name}</b>: {point.percentage:.2f} %',
		                                     'enabled'=> true,
		                                     
		                                 ]
	                             	]
                     			],
                            	'title' => ['text' => 'Persentase Jumlah Suara Kandidat'],
                               
                            	'series' => [
                               		[	
                               			'name' => 'Persentase Voting', 
                               			'colorByPoint' => true,
                                  		'data' => $dataGrafik//[
	                                      	/*[
		                                      	'name' => 'Jane', 
		                                      	'y' => 3
	                                      	],
	                                      	[
	                                      		'name' => 'Ke', 
	                                      		'y' => 2
	                                      	],
	                                      	[
	                                      		'name' => 'Yei', 
	                                      		'y' => 2
	                                      	],*/
                                  		//],
                               		],
                            	]
                            ]
                        ]);
				    ?>
				  </div>
			</div>
		</div>
  		<div class="col-lg-6 col-md-6 col-sm-6">
  			<div class="panel panel-success">
			  <div class="panel-heading">
			    <center><h3 class="panel-title"><b>Jumlah Suara Kandidat <?= $voting->nama_voting;?></b></h3></center>
			  </div>
			  <div class="panel-body">
			    <table class="table">
			    	<tr>
			    		<td><b>KANDIDAT</b></td>
			    		<td align="center"><b>JUMLAH SUARA</b></td>
			    	</tr>
			    	<?php
			    		foreach ($hasil_voting as $key => $value) {
			    	?>
			    			<tr>
					    		<td>
					    			<?php
					    				$kandidat =  TKandidat::find()->where(['id_kandidat' => $value['pilihan']])->one();
					    				echo $kandidat->nama_kandidat;
					    			?>
					    		</td>
					    		<td align="center"><h4><span class="label label-primary"><?= $value['Jumlah_Voting']?></span></h4></td>
					    	</tr>
			    	<?php
			    		}
			    	?>
			    	
			    </table>
			  </div>
			</div>
  		</div>
  	</div>
</div>
