1
1
var tekken ;
2
2
var tekkendata ;
3
- var showfiller = true ;
4
3
5
4
function drawChart ( ) {
6
5
function TimeEntriesEnd ( data , rowNum ) {
7
6
return data . getValue ( rowNum , 0 )
8
7
}
9
8
function CR2Perc ( data , rowNum ) {
10
- return Math . floor ( data . getValue ( rowNum , 1 ) / data . getValue ( rowNum , 2 ) * 100 )
9
+ return Math . floor ( data . getValue ( rowNum , 1 ) / data . getValue ( rowNum , 3 ) * 100 )
11
10
}
12
11
function Filler2Perc ( data , rowNum ) {
13
- return Math . floor ( ( data . getValue ( rowNum , 2 ) - data . getValue ( rowNum , 1 ) ) / data . getValue ( rowNum , 2 ) * 101 ) // make sure the math.round will get 100
12
+ return Math . floor ( data . getValue ( rowNum , 2 ) / data . getValue ( rowNum , 3 ) * 100 )
14
13
}
15
14
function CRTooltip ( data , rowNum ) {
16
- return '<p id="first_tooltip" class="google-visualization-tooltip-item"><strong>Estimated CR:</strong> ' + data . getValue ( rowNum , 1 ) + ' days<br/><strong>Total project:</strong> ' + data . getValue ( rowNum , 2 ) + ' days<br/><strong>Time entries:</strong> ' + data . getValue ( rowNum , 0 ) + ' days</p>'
15
+ return '<p id="first_tooltip" class="google-visualization-tooltip-item"><strong>Estimated CR:</strong> ' + data . getValue ( rowNum , 1 ) + ' days<br/><strong>Total project:</strong> ' + data . getValue ( rowNum , 3 ) + ' days<br/><strong>Time entries:</strong> ' + data . getValue ( rowNum , 0 ) + ' days</p>'
17
16
}
18
17
var view = new google . visualization . DataView ( tekkendata ) ;
19
18
columns = [ { calc : function ( ) { return '' } , type : 'string' } ,
20
19
{ calc : CR2Perc , type : 'number' } ,
21
20
{ calc : function ( ) { return 0 } , type : 'number' , role :'interval' } ,
22
21
{ calc : TimeEntriesEnd , type : 'number' , role :'interval' } ,
23
22
{ calc : CRTooltip , type : 'string' , role :'tooltip' , 'properties' : { 'html' :true } } ,
23
+ { calc : Filler2Perc , type : 'number' } ,
24
+ { calc : function ( ) { return 'Filler CR' } , type : 'string' , role :'tooltip' }
24
25
]
25
- if ( showfiller ) {
26
- columns . push ( { calc : Filler2Perc , type : 'number' } )
27
- columns . push ( { calc : function ( ) { return 'Filler CR' } , type : 'string' , role :'tooltip' } )
28
- }
29
26
view . setColumns ( columns ) ;
30
27
tekken . draw ( view ,
31
28
{ title :"Tekken bar" ,
@@ -54,6 +51,7 @@ function drawVisualization() {
54
51
tekkendata = new google . visualization . DataTable ( ) ;
55
52
tekkendata . addColumn ( 'number' , 'Time Entries' ) ;
56
53
tekkendata . addColumn ( 'number' , 'CR estimated' ) ;
54
+ tekkendata . addColumn ( 'number' , 'CR filler' ) ;
57
55
tekkendata . addColumn ( 'number' , 'Total project' ) ;
58
56
tekkendata . addRows ( 1 ) ;
59
57
tekken = new google . visualization . BarChart ( document . getElementById ( 'visualization' ) ) ;
@@ -77,17 +75,24 @@ google.setOnLoadCallback(function() {
77
75
var update_project_totals = function ( $bgb_header ) {
78
76
var totals = { } ,
79
77
total_estimate = 0 ,
78
+ total_filler = 0 ,
80
79
total_done = 0 ,
81
80
total_days = 0 ,
82
81
$bgb = $bgb_header . next ( '.bgb-project' ) ;
83
82
84
- $bgb . find ( 'tr[data-workflow-state]:visible' ) . each ( function ( ) {
85
- total_estimate += parseInt ( $ ( this ) . data ( 'duration-estimate' ) , 10 ) ;
83
+ $bgb . find ( 'tr[data-contract]:visible' ) . each ( function ( ) {
86
84
total_done += parseInt ( $ ( this ) . data ( 'duration-done' ) , 10 ) ;
87
85
total_days = parseInt ( $ ( this ) . data ( 'contract-days' ) , 10 ) ;
88
86
} ) ;
87
+ $bgb . find ( 'tr[data-contract]:not([data-filler]):visible' ) . each ( function ( ) {
88
+ total_estimate += parseInt ( $ ( this ) . data ( 'duration-estimate' ) , 10 ) ;
89
+ } ) ;
90
+ $bgb . find ( 'tr[data-filler]:visible' ) . each ( function ( ) {
91
+ total_filler += parseInt ( $ ( this ) . data ( 'duration-estimate' ) , 10 ) ;
92
+ } ) ;
89
93
return {
90
94
total_estimate : Math . round ( total_estimate / 60 / 60 / 8 ) ,
95
+ total_filler : Math . round ( total_filler / 60 / 60 / 8 ) ,
91
96
total_done : Math . round ( total_done / 60 / 60 / 8 ) ,
92
97
total_days : total_days ,
93
98
} ;
@@ -96,9 +101,11 @@ google.setOnLoadCallback(function() {
96
101
// update the tekken bar
97
102
var update_tekken = function ( ) {
98
103
var totals = update_project_totals ( $ ( '.bgb-project-header' ) ) ;
104
+ console . log ( totals ) ;
99
105
tekkendata . setValue ( 0 , 0 , totals . total_done ) ;
100
106
tekkendata . setValue ( 0 , 1 , totals . total_estimate ) ;
101
- tekkendata . setValue ( 0 , 2 , totals . total_days ) ;
107
+ tekkendata . setValue ( 0 , 2 , totals . total_filler ) ;
108
+ tekkendata . setValue ( 0 , 3 , totals . total_days ) ;
102
109
drawChart ( ) ;
103
110
} ;
104
111
0 commit comments