You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7 lines
87 KiB
JavaScript

/**
* D3 Force Network Chart - v3.1.0 - 2019-04-28
* https://github.com/ogobrecht/d3-force-apex-plugin
* Copyright (c) 2015-2019 Ottmar Gobrecht - MIT license
*/
function netGobrechtsD3Force(t,e,o,n){"use strict";var g={conf:{},confDefaults:{},data:{},dom:{},events:{},lib:{},main:{},status:{},tools:{},version:"3.1.0"},p={};return g.main.init=function(){g.dom.containerId=t||"D3Force"+Math.floor(1e6*Math.random()),g.confUser=e||{},g.status.apexPluginId=o,g.status.apexPageItemsToSubmit=!(!n||""===n)&&n.replace(/\s/g,"").split(","),g.main.setupConfiguration(),g.main.setupDom(),g.main.setupFunctionReferences()},g.main.setupConfiguration=function(){g.conf.debug=g.status.apexPluginId&&1===apex.jQuery("#pdebug").length,g.status.debugPrefix="D3 Force in DOM container #"+g.dom.containerId+": ",g.status.customize=!1,g.status.customizeCurrentMenu="nodes",g.status.customizeCurrentTabPosition=null,g.status.forceTickCounter=0,g.status.forceStartTime=0,g.status.forceRunning=!1,g.status.graphStarted=!1,g.status.graphRendering=!1,g.status.graphReady=!1,g.status.graphOldPositions=null,g.status.sampleData=!1,g.status.wrapLabelsOnNextTick=!1,g.status.labelFontSize=null,g.status.resizeTriggered=!1,g.confDefaults.minNodeRadius={display:!0,relation:"node",type:"number",val:6,options:[12,11,10,9,8,7,6,5,4,3,2,1]},g.confDefaults.maxNodeRadius={display:!0,relation:"node",type:"number",val:18,options:[36,34,32,30,28,26,24,22,20,18,16,14,12]},g.confDefaults.colorScheme={display:!0,relation:"node",type:"text",val:"color20",options:["color20","color20b","color20c","color10","direct"]},g.confDefaults.dragMode={display:!0,relation:"node",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.pinMode={display:!0,relation:"node",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.nodeEventToStopPinMode={display:!0,relation:"node",type:"text",val:"contextmenu",options:["none","dblclick","contextmenu"]},g.confDefaults.onNodeContextmenuPreventDefault={display:!0,relation:"node",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.nodeEventToOpenLink={display:!0,relation:"node",type:"text",val:"dblclick",options:["none","click","dblclick","contextmenu"]},g.confDefaults.nodeLinkTarget={display:!0,relation:"node",type:"text",val:"_blank",options:["none","_blank","nodeID","domContainerID"]},g.confDefaults.showLabels={display:!0,relation:"label",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.wrapLabels={display:!0,relation:"label",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.labelSplitCharacter={display:!0,relation:"label",type:"text",val:"none",options:["none","^","`","°","\\","|","/","#",":","::"]},g.confDefaults.wrappedLabelWidth={display:!0,relation:"label",type:"number",val:80,options:[200,190,180,170,160,150,140,130,120,110,100,90,80,70,60,50,40]},g.confDefaults.wrappedLabelLineHeight={display:!0,relation:"label",type:"number",val:1.2,options:[1.5,1.4,1.3,1.2,1.1,1]},g.confDefaults.labelsCircular={display:!0,relation:"label",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.labelDistance={display:!0,relation:"label",type:"number",val:12,options:[30,28,26,24,22,20,18,16,14,12,10,8,6,4,2]},g.confDefaults.preventLabelOverlappingOnForceEnd={display:!0,relation:"label",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.labelPlacementIterations={display:!0,relation:"label",type:"number",val:250,options:[2e3,1e3,500,250,125]},g.confDefaults.showTooltips={display:!0,relation:"node",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.tooltipPosition={display:!0,relation:"node",type:"text",val:"svgTopRight",options:["node","svgTopLeft","svgTopRight"]},g.confDefaults.alignFixedNodesToGrid={display:!0,relation:"node",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.gridSize={display:!0,relation:"node",type:"number",val:50,options:[150,140,130,120,110,100,90,80,70,60,50,40,30,20,10]},g.confDefaults.linkDistance={display:!0,relation:"link",type:"number",val:80,options:[120,110,100,90,80,70,60,50,40,30,20]},g.confDefaults.showLinkDirection={display:!0,relation:"link",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.showSelfLinks={display:!0,relation:"link",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.selfLinkDistance={display:!0,relation:"link",type:"number",val:20,options:[30,28,26,24,22,20,18,16,14,12,10,8]},g.confDefaults.useDomParentWidth={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.width={display:!0,relation:"graph",type:"number",val:600,options:[1200,1150,1100,1050,1e3,950,900,850,800,750,700,650,600,550,500,450,400,350,300]},g.confDefaults.height={display:!0,relation:"graph",type:"number",val:400,options:[1200,1150,1100,1050,1e3,950,900,850,800,750,700,650,600,550,500,450,400,350,300]},g.confDefaults.setDomParentPaddingToZero={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.showBorder={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.showLegend={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.showLoadingIndicatorOnAjaxCall={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.lassoMode={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.zoomMode={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.minZoomFactor={display:!0,relation:"graph",type:"number",val:.2,options:[1,.9,.8,.7,.6,.5,.4,.3,.2,.1]},g.confDefaults.maxZoomFactor={display:!0,relation:"graph",type:"number",val:5,options:[10,9,8,7,6,5,4,3,2,1]},g.confDefaults.transform={display:!1,relation:"graph",type:"object",val:{translate:[0,0],scale:1}},g.confDefaults.zoomToFitOnForceEnd={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.zoomToFitOnResize={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.keepAspectRatioOnResize={display:!0,relation:"graph",type:"bool",val:!0,options:[!0,!1]},g.confDefaults.onResizeFunctionTimeout={display:!0,relation:"graph",type:"number",val:300,options:[1e3,900,800,700,600,500,400,300,200,100,0]},g.confDefaults.autoRefresh={display:!0,relation:"graph",type:"bool",val:!1,options:[!0,!1]},g.confDefaults.refreshInterval={display:!0,relation:"graph",type:"number",val:5e3,options:[6e4,3e4,15e3,1e4,5e3,2500]},g.confDefaults.forceTimeLimit={display:!0,relation:"graph",type:"number",val:1/0,options:[1/0,6400,3200,1600,800,400,200,100]},g.confDefaults.chargeDistance={display:!1,relation:"graph",type:"number",val:1/0,options:[1/0,25600,12800,6400,3200,1600,800,400,200,100],internal:!0},g.confDefaults.charge={display:!0,relation:"graph",type:"number",val:-350,options:[-1e3,-950,-900,-850,-800,-750,-700,-650,-600,-550,-500,-450,-400,-350,-300,-250,-200,-150,-100,-50,0],internal:!0},g.confDefaults.gravity={display:!0,relation:"graph",type:"number",val:.1,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.confDefaults.linkStrength={display:!0,relation:"graph",type:"number",val:1,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.confDefaults.friction={display:!0,relation:"graph",type:"number",val:.9,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.confDefaults.theta={display:!0,relation:"graph",type:"number",val:.8,options:[1,.95,.9,.85,.8,.75,.7,.65,.6,.55,.5,.45,.4,.35,.3,.25,.2,.15,.1,.05,0],internal:!0},g.conf.debug=void 0!==g.confUser.debug&&g.tools.parseBool(g.confUser.debug),g.conf.minNodeRadius=g.confUser.minNodeRadius||g.confDefaults.minNodeRadius.val,g.conf.maxNodeRadius=g.confUser.maxNodeRadius||g.confDefaults.maxNodeRadius.val,g.conf.colorScheme=g.confUser.colorScheme||g.confDefaults.colorScheme.val,g.conf.dragMode=void 0!==g.confUser.dragMode?g.tools.parseBool(g.confUser.dragMode):g.confDefaults.dragMode.val,g.conf.pinMode=void 0!==g.confUser.pinMode?g.tools.parseBool(g.confUser.pinMode):g.confDefaults.pinMode.val,g.conf.nodeEventToStopPinMode=g.confUser.nodeEventToStopPinMode||g.confDefaults.nodeEventToStopPinMode.val,g.conf.onNodeContextmenuPreventDefault=void 0!==g.confUser.onNodeContextmenuPreventDefault?g.tools.parseBool(g.confUser.onNodeContextmenuPreventDefault):g.confDefaults.onNodeContextmenuPreventDefault.val,g.conf.nodeEventToOpenLink=g.confUser.nodeEventToOpenLink||g.confDefaults.nodeEventToOpenLink.val,g.conf.nodeLinkTarget=g.confUser.nodeLinkTarget||g.confDefaults.nodeLinkTarget.val,g.conf.showLabels=void 0!==g.confUser.showLabels?g.tools.parseBool(g.confUser.showLabels):g.confDefaults.showLabels.val,g.conf.wrapLabels=void 0!==g.confUser.wrapLabels?g.tools.parseBool(g.confUser.wrapLabels):g.confDefaults.wrapLabels.val,g.conf.labelSplitCharacter=g.confUser.labelSplitCharacter||g.confDefaults.labelSplitCharacter.val,g.conf.wrappedLabelWidth=g.confUser.wrappedLabelWidth||g.confDefaults.wrappedLabelWidth.val,g.conf.wrappedLabelLineHeight=g.confUser.wrappedLabelLineHeight||g.confDefaults.wrappedLabelLineHeight.val,g.conf.labelsCircular=void 0!==g.confUser.labelsCircular?g.tools.parseBool(g.confUser.labelsCircular):g.confDefaults.labelsCircular.val,g.conf.labelDistance=g.confUser.labelDistance||g.confDefaults.labelDistance.val,g.conf.preventLabelOverlappingOnForceEnd=void 0!==g.confUser.preventLabelOverlappingOnForceEnd?g.tools.parseBool(g.confUser.preventLabelOverlappingOnForceEnd):g.confDefaults.preventLabelOverlappingOnForceEnd.val,g.conf.labelPlacementIterations=g.confUser.labelPlacementIterations||g.confDefaults.labelPlacementIterations.val,g.conf.showTooltips=void 0!==g.confUser.showTooltips?g.tools.parseBool(g.confUser.showTooltips):g.confDefaults.showTooltips.val,g.conf.tooltipPosition=g.confUser.tooltipPosition||g.confDefaults.tooltipPosition.val,g.conf.alignFixedNodesToGrid=void 0!==g.confUser.alignFixedNodesToGrid?g.tools.parseBool(g.confUser.alignFixedNodesToGrid):g.confDefaults.alignFixedNodesToGrid.val,g.conf.gridSize=g.confUser.gridSize&&0<g.confUser.gridSize?g.confUser.gridSize:g.confDefaults.gridSize.val,g.conf.linkDistance=g.confUser.linkDistance||g.confDefaults.linkDistance.val,g.conf.showLinkDirection=void 0!==g.confUser.showLinkDirection?g.tools.parseBool(g.confUser.showLinkDirection):g.confDefaults.showLinkDirection.val,g.conf.showSelfLinks=void 0!==g.confUser.showSelfLinks?g.tools.parseBool(g.confUser.showSelfLinks):g.confDefaults.showSelfLinks.val,g.conf.selfLinkDistance=g.confUser.selfLinkDistance||g.confDefaults.selfLinkDistance.val,g.conf.useDomParentWidth=void 0!==g.confUser.useDomParentWidth?g.tools.parseBool(g.confUser.useDomParentWidth):g.confDefaults.useDomParentWidth.val,g.conf.width=g.confUser.width||g.confDefaults.width.val,g.conf.height=g.confUser.height||g.confDefaults.height.val,g.conf.setDomParentPaddingToZero=void 0!==g.confUser.setDomParentPaddingToZero?g.tools.parseBool(g.confUser.setDomParentPaddingToZero):g.confDefaults.setDomParentPaddingToZero.val,g.conf.showBorder=void 0!==g.confUser.showBorder?g.tools.parseBool(g.confUser.showBorder):g.confDefaults.showBorder.val,g.conf.showLegend=void 0!==g.confUser.showLegend?g.tools.parseBool(g.confUser.showLegend):g.confDefaults.showLegend.val,g.conf.showLoadingIndicatorOnAjaxCall=void 0!==g.confUser.showLoadingIndicatorOnAjaxCall?g.tools.parseBool(g.confUser.showLoadingIndicatorOnAjaxCall):g.confDefaults.showLoadingIndicatorOnAjaxCall.val,g.conf.lassoMode=void 0!==g.confUser.lassoMode?g.tools.parseBool(g.confUser.lassoMode):g.confDefaults.lassoMode.val,g.conf.zoomMode=void 0!==g.confUser.zoomMode?g.tools.parseBool(g.confUser.zoomMode):g.confDefaults.zoomMode.val,g.conf.minZoomFactor=g.confUser.minZoomFactor||g.confDefaults.minZoomFactor.val,g.conf.maxZoomFactor=g.confUser.maxZoomFactor||g.confDefaults.maxZoomFactor.val,g.conf.transform=g.confUser.transform||g.confDefaults.transform.val,g.conf.zoomToFitOnForceEnd=void 0!==g.confUser.zoomToFitOnForceEnd?g.tools.parseBool(g.confUser.zoomToFitOnForceEnd):g.confDefaults.zoomToFitOnForceEnd.val,g.conf.zoomToFitOnResize=void 0!==g.confUser.zoomToFitOnResize?g.tools.parseBool(g.confUser.zoomToFitOnResize):g.confDefaults.zoomToFitOnResize.val,g.conf.keepAspectRatioOnResize=void 0!==g.confUser.keepAspectRatioOnResize?g.tools.parseBool(g.confUser.keepAspectRatioOnResize):g.confDefaults.keepAspectRatioOnResize.val,g.conf.onResizeFunctionTimeout=g.confUser.onResizeFunctionTimeout||g.confDefaults.onResizeFunctionTimeout.val,g.conf.autoRefresh=void 0!==g.confUser.autoRefresh?g.tools.parseBool(g.confUser.autoRefresh):g.confDefaults.autoRefresh.val,g.conf.refreshInterval=g.confUser.refreshInterval||g.confDefaults.refreshInterval.val,g.conf.forceTimeLimit=g.confUser.forceTimeLimit||g.confDefaults.forceTimeLimit.val,g.conf.chargeDistance=g.confUser.chargeDistance||g.confDefaults.forceTimeLimit.val,g.conf.charge=g.confUser.charge||g.confDefaults.charge.val,g.conf.gravity=g.confUser.gravity||g.confDefaults.gravity.val,g.conf.linkStrength=g.confUser.linkStrength||g.confDefaults.linkStrength.val,g.conf.friction=g.confUser.friction||g.confDefaults.friction.val,g.conf.theta=g.confUser.theta||g.confDefaults.theta.val,g.conf.onNodeMouseenterFunction=g.confUser.onNodeMouseenterFunction||null,g.conf.onNodeMouseleaveFunction=g.confUser.onNodeMouseleaveFunction||null,g.conf.onNodeClickFunction=g.confUser.onNodeClickFunction||null,g.conf.onNodeDblclickFunction=g.confUser.onNodeDblclickFunction||null,g.conf.onNodeContextmenuFunction=g.confUser.onNodeContextmenuFunction||null,g.conf.onLinkClickFunction=g.confUser.onLinkClickFunction||null,g.conf.onLassoStartFunction=g.confUser.onLassoStartFunction||null,g.conf.onLassoEndFunction=g.confUser.onLassoEndFunction||null,g.conf.onRenderEndFunction=g.confUser.onRenderEndFunction||null,g.conf.onForceStartFunction=g.confUser.onForceStartFunction||null,g.conf.onForceEndFunction=g.confUser.onForceEndFunction||null,g.conf.onResizeFunction=g.confUser.onResizeFunction||null,g.data.sampleData='<data><nodes ID="7839" LABEL="KING is THE KING, you know?" LABELCIRCULAR="true" COLORVALUE="10" COLORLABEL="Accounting" SIZEVALUE="5000" LINK="http://apex.oracle.com/" INFOSTRING="This visualization is based on the well known emp table." /><nodes ID="7698" LABEL="BLAKE" COLORVALUE="30" COLORLABEL="Sales" SIZEVALUE="2850" /><nodes ID="7782" LABEL="CLARK" COLORVALUE="10" COLORLABEL="Accounting" SIZEVALUE="2450" /><nodes ID="7566" LABEL="JONES" COLORVALUE="20" COLORLABEL="Research" SIZEVALUE="2975" /><nodes ID="7788" LABEL="SCOTT with a very long label" COLORVALUE="20" COLORLABEL="Research" SIZEVALUE="3000" /><nodes ID="7902" LABEL="FORD" COLORVALUE="20" COLORLABEL="Research" SIZEVALUE="3000" /><nodes ID="7369" LABEL="SMITH" COLORVALUE="20" COLORLABEL="Research" SIZEVALUE="800" /><nodes ID="7499" LABEL="ALLEN" COLORVALUE="30" COLORLABEL="Sales" SIZEVALUE="1600" /><nodes ID="7521" LABEL="WARD" COLORVALUE="30" COLORLABEL="Sales" SIZEVALUE="1250" /><nodes ID="7654" LABEL="MARTIN" COLORVALUE="30" COLORLABEL="Sales" SIZEVALUE="1250" /><nodes ID="7844" LABEL="TURNER" COLORVALUE="30" COLORLABEL="Sales" SIZEVALUE="1500" /><nodes ID="7876" LABEL="ADAMS" COLORVALUE="20" COLORLABEL="Research" SIZEVALUE="1100" /><nodes ID="7900" LABEL="JAMES" COLORVALUE="30" COLORLABEL="Sales" SIZEVALUE="950" /><nodes ID="7934" LABEL="MILLER" COLORVALUE="10" COLORLABEL="Accounting" SIZEVALUE="1300" /><nodes ID="8888" LABEL="Who am I?" COLORVALUE="green" COLORLABEL="unspecified" SIZEVALUE="2000" LINK="https://ogobrecht.github.io/d3-force-apex-plugin/module-API.html#.nodeLinkTarget" INFOSTRING="This is a good question. Think about it." /><nodes ID="9999" LABEL="Where I am?" COLORVALUE="#f00" COLORLABEL="unspecified" SIZEVALUE="1000" LINK="https://ogobrecht.github.io/d3-force-apex-plugin/module-API.html#.nodeLinkTarget" INFOSTRING="This is a good question. What do you think?" /><links FROMID="7839" TOID="7839" STYLE="dotted" COLOR="blue" INFOSTRING="This is a self link (same source and target node) rendered along a path with the STYLE attribute set to dotted and COLOR attribute set to blue." /><links FROMID="7698" TOID="7839" STYLE="dashed" /><links FROMID="7782" TOID="7839" STYLE="dashed" COLOR="red" INFOSTRING="This is a link with the STYLE attribute set to dashed and COLOR attribute set to red." /><links FROMID="7566" TOID="7839" STYLE="dashed" /><links FROMID="7788" TOID="7566" STYLE="solid" /><links FROMID="7902" TOID="7566" STYLE="solid" /><links FROMID="7369" TOID="7902" STYLE="solid" /><links FROMID="7499" TOID="7698" STYLE="solid" LABEL="Allen>Blake" INFOSTRING="This link has the LABEL and INFOSTRING attributes set." /><links FROMID="7521" TOID="7698" STYLE="solid" /><links FROMID="7654" TOID="7698" STYLE="solid" /><links FROMID="7844" TOID="7698" STYLE="solid" /><links FROMID="7876" TOID="7788" STYLE="solid" /><links FROMID="7900" TOID="7698" STYLE="solid" /><links FROMID="7934" TOID="7782" STYLE="solid" /></data>',g.status.userAgent=navigator.userAgent,g.status.userAgentIe9To11=!1,(-1!==navigator.appVersion.indexOf("MSIE 9")||-1!==navigator.appVersion.indexOf("MSIE 10")||-1!==g.status.userAgent.indexOf("Trident")&&-1!==g.status.userAgent.indexOf("rv:11"))&&(g.status.userAgentIe9To11=!0,g.tools.logError("Houston, we have a problem - user agent is IE 9, 10 or 11 - we have to provide a fix for markers: http://stackoverflow.com/questions/15588478/internet-explorer-10-not-showing-svg-path-d3-js-graph"))},g.main.setupDom=function(){var t,e;g.dom.body=d3.select("body"),null===document.querySelector("#"+g.dom.containerId)?g.dom.container=g.dom.body.append("div").attr("id",g.dom.containerId):(g.dom.container=d3.select("#"+g.dom.containerId),d3.selectAll("#"+g.dom.containerId+"_tooltip, #"+g.dom.containerId+"_customizing").remove()),null===document.querySelector("#"+g.dom.containerId+" svg")?g.dom.svg=g.dom.container.append("svg"):(g.dom.svg=d3.select("#"+g.dom.containerId+" svg"),d3.selectAll("#"+g.dom.containerId+" svg *").remove()),g.dom.svgParent=d3.select(g.dom.svg.node().parentNode),g.conf.setDomParentPaddingToZero&&g.dom.svgParent.style("padding","0"),t=g.tools.getGraphWidth(),e=g.tools.getGraphHeight(),g.dom.svg.attr("class","net_gobrechts_d3_force").classed("border",g.conf.showBorder).attr("width",t).attr("height",e),g.conf.useDomParentWidth&&g.dom.svg.attr("width",g.tools.getSvgParentInnerWidth()),g.dom.defs=g.dom.svg.append("defs"),g.dom.graphOverlay=g.dom.svg.append("g").attr("class","graphOverlay"),g.dom.graphOverlaySizeHelper=g.dom.graphOverlay.append("rect").attr("class","graphOverlaySizeHelper"),g.dom.graph=g.dom.graphOverlay.append("g").attr("class","graph"),g.dom.legend=g.dom.svg.append("g").attr("class","legend"),g.dom.loading=g.dom.svg.append("svg:g").attr("class","loading").style("display","none"),g.dom.loadingRect=g.dom.loading.append("svg:rect").attr("width",t).attr("height",e),g.dom.loadingText=g.dom.loading.append("svg:text").attr("x",t/2).attr("y",e/2).text("Loading..."),g.dom.defs.append("svg:marker").attr("id",g.dom.containerId+"_highlighted").attr("class","highlighted").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").attr("markerUnits","strokeWidth").append("svg:path").attr("d","M0,0 L10,5 L0,10"),g.dom.defs.append("svg:marker").attr("id",g.dom.containerId+"_normal").attr("class","normal").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").attr("markerUnits","strokeWidth").append("svg:path").attr("d","M0,0 L10,5 L0,10"),null===document.querySelector("#"+g.dom.containerId+"_tooltip")?g.dom.tooltip=g.dom.body.append("div").attr("id",g.dom.containerId+"_tooltip").attr("class","net_gobrechts_d3_force_tooltip").style("top","0px").style("left","0px"):g.dom.tooltip=d3.select("#"+g.dom.containerId+"_tooltip")},g.main.setupFunctionReferences=function(){g.main.force=d3.layout.force().on("start",function(){g.tools.log("Force started."),g.status.customize&&g.dom.customizePositions&&g.dom.customizePositions.text("Force started - wait for end event to show positions..."),g.status.forceTickCounter=0,g.status.forceStartTime=(new Date).getTime(),g.status.forceRunning=!0,g.tools.log("Event forcestart triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_forcestart"),"function"==typeof g.conf.onForceStartFunction&&g.conf.onForceStartFunction.call(g.dom.svg)}).on("tick",function(){g.status.forceTickCounter+=1,g.status.userAgentIe9To11&&g.conf.showLinkDirection&&(g.main.links.each(function(){this.parentNode.insertBefore(this,this)}),g.main.selfLinks.each(function(){this.parentNode.insertBefore(this,this)})),g.main.selfLinks.attr("transform",function(t){return"translate("+t.source.x+","+t.source.y+")"}),g.main.links.attr("x1",function(t){return g.tools.adjustSourceX(t)}).attr("y1",function(t){return g.tools.adjustSourceY(t)}).attr("x2",function(t){return g.tools.adjustTargetX(t)}).attr("y2",function(t){return g.tools.adjustTargetY(t)}),g.conf.showLabels&&(g.main.labels.attr("x",function(t){return t.x}).attr("y",function(t){return t.y-t.radius-g.conf.labelDistance}),g.status.wrapLabelsOnNextTick&&(g.main.labels.call(g.tools.wrapLabels,g.conf.wrappedLabelWidth),g.status.wrapLabelsOnNextTick=!1),g.conf.wrapLabels&&g.main.labels.each(function(){var t=d3.select(this),e=t.attr("y")-(t.attr("lines")-1)*g.status.labelFontSize*g.conf.wrappedLabelLineHeight;t.attr("y",e).selectAll("tspan").attr("x",t.attr("x")).attr("y",e)}),g.main.labelPaths.attr("transform",function(t){return"translate("+t.x+","+t.y+")"}),g.main.linkLabelPaths.attr("d",function(t){return"M "+t.source.x+" "+t.source.y+" L "+t.target.x+" "+t.target.y}),g.main.linkLabels.attr("transform",function(t,e){if(t.target.x<t.source.x){var o=this.getBBox();return"rotate(180 "+(o.x+o.width/2)+" "+(o.y+o.height/2)+")"}return"rotate(0)"})),g.main.nodes.attr("cx",function(t){return t.x}).attr("cy",function(t){return t.y}),(new Date).getTime()-g.status.forceStartTime>g.conf.forceTimeLimit&&g.main.force.stop()}).on("end",function(){g.conf.showLabels&&g.conf.preventLabelOverlappingOnForceEnd&&(g.data.simulatedAnnealingLabels=[],g.data.simulatedAnnealingAnchors=[],g.main.labels.each(function(t,e){var o=d3.select(this);g.data.simulatedAnnealingLabels[e]={width:this.getBBox().width,height:this.getBBox().height,x:t.x,y:o.attr("y")-(o.attr("lines")-1)*g.status.labelFontSize*g.conf.wrappedLabelLineHeight}}),g.main.nodes.filter(function(t){return!t.LABELCIRCULAR&&!g.conf.labelsCircular}).each(function(t,e){g.data.simulatedAnnealingAnchors[e]={x:t.x,y:t.y-t.radius-g.conf.labelDistance,r:.5}}),g.lib.labelerPlugin().label(g.data.simulatedAnnealingLabels).anchor(g.data.simulatedAnnealingAnchors).width(g.tools.getGraphWidth()).height(g.tools.getGraphHeight()).start(g.conf.labelPlacementIterations),g.main.labels.each(function(t,e){var o=d3.select(this),n=g.data.simulatedAnnealingLabels[e].x,a=g.data.simulatedAnnealingLabels[e].y;g.conf.wrapLabels?(a-=(o.attr("lines")-1)*g.status.labelFontSize*g.conf.wrappedLabelLineHeight,o.transition().duration(800).attr("x",n).attr("y",a).selectAll("tspan").attr("x",n).attr("y",a)):o.transition().duration(800).attr("x",n).attr("y",a)})),g.status.forceRunning=!1;var t=(new Date).getTime()-g.status.forceStartTime,e=(t/1e3).toFixed(1),o=Math.round(g.status.forceTickCounter/(t/1e3)),n=Math.round(t/g.status.forceTickCounter);g.status.customize&&g.dom.customizePositions&&g.dom.customizePositions.text(JSON.stringify(p.positions())),g.tools.log("Force ended."),g.tools.log(e+" seconds, "+g.status.forceTickCounter+" ticks to cool down ("+o+" ticks/s, "+n+" ms/tick)."),g.tools.log("Event forceend triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_forceend"),g.conf.zoomToFitOnForceEnd?p.zoomToFit():g.conf.zoomMode||p.center(),"function"==typeof g.conf.onForceEndFunction&&g.conf.onForceEndFunction.call(g.dom.svg)}),g.main.drag=g.main.force.drag(),g.main.lasso=g.lib.lassoPlugin().closePathDistance(100).closePathSelect(!0).hoverSelect(!0).area(g.dom.graphOverlay).pathContainer(g.dom.svg),g.main.zoom=d3.behavior.zoom(),g.main.zoomed=function(){g.conf.transform={translate:g.main.zoom.translate(),scale:g.main.zoom.scale()},g.dom.graph.attr("transform","translate("+g.main.zoom.translate()+")scale("+g.main.zoom.scale()+")"),g.tools.writeConfObjectIntoWizard()},g.main.interpolateZoom=function(t,n,e){if(g.status.graphStarted)return n<g.conf.minZoomFactor?n=g.conf.minZoomFactor:n>g.conf.maxZoomFactor&&(n=g.conf.maxZoomFactor),d3.transition().duration(e).tween("zoom",function(){var e=d3.interpolate(g.main.zoom.translate(),t),o=d3.interpolate(g.main.zoom.scale(),n);return function(t){g.main.zoom.scale(o(t)).translate(e(t)),g.main.zoomed()}})}},g.tools.parseBool=function(t){switch(String(t).trim().toLowerCase()){case"true":case"yes":case"1":return!0;case"false":case"no":case"0":case"":default:return!1}},g.tools.parseXml=function(t){var e=null;if(t)if(window.DOMParser)try{e=(new DOMParser).parseFromString(t,"text/xml")}catch(t){e=null,g.tools.logError("DOMParser - unable to parse XML: "+t.message)}else if(window.ActiveXObject)try{(e=new ActiveXObject("Microsoft.XMLDOM")).async=!1,e.loadXML(t)||g.tools.logError("Microsoft.XMLDOM - unable to parse XML: "+e.parseError.reason+e.parseError.srcText)}catch(t){e=null,g.tools.logError("Microsoft.XMLDOM - unable to parse XML: "+t.message)}return e},g.tools.xmlToJson=function(t){var n,e,a,o,s,r=null,i=function(t){if(n={},0<t.attributes.length)for(var e=0;e<t.attributes.length;e++)s=t.attributes.item(e),n[s.nodeName]=s.nodeValue;if(t.hasChildNodes())for(var o=0;o<t.childNodes.length;o++)(a=t.childNodes.item(o)).hasChildNodes()?n[a.nodeName]=a.childNodes.item(0).nodeValue:n[a.nodeName]="";return n};if(t&&((r={data:{}}).data.nodes=[],r.data.links=[],t.childNodes.item(0).hasChildNodes()))for(var l=0;l<t.childNodes.item(0).childNodes.length;l++)n=null,"nodes"===(o=(e=t.childNodes.item(0).childNodes.item(l)).nodeName)||"node"===o?r.data.nodes.push(i(e)):"links"!==o&&"link"!==o||r.data.links.push(i(e));return r},g.tools.getSvgParentInnerWidth=function(){var t=parseInt(g.dom.svgParent.style("width")),e=parseInt(g.dom.svg.style("border-width"));return t=(isNaN(t)?g.conf.width:t)-parseInt(g.dom.svgParent.style("padding-left"))-parseInt(g.dom.svgParent.style("padding-right"))-2*(isNaN(e)?1:e)},g.tools.getGraphWidth=function(){return g.conf.useDomParentWidth?g.tools.getSvgParentInnerWidth():g.conf.width},g.tools.getGraphHeight=function(){return g.conf.useDomParentWidth&&g.conf.keepAspectRatioOnResize?1*g.tools.getSvgParentInnerWidth()/(g.status.aspectRatio?g.status.aspectRatio:1.5):g.conf.height},g.tools.executeResize=function(){var t=g.tools.getGraphWidth(),e=g.tools.getGraphHeight();g.dom.svg.attr("width",t),g.dom.svg.attr("height",e),g.dom.graphOverlaySizeHelper.attr("width",t),g.dom.graphOverlaySizeHelper.attr("height",e),g.dom.loadingRect.attr("width",t),g.dom.loadingRect.attr("height",e),g.dom.loadingText.attr("x",t/2),g.dom.loadingText.attr("y",e/2),g.main.zoom.size([t,e]),g.conf.zoomToFitOnResize?p.zoomToFit(0):g.conf.zoomMode||p.center(0),g.conf.showLegend&&g.tools.moveLegend(),g.tools.triggerResizeEvent()},g.tools.triggerResizeEvent=function(){g.status.graphStarted&&!g.status.resizeTriggered&&(g.status.resizeTriggered=!0,setTimeout(function(){g.tools.executeResizeEvent()},g.conf.onResizeFunctionTimeout))},g.tools.executeResizeEvent=function(){g.tools.log("Event resize triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_resize"),"function"==typeof g.conf.onResizeFunction&&g.conf.onResizeFunction.call(g.dom.svg),g.status.resizeTriggered=!1},g.tools.ResizeObserver=new ResizeObserver(function(t,e){t.forEach(function(t){g.conf.useDomParentWidth&&g.tools.executeResize()})}),g.tools.log=function(t,e){g.conf.debug&&(e?console.log(t):console.log(g.status.debugPrefix+t)),g.status.customize&&g.dom.customizeLog&&g.dom.customizeLog.text(t+"\n"+g.dom.customizeLog.text())},g.tools.logError=function(t){console.log(g.status.debugPrefix+"ERROR: "+t),g.status.customize&&g.dom.customizeLog&&g.dom.customizeLog.text("ERROR: "+t+"\n"+g.dom.customizeLog.text())},g.tools.triggerApexEvent=function(t,e,o){g.status.apexPluginId&&apex.event.trigger(t,e,o)},g.tools.setRadiusFunction=function(){g.tools.radius=d3.scale.sqrt().range([g.conf.minNodeRadius,g.conf.maxNodeRadius]).domain(d3.extent(g.data.nodes,function(t){return parseFloat(t.SIZEVALUE)}))},g.tools.setColorFunction=function(){"color20"===g.conf.colorScheme?g.tools.color=d3.scale.category20():"color20b"===g.conf.colorScheme?g.tools.color=d3.scale.category20b():"color20c"===g.conf.colorScheme?g.tools.color=d3.scale.category20c():"color10"===g.conf.colorScheme?g.tools.color=d3.scale.category10():"direct"===g.conf.colorScheme?g.tools.color=function(t){return t}:(g.conf.colorScheme="color20",g.tools.color=d3.scale.category20())},g.tools.neighboring=function(t,e){return-1<g.data.neighbors.indexOf(t.ID+":"+e.ID)||-1<g.data.neighbors.indexOf(e.ID+":"+t.ID)},g.tools.getNearestGridPosition=function(t,e){var o,n;return g.conf.zoomMode?n=(o=t%g.conf.gridSize)>g.conf.gridSize/2?t-o+g.conf.gridSize:t-o:e<=t?(n=e-(o=e%g.conf.gridSize))===e&&(n-=g.conf.gridSize):t<=g.conf.gridSize/2?n=g.conf.gridSize:e<=(n=(o=t%g.conf.gridSize)>g.conf.gridSize/2?t-o+g.conf.gridSize:t-o)&&(n-=g.conf.gridSize),n},g.tools.adjustSourceX=function(t){return t.source.x+Math.cos(g.tools.calcAngle(t))*t.source.radius},g.tools.adjustSourceY=function(t){return t.source.y+Math.sin(g.tools.calcAngle(t))*t.source.radius},g.tools.adjustTargetX=function(t){return t.target.x-Math.cos(g.tools.calcAngle(t))*t.target.radius},g.tools.adjustTargetY=function(t){return t.target.y-Math.sin(g.tools.calcAngle(t))*t.target.radius},g.tools.calcAngle=function(t){return Math.atan2(t.target.y-t.source.y,t.target.x-t.source.x)},g.tools.getSelfLinkPath=function(t){var e=t.source.radius,o=t.source.radius+g.conf.selfLinkDistance,n={source:{x:0,y:0,radius:e},target:{x:0-o/2,y:0+o,radius:e}},a={source:{x:0+o/2,y:0+o,radius:e},target:{x:0,y:0,radius:e}},s="M"+g.tools.adjustSourceX(n)+","+g.tools.adjustSourceY(n);return s+=" L"+(0-o/2)+","+(0+o),s+=" A"+o+","+o+" 0 0,0 "+(0+o/2)+","+(0+o),s+=" L"+g.tools.adjustTargetX(a)+","+g.tools.adjustTargetY(a)},g.tools.getLabelPath=function(t){var e=t.radius+g.conf.labelDistance,o="M"+(0-e)+",0";return o+=" a"+e+","+e+" 0 0,1 "+2*e+",0",o+=" a"+e+","+e+" 0 0,1 -"+2*e+",0"},g.tools.getPatternId=function(t){return g.dom.containerId+"_pattern_"+t.ID},g.tools.getLinkId=function(t){return t.FROMID+"_"+t.TOID},g.tools.getPathId=function(t){return g.dom.containerId+"_path_"+g.tools.getLinkId(t)},g.tools.openLink=function(t){"none"===g.conf.nodeLinkTarget?window.location.assign(t.LINK):"nodeID"===g.conf.nodeLinkTarget?window.open(t.LINK,t.ID).focus():"domContainerID"===g.conf.nodeLinkTarget?window.open(t.LINK,g.dom.containerId).focus():window.open(t.LINK,g.conf.nodeLinkTarget).focus()},g.tools.applyConfigurationObject=function(t){var e;for(e in t)t.hasOwnProperty(e)&&g.conf.hasOwnProperty(e)&&t[e]!==g.conf[e]&&p[e](t[e])},g.tools.zoomEventProxy=function(t){return function(){g.conf.dragMode&&(!g.conf.dragMode||"circle"===d3.event.target.tagName)||!g.conf.zoomMode||d3.event.altKey||d3.event.shiftKey||t.apply(this,arguments)}},g.tools.lassoEventProxy=function(t){return function(){g.conf.dragMode&&"circle"===d3.event.target.tagName||!g.conf.lassoMode||g.conf.zoomMode&&!d3.event.altKey&&!d3.event.shiftKey||t.apply(this,arguments)}},g.tools.showTooltip=function(t){var e;g.dom.tooltip.html(t).style("display","block"),"svgTopLeft"===g.conf.tooltipPosition?(e=g.tools.getOffsetRect(g.dom.svg.node()),g.dom.tooltip.style("top",e.top+(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)+"px").style("left",e.left+(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)+"px")):"svgTopRight"===g.conf.tooltipPosition?(e=g.tools.getOffsetRect(g.dom.svg.node()),g.dom.tooltip.style("top",e.top+parseInt(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)+"px").style("left",e.left+parseInt(g.dom.svg.style("width"))+parseInt(g.dom.svg.style("border-width")?parseInt(g.dom.svg.style("border-width")):1)-parseInt(g.dom.tooltip.style("width"))-2*parseInt(g.dom.tooltip.style("border-width")?parseInt(g.dom.tooltip.style("border-width")):0)-parseInt(g.dom.tooltip.style("padding-left"))-parseInt(g.dom.tooltip.style("padding-right"))+"px")):g.dom.tooltip.style("left",d3.event.pageX+10+"px").style("top",d3.event.pageY+"px")},g.tools.hideTooltip=function(){g.dom.tooltip.style("display","none")},g.tools.onLinkClick=function(t){if(d3.event.defaultPrevented)return null;g.tools.log("Event linkclick triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_linkclick",t),"function"==typeof g.conf.onLinkClickFunction&&g.conf.onLinkClickFunction.call(this,d3.event,t)},g.tools.getMarkerUrl=function(t){return g.conf.showLinkDirection?"url(#"+g.dom.containerId+"_"+(t.COLOR?t.COLOR:"normal")+")":null},g.tools.getMarkerUrlHighlighted=function(){return g.conf.showLinkDirection?"url(#"+g.dom.containerId+"_highlighted)":null},g.tools.onLinkMouseenter=function(t){g.conf.showTooltips&&t.INFOSTRING&&g.tools.showTooltip(t.INFOSTRING)},g.tools.onLinkMouseleave=function(){g.conf.showTooltips&&g.tools.hideTooltip()},g.tools.onNodeMouseenter=function(e){g.main.nodes.classed("highlighted",function(t){return g.tools.neighboring(t,e)}),g.main.links.classed("highlighted",function(t){return t.source.ID===e.ID||t.target.ID===e.ID}).style("marker-end",function(t){return t.source.ID===e.ID||t.target.ID===e.ID?g.tools.getMarkerUrlHighlighted(t):g.tools.getMarkerUrl(t)}),g.main.selfLinks.classed("highlighted",function(t){return t.FROMID===e.ID}).style("marker-end",function(t){return t.source.ID===e.ID||t.target.ID===e.ID?g.tools.getMarkerUrlHighlighted(t):g.tools.getMarkerUrl(t)}),g.conf.showLabels&&(g.main.labels.classed("highlighted",function(t){return t.ID===e.ID}),g.main.labelsCircular.classed("highlighted",function(t){return t.ID===e.ID})),d3.select(this).classed("highlighted",!0),g.tools.log("Event nodemouseenter triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_mouseenter",e),"function"==typeof g.conf.onNodeMouseenterFunction&&g.conf.onNodeMouseenterFunction.call(this,d3.event,e),g.conf.showTooltips&&e.INFOSTRING&&g.tools.showTooltip(e.INFOSTRING)},g.tools.onNodeMouseleave=function(t){g.main.nodes.classed("highlighted",!1),g.main.links.classed("highlighted",!1).style("marker-end",g.tools.getMarkerUrl),g.main.selfLinks.classed("highlighted",!1).style("marker-end",g.tools.getMarkerUrl),g.conf.showLabels&&(g.main.labels.classed("highlighted",!1),g.main.labelsCircular.classed("highlighted",!1)),g.tools.log("Event nodemouseleave triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_mouseleave",t),"function"==typeof g.conf.onNodeMouseleaveFunction&&g.conf.onNodeMouseleaveFunction.call(this,d3.event,t),g.conf.showTooltips&&g.tools.hideTooltip()},g.tools.onNodeClick=function(t){if(d3.event.defaultPrevented)return null;t.LINK&&"click"===g.conf.nodeEventToOpenLink&&g.tools.openLink(t),"click"===g.conf.nodeEventToStopPinMode&&d3.select(this).classed("fixed",t.fixed=0),g.tools.log("Event nodeclick triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_click",t),"function"==typeof g.conf.onNodeClickFunction&&g.conf.onNodeClickFunction.call(this,d3.event,t)},g.tools.onNodeDblclick=function(t){t.LINK&&"dblclick"===g.conf.nodeEventToOpenLink&&g.tools.openLink(t),"dblclick"===g.conf.nodeEventToStopPinMode&&d3.select(this).classed("fixed",t.fixed=0),g.tools.log("Event nodedblclick triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_dblclick",t),"function"==typeof g.conf.onNodeDblclickFunction&&g.conf.onNodeDblclickFunction.call(this,d3.event,t)},g.tools.onNodeContextmenu=function(t){g.conf.onNodeContextmenuPreventDefault&&d3.event.preventDefault(),t.LINK&&"contextmenu"===g.conf.nodeEventToOpenLink&&g.tools.openLink(t),"contextmenu"===g.conf.nodeEventToStopPinMode&&d3.select(this).classed("fixed",t.fixed=0),g.tools.log("Event nodecontextmenu triggered."),g.tools.triggerApexEvent(this,"net_gobrechts_d3_force_contextmenu",t),"function"==typeof g.conf.onNodeContextmenuFunction&&g.conf.onNodeContextmenuFunction.call(this,d3.event,t)},g.tools.onLassoStart=function(t){var e={numberOfSelectedNodes:0,idsOfSelectedNodes:null};e.numberOfNodes=t.size(),e.nodes=t,g.tools.log("Event lassostart triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_lassostart",e),"function"==typeof g.conf.onLassoStartFunction&&g.conf.onLassoStartFunction.call(g.dom.svg,d3.event,e)},g.tools.onLassoEnd=function(t){var e={numberOfSelectedNodes:0,idsOfSelectedNodes:""};e.numberOfNodes=t.size(),(e.nodes=t).each(function(t){t.selected&&(e.idsOfSelectedNodes+=t.ID+":",e.numberOfSelectedNodes++)}),e.idsOfSelectedNodes=0<e.idsOfSelectedNodes.length?e.idsOfSelectedNodes.substr(0,e.idsOfSelectedNodes.length-1):null,g.tools.log("Event lassoend triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_lassoend",e),"function"==typeof g.conf.onLassoEndFunction&&g.conf.onLassoEndFunction.call(g.dom.svg,d3.event,e)},g.tools.getOffsetRect=function(t){var e=t.getBoundingClientRect(),o=document.body,n=document.documentElement,a=window.pageYOffset||n.scrollTop||o.scrollTop,s=window.pageXOffset||n.scrollLeft||o.scrollLeft,r=n.clientTop||o.clientTop||0,i=n.clientLeft||o.clientLeft||0,l=e.top+a-r,d=e.left+s-i;return{top:Math.round(l),left:Math.round(d)}},g.tools.getGraphDataWithMessage=function(t){return{nodes:[{ID:"1",LABEL:"ERROR: "+t,COLORVALUE:"1",SIZEVALUE:"1"}],links:[]}},g.tools.getNodesDataWithMessage=function(t){return[{ID:"1",LABEL:"ERROR: "+t,COLORVALUE:"1",SIZEVALUE:"1"}]},g.tools.createLegend=function(){g.status.initialLegendHeight=g.tools.getGraphHeight(),g.data.distinctNodeColorValues.forEach(function(t,e){var o=t.split(";");g.dom.legend.append("circle").attr("cx",11).attr("cy",g.status.initialLegendHeight-(14*(e+1)-3)).attr("r",6).attr("fill",g.tools.color(o[1])),g.dom.legend.append("text").attr("x",21).attr("y",g.status.initialLegendHeight-(14*(e+1)-6)).text(o[0]?o[0]:o[1])})},g.tools.moveLegend=function(){var t=g.tools.getGraphHeight()-g.status.initialLegendHeight;g.dom.legend.attr("transform","translate(0,"+t+")")},g.tools.removeLegend=function(){g.dom.legend.selectAll("*").remove(),g.dom.legend.attr("transform",null)},g.tools.writeConfObjectIntoWizard=function(){g.status.customize&&g.dom.customizeConfObject.text(JSON.stringify(p.optionsCustomizationWizard(),null," "))},g.tools.createCustomizeLink=function(){!g.status.customize&&(g.conf.debug||document.querySelector("#apex-dev-toolbar")||document.querySelector("#apexDevToolbar"))&&null===document.querySelector("#"+g.dom.containerId+" svg text.link")&&g.dom.svg.append("svg:text").attr("class","link").attr("x",5).attr("y",15).attr("text-anchor","start").text("Customize Me").on("click",function(){p.customize(!0)})},g.tools.removeCustomizeLink=function(){g.dom.svg.select("#"+g.dom.containerId+" svg text.link").remove()},g.tools.customizeDrag=d3.behavior.drag().on("dragstart",function(){var t=d3.mouse(document.body);g.dom.customizePosition=g.tools.getOffsetRect(document.querySelector("#"+g.dom.containerId+"_customizing")),g.dom.customizePosition.mouseLeft=t[0]-g.dom.customizePosition.left,g.dom.customizePosition.mouseTop=t[1]-g.dom.customizePosition.top}).on("drag",function(){var t=d3.mouse(document.body);g.dom.customize.style("left",Math.max(0,t[0]-g.dom.customizePosition.mouseLeft)+"px").style("top",Math.max(0,t[1]-g.dom.customizePosition.mouseTop)+"px")}).on("dragend",function(){g.dom.customizePosition=g.tools.getOffsetRect(g.dom.customize.node())}),g.tools.createCustomizeWizardIfNotRendering=function(){g.status.customize&&!g.status.graphRendering&&g.tools.createCustomizeWizard()},g.tools.createCustomizeWizard=function(){var t,e,o,n,a,s,r,i,l,d=4,c=function(){p.releaseFixedNodes().resume()},u=function(){g.status.customizeCurrentTabPosition=this.id,"text"===g.confDefaults[this.name].type?p[this.name](this.options[this.selectedIndex].value).render():"number"===g.confDefaults[this.name].type?p[this.name](parseFloat(this.options[this.selectedIndex].value)).render():"bool"===g.confDefaults[this.name].type&&p[this.name]("true"===this.options[this.selectedIndex].value).render()},f=function(e){g.confDefaults[e].options.forEach(function(t){r=t,s.append("option").attr("value",t).attr("selected",function(){return"text"===g.confDefaults[e].type||"bool"===g.confDefaults[e].type?r===g.conf[e]?(i=!0,"selected"):null:"number"===g.confDefaults[e].type?parseFloat(r)===g.conf[e]?(i=!0,"selected"):null:void 0}).text(t)})};if(g.status.customize){for(l in g.tools.removeCustomizeLink(),g.dom.customizePosition||(g.dom.customizePosition=g.tools.getOffsetRect(g.dom.svg.node()),g.dom.customizePosition.top=g.dom.customizePosition.top+100,g.dom.customizePosition.left=g.dom.customizePosition.left+200),null!==document.querySelector("#"+g.dom.containerId+"_customizing")&&g.dom.customize.remove(),g.dom.customize=g.dom.body.insert("div").attr("id",g.dom.containerId+"_customizing").attr("class","net_gobrechts_d3_force_customize").style("left",g.dom.customizePosition.left+"px").style("top",g.dom.customizePosition.top+"px"),g.dom.customize.append("span").attr("class","drag").call(g.tools.customizeDrag).append("span").attr("class","title").text('Customize "'+g.dom.containerId+'"'),g.dom.customize.append("a").attr("class","close focus").attr("tabindex",1).text("Close").on("click",function(){g.status.customize=!1,g.tools.removeCustomizeWizard(),g.tools.createCustomizeLink()}).on("keydown",function(){13===d3.event.keyCode&&(g.status.customize=!1,g.tools.removeCustomizeWizard(),g.tools.createCustomizeLink())}),o=(e=(t=g.dom.customize.append("table")).append("tr")).append("td").style("vertical-align","top"),g.dom.customizeMenu=o.append("span"),g.dom.customizeOptionsTable=o.append("table"),g.confDefaults)g.confDefaults.hasOwnProperty(l)&&g.confDefaults[l].display&&(d+=1,(n=g.dom.customizeOptionsTable.append("tr").attr("class",g.confDefaults[l].relation+"-related")).append("td").attr("class","label").html('<a href="https://ogobrecht.github.io/d3-force-apex-plugin/module-API.html#.'+l+'" target="github_d3_force" tabindex="'+d+'100">'+l+"</a>"),a=n.append("td"),s=a.append("select").attr("id",g.dom.containerId+"_"+l).attr("name",l).attr("value",g.conf[l]).attr("tabindex",d+1).classed("warning",g.confDefaults[l].internal).on("change",u),i=!1,f(l),i||(s.append("option").attr("value",g.conf[l]).attr("selected","selected").text(g.conf[l]),g.confDefaults[l].options.push(g.conf[l])),"pinMode"===l&&a.append("a").text(" release all").attr("href",null).on("click",c));g.dom.customizeOptionsTable.style("width",d3.select(g.dom.customizeOptionsTable).node()[0][0].clientWidth+"px"),o.append("span").html("<br>"),(o=e.append("td").style("vertical-align","top").style("padding-left","5px")).append("span").html('Your Configuration Object<p style="font-size:10px;margin:0;">'+(g.status.apexPluginId?"To save your options please copy<br>this to your plugin region attributes.<br>Only non-default options are shown.</p>":"Use this to initialize your graph.<br>Only non-default options are shown.</p>")),g.dom.customizeConfObject=o.append("textarea").attr("tabindex",d+5).attr("readonly","readonly"),o.append("span").html("<br><br>Current Positions<br>"),g.dom.customizePositions=o.append("textarea").attr("tabindex",d+6).attr("readonly","readonly").text(g.status.forceRunning?"Force started - wait for end event to show positions...":JSON.stringify(p.positions())),o.append("span").html("<br><br>Debug Log (descending)<br>"),g.dom.customizeLog=o.append("textarea").attr("tabindex",d+7).attr("readonly","readonly"),o=(e=t.append("tr")).append("td").attr("colspan",2).html("Copyrights:"),o=(e=t.append("tr")).append("td").attr("colspan",2).html('<table><tr><td style="padding-right:20px;"><a href="https://github.com/ogobrecht/d3-force-apex-plugin" target="_blank" tabindex="'+(d+8)+'">D3 Force APEX Plugin</a> ('+g.version+')<br>Ottmar Gobrecht</td><td style="padding-right:20px;"><a href="https://github.com/mbostock/d3" target="d3js_org" tabindex="'+(d+9)+'">D3.js</a> ('+d3.version+') and <a href="https://github.com/d3/d3-plugins/tree/master/lasso" target="_blank" tabindex="'+(d+10)+'">D3 Lasso Plugin</a> (modified)<br>Mike Bostock</td></tr><tr><td colspan="3"><a href="https://github.com/tinker10/D3-Labeler" target="github_d3_labeler" tabindex="'+(d+11)+'">D3 Labeler Plugin</a> (automatic label placement using simulated annealing)<br>Evan Wang</td></tr></table>'),g.tools.createCustomizeMenu(g.status.customizeCurrentMenu),g.tools.writeConfObjectIntoWizard(),g.status.customizeCurrentTabPosition&&document.getElementById(g.status.customizeCurrentTabPosition).focus()}else g.tools.removeCustomizeWizard(),g.tools.createCustomizeLink()},g.tools.removeCustomizeWizard=function(){d3.select("#"+g.dom.containerId+"_customizing").remove()},g.tools.createCustomizeMenu=function(t){g.status.customizeCurrentMenu=t,g.dom.customizeMenu.selectAll("*").remove(),g.dom.customizeMenu.append("span").text("Show options for:"),"nodes"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("NODES"),g.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.label-related,tr.link-related,tr.graph-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("NODES").attr("tabindex",2).on("click",function(){g.tools.createCustomizeMenu("nodes"),g.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.label-related,tr.link-related,tr.graph-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("nodes"),g.dom.customizeOptionsTable.selectAll("tr.node-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.label-related,tr.link-related,tr.graph-related").classed("hidden",!0))}),"labels"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("LABELS"),g.dom.customizeOptionsTable.selectAll("tr.label-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related,tr.graph-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("LABELS").attr("tabindex",2).on("click",function(){g.tools.createCustomizeMenu("labels"),g.dom.customizeOptionsTable.selectAll("tr.label-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related,tr.graph-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("labels"),g.dom.customizeOptionsTable.selectAll("tr.label-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.link-related,tr.graph-related").classed("hidden",!0))}),"links"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("LINKS"),g.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.graph-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("LINKS").attr("tabindex",3).on("click",function(){g.tools.createCustomizeMenu("links"),g.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.graph-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("links"),g.dom.customizeOptionsTable.selectAll("tr.link-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.graph-related").classed("hidden",!0))}),"graph"===g.status.customizeCurrentMenu?(g.dom.customizeMenu.append("span").style("font-weight","bold").style("margin-left","10px").text("GRAPH"),g.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.link-related").classed("hidden",!0)):g.dom.customizeMenu.append("a").style("font-weight","bold").style("margin-left","10px").text("GRAPH").attr("tabindex",4).on("click",function(){g.tools.createCustomizeMenu("graph"),g.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.link-related").classed("hidden",!0)}).on("keydown",function(){13===d3.event.keyCode&&(g.tools.createCustomizeMenu("graph"),g.dom.customizeOptionsTable.selectAll("tr.graph-related").classed("hidden",!1),g.dom.customizeOptionsTable.selectAll("tr.node-related,tr.label-related,tr.link-related").classed("hidden",!0))}),g.dom.customizeMenu.append("span").html("<br><br>")},g.tools.wrapLabels=function(t,u){t.each(function(t,e){var o=d3.select(this);if(0===e&&(g.status.labelFontSize=parseInt(o.style("font-size"))),!this.hasAttribute("lines")){var n,a=o.text().split("none"!==g.conf.labelSplitCharacter?g.conf.labelSplitCharacter:/\s+/).reverse(),s=[],r=0,i=g.status.labelFontSize*g.conf.wrappedLabelLineHeight,l=o.attr("x"),d=o.attr("y"),c=o.text(null).append("tspan").attr("x",l).attr("y",d).attr("dy","0px");if("none"!==g.conf.labelSplitCharacter)for(;n=a.pop();)c=o.append("tspan").attr("x",l).attr("y",d).attr("dy",++r*i+0+"px").text(n);else for(;n=a.pop();)s.push(n),c.text(s.join(" ")),c.node().getComputedTextLength()>u&&(s.pop(),c.text(s.join(" ")),s=[n],c=o.append("tspan").attr("x",l).attr("y",d).attr("dy",++r*i+0+"px").text(n));o.attr("lines",r+1)}})},g.lib.labelerPlugin=function(){var u,h=[],m=[],f=1,g=1,e={},p=!1,L=function(t){var e=h.length,o=0,n=h[t].x-m[t].x,a=m[t].y-h[t].y,s=Math.sqrt(n*n+a*a);0<s&&(o+=.2*s),a/=s,o+=0<(n/=s)&&0<a?0:n<0&&0<a?1:n<0&&a<0?2:3;for(var r,i,l,d,c=h[t].x,u=h[t].y-h[t].height+2,f=h[t].x+h[t].width,g=h[t].y+2,p=0;p<e;p++)p!==t&&(v(m[t].x,h[t].x,m[p].x,h[p].x,m[t].y,h[t].y,m[p].y,h[p].y)&&(o+=1),r=h[p].x,l=h[p].y-h[p].height+2,i=h[p].x+h[p].width,d=h[p].y+2,o+=30*(Math.max(0,Math.min(i,f)-Math.max(r,c))*Math.max(0,Math.min(d,g)-Math.max(l,u)))),r=m[p].x-m[p].r,l=m[p].y-m[p].r,i=m[p].x+m[p].r,d=m[p].y+m[p].r,o+=30*(Math.max(0,Math.min(i,f)-Math.max(r,c))*Math.max(0,Math.min(d,g)-Math.max(l,u)));return o},s=function(t){var e,o=Math.floor(Math.random()*h.length),n=h[o].x,a=h[o].y;e=p?u(o,h,m):L(o),h[o].x+=5*(Math.random()-.5),h[o].y+=5*(Math.random()-.5),h[o].x>f&&(h[o].x=n),h[o].x<0&&(h[o].x=n),h[o].y>g&&(h[o].y=a),h[o].y<0&&(h[o].y=a);var s=(p?u(o,h,m):L(o))-e;Math.random()<Math.exp(-s/t)?1:(h[o].x=n,h[o].y=a,1)},r=function(t){var e,o=Math.floor(Math.random()*h.length),n=h[o].x,a=h[o].y;e=p?u(o,h,m):L(o);var s=.5*(Math.random()-.5),r=Math.sin(s),i=Math.cos(s);h[o].x-=m[o].x,h[o].y-=m[o].y;var l=h[o].x*i-h[o].y*r,d=h[o].x*r+h[o].y*i;h[o].x=l+m[o].x,h[o].y=d+m[o].y,h[o].x>f&&(h[o].x=n),h[o].x<0&&(h[o].x=n),h[o].y>g&&(h[o].y=a),h[o].y<0&&(h[o].y=a);var c=(p?u(o,h,m):L(o))-e;Math.random()<Math.exp(-c/t)?1:(h[o].x=n,h[o].y=a,1)},v=function(t,e,o,n,a,s,r,i){var l,d,c;return d=((e-t)*(a-r)-(s-a)*(t-o))/(c=(i-r)*(e-t)-(n-o)*(s-a)),!((l=((n-o)*(a-r)-(i-r)*(t-o))/c)<0||1<l||d<0||1<d)},i=function(t,e,o){return t-e/o};return e.start=function(t){for(var e=h.length,o=1,n=0;n<t;n++){for(var a=0;a<e;a++)Math.random()<.5?s(o):r(o);o=i(o,1,t)}},e.width=function(t){return arguments.length?(f=t,e):f},e.height=function(t){return arguments.length?(g=t,e):g},e.label=function(t){return arguments.length?(h=t,e):h},e.anchor=function(t){return arguments.length?(m=t,e):m},e.alt_energy=function(t){return arguments.length?(u=t,p=!0,e):L},e.alt_schedule=function(t){return arguments.length?(t,!0,e):i},e},g.lib.lassoPlugin=function(){var I=null,O=75,R=!0,E=!1,n=!0,a=null,s=null,C={start:function(){},draw:function(){},end:function(){}};function o(){var t,v,b,y,x,z,D,k,e,o=d3.select(this[0][0]);y=0===(s=s||o).selectAll("g.lasso").size()?(t=s.append("g").attr("class","lasso"),v=t.append("path").attr("class","drawn"),b=t.append("path").attr("class","loop_close"),t.append("path").attr("class","complete_path").attr("display","none")):(t=s.select("g.lasso"),v=t.select("path.drawn"),b=t.select("path.loop_close"),t.select("path.complete_path")),e=d3.behavior.drag().on("dragstart",function(){x="",v.attr("d",null),b.attr("d",null),I[k=0].forEach(function(t){t.hoverSelected=!1,t.loopSelected=!1;var e=t.getBBox(),o=t.getCTM();t.lassoPoint={cx:Math.round((e.x+e.width/2)*o.a+o.e),cy:Math.round((e.y+e.height/2)*o.d+o.f),edges:{top:0,right:0,bottom:0,left:0},close_edges:{left:0,right:0}}}),!0===n&&I.on("mouseover.lasso",function(){d3.select(this)[0][0].hoverSelected=!0}),C.start()}).on("drag",function(){var t,e,o,n,a,s,r,i,l,d,c,u,f=d3.mouse(this)[0],g=d3.mouse(this)[1],p=function(t){u.x>t.lassoPoint.cx&&(t.lassoPoint.edges.right=t.lassoPoint.edges.right+1),u.x<t.lassoPoint.cx&&(t.lassoPoint.edges.left=t.lassoPoint.edges.left+1)},h=function(t){Math.round(c.y)!==Math.round(l.y)&&Math.round(c.x)>t.lassoPoint.cx&&(t.lassoPoint.close_edges.right=1),Math.round(c.y)!==Math.round(l.y)&&Math.round(c.x)<t.lassoPoint.cx&&(t.lassoPoint.close_edges.left=1)},m=function(t){return t.lassoPoint.cy===Math.round(c.y)},L=function(t){return t.lassoPoint.cy===u.y&&t.lassoPoint.cy!==d.y?!(D={x:d.x,y:d.y}):(t.lassoPoint.cy!==u.y||t.lassoPoint.cy!==d.y)&&(t.lassoPoint.cy===d.y&&t.lassoPoint.cy!==u.y?S(t.lassoPoint.cy-u.y)!==S(t.lassoPoint.cy-D.y):(D={x:d.x,y:d.y},S(t.lassoPoint.cy-u.y)!==S(t.lassoPoint.cy-d.y)))};for(""===x?(x=x+"M "+f+" "+g,z=[f,g]):x=x+" L "+f+" "+g,I[0].forEach(function(t){t.lassoPoint.close_edges={left:0,right:0}}),t=Math.sqrt(Math.pow(f-z[0],2)+Math.pow(g-z[1],2)),e="M "+f+" "+g+" L "+z[0]+" "+z[1],v.attr("d",x),t<=O?b.attr("display",null):b.attr("display","none"),E=t<=O,o=d3.select("path")[0][0].attributes.d.value+"Z",y.attr("d",o),r=(s=v.node()).getTotalLength(),s.getPointAtLength(k-1),i=k;i<=r;i++)c=s.getPointAtLength(i),u={x:Math.round(100*c.x)/100,y:Math.round(100*c.y)/100},l=s.getPointAtLength(i-1),d={x:Math.round(100*l.x)/100,y:Math.round(100*l.y)/100},I[0].filter(L).forEach(p);if(!0===E&&!0===R){for(b.attr("d",e),a=(n=b.node()).getTotalLength(),i=0;i<=a;i++)c=n.getPointAtLength(i),l=n.getPointAtLength(i-1),I[0].filter(m).forEach(h);I[0].forEach(function(t){0<t.lassoPoint.edges.left+t.lassoPoint.close_edges.left&&(t.lassoPoint.edges.right+t.lassoPoint.close_edges.right)%2==1?t.loopSelected=!0:t.loopSelected=!1})}else I[0].forEach(function(t){t.loopSelected=!1});d3.selectAll(I[0].filter(function(t){return t.loopSelected&&E||t.hoverSelected})).attr("d",function(t){return t.possible=!0,t.possible}),d3.selectAll(I[0].filter(function(t){return!(t.loopSelected&&E||t.hoverSelected)})).attr("d",function(t){return t.possible=!1,t.possible}),C.draw(),k=r+1}).on("dragend",function(){I.on("mouseover.lasso",null),I.filter(function(t){return!0===t.possible}).attr("d",function(t){return t.selected=!0,t.selected}),I.filter(function(t){return!1===t.possible}).attr("d",function(t){return t.selected=!1,t.selected}),I.attr("d",function(t){return t.possible=!1,t.possible}),v.attr("d",null),b.attr("d",null),C.end()}),a.call(e)}function S(t){return t?t<0?-1:1:0}return o.items=function(t){return arguments.length?((I=t)[0].forEach(function(t){var e=d3.select(t);void 0===e.datum()?e.datum({possible:!1,selected:!1}):e.attr("d",function(t){return t.possible=!1,t.selected=!1,t})}),o):I},o.closePathDistance=function(t){return arguments.length?(O=t,o):O},o.closePathSelect=function(t){return arguments.length?(R=!0===t,o):R},o.isPathClosed=function(t){return arguments.length?(E=!0===t,o):E},o.hoverSelect=function(t){return arguments.length?(n=!0===t,o):n},o.on=function(t,e){if(!arguments.length)return C;if(1===arguments.length)return C[t];return-1<["start","draw","end"].indexOf(t)&&(C[t]=e),o},o.area=function(t){return arguments.length?(a=t,o):a},o.pathContainer=function(t){return arguments.length?(s=d3.select(t[0][0]),o):s},o},p.start=function(t){var e;return t?p.render(t):g.status.apexPluginId?(g.conf.showLoadingIndicatorOnAjaxCall&&p.showLoadingIndicator(!0),apex.server.plugin(g.status.apexPluginId,{p_debug:$v("pdebug"),pageItems:g.status.apexPageItemsToSubmit},{success:function(t){g.conf.showLoadingIndicatorOnAjaxCall&&p.showLoadingIndicator(!1),"<"===(e=t.trim().substr(0,1))||"{"===e?p.render(t.trim()):"no_query_defined"===t.trim().substr(0,16)?(g.tools.logError("No query defined."),p.render()):"query_returned_no_data"===t.trim().substr(0,22)?(g.tools.logError("Query returned no data."),p.render({data:{nodes:[{ID:"1",LABEL:"ERROR: No data.",COLORVALUE:"1",SIZEVALUE:"1"}],links:[]}})):(g.tools.logError(t),p.render({data:{nodes:[{ID:"1",LABEL:"ERROR: "+t+".",COLORVALUE:"1",SIZEVALUE:"1"}],links:[]}}))},error:function(t,e,o){g.tools.logError("AJAX call terminated with errors: "+o+"."),p.render({data:{nodes:[{ID:"1",LABEL:"AJAX call terminated with errors.",COLORVALUE:"1",SIZEVALUE:"1"}],links:[]}})},dataType:"text"})):p.render(),p},p.render=function(t){var e;if(g.status.graphStarted=!0,g.status.graphRendering=!0,g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"apexbeforerefresh"),t?g.status.sampleData=!1:t||g.status.graphReady||(g.tools.logError("Houston, we have a problem - we have to provide sample data."),g.status.sampleData=!0,t=g.data.sampleData),t){if(g.status.graphReady&&(g.status.graphOldPositions=p.positions()),t.constructor===Object)g.data.dataConverted=t,g.conf.debug&&(g.tools.log("Data object:"),g.tools.log(g.data.dataConverted,!0));else if(t.constructor===String){if("<"===t.trim().substr(0,1))try{g.data.dataConverted=g.tools.xmlToJson(g.tools.parseXml(t)),null===g.data.dataConverted&&(e="Unable to convert XML string.",g.tools.logError(e),g.data.dataConverted=g.tools.getGraphDataWithMessage(e))}catch(t){e="Unable to convert XML string: "+t.message+".",g.tools.logError(e),g.data.dataConverted=g.tools.getGraphDataWithMessage(e)}else if("{"===t.trim().substr(0,1))try{g.data.dataConverted=JSON.parse(t)}catch(t){e="Unable to parse JSON string: "+t.message+".",g.tools.logError(e),g.data.dataConverted=g.tools.getGraphDataWithMessage(e)}else e='Your data string is not starting with "<" or "{" - parsing not possible.',g.tools.logError(e),g.data.dataConverted=g.tools.getGraphDataWithMessage(e);g.conf.debug&&(g.tools.log("Data string:"),g.tools.log(t,!0),g.tools.log("Converted data object:"),g.tools.log(g.data.dataConverted,!0))}else e="Unable to parse your data - input data can be a XML string, JSON string or JavaScript object.",g.tools.logError(e),g.data.dataConverted=g.tools.getGraphDataWithMessage(e);null!==g.data.dataConverted?g.data.dataConverted.hasOwnProperty("data")&&null!==g.data.dataConverted.data?(g.data.dataConverted.data.hasOwnProperty("nodes")&&null!==g.data.dataConverted.data.nodes?(g.data.nodes=g.data.dataConverted.data.nodes,0===g.data.nodes.length&&(e="Your data contains an empty nodes array.",g.tools.logError(e),g.data.nodes=g.tools.getNodesDataWithMessage(e))):(e="Your data contains no nodes.",g.tools.logError(e),g.data.nodes=g.tools.getNodesDataWithMessage(e)),g.data.dataConverted.data.hasOwnProperty("links")&&null!==g.data.dataConverted.data.links?g.data.links=g.data.dataConverted.data.links:g.data.links=[]):(e="Missing root element named data.",g.tools.logError(e),g.data=g.tools.getGraphDataWithMessage(e)):(e="Unable to parse your data - please consult the API reference for possible data formats.",g.tools.logError(e),g.data=g.tools.getGraphDataWithMessage(e)),g.data.idLookup=[],g.data.nodes.forEach(function(t){t.SIZEVALUE=parseFloat(t.SIZEVALUE),t.LABELCIRCULAR=g.tools.parseBool(t.LABELCIRCULAR),t.fixed&&(t.fixed=g.tools.parseBool(t.fixed)),t.x&&(t.x=parseFloat(t.x)),t.y&&(t.y=parseFloat(t.y)),g.data.idLookup[t.ID]=t}),g.data.links.forEach(function(t){t.source=g.data.idLookup[t.FROMID],t.target=g.data.idLookup[t.TOID]}),g.data.links=g.data.links.filter(function(t){return void 0!==t.source&&void 0!==t.target}),g.data.neighbors=g.data.links.map(function(t){return t.FROMID+":"+t.TOID}),g.data.distinctNodeColorValues=g.data.nodes.map(function(t){return(t.COLORLABEL?t.COLORLABEL:"")+";"+t.COLORVALUE}).filter(function(t,e,o){return o.indexOf(t)===e}).sort(function(t,e){var o=t.toLowerCase(),n=e.toLowerCase();return o<n?1:n<o?-1:0}),g.data.distinctLinkColorValues=g.data.links.map(function(t){return t.COLOR}).filter(Boolean).filter(function(t,e,o){return o.indexOf(t)===e}).sort(function(t,e){var o=t.toLowerCase(),n=e.toLowerCase();return o<n?1:n<o?-1:0}),g.conf.positions?g.conf.positions.constructor===Array?g.conf.positions.forEach(function(t){void 0!==g.data.idLookup[t.ID]&&(g.data.idLookup[t.ID].fixed||(g.data.idLookup[t.ID].fixed=t.fixed),g.data.idLookup[t.ID].x||(g.data.idLookup[t.ID].x=g.data.idLookup[t.ID].px=t.x),g.data.idLookup[t.ID].y||(g.data.idLookup[t.ID].y=g.data.idLookup[t.ID].py=t.y))}):g.tools.logError("Unable to set node positions: positions method parameter must be an array of node positions"):g.status.graphOldPositions&&g.status.graphOldPositions.forEach(function(t){void 0!==g.data.idLookup[t.ID]&&(g.data.idLookup[t.ID].fixed||(g.data.idLookup[t.ID].fixed=t.fixed),g.data.idLookup[t.ID].x||(g.data.idLookup[t.ID].x=g.data.idLookup[t.ID].px=t.x),g.data.idLookup[t.ID].y||(g.data.idLookup[t.ID].y=g.data.idLookup[t.ID].py=t.y))}),g.conf.positions=null,g.status.graphOldPositions=null}g.tools.setColorFunction(),g.tools.setRadiusFunction(),g.data.nodes.forEach(function(t){t.radius=g.tools.radius(t.SIZEVALUE)}),g.main.markers=g.dom.defs.selectAll("marker.custom").data(g.data.distinctLinkColorValues,function(t){return t}),g.main.markers.enter().append("svg:marker").attr("id",function(t){return g.dom.containerId+"_"+t}).attr("class","custom").attr("stroke","none").attr("fill",function(t){return t}).attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").attr("markerUnits","strokeWidth").append("svg:path").attr("d","M0,0 L10,5 L0,10"),g.main.markers.exit().remove(),g.main.links=g.dom.graph.selectAll("line.link").data(g.data.links.filter(function(t){return t.FROMID!==t.TOID}),function(t){return g.tools.getLinkId(t)}),g.main.links.enter().append("svg:line").attr("class","link").on("mouseenter",g.tools.onLinkMouseenter).on("mouseleave",g.tools.onLinkMouseleave).on("click",g.tools.onLinkClick),g.main.links.exit().remove(),g.main.links.style("marker-end",g.tools.getMarkerUrl).classed("dotted",function(t){return"dotted"===t.STYLE}).classed("dashed",function(t){return"dashed"===t.STYLE}).style("stroke",function(t){return t.COLOR?t.COLOR:null}),g.main.selfLinks=g.dom.graph.selectAll("path.link").data(g.data.links.filter(function(t){return t.FROMID===t.TOID&&g.conf.showSelfLinks}),function(t){return g.tools.getLinkId(t)}),g.main.selfLinks.enter().append("svg:path").attr("id",function(t){return g.tools.getPathId(t)}).attr("class","link").on("mouseenter",g.tools.onLinkMouseenter).on("mouseleave",g.tools.onLinkMouseleave).on("click",g.tools.onLinkClick),g.main.selfLinks.exit().remove(),g.main.selfLinks.attr("d",function(t){return g.tools.getSelfLinkPath(t)}).style("marker-end",g.tools.getMarkerUrl).classed("dotted",function(t){return"dotted"===t.STYLE}).classed("dashed",function(t){return"dashed"===t.STYLE}).style("stroke",function(t){return t.COLOR?t.COLOR:null}),g.main.patterns=g.dom.defs.selectAll("pattern").data(g.data.nodes.filter(function(t){return!!t.IMAGE}),function(t){return t.ID});var o=g.main.patterns.enter().append("svg:pattern").attr("id",function(t){return g.tools.getPatternId(t)});return o.append("svg:rect"),o.append("svg:image"),o="",g.main.patterns.exit().remove(),g.main.patterns.each(function(){d3.select(this).attr("x",0).attr("y",0).attr("height",function(t){return 2*t.radius}).attr("width",function(t){return 2*t.radius}),d3.select(this.firstChild).attr("x",0).attr("y",0).attr("height",function(t){return 2*t.radius}).attr("width",function(t){return 2*t.radius}).attr("fill",function(t){return g.tools.color(t.COLORVALUE)}),d3.select(this.lastChild).attr("x",0).attr("y",0).attr("height",function(t){return 2*t.radius}).attr("width",function(t){return 2*t.radius}).attr("xlink:href",function(t){return t.IMAGE})}),g.main.nodes=g.dom.graph.selectAll("circle.node").data(g.data.nodes,function(t){return t.ID}),g.main.nodes.enter().append("svg:circle").attr("class","node").attr("cx",function(t){if(!t.fixed&&!t.x)return t.x=Math.floor(Math.random()*g.tools.getGraphWidth()+1),t.x}).attr("cy",function(t){if(!t.fixed&&!t.y)return t.y=Math.floor(Math.random()*g.conf.height+1),t.y}).on("mouseenter",g.tools.onNodeMouseenter).on("mouseleave",g.tools.onNodeMouseleave).on("click",g.tools.onNodeClick).on("dblclick",g.tools.onNodeDblclick).on("contextmenu",g.tools.onNodeContextmenu),g.main.nodes.exit().remove(),g.main.nodes.attr("r",function(t){return t.radius}).attr("fill",function(t){return t.IMAGE?"url(#"+g.tools.getPatternId(t)+")":g.tools.color(t.COLORVALUE)}),g.conf.showLabels?(g.main.linkLabelPaths=g.dom.defs.selectAll("path.linkLabel").data(g.data.links.filter(function(t){return t.LABEL&&t.FROMID!==t.TOID}),function(t){return g.tools.getLinkId(t)}),g.main.linkLabelPaths.enter().append("svg:path").attr("id",function(t){return g.tools.getPathId(t)}).attr("class","linkLabel"),g.main.linkLabelPaths.exit().remove(),g.main.linkLabelPaths.attr("d",function(t){return"M "+t.source.x+" "+t.source.y+" L "+t.target.x+" "+t.target.y}),g.main.linkLabels=g.dom.graph.selectAll("text.linkLabel").data(g.data.links.filter(function(t){return t.LABEL}),function(t){return g.tools.getLinkId(t)}),g.main.linkLabels.enter().append("svg:text").attr("class","linkLabel").attr("dx",function(t){return t.FROMID!==t.TOID?g.conf.linkDistance/2:g.conf.selfLinkDistance+t.source.radius}).attr("dy","-1").on("mouseenter",g.tools.onLinkMouseenter).on("mouseleave",g.tools.onLinkMouseleave).on("click",g.tools.onLinkClick).append("svg:textPath").attr("xlink:href",function(t){return"#"+g.tools.getPathId(t)}),g.main.linkLabels.exit().remove(),g.main.linkLabels.each(function(t){d3.select(this.firstChild).text(t.LABEL)}),g.main.labels=g.dom.graph.selectAll("text.label").data(g.data.nodes.filter(function(t){return!t.LABELCIRCULAR&&!g.conf.labelsCircular}),function(t){return t.ID}),g.main.labels.enter().append("svg:text").attr("class","label"),g.main.labels.exit().remove(),g.main.labels.text(function(t){return t.LABEL}),g.main.labelPaths=g.dom.defs.selectAll("path.label").data(g.data.nodes.filter(function(t){return t.LABELCIRCULAR||g.conf.labelsCircular}),function(t){return t.ID}),g.main.labelPaths.enter().append("svg:path").attr("id",function(t){return g.dom.containerId+"_textPath_"+t.ID}).attr("class","label"),g.main.labelPaths.exit().remove(),g.main.labelPaths.attr("d",function(t){return g.tools.getLabelPath(t)}),g.main.labelsCircular=g.dom.graph.selectAll("text.labelCircular").data(g.data.nodes.filter(function(t){return t.LABELCIRCULAR||g.conf.labelsCircular}),function(t){return t.ID}),g.main.labelsCircular.enter().append("svg:text").attr("class","labelCircular").append("svg:textPath").attr("xlink:href",function(t){return"#"+g.dom.containerId+"_textPath_"+t.ID}),g.main.labelsCircular.exit().remove(),g.main.labelsCircular.each(function(t){d3.select(this.firstChild).text(t.LABEL)})):(g.dom.defs.selectAll("path.label,path.linkLabel").remove(),g.dom.graph.selectAll("text.label,text.labelCircular,text.linkLabel").remove()),g.status.aspectRatio||(g.status.aspectRatio=g.conf.width/g.conf.height),g.tools.removeLegend(),g.conf.showLegend&&g.tools.createLegend(),g.tools.executeResize(),p.debug(g.conf.debug).showBorder(g.conf.showBorder).setDomParentPaddingToZero(g.conf.setDomParentPaddingToZero).useDomParentWidth(g.conf.useDomParentWidth).alignFixedNodesToGrid(g.conf.alignFixedNodesToGrid).wrapLabels(g.conf.wrapLabels).dragMode(g.conf.dragMode).pinMode(g.conf.pinMode).lassoMode(g.conf.lassoMode).zoomMode(g.conf.zoomMode).transform(g.conf.transform).autoRefresh(g.conf.autoRefresh).linkDistance(g.conf.linkDistance).charge(g.conf.charge).chargeDistance(g.conf.chargeDistance).gravity(g.conf.gravity).linkStrength(g.conf.linkStrength).friction(g.conf.friction).theta(g.conf.theta),g.main.force.nodes(g.data.nodes).links(g.data.links).size([g.tools.getGraphWidth(),g.tools.getGraphHeight()]).start(),g.status.graphReady=!0,g.status.graphRendering=!1,g.status.customize?g.tools.createCustomizeWizard():g.tools.createCustomizeLink(),g.tools.log("Event renderend triggered."),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"net_gobrechts_d3_force_renderend"),"function"==typeof g.conf.onRenderEndFunction&&g.conf.onRenderEndFunction.call(g.dom.svg),g.tools.triggerApexEvent(document.querySelector("#"+g.dom.containerId),"apexafterrefresh"),p},p.resume=function(){return g.status.graphReady&&g.main.force.resume(),g.tools.createCustomizeWizardIfNotRendering(),p},p.showBorder=function(t){return arguments.length?(g.conf.showBorder=t,g.status.graphStarted&&(g.dom.svg.classed("border",g.conf.showBorder),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.showBorder},p.showLegend=function(t){return arguments.length?(g.conf.showLegend=t,g.status.graphStarted&&(g.conf.showLegend?(g.tools.removeLegend(),g.tools.createLegend()):g.tools.removeLegend(),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.showLegend},p.showSelfLinks=function(t){return arguments.length?(g.conf.showSelfLinks=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.showSelfLinks},p.showLinkDirection=function(t){return arguments.length?(g.conf.showLinkDirection=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.showLinkDirection},p.showTooltips=function(t){return arguments.length?(g.conf.showTooltips=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.showTooltips},p.tooltipPosition=function(t){return arguments.length?(g.conf.tooltipPosition=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.tooltipPosition},p.colorScheme=function(t){return arguments.length?(g.conf.colorScheme=t,g.tools.setColorFunction(),g.status.graphStarted&&(g.main.nodes.attr("fill",function(t){return t.IMAGE?"url(#"+g.tools.getPatternId(t)+")":g.tools.color(t.COLORVALUE)}),g.conf.showLegend&&(g.tools.removeLegend(),g.tools.createLegend()),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.colorScheme},p.showLabels=function(t){return arguments.length?(g.conf.showLabels=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.showLabels},p.wrapLabels=function(t){return arguments.length?(g.conf.wrapLabels=t,g.conf.wrapLabels&&(g.status.wrapLabelsOnNextTick=!0),g.status.graphStarted&&(g.main.labels.attr("lines",null),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.wrapLabels},p.labelSplitCharacter=function(t){return arguments.length?(g.conf.labelSplitCharacter=t,g.conf.wrapLabels&&(g.status.wrapLabelsOnNextTick=!0),g.status.graphStarted&&(g.main.labels.attr("lines",null),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.labelSplitCharacter},p.wrappedLabelWidth=function(t){return arguments.length?(g.conf.wrappedLabelWidth=t,g.conf.wrapLabels&&(g.main.labels.attr("lines",null),g.status.wrapLabelsOnNextTick=!0),g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.wrappedLabelWidth},p.wrappedLabelLineHeight=function(t){return arguments.length?(g.conf.wrappedLabelLineHeight=t,g.conf.wrapLabels&&(g.status.wrapLabelsOnNextTick=!0),g.status.graphStarted&&(g.main.labels.attr("lines",null),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.wrappedLabelLineHeight},p.labelsCircular=function(t){return arguments.length?(g.conf.labelsCircular=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.labelsCircular},p.labelDistance=function(t){return arguments.length?(g.conf.labelDistance=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.labelDistance},p.preventLabelOverlappingOnForceEnd=function(t){return arguments.length?(g.conf.preventLabelOverlappingOnForceEnd=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.preventLabelOverlappingOnForceEnd},p.labelPlacementIterations=function(t){return arguments.length?(g.conf.labelPlacementIterations=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.labelPlacementIterations},p.dragMode=function(t){return arguments.length?(g.conf.dragMode=t,g.status.graphStarted&&(g.conf.dragMode?g.main.nodes.call(g.main.drag):(g.main.nodes.on("mousedown.drag",null),g.main.nodes.on("touchstart.drag",null)),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.dragMode},p.pinMode=function(t){return arguments.length?(g.conf.pinMode=t,g.status.graphStarted&&(g.conf.pinMode?g.main.drag.on("dragstart",function(t){d3.select(this).classed("fixed",t.fixed=1)}):g.main.drag.on("dragstart",null),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.pinMode},p.lassoMode=function(t){return arguments.length?(g.conf.lassoMode=t,g.status.graphStarted&&(g.conf.lassoMode?(g.dom.graphOverlay.call(g.main.lasso),g.main.lasso.items(g.main.nodes),g.main.lasso.on("start",function(){g.main.lasso.items().classed("selected",!1),g.tools.onLassoStart(g.main.lasso.items())}),g.main.lasso.on("draw",function(){g.main.lasso.items().filter(function(t){return!0===t.possible}).classed("selected",!0),g.main.lasso.items().filter(function(t){return!1===t.possible}).classed("selected",!1)}),g.main.lasso.on("end",function(){g.main.lasso.items().filter(function(t){return!0===t.selected}).classed("selected",!0),g.main.lasso.items().filter(function(t){return!1===t.selected}).classed("selected",!1),g.tools.onLassoEnd(g.main.lasso.items())}),g.events.mousedownLasso=g.dom.graphOverlay.on("mousedown.drag"),g.events.touchstartLasso=g.dom.graphOverlay.on("touchstart.drag"),g.dom.graphOverlay.on("mousedown.drag",g.tools.lassoEventProxy(g.events.mousedownLasso)),g.dom.graphOverlay.on("touchstart.drag",g.tools.lassoEventProxy(g.events.touchstartLasso))):(g.dom.graphOverlay.on(".drag",null),g.main.nodes.classed("selected",!1)),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.lassoMode},p.zoomMode=function(t){return arguments.length?(g.conf.zoomMode=t,g.status.graphStarted&&(g.conf.zoomMode?(g.main.zoom.scaleExtent([g.conf.minZoomFactor,g.conf.maxZoomFactor]).size([g.tools.getGraphWidth(),g.tools.getGraphHeight()]).on("zoom",g.main.zoomed),g.dom.graphOverlay.call(g.main.zoom),g.events.dblclickZoom=g.dom.graphOverlay.on("dblclick.zoom"),g.events.mousedownZoom=g.dom.graphOverlay.on("mousedown.zoom"),g.events.touchstartZoom=g.dom.graphOverlay.on("touchstart.zoom"),g.dom.graphOverlay.on("dblclick.zoom",g.tools.zoomEventProxy(g.events.dblclickZoom)),g.dom.graphOverlay.on("mousedown.zoom",g.tools.zoomEventProxy(g.events.mousedownZoom)),g.dom.graphOverlay.on("touchstart.zoom",g.tools.zoomEventProxy(g.events.touchstartZoom)),JSON.stringify(g.conf.transform)!==JSON.stringify(g.confDefaults.transform)&&(g.dom.graph.attr("transform","translate("+g.main.zoom.translate()+")scale("+g.main.zoom.scale()+")"),g.tools.writeConfObjectIntoWizard())):g.dom.graphOverlay.on(".zoom",null),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.zoomMode},p.minZoomFactor=function(t){return arguments.length?(g.conf.minZoomFactor=t,g.status.graphReady&&p.zoomMode(g.conf.zoomMode),p):g.conf.minZoomFactor},p.maxZoomFactor=function(t){return arguments.length?(g.conf.maxZoomFactor=t,g.status.graphReady&&p.zoomMode(g.conf.zoomMode),p):g.conf.maxZoomFactor},p.zoom=function(t,e,o,n){var a,s,r=g.tools.getGraphWidth(),i=g.tools.getGraphHeight();return t=isNaN(t)?r/2:parseInt(t),e=isNaN(e)?i/2:parseInt(e),o=isNaN(o)?r:parseInt(o),n=isNaN(n)?500:parseInt(n),a=[r/2-t*(s=r/o),i/2-e*s],g.main.interpolateZoom(a,s,n),p},p.zoomSmooth=function(t,e,o,n){return t=isNaN(t)?width/2:parseInt(t),e=isNaN(e)?height/2:parseInt(e),o=isNaN(o)?width:parseInt(o),n=isNaN(n)?1500:parseInt(n),p.zoom(t,e,o,n),p},p.transform=function(t,e){return arguments.length?(g.main.interpolateZoom(t.translate,t.scale,isNaN(e)?500:parseInt(e)),p):{translate:g.main.zoom.translate(),scale:g.main.zoom.scale()}},p.centerPositionGraph=function(){var t=g.dom.graph.node().getBBox();return[t.x+t.width/2,t.y+t.height/2]},p.centerPositionViewport=function(){var t,e,o={};return o.width=g.tools.getGraphWidth(),o.height=g.tools.getGraphHeight(),t=g.main.zoom.scale(),e=g.main.zoom.translate(),[1*(o.width/2-e[0])/t,1*(o.height/2-e[1])/t]},p.center=function(t){var e,o,n,a={};return t=isNaN(t)?500:parseInt(t),a.width=g.tools.getGraphWidth(),a.height=g.tools.getGraphHeight(),e=g.dom.graph.node().getBBox(),n=g.main.zoom.scale(),0<e.width&&0<e.height&&(o=[(a.width-e.width*n)/2-e.x*n,(a.height-e.height*n)/2-e.y*n],g.main.interpolateZoom(o,n,t)),p},p.zoomToFit=function(t){var e,o,n,a={};return t=isNaN(t)?500:parseInt(t),a.width=g.tools.getGraphWidth(),a.height=g.tools.getGraphHeight(),0<(e=g.dom.graph.node().getBBox()).width&&0<e.height&&(n=Math.min((a.height-20)/e.height,(a.width-20)/e.width),o=[(a.width-e.width*n)/2-e.x*n,(a.height-e.height*n)/2-e.y*n],g.main.interpolateZoom(o,n,t)),p},p.zoomToFitOnForceEnd=function(t){return arguments.length?(g.conf.zoomToFitOnForceEnd=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.zoomToFitOnForceEnd},p.zoomToFitOnResize=function(t){return arguments.length?(g.conf.zoomToFitOnResize=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.zoomToFitOnResize},p.keepAspectRatioOnResize=function(t){return arguments.length?(g.conf.keepAspectRatioOnResize=t,g.status.graphStarted&&(p.width(g.conf.width),p.height(g.conf.height),g.tools.removeLegend(),g.tools.createLegend(),g.tools.executeResize(),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.keepAspectRatioOnResize},p.onResizeFunction=function(t){return arguments.length?(g.conf.onResizeFunction=t,p):g.conf.onResizeFunction},p.onResizeFunctionTimeout=function(t){return arguments.length?(g.conf.onResizeFunctionTimeout=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.onResizeFunctionTimeout},p.showLoadingIndicatorOnAjaxCall=function(t){return arguments.length?(g.conf.showLoadingIndicatorOnAjaxCall=t,p):g.conf.showLoadingIndicatorOnAjaxCall},p.showLoadingIndicator=function(t){return g.tools.parseBool(t)?g.dom.loading.style("display","block"):g.dom.loading.style("display","none"),p},p.alignFixedNodesToGrid=function(t){var e,o;return arguments.length?(g.conf.alignFixedNodesToGrid=t,g.status.graphStarted&&(e=g.tools.getGraphWidth(),o=g.tools.getGraphHeight(),g.conf.alignFixedNodesToGrid?(g.status.graphReady&&g.main.nodes.each(function(t){t.fixed&&(t.x=t.px=g.tools.getNearestGridPosition(t.x,e),t.y=t.py=g.tools.getNearestGridPosition(t.y,o))}),g.main.drag.on("dragend",function(t){t.x=t.px=g.tools.getNearestGridPosition(t.x,e),t.y=t.py=g.tools.getNearestGridPosition(t.y,o)})):g.main.drag.on("dragend",null),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.alignFixedNodesToGrid},p.gridSize=function(t){return arguments.length?(g.conf.gridSize=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.gridSize},p.moveFixedNodes=function(e,o){return g.status.graphStarted&&(e||(e=0),o||(o=0),0===e&&0===o||g.main.nodes.each(function(t){t.fixed&&(t.x=t.px=g.conf.alignFixedNodesToGrid?g.tools.getNearestGridPosition(t.x+e,g.conf.width):t.x+e,t.y=t.py=g.conf.alignFixedNodesToGrid?g.tools.getNearestGridPosition(t.y+o,g.conf.width):t.y+o)})),p},p.releaseFixedNodes=function(){return g.status.graphStarted&&g.main.nodes.each(function(t){t.fixed=0}),p},p.nodeEventToStopPinMode=function(t){return arguments.length?(g.conf.nodeEventToStopPinMode=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.nodeEventToStopPinMode},p.onNodeContextmenuPreventDefault=function(t){return arguments.length?(g.conf.onNodeContextmenuPreventDefault=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.onNodeContextmenuPreventDefault},p.nodeEventToOpenLink=function(t){return arguments.length?(g.conf.nodeEventToOpenLink=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.nodeEventToOpenLink},p.nodeLinkTarget=function(t){return arguments.length?(g.conf.nodeLinkTarget=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.nodeLinkTarget},p.autoRefresh=function(t){return arguments.length?(g.conf.autoRefresh=t,g.status.graphStarted&&(g.conf.autoRefresh&&g.conf.refreshInterval&&!g.conf.interval?(g.conf.interval=window.setInterval(function(){p.start()},g.conf.refreshInterval),g.tools.log("Auto refresh started with an interval of "+g.conf.refreshInterval+" milliseconds.")):!g.conf.autoRefresh&&g.conf.interval&&(clearInterval(g.conf.interval),g.conf.interval=null,g.tools.log("Auto refresh stopped.")),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.autoRefresh},p.refreshInterval=function(t){return arguments.length?(g.conf.refreshInterval=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.refreshInterval},p.useDomParentWidth=function(t){return arguments.length?(g.conf.useDomParentWidth=t,g.status.graphStarted&&(g.conf.useDomParentWidth?g.tools.ResizeObserver.observe(g.dom.svgParent.node()):g.tools.ResizeObserver.unobserve(g.dom.svgParent.node()),g.conf.showLegend&&(g.tools.removeLegend(),g.tools.createLegend()),g.tools.executeResize()),p):g.conf.useDomParentWidth},p.setDomParentPaddingToZero=function(t){return arguments.length?(g.conf.setDomParentPaddingToZero=t,g.status.graphStarted&&(g.conf.setDomParentPaddingToZero?g.dom.svgParent.style("padding","0"):g.dom.svgParent.style("padding",null),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.setDomParentPaddingToZero},p.domParentWidth=function(){return g.tools.getSvgParentInnerWidth()},p.width=function(t){return arguments.length?(g.conf.width=t,g.status.graphStarted&&(g.conf.keepAspectRatioOnResize&&(g.conf.height=1*g.conf.width/g.status.aspectRatio),g.tools.executeResize(),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.width},p.height=function(t){return arguments.length?(g.conf.height=t,g.status.graphStarted&&(g.conf.keepAspectRatioOnResize&&(g.conf.width=g.conf.height*g.status.aspectRatio),g.tools.executeResize(),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.height},p.minNodeRadius=function(t){return arguments.length?(g.conf.minNodeRadius=t,g.status.graphReady&&(g.tools.setRadiusFunction(),g.main.nodes.each(function(t){t.radius=g.tools.radius(t.SIZEVALUE)}),g.main.nodes.attr("r",function(t){return t.radius}),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.minNodeRadius},p.maxNodeRadius=function(t){return arguments.length?(g.conf.maxNodeRadius=t,g.status.graphReady&&(g.tools.setRadiusFunction(),g.main.nodes.each(function(t){t.radius=g.tools.radius(t.SIZEVALUE)}),g.main.nodes.attr("r",function(t){return t.radius}),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.maxNodeRadius},p.selfLinkDistance=function(t){return arguments.length?(g.conf.selfLinkDistance=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.selfLinkDistance},p.linkDistance=function(t){return arguments.length?(g.conf.linkDistance=t,g.status.graphStarted&&(g.main.force.linkDistance(g.conf.linkDistance),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.linkDistance},p.charge=function(t){return arguments.length?(g.conf.charge=t,g.status.graphStarted&&(g.main.force.charge(g.conf.charge),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.charge},p.chargeDistance=function(t){return arguments.length?(g.conf.chargeDistance=t,g.status.graphStarted&&(g.main.force.chargeDistance(g.conf.chargeDistance),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.chargeDistance},p.gravity=function(t){return arguments.length?(g.conf.gravity=t,g.status.graphStarted&&(g.main.force.gravity(g.conf.gravity),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.gravity},p.linkStrength=function(t){return arguments.length?(g.conf.linkStrength=t,g.status.graphStarted&&(g.main.force.linkStrength(g.conf.linkStrength),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.linkStrength},p.friction=function(t){return arguments.length?(g.conf.friction=t,g.status.graphStarted&&(g.main.force.friction(g.conf.friction),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.friction},p.theta=function(t){return arguments.length?(g.conf.theta=t,g.status.graphStarted&&(g.main.force.theta(g.conf.theta),g.tools.createCustomizeWizardIfNotRendering()),p):g.conf.theta},p.forceTimeLimit=function(t){return arguments.length?(g.conf.forceTimeLimit=t,g.status.graphStarted&&g.tools.createCustomizeWizardIfNotRendering(),p):g.conf.forceTimeLimit},p.positions=function(t){if(arguments.length)return g.status.graphReady?t.constructor===Array?t.forEach(function(t){void 0!==g.data.idLookup[t.ID]&&(g.data.idLookup[t.ID].fixed=g.tools.parseBool(t.fixed),g.data.idLookup[t.ID].x=g.data.idLookup[t.ID].px=t.x,g.data.idLookup[t.ID].y=g.data.idLookup[t.ID].py=t.y)}):g.tools.logError("Unable to set node positions: positions method parameter must be an array of node positions"):g.conf.positions=t,p;var e=[];return g.data.nodes.forEach(function(t){e.push({ID:t.ID,x:Math.round(t.x),y:Math.round(t.y),fixed:t.fixed?1:0})}),e},p.onLinkClickFunction=function(t){return arguments.length?(g.conf.onLinkClickFunction=t,p):g.conf.onLinkClickFunction},p.onNodeMouseenterFunction=function(t){return arguments.length?(g.conf.onNodeMouseenterFunction=t,p):g.conf.onNodeMouseenterFunction},p.onNodeMouseleaveFunction=function(t){return arguments.length?(g.conf.onNodeMouseleaveFunction=t,p):g.conf.onNodeMouseleaveFunction},p.onNodeClickFunction=function(t){return arguments.length?(g.conf.onNodeClickFunction=t,p):g.conf.onNodeClickFunction},p.onNodeDblclickFunction=function(t){return arguments.length?(g.conf.onNodeDblclickFunction=t,p):g.conf.onNodeDblclickFunction},p.onNodeContextmenuFunction=function(t){return arguments.length?(g.conf.onNodeContextmenuFunction=t,p):g.conf.onNodeContextmenuFunction},p.onLassoStartFunction=function(t){return arguments.length?(g.conf.onLassoStartFunction=t,p):g.conf.onLassoStartFunction},p.onLassoEndFunction=function(t){return arguments.length?(g.conf.onLassoEndFunction=t,p):g.conf.onLassoEndFunction},p.onRenderEndFunction=function(t){return arguments.length?(g.conf.onRenderEndFunction=t,p):g.conf.onRenderEndFunction},p.onForceStartFunction=function(t){return arguments.length?(g.conf.onForceStartFunction=t,p):g.conf.onForceStartFunction},p.onForceEndFunction=function(t){return arguments.length?(g.conf.onForceEndFunction=t,p):g.conf.onForceEndFunction},p.sampleData=function(t){return arguments.length?(g.data.sampleData=t,p):g.data.sampleData},p.nodes=function(){return g.main.nodes},p.links=function(){return g.main.links},p.selfLinks=function(){return g.main.selfLinks},p.data=function(){return g.data.dataConverted},p.nodeDataById=function(t){return g.data.idLookup[t]},p.options=function(t){var e;if(arguments.length)return g.tools.applyConfigurationObject(t),p;var o={};for(e in g.conf)g.conf.hasOwnProperty(e)&&(g.confDefaults.hasOwnProperty(e)?"bool"!==g.confDefaults[e].type&&"number"!==g.confDefaults[e].type&&"text"!==g.confDefaults[e].type||g.confDefaults[e].val===g.conf[e]?"object"===g.confDefaults[e].type&&JSON.stringify(g.confDefaults[e].val)!==JSON.stringify(g.conf[e])&&(o[e]=g.conf[e]):o[e]=g.conf[e]:g.confDefaults.hasOwnProperty(e)||void 0===g.conf[e]||null===g.conf[e]||(o[e]=g.conf[e]));return o},p.optionsCustomizationWizard=function(t){var e;if(arguments.length)return g.tools.applyConfigurationObject(t),p;var o={};for(e in g.confDefaults)g.confDefaults.hasOwnProperty(e)&&("bool"!==g.confDefaults[e].type&&"number"!==g.confDefaults[e].type&&"text"!==g.confDefaults[e].type||g.confDefaults[e].val===g.conf[e]?"object"===g.confDefaults[e].type&&JSON.stringify(g.confDefaults[e].val)!==JSON.stringify(g.conf[e])&&(o[e]=g.conf[e]):o[e]=g.conf[e]);return o},p.customize=function(t){return arguments.length?(g.status.customize=t,g.status.graphStarted&&(g.status.customize?(g.tools.createCustomizeWizard(),g.tools.removeCustomizeLink()):(g.tools.removeCustomizeWizard(),g.conf.debug&&g.tools.createCustomizeLink())),p):g.status.customize},p.debug=function(t){return arguments.length?(g.conf.debug=t,g.status.graphStarted&&(g.conf.debug?g.tools.createCustomizeLink():g.tools.removeCustomizeLink()),p):g.conf.debug},p.userAgent=function(){return g.status.userAgent},p.inspect=function(){return g},p.version=function(){return g.version},g.main.init(),g.status.apexPluginId&&apex.jQuery("#"+g.dom.containerId).bind("apexrefresh",function(){p.start()}),p}