From 820888f47789c4b91e255db3671dc1811852554b Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Thu, 5 Dec 2019 15:10:00 -0700 Subject: [PATCH] only show less then and greater then in legend when values will be outside of std range --- .../legend/style_property_legend_row.js | 15 +++++++++++---- .../public/layers/styles/vector/vector_style.js | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/legend/style_property_legend_row.js b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/legend/style_property_legend_row.js index 7479bdb907286..dc5098c4d6d4d 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/legend/style_property_legend_row.js +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/legend/style_property_legend_row.js @@ -72,12 +72,12 @@ export class StylePropertyLegendRow extends Component { return !this.props.style.isDynamic() || !this.props.style.isComplete() || !this.props.style.getField().getName(); } - _formatValue = (value, prefix) => { + _formatValue = value => { if (!this.state.hasLoadedFieldFormatter || !this._fieldValueFormatter || value === EMPTY_VALUE) { return value; } - return this.props.style.isFieldMetaEnabled() ? `${prefix} ${this._fieldValueFormatter(value)}` : this._fieldValueFormatter(value); + return this._fieldValueFormatter(value); } render() { @@ -87,11 +87,18 @@ export class StylePropertyLegendRow extends Component { } const header = style.renderHeader(); + + const min = this._formatValue(_.get(range, 'min', EMPTY_VALUE)); + const minLabel = this.props.style.isFieldMetaEnabled() && range && range.isMinOutsideStdRange ? `< ${min}` : min; + + const max = this._formatValue(_.get(range, 'max', EMPTY_VALUE)); + const maxLabel = this.props.style.isFieldMetaEnabled() && range && range.isMaxOutsideStdRange ? `> ${max}` : max; + return ( ')} + minLabel={minLabel} + maxLabel={maxLabel} propertyLabel={getVectorStyleLabel(style.getStyleName())} fieldLabel={this.state.label} /> diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.js b/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.js index 1f30a3a7c38f0..2727e08f7d52c 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.js +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/vector_style.js @@ -329,6 +329,8 @@ export class VectorStyle extends AbstractStyle { min, max, delta: max - min, + isMinOutsideStdRange: stats.min < stdLowerBounds, + isMaxOutsideStdRange: stats.max > stdUpperBounds, }; } }