dagre-d3-es
Version:
<p align="center"> <a href="https://tbo47.github.io/" ><img src="https://img.shields.io/badge/created_by-tbo47-blue.svg" alt="Created by tbo47"></a> <a href="https://www.npmjs.com/dagre-d3-es"><img src="https://img.shields.io/npm/v/dagre-d3-es.svg?log
36 lines (28 loc) • 813 B
JavaScript
import * as util from '../util.js';
export { addHtmlLabel };
function addHtmlLabel(root, node) {
var fo = root.append('foreignObject').attr('width', '100000');
var div = fo.append('xhtml:div');
div.attr('xmlns', 'http://www.w3.org/1999/xhtml');
var label = node.label;
switch (typeof label) {
case 'function':
div.insert(label);
break;
case 'object':
// Currently we assume this is a DOM object.
div.insert(function () {
return label;
});
break;
default:
div.html(label);
}
util.applyStyle(div, node.labelStyle);
div.style('display', 'inline-block');
// Fix for firefox
div.style('white-space', 'nowrap');
var client = div.node();
fo.attr('width', client.offsetWidth).attr('height', client.offsetHeight);
return fo;
}