From 52ad64bd2360eaf785bd1f5308774692e63dffcb Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 10 Jul 2014 12:40:23 +0200 Subject: [PATCH] Move charts from taskboard. --- app/coffee/modules/taskboard/charts.coffee | 105 +++++++++++++++++++++ app/coffee/modules/taskboard/main.coffee | 74 --------------- 2 files changed, 105 insertions(+), 74 deletions(-) create mode 100644 app/coffee/modules/taskboard/charts.coffee diff --git a/app/coffee/modules/taskboard/charts.coffee b/app/coffee/modules/taskboard/charts.coffee new file mode 100644 index 00000000..07e98c09 --- /dev/null +++ b/app/coffee/modules/taskboard/charts.coffee @@ -0,0 +1,105 @@ +### +# Copyright (C) 2014 Andrey Antukh +# Copyright (C) 2014 Jesús Espino Garcia +# Copyright (C) 2014 David Barragán Merino +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +# File: modules/taskboard/charts.coffee +### + +taiga = @.taiga + +mixOf = @.taiga.mixOf +toggleText = @.taiga.toggleText +scopeDefer = @.taiga.scopeDefer +bindOnce = @.taiga.bindOnce +groupBy = @.taiga.groupBy + +module = angular.module("taigaTaskboard") + +############################################################################# +## Sprint burndown graph directive +############################################################################# + +SprintGraphDirective = -> + redrawChart = (element, dataToDraw) -> + width = element.width() + element.height(240) + + days = _.map(dataToDraw, (x) -> moment(x.day)) + + data = [] + data.unshift({ + data: _.zip(days, _.map(dataToDraw, (d) -> d.optimal_points)) + lines: + fillColor : "rgba(120,120,120,0.2)" + }) + data.unshift({ + data: _.zip(days, _.map(dataToDraw, (d) -> d.open_points)) + lines: + fillColor : "rgba(102,153,51,0.3)" + }) + + options = + grid: + borderWidth: { top: 0, right: 1, left:0, bottom: 0 } + borderColor: '#ccc' + xaxis: + tickSize: [1, "day"] + min: days[0] + max: _.last(days) + mode: "time" + daysNames: days + axisLabel: 'Day' + axisLabelUseCanvas: true + axisLabelFontSizePixels: 12 + axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif' + axisLabelPadding: 5 + yaxis: + min: 0 + series: + shadowSize: 0 + lines: + show: true + fill: true + points: + show: true + fill: true + radius: 4 + lineWidth: 2 + colors: ["rgba(102,153,51,1)", "rgba(120,120,120,0.2)"] + + element.empty() + element.plot(data, options).data("plot") + + link = ($scope, $el, $attrs) -> + element = angular.element($el) + $scope.$watch 'stats', (value) -> + if $scope.stats? + redrawChart(element, $scope.stats.days) + + $scope.$on "resize", -> + redrawChart(element, $scope.stats.days) + + $scope.$on "taskboard:graph:toggle-visibility", -> + $el.parent().toggleClass('open') + + $scope.$on "$destroy", -> + $el.off() + + return {link: link} + + +module.directive("tgSprintGraph", SprintGraphDirective) diff --git a/app/coffee/modules/taskboard/main.coffee b/app/coffee/modules/taskboard/main.coffee index 7098c194..7a94b695 100644 --- a/app/coffee/modules/taskboard/main.coffee +++ b/app/coffee/modules/taskboard/main.coffee @@ -273,80 +273,6 @@ TaskboardUsPointsDirective = ($repo, $confirm) -> return {link: link} -############################################################################# -## Sprint burndown graph directive -############################################################################# - -SprintGraphDirective = -> - redrawChart = (element, dataToDraw) -> - width = element.width() - element.height(240) - - days = _.map(dataToDraw, (x) -> moment(x.day)) - - data = [] - data.unshift({ - data: _.zip(days, _.map(dataToDraw, (d) -> d.optimal_points)) - lines: - fillColor : "rgba(120,120,120,0.2)" - }) - data.unshift({ - data: _.zip(days, _.map(dataToDraw, (d) -> d.open_points)) - lines: - fillColor : "rgba(102,153,51,0.3)" - }) - - options = - grid: - borderWidth: { top: 0, right: 1, left:0, bottom: 0 } - borderColor: '#ccc' - xaxis: - tickSize: [1, "day"] - min: days[0] - max: _.last(days) - mode: "time" - daysNames: days - axisLabel: 'Day' - axisLabelUseCanvas: true - axisLabelFontSizePixels: 12 - axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif' - axisLabelPadding: 5 - yaxis: - min: 0 - series: - shadowSize: 0 - lines: - show: true - fill: true - points: - show: true - fill: true - radius: 4 - lineWidth: 2 - colors: ["rgba(102,153,51,1)", "rgba(120,120,120,0.2)"] - - element.empty() - element.plot(data, options).data("plot") - - link = ($scope, $el, $attrs) -> - element = angular.element($el) - $scope.$watch 'stats', (value) -> - if $scope.stats? - redrawChart(element, $scope.stats.days) - - $scope.$on "resize", -> - redrawChart(element, $scope.stats.days) - - $scope.$on "taskboard:graph:toggle-visibility", -> - $el.parent().toggleClass('open') - - $scope.$on "$destroy", -> - $el.off() - - return {link: link} - - module.directive("tgTaskboard", ["$rootScope", TaskboardDirective]) module.directive("tgTaskboardRowSizeFixer", TaskboardRowSizeFixer) module.directive("tgTaskboardUsPoints", ["$tgRepo", "$tgConfirm", TaskboardUsPointsDirective]) -module.directive("tgSprintGraph", SprintGraphDirective)