text: function arcTween(t){var e=d3.interpolate(this._current,t);return this._current=e(0),function(t){return arc(e(t))}}function createVisualization(t){initializeBreadcrumbTrail(),drawLegend(),d3.select("#togglelegend").on("click",toggleLegend),vis.append("svg:circle").attr("r",radius).style("opacity",0);var e=partition.nodes(t).filter(function(t){return t.dx>.005}),r=vis.data([t]).selectAll("path").data(e).enter().append("svg:path").attr("display",function(t){return t.depth?null:"none"}).attr("d",arc).attr("fill-rule","evenodd").style("fill",function(t){return colors[t.name]}).style("opacity",1).on("mouseover",mouseover);d3.select("#container").on("mouseleave",mouseleave),totalSize=132420,console.log(totalSize)}function mouseover(t){var e=(100*t.value/totalSize).toPrecision(3),r=e+"%";.1>e&&(r="< 0.1%"),d3.select("#percentage").text(r),d3.select("#explanation").style("visibility","");var n=getAncestors(t);updateBreadcrumbs(n,r),d3.selectAll("path").style("opacity",.3),vis.selectAll("path").filter(function(t){return n.indexOf(t)>=0}).style("opacity",1)}function mouseleave(t){d3.select("#trail").style("visibility","hidden"),d3.selectAll("path").on("mouseover",null),d3.selectAll("path").transition().duration(1e3).style("opacity",1).each("end",function(){d3.select(this).on("mouseover",mouseover)}),d3.select("#explanation").style("visibility","hidden")}function getAncestors(t){for(var e=[],r=t;r.parent;)e.unshift(r),r=r.parent;return e}function initializeBreadcrumbTrail(){var t=d3.select("#sequence").append("svg:svg").attr("width",width+150).attr("height",50).attr("id","trail");t.append("svg:text").attr("id","endlabel").style("fill","#000")}function breadcrumbPoints(t,e){var r=[];return r.push("0,0"),r.push(b.w+100+",0"),r.push(b.w+100+b.t+","+b.h/2),r.push(b.w+100+","+b.h),r.push("0,"+b.h),e>0&&r.push(b.t+","+b.h/2),r.join(" ")}function updateBreadcrumbs(t,e){var r=d3.select("#trail").selectAll("g").data(t,function(t){return t.name+t.depth}),n=r.enter().append("svg:g");n.append("svg:polygon").attr("points",breadcrumbPoints).style("fill",function(t){return colors[t.name]}),n.append("svg:text").attr("x",(b.w+100+b.t)/2).attr("y",b.h/2).attr("dy","0.35em").attr("text-anchor","middle").text(function(t){return t.name}),r.attr("transform",function(t,e){return"translate("+e*(b.w+100+b.s)+", 0)"}),r.exit().remove(),d3.select("#trail").select("#endlabel").attr("x",(t.length+.5)*(b.w+100+b.s)-55).attr("y",b.h/2).attr("dy","0.35em").attr("text-anchor","middle").text(e),d3.select("#trail").style("visibility","")}function drawLegend(){var t={w:75,h:30,s:3,r:3},e=d3.select("#legend").append("svg:svg").attr("width",t.w).attr("height",d3.keys(colors).length*(t.h+t.s)),r=e.selectAll("g").data(d3.entries(colors)).enter().append("svg:g").attr("transform",function(e,r){return"translate(0,"+r*(t.h+t.s)+")"});r.append("svg:rect").attr("rx",t.r).attr("ry",t.r).attr("width",t.w).attr("height",t.h).style("fill",function(t){return t.value}),r.append("svg:text").attr("x",t.w/2).attr("y",t.h/2).attr("dy","0.35em").attr("text-anchor","middle").text(function(t){return t.key})}function toggleLegend(){var t=d3.select("#legend");"hidden"==t.style("visibility")?t.style("visibility",""):t.style("visibility","hidden")}function buildHierarchy(t){for(var e={name:"root",children:[]},r=0;r<t.length;r++){var n=t[r][0],a=+t[r][1];if(!isNaN(a))for(var i=n.split("-"),s=e,l=0;l<i.length;l++){var d=s.children,o=i[l],c;if(l+1<i.length){for(var u=!1,h=0;h<d.length;h++)if(d[h].name==o){c=d[h],u=!0;break}u||(c={name:o,children:[]},d.push(c)),s=c}else c={name:o,size:a},d.push(c)}}return e}var width=480,height=480,radius=Math.min(width,height)/2,b={w:75,h:30,s:3,t:10},colors={home:"#5687d1",product:"#7b615c",search:"#de783b",account:"#6ab975",other:"#a173d1",end:"#bbbbbb",Verbrauch:"#222222",Erzeugung:"#a0c884"},totalSize=0,vis=d3.select("#chart").append("svg:svg").attr("width",width).attr("height",height).append("svg:g").attr("id","container").attr("transform","translate("+width/2+","+height/2+")"),partition=d3.layout.partition().size([2*Math.PI,radius*radius]).value(function(t){return t.size}),arc=d3.svg.arc().startAngle(function(t){return t.x}).endAngle(function(t){return t.x+t.dx}).innerRadius(function(t){return Math.sqrt(t.y)}).outerRadius(function(t){return Math.sqrt(t.y+t.dy)});d3.text("../csv/visit-sequences.csv",function(t){var e=d3.csv.parseRows(t),r=buildHierarchy(e);createVisualization(r)}),$(".toggle-land").click(function(){d3.text("../csv/de-verbrauch.csv",function(t){var e=d3.csv.parseRows(t),r=buildHierarchy(e),n=partition.nodes(r).filter(function(t){return t.dx>.005}),a=vis.data([n]).selectAll("path");a=a.data(n),a.transition().duration(750).attrTween("d",arcTween),createVisualization(n)})});