D3 没有数据值
No Data value with D3
我正在使用 D3.js 画线:
[0,10,20,15,20,10,15,5]
但是如何使用空值呢?例如:
[0,10,20,null,null,10,15,5]
考虑使用内置线生成器d3.svg.line()
. By providing an appropriate accessor function to line.defined()
您可以指定定义线的位置以及如何处理您的null
值:
The defined accessor can be used to define where the line is defined
and undefined, which is typically useful in conjunction with missing
data; the generated path data will automatically be broken into
multiple distinct subpaths, skipping undefined data.
但是请注意,线生成器默认假定您的数据是作为二维数组提供的,但是您可以轻松地相应地映射您的输入数组或向 line.x()
和 [= 提供适当的访问函数14=].
我正在使用 D3.js 画线:
[0,10,20,15,20,10,15,5]
但是如何使用空值呢?例如:
[0,10,20,null,null,10,15,5]
考虑使用内置线生成器d3.svg.line()
. By providing an appropriate accessor function to line.defined()
您可以指定定义线的位置以及如何处理您的null
值:
The defined accessor can be used to define where the line is defined and undefined, which is typically useful in conjunction with missing data; the generated path data will automatically be broken into multiple distinct subpaths, skipping undefined data.
但是请注意,线生成器默认假定您的数据是作为二维数组提供的,但是您可以轻松地相应地映射您的输入数组或向 line.x()
和 [= 提供适当的访问函数14=].