new Series( [options])
Create a series.
Parameters:
Name | Type | Argument | Default | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
{} |
Properties
|
Examples
const from = '2016-01-01T00:00:00Z'; const until = '2016-01-01T01:00:00Z'; const interval = 5 * 60; // seconds const keyName = 'favorite name'; new Series({ from, until, interval, keyName}); // => Series' instance new Series({type: 'monospaced', from, until, interval, keyName}); // => same as above
const from = '2016-01-01T00:00:00Z'; const until = '2016-01-01T01:00:00Z'; const numOfData = 5 * 60; // seconds const keyName = 'favorite name'; new Series({type: 'random', from, until, numOfData, keyName}); // => Series' instance
Methods
-
_timestamps()
-
(Private) Create UNIX timestamps.
-
_trigonometric()
-
(Private) Return time series data by trigonometric functions.
-
clone( [options])
-
Clone self instance.
Parameters:
Name Type Argument Default Description options
Object <optional>
{} Properties
Name Type Argument Default Description type
string <optional>
this.type 'monospaced' or 'random'.
from
integer | string <optional>
this.from Lower bound of date range.
until
integer | string <optional>
this.until Upper bound of date range.
interval
integer <optional>
this.interval ('monospaced' only) Intervel of seconds between two data. [1 <= interval]
numOfData
integer <optional>
this.numOfData ('random' only) Number of data. [0 <= numOfData]
keyName
string <optional>
this.keyName Value's key name of result.
Returns:
- Type
- Series
Example
new Series().clone({keyName: 'changed name'}); // => Series' instance with keyName 'changed name'
-
cos( [options])
-
Return time series data describing cosine curve.
Parameters:
Name Type Argument Default Description options
Object <optional>
{} Properties
Name Type Argument Default Description coefficient
number <optional>
1.0 Coefficient of cosine curve.
constant
number <optional>
0.0 Constant of cosine curve.
decimalDigits
integer <optional>
2 Number of decimal places. [0 <= decimalDigits <= 10]
period
integer <optional>
1 * 60 * 60 Period of cosine curve. [1 <= period]
Returns:
- Type
- Array.<{timestamp: string, (string): number}>
Example
const coefficient = 1; const constant = 1; const decimalDigits = 3; const period = 1 * 60 * 60; // seconds new Series().cos({coefficient, constant, decimalDigits, period})); // => [{timestamp: '2017-05-31T02:20:48.000Z', value: 0.429}, ...]
-
gaussian( [options])
-
Return time series data by normal distribution.
Parameters:
Name Type Argument Default Description options
Object <optional>
{} Properties
Name Type Argument Default Description mean
number <optional>
10 Mean of normal distribution.
variance
number <optional>
1 Variance of normal distribution.
decimalDigits
integer <optional>
2 Number of decimal places. [0 <= decimalDigits <= 10]
Returns:
- Type
- Array.<{timestamp: string, (string): number}>
Example
const mean = 5; const variance = 1.5; const decimalDigits = 3; new Series().gaussian({mean, variance, decimalDigits}); // => [{timestamp: '2017-05-31T02:25:38.000Z', value: 2.56}, ...]
-
generate(func)
-
Return time series data by any functions using UNIX timestamp.
Parameters:
Name Type Description func
function (unixTimestamp) => any
Returns:
- Type
- Array.<{timestamp: string, (string): any}>
Example
new Series().generate((unix) => unix); // => [{timestamp: '2017-05-31T02:43:57.000Z', value: 1496198637}, ...]
-
ratio(weights)
-
Return time series data by ratio.
Parameters:
Name Type Description weights
Object.<string, integer> Map representing pairs of key and weight.
Returns:
- Type
- Array.<{timestamp: string, (string): string}>
Example
const weights = { rock : 1, scissors: 2, paper : 1, }; new Series().ratio(weights); // => [{timestamp: '2017-05-31T02:30:25.000Z', value: 'rock'}, ...]
-
sin( [options])
-
Return time series data describing sine curve.
Parameters:
Name Type Argument Default Description options
Object <optional>
{} Properties
Name Type Argument Default Description coefficient
number <optional>
1.0 Coefficient of sine curve.
constant
number <optional>
0.0 Constant of sine curve.
decimalDigits
integer <optional>
2 Number of decimal places. [0 <= decimalDigits <= 10]
period
integer <optional>
1 * 60 * 60 Period of sine curve. [1 <= period]
Returns:
- Type
- Array.<{timestamp: string, (string): number}>
Example
const coefficient = 1; const constant = 1; const decimalDigits = 3; const period = 1 * 60 * 60; // seconds new Series().sin({coefficient, constant, decimalDigits, period})); // => [{timestamp: '2017-05-31T02:17:23.000Z', value: 1.969}, ...]