Skip to content

Adding arrowhead2 & 3 markers to SVG for graphs #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion implementation/library-d3-svg/js/GraphDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,33 @@ GraphDrawer = function(svgOrigin,extraMargin,transTime){
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)

/* Add the arrowhead markers for directed edges in the SVG images */
var defs = svgOrigin
.attr("id","graph-defs")
.append("defs");

defs.append("marker")
.attr("id", "arrowhead2")
.attr("refX",24) /*must be smarter way to calculate shift*/
.attr("refY",4)
.attr("markerUnits","userSpaceOnUse")
.attr("markerWidth", 24)
.attr("markerHeight", 8)
.attr("orient", "auto")
.append("path")
.attr("d", "M 0,0 V 8 L12,4 Z"); //this is actual shape for arrowhead

defs.append("marker")
.attr("id", "arrowhead3")
.attr("refX",24) /*must be smarter way to calculate shift*/
.attr("refY",4)
.attr("markerUnits","userSpaceOnUse")
.attr("markerWidth", 24)
.attr("markerHeight", 8)
.attr("orient", "auto-start-reverse")
.append("path")
.attr("d", "M 0,0 V 8 L12,4 Z"); //this is actual shape for arrowhead

var svg = svgOrigin.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");

Expand Down Expand Up @@ -422,4 +449,4 @@ GraphDrawer.prototype.nodePos = function(d){
obj.x = this.x(this.nodeX(d));
obj.y = this.y(this.nodeY(d));
return obj;
}
}