将限制线添加到D3.js线图

New*_*bie 1 d3.js

有没有一种方法可以按照以下图片在D3.js折线图中添加限制线?(不必破折号)我的数据库中有上限和下限列。一直没有在网上搜索如何实现此目标的示例?

在此处输入图片说明

cmo*_*key 5

不确定确切的“极限线”是什么,但这在视觉上不是问题。首先,我建议这样做:

// (assuming some vars have been created per usual templates)

svg.append( "line" )
  .attr("x1", x( x.domain()[0] ) )
  .attr("x2", x( x.domain()[1] ) )
  .attr("y1", y( 80 ) )   // whatever the y-val should be
  .attr("y2", y( 80 ) )
Run Code Online (Sandbox Code Playgroud)

然后添加css或attrs来定义行的特定外观。

请评论任何不适用于您的方式。