tg-ganttchart 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babel.config.js +5 -0
- package/package.json +1 -4
- package/src/.eslintrc.js +18 -0
- package/src/App.vue +780 -0
- package/src/GanttElastic.standalone.vue +48 -0
- package/src/GanttElastic.vue +2305 -0
- package/src/assets/logo.png +0 -0
- package/src/components/Calendar/Calendar.vue +559 -0
- package/src/components/Calendar/CalendarRow.vue +112 -0
- package/src/components/Chart/Chart.vue +117 -0
- package/src/components/Chart/DaysHighlight.vue +60 -0
- package/src/components/Chart/DependencyLines.vue +112 -0
- package/src/components/Chart/Grid.vue +205 -0
- package/src/components/Chart/ProgressBar.vue +110 -0
- package/src/components/Chart/Row/Epic.vue +131 -0
- package/src/components/Chart/Row/Milestone.vue +117 -0
- package/src/components/Chart/Row/Project.vue +132 -0
- package/src/components/Chart/Row/Story.vue +127 -0
- package/src/components/Chart/Row/Subtask.vue +117 -0
- package/src/components/Chart/Row/Task.mixin.js +47 -0
- package/src/components/Chart/Row/Task.vue +82 -0
- package/src/components/Chart/Text.vue +105 -0
- package/src/components/Expander.vue +114 -0
- package/src/components/GanttElastic.standalone.vue +48 -0
- package/src/components/GanttElastic.vue +1646 -0
- package/src/components/Header/GanttViewFilter.vue +154 -0
- package/src/components/Header/Header.vue +266 -0
- package/src/components/MainView.vue +283 -0
- package/src/components/TaskList/ItemColumn.vue +212 -0
- package/src/components/TaskList/TaskList.vue +45 -0
- package/src/components/TaskList/TaskListHeader.vue +143 -0
- package/src/components/TaskList/TaskListItem.vue +35 -0
- package/src/components/bundle.js +28 -0
- package/src/components/components/Calendar/Calendar.vue +332 -0
- package/src/components/components/Calendar/CalendarRow.vue +96 -0
- package/src/components/components/Chart/Chart.vue +111 -0
- package/src/components/components/Chart/DaysHighlight.vue +71 -0
- package/src/components/components/Chart/DependencyLines.vue +112 -0
- package/src/components/components/Chart/Grid.vue +164 -0
- package/src/components/components/Chart/ProgressBar.vue +110 -0
- package/src/components/components/Chart/Row/Milestone.vue +117 -0
- package/src/components/components/Chart/Row/Project.vue +131 -0
- package/src/components/components/Chart/Row/Task.mixin.js +46 -0
- package/src/components/components/Chart/Row/Task.vue +107 -0
- package/src/components/components/Chart/Text.vue +105 -0
- package/src/components/components/Expander.vue +126 -0
- package/src/components/components/Header/Header.vue +265 -0
- package/src/components/components/MainView.vue +282 -0
- package/src/components/components/TaskList/ItemColumn.vue +121 -0
- package/src/components/components/TaskList/TaskList.vue +45 -0
- package/src/components/components/TaskList/TaskListHeader.vue +143 -0
- package/src/components/components/TaskList/TaskListItem.vue +35 -0
- package/src/components/components/bundle.js +28 -0
- package/src/components/style.js +308 -0
- package/src/index.js +12 -0
- package/src/main.js +6 -0
- package/src/style.js +398 -0
- package/vue.config.js +42 -0
- package/dist/demo.html +0 -1
- package/dist/tgganttchart.common.js +0 -9232
- package/dist/tgganttchart.common.js.map +0 -1
- package/dist/tgganttchart.css +0 -1
- package/dist/tgganttchart.umd.js +0 -9243
- package/dist/tgganttchart.umd.js.map +0 -1
- package/dist/tgganttchart.umd.min.js +0 -7
- package/dist/tgganttchart.umd.min.js.map +0 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<g class="gantt-elastic__chart-row-bar-wrapper gantt-elastic__chart-row-task-wrapper" :style="{
|
|
3
|
+
...root.style['chart-row-bar-wrapper'],
|
|
4
|
+
...root.style['chart-row-task-wrapper'],
|
|
5
|
+
...task.style['chart-row-bar-wrapper']
|
|
6
|
+
}">
|
|
7
|
+
<foreignObject class="gantt-elastic__chart-expander gantt-elastic__chart-expander--task" :style="{
|
|
8
|
+
...root.style['chart-expander'],
|
|
9
|
+
...root.style['chart-expander--task'],
|
|
10
|
+
...task.style['chart-expander']
|
|
11
|
+
}" :x="task.x - root.state.options.chart.expander.offset - root.state.options.chart.expander.size"
|
|
12
|
+
:y="task.y + (root.state.options.row.height - root.state.options.chart.expander.size) / 2"
|
|
13
|
+
:width="root.state.options.chart.expander.size" :height="root.state.options.chart.expander.size"
|
|
14
|
+
v-if="displayExpander">
|
|
15
|
+
<expander :tasks="[task]" :options="root.state.options.chart.expander" type="chart"></expander>
|
|
16
|
+
</foreignObject>
|
|
17
|
+
<svg class="gantt-elastic__chart-row-bar gantt-elastic__chart-row-task"
|
|
18
|
+
:style="{ ...root.style['chart-row-bar'], ...root.style['chart-row-task'], ...task.style['chart-row-bar'] }"
|
|
19
|
+
:x="task.x" :y="task.y" :width="task.width" :height="task.height" :viewBox="`0 0 ${task.width} ${task.height}`"
|
|
20
|
+
@click="emitEvent('click', $event)" @mouseenter="emitEvent('mouseenter', $event)"
|
|
21
|
+
@mouseover="emitEvent('mouseover', $event)" @mouseout="emitEvent('mouseout', $event)"
|
|
22
|
+
@mousemove="emitEvent('mousemove', $event)" @mousedown="emitEvent('mousedown', $event)"
|
|
23
|
+
@mouseup="emitEvent('mouseup', $event)" @mousewheel="emitEvent('mousewheel', $event)"
|
|
24
|
+
@touchstart="emitEvent('touchstart', $event)" @touchmove="emitEvent('touchmove', $event)"
|
|
25
|
+
@touchend="emitEvent('touchend', $event)" xmlns="http://www.w3.org/2000/svg">
|
|
26
|
+
<defs>
|
|
27
|
+
<clipPath :id="clipPathId">
|
|
28
|
+
<polygon :points="getPoints"></polygon>
|
|
29
|
+
</clipPath>
|
|
30
|
+
</defs>
|
|
31
|
+
<polygon class="gantt-elastic__chart-row-bar-polygon gantt-elastic__chart-row-task-polygon" :style="{
|
|
32
|
+
...root.style['chart-row-bar-polygon'],
|
|
33
|
+
...root.style['chart-row-task-polygon'],
|
|
34
|
+
...task.style['base'],
|
|
35
|
+
...task.style['chart-row-bar-polygon']
|
|
36
|
+
}" :points="getPoints"></polygon>
|
|
37
|
+
<progress-bar :task="task" :clip-path="'url(#' + clipPathId + ')'"></progress-bar>
|
|
38
|
+
</svg>
|
|
39
|
+
<chart-text :task="task" v-if="root.state.options.chart.text.display"></chart-text>
|
|
40
|
+
</g>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
import ChartText from '../Text.vue';
|
|
45
|
+
import ProgressBar from '../ProgressBar.vue';
|
|
46
|
+
import Expander from '../../Expander.vue';
|
|
47
|
+
import taskMixin from './Task.mixin.js';
|
|
48
|
+
export default {
|
|
49
|
+
name: 'Task',
|
|
50
|
+
components: {
|
|
51
|
+
ChartText,
|
|
52
|
+
ProgressBar,
|
|
53
|
+
Expander
|
|
54
|
+
},
|
|
55
|
+
inject: ['root'],
|
|
56
|
+
props: ['task'],
|
|
57
|
+
mixins: [taskMixin],
|
|
58
|
+
data() {
|
|
59
|
+
return {};
|
|
60
|
+
},
|
|
61
|
+
computed: {
|
|
62
|
+
/**
|
|
63
|
+
* Get clip path id
|
|
64
|
+
*
|
|
65
|
+
* @returns {string}
|
|
66
|
+
*/
|
|
67
|
+
clipPathId() {
|
|
68
|
+
return 'gantt-elastic__task-clip-path-' + this.task.id;
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get points
|
|
73
|
+
*
|
|
74
|
+
* @returns {string}
|
|
75
|
+
*/
|
|
76
|
+
getPoints() {
|
|
77
|
+
const task = this.task;
|
|
78
|
+
return `0,0 ${task.width},0 ${task.width},${task.height} 0,${task.height}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
</script>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<svg
|
|
4
|
+
class="gantt-elastic__chart-row-text-wrapper"
|
|
5
|
+
:style="{ ...root.style['chart-row-text-wrapper'] }"
|
|
6
|
+
:x="task.x + task.width + root.state.options.chart.text.offset"
|
|
7
|
+
:y="task.y - root.state.options.chart.grid.horizontal.gap"
|
|
8
|
+
:width="getWidth"
|
|
9
|
+
:height="getHeight"
|
|
10
|
+
>
|
|
11
|
+
<foreignObject x="0" y="0" width="100%" :height="getHeight">
|
|
12
|
+
<div
|
|
13
|
+
xmlns="http://www.w3.org/1999/xhtml"
|
|
14
|
+
class="gantt-elastic__chart-row-text"
|
|
15
|
+
:style="{ ...root.style['chart-row-text'] }"
|
|
16
|
+
>
|
|
17
|
+
<div
|
|
18
|
+
class="gantt-elastic__chart-row-text-content gantt-elastic__chart-row-text-content--text"
|
|
19
|
+
:style="{
|
|
20
|
+
...root.style['chart-row-text-content'],
|
|
21
|
+
...root.style['chart-row-text-content--text'],
|
|
22
|
+
...contentStyle
|
|
23
|
+
}"
|
|
24
|
+
v-if="!html"
|
|
25
|
+
>
|
|
26
|
+
<div>{{ task.label }}</div>
|
|
27
|
+
</div>
|
|
28
|
+
<div
|
|
29
|
+
class="gantt-elastic__chart-row-text-content gantt-elastic__chart-row-text-content--html"
|
|
30
|
+
:style="{
|
|
31
|
+
...root.style['chart-row-text-content'],
|
|
32
|
+
...root.style['chart-row-text-content--html'],
|
|
33
|
+
...contentStyle
|
|
34
|
+
}"
|
|
35
|
+
v-if="html"
|
|
36
|
+
v-html="task.label"
|
|
37
|
+
></div>
|
|
38
|
+
</div>
|
|
39
|
+
</foreignObject>
|
|
40
|
+
</svg>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
export default {
|
|
45
|
+
name: 'ChartText',
|
|
46
|
+
inject: ['root'],
|
|
47
|
+
props: ['task'],
|
|
48
|
+
data() {
|
|
49
|
+
return {};
|
|
50
|
+
},
|
|
51
|
+
computed: {
|
|
52
|
+
/**
|
|
53
|
+
* Get width
|
|
54
|
+
*
|
|
55
|
+
* @returns {number}
|
|
56
|
+
*/
|
|
57
|
+
getWidth() {
|
|
58
|
+
const textStyle = this.root.style['chart-row-text'];
|
|
59
|
+
const font = `${textStyle['font-weight']} ${textStyle['font-size']} ${textStyle['font-family']}`;
|
|
60
|
+
this.setFont(font); // Set font in a method
|
|
61
|
+
const textWidth = this.root.state.ctx.measureText(this.task.label).width;
|
|
62
|
+
return textWidth + this.root.state.options.chart.text.xPadding * 2;
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get height
|
|
67
|
+
*
|
|
68
|
+
* @returns {number}
|
|
69
|
+
*/
|
|
70
|
+
getHeight() {
|
|
71
|
+
return this.task.height + this.root.state.options.chart.grid.horizontal.gap * 2;
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get content style
|
|
76
|
+
*
|
|
77
|
+
* @returns {object}
|
|
78
|
+
*/
|
|
79
|
+
contentStyle() {
|
|
80
|
+
return { height: '100%', 'line-height': this.getHeight + 'px' };
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Should we render text as html?
|
|
85
|
+
*
|
|
86
|
+
* @returns {boolean}
|
|
87
|
+
*/
|
|
88
|
+
html() {
|
|
89
|
+
const cols = this.root.state.options.taskList.columns;
|
|
90
|
+
for (let i = 0, len = cols.length; i < len; i++) {
|
|
91
|
+
const col = cols[i];
|
|
92
|
+
if (col.value === 'label' && typeof col.html !== 'undefined' && col.html) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
methods: {
|
|
100
|
+
setFont(font) {
|
|
101
|
+
this.root.state.ctx.font = font; // Set font in a method
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
</script>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<div :class="getClassPrefix() + '-wrapper'" :style="{ ...root.style[getClassPrefix(false) + '-wrapper'], ...style }">
|
|
4
|
+
<svg
|
|
5
|
+
:class="getClassPrefix() + '-content'"
|
|
6
|
+
:style="{ ...root.style[getClassPrefix(false) + '-content'] }"
|
|
7
|
+
:width="options.size"
|
|
8
|
+
:height="options.size"
|
|
9
|
+
v-if="allChildren.length"
|
|
10
|
+
@click="toggle"
|
|
11
|
+
viewBox="0 0 16 16"
|
|
12
|
+
>
|
|
13
|
+
<!-- Simple arrow icon for expand/collapse -->
|
|
14
|
+
<path
|
|
15
|
+
:class="getClassPrefix() + '-arrow'"
|
|
16
|
+
:style="{ ...root.style[getClassPrefix(false) + '-arrow'] }"
|
|
17
|
+
:d="collapsed ? 'M6 4 L10 8 L6 12' : 'M4 6 L8 10 L12 6'"
|
|
18
|
+
fill="none"
|
|
19
|
+
stroke="currentColor"
|
|
20
|
+
stroke-width="2"
|
|
21
|
+
stroke-linecap="round"
|
|
22
|
+
stroke-linejoin="round"
|
|
23
|
+
/>
|
|
24
|
+
</svg>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
export default {
|
|
30
|
+
name: 'Expander',
|
|
31
|
+
inject: ['root'],
|
|
32
|
+
props: ['tasks', 'options', 'type'],
|
|
33
|
+
data() {
|
|
34
|
+
const border = 0.5;
|
|
35
|
+
return {
|
|
36
|
+
border,
|
|
37
|
+
borderStyle: {
|
|
38
|
+
'stroke-width': border
|
|
39
|
+
},
|
|
40
|
+
lineOffset: 5
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
computed: {
|
|
44
|
+
style() {
|
|
45
|
+
if (this.type !== 'taskList') {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
const margin = this.root.state.options.taskList.expander.margin;
|
|
49
|
+
const padding = this.tasks[0].parents.length * this.root.state.options.taskList.expander.padding;
|
|
50
|
+
return {
|
|
51
|
+
'padding-left': padding + margin + 'px',
|
|
52
|
+
margin: 'auto 0'
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Get all tasks
|
|
57
|
+
*
|
|
58
|
+
* @returns {array}
|
|
59
|
+
*/
|
|
60
|
+
allChildren() {
|
|
61
|
+
const children = [];
|
|
62
|
+
this.tasks.forEach(task => {
|
|
63
|
+
task.allChildren.forEach(childId => {
|
|
64
|
+
children.push(childId);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
return children;
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Is current expander collapsed?
|
|
71
|
+
*
|
|
72
|
+
* @returns {boolean}
|
|
73
|
+
*/
|
|
74
|
+
collapsed() {
|
|
75
|
+
if (this.tasks.length === 0) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
let collapsed = 0;
|
|
79
|
+
for (let i = 0, len = this.tasks.length; i < len; i++) {
|
|
80
|
+
if (this.tasks[i].collapsed) {
|
|
81
|
+
collapsed++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return collapsed === this.tasks.length;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
methods: {
|
|
88
|
+
/**
|
|
89
|
+
* Get specific class prefix
|
|
90
|
+
*
|
|
91
|
+
* @returns {string}
|
|
92
|
+
*/
|
|
93
|
+
getClassPrefix(full = true) {
|
|
94
|
+
return `${full ? 'gantt-elastic__' : ''}${this.options.type}-expander`;
|
|
95
|
+
},
|
|
96
|
+
/**
|
|
97
|
+
* Toggle expander
|
|
98
|
+
*/
|
|
99
|
+
toggle() {
|
|
100
|
+
if (this.tasks.length === 0) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const collapsed = !this.collapsed;
|
|
104
|
+
this.tasks.forEach(task => {
|
|
105
|
+
task.collapsed = collapsed;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Force reactivity update
|
|
109
|
+
this.$forceUpdate();
|
|
110
|
+
this.root.$forceUpdate();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
</script>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<gantt-elastic :tasks="tasks" :options="options" :dynamicStyle="dynamicStyle">
|
|
3
|
+
<component v-if="components.header" :is="components.header" slot="header"></component>
|
|
4
|
+
<component v-if="components.footer" :is="components.footer" slot="footer"></component>
|
|
5
|
+
</gantt-elastic>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import GanttElastic from './GanttElastic.vue';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
name: 'GanttElasticStandalone',
|
|
13
|
+
components: {
|
|
14
|
+
'gantt-elastic': GanttElastic,
|
|
15
|
+
},
|
|
16
|
+
props: {
|
|
17
|
+
// Props to receive from parent
|
|
18
|
+
tasks: {
|
|
19
|
+
type: Array,
|
|
20
|
+
default: () => [],
|
|
21
|
+
},
|
|
22
|
+
options: {
|
|
23
|
+
type: Object,
|
|
24
|
+
default: () => ({}),
|
|
25
|
+
},
|
|
26
|
+
dynamicStyle: {
|
|
27
|
+
type: Object,
|
|
28
|
+
default: () => ({}),
|
|
29
|
+
},
|
|
30
|
+
header: {
|
|
31
|
+
type: Object,
|
|
32
|
+
default: () => ({}),
|
|
33
|
+
},
|
|
34
|
+
footer: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: () => ({}),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
components: {
|
|
42
|
+
header: this.header,
|
|
43
|
+
footer: this.footer,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
</script>
|