diff --git a/lib/xcode-build-times-chart/gantt.js b/lib/xcode-build-times-chart/gantt.js index 88d6bb2..dbfe6c1 100755 --- a/lib/xcode-build-times-chart/gantt.js +++ b/lib/xcode-build-times-chart/gantt.js @@ -87,7 +87,7 @@ function build_gantt_chart() { const legend = [ ['Build time', build_time], ['Total computation time', compudataion_time], - ['Theoretical minimum', theoretical_minimum], + ['Theoretical minimum', theoretical_minimum.toFixed(2)], ['Theoretical speedup x', theoretical_speedup.toFixed(2)] ].map(function (t) { const title = t[0]; @@ -101,23 +101,22 @@ function build_gantt_chart() { console.log(legend); minDate = tasks[0].startDate; - - var max_time = 10 * 60 * 1000; + task_name_lengths = tasks_result.names.map( n => n.length ) + max_name_length = Math.max(...task_name_lengths) var gantt = d3.gantt() + .margin({ top : 20, right : 40, bottom : 20, left : 6 * max_name_length }) .taskTypes(tasks_result.names) .tickFormat("%M:%S") - .timeDomainMode("fixed") - .timeDomain([minDate, new Date(minDate.getTime() + max_time)]); + .timeDomainMode("fit") + updateWindow() gantt(tasks, legend); - var w = window; function updateWindow(){ - x = w.innerWidth || e.clientWidth || g.clientWidth; - y = w.innerHeight|| e.clientHeight|| g.clientHeight; + x = window.innerWidth || e.clientWidth || g.clientWidth; + y = window.innerHeight|| e.clientHeight|| g.clientHeight; - console.log("Gantt value " + gantt.margin); var margin = gantt.margin(); gantt .width(x - margin.left - margin.right - 5) @@ -125,7 +124,4 @@ function build_gantt_chart() { .redraw(tasks); } d3.select(window).on('resize.updatesvg', updateWindow); - - }; -