### Define rangeBand in context of rangePoints.

```Previously, the rangeBand was zero when rangePoints was used. Now it returns the
size of the step between points. Fixes #584.```
parent d1d71e16
 ... ... @@ -6762,7 +6762,7 @@ d3 = function() { if (arguments.length < 2) padding = 0; var start = x, stop = x, step = (stop - start) / (Math.max(1, domain.length - 1) + padding); range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); rangeBand = 0; rangeBand = Math.abs(step); ranger = { t: "rangePoints", a: arguments ... ...
This source diff could not be displayed because it is too large. You can view the blob instead.
 ... ... @@ -42,7 +42,7 @@ function d3_scale_ordinal(domain, ranger) { stop = x, step = (stop - start) / (Math.max(1, domain.length - 1) + padding); range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); rangeBand = 0; rangeBand = Math.abs(step); ranger = {t: "rangePoints", a: arguments}; return scale; }; ... ...
 ... ... @@ -109,29 +109,29 @@ suite.addBatch({ "computes discrete points in a continuous range": function(ordinal) { var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120]); assert.deepEqual(x.range(), [0, 60, 120]); assert.equal(x.rangeBand(), 0); assert.equal(x.rangeBand(), 60); var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120], 1); assert.deepEqual(x.range(), [20, 60, 100]); assert.equal(x.rangeBand(), 0); assert.equal(x.rangeBand(), 40); var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120], 2); assert.deepEqual(x.range(), [30, 60, 90]); assert.equal(x.rangeBand(), 0); assert.equal(x.rangeBand(), 30); }, "correctly handles singleton domains": function(ordinal) { var x = ordinal().domain(["a"]).rangePoints([0, 120]); assert.deepEqual(x.range(), ); assert.equal(x.rangeBand(), 0); assert.equal(x.rangeBand(), 120); }, "can be set to a descending range": function(ordinal) { var x = ordinal().domain(["a", "b", "c"]).rangePoints([120, 0]); assert.deepEqual(x.range(), [120, 60,0]); assert.equal(x.rangeBand(), 0); assert.equal(x.rangeBand(), 60); var x = ordinal().domain(["a", "b", "c"]).rangePoints([120, 0], 1); assert.deepEqual(x.range(), [100, 60, 20]); assert.equal(x.rangeBand(), 0); assert.equal(x.rangeBand(), 40); var x = ordinal().domain(["a", "b", "c"]).rangePoints([120, 0], 2); assert.deepEqual(x.range(), [90, 60, 30]); assert.equal(x.rangeBand(), 0); assert.equal(x.rangeBand(), 30); } }, ... ... @@ -244,14 +244,14 @@ suite.addBatch({ x.rangePoints([1, 2]); assert.inDelta(x(0), 1, 1e-6); assert.inDelta(x(1), 2, 1e-6); assert.inDelta(x.rangeBand(), 0, 1e-6); assert.inDelta(x.rangeBand(), 1, 1e-6); assert.inDelta(y(0), 1/11, 1e-6); assert.inDelta(y(1), 6/11, 1e-6); assert.inDelta(y.rangeBand(), 4/11, 1e-6); y.rangeBands([0, 1]); assert.inDelta(x(0), 1, 1e-6); assert.inDelta(x(1), 2, 1e-6); assert.inDelta(x.rangeBand(), 0, 1e-6); assert.inDelta(x.rangeBand(), 1, 1e-6); assert.inDelta(y(0), 0, 1e-6); assert.inDelta(y(1), 1/2, 1e-6); assert.inDelta(y.rangeBand(), 1/2, 1e-6); ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!