From abf05c757a8db8386dd6fcdc8d8343335ad0a4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20G=C3=A4rtner?= Date: Sun, 7 Jul 2019 22:22:50 +0200 Subject: [PATCH] chore: Bump version number --- CHANGELOG.md | 11 +++++++++++ README.md | 2 +- dist/dTree.js | 16 ++++++++-------- dist/dTree.js.map | 2 +- dist/dTree.min.js | 2 +- dist/dTree.min.js.map | 2 +- package.json | 2 +- 7 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 343ce1b..b78c1cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +## [2.2.2](https://github.com/ErikGartner/dtree/compare/2.2.1...v2.2.2) (2019-07-07) + + +### Bug Fixes + +* Lower rectangle border thinner than the upper one in Firefox ([748a0c4](https://github.com/ErikGartner/dtree/commit/748a0c4)) +* Rounding issues #92 ([9b70e04](https://github.com/ErikGartner/dtree/commit/9b70e04)) + + + ## [2.2.1](https://github.com/ErikGartner/dtree/compare/2.1.0...v2.2.1) (2019-05-07) diff --git a/README.md b/README.md index ee2b0b8..cc60966 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ yarn add d3-dtree Lastly dTree is also available through several CDNs such as [jsDelivr](https://www.jsdelivr.com/package/npm/d3-dtree): ``` -https://cdn.jsdelivr.net/npm/d3-dtree@2.2.1/dist/dTree.min.js +https://cdn.jsdelivr.net/npm/d3-dtree@2.2.2/dist/dTree.min.js ``` ## Requirements diff --git a/dist/dTree.js b/dist/dTree.js index 2374846..3bf3457 100644 --- a/dist/dTree.js +++ b/dist/dTree.js @@ -87,9 +87,9 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons nodes.append('foreignObject').filter(function (d) { return d.data.hidden ? false : true; }).attr('x', function (d) { - return d.x - d.cWidth / 2 + 'px'; + return Math.round(d.x - d.cWidth / 2) + 'px'; }).attr('y', function (d) { - return d.y - d.cHeight / 2 + 'px'; + return Math.round(d.y - d.cHeight / 2) + 'px'; }).attr('width', function (d) { return d.cWidth + 'px'; }).attr('height', function (d) { @@ -135,7 +135,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons if (d.target.data.noParent) { return 'M0,0L0,0'; } - var ny = d.target.y + (d.source.y - d.target.y) * 0.50; + var ny = Math.round(d.target.y + (d.source.y - d.target.y) * 0.50); var linedata = [{ x: d.target.x, @@ -185,23 +185,23 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons key: '_siblingLine', value: function _siblingLine(d, i) { - var ny = d.target.y + (d.source.y - d.target.y) * 0.50; + var ny = Math.round(d.target.y + (d.source.y - d.target.y) * 0.50); var nodeWidth = this.nodeSize[0]; var nodeHeight = this.nodeSize[1]; // Not first marriage if (d.number > 0) { - ny -= nodeHeight * 8 / 10; + ny -= Math.round(nodeHeight * 8 / 10); } var linedata = [{ x: d.source.x, y: d.source.y }, { - x: d.source.x + nodeWidth * 6 / 10, + x: Math.round(d.source.x + nodeWidth * 6 / 10), y: d.source.y }, { - x: d.source.x + nodeWidth * 6 / 10, + x: Math.round(d.source.x + nodeWidth * 6 / 10), y: ny }, { x: d.target.marriageNode.x, @@ -296,7 +296,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var dTree = { - VERSION: '2.2.1', + VERSION: '2.2.2', 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 2b277c2..7bee8dc 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,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C,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,\n opts.callbacks.nodeHeightSeperation(nodeSize[0], nodeSize[1])]);\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 .on('contextmenu', function(d)  {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n opts.callbacks.nodeRightClick(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 _nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return nodeMaxHeight + 25;\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 += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\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.2.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 nodeRightClick: function(name, extra, id) {},\n nodeHeightSeperation: function(nodeWidth, nodeMaxHeight) {\n return TreeBuilder._nodeHeightSeperation(nodeWidth, nodeMaxHeight);\n },\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 +{"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,EAA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,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,\n opts.callbacks.nodeHeightSeperation(nodeSize[0], nodeSize[1])]);\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 Math.round(d.x - d.cWidth / 2) + 'px';\n })\n .attr('y', function(d) {\n return Math.round(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 .on('contextmenu', function(d)  {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n opts.callbacks.nodeRightClick(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 = Math.round(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 = Math.round(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 -= Math.round(nodeHeight * 8 / 10);\n }\n\n let linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: Math.round(d.source.x + nodeWidth * 6 / 10),\n y: d.source.y\n }, {\n x: Math.round(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 _nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return nodeMaxHeight + 25;\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 += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\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.2.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 nodeRightClick: function(name, extra, id) {},\n nodeHeightSeperation: function(nodeWidth, nodeMaxHeight) {\n return TreeBuilder._nodeHeightSeperation(nodeWidth, nodeMaxHeight);\n },\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 1a43047..6779889 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;n0&&(n-=8*a/10);var i=[{x:e.source.x,y:e.source.y},{x:e.source.x+6*r/10,y:e.source.y},{x:e.source.x+6*r/10,y:n},{x:e.target.marriageNode.x,y:n},{x:e.target.marriageNode.x,y:e.target.y},{x:e.target.x,y:e.target.y}],o=d3.line().curve(d3.curveStepAfter).x(function(e){return e.x}).y(function(e){return e.y});return o(i)}}],[{key:"_nodeHeightSeperation",value:function(e,t){return t+25}},{key:"_nodeSize",value:function(e,t,n){var r=0,a=document.createElement("svg");return document.body.appendChild(a),_.map(e,function(e){var i=document.createElement("div");i.setAttribute("class",e.data["class"]),i.style.visibility="hidden",i.style.maxWidth=t+"px";var o=n(e.data.name,e.data.extra,e.data.textClass);i.innerHTML=o,a.appendChild(i);var d=i.offsetHeight;a.removeChild(i),r=Math.max(r,d),e.cHeight=d,e.data.hidden?e.cWidth=0:e.cWidth=t}),document.body.removeChild(a),[t,r]}},{key:"_nodeRenderer",value:function(e,t,n,r,a,i,o,d,s,c){var l="";return l+="
\n',l+=c(e,i,s),l+="
"}},{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:"2.2.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){},nodeRightClick:function(e,t,n){},nodeHeightSeperation:function(t,n){return e._nodeHeightSeperation(t,n)},nodeRenderer:function(t,n,r,a,i,o,d,s,c,l){return e._nodeRenderer(t,n,r,a,i,o,d,s,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:[]},o=function d(e,o){var s={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};o==i&&(s.noParent=!0);for(var c=0;c0&&(n-=Math.round(8*a/10));var i=[{x:e.source.x,y:e.source.y},{x:Math.round(e.source.x+6*r/10),y:e.source.y},{x:Math.round(e.source.x+6*r/10),y:n},{x:e.target.marriageNode.x,y:n},{x:e.target.marriageNode.x,y:e.target.y},{x:e.target.x,y:e.target.y}],o=d3.line().curve(d3.curveStepAfter).x(function(e){return e.x}).y(function(e){return e.y});return o(i)}}],[{key:"_nodeHeightSeperation",value:function(e,t){return t+25}},{key:"_nodeSize",value:function(e,t,n){var r=0,a=document.createElement("svg");return document.body.appendChild(a),_.map(e,function(e){var i=document.createElement("div");i.setAttribute("class",e.data["class"]),i.style.visibility="hidden",i.style.maxWidth=t+"px";var o=n(e.data.name,e.data.extra,e.data.textClass);i.innerHTML=o,a.appendChild(i);var d=i.offsetHeight;a.removeChild(i),r=Math.max(r,d),e.cHeight=d,e.data.hidden?e.cWidth=0:e.cWidth=t}),document.body.removeChild(a),[t,r]}},{key:"_nodeRenderer",value:function(e,t,n,r,a,i,o,d,s,c){var l="";return l+="
\n',l+=c(e,i,s),l+="
"}},{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:"2.2.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){},nodeRightClick:function(e,t,n){},nodeHeightSeperation:function(t,n){return e._nodeHeightSeperation(t,n)},nodeRenderer:function(t,n,r,a,i,o,d,s,c,l){return e._nodeRenderer(t,n,r,a,i,o,d,s,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:[]},o=function d(e,o){var s={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};o==i&&(s.noParent=!0);for(var c=0;c 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: '_nodeHeightSeperation',\n value: function _nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return nodeMaxHeight + 25;\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 += 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: '2.2.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 nodeRightClick: function nodeRightClick(name, extra, id) {},\n nodeHeightSeperation: function nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return TreeBuilder._nodeHeightSeperation(nodeWidth, nodeMaxHeight);\n },\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\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,\n opts.callbacks.nodeHeightSeperation(nodeSize[0], nodeSize[1])]);\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 .on('contextmenu', function(d)  {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n opts.callbacks.nodeRightClick(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 _nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return nodeMaxHeight + 25;\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 += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\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.2.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 nodeRightClick: function(name, extra, id) {},\n nodeHeightSeperation: function(nodeWidth, nodeMaxHeight) {\n return TreeBuilder._nodeHeightSeperation(nodeWidth, nodeMaxHeight);\n },\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 +{"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","nodeHeightSeperation","separation","a","b","data","_update","source","treenodes","links","selectAll","enter","l","noParent","styles","linage","_elbow","nodes","descendants","_linkSiblings","marriage","bind","_siblingLine","d","Math","round","x","cWidth","y","cHeight","id","html","nodeRenderer","name","extra","textClass","nodeClick","preventDefault","nodeRightClick","recurse","node","children","forEach","push","ny","linedata","fun","line","curve","curveStepAfter","start","v","end","marriageId","marriageNode","find","nodeHeight","number","nodeMaxHeight","maxHeight","tmpSvg","document","createElement","body","appendChild","map","container","setAttribute","style","visibility","maxWidth","text","innerHTML","offsetHeight","removeChild","max","nodeClass","msg","console","log","VERSION","init","options","arguments","undefined","defaultsDeep","_nodeHeightSeperation","_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,WAA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SAASC,EAAW7I,GAQlC,MAPiBsH,SAAbuB,GAA0BQ,MAAMC,QAAQT,IAC1CA,EAAUO,KAAK,SAASG,EAAWC,GACjC,GAAInH,GAAIkH,EAAUN,OACd3G,EAAIkH,EAAUP,MAClB,OAAOjJ,GAAKW,UAAUgH,WAAWtF,EAAE8B,KAAM9B,EAAE+B,MAAO9B,EAAE6B,KAAM7B,EAAE8B,SAGzDyE,GAKX,OAAOlJ","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, opts.callbacks.nodeHeightSeperation(nodeSize[0], nodeSize[1])]);\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 Math.round(d.x - d.cWidth / 2) + 'px';\n }).attr('y', function (d) {\n return Math.round(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 }).on('contextmenu', function (d) {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n opts.callbacks.nodeRightClick(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 = Math.round(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 = Math.round(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 -= Math.round(nodeHeight * 8 / 10);\n }\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: Math.round(d.source.x + nodeWidth * 6 / 10),\n y: d.source.y\n }, {\n x: Math.round(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: '_nodeHeightSeperation',\n value: function _nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return nodeMaxHeight + 25;\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 += 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: '2.2.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 nodeRightClick: function nodeRightClick(name, extra, id) {},\n nodeHeightSeperation: function nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return TreeBuilder._nodeHeightSeperation(nodeWidth, nodeMaxHeight);\n },\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\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,\n opts.callbacks.nodeHeightSeperation(nodeSize[0], nodeSize[1])]);\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 Math.round(d.x - d.cWidth / 2) + 'px';\n })\n .attr('y', function(d) {\n return Math.round(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 .on('contextmenu', function(d)  {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n opts.callbacks.nodeRightClick(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 = Math.round(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 = Math.round(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 -= Math.round(nodeHeight * 8 / 10);\n }\n\n let linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: Math.round(d.source.x + nodeWidth * 6 / 10),\n y: d.source.y\n }, {\n x: Math.round(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 _nodeHeightSeperation(nodeWidth, nodeMaxHeight) {\n return nodeMaxHeight + 25;\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 += textRenderer(name, extra, textClass);\n node += '
';\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\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.2.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 nodeRightClick: function(name, extra, id) {},\n nodeHeightSeperation: function(nodeWidth, nodeMaxHeight) {\n return TreeBuilder._nodeHeightSeperation(nodeWidth, nodeMaxHeight);\n },\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 fa03d90..3b8085f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "d3-dtree", - "version": "2.2.1", + "version": "2.2.2", "description": "A library for visualizing data trees built on top of D3.", "main": "dist/dTree.js", "scripts": {