Skip to content

Commit

Permalink
Fix #57 - accept and ignore count.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Apr 29, 2016
1 parent 8529d1a commit 3cc1011
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ x.ticks(d3.timeMinute.filter(function(d) {

Note: in some cases, such as with day ticks, specifying a *step* can result in irregular spacing of ticks because time intervals have varying length.

<a name="time_tickFormat" href="#time_tickFormat">#</a> <i>time</i>.<b>tickFormat</b>([<i>specifier</i>])
<a name="time_tickFormat" href="#time_tickFormat">#</a> <i>time</i>.<b>tickFormat</b>([<i>count</i>[, <i>specifier</i>]])

Returns a time format function suitable for displaying [tick](#time_ticks) values. If a format *specifier* is specified, this method is equivalent to [format](https://github.com/d3/d3-time-format#format). If *specifier* is not specified, the default time format is returned. The default multi-scale time format chooses a human-readable representation based on the specified date as follows:
Returns a time format function suitable for displaying [tick](#time_ticks) values. The specified *count* is currently ignored, but is accepted for consistency with other scales such as [*continuous*.tickFormat](#continuous_tickFormat). If a format *specifier* is specified, this method is equivalent to [format](https://github.com/d3/d3-time-format#format). If *specifier* is not specified, the default time format is returned. The default multi-scale time format chooses a human-readable representation based on the specified date as follows:

* `%Y` - for year boundaries, such as `2011`.
* `%B` - for month boundaries, such as `February`.
Expand Down
2 changes: 1 addition & 1 deletion src/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function calendar(year, month, week, day, hour, minute, second, milliseco
return r ? t.reverse() : t;
};

scale.tickFormat = function(specifier) {
scale.tickFormat = function(count, specifier) {
return specifier == null ? tickFormat : format(specifier);
};

Expand Down
4 changes: 2 additions & 2 deletions test/time-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ tape("time.tickFormat()(date) otherwise, formats second", function(test) {
test.end();
});

tape("time.tickFormat(specifier) returns a time format for the specified specifier", function(test) {
var f = scale.scaleTime().tickFormat("%c");
tape("time.tickFormat(count, specifier) returns a time format for the specified specifier", function(test) {
var f = scale.scaleTime().tickFormat(10, "%c");
test.equal(f(date.local(2011, 1, 2, 12)), "Wed Feb 2 12:00:00 2011");
test.end();
});
4 changes: 2 additions & 2 deletions test/utcTime-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ tape("scaleUtc.tickFormat()(date) otherwise, formats second", function(test) {
test.end();
});

tape("scaleUtc.tickFormat(specifier) returns a time format for the specified specifier", function(test) {
var f = scale.scaleUtc().tickFormat("%c");
tape("scaleUtc.tickFormat(count, specifier) returns a time format for the specified specifier", function(test) {
var f = scale.scaleUtc().tickFormat(10, "%c");
test.equal(f(date.utc(2011, 1, 2, 12)), "Wed Feb 2 12:00:00 2011");
test.end();
});

0 comments on commit 3cc1011

Please sign in to comment.