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

将限制线添加到D3.js线图,d3.js,D3.js,嗨。有没有办法为d3js线图设置一条限制线?表示沿x轴的极限线,显示最大极限 svg.append( "line" ) .attr("x1", x( x.domain()[0] ) ) .attr("y1", y( 80 ) ) // whatever the y-val should be 这是我现在使用的代码。但不起作用。对css部分有疑问吗 有人能给我一个详细的概述吗?我终于得到了我问题的答案。希望这对将来的人有所帮助。非常感谢所有回答我问题的人 .line { stroke: #9

嗨。有没有办法为d3js线图设置一条限制线?表示沿x轴的极限线,显示最大极限

svg.append( "line" )
.attr("x1", x( x.domain()[0] ) )
.attr("y1", y( 80 ) )   // whatever the y-val should be
这是我现在使用的代码。但不起作用。对css部分有疑问吗


有人能给我一个详细的概述吗?

我终于得到了我问题的答案。希望这对将来的人有所帮助。非常感谢所有回答我问题的人

.line {
stroke: #993300;
fill: none;
stroke-width: 0.75px;
}

.line.line5 {
 stroke:red; 
}


var valueline2 = d3.svg.line()

.x(function(d) { return main_x(d.date); })

.y(function(d) { return main_y0(Value); });

 var main1 = svg.append("g")

.attr("transform", "translate(" + main_margin.left + "," + main_margin.top + ")"); 


 main1.append("path")
    .datum(data)
    .attr("clip-path", "url(#clip)")
    .attr("class", "line line5")
    .style("stroke-dasharray", ("3, 3"))
    .attr("d", valueline2);

    main1.append("text")      
        .attr("x", 890)
        .attr("y",  65 )
        .style("text-anchor", "middle")
      .text("Value");

请提供一个用于创建一条线,您必须定义两个点。这与我所需要的类似。但没有真正起作用。很抱歉,我无法上传图像,感谢祈使和Anto Jurković的回复。特别感谢Neeku。这是什么,不起作用?请提供更多代码和详细的错误消息。你从另一个问题得到的样本非常可靠和直接。只需创建一条新线,它必须有两个坐标开始:x1,y1和结束:x2,y2。另一个类似的问题