-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Maps] Move legend rendering to style property #53173
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
thomasneirynck
merged 14 commits into
elastic:master
from
thomasneirynck:chore/move_legend
Dec 18, 2019
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
caa6cea
Move legend
thomasneirynck a6d3f58
Merge branch 'master' into chore/move_legend
elasticmachine 752b48d
Merge branch 'master' into chore/move_legend
elasticmachine 1adadcd
[Maps] gather field formatters in data request so they can be used sy…
nreese 08dbd14
review feedback
nreese 48982f8
hasMatchingMetricField
nreese b3e8265
review feedback
nreese c94dddc
Merge branch 'field_format_data_request' of https://github.com/nreese…
thomasneirynck 168170b
load ff sync
thomasneirynck 565eec2
feedback
thomasneirynck e9e0d37
make field-formatting accessible in the style
thomasneirynck c6887bc
linting
thomasneirynck 2923fbc
Merge branch 'master' into chore/move_legend2
thomasneirynck 0af75da
review feedback
thomasneirynck 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
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
57 changes: 0 additions & 57 deletions
57
...y/plugins/maps/public/layers/styles/vector/components/legend/style_property_legend_row.js
This file was deleted.
Oops, something went wrong.
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
81 changes: 81 additions & 0 deletions
81
...gacy/plugins/maps/public/layers/styles/vector/properties/components/dynamic_legend_row.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,81 @@ | ||
| /* | ||
| * 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 _ from 'lodash'; | ||
| import { RangedStyleLegendRow } from '../../../components/ranged_style_legend_row'; | ||
| import { getVectorStyleLabel } from '../../components/get_vector_style_label'; | ||
|
|
||
| const EMPTY_VALUE = ''; | ||
|
|
||
| export class DynamicLegendRow extends React.Component { | ||
| constructor() { | ||
| super(); | ||
| this._isMounted = false; | ||
| this.state = { | ||
| label: EMPTY_VALUE, | ||
| }; | ||
| } | ||
|
|
||
| async _loadParams() { | ||
| const label = await this.props.style.getField().getLabel(); | ||
| const newState = { label }; | ||
| if (this._isMounted && !_.isEqual(this.state, newState)) { | ||
| this.setState(newState); | ||
| } | ||
| } | ||
|
|
||
| componentDidUpdate() { | ||
| this._loadParams(); | ||
| } | ||
|
|
||
| componentWillUnmount() { | ||
| this._isMounted = false; | ||
| } | ||
|
|
||
| componentDidMount() { | ||
| this._isMounted = true; | ||
| this._loadParams(); | ||
| } | ||
|
|
||
| _formatValue(value) { | ||
| if (value === EMPTY_VALUE) { | ||
| return value; | ||
| } | ||
| return this.props.style.formatField(value); | ||
| } | ||
|
|
||
| render() { | ||
| const fieldMeta = this.props.style.getFieldMeta(); | ||
|
|
||
| let minLabel = EMPTY_VALUE; | ||
| let maxLabel = EMPTY_VALUE; | ||
| if (fieldMeta) { | ||
| const range = { min: fieldMeta.min, max: fieldMeta.max }; | ||
| const min = this._formatValue(_.get(range, 'min', EMPTY_VALUE)); | ||
| minLabel = | ||
| this.props.style.isFieldMetaEnabled() && range && range.isMinOutsideStdRange | ||
| ? `< ${min}` | ||
| : min; | ||
|
|
||
| const max = this._formatValue(_.get(range, 'max', EMPTY_VALUE)); | ||
| maxLabel = | ||
| this.props.style.isFieldMetaEnabled() && range && range.isMaxOutsideStdRange | ||
| ? `> ${max}` | ||
| : max; | ||
| } | ||
|
|
||
| return ( | ||
| <RangedStyleLegendRow | ||
| header={this.props.style.renderLegendHeader()} | ||
| minLabel={minLabel} | ||
| maxLabel={maxLabel} | ||
| propertyLabel={getVectorStyleLabel(this.props.style.getStyleName())} | ||
| fieldLabel={this.state.label} | ||
| /> | ||
| ); | ||
| } | ||
| } |
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.