• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

worktile / ngx-gantt / 30b6f0fd-8be6-4f56-81ac-1a22b8b3608e

17 Aug 2023 08:26AM UTC coverage: 72.137% (+0.6%) from 71.511%
30b6f0fd-8be6-4f56-81ac-1a22b8b3608e

push

circleci

web-flow
Merge pull request #414 from worktile/bumpAngular16

build: bump angular 16 #INFR-9186

342 of 593 branches covered (57.67%)

Branch coverage included in aggregate %.

1403 of 1826 relevant lines covered (76.83%)

862.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.47
/packages/gantt/src/views/test/custom-view.mock.ts
1
import {
2
    GanttView,
3
    GanttViewOptions,
4
    primaryDatePointTop,
5
    secondaryDatePointTop,
6
    GanttViewDate,
7
    GanttDate,
8
    eachDayOfInterval,
9
    GanttDatePoint,
10
    GanttViewType
11
} from 'ngx-gantt';
12

13
const viewOptions: GanttViewOptions = {
1✔
14
    cellWidth: 50,
15
    start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
16
    end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
17
    addAmount: 1,
18
    addUnit: 'month'
19
};
20

21
export class GanttViewCustom extends GanttView {
22
    override showWeekBackdrop = true;
1✔
23

24
    override showTimeline = true;
1✔
25

26
    override viewType = GanttViewType.day;
1✔
27

28
    constructor(start: GanttViewDate, end: GanttViewDate, options?: GanttViewOptions) {
29
        super(start, end, Object.assign({}, viewOptions, options));
1✔
30
    }
31

32
    startOf(date: GanttDate) {
33
        return date.startOfWeek({ weekStartsOn: 1 });
1✔
34
    }
35

36
    endOf(date: GanttDate) {
37
        return date.endOfWeek({ weekStartsOn: 1 });
1✔
38
    }
39

40
    getPrimaryWidth() {
41
        if (!this.options.showWeekend) {
1!
42
            return this.getCellWidth() * 5;
1✔
43
        } else {
44
            return this.getCellWidth() * 7;
×
45
        }
46
    }
47

48
    getDayOccupancyWidth(date: GanttDate): number {
49
        if (!this.options.showWeekend && date.isWeekend()) {
×
50
            return 0;
×
51
        }
52
        return this.cellWidth;
×
53
    }
54

55
    getPrimaryDatePoints(): GanttDatePoint[] {
56
        const days = eachDayOfInterval({ start: this.start.value, end: this.end.value });
1✔
57
        const points: GanttDatePoint[] = [];
1✔
58
        const dayInWeekMap = {
1✔
59
            '1': '周一',
60
            '2': '周二',
61
            '3': '周三',
62
            '4': '周四',
63
            '5': '周五',
64
            '6': '周六',
65
            '0': '周日'
66
        };
67
        for (let i = 0; i < days.length; i++) {
1✔
68
            const start = new GanttDate(days[i]);
371✔
69
            const isWeekend = start.isWeekend();
371✔
70
            const point = new GanttDatePoint(
371✔
71
                start,
72
                `${dayInWeekMap[start.getDay()]}`,
73
                i * this.getCellWidth() + this.getCellWidth() / 2,
74
                primaryDatePointTop,
75
                {
76
                    isWeekend,
77
                    isToday: start.isToday()
78
                }
79
            );
80
            points.push(point);
371✔
81
        }
82
        if (!this.options.showWeekend) {
1!
83
            return points
1✔
84
                .filter((point) => !point.additions.isWeekend)
371✔
85
                .map((point, i) => {
86
                    return { ...point, x: i * this.getCellWidth() + this.getCellWidth() / 2 };
265✔
87
                });
88
        } else {
89
            return points;
×
90
        }
91
    }
92

93
    getSecondaryDatePoints(): GanttDatePoint[] {
94
        const days = eachDayOfInterval({ start: this.start.value, end: this.end.value });
1✔
95
        const points: GanttDatePoint[] = [];
1✔
96
        for (let i = 0; i < days.length; i++) {
1✔
97
            const start = new GanttDate(days[i]);
371✔
98
            const isWeekend = start.isWeekend();
371✔
99
            const point = new GanttDatePoint(
371✔
100
                start,
101
                `${start.format('MM/d')}`,
102
                i * this.getCellWidth() + this.getCellWidth() / 2,
103
                secondaryDatePointTop,
104
                {
105
                    isWeekend,
106
                    isToday: start.isToday()
107
                }
108
            );
109
            points.push(point);
371✔
110
        }
111

112
        if (!this.options.showWeekend) {
1!
113
            return points
1✔
114
                .filter((point) => !point.additions.isWeekend)
371✔
115
                .map((point, i) => {
116
                    return { ...point, x: i * this.getCellWidth() + this.getCellWidth() / 2 };
265✔
117
                });
118
        } else {
119
            return points;
×
120
        }
121
    }
122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc