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

antvis / T8 / 17260410333

27 Aug 2025 07:37AM UTC coverage: 61.854% (-4.5%) from 66.348%
17260410333

Pull #131

github

web-flow
Merge 3d5c9d541 into cc7d997ee
Pull Request #131: refactor: update chart components

116 of 210 branches covered (55.24%)

Branch coverage included in aggregate %.

51 of 87 new or added lines in 6 files covered. (58.62%)

291 of 448 relevant lines covered (64.96%)

6.86 hits per line

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

41.18
/src/charts/utils/selection.ts
1
/**
2
 * Selection API for DOM manipulation
3
 * Provides D3-like selection interface for SVG elements
4
 */
5

6
export class Selection {
7
  private elements: Element[];
8

9
  constructor(elements: Element | Element[]) {
10
    this.elements = Array.isArray(elements) ? elements : [elements];
13✔
11
  }
12

13
  static select(selector: string): Selection {
NEW
14
    const element = document.querySelector(selector);
×
NEW
15
    return new Selection(element || []);
×
16
  }
17

18
  static selectAll(selector: string): Selection {
NEW
19
    const elements = document.querySelectorAll(selector);
×
NEW
20
    return new Selection(Array.from(elements));
×
21
  }
22

23
  attr(name: string, value: string | number): Selection {
24
    this.elements.forEach((el) => {
27✔
25
      if (el instanceof SVGElement) {
27!
26
        el.setAttribute(name, String(value));
27✔
27
      }
28
    });
29
    return this;
27✔
30
  }
31

32
  style(name: string, value: string): Selection {
NEW
33
    this.elements.forEach((el) => {
×
NEW
34
      (el as HTMLElement).style.setProperty(name, value);
×
35
    });
NEW
36
    return this;
×
37
  }
38

39
  append(tagName: string): Selection {
40
    const newElements: Element[] = [];
10✔
41
    this.elements.forEach((el) => {
10✔
42
      const newEl = document.createElementNS('http://www.w3.org/2000/svg', tagName);
10✔
43
      el.appendChild(newEl);
10✔
44
      newElements.push(newEl);
10✔
45
    });
46
    return new Selection(newElements);
10✔
47
  }
48

49
  text(content: string): Selection {
NEW
50
    this.elements.forEach((el) => {
×
NEW
51
      el.textContent = content;
×
52
    });
NEW
53
    return this;
×
54
  }
55

56
  on(event: string, handler: (event: Event) => void): Selection {
NEW
57
    this.elements.forEach((el) => {
×
NEW
58
      el.addEventListener(event, handler);
×
59
    });
NEW
60
    return this;
×
61
  }
62

63
  node(): Element | null {
NEW
64
    return this.elements[0] || null;
×
65
  }
66

67
  nodes(): Element[] {
NEW
68
    return this.elements;
×
69
  }
70
}
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