Commit eb384180 authored by Mike Bostock's avatar Mike Bostock
Browse files

Revert "Define rangeBand in context of rangePoints."

This reverts commit b7f5f305, which broke the
behavior of the axis component for ordinal scales by changing the meaning of
rangeBand.
parent cf4c17ad
{
"name": "d3",
"version": "3.1.8",
"version": "3.1.9",
"main": "index-browserify.js",
"scripts": [
"index-browserify.js",
......
d3 = function() {
var d3 = {
version: "3.1.8"
version: "3.1.9"
};
if (!Date.now) Date.now = function() {
return +new Date();
......@@ -6790,7 +6790,7 @@ d3 = function() {
if (arguments.length < 2) padding = 0;
var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding);
range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
rangeBand = Math.abs(step);
rangeBand = 0;
ranger = {
t: "rangePoints",
a: arguments
......
This diff is collapsed.
{
"name": "d3",
"version": "3.1.8",
"version": "3.1.9",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
......
......@@ -42,7 +42,7 @@ function d3_scale_ordinal(domain, ranger) {
stop = x[1],
step = (stop - start) / (Math.max(1, domain.length - 1) + padding);
range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
rangeBand = Math.abs(step);
rangeBand = 0;
ranger = {t: "rangePoints", a: arguments};
return scale;
};
......
d3 = (function(){
var d3 = {version: "3.1.8"}; // semver
var d3 = {version: "3.1.9"}; // semver
......@@ -109,29 +109,38 @@ 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(), 60);
var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120], 1);
assert.deepEqual(x.range(), [20, 60, 100]);
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(), 30);
},
"correctly handles singleton domains": function(ordinal) {
var x = ordinal().domain(["a"]).rangePoints([0, 120]);
assert.deepEqual(x.range(), [60]);
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(), 60);
var x = ordinal().domain(["a", "b", "c"]).rangePoints([120, 0], 1);
assert.deepEqual(x.range(), [100, 60, 20]);
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(), 30);
},
"has a rangeBand of zero": function(ordinal) {
var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120]);
assert.equal(x.rangeBand(), 0);
var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120], 1);
assert.equal(x.rangeBand(), 0);
var x = ordinal().domain(["a", "b", "c"]).rangePoints([0, 120], 2);
assert.equal(x.rangeBand(), 0);
var x = ordinal().domain(["a"]).rangePoints([0, 120]);
assert.equal(x.rangeBand(), 0);
var x = ordinal().domain(["a", "b", "c"]).rangePoints([120, 0]);
assert.equal(x.rangeBand(), 0);
var x = ordinal().domain(["a", "b", "c"]).rangePoints([120, 0], 1);
assert.equal(x.rangeBand(), 0);
var x = ordinal().domain(["a", "b", "c"]).rangePoints([120, 0], 2);
assert.equal(x.rangeBand(), 0);
}
},
......@@ -244,14 +253,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(), 1, 1e-6);
assert.inDelta(x.rangeBand(), 0, 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(), 1, 1e-6);
assert.inDelta(x.rangeBand(), 0, 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!
Please register or to comment