Comparing version 0.0.2 to 0.0.3
@@ -0,1 +1,6 @@ | ||
# v0.0.3 | ||
* Support for HTML node labels. To use an HTML node label, start the label with | ||
the `<` character. | ||
# v0.0.2 | ||
@@ -2,0 +7,0 @@ |
{ | ||
"name": "dagre", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Directed graph rendering", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -59,9 +59,9 @@ /* | ||
var text = createTextNode(u); | ||
svg.appendChild(text); | ||
var svgNode = createSVGNode(u); | ||
svg.appendChild(svgNode); | ||
var bbox = text.getBBox(); | ||
var bbox = svgNode.getBBox(); | ||
attrs.width = Math.max(attrs.width, bbox.width); | ||
attrs.height = Math.max(attrs.height, bbox.height); | ||
svg.removeChild(text); | ||
svg.removeChild(svgNode); | ||
}); | ||
@@ -68,0 +68,0 @@ |
@@ -57,4 +57,10 @@ /* | ||
var text = createTextNode(u); | ||
group.appendChild(text); | ||
var svgNode = createSVGNode(u); | ||
if(svgNode.nodeName === "foreignObject") { | ||
svgNode.setAttribute("x", -(u.attrs.width / 2 + u.attrs.strokeWidth / 2)); | ||
svgNode.setAttribute("y", -(u.attrs.height / 2 + u.attrs.strokeWidth / 2)); | ||
svgNode.setAttribute("width", u.attrs.width); | ||
svgNode.setAttribute("height", u.attrs.height); | ||
} | ||
group.appendChild(svgNode); | ||
}); | ||
@@ -61,0 +67,0 @@ } |
@@ -11,2 +11,28 @@ dagre.util = {}; | ||
*/ | ||
function createSVGNode(node, x){ | ||
if(node.attrs.label[0] === '<') { | ||
return createHTMLNode(node); | ||
} else { | ||
return createTextNode(node, x); | ||
} | ||
} | ||
function createHTMLNode(node){ | ||
var fo = createSVGElement("foreignObject"); | ||
var div = document.createElementNS("http://www.w3.org/1999/xhtml", "div"); | ||
div.innerHTML = node.attrs.label; | ||
div.setAttribute("id", "temporaryDiv"); | ||
var body = document.getElementsByTagName('body')[0]; | ||
body.appendChild(div); | ||
var td = document.getElementById("temporaryDiv"); | ||
td.setAttribute("style", "width:10;float:left;"); | ||
fo.setAttribute("width", td.clientWidth); | ||
fo.setAttribute("height", td.clientHeight); | ||
body.removeChild(td); | ||
div.setAttribute("id", ""); | ||
fo.appendChild(div); | ||
return fo; | ||
} | ||
function createTextNode(node, x) { | ||
@@ -13,0 +39,0 @@ var fontSize = node.attrs.fontSize; |
@@ -1,1 +0,1 @@ | ||
dagre.version = "0.0.2"; | ||
dagre.version = "0.0.3"; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68911
1829