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 5dcb80ec41..4380f36186 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 @@ -57,7 +57,7 @@ export class DataLayerPatternProcessor { public setup(): Observable { if (this.settings.type === DataLayerPatternType.function) { - return parseTbFunction(this.dataLayer.getCtx().http, this.settings.patternFunction, ['data', 'dsData']).pipe( + return parseTbFunction(this.dataLayer.getCtx().http, this.settings.patternFunction, ['data', 'dsData', 'ctx']).pipe( map((parsed) => { this.patternFunction = parsed; return null; @@ -72,7 +72,7 @@ export class DataLayerPatternProcessor { public processPattern(data: FormattedData, dsData: FormattedData[]): string { let pattern: string; if (this.settings.type === DataLayerPatternType.function) { - pattern = safeExecuteTbFunction(this.patternFunction, [data, dsData]); + pattern = safeExecuteTbFunction(this.patternFunction, [data, dsData, this.dataLayer.getCtx()]); } else { pattern = this.pattern; } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-pattern-settings.component.html b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-pattern-settings.component.html index 451d3f7282..be569813dc 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-pattern-settings.component.html +++ b/ui-ngx/src/app/modules/home/components/widget/lib/settings/common/map/data-layer-pattern-settings.component.html @@ -44,7 +44,7 @@ required withModules [globalVariables]="functionScopeVariables" - [functionArgs]="['data', 'dsData']" + [functionArgs]="['data', 'dsData', 'ctx']" functionTitle="{{ (patternType === 'label' ? 'widgets.maps.data-layer.label-function' : 'widgets.maps.data-layer.tooltip-function') | translate }}" [helpId]="helpId" [helpPopupStyle]="{width: '900px'}"> diff --git a/ui-ngx/src/assets/help/en_US/widget/lib/map/label_fn.md b/ui-ngx/src/assets/help/en_US/widget/lib/map/label_fn.md index 0028d77b82..7d85ffed26 100644 --- a/ui-ngx/src/assets/help/en_US/widget/lib/map/label_fn.md +++ b/ui-ngx/src/assets/help/en_US/widget/lib/map/label_fn.md @@ -3,7 +3,7 @@

-*function (data, dsData): string* +*function (data, dsData, ctx): string* A JavaScript function used to compute text or HTML code of the marker label. diff --git a/ui-ngx/src/assets/help/en_US/widget/lib/map/map_fn_args.md b/ui-ngx/src/assets/help/en_US/widget/lib/map/map_fn_args.md index a627e1867f..3df8c8324a 100644 --- a/ui-ngx/src/assets/help/en_US/widget/lib/map/map_fn_args.md +++ b/ui-ngx/src/assets/help/en_US/widget/lib/map/map_fn_args.md @@ -5,4 +5,6 @@ resolved from configured datasources. Each object represents basic entity properties (ex. entityId, entityName)
and provides access to other entity attributes/timeseries declared in datasources of data layers configuration including additional datasources of the map configuration. - +
  • ctx: WidgetContext - A reference to WidgetContext that has all necessary API + and data used by widget instance. +