simple-segment-aggregation.js v0.1.1
simple-segment-aggregation.js
Aggregate consecutive segments by their events.
This library is best used with data returned from time-segments.js and simple-segment-aggregation.js
Motivation
Some visualizations aggregate consecutive segments into a single unit. This library groups any segment with the same content into the same block.
Caveats
This library requires that each of your events
have a unique identifier.
Concepts
Aggregates
An aggregate is an Object with the following properties
events
- the events contained within the aggregationstart
- a Unix timestamp representing the start of the aggregationduration
- the length of the aggregationcontinuesForward
- a Boolean representing whether any of the events in this aggregate are in the subsequent aggregatecontinuesBackward
- a Boolean representing whether any of the events in this aggregate are in the previous aggregate
API
This library exposes a single method.
aggregate( group, scale [, options] )
It accepts a group
of segments and returns a group of aggregates. scale
can be
any resolution that moment.js supports. The number of aggregates you get could
be the same number of segments that you pass in, or less, but never more.
Options can be used to customize the behavior of the API. The available options are:
idAttribute
- The key containing the Event's unique identifier