Fix calculate tooltip
This commit is contained in:
parent
59d2fdc79e
commit
f0be7b8b97
@ -63,9 +63,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
|
|||||||
activeTrip: FormattedData;
|
activeTrip: FormattedData;
|
||||||
label;
|
label;
|
||||||
minTime: number;
|
minTime: number;
|
||||||
minTimeFormat: string;
|
|
||||||
maxTime: number;
|
maxTime: number;
|
||||||
maxTimeFormat: string;
|
|
||||||
anchors: number[] = [];
|
anchors: number[] = [];
|
||||||
useAnchors: boolean;
|
useAnchors: boolean;
|
||||||
currentTime: number;
|
currentTime: number;
|
||||||
@ -97,14 +95,14 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
|
|||||||
this.settings = { ...settings, ...this.ctx.settings };
|
this.settings = { ...settings, ...this.ctx.settings };
|
||||||
this.useAnchors = this.settings.showPoints && this.settings.usePointAsAnchor;
|
this.useAnchors = this.settings.showPoints && this.settings.usePointAsAnchor;
|
||||||
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.labelFunction = parseFunction(this.settings.labelFunction, ['data', 'dsData', 'dsIndex']);
|
||||||
this.settings.fitMapBounds = true;
|
this.settings.fitMapBounds = true;
|
||||||
this.normalizationStep = this.settings.normalizationStep;
|
this.normalizationStep = this.settings.normalizationStep;
|
||||||
const subscription = this.ctx.subscriptions[Object.keys(this.ctx.subscriptions)[0]];
|
const subscription = this.ctx.subscriptions[Object.keys(this.ctx.subscriptions)[0]];
|
||||||
if (subscription) subscription.callbacks.onDataUpdated = () => {
|
if (subscription) subscription.callbacks.onDataUpdated = () => {
|
||||||
this.historicalData = parseArray(this.ctx.data).filter(arr => arr.length);
|
this.historicalData = parseArray(this.ctx.data).filter(arr => arr.length);
|
||||||
if (this.historicalData.length) {
|
if (this.historicalData.length) {
|
||||||
if (!this.activeTrip)
|
|
||||||
this.activeTrip = this.historicalData[0][0];
|
|
||||||
this.calculateIntervals();
|
this.calculateIntervals();
|
||||||
this.timeUpdated(this.currentTime ? this.currentTime : this.minTime);
|
this.timeUpdated(this.currentTime ? this.currentTime : this.minTime);
|
||||||
}
|
}
|
||||||
@ -167,6 +165,9 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
|
|||||||
const maxTimeFormat = this.maxTime !== -Infinity ? moment(this.maxTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
const maxTimeFormat = this.maxTime !== -Infinity ? moment(this.maxTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
||||||
this.interpolatedTimeData[index] = this.interpolateArray(dataSource, minTimeFormat, maxTimeFormat);
|
this.interpolatedTimeData[index] = this.interpolateArray(dataSource, minTimeFormat, maxTimeFormat);
|
||||||
});
|
});
|
||||||
|
if(!this.activeTrip){
|
||||||
|
this.activeTrip = this.interpolatedTimeData.map(dataSource => dataSource[this.minTime]).filter(ds => ds)[0];
|
||||||
|
}
|
||||||
if (this.useAnchors) {
|
if (this.useAnchors) {
|
||||||
const anchorDate = Object.entries(_.union(this.interpolatedTimeData)[0]);
|
const anchorDate = Object.entries(_.union(this.interpolatedTimeData)[0]);
|
||||||
this.anchors = anchorDate
|
this.anchors = anchorDate
|
||||||
@ -181,7 +182,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
const data = this.activeTrip;
|
const data = this.activeTrip;
|
||||||
const tooltipPattern: string = this.settings.useTooltipFunction ?
|
const tooltipPattern: string = this.settings.useTooltipFunction ?
|
||||||
safeExecute(this.settings.tooolTipFunction, [data, this.historicalData, point.dsIndex]) : this.settings.tooltipPattern;
|
safeExecute(this.settings.tooltipFunction, [point, this.historicalData, point.dsIndex]) : this.settings.tooltipPattern;
|
||||||
const tooltipText = parseWithTranslation.parseTemplate(tooltipPattern, data, true);
|
const tooltipText = parseWithTranslation.parseTemplate(tooltipPattern, data, true);
|
||||||
if (setTooltip) {
|
if (setTooltip) {
|
||||||
this.mainTooltip = this.sanitizer.sanitize(
|
this.mainTooltip = this.sanitizer.sanitize(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user