feat: configurable lines
This commit is contained in:
parent
ab9ecf753f
commit
ecbec30fd7
@ -34,7 +34,7 @@ export default class Bar {
|
|||||||
this.duration *
|
this.duration *
|
||||||
(this.task.progress / 100) || 0;
|
(this.task.progress / 100) || 0;
|
||||||
this.group = createSVG("g", {
|
this.group = createSVG("g", {
|
||||||
class: "bar-wrapper " + (this.task.custom_class || "") + (this.task.important && 'important'),
|
class: "bar-wrapper" + (this.task.custom_class ? " " + this.task.custom_class : "") + (this.task.important ? ' important' : ''),
|
||||||
"data-id": this.task.id,
|
"data-id": this.task.id,
|
||||||
});
|
});
|
||||||
this.bar_group = createSVG("g", {
|
this.bar_group = createSVG("g", {
|
||||||
|
|||||||
30
src/index.js
30
src/index.js
@ -100,7 +100,8 @@ export default class Gantt {
|
|||||||
language: "en",
|
language: "en",
|
||||||
readonly: false,
|
readonly: false,
|
||||||
highlight_weekend: true,
|
highlight_weekend: true,
|
||||||
scroll_today: true
|
scroll_today: true,
|
||||||
|
lines: 'both'
|
||||||
};
|
};
|
||||||
this.options = Object.assign({}, default_options, options);
|
this.options = Object.assign({}, default_options, options);
|
||||||
if (!options.view_mode_padding) options.view_mode_padding = {}
|
if (!options.view_mode_padding) options.view_mode_padding = {}
|
||||||
@ -132,12 +133,17 @@ export default class Gantt {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
task._end = date_utils.parse(task.end);
|
task._end = date_utils.parse(task.end);
|
||||||
|
let diff = date_utils.diff(task._end, task._start, "year");
|
||||||
|
if (diff < 0) {
|
||||||
|
console.log(task._end, task._start)
|
||||||
|
throw Error("start of task can't be after end of task: in task #, " + (i + 1))
|
||||||
|
}
|
||||||
// make task invalid if duration too large
|
// make task invalid if duration too large
|
||||||
if (date_utils.diff(task._end, task._start, "year") > 10) {
|
if (date_utils.diff(task._end, task._start, "year") > 10) {
|
||||||
task.end = null;
|
task.end = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// cache index
|
// cache index
|
||||||
task._index = i;
|
task._index = i;
|
||||||
|
|
||||||
@ -401,15 +407,16 @@ export default class Gantt {
|
|||||||
class: "grid-row",
|
class: "grid-row",
|
||||||
append_to: rows_layer,
|
append_to: rows_layer,
|
||||||
});
|
});
|
||||||
|
if (this.options.lines === 'both' || this.options.lines === 'horizontal') {
|
||||||
createSVG("line", {
|
createSVG("line", {
|
||||||
x1: 0,
|
x1: 0,
|
||||||
y1: row_y + row_height,
|
y1: row_y + row_height,
|
||||||
x2: row_width,
|
x2: row_width,
|
||||||
y2: row_y + row_height,
|
y2: row_y + row_height,
|
||||||
class: "row-line",
|
class: "row-line",
|
||||||
append_to: lines_layer,
|
append_to: lines_layer,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
row_y += this.options.bar_height + this.options.padding;
|
row_y += this.options.bar_height + this.options.padding;
|
||||||
}
|
}
|
||||||
@ -429,6 +436,7 @@ export default class Gantt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
make_grid_ticks() {
|
make_grid_ticks() {
|
||||||
|
if (this.options.lines !== 'both' && this.options.lines !== 'vertical') return
|
||||||
let tick_x = 0;
|
let tick_x = 0;
|
||||||
let tick_y = this.options.header_height + this.options.padding / 2;
|
let tick_y = this.options.header_height + this.options.padding / 2;
|
||||||
let tick_height =
|
let tick_height =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user