diff --git a/x-pack/plugins/maps/public/classes/fields/es_agg_field.ts b/x-pack/plugins/maps/public/classes/fields/es_agg_field.ts index 667ae096e6eac..7b184819b839b 100644 --- a/x-pack/plugins/maps/public/classes/fields/es_agg_field.ts +++ b/x-pack/plugins/maps/public/classes/fields/es_agg_field.ts @@ -5,12 +5,12 @@ */ import { IndexPattern } from 'src/plugins/data/public'; -import { IField, getMbPropertyName } from './field'; +import { IField } from './field'; import { AggDescriptor } from '../../../common/descriptor_types'; import { IESAggSource } from '../sources/es_agg_source'; import { IVectorSource } from '../sources/vector_source'; import { ESDocField } from './es_doc_field'; -import { AGG_TYPE, FIELD_ORIGIN, VECTOR_STYLES } from '../../../common/constants'; +import { AGG_TYPE, FIELD_ORIGIN } from '../../../common/constants'; import { isMetricCountable } from '../util/is_metric_countable'; import { getField, addFieldToDSL } from '../util/es_agg_utils'; import { TopTermPercentageField } from './top_term_percentage_field'; diff --git a/x-pack/plugins/maps/public/classes/fields/field.ts b/x-pack/plugins/maps/public/classes/fields/field.ts index 7e8106a96f2e5..2c190d54f0265 100644 --- a/x-pack/plugins/maps/public/classes/fields/field.ts +++ b/x-pack/plugins/maps/public/classes/fields/field.ts @@ -4,10 +4,9 @@ * you may not use this file except in compliance with the Elastic License. */ -import { FIELD_ORIGIN, VECTOR_STYLES } from '../../../common/constants'; +import { FIELD_ORIGIN } from '../../../common/constants'; import { IVectorSource } from '../sources/vector_source'; import { ITooltipProperty, TooltipProperty } from '../tooltips/tooltip_property'; -import { getComputedFieldName } from '../styles/vector/style_util'; export interface IField { getName(): string; diff --git a/x-pack/plugins/maps/public/classes/fields/top_term_percentage_field.ts b/x-pack/plugins/maps/public/classes/fields/top_term_percentage_field.ts index 0cf432e9d3e78..fc931b13619ef 100644 --- a/x-pack/plugins/maps/public/classes/fields/top_term_percentage_field.ts +++ b/x-pack/plugins/maps/public/classes/fields/top_term_percentage_field.ts @@ -5,11 +5,10 @@ */ import { IESAggField } from './es_agg_field'; -import { getMbPropertyName } from './field'; import { IVectorSource } from '../sources/vector_source'; // @ts-ignore import { ITooltipProperty, TooltipProperty } from '../tooltips/tooltip_property'; -import { TOP_TERM_PERCENTAGE_SUFFIX, VECTOR_STYLES } from '../../../common/constants'; +import { TOP_TERM_PERCENTAGE_SUFFIX } from '../../../common/constants'; import { FIELD_ORIGIN } from '../../../common/constants'; export class TopTermPercentageField implements IESAggField { diff --git a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_orientation_property.ts b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_orientation_property.ts index a81d24a35ad36..e219d3bc857b0 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_orientation_property.ts +++ b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_orientation_property.ts @@ -18,11 +18,13 @@ export class DynamicOrientationProperty extends DynamicStyleProperty }; } - formatField(value: string | number | undefined): string | number { + formatField(value: string | number | undefined | null): string | number { if (this.getField()) { const fieldName = this.getFieldName(); const fieldFormatter = this._getFieldFormatter(fieldName); - return fieldFormatter ? fieldFormatter(value) : super.formatField(value); + return fieldFormatter && value !== null ? fieldFormatter(value) : super.formatField(value); } else { return super.formatField(value); } @@ -388,7 +388,11 @@ export class DynamicStyleProperty } } -export function getNumericalMbFeatureStateValue(value: string | number) { +export function getNumericalMbFeatureStateValue(value: string | number | null | undefined) { + if (typeof value !== 'string') { + return value; + } + const valueAsFloat = parseFloat(value); return isNaN(valueAsFloat) ? null : valueAsFloat; } diff --git a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_text_property.ts b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_text_property.ts index 8bd2c700dd55f..14240300f22c1 100644 --- a/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_text_property.ts +++ b/x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_text_property.ts @@ -30,7 +30,9 @@ export class DynamicTextProperty extends DynamicStyleProperty { isDynamic(): boolean; isComplete(): boolean; - formatField(value: string | number | undefined): string | number; + formatField(value: string | number | undefined | null): string | number; getStyleName(): VECTOR_STYLES; getOptions(): T; renderLegendDetailRow(legendProps: LegendProps): ReactElement | null; @@ -53,9 +53,8 @@ export class AbstractStyleProperty implements IStyleProperty { return true; } - formatField(value: string | number | undefined): string | number { - // eslint-disable-next-line eqeqeq - return value == undefined ? '' : value; + formatField(value: string | number | undefined | null): string | number { + return typeof value === 'undefined' || value === null ? '' : value; } getStyleName(): VECTOR_STYLES {