Move charts from taskboard.
parent
9500756335
commit
52ad64bd23
|
@ -0,0 +1,105 @@
|
|||
###
|
||||
# Copyright (C) 2014 Andrey Antukh <niwi@niwi.be>
|
||||
# Copyright (C) 2014 Jesús Espino Garcia <jespinog@gmail.com>
|
||||
# Copyright (C) 2014 David Barragán Merino <bameda@dbarragan.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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)
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue