|
122 | 122 |
|
123 | 123 | <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> |
124 | 124 | <script type="text/javascript"> |
125 | | - google.charts.load('current', {'packages':['gantt']}); |
| 125 | + google.charts.load("current", {packages:["timeline"]}); |
126 | 126 | google.charts.setOnLoadCallback(drawChart); |
127 | | - |
128 | 127 | function drawChart() { |
129 | 128 | if(project_end == null){ |
130 | | - let projectGantt = document.getElementById('projectGantt'); |
| 129 | + let projectGantt = document.getElementById('ganttContainer'); |
131 | 130 | projectGantt.classList.add('hidden'); |
132 | 131 | return; |
133 | 132 | } |
134 | | - let data = new google.visualization.DataTable(); |
135 | | - data.addColumn('string', 'Task ID'); |
136 | | - data.addColumn('string', 'Task Name'); |
137 | | - data.addColumn('string', 'Resource'); |
138 | | - data.addColumn('date', 'Start Date'); |
139 | | - data.addColumn('date', 'End Date'); |
140 | | - data.addColumn('number', 'Duration'); |
141 | | - data.addColumn('number', 'Percent Complete'); |
142 | | - data.addColumn('string', 'Dependencies'); |
143 | | - data.addColumn('string', 'tooltip'); |
| 133 | + var container = document.getElementById('ganttChart'); |
| 134 | + var chart = new google.visualization.Timeline(container); |
| 135 | + var data = new google.visualization.DataTable(); |
| 136 | + data.addColumn({ type: 'string', id: 'Term' }); |
| 137 | + data.addColumn({ type: 'string', id: 'Name' }); |
| 138 | + data.addColumn({ type: 'date', id: 'Start' }); |
| 139 | + data.addColumn({ type: 'date', id: 'End' }); |
144 | 140 |
|
145 | 141 | data.addRows([ |
146 | | - [project_name, project_name, project_name, |
147 | | - new Date(project_start), new Date(project_end), project_value, 100, null, "Project: "+project_name], |
| 142 | + [project_name, project_name, |
| 143 | + new Date(project_start), new Date(project_end)], |
148 | 144 | ]); |
| 145 | + let colorArray = ["#386671",]; |
149 | 146 |
|
150 | 147 | for(let i=0; i<activity_num; i++) { |
151 | 148 | let activityKey = document.getElementById("activityKey"+i).value; |
|
155 | 152 | let activityDays = document.getElementById("manDays"+i).value * 8; |
156 | 153 | let activityTotHoursCompiled = document.getElementById("TotHoursCompiled"+activityKey).value; |
157 | 154 | let activityPercentage = Math.round(100 * (activityTotHoursCompiled / activityDays)); |
| 155 | + let colorActivityBar = "#59a5b7" |
| 156 | + if(activityPercentage > 100) |
| 157 | + colorActivityBar = "#9b2222" |
| 158 | + else if(activityPercentage === 100) |
| 159 | + colorActivityBar = "#32c574" |
| 160 | + else if(activityPercentage === 0) |
| 161 | + colorActivityBar = "#8AB4B1" |
| 162 | + colorArray.push(colorActivityBar) |
158 | 163 | if(activityDateEnd === "") |
159 | 164 | activityDateEnd = project_end; |
160 | 165 | data.addRows([ |
161 | | - [activityKey, activityKey, "activity", |
162 | | - new Date(activityDateStart), new Date(activityDateEnd), activityDays, activityPercentage, null, "Compiled Days: " + activityTotHoursCompiled], |
| 166 | + [activityKey, "" + Math.round(activityTotHoursCompiled/8) + "/" + activityDays/8 + "gg (" + activityPercentage + "%)", |
| 167 | + new Date(activityDateStart), new Date(activityDateEnd)], |
163 | 168 | ]); |
164 | 169 | } |
165 | | - let options = { |
166 | | - tooltip: {isHtml: true}, |
167 | | - gantt: { |
168 | | - criticalPathEnabled: false, |
169 | | - labelStyle: { |
170 | | - fontFamily: "Arial", |
171 | | - fontWeight: "bold", |
172 | | - fontSize: 14, |
173 | | - color: '#f30606' |
| 170 | + console.log(colorArray); |
| 171 | + var options = { |
| 172 | + rowLabelStyle: { |
| 173 | + fontSize: 10, |
| 174 | + }, |
| 175 | + backgroundColor: "#f1f7f8", |
| 176 | + colors: colorArray, |
| 177 | + height: (1+activity_num)*50, |
| 178 | + timeline: { showRowLabels: true, |
| 179 | + barLabelStyle: { |
| 180 | + fontSize: 10 |
174 | 181 | }, |
175 | | - trackHeight: 20, |
176 | | - barHeight: 15, |
177 | | - palette: [ |
178 | | - { |
179 | | - "color": "#386671", |
180 | | - "dark": "#25454d", |
181 | | - "light": "#73b3c2" |
182 | | - }, |
183 | | - { |
184 | | - "color": "#5caabd", |
185 | | - "dark": "#417988", |
186 | | - "light": "#9ee3f6" |
187 | | - }, |
188 | | - ], |
189 | | - } |
| 182 | + }, |
| 183 | + |
190 | 184 | }; |
191 | | - let chart = new google.visualization.Gantt(document.getElementById('chart_div')); |
| 185 | + |
192 | 186 | chart.draw(data, options); |
193 | 187 | } |
194 | | - |
195 | 188 | window.addEventListener('resize', function(event) { |
196 | 189 | drawChart(); |
197 | 190 | }, true); |
198 | 191 | </script> |
199 | 192 |
|
200 | 193 |
|
| 194 | + |
201 | 195 | <section class=""> |
202 | 196 | <div class="container mt-6"> |
203 | 197 | <div class="columns"> |
|
366 | 360 | <span class="icon has-text-primary is-pulled-right mr-1" |
367 | 361 | data-tooltip="Order"> |
368 | 362 | <i class="fas fa-sort fa-lg table-button is-clickable" |
369 | | - th:onclick="'sortTable(\'activityKey\',columnList);'"></i> |
| 363 | + th:onclick="'sortTable(\'activityKey\',columnList), drawChart();'"></i> |
370 | 364 | </span> |
371 | 365 | </th> |
372 | 366 | <th class="activityTypeCol has-text-primary-dark table-header pl-2">Type |
373 | 367 | <span class="icon has-text-primary is-pulled-right mr-1" |
374 | 368 | data-tooltip="Order"> |
375 | 369 | <i class="fas fa-sort fa-lg table-button is-clickable" |
376 | | - th:onclick="'sortTable(\'activityType\',columnList);'"></i> |
| 370 | + th:onclick="'sortTable(\'activityType\',columnList), drawChart();'"></i> |
377 | 371 | </span> |
378 | 372 | </th> |
379 | 373 | <th class="dateCol has-text-primary-dark table-header pl-2">Start Date |
380 | 374 | <span class="icon has-text-primary is-pulled-right mr-1" |
381 | 375 | data-tooltip="Order"> |
382 | 376 | <i class="fas fa-sort fa-lg table-button is-clickable" |
383 | | - th:onclick="'sortTable(\'dateStart\',columnList);'"></i> |
| 377 | + th:onclick="'sortTable(\'dateStart\',columnList), drawChart();'"></i> |
384 | 378 | </span> |
385 | 379 | </th> |
386 | 380 | <th class="dateCol has-text-primary-dark table-header pl-2">End Date |
387 | 381 | <span class="icon has-text-primary is-pulled-right mr-1" |
388 | 382 | data-tooltip="Order"> |
389 | 383 | <i class="fas fa-sort fa-lg table-button is-clickable" |
390 | | - th:onclick="'sortTable(\'dateEnd\',columnList);'"></i> |
| 384 | + th:onclick="'sortTable(\'dateEnd\',columnList), drawChart();'"></i> |
391 | 385 | </span> |
392 | 386 | </th> |
393 | 387 | <th class="chargedCol has-text-primary-dark table-header pl-2">Charged |
394 | 388 | <span class="icon has-text-primary is-pulled-right mr-1" |
395 | 389 | data-tooltip="Order"> |
396 | 390 | <i class="fas fa-sort fa-lg table-button is-clickable" |
397 | | - th:onclick="'sortTable(\'charged\',columnList);'"></i> |
| 391 | + th:onclick="'sortTable(\'charged\',columnList), drawChart();'"></i> |
398 | 392 | </span> |
399 | 393 | </th> |
400 | 394 | <th class="manDaysCol has-text-primary-dark table-header pl-2">Days |
401 | 395 | <span class="icon has-text-primary is-pulled-right mr-1" |
402 | 396 | data-tooltip="Order"> |
403 | 397 | <i class="fas fa-sort fa-lg table-button is-clickable" |
404 | | - th:onclick="'sortTable(\'manDays\',columnList);'"></i> |
| 398 | + th:onclick="'sortTable(\'manDays\',columnList), drawChart();'"></i> |
405 | 399 | </span> |
406 | 400 | </th> |
407 | 401 | <th></th> |
|
520 | 514 | </div> |
521 | 515 | </div> |
522 | 516 | </div> |
523 | | - <div id="projectGantt" style="font-weight: bold;"> |
| 517 | + <div id="ganttContainer" class="mt-2" style="font-weight: bold;"> |
524 | 518 | <p class="subtitle has-text-weight-bold has-text-centered has-text-primary-dark has-text-weight-semibold m-auto mt-5 mb-3">Project summary</p> |
525 | 519 | <div class="columns is-centered"> |
526 | 520 | <div class="column"> |
527 | | - <div id="chart_div"></div> |
| 521 | + <div id="ganttChart" class="mt-3"></div> |
528 | 522 | </div> |
529 | 523 | </div> |
530 | 524 | </div> |
|
0 commit comments