diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fc41e9..68f8090 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + +## [0.7.5](https://github.com/ErikGartner/dtree/compare/0.7.4...v0.7.5) (2016-01-04) + + + + ## [0.7.4](https://github.com/ErikGartner/dtree/compare/0.7.3...v0.7.4) (2016-01-04) diff --git a/README.md b/README.md index 8d352c3..d073a1a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ There are several ways to use dTree. One way is to simply include the compiled f Lastly dTree is also available through the RawGit CDN: ``` -https://cdn.rawgit.com/ErikGartner/dTree/0.7.4/dist/dTree.min.js +https://cdn.rawgit.com/ErikGartner/dTree/0.7.5/dist/dTree.min.js ``` ## Requirements diff --git a/dist/dTree.js b/dist/dTree.js index 68a5b83..0a8870b 100644 --- a/dist/dTree.js +++ b/dist/dTree.js @@ -262,7 +262,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var dTree = { - VERSION: '0.7.4', + VERSION: '0.7.5', init: function init(data) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; diff --git a/dist/dTree.js.map b/dist/dTree.js.map index d8f1a49..8eb2350 100644 --- a/dist/dTree.js.map +++ b/dist/dTree.js.map @@ -1 +1 @@ -{"version":3,"sources":["dTree.js"],"names":[],"mappings":";;;;AAAA,AAAC,CAAA,UAAU,MAAM,EAAE,OAAO,EAAE;AAC1B,SAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,GACzF,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAC5D,MAAM,CAAC,KAAK,GAAG,OAAO,EAAE,CAAC;CAC1B,CAAA,CAAC,IAAI,EAAE,YAAY;AAAE,cAAY,CAAC;;MAE3B,WAAW;AAEJ,aAFP,WAAW,CAEH,IAAI,EAAE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AAI,CAAC,CAAC;OAC/B,CAAC,CAAC;;AAEH,aAAO;AACL,YAAI,EAAE,IAAI;AACV,gBAAQ,EAAE,QAAQ;OACnB,CAAC;KAEH;;AAED,gBAAY,EAAE,sBAAS,OAAO,EAAE,IAAI,EAAE;AACpC,UAAI,OAAO,IAAI,SAAS,EAAE;AACxB,eAAO,CAAC,IAAI,CAAC,UAAS,CAAC,EAAE,CAAC,EAAE;AAC1B,iBAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SACpE,CAAC,CAAC;OACJ;AACD,aAAO,OAAO,CAAC;KAChB;;GAEF,CAAC;;AAEF,SAAO,KAAK,CAAC;CAEd,CAAC,CAAE","file":"dTree.js","sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n TreeBuilder.DEBUG_LEVEL = opts.debug ? 1 : 0;\n\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n\n // Calculate node size\n var visibleNodes = _.filter(this.allNodes, function(n) {\n return !n.hidden;\n });\n this.nodeSize = opts.callbacks.nodeSize(visibleNodes,\n opts.nodeWidth, opts.callbacks.textRenderer);\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', width)\n .attr('height', height)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2]);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 2 + 'px';\n })\n .attr('width', nodeSize[0] + 'px')\n .attr('height', nodeSize[1] + 'px')\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(\n d.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.extra,\n d.id,\n d.class,\n d.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d)  {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n var maxWidth = 0;\n var maxHeight = 0;\n _.forEach(nodes, function(n) {\n var container = document.createElement('div');\n container.style.marginLeft = '5px';\n container.style.paddingTop = '5px';\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n var text = textRenderer(n.name, n.extra, n.textClass);\n container.innerHTML = text;\n document.body.appendChild(container);\n\n maxHeight = Math.max(maxHeight, container.offsetHeight);\n maxWidth = Math.max(maxWidth, container.clientWidth);\n document.body.removeChild(container);\n });\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

\\n';\n node += name;\n node += '

\\n';\n return node;\n }\n\n static _debug(msg) {\n if (TreeBuilder.DEBUG_LEVEL > 0)  {\n console.log(msg);\n }\n }\n\n }\n\n const dTree = {\n\n VERSION: '0.7.4',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRenderer: function(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra,\n id,nodeClass, textClass, textRenderer);\n },\n nodeSize: function(nodes, width, textRenderer) {\n return TreeBuilder._nodeSize(nodes, width, textRenderer);\n },\n nodeSorter: function(aName, aExtra, bName, bExtra) {return 0;},\n textRenderer: function(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data, opts);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data, opts) {\n\n var siblings = [];\n var id = 0;\n\n var root = {\n name: '',\n id: id++,\n hidden: true,\n children: []\n };\n\n var reconstructTree = function(person, parent) {\n\n // convert to person to d3 node\n var node = {\n name: person.name,\n id: id++,\n hidden: false,\n children: [],\n extra: person.extra,\n textClass: person.textClass ? person.textClass : opts.styles.text,\n class: person.class ? person.class : opts.styles.node\n };\n\n // hide linages to the hidden root node\n if (parent == root) {\n node.noParent = true;\n }\n\n // apply depth offset\n for (var i = 0; i < person.depthOffset; i++) {\n var pushNode = {\n name: '',\n id: id++,\n hidden: true,\n children: [],\n noParent: node.noParent\n };\n parent.children.push(pushNode);\n parent = pushNode;\n }\n\n // sort children\n dTree._sortPersons(person.children, opts);\n\n // add \"direct\" children\n _.forEach(person.children, function(child) {\n reconstructTree(child, node);\n });\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n var sp = person.marriage.spouse;\n\n var spouse = {\n name: sp.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: sp.textClass ? sp.textClass : opts.styles.text,\n class: sp.class ? sp.class : opts.styles.node,\n extra: sp.extra\n };\n\n var marriedCouple = dTree._sortPersons([node, spouse], opts);\n parent.children.push(marriedCouple[0], m, marriedCouple[1]);\n\n dTree._sortPersons(person.marriage.children, opts);\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n } else {\n parent.children.push(node);\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n },\n\n _sortPersons: function(persons, opts) {\n if (persons != undefined) {\n persons.sort(function(a, b) {\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return persons;\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["dTree.js"],"names":[],"mappings":";;;;AAAA,AAAC,CAAA,UAAU,MAAM,EAAE,OAAO,EAAE;AAC1B,SAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,GACzF,OAAO,MAAM,KAAK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EAAE;aACd;WACF,CAAC,CAAC;SAEJ,MAAM;AACL,gBAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC5B;OAEF,CAAC;;AAEF,OAAC,CAAC,OAAO,CAAC,IAAI,EAAE,UAAS,MAAM,EAAE;AAC/B,uBAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;OAC/B,CAAC,CAAC;;AAEH,aAAO;AACL,YAAI,EAAE,IAAI;AACV,gBAAQ,EAAE,QAAQ;OACnB,CAAC;KAEH;;AAED,gBAAY,EAAE,sBAAS,OAAO,EAAE,IAAI,EAAE;AACpC,UAAI,OAAO,IAAI,SAAS,EAAE;AACxB,eAAO,CAAC,IAAI,CAAC,UAAS,CAAC,EAAE,CAAC,EAAE;AAC1B,iBAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SACpE,CAAC,CAAC;OACJ;AACD,aAAO,OAAO,CAAC;KAChB;;GAEF,CAAC;;AAEF,SAAO,KAAK,CAAC;CAEd,CAAC,CAAE","file":"dTree.js","sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n TreeBuilder.DEBUG_LEVEL = opts.debug ? 1 : 0;\n\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n\n // Calculate node size\n var visibleNodes = _.filter(this.allNodes, function(n) {\n return !n.hidden;\n });\n this.nodeSize = opts.callbacks.nodeSize(visibleNodes,\n opts.nodeWidth, opts.callbacks.textRenderer);\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', width)\n .attr('height', height)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2]);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 2 + 'px';\n })\n .attr('width', nodeSize[0] + 'px')\n .attr('height', nodeSize[1] + 'px')\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(\n d.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.extra,\n d.id,\n d.class,\n d.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d)  {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n var maxWidth = 0;\n var maxHeight = 0;\n _.forEach(nodes, function(n) {\n var container = document.createElement('div');\n container.style.marginLeft = '5px';\n container.style.paddingTop = '5px';\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n var text = textRenderer(n.name, n.extra, n.textClass);\n container.innerHTML = text;\n document.body.appendChild(container);\n\n maxHeight = Math.max(maxHeight, container.offsetHeight);\n maxWidth = Math.max(maxWidth, container.clientWidth);\n document.body.removeChild(container);\n });\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

\\n';\n node += name;\n node += '

\\n';\n return node;\n }\n\n static _debug(msg) {\n if (TreeBuilder.DEBUG_LEVEL > 0)  {\n console.log(msg);\n }\n }\n\n }\n\n const dTree = {\n\n VERSION: '0.7.5',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRenderer: function(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra,\n id,nodeClass, textClass, textRenderer);\n },\n nodeSize: function(nodes, width, textRenderer) {\n return TreeBuilder._nodeSize(nodes, width, textRenderer);\n },\n nodeSorter: function(aName, aExtra, bName, bExtra) {return 0;},\n textRenderer: function(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data, opts);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data, opts) {\n\n var siblings = [];\n var id = 0;\n\n var root = {\n name: '',\n id: id++,\n hidden: true,\n children: []\n };\n\n var reconstructTree = function(person, parent) {\n\n // convert to person to d3 node\n var node = {\n name: person.name,\n id: id++,\n hidden: false,\n children: [],\n extra: person.extra,\n textClass: person.textClass ? person.textClass : opts.styles.text,\n class: person.class ? person.class : opts.styles.node\n };\n\n // hide linages to the hidden root node\n if (parent == root) {\n node.noParent = true;\n }\n\n // apply depth offset\n for (var i = 0; i < person.depthOffset; i++) {\n var pushNode = {\n name: '',\n id: id++,\n hidden: true,\n children: [],\n noParent: node.noParent\n };\n parent.children.push(pushNode);\n parent = pushNode;\n }\n\n // sort children\n dTree._sortPersons(person.children, opts);\n\n // add \"direct\" children\n _.forEach(person.children, function(child) {\n reconstructTree(child, node);\n });\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n var sp = person.marriage.spouse;\n\n var spouse = {\n name: sp.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: sp.textClass ? sp.textClass : opts.styles.text,\n class: sp.class ? sp.class : opts.styles.node,\n extra: sp.extra\n };\n\n var marriedCouple = dTree._sortPersons([node, spouse], opts);\n parent.children.push(marriedCouple[0], m, marriedCouple[1]);\n\n dTree._sortPersons(person.marriage.children, opts);\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n } else {\n parent.children.push(node);\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n },\n\n _sortPersons: function(persons, opts) {\n if (persons != undefined) {\n persons.sort(function(a, b) {\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return persons;\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/dist/dTree.min.js b/dist/dTree.min.js index a8a2dd7..af8b0ba 100644 --- a/dist/dTree.min.js +++ b/dist/dTree.min.js @@ -1,2 +1,2 @@ -function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n1&&(i=r[1].y),_.forEach(r,function(e){e.y=e.y-i/2});var a=this.tree.links(r);this.svg.selectAll(".link").data(a).enter().append("path").attr("class",t.styles.linage).attr("d",this._elbow);var r=this.svg.selectAll(".node").data(r).enter();this._linkSiblings(),this.svg.selectAll(".sibling").data(this.siblings).enter().append("path").attr("class",t.styles.marriage).attr("d",this._siblingLine),r.append("foreignObject").attr("display",function(e){return e.hidden?"none":""}).attr("x",function(e){return e.x-n[0]/2+"px"}).attr("y",function(e){return e.y-n[1]/2+"px"}).attr("width",n[0]+"px").attr("height",n[1]+"px").attr("id",function(e){return e.id}).html(function(e){return e.hidden?null:t.callbacks.nodeRenderer(e.name,e.x,e.y,n[0],n[1],e.extra,e.id,e["class"],e.textClass,t.callbacks.textRenderer)}).on("click",function(e){e.hidden||t.callbacks.nodeClick(e.name,e.extra,e.id)})}},{key:"_flatten",value:function(e){function t(e){e.children&&e.children.forEach(t),e.id||(e.id=++r),n.push(e)}var n=[],r=0;return t(e),n}},{key:"_elbow",value:function(e,t){if(e.target.noParent)return"M0,0L0,0";var n=e.target.y+.5*(e.source.y-e.target.y),r=[{x:e.target.x,y:e.target.y},{x:e.target.x,y:n},{x:e.source.x,y:e.source.y}],i=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}).interpolate("step-after");return i(r)}},{key:"_linkSiblings",value:function(){var e=this.allNodes;_.forEach(this.siblings,function(t){var n=e.filter(function(e){return t.source.id==e.id}),r=e.filter(function(e){return t.target.id==e.id});t.source.x=n[0].x,t.source.y=n[0].y,t.target.x=r[0].x,t.target.y=r[0].y})}},{key:"_siblingLine",value:function(e,t){var n=e.target.y+.5*(e.source.y-e.target.y),r=[{x:e.source.x,y:e.source.y},{x:e.target.x,y:n},{x:e.target.x,y:e.target.y}],i=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}).interpolate("step-after");return i(r)}}],[{key:"_nodeSize",value:function(e,t,n){var r=0,i=0;return _.forEach(e,function(e){var a=document.createElement("div");a.style.marginLeft="5px",a.style.paddingTop="5px",a.style.visibility="hidden",a.style.maxWidth=t+"px";var s=n(e.name,e.extra,e.textClass);a.innerHTML=s,document.body.appendChild(a),i=Math.max(i,a.offsetHeight),r=Math.max(r,a.clientWidth),document.body.removeChild(a)}),[t,i]}},{key:"_nodeRenderer",value:function(e,t,n,r,i,a,s,o,l,d){var c="";return c+="
\n',c+=d(e,a,l),c+="
"}},{key:"_textRenderer",value:function(e,t,n){var r="";return r+="

\n',r+=e,r+="

\n"}},{key:"_debug",value:function(t){e.DEBUG_LEVEL>0&&console.log(t)}}]),e}(),t={VERSION:"0.7.4",init:function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_.defaultsDeep(n||{},{target:"#graph",debug:!1,width:600,height:600,callbacks:{nodeClick:function(e,t,n){},nodeRenderer:function(t,n,r,i,a,s,o,l,d,c){return e._nodeRenderer(t,n,r,i,a,s,o,l,d,c)},nodeSize:function(t,n,r){return e._nodeSize(t,n,r)},nodeSorter:function(e,t,n,r){return 0},textRenderer:function(t,n,r){return e._textRenderer(t,n,r)}},margin:{top:0,right:0,bottom:0,left:0},nodeWidth:100,styles:{node:"node",linage:"linage",marriage:"marriage",text:"nodeText"}}),t=this._preprocess(t,r),i=new e(t.root,t.siblings,r);i.create()},_preprocess:function(e,n){var r=[],i=0,a={name:"",id:i++,hidden:!0,children:[]},s=function o(e,s){var l={name:e.name,id:i++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass?e.textClass:n.styles.text,"class":e["class"]?e["class"]:n.styles.node};s==a&&(l.noParent=!0);for(var d=0;d1&&(i=r[1].y),_.forEach(r,function(e){e.y=e.y-i/2});var a=this.tree.links(r);this.svg.selectAll(".link").data(a).enter().append("path").attr("class",t.styles.linage).attr("d",this._elbow);var r=this.svg.selectAll(".node").data(r).enter();this._linkSiblings(),this.svg.selectAll(".sibling").data(this.siblings).enter().append("path").attr("class",t.styles.marriage).attr("d",this._siblingLine),r.append("foreignObject").attr("display",function(e){return e.hidden?"none":""}).attr("x",function(e){return e.x-n[0]/2+"px"}).attr("y",function(e){return e.y-n[1]/2+"px"}).attr("width",n[0]+"px").attr("height",n[1]+"px").attr("id",function(e){return e.id}).html(function(e){return e.hidden?null:t.callbacks.nodeRenderer(e.name,e.x,e.y,n[0],n[1],e.extra,e.id,e["class"],e.textClass,t.callbacks.textRenderer)}).on("click",function(e){e.hidden||t.callbacks.nodeClick(e.name,e.extra,e.id)})}},{key:"_flatten",value:function(e){function t(e){e.children&&e.children.forEach(t),e.id||(e.id=++r),n.push(e)}var n=[],r=0;return t(e),n}},{key:"_elbow",value:function(e,t){if(e.target.noParent)return"M0,0L0,0";var n=e.target.y+.5*(e.source.y-e.target.y),r=[{x:e.target.x,y:e.target.y},{x:e.target.x,y:n},{x:e.source.x,y:e.source.y}],i=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}).interpolate("step-after");return i(r)}},{key:"_linkSiblings",value:function(){var e=this.allNodes;_.forEach(this.siblings,function(t){var n=e.filter(function(e){return t.source.id==e.id}),r=e.filter(function(e){return t.target.id==e.id});t.source.x=n[0].x,t.source.y=n[0].y,t.target.x=r[0].x,t.target.y=r[0].y})}},{key:"_siblingLine",value:function(e,t){var n=e.target.y+.5*(e.source.y-e.target.y),r=[{x:e.source.x,y:e.source.y},{x:e.target.x,y:n},{x:e.target.x,y:e.target.y}],i=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}).interpolate("step-after");return i(r)}}],[{key:"_nodeSize",value:function(e,t,n){var r=0,i=0;return _.forEach(e,function(e){var a=document.createElement("div");a.style.marginLeft="5px",a.style.paddingTop="5px",a.style.visibility="hidden",a.style.maxWidth=t+"px";var s=n(e.name,e.extra,e.textClass);a.innerHTML=s,document.body.appendChild(a),i=Math.max(i,a.offsetHeight),r=Math.max(r,a.clientWidth),document.body.removeChild(a)}),[t,i]}},{key:"_nodeRenderer",value:function(e,t,n,r,i,a,s,o,l,d){var c="";return c+="
\n',c+=d(e,a,l),c+="
"}},{key:"_textRenderer",value:function(e,t,n){var r="";return r+="

\n',r+=e,r+="

\n"}},{key:"_debug",value:function(t){e.DEBUG_LEVEL>0&&console.log(t)}}]),e}(),t={VERSION:"0.7.5",init:function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_.defaultsDeep(n||{},{target:"#graph",debug:!1,width:600,height:600,callbacks:{nodeClick:function(e,t,n){},nodeRenderer:function(t,n,r,i,a,s,o,l,d,c){return e._nodeRenderer(t,n,r,i,a,s,o,l,d,c)},nodeSize:function(t,n,r){return e._nodeSize(t,n,r)},nodeSorter:function(e,t,n,r){return 0},textRenderer:function(t,n,r){return e._textRenderer(t,n,r)}},margin:{top:0,right:0,bottom:0,left:0},nodeWidth:100,styles:{node:"node",linage:"linage",marriage:"marriage",text:"nodeText"}}),t=this._preprocess(t,r),i=new e(t.root,t.siblings,r);i.create()},_preprocess:function(e,n){var r=[],i=0,a={name:"",id:i++,hidden:!0,children:[]},s=function o(e,s){var l={name:e.name,id:i++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass?e.textClass:n.styles.text,"class":e["class"]?e["class"]:n.styles.node};s==a&&(l.noParent=!0);for(var d=0;d 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function (n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link').data(links).enter().append('path').attr('class', opts.styles.linage).attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node').data(nodes).enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling').data(this.siblings).enter().append('path').attr('class', opts.styles.marriage).attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject').attr('display', function (d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n }).attr('x', function (d) {\n return d.x - nodeSize[0] / 2 + 'px';\n }).attr('y', function (d) {\n return d.y - nodeSize[1] / 2 + 'px';\n }).attr('width', nodeSize[0] + 'px').attr('height', nodeSize[1] + 'px').attr('id', function (d) {\n return d.id;\n }).html(function (d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(d.name, d.x, d.y, nodeSize[0], nodeSize[1], d.extra, d.id, d['class'], d.textClass, opts.callbacks.textRenderer);\n }).on('click', function (d) {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n }, {\n key: '_flatten',\n value: function _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n }, {\n key: '_elbow',\n value: function _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }, {\n key: '_linkSiblings',\n value: function _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function (d) {\n var start = allNodes.filter(function (v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function (v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n }\n }, {\n key: '_siblingLine',\n value: function _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }], [{\n key: '_nodeSize',\n value: function _nodeSize(nodes, width, textRenderer) {\n var maxWidth = 0;\n var maxHeight = 0;\n _.forEach(nodes, function (n) {\n var container = document.createElement('div');\n container.style.marginLeft = '5px';\n container.style.paddingTop = '5px';\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n var text = textRenderer(n.name, n.extra, n.textClass);\n container.innerHTML = text;\n document.body.appendChild(container);\n\n maxHeight = Math.max(maxHeight, container.offsetHeight);\n maxWidth = Math.max(maxWidth, container.clientWidth);\n document.body.removeChild(container);\n });\n return [width, maxHeight];\n }\n }, {\n key: '_nodeRenderer',\n value: function _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n }, {\n key: '_textRenderer',\n value: function _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

\\n';\n node += name;\n node += '

\\n';\n return node;\n }\n }, {\n key: '_debug',\n value: function _debug(msg) {\n if (TreeBuilder.DEBUG_LEVEL > 0) {\n console.log(msg);\n }\n }\n }]);\n\n return TreeBuilder;\n })();\n\n var dTree = {\n\n VERSION: '0.7.4',\n\n init: function init(data) {\n var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function nodeClick(name, extra, id) {},\n nodeRenderer: function nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer);\n },\n nodeSize: function nodeSize(nodes, width, textRenderer) {\n return TreeBuilder._nodeSize(nodes, width, textRenderer);\n },\n nodeSorter: function nodeSorter(aName, aExtra, bName, bExtra) {\n return 0;\n },\n textRenderer: function textRenderer(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data, opts);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n },\n\n _preprocess: function _preprocess(data, opts) {\n\n var siblings = [];\n var id = 0;\n\n var root = {\n name: '',\n id: id++,\n hidden: true,\n children: []\n };\n\n var reconstructTree = function reconstructTree(person, parent) {\n\n // convert to person to d3 node\n var node = {\n name: person.name,\n id: id++,\n hidden: false,\n children: [],\n extra: person.extra,\n textClass: person.textClass ? person.textClass : opts.styles.text,\n 'class': person['class'] ? person['class'] : opts.styles.node\n };\n\n // hide linages to the hidden root node\n if (parent == root) {\n node.noParent = true;\n }\n\n // apply depth offset\n for (var i = 0; i < person.depthOffset; i++) {\n var pushNode = {\n name: '',\n id: id++,\n hidden: true,\n children: [],\n noParent: node.noParent\n };\n parent.children.push(pushNode);\n parent = pushNode;\n }\n\n // sort children\n dTree._sortPersons(person.children, opts);\n\n // add \"direct\" children\n _.forEach(person.children, function (child) {\n reconstructTree(child, node);\n });\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n var sp = person.marriage.spouse;\n\n var spouse = {\n name: sp.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: sp.textClass ? sp.textClass : opts.styles.text,\n 'class': sp['class'] ? sp['class'] : opts.styles.node,\n extra: sp.extra\n };\n\n var marriedCouple = dTree._sortPersons([node, spouse], opts);\n parent.children.push(marriedCouple[0], m, marriedCouple[1]);\n\n dTree._sortPersons(person.marriage.children, opts);\n _.forEach(person.marriage.children, function (child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n } else {\n parent.children.push(node);\n }\n };\n\n _.forEach(data, function (person) {\n reconstructTree(person, root);\n });\n\n return {\n root: root,\n siblings: siblings\n };\n },\n\n _sortPersons: function _sortPersons(persons, opts) {\n if (persons != undefined) {\n persons.sort(function (a, b) {\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return persons;\n }\n\n };\n\n return dTree;\n});\n//# sourceMappingURL=dTree.js.map\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n TreeBuilder.DEBUG_LEVEL = opts.debug ? 1 : 0;\n\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n\n // Calculate node size\n var visibleNodes = _.filter(this.allNodes, function(n) {\n return !n.hidden;\n });\n this.nodeSize = opts.callbacks.nodeSize(visibleNodes,\n opts.nodeWidth, opts.callbacks.textRenderer);\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', width)\n .attr('height', height)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2]);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 2 + 'px';\n })\n .attr('width', nodeSize[0] + 'px')\n .attr('height', nodeSize[1] + 'px')\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(\n d.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.extra,\n d.id,\n d.class,\n d.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d)  {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n var maxWidth = 0;\n var maxHeight = 0;\n _.forEach(nodes, function(n) {\n var container = document.createElement('div');\n container.style.marginLeft = '5px';\n container.style.paddingTop = '5px';\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n var text = textRenderer(n.name, n.extra, n.textClass);\n container.innerHTML = text;\n document.body.appendChild(container);\n\n maxHeight = Math.max(maxHeight, container.offsetHeight);\n maxWidth = Math.max(maxWidth, container.clientWidth);\n document.body.removeChild(container);\n });\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

\\n';\n node += name;\n node += '

\\n';\n return node;\n }\n\n static _debug(msg) {\n if (TreeBuilder.DEBUG_LEVEL > 0)  {\n console.log(msg);\n }\n }\n\n }\n\n const dTree = {\n\n VERSION: '0.7.4',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRenderer: function(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra,\n id,nodeClass, textClass, textRenderer);\n },\n nodeSize: function(nodes, width, textRenderer) {\n return TreeBuilder._nodeSize(nodes, width, textRenderer);\n },\n nodeSorter: function(aName, aExtra, bName, bExtra) {return 0;},\n textRenderer: function(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data, opts);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data, opts) {\n\n var siblings = [];\n var id = 0;\n\n var root = {\n name: '',\n id: id++,\n hidden: true,\n children: []\n };\n\n var reconstructTree = function(person, parent) {\n\n // convert to person to d3 node\n var node = {\n name: person.name,\n id: id++,\n hidden: false,\n children: [],\n extra: person.extra,\n textClass: person.textClass ? person.textClass : opts.styles.text,\n class: person.class ? person.class : opts.styles.node\n };\n\n // hide linages to the hidden root node\n if (parent == root) {\n node.noParent = true;\n }\n\n // apply depth offset\n for (var i = 0; i < person.depthOffset; i++) {\n var pushNode = {\n name: '',\n id: id++,\n hidden: true,\n children: [],\n noParent: node.noParent\n };\n parent.children.push(pushNode);\n parent = pushNode;\n }\n\n // sort children\n dTree._sortPersons(person.children, opts);\n\n // add \"direct\" children\n _.forEach(person.children, function(child) {\n reconstructTree(child, node);\n });\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n var sp = person.marriage.spouse;\n\n var spouse = {\n name: sp.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: sp.textClass ? sp.textClass : opts.styles.text,\n class: sp.class ? sp.class : opts.styles.node,\n extra: sp.extra\n };\n\n var marriedCouple = dTree._sortPersons([node, spouse], opts);\n parent.children.push(marriedCouple[0], m, marriedCouple[1]);\n\n dTree._sortPersons(person.marriage.children, opts);\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n } else {\n parent.children.push(node);\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n },\n\n _sortPersons: function(persons, opts) {\n if (persons != undefined) {\n persons.sort(function(a, b) {\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return persons;\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["dTree.min.js","/source/dTree.js"],"names":["_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","global","factory","exports","module","define","amd","dTree","this","TreeBuilder","root","siblings","opts","DEBUG_LEVEL","debug","allNodes","_flatten","visibleNodes","_","filter","n","hidden","nodeSize","callbacks","nodeWidth","textRenderer","value","width","margin","left","right","height","top","bottom","zoom","d3","behavior","scaleExtent","on","bind","svg","attr","event","translate","scale","select","append","call","tree","layout","separation","a","b","_update","source","nodes","rootOffset","y","forEach","links","selectAll","data","enter","styles","linage","_elbow","_linkSiblings","marriage","_siblingLine","d","x","id","html","nodeRenderer","name","extra","textClass","nodeClick","recurse","node","children","push","noParent","ny","linedata","fun","line","interpolate","start","v","end","maxWidth","maxHeight","container","document","createElement","style","marginLeft","paddingTop","visibility","text","innerHTML","body","appendChild","Math","max","offsetHeight","clientWidth","removeChild","nodeClass","msg","console","log","VERSION","init","options","arguments","undefined","defaultsDeep","_nodeRenderer","_nodeSize","nodeSorter","aName","aExtra","bName","bExtra","_textRenderer","_preprocess","treeBuilder","create","reconstructTree","person","parent","class","depthOffset","pushNode","_sortPersons","child","m","sp","spouse","marriedCouple","persons","sort"],"mappings":"AAEA,QAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCAFhH,GAAIC,cAAe,WAAe,QAASC,GAAiBC,EAAQC,GAAS,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,GAAIE,GAAaH,EAAMC,EAAIE,GAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,SAAWF,KAAYA,EAAWG,UAAW,GAAMC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAAiB,MAAO,UAAUR,EAAae,EAAYC,GAAiJ,MAA9HD,IAAYZ,EAAiBH,EAAYiB,UAAWF,GAAiBC,GAAab,EAAiBH,EAAagB,GAAqBhB,OCAjiB,SAAWkB,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBA,OAAOD,QAAUD,IAC9D,kBAAXG,SAAyBA,OAAOC,IAAMD,OAAOH,GACpDD,EAAOM,MAAQL,KACfM,KAAM,WAAc,YDKpB,ICHMC,GAAW,WAEJ,QAFPA,GAEQC,EAAMC,EAAUC,GDG1B/B,gBAAgB2B,KCLdC,GAGFA,EAAYI,YAAcD,EAAKE,MAAQ,EAAI,EAE3CN,KAAKE,KAAOA,EACZF,KAAK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a,SAAUpE,GAC7CM,EAAEwC,QAAQyE,EAAOhE,SAASa,SAAU,SAASyD,GAC3CP,EAAgBO,EAAOC,KAGzB/H,EAASsE,MACP3B,QACEiB,GAAIQ,EAAKR,IAEXpF,QACEoF,GAAIqE,EAAOrE,UAKf6D,GAAOpD,SAASC,KAAKF,GASzB,OAJA7D,GAAEwC,QAAQG,EAAM,SAASsE,GACvBD,EAAgBC,EAAQzH,MAIxBA,KAAMA,EACNC,SAAUA,IAKd6H,aAAc,SAASM,EAASlI,GAM9B,MALeyG,SAAXyB,GACFA,EAAQC,KAAK,SAAS5F,EAAGC,GACvB,MAAOxC,GAAKW,UAAUkG,WAAWtE,EAAEuB,KAAMvB,EAAEwB,MAAOvB,EAAEsB,KAAMtB,EAAEuB,SAGzDmE,GAKX,OAAOvI","file":"dTree.min.js","sourcesContent":["var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }\n\n(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.dTree = factory();\n})(this, function () {\n 'use strict';\n\n var TreeBuilder = (function () {\n function TreeBuilder(root, siblings, opts) {\n _classCallCheck(this, TreeBuilder);\n\n TreeBuilder.DEBUG_LEVEL = opts.debug ? 1 : 0;\n\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n\n // Calculate node size\n var visibleNodes = _.filter(this.allNodes, function (n) {\n return !n.hidden;\n });\n this.nodeSize = opts.callbacks.nodeSize(visibleNodes, opts.nodeWidth, opts.callbacks.textRenderer);\n }\n\n _createClass(TreeBuilder, [{\n key: 'create',\n value: function create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom().scaleExtent([0.1, 10]).on('zoom', _.bind(function () {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' + ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target).append('svg').attr('width', width).attr('height', height).call(zoom).append('g').attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree().nodeSize([nodeSize[0] * 2, nodeSize[1] * 2]);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n }\n }, {\n key: '_update',\n value: function _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function (n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link').data(links).enter().append('path').attr('class', opts.styles.linage).attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node').data(nodes).enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling').data(this.siblings).enter().append('path').attr('class', opts.styles.marriage).attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject').attr('display', function (d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n }).attr('x', function (d) {\n return d.x - nodeSize[0] / 2 + 'px';\n }).attr('y', function (d) {\n return d.y - nodeSize[1] / 2 + 'px';\n }).attr('width', nodeSize[0] + 'px').attr('height', nodeSize[1] + 'px').attr('id', function (d) {\n return d.id;\n }).html(function (d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(d.name, d.x, d.y, nodeSize[0], nodeSize[1], d.extra, d.id, d['class'], d.textClass, opts.callbacks.textRenderer);\n }).on('click', function (d) {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n }, {\n key: '_flatten',\n value: function _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n }, {\n key: '_elbow',\n value: function _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }, {\n key: '_linkSiblings',\n value: function _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function (d) {\n var start = allNodes.filter(function (v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function (v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n }\n }, {\n key: '_siblingLine',\n value: function _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }], [{\n key: '_nodeSize',\n value: function _nodeSize(nodes, width, textRenderer) {\n var maxWidth = 0;\n var maxHeight = 0;\n _.forEach(nodes, function (n) {\n var container = document.createElement('div');\n container.style.marginLeft = '5px';\n container.style.paddingTop = '5px';\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n var text = textRenderer(n.name, n.extra, n.textClass);\n container.innerHTML = text;\n document.body.appendChild(container);\n\n maxHeight = Math.max(maxHeight, container.offsetHeight);\n maxWidth = Math.max(maxWidth, container.clientWidth);\n document.body.removeChild(container);\n });\n return [width, maxHeight];\n }\n }, {\n key: '_nodeRenderer',\n value: function _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n }, {\n key: '_textRenderer',\n value: function _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

\\n';\n node += name;\n node += '

\\n';\n return node;\n }\n }, {\n key: '_debug',\n value: function _debug(msg) {\n if (TreeBuilder.DEBUG_LEVEL > 0) {\n console.log(msg);\n }\n }\n }]);\n\n return TreeBuilder;\n })();\n\n var dTree = {\n\n VERSION: '0.7.5',\n\n init: function init(data) {\n var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function nodeClick(name, extra, id) {},\n nodeRenderer: function nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer);\n },\n nodeSize: function nodeSize(nodes, width, textRenderer) {\n return TreeBuilder._nodeSize(nodes, width, textRenderer);\n },\n nodeSorter: function nodeSorter(aName, aExtra, bName, bExtra) {\n return 0;\n },\n textRenderer: function textRenderer(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data, opts);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n },\n\n _preprocess: function _preprocess(data, opts) {\n\n var siblings = [];\n var id = 0;\n\n var root = {\n name: '',\n id: id++,\n hidden: true,\n children: []\n };\n\n var reconstructTree = function reconstructTree(person, parent) {\n\n // convert to person to d3 node\n var node = {\n name: person.name,\n id: id++,\n hidden: false,\n children: [],\n extra: person.extra,\n textClass: person.textClass ? person.textClass : opts.styles.text,\n 'class': person['class'] ? person['class'] : opts.styles.node\n };\n\n // hide linages to the hidden root node\n if (parent == root) {\n node.noParent = true;\n }\n\n // apply depth offset\n for (var i = 0; i < person.depthOffset; i++) {\n var pushNode = {\n name: '',\n id: id++,\n hidden: true,\n children: [],\n noParent: node.noParent\n };\n parent.children.push(pushNode);\n parent = pushNode;\n }\n\n // sort children\n dTree._sortPersons(person.children, opts);\n\n // add \"direct\" children\n _.forEach(person.children, function (child) {\n reconstructTree(child, node);\n });\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n var sp = person.marriage.spouse;\n\n var spouse = {\n name: sp.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: sp.textClass ? sp.textClass : opts.styles.text,\n 'class': sp['class'] ? sp['class'] : opts.styles.node,\n extra: sp.extra\n };\n\n var marriedCouple = dTree._sortPersons([node, spouse], opts);\n parent.children.push(marriedCouple[0], m, marriedCouple[1]);\n\n dTree._sortPersons(person.marriage.children, opts);\n _.forEach(person.marriage.children, function (child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n } else {\n parent.children.push(node);\n }\n };\n\n _.forEach(data, function (person) {\n reconstructTree(person, root);\n });\n\n return {\n root: root,\n siblings: siblings\n };\n },\n\n _sortPersons: function _sortPersons(persons, opts) {\n if (persons != undefined) {\n persons.sort(function (a, b) {\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return persons;\n }\n\n };\n\n return dTree;\n});\n//# sourceMappingURL=dTree.js.map\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n TreeBuilder.DEBUG_LEVEL = opts.debug ? 1 : 0;\n\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n\n // Calculate node size\n var visibleNodes = _.filter(this.allNodes, function(n) {\n return !n.hidden;\n });\n this.nodeSize = opts.callbacks.nodeSize(visibleNodes,\n opts.nodeWidth, opts.callbacks.textRenderer);\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', width)\n .attr('height', height)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2]);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 2 + 'px';\n })\n .attr('width', nodeSize[0] + 'px')\n .attr('height', nodeSize[1] + 'px')\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(\n d.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.extra,\n d.id,\n d.class,\n d.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d)  {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n var maxWidth = 0;\n var maxHeight = 0;\n _.forEach(nodes, function(n) {\n var container = document.createElement('div');\n container.style.marginLeft = '5px';\n container.style.paddingTop = '5px';\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n var text = textRenderer(n.name, n.extra, n.textClass);\n container.innerHTML = text;\n document.body.appendChild(container);\n\n maxHeight = Math.max(maxHeight, container.offsetHeight);\n maxWidth = Math.max(maxWidth, container.clientWidth);\n document.body.removeChild(container);\n });\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

\\n';\n node += name;\n node += '

\\n';\n return node;\n }\n\n static _debug(msg) {\n if (TreeBuilder.DEBUG_LEVEL > 0)  {\n console.log(msg);\n }\n }\n\n }\n\n const dTree = {\n\n VERSION: '0.7.5',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRenderer: function(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra,\n id,nodeClass, textClass, textRenderer);\n },\n nodeSize: function(nodes, width, textRenderer) {\n return TreeBuilder._nodeSize(nodes, width, textRenderer);\n },\n nodeSorter: function(aName, aExtra, bName, bExtra) {return 0;},\n textRenderer: function(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data, opts);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data, opts) {\n\n var siblings = [];\n var id = 0;\n\n var root = {\n name: '',\n id: id++,\n hidden: true,\n children: []\n };\n\n var reconstructTree = function(person, parent) {\n\n // convert to person to d3 node\n var node = {\n name: person.name,\n id: id++,\n hidden: false,\n children: [],\n extra: person.extra,\n textClass: person.textClass ? person.textClass : opts.styles.text,\n class: person.class ? person.class : opts.styles.node\n };\n\n // hide linages to the hidden root node\n if (parent == root) {\n node.noParent = true;\n }\n\n // apply depth offset\n for (var i = 0; i < person.depthOffset; i++) {\n var pushNode = {\n name: '',\n id: id++,\n hidden: true,\n children: [],\n noParent: node.noParent\n };\n parent.children.push(pushNode);\n parent = pushNode;\n }\n\n // sort children\n dTree._sortPersons(person.children, opts);\n\n // add \"direct\" children\n _.forEach(person.children, function(child) {\n reconstructTree(child, node);\n });\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n var sp = person.marriage.spouse;\n\n var spouse = {\n name: sp.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: sp.textClass ? sp.textClass : opts.styles.text,\n class: sp.class ? sp.class : opts.styles.node,\n extra: sp.extra\n };\n\n var marriedCouple = dTree._sortPersons([node, spouse], opts);\n parent.children.push(marriedCouple[0], m, marriedCouple[1]);\n\n dTree._sortPersons(person.marriage.children, opts);\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n } else {\n parent.children.push(node);\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n },\n\n _sortPersons: function(persons, opts) {\n if (persons != undefined) {\n persons.sort(function(a, b) {\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return persons;\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/package.json b/package.json index e89a43e..63fcda4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "d3-dtree", - "version": "0.7.4", + "version": "0.7.5", "description": "A library for visualizing data trees built on top of D3.", "main": "dist/dTree.js", "scripts": {