d3 / d3-axis

Human-readable reference marks for scales.

Home Page:https://d3js.org/d3-axis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ordinal axis may generate invalid transforms when interrupting transitions.

Paulskit opened this issue · comments

If calling axis in transition while another axis transition is in place, there are errors in console:
Error: attribute transform: Expected number, "translate(NaN,0)".

Here is the example (click Different data button and see console errors output):
http://plnkr.co/edit/6dFgUrzAk3PMpaCTVhkq?p=preview

Per Reporting an Issue, please use bl.ocks.org, RunKit or a pull request to post your test case. The use of sites such as Plnkr interfere with debugging, and make it impossible for me to investigate without first migrating your example to another site. Which I have done, and also substantially reduced your test case:

https://bl.ocks.org/mbostock/d23a97cb8ac3674f87a26724e526a0ed

It appears that when the second axis transition starts, and the first axis transition is still running, that the second transition sees exiting ticks from the first transition. The position of the first transition’s exiting ticks is undefined in both the new scale and the old scale for the second transition. (Their position was only defined in the old scale of the first transition.)

Sorry for plnkr, I didn't found the link to Reporting an Issue doc.
You are correct about cause of this issue. Another thing is that __axis values is being written just before transition starts. So when second transition starts and first is not yet finished, it sees old ticks and updated __axis with new scale values instead of old ones.
I was able to fix this setting __axis to new scale only after transition end. Please see my pull request.

Is it possible to have new patch version of this lib published in npm?

Yes. Doing that now. Sorry for the delay.