%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/opti/workflow/src/public/app-assets/js/scripts/charts/d3/tree/
Upload File :
Create Path :
Current File : /home/opti/workflow/src/public/app-assets/js/scripts/charts/d3/tree/bracket.min.js

/*!
 * stack-admin-theme (https://pixinvent.com/bootstrap-admin-template/stack)
 * Copyright 2018 PIXINVENT
 * Licensed under the Themeforest Standard Licenses
 */
$(window).on("load",function(){function update(source){function click(d){d.children?(d._children=d.children,d.children=null):(d.children=d._children,d._children=null),update(source)}function resize(){width=ele.node().getBoundingClientRect().width-margin.left-margin.right,container.attr("width",width+margin.left+margin.right),svg.attr("width",width+margin.left+margin.right)}var nodes=toArray(source);nodes.forEach(function(d){d.y=180*d.depth+halfWidth});var node=svg.selectAll("g.node").data(nodes,function(d){return d.id||(d.id=++i)});nodes.forEach(function(d){var p=calcLeft(d);d.x0=p.x,d.y0=p.y});var nodeEnter=node.enter().append("g").attr("class","node").attr("transform",function(d){return"translate("+source.y0+","+source.x0+")"}).on("click",click);nodeEnter.append("circle").attr("r",1e-6).style("stroke","#F6BB42").style("stroke-width",1.5).style("cursor","pointer").style("fill",function(d){return d._children?"#F6BB42":"#fff"}),nodeEnter.append("text").attr("dy",function(d){return d.isRight?18:-12}).attr("text-anchor","middle").text(function(d){return d.name}).style("font-size",12).style("fill-opacity",1e-6);var nodeUpdate=node.transition().duration(duration).attr("transform",function(d){return p=calcLeft(d),"translate("+p.y+","+p.x+")"});nodeUpdate.select("circle").attr("r",4.5).style("fill",function(d){return d._children?"#F6BB42":"#fff"}),nodeUpdate.select("text").style("fill-opacity",1);var nodeExit=node.exit().transition().duration(duration).attr("transform",function(d){return p=calcLeft(d.parent||source),"translate("+p.y+","+p.x+")"}).remove();nodeExit.select("circle").attr("r",1e-6),nodeExit.select("text").style("fill-opacity",1e-6);var link=svg.selectAll("path.link").data(tree.links(nodes),function(d){return d.target.id});link.enter().insert("path","g").attr("class","link").style("stroke","#F6BB42").style("fill","none").style("stroke-width",1.5).attr("d",function(d){var o={x:source.x0,y:source.y0};return connector({source:o,target:o})}),link.transition().duration(duration).attr("d",connector),link.exit().transition().duration(duration).attr("d",function(d){var o=calcLeft(d.source||source);return d.source.isRight?o.y-=halfWidth-(d.target.y-d.source.y):o.y+=halfWidth-(d.target.y-d.source.y),connector({source:o,target:o})}).remove(),$(window).on("resize",resize),$(".menu-toggle").on("click",resize)}var root,ele=d3.select("#bracket-tree"),margin={top:0,right:0,bottom:0,left:0},width=ele.node().getBoundingClientRect().width-margin.left-margin.right,halfWidth=width/2,height=600-margin.top-margin.bottom-5,i=0,duration=500,container=ele.append("svg"),svg=container.attr("width",width+margin.left+margin.right).attr("height",height+margin.top+margin.bottom).append("g").attr("transform","translate("+margin.left+","+margin.top+")"),getChildren=function(d){var a=[];if(d.winners)for(var i=0;i<d.winners.length;i++)d.winners[i].isRight=!1,d.winners[i].parent=d,a.push(d.winners[i]);if(d.challengers)for(var i=0;i<d.challengers.length;i++)d.challengers[i].isRight=!0,d.challengers[i].parent=d,a.push(d.challengers[i]);return a.length?a:null},zoom=d3.behavior.zoom().scaleExtent([1,2]).on("zoom",function(){svg.attr("transform","translate("+d3.event.translate+") scale("+d3.event.scale+")")});container.call(zoom);var tree=d3.layout.tree().size([height,width]),elbow=(d3.svg.diagonal().projection(function(d){return[d.y,d.x]}),function(d,i){var source=calcLeft(d.source),target=calcLeft(d.target),hy=(target.y-source.y)/2;return d.isRight&&(hy=-hy),"M"+source.y+","+source.x+"H"+(source.y+hy)+"V"+target.x+"H"+target.y}),connector=elbow,calcLeft=function(d){var l=d.y;return d.isRight||(l=d.y-halfWidth,l=halfWidth-l),{x:d.x,y:l}},toArray=function(item,arr){arr=arr||[];var i=0,l=item.children?item.children.length:0;for(arr.push(item);i<l;i++)toArray(item.children[i],arr);return arr};d3.json("../../../app-assets/data/d3/tree/bracket-tree.json",function(json){root=json,root.x0=height/2,root.y0=width/2;var t1=d3.layout.tree().size([height,halfWidth]).children(function(d){return d.winners}),t2=d3.layout.tree().size([height,halfWidth]).children(function(d){return d.challengers});t1.nodes(root),t2.nodes(root);var rebuildChildren=function(node){node.children=getChildren(node),node.children&&node.children.forEach(rebuildChildren)};rebuildChildren(root),root.isRight=!1,update(root)})});

Zerion Mini Shell 1.0