Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: masters/master.chromium/public_html/gantt_chart.js

Issue 2484593002: Adding gantt chart to Build Status page on Buildbot Masters (Closed)
Patch Set: fixing spacing on build.html in master.tryserver.chromium.linux Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 google.charts.load('current', {'packages':['gantt']});
dsansome 2016/11/08 04:49:11 Add a copyright header: // Copyright 2016 The Chr
philwright 2016/11/09 04:58:38 Done.
2
3 /*
dsansome 2016/11/08 04:49:11 Use JSDoc style comments: https://engdoc.corp.goog
philwright 2016/11/09 04:58:38 Done.
4 reconcileSwarmingSteps reconciles a Swarming step's "trigger" step with
5 it's subsequent "collect results" step.
6
7 Swarming steps in BuildBot create two steps - one to trigger the work
8 on swarming, and a later step to collect the results.
9
10 The two steps have the same name, except the trigger step has "[trigger] "
11 prepended to the name.
12
13 This function consolidates the two steps into one by using the start
14 time from the trigger step and the end time from the "collect results"
15 step.
16
17 This function assumes that a trigger step will be found before the
18 corresponding "collect results" step in the list of steps.
19 */
20 function reconcileSwarmingSteps(steps) {
21 var reconciledSteps = [];
dsansome 2016/11/08 04:49:11 s/var/let/
philwright 2016/11/09 04:58:38 Done.
22 var triggerSteps = {};
23
24 for (i = 0; i < steps.length; i++) {
dsansome 2016/11/08 04:49:11 Use for...of (https://developer.mozilla.org/en-US/
philwright 2016/11/09 04:58:38 Done.
25 s = steps[i];
26 // trigger steps have names like "[trigger] TheRestOfTheNameGoesHere..."
27 isTriggerStep = /\[trigger\] (.*)/.exec(s.name);
dsansome 2016/11/08 04:49:11 Always scope local variables using "let".
philwright 2016/11/09 04:58:38 Done.
28 if (isTriggerStep) {
29 triggerSteps[isTriggerStep[1]] = s;
30 } else {
31 if (triggerSteps[s.name]) {
32 s.start = triggerSteps[s.name].start;
33 }
34 reconciledSteps.push(s);
35 }
36 }
37
38 return reconciledSteps;
39 };
40
41 function drawChart(steps) {
42 var data = new google.visualization.DataTable();
43 data.addColumn('string', 'Task ID');
44 data.addColumn('string', 'Task Name');
45 data.addColumn('string', 'Resource');
46 data.addColumn('date', 'Start Date');
47 data.addColumn('date', 'End Date');
48 data.addColumn('number', 'Duration');
49 data.addColumn('number', 'Percent Complete');
50 data.addColumn('string', 'Dependencies');
51
52 for (i = 0; i < steps.length; i++) {
dsansome 2016/11/08 04:49:11 for..of
philwright 2016/11/09 04:58:38 Done.
53 var s = steps[i];
54 data.addRows([['' + i, s.name, null, s.start, s.end, null, 100, null]]);
55 }
56
57 var trackHeight = 25
58 var options = {
59 height: data.getNumberOfRows() * trackHeight,
60 gantt: {
61 trackHeight: trackHeight,
62 barHeight: trackHeight * 0.8,
63 labelMaxWidth: 500
dsansome 2016/11/08 04:49:11 Trailing commas are OK now: https://engdoc.corp.go
philwright 2016/11/09 04:58:38 Done.
64 }
65 };
66
67 var chart = new google.visualization.Gantt(
68 document.getElementById('chart_div')
dsansome 2016/11/08 04:49:11 4-space indentation here
philwright 2016/11/09 04:58:38 Done.
69 );
dsansome 2016/11/08 04:49:11 And put this on the line above
philwright 2016/11/09 04:58:38 Done.
70 chart.draw(data, options);
71 }
72
73 var chartVisible = false;
74 function toggleChart(rawSteps) {
75 if (chartVisible) {
76 document.getElementById('chart_div').style.display = 'none';
77 chartVisible = false;
78 } else {
79 document.getElementById('chart_div').style.display = 'block';
80 var steps = reconcileSwarmingSteps(rawSteps);
81 drawChart(steps);
82 chartVisible = true;
83 }
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698