UNPKG

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

47 lines (37 loc) 1.03 kB
import * as _ from 'lodash-es'; // Public utility functions export { isSubgraph, edgeToId, applyStyle, applyClass, applyTransition }; /* * Returns true if the specified node in the graph is a subgraph node. A * subgraph node is one that contains other nodes. */ function isSubgraph(g, v) { return !!g.children(v).length; } function edgeToId(e) { return escapeId(e.v) + ':' + escapeId(e.w) + ':' + escapeId(e.name); } var ID_DELIM = /:/g; function escapeId(str) { return str ? String(str).replace(ID_DELIM, '\\:') : ''; } function applyStyle(dom, styleFn) { if (styleFn) { dom.attr('style', styleFn); } } function applyClass(dom, classFn, otherClasses) { if (classFn) { dom.attr('class', classFn).attr('class', otherClasses + ' ' + dom.attr('class')); } } function applyTransition(selection, g) { var graph = g.graph(); if (_.isPlainObject(graph)) { var transition = graph.transition; if (_.isFunction(transition)) { return transition(selection); } } return selection; }