Skip to content

Commit

Permalink
Dev: dynamic width for stats graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed May 18, 2016
1 parent 1eae5e3 commit 687705d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 2 additions & 3 deletions application/helpers/admin/statistics_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3034,7 +3034,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
{
case "1":
$nbcols = "12";
$canvaWidth = "1000";
$canvaWidth = "1150";
$canvaHeight = "800";
break;

Expand Down Expand Up @@ -3709,7 +3709,6 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
foreach($labels as $key => $label)
{
$cleanLabel = $label;
$cleanLabel = viewHelper::flatEllipsizeText($cleanLabel, true, 20);
$labels[$key] = $cleanLabel;
}

Expand All @@ -3733,7 +3732,7 @@ protected function displayResults($outputs, $results, $rt, $outputType, $surveyi
$statisticsoutput .= Yii::app()->getController()->renderPartial('/admin/export/generatestats/_statisticsoutput_graphs', $aData, true);

}
$statisticsoutput .= "</table></div><br /> <!-- in statistics helper --> \n";
$statisticsoutput .= "</table></div> <!-- in statistics helper --> \n";
}

return array("statisticsoutput"=>$statisticsoutput, "pdf"=>$this->pdf, "astatdata"=>$astatdata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<?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="col-lg-8 col-md-12 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 @@ -29,13 +29,14 @@



<!-- a default width/height is provided from the server side. But it's overwritten by javascript-->
<canvas class="canvas-chart " id="chartjs-<?php echo $qqid; ?>" width="<?php echo $canvaWidth?>" height="<?php echo $canvaHeight?>"
data-color="<?php echo $color; // the background color for bar, etc. ?>"></canvas>

<!-- maintainAspectRatio: false -->
</div>
<!-- legends -->
<div class="legend col-sm-2 vcenter">
<div class="legend col-lg-4 col-md-12">
<?php foreach($labels as $i=>$label): ?>
<?php $colorindex = $color+$i; $colorindex = ($colorindex < 72)?$colorindex:0;?>
<div class="row" style="margin-bottom: 10px;">
Expand Down
7 changes: 7 additions & 0 deletions scripts/admin/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ function init_chart_js_graph_with_datas($type,$qid)

$(document).ready(function() {

if($('.chartjs-container').length>0)
{
$elChartJsContainer = $('.chartjs-container').first();
$('.canvas-chart').width($elChartJsContainer.width());
console.log('$elChartJsContainer.width(): '+$elChartJsContainer.width());
console.log($('.canvas-chart').width());
}

if($('#showGraphOnPageLoad').length>0)
{
Expand Down

0 comments on commit 687705d

Please sign in to comment.