Skip to content

Commit 017a869

Browse files
mbostockchaichontat
authored andcommitted
quarter & half (observablehq#1312)
* quarter & half * Update README
1 parent 6f6a0ef commit 017a869

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ The default range depends on the scale: for [position scales](#position-options)
200200

201201
The behavior of the *scale*.**unknown** option depends on the scale type. For quantitative and temporal scales, the unknown value is used whenever the input value is undefined, null, or NaN. For ordinal or categorical scales, the unknown value is returned for any input value outside the domain. For band or point scales, the unknown option has no effect; it is effectively always equal to undefined. If the unknown option is set to undefined (the default), or null or NaN, then the affected input values will be considered undefined and filtered from the output.
202202

203-
For data at regular intervals, such as integer values or daily samples, the *scale*.**interval** option can be used to enforce uniformity. The specified *interval*—such as d3.utcMonth—must expose an *interval*.floor(*value*), *interval*.offset(*value*), and *interval*.range(*start*, *stop*) functions. The option can also be specified as a number, in which case it will be promoted to a numeric interval with the given step. The option can alternatively be specified as a string (second, minute, hour, day, week, month, year, monday, tuesday, wednesday, thursday, friday, saturday, sunday) naming the corresponding UTC interval. This option sets the default *scale*.transform to the given interval’s *interval*.floor function. In addition, the default *scale*.domain is an array of uniformly-spaced values spanning the extent of the values associated with the scale.
203+
For data at regular intervals, such as integer values or daily samples, the *scale*.**interval** option can be used to enforce uniformity. The specified *interval*—such as d3.utcMonth—must expose an *interval*.floor(*value*), *interval*.offset(*value*), and *interval*.range(*start*, *stop*) functions. The option can also be specified as a number, in which case it will be promoted to a numeric interval with the given step. The option can alternatively be specified as a string (*second*, *minute*, *hour*, *day*, *week*, *month*, *quarter*, *half*, *year*, *monday*, *tuesday*, *wednesday*, *thursday*, *friday*, *saturday*, *sunday*) naming the corresponding UTC interval. This option sets the default *scale*.transform to the given interval’s *interval*.floor function. In addition, the default *scale*.domain is an array of uniformly-spaced values spanning the extent of the values associated with the scale.
204204

205205
Quantitative scales can be further customized with additional options:
206206

src/time.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const timeIntervals = new Map([
1010
["day", timeDay],
1111
["week", timeWeek],
1212
["month", timeMonth],
13+
["quarter", timeMonth.every(3)],
14+
["half", timeMonth.every(6)],
1315
["year", timeYear],
1416
["monday", timeMonday],
1517
["tuesday", timeTuesday],
@@ -27,6 +29,8 @@ const utcIntervals = new Map([
2729
["day", utcDay],
2830
["week", utcWeek],
2931
["month", utcMonth],
32+
["quarter", utcMonth.every(3)],
33+
["half", utcMonth.every(6)],
3034
["year", utcYear],
3135
["monday", utcMonday],
3236
["tuesday", utcTuesday],

0 commit comments

Comments
 (0)