From 773fd6eaf154b339afc5fad14b3e1eaf9df35f33 Mon Sep 17 00:00:00 2001 From: huston Date: Tue, 21 Oct 2014 09:13:36 -0700 Subject: [PATCH] commit dist files for 0.3.1 --- bower.json | 2 +- dist/alchemy.js | 186 ++++++++++-------- dist/alchemy.min.js | 4 +- .../docs/_documentation/Annotated-Source.md | 131 ++++++------ 4 files changed, 166 insertions(+), 157 deletions(-) diff --git a/bower.json b/bower.json index 5df6d2c..601e009 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "alchemyjs", - "version": "0.3.0", + "version": "0.3.1", "main": [ "dist/alchemy.min.css", "dist/alchemy.min.js" diff --git a/dist/alchemy.js b/dist/alchemy.js index 85dbe3c..9bd675d 100644 --- a/dist/alchemy.js +++ b/dist/alchemy.js @@ -11,7 +11,7 @@ this.getEdges = __bind(this.getEdges, this); this.getNodes = __bind(this.getNodes, this); this.begin = __bind(this.begin, this); - this.version = "0.3.0"; + this.version = "0.3.1"; this.layout = {}; this.interactions = {}; this.utils = {}; @@ -236,6 +236,13 @@ }); } }, + activeNodes: function() { + return _.filter(alchemy._nodes, function(node) { + if (node._state === "active") { + return node; + } + }); + }, allEdges: function() { return _.flatten(_.map(alchemy._edges, function(edgeArray) { var e, _i, _len, _results; @@ -282,9 +289,11 @@ alchemy.clustering = (function() { function clustering() { - var nodes, _charge, _friction, _gravity, _linkDistancefn, _linkStrength; + var clustering, conf, nodes, _charge, _friction, _gravity, _linkDistancefn, _linkStrength; nodes = alchemy._nodes; - this.clusterKey = alchemy.conf.clusterKey; + conf = alchemy.conf; + clustering = this; + this.clusterKey = conf.clusterKey; this.identifyClusters(); _charge = -500; _linkStrength = function(edge) { @@ -599,11 +608,26 @@ "id": "toggle-edges", "class": "list-group-item active-label toggle" }).html("Toggle Edges").on("click", function() { - return _.each(_.values(alchemy._edges), function(edges) { - return _.each(edges, function(e) { - return e.toggleHidden(); + if (_.contains(_.pluck(_.flatten(_.values(alchemy._edges)), "_state"), "active")) { + return _.each(_.values(alchemy._edges), function(edges) { + return _.each(edges, function(e) { + if (e._state === "active") { + return e.toggleHidden(); + } + }); }); - }); + } else { + return _.each(_.values(alchemy._edges), function(edges) { + return _.each(edges, function(e) { + var source, target; + source = alchemy._nodes[e._properties.source]; + target = alchemy._nodes[e._properties.target]; + if (source._state === "active" && target._state === "active") { + return e.toggleHidden(); + } + }); + }); + } }); }, nodesToggle: function() { @@ -611,12 +635,23 @@ "id": "toggle-nodes", "class": "list-group-item active-label toggle" }).html("Toggle Nodes").on("click", function() { - return _.each(_.values(alchemy._nodes), function(n) { - if (alchemy.conf.toggleRootNodes && n._d3.root) { - return; - } - return n.toggleHidden(); - }); + if (_.contains(_.pluck(_.values(alchemy._nodes), "_state"), "active")) { + return _.each(_.values(alchemy._nodes), function(n) { + if (alchemy.conf.toggleRootNodes && n._d3.root) { + return; + } + if (n._state === "active") { + return n.toggleHidden(); + } + }); + } else { + return _.each(_.values(alchemy._nodes), function(n) { + if (alchemy.conf.toggleRootNodes && n._d3.root) { + return; + } + return n.toggleHidden(); + }); + } }); }, update: function() { @@ -624,16 +659,21 @@ var element, tag; element = d3.select(this); tag = element.attr("name"); - return alchemy.vis.selectAll("." + tag).each(function(d) { - var edge, node; + alchemy.vis.selectAll("." + tag).each(function(d) { + var edge, node, source, target; if (alchemy._nodes[d.id] != null) { node = alchemy._nodes[d.id]; return node.toggleHidden(); } else { edge = alchemy._edges[d.id][0]; - return edge.toggleHidden(); + source = alchemy._nodes[edge._properties.source]; + target = alchemy._nodes[edge._properties.target]; + if (source._state === "active" && target._state === "active") { + return edge.toggleHidden(); + } } }); + return alchemy.stats.nodeStats(); }); } }; @@ -827,7 +867,6 @@ function Layout() { this.linkDistancefn = __bind(this.linkDistancefn, this); this.tick = __bind(this.tick, this); - this.collide = __bind(this.collide, this); this.linkStrength = __bind(this.linkStrength, this); this.gravity = __bind(this.gravity, this); var conf, nodes; @@ -835,12 +874,9 @@ nodes = alchemy._nodes; this.k = Math.sqrt(Math.log(_.size(alchemy._nodes)) / (conf.graphWidth() * conf.graphHeight())); this._clustering = new alchemy.clustering; - if (conf.collisionDetection) { - this.d3NodeInternals = _.map(alchemy._nodes, function(v, k) { - return v._d3; - }); - this.q = d3.geom.quadtree(this.d3NodeInternals); - } + this.d3NodeInternals = _.map(alchemy._nodes, function(v, k) { + return v._d3; + }); if (conf.cluster) { this._charge = function() { return this._clustering.layout.charge; @@ -892,11 +928,7 @@ }; Layout.prototype.friction = function() { - if (alchemy.conf.cluster) { - return 0.7; - } else { - return 0.9; - } + return 0.9; }; Layout.prototype.collide = function(node) { @@ -927,12 +959,13 @@ }; Layout.prototype.tick = function() { - var edges, node, _i, _len, _ref; - if (alchemy.conf.collisionDetection) { + var edges, node, q, _i, _len, _ref; + if (alchemy.conf.collisionDetectionls) { + q = d3.geom.quadtree(this.d3NodeInternals); _ref = this.d3NodeInternals; for (_i = 0, _len = _ref.length; _i < _len; _i++) { node = _ref[_i]; - this.q.visit(this.collide(node)); + q.visit(this.collide(node)); } } alchemy.vis.selectAll("g.node").attr("transform", function(d) { @@ -1067,6 +1100,8 @@ return alchemy.create.edges(e); }); alchemy.vis = d3.select(conf.divSelector).attr("style", "width:" + (conf.graphWidth()) + "px; height:" + (conf.graphHeight()) + "px; background:" + conf.backgroundColour).append("svg").attr("xmlns", "http://www.w3.org/2000/svg").attr("xlink", "http://www.w3.org/1999/xlink").attr("pointer-events", "all").on('click', alchemy.interactions.deselectAll).call(alchemy.interactions.zoom(conf.scaleExtent)).on("dblclick.zoom", null).append('g').attr("transform", "translate(" + conf.initialTranslate + ") scale(" + conf.initialScale + ")"); + alchemy.interactions.zoom().scale(conf.initialScale); + alchemy.interactions.zoom().translate(conf.initialTranslate); alchemy.generateLayout(); alchemy.controlDash.init(); d3Edges = _.flatten(_.map(alchemy._edges, function(edgeArray) { @@ -1105,14 +1140,6 @@ alchemy[conf.afterLoad] = true; } } - if (conf.initialScale !== alchemy.defaults.initialScale) { - alchemy.interactions.zoom().scale(conf.initialScale); - return; - } - if (conf.initialTranslate !== alchemy.defaults.initialTranslate) { - alchemy.interactions.zoom().translate(conf.initialTranslate); - return; - } if (conf.cluster || conf.directedEdges) { defs = d3.select("" + alchemy.conf.divSelector + " svg").append("svg:defs"); } @@ -1126,6 +1153,9 @@ marker.attr('refX', 1); } } + if (conf.nodeStats) { + alchemy.stats.nodeStats(); + } if (conf.showEditor) { editor = new alchemy.editor.Editor; editorInteractions = new alchemy.editor.Interactions; @@ -1140,29 +1170,32 @@ return alchemy.stats.update(); }, nodeStats: function() { - var activeNodes, caption, inactiveNodes, nodeGraph, nodeKey, nodeNum, nodeStats, nodeType, nodeTypes, _i, _len, _ref; + var activeNodes, allNodes, caption, inactiveNodes, nodeData, nodeGraph, nodeKeys, nodeNum, nodeStats, nodeType, nodeTypes, _i, _len, _ref; nodeStats = ''; - nodeNum = alchemy.vis.selectAll(".node")[0].length; - activeNodes = alchemy.vis.selectAll(".node.active")[0].length; - inactiveNodes = alchemy.vis.selectAll(".node.inactive")[0].length; - nodeStats += "
  • Number of nodes: " + nodeNum + "
  • "; + nodeData = []; + allNodes = alchemy.get.allNodes().length; + activeNodes = alchemy.get.activeNodes().length; + inactiveNodes = allNodes - activeNodes; + nodeStats += "
  • Number of nodes: " + allNodes + "
  • "; nodeStats += "
  • Number of active nodes: " + activeNodes + "
  • "; nodeStats += "
  • Number of inactive nodes: " + inactiveNodes + "
  • "; if (alchemy.conf.nodeTypes) { - nodeKey = Object.keys(alchemy.conf.nodeTypes); + nodeKeys = Object.keys(alchemy.conf.nodeTypes); nodeTypes = ''; - _ref = alchemy.conf.nodeTypes[nodeKey]; + _ref = alchemy.conf.nodeTypes[nodeKeys]; for (_i = 0, _len = _ref.length; _i < _len; _i++) { nodeType = _ref[_i]; caption = nodeType.replace('_', ' '); nodeNum = alchemy.vis.selectAll("g.node." + nodeType)[0].length; - nodeTypes += "
  • Number of nodes of type " + caption + ": " + nodeNum + "
  • "; + nodeTypes += "
  • Number of " + caption + " nodes: " + nodeNum + "
  • "; + nodeData.push(["" + nodeType, nodeNum]); } nodeStats += nodeTypes; } nodeGraph = "
  • "; nodeStats += nodeGraph; - return alchemy.dash.select('#node-stats').html(nodeStats); + alchemy.dash.select('#node-stats').html(nodeStats); + return this.insertSVG("node", nodeData); }, edgeStats: function() { var activeEdges, caption, e, edgeData, edgeGraph, edgeNum, edgeType, inactiveEdges, _i, _j, _len, _len1, _ref, _ref1; @@ -1193,27 +1226,6 @@ alchemy.stats.insertSVG("edge", edgeData); return edgeData; }, - nodeStats: function() { - var activeNodes, inactiveNodes, nodeData, nodeGraph, nodeKey, nodeNum, nodeType, totalNodes, _i, _len, _ref; - nodeData = null; - totalNodes = alchemy.vis.selectAll(".node")[0].length; - activeNodes = alchemy.vis.selectAll(".node.active")[0].length; - inactiveNodes = alchemy.vis.selectAll(".node.inactive")[0].length; - if (alchemy.conf.nodeTypes) { - nodeData = []; - nodeKey = Object.keys(alchemy.conf.nodeTypes); - _ref = alchemy.conf.nodeTypes[nodeKey]; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - nodeType = _ref[_i]; - nodeNum = alchemy.vis.selectAll("g.node." + nodeType)[0].length; - nodeData.push(["" + nodeType, nodeNum]); - } - } - nodeGraph = "
  • Number of nodes: " + totalNodes + "
  • Number of active nodes: " + activeNodes + "
  • Number of inactive nodes: " + inactiveNodes + "
  • "; - alchemy.dash.select('#node-stats').html(nodeGraph); - alchemy.stats.insertSVG("node", nodeData); - return nodeData; - }, insertSVG: function(element, data) { var arc, arcs, color, height, pie, radius, svg, width; if (data === null) { @@ -1772,10 +1784,10 @@ alchemy.drawing.NodeUtils = { nodeStyle: function(d) { - var conf, nodeColours; + var conf; conf = alchemy.conf; if (conf.cluster) { - nodeColours = (function(d) { + d.fill = (function(d) { var clusterMap, clustering, colour, colourIndex, colours, key, node; clustering = alchemy.layout._clustering; node = alchemy._nodes[d.id].getProperties(); @@ -1786,14 +1798,6 @@ colour = colours[colourIndex]; return "" + colour; })(d); - } else { - nodeColours = function() { - if (conf.nodeColour) { - return conf.nodeColour; - } else { - return ''; - } - }; } return d; }, @@ -1844,12 +1848,11 @@ fill = toFunc(style.color); stroke = toFunc(style.borderColor); strokeWidth = toFunc(style.borderWidth); - svgStyles = { - "radius": radius(d), - "fill": fill(d), - "stroke": stroke(d), - "stroke-width": strokeWidth(d, radius(d)) - }; + svgStyles = {}; + svgStyles["radius"] = radius(d); + svgStyles["fill"] = fill(d); + svgStyles["stroke"] = stroke(d); + svgStyles["stroke-width"] = strokeWidth(d, radius(d)); return svgStyles; } }, @@ -2494,6 +2497,8 @@ if (_.isPlainObject(conf.edgeTypes)) { lookup = Object.keys(alchemy.conf.edgeTypes); edgeType = this._properties[lookup]; + } else if (_.isArray(conf.edgeTypes)) { + edgeType = this._properties["caption"]; } else if (typeof conf.edgeTypes === 'string') { edgeType = this._properties[conf.edgeTypes]; } @@ -2708,9 +2713,16 @@ this._state = this._state === "hidden" ? "active" : "hidden"; this.setStyles(); return _.each(this._adjacentEdges, function(id) { - var pos, source, target, _ref; + var e, pos, source, sourceState, target, targetState, _ref; _ref = id.split("-"), source = _ref[0], target = _ref[1], pos = _ref[2]; - return alchemy._edges["" + source + "-" + target][pos].toggleHidden(); + e = alchemy._edges["" + source + "-" + target][pos]; + sourceState = alchemy._nodes["" + source]._state; + targetState = alchemy._nodes["" + target]._state; + if (e._state === "hidden" && (sourceState === "active" && targetState === "active")) { + return e.toggleHidden(); + } else if (e._state === "active" && (sourceState === "hidden" || targetState === "hidden")) { + return e.toggleHidden(); + } }); }; diff --git a/dist/alchemy.min.js b/dist/alchemy.min.js index 47743db..ee921b0 100644 --- a/dist/alchemy.min.js +++ b/dist/alchemy.min.js @@ -1,3 +1,3 @@ -(function(){"Alchemy.js is a graph drawing application for the web.\nCopyright (C) 2014 GraphAlchemist, Inc.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see .\nlets";var a,b,c=function(a,b){return function(){return a.apply(b,arguments)}},d=[].slice;a=function(){function a(){this.allEdges=c(this.allEdges,this),this.allNodes=c(this.allNodes,this),this.getEdges=c(this.getEdges,this),this.getNodes=c(this.getNodes,this),this.begin=c(this.begin,this),this.version="0.3.0",this.layout={},this.interactions={},this.utils={},this.visControls={},this.styles={},this.models={},this.drawing={},this.editor={},this.log={},this.currentRelationshipTypes={},this.state={interactions:"default",layout:"default"},this._nodes={},this._edges={}}return a.prototype.begin=function(a){return this.setConf(a),"string"==typeof alchemy.conf.dataSource?d3.json(alchemy.conf.dataSource,alchemy.startGraph):"object"==typeof alchemy.conf.dataSource&&alchemy.startGraph(alchemy.conf.dataSource),this},a.prototype.setConf=function(a){var b,c;null!=a.theme&&_.merge(alchemy.defaults,alchemy.themes[""+a.theme]);for(b in a)c=a[b],"clusterColors"===b&&(a.clusterColours=c),"backgroundColor"===b&&(a.backgroundColour=c),"nodeColor"===b&&(a.nodeColour=c);return this.conf=_.merge(alchemy.defaults,a)},a.prototype.getNodes=function(){var a,b,c,e,f,g,h;if(a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[]){for(b.push(a),e=_.union(b),f=[],g=0,h=e.length;h>g;g++)c=e[g],f.push(alchemy._nodes[c].properties);return f}return[this._nodes[a].properties]},a.prototype.getEdges=function(a,b){var c,d,e;return null==a&&(a=null),null==b&&(b=null),null!=a&&null!=b?(d=""+a+"-"+b,c=this._edges[d],[c.properties]):null!=a&&null==b?(e=_.map(this._edges,function(b){return b.properties.source===a||b.properties.target===a?b.properties:void 0}),_.compact(e)):void 0},a.prototype.allNodes=function(){return _.map(this._nodes,function(a){return a.properties})},a.prototype.allEdges=function(){return _.map(this._edges,function(a){return a.properties})},a}(),b={},"undefined"!=typeof module&&module.exports?module.exports=new a:this.alchemy=new a,alchemy.create={nodes:function(){var a,b,c,e,f,g,h;if(b=arguments[0],c=2<=arguments.length?d.call(arguments,1):[],e=function(a){var b;return alchemy._nodes[a.id]?console.warn("A node with the id "+a.id+" already exists.\nConsider using the alchemy.get.nodes() method to \nretrieve the node and then using the Node methods."):(b=new alchemy.models.Node(a),alchemy._nodes[a.id]=b,[b])},0!==c.length){for(c.push(b),f=[],g=0,h=c.length;h>g;g++)a=c[g],e(a);return f}return e(b)},edges:function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[],c=function(a){var b,c;return a.id&&!alchemy._edges[a.id]?(b=new alchemy.models.Edge(a),alchemy._edges[a.id]=[b],[b]):a.id&&alchemy._edges[a.id]?console.warn("An edge with that id "+someEdgeMap.id+" already exists.\nConsider using the alchemy.get.edge() method to \nretrieve the edge and then using the Edge methods.\nNote: id's are not required for edges. Alchemy will create\nan unlimited number of edges for the same source and target node.\nSimply omit 'id' when creating the edge."):(c=alchemy._edges[""+a.source+"-"+a.target],c?(b=new alchemy.models.Edge(a,c.length),c.push(b),[b]):(b=new alchemy.models.Edge(a,0),alchemy._edges[""+a.source+"-"+a.target]=[b],[b]))},0!==b.length?console.warn("Make sure this function supports multiple arguments"):c(a)}},alchemy.get={nodes:function(){var a,b,c;return b=arguments[0],c=2<=arguments.length?d.call(arguments,1):[],null!=b?(a=_.map(arguments,function(a){return String(a)}),_.filter(alchemy._nodes,function(b,c){return _.contains(a,c)?b:void 0})):console.warn("Please specify a node id.")},edges:function(a,b){var c,d,e;return null==a&&(a=null),null==b&&(b=null),null!=a&&null!=b?(d=""+a+"-"+b,c=alchemy._edges[d],[c]):null!=a&&null==b?(null!=alchemy._edges[a]?[_.flatten(alchemy._edges[a])]:e=_.map(alchemy._edges,function(b){return b.properties.source===a||b.properties.target===a?b.properties:void 0}),_.compact(e)):void 0},allNodes:function(a){return null!=a?_.filter(alchemy._nodes,function(b){return b._nodeType===a?b:void 0}):_.map(alchemy._nodes,function(a){return a})},allEdges:function(){return _.flatten(_.map(alchemy._edges,function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b);return e}))},state:function(){return null!=alchemy.state.key?alchemy.state.key:void 0},clusters:function(){var a,b;return a=alchemy.layout._clustering.clusterMap,b={},_.each(a,function(a,c){return b[c]=_.select(alchemy.get.allNodes(),function(a){return a.getProperties()[alchemy.conf.clusterKey]===c})}),b},clusterColours:function(){var a,b;return b=alchemy.layout._clustering.clusterMap,a={},_.each(b,function(b,c){return a[c]=alchemy.conf.clusterColours[b%alchemy.conf.clusterColours.length]}),a}},alchemy.set={state:function(a,b){return alchemy.state.key=b}},alchemy.clustering=function(){function a(){var a,b,c,d,e,f;a=alchemy._nodes,this.clusterKey=alchemy.conf.clusterKey,this.identifyClusters(),b=-500,f=function(b){var c,d;return c=a[b.source.id]._properties[this.clusterKey],d=a[b.target.id]._properties[this.clusterKey],c===d?.15:0},c=function(){return.7},e=function(b){return a=alchemy._nodes,a[b.source.id]._properties.root||a[b.target.id]._properties.root?300:a[b.source.id]._properties[this.clusterKey]===a[b.target.id]._properties[this.clusterKey]?10:600},d=function(a){return 8*a},this.layout={charge:b,linkStrength:function(a){return f(a)},friction:function(){return c()},linkDistancefn:function(a){return e(a)},gravity:function(a){return d(a)}}}return a.prototype.identifyClusters=function(){var a,b,c;return b=alchemy.get.allNodes(),a=_.uniq(_.map(_.values(b),function(a){return a.getProperties()[alchemy.conf.clusterKey]})),this.clusterMap=_.zipObject(a,function(){c=[];for(var b=0,d=a.length;d>=0?d>=b:b>=d;d>=0?b++:b--)c.push(b);return c}.apply(this))},a.prototype.getClusterColour=function(a){var b;return b=this.clusterMap[a]%alchemy.conf.clusterColours.length,alchemy.conf.clusterColours[b]},a.prototype.edgeGradient=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o;for(c=alchemy.vis.select(""+alchemy.conf.divSelector+" svg"),b={},j=alchemy._nodes,n=_.map(a,function(a){return a._d3}),l=0,m=n.length;m>l;l++)if(d=n[l],!j[d.source.id]._properties.root&&!j[d.target.id]._properties.root&&j[d.source.id]._properties[this.clusterKey]!==j[d.target.id]._properties[this.clusterKey]&&j[d.target.id]._properties[this.clusterKey]!==j[d.source.id]._properties[this.clusterKey]){if(h=j[d.source.id]._properties[this.clusterKey]+"-"+j[d.target.id]._properties[this.clusterKey],h in b)continue;h in b||(k=this.getClusterColour(j[d.target.id]._properties[this.clusterKey]),e=this.getClusterColour(j[d.source.id]._properties[this.clusterKey]),b[h]={startColour:k,endColour:e})}o=[];for(i in b)g="cluster-gradient-"+i,f=c.append("svg:linearGradient").attr("id",g),f.append("svg:stop").attr("offset","0%").attr("stop-color",b[i].startColour),o.push(f.append("svg:stop").attr("offset","100%").attr("stop-color",b[i].endColour));return o},a}(),alchemy.clusterControls={init:function(){var a;return a="",alchemy.dash.select("#clustering-container").append("div").attr("id","cluster-key-container").attr("class","property form-inline form-group").html(a).style("display","none"),alchemy.dash.select("#cluster_control_header").on("click",function(){var a,b;return b=alchemy.dash.select("#cluster-key-container"),a=b.style("display")}),element.style("display",function(){return"block"===display?"none":"block"}),"none"===alchemy.dash.select("#cluster-key-container").style("display")?alchemy.dash.select("#cluster-arrow").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#cluster-arrow").attr("class","fa fa-2x fa-caret-down"),alchemy.dash.select("#cluster-key").on("keydown",function(){return"Enter"===d3.event.keyIdentifier?(alchemy.conf.cluster=!0,alchemy.conf.clusterKey=this.value,alchemy.generateLayout()):void 0})}},alchemy.controlDash={init:function(){var a;return this.dashIsShown()?(a=alchemy.conf.divSelector,alchemy.dash=d3.select(""+a).append("div").attr("id","control-dash-wrapper").attr("class","col-md-4 initial"),alchemy.dash.append("i").attr("id","dash-toggle").attr("class","fa fa-flask col-md-offset-12"),alchemy.dash.append("div").attr("id","control-dash").attr("class","col-md-12"),alchemy.dash.select("#dash-toggle").on("click",alchemy.interactions.toggleControlDash),alchemy.controlDash.zoomCtrl(),alchemy.controlDash.search(),alchemy.controlDash.filters(),alchemy.controlDash.stats(),alchemy.controlDash.clustering()):void 0},search:function(){return alchemy.conf.search?(alchemy.dash.select("#control-dash").append("div").attr("id","search").html("
    \n \n \n
    "),alchemy.search.init()):void 0},zoomCtrl:function(){return alchemy.conf.zoomControls?(alchemy.dash.select("#control-dash-wrapper").append("div").attr("id","zoom-controls").attr("class","col-md-offset-12").html(" "),alchemy.dash.select("#zoom-in").on("click",function(){return alchemy.interactions.clickZoom("in")}),alchemy.dash.select("#zoom-out").on("click",function(){return alchemy.interactions.clickZoom("out")}),alchemy.dash.select("#zoom-reset").on("click",function(){return alchemy.interactions.clickZoom("reset")})):void 0},filters:function(){return alchemy.conf.nodeFilters||alchemy.conf.edgeFilters?(alchemy.dash.select("#control-dash").append("div").attr("id","filters"),alchemy.filters.init()):void 0},stats:function(){var a;return alchemy.conf.nodeStats||alchemy.conf.edgeStats?(a='
    \n

    \n Statistics\n

    \n\n
    \n
    \n
      \n
        \n
        ',alchemy.dash.select("#control-dash").append("div").attr("id","stats").html(a).select("#stats-header").on("click",function(){return alchemy.dash.select("#all-stats").classed("in")?alchemy.dash.select("#stats-header>span").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#stats-header>span").attr("class","fa fa-2x fa-caret-down")}),alchemy.stats.init()):void 0},clustering:function(){var a;return alchemy.conf.clusterControl?(a='
        \n
        \n

        Clustering

        \n \n
        \n
        ',alchemy.dash.select("#control-dash").append("div").attr("id","clustering").html(a).select("#cluster_control_header"),alchemy.clusterControls.init()):void 0},dashIsShown:function(){var a;return a=alchemy.conf,a.showEditor||a.captionToggle||a.toggleRootNodes||a.removeElement||a.clusterControl||a.nodeStats||a.edgeStats||a.edgeFilters||a.nodeFilters||a.edgesToggle||a.nodesToggle||a.search}},alchemy.filters={init:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;if(alchemy.filters.show(),alchemy.conf.edgeFilters&&alchemy.filters.showEdgeFilters(),alchemy.conf.nodeFilters&&alchemy.filters.showNodeFilters(),alchemy.conf.nodeTypes){for(e=Object.keys(alchemy.conf.nodeTypes),g="",n=alchemy.conf.nodeTypes[e],h=0,k=n.length;k>h;h++)f=n[h],a=f.replace("_"," "),g+="";alchemy.dash.select("#node-dropdown").html(g)}if(alchemy.conf.edgeTypes){for(o=alchemy.dash.selectAll(".edge")[0],i=0,l=o.length;l>i;i++)b=o[i],alchemy.currentRelationshipTypes[[b].caption]=!0;for(d="",p=alchemy.conf.edgeTypes,j=0,m=p.length;m>j;j++)c=p[j],a=c.replace("_"," "),d+="";alchemy.dash.select("#rel-dropdown").html(d)}return alchemy.conf.captionsToggle&&alchemy.filters.captionsToggle(),alchemy.conf.edgesToggle&&alchemy.filters.edgesToggle(),alchemy.conf.nodesToggle&&alchemy.filters.nodesToggle(),alchemy.filters.update()},show:function(){var a;return a='
        \n

        Filters

        \n \n
        \n
        \n
        ',alchemy.dash.select("#control-dash #filters").html(a),alchemy.dash.selectAll("#filter-header").on("click",function(){return alchemy.dash.select("#filters>form").classed("in")?alchemy.dash.select("#filter-header>span").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#filter-header>span").attr("class","fa fa-2x fa-caret-down")}),alchemy.dash.select("#filters form")},showEdgeFilters:function(){var a;return a='
        \n

        \n Edge Types\n

        \n \n
        \n',alchemy.dash.select("#filters form").append("div").attr("id","filter-relationships").html(a),alchemy.dash.select("#filter-rel-header").on("click",function(){return alchemy.dash.select("#rel-dropdown").classed("in")?alchemy.dash.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-right"):alchemy.dash.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-down")})},showNodeFilters:function(){var a;return a='
        \n

        \n Node Types\n

        \n \n
        \n',alchemy.dash.select("#filters form").append("div").attr("id","filter-nodes").html(a),alchemy.dash.select("#filter-node-header").on("click",function(){return alchemy.dash.select("#node-dropdown").classed("in")?alchemy.dash.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-right"):alchemy.dash.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-down")})},captionsToggle:function(){return alchemy.dash.select("#filters form").append("li").attr({id:"toggle-captions","class":"list-group-item active-label toggle"}).html("Show Captions").on("click",function(){var a;return a=alchemy.dash.select("g text").attr("style"),"display: block"===a?alchemy.dash.selectAll("g text").attr("style","display: none"):alchemy.dash.selectAll("g text").attr("style","display: block")})},edgesToggle:function(){return alchemy.dash.select("#filters form").append("li").attr({id:"toggle-edges","class":"list-group-item active-label toggle"}).html("Toggle Edges").on("click",function(){return _.each(_.values(alchemy._edges),function(a){return _.each(a,function(a){return a.toggleHidden()})})})},nodesToggle:function(){return alchemy.dash.select("#filters form").append("li").attr({id:"toggle-nodes","class":"list-group-item active-label toggle"}).html("Toggle Nodes").on("click",function(){return _.each(_.values(alchemy._nodes),function(a){return alchemy.conf.toggleRootNodes&&a._d3.root?void 0:a.toggleHidden()})})},update:function(){return alchemy.dash.selectAll(".nodeType, .edgeType").on("click",function(){var a,b;return a=d3.select(this),b=a.attr("name"),alchemy.vis.selectAll("."+b).each(function(a){var b,c;return null!=alchemy._nodes[a.id]?(c=alchemy._nodes[a.id],c.toggleHidden()):(b=alchemy._edges[a.id][0],b.toggleHidden())})})}},alchemy.interactions={edgeClick:function(a){var b;return d3.event.stopPropagation(),b=alchemy._edges[a.id][a.pos],"hidden"!==b._state&&(b._state=function(){return"selected"===b._state?"active":"selected"}(),b.setStyles()),"function"==typeof(null!=alchemy.conf.edgeClick)?alchemy.conf.edgeClick():void 0},edgeMouseOver:function(a){var b;return b=alchemy._edges[a.id][a.pos],"hidden"!==b._state?("selected"!==b._state&&(b._state="highlighted"),b.setStyles()):void 0},edgeMouseOut:function(a){var b;return b=alchemy._edges[a.id][a.pos],"hidden"!==b._state?("selected"!==b._state&&(b._state="active"),b.setStyles()):void 0},nodeMouseOver:function(a){var b;if(b=alchemy._nodes[a.id],"hidden"!==b._state){if("selected"!==b._state&&(b._state="highlighted",b.setStyles()),"function"==typeof alchemy.conf.nodeMouseOver)return alchemy.conf.nodeMouseOver(b);if("number"==typeof alchemy.conf.nodeMouseOver)return b.properties[alchemy.conf.nodeMouseOver]}},nodeMouseOut:function(a){var b;return b=alchemy._nodes[a.id],"hidden"!==b._state&&("selected"!==b._state&&(b._state="active",b.setStyles()),null!=alchemy.conf.nodeMouseOut&&"function"==typeof alchemy.conf.nodeMouseOut)?alchemy.conf.nodeMouseOut(a):void 0},nodeClick:function(a){var b;if(!d3.event.defaultPrevented)return d3.event.stopPropagation(),b=alchemy._nodes[a.id],"hidden"!==b._state&&(b._state=function(){return"selected"===b._state?"active":"selected"}(),b.setStyles()),"function"==typeof alchemy.conf.nodeClick?alchemy.conf.nodeClick(a):void 0},zoom:function(a){return null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scaleExtent(a).on("zoom",function(){return alchemy.vis.attr("transform","translate("+d3.event.translate+") scale("+d3.event.scale+")")})},clickZoom:function(a){var b,c,d,e;return e=alchemy.vis.attr("transform").match(/(-*\d+\.*\d*)/g).map(function(a){return parseFloat(a)}),c=e[0],d=e[1],b=e[2],alchemy.vis.attr("transform",function(){return"in"===a?(balchemy.conf.scaleExtent[0]&&(b-=.2),"translate("+c+","+d+") scale("+b+")"):"reset"===a?"translate(0,0) scale(1)":console.log("error")}),null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scale(b).translate([c,d])},toggleControlDash:function(){var a;return a=alchemy.dash.classed("off-canvas")||alchemy.dash.classed("initial"),alchemy.dash.classed({"off-canvas":!a,initial:!1,"on-canvas":a})},nodeDragStarted:function(a){return d3.event.preventDefault,d3.event.sourceEvent.stopPropagation(),d3.select(this).classed("dragging",!0),a.fixed=!0},nodeDragged:function(a){var b,c,d,e,f,g,h;for(a.x+=d3.event.dx,a.y+=d3.event.dy,a.px+=d3.event.dx,a.py+=d3.event.dy,d=d3.select(this),d.attr("transform","translate("+a.x+", "+a.y+")"),b=alchemy._nodes[a.id]._adjacentEdges,h=[],f=0,g=b.length;g>f;f++)c=b[f],e=alchemy.vis.select("#edge-"+c),h.push(alchemy._drawEdges.updateEdge(e.data()[0]));return h},nodeDragended:function(){return d3.select(this).classed({dragging:!1}),alchemy.conf.forceLocked?void 0:alchemy.force.start()},deselectAll:function(){var a;if(null!=(a=d3.event)?!a.defaultPrevented:!0)return alchemy.conf.showEditor===!0&&alchemy.modifyElements.nodeEditorClear(),_.each(alchemy._nodes,function(a){return a._state="active",a.setStyles()}),_.each(alchemy._edges,function(a){return _.each(a,function(a){return a._state="active",a.setStyles()})}),alchemy.conf.deselectAll?alchemy.conf.deselectAll():void 0}},alchemy.Layout=function(){function a(){this.linkDistancefn=c(this.linkDistancefn,this),this.tick=c(this.tick,this),this.collide=c(this.collide,this),this.linkStrength=c(this.linkStrength,this),this.gravity=c(this.gravity,this);var a,b;a=alchemy.conf,b=alchemy._nodes,this.k=Math.sqrt(Math.log(_.size(alchemy._nodes))/(a.graphWidth()*a.graphHeight())),this._clustering=new alchemy.clustering,a.collisionDetection&&(this.d3NodeInternals=_.map(alchemy._nodes,function(a){return a._d3}),this.q=d3.geom.quadtree(this.d3NodeInternals)),a.cluster?(this._charge=function(){return this._clustering.layout.charge},this._linkStrength=function(a){return this._clustering.layout.linkStrength(a)}):(this._charge=function(){return-10/this.k},this._linkStrength=function(a){return b[a.source.id].getProperties("root")||b[a.target.id].getProperties("root")?1:.9}),a.cluster?this._linkDistancefn=function(a){return this._clustering.layout.linkDistancefn(a)}:"default"===a.linkDistancefn?this._linkDistancefn=function(){return 1/(50*this.k)}:"number"==typeof a.linkDistancefn?this._linkDistancefn=function(){return a.linkDistancefn}:"function"==typeof a.linkDistancefn&&(this._linkDistancefn=function(b){return a.linkDistancefn(b)})}return a.prototype.gravity=function(){return alchemy.conf.cluster?this._clustering.layout.gravity(this.k):50*this.k},a.prototype.linkStrength=function(a){return this._linkStrength(a)},a.prototype.friction=function(){return alchemy.conf.cluster?.7:.9},a.prototype.collide=function(a){var b,c,d,e,f,g;return b=alchemy.conf,g=2*(a.radius+a["stroke-width"])+b.nodeOverlap,c=a.x-g,d=a.x+g,e=a.y-g,f=a.y+g,function(b,h,i,j,k){var l,m,n;return b.point&&b.point!==a&&(m=a.x-Math.abs(b.point.x),n=a.y-b.point.y,l=Math.sqrt(m*m+n*n),g=g,g>l&&(l=(l-g)/l*alchemy.conf.alpha,a.x-=m*=l,a.y-=n*=l,b.point.x+=m,b.point.y+=n)),h>d||c>j||i>f||e>k}},a.prototype.tick=function(){var a,b,c,d,e;if(alchemy.conf.collisionDetection)for(e=this.d3NodeInternals,c=0,d=e.length;d>c;c++)b=e[c],this.q.visit(this.collide(b));return alchemy.vis.selectAll("g.node").attr("transform",function(a){return"translate("+a.x+","+a.y+")"}),a=alchemy.vis.selectAll("g.edge"),this.drawEdge=alchemy.drawing.DrawEdge,this.drawEdge.styleText(a),this.drawEdge.styleLink(a)},a.prototype.positionRootNodes=function(){var a,b,c,d,e,f,g,h,i,j;if(a=alchemy.conf,b={width:a.graphWidth(),height:a.graphHeight()},e=_.filter(alchemy.get.allNodes(),function(a){return a.getProperties("root")}),1!==e.length){for(j=[],c=f=0,g=e.length;g>f;c=++f)d=e[c],d._d3.x=b.width/Math.sqrt(e.length*(c+1)),d._d3.y=b.height/2,j.push(d._d3.fixed=!0);return j}d=e[0],h=[b.width/2,b.width/2],d._d3.x=h[0],d._d3.px=h[1],i=[b.height/2,b.height/2],d._d3.y=i[0],d._d3.py=i[1],d._d3.fixed=!0},a.prototype.chargeDistance=function(){return 500},a.prototype.linkDistancefn=function(a){return this._linkDistancefn(a)},a.prototype.charge=function(){return this._charge()},a}(),alchemy.generateLayout=function(a){var b;return null==a&&(a=!1),b=alchemy.conf,alchemy.layout=new alchemy.Layout,alchemy.force=d3.layout.force().size([b.graphWidth(),b.graphHeight()]).nodes(_.map(alchemy._nodes,function(a){return a._d3})).links(_.flatten(_.map(alchemy._edges,function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b._d3);return e}))),alchemy.force.charge(alchemy.layout.charge()).linkDistance(function(a){return alchemy.layout.linkDistancefn(a)}).theta(1).gravity(alchemy.layout.gravity()).linkStrength(function(a){return alchemy.layout.linkStrength(a)}).friction(alchemy.layout.friction()).chargeDistance(alchemy.layout.chargeDistance())},alchemy.search={init:function(){var a;return a=alchemy.dash.select("#search input"),a.on("keyup",function(){var b;return b=a[0][0].value.toLowerCase(),alchemy.vis.selectAll(".node").classed("inactive",!1),alchemy.vis.selectAll("text").attr("style",function(){return""!==b?"display: inline;":void 0}),alchemy.vis.selectAll(".node").classed("inactive",function(a){var c,d;switch(c=d3.select(this).text(),alchemy.conf.searchMethod){case"contains":d=c.toLowerCase().indexOf(b)<0;break;case"begins":d=0!==c.toLowerCase().indexOf(b)}return d?alchemy.vis.selectAll("[source-target*='"+a.id+"']").classed("inactive",d):alchemy.vis.selectAll("[source-target*='"+a.id+"']").classed("inactive",function(a){var b,c,d;return b=[a.source.id,a.target.id],c=alchemy.vis.select("#node-"+b[0]).classed("inactive"),d=alchemy.vis.select("#node-"+b[1]).classed("inactive"),d||c}),d})})}},alchemy.startGraph=function(a){return function(b){var c,d,e,f,g,h,i,j,k,l;for(d=alchemy.conf,d3.select(d.divSelector).empty()&&console.warn(alchemy.utils.warnings.divWarning()),b||alchemy.utils.warnings.dataWarning(),alchemy.create.nodes.apply(a,b.nodes),b.edges.forEach(function(a){return alchemy.create.edges(a)}),alchemy.vis=d3.select(d.divSelector).attr("style","width:"+d.graphWidth()+"px; height:"+d.graphHeight()+"px; background:"+d.backgroundColour).append("svg").attr("xmlns","http://www.w3.org/2000/svg").attr("xlink","http://www.w3.org/1999/xlink").attr("pointer-events","all").on("click",alchemy.interactions.deselectAll).call(alchemy.interactions.zoom(d.scaleExtent)).on("dblclick.zoom",null).append("g").attr("transform","translate("+d.initialTranslate+") scale("+d.initialScale+")"),alchemy.generateLayout(),alchemy.controlDash.init(),e=_.flatten(_.map(alchemy._edges,function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b._d3);return e})),f=_.map(alchemy._nodes,function(a){return a._d3}),alchemy.layout.positionRootNodes(),alchemy.force.start();alchemy.force.alpha()>.005;)alchemy.force.tick();return alchemy._drawEdges=alchemy.drawing.DrawEdges,alchemy._drawEdges.createEdge(e),alchemy._drawNodes=alchemy.drawing.DrawNodes,alchemy._drawNodes.createNode(f),j=!0,console.log(Date()+" completed initial computation"),l=alchemy.vis.selectAll("g.node").attr("transform",function(a){return"translate("+a.x+", "+a.y+")"}),d.forceLocked||alchemy.force.on("tick",alchemy.layout.tick).start(),null!=d.afterLoad&&("function"==typeof d.afterLoad?d.afterLoad():"string"==typeof d.afterLoad&&(alchemy[d.afterLoad]=!0)),d.initialScale!==alchemy.defaults.initialScale?void alchemy.interactions.zoom().scale(d.initialScale):d.initialTranslate!==alchemy.defaults.initialTranslate?void alchemy.interactions.zoom().translate(d.initialTranslate):((d.cluster||d.directedEdges)&&(g=d3.select(""+alchemy.conf.divSelector+" svg").append("svg:defs")),d.directedEdges&&(c=d.edgeArrowSize+2*d.edgeWidth(),k=g.append("svg:marker").attr("id","arrow").attr("viewBox","0 -"+.4*c+" "+c+" "+c).attr("markerUnits","userSpaceOnUse").attr("markerWidth",c).attr("markerHeight",c).attr("orient","auto"),k.append("svg:path").attr("d","M "+c+",0 L 0,"+.4*c+" L 0,-"+.4*c),d.curvedEdges?k.attr("refX",c+1):k.attr("refX",1)),d.showEditor?(h=new alchemy.editor.Editor,i=new alchemy.editor.Interactions,d3.select("body").on("keydown",i.deleteSelected),h.startEditor()):void 0)}}(this),alchemy.stats={init:function(){return alchemy.stats.update()},nodeStats:function(){var a,b,c,d,e,f,g,h,i,j,k,l;if(g="",f=alchemy.vis.selectAll(".node")[0].length,a=alchemy.vis.selectAll(".node.active")[0].length,c=alchemy.vis.selectAll(".node.inactive")[0].length,g+="
      • Number of nodes: "+f+"
      • ",g+="
      • Number of active nodes: "+a+"
      • ",g+="
      • Number of inactive nodes: "+c+"
      • ",alchemy.conf.nodeTypes){for(e=Object.keys(alchemy.conf.nodeTypes),i="",l=alchemy.conf.nodeTypes[e],j=0,k=l.length;k>j;j++)h=l[j],b=h.replace("_"," "),f=alchemy.vis.selectAll("g.node."+h)[0].length,i+="
      • Number of nodes of type "+b+": "+f+"
      • ";g+=i}return d="
      • ",g+=d,alchemy.dash.select("#node-stats").html(g)},edgeStats:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;if(d=null,f=alchemy.vis.selectAll(".edge")[0].length,a=alchemy.vis.selectAll(".edge.active")[0].length,h=alchemy.vis.selectAll(".edge.inactive")[0].length,e="
      • Number of relationships: "+f+"
      • Number of active relationships: "+a+"
      • Number of inactive relationships: "+h+"
      • ",alchemy.conf.edgeTypes){for(d=[],m=alchemy.vis.selectAll(".edge")[0],i=0,k=m.length;k>i;i++)c=m[i],alchemy.currentRelationshipTypes[[c].caption]=!0;for(n=alchemy.conf.edgeTypes,j=0,l=n.length;l>j;j++)g=n[j],g&&(b=g.replace("_"," "),f=alchemy.vis.selectAll(".edge."+g)[0].length,d.push([""+b,f]))}return alchemy.dash.select("#rel-stats").html(e),alchemy.stats.insertSVG("edge",d),d},nodeStats:function(){var a,b,c,d,e,f,g,h,i,j,k;if(c=null,h=alchemy.vis.selectAll(".node")[0].length,a=alchemy.vis.selectAll(".node.active")[0].length,b=alchemy.vis.selectAll(".node.inactive")[0].length,alchemy.conf.nodeTypes)for(c=[],e=Object.keys(alchemy.conf.nodeTypes),k=alchemy.conf.nodeTypes[e],i=0,j=k.length;j>i;i++)g=k[i],f=alchemy.vis.selectAll("g.node."+g)[0].length,c.push([""+g,f]);return d="
      • Number of nodes: "+h+"
      • Number of active nodes: "+a+"
      • Number of inactive nodes: "+b+"
      • ",alchemy.dash.select("#node-stats").html(d),alchemy.stats.insertSVG("node",c),c},insertSVG:function(a,b){var c,d,e,f,g,h,i,j;return null===b?alchemy.dash.select("#"+a+"-stats-graph").html("

        There are no "+a+"Types listed in your conf.

        "):(j=.25*alchemy.conf.graphWidth(),f=250,h=j/4,e=d3.scale.category20(),c=d3.svg.arc().outerRadius(h-10).innerRadius(h/2),g=d3.layout.pie().sort(null).value(function(a){return a[1]}),i=alchemy.dash.select("#"+a+"-stats-graph").append("svg").append("g").style({width:j,height:f}).attr("transform","translate("+j/2+","+f/2+")"),d=i.selectAll(".arc").data(g(b)).enter().append("g").classed("arc",!0).on("mouseover",function(a,c){return alchemy.dash.select("#"+b[c][0]+"-stat").classed("hidden",!1)}).on("mouseout",function(a,c){return alchemy.dash.select("#"+b[c][0]+"-stat").classed("hidden",!0)}),d.append("path").attr("d",c).attr("stroke",function(a,b){return e(b)}).attr("stroke-width",2).attr("fill-opacity","0.3"),d.append("text").attr("transform",function(a){return"translate("+c.centroid(a)+")"}).attr("id",function(a,c){return""+b[c][0]+"-stat"}).attr("dy",".35em").classed("hidden",!0).text(function(a,c){return b[c][0]}))},update:function(){return alchemy.conf.nodeStats&&alchemy.stats.nodeStats(),alchemy.conf.edgeStats?alchemy.stats.edgeStats():void 0}},alchemy.defaults={renderer:"svg",graphWidth:function(){return d3.select(this.divSelector).node().parentElement.clientWidth},graphHeight:function(){return"BODY"===d3.select(this.divSelector).node().parentElement.nodeName?window.innerHeight:d3.select(this.divSelector).node().parentElement.clientHeight},alpha:.5,collisionDetection:!0,nodeOverlap:25,fixNodes:!1,fixRootNodes:!1,forceLocked:!0,linkDistancefn:"default",nodePositions:null,showEditor:!1,captionToggle:!1,toggleRootNodes:!1,removeElement:!1,cluster:!1,clusterKey:"cluster",clusterColours:d3.shuffle(["#DD79FF","#FFFC00","#00FF30","#5168FF","#00C0FF","#FF004B","#00CDCD","#f83f00","#f800df","#ff8d8f","#ffcd00","#184fff","#ff7e00"]),clusterControl:!1,nodeStats:!1,edgeStats:!1,edgeFilters:!1,nodeFilters:!1,edgesToggle:!1,nodesToggle:!1,zoomControls:!1,nodeCaption:"caption",nodeCaptionsOnByDefault:!1,nodeStyle:{all:{radius:10,color:"#68B9FE",borderColor:"#127DC1",borderWidth:function(a,b){return b/3 -},captionColor:"#FFFFFF",captionBackground:null,captionSize:12,selected:{color:"#FFFFFF",borderColor:"#349FE3"},highlighted:{color:"#EEEEFF"},hidden:{color:"none",borderColor:"none"}}},nodeColour:null,nodeMouseOver:"caption",nodeRadius:10,nodeTypes:null,rootNodes:"root",rootNodeRadius:15,edgeCaption:"caption",edgeCaptionsOnByDefault:!1,edgeClick:"default",edgeStyle:{all:{width:4,color:"#CCC",opacity:.2,directed:!0,curved:!0,selected:{opacity:1},highlighted:{opacity:1},hidden:{opacity:0}}},edgeTypes:null,curvedEdges:!1,edgeWidth:function(){return 4},edgeOverlayWidth:20,directedEdges:!1,edgeArrowSize:5,search:!1,searchMethod:"contains",backgroundColour:"#000000",theme:null,afterLoad:"afterLoad",divSelector:"#alchemy",dataSource:null,initialScale:1,initialTranslate:[0,0],scaleExtent:[.5,2.4],dataWarning:"default",warningMessage:"There be no data! What's going on?"},alchemy.drawing.DrawEdge={createLink:function(){return function(a){var b,c,d,e,f;return b=alchemy.conf,c=b.curvedEdges,d=b.directedEdges,e=alchemy.interactions,f=alchemy.drawing.EdgeUtils,a.append("path").attr("class","edge-line").attr("id",function(a){return"path-"+a.id}),a.filter(function(a){return null!=a.caption}).append("text"),a.append("path").attr("class","edge-handler").style("stroke-width",""+b.edgeOverlayWidth)}}(this),styleLink:function(){return function(a){var b,c,d;return b=alchemy.conf,c=b.directedEdges,d=alchemy.drawing.EdgeUtils,a.each(function(a){var c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;return i=d.edgeWalk(a),k=d3.select(this),k.style(d.edgeStyle(a)),b.curvedEdges||k.attr("transform","translate("+i.startEdgeX+", "+i.startEdgeY+") rotate("+i.edgeAngle+")"),k.select(".edge-line").attr("d",b.curvedEdges?(c=d.edgeAngle(a),p=Math.abs(c)>90?-1:1,o=function(a){return 0===a?0:0>a?-1:1}(c),s=d.startLine(a),j=d.endLine(a),q=s.x,r=s.y,t=j.x,u=j.y,g=t-q,h=u-r,l=Math.sqrt(g*g+h*h),m=(g*alchemy.conf.nodeRadius+2)/l,n=(h*alchemy.conf.nodeRadius+2)/l,e=-o*b.edgeArrowSize+m,f=p*b.edgeArrowSize+n,"M "+(q-m)+","+(r-n)+" A "+l+", "+l+" "+d.edgeAngle(a)+" 0, 1 "+(t-e)+", "+(u-f)):b.directedEdges?"M "+i.startPathX+" "+i.startPathBottomY+"\nL "+i.arrowBendX+" "+i.arrowBendBottomY+"\nL "+i.arrowBendX+" "+i.arrowTipBottomY+"\nL "+i.arrowEndX+" "+i.arrowEndY+" \nL "+i.arrowBendX+" "+i.arrowTipTopY+" \nL "+i.arrowBendX+" "+i.arrowBendTopY+"\nL "+i.startPathX+" "+i.startPathTopY+"\nZ":"M "+i.startPathX+" "+i.startPathBottomY+"\nL "+i.arrowEndX+" "+i.arrowBendBottomY+"\nL "+i.arrowEndX+" "+i.arrowBendTopY+"\nL "+i.startPathX+" "+i.startPathTopY+"\nZ"),k.select(".edge-handler").attr("d",function(){return k.select(".edge-line").attr("d")})})}}(this),classEdge:function(){return function(a){return a.classed("active",!0)}}(this),styleText:function(){return function(a){var b,c,d,e;return b=alchemy.conf,c=b.curvedEdges,d=b.directedEdges,e=alchemy.drawing.EdgeUtils,a.select("text").each(c?function(a){var c;return c=e.edgeWalk(a),d3.select(this).attr("dx",function(a){return e.middlePath(a).x}).attr("dy",function(a){return e.middlePath(a).y+20}).attr("transform","rotate("+e.captionAngle(a)+")").text(a.caption).style("display",function(){return b.edgeCaptionsOnByDefault?"block":void 0})}:function(a){var c,d,f;return f=e.edgeWalk(a),c=e.captionAngle(a),d=180===c?-f.edgeLength/2:f.edgeLength/2,d3.select(this).attr("dx",""+d).attr("dy",""+1.1*-a["stroke-width"]).attr("transform","rotate("+c+")").text(a.caption).style("display",function(){return b.edgeCaptionsOnByDefault?"block":void 0})})}}(this),setInteractions:function(){return function(a){var b,c,d;return d=alchemy.interactions,b="editor"===alchemy.get.state("interactions"),b?(c=new alchemy.editor.Interactions,a.select(".edge-handler").on("click",c.edgeClick)):a.select(".edge-handler").on("click",d.edgeClick).on("mouseover",function(a){return d.edgeMouseOver(a)}).on("mouseout",function(a){return d.edgeMouseOut(a)})}}(this)},alchemy.drawing.DrawEdges={createEdge:function(a){var b,c;return b=alchemy.drawing.DrawEdge,c=alchemy.vis.selectAll("g.edge").data(a),c.enter().append("g").attr("id",function(a){return"edge-"+a.id+"-"+a.pos}).attr("class",function(a){return"edge "+a.edgeType}).attr("source-target",function(a){return""+a.source.id+"-"+a.target.id}),b.createLink(c),b.classEdge(c),b.styleLink(c),b.styleText(c),b.setInteractions(c),c.exit().remove(),alchemy.conf.directedEdges&&alchemy.conf.curvedEdges?c.select(".edge-line").attr("marker-end","url(#arrow)"):void 0},updateEdge:function(a){var b,c;return b=alchemy.drawing.DrawEdge,c=alchemy.vis.select("#edge-"+a.id+"-"+a.pos),b.classEdge(c),b.styleLink(c),b.styleText(c),b.setInteractions(c)}},alchemy.drawing.DrawNode={styleText:function(a){var b,c,d;return b=alchemy.conf,d=alchemy.drawing.NodeUtils,c=alchemy._nodes,a.selectAll("text").attr("dy",function(a){return c[a.id].getProperties().root?b.rootNodeRadius/2:2*b.nodeRadius-5}).html(function(a){return d.nodeText(a)}).style("display",function(){return b.nodeCaptionsOnByDefault?"block":void 0})},createNode:function(a){return a.append("circle").attr("id",function(a){return"circle-"+a.id}),a.append("svg:text").attr("id",function(a){return"text-"+a.id})},styleNode:function(a){var b;return b=alchemy.drawing.NodeUtils,a.selectAll("circle").attr("r",function(a){return"function"==typeof a.radius?a.radius():a.radius}).attr("shape-rendering","optimizeSpeed").each(function(a){return d3.select(this).style(b.nodeStyle(a))})},setInteractions:function(a){var b,c,d,e,f,g,h;return b=alchemy.conf,c=alchemy.interactions,e="editor"===alchemy.get.state("interactions"),d=d3.behavior.drag().origin(Object).on("dragstart",null).on("drag",null).on("dragend",null),e?(f=new alchemy.editor.Interactions,a.on("mouseup",function(a){return f.nodeMouseUp(a)}).on("mouseover",function(a){return f.nodeMouseOver(a)}).on("mouseout",function(a){return f.nodeMouseOut(a)}).on("dblclick",function(a){return c.nodeDoubleClick(a)}).on("click",function(a){return f.nodeClick(a)})):(a.on("mouseup",null).on("mouseover",function(a){return c.nodeMouseOver(a)}).on("mouseout",function(a){return c.nodeMouseOut(a)}).on("dblclick",function(a){return c.nodeDoubleClick(a)}).on("click",function(a){return c.nodeClick(a)}),d=d3.behavior.drag().origin(Object).on("dragstart",c.nodeDragStarted).on("drag",c.nodeDragged).on("dragend",c.nodeDragended),b.fixNodes||(g=a.filter(function(a){return a.root!==!0}),g.call(d)),b.fixRootNodes?void 0:(h=a.filter(function(a){return a.root===!0}),h.call(d)))}},alchemy.drawing.DrawNodes={createNode:function(a){var b,c;return b=alchemy.drawing.DrawNode,c=alchemy.vis.selectAll("g.node").data(a,function(a){return a.id}),c.enter().append("g").attr("class",function(a){var b;return b=alchemy._nodes[a.id]._nodeType,"node "+b+" active"}).attr("id",function(a){return"node-"+a.id}).classed("root",function(a){return a.root}),b.createNode(c),b.styleNode(c),b.styleText(c),b.setInteractions(c),c.exit().remove()},updateNode:function(a){var b,c;return b=alchemy.drawing.DrawNode,c=alchemy.vis.select("#node-"+a.id),b.styleNode(c),b.styleText(c),b.setInteractions(c)}},alchemy.drawing.EdgeUtils={edgeStyle:function(a){var b,c,d,e;return c=alchemy._edges[a.id][a.pos],e=alchemy.svgStyles.edge.update(c),d=alchemy._nodes,alchemy.conf.cluster&&(b=alchemy.layout._clustering,e.stroke=function(a){var c,e,f,g,h,i;return d=alchemy._nodes,c=alchemy.conf.clusterKey,h=d[a.source.id]._properties,i=d[a.target.id]._properties,h.root||i.root?(g=h.root?i[c]:h[c],""+b.getClusterColour(g)):h[c]===i[c]?(g=h[c],""+b.getClusterColour(g)):h[c]!==i[c]?(f=""+h[c]+"-"+i[c],e="cluster-gradient-"+f,"url(#"+e+")"):void 0}(a)),e},triangle:function(a){var b,c;return c=a.target.x-a.source.x,b=a.target.y-a.source.y,{width:c,height:b,hyp:Math.sqrt(b*b+c*c)}},edgeWalk:function(a){var b,c,d,e,f,g,h,i,j,k;return c=alchemy.conf.edgeArrowSize,b=.3,j=this.triangle(a),k=j.width,g=j.height,h=j.hyp,f=a["stroke-width"],d=2,i=0+a.source.radius+a.source["stroke-width"]-f/2+d,e=h-i-1.5*d,{edgeAngle:Math.atan2(g,k)/Math.PI*180,startEdgeX:a.source.x,startEdgeY:a.source.y,midLineX:a.source.x+k/2,midLineY:a.source.x+g/2,endLineX:a.source.x+k/h,endLineY:a.source.x+g/h,startPathX:i,startPathBottomY:f/2,arrowBendX:e-c,arrowBendBottomY:f/2,arrowTipBottomY:f/2+c*b,arrowEndX:e,arrowEndY:0,arrowTipTopY:-(c*b+f/2),arrowBendTopY:-f/2,startPathTopY:-f/2,edgeLength:e}},curvedDirectedEdgeWalk:function(a,b){var c,d,e,f,g,h;return c=alchemy.conf,h=a.target.x-a.source.x,e=a.target.y-a.source.y,f=Math.sqrt(e*e+h*h),g="middle"===b?(d=f/2,{x:a.source.x+h*d/f,y:a.source.y+e*d/f}):"linkStart"===b?(d=a.source.radius+a.source["stroke-width"],{x:a.source.x+h*d/f,y:a.source.y+e*d/f}):"linkEnd"===b?(d=c.curvedEdges?f:f-(a.target.radius+a.target["stroke-width"]),c.directedEdges?d-=c.edgeArrowSize:void 0,{x:a.source.x+h*d/f,y:a.source.y+e*d/f}):void 0},middleLine:function(a){return this.curvedDirectedEdgeWalk(a,"middle")},startLine:function(a){return this.curvedDirectedEdgeWalk(a,"linkStart")},endLine:function(a){return this.curvedDirectedEdgeWalk(a,"linkEnd")},edgeLength:function(a){var b,c,d;return d=a.target.x-a.source.x,b=a.target.y-a.source.y,c=Math.sqrt(b*b+d*d)},edgeAngle:function(a){var b,c;return c=a.target.x-a.source.x,b=a.target.y-a.source.y,Math.atan2(b,c)/Math.PI*180},captionAngle:function(a){return-90>a||a>90?180:0},middlePath:function(a){var b,c;return c=alchemy.vis.select("#path-"+a.id).node(),b=c.getPointAtLength(c.getTotalLength()/2),{x:b.x,y:b.y}},middlePathCurve:function(a){var b,c;return c=d3.select("#path-"+a.id).node(),b=c.getPointAtLength(c.getTotalLength()/2),{x:b.x,y:b.y}}},alchemy.drawing.NodeUtils={nodeStyle:function(a){var b,c;return b=alchemy.conf,c=b.cluster?function(a){var c,d,e,f,g,h,i;return d=alchemy.layout._clustering,i=alchemy._nodes[a.id].getProperties(),c=d.clusterMap,h=alchemy.conf.clusterKey,g=b.clusterColours,f=c[i[h]]%g.length,e=g[f],""+e}(a):function(){return b.nodeColour?b.nodeColour:""},a},nodeText:function(a){var b,c,d;return c=alchemy.conf,d=alchemy._nodes[a.id]._properties,c.nodeCaption&&"string"==typeof c.nodeCaption?null!=d[c.nodeCaption]?d[c.nodeCaption]:"":c.nodeCaption&&"function"==typeof c.nodeCaption?(b=c.nodeCaption(d),(void 0===b||"undefined"===String(b))&&(alchemy.log.caption="At least one caption returned undefined",c.caption=!1),b):void 0}},alchemy.svgStyles={node:{populate:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;return b=alchemy.conf,d=_.omit(b.nodeStyle.all,"selected","highlighted","hidden"),c=a,m=function(a){return"function"==typeof a?a:function(){return a}},g=_.keys(b.nodeTypes)[0],f=a.getProperties()[g],void 0===b.nodeStyle[f]&&(f="all"),n=_.assign(_.cloneDeep(d),b.nodeStyle[f]),k=_.assign(n,b.nodeStyle[f][a._state]),h=m(k.radius),e=m(k.color),i=m(k.borderColor),j=m(k.borderWidth),l={radius:h(c),fill:e(c),stroke:i(c),"stroke-width":j(c,h(c))}}},edge:{populate:function(a){var b,c,d,e,f,g,h,i,j,k;return c=alchemy.conf,d=_.omit(c.edgeStyle.all,"selected","highlighted","hidden"),i=function(a){return"function"==typeof a?a:function(){return a}},e=a._edgeType,void 0===c.edgeStyle[e]&&(e="all"),j=_.assign(_.cloneDeep(d),c.edgeStyle[e]),g=_.assign(j,c.edgeStyle[e][a._state]),k=i(g.width),b=i(g.color),f=i(g.opacity),h={stroke:b(a),"stroke-width":k(a),opacity:f(a),fill:"none"}},update:function(a){var b,c,d,e,f,g,h;return c=alchemy.conf,e=a._style,g=function(a){return"function"==typeof a?a:function(){return a}},h=g(e.width),b=g(e.color),d=g(e.opacity),f={stroke:b(a),"stroke-width":h(a),opacity:d(a),fill:"none"}}}},alchemy.editor.Editor=function(){function a(){this.nodeEditor=c(this.nodeEditor,this),this.startEditor=c(this.startEditor,this),this.utils=new alchemy.editor.Utils}return a.prototype.editorContainerHTML='
        \n

        Editor

        \n
        \n
        \n
          \n
        • Remove Selected
        • \n
        • Editor mode enabled, click to disable editor interactions
        • \n
        \n
        ',a.prototype.elementEditorHTML=function(a){return"

        "+a+' Editor

        \n
        \n
        \n \n \n
        \n \n
        \n
        \n \n
        '},a.prototype.startEditor=function(){var a,b,c,d,e;return a=alchemy.conf.divSelector,d=this.editorContainerHTML,b=alchemy.dash.select("#control-dash").append("div").attr("id","editor").html(d),b.select("#editor-header").on("click",function(){return alchemy.dash.select("#element-options").classed("in")?alchemy.dash.select("#editor-header>span").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#editor-header>span").attr("class","fa fa-2x fa-caret-down")}),c=b.select("#element-options ul #editor-interactions").on("click",function(){return d3.select(this).attr("class",function(){return"editor"===alchemy.get.state()?(alchemy.set.state("interactions","default"),"inactive list-group-item"):(alchemy.set.state("interactions","editor"),"active list-group-item")}).html(function(){return"editor"===alchemy.get.state()?"Disable Editor Interactions":"Enable Editor Interactions"})}),b.select("#element-options ul #remove").on("click",function(){return alchemy.editor.remove()}),e=this.utils,c.on("click",function(){return alchemy.dash.select("#editor-interactions").classed("active")?(e.disableEditor(),alchemy.dash.select("#editor-interactions").classed({active:!1,inactive:!0}).html("Editor mode disabled, click to enable editor interactions")):(e.enableEditor(),alchemy.dash.select("#editor-interactions").classed({active:!0,inactive:!1}).html("Editor mode enabled, click to disable editor interactions"))})},a.prototype.nodeEditor=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;c=alchemy.conf.divSelector,d=alchemy.dash.select("#control-dash #editor"),i=d.select("#element-options"),f=this.elementEditorHTML("Node"),e=i.append("div").attr("id","node-editor").html(f),e.attr("class",function(){var a;return a=alchemy.dash.select("#editor-interactions").classed("active"),a?"enabled":"hidden"}),b=d.select("#node-editor form #add-property"),b.select("#node-add-prop-key").attr("placeholder","New Property Name").attr("value",null),b.select("#node-add-prop-value").attr("placeholder","New Property Value").attr("value",null),alchemy.dash.select("#add-property-form").on("submit",function(){var a,b;return event.preventDefault(),a=alchemy.dash.select("#add-prop-key").property("value"),a=a.replace(/\s/g,"_"),b=alchemy.dash.select("#add-prop-value").property("value"),l(a,b,!0),alchemy.dash.selectAll("#add-property .edited-property").classed({"edited-property":!1}),this.reset()}),g=alchemy._nodes[a.id].getProperties(),alchemy.vis.select("#node-"+a.id).classed({editing:!0}),k=d.select("#node-editor #properties-list");for(j in g)m=g[j],h=k.append("div").attr("id","node-"+j).attr("class","property form-inline form-group"),h.append("label").attr("for","node-"+j+"-input").attr("class","form-control property-name").text(""+j),h.append("input").attr("id","node-"+j+"-input").attr("class","form-control property-value").attr("value",""+m);return alchemy.dash.select("#properties-list").on("submit",function(){var a,b,c,d,e,f,g;for(event.preventDefault(),b=alchemy.dash.selectAll(".edited-property"),g=b[0],e=0,f=g.length;f>e;e++)j=g[e],c=alchemy.dash.select(j),a=c.select("label").text(),d=c.select("input").attr("value"),l(a,d,!1);return alchemy.dash.selectAll("#node-properties-list .edited-property").classed({"edited-property":!1}),this.reset()}),d3.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown",function(){return 13===d3.event.keyCode&&event.preventDefault(),d3.select(this).classed({"edited-property":!0})}),l=function(b,c,d){var e,f;return f=a.id,""!==b&&""!==c?(alchemy._nodes[f].setProperty(""+b,""+c),e=alchemy._drawNodes,e.updateNode(alchemy.viz.select("#node-"+f)),d===!0?(alchemy.dash.select("#node-add-prop-key").attr("value","property added/updated to key: "+b),alchemy.dash.select("#node-add-prop-value").attr("value","property at "+b+" updated to: "+c)):alchemy.dash.select("#node-"+b+"-input").attr("value","property at "+b+" updated to: "+c)):d===!0?(alchemy.dash.select("#node-add-prop-key").attr("value","null or invalid input"),alchemy.dash.select("#node-add-prop-value").attr("value","null or invlid input")):alchemy.dash.select("#node-"+b+"-input").attr("value","null or invalid input")}},a.prototype.editorClear=function(){return alchemy.dash.selectAll(".node").classed({editing:!1}),alchemy.dash.selectAll(".edge").classed({editing:!1}),alchemy.dash.select("#node-editor").remove(),alchemy.dash.select("#edge-editor").remove(),alchemy.dash.select("#node-add-prop-submit").attr("placeholder",function(){return alchemy.vis.selectAll(".selected").empty()?"select a node or edge to edit properties":"add a property to this element"})},a.prototype.edgeEditor=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;c=alchemy.conf.divSelector,f=alchemy.dash("#control-dash #editor"),i=f.select("#element-options"),h=this.elementEditorHTML("Edge"),g=i.append("div").attr("id","edge-editor").html(h),g.attr("class",function(){return alchemy.dash.select("#editor-interactions").classed("active")?"enabled":"hidden"}),b=f.select("#edge-editor form #add-property"),b.select("#add-prop-key").attr("placeholder","New Property Name").attr("value",null),b.select("#add-prop-value").attr("placeholder","New Property Value").attr("value",null),d=alchemy._edges[a.id].getProperties(),alchemy.vis.select("#edge-"+a.id).classed({editing:!0}),k=f.select("#edge-editor #properties-list");for(j in d)m=d[j],e=k.append("div").attr("id","edge-"+j).attr("class","property form-inline form-group"),e.append("label").attr("for","edge-"+j+"-input").attr("class","form-control property-name").text(""+j),e.append("input").attr("id","edge-"+j+"-input").attr("class","form-control property-value").attr("value",""+m);return alchemy.dash.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown",function(){return 13===d3.event.keyCode&&event.preventDefault(),d3.select(this).classed({"edited-property":!0})}),alchemy.dash.select("#add-property-form").on("submit",function(){var a,b;return event.preventDefault(),a=alchemy.dash.select("#add-prop-key").property("value"),a=a.replace(/\s/g,"_"),b=alchemy.dash.select("#add-prop-value").property("value"),l(a,b,!0),alchemy.dash.selectAll("#add-property .edited-property").classed({"edited-property":!1}),this.reset()}),d3.select("#properties-list").on("submit",function(){var a,b,c,d,e,f,g;for(event.preventDefault(),b=alchemy.dash.selectAll(".edited-property"),g=b[0],e=0,f=g.length;f>e;e++)j=g[e],c=alchemy.dash.select(j),a=c.select("label").text(),d=c.select("input").property("value"),l(a,d,!1);return alchemy.dash.selectAll("#properties-list .edited-property").classed({"edited-property":!1}),this.reset()}),l=function(b,c,d){var e,f,g;return f=a.id,""!==b&&""!==c?(alchemy._edges[f].setProperty(""+b,""+c),g=alchemy.vis.select("#edge-"+f),e=new alchemy.drawing.DrawEdges,e.updateEdge(alchemy.vis.select("#edge-"+f)),d===!0?(alchemy.dash.select("#add-prop-key").attr("value","property added/updated to key: "+b),alchemy.dash.select("#add-prop-value").attr("value","property at "+b+" updated to: "+c)):alchemy.dash.select("#edge-"+b+"-input").attr("value","property at "+b+" updated to: "+c)):d===!0?(alchemy.dash.select("#add-prop-key").attr("value","null or invalid input"),alchemy.dash.select("#add-prop-value").attr("value","null or invlid input")):alchemy.dash.select("#edge-"+b+"-input").attr("value","null or invalid input")}},a}(),alchemy.editor.Interactions=function(){function a(){this.reset=c(this.reset,this),this.deleteSelected=c(this.deleteSelected,this),this.addNodeDragended=c(this.addNodeDragended,this),this.addNodeDragging=c(this.addNodeDragging,this),this.addNodeStart=c(this.addNodeStart,this),this.edgeClick=c(this.edgeClick,this),this.nodeClick=c(this.nodeClick,this),this.nodeMouseUp=c(this.nodeMouseUp,this),this.editor=new alchemy.editor.Editor}return a.prototype.nodeMouseOver=function(){var a;return d3.select(this).select("circle").empty()||(a=d3.select(this).select("circle").attr("r"),d3.select(this).select("circle").attr("r",3*a)),this},a.prototype.nodeMouseUp=function(a){return this.sourceNode!==a?(this.mouseUpNode=!0,this.targetNode=a,this.click=!1):this.click=!0,this},a.prototype.nodeMouseOut=function(){var a;return d3.select(this).select("circle").empty()||(a=d3.select(this).select("circle").attr("r"),d3.select(this).select("circle").attr("r",a/3)),this},a.prototype.nodeClick=function(a){var b;return d3.event.stopPropagation(),alchemy.vis.select("#node-"+a.id).empty()||(b=alchemy.vis.select("#node-"+a.id).classed("selected"),alchemy.vis.select("#node-"+a.id).classed("selected",!b)),this.editor.editorClear(),this.editor.nodeEditor(a)},a.prototype.edgeClick=function(a){return d3.event.stopPropagation(),this.editor.editorClear(),this.editor.edgeEditor(a)},a.prototype.addNodeStart=function(a){return d3.event.sourceEvent.stopPropagation(),this.sourceNode=a,alchemy.vis.select("#dragline").classed({hidden:!1}),this},a.prototype.addNodeDragging=function(){var a,b;return a=d3.event.x,b=d3.event.y,alchemy.vis.select("#dragline").attr("x1",this.sourceNode.x).attr("y1",this.sourceNode.y).attr("x2",a).attr("y2",b).attr("style","stroke: #FFF"),this},a.prototype.addNodeDragended=function(){var a,b,c;return this.click||(this.mouseUpNode||(a=alchemy.vis.select("#dragline"),b=a.attr("x2"),c=a.attr("y2"),this.targetNode={id:""+_.uniqueId("addedNode_"),x:parseFloat(b),y:parseFloat(c),caption:"node added"}),this.newEdge={id:""+this.sourceNode.id+"-"+this.targetNode.id,source:this.sourceNode.id,target:this.targetNode.id,caption:"edited"},alchemy.editor.update(this.targetNode,this.newEdge)),this.reset(),this},a.prototype.deleteSelected=function(){switch(d3.event.keyCode){case 8:case 46:if("INPUT"!==d3.select(d3.event.target).node().tagName)return d3.event.preventDefault(),alchemy.editor.remove()}},a.prototype.reset=function(){return this.mouseUpNode=null,this.sourceNode=null,this.targetNode=null,this.newEdge=null,this.click=null,alchemy.vis.select("#dragline").classed({hidden:!0}).attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",0),this},a}(),alchemy.editor.Utils=function(){function a(){this.enableEditor=c(this.enableEditor,this),this.drawNodes=alchemy._drawNodes,this.drawEdges=alchemy._drawEdges}return a.prototype.enableEditor=function(){var a,b,c;return alchemy.set.state("interactions","editor"),a=alchemy.vis.append("line").attr("id","dragline"),this.drawNodes.updateNode(alchemy.node),this.drawEdges.updateEdge(alchemy.edge),c=alchemy.vis.selectAll(".selected"),b=new alchemy.editor.Editor,c.empty()||1!==c.length?c.classed({selected:!1}):c.classed("node")?(b.nodeEditor(c.datum()),alchemy.dash.select("#node-editor").attr("class","enabled").style("opacity",1)):c.classed("edge")?(b.edgeEditor(c.datum()),alchemy.dash.select("#edge-editor").attr("class","enabled").style("opacity",1)):void 0},a.prototype.disableEditor=function(){return alchemy.setState("interactions","default"),alchemy.vis.select("#dragline").remove(),alchemy.dash.select("#node-editor").transition().duration(300).style("opacity",0),alchemy.dash.select("#node-editor").transition().delay(300).attr("class","hidden"),this.drawNodes.updateNode(alchemy.node),alchemy.vis.selectAll(".node").classed({selected:!1})},a.prototype.remove=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(e=alchemy.vis.selectAll(".selected.node"),j=e[0],l=[],f=0,h=j.length;h>f;f++)if(b=j[f],c=alchemy.vis.select(b).data()[0].id,d=alchemy._nodes[c],null!=d){for(k=d.adjacentEdges,g=0,i=k.length;i>g;g++)a=k[g],alchemy._edges=_.omit(alchemy._edges,""+a),alchemy.edge=alchemy.edge.data(_.map(alchemy._edges,function(a){return a._d3}),function(a){return a.id}),alchemy.vis.select("#edge-"+a).remove();alchemy._nodes=_.omit(alchemy._nodes,""+c),alchemy.node=alchemy.node.data(_.map(alchemy._nodes,function(a){return a._d3}),function(a){return a.id}),alchemy.vis.select(b).remove(),l.push("editor"===alchemy.get.state("interactions")?alchemy.modifyElements.nodeEditorClear():void 0)}else l.push(void 0);return l},a.prototype.addNode=function(a){var b;return b=alchemy._nodes[a.id]=new alchemy.models.Node({id:""+a.id}),b.setProperty("caption",a.caption),b.setD3Property("x",a.x),b.setD3Property("y",a.y),alchemy.node=alchemy.node.data(_.map(alchemy._nodes,function(a){return a._d3}),function(a){return a.id})},a.prototype.addEdge=function(a){var b;return b=alchemy._edges[a.id]=new alchemy.models.Edge(a),alchemy.edge=alchemy.edge.data(_.map(alchemy._edges,function(a){return a._d3}),function(a){return a.id})},a.prototype.update=function(a,b){return this.mouseUpNode?(alchemy.editor.addEdge(b),this.drawEdges.createEdge(alchemy.edge)):(alchemy.editor.addNode(a),alchemy.editor.addEdge(b),this.drawEdges.createEdge(alchemy.edge),this.drawNodes.createNode(alchemy.node)),alchemy.layout.tick()},a}(),alchemy.models.Edge=function(){function a(a,b){var d,e;null==b&&(b=null),this.allNodesActive=c(this.allNodesActive,this),this.getStyles=c(this.getStyles,this),this.getProperties=c(this.getProperties,this),this.setProperties=c(this.setProperties,this),this._setCaption=c(this._setCaption,this),this._setID=c(this._setID,this),this._setD3Properties=c(this._setD3Properties,this),d=alchemy,e=d.conf,this.id=this._setID(a),this._index=b,this._state="active",this._properties=a,this._edgeType=this._setEdgeType(),this._style=null!=e.edgeStyle[this._edgeType]?_.merge(_.clone(e.edgeStyle.all),e.edgeStyle[this._edgeType]):_.clone(e.edgeStyle.all),this._d3=_.merge({id:this.id,pos:this._index,edgeType:this._edgeType,source:d._nodes[this._properties.source]._d3,target:d._nodes[this._properties.target]._d3},d.svgStyles.edge.populate(this)),this._setCaption(a,e),d._nodes[""+a.source]._addEdge(""+this.id+"-"+this._index),d._nodes[""+a.target]._addEdge(""+this.id+"-"+this._index)}return a.prototype._setD3Properties=function(a){return _.merge(this._d3,a)},a.prototype._setID=function(a){return null!=a.id?a.id:""+a.source+"-"+a.target},a.prototype._setCaption=function(a,b){var c,d;return c=b.edgeCaption,d=function(a){switch(typeof c){case"string":return a[c];case"function":return c(a)}}(a),d?this._d3.caption=d:void 0},a.prototype._setEdgeType=function(){var a,b,c;return a=alchemy.conf,a.edgeTypes&&(_.isPlainObject(a.edgeTypes)?(c=Object.keys(alchemy.conf.edgeTypes),b=this._properties[c]):"string"==typeof a.edgeTypes&&(b=this._properties[a.edgeTypes])),void 0===b&&(b="all"),this._setD3Properties("edgeType",b),b},a.prototype.setProperties=function(a,b){return null==b&&(b=null),_.isPlainObject(a)?(_.assign(this._properties,a),"source"in a&&this._setD3Properties({source:alchemy._nodes[a.source]._d3}),"target"in a&&this._setD3Properties({target:alchemy._nodes[a.target]._d3})):(this._properties[a]=b,("source"===a||"target"===a)&&this._setD3Properties({property:alchemy._nodes[b]._d3})),this},a.prototype.getProperties=function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[],null==a&&(a=null),null==a&&0===b.length?this._properties:0!==b.length?(c=_.union([a],b),_.pick(this._properties,c)):this._properties[a]},a.prototype.getStyles=function(a){return null==a&&(a=null),null!=a?this._style[a]:this._style},a.prototype.setStyles=function(a,b){return null==b&&(b=null),void 0===a&&(a=alchemy.svgStyles.edge.populate(this)),_.isPlainObject(a)?_.assign(this._style,a):"string"==typeof a&&(this._style[a]=b),this._setD3Properties(alchemy.svgStyles.edge.update(this)),alchemy._drawEdges.updateEdge(this._d3),this},a.prototype.toggleHidden=function(){return this._state="hidden"===this._state?"active":"hidden",this.setStyles()},a.prototype.allNodesActive=function(){var a,b;return a=alchemy.vis.select("#node-"+this.properties.source),b=alchemy.vis.select("#node-"+this.properties.target),!a.classed("inactive")&&!b.classed("inactive")},a}(),alchemy.models.Node=function(){function a(a){this.getStyles=c(this.getStyles,this),this.removeProperty=c(this.removeProperty,this),this.setProperty=c(this.setProperty,this),this.getProperties=c(this.getProperties,this),this._setD3Properties=c(this._setD3Properties,this),this._setNodeType=c(this._setNodeType,this);var b,d;b=alchemy,d=b.conf,this.id=a.id,this._properties=a,this._d3=_.merge({id:this.id,root:this._properties[d.rootNodes]},b.svgStyles.node.populate(this)),this._nodeType=this._setNodeType(),this._style=d.nodeStyle[this._nodeType]?d.nodeStyle[this._nodeType]:d.nodeStyle.all,this._state="active",this._adjacentEdges=[]}return a.prototype._setNodeType=function(){var a,b,c,d;return a=alchemy.conf,a.nodeTypes&&(_.isPlainObject(a.nodeTypes)?(b=Object.keys(alchemy.conf.nodeTypes),d=_.values(a.nodeTypes),c=this._properties[b]):"string"==typeof a.nodeTypes&&(c=this._properties[a.nodeTypes])),void 0===c&&(c="all"),this._setD3Properties("nodeType",c),c},a.prototype._setD3Properties=function(a){return _.merge(this._d3,a)},a.prototype._addEdge=function(a){return this._adjacentEdges=_.union(this._adjacentEdges,[a])},a.prototype.getProperties=function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[],null==a&&(a=null),null==a&&0===b.length?this._properties:0!==b.length?(c=_.union([a],b),_.pick(this._properties,c)):this._properties[a]},a.prototype.setProperty=function(a,b){return null==b&&(b=null),_.isPlainObject(a)?_.assign(this._properties,a):this._properties[a]=b,this},a.prototype.removeProperty=function(a){return null!=this._properties.property&&_.omit(this._properties,a),this},a.prototype.getStyles=function(a){return null==a&&(a=null),null!=a?this._style[a]:this._style},a.prototype.setStyles=function(a,b){return null==b&&(b=null),void 0===a?a=alchemy.svgStyles.node.populate(this):_.isPlainObject(a)?_.assign(this._style,a):this._style[a]=b,this._setD3Properties(alchemy.svgStyles.node.populate(this)),alchemy._drawNodes.updateNode(this._d3),this},a.prototype.toggleHidden=function(){return this._state="hidden"===this._state?"active":"hidden",this.setStyles(),_.each(this._adjacentEdges,function(a){var b,c,d,e;return e=a.split("-"),c=e[0],d=e[1],b=e[2],alchemy._edges[""+c+"-"+d][b].toggleHidden()})},a.prototype.outDegree=function(){return this._adjacentEdges.length},a}(),alchemy.themes={"default":{backgroundColour:"#000000",nodeStyle:{all:{radius:function(){return 10},color:function(){return"#68B9FE"},borderColor:function(){return"#127DC1"},borderWidth:function(a,b){return b/3},captionColor:function(){return"#FFFFFF"},captionBackground:function(){return null},captionSize:12,selected:{color:function(){return"#FFFFFF"},borderColor:function(){return"#349FE3"}},highlighted:{color:function(){return"#EEEEFF"}},hidden:{color:function(){return"none"},borderColor:function(){return"none"}}}},edgeStyle:{all:{width:4,color:"#CCC",opacity:.2,directed:!0,curved:!0,selected:{opacity:1},highlighted:{opacity:1},hidden:{opacity:0}}}},white:{backgroundColour:"#FFFFFF",nodeStyle:{all:{radius:function(){return 10},color:function(){return"#68B9FE"},borderColor:function(){return"#127DC1"},borderWidth:function(a,b){return b/3},captionColor:function(){return"#FFFFFF"},captionBackground:function(){return null},captionSize:12,selected:{color:function(){return"#FFFFFF"},borderColor:function(){return"38DD38"}},highlighted:{color:function(){return"#EEEEFF"}},hidden:{color:function(){return"none"},borderColor:function(){return"none"}}}},edgeStyle:{all:{width:4,color:"#333",opacity:.4,directed:!1,curved:!1,selected:{color:"#38DD38",opacity:.9},highlighted:{color:"#383838",opacity:.7},hidden:{opacity:0}}}}},alchemy.utils.warnings={dataWarning:function(){var a;return alchemy.conf.dataWarning&&"function"==typeof alchemy.conf.dataWarning?alchemy.conf.dataWarning():"default"===alchemy.conf.dataWarning?(a='',$("body").append(a),$("#no-results").modal("show")):void 0 +(function(){"Alchemy.js is a graph drawing application for the web.\nCopyright (C) 2014 GraphAlchemist, Inc.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see .\nlets";var a,b,c=function(a,b){return function(){return a.apply(b,arguments)}},d=[].slice;a=function(){function a(){this.allEdges=c(this.allEdges,this),this.allNodes=c(this.allNodes,this),this.getEdges=c(this.getEdges,this),this.getNodes=c(this.getNodes,this),this.begin=c(this.begin,this),this.version="0.3.1",this.layout={},this.interactions={},this.utils={},this.visControls={},this.styles={},this.models={},this.drawing={},this.editor={},this.log={},this.currentRelationshipTypes={},this.state={interactions:"default",layout:"default"},this._nodes={},this._edges={}}return a.prototype.begin=function(a){return this.setConf(a),"string"==typeof alchemy.conf.dataSource?d3.json(alchemy.conf.dataSource,alchemy.startGraph):"object"==typeof alchemy.conf.dataSource&&alchemy.startGraph(alchemy.conf.dataSource),this},a.prototype.setConf=function(a){var b,c;null!=a.theme&&_.merge(alchemy.defaults,alchemy.themes[""+a.theme]);for(b in a)c=a[b],"clusterColors"===b&&(a.clusterColours=c),"backgroundColor"===b&&(a.backgroundColour=c),"nodeColor"===b&&(a.nodeColour=c);return this.conf=_.merge(alchemy.defaults,a)},a.prototype.getNodes=function(){var a,b,c,e,f,g,h;if(a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[]){for(b.push(a),e=_.union(b),f=[],g=0,h=e.length;h>g;g++)c=e[g],f.push(alchemy._nodes[c].properties);return f}return[this._nodes[a].properties]},a.prototype.getEdges=function(a,b){var c,d,e;return null==a&&(a=null),null==b&&(b=null),null!=a&&null!=b?(d=""+a+"-"+b,c=this._edges[d],[c.properties]):null!=a&&null==b?(e=_.map(this._edges,function(b){return b.properties.source===a||b.properties.target===a?b.properties:void 0}),_.compact(e)):void 0},a.prototype.allNodes=function(){return _.map(this._nodes,function(a){return a.properties})},a.prototype.allEdges=function(){return _.map(this._edges,function(a){return a.properties})},a}(),b={},"undefined"!=typeof module&&module.exports?module.exports=new a:this.alchemy=new a,alchemy.create={nodes:function(){var a,b,c,e,f,g,h;if(b=arguments[0],c=2<=arguments.length?d.call(arguments,1):[],e=function(a){var b;return alchemy._nodes[a.id]?console.warn("A node with the id "+a.id+" already exists.\nConsider using the alchemy.get.nodes() method to \nretrieve the node and then using the Node methods."):(b=new alchemy.models.Node(a),alchemy._nodes[a.id]=b,[b])},0!==c.length){for(c.push(b),f=[],g=0,h=c.length;h>g;g++)a=c[g],e(a);return f}return e(b)},edges:function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[],c=function(a){var b,c;return a.id&&!alchemy._edges[a.id]?(b=new alchemy.models.Edge(a),alchemy._edges[a.id]=[b],[b]):a.id&&alchemy._edges[a.id]?console.warn("An edge with that id "+someEdgeMap.id+" already exists.\nConsider using the alchemy.get.edge() method to \nretrieve the edge and then using the Edge methods.\nNote: id's are not required for edges. Alchemy will create\nan unlimited number of edges for the same source and target node.\nSimply omit 'id' when creating the edge."):(c=alchemy._edges[""+a.source+"-"+a.target],c?(b=new alchemy.models.Edge(a,c.length),c.push(b),[b]):(b=new alchemy.models.Edge(a,0),alchemy._edges[""+a.source+"-"+a.target]=[b],[b]))},0!==b.length?console.warn("Make sure this function supports multiple arguments"):c(a)}},alchemy.get={nodes:function(){var a,b,c;return b=arguments[0],c=2<=arguments.length?d.call(arguments,1):[],null!=b?(a=_.map(arguments,function(a){return String(a)}),_.filter(alchemy._nodes,function(b,c){return _.contains(a,c)?b:void 0})):console.warn("Please specify a node id.")},edges:function(a,b){var c,d,e;return null==a&&(a=null),null==b&&(b=null),null!=a&&null!=b?(d=""+a+"-"+b,c=alchemy._edges[d],[c]):null!=a&&null==b?(null!=alchemy._edges[a]?[_.flatten(alchemy._edges[a])]:e=_.map(alchemy._edges,function(b){return b.properties.source===a||b.properties.target===a?b.properties:void 0}),_.compact(e)):void 0},allNodes:function(a){return null!=a?_.filter(alchemy._nodes,function(b){return b._nodeType===a?b:void 0}):_.map(alchemy._nodes,function(a){return a})},activeNodes:function(){return _.filter(alchemy._nodes,function(a){return"active"===a._state?a:void 0})},allEdges:function(){return _.flatten(_.map(alchemy._edges,function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b);return e}))},state:function(){return null!=alchemy.state.key?alchemy.state.key:void 0},clusters:function(){var a,b;return a=alchemy.layout._clustering.clusterMap,b={},_.each(a,function(a,c){return b[c]=_.select(alchemy.get.allNodes(),function(a){return a.getProperties()[alchemy.conf.clusterKey]===c})}),b},clusterColours:function(){var a,b;return b=alchemy.layout._clustering.clusterMap,a={},_.each(b,function(b,c){return a[c]=alchemy.conf.clusterColours[b%alchemy.conf.clusterColours.length]}),a}},alchemy.set={state:function(a,b){return alchemy.state.key=b}},alchemy.clustering=function(){function a(){var a,b,c,d,e,f,g,h;c=alchemy._nodes,b=alchemy.conf,a=this,this.clusterKey=b.clusterKey,this.identifyClusters(),d=-500,h=function(a){var b,d;return b=c[a.source.id]._properties[this.clusterKey],d=c[a.target.id]._properties[this.clusterKey],b===d?.15:0},e=function(){return.7},g=function(a){return c=alchemy._nodes,c[a.source.id]._properties.root||c[a.target.id]._properties.root?300:c[a.source.id]._properties[this.clusterKey]===c[a.target.id]._properties[this.clusterKey]?10:600},f=function(a){return 8*a},this.layout={charge:d,linkStrength:function(a){return h(a)},friction:function(){return e()},linkDistancefn:function(a){return g(a)},gravity:function(a){return f(a)}}}return a.prototype.identifyClusters=function(){var a,b,c;return b=alchemy.get.allNodes(),a=_.uniq(_.map(_.values(b),function(a){return a.getProperties()[alchemy.conf.clusterKey]})),this.clusterMap=_.zipObject(a,function(){c=[];for(var b=0,d=a.length;d>=0?d>=b:b>=d;d>=0?b++:b--)c.push(b);return c}.apply(this))},a.prototype.getClusterColour=function(a){var b;return b=this.clusterMap[a]%alchemy.conf.clusterColours.length,alchemy.conf.clusterColours[b]},a.prototype.edgeGradient=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o;for(c=alchemy.vis.select(""+alchemy.conf.divSelector+" svg"),b={},j=alchemy._nodes,n=_.map(a,function(a){return a._d3}),l=0,m=n.length;m>l;l++)if(d=n[l],!j[d.source.id]._properties.root&&!j[d.target.id]._properties.root&&j[d.source.id]._properties[this.clusterKey]!==j[d.target.id]._properties[this.clusterKey]&&j[d.target.id]._properties[this.clusterKey]!==j[d.source.id]._properties[this.clusterKey]){if(h=j[d.source.id]._properties[this.clusterKey]+"-"+j[d.target.id]._properties[this.clusterKey],h in b)continue;h in b||(k=this.getClusterColour(j[d.target.id]._properties[this.clusterKey]),e=this.getClusterColour(j[d.source.id]._properties[this.clusterKey]),b[h]={startColour:k,endColour:e})}o=[];for(i in b)g="cluster-gradient-"+i,f=c.append("svg:linearGradient").attr("id",g),f.append("svg:stop").attr("offset","0%").attr("stop-color",b[i].startColour),o.push(f.append("svg:stop").attr("offset","100%").attr("stop-color",b[i].endColour));return o},a}(),alchemy.clusterControls={init:function(){var a;return a="",alchemy.dash.select("#clustering-container").append("div").attr("id","cluster-key-container").attr("class","property form-inline form-group").html(a).style("display","none"),alchemy.dash.select("#cluster_control_header").on("click",function(){var a,b;return b=alchemy.dash.select("#cluster-key-container"),a=b.style("display")}),element.style("display",function(){return"block"===display?"none":"block"}),"none"===alchemy.dash.select("#cluster-key-container").style("display")?alchemy.dash.select("#cluster-arrow").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#cluster-arrow").attr("class","fa fa-2x fa-caret-down"),alchemy.dash.select("#cluster-key").on("keydown",function(){return"Enter"===d3.event.keyIdentifier?(alchemy.conf.cluster=!0,alchemy.conf.clusterKey=this.value,alchemy.generateLayout()):void 0})}},alchemy.controlDash={init:function(){var a;return this.dashIsShown()?(a=alchemy.conf.divSelector,alchemy.dash=d3.select(""+a).append("div").attr("id","control-dash-wrapper").attr("class","col-md-4 initial"),alchemy.dash.append("i").attr("id","dash-toggle").attr("class","fa fa-flask col-md-offset-12"),alchemy.dash.append("div").attr("id","control-dash").attr("class","col-md-12"),alchemy.dash.select("#dash-toggle").on("click",alchemy.interactions.toggleControlDash),alchemy.controlDash.zoomCtrl(),alchemy.controlDash.search(),alchemy.controlDash.filters(),alchemy.controlDash.stats(),alchemy.controlDash.clustering()):void 0},search:function(){return alchemy.conf.search?(alchemy.dash.select("#control-dash").append("div").attr("id","search").html("
        \n \n \n
        "),alchemy.search.init()):void 0},zoomCtrl:function(){return alchemy.conf.zoomControls?(alchemy.dash.select("#control-dash-wrapper").append("div").attr("id","zoom-controls").attr("class","col-md-offset-12").html(" "),alchemy.dash.select("#zoom-in").on("click",function(){return alchemy.interactions.clickZoom("in")}),alchemy.dash.select("#zoom-out").on("click",function(){return alchemy.interactions.clickZoom("out")}),alchemy.dash.select("#zoom-reset").on("click",function(){return alchemy.interactions.clickZoom("reset")})):void 0},filters:function(){return alchemy.conf.nodeFilters||alchemy.conf.edgeFilters?(alchemy.dash.select("#control-dash").append("div").attr("id","filters"),alchemy.filters.init()):void 0},stats:function(){var a;return alchemy.conf.nodeStats||alchemy.conf.edgeStats?(a='
        \n

        \n Statistics\n

        \n\n
        \n
        \n
          \n
            \n
            ',alchemy.dash.select("#control-dash").append("div").attr("id","stats").html(a).select("#stats-header").on("click",function(){return alchemy.dash.select("#all-stats").classed("in")?alchemy.dash.select("#stats-header>span").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#stats-header>span").attr("class","fa fa-2x fa-caret-down")}),alchemy.stats.init()):void 0},clustering:function(){var a;return alchemy.conf.clusterControl?(a='
            \n
            \n

            Clustering

            \n \n
            \n
            ',alchemy.dash.select("#control-dash").append("div").attr("id","clustering").html(a).select("#cluster_control_header"),alchemy.clusterControls.init()):void 0},dashIsShown:function(){var a;return a=alchemy.conf,a.showEditor||a.captionToggle||a.toggleRootNodes||a.removeElement||a.clusterControl||a.nodeStats||a.edgeStats||a.edgeFilters||a.nodeFilters||a.edgesToggle||a.nodesToggle||a.search}},alchemy.filters={init:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;if(alchemy.filters.show(),alchemy.conf.edgeFilters&&alchemy.filters.showEdgeFilters(),alchemy.conf.nodeFilters&&alchemy.filters.showNodeFilters(),alchemy.conf.nodeTypes){for(e=Object.keys(alchemy.conf.nodeTypes),g="",n=alchemy.conf.nodeTypes[e],h=0,k=n.length;k>h;h++)f=n[h],a=f.replace("_"," "),g+="";alchemy.dash.select("#node-dropdown").html(g)}if(alchemy.conf.edgeTypes){for(o=alchemy.dash.selectAll(".edge")[0],i=0,l=o.length;l>i;i++)b=o[i],alchemy.currentRelationshipTypes[[b].caption]=!0;for(d="",p=alchemy.conf.edgeTypes,j=0,m=p.length;m>j;j++)c=p[j],a=c.replace("_"," "),d+="";alchemy.dash.select("#rel-dropdown").html(d)}return alchemy.conf.captionsToggle&&alchemy.filters.captionsToggle(),alchemy.conf.edgesToggle&&alchemy.filters.edgesToggle(),alchemy.conf.nodesToggle&&alchemy.filters.nodesToggle(),alchemy.filters.update()},show:function(){var a;return a='
            \n

            Filters

            \n \n
            \n
            \n
            ',alchemy.dash.select("#control-dash #filters").html(a),alchemy.dash.selectAll("#filter-header").on("click",function(){return alchemy.dash.select("#filters>form").classed("in")?alchemy.dash.select("#filter-header>span").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#filter-header>span").attr("class","fa fa-2x fa-caret-down")}),alchemy.dash.select("#filters form")},showEdgeFilters:function(){var a;return a='
            \n

            \n Edge Types\n

            \n \n
            \n',alchemy.dash.select("#filters form").append("div").attr("id","filter-relationships").html(a),alchemy.dash.select("#filter-rel-header").on("click",function(){return alchemy.dash.select("#rel-dropdown").classed("in")?alchemy.dash.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-right"):alchemy.dash.select("#filter-rel-header>span").attr("class","fa fa-lg fa-caret-down")})},showNodeFilters:function(){var a;return a='
            \n

            \n Node Types\n

            \n \n
            \n',alchemy.dash.select("#filters form").append("div").attr("id","filter-nodes").html(a),alchemy.dash.select("#filter-node-header").on("click",function(){return alchemy.dash.select("#node-dropdown").classed("in")?alchemy.dash.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-right"):alchemy.dash.select("#filter-node-header>span").attr("class","fa fa-lg fa-caret-down")})},captionsToggle:function(){return alchemy.dash.select("#filters form").append("li").attr({id:"toggle-captions","class":"list-group-item active-label toggle"}).html("Show Captions").on("click",function(){var a;return a=alchemy.dash.select("g text").attr("style"),"display: block"===a?alchemy.dash.selectAll("g text").attr("style","display: none"):alchemy.dash.selectAll("g text").attr("style","display: block")})},edgesToggle:function(){return alchemy.dash.select("#filters form").append("li").attr({id:"toggle-edges","class":"list-group-item active-label toggle"}).html("Toggle Edges").on("click",function(){return _.contains(_.pluck(_.flatten(_.values(alchemy._edges)),"_state"),"active")?_.each(_.values(alchemy._edges),function(a){return _.each(a,function(a){return"active"===a._state?a.toggleHidden():void 0})}):_.each(_.values(alchemy._edges),function(a){return _.each(a,function(a){var b,c;return b=alchemy._nodes[a._properties.source],c=alchemy._nodes[a._properties.target],"active"===b._state&&"active"===c._state?a.toggleHidden():void 0})})})},nodesToggle:function(){return alchemy.dash.select("#filters form").append("li").attr({id:"toggle-nodes","class":"list-group-item active-label toggle"}).html("Toggle Nodes").on("click",function(){return _.contains(_.pluck(_.values(alchemy._nodes),"_state"),"active")?_.each(_.values(alchemy._nodes),function(a){return alchemy.conf.toggleRootNodes&&a._d3.root?void 0:"active"===a._state?a.toggleHidden():void 0}):_.each(_.values(alchemy._nodes),function(a){return alchemy.conf.toggleRootNodes&&a._d3.root?void 0:a.toggleHidden()})})},update:function(){return alchemy.dash.selectAll(".nodeType, .edgeType").on("click",function(){var a,b;return a=d3.select(this),b=a.attr("name"),alchemy.vis.selectAll("."+b).each(function(a){var b,c,d,e;return null!=alchemy._nodes[a.id]?(c=alchemy._nodes[a.id],c.toggleHidden()):(b=alchemy._edges[a.id][0],d=alchemy._nodes[b._properties.source],e=alchemy._nodes[b._properties.target],"active"===d._state&&"active"===e._state?b.toggleHidden():void 0)}),alchemy.stats.nodeStats()})}},alchemy.interactions={edgeClick:function(a){var b;return d3.event.stopPropagation(),b=alchemy._edges[a.id][a.pos],"hidden"!==b._state&&(b._state=function(){return"selected"===b._state?"active":"selected"}(),b.setStyles()),"function"==typeof(null!=alchemy.conf.edgeClick)?alchemy.conf.edgeClick():void 0},edgeMouseOver:function(a){var b;return b=alchemy._edges[a.id][a.pos],"hidden"!==b._state?("selected"!==b._state&&(b._state="highlighted"),b.setStyles()):void 0},edgeMouseOut:function(a){var b;return b=alchemy._edges[a.id][a.pos],"hidden"!==b._state?("selected"!==b._state&&(b._state="active"),b.setStyles()):void 0},nodeMouseOver:function(a){var b;if(b=alchemy._nodes[a.id],"hidden"!==b._state){if("selected"!==b._state&&(b._state="highlighted",b.setStyles()),"function"==typeof alchemy.conf.nodeMouseOver)return alchemy.conf.nodeMouseOver(b);if("number"==typeof alchemy.conf.nodeMouseOver)return b.properties[alchemy.conf.nodeMouseOver]}},nodeMouseOut:function(a){var b;return b=alchemy._nodes[a.id],"hidden"!==b._state&&("selected"!==b._state&&(b._state="active",b.setStyles()),null!=alchemy.conf.nodeMouseOut&&"function"==typeof alchemy.conf.nodeMouseOut)?alchemy.conf.nodeMouseOut(a):void 0},nodeClick:function(a){var b;if(!d3.event.defaultPrevented)return d3.event.stopPropagation(),b=alchemy._nodes[a.id],"hidden"!==b._state&&(b._state=function(){return"selected"===b._state?"active":"selected"}(),b.setStyles()),"function"==typeof alchemy.conf.nodeClick?alchemy.conf.nodeClick(a):void 0},zoom:function(a){return null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scaleExtent(a).on("zoom",function(){return alchemy.vis.attr("transform","translate("+d3.event.translate+") scale("+d3.event.scale+")")})},clickZoom:function(a){var b,c,d,e;return e=alchemy.vis.attr("transform").match(/(-*\d+\.*\d*)/g).map(function(a){return parseFloat(a)}),c=e[0],d=e[1],b=e[2],alchemy.vis.attr("transform",function(){return"in"===a?(balchemy.conf.scaleExtent[0]&&(b-=.2),"translate("+c+","+d+") scale("+b+")"):"reset"===a?"translate(0,0) scale(1)":console.log("error")}),null==this._zoomBehavior&&(this._zoomBehavior=d3.behavior.zoom()),this._zoomBehavior.scale(b).translate([c,d])},toggleControlDash:function(){var a;return a=alchemy.dash.classed("off-canvas")||alchemy.dash.classed("initial"),alchemy.dash.classed({"off-canvas":!a,initial:!1,"on-canvas":a})},nodeDragStarted:function(a){return d3.event.preventDefault,d3.event.sourceEvent.stopPropagation(),d3.select(this).classed("dragging",!0),a.fixed=!0},nodeDragged:function(a){var b,c,d,e,f,g,h;for(a.x+=d3.event.dx,a.y+=d3.event.dy,a.px+=d3.event.dx,a.py+=d3.event.dy,d=d3.select(this),d.attr("transform","translate("+a.x+", "+a.y+")"),b=alchemy._nodes[a.id]._adjacentEdges,h=[],f=0,g=b.length;g>f;f++)c=b[f],e=alchemy.vis.select("#edge-"+c),h.push(alchemy._drawEdges.updateEdge(e.data()[0]));return h},nodeDragended:function(){return d3.select(this).classed({dragging:!1}),alchemy.conf.forceLocked?void 0:alchemy.force.start()},deselectAll:function(){var a;if(null!=(a=d3.event)?!a.defaultPrevented:!0)return alchemy.conf.showEditor===!0&&alchemy.modifyElements.nodeEditorClear(),_.each(alchemy._nodes,function(a){return a._state="active",a.setStyles()}),_.each(alchemy._edges,function(a){return _.each(a,function(a){return a._state="active",a.setStyles()})}),alchemy.conf.deselectAll?alchemy.conf.deselectAll():void 0}},alchemy.Layout=function(){function a(){this.linkDistancefn=c(this.linkDistancefn,this),this.tick=c(this.tick,this),this.linkStrength=c(this.linkStrength,this),this.gravity=c(this.gravity,this);var a,b;a=alchemy.conf,b=alchemy._nodes,this.k=Math.sqrt(Math.log(_.size(alchemy._nodes))/(a.graphWidth()*a.graphHeight())),this._clustering=new alchemy.clustering,this.d3NodeInternals=_.map(alchemy._nodes,function(a){return a._d3}),a.cluster?(this._charge=function(){return this._clustering.layout.charge},this._linkStrength=function(a){return this._clustering.layout.linkStrength(a)}):(this._charge=function(){return-10/this.k},this._linkStrength=function(a){return b[a.source.id].getProperties("root")||b[a.target.id].getProperties("root")?1:.9}),a.cluster?this._linkDistancefn=function(a){return this._clustering.layout.linkDistancefn(a)}:"default"===a.linkDistancefn?this._linkDistancefn=function(){return 1/(50*this.k)}:"number"==typeof a.linkDistancefn?this._linkDistancefn=function(){return a.linkDistancefn}:"function"==typeof a.linkDistancefn&&(this._linkDistancefn=function(b){return a.linkDistancefn(b)})}return a.prototype.gravity=function(){return alchemy.conf.cluster?this._clustering.layout.gravity(this.k):50*this.k},a.prototype.linkStrength=function(a){return this._linkStrength(a)},a.prototype.friction=function(){return.9},a.prototype.collide=function(a){var b,c,d,e,f,g;return b=alchemy.conf,g=2*(a.radius+a["stroke-width"])+b.nodeOverlap,c=a.x-g,d=a.x+g,e=a.y-g,f=a.y+g,function(b,h,i,j,k){var l,m,n;return b.point&&b.point!==a&&(m=a.x-Math.abs(b.point.x),n=a.y-b.point.y,l=Math.sqrt(m*m+n*n),g=g,g>l&&(l=(l-g)/l*alchemy.conf.alpha,a.x-=m*=l,a.y-=n*=l,b.point.x+=m,b.point.y+=n)),h>d||c>j||i>f||e>k}},a.prototype.tick=function(){var a,b,c,d,e,f;if(alchemy.conf.collisionDetectionls)for(c=d3.geom.quadtree(this.d3NodeInternals),f=this.d3NodeInternals,d=0,e=f.length;e>d;d++)b=f[d],c.visit(this.collide(b));return alchemy.vis.selectAll("g.node").attr("transform",function(a){return"translate("+a.x+","+a.y+")"}),a=alchemy.vis.selectAll("g.edge"),this.drawEdge=alchemy.drawing.DrawEdge,this.drawEdge.styleText(a),this.drawEdge.styleLink(a)},a.prototype.positionRootNodes=function(){var a,b,c,d,e,f,g,h,i,j;if(a=alchemy.conf,b={width:a.graphWidth(),height:a.graphHeight()},e=_.filter(alchemy.get.allNodes(),function(a){return a.getProperties("root")}),1!==e.length){for(j=[],c=f=0,g=e.length;g>f;c=++f)d=e[c],d._d3.x=b.width/Math.sqrt(e.length*(c+1)),d._d3.y=b.height/2,j.push(d._d3.fixed=!0);return j}d=e[0],h=[b.width/2,b.width/2],d._d3.x=h[0],d._d3.px=h[1],i=[b.height/2,b.height/2],d._d3.y=i[0],d._d3.py=i[1],d._d3.fixed=!0},a.prototype.chargeDistance=function(){return 500},a.prototype.linkDistancefn=function(a){return this._linkDistancefn(a)},a.prototype.charge=function(){return this._charge()},a}(),alchemy.generateLayout=function(a){var b;return null==a&&(a=!1),b=alchemy.conf,alchemy.layout=new alchemy.Layout,alchemy.force=d3.layout.force().size([b.graphWidth(),b.graphHeight()]).nodes(_.map(alchemy._nodes,function(a){return a._d3})).links(_.flatten(_.map(alchemy._edges,function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b._d3);return e}))),alchemy.force.charge(alchemy.layout.charge()).linkDistance(function(a){return alchemy.layout.linkDistancefn(a)}).theta(1).gravity(alchemy.layout.gravity()).linkStrength(function(a){return alchemy.layout.linkStrength(a)}).friction(alchemy.layout.friction()).chargeDistance(alchemy.layout.chargeDistance())},alchemy.search={init:function(){var a;return a=alchemy.dash.select("#search input"),a.on("keyup",function(){var b;return b=a[0][0].value.toLowerCase(),alchemy.vis.selectAll(".node").classed("inactive",!1),alchemy.vis.selectAll("text").attr("style",function(){return""!==b?"display: inline;":void 0}),alchemy.vis.selectAll(".node").classed("inactive",function(a){var c,d;switch(c=d3.select(this).text(),alchemy.conf.searchMethod){case"contains":d=c.toLowerCase().indexOf(b)<0;break;case"begins":d=0!==c.toLowerCase().indexOf(b)}return d?alchemy.vis.selectAll("[source-target*='"+a.id+"']").classed("inactive",d):alchemy.vis.selectAll("[source-target*='"+a.id+"']").classed("inactive",function(a){var b,c,d;return b=[a.source.id,a.target.id],c=alchemy.vis.select("#node-"+b[0]).classed("inactive"),d=alchemy.vis.select("#node-"+b[1]).classed("inactive"),d||c}),d})})}},alchemy.startGraph=function(a){return function(b){var c,d,e,f,g,h,i,j,k,l;for(d=alchemy.conf,d3.select(d.divSelector).empty()&&console.warn(alchemy.utils.warnings.divWarning()),b||alchemy.utils.warnings.dataWarning(),alchemy.create.nodes.apply(a,b.nodes),b.edges.forEach(function(a){return alchemy.create.edges(a)}),alchemy.vis=d3.select(d.divSelector).attr("style","width:"+d.graphWidth()+"px; height:"+d.graphHeight()+"px; background:"+d.backgroundColour).append("svg").attr("xmlns","http://www.w3.org/2000/svg").attr("xlink","http://www.w3.org/1999/xlink").attr("pointer-events","all").on("click",alchemy.interactions.deselectAll).call(alchemy.interactions.zoom(d.scaleExtent)).on("dblclick.zoom",null).append("g").attr("transform","translate("+d.initialTranslate+") scale("+d.initialScale+")"),alchemy.interactions.zoom().scale(d.initialScale),alchemy.interactions.zoom().translate(d.initialTranslate),alchemy.generateLayout(),alchemy.controlDash.init(),e=_.flatten(_.map(alchemy._edges,function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(b._d3);return e})),f=_.map(alchemy._nodes,function(a){return a._d3}),alchemy.layout.positionRootNodes(),alchemy.force.start();alchemy.force.alpha()>.005;)alchemy.force.tick();return alchemy._drawEdges=alchemy.drawing.DrawEdges,alchemy._drawEdges.createEdge(e),alchemy._drawNodes=alchemy.drawing.DrawNodes,alchemy._drawNodes.createNode(f),j=!0,console.log(Date()+" completed initial computation"),l=alchemy.vis.selectAll("g.node").attr("transform",function(a){return"translate("+a.x+", "+a.y+")"}),d.forceLocked||alchemy.force.on("tick",alchemy.layout.tick).start(),null!=d.afterLoad&&("function"==typeof d.afterLoad?d.afterLoad():"string"==typeof d.afterLoad&&(alchemy[d.afterLoad]=!0)),(d.cluster||d.directedEdges)&&(g=d3.select(""+alchemy.conf.divSelector+" svg").append("svg:defs")),d.directedEdges&&(c=d.edgeArrowSize+2*d.edgeWidth(),k=g.append("svg:marker").attr("id","arrow").attr("viewBox","0 -"+.4*c+" "+c+" "+c).attr("markerUnits","userSpaceOnUse").attr("markerWidth",c).attr("markerHeight",c).attr("orient","auto"),k.append("svg:path").attr("d","M "+c+",0 L 0,"+.4*c+" L 0,-"+.4*c),d.curvedEdges?k.attr("refX",c+1):k.attr("refX",1)),d.nodeStats&&alchemy.stats.nodeStats(),d.showEditor?(h=new alchemy.editor.Editor,i=new alchemy.editor.Interactions,d3.select("body").on("keydown",i.deleteSelected),h.startEditor()):void 0}}(this),alchemy.stats={init:function(){return alchemy.stats.update()},nodeStats:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;if(i="",e=[],b=alchemy.get.allNodes().length,a=alchemy.get.activeNodes().length,d=b-a,i+="
          • Number of nodes: "+b+"
          • ",i+="
          • Number of active nodes: "+a+"
          • ",i+="
          • Number of inactive nodes: "+d+"
          • ",alchemy.conf.nodeTypes){for(g=Object.keys(alchemy.conf.nodeTypes),k="",n=alchemy.conf.nodeTypes[g],l=0,m=n.length;m>l;l++)j=n[l],c=j.replace("_"," "),h=alchemy.vis.selectAll("g.node."+j)[0].length,k+="
          • Number of "+c+" nodes: "+h+"
          • ",e.push([""+j,h]);i+=k}return f="
          • ",i+=f,alchemy.dash.select("#node-stats").html(i),this.insertSVG("node",e)},edgeStats:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;if(d=null,f=alchemy.vis.selectAll(".edge")[0].length,a=alchemy.vis.selectAll(".edge.active")[0].length,h=alchemy.vis.selectAll(".edge.inactive")[0].length,e="
          • Number of relationships: "+f+"
          • Number of active relationships: "+a+"
          • Number of inactive relationships: "+h+"
          • ",alchemy.conf.edgeTypes){for(d=[],m=alchemy.vis.selectAll(".edge")[0],i=0,k=m.length;k>i;i++)c=m[i],alchemy.currentRelationshipTypes[[c].caption]=!0;for(n=alchemy.conf.edgeTypes,j=0,l=n.length;l>j;j++)g=n[j],g&&(b=g.replace("_"," "),f=alchemy.vis.selectAll(".edge."+g)[0].length,d.push([""+b,f]))}return alchemy.dash.select("#rel-stats").html(e),alchemy.stats.insertSVG("edge",d),d},insertSVG:function(a,b){var c,d,e,f,g,h,i,j;return null===b?alchemy.dash.select("#"+a+"-stats-graph").html("

            There are no "+a+"Types listed in your conf.

            "):(j=.25*alchemy.conf.graphWidth(),f=250,h=j/4,e=d3.scale.category20(),c=d3.svg.arc().outerRadius(h-10).innerRadius(h/2),g=d3.layout.pie().sort(null).value(function(a){return a[1]}),i=alchemy.dash.select("#"+a+"-stats-graph").append("svg").append("g").style({width:j,height:f}).attr("transform","translate("+j/2+","+f/2+")"),d=i.selectAll(".arc").data(g(b)).enter().append("g").classed("arc",!0).on("mouseover",function(a,c){return alchemy.dash.select("#"+b[c][0]+"-stat").classed("hidden",!1)}).on("mouseout",function(a,c){return alchemy.dash.select("#"+b[c][0]+"-stat").classed("hidden",!0)}),d.append("path").attr("d",c).attr("stroke",function(a,b){return e(b)}).attr("stroke-width",2).attr("fill-opacity","0.3"),d.append("text").attr("transform",function(a){return"translate("+c.centroid(a)+")"}).attr("id",function(a,c){return""+b[c][0]+"-stat"}).attr("dy",".35em").classed("hidden",!0).text(function(a,c){return b[c][0]}))},update:function(){return alchemy.conf.nodeStats&&alchemy.stats.nodeStats(),alchemy.conf.edgeStats?alchemy.stats.edgeStats():void 0}},alchemy.defaults={renderer:"svg",graphWidth:function(){return d3.select(this.divSelector).node().parentElement.clientWidth},graphHeight:function(){return"BODY"===d3.select(this.divSelector).node().parentElement.nodeName?window.innerHeight:d3.select(this.divSelector).node().parentElement.clientHeight},alpha:.5,collisionDetection:!0,nodeOverlap:25,fixNodes:!1,fixRootNodes:!1,forceLocked:!0,linkDistancefn:"default",nodePositions:null,showEditor:!1,captionToggle:!1,toggleRootNodes:!1,removeElement:!1,cluster:!1,clusterKey:"cluster",clusterColours:d3.shuffle(["#DD79FF","#FFFC00","#00FF30","#5168FF","#00C0FF","#FF004B","#00CDCD","#f83f00","#f800df","#ff8d8f","#ffcd00","#184fff","#ff7e00"]),clusterControl:!1,nodeStats:!1,edgeStats:!1,edgeFilters:!1,nodeFilters:!1,edgesToggle:!1,nodesToggle:!1,zoomControls:!1,nodeCaption:"caption",nodeCaptionsOnByDefault:!1,nodeStyle:{all:{radius:10,color:"#68B9FE",borderColor:"#127DC1",borderWidth:function(a,b){return b/3},captionColor:"#FFFFFF",captionBackground:null,captionSize:12,selected:{color:"#FFFFFF",borderColor:"#349FE3"},highlighted:{color:"#EEEEFF"},hidden:{color:"none",borderColor:"none"}}},nodeColour:null,nodeMouseOver:"caption",nodeRadius:10,nodeTypes:null,rootNodes:"root",rootNodeRadius:15,edgeCaption:"caption",edgeCaptionsOnByDefault:!1,edgeClick:"default",edgeStyle:{all:{width:4,color:"#CCC",opacity:.2,directed:!0,curved:!0,selected:{opacity:1},highlighted:{opacity:1},hidden:{opacity:0}}},edgeTypes:null,curvedEdges:!1,edgeWidth:function(){return 4 +},edgeOverlayWidth:20,directedEdges:!1,edgeArrowSize:5,search:!1,searchMethod:"contains",backgroundColour:"#000000",theme:null,afterLoad:"afterLoad",divSelector:"#alchemy",dataSource:null,initialScale:1,initialTranslate:[0,0],scaleExtent:[.5,2.4],dataWarning:"default",warningMessage:"There be no data! What's going on?"},alchemy.drawing.DrawEdge={createLink:function(){return function(a){var b,c,d,e,f;return b=alchemy.conf,c=b.curvedEdges,d=b.directedEdges,e=alchemy.interactions,f=alchemy.drawing.EdgeUtils,a.append("path").attr("class","edge-line").attr("id",function(a){return"path-"+a.id}),a.filter(function(a){return null!=a.caption}).append("text"),a.append("path").attr("class","edge-handler").style("stroke-width",""+b.edgeOverlayWidth)}}(this),styleLink:function(){return function(a){var b,c,d;return b=alchemy.conf,c=b.directedEdges,d=alchemy.drawing.EdgeUtils,a.each(function(a){var c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;return i=d.edgeWalk(a),k=d3.select(this),k.style(d.edgeStyle(a)),b.curvedEdges||k.attr("transform","translate("+i.startEdgeX+", "+i.startEdgeY+") rotate("+i.edgeAngle+")"),k.select(".edge-line").attr("d",b.curvedEdges?(c=d.edgeAngle(a),p=Math.abs(c)>90?-1:1,o=function(a){return 0===a?0:0>a?-1:1}(c),s=d.startLine(a),j=d.endLine(a),q=s.x,r=s.y,t=j.x,u=j.y,g=t-q,h=u-r,l=Math.sqrt(g*g+h*h),m=(g*alchemy.conf.nodeRadius+2)/l,n=(h*alchemy.conf.nodeRadius+2)/l,e=-o*b.edgeArrowSize+m,f=p*b.edgeArrowSize+n,"M "+(q-m)+","+(r-n)+" A "+l+", "+l+" "+d.edgeAngle(a)+" 0, 1 "+(t-e)+", "+(u-f)):b.directedEdges?"M "+i.startPathX+" "+i.startPathBottomY+"\nL "+i.arrowBendX+" "+i.arrowBendBottomY+"\nL "+i.arrowBendX+" "+i.arrowTipBottomY+"\nL "+i.arrowEndX+" "+i.arrowEndY+" \nL "+i.arrowBendX+" "+i.arrowTipTopY+" \nL "+i.arrowBendX+" "+i.arrowBendTopY+"\nL "+i.startPathX+" "+i.startPathTopY+"\nZ":"M "+i.startPathX+" "+i.startPathBottomY+"\nL "+i.arrowEndX+" "+i.arrowBendBottomY+"\nL "+i.arrowEndX+" "+i.arrowBendTopY+"\nL "+i.startPathX+" "+i.startPathTopY+"\nZ"),k.select(".edge-handler").attr("d",function(){return k.select(".edge-line").attr("d")})})}}(this),classEdge:function(){return function(a){return a.classed("active",!0)}}(this),styleText:function(){return function(a){var b,c,d,e;return b=alchemy.conf,c=b.curvedEdges,d=b.directedEdges,e=alchemy.drawing.EdgeUtils,a.select("text").each(c?function(a){var c;return c=e.edgeWalk(a),d3.select(this).attr("dx",function(a){return e.middlePath(a).x}).attr("dy",function(a){return e.middlePath(a).y+20}).attr("transform","rotate("+e.captionAngle(a)+")").text(a.caption).style("display",function(){return b.edgeCaptionsOnByDefault?"block":void 0})}:function(a){var c,d,f;return f=e.edgeWalk(a),c=e.captionAngle(a),d=180===c?-f.edgeLength/2:f.edgeLength/2,d3.select(this).attr("dx",""+d).attr("dy",""+1.1*-a["stroke-width"]).attr("transform","rotate("+c+")").text(a.caption).style("display",function(){return b.edgeCaptionsOnByDefault?"block":void 0})})}}(this),setInteractions:function(){return function(a){var b,c,d;return d=alchemy.interactions,b="editor"===alchemy.get.state("interactions"),b?(c=new alchemy.editor.Interactions,a.select(".edge-handler").on("click",c.edgeClick)):a.select(".edge-handler").on("click",d.edgeClick).on("mouseover",function(a){return d.edgeMouseOver(a)}).on("mouseout",function(a){return d.edgeMouseOut(a)})}}(this)},alchemy.drawing.DrawEdges={createEdge:function(a){var b,c;return b=alchemy.drawing.DrawEdge,c=alchemy.vis.selectAll("g.edge").data(a),c.enter().append("g").attr("id",function(a){return"edge-"+a.id+"-"+a.pos}).attr("class",function(a){return"edge "+a.edgeType}).attr("source-target",function(a){return""+a.source.id+"-"+a.target.id}),b.createLink(c),b.classEdge(c),b.styleLink(c),b.styleText(c),b.setInteractions(c),c.exit().remove(),alchemy.conf.directedEdges&&alchemy.conf.curvedEdges?c.select(".edge-line").attr("marker-end","url(#arrow)"):void 0},updateEdge:function(a){var b,c;return b=alchemy.drawing.DrawEdge,c=alchemy.vis.select("#edge-"+a.id+"-"+a.pos),b.classEdge(c),b.styleLink(c),b.styleText(c),b.setInteractions(c)}},alchemy.drawing.DrawNode={styleText:function(a){var b,c,d;return b=alchemy.conf,d=alchemy.drawing.NodeUtils,c=alchemy._nodes,a.selectAll("text").attr("dy",function(a){return c[a.id].getProperties().root?b.rootNodeRadius/2:2*b.nodeRadius-5}).html(function(a){return d.nodeText(a)}).style("display",function(){return b.nodeCaptionsOnByDefault?"block":void 0})},createNode:function(a){return a.append("circle").attr("id",function(a){return"circle-"+a.id}),a.append("svg:text").attr("id",function(a){return"text-"+a.id})},styleNode:function(a){var b;return b=alchemy.drawing.NodeUtils,a.selectAll("circle").attr("r",function(a){return"function"==typeof a.radius?a.radius():a.radius}).attr("shape-rendering","optimizeSpeed").each(function(a){return d3.select(this).style(b.nodeStyle(a))})},setInteractions:function(a){var b,c,d,e,f,g,h;return b=alchemy.conf,c=alchemy.interactions,e="editor"===alchemy.get.state("interactions"),d=d3.behavior.drag().origin(Object).on("dragstart",null).on("drag",null).on("dragend",null),e?(f=new alchemy.editor.Interactions,a.on("mouseup",function(a){return f.nodeMouseUp(a)}).on("mouseover",function(a){return f.nodeMouseOver(a)}).on("mouseout",function(a){return f.nodeMouseOut(a)}).on("dblclick",function(a){return c.nodeDoubleClick(a)}).on("click",function(a){return f.nodeClick(a)})):(a.on("mouseup",null).on("mouseover",function(a){return c.nodeMouseOver(a)}).on("mouseout",function(a){return c.nodeMouseOut(a)}).on("dblclick",function(a){return c.nodeDoubleClick(a)}).on("click",function(a){return c.nodeClick(a)}),d=d3.behavior.drag().origin(Object).on("dragstart",c.nodeDragStarted).on("drag",c.nodeDragged).on("dragend",c.nodeDragended),b.fixNodes||(g=a.filter(function(a){return a.root!==!0}),g.call(d)),b.fixRootNodes?void 0:(h=a.filter(function(a){return a.root===!0}),h.call(d)))}},alchemy.drawing.DrawNodes={createNode:function(a){var b,c;return b=alchemy.drawing.DrawNode,c=alchemy.vis.selectAll("g.node").data(a,function(a){return a.id}),c.enter().append("g").attr("class",function(a){var b;return b=alchemy._nodes[a.id]._nodeType,"node "+b+" active"}).attr("id",function(a){return"node-"+a.id}).classed("root",function(a){return a.root}),b.createNode(c),b.styleNode(c),b.styleText(c),b.setInteractions(c),c.exit().remove()},updateNode:function(a){var b,c;return b=alchemy.drawing.DrawNode,c=alchemy.vis.select("#node-"+a.id),b.styleNode(c),b.styleText(c),b.setInteractions(c)}},alchemy.drawing.EdgeUtils={edgeStyle:function(a){var b,c,d,e;return c=alchemy._edges[a.id][a.pos],e=alchemy.svgStyles.edge.update(c),d=alchemy._nodes,alchemy.conf.cluster&&(b=alchemy.layout._clustering,e.stroke=function(a){var c,e,f,g,h,i;return d=alchemy._nodes,c=alchemy.conf.clusterKey,h=d[a.source.id]._properties,i=d[a.target.id]._properties,h.root||i.root?(g=h.root?i[c]:h[c],""+b.getClusterColour(g)):h[c]===i[c]?(g=h[c],""+b.getClusterColour(g)):h[c]!==i[c]?(f=""+h[c]+"-"+i[c],e="cluster-gradient-"+f,"url(#"+e+")"):void 0}(a)),e},triangle:function(a){var b,c;return c=a.target.x-a.source.x,b=a.target.y-a.source.y,{width:c,height:b,hyp:Math.sqrt(b*b+c*c)}},edgeWalk:function(a){var b,c,d,e,f,g,h,i,j,k;return c=alchemy.conf.edgeArrowSize,b=.3,j=this.triangle(a),k=j.width,g=j.height,h=j.hyp,f=a["stroke-width"],d=2,i=0+a.source.radius+a.source["stroke-width"]-f/2+d,e=h-i-1.5*d,{edgeAngle:Math.atan2(g,k)/Math.PI*180,startEdgeX:a.source.x,startEdgeY:a.source.y,midLineX:a.source.x+k/2,midLineY:a.source.x+g/2,endLineX:a.source.x+k/h,endLineY:a.source.x+g/h,startPathX:i,startPathBottomY:f/2,arrowBendX:e-c,arrowBendBottomY:f/2,arrowTipBottomY:f/2+c*b,arrowEndX:e,arrowEndY:0,arrowTipTopY:-(c*b+f/2),arrowBendTopY:-f/2,startPathTopY:-f/2,edgeLength:e}},curvedDirectedEdgeWalk:function(a,b){var c,d,e,f,g,h;return c=alchemy.conf,h=a.target.x-a.source.x,e=a.target.y-a.source.y,f=Math.sqrt(e*e+h*h),g="middle"===b?(d=f/2,{x:a.source.x+h*d/f,y:a.source.y+e*d/f}):"linkStart"===b?(d=a.source.radius+a.source["stroke-width"],{x:a.source.x+h*d/f,y:a.source.y+e*d/f}):"linkEnd"===b?(d=c.curvedEdges?f:f-(a.target.radius+a.target["stroke-width"]),c.directedEdges?d-=c.edgeArrowSize:void 0,{x:a.source.x+h*d/f,y:a.source.y+e*d/f}):void 0},middleLine:function(a){return this.curvedDirectedEdgeWalk(a,"middle")},startLine:function(a){return this.curvedDirectedEdgeWalk(a,"linkStart")},endLine:function(a){return this.curvedDirectedEdgeWalk(a,"linkEnd")},edgeLength:function(a){var b,c,d;return d=a.target.x-a.source.x,b=a.target.y-a.source.y,c=Math.sqrt(b*b+d*d)},edgeAngle:function(a){var b,c;return c=a.target.x-a.source.x,b=a.target.y-a.source.y,Math.atan2(b,c)/Math.PI*180},captionAngle:function(a){return-90>a||a>90?180:0},middlePath:function(a){var b,c;return c=alchemy.vis.select("#path-"+a.id).node(),b=c.getPointAtLength(c.getTotalLength()/2),{x:b.x,y:b.y}},middlePathCurve:function(a){var b,c;return c=d3.select("#path-"+a.id).node(),b=c.getPointAtLength(c.getTotalLength()/2),{x:b.x,y:b.y}}},alchemy.drawing.NodeUtils={nodeStyle:function(a){var b;return b=alchemy.conf,b.cluster&&(a.fill=function(a){var c,d,e,f,g,h,i;return d=alchemy.layout._clustering,i=alchemy._nodes[a.id].getProperties(),c=d.clusterMap,h=alchemy.conf.clusterKey,g=b.clusterColours,f=c[i[h]]%g.length,e=g[f],""+e}(a)),a},nodeText:function(a){var b,c,d;return c=alchemy.conf,d=alchemy._nodes[a.id]._properties,c.nodeCaption&&"string"==typeof c.nodeCaption?null!=d[c.nodeCaption]?d[c.nodeCaption]:"":c.nodeCaption&&"function"==typeof c.nodeCaption?(b=c.nodeCaption(d),(void 0===b||"undefined"===String(b))&&(alchemy.log.caption="At least one caption returned undefined",c.caption=!1),b):void 0}},alchemy.svgStyles={node:{populate:function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;return b=alchemy.conf,d=_.omit(b.nodeStyle.all,"selected","highlighted","hidden"),c=a,m=function(a){return"function"==typeof a?a:function(){return a}},g=_.keys(b.nodeTypes)[0],f=a.getProperties()[g],void 0===b.nodeStyle[f]&&(f="all"),n=_.assign(_.cloneDeep(d),b.nodeStyle[f]),k=_.assign(n,b.nodeStyle[f][a._state]),h=m(k.radius),e=m(k.color),i=m(k.borderColor),j=m(k.borderWidth),l={},l.radius=h(c),l.fill=e(c),l.stroke=i(c),l["stroke-width"]=j(c,h(c)),l}},edge:{populate:function(a){var b,c,d,e,f,g,h,i,j,k;return c=alchemy.conf,d=_.omit(c.edgeStyle.all,"selected","highlighted","hidden"),i=function(a){return"function"==typeof a?a:function(){return a}},e=a._edgeType,void 0===c.edgeStyle[e]&&(e="all"),j=_.assign(_.cloneDeep(d),c.edgeStyle[e]),g=_.assign(j,c.edgeStyle[e][a._state]),k=i(g.width),b=i(g.color),f=i(g.opacity),h={stroke:b(a),"stroke-width":k(a),opacity:f(a),fill:"none"}},update:function(a){var b,c,d,e,f,g,h;return c=alchemy.conf,e=a._style,g=function(a){return"function"==typeof a?a:function(){return a}},h=g(e.width),b=g(e.color),d=g(e.opacity),f={stroke:b(a),"stroke-width":h(a),opacity:d(a),fill:"none"}}}},alchemy.editor.Editor=function(){function a(){this.nodeEditor=c(this.nodeEditor,this),this.startEditor=c(this.startEditor,this),this.utils=new alchemy.editor.Utils}return a.prototype.editorContainerHTML='
            \n

            Editor

            \n
            \n
            \n
              \n
            • Remove Selected
            • \n
            • Editor mode enabled, click to disable editor interactions
            • \n
            \n
            ',a.prototype.elementEditorHTML=function(a){return"

            "+a+' Editor

            \n
            \n
            \n \n \n
            \n \n
            \n
            \n \n
            '},a.prototype.startEditor=function(){var a,b,c,d,e;return a=alchemy.conf.divSelector,d=this.editorContainerHTML,b=alchemy.dash.select("#control-dash").append("div").attr("id","editor").html(d),b.select("#editor-header").on("click",function(){return alchemy.dash.select("#element-options").classed("in")?alchemy.dash.select("#editor-header>span").attr("class","fa fa-2x fa-caret-right"):alchemy.dash.select("#editor-header>span").attr("class","fa fa-2x fa-caret-down")}),c=b.select("#element-options ul #editor-interactions").on("click",function(){return d3.select(this).attr("class",function(){return"editor"===alchemy.get.state()?(alchemy.set.state("interactions","default"),"inactive list-group-item"):(alchemy.set.state("interactions","editor"),"active list-group-item")}).html(function(){return"editor"===alchemy.get.state()?"Disable Editor Interactions":"Enable Editor Interactions"})}),b.select("#element-options ul #remove").on("click",function(){return alchemy.editor.remove()}),e=this.utils,c.on("click",function(){return alchemy.dash.select("#editor-interactions").classed("active")?(e.disableEditor(),alchemy.dash.select("#editor-interactions").classed({active:!1,inactive:!0}).html("Editor mode disabled, click to enable editor interactions")):(e.enableEditor(),alchemy.dash.select("#editor-interactions").classed({active:!0,inactive:!1}).html("Editor mode enabled, click to disable editor interactions"))})},a.prototype.nodeEditor=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;c=alchemy.conf.divSelector,d=alchemy.dash.select("#control-dash #editor"),i=d.select("#element-options"),f=this.elementEditorHTML("Node"),e=i.append("div").attr("id","node-editor").html(f),e.attr("class",function(){var a;return a=alchemy.dash.select("#editor-interactions").classed("active"),a?"enabled":"hidden"}),b=d.select("#node-editor form #add-property"),b.select("#node-add-prop-key").attr("placeholder","New Property Name").attr("value",null),b.select("#node-add-prop-value").attr("placeholder","New Property Value").attr("value",null),alchemy.dash.select("#add-property-form").on("submit",function(){var a,b;return event.preventDefault(),a=alchemy.dash.select("#add-prop-key").property("value"),a=a.replace(/\s/g,"_"),b=alchemy.dash.select("#add-prop-value").property("value"),l(a,b,!0),alchemy.dash.selectAll("#add-property .edited-property").classed({"edited-property":!1}),this.reset()}),g=alchemy._nodes[a.id].getProperties(),alchemy.vis.select("#node-"+a.id).classed({editing:!0}),k=d.select("#node-editor #properties-list");for(j in g)m=g[j],h=k.append("div").attr("id","node-"+j).attr("class","property form-inline form-group"),h.append("label").attr("for","node-"+j+"-input").attr("class","form-control property-name").text(""+j),h.append("input").attr("id","node-"+j+"-input").attr("class","form-control property-value").attr("value",""+m);return alchemy.dash.select("#properties-list").on("submit",function(){var a,b,c,d,e,f,g;for(event.preventDefault(),b=alchemy.dash.selectAll(".edited-property"),g=b[0],e=0,f=g.length;f>e;e++)j=g[e],c=alchemy.dash.select(j),a=c.select("label").text(),d=c.select("input").attr("value"),l(a,d,!1);return alchemy.dash.selectAll("#node-properties-list .edited-property").classed({"edited-property":!1}),this.reset()}),d3.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown",function(){return 13===d3.event.keyCode&&event.preventDefault(),d3.select(this).classed({"edited-property":!0})}),l=function(b,c,d){var e,f;return f=a.id,""!==b&&""!==c?(alchemy._nodes[f].setProperty(""+b,""+c),e=alchemy._drawNodes,e.updateNode(alchemy.viz.select("#node-"+f)),d===!0?(alchemy.dash.select("#node-add-prop-key").attr("value","property added/updated to key: "+b),alchemy.dash.select("#node-add-prop-value").attr("value","property at "+b+" updated to: "+c)):alchemy.dash.select("#node-"+b+"-input").attr("value","property at "+b+" updated to: "+c)):d===!0?(alchemy.dash.select("#node-add-prop-key").attr("value","null or invalid input"),alchemy.dash.select("#node-add-prop-value").attr("value","null or invlid input")):alchemy.dash.select("#node-"+b+"-input").attr("value","null or invalid input")}},a.prototype.editorClear=function(){return alchemy.dash.selectAll(".node").classed({editing:!1}),alchemy.dash.selectAll(".edge").classed({editing:!1}),alchemy.dash.select("#node-editor").remove(),alchemy.dash.select("#edge-editor").remove(),alchemy.dash.select("#node-add-prop-submit").attr("placeholder",function(){return alchemy.vis.selectAll(".selected").empty()?"select a node or edge to edit properties":"add a property to this element"})},a.prototype.edgeEditor=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;c=alchemy.conf.divSelector,f=alchemy.dash("#control-dash #editor"),i=f.select("#element-options"),h=this.elementEditorHTML("Edge"),g=i.append("div").attr("id","edge-editor").html(h),g.attr("class",function(){return alchemy.dash.select("#editor-interactions").classed("active")?"enabled":"hidden"}),b=f.select("#edge-editor form #add-property"),b.select("#add-prop-key").attr("placeholder","New Property Name").attr("value",null),b.select("#add-prop-value").attr("placeholder","New Property Value").attr("value",null),d=alchemy._edges[a.id].getProperties(),alchemy.vis.select("#edge-"+a.id).classed({editing:!0}),k=f.select("#edge-editor #properties-list");for(j in d)m=d[j],e=k.append("div").attr("id","edge-"+j).attr("class","property form-inline form-group"),e.append("label").attr("for","edge-"+j+"-input").attr("class","form-control property-name").text(""+j),e.append("input").attr("id","edge-"+j+"-input").attr("class","form-control property-value").attr("value",""+m);return alchemy.dash.selectAll("#add-prop-key, #add-prop-value, .property").on("keydown",function(){return 13===d3.event.keyCode&&event.preventDefault(),d3.select(this).classed({"edited-property":!0})}),alchemy.dash.select("#add-property-form").on("submit",function(){var a,b;return event.preventDefault(),a=alchemy.dash.select("#add-prop-key").property("value"),a=a.replace(/\s/g,"_"),b=alchemy.dash.select("#add-prop-value").property("value"),l(a,b,!0),alchemy.dash.selectAll("#add-property .edited-property").classed({"edited-property":!1}),this.reset()}),d3.select("#properties-list").on("submit",function(){var a,b,c,d,e,f,g;for(event.preventDefault(),b=alchemy.dash.selectAll(".edited-property"),g=b[0],e=0,f=g.length;f>e;e++)j=g[e],c=alchemy.dash.select(j),a=c.select("label").text(),d=c.select("input").property("value"),l(a,d,!1);return alchemy.dash.selectAll("#properties-list .edited-property").classed({"edited-property":!1}),this.reset()}),l=function(b,c,d){var e,f,g;return f=a.id,""!==b&&""!==c?(alchemy._edges[f].setProperty(""+b,""+c),g=alchemy.vis.select("#edge-"+f),e=new alchemy.drawing.DrawEdges,e.updateEdge(alchemy.vis.select("#edge-"+f)),d===!0?(alchemy.dash.select("#add-prop-key").attr("value","property added/updated to key: "+b),alchemy.dash.select("#add-prop-value").attr("value","property at "+b+" updated to: "+c)):alchemy.dash.select("#edge-"+b+"-input").attr("value","property at "+b+" updated to: "+c)):d===!0?(alchemy.dash.select("#add-prop-key").attr("value","null or invalid input"),alchemy.dash.select("#add-prop-value").attr("value","null or invlid input")):alchemy.dash.select("#edge-"+b+"-input").attr("value","null or invalid input")}},a}(),alchemy.editor.Interactions=function(){function a(){this.reset=c(this.reset,this),this.deleteSelected=c(this.deleteSelected,this),this.addNodeDragended=c(this.addNodeDragended,this),this.addNodeDragging=c(this.addNodeDragging,this),this.addNodeStart=c(this.addNodeStart,this),this.edgeClick=c(this.edgeClick,this),this.nodeClick=c(this.nodeClick,this),this.nodeMouseUp=c(this.nodeMouseUp,this),this.editor=new alchemy.editor.Editor}return a.prototype.nodeMouseOver=function(){var a;return d3.select(this).select("circle").empty()||(a=d3.select(this).select("circle").attr("r"),d3.select(this).select("circle").attr("r",3*a)),this},a.prototype.nodeMouseUp=function(a){return this.sourceNode!==a?(this.mouseUpNode=!0,this.targetNode=a,this.click=!1):this.click=!0,this},a.prototype.nodeMouseOut=function(){var a;return d3.select(this).select("circle").empty()||(a=d3.select(this).select("circle").attr("r"),d3.select(this).select("circle").attr("r",a/3)),this},a.prototype.nodeClick=function(a){var b;return d3.event.stopPropagation(),alchemy.vis.select("#node-"+a.id).empty()||(b=alchemy.vis.select("#node-"+a.id).classed("selected"),alchemy.vis.select("#node-"+a.id).classed("selected",!b)),this.editor.editorClear(),this.editor.nodeEditor(a)},a.prototype.edgeClick=function(a){return d3.event.stopPropagation(),this.editor.editorClear(),this.editor.edgeEditor(a)},a.prototype.addNodeStart=function(a){return d3.event.sourceEvent.stopPropagation(),this.sourceNode=a,alchemy.vis.select("#dragline").classed({hidden:!1}),this},a.prototype.addNodeDragging=function(){var a,b;return a=d3.event.x,b=d3.event.y,alchemy.vis.select("#dragline").attr("x1",this.sourceNode.x).attr("y1",this.sourceNode.y).attr("x2",a).attr("y2",b).attr("style","stroke: #FFF"),this},a.prototype.addNodeDragended=function(){var a,b,c;return this.click||(this.mouseUpNode||(a=alchemy.vis.select("#dragline"),b=a.attr("x2"),c=a.attr("y2"),this.targetNode={id:""+_.uniqueId("addedNode_"),x:parseFloat(b),y:parseFloat(c),caption:"node added"}),this.newEdge={id:""+this.sourceNode.id+"-"+this.targetNode.id,source:this.sourceNode.id,target:this.targetNode.id,caption:"edited"},alchemy.editor.update(this.targetNode,this.newEdge)),this.reset(),this},a.prototype.deleteSelected=function(){switch(d3.event.keyCode){case 8:case 46:if("INPUT"!==d3.select(d3.event.target).node().tagName)return d3.event.preventDefault(),alchemy.editor.remove()}},a.prototype.reset=function(){return this.mouseUpNode=null,this.sourceNode=null,this.targetNode=null,this.newEdge=null,this.click=null,alchemy.vis.select("#dragline").classed({hidden:!0}).attr("x1",0).attr("y1",0).attr("x2",0).attr("y2",0),this},a}(),alchemy.editor.Utils=function(){function a(){this.enableEditor=c(this.enableEditor,this),this.drawNodes=alchemy._drawNodes,this.drawEdges=alchemy._drawEdges}return a.prototype.enableEditor=function(){var a,b,c;return alchemy.set.state("interactions","editor"),a=alchemy.vis.append("line").attr("id","dragline"),this.drawNodes.updateNode(alchemy.node),this.drawEdges.updateEdge(alchemy.edge),c=alchemy.vis.selectAll(".selected"),b=new alchemy.editor.Editor,c.empty()||1!==c.length?c.classed({selected:!1}):c.classed("node")?(b.nodeEditor(c.datum()),alchemy.dash.select("#node-editor").attr("class","enabled").style("opacity",1)):c.classed("edge")?(b.edgeEditor(c.datum()),alchemy.dash.select("#edge-editor").attr("class","enabled").style("opacity",1)):void 0},a.prototype.disableEditor=function(){return alchemy.setState("interactions","default"),alchemy.vis.select("#dragline").remove(),alchemy.dash.select("#node-editor").transition().duration(300).style("opacity",0),alchemy.dash.select("#node-editor").transition().delay(300).attr("class","hidden"),this.drawNodes.updateNode(alchemy.node),alchemy.vis.selectAll(".node").classed({selected:!1})},a.prototype.remove=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(e=alchemy.vis.selectAll(".selected.node"),j=e[0],l=[],f=0,h=j.length;h>f;f++)if(b=j[f],c=alchemy.vis.select(b).data()[0].id,d=alchemy._nodes[c],null!=d){for(k=d.adjacentEdges,g=0,i=k.length;i>g;g++)a=k[g],alchemy._edges=_.omit(alchemy._edges,""+a),alchemy.edge=alchemy.edge.data(_.map(alchemy._edges,function(a){return a._d3}),function(a){return a.id}),alchemy.vis.select("#edge-"+a).remove();alchemy._nodes=_.omit(alchemy._nodes,""+c),alchemy.node=alchemy.node.data(_.map(alchemy._nodes,function(a){return a._d3}),function(a){return a.id}),alchemy.vis.select(b).remove(),l.push("editor"===alchemy.get.state("interactions")?alchemy.modifyElements.nodeEditorClear():void 0)}else l.push(void 0);return l},a.prototype.addNode=function(a){var b;return b=alchemy._nodes[a.id]=new alchemy.models.Node({id:""+a.id}),b.setProperty("caption",a.caption),b.setD3Property("x",a.x),b.setD3Property("y",a.y),alchemy.node=alchemy.node.data(_.map(alchemy._nodes,function(a){return a._d3}),function(a){return a.id})},a.prototype.addEdge=function(a){var b;return b=alchemy._edges[a.id]=new alchemy.models.Edge(a),alchemy.edge=alchemy.edge.data(_.map(alchemy._edges,function(a){return a._d3}),function(a){return a.id})},a.prototype.update=function(a,b){return this.mouseUpNode?(alchemy.editor.addEdge(b),this.drawEdges.createEdge(alchemy.edge)):(alchemy.editor.addNode(a),alchemy.editor.addEdge(b),this.drawEdges.createEdge(alchemy.edge),this.drawNodes.createNode(alchemy.node)),alchemy.layout.tick()},a}(),alchemy.models.Edge=function(){function a(a,b){var d,e;null==b&&(b=null),this.allNodesActive=c(this.allNodesActive,this),this.getStyles=c(this.getStyles,this),this.getProperties=c(this.getProperties,this),this.setProperties=c(this.setProperties,this),this._setCaption=c(this._setCaption,this),this._setID=c(this._setID,this),this._setD3Properties=c(this._setD3Properties,this),d=alchemy,e=d.conf,this.id=this._setID(a),this._index=b,this._state="active",this._properties=a,this._edgeType=this._setEdgeType(),this._style=null!=e.edgeStyle[this._edgeType]?_.merge(_.clone(e.edgeStyle.all),e.edgeStyle[this._edgeType]):_.clone(e.edgeStyle.all),this._d3=_.merge({id:this.id,pos:this._index,edgeType:this._edgeType,source:d._nodes[this._properties.source]._d3,target:d._nodes[this._properties.target]._d3},d.svgStyles.edge.populate(this)),this._setCaption(a,e),d._nodes[""+a.source]._addEdge(""+this.id+"-"+this._index),d._nodes[""+a.target]._addEdge(""+this.id+"-"+this._index)}return a.prototype._setD3Properties=function(a){return _.merge(this._d3,a)},a.prototype._setID=function(a){return null!=a.id?a.id:""+a.source+"-"+a.target},a.prototype._setCaption=function(a,b){var c,d;return c=b.edgeCaption,d=function(a){switch(typeof c){case"string":return a[c];case"function":return c(a)}}(a),d?this._d3.caption=d:void 0},a.prototype._setEdgeType=function(){var a,b,c;return a=alchemy.conf,a.edgeTypes&&(_.isPlainObject(a.edgeTypes)?(c=Object.keys(alchemy.conf.edgeTypes),b=this._properties[c]):_.isArray(a.edgeTypes)?b=this._properties.caption:"string"==typeof a.edgeTypes&&(b=this._properties[a.edgeTypes])),void 0===b&&(b="all"),this._setD3Properties("edgeType",b),b},a.prototype.setProperties=function(a,b){return null==b&&(b=null),_.isPlainObject(a)?(_.assign(this._properties,a),"source"in a&&this._setD3Properties({source:alchemy._nodes[a.source]._d3}),"target"in a&&this._setD3Properties({target:alchemy._nodes[a.target]._d3})):(this._properties[a]=b,("source"===a||"target"===a)&&this._setD3Properties({property:alchemy._nodes[b]._d3})),this},a.prototype.getProperties=function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[],null==a&&(a=null),null==a&&0===b.length?this._properties:0!==b.length?(c=_.union([a],b),_.pick(this._properties,c)):this._properties[a]},a.prototype.getStyles=function(a){return null==a&&(a=null),null!=a?this._style[a]:this._style},a.prototype.setStyles=function(a,b){return null==b&&(b=null),void 0===a&&(a=alchemy.svgStyles.edge.populate(this)),_.isPlainObject(a)?_.assign(this._style,a):"string"==typeof a&&(this._style[a]=b),this._setD3Properties(alchemy.svgStyles.edge.update(this)),alchemy._drawEdges.updateEdge(this._d3),this},a.prototype.toggleHidden=function(){return this._state="hidden"===this._state?"active":"hidden",this.setStyles()},a.prototype.allNodesActive=function(){var a,b;return a=alchemy.vis.select("#node-"+this.properties.source),b=alchemy.vis.select("#node-"+this.properties.target),!a.classed("inactive")&&!b.classed("inactive")},a}(),alchemy.models.Node=function(){function a(a){this.getStyles=c(this.getStyles,this),this.removeProperty=c(this.removeProperty,this),this.setProperty=c(this.setProperty,this),this.getProperties=c(this.getProperties,this),this._setD3Properties=c(this._setD3Properties,this),this._setNodeType=c(this._setNodeType,this);var b,d;b=alchemy,d=b.conf,this.id=a.id,this._properties=a,this._d3=_.merge({id:this.id,root:this._properties[d.rootNodes]},b.svgStyles.node.populate(this)),this._nodeType=this._setNodeType(),this._style=d.nodeStyle[this._nodeType]?d.nodeStyle[this._nodeType]:d.nodeStyle.all,this._state="active",this._adjacentEdges=[]}return a.prototype._setNodeType=function(){var a,b,c,d;return a=alchemy.conf,a.nodeTypes&&(_.isPlainObject(a.nodeTypes)?(b=Object.keys(alchemy.conf.nodeTypes),d=_.values(a.nodeTypes),c=this._properties[b]):"string"==typeof a.nodeTypes&&(c=this._properties[a.nodeTypes])),void 0===c&&(c="all"),this._setD3Properties("nodeType",c),c},a.prototype._setD3Properties=function(a){return _.merge(this._d3,a)},a.prototype._addEdge=function(a){return this._adjacentEdges=_.union(this._adjacentEdges,[a])},a.prototype.getProperties=function(){var a,b,c;return a=arguments[0],b=2<=arguments.length?d.call(arguments,1):[],null==a&&(a=null),null==a&&0===b.length?this._properties:0!==b.length?(c=_.union([a],b),_.pick(this._properties,c)):this._properties[a]},a.prototype.setProperty=function(a,b){return null==b&&(b=null),_.isPlainObject(a)?_.assign(this._properties,a):this._properties[a]=b,this},a.prototype.removeProperty=function(a){return null!=this._properties.property&&_.omit(this._properties,a),this},a.prototype.getStyles=function(a){return null==a&&(a=null),null!=a?this._style[a]:this._style},a.prototype.setStyles=function(a,b){return null==b&&(b=null),void 0===a?a=alchemy.svgStyles.node.populate(this):_.isPlainObject(a)?_.assign(this._style,a):this._style[a]=b,this._setD3Properties(alchemy.svgStyles.node.populate(this)),alchemy._drawNodes.updateNode(this._d3),this},a.prototype.toggleHidden=function(){return this._state="hidden"===this._state?"active":"hidden",this.setStyles(),_.each(this._adjacentEdges,function(a){var b,c,d,e,f,g,h;return h=a.split("-"),d=h[0],f=h[1],c=h[2],b=alchemy._edges[""+d+"-"+f][c],e=alchemy._nodes[""+d]._state,g=alchemy._nodes[""+f]._state,"hidden"===b._state&&"active"===e&&"active"===g?b.toggleHidden():"active"!==b._state||"hidden"!==e&&"hidden"!==g?void 0:b.toggleHidden()})},a.prototype.outDegree=function(){return this._adjacentEdges.length},a}(),alchemy.themes={"default":{backgroundColour:"#000000",nodeStyle:{all:{radius:function(){return 10},color:function(){return"#68B9FE"},borderColor:function(){return"#127DC1"},borderWidth:function(a,b){return b/3},captionColor:function(){return"#FFFFFF"},captionBackground:function(){return null},captionSize:12,selected:{color:function(){return"#FFFFFF"},borderColor:function(){return"#349FE3"}},highlighted:{color:function(){return"#EEEEFF"}},hidden:{color:function(){return"none"},borderColor:function(){return"none"}}}},edgeStyle:{all:{width:4,color:"#CCC",opacity:.2,directed:!0,curved:!0,selected:{opacity:1},highlighted:{opacity:1},hidden:{opacity:0}}}},white:{backgroundColour:"#FFFFFF",nodeStyle:{all:{radius:function(){return 10},color:function(){return"#68B9FE"},borderColor:function(){return"#127DC1"},borderWidth:function(a,b){return b/3},captionColor:function(){return"#FFFFFF"},captionBackground:function(){return null},captionSize:12,selected:{color:function(){return"#FFFFFF"},borderColor:function(){return"38DD38"}},highlighted:{color:function(){return"#EEEEFF"}},hidden:{color:function(){return"none"},borderColor:function(){return"none"}}}},edgeStyle:{all:{width:4,color:"#333",opacity:.4,directed:!1,curved:!1,selected:{color:"#38DD38",opacity:.9},highlighted:{color:"#383838",opacity:.7},hidden:{opacity:0}}}}},alchemy.utils.warnings={dataWarning:function(){var a;return alchemy.conf.dataWarning&&"function"==typeof alchemy.conf.dataWarning?alchemy.conf.dataWarning():"default"===alchemy.conf.dataWarning?(a='',$("body").append(a),$("#no-results").modal("show")):void 0 },divWarning:function(){return"create an element that matches the value for 'divSelector' in your conf.\nFor instance, if you are using the default 'divSelector' conf, simply provide\n
            ."}}}).call(this); \ No newline at end of file diff --git a/site/app/docs/_documentation/Annotated-Source.md b/site/app/docs/_documentation/Annotated-Source.md index e9dd19b..c90880f 100644 --- a/site/app/docs/_documentation/Annotated-Source.md +++ b/site/app/docs/_documentation/Annotated-Source.md @@ -59,10 +59,6 @@ title: Anotated Source @_edges = {} begin: (userConf) => - # Make sure current instance hasn't already begun - d3.select userConf.divSelector - .html "" - console.log alchemy._nodes # overide configuration with user inputs @setConf(userConf) @@ -253,6 +249,9 @@ title: Anotated Source else _.map alchemy._nodes, (n) -> n + activeNodes: () -> + _.filter alchemy._nodes, (node) -> node if node._state is "active" + allEdges: -> _.flatten _.map(alchemy._edges, (edgeArray) -> e for e in edgeArray) @@ -583,10 +582,10 @@ title: Anotated Source # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - alchemy.filters = - init: () -> + alchemy.filters = + init: () -> alchemy.filters.show() - + if alchemy.conf.edgeFilters then alchemy.filters.showEdgeFilters() if alchemy.conf.nodeFilters then alchemy.filters.showNodeFilters() #generate filter forms @@ -612,7 +611,7 @@ title: Anotated Source edgeTypes += "" alchemy.dash.select '#rel-dropdown' .html edgeTypes - + if alchemy.conf.captionsToggle then alchemy.filters.captionsToggle() if alchemy.conf.edgesToggle then alchemy.filters.edgesToggle() if alchemy.conf.nodesToggle then alchemy.filters.nodesToggle() @@ -681,12 +680,12 @@ title: Anotated Source .append "div" .attr "id", "filter-nodes" .html node_filter_html - alchemy.dash.select "#filter-node-header" + alchemy.dash.select "#filter-node-header" .on 'click', () -> if alchemy.dash.select('#node-dropdown').classed "in" alchemy.dash.select "#filter-node-header>span" .attr "class", "fa fa-lg fa-caret-right" - else + else alchemy.dash.select "#filter-node-header>span" .attr "class", "fa fa-lg fa-caret-down" @@ -713,8 +712,16 @@ title: Anotated Source .attr {"id":"toggle-edges","class":"list-group-item active-label toggle"} .html "Toggle Edges" .on "click", -> - _.each _.values(alchemy._edges), (edges)-> - _.each edges, (e)-> e.toggleHidden() + if _.contains(_.pluck(_.flatten(_.values(alchemy._edges)), "_state"), "active") + _.each _.values(alchemy._edges), (edges)-> + _.each edges, (e)-> if e._state is "active" then e.toggleHidden() + else + _.each _.values(alchemy._edges), (edges)-> + _.each edges, (e)-> + source = alchemy._nodes[e._properties.source] + target = alchemy._nodes[e._properties.target] + if source._state is "active" and target._state is "active" + e.toggleHidden() #create nodes toggle nodesToggle: () -> @@ -723,9 +730,14 @@ title: Anotated Source .attr {"id":"toggle-nodes","class":"list-group-item active-label toggle"} .html "Toggle Nodes" .on "click", -> - _.each _.values(alchemy._nodes), (n)-> - if alchemy.conf.toggleRootNodes and n._d3.root then return - n.toggleHidden() + if _.contains(_.pluck(_.values(alchemy._nodes), "_state"), "active") + _.each _.values(alchemy._nodes), (n)-> + if alchemy.conf.toggleRootNodes and n._d3.root then return + if n._state is "active" then n.toggleHidden() + else + _.each _.values(alchemy._nodes), (n)-> + if alchemy.conf.toggleRootNodes and n._d3.root then return + n.toggleHidden() #update filters update: () -> @@ -734,13 +746,18 @@ title: Anotated Source element = d3.select this tag = element.attr "name" alchemy.vis.selectAll ".#{tag}" - .each (d)-> + .each (d)-> if alchemy._nodes[d.id]? node = alchemy._nodes[d.id] node.toggleHidden() else edge = alchemy._edges[d.id][0] - edge.toggleHidden() + source = alchemy._nodes[edge._properties.source] + target = alchemy._nodes[edge._properties.target] + if source._state is "active" and target._state is "active" + edge.toggleHidden() + alchemy.stats.nodeStats() + # Alchemy.js is a graph drawing application for the web. # Copyright (C) 2014 GraphAlchemist, Inc. @@ -928,12 +945,8 @@ title: Anotated Source nodes = alchemy._nodes @k = Math.sqrt Math.log(_.size(alchemy._nodes)) / (conf.graphWidth() * conf.graphHeight()) @_clustering = new alchemy.clustering + @d3NodeInternals = _.map alchemy._nodes, (v,k)-> v._d3 - # Set up quad tree - if conf.collisionDetection - @d3NodeInternals = _.map alchemy._nodes, (v,k)-> v._d3 - @q = d3.geom.quadtree @d3NodeInternals - if conf.cluster @_charge = () -> @_clustering.layout.charge @_linkStrength = (edge) -> @_clustering.layout.linkStrength(edge) @@ -955,6 +968,8 @@ title: Anotated Source else if typeof conf.linkDistancefn is 'function' @_linkDistancefn = (edge) -> conf.linkDistancefn(edge) + + gravity: () => if alchemy.conf.cluster @_clustering.layout.gravity @k @@ -964,10 +979,9 @@ title: Anotated Source linkStrength: (edge) => @_linkStrength edge - friction: () -> - if alchemy.conf.cluster then 0.7 else 0.9 + friction: () -> 0.9 - collide: (node) => + collide: (node) -> conf = alchemy.conf r = 2 * (node.radius + node['stroke-width']) + conf.nodeOverlap nx1 = node.x - r @@ -992,9 +1006,10 @@ title: Anotated Source y2 < ny1 tick: () => - if alchemy.conf.collisionDetection + if alchemy.conf.collisionDetectionls + q = d3.geom.quadtree @d3NodeInternals for node in @d3NodeInternals - @q.visit @collide(node) + q.visit @collide(node) # alchemy.node alchemy.vis @@ -1216,7 +1231,10 @@ title: Anotated Source if conf.curvedEdges marker.attr "refX", arrowSize + 1 else - marker.attr 'refX', 1 + marker.attr 'refX', 1 + + if conf.nodeStats + alchemy.stats.nodeStats() if conf.showEditor editor = new alchemy.editor.Editor @@ -1249,23 +1267,26 @@ title: Anotated Source nodeStats: () -> #general node stats nodeStats = '' - nodeNum = alchemy.vis.selectAll(".node")[0].length - activeNodes = alchemy.vis.selectAll(".node.active")[0].length - inactiveNodes = alchemy.vis.selectAll(".node.inactive")[0].length - nodeStats += "
          • Number of nodes: #{nodeNum}
          • " + nodeData = [] + + allNodes = alchemy.get.allNodes().length + activeNodes = alchemy.get.activeNodes().length + inactiveNodes = allNodes - activeNodes + + nodeStats += "
          • Number of nodes: #{allNodes}
          • " nodeStats += "
          • Number of active nodes: #{activeNodes}
          • " nodeStats += "
          • Number of inactive nodes: #{inactiveNodes}
          • " #add stats for all node types if alchemy.conf.nodeTypes - nodeKey = Object.keys(alchemy.conf.nodeTypes) + nodeKeys = Object.keys(alchemy.conf.nodeTypes) nodeTypes = '' - for nodeType in alchemy.conf.nodeTypes[nodeKey] - # if not currentNodeTypes[t] then continue + for nodeType in alchemy.conf.nodeTypes[nodeKeys] caption = nodeType.replace('_', ' ') nodeNum = alchemy.vis.selectAll("g.node.#{nodeType}")[0].length nodeTypes += "
          • Number of nodes of type #{caption}: #{nodeNum}
          • " + name = #{caption}>Number of #{caption} nodes: #{nodeNum}" + nodeData.push(["#{nodeType}", nodeNum]) nodeStats += nodeTypes #add the graph @@ -1274,6 +1295,7 @@ title: Anotated Source alchemy.dash .select '#node-stats' .html nodeStats + @insertSVG "node", nodeData edgeStats: () -> #general edge stats @@ -1305,33 +1327,6 @@ title: Anotated Source alchemy.stats.insertSVG "edge", edgeData return edgeData - nodeStats: () -> - #general node stats - nodeData = null - totalNodes = alchemy.vis.selectAll(".node")[0].length - activeNodes = alchemy.vis.selectAll(".node.active")[0].length - inactiveNodes = alchemy.vis.selectAll(".node.inactive")[0].length - - #add stats for all node types - if alchemy.conf.nodeTypes - nodeData = [] - nodeKey = Object.keys(alchemy.conf.nodeTypes) - for nodeType in alchemy.conf.nodeTypes[nodeKey] - nodeNum = alchemy.vis.selectAll("g.node.#{nodeType}")[0].length - nodeData.push(["#{nodeType}", nodeNum]) - - #add the graph - nodeGraph = "
          • Number of nodes: #{totalNodes}
          • -
          • Number of active nodes: #{activeNodes}
          • -
          • Number of inactive nodes: #{inactiveNodes}
          • -
          • " - - alchemy.dash - .select '#node-stats' - .html nodeGraph - alchemy.stats.insertSVG "node", nodeData - return nodeData - insertSVG: (element, data) -> if data is null alchemy.dash @@ -2813,13 +2808,13 @@ for the curve of the node. constructor: (edge, index=null) -> a = alchemy conf = a.conf - + @id = @_setID edge @_index = index @_state = "active" @_properties = edge @_edgeType = @_setEdgeType() - @_style = + @_style = if conf.edgeStyle[@_edgeType]? _.merge _.clone(conf.edgeStyle["all"]), conf.edgeStyle[@_edgeType] else @@ -2841,7 +2836,7 @@ for the curve of the node. _setCaption: (edge, conf) => cap = conf.edgeCaption - edgeCaption = do (edge) -> + edgeCaption = do (edge) -> switch typeof cap when ('string' or 'number') then edge[cap] when 'function' then cap(edge) @@ -2853,6 +2848,8 @@ for the curve of the node. if _.isPlainObject conf.edgeTypes lookup = Object.keys alchemy.conf.edgeTypes edgeType = @_properties[lookup] + else if _.isArray conf.edgeTypes + edgeType = @_properties["caption"] else if typeof conf.edgeTypes is 'string' edgeType = @_properties[conf.edgeTypes] if edgeType is undefined then edgeType = "all" @@ -2882,7 +2879,7 @@ for the curve of the node. # Style methods getStyles: (key=null) => if key? - @_style[key] + @_style[key] else @_style