svg / d3.js rounded corner on one corner of a rectangle

后端 未结 5 1268
青春惊慌失措
青春惊慌失措 2020-12-01 04:41

I know svg has an in built function to do rounded corners, but I need to do rounded corners on only 2 of the four corners.

I know I can draw multiple rectangles on t

5条回答
  •  我在风中等你
    2020-12-01 05:05

    In case others end up here wanting to round all corners of a rect element, you can add an rx attribute to the rect element (as @mbostock mentions in his fiddle above):

    var rectangle = group.append("rect")
        .attr("width", 60)
        .attr("height", 75)
        .attr("rx", 4)
        .style("fill", function(d) { return "#e6653e"; })
        .style("stroke", function(d) { return d3.rgb("#e6653e").darker(); })
    

提交回复
热议问题