This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit 804dde1a276f68f1766cb02522d89f8f498bf7c4 Merge: d1be9fa a5fc320 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Mon Jun 16 15:32:49 2014 +0200 Improve print result pollen-ui-angular/src/main/webapp/css/style.css | 8 ++ pollen-ui-angular/src/main/webapp/index.html | 12 ++- pollen-ui-angular/src/main/webapp/js/app.js | 89 ++++++++++++++++++++++ .../src/main/webapp/js/controllers/pollCtrl.js | 28 +++++-- .../src/main/webapp/partials/inline-poll.html | 6 +- .../src/main/webapp/partials/poll-comment.html | 1 + .../src/main/webapp/partials/poll-link.html | 1 + .../main/webapp/partials/poll-listParticipant.html | 1 + .../src/main/webapp/partials/poll-result.html | 8 +- .../src/main/webapp/partials/poll-settings.html | 2 +- 10 files changed, 142 insertions(+), 14 deletions(-) diff --cc pollen-ui-angular/src/main/webapp/js/app.js index e2e148f,03fb078..40155ae --- a/pollen-ui-angular/src/main/webapp/js/app.js +++ b/pollen-ui-angular/src/main/webapp/js/app.js @@@ -277,3 -277,77 +277,92 @@@ angular.module('pollen', ['pollenServic } }) + .directive('chart', function ($timeout) { + return { + restrict : 'E', + scope : { + data:'=', + }, + template:'<div class="jqplot-target"></div>', + link: function(scope, element, attrs) { ++ + var initChart = function () { + if (angular.isDefined(scope.data)) { - var plot = $.jqplot.config.enablePlugins = true; - $(element).find('div').jqplot([scope.data], { ++ $.jqplot.config.enablePlugins = true; ++ scope.plot = $(element).find('div').jqplot([scope.data], { + // Only animate if we're not using excanvas (not in IE 7 or IE 8).. - animate: !$.jqplot.use_excanvas, ++ //animate: !$.jqplot.use_excanvas, + seriesDefaults:{ + renderer:$.jqplot.BarRenderer, + pointLabels: { show: true }, + rendererOptions : { + varyBarColor: true + } + }, ++ axesDefaults: { ++ showTicks: true, ++ showTickMarks: true, ++ tickOptions: { ++ showGridline: false, ++ show:true, ++ showLabel: true, ++ } ++ }, + axes: { + xaxis: { + renderer: $.jqplot.CategoryAxisRenderer, + } + } + }); + } + }; + + scope.$watch('data', function () { - initChart(); - }); ++ if (angular.isDefined(scope.plot)) { ++ scope.plot.html(''); ++ initChart() ++ } else { ++ initChart(); ++ } ++ }, true); + } + } + }) + + .directive('pie', function ($timeout) { + return { + restrict : 'E', + scope : { + data:'=', + }, + template:'<div class="jqplot-target"></div>', + link: function(scope, element, attrs) { + var initChart = function () { + if (angular.isDefined(scope.data)) { + $.jqplot.config.enablePlugins = true; + $(element).find('div').jqplot([scope.data], { + // Only animate if we're not using excanvas (not in IE 7 or IE 8).. + animate: !$.jqplot.use_excanvas, + seriesDefaults:{ + renderer:$.jqplot.PieRenderer, + rendererOptions : { + padding: 8, + sliceMargin: 4, + showDataLabels: true, + varyBarColor: true + } + }, + legend:{ + show:true + } + }); + } + }; + + scope.$watch('data', function () { + initChart(); + }); + } + } + }) + diff --cc pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js index c3d2c18,086adb2..0f20f1c --- a/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js +++ b/pollen-ui-angular/src/main/webapp/js/controllers/pollCtrl.js @@@ -902,13 -900,16 +900,18 @@@ angular.module('pollControllers', [] var votesPromise = PollVote.query({pollId:$routeParams.pollId}, function (votes) { $scope.data.votants = votes; - $scope.data.result.nbVotant = $scope.data.votants.length; + resultPromise.then(function () { + $scope.data.result.nbVotant = $scope.data.votants.length; + }); }).$promise; - choicesPromise.then(function () { - Poll.result({pollId:$routeParams.pollId}, function (result) { - $scope.data.result = result; + var resultPromise = Poll.result({pollId:$routeParams.pollId}, function (result) { + $scope.data.result = result; + choicesPromise.then(function () { + var scoresSorted = []; ++ $scope.data.result.scoreTotal = 0; angular.forEach(result.scores, function(value, key) { ++ $scope.data.result.scoreTotal += value.scoreValue; for (var i = 0; i < $scope.data.choices.length; i++) { if ($scope.data.choices[i].id == value.choiceId) { value.choice = $scope.data.choices[i]; @@@ -916,9 -921,10 +923,16 @@@ } } }) + $scope.data.result.scoresChart = scoresSorted; }); - }); + }).$promise; + ++ votesPromise.then(function () { ++ angular.forEach($scope.data.result.scoresChart, function (value, key) { ++ value.push( Math.floor(value[1] * 100 / $scope.data.result.scoreTotal) + '% - '+value[1]+' Vote(s)'); ++ }); ++ }) + }]) .controller('PollListCtrl', -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.