title = $model->text;
$this->params['breadcrumbs'][] = ['text' => 'Опросы', 'url' =>'/inquirer'];
$url = '/inquirer/'.$model->id;
$widget = isset( $_REQUEST['widget'] )?$_REQUEST['widget']*1:1;
AppAsset::register($this);
// \yii\web\JqueryAsset::register($this);
// \yii\bootstrap\BootstrapAsset::register($this);
$do = $model->getPart();
?>
beginPage() ?>
= Html::encode($model->text)?>
text)))?>">
registerCsrfMetaTags() ?>
head() ?>
beginBody() ?>
if( $model->show == 'N' || $do){
?>
Результат опроса: =$model->text?>
$answers = $model->getAnswers();
$sum = 0;
foreach($answers as $item){
$sum += $item->count;
}
if( $widget != 3 ){
/*
круговые диаграммы
*/
?>
$s = '';
foreach($answers as $item){
$s .="['".$item['text']."', ".$item['count']."],";
}
$typech = "{'packages':['corechart']}";
if( $widget == 2 ){
$type = "is3D: false,pieHole: 0.4,legend: {position: 'right', textStyle: {color: 'black', fontSize: 12}}";
}elseif($widget == 3){
$type = 'bar: { groupWidth: "100%" },bars: "horizontal"';
$typech = "{'packages':['bar']}";
}else{
$type = "is3D: true,legend: {position: 'right', textStyle: {color: 'black', fontSize: 12}}";
}
$this->registerJs(
<<';
// console.log(png);
dwnload = 'Скачать';
chart_png.innerHTML = dwnload;
});
}
chart.draw(data, options);
}
JS
,
$this::POS_END,
'chart'
);
?>
}else{
/*
столбчатая гистограмма на html
*/
foreach($answers as $item){
$percent = ($sum)?round($item->count/$sum*100):0;
?>
}
}
}else{
?>
Опрос: =$model->text?>
echo yii\base\View::render("poll",['id'=>$model->id, 'model'=>$model]);
}
?>
endBody() ?>
endPage() ?>