-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Maps] use style metadata to calculate symbolization bands #51713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
9fc4d03
[Maps] use style metadata to calculate symbolization bands
nreese 9c756db
merge with master
nreese 44b6bdc
only update style meta when fields change
nreese 1aed323
load join source style meta
nreese 9893f84
use style meta data request to populate range
nreese 3315513
apply source filter to style meta request
nreese 7df849f
Merge branch 'master' of github.com:elastic/kibana into style_meta2
nreese c5c5cbe
fix heatmap
nreese fe8615a
only use style meta range if field supports field meta
nreese 69525f1
Merge branch 'master' of github.com:elastic/kibana into style_meta2
nreese 569b946
add fieldMetaOptions to style prperty descriptor and add migration sc…
nreese 3bf5b40
merge with master
nreese 2d16a71
add UI for setting fieldMetaOptions.isEnabled
nreese 467dca0
clean up
nreese e386597
review feedback
nreese edb9aed
fix can_skip_fetch tests
nreese 3541149
review feedback
nreese 5c8ed7d
only show field meta popover for fields that support field meta
nreese ba0bc74
avoid duplicate fields re-fetching style meta
nreese 67ad76c
clean up problems when first creating grid source
nreese 09d9a60
Merge branch 'master' of github.com:elastic/kibana into style_meta2
nreese a157eae
update text for enabling field meta toggle
nreese 474d38f
provide UI for setting sigma
nreese 1abd626
allow users to include global time in style meta request
nreese e9764e5
update SIEM saved objects
nreese 84f694b
add less than and greater than symbols when styling by field stats
nreese f4ee834
fix functional tests
nreese 6d943da
review feedback
nreese e80cb70
add support for date fields
nreese cc8b671
Merge branch 'master' of github.com:elastic/kibana into style_meta2
nreese ccabd81
review feedback
nreese 820888f
only show less then and greater then in legend when values will be ou…
nreese b9974b3
unnest VectorStyle._getFieldRange
nreese e69b03f
remove unused function
nreese 3bdac51
only show style isTimeAware switch when style fields use field meta
nreese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
x-pack/legacy/plugins/maps/common/migrations/add_field_meta_options.js
This file contains hidden or 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,38 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import _ from 'lodash'; | ||
| import { LAYER_TYPE, STYLE_TYPE } from '../constants'; | ||
|
|
||
| function isVectorLayer(layerDescriptor) { | ||
| const layerType = _.get(layerDescriptor, 'type'); | ||
| return layerType === LAYER_TYPE.VECTOR; | ||
| } | ||
|
|
||
| export function addFieldMetaOptions({ attributes }) { | ||
| if (!attributes.layerListJSON) { | ||
| return attributes; | ||
| } | ||
|
|
||
| const layerList = JSON.parse(attributes.layerListJSON); | ||
| layerList.forEach((layerDescriptor) => { | ||
| if (isVectorLayer(layerDescriptor) && _.has(layerDescriptor, 'style.properties')) { | ||
| Object.values(layerDescriptor.style.properties).forEach(stylePropertyDescriptor => { | ||
| if (stylePropertyDescriptor.type === STYLE_TYPE.DYNAMIC) { | ||
| stylePropertyDescriptor.options.fieldMetaOptions = { | ||
| isEnabled: false, // turn off field metadata to avoid changing behavior of existing saved objects | ||
| sigma: 3, | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| return { | ||
| ...attributes, | ||
| layerListJSON: JSON.stringify(layerList), | ||
| }; | ||
| } | ||
121 changes: 121 additions & 0 deletions
121
x-pack/legacy/plugins/maps/common/migrations/add_field_meta_options.test.js
This file contains hidden or 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,121 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import { addFieldMetaOptions } from './add_field_meta_options'; | ||
| import { LAYER_TYPE, STYLE_TYPE } from '../constants'; | ||
|
|
||
| describe('addFieldMetaOptions', () => { | ||
|
|
||
| test('Should handle missing layerListJSON attribute', () => { | ||
| const attributes = { | ||
| title: 'my map', | ||
| }; | ||
| expect(addFieldMetaOptions({ attributes })).toEqual({ | ||
| title: 'my map', | ||
| }); | ||
| }); | ||
|
|
||
| test('Should ignore non-vector layers', () => { | ||
| const layerListJSON = JSON.stringify([ | ||
| { | ||
| type: LAYER_TYPE.HEATMAP, | ||
| style: { | ||
| type: 'HEATMAP', | ||
| colorRampName: 'Greens' | ||
| } | ||
| } | ||
| ]); | ||
| const attributes = { | ||
| title: 'my map', | ||
| layerListJSON | ||
| }; | ||
| expect(addFieldMetaOptions({ attributes })).toEqual({ | ||
| title: 'my map', | ||
| layerListJSON | ||
| }); | ||
| }); | ||
|
|
||
| test('Should ignore static style properties', () => { | ||
| const layerListJSON = JSON.stringify([ | ||
| { | ||
| type: LAYER_TYPE.VECTOR, | ||
| style: { | ||
| type: 'VECTOR', | ||
| properties: { | ||
| lineColor: { | ||
| type: STYLE_TYPE.STATIC, | ||
| options: { | ||
| color: '#FFFFFF' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ]); | ||
| const attributes = { | ||
| title: 'my map', | ||
| layerListJSON | ||
| }; | ||
| expect(addFieldMetaOptions({ attributes })).toEqual({ | ||
| title: 'my map', | ||
| layerListJSON | ||
| }); | ||
| }); | ||
|
|
||
| test('Should add field meta options to dynamic style properties', () => { | ||
| const layerListJSON = JSON.stringify([ | ||
| { | ||
| type: LAYER_TYPE.VECTOR, | ||
| style: { | ||
| type: 'VECTOR', | ||
| properties: { | ||
| fillColor: { | ||
| type: STYLE_TYPE.DYNAMIC, | ||
| options: { | ||
| field: { | ||
| name: 'my_field', | ||
| origin: 'source' | ||
| }, | ||
| color: 'Greys' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ]); | ||
| const attributes = { | ||
| title: 'my map', | ||
| layerListJSON | ||
| }; | ||
| expect(addFieldMetaOptions({ attributes })).toEqual({ | ||
| title: 'my map', | ||
| layerListJSON: JSON.stringify([ | ||
| { | ||
| type: LAYER_TYPE.VECTOR, | ||
| style: { | ||
| type: 'VECTOR', | ||
| properties: { | ||
| fillColor: { | ||
| type: STYLE_TYPE.DYNAMIC, | ||
| options: { | ||
| field: { | ||
| name: 'my_field', | ||
| origin: 'source' | ||
| }, | ||
| color: 'Greys', | ||
| fieldMetaOptions: { | ||
| isEnabled: false, | ||
| sigma: 3, | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ]) | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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
29 changes: 29 additions & 0 deletions
29
x-pack/legacy/plugins/maps/public/layers/fields/es_agg_field.test.js
This file contains hidden or 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,29 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License; | ||
| * you may not use this file except in compliance with the Elastic License. | ||
| */ | ||
|
|
||
| import { ESAggMetricField } from './es_agg_field'; | ||
| import { METRIC_TYPE } from '../../../common/constants'; | ||
|
|
||
| describe('supportsFieldMeta', () => { | ||
|
|
||
| test('Non-counting aggregations should support field meta', () => { | ||
| const avgMetric = new ESAggMetricField({ aggType: METRIC_TYPE.AVG }); | ||
| expect(avgMetric.supportsFieldMeta()).toBe(true); | ||
| const maxMetric = new ESAggMetricField({ aggType: METRIC_TYPE.MAX }); | ||
| expect(maxMetric.supportsFieldMeta()).toBe(true); | ||
| const minMetric = new ESAggMetricField({ aggType: METRIC_TYPE.MIN }); | ||
| expect(minMetric.supportsFieldMeta()).toBe(true); | ||
| }); | ||
|
|
||
| test('Counting aggregations should not support field meta', () => { | ||
| const countMetric = new ESAggMetricField({ aggType: METRIC_TYPE.COUNT }); | ||
| expect(countMetric.supportsFieldMeta()).toBe(false); | ||
| const sumMetric = new ESAggMetricField({ aggType: METRIC_TYPE.SUM }); | ||
| expect(sumMetric.supportsFieldMeta()).toBe(false); | ||
| const uniqueCountMetric = new ESAggMetricField({ aggType: METRIC_TYPE.UNIQUE_COUNT }); | ||
| expect(uniqueCountMetric.supportsFieldMeta()).toBe(false); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.