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

worktile / ngx-gantt / 56afc371-2b0e-462c-80c7-441d1a207ba1

06 Mar 2024 10:45AM UTC coverage: 71.745%. Remained the same
56afc371-2b0e-462c-80c7-441d1a207ba1

push

circleci

web-flow
build: bump angular 17 #INFR-11782 (#441)

344 of 598 branches covered (57.53%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

1403 of 1837 relevant lines covered (76.37%)

932.38 hits per line

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

43.42
/packages/gantt/src/components/links/lines/curve.ts
1
import { Inject } from '@angular/core';
2
import { GanttLinkItem, GanttLinkType } from '../../../class/link';
3
import { GanttUpper, GANTT_UPPER_TOKEN } from '../../../gantt-upper';
4
import { GanttLinkLine } from './line';
5

6
export class GanttLinkLineCurve extends GanttLinkLine {
7
    constructor(@Inject(GANTT_UPPER_TOKEN) private ganttUpper: GanttUpper) {
57✔
8
        super();
57✔
9
    }
10

11
    generateSSPath(source: GanttLinkItem, target: GanttLinkItem) {
12
        const x1 = source.before.x;
×
13
        const y1 = source.before.y;
×
14
        const x4 = target.before.x;
×
15
        const y4 = target.before.y;
×
16
        const isMirror = y4 > y1 ? 0 : 1;
×
17
        const radius = Math.abs(y4 - y1) / 2;
×
18

19
        if (x4 > x1) {
×
20
            return `M ${x1} ${y1}
×
21
                    A ${radius} ${radius} 0 1 ${isMirror} ${x1} ${y4}
22
                    L ${x4} ${y4}`;
23
        } else {
24
            return `M ${x1} ${y1}
×
25
                    L ${x4} ${y1}
26
                    A ${radius} ${radius} 0 1 ${isMirror} ${x4} ${y4}`;
27
        }
28
    }
29
    generateFFPath(source: GanttLinkItem, target: GanttLinkItem) {
30
        const x1 = source.after.x;
×
31
        const y1 = source.after.y;
×
32
        const x4 = target.after.x;
×
33
        const y4 = target.after.y;
×
34
        const isMirror = y4 > y1 ? 1 : 0;
×
35
        const radius = Math.abs(y4 - y1) / 2;
×
36
        if (x4 > x1) {
×
37
            return `M ${x1} ${y1}
×
38
                    L ${x4} ${y1}
39
                    A ${radius} ${radius} 0 1 ${isMirror} ${x4} ${y4}`;
40
        } else {
41
            return `M ${x1} ${y1}
×
42
                    A ${radius} ${radius} 0 1 ${isMirror} ${x1} ${y4}
43
                    L ${x4} ${y4}`;
44
        }
45
    }
46

47
    generateFSAndSFPath(source: GanttLinkItem, target: GanttLinkItem, type?: GanttLinkType) {
48
        let x1 = source.after.x;
248✔
49
        let y1 = source.after.y;
248✔
50
        let x4 = target.before.x;
248✔
51
        let y4 = target.before.y;
248✔
52
        const bezierWeight = 0.5;
248✔
53

54
        if (type === GanttLinkType.sf) {
248!
55
            x1 = target.after.x;
×
56
            y1 = target.after.y;
×
57
            x4 = source.before.x;
×
58
            y4 = source.before.y;
×
59
        }
60

61
        let dx = Math.abs(x4 - x1) * bezierWeight;
248✔
62
        let x2 = x1 + dx;
248✔
63
        let x3 = x4 - dx;
248✔
64

65
        const centerX = (x1 + x4) / 2;
248✔
66
        const centerY = (y1 + y4) / 2;
248✔
67

68
        let controlX = this.ganttUpper.styles.lineHeight / 2;
248✔
69
        const controlY = this.ganttUpper.styles.lineHeight / 2;
248✔
70

71
        if (x1 >= x4) {
248✔
72
            if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
134✔
73
                return `M ${x1} ${y1}
124✔
74
                    C ${x1 + controlX} ${y1} ${x1 + controlX} ${y4 > y1 ? y1 + controlX : y1 - controlX} ${x1} ${
124!
75
                    y4 > y1 ? y1 + controlY : y1 - controlY
124!
76
                }
77
                    L ${x4} ${y4 > y1 ? y4 - controlY : y4 + controlY}
124!
78
                    C ${x4 - controlY} ${y4 > y1 ? y4 - controlY : y4 + controlY}  ${x4 - controlX} ${y4} ${x4} ${y4}
124!
79
                    `;
80
            } else {
81
                controlX = this.ganttUpper.styles.lineHeight;
10✔
82
                return `M ${x1} ${y1}
10✔
83
                    C ${x1 + controlX} ${y1} ${x1 + controlX} ${y4 > y1 ? y1 + controlX : y1 - controlX} ${centerX} ${centerY}
10!
84
                    C ${x4 - controlX} ${y4 > y1 ? y4 - controlX : y4 + controlX} ${x4 - controlX} ${y4} ${x4} ${y4}
10!
85
                    `;
86
            }
87
        } else if (this.ganttUpper.linkOptions?.showArrow && x4 - x1 < 200) {
114!
88
            dx = Math.max(Math.abs(y4 - y1) * bezierWeight, 60);
×
89
            x2 = x1 + dx;
×
90
            x3 = x4 - dx;
×
91
            return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
×
92
        }
93

94
        return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
114✔
95
    }
96
}
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