-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[maps] fix marker size scale issue for counts (#132057)
* [maps] fix marker size scale issue for counts * fix test names Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
94b894a
commit c9372dc
Showing
4 changed files
with
181 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
...plugins/maps/public/classes/layers/vector_layer/mvt_vector_layer/pluck_style_meta.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { FIELD_ORIGIN } from '../../../../../common/constants'; | ||
import { TileMetaFeature } from '../../../../../common/descriptor_types'; | ||
import { pluckOrdinalStyleMeta } from './pluck_style_meta'; | ||
import { IField } from '../../../fields/field'; | ||
import { DynamicSizeProperty } from '../../../styles/vector/properties/dynamic_size_property'; | ||
|
||
describe('pluckOrdinalStyleMeta', () => { | ||
test('should pluck range from metaFeatures', () => { | ||
const mockField = { | ||
isCount: () => { | ||
return false; | ||
}, | ||
pluckRangeFromTileMetaFeature: (metaFeature: TileMetaFeature) => { | ||
return { | ||
max: metaFeature.properties['aggregations.avg_of_bytes.max'], | ||
min: metaFeature.properties['aggregations.avg_of_bytes.min'], | ||
}; | ||
}, | ||
} as unknown as IField; | ||
const mockStyleProperty = { | ||
getField: () => { | ||
return mockField; | ||
}, | ||
isOrdinal: () => { | ||
return true; | ||
}, | ||
getFieldOrigin: () => { | ||
return FIELD_ORIGIN.SOURCE; | ||
}, | ||
} as unknown as DynamicSizeProperty; | ||
const metaFeatures = [ | ||
{ | ||
properties: { | ||
'aggregations.avg_of_bytes.max': 7565, | ||
'aggregations.avg_of_bytes.min': 1622, | ||
}, | ||
} as unknown as TileMetaFeature, | ||
{ | ||
properties: { | ||
'aggregations.avg_of_bytes.max': 11869, | ||
'aggregations.avg_of_bytes.min': 659, | ||
}, | ||
} as unknown as TileMetaFeature, | ||
]; | ||
expect(pluckOrdinalStyleMeta(mockStyleProperty, metaFeatures, undefined)).toEqual({ | ||
max: 11869, | ||
min: 659, | ||
delta: 11210, | ||
}); | ||
}); | ||
|
||
test('should pluck range with min: 1 from metaFeatures for count field', () => { | ||
const mockField = { | ||
isCount: () => { | ||
return true; | ||
}, | ||
pluckRangeFromTileMetaFeature: (metaFeature: TileMetaFeature) => { | ||
return { | ||
max: metaFeature.properties['aggregations._count.max'], | ||
min: metaFeature.properties['aggregations._count.min'], | ||
}; | ||
}, | ||
} as unknown as IField; | ||
const mockStyleProperty = { | ||
getField: () => { | ||
return mockField; | ||
}, | ||
isOrdinal: () => { | ||
return true; | ||
}, | ||
getFieldOrigin: () => { | ||
return FIELD_ORIGIN.SOURCE; | ||
}, | ||
} as unknown as DynamicSizeProperty; | ||
const metaFeatures = [ | ||
{ | ||
properties: { | ||
'aggregations._count.max': 35, | ||
'aggregations._count.min': 3, | ||
}, | ||
} as unknown as TileMetaFeature, | ||
{ | ||
properties: { | ||
'aggregations._count.max': 36, | ||
'aggregations._count.min': 5, | ||
}, | ||
} as unknown as TileMetaFeature, | ||
]; | ||
expect(pluckOrdinalStyleMeta(mockStyleProperty, metaFeatures, undefined)).toEqual({ | ||
max: 36, | ||
min: 1, | ||
delta: 35, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters