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

graphty-org / graphty-element / 16242819426

12 Jul 2025 10:52PM UTC coverage: 72.536% (-1.2%) from 73.747%
16242819426

push

github

apowers313
docs: add a chromatic-specific test for node styles

523 of 721 branches covered (72.54%)

Branch coverage included in aggregate %.

3996 of 5509 relevant lines covered (72.54%)

1084.38 hits per line

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

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

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

6
export const RandomLayoutConfig = z.strictObject({
1✔
7
    ... SimpleLayoutConfig.shape,
1✔
8
    center: z.array(z.number()).length(2).or(z.null()).default(null),
1✔
9
    dim: z.number().default(2),
1✔
10
    seed: z.number().positive().or(z.null()).default(null),
1✔
11
});
1✔
12
export type RandomLayoutConfigType = z.infer<typeof RandomLayoutConfig>;
13
export type RandomLayoutOpts = Partial<RandomLayoutConfigType>;
14

15
export class RandomLayout extends SimpleLayoutEngine {
1✔
16
    static type = "random";
1✔
17
    static maxDimensions = 3;
1✔
18
    scalingFactor = 100;
1✔
19
    config: RandomLayoutConfigType;
20

21
    constructor(opts: RandomLayoutOpts) {
1✔
22
        super(opts);
2✔
23
        this.config = RandomLayoutConfig.parse(opts);
2✔
24
    }
2✔
25

26
    doLayout(): void {
1✔
27
        this.stale = false;
×
28
        const nodes = (): LayoutNode[] => this._nodes.map((n) => n.id as LayoutNode);
×
29
        const edges = (): LayoutEdge[] => this._edges.map((e) => [e.srcId, e.dstId] as LayoutEdge);
×
30

31
        this.positions = randomLayout(
×
32
            {nodes, edges},
×
33
            this.config.center,
×
34
            this.config.dim,
×
35
            this.config.seed,
×
36
        );
×
37
    }
×
38
}
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