time-segments.js outputs segments. This library will group consecutive segments.
Not all visualizations show a single block for each segment. Sometimes you will want to aggregate consecutive blocks into a single block. This library prepares segments into a state suitable to be aggregated.
This library exposes a single method.
Takes in an array of segments
and a scale
, returns an array. Each item in the array
is an array of consecutive segments.
scale
can be any of the resolutions supported by moment.js.
A short list of examples include days
, years
, weeks
. Moment's abbrevations
are also supported, as in w
for weeks.
The default scale is weeks
.
This library transforms segments from this form:
{
1000: [eventOne, eventTwo]
}
to be of this form:
{
timestamp: 1000,
segments: [eventOne, eventTwo]
}