-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsota.min.js
1 lines (1 loc) · 46.6 KB
/
sota.min.js
1
!function(t,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a(require("d3")):"function"==typeof define&&define.amd?define(["d3"],a):(t=t||self).sota=a(t.d3)}(this,(function(t){"use strict";function a(t,a="#ffffff",e=8,n=!1){const s=t.substr(1),o=parseInt("0x"+s.substr(0,2)),l=parseInt("0x"+s.substr(2,2)),r=parseInt("0x"+s.substr(4,2)),i=a.substr(1),c=n?e:e+1,h=(parseInt("0x"+i.substr(0,2))-o)/c,d=(parseInt("0x"+i.substr(2,2))-l)/c,g=(parseInt("0x"+i.substr(4,2))-r)/c;let p,m=[t];for(let t=1;t<e-1;t++){const a=o+h*t,e=l+d*t,n=r+g*t,s="#"+Math.round(a).toString(16)+Math.round(e).toString(16)+Math.round(n).toString(16);m.push(s)}if(n)p=a;else{const t=o+h*e,a=l+d*e,n=r+g*e;p="#"+Math.round(t).toString(16)+Math.round(a).toString(16)+Math.round(n).toString(16)}return m.push(p),m}var e={numberFont:"Montserrat",labelFont:"Lora",sections:[{slug:"default",name:"Default",colors:a("#000000")}],separatorStrokeWidth:1,barHeight:32,barMargin:16,labelLeft:6,labelBelow:8,groupLabelMargin:32,legendMargin:24,xAxisTop:24,overflowOffset:24,lineColor:"#777777",labelColor:"#777777",mainHeight:300,tickSize:4,labelAngle:30,groupedBarChart:{barHeight:24,barMargin:8},margin:{top:20,bottom:20,left:0,right:0},swatch:{between:12,belowBetween:8,right:24,width:32,height:24,below:16}};function n(a){const e=a.node().offsetWidth/2,n=t.event.pageX;return n-e<0?e:n+e>window.innerWidth?window.innerWidth-e:n}function s(a){return t.format(".1f")(a)+"%"}function o(a,o,l,r,i){a.on("mouseover",(function(a,c){t.select(this).attr("opacity",e.hoverOpacity),o.style("opacity",1).html(()=>{let t=`<span class="sota-text-label"></span><span class="sota-heavy-label">${r[c]}</span><br/>Percentage: ${s(l[c])}`;return i&&(t+="<br/>Number of responses: "+i[c]),t+="</span>",t}).style("left",n(o)+"px").style("top",t.event.pageY+"px")})).on("mousemove",a=>{o.style("left",n(o)+"px").style("top",t.event.pageY+"px")}).on("mouseout",(function(a){t.select(this).attr("opacity",1),o.style("opacity",0)}))}function l(a,e,n,s,o,l){if(!a&&!e)throw`No selector or section specified for chart with "${dataFile}" dataFile parameter.`;const r=a?t.select(a):t.select(`#sota-section-${e} .sota-section-inner`).append("div").attr("class","sota-module");e&&n&&r.append("h3").text(n),e&&s&&r.append("div").attr("class","sota-subtitle").append("span").text(s);const i=r.append("svg").style("margin-top",o.top+"px").style("margin-bottom",o.bottom+"px"),c=t.select("body").append("div").attr("class","sota-tooltip"),h=r.node().offsetWidth,d=h-o.left-o.right,g=i.append("g").attr("class","sota-mainChart").attr("transform",`translate(${o.left+l} 0)`).attr("width",d);return{container:r,svg:i,tooltip:c,width:h,mainWidth:d,mainChart:g}}function r(a,e,n=null){return n=null==n?t.sum(a,t=>+t.value):n,[e?a.map(t=>+t.value):a.map(t=>+t.value/n*100),!e&&a.map(t=>+t.value),a.map(t=>t.label)]}function i(t){const a=new Event("sotaChartRendered"),e=t.closest(".sota-section-inner");null!==e&&e.dispatchEvent(a)}function c(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}let h={barChart:function({dataFile:a,selector:n=!1,title:c=!1,subtitle:h=!1,section:d=!1,inputIsPercentage:g=!1,showXAxis:p=!0,showSeparators:m=!0,displayPercentage:x=!0,totalResp:u=null,maxVal:f=null,minVal:b=null,margin:w=e.margin}){const v=e.tickSize,y=e.separatorStrokeWidth,B=e.labelLeft,k=e.barHeight,C=e.barMargin,$=e.overflowOffset,A=e.xAxisTop,{container:j,svg:L,tooltip:z,width:M,mainWidth:S,mainChart:N}=l(n,d,c,h,w,$);t.csv(a+".csv").then(a=>{const e=k+C;let l=a.length*e;const[c,h,d]=r(a,g,u),P=x||g?c:h;if(null==b)b=0;else if(!0===b)b=t.min(P);else if(isNaN(b)||""===b)throw"invalid minVal for graph on "+n;if(null==f)f=g||x?100:t.max(P);else if(!0===f)f=t.max(P);else if(isNaN(f)||""===f)throw"invalid maxVal for graph on "+n;const I=t.scaleLinear().domain([b,f]).range([0,S]);let W;function V(t){return t*e}if(p&&(W=N.append("g").attr("class","sota-gen-axis sota-gen-xAxis sota-num-axis").call(t.axisBottom(I).tickSize(-v)).attr("transform","translate(0 "+(l+A)+")")),N.selectAll(".sota-barChart-bar").data(P).join("rect").attr("class","sota-barChart-bar sota-gen-bar").attr("width",t=>I(t)).attr("height",k).attr("x",0).attr("y",(t,a)=>V(a)),N.selectAll(".sota-barChart-hiddenBar").data(P).join("rect").attr("class","sota-barChart-hiddenBar").attr("width",S).attr("height",k).attr("x",0).attr("y",(t,a)=>V(a)).attr("fill","transparent").call(o,z,c,d,h),N.selectAll(".sota-barChart-label").data(a).join("text").attr("class","sota-barChart-label sota-text-label sota-heavy-label").html(t=>t.label).attr("alignment-baseline","central").attr("dominant-baseline","central").attr("x",B).attr("y",(t,a)=>V(a)+k/2),m&&N.selectAll(".sota-barChart-separator").data(P).join("line").attr("class","sota-barChart-separator").attr("x1",0).attr("x2",S).attr("y1",(t,a)=>V(a)+k+6).attr("y2",(t,a)=>V(a)+k+6).attr("stroke-width",y).attr("stroke","#dddddd"),N.selectAll(".sota-barChart-value").data(P).join("text").attr("class","sota-barChart-value sota-num-label").html((t,a)=>g||x?s(t):t).attr("alignment-baseline","central").attr("dominant-baseline","central").attr("text-anchor","end").attr("x",S).attr("y",(t,a)=>V(a)+k/2),p){let a=[];W.selectAll("text").each((function(){a.push(this.getBBox().y+this.getBBox().height)})),l+=+t.max(a)}const O=l+w.top+w.bottom;L.style("width",M+2*$+"px").attr("height",O).style("margin-left",-$+"px"),i(j.node())})},pieChart:function({dataFile:a,selector:n=!1,title:c=!1,subtitle:h=!1,section:d=!1,inputIsPercentage:g=!1,sorted:p=!0,pieRad:m=150,pieThick:x=80,margin:u=e.margin}){const f=e.lineColor,b=e.separatorStrokeWidth,w=e.separatorStrokeWidth,v=e.swatch.between,y=e.swatch.right,B=e.swatch.width,k=e.swatch.height,C=e.swatch.belowBetween,$=e.swatch.below,A=e.legendMargin,j=e.overflowOffset,{container:L,svg:z,tooltip:M,width:S,mainWidth:N,mainChart:P}=l(n,d,c,h,u,j);N<2*m&&(m=N/2),x>m&&(x=50),t.csv(a+".csv").then(a=>{const[e,n,l]=r(a,g),c=(p?t.pie():t.pie().sort(null))(e);let h=0,d=[];const I=t.scaleOrdinal().domain(l).range(t.map(l,(t,a)=>"sota-fill-"+(l.length>3?a+1:2*a+1)).keys()),W=P.append("g").lower().attr("class","sota-gen-legend").attr("transform",`translate(0 ${u.top})`);if(W.selectAll("nothing").data(a).enter().append("text").attr("class","sota-gen-legend-text").text(t=>t.label).attr("x",(function(){d.push(this.getBBox().width)})).remove(),t.sum(d,t=>t)+l.length*(B+v)+(l.length-1)*y>N){let a=N-t.max(d)-B-v;W.selectAll(".sota-gen-legend-swatch").data(l).join("rect").attr("class",t=>"sota-gen-legend-swatch "+I(t)).attr("x",a).attr("y",(t,a)=>(k+C)*a).attr("width",B).attr("height",k),W.selectAll(".sota-gen-legend-text").data(l).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",a+B+v).attr("y",(t,a)=>(k+C)*a+k/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),h=l.length*k+(l.length-1)*C+$+A}else{let a=N-(t.sum(d,t=>t)+l.length*(B+v)+(l.length-1)*y);W.selectAll(".sota-gen-legend-swatch").data(l).join("rect").attr("class",t=>"sota-gen-legend-swatch "+I(t)).attr("x",(e,n)=>a+n*(B+v+y)+t.sum(d.slice(0,n),t=>t)).attr("y",0).attr("width",B).attr("height",k),W.selectAll(".sota-gen-legend-text").data(l).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",(e,n)=>a+n*(B+v+y)+B+v+t.sum(d.slice(0,n),t=>t)).attr("y",k/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),h=k+$+A}const V=P.append("g").attr("transform","translate("+N/2+","+(m+h)+")"),O=t.arc().innerRadius(.8*m-.8*x).outerRadius(.8*m),E=t.arc().innerRadius(.9*m).outerRadius(.9*m);V.selectAll(".sota-pieChart-slice").data(c).join("path").attr("class",(t,a)=>"sota-pieChart-slice "+I(a)).attr("d",O).attr("stroke","#fff").style("stroke-width",w).call(o,M,e,l,n);let F=!1;V.selectAll(".sota-pieChart-polyline").data(c).join("polyline").attr("class","sota-pieChart-polyline").attr("stroke",f).style("fill","none").attr("stroke-width",b).attr("points",(t,a)=>{let e=O.centroid(t),n=E.centroid(t),s=E.centroid(t);const o=E.centroid(t),l=a>0&&E.centroid(c[a-1]),r=(t.endAngle+t.startAngle)/2<Math.PI;return a>0&&Math.sign(o[0])==Math.sign(l[0])&&Math.abs(l[1]-o[1])<20?(s[0]=.95*m*((F?r:!r)?1:-1),F=!0):(s[0]=.95*m*((F?!r:r)?1:-1),F=!1),[e,n,s]}),F=!1,V.selectAll(".sota-pieChart-label").data(c).join("text").attr("class","sota-pieChart-label sota-num-label").text((t,a)=>s(e[a])).attr("alignment-baseline","central").attr("dominant-baseline","central").attr("transform",(t,a)=>{const e=E.centroid(t),n=a>0&&E.centroid(c[a-1]),s=(t.endAngle+t.startAngle)/2<Math.PI;return a>0&&Math.sign(e[0])==Math.sign(n[0])&&Math.abs(n[1]-e[1])<20?(e[0]=.99*m*((F?s:!s)?1:-1),F=!0):(e[0]=.99*m*((F?!s:s)?1:-1),F=!1),a==c.length-1&&(F=!1),"translate("+e+")"}).style("text-anchor",(t,a)=>{const e=E.centroid(t),n=a>0&&E.centroid(c[a-1]),s=(t.endAngle+t.startAngle)/2<Math.PI;if(a>0&&Math.sign(e[0])==Math.sign(n[0])&&Math.abs(n[1]-e[1])<20){const t=(F?s:!s)?"start":"end";return F=!0,t}{const t=(F?!s:s)?"start":"end";return F=!1,t}});const Y=2*m*.8+h+u.top+u.bottom;z.style("width",S+2*j+"px").attr("height",Y).style("margin-left",-j+"px"),i(L.node())})},lineGraph:function({dataFile:a,selector:n=!1,title:o=!1,subtitle:r=!1,section:c=!1,inputIsPercentage:h=!1,minVal:d=null,maxVal:g=null,height:p=300,margin:m={top:20,bottom:20,left:24,right:0}}){const x=e.separatorStrokeWidth,u=e.overflowOffset,{container:f,svg:b,tooltip:w,width:v,mainWidth:y,mainChart:B}=l(n,c,o,r,m,u);t.csv(a+".csv").then(a=>{const e=a.map(t=>t.label),o=a.map(t=>+t.value);if(null==d)d=h?0:t.min(a,t=>t.value);else if(1==d)d=t.min(a,t=>t.value);else if(isNaN(d)||""==d)throw"invalid minVal for graph on "+n;if(null==g)g=h?100:t.max(a,t=>t.value);else if(1==g)g=t.max(a,t=>t.value);else if(isNaN(g)||""==g)throw"invalid maxVal for graph on "+n;const l=t.scaleBand().domain(e.map(t=>t)).range([0,y]),r=t.scaleLinear().domain([d,g]).range([p-m.bottom,m.top]);B.append("g").attr("class","sota-gen-axis sota-gen-xAxis sota-text-axis").call(t.axisBottom(l).ticks(a.length).tickSize(-8)).style("transform","translateY("+(p-m.bottom)+"px)"),B.append("g").attr("class","sota-gen-axis sota-gen-YAxis sota-num-axis").call(t.axisLeft(r).tickSize(-8)),B.selectAll(".sota-lineGraph-path").data([o]).join("path").attr("class","sota-lineGraph-path").attr("d",t.line().x((t,a)=>l(e[a])+l.bandwidth()/2).y(t=>r(t))).attr("fill","none").attr("stroke","#bbb").style("stroke-width",3),B.selectAll(".sota-lineGraph-circle").data(o).join("circle").attr("class","sota-lineGraph-circle").attr("cx",(t,a)=>l(e[a])+l.bandwidth()/2).attr("cy",t=>r(t)).attr("r",4).attr("stroke","white").style("stroke-width",x).on("mouseover",(function(a,n){t.select(this).attr("opacity",.8),w.style("opacity",1).html(`<span class="sota-tooltip-label">${e[n]}</span><br/>Value: `+(h?s(a):a)+"</span>").style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")})).on("mousemove",a=>{w.style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")}).on("mouseout",(function(a){t.select(this).attr("opacity",1),w.style("opacity",0)})),B.selectAll(".sota-lineGraph-label").data(o).join("text").attr("class","sota-lineGraph-label sota-num-label").text((t,a)=>{if(h)return t+"%"}).attr("x",(t,a)=>l(e[a])+l.bandwidth()/2).attr("y",t=>r(t)-16).style("text-anchor","middle"),b.style("width",v+2*u+"px").attr("height",p).style("margin-left",-u+"px"),i(f.node())})},stackedBarChart:function({dataFile:a,selector:n=!1,title:o=!1,subtitle:r=!1,section:h=!1,inputIsPercentage:d=!1,showXAxis:g=!0,labelStyle:p="onBar",groupLabelStyle:m="none",showLegend:x=!0,margin:u=e.margin,customColors:f=!1}){const b=e.separatorStrokeWidth,w=e.barHeight,v=e.barMargin,y=e.overflowOffset,B=e.groupLabelMargin,k=e.labelLeft,C=e.labelBelow,$=e.lineColor,A=e.swatch.between,j=e.swatch.right,L=e.swatch.width,z=e.swatch.height,M=e.swatch.belowBetween,S=e.swatch.below,N=e.xAxisTop,{container:P,svg:I,tooltip:W,width:V,mainWidth:O,mainChart:E}=l(n,h,o,r,u,y);t.csv(a+".csv").then(a=>{let e=w+v,n=a.length*e,o=0;"onBar"==m&&(e+=a.length*B,n+=a.length*B,o=B);const l=a.columns.slice(1),r=t.map(a,t=>t.group).keys(),h=c();if(f){if(f.length!==l.length)throw"Invalid custom colors array. Custom colors array must have exactly as many elements as value groups in the data.";let t="";for(let a in f)t+=`.sota-fill-${h}-${+a+1} { fill: ${f[a]} }`;P.append("style").html(t)}let F=[];d?a.forEach(t=>{let a=0,e=[];for(let n of l){let s=+t[n];e.push([s,a]),a+=s}F.push(e)}):a.forEach(a=>{let e=0,n=t.sum(l,t=>+a[t]),s=[];for(let t of l){let o=+a[t]/n*100;s.push([o,e,+a[t]]),e+=o}F.push(s)});const Y=t.scaleBand().domain(r).range([0,n]).padding([.2]),H=t.scaleLinear().domain([0,100]).range([0,O]),G=t.scaleOrdinal().domain(l).range(t.map(l,(t,a)=>"sota-fill-"+(f?h+"-":"")+(l.length>3||f?a+1:2*a+1)).keys());g&&(E.append("g").attr("class","sota-gen-axis sota-gen-xAxis sota-num-axis").call(t.axisBottom(H).ticks(a.length).tickSize(-8)).attr("transform","translate(0 "+(n+N)+")"),n+=20+N);var X=0;if(x){let a=[];const e=I.append("g").lower().attr("class","sota-gen-legend").attr("transform",`translate(0 ${u.top})`);if(e.selectAll("nothing").data(l).enter().append("text").attr("class","sota-gen-legend-text").text(t=>t).attr("x",(function(){a.push(this.getBBox().width)})).remove(),t.sum(a,t=>t)+l.length*(L+A)+(l.length-1)*j>O){let n=V+y-t.max(a)-L-A;e.selectAll(".sota-gen-legend-swatch").data(l).join("rect").attr("class",t=>"sota-gen-legend-swatch "+G(t)).attr("x",n).attr("y",(t,a)=>(z+M)*a).attr("width",L).attr("height",z),e.selectAll(".sota-gen-legend-text").data(l).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",n+L+A).attr("y",(t,a)=>(z+M)*a+z/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),X=l.length*z+(l.length-1)*M+S}else{let n=V+y-(t.sum(a,t=>t)+l.length*(L+A)+(l.length-1)*j);e.selectAll(".sota-gen-legend-swatch").data(l).join("rect").attr("class",t=>"sota-gen-legend-swatch "+G(t)).attr("x",(e,s)=>n+s*(L+A+j)+t.sum(a.slice(0,s),t=>t)).attr("y",0).attr("width",L).attr("height",z),e.selectAll(".sota-gen-legend-text").data(l).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",(e,s)=>n+s*(L+A+j)+L+A+t.sum(a.slice(0,s),t=>t)).attr("y",z/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),X=z+S}}const R=E.selectAll(".sota-stackedBarChart-group").data(F).join("g").attr("class","sota-stackedBarChart-group").attr("transform",(t,a)=>"translate(0 "+(Y(r[a])+o-v)+")");R.selectAll(".sota-stackedBarChart-bar").data(t=>t).join("rect").attr("class",(t,a)=>"sota-stackedBarChart-bar "+G(a)).attr("x",t=>H(t[1])).attr("y",0).attr("width",t=>H(t[0])).attr("height",w).on("mouseover",(function(a,e){t.select(this).attr("opacity",.8),W.style("opacity",1).html(()=>{let t=`<span class="sota-text-label"><span class="sota-heavy-label">${l[e]}</span><br/>Percentage: ${s(a[0])}`;return d||(t+="<br/>Number of responses: "+a[2]),t+="</span>",t}).style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")})).on("mousemove",()=>{W.style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")}).on("mouseout",(function(a){t.select(this).attr("opacity",1),W.style("opacity",0)})),R.selectAll(".sota-stackedBarChart-separator").data(t=>t).join("rect").attr("class","sota-stackedBarChart-separator").attr("fill","white").attr("x",t=>H(t[1])+H(t[0])).attr("y",0).attr("width",t=>t[0]>0?b:0).attr("height",w),"onBar"==m&&E.selectAll(".sota-stackedBarChart-groupLabel-onBar").data(r).join("text").attr("class","sota-stackedBarChart-groupLabel-onBar sota-text-label sota-heavy-label").text(t=>t).attr("alignment-baseline","bottom").attr("dominant-baseline","bottom").attr("x",0).attr("y",t=>Y(t));var T=0;if("onBar"==p)R.selectAll(".sota-stackedBarChart-label-onBar").data(t=>t).join("text").attr("class","sota-stackedBarChart-label-onBar sota-num-label").text(a=>t.format(".1f")(a[0])+"%").attr("alignment-baseline","central").attr("dominant-baseline","central").attr("text-anchor","end").attr("x",t=>H(t[1])+H(t[0])-k).attr("y",w/2).style("display",(function(t,a){return this.getBBox().x<(a>0?H(t[1]):u.left)?"none":""}));else if("aboveBar"==p){var D=[];R.selectAll(".sota-stackedBarChart-label-aboveBar-text").data(t=>t).join("text").attr("class","sota-stackedBarChart-label-aboveBar-text sota-num-label").text((a,e)=>`${l[e]}: ${t.format(".1f")(a[0])}%`).attr("x",t=>H(t[1])+H(t[0])/2).attr("y",(function(t){return D.push([this.getBBox().x,this.getBBox().width]),-2*C})).attr("alignment-baseline","bottom");let a=[];!function t(e){if(e==D.length-1)return a[e]=-2,-2;if(D[e][0]+D[e][1]+k>D[e+1][0]){D[e+1][0]=D[e][0]+D[e][1]+k;let n=t(e+1)-1;return a[e]=n,n}return t(e+1),a[e]=-2,-2}(0),R.selectAll(".sota-stackedBarChart-label-aboveBar-line").data(t=>t).join("polyline").attr("class","sota-stackedBarChart-label-aboveBar-line").attr("points",(t,e)=>{let n=H(t[1])+H(t[0])/2,s=w/2,o=n,l=(a[e]+1)*C;return`${n},${s} ${o},${l} ${D[e][0]+D[e][1]},${l}`}).attr("stroke-width",b).attr("stroke",$).attr("fill","none"),R.selectAll(".sota-stackedBarChart-label-aboveBar-text").data(t=>t).join("text").attr("x",(t,a)=>D[a][0]).attr("y",(t,e)=>a[e]*C),T=-1*t.min(a)*C+20}const q=n+u.top+u.bottom+X+T;I.style("width",V+2*y+"px").attr("height",q).style("margin-left",-y+"px"),E.attr("transform",`translate(${y} ${u.top+X+T})`).attr("width",O),i(P.node())})},customBarChart:function({dataFile:a,selector:n=!1,title:h=!1,subtitle:d=!1,section:g=!1,shapeFile:p,shapeWidth:m=300,inputIsPercentage:x=!1,margin:u=e.margin}){const{container:f,svg:b,tooltip:w,width:v,mainWidth:y,mainChart:B}=l(n,g,h,d,u,0),k=e.separatorStrokeWidth,C=e.labelLeft,$=e.labelBelow,A=e.lineColor;t.xml(p+".svg").then(e=>{let n=document.importNode(e.documentElement,!0),l=t.select(n).select("path").node(),h=0,d=0;b.append(()=>l).attr("class",(function(){return h=this.getBBox().width,d=this.getBBox().height,""})).remove();let g=m/h,p=d*g;const v=c();b.append("defs").append("clipPath").attr("id","shapeDef"+v).append(()=>l).attr("transform",`scale(${g})`),t.csv(a+".csv").then(a=>{const[e,n,l]=r(a,x);let i=0,c=[];for(let t of a)c.push(i),i+=+t.value;const h=t.scaleLinear().domain([0,t.sum(a,t=>+t.value)]).range([0,m]),d=t.scaleOrdinal().domain(t.map(a,t=>t.label)).range(t.map(a,(t,a)=>"sota-fill-"+(a+1)).keys());B.selectAll(".sota-customBarChart-bar").data(a).join("rect").attr("class",t=>"sota-customBarChart-bar "+d(t.label)).attr("x",(t,a)=>h(c[a])).attr("y",0).attr("width",t=>h(t.value)).attr("height",p).attr("clip-path","url(#shapeDef"+v+")").call(o,w,e,l,n),B.selectAll(".sota-customBarChart-separator").data(a).join("rect").attr("class","sota-customBarChart-separator").attr("x",(t,a)=>0==a?-k:h(c[a])).attr("y",0).attr("width",k).attr("height",p).attr("fill","white").attr("clip-path","url(#shapeDef"+v+")");var g=[];B.selectAll(".sota-customBarChart-label-aboveBar-text").data(a).join("text").attr("class","sota-customBarChart-label-aboveBar-text").html((t,a)=>`<tspan class="sota-text-label sota-heavy-label">${t.label}:</tspan><tspan class="sota-num-label"> ${s(e[a])}</tspan>`).attr("x",(t,a)=>h(c[a])+h(t.value)/2+C).attr("y",(function(t){return g.push([this.getBBox().x,this.getBBox().width]),p+3*$})).attr("alignment-baseline","top");let f=[];!function t(a){if(a==g.length-1)return f[a]=3,3;if(g[a][0]+g[a][1]+2*C>g[a+1][0]){g[a+1][0]=g[a][0]+g[a][1]+2*C;let e=t(a+1)+1;return f[a]=e,e}return t(a+1),f[a]=3,3}(0),B.selectAll(".sota-customBarChart-label-aboveBar-line").data(a).join("polyline").attr("class","sota-customBarChart-label-aboveBar-line").attr("points",(t,a)=>{let e=h(c[a])+h(t.value)/2,n=p/2,s=e,o=p+(f[a]+1)*$;return`${e},${n} ${s},${o} ${g[a][0]+g[a][1]},${o}`}).attr("stroke-width",k).attr("stroke",A).attr("fill","none"),B.selectAll(".sota-customBarChart-label-aboveBar-text").data(a).join("text").attr("x",(t,a)=>g[a][0]).attr("y",(t,a)=>p+f[a]*$);let y=t.max(f)*$+20,j=p+u.top+u.bottom+y;b.attr("height",j),B.attr("transform",`translate(${u.left} ${u.top})`)}),i(f.node())})},columnChart:function({dataFile:a,selector:n=!1,title:s=!1,subtitle:c=!1,section:h=!1,inputIsPercentage:d=!1,displayPercentage:g=!0,totalResp:p=null,maxVal:m=null,minVal:x=null,mainHeight:u=e.mainHeight,showLegend:f=!1,margin:b={top:20,bottom:20,left:24,right:0}}){const w=e.overflowOffset,v=e.tickSize,y=e.labelAngle,B=e.swatch.between,k=e.swatch.right,C=e.swatch.width,$=e.swatch.height,A=e.swatch.belowBetween,j=e.swatch.below,{container:L,svg:z,tooltip:M,width:S,mainWidth:N,mainChart:P}=l(n,h,s,c,b,w);t.csv(a+".csv").then(a=>{const[e,s,l]=r(a,d,p),c=g||d?e:s;if(null===x)x=d||g?0:t.min(c);else if(!0===x)x=t.min(c);else if(isNaN(x)||""===x)throw"invalid minVal for graph on "+n;if(null===m)m=d||g?100:t.max(c);else if(!0===m)m=t.max(c);else if(isNaN(m)||""===m)throw"invalid maxVal for graph on "+n;const h=t.scaleBand().domain(l).range([0,N]).padding([.3]),I=t.scaleLinear().domain([x,m]).range([u,0]),W=t.scaleOrdinal().domain(l).range(t.map(l,(t,a)=>"sota-fill-"+(a+1)).keys());let V,O=0,E=!1;if(f){let e=[];const n=z.append("g").lower().attr("class","sota-gen-legend").attr("transform",`translate(0 ${b.top})`);if(n.selectAll("nothing").data(a).enter().append("text").attr("class","sota-gen-legend-text").text(t=>t.label).attr("x",(function(){e.push(this.getBBox().width)})).remove(),t.sum(e,t=>t)+e.length*B+(e.length-1)*k>N){let a=S-t.max(e)-C-B;n.selectAll(".sota-gen-legend-swatch").data(l).join("rect").attr("class",t=>"sota-gen-legend-swatch "+W(t)).attr("x",a).attr("y",(t,a)=>($+A)*a).attr("width",C).attr("height",$),n.selectAll(".sota-gen-legend-text").data(l).join("text").attr("class","sota-gen-legend-text sota-text-label").text(t=>t).attr("x",a+C+B).attr("y",(t,a)=>($+A)*a+$/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),O=l.length*$+(l.length-1)*A+j}else{let a=S-(t.sum(e,t=>t)+l.length*(C+B)+(l.length-1)*k);n.selectAll(".sota-gen-legend-swatch").data(l).join("rect").attr("class",t=>"sota-gen-legend-swatch "+W(t)).attr("x",(n,s)=>a+s*(C+B+k)+t.sum(e.slice(0,s),t=>t)).attr("y",0).attr("width",C).attr("height",$),n.selectAll(".sota-gen-legend-text").data(l).join("text").attr("class","sota-gen-legend-text sota-text-label").text(t=>t).attr("x",(n,s)=>a+s*(C+B+k)+C+B+t.sum(e.slice(0,s),t=>t)).attr("y",$/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),O=$+j}}else{V=P.append("g").attr("class","sota-gen-axis sota-gen-xAxis sota-text-axis").call(t.axisBottom(h).tickSize(0)).attr("transform",`translate(0 ${u})`);const a=V.selectAll("text"),e=a.nodes();for(let t in e){if(t==e.length-1)continue;let a=e[+t].getBBox(),n=e[+t+1].getBBox();if(a.x+a.width>n.x){E=!0;break}}E&&a.attr("text-anchor","end").style("transform",`translateY(4px) rotate(-${y}deg)`).node().classList.add("angled-label")}P.append("g").attr("class","sota-gen-axis sota-gen-yAxis sota-num-axis").call(t.axisLeft(I).tickSize(-v));if(P.selectAll(".sota-columnChart-bar").data(c).join("rect").attr("class",(t,a)=>{let e="sota-columnChart-bar sota-gen-bar";return e+=f?" "+W(l[a]):"",e}).attr("x",(t,a)=>h(l[a])).attr("y",t=>I(t)).attr("width",h.bandwidth()).attr("height",t=>u-I(t)).call(o,M,e,l,s),f)u+=O;else if(E){let a=[];const e=V.select("text").node().getBBox(),n=e.y,s=e.height;V.selectAll("text").each((function(){a.push(this.getBBox().width)}));const o=t.max(a)*Math.sin(y*Math.PI/180),l=s*Math.cos(y*Math.PI/180);u+=n+o+l}else{let a=[];V.selectAll("text").each((function(){a.push(this.getBBox().y+this.getBBox().height)})),u+=+t.max(a)}let F=u+b.top+b.bottom;z.style("width",S+2*w+"px").attr("height",F).style("margin-left",-w+"px"),P.attr("transform",`translate(${b.left+w} ${b.top+O})`).attr("width",N),i(L.node())})},groupedBarChart:function({dataFile:a,selector:n=!1,title:o=!1,subtitle:r=!1,section:c=!1,totalResp:h=null,inputIsPercentage:d=!1,displayPercentage:g=!0,minVal:p=0,maxVal:m=null,margin:x=e.margin}){const u=e.groupedBarChart.barHeight,f=e.groupedBarChart.barMargin,b=e.overflowOffset,w=e.groupLabelMargin,v=(e.swatch.between,e.swatch.right,e.swatch.width,e.swatch.height,e.swatch.belowBetween,e.swatch.below,e.xAxisTop),{container:y,svg:B,tooltip:k,width:C,mainWidth:$,mainChart:A}=l(n,c,o,r,x,b);t.csv(a+".csv").then(a=>{window.wow=a;const e=a.columns.splice(1),o=t.map(a,t=>t.group).keys(),l=t.map(a,a=>{let n=[];for(let t of e)n.push(+a[t]);return t.max(n)}).keys(),r=t.max(l,t=>+t);if(null==m)m=d||g?100:r;else if(isNaN(m)||""===m)throw"invalid maxVal for graph on "+n;const c=u+f,j=c*e.length;let L=(j+w)*a.length;const z=t.scaleLinear().domain([p,m]).range([0,$]),M=t.scaleOrdinal().domain(t.map(a,t=>t.group)).range(t.map(a,(t,a)=>(j+w)*a).keys()),S=t.scaleOrdinal().domain(e).range(t.map(e,(t,a)=>c*a).keys());A.append("g").attr("class","sota-gen-axis sota-gen-xAxis sota-groupedBarChart-xAxis sota-num-axis").call(t.axisBottom(z).tickSize(-(L+v))).attr("transform","translate(0 "+(L+v)+")");L+=20+v;const N=A.selectAll(".sota-groupedBarChart-group").data(a).join("g").attr("class","sota-groupedBarChart-group").attr("transform",(t,a)=>`translate(0 ${M(t.group)})`),P=t.scaleOrdinal().domain(e).range(t.map(e,(t,a)=>"sota-fill-"+(a+1)).keys());N.selectAll(".sota-gen-bar").data(t=>{let a=[];for(let n of e)a.push(+t[n]);return a}).join("rect").attr("class",(t,a)=>"sota-gen-bar "+P(e[a])).attr("y",(t,a)=>+S(e[a])+ +w).attr("x",0).attr("width",(t,a)=>z(d?t:t/h[e[a]]*100)).attr("height",u).on("mouseover",(function(a,n){t.select(this).attr("opacity",.8),k.style("opacity",1).html(()=>{let t=`<span class="sota-text-label"><span class="sota-heavy-label">${e[n]}</span><br/>Percentage: ${s(d?a:a/h[e[n]]*100)}`;return d||(t+="<br/>Number of responses: "+a),t+="</span>",t}).style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")})).on("mousemove",()=>{k.style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")}).on("mouseout",(function(a){t.select(this).attr("opacity",1),k.style("opacity",0)})),A.selectAll(".sota-gen-groupLabel").data(o).join("text").attr("class","sota-gen-groupLabel sota-text-label sota-heavy-label").text(t=>t).attr("alignment-baseline","bottom").attr("x",0).attr("y",t=>+M(t)+ +w).attr("transform","translate(0 -8)");let I=L+x.top+x.bottom;B.style("width",C+2*b+"px").attr("height",I).style("margin-left",-b+"px"),A.attr("transform",`translate(${x.left+b} ${x.top})`).attr("width",$),i(y.node())})},stackedColumnChart:function({dataFile:a,selector:n=!1,title:o=!1,subtitle:r=!1,section:c=!1,inputIsPercentage:h=!1,displayPercentage:d=!0,maxVal:g=null,minVal:p=null,mainHeight:m=e.mainHeight,margin:x={top:20,bottom:20,left:24,right:0}}){const u=e.tickSize,f=e.separatorStrokeWidth,b=e.overflowOffset,w=e.labelAngle,v=e.swatch.between,y=e.swatch.right,B=e.swatch.width,k=e.swatch.height,C=e.swatch.belowBetween,$=e.swatch.below,{container:A,svg:j,tooltip:L,width:z,mainWidth:M,mainChart:S}=l(n,c,o,r,x,0);t.csv(a+".csv").then(a=>{const e=a.columns.slice(1),o=t.map(a,t=>t.group).keys();var l=[];h?a.forEach(t=>{let a=0,n=[];for(let s of e){let e=+t[s];n.push([e,a]),a+=e}l.push(n)}):a.forEach(a=>{let n=0,s=t.sum(e,t=>+a[t]),o=[];for(let t of e){let e=+a[t]/s*100;o.push([e,n,+a[t]]),n+=e}l.push(o)});const r=d||h?l:a.map(t=>+t.value);if(null===p)p=h||d?0:t.min(r);else if(!0===p)p=t.min(r);else if(isNaN(p)||""===p)throw"invalid minVal for graph on "+n;if(null===g)g=h||d?100:t.max(r);else if(!0===g)g=t.max(r);else if(isNaN(g)||""===g)throw"invalid maxVal for graph on "+n;const c=t.scaleBand().domain(o).range([0,M]).padding([.3]),N=t.scaleLinear().domain([p,g]).range([m,0]),P=t.scaleOrdinal().domain(e).range(t.map(e,(t,a)=>"sota-fill-"+(e.length>3?a+1:2*a+1)).keys()),I=(S.append("g").attr("class","sota-gen-axis sota-gen-yAxis sota-num-axis").call(t.axisLeft(N).tickSize(-u)),S.append("g").attr("class","sota-gen-axis sota-gen-xAxis sota-text-axis").call(t.axisBottom(c).tickSize(0)).attr("transform",`translate(0 ${m})`));let W=!1;const V=I.selectAll("text"),O=V.nodes();for(let t in O){if(t==O.length-1)continue;let a=O[+t].getBBox(),e=O[+t+1].getBBox();if(a.x+a.width>e.x){W=!0;break}}W&&V.attr("text-anchor","end").style("transform",`translateY(4px) rotate(-${w}deg)`).node().classList.add("angled-label");let E=0,F=[];const Y=j.append("g").lower().attr("class","sota-gen-legend").attr("transform",`translate(0 ${x.top})`);if(Y.selectAll("nothing").data(e).enter().append("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",(function(){F.push(this.getBBox().width)})).remove(),t.sum(F,t=>t)+F.length*(B+v)+(F.length-1)*y>M){let a=z+b-t.max(F)-B-v;Y.selectAll(".sota-gen-legend-swatch").data(e).join("rect").attr("class",t=>"sota-gen-legend-swatch "+P(t)).attr("x",a).attr("y",(t,a)=>(k+C)*a).attr("width",B).attr("height",k),Y.selectAll(".sota-gen-legend-text").data(e).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",a+B+v).attr("y",(t,a)=>(k+C)*a+k/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),E=e.length*k+(e.length-1)*C+$}else{let a=z+b-(t.sum(F,t=>t)+e.length*(B+v)+(e.length-1)*y);Y.selectAll(".sota-gen-legend-swatch").data(e).join("rect").attr("class",t=>"sota-gen-legend-swatch "+P(t)).attr("x",(e,n)=>a+n*(B+v+y)+t.sum(F.slice(0,n),t=>t)).attr("y",0).attr("width",B).attr("height",k),Y.selectAll(".sota-gen-legend-text").data(e).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",(e,n)=>a+n*(B+v+y)+B+v+t.sum(F.slice(0,n),t=>t)).attr("y",k/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),E=k+$}const H=S.selectAll(".sota-stackedColumnChart-group").data(l).join("g").attr("class","sota-stackedColumnChart-group").attr("transform",(t,a)=>"translate("+c(o[a])+" 0)");if(H.selectAll(".sota-stackedColumnChart-bar").data(t=>t).join("rect").attr("class",(t,a)=>"sota-stackedColumnChart-bar "+P(a)).attr("x",0).attr("y",t=>N(t[0]+t[1])).attr("width",c.bandwidth()).attr("height",t=>m-N(t[0])).on("mouseover",(function(a,n){t.select(this).attr("opacity",.8),L.style("opacity",1).html(()=>{let t=`<span class="sota-text-label"><span class="sota-heavy-label">${e[n]}</span><br/>Percentage: ${s(a[0])}`;return h||(t+="<br/>Number of responses: "+a[2]),t+="</span>",t}).style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")})).on("mousemove",()=>{L.style("left",t.event.pageX+"px").style("top",t.event.pageY+"px")}).on("mouseout",(function(a){t.select(this).attr("opacity",1),L.style("opacity",0)})),H.selectAll(".sota-stackedColumnChart-separator").data(t=>t).join("rect").attr("class","sota-stackedColumnChart-separator").attr("fill","white").attr("x",0).attr("y",(t,a)=>N(t[0])+N(t[1])-m).attr("height",t=>t[0]>0?f:0).attr("width",c.bandwidth()),m+=E,W){let a=[];const e=I.select("text").node().getBBox(),n=e.y,s=e.height;I.selectAll("text").each((function(){a.push(this.getBBox().width)}));const o=t.max(a)*Math.sin(w*Math.PI/180),l=s*Math.cos(w*Math.PI/180);m+=n+o+l}else{let a=[];I.selectAll("text").each((function(){a.push(this.getBBox().y+this.getBBox().height)})),m+=+t.max(a)}let G=m+x.top+x.bottom+E;j.style("width",z+2*b+"px").attr("height",G).style("margin-left",-b+"px"),S.attr("transform",`translate(${x.left+b} ${x.top+E})`).attr("width",M),i(A.node())})},customColumnChart:function({dataFile:a,selector:n=!1,title:h=!1,subtitle:d=!1,section:g=!1,shapeFile:p,shapeHeight:m=300,inputIsPercentage:x=!1,margin:u=e.margin}){const{container:f,svg:b,tooltip:w,width:v,mainWidth:y,mainChart:B}=l(n,g,h,d,u,0),k=e.separatorStrokeWidth,C=e.labelBelow,$=e.lineColor;t.xml(p+".svg").then(e=>{let n=document.importNode(e.documentElement,!0),l=t.select(n).select("path").node(),h=0,d=0;b.append(()=>l).attr("class",(function(){return h=this.getBBox().width,d=this.getBBox().height,""})).remove();let g=m/d,p=h*g;const A=c();b.append("defs").append("clipPath").attr("id","shapeDef"+A).append(()=>l).attr("transform",`scale(${g})`),t.csv(a+".csv").then(a=>{const[e,n,l]=r(a,x);let c=0,h=[];for(let t of a)h.push(c),c+=+t.value;const d=t.scaleLinear().domain([0,t.sum(a,t=>+t.value)]).range([0,m]),g=t.scaleOrdinal().domain(l).range(t.map(l,(t,a)=>"sota-fill-"+(a+1)).keys());B.selectAll(".sota-customColumnChart-bar").data(a).join("rect").attr("class",t=>"sota-customColumnChart-bar "+g(t.label)).attr("x",0).attr("y",(t,a)=>d(h[a])).attr("width",p).attr("height",t=>d(t.value)).attr("clip-path","url(#shapeDef"+A+")").call(o,w,e,l,n),B.selectAll(".sota-customColumnChart-separator").data(a).join("rect").attr("class","sota-customColumnChart-separator").attr("x",0).attr("y",(t,a)=>0==a?-k:d(h[a])).attr("width",p).attr("height",k).attr("fill","white").attr("clip-path","url(#shapeDef"+A+")"),B.selectAll(".sota-customColumnChart-label-line").data(a).join("polyline").attr("class","sota-customColumnChart-label-line").attr("points",(t,a)=>{const e=p/2,n=(d(h[a])+d(t.value))/2;return`${e},${n} ${y},${n}`}).attr("stroke-width",k).attr("stroke",$).attr("fill","none"),B.selectAll(".sota-customColumnChart-label-text").data(a).join("text").html((t,a)=>`<tspan class="sota-text-label sota-heavy-label">${t.label}:</tspan><tspan class="sota-num-label"> ${s(e[a])}</tspan>`).attr("text-anchor","end").attr("alignment-baseline","bottom").attr("dominant-baseline","bottom").attr("x",y).attr("y",(t,a)=>(d(h[a])+d(t.value))/2-C);const j=m+u.top+u.bottom;b.attr("height",j),B.attr("transform",`translate(${u.left} ${u.top})`).attr("width",v-u.left-u.right),i(f.node())})})},multiLineGraph:function({dataFile:a,selector:n=!1,title:s=!1,subtitle:o=!1,section:r=!1,minVal:c,maxVal:h,height:d=300,showLegend:g=!0,inputIsPercentage:p=!1,displayPercentage:m=!0,margin:x={top:20,bottom:20,left:24,right:0}}){const u=e.overflowOffset,f=e.swatch.between,b=e.swatch.right,w=e.swatch.width,v=e.swatch.height,y=e.swatch.belowBetween,B=e.swatch.below,{container:k,svg:C,tooltip:$,width:A,mainWidth:j,mainChart:L}=l(n,r,s,o,x,u),z=d-x.top-x.bottom;t.csv(a+".csv").then(a=>{const e=a.columns.slice(1),s=t.map(a,t=>t.group).keys();let o=[],l=[],r=[],$=[],M=[];if(p)for(const e of a){let a=[];for(const t in e)"group"!==t&&a.push(+e[t]);l.push(t.max(a,t=>t[0])),r.push(t.min(a,t=>t[0])),o.push(a)}else for(const n of a){const a=t.sum(e,t=>+n[t]),s=[];for(const t in n){if("group"===t)continue;const e=+n[t]/a*100;s.push([e,+n[t]])}l.push(t.max(s,t=>t[1])),r.push(t.min(s,t=>t[1])),$.push(t.max(s,t=>t[0])),M.push(t.min(s,t=>t[0])),o.push(s)}if(null==c)c=p||m?0:t.min(r);else if(!0===c)c=t.min(M);else if(isNaN(c)||""===c)throw"invalid minVal for graph on "+n;if(null==h)h=p||m?100:t.max(l);else if(!0===h)h=t.max($);else if(isNaN(h)||""===h)throw"invalid maxVal for graph on "+n;const S=t.scaleBand().domain(e).range([0,j]),N=t.scaleLinear().domain([c,h]).range([z,0]),P=t.scaleOrdinal().domain(s).range(t.map(s,(t,a)=>"sota-fill-"+(s.length>3?a+1:2*a+1)).keys()),I=t.scaleOrdinal().domain(s).range(t.map(s,(t,a)=>"sota-stroke-"+(s.length>3?a+1:2*a+1)).keys());let W=0;if(g){let a=[];const e=C.append("g").lower().attr("class","sota-gen-legend").attr("transform",`translate(0 ${x.top})`);if(e.selectAll("nothing").data(s).enter().append("text").attr("class","sota-gen-legend-text").text(t=>t).attr("x",(function(){a.push(this.getBBox().width)})).remove(),t.sum(a,t=>t)+s.length*(w+f)+(s.length-1)*b>j){let n=A+u-t.max(a)-w-f;e.selectAll(".sota-gen-legend-swatch").data(s).join("rect").attr("class",t=>"sota-gen-legend-swatch "+P(t)).attr("x",n).attr("y",(t,a)=>(v+y)*a).attr("width",w).attr("height",v),e.selectAll(".sota-gen-legend-text").data(s).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",n+w+f).attr("y",(t,a)=>(v+y)*a+v/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),W=s.length*v+(s.length-1)*y+B}else{let n=A+u-(t.sum(a,t=>t)+s.length*(w+f)+(s.length-1)*b);e.selectAll(".sota-gen-legend-swatch").data(s).join("rect").attr("class",t=>"sota-gen-legend-swatch "+P(t)).attr("x",(e,s)=>n+s*(w+f+b)+t.sum(a.slice(0,s),t=>t)).attr("y",0).attr("width",w).attr("height",v),e.selectAll(".sota-gen-legend-text").data(s).join("text").attr("class","sota-gen-legend-text sota-text-label sota-heavy-label").text(t=>t).attr("x",(e,s)=>n+s*(w+f+b)+w+f+t.sum(a.slice(0,s),t=>t)).attr("y",v/2).attr("alignment-baseline","central").attr("dominant-baseline","central"),W=v+B}}L.append("g").attr("class","sota-gen-axis sota-gen-xAxis sota-text-axis").call(t.axisBottom(S).ticks(a.length).tickSize(-8)).style("transform","translateY("+z+"px)"),L.append("g").attr("class","sota-gen-axis sota-gen-yAxis sota-num-axis").call(t.axisLeft(N).tickSize(-8)),L.selectAll(".sota-multiLineGraph-group").data(o).join("g").attr("class",(t,a)=>"sota-multiLineGraph-group "+I(s[a])).selectAll(".sota-multiLineGraph-path").data(t=>[t]).join("path").attr("class","sota-multiLineGraph-path").attr("d",t.line().x((t,a)=>S(e[a])+S.bandwidth()/2).y(t=>N(t[0]))).attr("fill","none").style("stroke-width",3),C.style("width",A+2*u+"px").attr("height",d+W+"px").style("margin-left",-u+"px"),L.attr("transform",`translate(${x.left+u} ${x.top+W})`).attr("width",j),i(k.node())})},bigNumber:function({title:a,number:e,subtitle:n,selector:s=!1,section:o=!1}){if(!s&&!o)throw`No selector or section specified for chart with "${a}" title parameter.`;const l=s?t.select(s):t.select(`#sota-section-${o} .sota-section-inner`).append("div").attr("class","sota-module");l.append("h3").text(a),l.append("div").attr("class","sota-big").append("span").text(e),l.append("div").attr("class","sota-subtitle").append("span").text(n)},contentModule:function({title:a,content:e,subtitle:n,selector:s=!1,section:o=!1}){if(!s&&!o)throw`No selector or section specified for chart with "${a}" title parameter.`;const l=s?t.select(s):t.select(`#sota-section-${o} .sota-section-inner`).append("div").attr("class","sota-module");l.append("h3").text(a),l.append("div").attr("class","sota-subtitle").append("span").text(n),l.append("div").html(e)},setColors:function(t){let a="";for(const e of t.sections){const t=e.slug;a+=`\n #sota-section-${t}{\n background-color: ${e.colors[0]};\n color: ${e.colors[0]};\n }\n #sota-section-${t} .sota-gen-bar, .sota-section-${t} .sota-gen-bar{\n fill: ${e.colors[3]};\n } \n #sota-navbar #sota-navbar-item-${t}:hover, #sota-navbar #sota-navbar-item-${t}.selected{\n background-color: ${e.colors[0]}; \n }\n @media (max-width: 1400px){\n #sota-navbar #sota-navbar-item-${t}{\n background-color: ${e.colors[0]}; \n } \n }\n `;for(const n in e.colors)a+=`\n #sota-section-${t} .sota-fill-${+n+1}, .sota-section-${t} .sota-fill-${+n+1}{\n fill: ${e.colors[n]};\n }\n #sota-section-${t} .sota-stroke-${+n+1}, .sota-section-${t} .sota-stroke-${+n+1}{\n stroke: ${e.colors[n]};\n }\n `}document.head.appendChild(document.createElement("style")).textContent=a},setStyles:function(t=t){const a=t.numberFont,e=t.labelFont,n=t.separatorStrokeWidth,s=t.lineColor,o="https://fonts.googleapis.com/css2?"+("family="+a.replace(" ","+")+":wght@400;700")+"&"+("family="+e.replace(" ","+")+":wght@400;700");let l=document.createElement("link");l.rel="stylesheet",l.href=o,document.head.appendChild(l);let r=`\n.sota-section {\n\tpadding: 48px 0;\n\twidth: 100%\n}\n\n.sota-section > p{\n color: #fff;\n font-family: ${e};\n line-height: 1.5;\n max-width: 800px;\n margin: 64px auto;\n padding: 0 24px;\n}\n\n.sota-section h1 {\n\tfont-size: 56px;\n\tfont-family: ${a}, sans-serif;\n\ttext-transform: uppercase;\n\tfont-weight: 700;\n\ttext-align: center;\n\tcolor: #fff\n}\n\n.sota-section-inner {\n position: relative;\n\tmax-width: 1500px;\n\tbox-sizing: border-box;\n\tfont-family: ${a}, Arial, sans-serif;\n\twidth: 100%;\n\tpadding: 48px 24px;\n\tmargin: 0 auto;\n\tbackground-color: #fff;\n\tgrid-template-columns: minmax(0, 1fr)\n}\n\n.sota-section-inner:not(.sota-content-section):before{\n pointer-events: none;\n content: "";\n position: absolute;\n left: 0;\n top: 32px;\n display: none;\n height: calc(100% - 64px);\n}\n\n.sota-section-inner:not(.sota-content-section):after{\n content: "";\n clear: both;\n display: table; \n}\n\n.sota-section .sota-module {\n\tposition: absolute;\n\tfloat: left;\n\twidth: calc(100% - 48px);\n\tborder-bottom: 1px solid rgba(0,0,0,0.2);\n\tpadding-bottom: 32px;\n\tmargin-bottom: 32px;\n}\n\n@media (min-width: 800px) {\n .sota-section-inner:not(.sota-content-section):before{\n width: 50%;\n display: block;\n border-right: 1px solid rgba(0,0,0,0.1);\n }\n \n .sota-section .sota-module {\n width: calc(50% - 48px);\n }\n}\n\n@media (min-width: 1200px) { \n .sota-section .sota-module {\n width: calc(33% - 48px);\n }\n\n .sota-section-inner:not(.sota-content-section):before{\n width: calc(33.3% - 6px);\n left: calc(33.3% - 6px);\n border-left: 1px solid rgba(0,0,0,0.1);\n }\n}\n\n.sota-module>svg {\n\twidth: 100%\n}\n\n.sota-module h3 {\n\tfont-family: ${a}, sans-serif;\n\tfont-weight: 700;\n\ttext-transform: uppercase;\n\tline-height: 1.1;\n}\n\n.sota-module p, ul, ol{\n font-size: 20px;\n line-height: 1.4;\n font-family: ${e};\n}\n\n.sota-module hr{\n opacity: 0.5;\n margin: 48px 0;\n}\n\n.sota-module img{\n max-width: 100%;\n margin: 32px 0;\n}\n\n.sota-module .sota-subtitle {\n\tfont-family: ${e}, serif;\n\topacity: 0.4;\n\tline-height: 1.1;\n}\n\n.sota-heavy-label{\n font-weight: 700;\n}\n\n.sota-num-label, .sota-num-axis .tick text{\n font-family: ${a}, sans-serif;\n font-size: 14px;\n fill: ${t.labelColor};\n}\n\n.sota-text-label, .sota-text-axis .tick text{\n font-family: ${e}, serif;\n fill: black;\n}\n\n.sota-num-label.sota-stackedBarChart-label-onBar{\n fill: rgba(255,255,255,0.6);\n}\n\n.sota-tooltip {\n\tbackground-color: #222;\n\tcolor: #fff;\n\tpadding: 12px;\n\tposition: absolute;\n\tpointer-events: none;\n\topacity: 0;\n\ttransform: translate(-50%, -100%);\n\twhite-space: nowrap\n}\n\n.sota-gen-axis{\n opacity: 0.4;\n}\n\n.sota-gen-axis.sota-gen-xAxis .tick text {\n\ttransform: translateY(4px);\n}\n\n.sota-gen-axis.sota-gen-yAxis .tick text {\n\ttransform: translateX(-8px);\n\ttext-anchor: end\n}\n\n.sota-gen-xAxis:not(.sota-text-axis) g.tick:first-of-type text:not(.angled-label){\n text-anchor: start;\n}\n\n.sota-gen-xAxis:not(.sota-text-axis) g.tick:last-of-type text:not(.angled-label){\n text-anchor: end;\n}\n\n.sota-gen-axis .tick line,\n.sota-gen-axis path.domain {\n\tstroke-width: ${n}px;\n\tstroke: ${s};\n}\n\n.sota-groupedBarChart-xAxis .tick line {\n\topacity: 0.2\n}\n\n.sota-big {\n\tfont-weight: 700;\n\tfont-size: 96px;\n\tline-height: 1.0;\n\tmargin-top: -8px;\n\tfont-family: ${e}, serif\n}\n\n.sota-section-inner.sota-hide .sota-module{\n border-bottom: none;\n}\n\n.sota-section-inner.sota-hide .sota-module > *{\n visibility: hidden;\n}\n\n.sota-section-inner:not(.sota-hide) .sota-loading{\n display: none;\n}\n\n#sota-navbar ~ .sota-section:before{\n content: "";\n z-index: 4;\n position: sticky;\n top: 64px;\n width: 100%;\n height: 8px;\n background-color: inherit;\n display: block;\n}\n\n#sota-navbar{\n color: #fff;\n}\n\n#sota-navbar .sz-navbar-item a, #sota-navbar .sz-navbar-item span{\n font-family: ${a};\n line-height: 64px;\n box-sizing: border-box;\n text-align: center;\n text-decoration: none;\n color: #fff;\n height: 64px;\n padding: 0 8px;\n display: block;\n}\n\n#sota-navbar .sota-navbar-logo, #sota-navbar .sota-navbar-logo a{\n height: 100%;\n display: flex;\n align-items: center;\n}\n\n#sota-navbar .sota-navbar-logo img{\n height: 50%;\n}\n\n@media (max-width: 1400px){\n #sota-navbar .sz-navbar-items{\n background-color: #000;\n z-index: 4;\n height: 100vh;\n box-sizing: border-box;\n justify-content: flex-start;\n }\n\n #sota-navbar div.sz-navbar-item{\n width: 100%;\n margin-bottom: 0;\n }\n \n #sota-navbar .sz-navbar-inner > .sota-navbar-text{\n display: none;\n }\n}\n\n@media (min-width: 1400px){\n #sota-navbar .sz-navbar-items{\n margin-left: auto;\n }\n\n #sota-navbar .sz-navbar-item.sota-navbar-text{\n display: none;\n }\n \n #sota-navbar .sota-navbar-logo{\n margin-right: 24px;\n }\n}\n\n#sota-navbar .sota-navbar-text span{\n font-family: ${e};\n font-weight: 700;\n}\n\n `;document.head.appendChild(document.createElement("style")).textContent=r,console.log("styles set")}};return h.sotaConfig=e,h.colorInterpolate=a,h.sotaMasonry=function(){document.querySelectorAll(".sota-section-inner").forEach(t=>{if(t.classList.contains("sota-content-section"))return;let a=0;const e=t.querySelectorAll(".sota-module svg").length;if(0===e){new Masonry(t,{itemSelector:".sota-module",columnWidth:".sota-module",gutter:48});return}const n=document.createElement("p");n.innerHTML="Loading...",n.classList.add("sota-loading"),t.prepend(n),t.addEventListener("sotaChartRendered",()=>{if(a++,a===e){t.classList.remove("sota-hide");new Masonry(t,{itemSelector:".sota-module",columnWidth:".sota-module",gutter:48})}})})},h.sotaNavbar=function(t,a="",e=!1,n=!1,s=!1){const o=document.getElementById("sota-navbar");o.classList.add("sz-navbar");let l='\n <div class="sz-navbar-left sz-navbar-inner">\n <input type="checkbox" id="sz-navbar-check">\n <label for="sz-navbar-check" class="sz-navbar-hamburger">☰</label>';e&&(l+=s?`<div class="sota-navbar-logo"><a href="${s}"><img src="${e}" alt="Navbar logo"></a></div>`:`<div class="sota-navbar-logo"><img src="${e}" alt="Navbar logo"></div>`),l+=n?`<div class="sota-navbar-text"><span><a href="${n}"><${a}</a></span></div>`:`<div class="sota-navbar-text"><span>${a}</span></div>`,l+='<div class="sz-navbar-items">',l+=n?`<div class="sota-navbar-text sz-navbar-item"><span><a href="${n}"><${a}</a></span></div>`:`<div class="sota-navbar-text sz-navbar-item"><span>${a}</span></div>`;for(const a of t.sections)l+=`<div class="sz-navbar-item" id="sota-navbar-item-${a.slug}"><a href="#sota-section-${a.slug}">${a.name}</a></div>`;l+="</div>",o.innerHTML=l;const r=[];for(const a of t.sections)r.push(document.getElementById("sota-section-"+a.slug));function i(){if(window.innerWidth>600)for(const a in r){const e=r[a],n=t.sections[a],s=document.getElementById("sota-navbar-item-"+n.slug);window.scrollY>=e.offsetTop&&window.scrollY<e.offsetTop+e.offsetHeight?s.classList.add("selected"):s.classList.remove("selected")}}console.log(r),window.onload=()=>{i()},window.addEventListener("scroll",()=>{i()});const c=document.querySelectorAll("#sota-navbar .sz-navbar-item"),h=document.getElementById("sz-navbar-check");for(let t=0;t<c.length;t++)c[t].addEventListener("click",()=>{i(),h.checked=!1})},h.createSections=function(a){for(const e of a.sections){const a=e.slug;if(t.select("body").select("#sota-section-"+a).size()>0)continue;const n=t.select("body").append("div").attr("id","sota-section-"+a).attr("class","sota-section");n.append("h1").text(e.name),void 0!==e.blurb&&n.append("p").text(e.blurb);const s="sota-section-inner "+(e.content?"sota-content-section":"sota-hide"),o=n.append("div").attr("class",s);e.content&&(o.node().innerHTML=e.content)}},h.setParam=function(t,a){this.sotaConfig[t]=a},h.getParam=function(t){return this.sotaConfig[t]},h}));