Merge pull request #3935 from vvlladd28/bugs/map-chart

[3.x] Fixed bugs in chart and map widgets
This commit is contained in:
Igor Kulikov 2021-01-13 16:34:56 +02:00 committed by GitHub
commit b83811eb3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -388,7 +388,7 @@ export class TbFlot {
item.settings = {}; item.settings = {};
}); });
subscription.datasources.forEach((item) => { subscription.datasources.forEach((item) => {
let datasource: Datasource = { const datasource: Datasource = {
type: item.type, type: item.type,
entityType: item.entityType, entityType: item.entityType,
entityId: item.entityId, entityId: item.entityId,
@ -829,7 +829,7 @@ export class TbFlot {
useDashboardTimewindow: false, useDashboardTimewindow: false,
type: widgetType.latest, type: widgetType.latest,
callbacks: { callbacks: {
onDataUpdated: (subscription) => {this.thresholdsSourcesDataUpdated(subscription.data)} onDataUpdated: (subscription) => this.thresholdsSourcesDataUpdated(subscription.data)
} }
}; };
this.ctx.subscriptionApi.createSubscription(thresholdsSourcesSubscriptionOptions, true).subscribe( this.ctx.subscriptionApi.createSubscription(thresholdsSourcesSubscriptionOptions, true).subscribe(
@ -896,7 +896,7 @@ export class TbFlot {
type: widgetType.latest, type: widgetType.latest,
callbacks: { callbacks: {
onDataUpdated: (subscription) => { onDataUpdated: (subscription) => {
this.labelPatternsParamsDataUpdated(subscription.data) this.labelPatternsParamsDataUpdated(subscription.data);
} }
} }
}; };
@ -918,22 +918,22 @@ export class TbFlot {
} }
private substituteLabelPatterns(series: TbFlotSeries, seriesIndex: number) { private substituteLabelPatterns(series: TbFlotSeries, seriesIndex: number) {
let seriesLabelPatternsSourcesData = this.labelPatternsSourcesData.filter((item) => { const seriesLabelPatternsSourcesData = this.labelPatternsSourcesData.filter((item) => {
return item.datasource.entityId === series.datasource.entityId; return item.datasource.entityId === series.datasource.entityId;
}); });
let label = createLabelFromDatasource(series.datasource, series.dataKey.pattern); let label = createLabelFromDatasource(series.datasource, series.dataKey.pattern);
for (let i = 0; i < seriesLabelPatternsSourcesData.length; i++) { for (let i = 0; i < seriesLabelPatternsSourcesData.length; i++) {
let keyData = seriesLabelPatternsSourcesData[i]; const keyData = seriesLabelPatternsSourcesData[i];
if (keyData && keyData.data && keyData.data[0]) { if (keyData && keyData.data && keyData.data[0]) {
let attrValue = keyData.data[0][1]; const attrValue = keyData.data[0][1];
let attrName = keyData.dataKey.name; const attrName = keyData.dataKey.name;
if (isDefined(attrValue) && (attrValue !== null)) { if (isDefined(attrValue) && (attrValue !== null)) {
label = insertVariable(label, attrName, attrValue); label = insertVariable(label, attrName, attrValue);
} }
} }
} }
if (isDefined(this.subscription.legendData)) { if (isDefined(this.subscription.legendData)) {
let targetLegendKeyIndex = this.subscription.legendData.keys.findIndex((key) => { const targetLegendKeyIndex = this.subscription.legendData.keys.findIndex((key) => {
return key.dataIndex === seriesIndex; return key.dataIndex === seriesIndex;
}); });
if (targetLegendKeyIndex !== -1) { if (targetLegendKeyIndex !== -1) {
@ -1098,7 +1098,7 @@ export class TbFlot {
flex: '1' flex: '1'
}); });
let columnContent = ''; let columnContent = '';
for (let i = c*maxRows; i < (c+1)*maxRows; i++) { for (let i = c * maxRows; i < (c + 1) * maxRows; i++) {
if (i >= hoverData.seriesHover.length) { if (i >= hoverData.seriesHover.length) {
break; break;
} }
@ -1287,7 +1287,7 @@ export class TbFlot {
let minTimeHistorical: any; let minTimeHistorical: any;
let hoverData: TbFlotSeriesHoverInfo; let hoverData: TbFlotSeriesHoverInfo;
let value: any; let value: any;
let lastValue: any; let lastValue = 0;
let minDistanceHistorical: number; let minDistanceHistorical: number;
const results: TbFlotHoverInfo[] = [{ const results: TbFlotHoverInfo[] = [{
seriesHover: [] seriesHover: []

View File

@ -581,10 +581,10 @@ export default abstract class LeafletMap {
const marker: Marker = this.markers.get(key); const marker: Marker = this.markers.get(key);
const location = this.convertPosition(data); const location = this.convertPosition(data);
marker.updateMarkerPosition(location); marker.updateMarkerPosition(location);
marker.setDataSources(data, dataSources);
if (settings.showTooltip) { if (settings.showTooltip) {
marker.updateMarkerTooltip(data); marker.updateMarkerTooltip(data);
} }
marker.setDataSources(data, dataSources);
marker.updateMarkerIcon(settings); marker.updateMarkerIcon(settings);
return marker; return marker;
} }