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

antvis / L7Plot / 5285254265

pending completion
5285254265

Pull #298

github

web-flow
Merge 57af74f09 into 0ba79c99e
Pull Request #298: fix: 替换 d3 系列包,以修复 umd 打包体积过大的问题

819 of 2177 branches covered (37.62%)

Branch coverage included in aggregate %.

12 of 12 new or added lines in 3 files covered. (100.0%)

3378 of 5054 relevant lines covered (66.84%)

200.11 hits per line

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

15.79
/packages/composite-layers/src/composite-layers/flow-layer/utils/style.ts
1
import { ScaleTypes } from '@antv/l7';
2
import { Log } from '@antv/scale';
24✔
3
import { LineLayerStyleOptions } from '../../../core-layers/line-layer/types';
24✔
4
import { ColorAttr, SizeAttr } from '../../../types';
24✔
5

24✔
6
const DefaultScaleType = ScaleTypes.LINEAR;
24✔
7

24✔
8
export function getSizeAttribute(sizeAttr: SizeAttr, weightRange: [number, number]): SizeAttr {
9
  if (sizeAttr instanceof Object && !(sizeAttr instanceof Function) && !Array.isArray(sizeAttr)) {
10
    const { field, value } = sizeAttr;
×
11
    if (field === 'weight' && Array.isArray(value) && value.length) {
×
12
      const scaleType = (sizeAttr.scale?.type || DefaultScaleType) as ScaleTypes;
×
13
      return {
×
14
        ...sizeAttr,
×
15
        scale: {
16
          field: 'size',
17
          type: scaleType,
18
          domain: weightRange,
19
          range: value,
20
        },
21
      };
22
    }
×
23
  }
24
  return sizeAttr;
24✔
25
}
26

27
export function getColorAttribute(colorAttr: ColorAttr, weightRange: [number, number]): ColorAttr {
×
28
  if (colorAttr instanceof Object && !(colorAttr instanceof Function) && !Array.isArray(colorAttr)) {
×
29
    const { field, value } = colorAttr;
×
30
    if (field === 'weight' && Array.isArray(value) && value.length) {
×
31
      const scaleType = (colorAttr.scale?.type || DefaultScaleType) as ScaleTypes;
×
32
      return {
33
        ...colorAttr,
34
        scale: {
35
          field: 'color',
36
          type: scaleType,
37
          domain: weightRange,
38
          range: value,
39
        },
×
40
      };
41
    }
24✔
42
  }
43
  return colorAttr;
×
44
}
45

46
export function getOpacityColorAttribute(
47
  weightRange: [number, number],
×
48
  fadeOpacityAmount: number
×
49
): LineLayerStyleOptions['opacity'] {
50
  const scaleFunc = new Log({
51
    domain: weightRange,
×
52
    range: [0, 1],
53
  });
54
  const ratio = (1 - fadeOpacityAmount / 100) * 1.5;
55
  return [
24✔
56
    'weight',
57
    (weight: any) => {
58
      return scaleFunc.map(weight) * ratio;
59
    },
60
  ];
61
}
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