示例#1
0
文件: view.php 项目: BoBRoID/new.k-z
        <?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];
}
echo \speixoto\amcharts\Widget::widget(['width' => 'auto', 'height' => '600px', 'chartConfiguration' => ['colors' => $colors, 'type' => 'serial', 'dataProvider' => $quiz->answersByDayForChart, 'categoryField' => 'date', 'startDuration' => 1, 'chartScrollbar' => ['enabled' => true], 'chartCursor' => ['enabled' => true], 'trendLines' => [], 'guides' => [], 'valueAxes' => [['stackType' => 'regular', 'id' => 'values']], 'categoryAxis' => ['gridPosition' => 'start', 'autoGridCount' => false], 'legend' => ['enabled' => true, 'useGraphSettings' => true], 'gridAboveGraphs' => true, 'graphs' => $graphs]]);
?>
        </div>
    </div>
</div>
示例#2
0
文件: index.php 项目: BoBRoID/new.k-z
                <?php 
echo GridView::widget(['dataProvider' => $popularToday, 'export' => false, 'tableOptions' => ['style' => 'margin: 0; table-layout: fixed', 'class' => 'table table-striped lastNewsTable col-xs-12'], 'columns' => [['attribute' => 'title', 'format' => 'raw', 'header' => 'Название', 'value' => function ($model) {
    return \yii\helpers\Html::a($model->title, ['/news/show/' . $model->id], ['title' => $model->title, 'class' => 'longText']);
}], ['attribute' => 'hits', 'width' => '100px', 'format' => 'raw', 'header' => 'Просмотры', 'value' => function ($model) {
    $views = $model->hits;
    if ($todayViews = $model->todayViews) {
        $views .= Html::tag('span', " (+{$todayViews->views})", ['class' => 'text-success']);
    }
    return $views;
}]], 'summary' => false, 'layout' => '{items}']);
?>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
    <div class="col-xs-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2 class="panel-title">Просмотры на графике</h2>
            </div>
            <div class="panel-body" style="padding: 0">
                <?php 
echo \speixoto\amcharts\Widget::widget(['width' => 'auto', 'height' => '225px', 'chartConfiguration' => ['type' => 'serial', 'dataProvider' => $monthlyViews, 'categoryField' => 'title', 'startDuration' => 1, 'chartScrollbar' => ['enabled' => true], 'categoryAxis' => ['gridPosition' => 'start', 'labelsEnabled' => false], 'gridAboveGraphs' => true, 'graphs' => [['type' => 'column', 'title' => 'Статья', 'valueField' => 'views', 'fillAlphas' => 1, 'balloonText' => '[[category]]: <b>[[value]]</b>']]]]);
?>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
</div>