diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/map-data-layer.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/map-data-layer.ts index 3ae61642ce..ad1f8c17e9 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/map-data-layer.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/map-data-layer.ts @@ -15,15 +15,24 @@ /// import { - DataLayerColorSettings, DataLayerColorType, - DataLayerPatternSettings, DataLayerPatternType, - MapDataLayerSettings, MapDataLayerType, mapDataSourceSettingsToDatasource, - MapStringFunction, MapType, + DataLayerColorSettings, + DataLayerColorType, + DataLayerPatternSettings, + DataLayerPatternType, + MapDataLayerSettings, + MapDataLayerType, + mapDataSourceSettingsToDatasource, + MapStringFunction, + MapType, TbMapDatasource } from '@shared/models/widget/maps/map.models'; import { createLabelFromPattern, - guid, isDefined, + guid, + isDefined, + isDefinedAndNotNull, + isNumber, + isNumeric, mergeDeepIgnoreArray, parseTbFunction, safeExecuteTbFunction @@ -32,10 +41,11 @@ import L from 'leaflet'; import { CompiledTbFunction } from '@shared/models/js-function.models'; import { forkJoin, Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; -import { FormattedData } from '@shared/models/widget.models'; +import { DataKey, FormattedData } from '@shared/models/widget.models'; import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; import { TbMap } from '@home/components/widget/lib/maps/map'; import { WidgetContext } from '@home/models/widget-component.models'; +import { ColorRange } from '@shared/models/widget-settings.models'; export class DataLayerPatternProcessor { @@ -77,22 +87,26 @@ export class DataLayerColorProcessor { private colorFunction: CompiledTbFunction; private color: string; + private rangeKey: DataKey; + private range: ColorRange[]; constructor(private dataLayer: TbMapDataLayer, private settings: DataLayerColorSettings) {} public setup(): Observable { this.color = this.settings.color; - if (this.settings.type === DataLayerColorType.function) { + if (this.settings.type === DataLayerColorType.range) { + this.rangeKey = this.settings.rangeKey; + this.range = this.settings.range; + } else if (this.settings.type === DataLayerColorType.function) { return parseTbFunction(this.dataLayer.getCtx().http, this.settings.colorFunction, ['data', 'dsData']).pipe( map((parsed) => { this.colorFunction = parsed; return null; }) ); - } else { - return of(null) } + return of(null) } public processColor(data: FormattedData, dsData: FormattedData[]): string { @@ -102,12 +116,33 @@ export class DataLayerColorProcessor { if (!color) { color = this.color; } + } else if (this.settings.type === DataLayerColorType.range) { + color = this.color; + if (this.rangeKey && this.range?.length) { + const value = data[this.rangeKey.label]; + if (isDefinedAndNotNull(value) && isNumeric(value)) { + const num = Number(value); + for (const range of this.range) { + if (DataLayerColorProcessor.constantRange(range) && range.from === num) { + color = range.color; + break; + } else if ((!isNumber(range.from) || num >= range.from) && (!isNumber(range.to) || num < range.to)) { + color = range.color; + break; + } + } + } + } } else { color = this.color; } return color; } + static constantRange(range: ColorRange): boolean { + return isNumber(range.from) && isNumber(range.to) && range.from === range.to; + } + } export abstract class TbDataLayerItem { @@ -169,6 +204,9 @@ export abstract class TbMapDataLayer { this.datasource = mapDataSourceSettingsToDatasource(this.settings); this.datasource.dataKeys = this.settings.additionalDataKeys ? [...this.settings.additionalDataKeys] : []; + const colorRangeKeys = this.allColorSettings().filter(settings => settings.type === DataLayerColorType.range && settings.rangeKey) + .map(settings => settings.rangeKey); + this.datasource.dataKeys.push(...colorRangeKeys); this.mapDataId = this.datasource.mapDataIds[0]; this.datasource = this.setupDatasource(this.datasource); return forkJoin( @@ -251,6 +289,10 @@ export abstract class TbMapDataLayer { @@ -218,8 +221,7 @@ abstract class MarkerIconProcessor { abstract class BaseColorMarkerShapeProcessor extends MarkerIconProcessor { - private markerColorFunction: CompiledTbFunction; - + private colorProcessor: DataLayerColorProcessor; private defaultMarkerIconInfo: MarkerIconInfo; protected constructor(protected dataProcessor: MarkerDataProcessor, @@ -229,40 +231,28 @@ abstract class BaseColorMarkerShapeProcessor public setup(): Observable { const colorSettings = this.settings.color; - if (colorSettings.type === DataLayerColorType.function) { - return parseTbFunction(this.dataProcessor.dataLayer.getCtx().http, colorSettings.colorFunction, ['data', 'dsData']).pipe( - map((parsed) => { - this.markerColorFunction = parsed; - return null; - }) - ); - } else { + this.colorProcessor = new DataLayerColorProcessor(this.dataProcessor.dataLayer, colorSettings); + const setup$: Observable[] = [this.colorProcessor.setup()]; + if (colorSettings.type === DataLayerColorType.constant) { const color = tinycolor(colorSettings.color); - return this.createMarkerShape(color, 0, this.settings.size).pipe( - map((info) => { - this.defaultMarkerIconInfo = info; - return null; - } - )); + setup$.push( + this.createMarkerShape(color, 0, this.settings.size).pipe( + map((info) => { + this.defaultMarkerIconInfo = info; + return null; + })) + ); } + return forkJoin(setup$).pipe(map(() => null)); } public createMarkerIcon(data: FormattedData, dsData: FormattedData[], rotationAngle = 0): Observable { const colorSettings = this.settings.color; - let color: tinycolor.Instance; - if (colorSettings.type === DataLayerColorType.function) { - const functionColor = safeExecuteTbFunction(this.markerColorFunction, [data, dsData]); - if (isDefinedAndNotNull(functionColor)) { - color = tinycolor(functionColor); - } else { - color = tinycolor(colorSettings.color); - } - return this.createMarkerShape(color, rotationAngle, this.settings.size); - } else if (rotationAngle === 0) { + if (colorSettings.type === DataLayerColorType.constant && rotationAngle === 0) { return of(this.defaultMarkerIconInfo); } else { - color = tinycolor(colorSettings.color); - return this.createMarkerShape(color, rotationAngle, this.settings.size); + const color = this.colorProcessor.processColor(data, dsData); + return this.createMarkerShape(tinycolor(color), rotationAngle, this.settings.size); } } @@ -639,6 +629,15 @@ export class TbMarkersDataLayer extends TbLatestMapDataLayer): Partial { return defaultBaseMarkersDataLayerSettings(map.type()); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/shapes-data-layer.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/shapes-data-layer.ts index ec6c5aba80..836b0e7947 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/shapes-data-layer.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/shapes-data-layer.ts @@ -14,7 +14,7 @@ /// limitations under the License. /// -import { ShapeDataLayerSettings, TbMapDatasource } from '@shared/models/widget/maps/map.models'; +import { DataLayerColorSettings, ShapeDataLayerSettings, TbMapDatasource } from '@shared/models/widget/maps/map.models'; import L from 'leaflet'; import { TbMap } from '@home/components/widget/lib/maps/map'; import { forkJoin, Observable } from 'rxjs'; @@ -45,6 +45,10 @@ export abstract class TbShapesDataLayer { this.fillColorProcessor = new DataLayerColorProcessor(this, this.settings.fillColor); this.strokeColorProcessor = new DataLayerColorProcessor(this, this.settings.strokeColor); diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts index d6cbe5e4c9..e598685786 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/data-layer/trips-data-layer.ts @@ -16,16 +16,16 @@ import { calculateInterpolationRatio, - calculateLastPoints, + calculateLastPoints, DataLayerColorSettings, DataLayerColorType, defaultBaseTripsDataLayerSettings, findRotationAngle, interpolateLineSegment, - MapDataLayerType, + MapDataLayerType, MarkerType, TbMapDatasource, TripsDataLayerSettings } from '@shared/models/widget/maps/map.models'; import { forkJoin, Observable } from 'rxjs'; -import { FormattedData, WidgetActionType } from '@shared/models/widget.models'; +import { DataKey, FormattedData, WidgetActionType } from '@shared/models/widget.models'; import { map } from 'rxjs/operators'; import L from 'leaflet'; import { deepClone, isDefined, isUndefined } from '@core/utils'; @@ -530,9 +530,14 @@ export class TbTripsDataLayer extends TbMapDataLayer settings.type === DataLayerColorType.range && settings.rangeKey) + .map(settings => settings.rangeKey); if (this.settings.additionalDataKeys?.length) { - const tsKeys = this.settings.additionalDataKeys.filter(key => key.type === DataKeyType.timeseries); - const latestKeys = this.settings.additionalDataKeys.filter(key => key.type !== DataKeyType.timeseries); + additionalKeys.push(...this.settings.additionalDataKeys); + } + if (additionalKeys.length) { + const tsKeys = additionalKeys.filter(key => key.type === DataKeyType.timeseries); + const latestKeys = additionalKeys.filter(key => key.type !== DataKeyType.timeseries); datasource.dataKeys.push(...tsKeys); if (latestKeys.length) { datasource.latestDataKeys = latestKeys; @@ -541,6 +546,24 @@ export class TbTripsDataLayer extends TbMapDataLayer): Partial { return defaultBaseTripsDataLayerSettings(map.type()); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts index b0b677e2b0..f7c68fec3d 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.ts @@ -85,6 +85,10 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On @Input() datasource: Datasource; + @Input() + @coerceBoolean() + simpleRange = false; + @Input() @coerceBoolean() advancedMode = false; @@ -133,7 +137,7 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On writeValue(value: any): void { if (value) { let rangeList: ColorRangeSettings = {}; - if (isUndefined(value?.advancedMode) && value?.length) { + if (this.simpleRange || (isUndefined(value?.advancedMode) && value?.length)) { rangeList.advancedMode = false; rangeList.range = value; } else { @@ -229,7 +233,11 @@ export class ColorRangeListComponent implements OnInit, ControlValueAccessor, On } updateModel() { - this.propagateChange(this.colorRangeListFormGroup.value); + if (this.simpleRange) { + this.propagateChange(this.colorRangeListFormGroup.get('range').value); + } else { + this.propagateChange(this.colorRangeListFormGroup.value); + } } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.html index e512e06a32..51cbc572a5 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.html @@ -22,6 +22,9 @@ {{ 'widgets.maps.data-layer.color-type-constant' | translate }} + + {{ 'widgets.maps.data-layer.color-type-range' | translate }} + {{ 'widgets.maps.data-layer.color-type-function' | translate }} @@ -35,6 +38,35 @@
+
+ + +
+
widgets.maps.data-layer.color-range
+ + +
+
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.scss b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.scss index b3d0e20de8..47ab07639b 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.scss +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.scss @@ -16,6 +16,8 @@ @import '../../../../../../../../../scss/constants'; .tb-data-layer-color-settings-panel { + --mdc-outlined-text-field-outline-color: rgba(0,0,0,0.12); + --mat-form-field-trailing-icon-color: rgba(0,0,0,0.38); width: 700px; max-width: 90vw; min-height: 300px; @@ -50,4 +52,14 @@ justify-content: flex-end; align-items: flex-end; } + .tb-color-ranges-panel { + flex: 1; + min-height: 0; + gap: 16px; + display: flex; + flex-direction: column; + .tb-color-ranges { + --mat-icon-color: rgba(0, 0, 0, 0.38); + } + } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.ts index 2ce10c25ed..895fb3e782 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component.ts @@ -17,12 +17,15 @@ import { Component, DestroyRef, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; import { PageComponent } from '@shared/components/page.component'; import { TbPopoverComponent } from '@shared/components/popover.component'; -import { UntypedFormBuilder, UntypedFormGroup } from '@angular/forms'; +import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; import { WidgetService } from '@core/http/widget.service'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { DataLayerColorSettings, DataLayerColorType } from '@shared/models/widget/maps/map.models'; +import { DataLayerColorSettings, DataLayerColorType, MapType } from '@shared/models/widget/maps/map.models'; +import { DataKey, DatasourceType, widgetType } from '@shared/models/widget.models'; +import { DataKeyType } from '@shared/models/telemetry/telemetry.models'; +import { MapSettingsContext } from '@home/components/widget/lib/settings/common/map/map-settings.component.models'; @Component({ selector: 'tb-data-layer-color-settings-panel', @@ -33,9 +36,25 @@ import { DataLayerColorSettings, DataLayerColorType } from '@shared/models/widge }) export class DataLayerColorSettingsPanelComponent extends PageComponent implements OnInit { + widgetType = widgetType; + + DataKeyType = DataKeyType; + @Input() colorSettings: DataLayerColorSettings; + @Input() + context: MapSettingsContext; + + @Input() + dsType: DatasourceType; + + @Input() + dsEntityAliasId: string; + + @Input() + dsDeviceId: string; + @Input() helpId = 'widget/lib/map/color_fn'; @@ -63,14 +82,18 @@ export class DataLayerColorSettingsPanelComponent extends PageComponent implemen { type: [this.colorSettings?.type || DataLayerColorType.constant, []], color: [this.colorSettings?.color, []], + rangeKey: [this.colorSettings?.rangeKey, [Validators.required]], + range: [this.colorSettings?.range, []], colorFunction: [this.colorSettings?.colorFunction, []] } ); this.colorSettingsFormGroup.get('type').valueChanges.pipe( takeUntilDestroyed(this.destroyRef) ).subscribe(() => { + this.updateValidators(); setTimeout(() => {this.popover?.updatePosition();}, 0); }); + this.updateValidators(); } cancel() { @@ -82,4 +105,25 @@ export class DataLayerColorSettingsPanelComponent extends PageComponent implemen this.colorSettingsApplied.emit(colorSettings); } + public editRangeKey() { + const targetDataKey: DataKey = this.colorSettingsFormGroup.get('rangeKey').value; + this.context.editKey(targetDataKey, + this.dsDeviceId, this.dsEntityAliasId, widgetType.latest).subscribe( + (updatedDataKey) => { + if (updatedDataKey) { + this.colorSettingsFormGroup.get('rangeKey').patchValue(updatedDataKey); + this.colorSettingsFormGroup.markAsDirty(); + } + } + ); + } + + private updateValidators() { + const type: DataLayerColorType = this.colorSettingsFormGroup.get('type').value; + if (type === DataLayerColorType.range) { + this.colorSettingsFormGroup.get('rangeKey').enable({emitEvent: false}); + } else { + this.colorSettingsFormGroup.get('rangeKey').disable({emitEvent: false}); + } + } } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings.component.ts index 75cfb9c7bc..5f56bd85c3 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-color-settings.component.ts @@ -16,13 +16,15 @@ import { Component, forwardRef, Input, Renderer2, ViewContainerRef } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import { ComponentStyle } from '@shared/models/widget-settings.models'; +import { ColorType, ComponentStyle } from '@shared/models/widget-settings.models'; import { MatButton } from '@angular/material/button'; import { TbPopoverService } from '@shared/components/popover.service'; import { DataLayerColorSettings, DataLayerColorType } from '@shared/models/widget/maps/map.models'; import { DataLayerColorSettingsPanelComponent } from '@home/components/widget/lib/settings/common/map/data-layer-color-settings-panel.component'; +import { MapSettingsContext } from '@home/components/widget/lib/settings/common/map/map-settings.component.models'; +import { DatasourceType } from '@shared/models/widget.models'; @Component({ selector: 'tb-data-layer-color-settings', @@ -41,6 +43,18 @@ export class DataLayerColorSettingsComponent implements ControlValueAccessor { @Input() disabled: boolean; + @Input() + context: MapSettingsContext; + + @Input() + dsType: DatasourceType; + + @Input() + dsEntityAliasId: string; + + @Input() + dsDeviceId: string; + @Input() helpId = 'widget/lib/map/color_fn'; @@ -85,6 +99,10 @@ export class DataLayerColorSettingsComponent implements ControlValueAccessor { } else { const ctx: any = { colorSettings: this.modelValue, + context: this.context, + dsType: this.dsType, + dsEntityAliasId: this.dsEntityAliasId, + dsDeviceId: this.dsDeviceId, helpId: this.helpId }; const colorSettingsPanelPopover = this.popoverService.displayPopover(trigger, this.renderer, @@ -103,11 +121,23 @@ export class DataLayerColorSettingsComponent implements ControlValueAccessor { } private updateColorStyle() { - if (!this.disabled && this.modelValue) { - if (this.modelValue.type === DataLayerColorType.constant) { - this.colorStyle = {backgroundColor: this.modelValue.color}; + if (!this.disabled && this.modelValue && this.modelValue.type !== DataLayerColorType.function) { + let colors: string[] = [this.modelValue.color]; + const rangeList = this.modelValue.range; + if (this.modelValue.type === DataLayerColorType.range && rangeList?.length) { + const rangeColors = rangeList.slice(0, Math.min(2, rangeList.length)).map(r => r.color); + colors = colors.concat(rangeColors); + } + if (colors.length === 1) { + this.colorStyle = {backgroundColor: colors[0]}; } else { - this.colorStyle = {}; + const gradientValues: string[] = []; + const step = 100 / colors.length; + for (let i = 0; i < colors.length; i++) { + gradientValues.push(`${colors[i]} ${step*i}%`); + gradientValues.push(`${colors[i]} ${step*(i+1)}%`); + } + this.colorStyle = {background: `linear-gradient(90deg, ${gradientValues.join(', ')})`}; } } else { this.colorStyle = {}; diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-data-layer-dialog.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-data-layer-dialog.component.html index e4ae3a1c58..803cdd01f1 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-data-layer-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/map-data-layer-dialog.component.html @@ -200,11 +200,21 @@
widgets.maps.data-layer.marker.shape
- +
widgets.maps.data-layer.marker.icon
- +
widgets.maps.data-layer.marker.image
@@ -275,7 +285,12 @@ px - +
@@ -361,7 +376,12 @@ px - +
widgets.maps.data-layer.fill-color
- +
widgets.maps.data-layer.stroke
@@ -388,7 +413,12 @@ px - +
diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.html index 0a78698f0f..0ee3b1de37 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.html @@ -30,5 +30,9 @@
- + diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.ts index 14e80e4fd2..4400c5a151 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/marker-shape-settings.component.ts @@ -49,6 +49,8 @@ import { coerceBoolean } from '@shared/decorators/coercion'; import { MarkerIconShapesComponent } from '@home/components/widget/lib/settings/common/map/marker-icon-shapes.component'; +import { MapSettingsContext } from '@home/components/widget/lib/settings/common/map/map-settings.component.models'; +import { DatasourceType } from '@shared/models/widget.models'; @Component({ selector: 'tb-marker-shape-settings', @@ -69,6 +71,18 @@ export class MarkerShapeSettingsComponent implements ControlValueAccessor, OnIni @Input() disabled: boolean; + @Input() + context: MapSettingsContext; + + @Input() + dsType: DatasourceType; + + @Input() + dsEntityAliasId: string; + + @Input() + dsDeviceId: string; + @Input() markerType: MarkerType; diff --git a/ui-ngx/src/app/shared/models/widget/maps/map.models.ts b/ui-ngx/src/app/shared/models/widget/maps/map.models.ts index 06083f4298..1884e86215 100644 --- a/ui-ngx/src/app/shared/models/widget/maps/map.models.ts +++ b/ui-ngx/src/app/shared/models/widget/maps/map.models.ts @@ -41,7 +41,7 @@ import { Observable, Observer, of, switchMap } from 'rxjs'; import { map } from 'rxjs/operators'; import { ImagePipe } from '@shared/pipe/image.pipe'; import { MarkerIconContainer, MarkerShape } from '@shared/models/widget/maps/marker-shape.models'; -import { DateFormatSettings, simpleDateFormat } from '@shared/models/widget-settings.models'; +import { ColorRange, DateFormatSettings, simpleDateFormat } from '@shared/models/widget-settings.models'; export enum MapType { geoMap = 'geoMap', @@ -233,12 +233,15 @@ export enum MarkerType { export enum DataLayerColorType { constant = 'constant', + range = 'range', function = 'function' } export interface DataLayerColorSettings { type: DataLayerColorType; color: string; + rangeKey?: DataKey; + range?: ColorRange[]; colorFunction?: TbFunction; } diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index eede6bb27e..eacc85992d 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -7979,7 +7979,11 @@ "stroke": "Stroke", "color-settings": "Color settings", "color-type-constant": "Constant", + "color-type-range": "Range", "color-type-function": "Function", + "color-range-source-key": "Color range source key", + "color-range-source-key-required": "Color range source key is required", + "color-range": "Color range", "color-function": "Color function", "label": "Label", "tooltip": "Tooltip",