time-series-data-generator
Generate time series data for development!
Installation
$ npm install --save time-series-data-generator
Getting started
- Use simply. This generator outputs sine curve values with timestamps from "now - 1 hour" until now at 5 min interval.
const Series = ; const series = ;console;// => [{timestamp: '2017-05-28T03:34:31.000Z', value: -0.46}, {timestamp: '2017-05-28T03:39:31.000Z', value: -0.84}, ...]
- Use with options.
const Series = ; const from = "2016-01-01T00:00:00Z";const until = "2016-01-01T01:00:00Z";const interval = 5 * 60; // secondsconst keyName = "key-name-of-value";const series = from until interval keyName ;console;// => [{timestamp: '2016-01-01T00:00:00.000Z', 'key-name-of-value': 0}, {timestamp: '2016-01-01T00:05:00.000Z', 'key-name-of-value': 0.5}, ...]
- Output data with "random" timestamps.
const Series = ; const from = "2016-01-01T00:00:00Z";const until = "2016-01-01T01:00:00Z";const numOfData = 10;const series = type: "random" from until numOfData ;console;// => [{timestamp: '2016-01-01T00:01:43.000Z', value: 0.18}, {timestamp: '2016-01-01T00:02:19.000Z', value: 0.24}, ...]
Examples for each APIs
-
sin()
: Describing sine curve.const Series = ;const series = ;console;// => [{timestamp: '2017-05-31T02:17:23.000Z', value: 0.97}, {imestamp: '2017-05-31T02:22:23.000Z', value: 0.72}, ...]const coefficient = 1;const constant = 1;const decimalDigits = 3;const period = 1 * 60 * 60; // secondsconsole;// => [{timestamp: '2017-05-31T02:17:23.000Z', value: 1.969}, {timestamp: '2017-05-31T02:22:23.000Z', value: 1.716}, ...] -
cos()
: Describing cosine curve.const Series = ;const series = ;console;// => [{timestamp: '2017-05-31T02:20:48.000Z', value: -0.57}, {timestamp: '2017-05-31T02:25:48.000Z', value: -0.9}, ...]const coefficient = 1;const constant = 1;const decimalDigits = 3;const period = 1 * 60 * 60; // secondsconsole;// => [{timestamp: '2017-05-31T02:20:48.000Z', value: 0.429}, {timestamp: '2017-05-31T02:25:48.000Z', value: 0.095}, ...] -
gaussian()
: Plotting numbers with normal distribution.const Series = ;const series = ;console;// => [{timestamp: '2017-05-31T02:25:38.000Z', value: 10.15}, {timestamp: '2017-05-31T02:30:38.000Z', value: 9.68}, ...]const mean = 5;const variance = 15;const decimalDigits = 3;console;// => [{timestamp: '2017-05-31T02:25:38.000Z', value: 2.56}, {timestamp: '2017-05-31T02:30:38.000Z', value: 5.924}, ...] -
ratio()
: Sampling strings following theirs weights.const Series = ;const series = type: "random" ;const weights =rock: 1scissors: 2paper: 1;console;// => [{timestamp: '2017-05-31T02:30:25.000Z', value: 'rock'}, {timestamp: '2017-05-31T02:37:31.000Z', value: 'scissors'}, ...] -
generate()
: General function.const Series = ;const series = type: "random" ;console;// => [{timestamp: '2017-05-31T02:43:57.000Z', value: 1496198637}, {timestamp: '2017-05-31T02:53:07.000Z', value: 1496199187}, ...]