https://github.com/jamesplease/simple-segment-aggregation.js
Aggregate consecutive segments by their events.
https://github.com/jamesplease/simple-segment-aggregation.js
Last synced: 3 months ago
JSON representation
Aggregate consecutive segments by their events.
- Host: GitHub
- URL: https://github.com/jamesplease/simple-segment-aggregation.js
- Owner: jamesplease
- License: mit
- Created: 2015-01-14T21:21:08.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-05-30T21:10:41.000Z (about 10 years ago)
- Last Synced: 2025-03-12T22:37:20.028Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 320 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-segment-aggregation.js
[](https://travis-ci.org/jmeas/simple-segment-aggregation.js)
[](https://david-dm.org/jmeas/simple-segment-aggregation.js)
[](https://david-dm.org/jmeas/simple-segment-aggregation.js#info=devDependencies)Aggregate consecutive segments by their events.
This library is best used with data returned from [time-segments.js](https://github.com/jmeas/time-segments.js)
and [simple-segment-aggregation.js](https://github.com/jmeas/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 aggregation
- `start` - a Unix timestamp representing the start of the aggregation
- `duration` - the length of the aggregation
- `continuesForward` - a Boolean representing whether any of the events in this
aggregate are in the subsequent aggregate
- `continuesBackward` - 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