Skip to content

Commit

Permalink
Adjust Left Margin and time axis to fit
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Halligon committed Mar 27, 2019
1 parent 3e5bdcf commit 541588c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/xcode-build-times-chart/gantt.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -101,31 +101,27 @@ 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)
.height(y - margin.top - margin.bottom - 5)
.redraw(tasks);
}
d3.select(window).on('resize.updatesvg', updateWindow);


};

0 comments on commit 541588c

Please sign in to comment.