diff --git a/packages/district/src/layer/country.ts b/packages/district/src/layer/country.ts index ec043820b7..a282ddced9 100644 --- a/packages/district/src/layer/country.ts +++ b/packages/district/src/layer/country.ts @@ -24,7 +24,9 @@ export default class CountryLayer extends BaseLayer { } protected async addProvinceFill() { const { depth } = this.options; - const countryConfig = getDataConfig(this.options.geoDataLevel).CHN[depth]; + const countryConfig = getDataConfig(this.options.geoDataLevel).country.CHN[ + depth + ]; const fillData = await this.fetchData(countryConfig.fill); this.addFillLayer(fillData); } diff --git a/packages/utils/__tests__/statistic.spec.ts b/packages/utils/__tests__/statistic.spec.ts index bea992c0a2..48380a3ead 100644 --- a/packages/utils/__tests__/statistic.spec.ts +++ b/packages/utils/__tests__/statistic.spec.ts @@ -1,10 +1,35 @@ -import { sum } from '../src/statistics'; -describe('sum', () => { - it('sum string array', () => { - const a = ['1', '2', '3']; - const b = [1, 2, 3]; +import { max, mean, min, sum, mode } from '../src/statistics'; +const a = ['1', '2', '3']; +const b = [1, 2, 3]; +const c = [1, 2, 3, '1', 2, '3', 3]; +describe('statistic', () => { + it('sum', () => { // @ts-ignore expect(sum(a)).toEqual(6); expect(sum(b)).toEqual(6); }); + it('max', () => { + // @ts-ignore + expect(max(a)).toEqual(3); + expect(max(b)).toEqual(3); + }); + + it('min', () => { + // @ts-ignore + expect(min(a)).toEqual(1); + expect(min(b)).toEqual(1); + }); + + it('mean', () => { + // @ts-ignore + expect(mean(a)).toEqual(2); + // @ts-ignore + expect(mean(b)).toEqual(2); + }); + + it('mode', () => { + // @ts-ignore + expect(mode(a)).toEqual(1); + expect(mode(c)).toEqual(2); + }); }); diff --git a/packages/utils/src/statistics.ts b/packages/utils/src/statistics.ts index 31f4e2d6db..9a3a05ad7c 100644 --- a/packages/utils/src/statistics.ts +++ b/packages/utils/src/statistics.ts @@ -14,7 +14,7 @@ function max(x: number[]) { value = x[i]; } } - return value; + return value * 1; } function min(x: number[]) { @@ -30,7 +30,7 @@ function min(x: number[]) { value = x[i]; } } - return value; + return value * 1; } function sum(x: number[]) { @@ -81,7 +81,7 @@ function mode(x: any[]) { seenThis++; } } - return value; + return value * 1; } export { sum, max, min, mean, mode }; diff --git a/stories/Draw/Components/DrawLine.tsx b/stories/Draw/Components/DrawLine.tsx index f9b3148cc5..4e28165fea 100644 --- a/stories/Draw/Components/DrawLine.tsx +++ b/stories/Draw/Components/DrawLine.tsx @@ -21,6 +21,7 @@ export default class Circle extends React.Component { }), }); this.scene = scene; + const line = scene.on('loaded', () => { const drawLine = new DrawLine(scene);