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,117 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<div class="gantt-elastic__chart" :style="{ ...root.style['chart'] }" ref="chart">
|
|
4
|
+
<div
|
|
5
|
+
class="gantt-elastic__chart-calendar-container"
|
|
6
|
+
ref="chartCalendarContainer"
|
|
7
|
+
:style="{
|
|
8
|
+
...root.style['chart-calendar-container'],
|
|
9
|
+
height: root.state.options.calendar.height + 'px',
|
|
10
|
+
'margin-bottom': root.state.options.calendar.gap + 'px'
|
|
11
|
+
}"
|
|
12
|
+
>
|
|
13
|
+
<calendar></calendar>
|
|
14
|
+
</div>
|
|
15
|
+
<div
|
|
16
|
+
class="gantt-elastic__chart-graph-container"
|
|
17
|
+
ref="chartGraphContainer"
|
|
18
|
+
:style="{
|
|
19
|
+
...root.style['chart-graph-container'],
|
|
20
|
+
height: root.state.options.height - root.state.options.calendar.height + 'px'
|
|
21
|
+
}"
|
|
22
|
+
>
|
|
23
|
+
<div
|
|
24
|
+
:style="{
|
|
25
|
+
...root.style['chart-area'],
|
|
26
|
+
width: root.state.options.width + 'px',
|
|
27
|
+
height: root.state.options.rowsHeight + 'px'
|
|
28
|
+
}"
|
|
29
|
+
>
|
|
30
|
+
<div
|
|
31
|
+
class="gantt-elastic__chart-graph"
|
|
32
|
+
ref="chartGraph"
|
|
33
|
+
:style="{ ...root.style['chart-graph'], height: '100%' }"
|
|
34
|
+
>
|
|
35
|
+
<svg
|
|
36
|
+
class="gantt-elastic__chart-graph-svg"
|
|
37
|
+
:style="{ ...root.style['chart-graph-svg'] }"
|
|
38
|
+
ref="chartGraphSvg"
|
|
39
|
+
x="0"
|
|
40
|
+
y="0"
|
|
41
|
+
:width="root.state.options.width + 'px'"
|
|
42
|
+
:height="root.state.options.allVisibleTasksHeight + 'px'"
|
|
43
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
44
|
+
>
|
|
45
|
+
<days-highlight></days-highlight>
|
|
46
|
+
<grid></grid>
|
|
47
|
+
<dependency-lines :tasks="root.visibleTasks"></dependency-lines>
|
|
48
|
+
<g
|
|
49
|
+
class="gantt-elastic__chart-row-wrapper"
|
|
50
|
+
:style="{ ...root.style['chart-row-wrapper'] }"
|
|
51
|
+
v-for="task in root.visibleTasks"
|
|
52
|
+
:task="task"
|
|
53
|
+
:key="task.id"
|
|
54
|
+
>
|
|
55
|
+
<component :task="task" :is="task.type"></component>
|
|
56
|
+
</g>
|
|
57
|
+
</svg>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<script>
|
|
65
|
+
import Grid from './Grid.vue';
|
|
66
|
+
import DaysHighlight from './DaysHighlight.vue';
|
|
67
|
+
import Calendar from '../Calendar/Calendar.vue';
|
|
68
|
+
import DependencyLines from './DependencyLines.vue';
|
|
69
|
+
import Task from './Row/Task.vue';
|
|
70
|
+
import Milestone from './Row/Milestone.vue';
|
|
71
|
+
import Project from './Row/Project.vue';
|
|
72
|
+
import Epic from './Row/Epic.vue';
|
|
73
|
+
import Subtask from './Row/Subtask.vue';
|
|
74
|
+
import Story from './Row/Story.vue';
|
|
75
|
+
export default {
|
|
76
|
+
name: 'Chart',
|
|
77
|
+
components: {
|
|
78
|
+
Grid,
|
|
79
|
+
DependencyLines,
|
|
80
|
+
Calendar,
|
|
81
|
+
task: Task,
|
|
82
|
+
milestone: Milestone,
|
|
83
|
+
project: Project,
|
|
84
|
+
epic: Epic,
|
|
85
|
+
subtask: Subtask,
|
|
86
|
+
story: Story,
|
|
87
|
+
DaysHighlight
|
|
88
|
+
},
|
|
89
|
+
inject: ['root'],
|
|
90
|
+
data() {
|
|
91
|
+
return {
|
|
92
|
+
moving: false
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* Mounted
|
|
97
|
+
*/
|
|
98
|
+
mounted() {
|
|
99
|
+
this.root.state.refs.chart = this.$refs.chart;
|
|
100
|
+
this.root.state.refs.chartCalendarContainer = this.$refs.chartCalendarContainer;
|
|
101
|
+
this.root.state.refs.chartGraphContainer = this.$refs.chartGraphContainer;
|
|
102
|
+
this.root.state.refs.chartGraph = this.$refs.chartGraph;
|
|
103
|
+
this.root.state.refs.chartGraphSvg = this.$refs.chartGraphSvg;
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
computed: {
|
|
107
|
+
/**
|
|
108
|
+
* Get view box
|
|
109
|
+
*
|
|
110
|
+
* @returns {string}
|
|
111
|
+
*/
|
|
112
|
+
getViewBox() {
|
|
113
|
+
return `0 0 ${this.root.state.options.width} ${this.root.state.options.allVisibleTasksHeight}`;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
</script>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<g class="gantt-elastic__chart-days-highlight-container" :style="{ ...root.style['chart-days-highlight-container'] }"
|
|
3
|
+
v-if="showWorkingDays">
|
|
4
|
+
<rect class="gantt-elastic__chart-days-highlight-rect" v-for="day in workingDays" :key="getKey(day)"
|
|
5
|
+
:x="day.offset.px" y="0" :width="day.width.px" height="100%"
|
|
6
|
+
:style="{ ...root.style['chart-days-highlight-rect'] }"></rect>
|
|
7
|
+
</g>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import dayjs from 'dayjs';
|
|
12
|
+
export default {
|
|
13
|
+
name: 'DaysHighlight',
|
|
14
|
+
inject: ['root'],
|
|
15
|
+
data() {
|
|
16
|
+
return {};
|
|
17
|
+
},
|
|
18
|
+
methods: {
|
|
19
|
+
/**
|
|
20
|
+
* Get key
|
|
21
|
+
*
|
|
22
|
+
* @param {object} day
|
|
23
|
+
* @returns {string} key ideintifier for loop
|
|
24
|
+
*/
|
|
25
|
+
getKey(day) {
|
|
26
|
+
// Return the full date-time format
|
|
27
|
+
return dayjs(day.time).format('YYYY-MM-DD HH:mm');
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
computed: {
|
|
31
|
+
/**
|
|
32
|
+
* Get working days
|
|
33
|
+
*
|
|
34
|
+
* @returns {array}
|
|
35
|
+
*/
|
|
36
|
+
workingDays() {
|
|
37
|
+
return this.root.state.options.times.steps.filter(step => {
|
|
38
|
+
return this.root.state.options.calendar.workingDays.indexOf(dayjs(step.time).day()) === -1;
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Show working days?
|
|
44
|
+
*
|
|
45
|
+
* @returns {bool}
|
|
46
|
+
*/
|
|
47
|
+
showWorkingDays() {
|
|
48
|
+
const calendar = this.root.state.options.calendar;
|
|
49
|
+
if (
|
|
50
|
+
typeof calendar.workingDays !== 'undefined' &&
|
|
51
|
+
Array.isArray(calendar.workingDays) &&
|
|
52
|
+
calendar.workingDays.length
|
|
53
|
+
) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
</script>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<svg
|
|
4
|
+
x="0"
|
|
5
|
+
y="0"
|
|
6
|
+
width="100%"
|
|
7
|
+
height="100%"
|
|
8
|
+
class="gantt-elastic__chart-dependency-lines-container"
|
|
9
|
+
:style="{ ...root.style['chart-dependency-lines-container'] }"
|
|
10
|
+
>
|
|
11
|
+
<g v-for="task in dependencyTasks" :key="task.id" :task="task">
|
|
12
|
+
<path
|
|
13
|
+
class="gantt-elastic__chart-dependency-lines-path"
|
|
14
|
+
:style="{ ...root.style['chart-dependency-lines-path'], ...task.style['chart-dependency-lines-path'], ...task.style['chart-dependency-lines-path-' + dependencyLine.task_id] }"
|
|
15
|
+
v-for="dependencyLine in task.dependencyLines"
|
|
16
|
+
:key="dependencyLine.id"
|
|
17
|
+
:task="task"
|
|
18
|
+
:d="dependencyLine.points"
|
|
19
|
+
></path>
|
|
20
|
+
</g>
|
|
21
|
+
</svg>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
export default {
|
|
26
|
+
name: 'DependencyLines',
|
|
27
|
+
inject: ['root'],
|
|
28
|
+
props: ['tasks'],
|
|
29
|
+
data() {
|
|
30
|
+
return {};
|
|
31
|
+
},
|
|
32
|
+
methods: {
|
|
33
|
+
/**
|
|
34
|
+
* Get path points
|
|
35
|
+
*
|
|
36
|
+
* @param {any} fromTaskId
|
|
37
|
+
* @param {any} toTaskId
|
|
38
|
+
* @returns {string}
|
|
39
|
+
*/
|
|
40
|
+
getPoints(fromTaskId, toTaskId) {
|
|
41
|
+
const fromTask = this.root.getTask(fromTaskId);
|
|
42
|
+
const toTask = this.root.getTask(toTaskId);
|
|
43
|
+
if (
|
|
44
|
+
fromTask === null ||
|
|
45
|
+
toTask === null ||
|
|
46
|
+
!this.root.isTaskVisible(toTask) ||
|
|
47
|
+
!this.root.isTaskVisible(fromTask)
|
|
48
|
+
) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const startX = fromTask.x + fromTask.width;
|
|
52
|
+
const startY = fromTask.y + fromTask.height / 2;
|
|
53
|
+
const stopX = toTask.x;
|
|
54
|
+
const stopY = toTask.y + toTask.height / 2;
|
|
55
|
+
const distanceX = stopX - startX;
|
|
56
|
+
let distanceY;
|
|
57
|
+
let yMultiplier = 1;
|
|
58
|
+
if (stopY >= startY) {
|
|
59
|
+
distanceY = stopY - startY;
|
|
60
|
+
} else {
|
|
61
|
+
distanceY = startY - stopY;
|
|
62
|
+
yMultiplier = -1;
|
|
63
|
+
}
|
|
64
|
+
const offset = 10;
|
|
65
|
+
const roundness = 4;
|
|
66
|
+
const isBefore = distanceX <= offset + roundness;
|
|
67
|
+
let points = `M ${startX} ${startY}
|
|
68
|
+
L ${startX + offset},${startY} `;
|
|
69
|
+
if (isBefore) {
|
|
70
|
+
points += `Q ${startX + offset + roundness},${startY} ${startX + offset + roundness},${startY +
|
|
71
|
+
roundness * yMultiplier}
|
|
72
|
+
L ${startX + offset + roundness},${startY + (distanceY * yMultiplier) / 2 - roundness * yMultiplier}
|
|
73
|
+
Q ${startX + offset + roundness},${startY + (distanceY * yMultiplier) / 2} ${startX + offset},${startY +
|
|
74
|
+
(distanceY * yMultiplier) / 2}
|
|
75
|
+
L ${startX - offset + distanceX},${startY + (distanceY * yMultiplier) / 2}
|
|
76
|
+
Q ${startX - offset + distanceX - roundness},${startY + (distanceY * yMultiplier) / 2} ${startX -
|
|
77
|
+
offset +
|
|
78
|
+
distanceX -
|
|
79
|
+
roundness},${startY + (distanceY * yMultiplier) / 2 + roundness * yMultiplier}
|
|
80
|
+
L ${startX - offset + distanceX - roundness},${stopY - roundness * yMultiplier}
|
|
81
|
+
Q ${startX - offset + distanceX - roundness},${stopY} ${startX - offset + distanceX},${stopY}
|
|
82
|
+
L ${stopX},${stopY}`;
|
|
83
|
+
} else {
|
|
84
|
+
points += `L ${startX + distanceX / 2 - roundness},${startY}
|
|
85
|
+
Q ${startX + distanceX / 2},${startY} ${startX + distanceX / 2},${startY + roundness * yMultiplier}
|
|
86
|
+
L ${startX + distanceX / 2},${stopY - roundness * yMultiplier}
|
|
87
|
+
Q ${startX + distanceX / 2},${stopY} ${startX + distanceX / 2 + roundness},${stopY}
|
|
88
|
+
L ${stopX},${stopY}`;
|
|
89
|
+
}
|
|
90
|
+
return points;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
computed: {
|
|
94
|
+
/**
|
|
95
|
+
* Get tasks which are dependent on other tasks
|
|
96
|
+
*
|
|
97
|
+
* @returns {array}
|
|
98
|
+
*/
|
|
99
|
+
dependencyTasks() {
|
|
100
|
+
return this.tasks
|
|
101
|
+
.filter(task => typeof task.dependentOn !== 'undefined')
|
|
102
|
+
.map(task => {
|
|
103
|
+
task.dependencyLines = task.dependentOn.map(id => {
|
|
104
|
+
return { points: this.getPoints(id, task.id), task_id: id };
|
|
105
|
+
});
|
|
106
|
+
return task;
|
|
107
|
+
})
|
|
108
|
+
.filter(task => task.dependencyLines.points !== null);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
</script>
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<svg
|
|
4
|
+
class="gantt-elastic__grid-lines-wrapper"
|
|
5
|
+
:style="{ ...root.style['grid-lines-wrapper'] }"
|
|
6
|
+
ref="chart"
|
|
7
|
+
x="0"
|
|
8
|
+
y="0"
|
|
9
|
+
:width="root.state.options.width"
|
|
10
|
+
:height="root.state.options.allVisibleTasksHeight"
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
>
|
|
13
|
+
<g class="gantt-elastic__grid-lines" :style="{ ...root.style['grid-lines'] }">
|
|
14
|
+
<line
|
|
15
|
+
class="gantt-elastic__grid-line-horizontal"
|
|
16
|
+
:style="{ ...root.style['grid-line-horizontal'] }"
|
|
17
|
+
v-for="line in horizontalLines"
|
|
18
|
+
:key="line.key"
|
|
19
|
+
:x1="line.x1"
|
|
20
|
+
:y1="line.y1"
|
|
21
|
+
:x2="line.x2"
|
|
22
|
+
:y2="line.y2"
|
|
23
|
+
></line>
|
|
24
|
+
<line
|
|
25
|
+
class="gantt-elastic__grid-line-vertical"
|
|
26
|
+
:style="{ ...root.style['grid-line-vertical'] }"
|
|
27
|
+
v-for="line in verticalLines"
|
|
28
|
+
:key="line.key"
|
|
29
|
+
:x1="line.x1"
|
|
30
|
+
:y1="line.y1"
|
|
31
|
+
:x2="line.x2"
|
|
32
|
+
:y2="line.y2"
|
|
33
|
+
></line>
|
|
34
|
+
<line
|
|
35
|
+
class="gantt-elastic__grid-line-time"
|
|
36
|
+
:style="{ ...root.style['grid-line-time'] }"
|
|
37
|
+
:x1="timeLinePosition.x"
|
|
38
|
+
:y1="timeLinePosition.y1"
|
|
39
|
+
:x2="timeLinePosition.x"
|
|
40
|
+
:y2="timeLinePosition.y2"
|
|
41
|
+
></line>
|
|
42
|
+
</g>
|
|
43
|
+
</svg>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
export default {
|
|
48
|
+
name: 'Grid',
|
|
49
|
+
inject: ['root'],
|
|
50
|
+
data() {
|
|
51
|
+
return {};
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Created
|
|
55
|
+
*/
|
|
56
|
+
created() {
|
|
57
|
+
this.root.$on('recenterPosition', this.recenterPosition);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Mounted
|
|
62
|
+
*/
|
|
63
|
+
mounted() {
|
|
64
|
+
this.$nextTick(() => {
|
|
65
|
+
this.$nextTick(() => {
|
|
66
|
+
// because of stupid slider :/
|
|
67
|
+
this.root.scrollToTime(this.timeLinePosition.time);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
methods: {
|
|
73
|
+
/**
|
|
74
|
+
* Recenter position - go to current time line
|
|
75
|
+
*/
|
|
76
|
+
recenterPosition() {
|
|
77
|
+
this.root.scrollToTime(this.timeLinePosition.time);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
computed: {
|
|
82
|
+
/**
|
|
83
|
+
* Generate vertical lines of the grid
|
|
84
|
+
*
|
|
85
|
+
* @returns {array}
|
|
86
|
+
*/
|
|
87
|
+
verticalLines() {
|
|
88
|
+
let lines = [];
|
|
89
|
+
const state = this.root.state;
|
|
90
|
+
|
|
91
|
+
// Add grid lines for all steps (remove viewport check to ensure all borders are drawn)
|
|
92
|
+
state.options.times.steps.forEach((step, index) => {
|
|
93
|
+
// Only generate grid lines for steps with valid coordinates
|
|
94
|
+
if (step.offset && typeof step.offset.px === 'number' && !isNaN(step.offset.px)) {
|
|
95
|
+
const line = {
|
|
96
|
+
key: step.time,
|
|
97
|
+
x1: Math.round(step.offset.px), // Round to ensure exact pixel alignment
|
|
98
|
+
y1: 0,
|
|
99
|
+
x2: Math.round(step.offset.px), // Round to ensure exact pixel alignment
|
|
100
|
+
y2:
|
|
101
|
+
state.tasks.length * (state.options.row.height + state.options.chart.grid.horizontal.gap * 2) +
|
|
102
|
+
this.root.style['grid-line-vertical']['stroke-width']
|
|
103
|
+
};
|
|
104
|
+
lines.push(line);
|
|
105
|
+
|
|
106
|
+
// Debug: Log grid lines for quarter view
|
|
107
|
+
if (state.options.times.stepDuration === 'quarter') {
|
|
108
|
+
console.log(`Grid Line ${index}:`, {
|
|
109
|
+
x: line.x1,
|
|
110
|
+
time: new Date(step.time).toISOString().split('T')[0],
|
|
111
|
+
quarter: new Date(step.time).getMonth() < 3 ? 1 : new Date(step.time).getMonth() < 6 ? 2 : new Date(step.time).getMonth() < 9 ? 3 : 4,
|
|
112
|
+
stepWidth: step.width?.px || 0,
|
|
113
|
+
stepOffset: step.offset?.px || 0,
|
|
114
|
+
hasValidX: line.x1 >= 0 && !isNaN(line.x1)
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
// Debug: Log steps that are being skipped
|
|
119
|
+
if (state.options.times.stepDuration === 'quarter') {
|
|
120
|
+
console.log(`Skipped Grid Line ${index}:`, {
|
|
121
|
+
time: new Date(step.time).toISOString().split('T')[0],
|
|
122
|
+
offset: step.offset,
|
|
123
|
+
hasValidOffset: !!(step.offset && typeof step.offset.px === 'number' && !isNaN(step.offset.px))
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// Add final grid line at the end of the chart area to eliminate empty space
|
|
130
|
+
const lastStep = state.options.times.steps[state.options.times.steps.length - 1];
|
|
131
|
+
if (lastStep) {
|
|
132
|
+
const finalX = Math.round(lastStep.offset.px + lastStep.width.px);
|
|
133
|
+
lines.push({
|
|
134
|
+
key: 'final-line',
|
|
135
|
+
x1: finalX,
|
|
136
|
+
y1: 0,
|
|
137
|
+
x2: finalX,
|
|
138
|
+
y2:
|
|
139
|
+
state.tasks.length * (state.options.row.height + state.options.chart.grid.horizontal.gap * 2) +
|
|
140
|
+
this.root.style['grid-line-vertical']['stroke-width']
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return lines;
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Generate horizontal lines of the grid
|
|
149
|
+
*
|
|
150
|
+
* @returns {array}
|
|
151
|
+
*/
|
|
152
|
+
horizontalLines() {
|
|
153
|
+
let lines = [];
|
|
154
|
+
const state = this.root.state.options;
|
|
155
|
+
let tasks = this.root.visibleTasks;
|
|
156
|
+
for (let index = 0, len = tasks.length; index <= len; index++) {
|
|
157
|
+
const y =
|
|
158
|
+
index * (state.row.height + state.chart.grid.horizontal.gap * 2) +
|
|
159
|
+
this.root.style['grid-line-vertical']['stroke-width'] / 2;
|
|
160
|
+
lines.push({
|
|
161
|
+
key: 'hl' + index,
|
|
162
|
+
x1: 0,
|
|
163
|
+
y1: y,
|
|
164
|
+
x2: '100%',
|
|
165
|
+
y2: y
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
return lines;
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Check if specified line is inside viewport (visible)
|
|
173
|
+
*
|
|
174
|
+
* @returns {function}
|
|
175
|
+
*/
|
|
176
|
+
inViewPort() {
|
|
177
|
+
return line => {
|
|
178
|
+
const state = this.root.state.options;
|
|
179
|
+
return line.x1 >= state.scroll.chart.left && line.x1 <= state.scroll.chart.right;
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Get current time line position
|
|
185
|
+
*
|
|
186
|
+
* @returns {object}
|
|
187
|
+
*/
|
|
188
|
+
timeLinePosition() {
|
|
189
|
+
const d = new Date();
|
|
190
|
+
const current = d.getTime();
|
|
191
|
+
const currentOffset = this.root.timeToPixelOffsetX(current);
|
|
192
|
+
const timeLine = {
|
|
193
|
+
x: 0,
|
|
194
|
+
y1: 0,
|
|
195
|
+
y2: '100%',
|
|
196
|
+
dateTime: '',
|
|
197
|
+
time: current
|
|
198
|
+
};
|
|
199
|
+
timeLine.x = currentOffset;
|
|
200
|
+
timeLine.dateTime = d.toLocaleDateString();
|
|
201
|
+
return timeLine;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
</script>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
|
|
2
|
+
<template>
|
|
3
|
+
<g
|
|
4
|
+
class="gantt-elastic__chart-row-progress-bar-wrapper"
|
|
5
|
+
:style="{ ...root.style['chart-row-progress-bar-wrapper'], ...task.style['chart-row-progress-bar-wrapper'] }"
|
|
6
|
+
>
|
|
7
|
+
<defs>
|
|
8
|
+
<pattern
|
|
9
|
+
id="diagonalHatch"
|
|
10
|
+
:width="root.state.options.chart.progress.width"
|
|
11
|
+
:height="root.state.options.chart.progress.width"
|
|
12
|
+
patternTransform="rotate(45 0 0)"
|
|
13
|
+
patternUnits="userSpaceOnUse"
|
|
14
|
+
>
|
|
15
|
+
<line
|
|
16
|
+
class="chart-row-progress-bar-line"
|
|
17
|
+
:style="{ ...root.style['chart-row-progress-bar-line'], ...task.style['chart-row-progress-bar-line'] }"
|
|
18
|
+
x1="0"
|
|
19
|
+
y1="0"
|
|
20
|
+
x2="0"
|
|
21
|
+
:y2="root.state.options.chart.progress.width"
|
|
22
|
+
/>
|
|
23
|
+
</pattern>
|
|
24
|
+
</defs>
|
|
25
|
+
<rect
|
|
26
|
+
v-if="root.state.options.chart.progress.bar"
|
|
27
|
+
class="gantt-elastic__chart-row-progress-bar-solid"
|
|
28
|
+
:style="{ ...root.style['chart-row-progress-bar-solid'], ...task.style['chart-row-progress-bar-solid'] }"
|
|
29
|
+
x="0"
|
|
30
|
+
y="0"
|
|
31
|
+
:width="getProgressWidth"
|
|
32
|
+
></rect>
|
|
33
|
+
<g v-if="root.state.options.chart.progress.pattern">
|
|
34
|
+
<rect
|
|
35
|
+
class="gantt-elastic__chart-row-progress-bar-pattern"
|
|
36
|
+
:style="{ ...root.style['chart-row-progress-bar-pattern'], ...task.style['chart-row-progress-bar-pattern'] }"
|
|
37
|
+
:x="getProgressWidth"
|
|
38
|
+
y="0"
|
|
39
|
+
:width="100 - task.progress + '%'"
|
|
40
|
+
height="100%"
|
|
41
|
+
></rect>
|
|
42
|
+
<path
|
|
43
|
+
class="gantt-elastic__chart-row-progress-bar-outline"
|
|
44
|
+
:style="{
|
|
45
|
+
...root.style['chart-row-progress-bar-outline'],
|
|
46
|
+
...task.style['base'],
|
|
47
|
+
...task.style['chart-row-progress-bar-outline']
|
|
48
|
+
}"
|
|
49
|
+
:d="getLinePoints"
|
|
50
|
+
></path>
|
|
51
|
+
</g>
|
|
52
|
+
</g>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
export default {
|
|
57
|
+
name: 'ProgressBar',
|
|
58
|
+
inject: ['root'],
|
|
59
|
+
props: ['task'],
|
|
60
|
+
data() {
|
|
61
|
+
return {};
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
computed: {
|
|
65
|
+
/**
|
|
66
|
+
* Get progress width
|
|
67
|
+
*
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
getProgressWidth() {
|
|
71
|
+
return this.task.progress + '%';
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get line points
|
|
76
|
+
*
|
|
77
|
+
* @returns {string}
|
|
78
|
+
*/
|
|
79
|
+
getLinePoints() {
|
|
80
|
+
const start = (this.task.width / 100) * this.task.progress;
|
|
81
|
+
return `M ${start} 0 L ${start} ${this.task.height}`;
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get solid style
|
|
86
|
+
*
|
|
87
|
+
* @returns {object}
|
|
88
|
+
*/
|
|
89
|
+
getSolidStyle() {
|
|
90
|
+
return Object.assign({}, this.root.state.options.chart.progress.styles.bar.solid, this.task.progressBarStyle.bar);
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get line style
|
|
95
|
+
*
|
|
96
|
+
* @returns {object}
|
|
97
|
+
*/
|
|
98
|
+
getLineStyle() {
|
|
99
|
+
return Object.assign(
|
|
100
|
+
{},
|
|
101
|
+
{
|
|
102
|
+
stroke: this.root.state.options.row.styles.bar.stroke + 'a0',
|
|
103
|
+
'stroke-width': this.root.state.options.row.styles.bar['stroke-width'] / 2
|
|
104
|
+
},
|
|
105
|
+
this.task.style
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
</script>
|