Could someone show me how to use the pondjs timeSeries.fixedWindowRollup
because I can’t figure out what I’m doing wrong.
I’d like to resample a dataset to have uniform timestamps, so here is the code I’m using based on doc and what I see in the source:
const data = res.map((data: any) => {
return {
timestamp: new Date(data.End).getTime(),
value: data.Value,
}
})
const ts = timeSeries({
points: data.map((entry: any) => [entry.timestamp, entry.value]),
columns: ["time", "value"],
name: "data",
})
.fixedWindowRollup({
window: window(duration("1day")),
//aggregation: { value: { value: avg() } }, //ts compiler complains
aggregation: {value: ["value", avg()]},
})
.eventList().map(e => {
return {
timestamp: e?.timestamp().getTime(),
value: e?.get("value")
}
});
but the fixedWindowRollup returns that error:
TypeError: Cannot read properties of undefined (reading 'mid')
at Index.timestamp (project/node_modules/pondjs/src/index.ts:89:32)
at Event.timestamp (project/node_modules/pondjs/src/event.ts:578:30)
at project/node_modules/pondjs/src/collection.ts:839:23
at List.__iterate (project/node_modules/immutable/dist/immutable.js:3370:13)
at List.forEach (project/node_modules/immutable/dist/immutable.js:4899:19)
at SortedCollection.forEach (project/node_modules/pondjs/src/collection.ts:425:29)
at SortedCollection.isChronological (project/node_modules/pondjs/src/collection.ts:837:14)
at new SortedCollection (project/node_modules/pondjs/src/sortedcollection.ts:43:20)
at project/node_modules/pondjs/src/windowedcollection.ts:177:51
at project/node_modules/immutable/dist/immutable.js:2488:31
at project/node_modules/immutable/dist/immutable.js:2506:18
btw I'm using syntax from version 1.0.0-alpha.0 because latest version didn't work with my ts compiler ...
I also posted the question fixedWindowRollup example needed as an issue directly to the repo but no luck so far unfortunately…
Thanks for any hint!