forked from RallyApps/app-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlannedVsActualBurndownApp.html
373 lines (313 loc) · 16.5 KB
/
PlannedVsActualBurndownApp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Copyright (c) 2011 Rally Software Development Corp. All rights reserved -->
<html>
<head>
<title>Planned vs. Actual Burndown</title>
<meta name="Name" content="App: Planned vs. Actual Burndown"/>
<meta name="Version" content="2012.01.14"/>
<meta name="Vendor" content="Rally Software"/>
<script type="text/javascript" src="/apps/1.33/sdk.js?apiVersion=1.29"></script>
<script type="text/javascript">
function PlannedVsActualBurndown() {
this.display = function() {
dojo.require("dojox.charting.Chart2D");
var iterations = {};
var waiter, releaseDropdown, aggregatedTable, chart;
var showLegend = function() {
dojo.byId("legendDiv").innerHTML =
"<div class='blue box'></div> Actual Burndown <div class='green box'></div> Planned Burndown";
};
var buildLineChart = function() {
var labels = [];
var plannedBurndown = [];
var actualBurndownPast = [];
var actualBurndownFuture = [];
var zeros = [];
var i = 1;
var futureCount = 0;
rally.forEach(iterations, function(value) {
labels.push({value: i, text: value.Name});
plannedBurndown.push(value.PlannedBurndown);
if (value.IsFuture && futureCount === 0) { // past/future plot point
futureCount = 1;
actualBurndownPast.push(value.ActualBurndown);
actualBurndownFuture.push(value.ActualBurndown);
} else if (value.IsFuture && futureCount > 0) { // future plot points
actualBurndownPast.push(null);
actualBurndownFuture.push(value.ActualBurndown);
} else { // past plot points
actualBurndownPast.push(value.ActualBurndown);
actualBurndownFuture.push(null);
}
zeros.push(0);
i++;
});
chart = new dojox.charting.Chart2D("lineChartDiv");
chart.addPlot("default", {type: "Lines"});
chart.addAxis("x", {labels: labels});
chart.addAxis("y", {vertical: true});
chart.addSeries("Planned Burndown", plannedBurndown, {stroke: {color:"#666666", style: "LongDash"}});
chart.addSeries("Actual Burndown Past", actualBurndownPast, {stroke: {color:"#5C9ACB"}});
chart.addSeries("Actual Burndown Future", actualBurndownFuture, {stroke: {color:"#5C9ACB", style: "LongDash"}});
chart.addSeries("Zero Axis", zeros, {stroke: {color:"black", width:1}});
chart.render();
showLegend();
};
var populateTable = function(table) {
function formatDate(date) {
if (date === "") {
return "";
}
return dojo.date.locale.format(dojo.date.stamp.fromISOString(date.replace(/Z/, "")), {datePattern: "yyyy-MM-dd", selector: "date"});
}
var i = 0;
rally.forEach(iterations, function(value) {
var colorClass = value.IsFuture ? "greyText" : "blueText";
table.setCell(i, 0, value.Name);
table.setCell(i, 1, formatDate(value.StartDate));
table.setCell(i, 2, formatDate(value.EndDate));
table.setCell(i, 3, '' + value.PlanEstimate);
table.setCell(i, 4, '' + value.ActualVelocity);
table.setCell(i, 5, '' + value.Resources);
table.setCell(i, 6, "<span class='" + colorClass + "'>" + value.ActualBurndown + "</span>");
table.setCell(i, 7, "<span class='greenText'>" + value.PlannedBurndown + "</span>");
i++;
});
};
var showTable = function(releasePlanEstimate) {
var aggregatedTableConfig = {
'sortingEnabled': false,
'columnKeys' : ['Iteration Name', 'Start Date', 'End Date', 'Plan Estimate', 'Actual Velocity', 'Planned Velocity', 'Actual Burndown', 'Planned Burndown'],
'width' : '880px'
};
aggregatedTable = new rally.sdk.ui.Table(aggregatedTableConfig);
populateTable(aggregatedTable);
waiter.hide();
dojo.byId('planEstimateDiv').innerHTML = 'Release Plan Estimate: ' + releasePlanEstimate;
dojo.byId("legendDiv").style.display = "";
dojo.byId("planEstimateDiv").style.display = "";
dojo.byId("aggregatedDataDiv").style.display = "";
aggregatedTable.display("aggregatedDataDiv");
buildLineChart();
};
var aggregateBurndown = function(releasePlanEstimate) {
function getRallyDate(jsDate) {
var yr = jsDate.getUTCFullYear();
var mon = ("0" + (jsDate.getUTCMonth() + 1));
var day = ("0" + jsDate.getUTCDate()).substr(-2);
var hr = ("0" + jsDate.getUTCHours()).substr(-2);
var min = ("0" + jsDate.getUTCMinutes()).substr(-2);
var sec = ("0" + jsDate.getUTCSeconds()).substr(-2);
return yr +
"-" + mon.substr(mon.length - 2, 2) +
"-" + day.substr(day.length - 2, 2) +
"T" + hr + ":" + min + ":" + sec;
}
var actualBurndown, plannedBurndown, future, lastPlannedVelocity, lastActualVelocity;
var today = getRallyDate(new Date());
var i = 1;
rally.forEach(iterations, function(value) {
/* The first row shows the first iteration of the release.
And because what's shown on each row is the state of the
release at the BEGINNING of that row's iteration, both
the planned burndown and the actual burndown are set to
the total release plan estimate. */
if (i === 1) {
actualBurndown = releasePlanEstimate;
plannedBurndown = releasePlanEstimate;
future = value.EndDate >= today;
/* The final row shows the state of the release after the
completion of the last iteration. */
} else if (value.Name === "Release") {
if (future) {
actualBurndown -= lastPlannedVelocity;
plannedBurndown -= lastPlannedVelocity;
} else {
actualBurndown -= lastActualVelocity;
plannedBurndown -= lastPlannedVelocity;
}
/* if the PREVIOUS iteration has NOT been completed,
use the -planned- velocity of that iteration
to compute the point on the burndown where the
CURRENT iteration would start */
} else if (future) {
actualBurndown -= lastPlannedVelocity;
plannedBurndown -= lastPlannedVelocity;
future = true;
/* if the PREVIOUS iteration HAS been completed,
use the -actual- velocity of that iteration
to compute the point on the burndown where the
CURRENT iteration would start */
} else { // past iteration
actualBurndown -= lastActualVelocity;
plannedBurndown -= lastPlannedVelocity;
future = false;
}
future = value.EndDate >= today;
lastPlannedVelocity = value.Resources;
lastActualVelocity = value.ActualVelocity;
iterations[value.Name].ActualBurndown = actualBurndown;
iterations[value.Name].PlannedBurndown = plannedBurndown;
iterations[value.Name].IsFuture = future;
i++;
});
showTable(releasePlanEstimate);
};
var aggregateData = function(results) {
var releasePlanEstimate = 0;
var allStoriesDefectsDefectSuites = results.stories;
allStoriesDefectsDefectSuites = allStoriesDefectsDefectSuites.concat(results.defects);
allStoriesDefectsDefectSuites = allStoriesDefectsDefectSuites.concat(results.defectSuites);
dojo.forEach(allStoriesDefectsDefectSuites, function(item) { //aggregate story, defect, & defect suite data
var estimate = item.PlanEstimate || 0;
iterations[item.Iteration.Name].PlanEstimate += estimate;
releasePlanEstimate += estimate;
if (item.ScheduleState === 'Accepted') {
iterations[item.Iteration.Name].ActualVelocity += estimate;
}
});
aggregateBurndown(releasePlanEstimate);
};
var makeIterationObjects = function(results) {
dojo.forEach(results.iterations, function(iteration) {
var resources = iteration.Resources || 0;
if (iterations[iteration.Name]) {
resources = resources + iterations[iteration.Name].Resources;
}
iterations[iteration.Name] = {
_ref: iteration._ref,
Name: iteration.Name,
StartDate: iteration.StartDate,
EndDate: iteration.EndDate,
Resources: resources,
PlanEstimate: 0,
ActualVelocity: 0,
ActualBurndown: 0,
PlannedBurndown:0,
IsFuture: ""};
});
iterations.Release = {
_ref: "",
Name: "Release",
StartDate: "",
EndDate: "",
Resources: "",
PlanEstimate: "",
ActualVelocity: "",
ActualBurndown: 0,
PlannedBurndown:0,
IsFuture: ""};
aggregateData(results);
};
function clearComponents() {
dojo.byId("legendDiv").style.display = "none";
dojo.byId("planEstimateDiv").style.display = "none";
dojo.byId("aggregatedDataDiv").style.display = "none";
waiter.display("waiter");
iterations = {};
if (chart) {
chart.destroy();
}
if (aggregatedTable) {
aggregatedTable.destroy();
aggregatedTable = null;
}
}
function releaseSelected() {
clearComponents();
var queryConfig = [];
var typeArray = ['hierarchicalrequirement','Defect','DefectSuite'];
var keyArray = ['stories','defects','defectSuites'];
dojo.forEach(typeArray, function(query, i) {
queryConfig.push({
type : typeArray[i],
key : keyArray[i],
query: rally.sdk.util.Query.and(['Iteration.StartDate >= "' + releaseDropdown.getSelectedStart() + '"',
'Iteration.StartDate <= "' + releaseDropdown.getSelectedEnd() + '"']).or(
rally.sdk.util.Query.and(['Iteration.EndDate >= "' + releaseDropdown.getSelectedStart() + '"',
'Iteration.EndDate <= "' + releaseDropdown.getSelectedEnd() + '"'])),
fetch: 'Name,Iteration,ScheduleState,PlanEstimate'
});
});
queryConfig.push({
type : 'Iterations',
key : 'iterations',
query: rally.sdk.util.Query.and(['StartDate >= "' + releaseDropdown.getSelectedStart() + '"',
'StartDate <= "' + releaseDropdown.getSelectedEnd() + '"']).or(
rally.sdk.util.Query.and(['EndDate >= "' + releaseDropdown.getSelectedStart() + '"',
'EndDate <= "' + releaseDropdown.getSelectedEnd() + '"'])),
fetch: 'Name,Resources,StartDate,EndDate',
order: 'EndDate'
});
rallyDataSource.findAll(queryConfig, makeIterationObjects);
}
rally.sdk.ui.AppHeader.setHelpTopic("240");
rally.sdk.ui.AppHeader.showPageTools(true);
rallyDataSource = new rally.sdk.data.RallyDataSource('__WORKSPACE_OID__',
'__PROJECT_OID__',
'__PROJECT_SCOPING_UP__',
'__PROJECT_SCOPING_DOWN__');
releaseDropdown = new rally.sdk.ui.ReleaseDropdown({}, rallyDataSource);
waiter = new rally.sdk.ui.basic.Wait({hideTarget:false});
waiter.display("waiter");
dojo.addOnLoad(function() { //executes when dojo requirements are loaded
releaseDropdown.display("dropdownDiv", releaseSelected);
});
};
}
</script>
<style type="text/css">
.box {
display: inline-block;
height: 10px;
width: 10px;
}
.blue {
background-color: #5C9ACB;
}
.green {
background-color: #666666;
}
.greenText {
color: #666666;
}
.blueText {
color: #5C9ACB;
}
.greyText {
color: #999999;
}
#aggregatedDataDiv,
#legendDiv {
padding-top: 10px;
}
#lineChartDiv,
#planEstimateDiv,
#legendDiv,
#waiter {
width: 850px;
}
#planEstimateDiv,
#legendDiv {
text-align: right;
font-size: 12px;
}
</style>
<script type="text/javascript">
function onLoad() {
var plannedVsActualBurndown = new PlannedVsActualBurndown();
plannedVsActualBurndown.display();
}
rally.addOnLoad(onLoad);
</script>
</head>
<body>
<div id="waiter"></div>
<div id="releaseDiv"></div>
<div id="dropdownDiv"></div>
<div id="legendDiv"></div>
<div id="lineChartDiv"></div>
<div id="planEstimateDiv"></div>
<div id="aggregatedDataDiv"></div>
</body>
</html>