-
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.
Browse files
Browse the repository at this point in the history
…52401) * [Maps] use style metadata to calculate symbolization bands * only update style meta when fields change * load join source style meta * use style meta data request to populate range * apply source filter to style meta request * fix heatmap * only use style meta range if field supports field meta * add fieldMetaOptions to style prperty descriptor and add migration script * add UI for setting fieldMetaOptions.isEnabled * clean up * review feedback * fix can_skip_fetch tests * review feedback * only show field meta popover for fields that support field meta * avoid duplicate fields re-fetching style meta * clean up problems when first creating grid source * update text for enabling field meta toggle * provide UI for setting sigma * allow users to include global time in style meta request * update SIEM saved objects * add less than and greater than symbols when styling by field stats * fix functional tests * review feedback * add support for date fields * review feedback * only show less then and greater then in legend when values will be outside of std range * unnest VectorStyle._getFieldRange * remove unused function * only show style isTimeAware switch when style fields use field meta
- Loading branch information
Showing
39 changed files
with
910 additions
and
119 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
38 changes: 38 additions & 0 deletions
38
x-pack/legacy/plugins/maps/common/migrations/add_field_meta_options.js
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,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 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 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
29 changes: 29 additions & 0 deletions
29
x-pack/legacy/plugins/maps/public/layers/fields/es_agg_field.test.js
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,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 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
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
Oops, something went wrong.