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

antvis / L7Plot / 3763448570

pending completion
3763448570

Pull #262

github

GitHub
Merge 3128c703f into da129e8ec
Pull Request #262: refactor: 图层属性更新逻辑性能优化

723 of 1953 branches covered (37.02%)

Branch coverage included in aggregate %.

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

3049 of 4601 relevant lines covered (66.27%)

177.64 hits per line

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

25.93
/packages/l7plot/src/plots/choropleth/helper.ts
1
import { pick, isUndefined } from '@antv/util';
2
import * as topojson from 'topojson-client';
127✔
3
import { Topology } from 'topojson-specification';
127✔
4
import { GEO_AREA_URL } from './constants';
127✔
5
import { ChoroplethOptions, DrillStep, DrillStepConfig } from './types';
127✔
6

127✔
7
export const getGeoAreaConfig = (geoArea?: ChoroplethOptions['geoArea']) => {
127✔
8
  const config = { url: GEO_AREA_URL, type: 'topojson', extension: 'topo.json' };
127✔
9
  if (isUndefined(geoArea)) return config;
×
10
  if (typeof geoArea === 'string') {
×
11
    config.url = geoArea;
×
12
  } else {
×
13
    config.url = geoArea?.url || GEO_AREA_URL;
×
14
    config.type = geoArea.type;
15
    config.extension = geoArea.type === 'topojson' ? 'topo.json' : 'json';
16
  }
×
17
  return config;
×
18
};
×
19

20
export const topojson2geojson = (json: Topology) => {
×
21
  try {
22
    const geojson = topojson.feature(json, 'json');
127✔
23
    return geojson;
127✔
24
  } catch (err) {
×
25
    throw new Error('Failed convert to geojson from topojson, topojson default layer name "json"');
×
26
  }
×
27
};
28

29
export const isEqualDrillSteps = (newSteps: DrillStep[], oldSteps: DrillStep[]) => {
×
30
  if (newSteps.length !== oldSteps.length) {
31
    return false;
32
  }
127✔
33

127✔
34
  for (let index = 0; index < newSteps.length; index++) {
×
35
    const { level, granularity } = newSteps[index];
×
36
    if (oldSteps[index].level !== level || oldSteps[index].granularity !== granularity) {
37
      return false;
×
38
    }
×
39
  }
×
40

×
41
  return true;
42
};
43

×
44
export const getDrillStepDefaultConfig = (options: ChoroplethOptions) => {
45
  const config = pick<any>(options, ['source', 'color', 'style', 'state', 'label', 'tooltip']) as DrillStepConfig;
127✔
46

127✔
47
  return config;
×
48
};
×
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