Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

axis transition with ordinal scale broken since 3.3.4 #1535

Closed
bmesuere opened this issue Sep 21, 2013 · 4 comments
Closed

axis transition with ordinal scale broken since 3.3.4 #1535

bmesuere opened this issue Sep 21, 2013 · 4 comments
Labels
bug Something isn’t working
Milestone

Comments

@bmesuere
Copy link

This problem occurs since updating from 3.3.3 to 3.3.4, and probably has something to do with 06e2077.

I have a graph with an ordinal x-axis to which the user can add and remove items. Since the update to 3.3.4, after removing an item (and updating the domain to reflect this), the position of the ticks and labels on the x-axis don't update. However, the value of the labels and the position of the datapoints on the graph are updated correctly.

relevant code:

var x = d3.scale.ordinal().rangePoints([0, width], 1);
var xAxis = d3.svg.axis()
        .scale(x)
        .tickFormat(function (id) { return labels[id].name; })
        .orient("bottom");

on update:

x.domain(ids);
svg.select(".x.axis").transition().call(xAxis);

Quite possibly this caused by me relying on something I shouldn't be relying on, but I can't figure out what's wrong.

@bmesuere
Copy link
Author

The problem can be reproduced with this minimal example: http://jsfiddle.net/Xmdg4/1/

@mbostock
Copy link
Member

Thanks for the report. I think the axis is actually doing the right thing here, and the bug is in the behavior of the ordinal scale. I filed #1536 to track that.

mbostock added a commit that referenced this issue Sep 21, 2013
When an ordinal scale’s range is explicitly defined as an array of values, we
can build the domain implicitly by progressively assigning values from the
range; this is commonly done with color palettes, for example.

However, when an ordinal scale’s range is rather implied by chopping a
continuous range into a series of points or bands, then the domain must be
specified explicitly: for the scale to be consistent, we need to know the
cardinality of the domain to compute the implied range values.

Thus, it only makes sense to extend the domain implicitly when the range is
specified explicitly. Fixes #1536 #1535.
@bmesuere
Copy link
Author

Great, thanks for the quick fix, Mike!

@mbostock
Copy link
Member

Fixed in 3.3.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Development

No branches or pull requests

2 participants