Skip to content

Commit

Permalink
Fixed issue #13437: simple statistics looks odd
Browse files Browse the repository at this point in the history
Made the view responsive and have 1, 2 columns or 3 depending on the screen width.
Made the legends to be below the chart, and not on its right side.
  • Loading branch information
gabrieljenik authored and eddylackmann committed Oct 9, 2020
1 parent 2abb576 commit 5f11205
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
26 changes: 12 additions & 14 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -2131,6 +2131,7 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
if ($outputType == 'html') {
// show this block only when we show graphs and are not in the public statics controller
if ($usegraph == 1 && $bShowGraph && get_class(Yii::app()->getController()) !== 'Statistics_userController') {
$fullLabels = $labels;
// We clean the labels
$iMaxLabelLength = 0;
foreach ($labels as $key => $label) {
Expand All @@ -2145,6 +2146,7 @@ protected function displaySimpleResults($outputs, $results, $rt, $outputType, $s
$aData['rt'] = $rt;
$aData['qqid'] = $qqid;
$aData['labels'] = $labels;
$aData['fullLabels'] = $fullLabels;
$aData['charttype'] = $charttype;
$aData['sChartname'] = '';
$aData['grawdata'] = $grawdata;
Expand Down Expand Up @@ -3552,7 +3554,7 @@ public function generate_simple_statistics($surveyid, $allfields, $q2show = 'all
$aData['surveyid'] = $surveyid;
$aData['sql'] = $sql;

$sOutputHTML = '';
$sOutputHTML = '<div class="row">';

//let's run through the survey
$runthrough = $summary;
Expand All @@ -3561,7 +3563,7 @@ public function generate_simple_statistics($surveyid, $allfields, $q2show = 'all

//loop through all selected questions
$count = 0;
$rowOpened = 0;
//$rowOpened = 0;
foreach ($runthrough as $rt) {
////Step 1: Get information about this response field (SGQA) for the summary
$outputs = $this->buildOutputList($rt, $language, $surveyid, $outputType, $sql, $sLanguageCode);
Expand All @@ -3571,19 +3573,19 @@ public function generate_simple_statistics($surveyid, $allfields, $q2show = 'all
if (isset($outputs['alist']) && $outputs['alist']) {
//Make sure there really is an answerlist, and if so:
$count = $count + 1;
if ($count == 1) {
$sOutputHTML .= '<div class="row">';
$rowOpened = 1;
}


$display = $this->displaySimpleResults($outputs, $results, $rt, $outputType, $surveyid, $sql, $usegraph, $browse, $sLanguageCode);
$sOutputHTML .= $display['statisticsoutput'];
$aStatisticsData = array_merge($aStatisticsData, $display['astatdata']);

if ($count == 3) {
$sOutputHTML .= '</div>';
$rowOpened = 0;
$count = 0;
// Add row break after every second column for md size
if ($count % 2 == 0) {
$sOutputHTML .= '<div class="clearfix visible-md-block"></div>';
}
// Add row break after every third column for lg size
if ($count % 3 == 0) {
$sOutputHTML .= '<div class="clearfix visible-lg-block"></div>';
}

} //end if -> collect and display results
Expand All @@ -3597,10 +3599,6 @@ public function generate_simple_statistics($surveyid, $allfields, $q2show = 'all

}

if ($rowOpened) {
$sOutputHTML .= '</div>';
}

$sOutputHTML .= '</div>';

$sGoogleMapsAPIKey = trim(Yii::app()->getConfig("googleMapsAPIKey"));
Expand Down
Expand Up @@ -16,8 +16,8 @@
<!-- _statisticsoutput_graphs -->
<?php if(count($labels) < 70): ?>
<!-- Charts -->
<div class="row">
<div class="col-sm-9 vcenter chartjs-container" id="chartjs-container-<?php echo $qqid; ?>"
<div class="row custom custom-padding bottom-20">
<div class="col-sm-12 vcenter chartjs-container" id="chartjs-container-<?php echo $qqid; ?>"
data-chartname="<?php echo $sChartname; // The name of the jschart object ?>"
data-qid="<?php echo $qqid; // the question id ?>"
data-type="<?php echo $charttype; // the chart start type (bar, donut, etc.) ?>"
Expand All @@ -30,11 +30,12 @@
<canvas class="canvas-chart " id="chartjs-<?php echo $qqid; ?>" width="400" height="300<?php // echo $iCanvaHeight;?>"
data-color="<?php echo $color; // the background color for bar, etc. ?>"></canvas>
</div>

<!-- legends -->
<?php if($charttype=='Pie' || $charttype=='Doughnut'): ?>
<div class="legend col-sm-2 vcenter">
<?php foreach($labels as $i=>$label): ?>
</div>

<!-- legends -->
<div class="row">
<div class="legend col-sm-12 vcenter">
<?php foreach($fullLabels as $i=>$label): ?>
<?php $colorindex = $color+$i; ?>
<div class="row" style="margin-bottom: 10px;">
<div class="col-sm-1">
Expand All @@ -47,7 +48,6 @@
</div>
<?php endforeach;?>
</div>
<?php endif; ?>
</div>

<!-- Buttons to change graph type -->
Expand Down
Expand Up @@ -9,6 +9,6 @@
?>

<!-- _statisticsoutput_header -->
<div class="col-sm-4 printable" style="margin-top: 2em;margin-bottom: 2em;">
<div class="col-sm-12 col-md-6 col-lg-4 printable" style="margin-top: 2em;margin-bottom: 2em;">
<h4><?php echo $outputs['qquestion'];?></h4>
<!-- end of _statisticsoutput_header -->

0 comments on commit 5f11205

Please sign in to comment.