diff --git a/CHANGELOG.md b/CHANGELOG.md index 14c2c31..1940ecc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [2.0.2](https://github.com/ErikGartner/dtree/compare/2.0.1...v2.0.2) (2017-05-02) + + +### Bug Fixes + +* Incorrect marriages line. #53 ([25fd62e](https://github.com/ErikGartner/dtree/commit/25fd62e)) + + + ## [2.0.1](https://github.com/ErikGartner/dtree/compare/2.0.0...v2.0.1) (2017-04-10) diff --git a/README.md b/README.md index 515b293..f1b05d5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,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/2.0.1/dist/dTree.min.js +https://cdn.rawgit.com/ErikGartner/dTree/2.0.2/dist/dTree.min.js ``` ## Requirements diff --git a/dist/dTree.js b/dist/dTree.js index 32c45dd..16f0f4e 100644 --- a/dist/dTree.js +++ b/dist/dTree.js @@ -166,6 +166,13 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons d.source.y = start[0].y; d.target.x = end[0].x; d.target.y = end[0].y; + + var marriageId = start[0].data.marriageNode != null ? start[0].data.marriageNode.id : end[0].data.marriageNode.id; + var marriageNode = allNodes.find(function (n) { + return n.data.id == marriageId; + }); + d.source.marriageNode = marriageNode; + d.target.marriageNode = marriageNode; }); } }, { @@ -191,10 +198,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons x: d.source.x + nodeWidth * 6 / 10, y: ny }, { - x: d.target.x - nodeWidth * 6 / 10, + x: d.target.marriageNode.x, y: ny }, { - x: d.target.x - nodeWidth * 6 / 10, + x: d.target.marriageNode.x, y: d.target.y }, { x: d.target.x, @@ -231,7 +238,11 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons maxHeight = Math.max(maxHeight, height); n.cHeight = height; - n.cWidth = width; + if (n.data.hidden) { + n.cWidth = 0; + } else { + n.cWidth = width; + } }); document.body.removeChild(tmpSvg); @@ -274,7 +285,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var dTree = { - VERSION: '2.0.1', + VERSION: '2.0.2', init: function init(data) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; @@ -397,7 +408,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons children: [], textClass: sp.textClass ? sp.textClass : opts.styles.text, 'class': sp['class'] ? sp['class'] : opts.styles.node, - extra: sp.extra + extra: sp.extra, + marriageNode: m }; parent.children.push(m, spouse); diff --git a/dist/dTree.js.map b/dist/dTree.js.map index 30427b3..de26da8 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;AAC3B,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,GAC3D,MAAM,CAAC,KAAK,GAAG,OAAO,EAAE,AAAC,CAAC;CAC3B,CAAA,CAAC,IAAI,EAAG,YAAY;AAAE,cAAY,CAAC;;MAE9B,WAAW;AAEJ,aAFP,WAAW,CAEH,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;4BAF9B,WAAW;;AAGb,iBAAW,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC;;AAE7C,UAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACjB,UAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;AACzB,UAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;;AAGjB,UAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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AS,CAAC;KAClB;;GAEF,CAAC;;AAEF,SAAO,KAAK,CAAC;CAEZ,CAAE,CAAE","file":"dTree.js","sourcesContent":["(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.dTree = factory());\n}(this, (function () { 'use strict';\n\nclass 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 let 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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let width = opts.width + opts.margin.left + opts.margin.right;\n let height = opts.height + opts.margin.top + opts.margin.bottom;\n\n let zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function() {\n svg.attr('transform', d3.event.transform.translate(width / 2, opts.margin.top));\n });\n\n //make an SVG\n let 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 // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2.5]);\n\n this.tree.separation(function separation(a, b) {\n if (a.data.hidden || b.data.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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n // filter links with no parents to prevent empty nodes\n .filter(function(l) {\n return !l.target.data.noParent;\n })\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n let nodes = this.svg.selectAll('.node')\n .data(treenodes.descendants())\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', _.bind(this._siblingLine, this));\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .filter(function(d) {\n return d.data.hidden ? false : true;\n })\n .attr('x', function(d) {\n return d.x - d.cWidth / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - d.cHeight / 2 + 'px';\n })\n .attr('width', function(d) {\n return d.cWidth + 'px';\n })\n .attr('height', function(d) {\n return d.cHeight + 'px';\n })\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n return opts.callbacks.nodeRenderer(\n d.data.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.data.extra,\n d.data.id,\n d.data.class,\n d.data.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d) {\n if (d.data.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.data.name, d.data.extra, d.data.id);\n });\n }\n\n _flatten(root) {\n let n = [];\n let 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.data.noParent) {\n return 'M0,0L0,0';\n }\n let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n let 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 let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n let allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d) {\n let start = allNodes.filter(function(v) {\n return d.source.id == v.data.id;\n });\n let end = allNodes.filter(function(v) {\n return d.target.id == v.data.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 let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n let nodeWidth = this.nodeSize[0];\n let nodeHeight = this.nodeSize[1];\n\n // Not first marriage\n if (d.number > 0) {\n ny -= nodeHeight * 8 / 10;\n }\n\n let linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: ny\n }, {\n x: d.target.x - nodeWidth * 6 / 10,\n y: ny\n }, {\n x: d.target.x - nodeWidth * 6 / 10,\n y: d.target.y\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n let maxWidth = 0;\n let maxHeight = 0;\n let tmpSvg = document.createElement('svg');\n document.body.appendChild(tmpSvg);\n\n _.map(nodes, function(n) {\n let container = document.createElement('div');\n container.setAttribute('class', n.data.class);\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n let text = textRenderer(n.data.name, n.data.extra, n.data.textClass);\n container.innerHTML = text;\n\n tmpSvg.appendChild(container);\n let height = container.offsetHeight;\n tmpSvg.removeChild(container);\n\n maxHeight = Math.max(maxHeight, height);\n n.cHeight = height;\n n.cWidth = width;\n });\n document.body.removeChild(tmpSvg);\n\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n let 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\nconst dTree = {\n\n VERSION: '2.0.1',\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 parent.children.push(node);\n\n //sort marriages\n dTree._sortMarriages(person.marriages, opts);\n\n // go through marriage\n _.forEach(person.marriages, function(marriage, index) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: marriage.extra\n };\n\n var sp = 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 parent.children.push(m, spouse);\n\n dTree._sortPersons(marriage.children, opts);\n _.forEach(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 number: index\n });\n });\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: d3.hierarchy(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 _sortMarriages: function(marriages, opts) {\n if (marriages != undefined && Array.isArray(marriages)) {\n marriages.sort(function(marriageA, marriageB) {\n var a = marriageA.spouse;\n var b = marriageB.spouse;\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return marriages;\n }\n\n};\n\nreturn dTree;\n\n})));\n"]} \ No newline at end of file +{"version":3,"sources":["dTree.js"],"names":[],"mappings":";;;;AAAA,AAAC,CAAA,UAAU,MAAM,EAAE,OAAO,EAAE;AAC3B,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,GAC3D,MAAM,CAAC,KAAK,GAAG,OAAO,EAAE,AAAC,CAAC;CAC3B,CAAA,CAAC,IAAI,EAAG,YAAY;AAA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E,IAAI,CAAC,CAAC;OAC/B,CAAC,CAAC;;AAEH,aAAO;AACL,YAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;AACxB,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;;AAED,kBAAc,EAAE,wBAAS,SAAS,EAAE,IAAI,EAAE;AACxC,UAAI,SAAS,IAAI,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;AACtD,iBAAS,CAAC,IAAI,CAAC,UAAS,SAAS,EAAE,SAAS,EAAE;AAC5C,cAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;AACzB,cAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;AACzB,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,SAAS,CAAC;KAClB;;GAEF,CAAC;;AAEF,SAAO,KAAK,CAAC;CAEZ,CAAE,CAAE","file":"dTree.js","sourcesContent":["(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.dTree = factory());\n}(this, (function () { 'use strict';\n\nclass 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 let 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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let width = opts.width + opts.margin.left + opts.margin.right;\n let height = opts.height + opts.margin.top + opts.margin.bottom;\n\n let zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function() {\n svg.attr('transform', d3.event.transform.translate(width / 2, opts.margin.top));\n });\n\n //make an SVG\n let 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 // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2.5]);\n\n this.tree.separation(function separation(a, b) {\n if (a.data.hidden || b.data.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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n // filter links with no parents to prevent empty nodes\n .filter(function(l) {\n return !l.target.data.noParent;\n })\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n let nodes = this.svg.selectAll('.node')\n .data(treenodes.descendants())\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', _.bind(this._siblingLine, this));\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .filter(function(d) {\n return d.data.hidden ? false : true;\n })\n .attr('x', function(d) {\n return d.x - d.cWidth / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - d.cHeight / 2 + 'px';\n })\n .attr('width', function(d) {\n return d.cWidth + 'px';\n })\n .attr('height', function(d) {\n return d.cHeight + 'px';\n })\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n return opts.callbacks.nodeRenderer(\n d.data.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.data.extra,\n d.data.id,\n d.data.class,\n d.data.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d) {\n if (d.data.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.data.name, d.data.extra, d.data.id);\n });\n }\n\n _flatten(root) {\n let n = [];\n let 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.data.noParent) {\n return 'M0,0L0,0';\n }\n let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n let 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 let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n let allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d) {\n let start = allNodes.filter(function(v) {\n return d.source.id == v.data.id;\n });\n let end = allNodes.filter(function(v) {\n return d.target.id == v.data.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 let marriageId = (start[0].data.marriageNode != null ?\n start[0].data.marriageNode.id :\n end[0].data.marriageNode.id);\n let marriageNode = allNodes.find(function(n) {\n return n.data.id == marriageId;\n });\n d.source.marriageNode = marriageNode;\n d.target.marriageNode = marriageNode;\n });\n\n }\n\n _siblingLine(d, i) {\n\n let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n let nodeWidth = this.nodeSize[0];\n let nodeHeight = this.nodeSize[1];\n\n // Not first marriage\n if (d.number > 0) {\n ny -= nodeHeight * 8 / 10;\n }\n\n let linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: ny\n }, {\n x: d.target.marriageNode.x,\n y: ny\n }, {\n x: d.target.marriageNode.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n let maxWidth = 0;\n let maxHeight = 0;\n let tmpSvg = document.createElement('svg');\n document.body.appendChild(tmpSvg);\n\n _.map(nodes, function(n) {\n let container = document.createElement('div');\n container.setAttribute('class', n.data.class);\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n let text = textRenderer(n.data.name, n.data.extra, n.data.textClass);\n container.innerHTML = text;\n\n tmpSvg.appendChild(container);\n let height = container.offsetHeight;\n tmpSvg.removeChild(container);\n\n maxHeight = Math.max(maxHeight, height);\n n.cHeight = height;\n if (n.data.hidden) {\n n.cWidth = 0;\n } else {\n n.cWidth = width;\n }\n });\n document.body.removeChild(tmpSvg);\n\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n let 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\nconst dTree = {\n\n VERSION: '2.0.2',\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 parent.children.push(node);\n\n //sort marriages\n dTree._sortMarriages(person.marriages, opts);\n\n // go through marriage\n _.forEach(person.marriages, function(marriage, index) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: marriage.extra\n };\n\n var sp = 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 marriageNode: m\n };\n\n parent.children.push(m, spouse);\n\n dTree._sortPersons(marriage.children, opts);\n _.forEach(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 number: index\n });\n });\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: d3.hierarchy(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 _sortMarriages: function(marriages, opts) {\n if (marriages != undefined && Array.isArray(marriages)) {\n marriages.sort(function(marriageA, marriageB) {\n var a = marriageA.spouse;\n var b = marriageB.spouse;\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return marriages;\n }\n\n};\n\nreturn dTree;\n\n})));\n"]} \ No newline at end of file diff --git a/dist/dTree.min.js b/dist/dTree.min.js index 237128f..da3460c 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;n\n',r+=e,r+="
\n"}},{key:"_debug",value:function(t){e.DEBUG_LEVEL>0&&console.log(t)}}]),e}(),t={VERSION:"2.0.1",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,a,i,s,o,d,c,l){return e._nodeRenderer(t,n,r,a,i,s,o,d,c,l)},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),a=new e(t.root,t.siblings,r);a.create()},_preprocess:function(e,n){var r=[],a=0,i={name:"",id:a++,hidden:!0,children:[]},s=function o(e,s){var d={name:e.name,id:a++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass?e.textClass:n.styles.text,"class":e["class"]?e["class"]:n.styles.node};s==i&&(d.noParent=!0);for(var c=0;c\n',r+=e,r+="
\n"}},{key:"_debug",value:function(t){e.DEBUG_LEVEL>0&&console.log(t)}}]),e}(),t={VERSION:"2.0.2",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,a,i,s,o,d,c,l){return e._nodeRenderer(t,n,r,a,i,s,o,d,c,l)},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),a=new e(t.root,t.siblings,r);a.create()},_preprocess:function(e,n){var r=[],a=0,i={name:"",id:a++,hidden:!0,children:[]},s=function o(e,s){var d={name:e.name,id:a++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass?e.textClass:n.styles.text,"class":e["class"]?e["class"]:n.styles.node};s==i&&(d.noParent=!0);for(var c=0;c\\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: '2.0.1',\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 parent.children.push(node);\n\n //sort marriages\n dTree._sortMarriages(person.marriages, opts);\n\n // go through marriage\n _.forEach(person.marriages, function (marriage, index) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: marriage.extra\n };\n\n var sp = 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 parent.children.push(m, spouse);\n\n dTree._sortPersons(marriage.children, opts);\n _.forEach(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 number: index\n });\n });\n };\n\n _.forEach(data, function (person) {\n reconstructTree(person, root);\n });\n\n return {\n root: d3.hierarchy(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 _sortMarriages: function _sortMarriages(marriages, opts) {\n if (marriages != undefined && Array.isArray(marriages)) {\n marriages.sort(function (marriageA, marriageB) {\n var a = marriageA.spouse;\n var b = marriageB.spouse;\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return marriages;\n }\n\n };\n\n return dTree;\n});\n//# sourceMappingURL=dTree.js.map\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.dTree = factory());\n}(this, (function () { 'use strict';\n\nclass 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 let 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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let width = opts.width + opts.margin.left + opts.margin.right;\n let height = opts.height + opts.margin.top + opts.margin.bottom;\n\n let zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function() {\n svg.attr('transform', d3.event.transform.translate(width / 2, opts.margin.top));\n });\n\n //make an SVG\n let 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 // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2.5]);\n\n this.tree.separation(function separation(a, b) {\n if (a.data.hidden || b.data.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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n // filter links with no parents to prevent empty nodes\n .filter(function(l) {\n return !l.target.data.noParent;\n })\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n let nodes = this.svg.selectAll('.node')\n .data(treenodes.descendants())\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', _.bind(this._siblingLine, this));\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .filter(function(d) {\n return d.data.hidden ? false : true;\n })\n .attr('x', function(d) {\n return d.x - d.cWidth / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - d.cHeight / 2 + 'px';\n })\n .attr('width', function(d) {\n return d.cWidth + 'px';\n })\n .attr('height', function(d) {\n return d.cHeight + 'px';\n })\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n return opts.callbacks.nodeRenderer(\n d.data.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.data.extra,\n d.data.id,\n d.data.class,\n d.data.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d) {\n if (d.data.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.data.name, d.data.extra, d.data.id);\n });\n }\n\n _flatten(root) {\n let n = [];\n let 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.data.noParent) {\n return 'M0,0L0,0';\n }\n let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n let 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 let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n let allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d) {\n let start = allNodes.filter(function(v) {\n return d.source.id == v.data.id;\n });\n let end = allNodes.filter(function(v) {\n return d.target.id == v.data.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 let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n let nodeWidth = this.nodeSize[0];\n let nodeHeight = this.nodeSize[1];\n\n // Not first marriage\n if (d.number > 0) {\n ny -= nodeHeight * 8 / 10;\n }\n\n let linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: ny\n }, {\n x: d.target.x - nodeWidth * 6 / 10,\n y: ny\n }, {\n x: d.target.x - nodeWidth * 6 / 10,\n y: d.target.y\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n let maxWidth = 0;\n let maxHeight = 0;\n let tmpSvg = document.createElement('svg');\n document.body.appendChild(tmpSvg);\n\n _.map(nodes, function(n) {\n let container = document.createElement('div');\n container.setAttribute('class', n.data.class);\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n let text = textRenderer(n.data.name, n.data.extra, n.data.textClass);\n container.innerHTML = text;\n\n tmpSvg.appendChild(container);\n let height = container.offsetHeight;\n tmpSvg.removeChild(container);\n\n maxHeight = Math.max(maxHeight, height);\n n.cHeight = height;\n n.cWidth = width;\n });\n document.body.removeChild(tmpSvg);\n\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n let 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\nconst dTree = {\n\n VERSION: '2.0.1',\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 parent.children.push(node);\n\n //sort marriages\n dTree._sortMarriages(person.marriages, opts);\n\n // go through marriage\n _.forEach(person.marriages, function(marriage, index) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: marriage.extra\n };\n\n var sp = 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 parent.children.push(m, spouse);\n\n dTree._sortPersons(marriage.children, opts);\n _.forEach(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 number: index\n });\n });\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: d3.hierarchy(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 _sortMarriages: function(marriages, opts) {\n if (marriages != undefined && Array.isArray(marriages)) {\n marriages.sort(function(marriageA, marriageB) {\n var a = marriageA.spouse;\n var b = marriageB.spouse;\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return marriages;\n }\n\n};\n\nreturn dTree;\n\n})));\n"]} \ No newline at end of file +{"version":3,"sources":["dTree.min.js","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","scaleExtent","on","svg","attr","event","transform","translate","select","append","call","tree","separation","a","b","data","_update","source","treenodes","links","selectAll","enter","l","noParent","styles","linage","_elbow","nodes","descendants","_linkSiblings","marriage","bind","_siblingLine","d","x","cWidth","y","cHeight","id","html","nodeRenderer","name","extra","textClass","nodeClick","recurse","node","children","forEach","push","ny","linedata","fun","line","curve","curveStepAfter","start","v","end","marriageId","marriageNode","find","nodeHeight","number","maxHeight","tmpSvg","document","createElement","body","appendChild","map","container","setAttribute","style","visibility","maxWidth","text","innerHTML","offsetHeight","removeChild","Math","max","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","_sortMarriages","marriages","index","m","sp","spouse","hierarchy","persons","sort","Array","isArray","marriageA","marriageB"],"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,GACC,gBAAZC,UAA0C,mBAAXC,QAAyBA,OAAOD,QAAUD,IAC9D,kBAAXG,SAAyBA,OAAOC,IAAMD,OAAOH,GACnDD,EAAOM,MAAQL,KACfM,KAAO,WAAc,YDKrB,ICHIC,GAAW,WAEJ,QAFPA,GAEQC,EAAMC,EAAUC,GDGxB/B,gBAAgB2B,KCLhBC,GAGFA,EAAYI,YAAcD,EAAKE,MAAQ,EAAI,EAE3CN,KAAKE,KAAOA,EACZF,KAAKG,SAAWA,EAChBH,KAAKI,KAAOA,EAGZJ,KAAKO,SAAWP,KAAKQ,SAASR,KAAKE,KAGnC,IAAIO,GAAeC,EAAEC,OAAOX,KAAKO,SAAU,SAASK,GAClD,OAAQA,EAAEC,QAEZb,MAAKc,SAAWV,EAAKW,UAAUD,SAASL,EACtCL,EAAKY,UAAWZ,EAAKW,UAAUE,cDmQjC,MA7PAxC,cCvBEwB,IDwBAZ,IAAK,SACL6B,MC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M5B,EAAE6B,MAAO5B,EAAE2B,KAAM3B,EAAE4B,SAGzDsE,GAKX,OAAO5I","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.zoom().scaleExtent([0.1, 10]).on('zoom', function () {\n svg.attr('transform', d3.event.transform.translate(width / 2, opts.margin.top));\n });\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 // Compute the layout.\n this.tree = d3.tree().nodeSize([nodeSize[0] * 2, nodeSize[1] * 2.5]);\n\n this.tree.separation(function separation(a, b) {\n if (a.data.hidden || b.data.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 treenodes = this.tree(source);\n var links = treenodes.links();\n\n // Create the link lines.\n this.svg.selectAll('.link').data(links).enter()\n // filter links with no parents to prevent empty nodes\n .filter(function (l) {\n return !l.target.data.noParent;\n }).append('path').attr('class', opts.styles.linage).attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node').data(treenodes.descendants()).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', _.bind(this._siblingLine, this));\n\n // Create the node rectangles.\n nodes.append('foreignObject').filter(function (d) {\n return d.data.hidden ? false : true;\n }).attr('x', function (d) {\n return d.x - d.cWidth / 2 + 'px';\n }).attr('y', function (d) {\n return d.y - d.cHeight / 2 + 'px';\n }).attr('width', function (d) {\n return d.cWidth + 'px';\n }).attr('height', function (d) {\n return d.cHeight + 'px';\n }).attr('id', function (d) {\n return d.id;\n }).html(function (d) {\n return opts.callbacks.nodeRenderer(d.data.name, d.x, d.y, nodeSize[0], nodeSize[1], d.data.extra, d.data.id, d.data['class'], d.data.textClass, opts.callbacks.textRenderer);\n }).on('click', function (d) {\n if (d.data.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.data.name, d.data.extra, d.data.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.data.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.line().curve(d3.curveStepAfter).x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n });\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.data.id;\n });\n var end = allNodes.filter(function (v) {\n return d.target.id == v.data.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 var marriageId = start[0].data.marriageNode != null ? start[0].data.marriageNode.id : end[0].data.marriageNode.id;\n var marriageNode = allNodes.find(function (n) {\n return n.data.id == marriageId;\n });\n d.source.marriageNode = marriageNode;\n d.target.marriageNode = marriageNode;\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 var nodeWidth = this.nodeSize[0];\n var nodeHeight = this.nodeSize[1];\n\n // Not first marriage\n if (d.number > 0) {\n ny -= nodeHeight * 8 / 10;\n }\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: ny\n }, {\n x: d.target.marriageNode.x,\n y: ny\n }, {\n x: d.target.marriageNode.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.line().curve(d3.curveStepAfter).x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n });\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 var tmpSvg = document.createElement('svg');\n document.body.appendChild(tmpSvg);\n\n _.map(nodes, function (n) {\n var container = document.createElement('div');\n container.setAttribute('class', n.data['class']);\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n var text = textRenderer(n.data.name, n.data.extra, n.data.textClass);\n container.innerHTML = text;\n\n tmpSvg.appendChild(container);\n var height = container.offsetHeight;\n tmpSvg.removeChild(container);\n\n maxHeight = Math.max(maxHeight, height);\n n.cHeight = height;\n if (n.data.hidden) {\n n.cWidth = 0;\n } else {\n n.cWidth = width;\n }\n });\n document.body.removeChild(tmpSvg);\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 += 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: '2.0.2',\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 parent.children.push(node);\n\n //sort marriages\n dTree._sortMarriages(person.marriages, opts);\n\n // go through marriage\n _.forEach(person.marriages, function (marriage, index) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: marriage.extra\n };\n\n var sp = 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 marriageNode: m\n };\n\n parent.children.push(m, spouse);\n\n dTree._sortPersons(marriage.children, opts);\n _.forEach(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 number: index\n });\n });\n };\n\n _.forEach(data, function (person) {\n reconstructTree(person, root);\n });\n\n return {\n root: d3.hierarchy(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 _sortMarriages: function _sortMarriages(marriages, opts) {\n if (marriages != undefined && Array.isArray(marriages)) {\n marriages.sort(function (marriageA, marriageB) {\n var a = marriageA.spouse;\n var b = marriageB.spouse;\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return marriages;\n }\n\n };\n\n return dTree;\n});\n//# sourceMappingURL=dTree.js.map\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(global.dTree = factory());\n}(this, (function () { 'use strict';\n\nclass 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 let 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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let width = opts.width + opts.margin.left + opts.margin.right;\n let height = opts.height + opts.margin.top + opts.margin.bottom;\n\n let zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function() {\n svg.attr('transform', d3.event.transform.translate(width / 2, opts.margin.top));\n });\n\n //make an SVG\n let 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 // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2, nodeSize[1] * 2.5]);\n\n this.tree.separation(function separation(a, b) {\n if (a.data.hidden || b.data.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 let opts = this.opts;\n let allNodes = this.allNodes;\n let nodeSize = this.nodeSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n // filter links with no parents to prevent empty nodes\n .filter(function(l) {\n return !l.target.data.noParent;\n })\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n let nodes = this.svg.selectAll('.node')\n .data(treenodes.descendants())\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', _.bind(this._siblingLine, this));\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .filter(function(d) {\n return d.data.hidden ? false : true;\n })\n .attr('x', function(d) {\n return d.x - d.cWidth / 2 + 'px';\n })\n .attr('y', function(d) {\n return d.y - d.cHeight / 2 + 'px';\n })\n .attr('width', function(d) {\n return d.cWidth + 'px';\n })\n .attr('height', function(d) {\n return d.cHeight + 'px';\n })\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n return opts.callbacks.nodeRenderer(\n d.data.name,\n d.x,\n d.y,\n nodeSize[0],\n nodeSize[1],\n d.data.extra,\n d.data.id,\n d.data.class,\n d.data.textClass,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d) {\n if (d.data.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.data.name, d.data.extra, d.data.id);\n });\n }\n\n _flatten(root) {\n let n = [];\n let 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.data.noParent) {\n return 'M0,0L0,0';\n }\n let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n let 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 let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n let allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d) {\n let start = allNodes.filter(function(v) {\n return d.source.id == v.data.id;\n });\n let end = allNodes.filter(function(v) {\n return d.target.id == v.data.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 let marriageId = (start[0].data.marriageNode != null ?\n start[0].data.marriageNode.id :\n end[0].data.marriageNode.id);\n let marriageNode = allNodes.find(function(n) {\n return n.data.id == marriageId;\n });\n d.source.marriageNode = marriageNode;\n d.target.marriageNode = marriageNode;\n });\n\n }\n\n _siblingLine(d, i) {\n\n let ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n let nodeWidth = this.nodeSize[0];\n let nodeHeight = this.nodeSize[1];\n\n // Not first marriage\n if (d.number > 0) {\n ny -= nodeHeight * 8 / 10;\n }\n\n let linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: d.source.y\n }, {\n x: d.source.x + nodeWidth * 6 / 10,\n y: ny\n }, {\n x: d.target.marriageNode.x,\n y: ny\n }, {\n x: d.target.marriageNode.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n let fun = d3.line().curve(d3.curveStepAfter)\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n });\n return fun(linedata);\n }\n\n static _nodeSize(nodes, width, textRenderer) {\n let maxWidth = 0;\n let maxHeight = 0;\n let tmpSvg = document.createElement('svg');\n document.body.appendChild(tmpSvg);\n\n _.map(nodes, function(n) {\n let container = document.createElement('div');\n container.setAttribute('class', n.data.class);\n container.style.visibility = 'hidden';\n container.style.maxWidth = width + 'px';\n\n let text = textRenderer(n.data.name, n.data.extra, n.data.textClass);\n container.innerHTML = text;\n\n tmpSvg.appendChild(container);\n let height = container.offsetHeight;\n tmpSvg.removeChild(container);\n\n maxHeight = Math.max(maxHeight, height);\n n.cHeight = height;\n if (n.data.hidden) {\n n.cWidth = 0;\n } else {\n n.cWidth = width;\n }\n });\n document.body.removeChild(tmpSvg);\n\n return [width, maxHeight];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n let 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\nconst dTree = {\n\n VERSION: '2.0.2',\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 parent.children.push(node);\n\n //sort marriages\n dTree._sortMarriages(person.marriages, opts);\n\n // go through marriage\n _.forEach(person.marriages, function(marriage, index) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: marriage.extra\n };\n\n var sp = 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 marriageNode: m\n };\n\n parent.children.push(m, spouse);\n\n dTree._sortPersons(marriage.children, opts);\n _.forEach(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 number: index\n });\n });\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n return {\n root: d3.hierarchy(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 _sortMarriages: function(marriages, opts) {\n if (marriages != undefined && Array.isArray(marriages)) {\n marriages.sort(function(marriageA, marriageB) {\n var a = marriageA.spouse;\n var b = marriageB.spouse;\n return opts.callbacks.nodeSorter(a.name, a.extra, b.name, b.extra);\n });\n }\n return marriages;\n }\n\n};\n\nreturn dTree;\n\n})));\n"]} \ No newline at end of file diff --git a/package.json b/package.json index 3ed3779..7006a35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "d3-dtree", - "version": "2.0.1", + "version": "2.0.2", "description": "A library for visualizing data trees built on top of D3.", "main": "dist/dTree.js", "scripts": {