将限制线添加到D3.js线图 [英] Add Limit Lines to D3.js Line Graph
本文介绍了将限制线添加到D3.js线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法,添加限制线到D3.js线图如下图所示? (不必是虚线)我在数据库中有上限和下限列。一直在搜索在线失败的示例如何实现这一点?
Is there a way of adding limit lines to a D3.js line graph as per image below? (doesn't have to be dashed) I have upper and lower limit columns in my database. Have been searching unsuccessfully online for an example of how this could be achieved?
推荐答案
不确定限制线是什么,不是问题。作为一个起点,我建议:
Not sure exactly what a 'limit line' is, but this is visually not a problem. As a starting point, I'd suggest this:
// (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 ) )
然后添加css或attrs以定义您的行的具体外观。
Then add css or attrs to define your line's specific look.
请评论任何不适合你的方式。
Please comment on any ways in which it doesn't work for you.
这篇关于将限制线添加到D3.js线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文