D3: Random error when changing scales

Created on 14 Jun 2016  Â·  5Comments  Â·  Source: d3/d3

d3.js:5949 Error: <g> attribute transform: Trailing garbage, "translate(0,NaN)".

I keep getting this error randomly with d3 when I'm changing scales in my application.

Any idea what might cause it?
Just to sum up:

  • I'm only switching between linear and logarithmic scales.
  • Data stays intact.
  • Error shows randomly.
  • All data points are positive.
  • Can't google solution to this error.

Most helpful comment

Sounds like you’re trying to render a log scale with a domain that crosses (or includes) zero.

All 5 comments

Can you please post a code example in JSBin/JSFiddle/bl.ocks.org that reproduces the error? Without a code example, it's nearly impossible to debug and find the root cause. Thank you.

Sounds like you’re trying to render a log scale with a domain that crosses (or includes) zero.

I tested some axis transitions between linear and log, and even in the case that you’re going to or from a linear scale that crosses zero, the negative ticks just fade-out or fade-in rather than transitioning from an undefined position in log space.

The axis uses the scale as the key for the join, so for example, when transitioning to a log scale with a positive domain, any zero or negative ticks would have the key “NaN” and are put in the exit selection rather than the update selection. Then when the axis computes the ending transform for the exiting ticks, the log scale’s position for the exiting ticks is likewise NaN, and so the exiting ticks simply fade-out in-place.

I’ll reopen this and investigate if you post an example demonstrating the issue. Thank you.

So how we can avoid this error in console when i am doing the switch from linear scale (having negative domain) to log scale with positive domain

Also had this error while trying to convert a scatter plot with linear scale to a log scale. Thanks for clearing this up!

Was this page helpful?
0 / 5 - 0 ratings