From 9f032700430eff2cf9b357d82d50732488ec6143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximiliano=20B=C3=A1ez=20Gonz=C3=A1lez?= Date: Fri, 10 Jun 2016 11:54:18 -0400 Subject: [PATCH] =?UTF-8?q?Se=20a=C3=B1ade=20el=20size=20toogle=20control?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/css/bubbles-chart.css | 6 +++--- dist/js/bubbles-chart.full.js | 4 ++-- dist/js/bubbles-chart.js | 4 ++-- src/js/bubbles-chart.js | 38 ++++++++++++++++++++++++++++++++++- src/scss/_bubbles-chart.scss | 5 +++++ 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/dist/css/bubbles-chart.css b/dist/css/bubbles-chart.css index 77a7be9..0f20bd3 100644 --- a/dist/css/bubbles-chart.css +++ b/dist/css/bubbles-chart.css @@ -1,8 +1,8 @@ /*! * bubbles-chart : Bubble chart - * @version v0.0.0 + * @version v0.0.1 * @author Maximiliano Báez González - * @date 2016-06-09 + * @date 2016-06-10 */ -g{cursor:pointer}.wrap{stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;font-weight:800;paint-order:stroke}.timeline{position:relative;text-align:center}.timeline:focus{outline:none}.timeline .entry{padding:5px;border:solid 1px #c3c3c3;border-right:solid 0px;display:inline-block;font-size:12px;text-align:center;position:relative;cursor:pointer}.timeline .entry a{color:#444}.timeline .entry a:hover{text-decoration:none}.timeline .entry.selected{background:#c3c3c3;border-color:#f1f1f1}.timeline .entry:hover{background:#f1f1f1}.timeline .entry:last-child{border-right:solid 1px #c3c3c3}.timeline .entry:hover:last-child{border-color:#f1f1f1} +g{cursor:pointer}.wrap{stroke-width:2px;stroke-linecap:butt;stroke-linejoin:miter;font-weight:800;paint-order:stroke}.timeline{position:relative;text-align:center}.timeline:focus{outline:none}.timeline .entry{padding:5px;border:solid 1px #c3c3c3;border-right:solid 0px;display:inline-block;font-size:12px;text-align:center;position:relative;cursor:pointer}.timeline .entry a{color:#444}.timeline .entry a:hover{text-decoration:none}.timeline .entry.selected{background:#c3c3c3;border-color:#f1f1f1}.timeline .entry:hover{background:#f1f1f1}.timeline .entry:last-child{border-right:solid 1px #c3c3c3}.timeline .entry:hover:last-child{border-color:#f1f1f1}.bubble-toogle{display:block;text-align:center} diff --git a/dist/js/bubbles-chart.full.js b/dist/js/bubbles-chart.full.js index 58a97f2..8f955ed 100644 --- a/dist/js/bubbles-chart.full.js +++ b/dist/js/bubbles-chart.full.js @@ -1,6 +1,6 @@ /*! * bubbles-chart : Bubble chart - * @version v0.0.0 + * @version v0.0.1 * @author Maximiliano Báez González * @date 2016-06-10 */ @@ -33,4 +33,4 @@ value:s[e]},padding:{accepted:[Number],value:.1},persist:{position:{accepted:[Bo "string"==typeof h[0]){for(y=h.length;y>=0;)h.splice(y,0,"d3plus_buffer_"+y),y--;return j=e[t].scale.viz.range(),j=n(d3.extent(j),h.length),e[t].scale.viz.domain(h).range(j)}if(0===t.indexOf("y")&&(h=h.slice().reverse()),1===e[t].ticks.values.length)e[t].value===e.time.value&&1!==e.data.time.ticks.length?(u=a(e.data.time.ticks,h[0]),F=e.data.time.ticks.indexOf(u),F>0?h[0]=e.data.time.ticks[F-1]:(f=e.data.time.ticks[F+1]-u,h[0]=new Date(u.getTime()-f)),F=0;)d=y?A[y-1]+o:A[y]-o,h.splice(y,0,d),y--;j=e[t].scale.viz.range(),j=n(d3.extent(j),h.length),e[t].scale.viz.domain(h).range(j)}return 0===t.indexOf("y")&&(h=h.reverse()),e[t].scale.viz.domain(h)}if("x"===r&&0===t.indexOf("x")||"y"===r&&0===t.indexOf("y")||r===!0)return h=e[t].scale.viz.domain(),l=h[0]>=0&&h[1]>=0,s=h[0]<=0&&h[1]<=0,"log"===e[t].scale.value?(N=l?1:-1,l&&0===t.indexOf("y")&&(h=h.slice().reverse()),w=Math.pow(10,parseInt(Math.abs(h[0])).toString().length-1)*N,b=h[0]%w,x=b,b&&.1>=x/w&&(x+=w*N),_=0===b?w:x,h[0]-=_,0===h[0]&&(h[0]=N),C=Math.pow(10,parseInt(Math.abs(h[1])).toString().length-1)*N,T=h[1]%C,S=Math.abs(C-T),T&&.1>=S/C&&(S+=C*N),B=0===T?C:S,h[1]+=B,0===h[1]&&(h[1]=N),l&&0===t.indexOf("y")&&(h=h.reverse())):(N=0,0===t.indexOf("y")&&(h=h.slice().reverse()),E=h.filter(function(e){return e.constructor===String}),i=.05*Math.abs(h[1]-h[0])||1,E.length||(h[0]=h[0]-i,h[1]=h[1]+i,(l&&h[0]N)&&(h[0]=N),(l&&h[1]N)&&(h[1]=N)),0===t.indexOf("y")&&(h=h.reverse())),e[t].scale.viz.domain(h);if(e.axes.scale)return c=!1,e.axes.mirror.value&&(z=0===t.indexOf("y")?"x":"y",c=e[z].scale.viz,O=e.width.viz>e.height.viz?"x":"y"),t===O&&c?h=c.domain().slice().reverse():(M=e[t].scale.viz.range()[1],k=e.axes.scale.range()[1],m=e[t].scale.viz.invert(1.5*-k),g=e[t].scale.viz.invert(M+1.5*k),h=[m,g],0===t.indexOf("y")&&(h=h.reverse()),v=e[t].scale.viz.domain(),v=v[1]-v[0],v||(h[0]-=1,h[1]+=1),0===t.indexOf("y")&&(h=h.reverse())),e[t].scale.viz.domain(h)}}},{"../../../../../util/buckets.coffee":203,"../../../../../util/closest.coffee":205}],316:[function(e,t,r){var n,a,o,i,s,l;n=e("../../../../../util/copy.coffee"),a=e("../../../../../client/pointer.coffee"),o=e("../../../../../core/fetch/color.coffee"),i=e("../../../../../core/fetch/value.coffee"),s=e("../../../../../color/legible.coffee"),l=e("../../../../../color/text.coffee"),t.exports=function(e,t){var r,n,u,c,d,f,p,h,v,g,m,y,x,b,w,_,k,z;return r=d3.event.type===a.click&&(t.tooltip.value["long"]||t.tooltip.html.value),u=[a.over,a.move].indexOf(d3.event.type)>=0,k=e.d3plus.x,z=e.d3plus.y,g=e.d3plus.r||0,x=t.types[t.type.value].scale||1,g*=x,c=t.axes,_=t.draw.timing?t.timing.mouseevents:0,!r&&u?(n=s(o(t,e)),d=["x","y","x2","y2"].filter(function(r){var n;return n=i(t,e,t[r].value),n&&!(n instanceof Array)&&r!==t.axes.stacked&&t[r].mouse.value&&r!==t.axes.discrete})):d=[],f=function(e){return e.attr("x1",function(e){return 0===e.indexOf("x")?k:k-g}).attr("y1",function(e){return 0===e.indexOf("y")?z:z+g}).attr("x2",function(e){return 0===e.indexOf("x")?k:k-g}).attr("y2",function(e){return 0===e.indexOf("y")?z:z+g}).attr("opacity",0)},p=function(e){return e.style("stroke",function(e){return"area"===t.shape.value?"white":n}).attr("stroke-dasharray",function(e){return t[e].mouse.dasharray.value}).attr("shape-rendering",function(e){return t[e].mouse.rendering.value}).style("stroke-width",function(e){return t[e].mouse.width})},h=function(r){return r.attr("x1",function(e){return 0===e.indexOf("x")?k:k-g}).attr("y1",function(e){return 0===e.indexOf("y")?z:z+g}).attr("x2",function(r){return 0===r.indexOf("x")?k:e.d3plus.x0?e.d3plus.x0:"y"===r?c.margin.left-t[r].ticks.size:c.margin.left+c.width+t[r].ticks.size}).attr("y2",function(r){return 0===r.indexOf("y")?z:e.d3plus.y0?e.d3plus.y0:"x"===r?c.height+c.margin.top+t[r].ticks.size:c.margin.top-t[r].ticks.size}).style("opacity",1)},v=t.g.labels.selectAll("line.d3plus_mouse_axis_label").data(d),_?(v.enter().append("line").attr("class","d3plus_mouse_axis_label").attr("pointer-events","none").call(f).call(p),v.transition().duration(_).call(h).call(p),v.exit().transition().duration(_).call(f).remove()):(v.call(h).call(p),v.enter().append("line").attr("class","d3plus_mouse_axis_label").attr("pointer-events","none").call(f).call(p),v.exit().remove()),b=function(r){return r.attr("font-size",function(e){return t[e].ticks.font.size+"px"}).attr("font-family",function(e){return t[e].ticks.font.family.value}).attr("font-weight",function(e){return t[e].ticks.font.weight}).attr("x",function(e){return 0===e.indexOf("x")?k:"y"===e?c.margin.left-5-t[e].ticks.size:c.margin.left+c.width+5+t[e].ticks.size}).attr("y",function(r){return 0===r.indexOf("y")?z:e.d3plus.y0?e.d3plus.y+(e.d3plus.y0-e.d3plus.y)/2+c.margin.top-6:"x"===r?c.height+c.margin.top+5+t[r].ticks.size:c.margin.top-5-t[r].ticks.size-1.35*t[r].ticks.font.size}).attr("fill","area"===t.shape.value?"white":l(n))},w=t.g.labels.selectAll("text.d3plus_mouse_axis_label").data(d),w.enter().append("text").attr("class","d3plus_mouse_axis_label").attr("id",function(e){return e+"_d3plusmouseaxislabel"}).attr("dy",function(e){return 0===e.indexOf("y")?.35*t[e].ticks.font.size:t[e].ticks.font.size}).style("text-anchor",function(e){return"y"===e?"end":"y2"===e?"start":"middle"}).attr("opacity",0).attr("pointer-events","none").call(b),w.text(function(r){var n,a;return n=t.axes.stacked||r,a=i(t,e,t[n].value),t.format.value(a,{key:t[n].value,vars:t,labels:t[n].affixes.value})}),_?(w.transition().duration(_).delay(_).attr("opacity",1).call(b),w.exit().transition().duration(_).attr("opacity",0).remove()):(w.attr("opacity",1).call(b),w.exit().remove()),m=function(r){var a;return a=function(e){var t;return t=d3.select("text#"+e+"_d3plusmouseaxislabel"),t.size()?t.node().getBBox():{width:0,height:0}},r.attr("x",function(e){var r;return r=a(e).width,0===e.indexOf("x")?k-r/2-5:"y"===e?c.margin.left-t[e].ticks.size-r-10:c.margin.left+c.width+t[e].ticks.size}).attr("y",function(r){var n;return n=a(r).height,0===r.indexOf("y")?z-(n/2+5):e.d3plus.y0?e.d3plus.y+(e.d3plus.y0-e.d3plus.y)/2+c.margin.top-(n/2+5):"x"===r?c.height+c.margin.top+t[r].ticks.size:c.margin.top-t[r].ticks.size-n-10}).attr("width",function(e){return a(e).width+10}).attr("height",function(e){return a(e).height+10}).style("stroke","area"===t.shape.value?"transparent":n).attr("fill",n).attr("shape-rendering",function(e){return t[e].mouse.rendering.value}).style("stroke-width",function(e){return t[e].mouse.width})},y=t.g.labels.selectAll("rect.d3plus_mouse_axis_label").data(d),_?(y.enter().insert("rect","text.d3plus_mouse_axis_label").attr("class","d3plus_mouse_axis_label").attr("pointer-events","none").attr("opacity",0).call(m),y.transition().duration(_).delay(_).attr("opacity",1).call(m),y.exit().transition().duration(_).attr("opacity",0).remove()):(y.attr("opacity",1).call(m),y.enter().insert("rect","text.d3plus_mouse_axis_label").attr("class","d3plus_mouse_axis_label").attr("pointer-events","none").call(m),y.exit().remove())}},{"../../../../../client/pointer.coffee":38,"../../../../../color/legible.coffee":44,"../../../../../color/text.coffee":50,"../../../../../core/fetch/color.coffee":63,"../../../../../core/fetch/value.coffee":67,"../../../../../util/copy.coffee":206}],317:[function(e,t,r){var n,a,o,i,s,l,u,c,d,f,p,h;n=e("../../../../../util/buckets.coffee"),a=e("./buffer.coffee"),i=e("../../../../../core/fetch/value.coffee"),s=e("../../../../../font/sizes.coffee"),f=e("../../../../../textwrap/textwrap.coffee"),p=e("../../../../../core/data/time.coffee"),h=e("../../../../../util/uniques.coffee"),t.exports=function(e,t){var r,n,s,l,d,f,h,v,g,m,y,x,b,w,_,k,z,A;for(e.axes.margin=c(e),e.axes.height=e.height.viz,e.axes.width=e.width.viz,r=e.width.viz>e.height.viz?["y","y2","x","x2"]:["x","x2","y","y2"],d=0,h=r.length;h>d;d++)if(n=r[d],e[n].value){if(e[n].ticks.values===!1)if(e[n].value===e.time.value){for(k=e.time.solo.value,k=k.length?k.map(function(e){return e.constructor!==Date&&(e+="",4===e.length&&parseInt(e)+""===e&&(e+="/01/01"),e=new Date(e)),e}):e.data.time.values,l=d3.extent(k),b=e.data.time.stepType,k=[l[0]],_=l[0];_f;f++)n=r[f],e[n].axis.svg=o(e,n)},c=function(e){return e.small?{top:0,right:0,bottom:0,left:0}:{top:10,right:10,bottom:10,left:10}},u=function(e){var t,r,a,o,i,u,c,d,p,h,v,g,m,y,x,b,w,_,k,z,A,j,M,O,E,F,S,T,C,B;for(b=e.x.scale.viz.domain(),F=e.y.scale.viz.domain(),e.x2.value&&(g=e.x2.scale.viz.domain()),e.y2.value&&(M=e.y2.scale.viz.domain()),d=["y","y2"],r=0,i=d.length;i>r;r++)t=d[r],e[t].value&&(c="y"===t?"left":"right",O={"font-size":e[t].ticks.font.size+"px","font-family":e[t].ticks.font.family.value,"font-weight":e[t].ticks.font.weight,"text-transform":e[t].ticks.font.transform.value,"letter-spacing":e[t].ticks.font.spacing+"px"},B=e[t].ticks.visible,"log"===e[t].scale.value?C=B.map(function(e){return l(e)}):"share"===e[t].scale.value?C=B.map(function(r){return e.format.value(100*r,{key:"share",vars:e,output:t})}):e[t].value===e.time.value?C=B.map(function(r,n){return e[t].ticks.format(new Date(r))}):("string"==typeof B[0]&&(B=e[t].scale.viz.domain().filter(function(e){return 0!==e.indexOf("d3plus_buffer_")})),C=B.map(function(r){return e.format.value(r,{key:e[t].value,vars:e,labels:e[t].affixes.value,output:t})})),e[t].ticks.labels.value?(e[t].ticks.hidden=!1,E=d3.max(s(C,O),function(e){return e.width}),E=Math.ceil(E+e.labels.padding),e.axes.margin[c]+=E):e[t].ticks.hidden=!0,S=e[t].label.fetch(e),S?(T={"font-family":e[t].label.font.family.value,"font-weight":e[t].label.font.weight,"font-size":e[t].label.font.size+"px","text-transform":e[t].label.font.transform.value,"letter-spacing":e[t].label.font.spacing+"px"},e[t].label.height=s([S],T)[0].height):e[t].label.height=0,e[t].label.value&&(e.axes.margin[c]+=e[t].label.height,e.axes.margin[c]+=2*e[t].label.padding));for(e.axes.width-=e.axes.margin.left+e.axes.margin.right,e.x.scale.viz.range(n([0,e.axes.width],b.length)),g&&e.x2.scale.viz.range(n([0,e.axes.width],g.length)),p=["x","x2"],a=0,u=p.length;u>a;a++)t=p[a],e[t].value&&(c="x"===t?"bottom":"top",e[t].ticks.labels.value?(e[t].ticks.hidden=!1,m={"font-size":e[t].ticks.font.size+"px","font-family":e[t].ticks.font.family.value,"font-weight":e[t].ticks.font.weight,"text-transform":e[t].ticks.font.transform.value,"letter-spacing":e[t].ticks.font.spacing+"px"},j=e[t].ticks.visible,"log"===e[t].scale.value?A=j.map(function(e){return l(e)}):"share"===e[t].scale.value?A=j.map(function(r){return e.format.value(100*r,{key:"share",vars:e,output:t})}):e[t].value===e.time.value?A=j.map(function(r,n){return e[t].ticks.format(new Date(r))}):("string"==typeof j[0]&&(j=e[t].scale.viz.domain().filter(function(e){return 0!==e.indexOf("d3plus_buffer_")})),A=j.map(function(r){return e.format.value(r,{key:e[t].value,vars:e,labels:e[t].affixes.value,output:t})})),z=s(A,m),x=d3.max(z,function(e){return e.width}),y=d3.max(z,function(e){return e.height}),1===j.length?k=e.axes.width:(k=e[t].scale.viz(j[1])-e[t].scale.viz(j[0]),k=Math.abs(k)),x>k&&A.join("").indexOf(" ")>0?(e[t].ticks.wrap=!0,z=s(A,m,{mod:function(t){return f().container(d3.select(t)).height(e.axes.height/2).width(k).draw()}}),x=d3.max(z,function(e){return e.width}),y=d3.max(z,function(e){return e.height})):e[t].ticks.wrap=!1,e[t].ticks.baseline="auto",k>=x?e[t].ticks.rotate=0:xe.width.value&&(v=h-e.width.value+e.axes.margin.right,e.axes.width-=v,e.axes.margin.right+=v)):e[t].ticks.hidden=!0,w=e[t].label.fetch(e),w?(_={"font-family":e[t].label.font.family.value,"font-weight":e[t].label.font.weight,"font-size":e[t].label.font.size+"px","text-transform":e[t].label.font.transform.value,"letter-spacing":e[t].label.font.spacing+"px"},e[t].label.height=s([w],_)[0].height):e[t].label.height=0,e[t].label.value&&(e.axes.margin[c]+=e[t].label.height,e.axes.margin[c]+=2*e[t].label.padding));return e.axes.height-=e.axes.margin.top+e.axes.margin.bottom,e.x.scale.viz.range(n([0,e.axes.width],b.length)),g&&e.x2.scale.viz.range(n([0,e.axes.width],g.length)),e.y.scale.viz.range(n([0,e.axes.height],F.length)),M?e.y2.scale.viz.range(n([0,e.axes.height],M.length)):void 0},o=function(e,t){return d3.svg.axis().tickSize(e[t].ticks.size).tickPadding(5).orient(e[t].orient.value).scale(e[t].scale.viz).tickValues(e[t].ticks.values).tickFormat(function(r,n){var a,o;return e[t].ticks.hidden?null:(o=e[t].scale.value,a=r.constructor===Date?+r:r,e[t].ticks.visible.indexOf(a)>=0?"share"===o?e.format.value(100*r,{key:"share",vars:e,labels:e[t].affixes.value,output:t}):r.constructor===Date?e[t].ticks.format(r):"log"===o?l(r):e.format.value(r,{key:e[t].value,vars:e,labels:e[t].affixes.value,output:t}):null)})},d="⁰¹²³⁴⁵⁶⁷⁸⁹",l=function(e){var t,r,n;return r=Math.round(Math.log(Math.abs(e))/Math.LN10),n=Math.abs(e).toString().charAt(0),t="10 "+(r+"").split("").map(function(e){return d[e]}).join(""),"1"!==n&&(t=n+" x "+t),0>e?"-"+t:t}},{"../../../../../core/data/time.coffee":62,"../../../../../core/fetch/value.coffee":67,"../../../../../font/sizes.coffee":101,"../../../../../textwrap/textwrap.coffee":199,"../../../../../util/buckets.coffee":203,"../../../../../util/uniques.coffee":209,"./buffer.coffee":315}],318:[function(e,t,r){var n,a,o;n=e("../../../../../color/mix.coffee"),a=e("../../../../../textwrap/textwrap.coffee"),o=e("../../../../../object/validate.coffee"),t.exports=function(e){var t,r,i,s,l,u,c,d,f,p,h,v,g,m,y,x,b,w,_,k,z,A,j,M,O,E,F,S,T,C,B,N,P,I,q,V,R,D,U,L,Y,H,X,G,W,Q,J,K,Z,$,ee,te,re,ne,ae,oe,ie,se,le,ue,ce;if(h=e.x.domain.viz.concat(e.y.domain.viz),h.indexOf(void 0)>=0)return null;for(d={width:e.axes.width,height:e.axes.height,fill:e.axes.background.color,stroke:e.axes.background.stroke.color,"stroke-width":e.axes.background.stroke.width,"shape-rendering":e.axes.background.rendering.value},r={left:"start",center:"middle",right:"end"},s=e.small?[]:[0],oe=function(t,r){return t.attr("x1",function(t){return 0===r.indexOf("x")?e.x.scale.viz(t):0}).attr("x2",function(t){return 0===r.indexOf("x")?e.x.scale.viz(t):e.axes.width}).attr("y1",function(t){return 0===r.indexOf("y")?e.y.scale.viz(t):0}).attr("y2",function(t){return 0===r.indexOf("y")?e.y.scale.viz(t):e.axes.height})},ie=function(t,r,a){var o,i;return o=a?e[r].grid.color:e[r].ticks.color,i="log"===e[r].scale.value,t.attr("stroke",function(t){var s;return 0===t?e[r].axis.color:(t.constructor===Date&&(t=+t),s=e[r].ticks.visible.indexOf(t)>=0,!s||i&&"1"!==Math.abs(t).toString().charAt(0)?a&&"transparent"!==e.axes.background.color?n(o,e.axes.background.color,.4,1):"transparent"!==e.background.value?n(o,e.background.value,.4,1):n(o,"white",.4,1):o)}).attr("stroke-width",e[r].ticks.width).attr("shape-rendering",e[r].ticks.rendering.value)},v=function(t,r,n){var a;return a=0===r?"axis":"ticks",r=e[t][a].font[n],r&&(r.length||"number"==typeof r)?r:e[t].ticks.font[n]},ae=function(t,r){var a;return a="log"===e[r].scale.value,t.attr("font-size",function(e){return v(r,e,"size")+"px"}).attr("stroke","none").attr("fill",function(t){var o;return o=v(r,t,"color"),a&&"1"!==Math.abs(t).toString().charAt(0)?n(o,e.background.value,.4,1):o}).attr("font-family",function(e){return v(r,e,"family").value}).attr("font-weight",function(e){return v(r,e,"weight")}).style("text-transform",function(e){return v(r,e,"transform").value}).style("letter-spacing",function(e){return v(r,e,"spacing")+"px"})},N=function(t,r){var n,a;return n=0===r.indexOf("x")?"height":"width",a=0===r.indexOf("x")?"y":"x",t.attr(a+"1",0).attr(a+"2",e.axes[n]).attr(r+"1",function(e){return e.coords.line}).attr(r+"2",function(e){return e.coords.line}).attr("stroke",function(t){return t.color||e[r].lines.color}).attr("stroke-width",e[r].lines.width).attr("shape-rendering",e[r].lines.rendering.value).attr("stroke-dasharray",e[r].lines.dasharray.value)},T=function(t,n){var a;return a=0===n.indexOf("x")?"y":"x",t.attr(a,function(e){return e.coords.text[a]+"px"}).attr(n,function(e){return e.coords.text[n]+"px"}).attr("dy",e[n].lines.font.position.value).attr("text-anchor",r[e[n].lines.font.align.value]).attr("transform",function(e){return e.transform}).attr("font-size",e[n].lines.font.size+"px").attr("fill",function(t){return t.color||e[n].lines.color}).attr("font-family",e[n].lines.font.family.value).attr("font-weight",e[n].lines.font.weight)},L="translate("+e.axes.margin.left+","+e.axes.margin.top+")",U=e.group.selectAll("g#d3plus_graph_plane").data([0]),U.transition().duration(e.draw.timing).attr("transform",L),U.enter().append("g").attr("id","d3plus_graph_plane").attr("transform",L),c=U.selectAll("rect#d3plus_graph_background").data([0]),c.transition().duration(e.draw.timing).attr(d),c.enter().append("rect").attr("id","d3plus_graph_background").attr("x",0).attr("y",0).attr(d),V=U.selectAll("path#d3plus_graph_mirror").data([0]),V.enter().append("path").attr("id","d3plus_graph_mirror").attr("fill","#000").attr("fill-opacity",.03).attr("stroke-width",1).attr("stroke","#ccc").attr("stroke-dasharray","10,10").attr("opacity",0),V.transition().duration(e.draw.timing).attr("opacity",function(){return e.axes.mirror.value?1:0}).attr("d",function(){var e,t;return t=d.width,e=d.height,"M "+t+" "+e+" L 0 "+e+" L "+t+" 0 Z"}),Z=0!==e.x.ticks.rotate,ue=function(t,r){var n,o;return o="x"===r?e.axes.height:0,n=t.attr("transform","translate(0,"+o+")").call(e[r].axis.svg.scale(e[r].scale.viz)).selectAll("g.tick"),n.selectAll("line").attr("y2",function(t){var n;return t.constructor===Date&&(t=+t),n=d3.select(this).attr("y2"),e[r].ticks.visible.indexOf(t)>=0?n:n/2}),n.select("text").style("text-anchor",Z&&"x"===r?"end":Z?"start":"middle").call(ae,r).each(function(t){return d3.select(this).attr("dy","0px").attr("font-size",function(e){return v(r,e,"size")+"px"}),t.constructor===Date&&(t=+t),!e[r].ticks.hidden&&e[r].ticks.visible.indexOf(t)>=0?a().container(d3.select(this)).rotate(e[r].ticks.rotate).align(Z?"end":"center").valign(Z?"middle":"x"===r?"top":"bottom").width(e[r].ticks.maxWidth).height(e[r].ticks.maxHeight).padding(0).x(-e[r].ticks.maxWidth/2).y("x2"===r?-(e[r].ticks.maxHeight+2*e.labels.padding):0).draw():void 0})},ce=function(t,r){var n,a;return a="y2"===r?e.axes.width:0,n=t.attr("transform","translate("+a+", 0)").call(e[r].axis.svg.scale(e[r].scale.viz)).selectAll("g.tick"),n.selectAll("line").attr("y2",function(t){var r;return t.constructor===Date&&(t=+t),r=d3.select(this).attr("y2"),e.x.ticks.visible.indexOf(t)>=0?r:r/2}),n.select("text").call(ae,r)},W=["x","x2","y","y2"],x=0,A=W.length;A>x;x++)i=W[x],ee=0===i.indexOf("x")?ue:ce,H=s.length&&e[i].value?[0]:[],l=U.selectAll("g#d3plus_graph_"+i+"ticks").data(H),l.transition().duration(e.draw.timing).call(ee,i),l.selectAll("line").transition().duration(e.draw.timing).call(ie,i),y=l.enter().append("g").attr("id","d3plus_graph_"+i+"ticks").call(ee,i),y.selectAll("path").attr("fill","none").attr("stroke","none"),y.selectAll("line").call(ie,i),l.exit().transition().duration(e.data.timing).attr("opacity",0).remove();for(z=function(t,r){return t.attr("x",0===r.indexOf("x")?e.width.viz/2:-(e.axes.height/2+e.axes.margin.top)).attr("y","x"===r?e.height.viz-e[r].label.height/2-e[r].label.padding:"y2"===r?e.width.viz-e[r].label.height/2-e[r].label.padding:e[r].label.height/2+e[r].label.padding).attr("transform",0===r.indexOf("y")?"rotate(-90)":null).attr("font-family",e[r].label.font.family.value).attr("font-weight",e[r].label.font.weight).attr("font-size",e[r].label.font.size+"px").attr("fill",e[r].label.font.color).style("text-anchor","middle").attr("dominant-baseline","central").style("text-transform",e[r].label.font.transform.value).style("letter-spacing",e[r].label.font.spacing+"px")},Q=["x","y"],b=0,j=Q.length;j>b;b++)i=Q[b],e[i].grid.value?m=e[i].ticks.value?e[i].ticks.value:e[i].ticks.values:(m=[],D="x"===i?"y":"x",e[i].ticks.values.indexOf(0)>=0&&e[D].axis.value&&(m=[0])),g=U.selectAll("g#d3plus_graph_"+i+"grid").data([0]),g.enter().append("g").attr("id","d3plus_graph_"+i+"grid"),P=g.selectAll("line").data(m,function(e,t){return e.constructor===Date?e.getTime():e}),P.transition().duration(e.draw.timing).call(oe,i).call(ie,i,!0),P.enter().append("line").style("opacity",0).call(oe,i).call(ie,i,!0).transition().duration(e.draw.timing).delay(e.draw.timing/2).style("opacity",1),P.exit().transition().duration(e.draw.timing/2).style("opacity",0).remove();for(J=["x","x2","y","y2"],w=0,M=J.length;M>w;w++)i=J[w],e[i].value?(u=e[i].label.fetch(e),k=s&&u?[0]:[],t=e.format.affixes.value[e[i].value],u&&!e[i].affixes.value&&t&&($=e[i].affixes.separator.value,$===!0?$=["[","]"]:$===!1&&($=["",""]),u+=" "+$[0]+t[0]+" "+t[1]+$[1])):(u="",k=[]),_=e.group.selectAll("text#d3plus_graph_"+i+"label").data(k),_.text(u).transition().duration(e.draw.timing).call(z,i),_.enter().append("text").attr("stroke","none").attr("id","d3plus_graph_"+i+"label").text(u).call(z,i),_.exit().transition().duration(e.data.timing).attr("opacity",0).remove();for(K=["x","y","x2","y2"],q=0,O=K.length;O>q;q++)if(i=K[q],e[i].value){for(C=U.selectAll("g#d3plus_graph_"+i+"_userlines").data([0]),C.enter().append("g").attr("id","d3plus_graph_"+i+"_userlines"),p=e[i].scale.viz.domain(),0===i.indexOf("y")&&(p=p.slice().reverse()),te=[],S=[],se=e[i].lines.value||[],R=0,E=se.length;E>R;R++)F=se[R],f=o(F)?F.position:F,le=i===e.axes.discrete?p.indexOf(f)>=0:f>=p[0]&&f<=p[1],le&&(f=o(F)?F:{position:f},f.coords={line:e[i].scale.viz(f.position)},S.push(f),f.text&&(f.axis=i,f.padding=.5*e[i].lines.font.padding.value,f.align=e[i].lines.font.align.value,Y=e[i].lines.font.position.text,re="middle"===Y?0:2*f.padding,"top"===Y&&(re=-re),0===i.indexOf("x")?(ne="left"===f.align?e.axes.height:"center"===f.align?e.axes.height/2:0,"left"===f.align&&(ne-=2*f.padding),"right"===f.align&&(ne+=2*f.padding)):(ne="left"===f.align?0:"center"===f.align?e.axes.width/2:e.axes.width,"right"===f.align&&(ne-=2*f.padding),"left"===f.align&&(ne+=2*f.padding)),f.coords.text={},f.coords.text[0===i.indexOf("x")?"y":"x"]=ne,f.coords.text[i]=e[i].scale.viz(f.position)+re,f.transform=0===i.indexOf("x")?"rotate(-90,"+f.coords.text.x+","+f.coords.text.y+")":null,te.push(f)));P=C.selectAll("line.d3plus_graph_"+i+"line").data(S,function(e){return e.position}),P.enter().append("line").attr("class","d3plus_graph_"+i+"line").attr("opacity",0).call(N,i),P.transition().duration(e.draw.timing).attr("opacity",1).call(N,i),P.exit().transition().duration(e.draw.timing).attr("opacity",0).remove(),I=C.selectAll("text.d3plus_graph_"+i+"line_text").data(te,function(e){return e.position}),I.enter().append("text").attr("class","d3plus_graph_"+i+"line_text").attr("id",function(e){var t;return t=e.position+"",t=t.replace("-","neg"),t=t.replace(".","p"),"d3plus_graph_"+i+"line_text_"+t}).attr("opacity",0).call(T,i),I.text(function(e){return e.text}).transition().duration(e.draw.timing).attr("opacity",1).call(T,i),I.exit().transition().duration(e.draw.timing).attr("opacity",0).remove(),G=function(t){var r;return r=function(e){var t;return t=e.position+"",t=t.replace("-","neg"),t=t.replace(".","p"),U.select("text#d3plus_graph_"+e.axis+"line_text_"+t).node().getBBox()},t.attr("x",function(e){return r(e).x-e.padding}).attr("y",function(e){return r(e).y-e.padding}).attr("transform",function(e){return e.transform}).attr("width",function(e){return r(e).width+2*e.padding}).attr("height",function(e){return r(e).height+2*e.padding}).attr("fill","transparent"!==e.axes.background.color?e.axes.background.color:"white")},X=e[i].lines.font.background.value?te:[],B=C.selectAll("rect.d3plus_graph_"+i+"line_rect").data(X,function(e){return e.position}),B.enter().insert("rect","text.d3plus_graph_"+i+"line_text").attr("class","d3plus_graph_"+i+"line_rect").attr("pointer-events","none").attr("opacity",0).call(G),B.transition().delay(e.draw.timing).each("end",function(t){return d3.select(this).transition().duration(e.draw.timing).attr("opacity",1).call(G)}),B.exit().transition().duration(e.draw.timing).attr("opacity",0).remove()}}},{"../../../../../color/mix.coffee":46,"../../../../../object/validate.coffee":171,"../../../../../textwrap/textwrap.coffee":199}],319:[function(e,t,r){var n,a,o;n=e("../../../../core/fetch/value.coffee"),a=e("../../../../string/strip.js"),o=e("../../../../util/uniques.coffee"),t.exports=function(e,t,r){var i,s,l,u,c,d,f;return void 0===r?r=e.id.nesting.slice(0,e.depth.value+1):r.constructor!==Array&&(r=[r]),void 0===s&&(s=[]),t||(t=e.data.viz),i=e[e.axes.discrete],u=e[e.axes.opposite],f=i.value===e.time.value,f?(d=e.data.time.ticks,l=e.time.solo.value.length?"solo":"mute",e.time[l].value.length&&(c=e.time[l].value.slice().map(function(e){return e.constructor!==Date&&(e+="",4===e.length&&parseInt(e)+""===e&&(e+="/01/01"),e=new Date(e)),+e}),d=d.filter(function(e){return"solo"===l?c.indexOf(+e)>=0:c.indexOf(+e)<0}))):d=i.ticks.values?i.ticks.values:o(t,i.value,n,e),d3.nest().key(function(t){var o,i,s,l,u;for(l="nesting",i=0,s=r.length;s>i;i++)o=r[i],u=n(e,t,o),u instanceof Array&&(u=u.join("_")),l+="_"+a(u);return l}).rollup(function(t){var r,a,s,c,p,h,v,g,m,y,x,b;if(r=o(t,i.value,n,e),b=r.length&&r[0].constructor===Date,b&&(r=r.map(Number)),i.zerofill.value)for(a="log"===i.scale.value?u.scale.viz.domain().every(function(e){return 0>e})?-1:1:0,s=c=0,h=d.length;h>c;s=++c)if(x=d[s],y=f?+x:x,r.indexOf(y)<0){for(g={d3plus:{}},m=e.id.nesting,p=0,v=m.length;v>p;p++)l=m[p],l in t[0]&&(g[l]=t[0][l]);g[i.value]=x,g[u.value]=0,g[u.value]=a,t.splice(s,0,g)}return"string"==typeof t[0][i.value]?t:t.sort(function(t,r){var a,o,s,l,c;return a=n(e,t,i.value),s=n(e,r,i.value),(c=a-s)?c:(o=n(e,t,u.value),l=n(e,r,u.value),o-l)})}).entries(t)}},{"../../../../core/fetch/value.coffee":67,"../../../../string/strip.js":174,"../../../../util/uniques.coffee":209}],320:[function(e,t,r){var n;n=e("../../../../core/fetch/value.coffee"),t.exports=function(e,t){var r,a,o,i,s,l,u,c,d,f,p,h,v,g,m,y,x;for(m=e.axes.stacked||e.axes.opposite,a=e[m].scale.viz(0),v=e[m].scale.value,p="x"===m?"y":"x",u="y"===m?e.axes.margin.top:e.axes.margin.left,f="share"===v?"expand":"zero",g=d3.layout.stack().values(function(e){return e.values||[e]}).offset(f).x(function(e){return e.d3plus[p]}).y(function(t){return a-e[m].scale.viz(n(e,t,e[m].value))}).out(function(t,r,o){var i,s;return s=n(e,t,e[m].value),i=0>s,"share"===v?(t.d3plus[m+"0"]=(1-r)*a,t.d3plus[m]=t.d3plus[m+"0"]-o*a):(t.d3plus[m+"0"]=a,e.axes.stacked&&(t.d3plus[m+"0"]-=r),t.d3plus[m]=t.d3plus[m+"0"]-o),t.d3plus[m]+=u,t.d3plus[m+"0"]+=u}),h=[],d=[],o=0,s=t.length;s>o;o++)if(r=t[o],x=n(e,r,e[m].value),x instanceof Array){for(c=!0,i=0,l=x.length;l>i;i++)if(y=x[i],y>=0){c=!1;break}c?d.push(r):h.push(r)}else x>=0&&h.push(r),0>x&&d.push(r);return 0===h.length||0===d.length?g(t):(h.length&&(h=g(h)),d.length&&(d=g(d)),h.concat(d))}},{"../../../../core/fetch/value.coffee":67}],321:[function(e,t,r){var n,a,o,i,s,l;n=e("../../core/fetch/value.coffee"),a=e("./helpers/graph/draw.coffee"),i=e("./helpers/graph/nest.coffee"),s=e("../../array/sort.coffee"),l=e("./helpers/graph/stack.coffee"),o=function(e){var t,r,o,i,u,c,d,f,p,h,v;if(a(e,{buffer:e.axes.opposite,mouse:!0}),o=e.x.domain.viz.concat(e.y.domain.viz),o.indexOf(void 0)>=0)return[];for(r=s(e.data.viz,null,null,null,e),i=0,c=r.length;c>i;i++)for(f=r[i],p=f.values,u=0,d=p.length;d>u;u++)t=p[u],h=n(e,t,e.x.value),null!==h?(t.d3plus.x2=!1,t.d3plus.x=e.x.scale.viz(h)):(t.d3plus.x2=!0,t.d3plus.x=e.x2.scale.viz(n(e,t,e.x2.value))),t.d3plus.x+=e.axes.margin.left,v=n(e,t,e.y.value),null!==v?(t.d3plus.y2=!1,t.d3plus.y=e.y.scale.viz(v)):(t.d3plus.y2=!0,t.d3plus.y=e.y2.scale.viz(n(e,t,e.y2.value))),t.d3plus.y+=e.axes.margin.top;return e.axes.stacked?l(e,r):r},o.filter=function(e,t){return i(e,t)},o.requirements=["data","x","y"],o.setup=function(e){var t;e.axes.discrete||(t=e.time.value===e.y.value?"y":"x",e.self[t]({scale:"discrete"}))},o.shapes=["line"],o.tooltip="static",t.exports=o},{"../../array/sort.coffee":34,"../../core/fetch/value.coffee":67,"./helpers/graph/draw.coffee":313,"./helpers/graph/nest.coffee":319,"./helpers/graph/stack.coffee":320}],322:[function(e,t,r){var n=e("../../network/smallestGap.coffee"),a=e("../../core/fetch/value.coffee"),o=function(e){var t=e.nodes.restricted||e.nodes.value,r=e.edges.restricted||e.edges.value,o=d3.extent(t,function(e){return e.x}),i=d3.extent(t,function(e){return e.y}),s=[1,1];if("number"==typeof e.size.value?s=[e.size.value,e.size.value]:e.size.value&&(s=d3.extent(t,function(t){var r=a(e,t,e.size.value);return 0===r?null:r})),"undefined"==typeof s[0]&&(s=[1,1]),"number"==typeof e.size.value)var l=e.size.value,u=e.size.value;else{var l=n(t,{accessor:function(e){return[e.x,e.y]}}),c=l/2,d=e.size.value?e.nodes.overlap:.4;if(l*=d,e.edges.arrows.value&&(l=.5*l),s[0]===s[1]){var u=c;l=c}else{var f=o[1]+1.1*l-(o[0]-1.1*l),p=i[1]+1.1*l-(i[0]-1.1*l),h=f/p,v=e.width.viz/e.height.viz;if(v>h)var g=e.height.viz/p;else var g=e.width.viz/f;var u=.25*l;2>u*g&&(u=2/g)}}var m=e.size.scale.value.domain(s).range([u,l]);e.zoom.bounds=[[o[0]-1.1*l,i[0]-1.1*l],[o[1]+1.1*l,i[1]+1.1*l]];var y=[],x={};return t.forEach(function(t){var r=e.data.viz.filter(function(r){return r[e.id.value]==t[e.id.value]})[0],n=r||{};n[e.id.value]=t[e.id.value],n.d3plus={},n.d3plus.x=t.x,n.d3plus.y=t.y;var o=a(e,n,e.size.value);n.d3plus.r=o?m(o):m.range()[0],x[n[e.id.value]]={x:n.d3plus.x,y:n.d3plus.y, r:n.d3plus.r},y.push(n)}),y.sort(function(e,t){return t.d3plus.r-e.d3plus.r}),r.forEach(function(t,r){t.d3plus&&delete t.d3plus.spline,t[e.edges.source].d3plus={};var n=x[t[e.edges.source][e.id.value]];t[e.edges.source].d3plus.r=n.r,t[e.edges.source].d3plus.x=n.x,t[e.edges.source].d3plus.y=n.y,t[e.edges.target].d3plus={};var a=x[t[e.edges.target][e.id.value]];t[e.edges.target].d3plus.r=a.r,t[e.edges.target].d3plus.x=a.x,t[e.edges.target].d3plus.y=a.y}),{nodes:y,edges:r}};o.nesting=!1,o.requirements=["nodes","edges"],o.scale=1.05,o.shapes=["circle","square","donut"],o.tooltip="static",o.zoom=!0,t.exports=o},{"../../core/fetch/value.coffee":67,"../../network/smallestGap.coffee":167}],323:[function(e,t,r){var n,a,o,i,s=[].indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(t in this&&this[t]===e)return t;return-1};a=e("../../network/shortestPath.coffee"),n=e("../../core/fetch/value.coffee"),o=e("../../util/uniques.coffee"),i=function(e){var t,r,a,o,l,u,c,d,f,p,h,v,g,m,y,x,b,w,_,k,z,A,j,M,O,E,F,S,T,C,B,N,P,I,q,V,R,D,U,L,Y,H,X,G,W,Q,J,K,Z,$,ee,te,re,ne,ae,oe,ie,se,le,ue,ce,de,fe;for(h=[],H={},H[e.focus.value[0]]=0,H[e.focus.value[1]]=0,X={all:[[e.focus.value[0]],[e.focus.value[1]]]},J=i.paths,Y=m=0,k=J.length;k>m;Y=++m)for(L=J[Y],h=h.concat(L.edges),_=e.focus.value[0],X[Y]=[_],K=L.edges,p=y=0,z=K.length;z>y;p=++y)f=K[p],f[e.edges.source]=e.data.viz.filter(function(t){return f[e.edges.source][e.id.value]===t[e.id.value]})[0],f[e.edges.target]=e.data.viz.filter(function(t){return f[e.edges.target][e.id.value]===t[e.id.value]})[0],I=f[e.edges.source][e.id.value]===_?"target":"source",q=f[e.edges[I]][e.id.value],void 0===H[q]&&(H[q]=Y),X[Y].push(q),_=q;oe=0;for(Y in X)if(L=X[Y],"all"!==Y){for(N=0,v=x=0,A=L.length;A>x;v=++x)if(g=L[v],0!==v&&v!==L.length-1&&H[g]===parseFloat(Y)){for(N=1,G=L[v-1],P=L[v+1],W=null,V=null,Z=X.all,u=S=0,j=Z.length;j>S;u=++S)l=Z[u],s.call(l,G)>=0&&(W=u),s.call(l,P)>=0&&(V=u);null!==W&&null===V?W+1===X.all.length-1?X.all.splice(W+1,0,[g]):X.all[W+1].push(g):V-W===1?X.all.splice(V,0,[g]):V-W>1&&X.all[V-1].push(g)}oe+=N}for(ae=Math.floor(e.height.viz/oe),fe=[],v=0;oe>v;)v%2===0?fe.push(v):fe.unshift(v),v++;for(b=e.size.value&&!e.small?30:0,de=d3.scale.ordinal().domain(fe).range(d3.range(ae/2-b,e.height.viz+ae/2-b,(e.height.viz-ae)/(oe-1))),d=X.all.length,c=Math.floor(e.width.viz/d),ue=d3.scale.linear().domain([0,d-1]).rangeRound([c/2,e.width.viz-c/2]),C=5,T=.4*d3.min([c,ae-b]),se=d3.extent(e.data.viz,function(t){var r;return r=n(e,t,e.size.value),r||0}),ie=e.size.scale.value.domain(se).rangeRound([C,T]),$=e.data.viz,B=0,M=$.length;M>B;B++){for(R=$[B],null==R.d3plus&&(R.d3plus={}),ee=X.all,u=D=0,O=ee.length;O>D;u=++D)l=ee[u],te=R[e.id.value],s.call(l,te)>=0&&(R.d3plus.x=ue(u));R.d3plus.y=de(H[R[e.id.value]]),e.size.value?(le=n(e,R,e.size.value),R.d3plus.r=le?ie(le):C):R.d3plus.r=T,R.d3plus.r<.1*c&&!e.small?R.d3plus.label={x:0,y:R.d3plus.r+2*e.labels.padding,w:.6*c,h:b+T-R.d3plus.r,resize:!1}:delete R.d3plus.label}for(re=i.paths,Y=U=0,E=re.length;E>U;Y=++U)for(L=re[Y],_=e.focus.value[0],ne=L.edges,p=Q=0,F=ne.length;F>Q;p=++Q)f=ne[p],I=f[e.edges.source][e.id.value]===_?"target":"source",w="target"===I?"source":"target",q=f[e.edges[I]][e.id.value],H[_]!==H[q]?(f.d3plus={spline:!0},null==(t=f[e.edges.source]).d3plus&&(t.d3plus={}),null==(r=f[e.edges.source].d3plus).edges&&(r.edges={}),null==(a=f[e.edges.target]).d3plus&&(a.d3plus={}),null==(o=f[e.edges.target].d3plus).edges&&(o.edges={}),ce=f[I].d3plus.x-f[w].d3plus.x,f[w].d3plus.edges[f[I][e.id.value]]={angle:Math.PI,radius:c/2},f[I].d3plus.edges[f[w][e.id.value]]={angle:0,radius:c/2,offset:ce-c}):delete f.d3plus,_=q;return{nodes:e.data.viz,edges:h}},i.filter=function(e,t){var r,s,l,u,c,d,f,p,h,v,g,m,y,x,b,w,_,k,z;for(u=e.edges.filtered||e.edges.value,i.paths=a(u,e.focus.value[0],{target:e.focus.value[1],distance:e.edges.size.value||void 0,nodeid:e.id.value,startpoint:e.edges.source,endpoint:e.edges.target,K:e.edges.limit.value||5}),i.nodes=[],r=[],b=i.paths,f=0,v=b.length;v>f;f++)for(x=b[f],w=x.edges,p=0,g=w.length;g>p;p++)l=w[p],k=l[e.edges.source],z=l[e.edges.target],r.indexOf(k[e.id.value])<0&&(i.nodes.push(k),r.push(k[e.id.value])),r.indexOf(z[e.id.value])<0&&(i.nodes.push(z),r.push(z[e.id.value]));for(d=o(i.nodes,e.id.value,n,e),_=[],h=0,m=d.length;m>h;h++)c=d[h],s=t.filter(function(t){return t[e.id.value]===c}),s[0]?_.push(s[0]):(y={d3plus:{}},y[e.id.value]=c,_.push(y));return _},i.nesting=!1,i.requirements=[function(e){return{status:2===e.focus.value.length,text:e.format.locale.value.method.focus+" x 2"}},"edges"],i.scale=1,i.shapes=["circle","square","donut"],i.tooltip="static",t.exports=i},{"../../core/fetch/value.coffee":67,"../../network/shortestPath.coffee":166,"../../util/uniques.coffee":209}],324:[function(e,t,r){var n,a,o,i;n=e("../../array/comparator.coffee"),a=e("../../core/data/threshold.js"),o=e("../../core/data/group.coffee"),i=function(e){var t,r,a,i,s,l,u,c,d;for(u=d3.layout.pie().value(function(e){return e.value}).sort(function(t,r){return e.order.value?n(t.d3plus,r.d3plus,[e.order.value],e.order.sort.value,[],e):e.id.nesting.length>1?n(t.d3plus,r.d3plus,e.id.nesting.concat([e.size.value]),void 0,[],e):n(t.d3plus,r.d3plus,[e.size.value],"desc",[],e)}),r=o(e,e.data.viz,[]),l=u(r),d=[],c=d3.min([e.width.viz,e.height.viz])/2-2*e.labels.padding,a=0,s=l.length;s>a;a++)t=l[a],i=t.data.d3plus,i.d3plus.startAngle=t.startAngle,i.d3plus.endAngle=t.endAngle,i.d3plus.r=c,i.d3plus.x=e.width.viz/2,i.d3plus.y=e.height.viz/2,i.d3plus.share=(t.endAngle-t.startAngle)/(2*Math.PI),d.push(i);return d},i.filter=a,i.requirements=["data","size"],i.shapes=["arc"],i.threshold=function(e){return 1600/(e.width.viz*e.height.viz)},t.exports=i},{"../../array/comparator.coffee":32,"../../core/data/group.coffee":57,"../../core/data/threshold.js":61}],325:[function(e,t,r){var n,a,o,i,s,l,u,c,d,f,p;a=e("../../array/comparator.coffee"),d=e("../../array/sort.coffee"),o=e("../../core/data/threshold.js"),i=e("../../core/fetch/text.js"),s=e("../../core/fetch/value.coffee"),l=e("../../font/sizes.coffee"),u=e("../../geom/offset.coffee"),f=e("../../textwrap/textwrap.coffee"),n=e("../../util/buckets.coffee"),p=e("../../util/uniques.coffee"),c=function(e){var t,r,a,o,c,d,h,v,g,m,y,x,b,w,_,k,z,A,j,M,O,E,F,S,T,C,B,N,P,I,q,V,R,D,U,L,Y,H,X,G,W,Q,J,K,Z,$,ee,te,re,ne,ae,oe,ie,se;for(m=e.data.viz,L=e.depth.value+1,Y=e.id.nesting[L],v=function(){var e,t,r;for(r=[],e=0,t=m.length;t>e;e++)g=m[e],r.push(g[Y]);return r}(),oe=function(){var t,r,n;for(n=[],t=0,r=m.length;r>t;t++)g=m[t],n.push(p(m,Y,s,e,L));return n}(),oe=p(d3.merge(oe)).length,o=2*Math.PI/oe,D=d3.min([e.width.viz,e.height.viz])/2,F=0,C=0,B=function(){var t,r,n;for(n=[],t=0,r=v.length;r>t;t++)d=v[t],n.push(i(e,d,L)[0]);return n}(),B=p(d3.merge(B)),e.labels.value&&(y=u(Math.PI/2,D),ee=u(o+Math.PI/2,D),F=y.x-ee.x-2*e.labels.padding,ne={fill:e.x.ticks.font.color,"font-family":e.x.ticks.font.family.value,"font-weight":e.x.ticks.font.weight,"font-size":e.x.ticks.font.size+"px"},te=l(B,ne,{mod:function(t){return f().container(d3.select(t)).width(e.height.viz/8).height(F).draw()}}),C=d3.max(te,function(e){return e.width}),D-=C,D-=2*e.labels.padding),R=function(){var t,r,n;for(n=[],t=0,r=v.length;r>t;t++)d=v[t],n.push(function(){var t,r,n;for(n=[],t=0,r=d.length;r>t;t++)g=d[t],n.push(s(e,g,e.size.value));return n}());return n}(),R=d3.max(d3.merge(R)),G=d3.scale.linear().domain([0,R]).range([0,D]),k=function(){var t,r,n;for(n=[],t=0,r=v.length;r>t;t++)d=v[t],n.push(s(e,d,Y));return n}(),k=p(d3.merge(k)),_=d3.scale.ordinal().domain(k).range(d3.range(0,k.length)),A=0,N=m.length;N>A;A++)for(g=m[A],g.d3plus.x=e.width.viz/2+e.margin.top,g.d3plus.y=e.height.viz/2+e.margin.left,W=g[Y],w=j=0,P=W.length;P>j;w=++j)t=W[w],t.d3plus||(t.d3plus={}),t.d3plus.r=G(s(e,t,e.size.value)),t.d3plus.a=_(s(e,t,Y))*o;for(z=1,Q=[10,5,4,2],V=0,I=Q.length;I>V;V++)if(w=Q[V],D/w>=20){z=w;break}for(K=n([D/z,D],z-1).reverse(),K.length===z&&K.shift(),$=e.group.selectAll(".d3plus_radar_rings").data(K,function(e,t){return t}),Z=function(t){return t.attr("fill",function(t,r){return 0===r?e.axes.background.color:"transparent"}).attr("cx",e.width.viz/2+e.margin.top).attr("cy",e.height.viz/2+e.margin.left).attr("stroke",e.x.grid.value?e.x.grid.color:"transparent")},$.enter().append("circle").attr("class","d3plus_radar_rings").call(Z).attr("r",0),$.transition().duration(e.draw.timing).call(Z).attr("r",function(e){return e}),$.exit().transition().duration(e.draw.timing).attr("opacity",0).remove(),S=d3.scale.ordinal().domain(B).range(d3.range(0,B.length)),O=[],U=0,q=B.length;q>U;U++)M=B[U],r=o*S(M)-Math.PI/2,t=r*(180/Math.PI),-90>t||t>90?(t-=180,c=-(D+2*e.labels.padding+C),a="end"):(c=D+2*e.labels.padding,a="start"),ae=0>r||r>Math.PI,J=r=0,h&&(ie-=C/2),O.push({text:M,angle:t,x:c,anchor:a,offset:H});return E=e.group.selectAll("g.d3plus_radar_label_group").data([0]),E.enter().append("g").attr("class","d3plus_radar_label_group").attr("transform","translate("+e.width.viz/2+","+e.height.viz/2+")"),E.transition().duration(e.draw.timing).attr("transform","translate("+e.width.viz/2+","+e.height.viz/2+")"),re=E.selectAll(".d3plus_radar_labels").data(e.labels.value?O:[],function(e,t){return t}),T=function(e){return e.attr(ne).each(function(e,t){return f().container(d3.select(this)).height(F).width(C).align(e.anchor).text(e.text).padding(0).valign("middle").x(e.x).y(-F/2).draw()}).attr("transform",function(e){var t;return t=d3.select(this).attr("transform")||"",t.length&&(t=t.split(")").slice(-3).join(")")),"rotate("+e.angle+")"+t})},re.call(T),re.enter().append("text").attr("class","d3plus_radar_labels").attr("opacity",0).call(T).transition().duration(e.draw.timing).attr("opacity",1),re.exit().transition().duration(e.draw.timing).attr("opacity",0).remove(),x=e.group.selectAll(".d3plus_radar_lines").data(O,function(e,t){return t}),b=function(t){return t.attr("stroke",e.x.grid.color).attr("x1",e.width.viz/2+e.margin.left).attr("y1",e.height.viz/2+e.margin.top)},x.enter().append("line").attr("class","d3plus_radar_lines").call(b).attr("x2",e.width.viz/2+e.margin.left).attr("y2",e.height.viz/2+e.margin.top),x.transition().duration(e.draw.timing).call(b).attr("x2",function(t){return e.width.viz/2+e.margin.left+t.offset.x}).attr("y2",function(t){return e.height.viz/2+e.margin.top+t.offset.y}),x.exit().transition().duration(e.draw.timing).attr("opacity",0).remove(),e.mouse.viz={click:!1},m},c.requirements=["data","size"],c.shapes=["radial"],t.exports=c},{"../../array/comparator.coffee":32,"../../array/sort.coffee":34,"../../core/data/threshold.js":61,"../../core/fetch/text.js":66,"../../core/fetch/value.coffee":67,"../../font/sizes.coffee":101,"../../geom/offset.coffee":160,"../../textwrap/textwrap.coffee":199,"../../util/buckets.coffee":203,"../../util/uniques.coffee":209}],326:[function(e,t,r){var n=e("../../array/sort.coffee"),o=e("../../client/pointer.coffee"),i=e("../../core/fetch/value.coffee"),s=e("../../core/fetch/color.coffee"),l=e("../../color/legible.coffee"),u=e("../../tooltip/remove.coffee"),c=e("../../network/smallestGap.coffee"),d=e("../../color/text.coffee"),f=e("../../util/uniques.coffee"),p=function(e){var t=d3.min([e.height.viz,e.width.viz])/2,r=e.small||!e.labels.value?(t-2*e.labels.padding)/2:t/3,p=e.small||!e.labels.value?1.4*r:r,h=2*r,v=[],g=[],m=e.data.viz.filter(function(t){return t[e.id.value]===e.focus.value[0]})[0];m||(m={d3plus:{}},m[e.id.value]=e.focus.value[0]),m.d3plus.x=e.width.viz/2,m.d3plus.y=e.height.viz/2,m.d3plus.r=.65*p;var y=[],x=[e.focus.value[0]];e.edges.connections(e.focus.value[0],e.id.value).forEach(function(t){var r=t[e.edges.source][e.id.value]==e.focus.value[0]?t[e.edges.target]:t[e.edges.source],n=e.data.viz.filter(function(t){return t[e.id.value]===r[e.id.value]})[0];n||(n={d3plus:{}},n[e.id.value]=r[e.id.value]),n.d3plus.edges=e.edges.connections(n[e.id.value],e.id.value).filter(function(t){return t[e.edges.source][e.id.value]!=e.focus.value[0]&&t[e.edges.target][e.id.value]!=e.focus.value[0]}),n.d3plus.edge=t,x.push(n[e.id.value]),y.push(n)});var b=e.order.value||e.color.value||e.size.value||e.id.value;y.sort(function(t,r){var a=t.d3plus.edges.length-r.d3plus.edges.length;return a?a:n([t,r],b,e.order.sort.value,e.color.value||[],e)}),"number"==typeof e.edges.limit.value?y=y.slice(0,e.edges.limit.value):"function"==typeof e.edges.limit.value&&(y=e.edges.limit.value(y));var w=[],_=0;y.forEach(function(t){var r=t[e.id.value];t.d3plus.edges=t.d3plus.edges.filter(function(t){var n=t[e.edges.source][e.id.value],a=t[e.edges.target][e.id.value];return x.indexOf(n)<0&&a==r||x.indexOf(a)<0&&n==r}),_+=t.d3plus.edges.length||1,t.d3plus.edges.forEach(function(t){var n=t[e.edges.source],a=t[e.edges.target],o=a[e.id.value]==r?n:a;x.push(o[e.id.value])})}),n(y,b,e.order.sort.value,e.color.value||[],e);var k=0,z=2*Math.PI,A=0;y.forEach(function(t,r){var o=t.d3plus.edges.length||1,i=z/_*o;0==r&&(A=s,k-=i/2);var s=k+i/2;s-=z/4,t.d3plus.radians=s,t.d3plus.x=e.width.viz/2+p*Math.cos(s),t.d3plus.y=e.height.viz/2+p*Math.sin(s),k+=i,t.d3plus.edges.sort(function(r,a){var r=r[e.edges.source][e.id.value]==t[e.id.value]?r[e.edges.target]:r[e.edges.source],a=a[e.edges.source][e.id.value]==t[e.id.value]?a[e.edges.target]:a[e.edges.source];return n([r,a],b,e.order.sort.value,e.color.value||[],e)}),t.d3plus.edges.forEach(function(r,n){var i=r[e.edges.source][e.id.value]==t[e.id.value]?r[e.edges.target]:r[e.edges.source],l=z/_,u=e.data.viz.filter(function(t){return t[e.id.value]===i[e.id.value]})[0];u||(u={d3plus:{}},u[e.id.value]=i[e.id.value]),a=s-l*o/2+l/2+l*n,u.d3plus.radians=a,u.d3plus.x=e.width.viz/2+h*Math.cos(a),u.d3plus.y=e.height.viz/2+h*Math.sin(a),w.push(u)})});var j=c(y,{accessor:function(e){return[e.d3plus.x,e.d3plus.y]}}),M=c(w,{accessor:function(e){return[e.d3plus.x,e.d3plus.y]}});if(j||(j=r/2),M||(M=r/4),8>j/2-4)var O=d3.min([j/2,8]);else var O=j/2-4;if(4>M/2-4)var E=d3.min([M/2,4]);else var E=M/2-4;E>r/10&&(E=r/10),E>O&&E>10&&(E=.75*O),O>1.5*E&&(O=1.5*E),O=Math.floor(O),E=Math.floor(E);var F=f(y,e.id.value,i,e);F=F.concat(f(w,e.id.value,i,e)),F.push(e.focus.value[0]);var S=e.data.viz.filter(function(t){return F.indexOf(t[e.id.value])>=0});if(e.size.value){var T=d3.extent(S,function(t){return i(e,t,e.size.value)});T[0]==T[1]&&(T[0]=0);var t=d3.scale.linear().domain(T).rangeRound([3,d3.min([O,E])]),C=i(e,m,e.size.value);m.d3plus.r=t(C)}else{var t=d3.scale.linear().domain([1,2]).rangeRound([O,E]);e.edges.label&&(m.d3plus.r=1.5*t(1))}w.forEach(function(r){r.d3plus.ring=2;var n=e.size.value?i(e,r,e.size.value):2;r.d3plus.r=t(n)}),y.forEach(function(r){r.d3plus.ring=1;var n=e.size.value?i(e,r,e.size.value):1;r.d3plus.r=t(n)}),g=[m].concat(y).concat(w),y.forEach(function(t,n){var a=[e.edges.source,e.edges.target],o=t.d3plus.edge;a.forEach(function(t){o[t]=g.filter(function(r){return r[e.id.value]==o[t][e.id.value]})[0]}),delete o.d3plus,v.push(o),e.edges.connections(t[e.id.value],e.id.value).forEach(function(n){var a=n[e.edges.source][e.id.value]==t[e.id.value]?n[e.edges.target]:n[e.edges.source];if(a[e.id.value]!=m[e.id.value]){var o=w.filter(function(t){return t[e.id.value]==a[e.id.value]})[0];if(o);else{o=y.filter(function(t){return t[e.id.value]==a[e.id.value]})[0]}if(o){n.d3plus={spline:!0,translate:{x:e.width.viz/2,y:e.height.viz/2}};var i=[e.edges.source,e.edges.target];i.forEach(function(a,i){n[a]=g.filter(function(t){return t[e.id.value]==n[a][e.id.value]})[0],void 0===n[a].d3plus.edges&&(n[a].d3plus.edges={});var s=0===i?n[e.edges.target][e.id.value]:n[e.edges.source][e.id.value];n[a][e.id.value]==t[e.id.value]?n[a].d3plus.edges[s]={angle:t.d3plus.radians+Math.PI,radius:r/2}:n[a].d3plus.edges[s]={angle:o.d3plus.radians,radius:r/2}}),v.push(n)}}})});var B=!1;return e.background.value&&["transparent","none"].indexOf(e.background.value)<0&&d3.hsl(e.background.value).l<.5&&(B=d(e.background.value)),g.forEach(function(t){if(!e.small&&e.labels.value)if(t[e.id.value]!=e.focus.value[0]){t.d3plus.rotate=t.d3plus.radians*(180/Math.PI);var n=t.d3plus.rotate,a=r-3*e.labels.padding-t.d3plus.r;if(-90>n||n>90){n-=180;var o=-(t.d3plus.r+a/2+e.labels.padding),i="end"}else var o=t.d3plus.r+a/2+e.labels.padding,i="start";var u=y.indexOf(t)>=0?!0:!1,c=1==t.d3plus.ring?j:M;t.d3plus.label={x:o,y:0,w:a,h:c,angle:n,anchor:i,valign:"center",color:B||l(s(e,t)),resize:[8,e.labels.font.size],background:u,mouse:!0}}else if(e.size.value||e.edges.label){var c=p-2*t.d3plus.r-2*e.labels.padding;t.d3plus.label={x:0,y:t.d3plus.r+c/2,w:p,h:c,color:B||l(s(e,t)),resize:[10,40],background:!0,mouse:!0}}else delete t.d3plus.rotate,delete t.d3plus.label;else delete t.d3plus.rotate,delete t.d3plus.label}),e.mouse.viz={},e.mouse.viz[o.click]=function(t){if(t[e.id.value]!=e.focus.value[0]){u(e.type.value);var r=e.focus.value[0];e.history.states.push(function(){e.self.focus(r).draw()}),e.self.focus(t[e.id.value]).draw()}},{edges:v,nodes:g,data:S}};p.filter=function(e,t){var r=e.edges.connections(e.focus.value[0],e.id.value,!0),n=[];r.forEach(function(t){n=n.concat(e.edges.connections(t[e.id.value],e.id.value,!0))});var a=r.concat(n),o=f(a,e.id.value,i,e),s=[];return o.forEach(function(r){var n=t.filter(function(t){return t[e.id.value]==r})[0];if(n)s.push(n);else{var a={d3plus:{}};a[e.id.value]=r,s.push(a)}}),s},p.nesting=!1,p.scale=1,p.shapes=["circle","square","donut"],p.requirements=["edges","focus"],p.tooltip="static",t.exports=p},{"../../array/sort.coffee":34,"../../client/pointer.coffee":38,"../../color/legible.coffee":44,"../../color/text.coffee":50,"../../core/fetch/color.coffee":63,"../../core/fetch/value.coffee":67,"../../network/smallestGap.coffee":167,"../../tooltip/remove.coffee":202,"../../util/uniques.coffee":209}],327:[function(e,t,r){var n,a,o,i,s;n=e("./sankey.js"),a=e("../../client/pointer.coffee"),o=e("../../tooltip/remove.coffee"),s=e("../../util/uniques.coffee"),i=function(e){var t,r,i,s,l,u,c,d,f,p,h,v,g,m,y;for(s=e.focus.value[0],v=2*e.data.stroke.width,y=e.size.value.constructor===Number?e.size.value:20,i=e.edges.connections(s,e.id.value).filter(function(t){return t[e.edges.source][e.id.value]!==s||t[e.edges.target][e.id.value]!==s}),h=[],g=[],i=i.map(function(t){var r,n;return t[e.edges.target][e.id.value]===s?(r={id:"left_"+t[e.edges.source][e.id.value],dupe:"left",data:t[e.edges.source],value:t[e.edges.strength.value]},n=t[e.edges.target]):(r=t[e.edges.source],n={id:"right_"+t[e.edges.target][e.id.value],dupe:"right",data:t[e.edges.target],value:t[e.edges.strength.value]}),g.indexOf(r.id)<0&&h.push(r),g.indexOf(n.id)<0&&h.push(n),g.push(r.id),g.push(n.id),{source:r,target:n,value:t[e.edges.strength.value]||1}}),c=n().nodeWidth(y).nodePadding(e.data.padding.value).size([e.width.viz-2*v,e.height.viz-2*v]).nodes(h).links(i).layout(2),m=[],l=0,d=h.length;d>l;l++)p=h[l],t=p.data||p,t={id:t[e.id.value]},t.d3plus={x:p.x+p.dx/2+v,y:p.y+p.dy/2+v,width:p.dx,height:p.dy,suffix:p.dupe},t.id!==s&&(t[e.edges.strength.value]=p.value),m.push(t);for(e.edges.path=c.link(),u=0,f=i.length;f>u;u++)r=i[u],r.d3plus={x:v,y:v};return e.mouse.viz={},e.mouse.viz[a.click]=function(t){var r;return t[e.id.value]!==e.focus.value[0]?(o(e.type.value),r=e.focus.value[0],e.history.states.push(function(){return e.self.focus(r).draw()}),e.self.focus(t[e.id.value]).draw()):void 0},{nodes:m,edges:i}},i.requirements=["edges","focus","nodes"],i.shapes=["square"],t.exports=i},{"../../client/pointer.coffee":38,"../../tooltip/remove.coffee":202,"../../util/uniques.coffee":209,"./sankey.js":328}],328:[function(e,t,r){t.exports=function(){function e(){p.forEach(function(e){e.sourceLinks=[],e.targetLinks=[]}),h.forEach(function(e){var t=e.source,r=e.target;"number"==typeof t&&(t=e.source=p[e.source]),"number"==typeof r&&(r=e.target=p[e.target]),t.sourceLinks.push(e),r.targetLinks.push(e)})}function t(){p.forEach(function(e){e.value=Math.max(d3.sum(e.sourceLinks,l),d3.sum(e.targetLinks,l))})}function r(){for(var e,t=p,r=0;t.length;)e=[],t.forEach(function(t){t.x=r,t.dx=c,t.sourceLinks.forEach(function(t){e.indexOf(t.target)<0&&e.push(t.target)})}),t=e,++r;n(r),a((f[0]-c)/(r-1))}function n(e){p.forEach(function(t){t.sourceLinks.length||(t.x=e-1)})}function a(e){p.forEach(function(t){t.x*=e})}function o(e){function t(){var e=d3.min(i,function(e){return(f[1]-(e.length-1)*d)/d3.sum(e,l)});i.forEach(function(t){t.forEach(function(t,r){t.y=r,t.dy=t.value*e})}),h.forEach(function(t){t.dy=t.value*e})}function r(e){function t(e){return s(e.source)*e.value}i.forEach(function(r,n){r.forEach(function(r){if(r.targetLinks.length){var n=d3.sum(r.targetLinks,t)/d3.sum(r.targetLinks,l);r.y+=(n-s(r))*e}})})}function n(e){function t(e){return s(e.target)*e.value}i.slice().reverse().forEach(function(r){r.forEach(function(r){if(r.sourceLinks.length){var n=d3.sum(r.sourceLinks,t)/d3.sum(r.sourceLinks,l);r.y+=(n-s(r))*e}})})}function a(){i.forEach(function(e){var t,r,n,a=0,i=e.length;for(e.sort(o),n=0;i>n;++n)t=e[n],r=a-t.y,r>0&&(t.y+=r),a=t.y+t.dy+d;if(r=a-d-f[1],r>0)for(a=t.y-=r,n=i-2;n>=0;--n)t=e[n],r=t.y+t.dy+d-a,r>0&&(t.y-=r),a=t.y})}function o(e,t){return e.y-t.y}var i=d3.nest().key(function(e){return e.x}).sortKeys(d3.ascending).entries(p).map(function(e){return e.values});t(),a();for(var u=1;e>0;--e)n(u*=.99),a(),r(u),a()}function i(){function e(e,t){return e.source.y-t.source.y}function t(e,t){return e.target.y-t.target.y}p.forEach(function(r){r.sourceLinks.sort(t),r.targetLinks.sort(e)}),p.forEach(function(e){var t=0,r=0;e.sourceLinks.forEach(function(e){e.sy=t,t+=e.dy}),e.targetLinks.forEach(function(e){e.ty=r,r+=e.dy})})}function s(e){return e.y+e.dy/2}function l(e){return e.value}var u={},c=24,d=8,f=[1,1],p=[],h=[];return u.nodeWidth=function(e){return arguments.length?(c=+e,u):c},u.nodePadding=function(e){return arguments.length?(d=+e,u):d},u.nodes=function(e){return arguments.length?(p=e,u):p},u.links=function(e){return arguments.length?(h=e,u):h},u.size=function(e){return arguments.length?(f=e,u):f},u.layout=function(n){return e(),t(),r(),o(n),i(),u},u.relayout=function(){return i(),u},u.link=function(){function e(e){var r=e.source.x+e.source.dx,n=e.target.x,a=d3.interpolateNumber(r,n),o=a(t),i=a(1-t),s=e.source.y+e.sy+e.dy/2,l=e.target.y+e.ty+e.dy/2;return"M"+r+","+s+"C"+o+","+s+" "+i+","+l+" "+n+","+l}var t=.5;return e.curvature=function(r){return arguments.length?(t=+r,e):t},e},u}},{}],329:[function(e,t,r){var n,a,o,i,s,l;n=e("../../core/fetch/value.coffee"),a=e("./helpers/graph/draw.coffee"),o=e("../../core/console/print.coffee"),s=e("../../array/sort.coffee"),l=e("./helpers/graph/dataTicks.coffee"),i=function(e){var t,r,o,i,u;if(a(e,{buffer:"size",mouse:!0}),r=e.x.domain.viz.concat(e.y.domain.viz),r.indexOf(void 0)>=0)return[];for(u=e.data.viz,o=0,i=u.length;i>o;o++)t=u[o],t.d3plus.x=e.x.scale.viz(n(e,t,e.x.value)),t.d3plus.x+=e.axes.margin.left,t.d3plus.y=e.y.scale.viz(n(e,t,e.y.value)),t.d3plus.y+=e.axes.margin.top,"number"!=typeof e.size.value&&e.size.value?t.d3plus.r=e.axes.scale(n(e,t,e.size.value)):t.d3plus.r=e.axes.scale(0);return l(e),s(e.data.viz,e.order.value||e.size.value||e.id.value,"desc"===e.order.sort.value?"asc":"desc",e.color.value||[],e)},i.fill=!0,i.requirements=["data","x","y"],i.scale=1.1,i.setup=function(e){return e.time.value&&!e.axes.discrete&&(e.time.value===e.x.value&&e.self.x({scale:"discrete"}),e.time.value===e.y.value)?e.self.y({scale:"discrete"}):void 0},i.shapes=["circle","square","donut"],i.tooltip="static",t.exports=i},{"../../array/sort.coffee":34,"../../core/console/print.coffee":52,"../../core/fetch/value.coffee":67,"./helpers/graph/dataTicks.coffee":312,"./helpers/graph/draw.coffee":313}],330:[function(e,t,r){var n=e("../../core/fetch/value.coffee"),a=e("../../util/uniques.coffee"),o=e("../../util/copy.coffee"),i=e("../../color/random.coffee"),s=function(e){var t=a(e.data.viz,e.id.value,n,e),r=a(e.cols.value);r.indexOf("label")<0&&e.cols.index.value&&r.unshift("label");var s=e.height.viz/(t.length+1),l=e.width.viz/r.length;e.group.selectAll("rect").data([0]).enter().append("rect").attr("class","background").attr("height",e.height.viz).attr("width",e.width.viz).style("fill",e.color.missing);var u=e.group.selectAll("line.horiz").data(e.data.viz);u.enter().append("line").attr("class","horiz"),u.attr("x1",0).attr("y1",function(e,t){return s*t+s}).attr("x2",e.width.viz).attr("y2",function(e,t){return s*t+s}).style("fill","#fff").style("stroke","#fff"),u.exit().remove();var c=e.group.selectAll("line.vert").data(r);c.enter().append("line").attr("class","vert"),c.attr("x1",function(e,t){return l*t+l}).attr("y1",0).attr("x2",function(e,t){return l*t+l}).attr("y2",e.height.viz).style("fill","#fff").style("stroke","#fff"),c.exit().remove();var d=[],f={};return r.forEach(function(t,r){var n={d3plus:{x:l*r+l/2,y:s/2,width:l,height:s,id:"d3p_header_"+t.toString().replace(/ /g,"_"),shape:"square",color:"#fff",text:e.format.value(t)}};if(t==e.id.value&&(n.d3plus.color="#fff"),"label"==t&&(n.d3plus.label=!1,n.d3plus.color="#fff",n.d3plus.stroke="#fff"),d.push(n),"number"==e.data.keys[t]){var a=d3.extent(e.data.viz,function(e){return e[t]});a[0]==a[1]&&(a=[a[0]-1,a[1]]),f[t]=d3.scale.linear().domain(a).range([e.color.missing,i(t)])}else"boolean"==e.data.keys[t]&&(f[t]=function(r){return r?i(t):e.color.missing})}),e.data.viz.forEach(function(t,n){n+=1,r.forEach(function(r,a){var i=o(t);i.d3plus.id="d3p_"+i[e.id.value].toString().replace(/ /g,"_")+"_"+r,i.d3plus.x=l*a+l/2,i.d3plus.y=s*n+s/2,i.d3plus.width=l,i.d3plus.height=s,"label"==r&&(i.d3plus.shape="square",i.d3plus.color="#fff",d.push(i)),d3.keys(t).indexOf(r)>=0&&r in t&&(f[r]&&(i.d3plus.color=f[r](i[r])),i.d3plus.text=e.format.value(i[r]),"boolean"==e.data.keys[r]?i.d3plus.label=!1:"string"==e.data.keys[r]&&(i.d3plus.color=e.color.missing,i.d3plus.stroke="#fff",i.d3plus.shape="square"),d.push(i))})}),d};s.shapes=["check","cross","diamond","square","triangle","triangle_up","triangle_down"],s.requirements=["data","cols"],t.exports=s},{"../../color/random.coffee":47,"../../core/fetch/value.coffee":67,"../../util/copy.coffee":206,"../../util/uniques.coffee":209}],331:[function(e,t,r){var n,a,o,i;n=e("../../core/data/threshold.js"),a=e("../../core/data/group.coffee"),o=e("../../object/merge.coffee"),i=function(e){var t,r,n,i,s,l,u;if(n=a(e,e.data.viz),r=d3.layout.treemap().mode(e.type.mode.value).round(!0).size([e.width.viz,e.height.viz]).children(function(e){return e.values}).padding(e.data.padding.value).sort(function(e,t){var r;return r=e.value-t.value,0===r?e.idi;i++)t=r[i],t.d3plus.d3plus=o(t.d3plus.d3plus,{x:t.x+t.dx/2,y:t.y+t.dy/2,width:t.dx,height:t.dy,share:t.value/u.value}),l.push(t.d3plus)}return l},i.filter=n,i.modes=["squarify","slice","dice","slice-dice"],i.requirements=["data","size"],i.shapes=["square"],i.threshold=function(e){return 1600/(e.width.viz*e.height.viz)},t.exports=i},{"../../core/data/group.coffee":57,"../../core/data/threshold.js":61,"../../object/merge.coffee":170}],332:[function(e,t,r){var n,a,o,i,s,l,u;n=e("../core/methods/attach.coffee"),a=e("./methods/helpers/axis.coffee"),i=e("./helpers/ui/message.js"),s=e("./helpers/drawSteps.js"),l=e("../core/console/print.coffee"),o=e("./helpers/container.coffee"),u=e("../object/validate.coffee"),t.exports=function(){var t;return t={g:{apps:{}},types:{area:e("./types/area.coffee"),bar:e("./types/bar.coffee"),bubbles:e("./types/bubbles.coffee"),box:e("./types/box.coffee"),chart:e("./types/deprecated/chart.coffee"),geo_map:e("./types/geo_map.coffee"),line:e("./types/line.coffee"),network:e("./types/network.js"),paths:e("./types/paths.coffee"),pie:e("./types/pie.coffee"),radar:e("./types/radar.coffee"),rings:e("./types/rings.js"),sankey:e("./types/sankey.coffee"),scatter:e("./types/scatter.coffee"),stacked:e("./types/area.coffee"),table:e("./types/table.js"),tree_map:e("./types/tree_map.coffee")}},t.self=function(e){return e.each(function(){var e,r,n,a,u,c,d;t.draw.frozen=!0,t.error.internal=null,"timing"in t.draw||(t.draw.timing=t.timing.transitions),t.error.value&&(t.draw.timing=0),o(t),c=t.width.value<=t.width.small,u=t.height.value<=t.height.small,t.small=c||u,t.width.viz=t.width.value,t.height.viz=t.height.value,e=!1,r=function(){d.length?a():t.dev.value&&(l.groupEnd(),l.timeEnd("total draw time"),l.log("\n"))},n=function(e,n){n=n||"function",e[n]instanceof Array?e[n].forEach(function(e){e(t,r)}):"function"==typeof e[n]&&e[n](t,r),e.wait||r()},a=function(){var a,o,s,u;u=d.shift(),s=t.g.message&&e===u.message,o="check"in u?u.check:!0,"function"==typeof o&&(o=o(t)),o?s?n(u):(t.dev.value&&(e!==!1&&l.groupEnd(),l.group(u.message)),"string"==typeof t.messages.value?(e=t.messages.value,a=t.messages.value):(e=u.message,a=t.format.value(u.message)),t.draw.update?(i(t,a),t.error.value?n(u):setTimeout(function(){return n(u)},10)):n(u)):"otherwise"in u?t.error.value?n(u,"otherwise"):setTimeout(function(){return n(u,"otherwise")},10):r()},t.messages.style.backup=t.group&&"1"===t.group.attr("opacity")?"small":"large",d=s(t),a()}),t.self},n(t,{active:e("./methods/active.coffee"),aggs:e("./methods/aggs.coffee"),attrs:e("./methods/attrs.coffee"),axes:e("./methods/axes.coffee"),background:e("./methods/background.coffee"),"class":e("./methods/class.coffee"),color:e("./methods/color.coffee"),cols:e("./methods/cols.js"),config:e("./methods/config.coffee"),container:e("./methods/container.coffee"),coords:e("./methods/coords.coffee"),csv:e("./methods/csv.coffee"),data:e("./methods/data.coffee"),depth:e("./methods/depth.coffee"),descs:e("./methods/descs.coffee"),dev:e("./methods/dev.coffee"),draw:e("./methods/draw.js"),edges:e("./methods/edges.js"),error:e("./methods/error.coffee"),focus:e("./methods/focus.coffee"),font:e("./methods/font.coffee"),footer:e("./methods/footer.coffee"),format:e("./methods/format.coffee"),height:e("./methods/height.coffee"),history:e("./methods/history.coffee"),icon:e("./methods/icon.coffee"),id:e("./methods/id.coffee"),labels:e("./methods/labels.coffee"),legend:e("./methods/legend.coffee"),links:e("./methods/links.coffee"),margin:e("./methods/margin.coffee"),messages:e("./methods/messages.coffee"),mouse:e("./methods/mouse.coffee"),nodes:e("./methods/nodes.coffee"),order:e("./methods/order.coffee"),resize:e("./methods/resize.coffee"),shape:e("./methods/shape.coffee"),size:e("./methods/size.coffee"),style:e("./methods/style.coffee"),temp:e("./methods/temp.coffee"),text:e("./methods/text.coffee"),time:e("./methods/time.coffee"),timeline:e("./methods/timeline.coffee"),timing:e("./methods/timing.coffee"),title:e("./methods/title.coffee"),tooltip:e("./methods/tooltip.coffee"),total:e("./methods/total.coffee"),type:e("./methods/type.coffee"),ui:e("./methods/ui.coffee"),width:e("./methods/width.coffee"),x:a("x"),x2:a("x2"),y:a("y"),y2:a("y2"),zoom:e("./methods/zoom.js")}),t.self}},{"../core/console/print.coffee":52,"../core/methods/attach.coffee":79,"../object/validate.coffee":171,"./helpers/container.coffee":210,"./helpers/drawSteps.js":211,"./helpers/ui/message.js":245,"./methods/active.coffee":254,"./methods/aggs.coffee":255,"./methods/attrs.coffee":256,"./methods/axes.coffee":257,"./methods/background.coffee":258,"./methods/class.coffee":259,"./methods/color.coffee":260,"./methods/cols.js":261,"./methods/config.coffee":262,"./methods/container.coffee":263,"./methods/coords.coffee":264,"./methods/csv.coffee":265,"./methods/data.coffee":266,"./methods/depth.coffee":267,"./methods/descs.coffee":268,"./methods/dev.coffee":269,"./methods/draw.js":270,"./methods/edges.js":271,"./methods/error.coffee":272,"./methods/focus.coffee":273,"./methods/font.coffee":274,"./methods/footer.coffee":275,"./methods/format.coffee":276,"./methods/height.coffee":277,"./methods/helpers/axis.coffee":278,"./methods/history.coffee":279,"./methods/icon.coffee":280,"./methods/id.coffee":281, "./methods/labels.coffee":282,"./methods/legend.coffee":283,"./methods/links.coffee":284,"./methods/margin.coffee":285,"./methods/messages.coffee":286,"./methods/mouse.coffee":287,"./methods/nodes.coffee":288,"./methods/order.coffee":289,"./methods/resize.coffee":290,"./methods/shape.coffee":291,"./methods/size.coffee":292,"./methods/style.coffee":293,"./methods/temp.coffee":294,"./methods/text.coffee":295,"./methods/time.coffee":296,"./methods/timeline.coffee":297,"./methods/timing.coffee":298,"./methods/title.coffee":299,"./methods/tooltip.coffee":300,"./methods/total.coffee":301,"./methods/type.coffee":302,"./methods/ui.coffee":303,"./methods/width.coffee":304,"./methods/zoom.js":305,"./types/area.coffee":306,"./types/bar.coffee":307,"./types/box.coffee":308,"./types/bubbles.coffee":309,"./types/deprecated/chart.coffee":310,"./types/geo_map.coffee":311,"./types/line.coffee":321,"./types/network.js":322,"./types/paths.coffee":323,"./types/pie.coffee":324,"./types/radar.coffee":325,"./types/rings.js":326,"./types/sankey.coffee":327,"./types/scatter.coffee":329,"./types/table.js":330,"./types/tree_map.coffee":331}]},{},[162]);; -function ConfigBuilder(){return{defaultColor:"#ddd",type:"none",sort:!1,percentage:!1,color:d3plus.color.scale,offset:5,padding:30,tooltip:!1,wave:{dy:11,count:4},format:{text:function(text,key){return d3plus.string.title(text)},number:function(number,data){return d3plus.number.format(number)}}}}function BubbleBuilder(options){this.dataArray=[],this.timeArray=[],this.timeSelection=[],this.event={},this.config=new ConfigBuilder,this.initialize(options)}function BubbleChart(options){this.builder=new BubbleBuilder(options)}BubbleBuilder.prototype.trigger=function(name,d){"undefined"!=typeof this.event[name]&&this.event[name](d)},BubbleBuilder.prototype.initialize=function(options){for(var attr in options)"format"==attr&&(options.format=d3plus.object.merge(this.config.format,options.format)),this.config[attr]=options[attr];this.prepareContainer()},BubbleBuilder.prototype.selectable=function(ul,li,update){function isParentNode(parentNode,node){return node?node===parentNode?!0:isParentNode(parentNode,node.parentNode):!1}function selectFirst(selection){selection.each(function(d,i){0===i&&(d._selected=!0)})}function selectLast(selection){selection.each(function(d,i,j){i===selection[j].length-1&&(d._selected=!0)})}function select(d,node){var parentNode=ul.filter(function(){return isParentNode(this,node)}).node(),lis=li.filter(function(){return isParentNode(parentNode,this)});if(d3.event.shiftKey){var firstSelectedIndex,lastSelectedIndex,currentIndex;lis.each(function(dl,i){dl._selected&&(firstSelectedIndex||(firstSelectedIndex=i),lastSelectedIndex=i),this===node&&(currentIndex=i)});var min=Math.min(firstSelectedIndex,lastSelectedIndex,currentIndex),max=Math.max(firstSelectedIndex,lastSelectedIndex,currentIndex);lis.each(function(d,i){d._selected=d3.event.ctrlKey&&d._selected||i>=min&&max>=i})}else d3.event.ctrlKey||lis.each(function(d){d._selected=!1}),d._selected=!d._selected;lastDecision=d._selected,update()}var lastDecision;ul.selectAll("li").on("mousedown",function(d){select(d,this)}).on("mouseover",function(d){d3.event.which&&(d._selected=lastDecision,update())});var keyCodes={up:38,down:40,home:36,end:35,a:65};ul.on("keydown",function(){if(-1!==d3.values(keyCodes).indexOf(d3.event.keyCode)&&(d3.event.keyCode!==keyCodes.a||d3.event.ctrlKey)){var focus=ul.filter(":focus").node();if(focus){d3.event.preventDefault();var scope=li.filter(function(d){return isParentNode(focus,this)}),selecteds=scope.select(function(d){return d._selected});d3.event.ctrlKey||scope.each(function(d){d._selected=!1});var madeSelection=!1;switch(d3.event.keyCode){case keyCodes.up:selecteds.each(function(d,i,j){scope[j][i-1]&&(madeSelection=d3.select(scope[j][i-1]).data()[0]._selected=!0)}),madeSelection||selectLast(scope);break;case keyCodes.down:selecteds.each(function(d,i,j){scope[j][i+1]&&(madeSelection=d3.select(scope[j][i+1]).data()[0]._selected=!0)}),madeSelection||selectFirst(scope);break;case keyCodes.home:selectFirst(scope);break;case keyCodes.end:selectLast(scope);break;case keyCodes.a:scope.each(function(d){d._selected=!d3.event.shiftKey})}update()}}})},BubbleBuilder.prototype.prepareContainer=function(){this.diameter=$(this.config.container).height(),this.width=$(this.config.container).width()-this.config.padding,this.diameter=this.diameter<500?500:this.diameter,this.config.scope=this.config.container.replace("#",""),this.vizId=this.config.scope+"-viz",this.footerId=this.config.scope+"-footer";var $viz=$("
");$viz.attr("id",this.vizId);var $footer=$("
");$footer.attr("id",this.footerId),$(this.config.container).append($viz),$(this.config.container).append($footer),d3.select(self.frameElement).style("height",this.diameter+"px")},BubbleBuilder.prototype.builder=function(data){var thiz=this,bubble=d3.layout.pack().size([this.width,this.diameter]).padding(1.5);this.config.sort&&bubble.sort(function(a,b){return a.value-b.value});var vizId="#"+this.vizId;$(vizId).html("");var svg=d3.select(vizId).append("svg").attr("width",this.width).attr("height",this.diameter).attr("class","bubble"),node=svg.selectAll(".node").data(bubble.nodes(this.buildNodes(data)).filter(function(d){return!d.children})).enter().append("g").attr("class","node").on("click",function(d){thiz.trigger("click",d)}).on("mouseenter",function(d){thiz.trigger("mouseenter",d)}).on("mouseover",function(d){thiz.trigger("mouseover",d),d3.select(this).attr("stroke-width","5px"),thiz.createTooltip(d)}).on("mouseout",function(d){thiz.trigger("mouseout",d),d3.select(this).attr("stroke-width","1px"),d3plus.tooltip.remove(thiz.config.scope+"_visualization_focus")}).attr("transform",function(d){return"translate("+d.x+","+d.y+")"}),gnode=node.append("g");this.circle(gnode).style("stroke",function(d){var c=thiz.config.color(d[thiz.config.label]);return d3plus.color.legible(c)});this.config.percentage?(this.circle(gnode,{offset:thiz.config.offset}).style("stroke","#FFF").style("stroke-width","2px"),this.buildGauge(node)):(this.circle(gnode),this.text(gnode))},BubbleBuilder.prototype.text=function(node,options){function isLikeWhite(c){var dc=235,rgb=d3.rgb(c);return rgb.r>=dc&&rgb.g>=dc&&rgb.b>=dc}var thiz=this;return node.append("text").attr("class","wrap").style("fill",function(d){var c=thiz.config.color(d[thiz.config.label]);return c=d3plus.color.text(c),isLikeWhite(c)?thiz.config.defaultColor:c}).text(function(d){return thiz.config.format.text(d[thiz.config.label])})},BubbleBuilder.prototype.circle=function(node,options){var thiz=this;return options="undefined"==typeof options?{}:options,options.offset="undefined"==typeof options.offset?0:options.offset,options["class"]="undefined"==typeof options["class"]?"shape":options["class"],node.append("circle").attr("r",function(d){return d.rp?0:parseInt(p)},BubbleBuilder.prototype.buildWave=function(clip){var thiz=this,path=clip.append("path").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("class","path").attr("d",function(d){var p=thiz.fillPercentage(d);if(0==p)return"";for(var x=parseInt(2*-d.r),dx=parseInt(4*d.r/thiz.config.wave.count),b="",y0=p-d.r;x<2*d.r;)b+=" M "+x+" "+y0+" q "+dx/2+" "+thiz.config.wave.dy+" "+dx+" 0",x+=dx;return b+""});"liquid"==this.config.type&&this.animateWave(path)},BubbleBuilder.prototype.buildGauge=function(node){var g=node.append("g"),thiz=this,clip=g.append("clipPath").attr("id",function(d){return"g-clip-"+d3plus.string.strip(d[thiz.config.label])});clip.append("rect").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("y",function(d){return-d.r+thiz.config.offset}).attr("x",function(d){return-d.r+thiz.config.offset}).attr("width",function(d){return 2*d.rp?0:p}),"liquid"!=this.config.type&&"wave"!=this.config.type||this.buildWave(clip),this.circle(g,{offset:thiz.config.offset,fill:"#FFF"}).attr("clip-path",function(d){var clip=window.location.href;return clip+="#g-clip-"+d3plus.string.strip(d[thiz.config.label]),"url("+clip+")"}),this.text(g)},BubbleBuilder.prototype.createTooltip=function(d){var thiz=this,data=[{value:d[thiz.config.size],name:thiz.config.size}];this.config.percentage&&data.push({value:100*this.config.percentage(d),name:"Percentage"}),data=this.config.tooltip?this.config.tooltip(d):data;for(var i=0;ix?0:x,y=0>x?0:y;var config={id:thiz.config.scope+"_visualization_focus",x:x,y:y-20,allColors:!0,fixed:!0,size:"small",color:thiz.config.color(d[thiz.config.label]),fontfamily:"Helvetica Neue",fontweight:200,fontsize:"15px",data:data,width:maxWidth,max_width:maxWidth,mouseevents:!1,arrow:!0,align:"bottom center",anchor:"top left",title:thiz.config.format.text(d[thiz.config.label])};d3plus.tooltip.create(config)},BubbleBuilder.prototype.buildNodes=function(data){for(var thiz=this,d=this.groupingData(data),i=0;i=0}),filters=d3.nest().key(function(d){return sampleObj=d,d[thiz.config.label]}).rollup(function(v){return thiz.roolup(v,sampleObj)}).entries(tmp);return filters.map(function(d){return d.values})},BubbleBuilder.prototype.onChange=function(){var data=$.extend([],this.dataArray,!0);this.builder(data),this.wrapText()},BubbleBuilder.prototype.timeline=function(){var ul=d3.select("#"+this.footerId).append("ul").attr("class","timeline").attr("tabindex",1),thiz=this,time=this.timeArray.sort().map(function(d){var data={time:d,_selected:!0};return data}),li=ul.selectAll("li").data(time).enter().append("li").attr("class","entry").classed("selected",function(d){return d._selected}).append("a").text(function(d){return d.time});this.selectable(ul,li,function(e){var selections=[];ul.selectAll("li").classed("selected",function(d){return d._selected&&selections.push(d),d._selected}),thiz.timeSelection=selections.map(function(d){return d.time}),thiz.onChange(),thiz.trigger("timechange",thiz.timeSelection)})},BubbleChart.prototype.data=function(data){this.builder.data(data)},BubbleChart.prototype.on=function(event,handler){this.builder.event[event]=handler}; \ No newline at end of file +function ConfigBuilder(){return{defaultColor:"#ddd",type:"none",sort:!1,percentage:!1,color:d3plus.color.scale,offset:5,padding:30,tooltip:!1,toggle:{title:"",size:!1},wave:{dy:11,count:4},format:{text:function(text,key){return d3plus.string.title(text)},number:function(number,data){return d3plus.number.format(number)}}}}function BubbleBuilder(options){this.dataArray=[],this.timeArray=[],this.timeSelection=[],this.event={},this.config=new ConfigBuilder,this.initialize(options)}function BubbleChart(options){this.builder=new BubbleBuilder(options)}BubbleBuilder.prototype.trigger=function(name,d){"undefined"!=typeof this.event[name]&&this.event[name](d)},BubbleBuilder.prototype.initialize=function(options){for(var attr in options)"format"==attr&&(options.format=d3plus.object.merge(this.config.format,options.format)),this.config[attr]=options[attr];this.prepareContainer()},BubbleBuilder.prototype.selectable=function(ul,li,update){function isParentNode(parentNode,node){return node?node===parentNode?!0:isParentNode(parentNode,node.parentNode):!1}function selectFirst(selection){selection.each(function(d,i){0===i&&(d._selected=!0)})}function selectLast(selection){selection.each(function(d,i,j){i===selection[j].length-1&&(d._selected=!0)})}function select(d,node){var parentNode=ul.filter(function(){return isParentNode(this,node)}).node(),lis=li.filter(function(){return isParentNode(parentNode,this)});if(d3.event.shiftKey){var firstSelectedIndex,lastSelectedIndex,currentIndex;lis.each(function(dl,i){dl._selected&&(firstSelectedIndex||(firstSelectedIndex=i),lastSelectedIndex=i),this===node&&(currentIndex=i)});var min=Math.min(firstSelectedIndex,lastSelectedIndex,currentIndex),max=Math.max(firstSelectedIndex,lastSelectedIndex,currentIndex);lis.each(function(d,i){d._selected=d3.event.ctrlKey&&d._selected||i>=min&&max>=i})}else d3.event.ctrlKey||lis.each(function(d){d._selected=!1}),d._selected=!d._selected;lastDecision=d._selected,update()}var lastDecision;ul.selectAll("li").on("mousedown",function(d){select(d,this)}).on("mouseover",function(d){d3.event.which&&(d._selected=lastDecision,update())});var keyCodes={up:38,down:40,home:36,end:35,a:65};ul.on("keydown",function(){if(-1!==d3.values(keyCodes).indexOf(d3.event.keyCode)&&(d3.event.keyCode!==keyCodes.a||d3.event.ctrlKey)){var focus=ul.filter(":focus").node();if(focus){d3.event.preventDefault();var scope=li.filter(function(d){return isParentNode(focus,this)}),selecteds=scope.select(function(d){return d._selected});d3.event.ctrlKey||scope.each(function(d){d._selected=!1});var madeSelection=!1;switch(d3.event.keyCode){case keyCodes.up:selecteds.each(function(d,i,j){scope[j][i-1]&&(madeSelection=d3.select(scope[j][i-1]).data()[0]._selected=!0)}),madeSelection||selectLast(scope);break;case keyCodes.down:selecteds.each(function(d,i,j){scope[j][i+1]&&(madeSelection=d3.select(scope[j][i+1]).data()[0]._selected=!0)}),madeSelection||selectFirst(scope);break;case keyCodes.home:selectFirst(scope);break;case keyCodes.end:selectLast(scope);break;case keyCodes.a:scope.each(function(d){d._selected=!d3.event.shiftKey})}update()}}})},BubbleBuilder.prototype.prepareContainer=function(){this.diameter=$(this.config.container).height(),this.width=$(this.config.container).width()-this.config.padding,this.diameter=this.diameter<500?500:this.diameter,this.config.scope=this.config.container.replace("#",""),this.vizId=this.config.scope+"-viz",this.footerId=this.config.scope+"-footer";var $viz=$("
");$viz.attr("id",this.vizId);var $footer=$("
");$footer.attr("id",this.footerId),$(this.config.container).append($viz),$(this.config.container).append($footer),d3.select(self.frameElement).style("height",this.diameter+"px")},BubbleBuilder.prototype.builder=function(data){var thiz=this,bubble=d3.layout.pack().size([this.width,this.diameter]).padding(1.5);this.config.sort&&bubble.sort(function(a,b){return a.value-b.value});var vizId="#"+this.vizId;$(vizId).html("");var svg=d3.select(vizId).append("svg").attr("width",this.width).attr("height",this.diameter).attr("class","bubble"),node=svg.selectAll(".node").data(bubble.nodes(this.buildNodes(data)).filter(function(d){return!d.children})).enter().append("g").attr("class","node").on("click",function(d){thiz.trigger("click",d)}).on("mouseenter",function(d){thiz.trigger("mouseenter",d)}).on("mouseover",function(d){thiz.trigger("mouseover",d),d3.select(this).attr("stroke-width","5px"),thiz.createTooltip(d)}).on("mouseout",function(d){thiz.trigger("mouseout",d),d3.select(this).attr("stroke-width","1px"),d3plus.tooltip.remove(thiz.config.scope+"_visualization_focus")}).attr("transform",function(d){return"translate("+d.x+","+d.y+")"}),gnode=node.append("g");this.circle(gnode).style("stroke",function(d){var c=thiz.config.color(d[thiz.config.label]);return d3plus.color.legible(c)});this.config.percentage?(this.circle(gnode,{offset:thiz.config.offset}).style("stroke","#FFF").style("stroke-width","2px"),this.buildGauge(node)):(this.circle(gnode),this.text(gnode))},BubbleBuilder.prototype.text=function(node,options){function isLikeWhite(c){var dc=235,rgb=d3.rgb(c);return rgb.r>=dc&&rgb.g>=dc&&rgb.b>=dc}var thiz=this;return node.append("text").attr("class","wrap").style("fill",function(d){var c=thiz.config.color(d[thiz.config.label]);return c=d3plus.color.text(c),isLikeWhite(c)?thiz.config.defaultColor:c}).text(function(d){return thiz.config.format.text(d[thiz.config.label])})},BubbleBuilder.prototype.circle=function(node,options){var thiz=this;return options="undefined"==typeof options?{}:options,options.offset="undefined"==typeof options.offset?0:options.offset,options["class"]="undefined"==typeof options["class"]?"shape":options["class"],node.append("circle").attr("r",function(d){return d.rp?0:parseInt(p)},BubbleBuilder.prototype.buildWave=function(clip){var thiz=this,path=clip.append("path").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("class","path").attr("d",function(d){var p=thiz.fillPercentage(d);if(0==p)return"";for(var x=parseInt(2*-d.r),dx=parseInt(4*d.r/thiz.config.wave.count),b="",y0=p-d.r;x<2*d.r;)b+=" M "+x+" "+y0+" q "+dx/2+" "+thiz.config.wave.dy+" "+dx+" 0",x+=dx;return b+""});"liquid"==this.config.type&&this.animateWave(path)},BubbleBuilder.prototype.buildGauge=function(node){var g=node.append("g"),thiz=this,clip=g.append("clipPath").attr("id",function(d){return"g-clip-"+d3plus.string.strip(d[thiz.config.label])});clip.append("rect").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("y",function(d){return-d.r+thiz.config.offset}).attr("x",function(d){return-d.r+thiz.config.offset}).attr("width",function(d){return 2*d.rp?0:p}),"liquid"!=this.config.type&&"wave"!=this.config.type||this.buildWave(clip),this.circle(g,{offset:thiz.config.offset,fill:"#FFF"}).attr("clip-path",function(d){var clip=window.location.href;return clip+="#g-clip-"+d3plus.string.strip(d[thiz.config.label]),"url("+clip+")"}),this.text(g)},BubbleBuilder.prototype.createTooltip=function(d){var thiz=this,data=[{value:d[thiz.config.size],name:thiz.config.size}];this.config.percentage&&data.push({value:100*this.config.percentage(d),name:"Percentage"}),data=this.config.tooltip?this.config.tooltip(d):data;for(var i=0;ix?0:x,y=0>x?0:y;var config={id:thiz.config.scope+"_visualization_focus",x:x,y:y-20,allColors:!0,fixed:!0,size:"small",color:thiz.config.color(d[thiz.config.label]),fontfamily:"Helvetica Neue",fontweight:200,fontsize:"15px",data:data,width:maxWidth,max_width:maxWidth,mouseevents:!1,arrow:!0,align:"bottom center",anchor:"top left",title:thiz.config.format.text(d[thiz.config.label])};d3plus.tooltip.create(config)},BubbleBuilder.prototype.buildNodes=function(data){for(var thiz=this,d=this.groupingData(data),i=0;i=0}),filters=d3.nest().key(function(d){return sampleObj=d,d[thiz.config.label]}).rollup(function(v){return thiz.roolup(v,sampleObj)}).entries(tmp);return filters.map(function(d){return d.values})},BubbleBuilder.prototype.onChange=function(){var data=$.extend([],this.dataArray,!0);this.builder(data),this.wrapText()},BubbleBuilder.prototype.timeline=function(){var ul=d3.select("#"+this.footerId).append("ul").attr("class","timeline").attr("tabindex",1),thiz=this,time=this.timeArray.sort().map(function(d){var data={time:d,_selected:!0};return data}),li=ul.selectAll("li").data(time).enter().append("li").attr("class","entry").classed("selected",function(d){return d._selected}).append("a").text(function(d){return d.time});this.selectable(ul,li,function(e){var selections=[];ul.selectAll("li").classed("selected",function(d){return d._selected&&selections.push(d),d._selected}),thiz.timeSelection=selections.map(function(d){return d.time}),thiz.onChange(),thiz.trigger("timechange",thiz.timeSelection)})},BubbleBuilder.prototype.sizeToggle=function(){var $footer=$("#"+this.footerId),$toogle=$("
");$toogle.addClass("bubble-toogle"),$toogle.attr("id",this.footerId+"-toogle"),$footer.append($toogle);var thiz=this;d3plus.form().data(this.config.toggle.size).title(this.config.toggle.title).container("#"+this.footerId+"-toogle").id("value").text("text").type("toggle").draw();$footer.find(".d3plus_toggle").on("click",function(d){var $target=$(this)[0],data=$target.__data__;"undefined"!=typeof data&&(thiz.config.size=data.value,thiz.onChange())})},BubbleChart.prototype.data=function(data){this.builder.data(data)},BubbleChart.prototype.on=function(event,handler){this.builder.event[event]=handler}; \ No newline at end of file diff --git a/dist/js/bubbles-chart.js b/dist/js/bubbles-chart.js index 1c54a9b..0b38f72 100644 --- a/dist/js/bubbles-chart.js +++ b/dist/js/bubbles-chart.js @@ -1,8 +1,8 @@ /*! * bubbles-chart : Bubble chart - * @version v0.0.0 + * @version v0.0.1 * @author Maximiliano Báez González * @date 2016-06-10 */ -function ConfigBuilder(){return{defaultColor:"#ddd",type:"none",sort:!1,percentage:!1,color:d3plus.color.scale,offset:5,padding:30,tooltip:!1,wave:{dy:11,count:4},format:{text:function(text,key){return d3plus.string.title(text)},number:function(number,data){return d3plus.number.format(number)}}}}function BubbleBuilder(options){this.dataArray=[],this.timeArray=[],this.timeSelection=[],this.event={},this.config=new ConfigBuilder,this.initialize(options)}function BubbleChart(options){this.builder=new BubbleBuilder(options)}BubbleBuilder.prototype.trigger=function(name,d){"undefined"!=typeof this.event[name]&&this.event[name](d)},BubbleBuilder.prototype.initialize=function(options){for(var attr in options)"format"==attr&&(options.format=d3plus.object.merge(this.config.format,options.format)),this.config[attr]=options[attr];this.prepareContainer()},BubbleBuilder.prototype.selectable=function(ul,li,update){function isParentNode(parentNode,node){return node?node===parentNode?!0:isParentNode(parentNode,node.parentNode):!1}function selectFirst(selection){selection.each(function(d,i){0===i&&(d._selected=!0)})}function selectLast(selection){selection.each(function(d,i,j){i===selection[j].length-1&&(d._selected=!0)})}function select(d,node){var parentNode=ul.filter(function(){return isParentNode(this,node)}).node(),lis=li.filter(function(){return isParentNode(parentNode,this)});if(d3.event.shiftKey){var firstSelectedIndex,lastSelectedIndex,currentIndex;lis.each(function(dl,i){dl._selected&&(firstSelectedIndex||(firstSelectedIndex=i),lastSelectedIndex=i),this===node&&(currentIndex=i)});var min=Math.min(firstSelectedIndex,lastSelectedIndex,currentIndex),max=Math.max(firstSelectedIndex,lastSelectedIndex,currentIndex);lis.each(function(d,i){d._selected=d3.event.ctrlKey&&d._selected||i>=min&&max>=i})}else d3.event.ctrlKey||lis.each(function(d){d._selected=!1}),d._selected=!d._selected;lastDecision=d._selected,update()}var lastDecision;ul.selectAll("li").on("mousedown",function(d){select(d,this)}).on("mouseover",function(d){d3.event.which&&(d._selected=lastDecision,update())});var keyCodes={up:38,down:40,home:36,end:35,a:65};ul.on("keydown",function(){if(-1!==d3.values(keyCodes).indexOf(d3.event.keyCode)&&(d3.event.keyCode!==keyCodes.a||d3.event.ctrlKey)){var focus=ul.filter(":focus").node();if(focus){d3.event.preventDefault();var scope=li.filter(function(d){return isParentNode(focus,this)}),selecteds=scope.select(function(d){return d._selected});d3.event.ctrlKey||scope.each(function(d){d._selected=!1});var madeSelection=!1;switch(d3.event.keyCode){case keyCodes.up:selecteds.each(function(d,i,j){scope[j][i-1]&&(madeSelection=d3.select(scope[j][i-1]).data()[0]._selected=!0)}),madeSelection||selectLast(scope);break;case keyCodes.down:selecteds.each(function(d,i,j){scope[j][i+1]&&(madeSelection=d3.select(scope[j][i+1]).data()[0]._selected=!0)}),madeSelection||selectFirst(scope);break;case keyCodes.home:selectFirst(scope);break;case keyCodes.end:selectLast(scope);break;case keyCodes.a:scope.each(function(d){d._selected=!d3.event.shiftKey})}update()}}})},BubbleBuilder.prototype.prepareContainer=function(){this.diameter=$(this.config.container).height(),this.width=$(this.config.container).width()-this.config.padding,this.diameter=this.diameter<500?500:this.diameter,this.config.scope=this.config.container.replace("#",""),this.vizId=this.config.scope+"-viz",this.footerId=this.config.scope+"-footer";var $viz=$("
");$viz.attr("id",this.vizId);var $footer=$("
");$footer.attr("id",this.footerId),$(this.config.container).append($viz),$(this.config.container).append($footer),d3.select(self.frameElement).style("height",this.diameter+"px")},BubbleBuilder.prototype.builder=function(data){var thiz=this,bubble=d3.layout.pack().size([this.width,this.diameter]).padding(1.5);this.config.sort&&bubble.sort(function(a,b){return a.value-b.value});var vizId="#"+this.vizId;$(vizId).html("");var svg=d3.select(vizId).append("svg").attr("width",this.width).attr("height",this.diameter).attr("class","bubble"),node=svg.selectAll(".node").data(bubble.nodes(this.buildNodes(data)).filter(function(d){return!d.children})).enter().append("g").attr("class","node").on("click",function(d){thiz.trigger("click",d)}).on("mouseenter",function(d){thiz.trigger("mouseenter",d)}).on("mouseover",function(d){thiz.trigger("mouseover",d),d3.select(this).attr("stroke-width","5px"),thiz.createTooltip(d)}).on("mouseout",function(d){thiz.trigger("mouseout",d),d3.select(this).attr("stroke-width","1px"),d3plus.tooltip.remove(thiz.config.scope+"_visualization_focus")}).attr("transform",function(d){return"translate("+d.x+","+d.y+")"}),gnode=node.append("g");this.circle(gnode).style("stroke",function(d){var c=thiz.config.color(d[thiz.config.label]);return d3plus.color.legible(c)});this.config.percentage?(this.circle(gnode,{offset:thiz.config.offset}).style("stroke","#FFF").style("stroke-width","2px"),this.buildGauge(node)):(this.circle(gnode),this.text(gnode))},BubbleBuilder.prototype.text=function(node,options){function isLikeWhite(c){var dc=235,rgb=d3.rgb(c);return rgb.r>=dc&&rgb.g>=dc&&rgb.b>=dc}var thiz=this;return node.append("text").attr("class","wrap").style("fill",function(d){var c=thiz.config.color(d[thiz.config.label]);return c=d3plus.color.text(c),isLikeWhite(c)?thiz.config.defaultColor:c}).text(function(d){return thiz.config.format.text(d[thiz.config.label])})},BubbleBuilder.prototype.circle=function(node,options){var thiz=this;return options="undefined"==typeof options?{}:options,options.offset="undefined"==typeof options.offset?0:options.offset,options["class"]="undefined"==typeof options["class"]?"shape":options["class"],node.append("circle").attr("r",function(d){return d.rp?0:parseInt(p)},BubbleBuilder.prototype.buildWave=function(clip){var thiz=this,path=clip.append("path").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("class","path").attr("d",function(d){var p=thiz.fillPercentage(d);if(0==p)return"";for(var x=parseInt(2*-d.r),dx=parseInt(4*d.r/thiz.config.wave.count),b="",y0=p-d.r;x<2*d.r;)b+=" M "+x+" "+y0+" q "+dx/2+" "+thiz.config.wave.dy+" "+dx+" 0",x+=dx;return b+""});"liquid"==this.config.type&&this.animateWave(path)},BubbleBuilder.prototype.buildGauge=function(node){var g=node.append("g"),thiz=this,clip=g.append("clipPath").attr("id",function(d){return"g-clip-"+d3plus.string.strip(d[thiz.config.label])});clip.append("rect").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("y",function(d){return-d.r+thiz.config.offset}).attr("x",function(d){return-d.r+thiz.config.offset}).attr("width",function(d){return 2*d.rp?0:p}),"liquid"!=this.config.type&&"wave"!=this.config.type||this.buildWave(clip),this.circle(g,{offset:thiz.config.offset,fill:"#FFF"}).attr("clip-path",function(d){var clip=window.location.href;return clip+="#g-clip-"+d3plus.string.strip(d[thiz.config.label]),"url("+clip+")"}),this.text(g)},BubbleBuilder.prototype.createTooltip=function(d){var thiz=this,data=[{value:d[thiz.config.size],name:thiz.config.size}];this.config.percentage&&data.push({value:100*this.config.percentage(d),name:"Percentage"}),data=this.config.tooltip?this.config.tooltip(d):data;for(var i=0;ix?0:x,y=0>x?0:y;var config={id:thiz.config.scope+"_visualization_focus",x:x,y:y-20,allColors:!0,fixed:!0,size:"small",color:thiz.config.color(d[thiz.config.label]),fontfamily:"Helvetica Neue",fontweight:200,fontsize:"15px",data:data,width:maxWidth,max_width:maxWidth,mouseevents:!1,arrow:!0,align:"bottom center",anchor:"top left",title:thiz.config.format.text(d[thiz.config.label])};d3plus.tooltip.create(config)},BubbleBuilder.prototype.buildNodes=function(data){for(var thiz=this,d=this.groupingData(data),i=0;i=0}),filters=d3.nest().key(function(d){return sampleObj=d,d[thiz.config.label]}).rollup(function(v){return thiz.roolup(v,sampleObj)}).entries(tmp);return filters.map(function(d){return d.values})},BubbleBuilder.prototype.onChange=function(){var data=$.extend([],this.dataArray,!0);this.builder(data),this.wrapText()},BubbleBuilder.prototype.timeline=function(){var ul=d3.select("#"+this.footerId).append("ul").attr("class","timeline").attr("tabindex",1),thiz=this,time=this.timeArray.sort().map(function(d){var data={time:d,_selected:!0};return data}),li=ul.selectAll("li").data(time).enter().append("li").attr("class","entry").classed("selected",function(d){return d._selected}).append("a").text(function(d){return d.time});this.selectable(ul,li,function(e){var selections=[];ul.selectAll("li").classed("selected",function(d){return d._selected&&selections.push(d),d._selected}),thiz.timeSelection=selections.map(function(d){return d.time}),thiz.onChange(),thiz.trigger("timechange",thiz.timeSelection)})},BubbleChart.prototype.data=function(data){this.builder.data(data)},BubbleChart.prototype.on=function(event,handler){this.builder.event[event]=handler}; \ No newline at end of file +function ConfigBuilder(){return{defaultColor:"#ddd",type:"none",sort:!1,percentage:!1,color:d3plus.color.scale,offset:5,padding:30,tooltip:!1,toggle:{title:"",size:!1},wave:{dy:11,count:4},format:{text:function(text,key){return d3plus.string.title(text)},number:function(number,data){return d3plus.number.format(number)}}}}function BubbleBuilder(options){this.dataArray=[],this.timeArray=[],this.timeSelection=[],this.event={},this.config=new ConfigBuilder,this.initialize(options)}function BubbleChart(options){this.builder=new BubbleBuilder(options)}BubbleBuilder.prototype.trigger=function(name,d){"undefined"!=typeof this.event[name]&&this.event[name](d)},BubbleBuilder.prototype.initialize=function(options){for(var attr in options)"format"==attr&&(options.format=d3plus.object.merge(this.config.format,options.format)),this.config[attr]=options[attr];this.prepareContainer()},BubbleBuilder.prototype.selectable=function(ul,li,update){function isParentNode(parentNode,node){return node?node===parentNode?!0:isParentNode(parentNode,node.parentNode):!1}function selectFirst(selection){selection.each(function(d,i){0===i&&(d._selected=!0)})}function selectLast(selection){selection.each(function(d,i,j){i===selection[j].length-1&&(d._selected=!0)})}function select(d,node){var parentNode=ul.filter(function(){return isParentNode(this,node)}).node(),lis=li.filter(function(){return isParentNode(parentNode,this)});if(d3.event.shiftKey){var firstSelectedIndex,lastSelectedIndex,currentIndex;lis.each(function(dl,i){dl._selected&&(firstSelectedIndex||(firstSelectedIndex=i),lastSelectedIndex=i),this===node&&(currentIndex=i)});var min=Math.min(firstSelectedIndex,lastSelectedIndex,currentIndex),max=Math.max(firstSelectedIndex,lastSelectedIndex,currentIndex);lis.each(function(d,i){d._selected=d3.event.ctrlKey&&d._selected||i>=min&&max>=i})}else d3.event.ctrlKey||lis.each(function(d){d._selected=!1}),d._selected=!d._selected;lastDecision=d._selected,update()}var lastDecision;ul.selectAll("li").on("mousedown",function(d){select(d,this)}).on("mouseover",function(d){d3.event.which&&(d._selected=lastDecision,update())});var keyCodes={up:38,down:40,home:36,end:35,a:65};ul.on("keydown",function(){if(-1!==d3.values(keyCodes).indexOf(d3.event.keyCode)&&(d3.event.keyCode!==keyCodes.a||d3.event.ctrlKey)){var focus=ul.filter(":focus").node();if(focus){d3.event.preventDefault();var scope=li.filter(function(d){return isParentNode(focus,this)}),selecteds=scope.select(function(d){return d._selected});d3.event.ctrlKey||scope.each(function(d){d._selected=!1});var madeSelection=!1;switch(d3.event.keyCode){case keyCodes.up:selecteds.each(function(d,i,j){scope[j][i-1]&&(madeSelection=d3.select(scope[j][i-1]).data()[0]._selected=!0)}),madeSelection||selectLast(scope);break;case keyCodes.down:selecteds.each(function(d,i,j){scope[j][i+1]&&(madeSelection=d3.select(scope[j][i+1]).data()[0]._selected=!0)}),madeSelection||selectFirst(scope);break;case keyCodes.home:selectFirst(scope);break;case keyCodes.end:selectLast(scope);break;case keyCodes.a:scope.each(function(d){d._selected=!d3.event.shiftKey})}update()}}})},BubbleBuilder.prototype.prepareContainer=function(){this.diameter=$(this.config.container).height(),this.width=$(this.config.container).width()-this.config.padding,this.diameter=this.diameter<500?500:this.diameter,this.config.scope=this.config.container.replace("#",""),this.vizId=this.config.scope+"-viz",this.footerId=this.config.scope+"-footer";var $viz=$("
");$viz.attr("id",this.vizId);var $footer=$("
");$footer.attr("id",this.footerId),$(this.config.container).append($viz),$(this.config.container).append($footer),d3.select(self.frameElement).style("height",this.diameter+"px")},BubbleBuilder.prototype.builder=function(data){var thiz=this,bubble=d3.layout.pack().size([this.width,this.diameter]).padding(1.5);this.config.sort&&bubble.sort(function(a,b){return a.value-b.value});var vizId="#"+this.vizId;$(vizId).html("");var svg=d3.select(vizId).append("svg").attr("width",this.width).attr("height",this.diameter).attr("class","bubble"),node=svg.selectAll(".node").data(bubble.nodes(this.buildNodes(data)).filter(function(d){return!d.children})).enter().append("g").attr("class","node").on("click",function(d){thiz.trigger("click",d)}).on("mouseenter",function(d){thiz.trigger("mouseenter",d)}).on("mouseover",function(d){thiz.trigger("mouseover",d),d3.select(this).attr("stroke-width","5px"),thiz.createTooltip(d)}).on("mouseout",function(d){thiz.trigger("mouseout",d),d3.select(this).attr("stroke-width","1px"),d3plus.tooltip.remove(thiz.config.scope+"_visualization_focus")}).attr("transform",function(d){return"translate("+d.x+","+d.y+")"}),gnode=node.append("g");this.circle(gnode).style("stroke",function(d){var c=thiz.config.color(d[thiz.config.label]);return d3plus.color.legible(c)});this.config.percentage?(this.circle(gnode,{offset:thiz.config.offset}).style("stroke","#FFF").style("stroke-width","2px"),this.buildGauge(node)):(this.circle(gnode),this.text(gnode))},BubbleBuilder.prototype.text=function(node,options){function isLikeWhite(c){var dc=235,rgb=d3.rgb(c);return rgb.r>=dc&&rgb.g>=dc&&rgb.b>=dc}var thiz=this;return node.append("text").attr("class","wrap").style("fill",function(d){var c=thiz.config.color(d[thiz.config.label]);return c=d3plus.color.text(c),isLikeWhite(c)?thiz.config.defaultColor:c}).text(function(d){return thiz.config.format.text(d[thiz.config.label])})},BubbleBuilder.prototype.circle=function(node,options){var thiz=this;return options="undefined"==typeof options?{}:options,options.offset="undefined"==typeof options.offset?0:options.offset,options["class"]="undefined"==typeof options["class"]?"shape":options["class"],node.append("circle").attr("r",function(d){return d.rp?0:parseInt(p)},BubbleBuilder.prototype.buildWave=function(clip){var thiz=this,path=clip.append("path").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("class","path").attr("d",function(d){var p=thiz.fillPercentage(d);if(0==p)return"";for(var x=parseInt(2*-d.r),dx=parseInt(4*d.r/thiz.config.wave.count),b="",y0=p-d.r;x<2*d.r;)b+=" M "+x+" "+y0+" q "+dx/2+" "+thiz.config.wave.dy+" "+dx+" 0",x+=dx;return b+""});"liquid"==this.config.type&&this.animateWave(path)},BubbleBuilder.prototype.buildGauge=function(node){var g=node.append("g"),thiz=this,clip=g.append("clipPath").attr("id",function(d){return"g-clip-"+d3plus.string.strip(d[thiz.config.label])});clip.append("rect").attr("id",function(d){return"g-clip-rect"+d3plus.string.strip(d[thiz.config.label])}).attr("y",function(d){return-d.r+thiz.config.offset}).attr("x",function(d){return-d.r+thiz.config.offset}).attr("width",function(d){return 2*d.rp?0:p}),"liquid"!=this.config.type&&"wave"!=this.config.type||this.buildWave(clip),this.circle(g,{offset:thiz.config.offset,fill:"#FFF"}).attr("clip-path",function(d){var clip=window.location.href;return clip+="#g-clip-"+d3plus.string.strip(d[thiz.config.label]),"url("+clip+")"}),this.text(g)},BubbleBuilder.prototype.createTooltip=function(d){var thiz=this,data=[{value:d[thiz.config.size],name:thiz.config.size}];this.config.percentage&&data.push({value:100*this.config.percentage(d),name:"Percentage"}),data=this.config.tooltip?this.config.tooltip(d):data;for(var i=0;ix?0:x,y=0>x?0:y;var config={id:thiz.config.scope+"_visualization_focus",x:x,y:y-20,allColors:!0,fixed:!0,size:"small",color:thiz.config.color(d[thiz.config.label]),fontfamily:"Helvetica Neue",fontweight:200,fontsize:"15px",data:data,width:maxWidth,max_width:maxWidth,mouseevents:!1,arrow:!0,align:"bottom center",anchor:"top left",title:thiz.config.format.text(d[thiz.config.label])};d3plus.tooltip.create(config)},BubbleBuilder.prototype.buildNodes=function(data){for(var thiz=this,d=this.groupingData(data),i=0;i=0}),filters=d3.nest().key(function(d){return sampleObj=d,d[thiz.config.label]}).rollup(function(v){return thiz.roolup(v,sampleObj)}).entries(tmp);return filters.map(function(d){return d.values})},BubbleBuilder.prototype.onChange=function(){var data=$.extend([],this.dataArray,!0);this.builder(data),this.wrapText()},BubbleBuilder.prototype.timeline=function(){var ul=d3.select("#"+this.footerId).append("ul").attr("class","timeline").attr("tabindex",1),thiz=this,time=this.timeArray.sort().map(function(d){var data={time:d,_selected:!0};return data}),li=ul.selectAll("li").data(time).enter().append("li").attr("class","entry").classed("selected",function(d){return d._selected}).append("a").text(function(d){return d.time});this.selectable(ul,li,function(e){var selections=[];ul.selectAll("li").classed("selected",function(d){return d._selected&&selections.push(d),d._selected}),thiz.timeSelection=selections.map(function(d){return d.time}),thiz.onChange(),thiz.trigger("timechange",thiz.timeSelection)})},BubbleBuilder.prototype.sizeToggle=function(){var $footer=$("#"+this.footerId),$toogle=$("
");$toogle.addClass("bubble-toogle"),$toogle.attr("id",this.footerId+"-toogle"),$footer.append($toogle);var thiz=this;d3plus.form().data(this.config.toggle.size).title(this.config.toggle.title).container("#"+this.footerId+"-toogle").id("value").text("text").type("toggle").draw();$footer.find(".d3plus_toggle").on("click",function(d){var $target=$(this)[0],data=$target.__data__;"undefined"!=typeof data&&(thiz.config.size=data.value,thiz.onChange())})},BubbleChart.prototype.data=function(data){this.builder.data(data)},BubbleChart.prototype.on=function(event,handler){this.builder.event[event]=handler}; \ No newline at end of file diff --git a/src/js/bubbles-chart.js b/src/js/bubbles-chart.js index 71bae57..270daea 100644 --- a/src/js/bubbles-chart.js +++ b/src/js/bubbles-chart.js @@ -27,6 +27,10 @@ function ConfigBuilder() { offset: 5, padding: 30, tooltip: false, + toggle: { + title: "", + size: false + }, wave: { dy: 11, count: 4 @@ -374,9 +378,14 @@ BubbleBuilder.prototype.circle = function (node, options) { BubbleBuilder.prototype.data = function (data) { this.dataArray = $.extend([], data, true); this.builder(data) - if (typeof this.config.time != "undefined") { + if (this.config.time) { this.timeline(); } + if (this.config.toggle.size) { + this.sizeToggle(); + } + + this.wrapText(); } @@ -700,6 +709,33 @@ BubbleBuilder.prototype.timeline = function () { }); } + +BubbleBuilder.prototype.sizeToggle = function () { + var $footer = $("#" + this.footerId); + var $toogle = $("
"); + $toogle.addClass("bubble-toogle"); + $toogle.attr("id", this.footerId + "-toogle"); + $footer.append($toogle); + var thiz = this; + var toggle = d3plus.form() + .data(this.config.toggle.size) + .title(this.config.toggle.title) + .container("#" + this.footerId + "-toogle") + .id("value") + .text("text") + .type("toggle") + .draw(); + + $footer.find(".d3plus_toggle").on("click", function (d) { + var $target = $(this)[0]; + var data = $target["__data__"]; + if (typeof data != "undefined") { + thiz.config.size = data.value; + thiz.onChange(); + } + }); +} + /** * Bubble chart visualization builder * @param{Config} options diff --git a/src/scss/_bubbles-chart.scss b/src/scss/_bubbles-chart.scss index 08d4aa7..c92ec4b 100644 --- a/src/scss/_bubbles-chart.scss +++ b/src/scss/_bubbles-chart.scss @@ -10,6 +10,7 @@ g { } /*Timeline*/ + $time_active: #c3c3c3; $time_border: #c3c3c3; $text_color: #444444; @@ -50,3 +51,7 @@ $time_hover:#f1f1f1; } } } +.bubble-toogle { + display: block; + text-align: center; +}