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

antvis / L7Plot / 9478568050

12 Jun 2024 07:33AM UTC coverage: 56.968% (-2.6%) from 59.55%
9478568050

push

github

web-flow
chore: type mis (#356)

* chore: type mis

* chore: compiler options target

960 of 2222 branches covered (43.2%)

Branch coverage included in aggregate %.

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

916 existing lines in 53 files now uncovered.

2768 of 4322 relevant lines covered (64.04%)

234.63 hits per line

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

93.75
/packages/l7plot/src/component/legend.ts
1
import type { IControlOption } from '@antv/l7';
2
import { Control } from '@antv/l7';
124✔
3
import { CategoryLegendOptions, ContinueLegendOptions, CategoryLegend, ContinueLegend } from '@antv/l7plot-component';
124✔
4

124✔
5
export type LegendItem =
124✔
6
  | { type: 'category'; options: CategoryLegendOptions }
7
  | { type: 'continue'; options: ContinueLegendOptions };
8
export interface LegendOptions extends Partial<IControlOption> {
35✔
9
  items: LegendItem[];
10
}
11

12
export class Legend extends Control {
35✔
13
  /**
35✔
14
   * legend 的 schema 配置
35✔
15
   */
16
  protected options: LegendOptions;
17
  /**
35✔
18
   * legendComponents 实例
35✔
19
   */
35✔
20
  private legendComponents: (CategoryLegend | ContinueLegend)[] = [];
35✔
21

20✔
22
  constructor(options: LegendOptions) {
23
    super(options);
24
    this.options = options;
25
    this.legendComponents = this.initLegendComponents(options.items);
26
  }
27

28
  private initLegendComponents(legendItem: LegendItem[]) {
20✔
29
    const legendComponents: (CategoryLegend | ContinueLegend)[] = [];
30

15!
31
    for (let index = 0; index < legendItem.length; index++) {
15✔
32
      const item = legendItem[index];
33
      if (item.type === 'category') {
34
        const legend = new CategoryLegend({
35
          title: item.options.title,
36
          items: item.options.items,
37
          className: item.options.className,
38
          customContent: item.options.customContent,
39
          domStyles: item.options.domStyles,
40
        });
15✔
41
        legendComponents.push(legend);
42
      } else if (item.type === 'continue') {
43
        const legend = new ContinueLegend({
35✔
44
          title: item.options.title,
45
          min: item.options.min,
46
          max: item.options.max,
47
          colors: item.options.colors,
48
          className: item.options.className,
UNCOV
49
          customContent: item.options.customContent,
×
50
          domStyles: item.options.domStyles,
51
        });
52
        legendComponents.push(legend);
53
      }
54
    }
35✔
55

35✔
56
    return legendComponents;
35✔
57
  }
35✔
58

35✔
59
  /**
60
   * 获取默认配置
35✔
61
   */
62
  protected getDefaultOptions(): Partial<LegendOptions> {
63
    return {
66✔
64
      position: 'bottomleft',
66✔
65
    };
66
  }
67

68
  public onAdd(): HTMLElement {
124✔
69
    const container = window.document.createElement('div');
70
    container.className = 'l7plot-legend-container';
71
    this.legendComponents.forEach((legendComponent) => {
72
      const legend = legendComponent.getContainer();
73
      container.appendChild(legend);
74
    });
75

76
    return container;
77
  }
78

79
  public onRemove() {
80
    this.legendComponents.forEach((legendComponent) => {
81
      legendComponent.destroy();
82
    });
83
  }
84
}
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