diff --git a/CHANGELOG.md b/CHANGELOG.md index abee4b3..f1c4595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +## [0.3.1](https://github.com/ErikGartner/dtree/compare/0.3.0...v0.3.1) (2015-12-31) + + +### Bug Fixes + +* Build including old dist ([5ca3f2a](https://github.com/ErikGartner/dtree/commit/5ca3f2a)) + + + # [0.3.0](https://github.com/ErikGartner/dtree/compare/0.2.5...v0.3.0) (2015-12-31) diff --git a/README.md b/README.md index f7d5eea..b1249ca 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ dTree is available through the RawGit CDN: ``` -https://cdn.rawgit.com/ErikGartner/dTree/0.2.4/dist/dTree.min.js +https://cdn.rawgit.com/ErikGartner/dTree/0.3.1/dist/dTree.min.js ``` ## Requirements diff --git a/dist/dTree.js b/dist/dTree.js index e918a2b..a472a8c 100644 --- a/dist/dTree.js +++ b/dist/dTree.js @@ -18,6 +18,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons // flatten nodes this.allNodes = this._flatten(this.root); this.nodeSize = this._calculateNodeSize(); + + TreeBuilder.debugLevel = opts.debug ? 1 : 0; } _createClass(TreeBuilder, [{ @@ -28,12 +30,17 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var allNodes = this.allNodes; var nodeSize = this.nodeSize; + var width = opts.width + opts.margin.left + opts.margin.right; + var height = opts.height + opts.margin.top + opts.margin.bottom; + var zoom = d3.behavior.zoom().scaleExtent([0.1, 10]).on('zoom', _.bind(function () { svg.attr('transform', 'translate(' + d3.event.translate + ')' + ' scale(' + d3.event.scale + ')'); }, this)); //make an SVG - var svg = this.svg = d3.select(opts.target).append('svg').attr('width', opts.width + opts.margin.left + opts.margin.right).attr('height', opts.height + opts.margin.top + opts.margin.bottom).call(zoom).append('g').attr('transform', 'translate(' + opts.margin.left + ',' + opts.margin.top + ')'); + var svg = this.svg = d3.select(opts.target).append('svg').attr('width', width).attr('height', height).call(zoom).append('g').attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')'); + + zoom.translate([width / 2, opts.margin.top]); // Compute the layout. this.tree = d3.layout.tree().nodeSize(nodeSize); @@ -80,11 +87,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons this.svg.selectAll('.sibling').data(this.siblings).enter().append('path').attr('class', opts.styles.marriage).attr('d', this._siblingLine); // Create the node rectangles. - nodes.append('rect').attr('class', function (d) { - return d['class'] ? d['class'] : opts.styles.nodes; - }).attr('width', nodeSize[0] / 2).attr('height', nodeSize[1] / 3).attr('id', function (d) { - return d.id; - }).attr('display', function (d) { + nodes.append('foreignObject').attr('display', function (d) { if (d.hidden) { return 'none'; } else { @@ -94,20 +97,17 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons return d.x - nodeSize[0] / 4; }).attr('y', function (d) { return d.y - nodeSize[1] / 6; + }).attr('width', nodeSize[0] / 2).attr('height', nodeSize[1] / 3).attr('id', function (d) { + return d.id; + }).html(function (d) { + if (d.hidden) { + return null; + } + return opts.callbacks.nodeRenderer(d.name, d.x, d.y, nodeSize[0] / 2, nodeSize[1] / 3, d.extra, d.id, d['class'] ? d['class'] : opts.styles.nodes, d.textClass ? d.textClass : opts.styles.text, opts.callbacks.textRenderer); }).on('click', function (d) { - opts.callbacks.nodeClick(d.name, d.extra, d.id); - }); - - // Create the node text label. - nodes.append('text').text(function (d) { - return opts.callbacks.text(d.name, d.extra, d.id); - }).attr('class', function (d) { - return d.textClass ? d.textClass : opts.styles.text; - }).attr('x', function (d) { - return d.x - nodeSize[0] / 4 + 5; - }).attr('y', function (d) { - return d.y + 4; - }).on('click', function (d) { + if (d.hidden) { + return; + } opts.callbacks.nodeClick(d.name, d.extra, d.id); }); } @@ -201,6 +201,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons }, { key: '_calculateNodeSize', value: function _calculateNodeSize() { + + // Not used at the moment var longest = ''; _.forEach(this.allNodes, function (n) { if (n.name.length > longest.length) { @@ -208,7 +210,40 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons } }); - return [longest.length * 10 + 10, longest.length * 5]; + return [200, 100]; + } + }], [{ + key: '_nodeRenderer', + value: function _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) { + + var node = ''; + node += '
\n'; + node += textRenderer(name, extra, textClass); + node += '
'; + + return node; + } + }, { + key: '_textRenderer', + value: function _textRenderer(name, extra, textClass) { + var node = ''; + node += '

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

\n'; + return node; + } + }, { + key: '_debug', + value: function _debug(msg) { + if (TreeBuilder.debugLevel > 0) { + console.log(msg); + } } }]); @@ -217,19 +252,23 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var dTree = { - version: '0.2.4', + version: '0.3.1', init: function init(data) { var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; var opts = _.defaultsDeep(options || {}, { target: '#graph', + debug: false, width: 600, height: 600, callbacks: { nodeClick: function nodeClick(name, extra, id) {}, - text: function text(name, extra, id) { - return name; + nodeRenderer: function nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) { + return TreeBuilder._nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer); + }, + textRenderer: function textRenderer(name, extra, textClass) { + return TreeBuilder._textRenderer(name, extra, textClass); } }, margin: { diff --git a/dist/dTree.js.map b/dist/dTree.js.map index 5c5f9ba..3c7123d 100644 --- a/dist/dTree.js.map +++ b/dist/dTree.js.map @@ -1 +1 @@ -{"version":3,"sources":["dTree.js"],"names":[],"mappings":";;;;AAAA,AAAC,CAAA,UAAU,MAAM,EAAE,OAAO,EAAE;AAC1B,SAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,OAAO,GAAG,OAAO,EAAE,GACzF,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,GAC5D,MAAM,C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AAQ,CAAC,QAAQ,EAAE,UAAS,KAAK,EAAE;AAClD,2BAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;WAC3B,CAAC,CAAC;;AAEH,kBAAQ,CAAC,IAAI,CAAC;AACZ,kBAAM,EAAE;AACN,gBAAE,EAAE,IAAI,CAAC,EAAE;aACZ;AACD,kBAAM,EAAE;AACN,gBAAE,EAAE,MAAM,CAAC,EAAE;aACd;WACF,CAAC,CAAC;SAEJ;OAEF,CAAC;;AAEF,OAAC,CAAC,OAAO,CAAC,IAAI,EAAE,UAAS,MAAM,EAAE;AAC/B,uBAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;OAC/B,CAAC,CAAC;;AAEH,OAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAS,KAAK,EAAE;AACvC,aAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;OACvB,CAAC,CAAC;;AAEH,aAAO;AACL,YAAI,EAAE,IAAI;AACV,gBAAQ,EAAE,QAAQ;OACnB,CAAC;KAEH;;GAEF,CAAC;;AAEF,SAAO,KAAK,CAAC;CAEd,CAAC,CAAE","file":"dTree.js","sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n this.nodeSize = this._calculateNodeSize();\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', opts.width + opts.margin.left + opts.margin.right)\n .attr('height', opts.height + opts.margin.top + opts.margin.bottom)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + opts.margin.left + ',' + opts.margin.top + ')');\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize(nodeSize);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('rect')\n .attr('class', function(d) {\n return d.class ? d.class : opts.styles.nodes;\n })\n .attr('width', nodeSize[0] / 2)\n .attr('height', nodeSize[1] / 3)\n .attr('id', function(d) {\n return d.id;\n })\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 4;\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 6;\n })\n .on('click', function(d) {\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n\n // Create the node text label.\n nodes.append('text')\n .text(function(d) {\n return opts.callbacks.text(d.name, d.extra, d.id);\n })\n .attr('class', function(d) {\n return d.textClass ? d.textClass : opts.styles.text;\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 4 + 5;\n })\n .attr('y', function(d) {\n return d.y + 4;\n })\n .on('click', function(d) {\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _calculateNodeSize() {\n var longest = '';\n _.forEach(this.allNodes, function(n) {\n if (n.name.length > longest.length) {\n longest = n.name;\n }\n });\n\n return [longest.length * 10 + 10, longest.length * 5];\n }\n\n }\n\n const dTree = {\n\n version: '0.2.4',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n text: function(name, extra, id) {return name;}\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data) {\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,\n class: person.class\n };\n\n // add to parent as child\n parent.children.push(node);\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n parent.children.push(m);\n\n var spouse = {\n name: person.marriage.spouse.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: person.marriage.spouse.textClass,\n class: person.marriage.spouse.class,\n extra: person.marriage.spouse.extra\n };\n\n parent.children.push(spouse);\n\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n _.forEach(root.children, function(child) {\n child.noParent = true;\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["dTree.js"],"names":[],"mappings":";;;;AAAA,AAAC,CAAA,UAAU,MAAM,EAAE,OAAO,EAAE;AAC1B,SAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC,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CAAC,KAAK;WACpC,CAAC;;AAEF,gBAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;AAE7B,WAAC,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,UAAS,KAAK,EAAE;AAClD,2BAAe,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;WAC3B,CAAC,CAAC;;AAEH,kBAAQ,CAAC,IAAI,CAAC;AACZ,kBAAM,EAAE;AACN,gBAAE,EAAE,IAAI,CAAC,EAAE;aACZ;AACD,kBAAM,EAAE;AACN,gBAAE,EAAE,MAAM,CAAC,EAAE;aACd;WACF,CAAC,CAAC;SAEJ;OAEF,CAAC;;AAEF,OAAC,CAAC,OAAO,CAAC,IAAI,EAAE,UAAS,MAAM,EAAE;AAC/B,uBAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;OAC/B,CAAC,CAAC;;AAEH,OAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAS,KAAK,EAAE;AACvC,aAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;OACvB,CAAC,CAAC;;AAEH,aAAO;AACL,YAAI,EAAE,IAAI;AACV,gBAAQ,EAAE,QAAQ;OACnB,CAAC;KAEH;;GAEF,CAAC;;AAEF,SAAO,KAAK,CAAC;CAEd,CAAC,CAAE","file":"dTree.js","sourcesContent":["(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n this.nodeSize = this._calculateNodeSize();\n\n TreeBuilder.debugLevel = opts.debug ? 1 : 0;\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', width)\n .attr('height', height)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize(nodeSize);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 4;\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 6;\n })\n .attr('width', nodeSize[0] / 2)\n .attr('height', nodeSize[1] / 3)\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(\n d.name,\n d.x,\n d.y,\n nodeSize[0] / 2,\n nodeSize[1] / 3,\n d.extra,\n d.id,\n d.class ? d.class : opts.styles.nodes,\n d.textClass ? d.textClass : opts.styles.text,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d) {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _calculateNodeSize() {\n\n // Not used at the moment\n var longest = '';\n _.forEach(this.allNodes, function(n) {\n if (n.name.length > longest.length) {\n longest = n.name;\n }\n });\n\n return [200, 100];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

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

\\n';\n return node;\n }\n\n static _debug(msg) {\n if (TreeBuilder.debugLevel > 0) {\n console.log(msg);\n }\n }\n\n }\n\n const dTree = {\n\n version: '0.3.1',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRenderer: function(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra,\n id,nodeClass, textClass, textRenderer);\n },\n textRenderer: function(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data) {\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,\n class: person.class\n };\n\n // add to parent as child\n parent.children.push(node);\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n parent.children.push(m);\n\n var spouse = {\n name: person.marriage.spouse.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: person.marriage.spouse.textClass,\n class: person.marriage.spouse.class,\n extra: person.marriage.spouse.extra\n };\n\n parent.children.push(spouse);\n\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n _.forEach(root.children, function(child) {\n child.noParent = true;\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/dist/dTree.min.js b/dist/dTree.min.js index ef96317..06fe6d0 100644 --- a/dist/dTree.min.js +++ b/dist/dTree.min.js @@ -1,2 +1,2 @@ -function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function t(t,e){for(var n=0;n1&&(a=r[1].y),_.forEach(r,function(t){t.y=t.y-a/2});var i=this.tree.links(r);this.svg.selectAll(".link").data(i).enter().append("path").attr("class",e.styles.linage).attr("d",this._elbow);var r=this.svg.selectAll(".node").data(r).enter();this._linkSiblings(),this.svg.selectAll(".sibling").data(this.siblings).enter().append("path").attr("class",e.styles.marriage).attr("d",this._siblingLine),r.append("rect").attr("class",function(t){return t["class"]?t["class"]:e.styles.nodes}).attr("width",n[0]/2).attr("height",n[1]/3).attr("id",function(t){return t.id}).attr("display",function(t){return t.hidden?"none":""}).attr("x",function(t){return t.x-n[0]/4}).attr("y",function(t){return t.y-n[1]/6}).on("click",function(t){e.callbacks.nodeClick(t.name,t.extra,t.id)}),r.append("text").text(function(t){return e.callbacks.text(t.name,t.extra,t.id)}).attr("class",function(t){return t.textClass?t.textClass:e.styles.text}).attr("x",function(t){return t.x-n[0]/4+5}).attr("y",function(t){return t.y+4}).on("click",function(t){e.callbacks.nodeClick(t.name,t.extra,t.id)})}},{key:"_flatten",value:function(t){function e(t){t.children&&t.children.forEach(e),t.id||(t.id=++r),n.push(t)}var n=[],r=0;return e(t),n}},{key:"_elbow",value:function(t,e){if(t.target.noParent)return"M0,0L0,0";var n=t.target.y+.5*(t.source.y-t.target.y),r=[{x:t.target.x,y:t.target.y},{x:t.target.x,y:n},{x:t.source.x,y:t.source.y}],a=d3.svg.line().x(function(t){return t.x}).y(function(t){return t.y}).interpolate("step-after");return a(r)}},{key:"_linkSiblings",value:function(){var t=this.allNodes;_.forEach(this.siblings,function(e){var n=t.filter(function(t){return e.source.id==t.id}),r=t.filter(function(t){return e.target.id==t.id});e.source.x=n[0].x,e.source.y=n[0].y,e.target.x=r[0].x,e.target.y=r[0].y})}},{key:"_siblingLine",value:function(t,e){var n=t.target.y+.5*(t.source.y-t.target.y),r=[{x:t.source.x,y:t.source.y},{x:t.target.x,y:n},{x:t.target.x,y:t.target.y}],a=d3.svg.line().x(function(t){return t.x}).y(function(t){return t.y}).interpolate("step-after");return a(r)}},{key:"_calculateNodeSize",value:function(){var t="";return _.forEach(this.allNodes,function(e){e.name.length>t.length&&(t=e.name)}),[10*t.length+10,5*t.length]}}]),t}(),e={version:"0.2.4",init:function(e){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_.defaultsDeep(n||{},{target:"#graph",width:600,height:600,callbacks:{nodeClick:function(t,e,n){},text:function(t,e,n){return t}},margin:{top:0,right:0,bottom:0,left:0},styles:{node:"node",linage:"linage",marriage:"marriage",text:"nodeText"}}),e=this._preprocess(e),a=new t(e.root,e.siblings,r);a.create()},_preprocess:function(t){var e=[],n=0,r={name:"",id:n++,hidden:!0,children:[]},a=function i(t,r){var a={name:t.name,id:n++,hidden:!1,children:[],extra:t.extra,textClass:t.textClass,"class":t["class"]};if(r.children.push(a),t.marriage){var s={name:"",id:n++,hidden:!0,noParent:!0,children:[],extra:t.marriage.extra};r.children.push(s);var o={name:t.marriage.spouse.name,id:n++,hidden:!1,noParent:!0,children:[],textClass:t.marriage.spouse.textClass,"class":t.marriage.spouse["class"],extra:t.marriage.spouse.extra};r.children.push(o),_.forEach(t.marriage.children,function(t){i(t,s)}),e.push({source:{id:a.id},target:{id:o.id}})}};return _.forEach(t,function(t){a(t,r)}),_.forEach(r.children,function(t){t.noParent=!0}),{root:r,siblings:e}}};return e}); +function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n1&&(a=r[1].y),_.forEach(r,function(e){e.y=e.y-a/2});var i=this.tree.links(r);this.svg.selectAll(".link").data(i).enter().append("path").attr("class",t.styles.linage).attr("d",this._elbow);var r=this.svg.selectAll(".node").data(r).enter();this._linkSiblings(),this.svg.selectAll(".sibling").data(this.siblings).enter().append("path").attr("class",t.styles.marriage).attr("d",this._siblingLine),r.append("foreignObject").attr("display",function(e){return e.hidden?"none":""}).attr("x",function(e){return e.x-n[0]/4}).attr("y",function(e){return e.y-n[1]/6}).attr("width",n[0]/2).attr("height",n[1]/3).attr("id",function(e){return e.id}).html(function(e){return e.hidden?null:t.callbacks.nodeRenderer(e.name,e.x,e.y,n[0]/2,n[1]/3,e.extra,e.id,e["class"]?e["class"]:t.styles.nodes,e.textClass?e.textClass:t.styles.text,t.callbacks.textRenderer)}).on("click",function(e){e.hidden||t.callbacks.nodeClick(e.name,e.extra,e.id)})}},{key:"_flatten",value:function(e){function t(e){e.children&&e.children.forEach(t),e.id||(e.id=++r),n.push(e)}var n=[],r=0;return t(e),n}},{key:"_elbow",value:function(e,t){if(e.target.noParent)return"M0,0L0,0";var n=e.target.y+.5*(e.source.y-e.target.y),r=[{x:e.target.x,y:e.target.y},{x:e.target.x,y:n},{x:e.source.x,y:e.source.y}],a=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}).interpolate("step-after");return a(r)}},{key:"_linkSiblings",value:function(){var e=this.allNodes;_.forEach(this.siblings,function(t){var n=e.filter(function(e){return t.source.id==e.id}),r=e.filter(function(e){return t.target.id==e.id});t.source.x=n[0].x,t.source.y=n[0].y,t.target.x=r[0].x,t.target.y=r[0].y})}},{key:"_siblingLine",value:function(e,t){var n=e.target.y+.5*(e.source.y-e.target.y),r=[{x:e.source.x,y:e.source.y},{x:e.target.x,y:n},{x:e.target.x,y:e.target.y}],a=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}).interpolate("step-after");return a(r)}},{key:"_calculateNodeSize",value:function(){var e="";return _.forEach(this.allNodes,function(t){t.name.length>e.length&&(e=t.name)}),[200,100]}}],[{key:"_nodeRenderer",value:function(e,t,n,r,a,i,s,o,l,c){var d="";return d+="
\n',d+=c(e,i,l),d+="
"}},{key:"_textRenderer",value:function(e,t,n){var r="";return r+="

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

\n"}},{key:"_debug",value:function(t){e.debugLevel>0&&console.log(t)}}]),e}(),t={version:"0.3.1",init:function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],r=_.defaultsDeep(n||{},{target:"#graph",debug:!1,width:600,height:600,callbacks:{nodeClick:function(e,t,n){},nodeRenderer:function(t,n,r,a,i,s,o,l,c,d){return e._nodeRenderer(t,n,r,a,i,s,o,l,c,d)},textRenderer:function(t,n,r){return e._textRenderer(t,n,r)}},margin:{top:0,right:0,bottom:0,left:0},styles:{node:"node",linage:"linage",marriage:"marriage",text:"nodeText"}}),t=this._preprocess(t),a=new e(t.root,t.siblings,r);a.create()},_preprocess:function(e){var t=[],n=0,r={name:"",id:n++,hidden:!0,children:[]},a=function i(e,r){var a={name:e.name,id:n++,hidden:!1,children:[],extra:e.extra,textClass:e.textClass,"class":e["class"]};if(r.children.push(a),e.marriage){var s={name:"",id:n++,hidden:!0,noParent:!0,children:[],extra:e.marriage.extra};r.children.push(s);var o={name:e.marriage.spouse.name,id:n++,hidden:!1,noParent:!0,children:[],textClass:e.marriage.spouse.textClass,"class":e.marriage.spouse["class"],extra:e.marriage.spouse.extra};r.children.push(o),_.forEach(e.marriage.children,function(e){i(e,s)}),t.push({source:{id:a.id},target:{id:o.id}})}};return _.forEach(e,function(e){a(e,r)}),_.forEach(r.children,function(e){e.noParent=!0}),{root:r,siblings:t}}};return t}); //# sourceMappingURL=dTree.min.js.map diff --git a/dist/dTree.min.js.map b/dist/dTree.min.js.map index d37f119..17c9d61 100644 --- a/dist/dTree.min.js.map +++ b/dist/dTree.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["dTree.min.js","/source/dTree.js"],"names":["_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","global","factory","exports","module","define","amd","dTree","this","TreeBuilder","root","siblings","opts","allNodes","_flatten","nodeSize","_calculateNodeSize","value","zoom","d3","behavior","scaleExtent","on","_","bind","svg","attr","event","translate","scale","select","append","width","margin","left","right","height","top","bottom","call","tree","layout","separation","a","b","hidden","_update","source","nodes","rootOffset","y","forEach","n","links","selectAll","data","enter","styles","linage","_elbow","_linkSiblings","marriage","_siblingLine","d","id","x","callbacks","nodeClick","name","extra","text","textClass","recurse","node","children","push","noParent","ny","linedata","fun","line","interpolate","start","filter","v","end","longest","version","init","options","arguments","undefined","defaultsDeep","_preprocess","treeBuilder","create","reconstructTree","person","parent","class","m","spouse","child"],"mappings":"AAEA,QAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCAFhH,GAAIC,cAAe,WAAe,QAASC,GAAiBC,EAAQC,GAAS,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,GAAIE,GAAaH,EAAMC,EAAIE,GAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,SAAWF,KAAYA,EAAWG,UAAW,GAAMC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAAiB,MAAO,UAAUR,EAAae,EAAYC,GAAiJ,MAA9HD,IAAYZ,EAAiBH,EAAYiB,UAAWF,GAAiBC,GAAab,EAAiBH,EAAagB,GAAqBhB,OCAjiB,SAAWkB,EAAQ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QAAQzC,EAAKgE,SAAU,SAAS4B,GAChCA,EAAM1B,UAAW,KAIjBlE,KAAMA,EACNC,SAAUA,IAOhB,OAAOJ","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 this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n this.nodeSize = this._calculateNodeSize();\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 zoom = d3.behavior.zoom().scaleExtent([0.1, 10]).on('zoom', _.bind(function () {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' + ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target).append('svg').attr('width', opts.width + opts.margin.left + opts.margin.right).attr('height', opts.height + opts.margin.top + opts.margin.bottom).call(zoom).append('g').attr('transform', 'translate(' + opts.margin.left + ',' + opts.margin.top + ')');\n\n // Compute the layout.\n this.tree = d3.layout.tree().nodeSize(nodeSize);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n }\n }, {\n key: '_update',\n value: function _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function (n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link').data(links).enter().append('path').attr('class', opts.styles.linage).attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node').data(nodes).enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling').data(this.siblings).enter().append('path').attr('class', opts.styles.marriage).attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('rect').attr('class', function (d) {\n return d['class'] ? d['class'] : opts.styles.nodes;\n }).attr('width', nodeSize[0] / 2).attr('height', nodeSize[1] / 3).attr('id', function (d) {\n return d.id;\n }).attr('display', function (d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n }).attr('x', function (d) {\n return d.x - nodeSize[0] / 4;\n }).attr('y', function (d) {\n return d.y - nodeSize[1] / 6;\n }).on('click', function (d) {\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n\n // Create the node text label.\n nodes.append('text').text(function (d) {\n return opts.callbacks.text(d.name, d.extra, d.id);\n }).attr('class', function (d) {\n return d.textClass ? d.textClass : opts.styles.text;\n }).attr('x', function (d) {\n return d.x - nodeSize[0] / 4 + 5;\n }).attr('y', function (d) {\n return d.y + 4;\n }).on('click', function (d) {\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n }, {\n key: '_flatten',\n value: function _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n }, {\n key: '_elbow',\n value: function _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }, {\n key: '_linkSiblings',\n value: function _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function (d) {\n var start = allNodes.filter(function (v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function (v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n }\n }, {\n key: '_siblingLine',\n value: function _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }, {\n key: '_calculateNodeSize',\n value: function _calculateNodeSize() {\n var longest = '';\n _.forEach(this.allNodes, function (n) {\n if (n.name.length > longest.length) {\n longest = n.name;\n }\n });\n\n return [longest.length * 10 + 10, longest.length * 5];\n }\n }]);\n\n return TreeBuilder;\n })();\n\n var dTree = {\n\n version: '0.2.4',\n\n init: function init(data) {\n var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function nodeClick(name, extra, id) {},\n text: function text(name, extra, id) {\n return name;\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n },\n\n _preprocess: function _preprocess(data) {\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,\n 'class': person['class']\n };\n\n // add to parent as child\n parent.children.push(node);\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n parent.children.push(m);\n\n var spouse = {\n name: person.marriage.spouse.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: person.marriage.spouse.textClass,\n 'class': person.marriage.spouse['class'],\n extra: person.marriage.spouse.extra\n };\n\n parent.children.push(spouse);\n\n _.forEach(person.marriage.children, function (child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n }\n };\n\n _.forEach(data, function (person) {\n reconstructTree(person, root);\n });\n\n _.forEach(root.children, function (child) {\n child.noParent = true;\n });\n\n return {\n root: root,\n siblings: siblings\n };\n }\n\n };\n\n return dTree;\n});\n//# sourceMappingURL=dTree.js.map\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n this.nodeSize = this._calculateNodeSize();\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', opts.width + opts.margin.left + opts.margin.right)\n .attr('height', opts.height + opts.margin.top + opts.margin.bottom)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + opts.margin.left + ',' + opts.margin.top + ')');\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize(nodeSize);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('rect')\n .attr('class', function(d) {\n return d.class ? d.class : opts.styles.nodes;\n })\n .attr('width', nodeSize[0] / 2)\n .attr('height', nodeSize[1] / 3)\n .attr('id', function(d) {\n return d.id;\n })\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 4;\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 6;\n })\n .on('click', function(d) {\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n\n // Create the node text label.\n nodes.append('text')\n .text(function(d) {\n return opts.callbacks.text(d.name, d.extra, d.id);\n })\n .attr('class', function(d) {\n return d.textClass ? d.textClass : opts.styles.text;\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 4 + 5;\n })\n .attr('y', function(d) {\n return d.y + 4;\n })\n .on('click', function(d) {\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _calculateNodeSize() {\n var longest = '';\n _.forEach(this.allNodes, function(n) {\n if (n.name.length > longest.length) {\n longest = n.name;\n }\n });\n\n return [longest.length * 10 + 10, longest.length * 5];\n }\n\n }\n\n const dTree = {\n\n version: '0.2.4',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n text: function(name, extra, id) {return name;}\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data) {\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,\n class: person.class\n };\n\n // add to parent as child\n parent.children.push(node);\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n parent.children.push(m);\n\n var spouse = {\n name: person.marriage.spouse.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: person.marriage.spouse.textClass,\n class: person.marriage.spouse.class,\n extra: person.marriage.spouse.extra\n };\n\n parent.children.push(spouse);\n\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n _.forEach(root.children, function(child) {\n child.noParent = true;\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["dTree.min.js","/source/dTree.js"],"names":["_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","global","factory","exports","module","define","amd","dTree","this","TreeBuilder","root","siblings","opts","allNodes","_flatten","nodeSize","_calculateNodeSize","debugLevel","debug","value","width","margin","left","right","height","top","bottom","zoom","d3","behavior","scaleExtent","on","_","bind","svg","attr","event","translate","scale","select","append","call","tree","layout","separation","a","b","hidden","_update","source","nodes","rootOffset","y","forEach","n","links","selectAll","data","enter","styles","linage","_elbow","_linkSiblings","marriage","_siblingLine","d","x","id","html","callbacks","nodeRenderer","name","extra","textClass","text","textRenderer","nodeClick","recurse","node","children","push","noParent","ny","linedata","fun","line","interpolate","start","filter","v","end","longest","nodeClass","msg","console","log","version","init","options","arguments","undefined","defaultsDeep","_nodeRenderer","_textRenderer","_preprocess","treeBuilder","create","reconstructTree","person","parent","class","m","spouse","child"],"mappings":"AAEA,QAASA,iBAAgBC,EAAUC,GAAe,KAAMD,YAAoBC,IAAgB,KAAM,IAAIC,WAAU,qCAFhH,GAAIC,cAAe,WAAe,QAASC,GAAiBC,EAAQC,GAAS,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CAAE,GAAIE,GAAaH,EAAMC,EAAIE,GAAWC,WAAaD,EAAWC,aAAc,EAAOD,EAAWE,cAAe,EAAU,SAAWF,KAAYA,EAAWG,UAAW,GAAMC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAAiB,MAAO,UAAUR,EAAae,EAAYC,GAAiJ,MAA9HD,IAAYZ,EAAiBH,EAAYiB,UAAWF,GAAiBC,GAAab,EAAiBH,EAAagB,GAAqBhB,OCAjiB,SAAWkB,EAAQC,GACE,gBAAZC,UAA0C,mBAAXC,QAAyBA,OAAOD,QAAUD,IAC9D,kBAAXG,SAAyBA,OAAOC,IAA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U,EACVF,YACAP,MAAOoC,EAAO7C,SAASS,MAGzBqC,GAAO9B,SAASC,KAAK+B,EAErB,IAAIC,IACFzC,KAAMqC,EAAO7C,SAASiD,OAAOzC,KAC7BJ,GAAIA,IACJpB,QAAQ,EACRkC,UAAU,EACVF,YACAN,UAAWmC,EAAO7C,SAASiD,OAAOvC,UAClCqC,QAAOF,EAAO7C,SAASiD,OAAM,SAC7BxC,MAAOoC,EAAO7C,SAASiD,OAAOxC,MAGhCqC,GAAO9B,SAASC,KAAKgC,GAErBhF,EAAEqB,QAAQuD,EAAO7C,SAASgB,SAAU,SAASkC,GAC3CN,EAAgBM,EAAOF,KAGzBpG,EAASqE,MACP/B,QACEkB,GAAIW,EAAKX,IAEXhF,QACEgF,GAAI6C,EAAO7C,OAgBnB,OARAnC,GAAEqB,QAAQI,EAAM,SAASmD,GACvBD,EAAgBC,EAAQlG,KAG1BsB,EAAEqB,QAAQ3C,EAAKqE,SAAU,SAASkC,GAChCA,EAAMhC,UAAW,KAIjBvE,KAAMA,EACNC,SAAUA,IAOhB,OAAOJ","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 this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n this.nodeSize = this._calculateNodeSize();\n\n TreeBuilder.debugLevel = opts.debug ? 1 : 0;\n }\n\n _createClass(TreeBuilder, [{\n key: 'create',\n value: function create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom().scaleExtent([0.1, 10]).on('zoom', _.bind(function () {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' + ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target).append('svg').attr('width', width).attr('height', height).call(zoom).append('g').attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree().nodeSize(nodeSize);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n }\n }, {\n key: '_update',\n value: function _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function (n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link').data(links).enter().append('path').attr('class', opts.styles.linage).attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node').data(nodes).enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling').data(this.siblings).enter().append('path').attr('class', opts.styles.marriage).attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject').attr('display', function (d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n }).attr('x', function (d) {\n return d.x - nodeSize[0] / 4;\n }).attr('y', function (d) {\n return d.y - nodeSize[1] / 6;\n }).attr('width', nodeSize[0] / 2).attr('height', nodeSize[1] / 3).attr('id', function (d) {\n return d.id;\n }).html(function (d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(d.name, d.x, d.y, nodeSize[0] / 2, nodeSize[1] / 3, d.extra, d.id, d['class'] ? d['class'] : opts.styles.nodes, d.textClass ? d.textClass : opts.styles.text, opts.callbacks.textRenderer);\n }).on('click', function (d) {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n }, {\n key: '_flatten',\n value: function _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n }, {\n key: '_elbow',\n value: function _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }, {\n key: '_linkSiblings',\n value: function _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function (d) {\n var start = allNodes.filter(function (v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function (v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n }\n }, {\n key: '_siblingLine',\n value: function _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line().x(function (d) {\n return d.x;\n }).y(function (d) {\n return d.y;\n }).interpolate('step-after');\n return fun(linedata);\n }\n }, {\n key: '_calculateNodeSize',\n value: function _calculateNodeSize() {\n\n // Not used at the moment\n var longest = '';\n _.forEach(this.allNodes, function (n) {\n if (n.name.length > longest.length) {\n longest = n.name;\n }\n });\n\n return [200, 100];\n }\n }], [{\n key: '_nodeRenderer',\n value: function _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n\n return node;\n }\n }, {\n key: '_textRenderer',\n value: function _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

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

\\n';\n return node;\n }\n }, {\n key: '_debug',\n value: function _debug(msg) {\n if (TreeBuilder.debugLevel > 0) {\n console.log(msg);\n }\n }\n }]);\n\n return TreeBuilder;\n })();\n\n var dTree = {\n\n version: '0.3.1',\n\n init: function init(data) {\n var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function nodeClick(name, extra, id) {},\n nodeRenderer: function nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer);\n },\n textRenderer: function textRenderer(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n },\n\n _preprocess: function _preprocess(data) {\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,\n 'class': person['class']\n };\n\n // add to parent as child\n parent.children.push(node);\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n parent.children.push(m);\n\n var spouse = {\n name: person.marriage.spouse.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: person.marriage.spouse.textClass,\n 'class': person.marriage.spouse['class'],\n extra: person.marriage.spouse.extra\n };\n\n parent.children.push(spouse);\n\n _.forEach(person.marriage.children, function (child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n }\n };\n\n _.forEach(data, function (person) {\n reconstructTree(person, root);\n });\n\n _.forEach(root.children, function (child) {\n child.noParent = true;\n });\n\n return {\n root: root,\n siblings: siblings\n };\n }\n\n };\n\n return dTree;\n});\n//# sourceMappingURL=dTree.js.map\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :\n typeof define === 'function' && define.amd ? define(factory) :\n global.dTree = factory();\n}(this, function () { 'use strict';\n\n class TreeBuilder {\n\n constructor(root, siblings, opts) {\n this.root = root;\n this.siblings = siblings;\n this.opts = opts;\n\n // flatten nodes\n this.allNodes = this._flatten(this.root);\n this.nodeSize = this._calculateNodeSize();\n\n TreeBuilder.debugLevel = opts.debug ? 1 : 0;\n }\n\n create() {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var width = opts.width + opts.margin.left + opts.margin.right;\n var height = opts.height + opts.margin.top + opts.margin.bottom;\n\n var zoom = d3.behavior.zoom()\n .scaleExtent([0.1, 10])\n .on('zoom', _.bind(function() {\n svg.attr('transform', 'translate(' + d3.event.translate + ')' +\n ' scale(' + d3.event.scale + ')');\n }, this));\n\n //make an SVG\n var svg = this.svg = d3.select(opts.target)\n .append('svg')\n .attr('width', width)\n .attr('height', height)\n .call(zoom)\n .append('g')\n .attr('transform', 'translate(' + width / 2 + ',' + opts.margin.top + ')');\n\n zoom.translate([width / 2, opts.margin.top]);\n\n // Compute the layout.\n this.tree = d3.layout.tree()\n .nodeSize(nodeSize);\n\n this.tree.separation(function separation(a, b) {\n if (a.hidden || b.hidden) {\n return 0.3;\n } else {\n return 0.6;\n }\n });\n\n this._update(this.root);\n\n }\n\n _update(source) {\n\n var opts = this.opts;\n var allNodes = this.allNodes;\n var nodeSize = this.nodeSize;\n\n var nodes = this.tree.nodes(source);\n\n // Since root node is hidden, readjust height.\n var rootOffset = 0;\n if (nodes.length > 1) {\n rootOffset = nodes[1].y;\n }\n _.forEach(nodes, function(n) {\n n.y = n.y - rootOffset / 2;\n });\n\n var links = this.tree.links(nodes);\n\n // Create the link lines.\n this.svg.selectAll('.link')\n .data(links)\n .enter()\n .append('path')\n .attr('class', opts.styles.linage)\n .attr('d', this._elbow);\n\n var nodes = this.svg.selectAll('.node')\n .data(nodes)\n .enter();\n\n this._linkSiblings();\n\n // Draw siblings (marriage)\n this.svg.selectAll('.sibling')\n .data(this.siblings)\n .enter()\n .append('path')\n .attr('class', opts.styles.marriage)\n .attr('d', this._siblingLine);\n\n // Create the node rectangles.\n nodes.append('foreignObject')\n .attr('display', function(d) {\n if (d.hidden) {\n return 'none';\n } else {\n return '';\n };\n })\n .attr('x', function(d) {\n return d.x - nodeSize[0] / 4;\n })\n .attr('y', function(d) {\n return d.y - nodeSize[1] / 6;\n })\n .attr('width', nodeSize[0] / 2)\n .attr('height', nodeSize[1] / 3)\n .attr('id', function(d) {\n return d.id;\n })\n .html(function(d) {\n if (d.hidden) {\n return null;\n }\n return opts.callbacks.nodeRenderer(\n d.name,\n d.x,\n d.y,\n nodeSize[0] / 2,\n nodeSize[1] / 3,\n d.extra,\n d.id,\n d.class ? d.class : opts.styles.nodes,\n d.textClass ? d.textClass : opts.styles.text,\n opts.callbacks.textRenderer);\n })\n .on('click', function(d) {\n if (d.hidden) {\n return;\n }\n opts.callbacks.nodeClick(d.name, d.extra, d.id);\n });\n }\n\n _flatten(root) {\n var n = [];\n var i = 0;\n\n function recurse(node) {\n if (node.children) {\n node.children.forEach(recurse);\n }\n if (!node.id) {\n node.id = ++i;\n }\n n.push(node);\n }\n recurse(root);\n return n;\n }\n\n _elbow(d, i) {\n if (d.target.noParent) {\n return 'M0,0L0,0';\n }\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.target.x,\n y: d.target.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.source.x,\n y: d.source.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _linkSiblings() {\n\n var allNodes = this.allNodes;\n\n _.forEach(this.siblings, function(d)  {\n var start = allNodes.filter(function(v) {\n return d.source.id == v.id;\n });\n var end = allNodes.filter(function(v) {\n return d.target.id == v.id;\n });\n d.source.x = start[0].x;\n d.source.y = start[0].y;\n d.target.x = end[0].x;\n d.target.y = end[0].y;\n });\n\n }\n\n _siblingLine(d, i) {\n\n var ny = d.target.y + (d.source.y - d.target.y) * 0.50;\n\n var linedata = [{\n x: d.source.x,\n y: d.source.y\n }, {\n x: d.target.x,\n y: ny\n }, {\n x: d.target.x,\n y: d.target.y\n }];\n\n var fun = d3.svg.line()\n .x(function(d) {\n return d.x;\n })\n .y(function(d) {\n return d.y;\n })\n .interpolate('step-after');\n return fun(linedata);\n }\n\n _calculateNodeSize() {\n\n // Not used at the moment\n var longest = '';\n _.forEach(this.allNodes, function(n) {\n if (n.name.length > longest.length) {\n longest = n.name;\n }\n });\n\n return [200, 100];\n }\n\n static _nodeRenderer(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n\n var node = '';\n node += '
\\n';\n node += textRenderer(name, extra, textClass);\n node += '
';\n\n return node;\n }\n\n static _textRenderer(name, extra, textClass) {\n var node = '';\n node += '

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

\\n';\n return node;\n }\n\n static _debug(msg) {\n if (TreeBuilder.debugLevel > 0) {\n console.log(msg);\n }\n }\n\n }\n\n const dTree = {\n\n version: '0.3.1',\n\n init: function(data, options = {}) {\n\n var opts = _.defaultsDeep(options || {}, {\n target: '#graph',\n debug: false,\n width: 600,\n height: 600,\n callbacks: {\n nodeClick: function(name, extra, id) {},\n nodeRenderer: function(name, x, y, height, width, extra, id, nodeClass, textClass, textRenderer) {\n return TreeBuilder._nodeRenderer(name, x, y, height, width, extra,\n id,nodeClass, textClass, textRenderer);\n },\n textRenderer: function(name, extra, textClass) {\n return TreeBuilder._textRenderer(name, extra, textClass);\n }\n },\n margin: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n styles: {\n node: 'node',\n linage: 'linage',\n marriage: 'marriage',\n text: 'nodeText'\n }\n });\n\n var data = this._preprocess(data);\n var treeBuilder = new TreeBuilder(data.root, data.siblings, opts);\n treeBuilder.create();\n\n },\n\n _preprocess: function(data) {\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,\n class: person.class\n };\n\n // add to parent as child\n parent.children.push(node);\n\n // go through marriage\n if (person.marriage) {\n\n var m = {\n name: '',\n id: id++,\n hidden: true,\n noParent: true,\n children: [],\n extra: person.marriage.extra\n };\n\n parent.children.push(m);\n\n var spouse = {\n name: person.marriage.spouse.name,\n id: id++,\n hidden: false,\n noParent: true,\n children: [],\n textClass: person.marriage.spouse.textClass,\n class: person.marriage.spouse.class,\n extra: person.marriage.spouse.extra\n };\n\n parent.children.push(spouse);\n\n _.forEach(person.marriage.children, function(child) {\n reconstructTree(child, m);\n });\n\n siblings.push({\n source: {\n id: node.id\n },\n target: {\n id: spouse.id\n }\n });\n\n }\n\n };\n\n _.forEach(data, function(person) {\n reconstructTree(person, root);\n });\n\n _.forEach(root.children, function(child) {\n child.noParent = true;\n });\n\n return {\n root: root,\n siblings: siblings\n };\n\n }\n\n };\n\n return dTree;\n\n}));"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/package.json b/package.json index a905ab0..c6b469b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "d3-dtree", - "version": "0.3.0", + "version": "0.3.1", "description": "A library for visualizing data trees built on top of D3.", "main": "dist/dTree.js", "scripts": {