Browse Source

Dynamic color for data points

pull/4002/head
ponvalavan annamalai 6 years ago
parent
commit
fc40047a5e
  1. 4
      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. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/map-widget2.ts
  4. 7
      ui-ngx/src/app/modules/home/components/widget/trip-animation/trip-animation.component.ts

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

@ -626,10 +626,10 @@ export default abstract class LeafletMap {
} }
this.points = new FeatureGroup(); this.points = new FeatureGroup();
} }
let pointColor = this.options.pointColor;
for (const pointsList of pointsData) { for (const pointsList of pointsData) {
pointsList.filter(pdata => !!this.convertPosition(pdata)).forEach(data => { pointsList.filter(pdata => !!this.convertPosition(pdata)).forEach(data => {
let pointColor = this.options.pointColor; if (this.options.useColorPointFunction) {
if (this.options.useColorPointFunction) {
pointColor = safeExecute(this.options.colorPointFunction,[data, pointsData, data.dsIndex]); pointColor = safeExecute(this.options.colorPointFunction,[data, pointsData, data.dsIndex]);
} }
const point = L.circleMarker(this.convertPosition(data), { const point = L.circleMarker(this.convertPosition(data), {

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

@ -201,7 +201,7 @@ export type TripAnimationSettings = {
pointAsAnchorFunction: GenericFunction; pointAsAnchorFunction: GenericFunction;
tooltipFunction: GenericFunction; tooltipFunction: GenericFunction;
labelFunction: GenericFunction; labelFunction: GenericFunction;
useColorPointFunction: boolean; useColorPointFunction: boolean;
colorPointFunction: GenericFunction; colorPointFunction: GenericFunction;
}; };

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

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

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

@ -112,7 +112,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit, OnDestroy
this.settings.pointAsAnchorFunction = parseFunction(this.settings.pointAsAnchorFunction, ['data', 'dsData', 'dsIndex']); this.settings.pointAsAnchorFunction = parseFunction(this.settings.pointAsAnchorFunction, ['data', 'dsData', 'dsIndex']);
this.settings.tooltipFunction = parseFunction(this.settings.tooltipFunction, ['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.labelFunction = parseFunction(this.settings.labelFunction, ['data', 'dsData', 'dsIndex']);
this.settings.colorPointFunction = parseFunction(this.settings.colorPointFunction, ['data', 'dsData', 'dsIndex']); this.settings.colorPointFunction = parseFunction(this.settings.colorPointFunction, ['data', 'dsData', 'dsIndex']);
this.normalizationStep = this.settings.normalizationStep; this.normalizationStep = this.settings.normalizationStep;
const subscription = this.ctx.defaultSubscription; const subscription = this.ctx.defaultSubscription;
subscription.callbacks.onDataUpdated = () => { subscription.callbacks.onDataUpdated = () => {
@ -179,11 +179,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit, OnDestroy
if (this.settings.showPolygon) { if (this.settings.showPolygon) {
this.mapWidget.map.updatePolygons(this.interpolatedTimeData); this.mapWidget.map.updatePolygons(this.interpolatedTimeData);
} }
if (this.settings.showPoints) { if (this.settings.showPoints || this.settings.useColorPointFunction) {
this.mapWidget.map.updatePoints(formattedInterpolatedTimeData.map(ds => _.union(ds)), this.calcTooltip); 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.mapWidget.map.updateMarkers(currentPosition, true, (trip) => {
this.activeTrip = trip; this.activeTrip = trip;

Loading…
Cancel
Save