Bug report: d3.range, when supplied with NaN or undefined, gets corrupted

107 views
Skip to first unread message

Nav N

unread,
Dec 15, 2014, 12:06:00 AM12/15/14
to d3...@googlegroups.com
Hi. I searched for where to submit a bug report and couldn't find any place, so posting here.
 
When working with the path transitions example: http://bost.ocks.org/mike/path/ to create a realtime dynamic graph I used:
var data = d3.range(n).map(random);
 
and used AJAX to retrieve values from a server and push the values into data
 
when pushing values to data:

data.push(valueFromServer);

The first value I got from the server was sometimes NaN or undefined. All other values I got from the server were normal integers. But just because of this initial NaN or undefined, the range appeared to get corrupted and no lines would get displayed on the graph.

Perhaps the range function could be modified to detect NaN or undefined values and reject the values and prevent it from affecting the range?

Kai Chang

unread,
Dec 15, 2014, 12:58:45 AM12/15/14
to d3...@googlegroups.com
d3.range is a pure function. It returns an array of numbers.

  d3.range(3)          // returns [0, 1, 2]

d3.range does not modify the behavior of arrays. `map` and `push` are array methods.

NaN and undefined values may be pushed onto an array. That's the correct behavior.

d3.svg.line can exclude undefined or NaN values with line.defined()


--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages