Readonly
pointsThe dates of the points in the timeseries.
The first point in the timeseries, or undefined if the timeseries is empty.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The first value in the timeseries, or undefined if the timeseries is empty.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The last point in the timeseries or undefined if the timeseries is empty.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The last value in the timeseries or undefined if the timeseries is empty.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The length of the timeseries.
The maximum (latest) date in the timeseries.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The maximum value in the timeseries.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The minimum (earliest) date in the timeseries.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The minimum value in the timeseries.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
Returns the sum of all numeric values in the timeseries.
The values of the points in the timeseries.
Throws an exception if any values in the timeseries are not boolean.
The returned timeseries will cast to Timeseries<boolean>
so any subsequent
code doesn't need to deal with non-boolean values.
Throws an exception if any values in the timeseries are not finite numbers (e.g. strings, null, undefined, infinity, NaN).
The returned timeseries will cast to Timeseries<number>
so any subsequent
code doesn't need to deal with non-number values.
Throws an exception if any values in the timeseries are not of type string.
The returned timeseries will cast to Timeseries<string>
so any subsequent
code doesn't need to deal with non-string values.
Private
castInternal helper to cast the timeseries values to a new type. Should only be used after verifying all values match the new type.
Computes deltas between each point in the timeseries.
A timeseries made up of the deltas between timeseries points.
Optional
opts: { Optional
keepWhether to include the initial value in the series as a delta (with an assumed prior value of 0).
Optional
minThe minimum delta to keep. By default all deltas are kept, but can be set to 0 to drop negative deltas or 1 to only keep positive deltas.
Filters the timeseries by calling the provided filterFn
on each point in
the timeseries.
A new timeseries with the filtered points.
The function to call on each point in the timeseries. If it returns true, the point will be kept, else discarded.
Filters the timeseries by calling the provided filterFn
on each value in
the timeseries.
A new timeseries with the filtered points.
The function to call on each value in the timeseries. If it returns true, the point will be kept, else discarded.
Filters the timeseries down to the specified date range, specified using either inclusive or exclusive endpoints.
A new timeseries with the filtered points.
The date range to keep.
Returns the point with the date closest to the provided date, or undefined if the timeseries is empty.
You can use hasData to guard against the timeseries being empty and ensure this can't return undefined.
The point with the date closest to the provided date or undefined if the timeseries is empty.
The date to find the closest point to.
Returns whether the timeseries has any data.
You can use this method as a type guard before calling last() or findNearestDate() to ensure last() won't return undefined. See NonEmptyTimeseries for details.
Returns a new timeseries with the points in the timeseries mapped to new
points using the provided mapFn
function. Points can be discarded by
returning undefined.
A new timeseries with the mapped points.
The function to call on each point in the timeseries. The return value is used as the point's value in the new timeseries. Undefined can be returned to drop the point.
Returns a new timeseries with the values in the timeseries mapped to new
values using the provided mapFn
function.
A new timeseries with the mapped points.
The function to call on each value in the timeseries. The return value is used as the point's value in the new timeseries.
Computes a rolling average of the timeseries where each point represents
the average of the prior opts.days
days of data points.
A new timeseries containing the rolling average of the original one.
The number of days to average over.
Optional
treatWhether to treat missing dates as 0. This is typically what you want for "incidence" metrics (like "daily new cases") but not "current" metrics (like "% of beds in use").
Returns a new Timeseries from the slice of data points indicated by the
provided start
and end
indices.
ts.slice(2, 4); // Returns a Timeseries with the 3rd and 4th points.
A new Timeseries with the sliced data points.
The first index to be included in the new Timeseries.
Optional
end: numberThe first index not to be included in the new Timeseries.
Convert Timeseries instance into serialized JSON format.
Timeseries points serialized as JSON.
Breaks the timeseries into overlapping windows of the specified size and makes a new timeseries from them. Handy for computing aggregations like a rolling average.
A new timeseries that has a point for every point in the original
timeseries, but contains a TimeseriesWindow
object containing the window
of points leading up to that point.
The number of days to include in each window. Note that the points at the beginning of the timeseries will have a smaller window due to no prior history.
Static
Private
assertInternal helper to verify all dates are pure dates with no time component.
Static
Private
assertInternal helper to verify there are no nil points in the timeseries.
Static
fromStatic constructor to help create a timeseries from a range of dates and some values.
A new timeseries.
An array of values or iteratee function that returns values for the dates in the date range.
Static
fromJSONConstruct a Timeseries instance from JSON timeseries points.
The constructed timeseries.
Serialized timeseries points from which to construct a Timeseries.
Generated using TypeDoc
An immutable series of dates and values, representing a value that changes over time.