Skip to content

Commit

Permalink
Fix format issues (#1391)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikriemer committed Mar 9, 2023
1 parent 6fc37bb commit f8e149a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,12 @@
></tr>
<tr mat-row *matRowDef="let row; columns: columnNames"></tr>
</table>
<mat-paginator [length]="100"
[pageSize]="500"
[pageSizeOptions]="[10, 20, 50, 100, 500, 1000]"
aria-label="Select page">
<mat-paginator
[length]="100"
[pageSize]="500"
[pageSizeOptions]="[10, 20, 50, 100, 500, 1000]"
aria-label="Select page"
>
</mat-paginator>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export class TableWidgetComponent
extends BaseDataExplorerWidgetDirective<TableWidgetModel>
implements OnInit, OnDestroy
{
@ViewChild(MatSort, {static: true}) sort: MatSort;
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
@ViewChild(MatSort, { static: true }) sort: MatSort;
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;

dataSource = new MatTableDataSource();
columnNames: string[];
Expand All @@ -47,15 +47,18 @@ export class TableWidgetComponent
this.dataSource.sort = this.sort;
this.dataSource.paginator = this.paginator;
this.columnNames = ['time'].concat(
this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
c => c.fullDbName,
),
this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
c => c.fullDbName,
),
);
}

transformData(spQueryResult: SpQueryResult) {
return spQueryResult.allDataSeries.flatMap(series =>
series.rows.map(row => this.createTableObject(spQueryResult.headers, row)));
series.rows.map(row =>
this.createTableObject(spQueryResult.headers, row),
),
);
}

createTableObject(keys, values) {
Expand Down Expand Up @@ -115,11 +118,13 @@ export class TableWidgetComponent

onDataReceived(spQueryResults: SpQueryResult[]) {
this.columnNames = ['time'].concat(
this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
c => c.fullDbName,
),
this.dataExplorerWidget.visualizationConfig.selectedColumns.map(
c => c.fullDbName,
),
);
const transformedData = spQueryResults.map(spQueryResult => this.transformData(spQueryResult)).flat();
const transformedData = spQueryResults
.map(spQueryResult => this.transformData(spQueryResult))
.flat();
this.dataSource.data = [...transformedData];
this.setShownComponents(false, true, false, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ export class TimeSeriesChartWidgetComponent

let maxValue = -Infinity;

const selectedFields = this.dataExplorerWidget.visualizationConfig.selectedTimeSeriesChartProperties;
const selectedFields =
this.dataExplorerWidget.visualizationConfig
.selectedTimeSeriesChartProperties;
data.allDataSeries.forEach(group => {
group.rows.forEach(row => {
selectedFields.forEach(field => {
Expand All @@ -176,26 +178,34 @@ export class TimeSeriesChartWidgetComponent
const columnIndex = this.getColumnIndex(field, data);
const name = field.fullDbName + sourceIndex.toString();
let value = row[columnIndex];
const fullDbNameAndIndex = field.fullDbName + field.sourceIndex.toString();
if (!this.orderedSelectedProperties.includes(fullDbNameAndIndex)) {
this.orderedSelectedProperties.push(fullDbNameAndIndex);
const fullDbNameAndIndex =
field.fullDbName + field.sourceIndex.toString();
if (
!this.orderedSelectedProperties.includes(
fullDbNameAndIndex,
)
) {
this.orderedSelectedProperties.push(
fullDbNameAndIndex,
);
}

const {tags} = group;
const { tags } = group;
if (tags != null) {
const groupValues = this.groupKeeper[name] ?? new Set();
const groupValues =
this.groupKeeper[name] ?? new Set();
for (const [key, val] of Object.entries(tags)) {
groupValues.add(val);
}
this.groupKeeper[name] = groupValues;
}

if (
this.fieldProvider.booleanFields.find(
f =>
field.fullDbName === f.fullDbName &&
f.sourceIndex === data.sourceIndex,
) !== undefined
this.fieldProvider.booleanFields.find(
f =>
field.fullDbName === f.fullDbName &&
f.sourceIndex === data.sourceIndex,
) !== undefined
) {
value = value === true ? this.maxValue + 2 : 0;
}
Expand All @@ -204,13 +214,8 @@ export class TimeSeriesChartWidgetComponent
const traceExists = traceKey in tmpLineChartTraces;

if (!traceExists) {
const headerName =
data.headers[
columnIndex
];
tmpLineChartTraces[
traceKey
] = {
const headerName = data.headers[columnIndex];
tmpLineChartTraces[traceKey] = {
type: 'scatter',
mode: 'Line',
name: headerName,
Expand All @@ -220,12 +225,10 @@ export class TimeSeriesChartWidgetComponent
};
}

tmpLineChartTraces[
traceKey
].x.push(new Date(row[indexXkey]));
tmpLineChartTraces[
traceKey
].y.push(value);
tmpLineChartTraces[traceKey].x.push(
new Date(row[indexXkey]),
);
tmpLineChartTraces[traceKey].y.push(value);
}
}
}
Expand Down Expand Up @@ -516,8 +519,8 @@ export class TimeSeriesChartWidgetComponent

this.orderedSelectedProperties = [];

this.data = spQueryResults.flatMap((spQueryResult) =>
this.transformData(spQueryResult, spQueryResult.sourceIndex)
this.data = spQueryResults.flatMap(spQueryResult =>
this.transformData(spQueryResult, spQueryResult.sourceIndex),
);

this.setShownComponents(false, true, false, false);
Expand Down

0 comments on commit f8e149a

Please sign in to comment.