问题
JSBin of my example with code
I have a line chart of two variables on separate axes:

The .csv file has missing values at the beginning and end for the blue series ('close'):
date,open,close
1-May-89,161,
1-May-90,170,
1-May-91,137,
1-May-92,144,91.9
1-May-93,91,91.8
(...)
1-May-11,12,75.7
1-May-12,7,68.2
1-May-13,15,
The missing value at the end is handled properly (the line is truncated), but the first three are treated as zero values. How can I have the blue, 'close' series start at 1992?
回答1:
Fixed by using @mccannf's suggestion, I changed one block to:
var valueline = d3.svg.line()
.defined(function(d) { return d.close != 0; }) // added this line
.x(function(d) { return x(d.date); })
.y(function(d) { return y0(d.close); });
For some reason, the following didn't work, even though it's what's cited in the example:
.defined(function(d) { return d.close != null; })
来源:https://stackoverflow.com/questions/26387359/how-do-i-get-d3-to-treat-missing-values-as-null-instead-of-zero