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

Preserve tick ordering when updating axis.

Fixes #1748.
parent b86e4e4a
......@@ -8686,7 +8686,7 @@
g.each(function() {
var g = d3.select(this);
var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy();
var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickTransform;
var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"),
d3.transition(path));
tickEnter.append("line");
......
This diff is collapsed.
......@@ -30,7 +30,7 @@ d3.svg.axis = function() {
tick = g.selectAll(".tick").data(ticks, scale1),
tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε),
tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(),
tickUpdate = d3.transition(tick).style("opacity", 1),
tickUpdate = d3.transition(tick.order()).style("opacity", 1),
tickTransform;
// Domain.
......
......@@ -486,6 +486,15 @@ suite.addBatch({
assert.isFalse(t.select("text").empty());
assert.equal(t.select("text").text(), tickFormat(ticks[i]));
});
},
"maintains the order of tick marks": function(d3) {
var a = d3.svg.axis(),
g = d3.select("body").html("").append("g").call(a),
x = d3.scale.linear().domain([1, 1.5]);
a.scale().domain(x.domain());
g.call(a.ticks(10));
g.call(a.ticks(20));
assert.deepEqual(g.selectAll(".tick").data(), x.ticks(20));
}
}
}
......
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