From a96ed11368ab307855e50e17fe0bf3488461b888 Mon Sep 17 00:00:00 2001 From: Dean Malmgren Date: Tue, 22 Oct 2013 17:19:40 -0500 Subject: [PATCH] bump to 0.3.1 --- catcorr.min.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/catcorr.min.js b/catcorr.min.js index a7ca462..eb1d04b 100644 --- a/catcorr.min.js +++ b/catcorr.min.js @@ -1 +1 @@ -!function(t){function e(t,e){function r(t){d3.select(this).call(t)}function a(){g.each(r),d3.select("aside.catcorr #active").text(s(d.value()))}function n(t){function e(e){function a(t){for(var e,a=[],n=-1,l=t.length;++ne){var n=a.substring(0,e-3).split(" ");a=n.slice(0,n.length-1).join(" "),a+="..."}return a});u&&(u.html(function(t){return r.labels[t]}),o.on("mouseover",u.show).on("mouseout",u.hide));var i=n.append("g").attr("class","catcorr brush").call(f);i.selectAll("rect").attr("fill","url(#diagonalHatch)").attr("height",b),i.selectAll(".resize").append("path").attr("d",v)}n.selectAll(".bar").attr("d",a),n.selectAll(".all_background.all_bar").attr("d",function(t,e){var r=d3.select(this).attr("d");return null===r?a(t,e):r}),f.empty()?n.selectAll(".all_proportion.all_bar").attr("d",g):n.selectAll(".asterisk").remove()})}n.id||(n.id=0);var r,a,l,o,s={top:10,right:10,bottom:20,left:10},i=m,u=b[n.id],h=n.id++,p=d3.svg.axis().orient("bottom").tickSize(6,0,0),f=d3.svg.brush();return f.on("brushstart.chart",function(){var t=d3.select(this.parentNode.parentNode.parentNode);t.select(".title a").style("display",null)}),f.on("brush.chart",function(){var t=d3.select(this.parentNode),e=f.extent();o&&t.select(".brush").call(f.extent(e=e.map(o))).selectAll(".resize").style("display",null),t.select("#clip-"+h+" rect").attr("x",r(e[0])).attr("width",r(e[1])-r(e[0])),a.filterRange(e)}),f.on("brushend.chart",function(){if(f.empty()){var t=d3.select(this.parentNode.parentNode.parentNode);t.select(".title a").style("display","none"),t.select("#clip-"+h+" rect").attr("x",null).attr("width","100%"),a.filterAll()}else{if(d3.version<"3.3")return;if(!d3.event.sourceEvent)return;var e=f.extent(),r=e.map(function(t){return d3.round(t+.5)-.5});r[0]>=r[1]&&(r[0]=Math.floor(e[0]+.5)-.5,r[1]=Math.ceil(e[1]+.5)-.5),d3.select(this).transition().call(f.extent(r)).call(f.event)}}),e.margin=function(t){return arguments.length?(s=t,e):s},e.x=function(t){return arguments.length?(r=t,p.scale(r),f.x(r),e):r},e.y=function(t){return arguments.length?(i=t,e):i},e.dimension=function(t){return arguments.length?(a=t,e):a},e.filter=function(t){return t?(f.extent(t),a.filterRange(t)):(f.clear(),a.filterAll()),e},e.group=function(t){return arguments.length?(l=t,e):l},e.round=function(t){return arguments.length?(o=t,e):o},d3.rebind(e,f,"on")}var l=e.questions,c=e.responses,o={};l.forEach(function(t){o[t.number]={},t.choices.forEach(function(e,r){o[t.number][e]=r})}),c.forEach(function(t){l.forEach(function(e){t[e.number]=o[e.number][t[e.number]]})}),l.forEach(function(e){d3.select(t).append("div").attr("id",e.number+"-chart").attr("class","catcorr chart").append("div").attr("class","title").text(e.number+". "+e.text)});var s=d3.format(",d"),i=crossfilter(c),d=i.groupAll(),u=[],h=[];l.forEach(function(t,e){u.push(i.dimension(function(e){return e[t.number]})),h.push(u[e].group())}),h.forEach(function(t){t.__all__=t.all().map(function(t){return t.value})});var p,f,g,v=[],m=d3.scale.linear().range([100,0]),b=[],x=[],_=80,y=3;l.forEach(function(t,e){var r={};t.choices.forEach(function(t,e){r[e]=t}),d3.tip&&(f=d3.tip().attr("class","d3-tip").direction("s").html(function(t){return"awesome "+t}),b.push(f));var a=0,l=t.choices.length-1;p=d3.scale.linear().domain([-.5,l+.5]).rangeRound([0,_*(l-a+1)]),p.labels=r,v.push(p),m.domain([0,d3.max([m.domain()[1],h[e].top(1)[0].value])]),g=n(t).dimension(u[e]).group(h[e]).x(p),x.push(g)});var g=d3.selectAll(".catcorr.chart").data(x).each(function(t){t.on("brush",a).on("brushend",a)}),M=d3.select(t).append("aside").attr("id","legend").attr("class","catcorr").html("
- / -
selected respondents"),A=300,w=120,j=M.insert("svg","div").attr("width",A).attr("height",w).append("g").attr("transform","translate(0,0)");j.selectAll(".bar").data(["all_background","background","foreground","all_proportion"]).enter().append("path").attr("class",function(t,e){return 0===e?"catcorr "+t+" all_bar outcome":3===e?"catcorr "+t+" all_bar outcome":"catcorr "+t+" bar outcome"}),j.select(".all_background.all_bar").attr("d",["M",(A-(_-2*y))/2,",",10,"v",100,"h",_-2*y,"v",-100].join("")),j.select(".foreground.bar").attr("d",["M",(A-(_-2*y))/2,",",80,"v",30,"h",_-2*y,"v",-30].join("")),j.select(".all_proportion.all_bar").attr("d",["M",(A-(_-2*y))/2,",",40,"h",_-2*y,"M",A/2,",",15,"v",44].join("")),j.append("foreignObject").attr("class","catcorr legend").attr("width",(A-_)/2).attr("height","3em").attr("x",A/2+_/2+y).attr("y",0).text("all respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2+_/2,",",7,"h",-15,"l",-7,",",7].join("")),j.append("foreignObject").attr("class","catcorr legend").attr("width",(A-_)/2).attr("height","3em").attr("x",A/2+_/2+y).attr("y",106).text("selected respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2+_/2,",",113,"h",-15,"l",-7,",",-7].join("")),j.append("foreignObject").attr("class","catcorr legend").attr("width",(A-_)/2).attr("height","3em").attr("x",A/2+_/2+y).attr("y",35).text("expected number of selected respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2+_/2,",",47,"h",-15,"l",-7,",",-7].join("")),j.append("foreignObject").attr("class","catcorr legend right").attr("width",(A-_)/2-20).attr("height","5em").attr("x",0).attr("y",12).attr("text-align","right").text("variation in expected number of selected respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2-_/2-18,",",36,"h",15,"v",22,"h",42,"M",A/2-_/2-3,",",36,"v",-22,"h",42].join(""));var k=d3.set();if(l.forEach(function(t){k.add(t.type)}),k=k.values(),k.length>1){var E=20,N=5;M.insert("div","svg").style("clear","both");var V=M.insert("svg","div").attr("width",A).attr("height",k.length*(E+N)+N).style("margin-bottom",20).append("g").attr("transform","translate(0,0)");V.selectAll().data(k).enter().append("path").attr("class",function(t){return"catcorr foreground bar "+t}).attr("d",function(t,e){return["M",A/2-E/2,",",N+e*(E+N),"h",E,"v",E,"h",-E].join("")}),V.selectAll().data(k).enter().append("text").attr("class","catcorr legend").attr("x",A/2+E/2+y).attr("y",function(t,e){return N+e*(E+N)+E/2}).attr("dy","0.35em").text(function(t){return t})}d3.selectAll("aside.catcorr #total").text(s(i.size())),a(),window.filter=function(t){t.forEach(function(t,e){x[e].filter(t)}),a()},window.reset=function(t){x[t].filter(null),a()}}e.version="0.2.0",t.catcorr=e}(this); \ No newline at end of file +!function(t){function e(t,e){function r(t){d3.select(this).call(t)}function a(){g.each(r),d3.select("aside.catcorr #active").text(s(d.value()))}function n(t){function e(e){function a(t){for(var e,a=[],n=-1,l=t.length;++ne){var n=a.substring(0,e-3).split(" ");a=n.slice(0,n.length-1).join(" "),a+="..."}return a});u&&(u.html(function(t){return r.labels[t]}),o.on("mouseover",u.show).on("mouseout",u.hide));var i=n.append("g").attr("class","catcorr brush").call(f);i.selectAll("rect").attr("fill","url(#diagonalHatch)").attr("height",b),i.selectAll(".resize").append("path").attr("d",v)}n.selectAll(".bar").attr("d",a),n.selectAll(".all_background.all_bar").attr("d",function(t,e){var r=d3.select(this).attr("d");return null===r?a(t,e):r}),f.empty()?n.selectAll(".all_proportion.all_bar").attr("d",g):n.selectAll(".asterisk").remove()})}n.id||(n.id=0);var r,a,l,o,s={top:10,right:10,bottom:20,left:10},i=m,u=b[n.id],h=n.id++,p=d3.svg.axis().orient("bottom").tickSize(6,0,0),f=d3.svg.brush();return f.on("brushstart.chart",function(){var t=d3.select(this.parentNode.parentNode.parentNode);t.select(".title a").style("display",null)}),f.on("brush.chart",function(){var t=d3.select(this.parentNode),e=f.extent();o&&t.select(".brush").call(f.extent(e=e.map(o))).selectAll(".resize").style("display",null),t.select("#clip-"+h+" rect").attr("x",r(e[0])).attr("width",r(e[1])-r(e[0])),a.filterRange(e)}),f.on("brushend.chart",function(){if(f.empty()){var t=d3.select(this.parentNode.parentNode.parentNode);t.select(".title a").style("display","none"),t.select("#clip-"+h+" rect").attr("x",null).attr("width","100%"),a.filterAll()}else{if(d3.version<"3.3")return;if(!d3.event.sourceEvent)return;var e=f.extent(),r=e.map(function(t){return d3.round(t+.5)-.5});r[0]>=r[1]&&(r[0]=Math.floor(e[0]+.5)-.5,r[1]=Math.ceil(e[1]+.5)-.5),d3.select(this).transition().call(f.extent(r)).call(f.event)}}),e.margin=function(t){return arguments.length?(s=t,e):s},e.x=function(t){return arguments.length?(r=t,p.scale(r),f.x(r),e):r},e.y=function(t){return arguments.length?(i=t,e):i},e.dimension=function(t){return arguments.length?(a=t,e):a},e.filter=function(t){return t?(f.extent(t),a.filterRange(t)):(f.clear(),a.filterAll()),e},e.group=function(t){return arguments.length?(l=t,e):l},e.round=function(t){return arguments.length?(o=t,e):o},d3.rebind(e,f,"on")}var l=e.questions,c=e.responses,o={};l.forEach(function(t){o[t.number]={},t.choices.forEach(function(e,r){o[t.number][e]=r})}),c.forEach(function(t){l.forEach(function(e){t[e.number]=o[e.number][t[e.number]]})}),l.forEach(function(e){d3.select(t).append("div").attr("id",e.number+"-chart").attr("class","catcorr chart").append("div").attr("class","title").text(e.number+". "+e.text)});var s=d3.format(",d"),i=crossfilter(c),d=i.groupAll(),u=[],h=[];l.forEach(function(t,e){u.push(i.dimension(function(e){return e[t.number]})),h.push(u[e].group())}),h.forEach(function(t){t.__all__=t.all().map(function(t){return t.value})});var p,f,g,v=[],m=d3.scale.linear().range([100,0]),b=[],x=[],_=80,y=3;l.forEach(function(t,e){var r={};t.choices.forEach(function(t,e){r[e]=t}),d3.tip&&(f=d3.tip().attr("class","d3-tip").direction("s").html(function(t){return"awesome "+t}),b.push(f));var a=0,l=t.choices.length-1;p=d3.scale.linear().domain([-.5,l+.5]).rangeRound([0,_*(l-a+1)]),p.labels=r,v.push(p),m.domain([0,d3.max([m.domain()[1],h[e].top(1)[0].value])]),g=n(t).dimension(u[e]).group(h[e]).x(p),x.push(g)});var g=d3.selectAll(".catcorr.chart").data(x).each(function(t){t.on("brush",a).on("brushend",a)}),M=d3.select(t).append("aside").attr("id","legend").attr("class","catcorr").html("
- / -
selected respondents"),A=300,w=120,j=M.insert("svg","div").attr("width",A).attr("height",w).append("g").attr("transform","translate(0,0)");d3.select(t).append("div").style("clear","both"),j.selectAll(".bar").data(["all_background","background","foreground","all_proportion"]).enter().append("path").attr("class",function(t,e){return 0===e?"catcorr "+t+" all_bar outcome":3===e?"catcorr "+t+" all_bar outcome":"catcorr "+t+" bar outcome"}),j.select(".all_background.all_bar").attr("d",["M",(A-(_-2*y))/2,",",10,"v",100,"h",_-2*y,"v",-100].join("")),j.select(".foreground.bar").attr("d",["M",(A-(_-2*y))/2,",",80,"v",30,"h",_-2*y,"v",-30].join("")),j.select(".all_proportion.all_bar").attr("d",["M",(A-(_-2*y))/2,",",40,"h",_-2*y,"M",A/2,",",15,"v",44].join("")),j.append("foreignObject").attr("class","catcorr legend").attr("width",(A-_)/2).attr("height","3em").attr("x",A/2+_/2+y).attr("y",0).text("all respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2+_/2,",",7,"h",-15,"l",-7,",",7].join("")),j.append("foreignObject").attr("class","catcorr legend").attr("width",(A-_)/2).attr("height","3em").attr("x",A/2+_/2+y).attr("y",106).text("selected respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2+_/2,",",113,"h",-15,"l",-7,",",-7].join("")),j.append("foreignObject").attr("class","catcorr legend").attr("width",(A-_)/2).attr("height","3em").attr("x",A/2+_/2+y).attr("y",35).text("expected number of selected respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2+_/2,",",47,"h",-15,"l",-7,",",-7].join("")),j.append("foreignObject").attr("class","catcorr legend right").attr("width",(A-_)/2-20).attr("height","5em").attr("x",0).attr("y",12).attr("text-align","right").text("variation in expected number of selected respondents"),j.append("path").attr("class","catcorr legend").attr("d",["M",A/2-_/2-18,",",36,"h",15,"v",22,"h",42,"M",A/2-_/2-3,",",36,"v",-22,"h",42].join(""));var k=d3.set();if(l.forEach(function(t){k.add(t.type)}),k=k.values(),k.length>1){var E=20,N=5;M.insert("div","svg").style("clear","both");var V=M.insert("svg","div").attr("width",A).attr("height",k.length*(E+N)+N).style("margin-bottom",20).append("g").attr("transform","translate(0,0)");V.selectAll().data(k).enter().append("path").attr("class",function(t){return"catcorr foreground bar "+t}).attr("d",function(t,e){return["M",A/2-E/2,",",N+e*(E+N),"h",E,"v",E,"h",-E].join("")}),V.selectAll().data(k).enter().append("text").attr("class","catcorr legend").attr("x",A/2+E/2+y).attr("y",function(t,e){return N+e*(E+N)+E/2}).attr("dy","0.35em").text(function(t){return t})}d3.selectAll("aside.catcorr #total").text(s(i.size())),a(),window.filter=function(t){t.forEach(function(t,e){x[e].filter(t)}),a()},window.reset=function(t){x[t].filter(null),a()}}e.version="0.2.0",t.catcorr=e}(this); \ No newline at end of file diff --git a/package.json b/package.json index 1b1a89e..8245717 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "catcorrjs", - "version": "0.3.0", + "version": "0.3.1", "description": "Visualize correlations across many dimensions of categorical data (e.g., from a survey)", "main": "catcorr.js", "directories": {