interval.floor method
The interval.floor method takes a value and returns the corresponding value representing the greatest interval boundary less than or equal to the specified value. For example, Plot.utcInterval("day").floor(new Date("2013-04-12T12:34:56Z")) returns 2013-04-12.
interval.offset method
The interval.offset method takes a value and an optional step parameter and returns the corresponding value equal to value plus step intervals. If step is not specified it defaults to 1. If step is negative, the returned value will be less than the specified value. For example, Plot.utcInterval("day").offset(new Date("2013-04-12T12:34:56Z"), 1) returns 2013-04-13T12:34:56Z, and Plot.utcInterval("day").offset(new Date("2013-04-12T12:34:56Z"), -2) returns 2013-04-10T12:34:56Z.
interval.range method
The interval.range method returns an array of values representing every interval boundary greater than or equal to start (inclusive) and less than stop (exclusive). The first value in the returned array is the least boundary greater than or equal to start; subsequent values are offset by intervals and floored. For example, Plot.utcInterval("week").range(new Date("2013-04-12T12:34:56Z"), new Date("2013-05-12T12:34:56Z")) returns [2013-04-14, 2013-04-21, 2013-04-28, 2013-05-05, 2013-05-12].
interval.ceil method
The interval.ceil method returns the value representing the least interval boundary value greater than or equal to the specified value. For example, Plot.utcInterval("day").ceil(new Date("2013-04-12T12:34:56Z")) returns 2013-04-13.
Minimum interval methods required
At a minimum, intervals must implement interval.floor and interval.offset. Range intervals additionally implement interval.range. Nice intervals additionally implement interval.ceil.
Plot.numberInterval function
Plot.numberInterval(period) takes a number period and returns a corresponding range interval implementation. If period is a negative number, the resulting interval uses 1 / -period; this allows more precise results when period is a negative integer. The returned interval implements interval.range, interval.floor, and interval.offset methods.
Plot.timeInterval function
Plot.timeInterval(period) takes a string period describing a local time interval and returns a corresponding nice interval implementation. The period can be second, minute, hour, day, week, month, quarter, half, year, monday, tuesday, wednesday, thursday, friday, saturday, or sunday, or a skip interval consisting of a number followed by the interval name (possibly pluralized), such as "3 months" or "10 years". The returned interval implements interval.range, interval.floor, interval.ceil, and interval.offset methods.
Plot.utcInterval function
Plot.utcInterval(period) takes a string period describing a UTC time interval and returns a corresponding nice interval implementation. The period can be second, minute, hour, day, week, month, quarter, half, year, monday, tuesday, wednesday, thursday, friday, saturday, or sunday, or a skip interval consisting of a number followed by the interval name (possibly pluralized), such as "3 months" or "10 years". The returned interval implements interval.range, interval.floor, interval.ceil, and interval.offset methods.
Intervals usage contexts
Plot provides several built-in interval implementations for use with the tick option for scales, the thresholds option for a bin transform, and other use cases.