-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Maps] choropleth layer wizard #69699
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
22 commits
Select commit
Hold shift + click to select a range
df6737b
[Maps] choropleth layer wizard
nreese 7ec1c88
add boundaries radio group
nreese 3ded282
geo_index_pattern_select
nreese ec5818f
consolidate more logic into geo_index_pattern_select
nreese 9ff163b
small clean-up
nreese 6b965f0
left geo field and join field
nreese 1339ce0
move EuiPanel into render wizard
nreese f8f16f6
cleanup
nreese a6c3a1c
Merge branch 'master' of github.com:elastic/kibana into choropleth_wi…
nreese de436cc
right panel
nreese f42cb7a
createEmsChoroplethLayerDescriptor
nreese 6aa28cb
createEsChoroplethLayerDescriptor
nreese 8b7afb5
i18n cleanup
nreese abcb459
tslint
nreese e85fb90
snapshot update
nreese c99ccb2
Merge branch 'master' into choropleth_wizard
elasticmachine aaf17fd
review feedback
nreese ebdff3f
review feedback
nreese 4198d11
update snapshot
nreese 4bcfe80
make EMS default source
nreese d50006b
merge wit master
nreese 97bc437
tslint
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
107 changes: 107 additions & 0 deletions
107
.../public/classes/layers/choropleth_layer_wizard/__snapshots__/layer_template.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
...ck/plugins/maps/public/classes/layers/choropleth_layer_wizard/choropleth_layer_wizard.tsx
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,25 @@ | ||
| /* | ||
| * 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 React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { LAYER_WIZARD_CATEGORY } from '../../../../common/constants'; | ||
| import { LayerWizard, RenderWizardArguments } from '../layer_wizard_registry'; | ||
| import { LayerTemplate } from './layer_template'; | ||
|
|
||
| export const choroplethLayerWizardConfig: LayerWizard = { | ||
| categories: [LAYER_WIZARD_CATEGORY.ELASTICSEARCH], | ||
| description: i18n.translate('xpack.maps.choropleth.desc', { | ||
| defaultMessage: 'Shaded areas to compare statistics across boundaries', | ||
| }), | ||
| icon: 'logoElasticsearch', | ||
| renderWizard: (renderWizardArguments: RenderWizardArguments) => { | ||
| return <LayerTemplate {...renderWizardArguments} />; | ||
| }, | ||
| title: i18n.translate('xpack.maps.choropleth.title', { | ||
| defaultMessage: 'Choropleth', | ||
| }), | ||
| }; |
144 changes: 144 additions & 0 deletions
144
.../maps/public/classes/layers/choropleth_layer_wizard/create_choropleth_layer_descriptor.ts
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,144 @@ | ||
| /* | ||
| * 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 uuid from 'uuid/v4'; | ||
| import { | ||
| AGG_TYPE, | ||
| COLOR_MAP_TYPE, | ||
| FIELD_ORIGIN, | ||
| SCALING_TYPES, | ||
| SOURCE_TYPES, | ||
| STYLE_TYPE, | ||
| VECTOR_STYLES, | ||
| } from '../../../../common/constants'; | ||
| import { getJoinAggKey } from '../../../../common/get_agg_key'; | ||
| import { | ||
| AggDescriptor, | ||
| ColorDynamicOptions, | ||
| EMSFileSourceDescriptor, | ||
| ESSearchSourceDescriptor, | ||
| } from '../../../../common/descriptor_types'; | ||
| import { VectorStyle } from '../../styles/vector/vector_style'; | ||
| import { VectorLayer } from '../vector_layer/vector_layer'; | ||
| import { EMSFileSource } from '../../sources/ems_file_source'; | ||
| // @ts-ignore | ||
| import { ESSearchSource } from '../../sources/es_search_source'; | ||
| import { getDefaultDynamicProperties } from '../../styles/vector/vector_style_defaults'; | ||
|
|
||
| const defaultDynamicProperties = getDefaultDynamicProperties(); | ||
|
|
||
| function createChoroplethLayerDescriptor({ | ||
| sourceDescriptor, | ||
| leftField, | ||
| rightIndexPatternId, | ||
| rightIndexPatternTitle, | ||
| rightTermField, | ||
| }: { | ||
| sourceDescriptor: EMSFileSourceDescriptor | ESSearchSourceDescriptor; | ||
| leftField: string; | ||
| rightIndexPatternId: string; | ||
| rightIndexPatternTitle: string; | ||
| rightTermField: string; | ||
| }) { | ||
| const metricsDescriptor: AggDescriptor = { type: AGG_TYPE.COUNT }; | ||
| const joinId = uuid(); | ||
| const joinKey = getJoinAggKey({ | ||
| aggType: metricsDescriptor.type, | ||
| aggFieldName: metricsDescriptor.field ? metricsDescriptor.field : '', | ||
| rightSourceId: joinId, | ||
| }); | ||
| return VectorLayer.createDescriptor({ | ||
| joins: [ | ||
nreese marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| leftField, | ||
| right: { | ||
| type: SOURCE_TYPES.ES_TERM_SOURCE, | ||
| id: joinId, | ||
| indexPatternId: rightIndexPatternId, | ||
| indexPatternTitle: rightIndexPatternTitle, | ||
| term: rightTermField, | ||
| metrics: [metricsDescriptor], | ||
| }, | ||
| }, | ||
| ], | ||
| sourceDescriptor, | ||
| style: VectorStyle.createDescriptor({ | ||
| [VECTOR_STYLES.FILL_COLOR]: { | ||
| type: STYLE_TYPE.DYNAMIC, | ||
| options: { | ||
| ...(defaultDynamicProperties[VECTOR_STYLES.FILL_COLOR]!.options as ColorDynamicOptions), | ||
| field: { | ||
| name: joinKey, | ||
| origin: FIELD_ORIGIN.JOIN, | ||
| }, | ||
| color: 'Yellow to Red', | ||
| type: COLOR_MAP_TYPE.ORDINAL, | ||
| }, | ||
| }, | ||
| [VECTOR_STYLES.LINE_COLOR]: { | ||
| type: STYLE_TYPE.STATIC, | ||
| options: { | ||
| color: '#3d3d3d', | ||
| }, | ||
| }, | ||
| }), | ||
| }); | ||
| } | ||
|
|
||
| export function createEmsChoroplethLayerDescriptor({ | ||
| leftEmsFileId, | ||
| leftEmsField, | ||
| rightIndexPatternId, | ||
| rightIndexPatternTitle, | ||
| rightTermField, | ||
| }: { | ||
| leftEmsFileId: string; | ||
| leftEmsField: string; | ||
| rightIndexPatternId: string; | ||
| rightIndexPatternTitle: string; | ||
| rightTermField: string; | ||
| }) { | ||
| return createChoroplethLayerDescriptor({ | ||
| sourceDescriptor: EMSFileSource.createDescriptor({ | ||
| id: leftEmsFileId, | ||
| tooltipProperties: [leftEmsField], | ||
| }), | ||
| leftField: leftEmsField, | ||
| rightIndexPatternId, | ||
| rightIndexPatternTitle, | ||
| rightTermField, | ||
| }); | ||
| } | ||
|
|
||
| export function createEsChoroplethLayerDescriptor({ | ||
| leftIndexPatternId, | ||
| leftGeoField, | ||
| leftJoinField, | ||
| rightIndexPatternId, | ||
| rightIndexPatternTitle, | ||
| rightTermField, | ||
| }: { | ||
| leftIndexPatternId: string; | ||
| leftGeoField: string; | ||
| leftJoinField: string; | ||
| rightIndexPatternId: string; | ||
| rightIndexPatternTitle: string; | ||
| rightTermField: string; | ||
| }) { | ||
| return createChoroplethLayerDescriptor({ | ||
| sourceDescriptor: ESSearchSource.createDescriptor({ | ||
| indexPatternId: leftIndexPatternId, | ||
| geoField: leftGeoField, | ||
| scalingType: SCALING_TYPES.LIMIT, | ||
| tooltipProperties: [leftJoinField], | ||
| applyGlobalQuery: false, | ||
| }), | ||
| leftField: leftJoinField, | ||
| rightIndexPatternId, | ||
| rightIndexPatternTitle, | ||
| rightTermField, | ||
| }); | ||
| } | ||
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/maps/public/classes/layers/choropleth_layer_wizard/index.ts
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,7 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| export { choroplethLayerWizardConfig } from './choropleth_layer_wizard'; |
43 changes: 43 additions & 0 deletions
43
x-pack/plugins/maps/public/classes/layers/choropleth_layer_wizard/layer_template.test.tsx
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,43 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| jest.mock('../../../kibana_services', () => { | ||
| const MockIndexPatternSelect = (props: unknown) => { | ||
| return <div />; | ||
| }; | ||
| return { | ||
| getIndexPatternSelectComponent: () => { | ||
| return MockIndexPatternSelect; | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| import React from 'react'; | ||
| import { shallow } from 'enzyme'; | ||
| import { BOUNDARIES_SOURCE, LayerTemplate } from './layer_template'; | ||
|
|
||
| const renderWizardArguments = { | ||
| previewLayers: () => {}, | ||
| mapColors: [], | ||
| currentStepId: null, | ||
| enableNextBtn: () => {}, | ||
| disableNextBtn: () => {}, | ||
| startStepLoading: () => {}, | ||
| stopStepLoading: () => {}, | ||
| advanceToNextStep: () => {}, | ||
| }; | ||
|
|
||
| test('should render elasticsearch UI when left source is BOUNDARIES_SOURCE.ELASTICSEARCH', async () => { | ||
| const component = shallow(<LayerTemplate {...renderWizardArguments} />); | ||
| component.setState({ leftSource: BOUNDARIES_SOURCE.ELASTICSEARCH }); | ||
| expect(component).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('should render EMS UI when left source is BOUNDARIES_SOURCE.EMS', async () => { | ||
| const component = shallow(<LayerTemplate {...renderWizardArguments} />); | ||
| component.setState({ leftSource: BOUNDARIES_SOURCE.EMS }); | ||
| expect(component).toMatchSnapshot(); | ||
| }); |
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.