You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by eb...@apache.org on 2020/05/13 10:37:30 UTC
[incubator-streampipes] 05/09: Add label information to data result
This is an automated email from the ASF dual-hosted git repository.
ebi pushed a commit to branch timeseries-labeling
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit ae20daac95b0af18c84c3747facb79259e12abb2
Author: Daniel Ebi <eb...@fzi.de>
AuthorDate: Wed May 13 10:45:42 2020 +0200
Add label information to data result
---
ui/src/app/core-model/datalake/DataResult.ts | 3 ++-
ui/src/app/core-ui/linechart/lineChart.component.ts | 11 ++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/ui/src/app/core-model/datalake/DataResult.ts b/ui/src/app/core-model/datalake/DataResult.ts
index 1b8096a..bf0c051 100644
--- a/ui/src/app/core-model/datalake/DataResult.ts
+++ b/ui/src/app/core-model/datalake/DataResult.ts
@@ -20,4 +20,5 @@ export class DataResult {
total: number;
headers: string[];
rows: any[];
-}
\ No newline at end of file
+ labels: string[];
+}
diff --git a/ui/src/app/core-ui/linechart/lineChart.component.ts b/ui/src/app/core-ui/linechart/lineChart.component.ts
index 3f3f015..39cc377 100644
--- a/ui/src/app/core-ui/linechart/lineChart.component.ts
+++ b/ui/src/app/core-ui/linechart/lineChart.component.ts
@@ -155,6 +155,8 @@ export class LineChartComponent extends BaseChartComponent implements OnChanges
});
this.dataToDisplay = tmp;
+
+
/**
* TODO: fetching stored labels, filling this.labels and drawing related shapes
*/
@@ -189,20 +191,24 @@ export class LineChartComponent extends BaseChartComponent implements OnChanges
}
}
- transformData(data: DataResult, xKey: String): DataResult {
+ transformData(data: DataResult, xKey: string): DataResult {
const tmp: any[] = [];
const dataKeys = [];
+ const label_column = [];
data.rows.forEach(row => {
data.headers.forEach((headerName, index) => {
if (!dataKeys.includes(index) && typeof row[index] == 'number') {
dataKeys.push(index);
+ } else if (!label_column.includes(index) && typeof row[index] == 'string' && data.headers[index] == "sp_internal_label") {
+ label_column.push(index);
}
});
});
const indexXkey = data.headers.findIndex(headerName => headerName === this.xKey);
+ const labels = [];
dataKeys.forEach(key => {
const headerName = data.headers[key];
@@ -218,9 +224,12 @@ export class LineChartComponent extends BaseChartComponent implements OnChanges
} else {
tmp[index].y.push(null);
}
+ } else if (label_column.length > 0 && label_column.includes(index)) {
+ labels.push(row[index]);
}
});
});
+ data.labels = labels;
data.rows = tmp;
return data;