$this->params['breadcrumbs'][] = 'Просмотр опроса'; $colors = \Colors\RandomColor::many(sizeof($quiz->answersWithCount), ['hue' => 'blue', 'luminosity' => 'light']); ?> <div class="panel panel-default"> <div class="panel-heading"> <?php echo Html::a(FontAwesome::i('arrow-left') . Html::tag('small', 'Назад'), ['/quiz/default/index'], ['class' => 'btn btn-app']); ?> <?php echo Html::a(FontAwesome::i('pencil') . Html::tag('small', 'Редактировать'), ['/quiz/edit/' . $quiz->id], ['class' => 'btn btn-app']); ?> </div> <div class="panel-body"> <div class="col-xs-6"> <?php echo ChartJs::widget(['type' => 'pie', 'data' => ['datasets' => [['data' => ArrayHelper::toPercents(array_values(ArrayHelper::getColumn($quiz->answersWithCount, 'count'))), 'label' => 'Результаты опроса', 'backgroundColor' => $colors]], 'labels' => array_values(ArrayHelper::getColumn($quiz->answersWithCount, 'text'))]]); ?> </div> <div class="col-xs-6"> <?php echo ChartJs::widget(['type' => 'bar', 'data' => ['datasets' => [['data' => array_values(ArrayHelper::getColumn($quiz->answersWithCount, 'count')), 'label' => 'Результаты опроса', 'backgroundColor' => $colors]], 'labels' => array_values(ArrayHelper::getColumn($quiz->answersWithCount, 'text'))], 'options' => []]); ?> </div> <div class="col-xs-12"> <hr> <h3>Ответы по дням</h3> <?php $graphs = []; foreach ($quiz->answers as $key => $answer) { $graphs[] = ['balloonText' => '[[title]]: <b>[[value]]</b>', 'fillAlphas' => true, 'id' => 'Graph' . $key, 'title' => $answer->text, 'type' => 'column', 'valueField' => 'answer' . $answer->id]; }