[英]How to draw a diamond with the path “d” attribute?
Is anybody able to show me how to draw a diamond using the path "d" attribute? 有人能告诉我如何使用路径“ d”属性绘制菱形吗? I'm trying to append the diamond to the end of a graph's edge.
我试图将菱形附加到图形边缘的末端。 I haven't been able to find any good examples..I currently have:
我一直找不到合适的例子。.我目前有:
var marker = parent.append("marker")
.attr("id", id)
.attr("viewBox", "0 0 10 10")
.attr("refX", 11)
.attr("refY", 5)
.attr("markerUnits", "strokeWidth")
.attr("markerWidth", 7)
.attr("markerHeight", 7)
.attr("orient", "auto");
var path = marker.append("path")
// trying to draw a diamond here
.attr("d", "M 0 0 A 200 400 30 1 0 600 200")
.style("stroke-width", 1)
.style("stroke-dasharray", "1,0")
.style("fill", "red")
.style("stroke", "black");
Here's a diamond shape. 这是菱形。 I don't know why you had an elliptical arc in your question as you only really need lines for a diamond.
我不知道为什么您的问题中会有椭圆弧,因为您只需要钻石的直线。
var path = d3.select("svg") .append("path") // trying to draw a diamond here .attr("d", "M 50 0 100 100 50 200 0 100 Z") .style("stroke-width", 1) .style("stroke-dasharray", "1,0") .style("fill", "red") .style("stroke", "black");
html, body { height: 100%; width: 100%; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script> <svg width="100%" height="100%"></svg>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.