Browse Source

Dynamic color for data points

pull/4002/head
ponvalavan annamalai 6 years ago
parent
commit
6cd6568ee3
  1. 6
      ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts
  2. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts
  3. 1
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
  4. 16
      ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts
  5. 4
      ui-ngx/src/app/modules/home/components/widget/trip-animation/trip-animation.component.ts

6
ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts

@ -628,8 +628,12 @@ export default abstract class LeafletMap {
}
for (const pointsList of pointsData) {
pointsList.filter(pdata => !!this.convertPosition(pdata)).forEach(data => {
let pointColor = this.options.pointColor;
if (this.options.useColorPointFunction) {
pointColor = safeExecute(this.options.colorPointFunction,[data, pointsData, data.dsIndex]);
}
const point = L.circleMarker(this.convertPosition(data), {
color: this.options.pointColor,
color: pointColor,
radius: this.options.pointSize
});
if (!this.options.pointTooltipOnRightPanel) {

2
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-models.ts

@ -201,6 +201,8 @@ export type TripAnimationSettings = {
pointAsAnchorFunction: GenericFunction;
tooltipFunction: GenericFunction;
labelFunction: GenericFunction;
useColorPointFunction: boolean;
colorPointFunction: GenericFunction;
};
export type actionsHandler = ($event: Event, datasource: Datasource) => void;

1
ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts

@ -301,6 +301,7 @@ export class MapWidgetController implements MapWidgetInterface {
labelFunction: parseFunction(settings.labelFunction, functionParams),
tooltipFunction: parseFunction(settings.tooltipFunction, functionParams),
colorFunction: parseFunction(settings.colorFunction, functionParams),
colorPointFunction: parseFunction(settings.colorPointFunction, functionParams),
polygonColorFunction: parseFunction(settings.polygonColorFunction, functionParams),
polygonTooltipFunction: parseFunction(settings.polygonTooltipFunction, functionParams),
markerImageFunction: parseFunction(settings.markerImageFunction, ['data', 'images', 'dsData', 'dsIndex']),

16
ui-ngx/src/app/modules/home/components/widget/lib/maps/schemes.ts

@ -1036,6 +1036,15 @@ export const tripAnimationSchema = {
title: 'Custom marker image',
type: 'string'
},
useColorPointFunction: {
title: 'Use color point function',
type: 'boolean',
default: false
},
colorPointFunction: {
title: 'Color point function: f(data, dsData, dsIndex)',
type: 'string'
},
markerImageSize: {
title: 'Custom marker image size (px)',
type: 'number',
@ -1081,7 +1090,12 @@ export const tripAnimationSchema = {
}, 'useTooltipFunction', {
key: 'tooltipFunction',
type: 'javascript'
}, 'autocloseTooltip', {
}, 'autocloseTooltip', 'useColorPointFunction',
{
key: 'colorPointFunction',
type: 'javascript'
},
{
key: 'markerImage',
type: 'image'
}, 'markerImageSize', 'rotationAngle', 'useMarkerImageFunction',

4
ui-ngx/src/app/modules/home/components/widget/trip-animation/trip-animation.component.ts

@ -112,6 +112,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit, OnDestroy
this.settings.pointAsAnchorFunction = parseFunction(this.settings.pointAsAnchorFunction, ['data', 'dsData', 'dsIndex']);
this.settings.tooltipFunction = parseFunction(this.settings.tooltipFunction, ['data', 'dsData', 'dsIndex']);
this.settings.labelFunction = parseFunction(this.settings.labelFunction, ['data', 'dsData', 'dsIndex']);
this.settings.colorPointFunction = parseFunction(this.settings.colorPointFunction, ['data', 'dsData', 'dsIndex']);
this.normalizationStep = this.settings.normalizationStep;
const subscription = this.ctx.defaultSubscription;
subscription.callbacks.onDataUpdated = () => {
@ -180,6 +181,9 @@ export class TripAnimationComponent implements OnInit, AfterViewInit, OnDestroy
}
if (this.settings.showPoints) {
this.mapWidget.map.updatePoints(formattedInterpolatedTimeData.map(ds => _.union(ds)), this.calcTooltip);
}
if (this.settings.useColorPointFunction) {
this.mapWidget.map.updatePoints(_.values(_.union(this.interpolatedTimeData)[0]), this.calcTooltip);
}
this.mapWidget.map.updateMarkers(currentPosition, true, (trip) => {
this.activeTrip = trip;

Loading…
Cancel
Save