Skip to content

Commit

Permalink
Merge pull request #142 from fledge-iot/FOGL-6144
Browse files Browse the repository at this point in the history
FOGL-6144: fixed erroneously merges gaps in time series data
  • Loading branch information
mshariq-nerd authored Jan 17, 2022
2 parents 09df8b0 + 087a822 commit 7b18c41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
13 changes: 5 additions & 8 deletions src/app/components/common/chart/chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,9 @@ export class ChartComponent implements OnInit, OnChanges, OnDestroy {
ngOnInit() { }

ngOnChanges() {
// set alpha only for asset reading graphs
if (this.from && this.from !== 'dashboard' && this.rangeSliderService.getAlphControlStatus()) {
this.setAlpha();
}
if (this.chart) {
if (!isEmpty(this.data)) {
this.chart.data.datasets.forEach((dataset) => {
dataset.data = this.data.datasets.find(d => dataset.label === d.label).data;
});
this.chart.data.labels = this.data.labels;
this.chart.data = this.data;
this.chart.update(0);
}
} else {
Expand All @@ -45,6 +38,10 @@ export class ChartComponent implements OnInit, OnChanges, OnDestroy {
this.chart.update(0);
}
}
// set alpha only for asset reading graphs
if (this.from && this.from !== 'dashboard' && this.rangeSliderService.getAlphControlStatus()) {
this.setAlpha();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class ReadingsGraphComponent implements OnDestroy {
}

if (this.selectedTab === 1 && this.numberTypeReadingsList.length > 0) {
this.statsAssetReadingsGraph(this.numberTypeReadingsList, this.timestamps);
this.statsAssetReadingsGraph(this.numberTypeReadingsList);
} else if (this.selectedTab === 2 && this.arrayTypeReadingsList.length > 0) {
this.create3DGraph(this.arrayTypeReadingsList, this.timestamps);
}
Expand All @@ -321,11 +321,14 @@ export class ReadingsGraphComponent implements OnDestroy {
}).value();
}

private statsAssetReadingsGraph(assetReadings: any, ts: any): void {
const timestamps = ts.map((t: any) => this.dateFormatter.transform(t, 'HH:mm:ss'));
private statsAssetReadingsGraph(assetReadings: any): void {
const dataset = [];
assetReadings = orderBy(assetReadings, [reading => reading.key.toLowerCase()], ['asc']);
for (const r of assetReadings) {
r.read = r.read.map(dt => {
dt.x = this.dateFormatter.transform(dt.x, 'YYYY-MM-DD HH:mm:ss')
return dt;
});
const dsColor = Utils.namedColor(dataset.length);
const dt = {
label: r.key,
Expand All @@ -340,7 +343,7 @@ export class ReadingsGraphComponent implements OnDestroy {
dataset.push(dt);
}
}
this.setAssetReadingValues(dataset, timestamps);
this.setAssetReadingValues(dataset);
}

getColorCode(readKey, dsColor) {
Expand Down Expand Up @@ -370,9 +373,8 @@ export class ReadingsGraphComponent implements OnDestroy {
}
}

private setAssetReadingValues(ds: any, timestamps) {
private setAssetReadingValues(ds: any) {
this.assetReadingValues = {
labels: timestamps,
datasets: ds
};

Expand All @@ -384,6 +386,7 @@ export class ReadingsGraphComponent implements OnDestroy {
scales: {
xAxes: [{
distribution: 'linear',
type: 'time',
time: {
unit: 'second',
tooltipFormat: 'HH:mm:ss:SSS',
Expand Down

0 comments on commit 7b18c41

Please sign in to comment.