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

graphty-org / graphty-element / 16201911984

10 Jul 2025 05:29PM UTC coverage: 67.128% (+0.9%) from 66.274%
16201911984

push

github

apowers313
refactor: refactor RichTextLabel into multiple classes

469 of 723 branches covered (64.87%)

Branch coverage included in aggregate %.

534 of 950 new or added lines in 7 files covered. (56.21%)

40 existing lines in 2 files now uncovered.

3699 of 5486 relevant lines covered (67.43%)

1232.77 hits per line

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

65.12
/src/layout/SpringLayoutEngine.ts
1
import {Edge as LayoutEdge, Node as LayoutNode, springLayout} from "@graphty/layout";
1✔
2
import {z} from "zod/v4";
1✔
3

4
import {SimpleLayoutConfig, SimpleLayoutEngine} from "./LayoutEngine";
1✔
5

6
export const SpringLayoutConfig = z.strictObject({
1✔
7
    ... SimpleLayoutConfig.shape,
1✔
8
    k: z.number().or(z.null()).default(null),
1✔
9
    pos: z.record(
1✔
10
        z.number(),
1✔
11
        z.array(z.number()),
1✔
12
    ).or(z.null()).default(null),
1✔
13
    fixed: z.array(z.number()).or(z.null()).default(null),
1✔
14
    iterations: z.number().positive().default(50),
1✔
15
    scale: z.number().positive().default(1),
1✔
16
    center: z.array(z.number()).length(2).or(z.null()).default(null),
1✔
17
    dim: z.number().default(3),
1✔
18
    seed: z.number().positive().or(z.null()).default(null),
1✔
19
});
1✔
20
export type SpringLayoutConfigType = z.infer<typeof SpringLayoutConfig>;
21
export type SpringLayoutOpts = Partial<SpringLayoutConfigType>;
22

23
export class SpringLayout extends SimpleLayoutEngine {
1✔
24
    static type = "spring";
1✔
25
    static maxDimensions = 3;
1✔
26
    scalingFactor = 100;
1✔
27
    config: SpringLayoutConfigType;
28

29
    constructor(opts: SpringLayoutOpts) {
1✔
30
        super(opts);
2✔
31
        this.config = SpringLayoutConfig.parse(opts);
2✔
32
    }
2✔
33

34
    doLayout(): void {
1✔
UNCOV
35
        this.stale = false;
×
UNCOV
36
        const nodes = (): LayoutNode[] => this._nodes.map((n) => n.id as LayoutNode);
×
UNCOV
37
        const edges = (): LayoutEdge[] => this._edges.map((e) => [e.srcId, e.dstId] as LayoutEdge);
×
38

UNCOV
39
        this.positions = springLayout(
×
UNCOV
40
            {nodes, edges},
×
UNCOV
41
            this.config.k,
×
UNCOV
42
            this.config.pos,
×
UNCOV
43
            this.config.fixed,
×
UNCOV
44
            this.config.iterations,
×
UNCOV
45
            this.config.scale,
×
UNCOV
46
            this.config.center,
×
UNCOV
47
            this.config.dim,
×
UNCOV
48
            this.config.seed,
×
UNCOV
49
        );
×
UNCOV
50
    }
×
51
}
1✔
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

© 2026 Coveralls, Inc