Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some comments on code #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export default class Gantt {
this.options = Object.assign({}, default_options, options);
}

/**
* Set x._start, x._end, x._index for each task
* May set x.id, x.invalid, x.dependencies
*/
setup_tasks(tasks) {
// prepare tasks
this.tasks = tasks.map((task, i) => {
Expand Down Expand Up @@ -156,6 +160,9 @@ export default class Gantt {
this.setup_dependencies();
}

/**
* Set this.dependency_map
*/
setup_dependencies() {
this.dependency_map = {};
for (let t of this.tasks) {
Expand All @@ -179,6 +186,10 @@ export default class Gantt {
this.trigger_event('view_change', [mode]);
}

/**
* Set this.options.view_mode, this.options.step and this.options.column_width
* according to view_mode
*/
update_view_scale(view_mode) {
this.options.view_mode = view_mode;

Expand Down Expand Up @@ -208,6 +219,9 @@ export default class Gantt {
this.setup_date_values();
}

/**
* Set this.gantt_start and this.gantt_end
*/
setup_gantt_dates() {
this.gantt_start = this.gantt_end = null;

Expand Down Expand Up @@ -240,6 +254,9 @@ export default class Gantt {
}
}

/**
* Set this.dates
*/
setup_date_values() {
this.dates = [];
let cur_date = null;
Expand Down Expand Up @@ -439,6 +456,9 @@ export default class Gantt {
}
}

/**
* Render month names, day numbers, hours on diagram
*/
make_dates() {
for (let date of this.get_dates_to_draw()) {
createSVG('text', {
Expand Down Expand Up @@ -562,6 +582,9 @@ export default class Gantt {
};
}

/**
* Render task bars on diagram
*/
make_bars() {
this.bars = this.tasks.map(task => {
const bar = new Bar(this, task);
Expand All @@ -570,6 +593,9 @@ export default class Gantt {
});
}

/**
* Render dependency arrows on diagram
*/
make_arrows() {
this.arrows = [];
for (let task of this.tasks) {
Expand Down Expand Up @@ -602,6 +628,9 @@ export default class Gantt {
}
}

/**
* Set svg rect. Scrollbars will appear.
*/
set_width() {
const cur_width = this.$svg.getBoundingClientRect().width;
const actual_width = this.$svg
Expand Down