diff --git a/alamode.css b/alamode.css index 5ef38d2..681ede4 100644 --- a/alamode.css +++ b/alamode.css @@ -154,6 +154,18 @@ h1.mode-error { fill: none; } +.mode-zipcode-chorolpleth-legend{ + text-align: center; + font-size: 12px; + line-height: 24px; + height: 24px; +} + +.mode-zipcode-chorolpleth-zipcodes:hover { + fill: red; +} + + /*County choropleth*/ .mode-county-chorolpleth{ text-align: center; @@ -180,6 +192,30 @@ h1.mode-error { stroke-linejoin: round; } +.mode-state-chorolpleth-legend{ + text-align: center; + font-size: 12px; + line-height: 24px; + height: 24px; +} + +.mode-state-chorolpleth-states-base { + fill: #C3CBCB; +} + +.mode-state-chorolpleth-states:hover { + fill: red; +} + +.mode-state-chorolpleth-tooltip { + line-height: 1; + font-weight: normal; + padding: 12px; + background: rgba(0, 0, 0, 0.8); + color: #fff; + border-radius: 2px; +} + /*World choropleth*/ .mode-world-chorolpleth { text-align: center; diff --git a/alamode.js b/alamode.js index 51cd0f6..c37afa2 100644 --- a/alamode.js +++ b/alamode.js @@ -1581,7 +1581,9 @@ var alamode = { d3.select(uniqContainerClass) .append("div") .attr("class","mode-graphic-title") - .text(title) + .attr("class","mode-zipcode-chorolpleth-legend") + .attr("id","mode-zipcode-chorolpleth-legend-" + id) + .text("Hover over a Zipcode area to see details") svg = d3.select(uniqContainerClass) .append("div") @@ -1619,13 +1621,23 @@ var alamode = { .enter().append("path") .attr("class","mode-zipcode-chorolpleth-zipcodes-" + id) .attr("fill", function(d) { return quantize(rateById.get(d.properties.zip)); }) - .attr("d", path); + .attr("d", path) + .on("mouseover",function(d) { + d3.select(this).attr("class", "mode-zipcode-chorolpleth-zipcodes") + var zipcode = d.properties.zip; - // d3.select("#mode-county-chorolpleth-" + id) - // .append("path") - // .datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; })) - // .attr("class", "mode-county-chorolpleth-states") - // .attr("d", path); + if (rateById.get(d.properties.zip)) { + value = rateById.get(d.properties.zip); + } else { + value = "--" + } + + d3.select("#mode-zipcode-chorolpleth-legend-" + id).text(zipcode + ": " + value) + }) + .on("mouseout",function(d) { + d3.select(this).classed("mode-zipcode-chorolpleth-zipcodes", false); + d3.select("#mode-zipcode-chorolpleth-legend-" + id).text("Hover over a state to see details") + }) } }, @@ -1742,7 +1754,9 @@ var alamode = { d3.select(uniqContainerClass) .append("div") .attr("class","mode-graphic-title") - .text(title) + .attr("class","mode-state-chorolpleth-legend") + .attr("id","mode-state-chorolpleth-legend-" + id) + .text("Hover over a State to see details") svg = d3.select(uniqContainerClass) .append("div") @@ -1774,13 +1788,29 @@ var alamode = { d3.select("#mode-state-chorolpleth-" + id) .append("g") - .attr("class","mode-state-chorolpleth-states") + .attr("class","mode-state-chorolpleth-states-base") .selectAll(".mode-state-chorolpleth-states-" + id) .data(us.features) .enter().append("path") .attr("class","mode-state-chorolpleth-states-" + id) .attr("fill", function(d) { return quantize(rateById.get(d.properties[code]))}) - .attr("d", path); + .attr("d", path) + .on("mouseover",function(d) { + d3.select(this).attr("class", "mode-state-chorolpleth-states") + var state = d.properties.name; + + if (rateById.get(d.properties[code])) { + value = rateById.get(d.properties[code]); + } else { + value = "--" + } + + d3.select("#mode-state-chorolpleth-legend-" + id).text(state + ": " + value) + }) + .on("mouseout",function(d) { + d3.select(this).classed("mode-state-chorolpleth-states", false); + d3.select("#mode-state-chorolpleth-legend-" + id).text("Hover over a state to see details") + }) } }, diff --git a/alamode.min.css b/alamode.min.css index e52eb94..0c636ec 100644 --- a/alamode.min.css +++ b/alamode.min.css @@ -1 +1 @@ -.mode-graphic-container{border:1px solid #f2f3f3;max-width:1162px;margin:15px auto;overflow:scroll}.mode-graphic-title{font-size:14px;line-height:48px;height:48px;padding-left:16px;font-weight:500}h1.mode-error{padding:.2em 2em;background:#da364a;color:#fcfcfc;font-size:20px;font-weight:500}.mode-retention-heatmap-pivot-label{font-size:12px;text-align:center;margin:10px}.mode-retention-heatmap-table{table-layout:fixed;border-collapse:separate;font-size:10px;border-spacing:1px;margin:5px auto 10px}.mode-retention-heatmap-table-header-cell{overflow:hidden;font-size:12px;padding:4px;color:#fff;background:gray}.heatmap-string{text-align:left}.heatmap-number{text-align:center}.mode-retention-heatmap-table td{overflow:hidden;padding:6px 6px 4px}.mode-retention-heatmap-label{text-align:center;color:#8d9d9f}.mode-google-map{height:100%;width:100%;max-width:1162px;position:absolute}.mode-leaflet-map{width:95%;max-width:1162px}.mode-wordcloud{text-align:center}.mode-funnel{margin:0 auto}.mode-bullet-chart,.mode-funnel,.mode-sunburst,.mode-sunburst-sequence{text-align:center}.mode-sunburst path{stroke:#fff}.mode-sunburst-legend-container{display:block;margin:0 auto;text-align:center;max-width:600px}.mode-sunburst-legend-container text,.mode-sunburst-sequence text{fill:#fff}.mode-sunburst-legend{position:relative;vertical-align:middle;display:inline-block;margin-left:5px;margin-top:5px;width:195px;padding:5px}.mode-sunburst-explanation{margin:0 auto;fill:#666;padding:10px}.mode-sunburst-percentage{font-size:2.5em;color:#666}.mode-sunburst-cond-percentage{font-size:1.8em;color:#666}.mode-zipcode-chorolpleth{text-align:center}.zipcodes{fill:none}.mode-county-chorolpleth{text-align:center}.mode-county-chorolpleth-counties{fill:#666}.mode-county-chorolpleth-states{fill:none;stroke:#fff;stroke-linejoin:round}.mode-state-chorolpleth{text-align:center}.mode-state-chorolpleth-states{fill:#666;stroke:#fff;stroke-linejoin:round}.mode-world-chorolpleth{text-align:center}.mode-world-chorolpleth-legend{text-align:center;font-size:12px;line-height:24px;height:24px}.mode-world-chorolpleth-countries-base{fill:#c3cbcb}.mode-network-matrix-column-text.active,.mode-network-matrix-row-text.active,.mode-world-chorolpleth-countries:hover{fill:red}.mode-world-chorolpleth-boundaries{fill:none;stroke:#fff;stroke-linejoin:round}.mode-world-chorolpleth-tooltip{line-height:1;font-weight:400;padding:12px;background:rgba(0,0,0,.8);color:#fff;border-radius:2px}.mode-pivot-table{padding:10px}.mode-force-directed-graph{text-align:center;margin:0 auto}.mode-force-directed-graph-node{stroke:#394242;stroke-width:1px}.mode-force-directed-graph-link{fill:none;stroke:#a4a5a9}.mode-force-directed-graph-tooltip,.mode-hive-tooltip,.mode-network-matrix-tooltip{line-height:1;font-weight:400;padding:12px;background:rgba(0,0,0,.8);color:#fff;border-radius:2px}.mode-network-matrix{text-align:center;margin:0 auto}.mode-network-matrix-background{fill:#eee}.mode-network-matrix-line{stroke:#fff}.mode-network-matrix-order-picker{text-align:left;padding-left:16px}.mode-hive-link{fill:none;stroke-width:1px;stroke-opacity:.4}.mode-hive-link-selected{fill:none;stroke-width:3px;stroke-opacity:.6}.mode-hive-axis,.mode-hive-node{stroke:#394242;stroke-width:1px}.mode-hive-axis{stroke-opacity:.2}.mode-hive-node-selected{stroke-width:3px}.fixed-nav-bar{position:fixed;top:4px;z-index:9999;background-color:#fff;padding:0;box-shadow:0 2px 2px rgba(0,0,0,.1);border-radius:3px;font-size:0}.fixed-nav-bar a{padding:6px 10px;display:inline-block;font-weight:500;font-size:13px;color:#4e4d4d;border-right:1px solid rgba(0,0,0,.05)}.fixed-nav-bar a:hover{color:#f27802;text-decoration:none}.fixed-nav-bar a:last-child{border-radius:0 3px 3px 0;border-right:none}.fixed-nav-bar a:first-child{border-radius:3px 0 0 3px}.has-nav{padding-top:3em} +.mode-graphic-container{border:1px solid #f2f3f3;max-width:1162px;margin:15px auto;overflow:scroll}.mode-graphic-title{font-size:14px;line-height:48px;height:48px;padding-left:16px;font-weight:500}h1.mode-error{padding:.2em 2em;background:#da364a;color:#fcfcfc;font-size:20px;font-weight:500}.mode-retention-heatmap-pivot-label{font-size:12px;text-align:center;margin:10px}.mode-retention-heatmap-table{table-layout:fixed;border-collapse:separate;font-size:10px;border-spacing:1px;margin:5px auto 10px}.mode-retention-heatmap-table-header-cell{overflow:hidden;font-size:12px;padding:4px;color:#fff;background:gray}.heatmap-string{text-align:left}.heatmap-number{text-align:center}.mode-retention-heatmap-table td{overflow:hidden;padding:6px 6px 4px}.mode-retention-heatmap-label{text-align:center;color:#8d9d9f}.mode-google-map{height:100%;width:100%;max-width:1162px;position:absolute}.mode-leaflet-map{width:95%;max-width:1162px}.mode-wordcloud{text-align:center}.mode-funnel{margin:0 auto}.mode-bullet-chart,.mode-funnel,.mode-sunburst,.mode-sunburst-sequence{text-align:center}.mode-sunburst path{stroke:#fff}.mode-sunburst-legend-container{display:block;margin:0 auto;text-align:center;max-width:600px}.mode-sunburst-legend-container text,.mode-sunburst-sequence text{fill:#fff}.mode-sunburst-legend{position:relative;vertical-align:middle;display:inline-block;margin-left:5px;margin-top:5px;width:195px;padding:5px}.mode-sunburst-explanation{margin:0 auto;fill:#666;padding:10px}.mode-sunburst-percentage{font-size:2.5em;color:#666}.mode-sunburst-cond-percentage{font-size:1.8em;color:#666}.mode-zipcode-chorolpleth{text-align:center}.zipcodes{fill:none}.mode-zipcode-chorolpleth-legend{text-align:center;font-size:12px;line-height:24px;height:24px}.mode-network-matrix-column-text.active,.mode-network-matrix-row-text.active,.mode-state-chorolpleth-states:hover,.mode-world-chorolpleth-countries:hover,.mode-zipcode-chorolpleth-zipcodes:hover{fill:red}.mode-county-chorolpleth{text-align:center}.mode-county-chorolpleth-counties{fill:#666}.mode-county-chorolpleth-states{fill:none;stroke:#fff;stroke-linejoin:round}.mode-state-chorolpleth{text-align:center}.mode-state-chorolpleth-states{fill:#666;stroke:#fff;stroke-linejoin:round}.mode-state-chorolpleth-legend{text-align:center;font-size:12px;line-height:24px;height:24px}.mode-state-chorolpleth-states-base{fill:#c3cbcb}.mode-state-chorolpleth-tooltip{line-height:1;font-weight:400;padding:12px;background:rgba(0,0,0,.8);color:#fff;border-radius:2px}.mode-world-chorolpleth{text-align:center}.mode-world-chorolpleth-legend{text-align:center;font-size:12px;line-height:24px;height:24px}.mode-world-chorolpleth-countries-base{fill:#c3cbcb}.mode-world-chorolpleth-boundaries{fill:none;stroke:#fff;stroke-linejoin:round}.mode-world-chorolpleth-tooltip{line-height:1;font-weight:400;padding:12px;background:rgba(0,0,0,.8);color:#fff;border-radius:2px}.mode-pivot-table{padding:10px}.mode-force-directed-graph{text-align:center;margin:0 auto}.mode-force-directed-graph-node{stroke:#394242;stroke-width:1px}.mode-force-directed-graph-link{fill:none;stroke:#a4a5a9}.mode-force-directed-graph-tooltip,.mode-hive-tooltip,.mode-network-matrix-tooltip{line-height:1;font-weight:400;padding:12px;background:rgba(0,0,0,.8);color:#fff;border-radius:2px}.mode-network-matrix{text-align:center;margin:0 auto}.mode-network-matrix-background{fill:#eee}.mode-network-matrix-line{stroke:#fff}.mode-network-matrix-order-picker{text-align:left;padding-left:16px}.mode-hive-link{fill:none;stroke-width:1px;stroke-opacity:.4}.mode-hive-link-selected{fill:none;stroke-width:3px;stroke-opacity:.6}.mode-hive-axis,.mode-hive-node{stroke:#394242;stroke-width:1px}.mode-hive-axis{stroke-opacity:.2}.mode-hive-node-selected{stroke-width:3px}.fixed-nav-bar{position:fixed;top:4px;z-index:9999;background-color:#fff;padding:0;box-shadow:0 2px 2px rgba(0,0,0,.1);border-radius:3px;font-size:0}.fixed-nav-bar a{padding:6px 10px;display:inline-block;font-weight:500;font-size:13px;color:#4e4d4d;border-right:1px solid rgba(0,0,0,.05)}.fixed-nav-bar a:hover{color:#f27802;text-decoration:none}.fixed-nav-bar a:last-child{border-radius:0 3px 3px 0;border-right:none}.fixed-nav-bar a:first-child{border-radius:3px 0 0 3px}.has-nav{padding-top:3em} \ No newline at end of file diff --git a/alamode.min.js b/alamode.min.js index 95fbf80..8395889 100644 --- a/alamode.min.js +++ b/alamode.min.js @@ -1 +1 @@ -var version="0.15",alamode={reportError:function(t){$("
Order: '),d3.select(_).append("div").attr("class","mode-network-matrix").style("width",u).attr("id",o);var w=d3.tip().attr("class","mode-network-matrix-tooltip").offset([-10,0]).html(function(t){return t.z}),k=d3.select("#"+o).append("svg").attr("width",u+g.left+g.right).attr("height",m+g.top+g.bottom);k.call(w);var $=k.append("g").attr("transform","translate("+g.left+","+g.top+")");graph={nodes:v,links:y};var E=[],C=(v=graph.nodes).length;v.forEach(function(t,e){t.index=e,t.count=0,E[e]=d3.range(C).map(function(t){return{x:t,y:e,z:0}})}),graph.links.forEach(function(t){void 0!==E[t.source_id][t.target_id]?(E[t.source_id][t.target_id].z+=t.edge_size,v[t.source_id].count+=t.edge_size,v[t.target_id].count+=t.edge_size):(E[t.source_id][t.target_id]={},E[t.source_id][t.target_id].z=0)});var z={name:d3.range(C).sort(function(t,e){return d3.ascending(v[t].node,v[e].node)}),count:d3.range(C).sort(function(t,e){return v[e].count-v[t].count}),group:d3.range(C).sort(function(t,e){return d3.ascending(v[t].node_group,v[e].node_group)})};x.domain(z.name),k.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(u+g.left+g.right)/2).attr("y",25).attr("text-anchor","middle").text(p),k.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(m+g.top+g.bottom)/-2).attr("y",25).attr("transform","rotate(-90)").attr("text-anchor","middle").text(f),$.append("rect").attr("class","mode-network-matrix-background").attr("width",u).attr("height",m),(e=$.selectAll(".mode-network-matrix-row").data(E).enter().append("g").attr("class","mode-network-matrix-row").attr("transform",function(t,e){return"translate(0,"+x(e)+")"}).each(e)).append("line").attr("class","mode-network-matrix-line").attr("x2",u),e.append("text").attr("class","mode-network-matrix-row-text").attr("x",-6).attr("y",x.rangeBand()/2).attr("dy",".32em").attr("text-anchor","end").text(function(t,e){return v[e].node});var F=$.selectAll(".mode-network-matrix-column").data(E).enter().append("g").attr("class","mode-network-matrix-column").attr("transform",function(t,e){return"translate("+x(e)+")rotate(-90)"});F.append("line").attr("class","mode-network-matrix-line").attr("x1",-u),F.append("text").attr("class","mode-network-matrix-column-text").attr("x",6).attr("y",x.rangeBand()/2).attr("dy",".32em").attr("text-anchor","start").text(function(t,e){return v[e].node}),d3.select("#mode-network-matrix-order-picker-"+o).on("change",function(){r(this.value)})},hive:function(t){function e(t){return t/Math.PI*180-90}d3.hive={},d3.hive.link=function(){function t(t,r){var o,l=e(a,this,t,r),i=e(n,this,t,r);l.a>i.a&&(o=i,i=l,l=o),i.a-l.a>Math.PI&&(l.a+=2*Math.PI);var s=l.a+(i.a-l.a)/3,d=i.a-(i.a-l.a)/3;return l.r0-l.r1||i.r0-i.r1?"M"+Math.cos(l.a)*l.r0+","+Math.sin(l.a)*l.r0+"L"+Math.cos(l.a)*l.r1+","+Math.sin(l.a)*l.r1+"C"+Math.cos(s)*l.r1+","+Math.sin(s)*l.r1+" "+Math.cos(d)*i.r1+","+Math.sin(d)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1+"L"+Math.cos(i.a)*i.r0+","+Math.sin(i.a)*i.r0+"C"+Math.cos(d)*i.r0+","+Math.sin(d)*i.r0+" "+Math.cos(s)*l.r0+","+Math.sin(s)*l.r0+" "+Math.cos(l.a)*l.r0+","+Math.sin(l.a)*l.r0:"M"+Math.cos(l.a)*l.r0+","+Math.sin(l.a)*l.r0+"C"+Math.cos(s)*l.r1+","+Math.sin(s)*l.r1+" "+Math.cos(d)*i.r1+","+Math.sin(d)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1}function e(t,e,a,n){var s=t.call(e,a,n),d=+("function"==typeof r?r.call(e,s,n):r)+i,c=+("function"==typeof o?o.call(e,s,n):o);return{r0:c,r1:o===l?c:+("function"==typeof l?l.call(e,s,n):l),a:d}}var a=function(t){return t.source},n=function(t){return t.target},r=function(t){return t.angle},o=function(t){return t.radius},l=o,i=-Math.PI/2;return t.source=function(e){return arguments.length?(a=e,t):a},t.target=function(e){return arguments.length?(n=e,t):n},t.angle=function(e){return arguments.length?(r=e,t):r},t.radius=function(e){return arguments.length?(o=l=e,t):o},t.startRadius=function(e){return arguments.length?(o=e,t):o},t.endRadius=function(e){return arguments.length?(l=e,t):l},t};var a=alamode.makeId(10),n=t.node_query,r=t.edge_query,o=t.groups_are_numeric,l=t.html_element||"body",i=t.title||queryName,s=t.chart_width||"800",d=t.chart_height||"800",c=t.group_colors||"",u=Math.min(s,d)/2-30,m=.2*u,h=alamode.getDataFromQuery(n),f=alamode.getDataFromQuery(r),p=_.uniq(_.map(h,"node_group")),g={};h.forEach(function(t){t.x=o?t.node_group:p.indexOf(t.node_group),t.y=t.node_size,g[t.node]=t}),f.forEach(function(t){t.source=g[t.source],t.target=g[t.target]});var v=alamode.addContainerElement(l);d3.select(v).append("div").attr("class","mode-graphic-title").text(i),d3.select(v).append("div").attr("class","mode-network-matrix").style("width",s).attr("id",a),angle=o?d3.scale.linear().domain(d3.extent(h,function(t){return t.node_group})).range([0,2*Math.PI]):d3.scale.ordinal().domain(d3.range(p.length+1)).rangePoints([0,2*Math.PI]);var y=d3.scale.linear().domain(d3.extent(h,function(t){return t.node_size})).range([m,u]),x=d3.tip().attr("class","mode-hive-tooltip").offset([-10,0]).html(function(t){return t.node}),b=d3.select("#"+a).append("svg").attr("width",s).attr("height",d).append("g").attr("transform","translate("+s/2+","+d/2+")");b.call(x),b.selectAll(".mode-hive-axis").data(d3.range(p.length)).enter().append("line").attr("class","mode-hive-axis").attr("transform",function(t){return"rotate("+e(angle(t))+")"}).attr("x1",y.range()[0]).attr("x2",y.range()[1]),b.selectAll(".mode-hive-link").data(f).enter().append("path").attr("class","mode-hive-link").attr("d",d3.hive.link().angle(function(t){return angle(t.x)}).radius(function(t){return y(t.y)})).style("stroke",function(t){return c[t.source.node_group]}),b.selectAll(".mode-hive-node").data(h).enter().append("circle").attr("class","mode-hive-node").attr("transform",function(t){return"rotate("+e(angle(t.x))+")"}).attr("cx",function(t){return y(t.y)}).attr("r",5).style("fill",function(t){return c[t.node_group]}).on("mouseover",function(t){x.show(t),d3.select(this).attr("class","mode-hive-node mode-hive-node-selected"),d3.selectAll(".mode-hive-link").data(f).attr("class",function(e){return e.source.node==t.node?"mode-hive-link-selected":e.target.node==t.node?"mode-hive-link-selected":"mode-hive-link"})}).on("mouseout",function(t){x.hide(t),d3.select(this).attr("class","mode-hive-node"),d3.selectAll(".mode-hive-link-selected").attr("class","mode-hive-link")})},conditionalFormattingByColumn:function(t){function e(t){var e=$(l+" table"),r=$(l+" .js-header-table"),o=r?$(l+" .js-col-header"):$(r).find("th"),i=(e.find("tr"),0);o.each(function(){text=$(this).find(".axel-table-header-label").text(),i=$(this).attr("data-axel-column"),c[text]=i}),t.forEach(function(t){t.rules.forEach(function(e){var r=e.shade_text||!1;"gradient"==e.type?a(t.column,e.color,r):"above"!=e.type&&"below"!=e.type&&"equal"!=e.type||n(t.column,e.type,e.value,e.color,r)})})}function a(t,e,a){var n=d3.extent(_.map(d,t)),r=d3.scale.linear().domain(n).interpolate(d3.interpolateHsl).range(e),i=c[t];d.forEach(function(e,n){var s=l+" table [data-axel-rowkey='"+n+"'][data-axel-column='"+i+"']",d=r(e[t]),c=o(d),u=$(s);a?u.css("color",d):u.css({background:d,color:c})})}function n(t,e,a,n,r){var i=c[t],s=o(n);d.forEach(function(o,d){var c=l+" table [data-axel-rowkey='"+d+"'][data-axel-column='"+i+"']",u=$(c);"above"==e&&o[t]>=a?r?u.css("color",n):u.css({background:n,color:s}):"below"==e&&o[t]<=a?r?u.css("color",n):u.css({background:n,color:s}):"equal"==e&&o[t]==a&&(r?u.css("color",n):u.css({background:n,color:s}))})}function r(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function o(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)?(rgb=r(e),t=Math.round((299*parseInt(rgb.r)+587*parseInt(rgb.g)+114*parseInt(rgb.b))/1e3)):t=255,t>125?"#2B2B2B":"#FCFCFC"}var l="#"+t.table_id,i=t.query_name,s=t.column_rules,d=alamode.getDataFromQuery(i),c=(alamode.getColumnsFromQuery(i),{});setTimeout(function(){e(s)},1e3),$(l).mousemove(function(){e(s)})},conditionalFormattingByTable:function(t){function e(t){var e=$(l+" table"),r=$(l+" .js-header-table"),o=r?$(l+" .js-col-header"):$(r).find("th"),i=(e.find("tr"),0);o.each(function(){text=$(this).find(".axel-table-header-label").text(),i=$(this).attr("data-axel-column"),c[text]=i}),t.forEach(function(t){var e=t.shade_text||!1;"gradient"==t.type?a(t.color,e):"above"!=t.type&&"below"!=t.type&&"equal"!=t.type||n(t.type,t.value,t.color,e)})}function a(t,e){var a=d3.scale.linear().domain(m).interpolate(d3.interpolateHsl).range(t);d.forEach(function(t,n){s.forEach(function(r){var i=c[r],s=l+" table [data-axel-rowkey='"+n+"'][data-axel-column='"+i+"']",d=a(t[r]),u=o(d),m=$(s);e?m.css("color",d):m.css({background:d,color:u})})})}function n(t,e,a,n){var r=o(a);d.forEach(function(o,i){s.forEach(function(s){var d=c[s],u=l+" table [data-axel-rowkey='"+i+"'][data-axel-column='"+d+"']",m=$(u);"above"==t&&o[s]>=e?n?m.css("color",a):m.css({background:a,color:r}):"below"==t&&o[s]<=e?n?m.css("color",a):m.css({background:a,color:r}):"equal"==t&&o[s]==e&&(n?m.css("color",a):m.css({background:a,color:r}))})})}function r(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function o(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)?(rgb=r(e),t=Math.round((299*parseInt(rgb.r)+587*parseInt(rgb.g)+114*parseInt(rgb.b))/1e3)):t=255,t>125?"#2B2B2B":"#FCFCFC"}var l="#"+t.table_id,i=t.query_name,s=t.columns;rules=t.rules;var d=alamode.getDataFromQuery(i),c=(alamode.getColumnsFromQuery(i),{}),u=[];s.forEach(function(t){var e=d3.extent(_.map(d,t));u=u.concat(e)});var m=d3.extent(u);setTimeout(function(){e(rules)},1e3),$(l).mousemove(function(){e(rules)})},addTableOfContents:function(t){void 0===t&&(t="default");var e=t.text_color,a=t.background_color,n=t.hover_color;$(".mode-header").addClass("has-nav");var r=$("");$(".row").each(function(){$(this).children().each(function(){var t,e=$(this).find("mode-chart").attr("id")||$(this).find("mode-table").attr("id")||$(this).find("mode-python").attr("id");if(!e)return!0;if(e.includes("chart")||e.includes("table")){var a=document.getElementById(e);t=$(a).find("mode-pivot-table").length>0?document.getElementById(e).getElementsByClassName("in-place-edit-text")[0].innerText:document.getElementById(e).getElementsByClassName("chart-title")[0].innerText}else e.includes("python")&&(t=document.getElementById(e).getElementsByClassName("in-place-edit-text")[0].innerText);var n=$(""+(t.includes("Click to add title")?"Untitled":t)+"");r.append(n)})});var o=$("
");$(".mode-content").prepend(o);var l=$("");o.prepend(l);var i=$("");l.prepend(i),i.prepend(r),e&&$(".fixed-nav-bar a").css("color",e),a&&$(".fixed-nav-bar").css("background-color",a),n&&$(".fixed-nav-bar a").hover(function(){$(this).css("color",n)},function(){e?$(this).css("color",e):$(this).css("color","")}),setTimeout(function(){function t(t,e){var a=$(t).offset().top-50;$("html,body").animate({scrollTop:a},e)}$(".scroll-link").on("click",function(e){e.preventDefault(),t($(this).attr("href"),750)})},100)}}; \ No newline at end of file +var version="0.15",alamode={reportError:function(t){$("Order: '),d3.select(_).append("div").attr("class","mode-network-matrix").style("width",u).attr("id",o);var w=d3.tip().attr("class","mode-network-matrix-tooltip").offset([-10,0]).html(function(t){return t.z}),k=d3.select("#"+o).append("svg").attr("width",u+g.left+g.right).attr("height",m+g.top+g.bottom);k.call(w);var $=k.append("g").attr("transform","translate("+g.left+","+g.top+")");graph={nodes:v,links:y};var E=[],z=(v=graph.nodes).length;v.forEach(function(t,e){t.index=e,t.count=0,E[e]=d3.range(z).map(function(t){return{x:t,y:e,z:0}})}),graph.links.forEach(function(t){void 0!==E[t.source_id][t.target_id]?(E[t.source_id][t.target_id].z+=t.edge_size,v[t.source_id].count+=t.edge_size,v[t.target_id].count+=t.edge_size):(E[t.source_id][t.target_id]={},E[t.source_id][t.target_id].z=0)});var C={name:d3.range(z).sort(function(t,e){return d3.ascending(v[t].node,v[e].node)}),count:d3.range(z).sort(function(t,e){return v[e].count-v[t].count}),group:d3.range(z).sort(function(t,e){return d3.ascending(v[t].node_group,v[e].node_group)})};x.domain(C.name),k.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(u+g.left+g.right)/2).attr("y",25).attr("text-anchor","middle").text(f),k.append("text").attr("class","mode-network-matrix-axis-label").attr("x",(m+g.top+g.bottom)/-2).attr("y",25).attr("transform","rotate(-90)").attr("text-anchor","middle").text(p),$.append("rect").attr("class","mode-network-matrix-background").attr("width",u).attr("height",m),(e=$.selectAll(".mode-network-matrix-row").data(E).enter().append("g").attr("class","mode-network-matrix-row").attr("transform",function(t,e){return"translate(0,"+x(e)+")"}).each(e)).append("line").attr("class","mode-network-matrix-line").attr("x2",u),e.append("text").attr("class","mode-network-matrix-row-text").attr("x",-6).attr("y",x.rangeBand()/2).attr("dy",".32em").attr("text-anchor","end").text(function(t,e){return v[e].node});var F=$.selectAll(".mode-network-matrix-column").data(E).enter().append("g").attr("class","mode-network-matrix-column").attr("transform",function(t,e){return"translate("+x(e)+")rotate(-90)"});F.append("line").attr("class","mode-network-matrix-line").attr("x1",-u),F.append("text").attr("class","mode-network-matrix-column-text").attr("x",6).attr("y",x.rangeBand()/2).attr("dy",".32em").attr("text-anchor","start").text(function(t,e){return v[e].node}),d3.select("#mode-network-matrix-order-picker-"+o).on("change",function(){r(this.value)})},hive:function(t){function e(t){return t/Math.PI*180-90}d3.hive={},d3.hive.link=function(){function t(t,r){var o,l=e(a,this,t,r),i=e(n,this,t,r);l.a>i.a&&(o=i,i=l,l=o),i.a-l.a>Math.PI&&(l.a+=2*Math.PI);var s=l.a+(i.a-l.a)/3,d=i.a-(i.a-l.a)/3;return l.r0-l.r1||i.r0-i.r1?"M"+Math.cos(l.a)*l.r0+","+Math.sin(l.a)*l.r0+"L"+Math.cos(l.a)*l.r1+","+Math.sin(l.a)*l.r1+"C"+Math.cos(s)*l.r1+","+Math.sin(s)*l.r1+" "+Math.cos(d)*i.r1+","+Math.sin(d)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1+"L"+Math.cos(i.a)*i.r0+","+Math.sin(i.a)*i.r0+"C"+Math.cos(d)*i.r0+","+Math.sin(d)*i.r0+" "+Math.cos(s)*l.r0+","+Math.sin(s)*l.r0+" "+Math.cos(l.a)*l.r0+","+Math.sin(l.a)*l.r0:"M"+Math.cos(l.a)*l.r0+","+Math.sin(l.a)*l.r0+"C"+Math.cos(s)*l.r1+","+Math.sin(s)*l.r1+" "+Math.cos(d)*i.r1+","+Math.sin(d)*i.r1+" "+Math.cos(i.a)*i.r1+","+Math.sin(i.a)*i.r1}function e(t,e,a,n){var s=t.call(e,a,n),d=+("function"==typeof r?r.call(e,s,n):r)+i,c=+("function"==typeof o?o.call(e,s,n):o);return{r0:c,r1:o===l?c:+("function"==typeof l?l.call(e,s,n):l),a:d}}var a=function(t){return t.source},n=function(t){return t.target},r=function(t){return t.angle},o=function(t){return t.radius},l=o,i=-Math.PI/2;return t.source=function(e){return arguments.length?(a=e,t):a},t.target=function(e){return arguments.length?(n=e,t):n},t.angle=function(e){return arguments.length?(r=e,t):r},t.radius=function(e){return arguments.length?(o=l=e,t):o},t.startRadius=function(e){return arguments.length?(o=e,t):o},t.endRadius=function(e){return arguments.length?(l=e,t):l},t};var a=alamode.makeId(10),n=t.node_query,r=t.edge_query,o=t.groups_are_numeric,l=t.html_element||"body",i=t.title||queryName,s=t.chart_width||"800",d=t.chart_height||"800",c=t.group_colors||"",u=Math.min(s,d)/2-30,m=.2*u,h=alamode.getDataFromQuery(n),p=alamode.getDataFromQuery(r),f=_.uniq(_.map(h,"node_group")),g={};h.forEach(function(t){t.x=o?t.node_group:f.indexOf(t.node_group),t.y=t.node_size,g[t.node]=t}),p.forEach(function(t){t.source=g[t.source],t.target=g[t.target]});var v=alamode.addContainerElement(l);d3.select(v).append("div").attr("class","mode-graphic-title").text(i),d3.select(v).append("div").attr("class","mode-network-matrix").style("width",s).attr("id",a),angle=o?d3.scale.linear().domain(d3.extent(h,function(t){return t.node_group})).range([0,2*Math.PI]):d3.scale.ordinal().domain(d3.range(f.length+1)).rangePoints([0,2*Math.PI]);var y=d3.scale.linear().domain(d3.extent(h,function(t){return t.node_size})).range([m,u]),x=d3.tip().attr("class","mode-hive-tooltip").offset([-10,0]).html(function(t){return t.node}),b=d3.select("#"+a).append("svg").attr("width",s).attr("height",d).append("g").attr("transform","translate("+s/2+","+d/2+")");b.call(x),b.selectAll(".mode-hive-axis").data(d3.range(f.length)).enter().append("line").attr("class","mode-hive-axis").attr("transform",function(t){return"rotate("+e(angle(t))+")"}).attr("x1",y.range()[0]).attr("x2",y.range()[1]),b.selectAll(".mode-hive-link").data(p).enter().append("path").attr("class","mode-hive-link").attr("d",d3.hive.link().angle(function(t){return angle(t.x)}).radius(function(t){return y(t.y)})).style("stroke",function(t){return c[t.source.node_group]}),b.selectAll(".mode-hive-node").data(h).enter().append("circle").attr("class","mode-hive-node").attr("transform",function(t){return"rotate("+e(angle(t.x))+")"}).attr("cx",function(t){return y(t.y)}).attr("r",5).style("fill",function(t){return c[t.node_group]}).on("mouseover",function(t){x.show(t),d3.select(this).attr("class","mode-hive-node mode-hive-node-selected"),d3.selectAll(".mode-hive-link").data(p).attr("class",function(e){return e.source.node==t.node?"mode-hive-link-selected":e.target.node==t.node?"mode-hive-link-selected":"mode-hive-link"})}).on("mouseout",function(t){x.hide(t),d3.select(this).attr("class","mode-hive-node"),d3.selectAll(".mode-hive-link-selected").attr("class","mode-hive-link")})},conditionalFormattingByColumn:function(t){function e(t){var e=$(l+" table"),r=$(l+" .js-header-table"),o=r?$(l+" .js-col-header"):$(r).find("th"),i=(e.find("tr"),0);o.each(function(){text=$(this).find(".axel-table-header-label").text(),i=$(this).attr("data-axel-column"),c[text]=i}),t.forEach(function(t){t.rules.forEach(function(e){var r=e.shade_text||!1;"gradient"==e.type?a(t.column,e.color,r):"above"!=e.type&&"below"!=e.type&&"equal"!=e.type||n(t.column,e.type,e.value,e.color,r)})})}function a(t,e,a){var n=d3.extent(_.map(d,t)),r=d3.scale.linear().domain(n).interpolate(d3.interpolateHsl).range(e),i=c[t];d.forEach(function(e,n){var s=l+" table [data-axel-rowkey='"+n+"'][data-axel-column='"+i+"']",d=r(e[t]),c=o(d),u=$(s);a?u.css("color",d):u.css({background:d,color:c})})}function n(t,e,a,n,r){var i=c[t],s=o(n);d.forEach(function(o,d){var c=l+" table [data-axel-rowkey='"+d+"'][data-axel-column='"+i+"']",u=$(c);"above"==e&&o[t]>=a?r?u.css("color",n):u.css({background:n,color:s}):"below"==e&&o[t]<=a?r?u.css("color",n):u.css({background:n,color:s}):"equal"==e&&o[t]==a&&(r?u.css("color",n):u.css({background:n,color:s}))})}function r(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function o(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)?(rgb=r(e),t=Math.round((299*parseInt(rgb.r)+587*parseInt(rgb.g)+114*parseInt(rgb.b))/1e3)):t=255,t>125?"#2B2B2B":"#FCFCFC"}var l="#"+t.table_id,i=t.query_name,s=t.column_rules,d=alamode.getDataFromQuery(i),c=(alamode.getColumnsFromQuery(i),{});setTimeout(function(){e(s)},1e3),$(l).mousemove(function(){e(s)})},conditionalFormattingByTable:function(t){function e(t){var e=$(l+" table"),r=$(l+" .js-header-table"),o=r?$(l+" .js-col-header"):$(r).find("th"),i=(e.find("tr"),0);o.each(function(){text=$(this).find(".axel-table-header-label").text(),i=$(this).attr("data-axel-column"),c[text]=i}),t.forEach(function(t){var e=t.shade_text||!1;"gradient"==t.type?a(t.color,e):"above"!=t.type&&"below"!=t.type&&"equal"!=t.type||n(t.type,t.value,t.color,e)})}function a(t,e){var a=d3.scale.linear().domain(m).interpolate(d3.interpolateHsl).range(t);d.forEach(function(t,n){s.forEach(function(r){var i=c[r],s=l+" table [data-axel-rowkey='"+n+"'][data-axel-column='"+i+"']",d=a(t[r]),u=o(d),m=$(s);e?m.css("color",d):m.css({background:d,color:u})})})}function n(t,e,a,n){var r=o(a);d.forEach(function(o,i){s.forEach(function(s){var d=c[s],u=l+" table [data-axel-rowkey='"+i+"'][data-axel-column='"+d+"']",m=$(u);"above"==t&&o[s]>=e?n?m.css("color",a):m.css({background:a,color:r}):"below"==t&&o[s]<=e?n?m.css("color",a):m.css({background:a,color:r}):"equal"==t&&o[s]==e&&(n?m.css("color",a):m.css({background:a,color:r}))})})}function r(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function o(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)?(rgb=r(e),t=Math.round((299*parseInt(rgb.r)+587*parseInt(rgb.g)+114*parseInt(rgb.b))/1e3)):t=255,t>125?"#2B2B2B":"#FCFCFC"}var l="#"+t.table_id,i=t.query_name,s=t.columns;rules=t.rules;var d=alamode.getDataFromQuery(i),c=(alamode.getColumnsFromQuery(i),{}),u=[];s.forEach(function(t){var e=d3.extent(_.map(d,t));u=u.concat(e)});var m=d3.extent(u);setTimeout(function(){e(rules)},1e3),$(l).mousemove(function(){e(rules)})},addTableOfContents:function(t){void 0===t&&(t="default");var e=t.text_color,a=t.background_color,n=t.hover_color;$(".mode-header").addClass("has-nav");var r=$("");$(".row").each(function(){$(this).children().each(function(){var t,e=$(this).find("mode-chart").attr("id")||$(this).find("mode-table").attr("id")||$(this).find("mode-python").attr("id");if(!e)return!0;if(e.includes("chart")||e.includes("table")){var a=document.getElementById(e);t=$(a).find("mode-pivot-table").length>0?document.getElementById(e).getElementsByClassName("in-place-edit-text")[0].innerText:document.getElementById(e).getElementsByClassName("chart-title")[0].innerText}else e.includes("python")&&(t=document.getElementById(e).getElementsByClassName("in-place-edit-text")[0].innerText);var n=$(""+(t.includes("Click to add title")?"Untitled":t)+"");r.append(n)})});var o=$("
");$(".mode-content").prepend(o);var l=$("");o.prepend(l);var i=$("");l.prepend(i),i.prepend(r),e&&$(".fixed-nav-bar a").css("color",e),a&&$(".fixed-nav-bar").css("background-color",a),n&&$(".fixed-nav-bar a").hover(function(){$(this).css("color",n)},function(){e?$(this).css("color",e):$(this).css("color","")}),setTimeout(function(){function t(t,e){var a=$(t).offset().top-50;$("html,body").animate({scrollTop:a},e)}$(".scroll-link").on("click",function(e){e.preventDefault(),t($(this).attr("href"),750)})},100)}}; \ No newline at end of file