diff --git a/CHANGELOG.md b/CHANGELOG.md index 348d6f8..a653921 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + +## [2.4.1](https://github.com/ErikGartner/dtree/compare/2.4.0...v2.4.1) (2020-04-24) + + + + # [2.4.0](https://github.com/ErikGartner/dtree/compare/2.3.0...v2.4.0) (2020-04-24) diff --git a/README.md b/README.md index 710adbb..b91335a 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,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.4.0/dist/dTree.min.js +https://cdn.jsdelivr.net/npm/d3-dtree@2.4.1/dist/dTree.min.js ``` ## Requirements diff --git a/dist/dTree.js b/dist/dTree.js index a46d5eb..5c6f110 100644 --- a/dist/dTree.js +++ b/dist/dTree.js @@ -344,7 +344,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var dTree = { - VERSION: '2.4.0', + VERSION: '2.4.1', 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 dfc0435..3e4a25b 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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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,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC/E,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 sizes\n this.nodeSize = opts.callbacks.nodeSize.call(this,\n // filter hidden and marriage nodes\n _.filter(\n this.allNodes,\n node => !(node.hidden || _.get(node, 'data.isMarriage'))\n ),\n opts.nodeWidth,\n opts.callbacks.textRenderer\n );\n this.marriageSize = opts.callbacks.marriageSize.call(this,\n // filter hidden and non marriage nodes\n _.filter(\n this.allNodes,\n node => !node.hidden && _.get(node, 'data.isMarriage')\n ),\n this.opts.marriageNodeSize\n );\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 // create zoom handler\n const zoom = this.zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function () {\n g.attr('transform', d3.event.transform);\n });\n\n // make a svg\n const svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('viewBox', [0, 0, width, height])\n .call(zoom);\n\n // create svg group that holds all nodes\n const g = this.g = svg.append('g');\n\n // set zoom identity\n svg.call(zoom.transform, d3.zoomIdentity.translate(width / 2, opts.margin.top).scale(1));\n\n // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2,\n opts.callbacks.nodeHeightSeperation.call(this, 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 let marriageSize = this.marriageSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.g.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.g.selectAll('.node')\n .data(treenodes.descendants())\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.g.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 if (d.data.isMarriage) {\n return opts.callbacks.marriageRenderer.call(this,\n d.x,\n d.y,\n marriageSize[0],\n marriageSize[1],\n d.data.extra,\n d.data.id,\n d.data.class\n )\n } else {\n return opts.callbacks.nodeRenderer.call(this,\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 }\n })\n .on('dblclick', function () {\n // do not propagate a double click on a node\n // to prevent the zoom from being triggered\n d3.event.stopPropagation();\n })\n .on('click', function(d) {\n // ignore double-clicks and clicks on hidden nodes\n if (d3.event.detail === 2 || d.data.hidden) {\n return;\n }\n if (d.data.isMarriage) {\n opts.callbacks.marriageClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\n })\n .on('contextmenu', function(d) {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n if (d.data.isMarriage) {\n opts.callbacks.marriageRightClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeRightClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\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 _marriageSize (nodes, size) {\n _.map(nodes, function (n) {\n if (!n.data.hidden) {\n n.cHeight = size;\n n.cWidth = size;\n }\n });\n\n return [size, size]\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 _marriageRenderer (x, y, height, width, extra, id, nodeClass) {\n return ``\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.4.0',\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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRightClick: function(name, extra, id) {},\n marriageClick: function(extra, id) {},\n marriageRightClick: function(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 marriageRenderer: function (x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass)\n },\n marriageSize: function (nodes, size) {\n return TreeBuilder._marriageSize(nodes, size)\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo (x, y, zoom = 1, duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(opts.width / 2, opts.height / 2)\n .scale(zoom)\n .translate(-x, -y)\n );\n }\n\n return {\n resetZoom: function (duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1)\n );\n },\n zoomTo: _zoomTo,\n zoomToNode: function (nodeId, zoom = 2, duration = 500) {\n const node = _.find(treeBuilder.allNodes, {data: {id: nodeId}});\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function (duration = 500) {\n const groupBounds = treeBuilder.g.node().getBBox();\n const width = groupBounds.width;\n const height = groupBounds.height;\n const fullWidth = treeBuilder.svg.node().clientWidth;\n const fullHeight = treeBuilder.svg.node().clientHeight;\n const scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(\n fullWidth / 2 - scale * (groupBounds.x + width / 2),\n fullHeight / 2 - scale * (groupBounds.y + height / 2)\n )\n .scale(scale)\n );\n }\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n class: marriage.class ? marriage.class : opts.styles.marriageNode\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.call(this, 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.call(this, a.name, a.extra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E,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,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC/E,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,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC/E,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 sizes\n this.nodeSize = opts.callbacks.nodeSize.call(this,\n // filter hidden and marriage nodes\n _.filter(\n this.allNodes,\n node => !(node.hidden || _.get(node, 'data.isMarriage'))\n ),\n opts.nodeWidth,\n opts.callbacks.textRenderer\n );\n this.marriageSize = opts.callbacks.marriageSize.call(this,\n // filter hidden and non marriage nodes\n _.filter(\n this.allNodes,\n node => !node.hidden && _.get(node, 'data.isMarriage')\n ),\n this.opts.marriageNodeSize\n );\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 // create zoom handler\n const zoom = this.zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function () {\n g.attr('transform', d3.event.transform);\n });\n\n // make a svg\n const svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('viewBox', [0, 0, width, height])\n .call(zoom);\n\n // create svg group that holds all nodes\n const g = this.g = svg.append('g');\n\n // set zoom identity\n svg.call(zoom.transform, d3.zoomIdentity.translate(width / 2, opts.margin.top).scale(1));\n\n // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2,\n opts.callbacks.nodeHeightSeperation.call(this, 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 let marriageSize = this.marriageSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.g.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.g.selectAll('.node')\n .data(treenodes.descendants())\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.g.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 if (d.data.isMarriage) {\n return opts.callbacks.marriageRenderer.call(this,\n d.x,\n d.y,\n marriageSize[0],\n marriageSize[1],\n d.data.extra,\n d.data.id,\n d.data.class\n )\n } else {\n return opts.callbacks.nodeRenderer.call(this,\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 }\n })\n .on('dblclick', function () {\n // do not propagate a double click on a node\n // to prevent the zoom from being triggered\n d3.event.stopPropagation();\n })\n .on('click', function(d) {\n // ignore double-clicks and clicks on hidden nodes\n if (d3.event.detail === 2 || d.data.hidden) {\n return;\n }\n if (d.data.isMarriage) {\n opts.callbacks.marriageClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\n })\n .on('contextmenu', function(d) {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n if (d.data.isMarriage) {\n opts.callbacks.marriageRightClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeRightClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\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 _marriageSize (nodes, size) {\n _.map(nodes, function (n) {\n if (!n.data.hidden) {\n n.cHeight = size;\n n.cWidth = size;\n }\n });\n\n return [size, size]\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 _marriageRenderer (x, y, height, width, extra, id, nodeClass) {\n return ``\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.4.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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRightClick: function(name, extra, id) {},\n marriageClick: function(extra, id) {},\n marriageRightClick: function(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 marriageRenderer: function (x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass)\n },\n marriageSize: function (nodes, size) {\n return TreeBuilder._marriageSize(nodes, size)\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo (x, y, zoom = 1, duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(opts.width / 2, opts.height / 2)\n .scale(zoom)\n .translate(-x, -y)\n );\n }\n\n return {\n resetZoom: function (duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1)\n );\n },\n zoomTo: _zoomTo,\n zoomToNode: function (nodeId, zoom = 2, duration = 500) {\n const node = _.find(treeBuilder.allNodes, {data: {id: nodeId}});\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function (duration = 500) {\n const groupBounds = treeBuilder.g.node().getBBox();\n const width = groupBounds.width;\n const height = groupBounds.height;\n const fullWidth = treeBuilder.svg.node().clientWidth;\n const fullHeight = treeBuilder.svg.node().clientHeight;\n const scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(\n fullWidth / 2 - scale * (groupBounds.x + width / 2),\n fullHeight / 2 - scale * (groupBounds.y + height / 2)\n )\n .scale(scale)\n );\n }\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n class: marriage.class ? marriage.class : opts.styles.marriageNode\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.call(this, 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.call(this, 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 95a9d85..7db8628 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 a=0;a\n',r+=e,r+="
\n"}},{key:"_marriageRenderer",value:function(e,t,a,r,n,i,o){return''}},{key:"_debug",value:function(t){e.DEBUG_LEVEL>0&&console.log(t)}}]),e}(),t={VERSION:"2.4.0",init:function(t){function a(e,t){var a=arguments.length<=2||void 0===arguments[2]?1:arguments[2],r=arguments.length<=3||void 0===arguments[3]?500:arguments[3];i.svg.transition().duration(r).call(i.zoom.transform,d3.zoomIdentity.translate(n.width/2,n.height/2).scale(a).translate(-e,-t))}var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=_.defaultsDeep(r||{},{target:"#graph",debug:!1,width:600,height:600,hideMarriageNodes:!0,callbacks:{nodeClick:function(e,t,a){},nodeRightClick:function(e,t,a){},marriageClick:function(e,t){},marriageRightClick:function(e,t){},nodeHeightSeperation:function(t,a){return e._nodeHeightSeperation(t,a)},nodeRenderer:function(t,a,r,n,i,o,d,s,l,c){return e._nodeRenderer(t,a,r,n,i,o,d,s,l,c)},nodeSize:function(t,a,r){return e._nodeSize(t,a,r)},nodeSorter:function(e,t,a,r){return 0},textRenderer:function(t,a,r){return e._textRenderer(t,a,r)},marriageRenderer:function(t,a,r,n,i,o,d){return e._marriageRenderer(t,a,r,n,i,o,d)},marriageSize:function(t,a){return e._marriageSize(t,a)}},margin:{top:0,right:0,bottom:0,left:0},nodeWidth:100,marriageNodeSize:10,styles:{node:"node",marriageNode:"marriageNode",linage:"linage",marriage:"marriage",text:"nodeText"}}),t=this._preprocess(t,n),i=new e(t.root,t.siblings,n);return i.create(),{resetZoom:function(){var e=arguments.length<=0||void 0===arguments[0]?500:arguments[0];i.svg.transition().duration(e).call(i.zoom.transform,d3.zoomIdentity.translate(n.width/2,n.margin.top).scale(1))},zoomTo:a,zoomToNode:function(e){var t=arguments.length<=1||void 0===arguments[1]?2:arguments[1],r=arguments.length<=2||void 0===arguments[2]?500:arguments[2],n=_.find(i.allNodes,{data:{id:e}});n&&a(n.x,n.y,t,r)},zoomToFit:function(){var e=arguments.length<=0||void 0===arguments[0]?500:arguments[0],t=i.g.node().getBBox(),a=t.width,r=t.height,n=i.svg.node().clientWidth,o=i.svg.node().clientHeight,d=.95/Math.max(a/n,r/o);i.svg.transition().duration(e).call(i.zoom.transform,d3.zoomIdentity.translate(n/2-d*(t.x+a/2),o/2-d*(t.y+r/2)).scale(d))}}},_preprocess:function(e,a){var r=[],n=0,i={name:"",id:n++,hidden:!0,children:[]},o=function d(e,o){var s={name:e.name,id:n++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass?e.textClass:a.styles.text,"class":e["class"]?e["class"]:a.styles.node};o==i&&(s.noParent=!0);for(var l=0;l\n',r+=e,r+="
\n"}},{key:"_marriageRenderer",value:function(e,t,a,r,n,i,o){return''}},{key:"_debug",value:function(t){e.DEBUG_LEVEL>0&&console.log(t)}}]),e}(),t={VERSION:"2.4.1",init:function(t){function a(e,t){var a=arguments.length<=2||void 0===arguments[2]?1:arguments[2],r=arguments.length<=3||void 0===arguments[3]?500:arguments[3];i.svg.transition().duration(r).call(i.zoom.transform,d3.zoomIdentity.translate(n.width/2,n.height/2).scale(a).translate(-e,-t))}var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=_.defaultsDeep(r||{},{target:"#graph",debug:!1,width:600,height:600,hideMarriageNodes:!0,callbacks:{nodeClick:function(e,t,a){},nodeRightClick:function(e,t,a){},marriageClick:function(e,t){},marriageRightClick:function(e,t){},nodeHeightSeperation:function(t,a){return e._nodeHeightSeperation(t,a)},nodeRenderer:function(t,a,r,n,i,o,d,s,l,c){return e._nodeRenderer(t,a,r,n,i,o,d,s,l,c)},nodeSize:function(t,a,r){return e._nodeSize(t,a,r)},nodeSorter:function(e,t,a,r){return 0},textRenderer:function(t,a,r){return e._textRenderer(t,a,r)},marriageRenderer:function(t,a,r,n,i,o,d){return e._marriageRenderer(t,a,r,n,i,o,d)},marriageSize:function(t,a){return e._marriageSize(t,a)}},margin:{top:0,right:0,bottom:0,left:0},nodeWidth:100,marriageNodeSize:10,styles:{node:"node",marriageNode:"marriageNode",linage:"linage",marriage:"marriage",text:"nodeText"}}),t=this._preprocess(t,n),i=new e(t.root,t.siblings,n);return i.create(),{resetZoom:function(){var e=arguments.length<=0||void 0===arguments[0]?500:arguments[0];i.svg.transition().duration(e).call(i.zoom.transform,d3.zoomIdentity.translate(n.width/2,n.margin.top).scale(1))},zoomTo:a,zoomToNode:function(e){var t=arguments.length<=1||void 0===arguments[1]?2:arguments[1],r=arguments.length<=2||void 0===arguments[2]?500:arguments[2],n=_.find(i.allNodes,{data:{id:e}});n&&a(n.x,n.y,t,r)},zoomToFit:function(){var e=arguments.length<=0||void 0===arguments[0]?500:arguments[0],t=i.g.node().getBBox(),a=t.width,r=t.height,n=i.svg.node().clientWidth,o=i.svg.node().clientHeight,d=.95/Math.max(a/n,r/o);i.svg.transition().duration(e).call(i.zoom.transform,d3.zoomIdentity.translate(n/2-d*(t.x+a/2),o/2-d*(t.y+r/2)).scale(d))}}},_preprocess:function(e,a){var r=[],n=0,i={name:"",id:n++,hidden:!0,children:[]},o=function d(e,o){var s={name:e.name,id:n++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass?e.textClass:a.styles.text,"class":e["class"]?e["class"]:a.styles.node};o==i&&(s.noParent=!0);for(var l=0;l\\n';\n node += name;\n node += '
\\n';\n return node;\n }\n }, {\n key: '_marriageRenderer',\n value: function _marriageRenderer(x, y, height, width, extra, id, nodeClass) {\n return '';\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.4.0',\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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function nodeClick(name, extra, id) {},\n nodeRightClick: function nodeRightClick(name, extra, id) {},\n marriageClick: function marriageClick(extra, id) {},\n marriageRightClick: function marriageRightClick(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 marriageRenderer: function marriageRenderer(x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass);\n },\n marriageSize: function marriageSize(nodes, size) {\n return TreeBuilder._marriageSize(nodes, size);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo(x, y) {\n var zoom = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];\n var duration = arguments.length <= 3 || arguments[3] === undefined ? 500 : arguments[3];\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(opts.width / 2, opts.height / 2).scale(zoom).translate(-x, -y));\n }\n\n return {\n resetZoom: function resetZoom() {\n var duration = arguments.length <= 0 || arguments[0] === undefined ? 500 : arguments[0];\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1));\n },\n zoomTo: _zoomTo,\n zoomToNode: function zoomToNode(nodeId) {\n var zoom = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1];\n var duration = arguments.length <= 2 || arguments[2] === undefined ? 500 : arguments[2];\n\n var node = _.find(treeBuilder.allNodes, { data: { id: nodeId } });\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function zoomToFit() {\n var duration = arguments.length <= 0 || arguments[0] === undefined ? 500 : arguments[0];\n\n var groupBounds = treeBuilder.g.node().getBBox();\n var width = groupBounds.width;\n var height = groupBounds.height;\n var fullWidth = treeBuilder.svg.node().clientWidth;\n var fullHeight = treeBuilder.svg.node().clientHeight;\n var scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(fullWidth / 2 - scale * (groupBounds.x + width / 2), fullHeight / 2 - scale * (groupBounds.y + height / 2)).scale(scale));\n }\n };\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n 'class': marriage['class'] ? marriage['class'] : opts.styles.marriageNode\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.call(this, 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.call(this, 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 sizes\n this.nodeSize = opts.callbacks.nodeSize.call(this,\n // filter hidden and marriage nodes\n _.filter(\n this.allNodes,\n node => !(node.hidden || _.get(node, 'data.isMarriage'))\n ),\n opts.nodeWidth,\n opts.callbacks.textRenderer\n );\n this.marriageSize = opts.callbacks.marriageSize.call(this,\n // filter hidden and non marriage nodes\n _.filter(\n this.allNodes,\n node => !node.hidden && _.get(node, 'data.isMarriage')\n ),\n this.opts.marriageNodeSize\n );\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 // create zoom handler\n const zoom = this.zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function () {\n g.attr('transform', d3.event.transform);\n });\n\n // make a svg\n const svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('viewBox', [0, 0, width, height])\n .call(zoom);\n\n // create svg group that holds all nodes\n const g = this.g = svg.append('g');\n\n // set zoom identity\n svg.call(zoom.transform, d3.zoomIdentity.translate(width / 2, opts.margin.top).scale(1));\n\n // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2,\n opts.callbacks.nodeHeightSeperation.call(this, 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 let marriageSize = this.marriageSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.g.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.g.selectAll('.node')\n .data(treenodes.descendants())\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.g.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 if (d.data.isMarriage) {\n return opts.callbacks.marriageRenderer.call(this,\n d.x,\n d.y,\n marriageSize[0],\n marriageSize[1],\n d.data.extra,\n d.data.id,\n d.data.class\n )\n } else {\n return opts.callbacks.nodeRenderer.call(this,\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 }\n })\n .on('dblclick', function () {\n // do not propagate a double click on a node\n // to prevent the zoom from being triggered\n d3.event.stopPropagation();\n })\n .on('click', function(d) {\n // ignore double-clicks and clicks on hidden nodes\n if (d3.event.detail === 2 || d.data.hidden) {\n return;\n }\n if (d.data.isMarriage) {\n opts.callbacks.marriageClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\n })\n .on('contextmenu', function(d) {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n if (d.data.isMarriage) {\n opts.callbacks.marriageRightClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeRightClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\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 _marriageSize (nodes, size) {\n _.map(nodes, function (n) {\n if (!n.data.hidden) {\n n.cHeight = size;\n n.cWidth = size;\n }\n });\n\n return [size, size]\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 _marriageRenderer (x, y, height, width, extra, id, nodeClass) {\n return ``\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.4.0',\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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRightClick: function(name, extra, id) {},\n marriageClick: function(extra, id) {},\n marriageRightClick: function(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 marriageRenderer: function (x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass)\n },\n marriageSize: function (nodes, size) {\n return TreeBuilder._marriageSize(nodes, size)\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo (x, y, zoom = 1, duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(opts.width / 2, opts.height / 2)\n .scale(zoom)\n .translate(-x, -y)\n );\n }\n\n return {\n resetZoom: function (duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1)\n );\n },\n zoomTo: _zoomTo,\n zoomToNode: function (nodeId, zoom = 2, duration = 500) {\n const node = _.find(treeBuilder.allNodes, {data: {id: nodeId}});\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function (duration = 500) {\n const groupBounds = treeBuilder.g.node().getBBox();\n const width = groupBounds.width;\n const height = groupBounds.height;\n const fullWidth = treeBuilder.svg.node().clientWidth;\n const fullHeight = treeBuilder.svg.node().clientHeight;\n const scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(\n fullWidth / 2 - scale * (groupBounds.x + width / 2),\n fullHeight / 2 - scale * (groupBounds.y + height / 2)\n )\n .scale(scale)\n );\n }\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n class: marriage.class ? marriage.class : opts.styles.marriageNode\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.call(this, 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.call(this, 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","nodeSize","callbacks","call","_","filter","node","hidden","get","nodeWidth","textRenderer","marriageSize","marriageNodeSize","value","width","margin","left","right","height","top","bottom","zoom","d3","scaleExtent","on","g","attr","event","transform","svg","select","append","zoomIdentity","translate","scale","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","isMarriage","marriageRenderer","extra","nodeRenderer","name","textClass","stopPropagation","detail","marriageClick","nodeClick","preventDefault","marriageRightClick","nodeRightClick","recurse","children","forEach","n","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","size","nodeClass","msg","console","log","VERSION","init","_zoomTo","arguments","undefined","duration","treeBuilder","transition","options","defaultsDeep","hideMarriageNodes","_nodeHeightSeperation","_nodeRenderer","_nodeSize","nodeSorter","aName","aExtra","bName","bExtra","_textRenderer","_marriageRenderer","_marriageSize","_preprocess","create","resetZoom","zoomTo","zoomToNode","nodeId","zoomToFit","groupBounds","getBBox","fullWidth","clientWidth","fullHeight","clientHeight","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,IAA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AAOoG,EAAGpG,MACV0B,aAAcyE,EAGhBT,GAAO9E,SAASG,KAAKoF,EAAGE,GAExBnL,EAAM4K,aAAa5G,EAAS0B,SAAUrF,GACtCQ,EAAE8E,QAAQ3B,EAAS0B,SAAU,SAASmF,GACpCP,EAAgBO,EAAOI,KAGzB7K,EAASyF,MACP1C,QACEuB,GAAI3D,EAAK2D,IAEX9F,QACE8F,GAAIyG,EAAOzG,IAEbiC,OAAQqE,MAUd,OAJAnK,GAAE8E,QAAQ1C,EAAM,SAASsH,GACvBD,EAAgBC,EAAQpK,MAIxBA,KAAM4B,GAAGqJ,UAAUjL,GACnBC,SAAUA,IAKdwK,aAAc,SAASS,EAAShL,GAM9B,MALekI,SAAX8C,GACFA,EAAQC,KAAK,SAASvI,EAAGC,GACvB,MAAO3C,GAAKM,UAAUsI,WAAWrI,KAAKX,KAAM8C,EAAEiC,KAAMjC,EAAE+B,MAAO9B,EAAEgC,KAAMhC,EAAE8B,SAGpEuG,GAGTP,eAAgB,SAASC,EAAW1K,GAQlC,MAPiBkI,SAAbwC,GAA0BQ,MAAMC,QAAQT,IAC1CA,EAAUO,KAAK,SAASG,EAAWC,GACjC,GAAI3I,GAAI0I,EAAUN,OACdnI,EAAI0I,EAAUP,MAClB,OAAO9K,GAAKM,UAAUsI,WAAWrI,KAAKX,KAAM8C,EAAEiC,KAAMjC,EAAE+B,MAAO9B,EAAEgC,KAAMhC,EAAE8B,SAGpEiG,GAKX,OAAO/K","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 sizes\n this.nodeSize = opts.callbacks.nodeSize.call(this,\n // filter hidden and marriage nodes\n _.filter(this.allNodes, function (node) {\n return !(node.hidden || _.get(node, 'data.isMarriage'));\n }), opts.nodeWidth, opts.callbacks.textRenderer);\n this.marriageSize = opts.callbacks.marriageSize.call(this,\n // filter hidden and non marriage nodes\n _.filter(this.allNodes, function (node) {\n return !node.hidden && _.get(node, 'data.isMarriage');\n }), this.opts.marriageNodeSize);\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 // create zoom handler\n var zoom = this.zoom = d3.zoom().scaleExtent([0.1, 10]).on('zoom', function () {\n g.attr('transform', d3.event.transform);\n });\n\n // make a svg\n var svg = this.svg = d3.select(opts.target).append('svg').attr('viewBox', [0, 0, width, height]).call(zoom);\n\n // create svg group that holds all nodes\n var g = this.g = svg.append('g');\n\n // set zoom identity\n svg.call(zoom.transform, d3.zoomIdentity.translate(width / 2, opts.margin.top).scale(1));\n\n // Compute the layout.\n this.tree = d3.tree().nodeSize([nodeSize[0] * 2, opts.callbacks.nodeHeightSeperation.call(this, 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 var marriageSize = this.marriageSize;\n\n var treenodes = this.tree(source);\n var links = treenodes.links();\n\n // Create the link lines.\n this.g.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.g.selectAll('.node').data(treenodes.descendants()).enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.g.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 if (d.data.isMarriage) {\n return opts.callbacks.marriageRenderer.call(this, d.x, d.y, marriageSize[0], marriageSize[1], d.data.extra, d.data.id, d.data['class']);\n } else {\n return opts.callbacks.nodeRenderer.call(this, 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 }\n }).on('dblclick', function () {\n // do not propagate a double click on a node\n // to prevent the zoom from being triggered\n d3.event.stopPropagation();\n }).on('click', function (d) {\n // ignore double-clicks and clicks on hidden nodes\n if (d3.event.detail === 2 || d.data.hidden) {\n return;\n }\n if (d.data.isMarriage) {\n opts.callbacks.marriageClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeClick.call(this, 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 if (d.data.isMarriage) {\n opts.callbacks.marriageRightClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeRightClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\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: '_marriageSize',\n value: function _marriageSize(nodes, size) {\n _.map(nodes, function (n) {\n if (!n.data.hidden) {\n n.cHeight = size;\n n.cWidth = size;\n }\n });\n\n return [size, size];\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: '_marriageRenderer',\n value: function _marriageRenderer(x, y, height, width, extra, id, nodeClass) {\n return '';\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.4.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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function nodeClick(name, extra, id) {},\n nodeRightClick: function nodeRightClick(name, extra, id) {},\n marriageClick: function marriageClick(extra, id) {},\n marriageRightClick: function marriageRightClick(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 marriageRenderer: function marriageRenderer(x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass);\n },\n marriageSize: function marriageSize(nodes, size) {\n return TreeBuilder._marriageSize(nodes, size);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo(x, y) {\n var zoom = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];\n var duration = arguments.length <= 3 || arguments[3] === undefined ? 500 : arguments[3];\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(opts.width / 2, opts.height / 2).scale(zoom).translate(-x, -y));\n }\n\n return {\n resetZoom: function resetZoom() {\n var duration = arguments.length <= 0 || arguments[0] === undefined ? 500 : arguments[0];\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1));\n },\n zoomTo: _zoomTo,\n zoomToNode: function zoomToNode(nodeId) {\n var zoom = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1];\n var duration = arguments.length <= 2 || arguments[2] === undefined ? 500 : arguments[2];\n\n var node = _.find(treeBuilder.allNodes, { data: { id: nodeId } });\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function zoomToFit() {\n var duration = arguments.length <= 0 || arguments[0] === undefined ? 500 : arguments[0];\n\n var groupBounds = treeBuilder.g.node().getBBox();\n var width = groupBounds.width;\n var height = groupBounds.height;\n var fullWidth = treeBuilder.svg.node().clientWidth;\n var fullHeight = treeBuilder.svg.node().clientHeight;\n var scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(fullWidth / 2 - scale * (groupBounds.x + width / 2), fullHeight / 2 - scale * (groupBounds.y + height / 2)).scale(scale));\n }\n };\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n 'class': marriage['class'] ? marriage['class'] : opts.styles.marriageNode\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.call(this, 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.call(this, 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 sizes\n this.nodeSize = opts.callbacks.nodeSize.call(this,\n // filter hidden and marriage nodes\n _.filter(\n this.allNodes,\n node => !(node.hidden || _.get(node, 'data.isMarriage'))\n ),\n opts.nodeWidth,\n opts.callbacks.textRenderer\n );\n this.marriageSize = opts.callbacks.marriageSize.call(this,\n // filter hidden and non marriage nodes\n _.filter(\n this.allNodes,\n node => !node.hidden && _.get(node, 'data.isMarriage')\n ),\n this.opts.marriageNodeSize\n );\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 // create zoom handler\n const zoom = this.zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function () {\n g.attr('transform', d3.event.transform);\n });\n\n // make a svg\n const svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('viewBox', [0, 0, width, height])\n .call(zoom);\n\n // create svg group that holds all nodes\n const g = this.g = svg.append('g');\n\n // set zoom identity\n svg.call(zoom.transform, d3.zoomIdentity.translate(width / 2, opts.margin.top).scale(1));\n\n // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2,\n opts.callbacks.nodeHeightSeperation.call(this, 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 let marriageSize = this.marriageSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.g.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.g.selectAll('.node')\n .data(treenodes.descendants())\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.g.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 if (d.data.isMarriage) {\n return opts.callbacks.marriageRenderer.call(this,\n d.x,\n d.y,\n marriageSize[0],\n marriageSize[1],\n d.data.extra,\n d.data.id,\n d.data.class\n )\n } else {\n return opts.callbacks.nodeRenderer.call(this,\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 }\n })\n .on('dblclick', function () {\n // do not propagate a double click on a node\n // to prevent the zoom from being triggered\n d3.event.stopPropagation();\n })\n .on('click', function(d) {\n // ignore double-clicks and clicks on hidden nodes\n if (d3.event.detail === 2 || d.data.hidden) {\n return;\n }\n if (d.data.isMarriage) {\n opts.callbacks.marriageClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\n })\n .on('contextmenu', function(d) {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n if (d.data.isMarriage) {\n opts.callbacks.marriageRightClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeRightClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\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 _marriageSize (nodes, size) {\n _.map(nodes, function (n) {\n if (!n.data.hidden) {\n n.cHeight = size;\n n.cWidth = size;\n }\n });\n\n return [size, size]\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 _marriageRenderer (x, y, height, width, extra, id, nodeClass) {\n return ``\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.4.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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRightClick: function(name, extra, id) {},\n marriageClick: function(extra, id) {},\n marriageRightClick: function(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 marriageRenderer: function (x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass)\n },\n marriageSize: function (nodes, size) {\n return TreeBuilder._marriageSize(nodes, size)\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo (x, y, zoom = 1, duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(opts.width / 2, opts.height / 2)\n .scale(zoom)\n .translate(-x, -y)\n );\n }\n\n return {\n resetZoom: function (duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1)\n );\n },\n zoomTo: _zoomTo,\n zoomToNode: function (nodeId, zoom = 2, duration = 500) {\n const node = _.find(treeBuilder.allNodes, {data: {id: nodeId}});\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function (duration = 500) {\n const groupBounds = treeBuilder.g.node().getBBox();\n const width = groupBounds.width;\n const height = groupBounds.height;\n const fullWidth = treeBuilder.svg.node().clientWidth;\n const fullHeight = treeBuilder.svg.node().clientHeight;\n const scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(\n fullWidth / 2 - scale * (groupBounds.x + width / 2),\n fullHeight / 2 - scale * (groupBounds.y + height / 2)\n )\n .scale(scale)\n );\n }\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n class: marriage.class ? marriage.class : opts.styles.marriageNode\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.call(this, 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.call(this, 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 ae45f06..f5699ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "d3-dtree", - "version": "2.4.0", + "version": "2.4.1", "description": "A library for visualizing data trees built on top of D3.", "main": "dist/dTree.js", "demo": "test/demo/", diff --git a/test/demo/dTree.min.js b/test/demo/dTree.min.js new file mode 100644 index 0000000..7db8628 --- /dev/null +++ b/test/demo/dTree.min.js @@ -0,0 +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 a=0;a\n',r+=e,r+="
\n"}},{key:"_marriageRenderer",value:function(e,t,a,r,n,i,o){return''}},{key:"_debug",value:function(t){e.DEBUG_LEVEL>0&&console.log(t)}}]),e}(),t={VERSION:"2.4.1",init:function(t){function a(e,t){var a=arguments.length<=2||void 0===arguments[2]?1:arguments[2],r=arguments.length<=3||void 0===arguments[3]?500:arguments[3];i.svg.transition().duration(r).call(i.zoom.transform,d3.zoomIdentity.translate(n.width/2,n.height/2).scale(a).translate(-e,-t))}var r=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=_.defaultsDeep(r||{},{target:"#graph",debug:!1,width:600,height:600,hideMarriageNodes:!0,callbacks:{nodeClick:function(e,t,a){},nodeRightClick:function(e,t,a){},marriageClick:function(e,t){},marriageRightClick:function(e,t){},nodeHeightSeperation:function(t,a){return e._nodeHeightSeperation(t,a)},nodeRenderer:function(t,a,r,n,i,o,d,s,l,c){return e._nodeRenderer(t,a,r,n,i,o,d,s,l,c)},nodeSize:function(t,a,r){return e._nodeSize(t,a,r)},nodeSorter:function(e,t,a,r){return 0},textRenderer:function(t,a,r){return e._textRenderer(t,a,r)},marriageRenderer:function(t,a,r,n,i,o,d){return e._marriageRenderer(t,a,r,n,i,o,d)},marriageSize:function(t,a){return e._marriageSize(t,a)}},margin:{top:0,right:0,bottom:0,left:0},nodeWidth:100,marriageNodeSize:10,styles:{node:"node",marriageNode:"marriageNode",linage:"linage",marriage:"marriage",text:"nodeText"}}),t=this._preprocess(t,n),i=new e(t.root,t.siblings,n);return i.create(),{resetZoom:function(){var e=arguments.length<=0||void 0===arguments[0]?500:arguments[0];i.svg.transition().duration(e).call(i.zoom.transform,d3.zoomIdentity.translate(n.width/2,n.margin.top).scale(1))},zoomTo:a,zoomToNode:function(e){var t=arguments.length<=1||void 0===arguments[1]?2:arguments[1],r=arguments.length<=2||void 0===arguments[2]?500:arguments[2],n=_.find(i.allNodes,{data:{id:e}});n&&a(n.x,n.y,t,r)},zoomToFit:function(){var e=arguments.length<=0||void 0===arguments[0]?500:arguments[0],t=i.g.node().getBBox(),a=t.width,r=t.height,n=i.svg.node().clientWidth,o=i.svg.node().clientHeight,d=.95/Math.max(a/n,r/o);i.svg.transition().duration(e).call(i.zoom.transform,d3.zoomIdentity.translate(n/2-d*(t.x+a/2),o/2-d*(t.y+r/2)).scale(d))}}},_preprocess:function(e,a){var r=[],n=0,i={name:"",id:n++,hidden:!0,children:[]},o=function d(e,o){var s={name:e.name,id:n++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass?e.textClass:a.styles.text,"class":e["class"]?e["class"]:a.styles.node};o==i&&(s.noParent=!0);for(var l=0;l\\n';\n node += name;\n node += '
\\n';\n return node;\n }\n }, {\n key: '_marriageRenderer',\n value: function _marriageRenderer(x, y, height, width, extra, id, nodeClass) {\n return '';\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.4.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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function nodeClick(name, extra, id) {},\n nodeRightClick: function nodeRightClick(name, extra, id) {},\n marriageClick: function marriageClick(extra, id) {},\n marriageRightClick: function marriageRightClick(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 marriageRenderer: function marriageRenderer(x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass);\n },\n marriageSize: function marriageSize(nodes, size) {\n return TreeBuilder._marriageSize(nodes, size);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo(x, y) {\n var zoom = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];\n var duration = arguments.length <= 3 || arguments[3] === undefined ? 500 : arguments[3];\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(opts.width / 2, opts.height / 2).scale(zoom).translate(-x, -y));\n }\n\n return {\n resetZoom: function resetZoom() {\n var duration = arguments.length <= 0 || arguments[0] === undefined ? 500 : arguments[0];\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1));\n },\n zoomTo: _zoomTo,\n zoomToNode: function zoomToNode(nodeId) {\n var zoom = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1];\n var duration = arguments.length <= 2 || arguments[2] === undefined ? 500 : arguments[2];\n\n var node = _.find(treeBuilder.allNodes, { data: { id: nodeId } });\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function zoomToFit() {\n var duration = arguments.length <= 0 || arguments[0] === undefined ? 500 : arguments[0];\n\n var groupBounds = treeBuilder.g.node().getBBox();\n var width = groupBounds.width;\n var height = groupBounds.height;\n var fullWidth = treeBuilder.svg.node().clientWidth;\n var fullHeight = treeBuilder.svg.node().clientHeight;\n var scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg.transition().duration(duration).call(treeBuilder.zoom.transform, d3.zoomIdentity.translate(fullWidth / 2 - scale * (groupBounds.x + width / 2), fullHeight / 2 - scale * (groupBounds.y + height / 2)).scale(scale));\n }\n };\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n 'class': marriage['class'] ? marriage['class'] : opts.styles.marriageNode\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.call(this, 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.call(this, 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 sizes\n this.nodeSize = opts.callbacks.nodeSize.call(this,\n // filter hidden and marriage nodes\n _.filter(\n this.allNodes,\n node => !(node.hidden || _.get(node, 'data.isMarriage'))\n ),\n opts.nodeWidth,\n opts.callbacks.textRenderer\n );\n this.marriageSize = opts.callbacks.marriageSize.call(this,\n // filter hidden and non marriage nodes\n _.filter(\n this.allNodes,\n node => !node.hidden && _.get(node, 'data.isMarriage')\n ),\n this.opts.marriageNodeSize\n );\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 // create zoom handler\n const zoom = this.zoom = d3.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', function () {\n g.attr('transform', d3.event.transform);\n });\n\n // make a svg\n const svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('viewBox', [0, 0, width, height])\n .call(zoom);\n\n // create svg group that holds all nodes\n const g = this.g = svg.append('g');\n\n // set zoom identity\n svg.call(zoom.transform, d3.zoomIdentity.translate(width / 2, opts.margin.top).scale(1));\n\n // Compute the layout.\n this.tree = d3.tree()\n .nodeSize([nodeSize[0] * 2,\n opts.callbacks.nodeHeightSeperation.call(this, 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 let marriageSize = this.marriageSize;\n\n let treenodes = this.tree(source);\n let links = treenodes.links();\n\n // Create the link lines.\n this.g.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.g.selectAll('.node')\n .data(treenodes.descendants())\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.g.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 if (d.data.isMarriage) {\n return opts.callbacks.marriageRenderer.call(this,\n d.x,\n d.y,\n marriageSize[0],\n marriageSize[1],\n d.data.extra,\n d.data.id,\n d.data.class\n )\n } else {\n return opts.callbacks.nodeRenderer.call(this,\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 }\n })\n .on('dblclick', function () {\n // do not propagate a double click on a node\n // to prevent the zoom from being triggered\n d3.event.stopPropagation();\n })\n .on('click', function(d) {\n // ignore double-clicks and clicks on hidden nodes\n if (d3.event.detail === 2 || d.data.hidden) {\n return;\n }\n if (d.data.isMarriage) {\n opts.callbacks.marriageClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\n })\n .on('contextmenu', function(d) {\n if (d.data.hidden) {\n return;\n }\n d3.event.preventDefault();\n if (d.data.isMarriage) {\n opts.callbacks.marriageRightClick.call(this, d.data.extra, d.data.id);\n } else {\n opts.callbacks.nodeRightClick.call(this, d.data.name, d.data.extra, d.data.id);\n }\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 _marriageSize (nodes, size) {\n _.map(nodes, function (n) {\n if (!n.data.hidden) {\n n.cHeight = size;\n n.cWidth = size;\n }\n });\n\n return [size, size]\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 _marriageRenderer (x, y, height, width, extra, id, nodeClass) {\n return ``\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.4.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 hideMarriageNodes: true,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRightClick: function(name, extra, id) {},\n marriageClick: function(extra, id) {},\n marriageRightClick: function(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 marriageRenderer: function (x, y, height, width, extra, id, nodeClass) {\n return TreeBuilder._marriageRenderer(x, y, height, width, extra, id, nodeClass)\n },\n marriageSize: function (nodes, size) {\n return TreeBuilder._marriageSize(nodes, size)\n },\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n nodeWidth: 100,\n marriageNodeSize: 10,\n styles: {\n node: 'node',\n marriageNode: 'marriageNode',\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 function _zoomTo (x, y, zoom = 1, duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(opts.width / 2, opts.height / 2)\n .scale(zoom)\n .translate(-x, -y)\n );\n }\n\n return {\n resetZoom: function (duration = 500) {\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity.translate(opts.width / 2, opts.margin.top).scale(1)\n );\n },\n zoomTo: _zoomTo,\n zoomToNode: function (nodeId, zoom = 2, duration = 500) {\n const node = _.find(treeBuilder.allNodes, {data: {id: nodeId}});\n if (node) {\n _zoomTo(node.x, node.y, zoom, duration);\n }\n },\n zoomToFit: function (duration = 500) {\n const groupBounds = treeBuilder.g.node().getBBox();\n const width = groupBounds.width;\n const height = groupBounds.height;\n const fullWidth = treeBuilder.svg.node().clientWidth;\n const fullHeight = treeBuilder.svg.node().clientHeight;\n const scale = 0.95 / Math.max(width / fullWidth, height / fullHeight);\n\n treeBuilder.svg\n .transition()\n .duration(duration)\n .call(\n treeBuilder.zoom.transform,\n d3.zoomIdentity\n .translate(\n fullWidth / 2 - scale * (groupBounds.x + width / 2),\n fullHeight / 2 - scale * (groupBounds.y + height / 2)\n )\n .scale(scale)\n );\n }\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 var m = {\n name: '',\n id: id++,\n hidden: opts.hideMarriageNodes,\n noParent: true,\n children: [],\n isMarriage: true,\n extra: marriage.extra,\n class: marriage.class ? marriage.class : opts.styles.marriageNode\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.call(this, 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.call(this, 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