Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // this reduce block converts the ChartDataSuperArray values into objects
- const dataObjects = this.ChartDataSuperArray.reduce((acc, elem) => {
- acc['data'] = elem;
- return acc;
- }, {});
- // complete block (just in case you wanna see it):
- getDataAndSetChartValues() {
- return this.http.get(this.staticData).subscribe(historianData => { // switch URL to dataQueryUrl when ready for production!
- const rawValuesArray = historianData['Data'];
- // console.log(rawValuesArray);
- const timeAndValuesData = rawValuesArray.map(tagData => tagData['Samples']);
- // console.log(timeAndValuesData);
- timeAndValuesData.forEach(set => {
- const valuesArray = set.map(dataObject => dataObject['Value']);
- // console.log(valuesArray);
- this.ChartDataSuperArray.push(valuesArray);
- console.log(this.ChartDataSuperArray);
- // this reduce block converts the ChartDataSuperArray values into objects
- const dataObjects = this.ChartDataSuperArray.reduce((acc, elem) => {
- acc['data'] = elem;
- return acc;
- }, {});
- this.ChartDataObjectsArray.push(dataObjects);
- console.log(this.ChartDataObjectsArray);
- });
- const timeStampsArray = timeAndValuesData[0].map(set => set['TimeStamp']);
- this.ChartLabels = timeStampsArray.map(timestamp => timestamp.slice(0, 16));
- // console.log(simpleChartLabels);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement