diff --git a/README.md b/README.md index e9f3338..6c65e82 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ See also [*axis*.ticks](#axis_ticks). # axis.tickValues([values]) · [Source](https://github.com/d3/d3-axis/blob/master/src/axis.js) -If a *values* array is specified, the specified values are used for ticks rather than using the scale’s automatic tick generator. If *values* is null, clears any previously-set explicit tick values and reverts back to the scale’s tick generator. If *values* is not specified, returns the current tick values, which defaults to null. For example, to generate ticks at specific values: +If a *values* iterable is specified, the specified values are used for ticks rather than using the scale’s automatic tick generator. If *values* is null, clears any previously-set explicit tick values and reverts back to the scale’s tick generator. If *values* is not specified, returns the current tick values, which defaults to null. For example, to generate ticks at specific values: ```js var xAxis = d3.axisBottom(x) diff --git a/src/array.js b/src/array.js deleted file mode 100644 index 8eeac16..0000000 --- a/src/array.js +++ /dev/null @@ -1 +0,0 @@ -export var slice = Array.prototype.slice; diff --git a/src/axis.js b/src/axis.js index 3f79513..78e1bcb 100644 --- a/src/axis.js +++ b/src/axis.js @@ -1,4 +1,3 @@ -import {slice} from "./array.js"; import identity from "./identity.js"; var top = 1, @@ -120,15 +119,15 @@ function axis(orient, scale) { }; axis.ticks = function() { - return tickArguments = slice.call(arguments), axis; + return tickArguments = Array.from(arguments), axis; }; axis.tickArguments = function(_) { - return arguments.length ? (tickArguments = _ == null ? [] : slice.call(_), axis) : tickArguments.slice(); + return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis) : tickArguments.slice(); }; axis.tickValues = function(_) { - return arguments.length ? (tickValues = _ == null ? null : slice.call(_), axis) : tickValues && tickValues.slice(); + return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis) : tickValues && tickValues.slice(); }; axis.tickFormat = function(_) { diff --git a/test/.eslintrc.json b/test/.eslintrc.json index 1da3303..79b1754 100644 --- a/test/.eslintrc.json +++ b/test/.eslintrc.json @@ -6,6 +6,7 @@ }, "env": { "browser": true, + "es6": true, "node": true, "mocha": true } diff --git a/test/axis-test.js b/test/axis-test.js index 072d8cc..9df3f14 100644 --- a/test/axis-test.js +++ b/test/axis-test.js @@ -61,3 +61,8 @@ it("axis.tickValues() makes a defensive copy of the tick values", () => { v.push(4); assert.deepStrictEqual(a.tickValues(), [1, 2, 3]); }); + +it("axis.tickValues(values) accepts an iterable", () => { + const a = axisLeft(scaleLinear()).tickValues(new Set([1, 2, 3])); + assert.deepStrictEqual(a.tickValues(), [1, 2, 3]); +});