Skip to content

Commit

Permalink
convert influx data correctly for chart export widget; fix #SNRGY-3265
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahannes committed Apr 26, 2024
1 parent 9001b30 commit 54530e2
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/app/widgets/charts/export/shared/charts-export.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,21 @@ export class ChartsExportService {
const obs: Observable<{ source: string; res: any[][][][] }>[] = [];

if (influxElements.length > 0) {
obs.push(this.exportDataService.queryInflux(influxElements).pipe(map(res => ({
source: 'influx',
res: res ? [res] : []
}))));
obs.push(this.exportDataService.queryInflux(influxElements).pipe(
map(res => {
const responseTimescaleFormat: any = [];
if(res != null) {
res.forEach(responsePerRequest => {
responseTimescaleFormat.push([responsePerRequest]);
});
}

return {
source: 'influx',
res: responseTimescaleFormat
};
})
));
}

if (timescaleElements.length > 0) {
Expand Down Expand Up @@ -312,6 +323,11 @@ export class ChartsExportService {
table: ChartDataTableModel;
colors?: string[];
} {
// data[] -> requests/vAxis
// data[][] -> number of columns within request
// data[][][] -> rows
// data[][][][] -> values per column

const repeats: number[] = [];
const table: any[][] = [];
let columns = 1; // time column
Expand Down Expand Up @@ -384,10 +400,10 @@ export class ChartsExportService {
conversionDefault: vAxis.conversionDefault,
type: vAxis.valueType,
});
header.push(vAxis.valueAlias || vAxis.valueName);
colors2.push(colors[index]);
}
}
header.push(vAxis.valueAlias || vAxis.valueName);
colors2.push(colors[index]);
});
colors = colors2;
}
Expand Down

0 comments on commit 54530e2

Please sign in to comment.