Skip to content
Snippets Groups Projects
Commit cd33ce06 authored by Bilal Hassan's avatar Bilal Hassan
Browse files

-fixing show empty data also in the beginning of the graph issue #47

parent 5ebdd980
No related branches found
No related tags found
3 merge requests!25Draft: Resolve #78,!7fixUrlPath,!6Improve performance of chart.js
......@@ -6,6 +6,7 @@ import { LogLevel, MyLoggerServiceService } from '../../../../shared/service/my-
import { SensorData } from '../../pro-view/pro-view.component'
import { ReadingPayload } from '../../../../../../projects/generated-api/src'
@Component({
selector: 'app-Cjs-timeline-multiple',
templateUrl: './cjsTimlineMultiple.component.html',
......@@ -90,7 +91,7 @@ export class CjsTimelineMultiple implements OnInit, OnChanges {
},
]
let datePipe = new DatePipe('en-US')
let startDate: Date
let endDate: Date
let newData = []
......@@ -286,11 +287,23 @@ export class CjsTimelineMultiple implements OnInit, OnChanges {
if(this.sensorDataArray.at(0)!=undefined)
timestamp=this.sensorDataArray.at(1)?.map(x=>x.timestamp)??[];
let lastDateUser=new Date(this.to?.toString()??"")
let firstUserDate=new Date(this.from?.toString()??"")
let firstDateData=new Date(timestamp.at(0)??"")
let lastDateData=new Date(timestamp.at(timestamp.length-1)??"")
let bevorelastDateData=new Date(timestamp.at(timestamp.length-2)??"")
//add missing data if it is missing at the start
//calculation time difference
//calculate Missing data
let timeDiff=timeDifference(bevorelastDateData,lastDateData)
let firstDateDateBevore=new Date(firstDateData.getTime()-timeDiff);
let missingDateStart:string[]=getMissingData(firstUserDate,firstDateDateBevore,timeDiff)
this.timeStampsAsHour=[...missingDateStart,...this.timeStampsAsHour]
let yMissing=Array(missingDateStart.length).fill(null)
//have to fill missing y values with null
//add missing data if it is missing at the end
//calculation time difference
//calculate Missing data
let misssingData:string[]=getMissingData(lastDateData,lastDateUser,timeDiff)
//add Missing data to the array
......@@ -305,7 +318,7 @@ export class CjsTimelineMultiple implements OnInit, OnChanges {
this.dataParentArrayError = [[]]
this.sensorDataArray.forEach((sensDat) => {
this.dataParentArray.push(
sensDat.map((x) => x.readings.map((y) => y.value)).flat(),
[...yMissing,...sensDat.map((x) => x.readings.map((y) => y.value)).flat()],
)
this.dataParentArrayError.push(sensDat.map((x) => x.errorStatus))
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment