ability to specify custom class for tasks
This commit is contained in:
parent
4534f6b6fe
commit
407f076d51
43
index.html
43
index.html
@ -1,9 +1,9 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Simple Gantt</title>
|
<title>Simple Gantt</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
background: #ccc;
|
background: #ccc;
|
||||||
@ -15,13 +15,17 @@
|
|||||||
.gantt-container {
|
.gantt-container {
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
/* custom class */
|
||||||
|
.gantt .bar-milestone .bar-progress {
|
||||||
|
fill: tomato;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src="node_modules/moment/min/moment.min.js"></script>
|
<script src="node_modules/moment/min/moment.min.js"></script>
|
||||||
<script src="node_modules/snapsvg/dist/snap.svg-min.js"></script>
|
<script src="node_modules/snapsvg/dist/snap.svg-min.js"></script>
|
||||||
<script src="dist/frappe-gantt.js"></script>
|
<script src="dist/frappe-gantt.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Interactive Gantt Chart entirely made in SVG!</h2>
|
<h2>Interactive Gantt Chart entirely made in SVG!</h2>
|
||||||
<div class="gantt-container">
|
<div class="gantt-container">
|
||||||
<svg id="gantt" width="400" height="600"></svg>
|
<svg id="gantt" width="400" height="600"></svg>
|
||||||
@ -56,21 +60,22 @@
|
|||||||
tasks[2].dependencies = "Task 1"
|
tasks[2].dependencies = "Task 1"
|
||||||
tasks[3].dependencies = "Task 2"
|
tasks[3].dependencies = "Task 2"
|
||||||
tasks[5].dependencies = "Task 4"
|
tasks[5].dependencies = "Task 4"
|
||||||
|
tasks[5].custom_class = "bar-milestone";
|
||||||
|
|
||||||
var gantt_chart = Gantt("#gantt", tasks, {
|
var gantt_chart = Gantt("#gantt", tasks, {
|
||||||
on_click: function (task) {
|
on_click: function (task) {
|
||||||
console.log(task);
|
console.log(task);
|
||||||
},
|
},
|
||||||
on_date_change: function(task, start, end) {
|
on_date_change: function(task, start, end) {
|
||||||
console.log(task, start, end);
|
console.log(task, start, end);
|
||||||
},
|
},
|
||||||
on_progress_change: function(task, progress) {
|
on_progress_change: function(task, progress) {
|
||||||
console.log(task, progress);
|
console.log(task, progress);
|
||||||
},
|
},
|
||||||
on_view_change: function(mode) {
|
on_view_change: function(mode) {
|
||||||
console.log(mode);
|
console.log(mode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(gantt_chart);
|
console.log(gantt_chart);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -37,7 +37,7 @@ export default function Bar(gt, task) {
|
|||||||
self.duration = (self.task._end.diff(self.task._start, 'hours') + 24) / gt.config.step;
|
self.duration = (self.task._end.diff(self.task._start, 'hours') + 24) / gt.config.step;
|
||||||
self.width = gt.config.column_width * self.duration;
|
self.width = gt.config.column_width * self.duration;
|
||||||
self.progress_width = gt.config.column_width * self.duration * (self.task.progress / 100) || 0;
|
self.progress_width = gt.config.column_width * self.duration * (self.task.progress / 100) || 0;
|
||||||
self.group = gt.canvas.group().addClass('bar-wrapper');
|
self.group = gt.canvas.group().addClass('bar-wrapper').addClass(self.task.custom_class || '');
|
||||||
self.bar_group = gt.canvas.group().addClass('bar-group').appendTo(self.group);
|
self.bar_group = gt.canvas.group().addClass('bar-group').appendTo(self.group);
|
||||||
self.handle_group = gt.canvas.group().addClass('handle-group').appendTo(self.group);
|
self.handle_group = gt.canvas.group().addClass('handle-group').appendTo(self.group);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Gantt:
|
* Gantt:
|
||||||
* element: querySelector string, required
|
* element: querySelector string, required
|
||||||
* tasks: array of tasks, required
|
* tasks: array of tasks, required
|
||||||
* task: { id, name, start, end, progress, dependencies }
|
* task: { id, name, start, end, progress, dependencies, custom_class }
|
||||||
* config: configuration options, optional
|
* config: configuration options, optional
|
||||||
*/
|
*/
|
||||||
import './gantt.scss';
|
import './gantt.scss';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user