Advertisement
Shell_Casing

code

Jan 4th, 2019
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // this reduce block converts the ChartDataSuperArray values into objects
  2.  
  3.         const dataObjects = this.ChartDataSuperArray.reduce((acc, elem) => {
  4.           acc['data'] = elem;
  5.           return acc;
  6.         }, {});
  7.  
  8.  
  9.  
  10.  
  11. // complete block (just in case you wanna see it):
  12.  getDataAndSetChartValues() {
  13.     return this.http.get(this.staticData).subscribe(historianData => {    // switch URL to dataQueryUrl when ready for production!
  14.       const rawValuesArray = historianData['Data'];
  15.       // console.log(rawValuesArray);
  16.       const timeAndValuesData = rawValuesArray.map(tagData => tagData['Samples']);
  17.       // console.log(timeAndValuesData);
  18.  
  19.       timeAndValuesData.forEach(set => {
  20.         const valuesArray = set.map(dataObject => dataObject['Value']);
  21.         // console.log(valuesArray);
  22.         this.ChartDataSuperArray.push(valuesArray);
  23.         console.log(this.ChartDataSuperArray);
  24.  
  25.         // this reduce block converts the ChartDataSuperArray values into objects
  26.         const dataObjects = this.ChartDataSuperArray.reduce((acc, elem) => {
  27.           acc['data'] = elem;
  28.           return acc;
  29.         }, {});
  30.  
  31.         this.ChartDataObjectsArray.push(dataObjects);
  32.         console.log(this.ChartDataObjectsArray);
  33.       });
  34.  
  35.       const timeStampsArray = timeAndValuesData[0].map(set => set['TimeStamp']);
  36.       this.ChartLabels = timeStampsArray.map(timestamp => timestamp.slice(0, 16));
  37.       // console.log(simpleChartLabels);
  38.     });
  39.  
  40.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement