checkpoint - got CSV access working
[tech-radar.git] / examples / tech-radar.min.js
1 var tr=tr||{};tr.models={},tr.graphing={},tr.util={},tr.graphing.Radar=function(t,n,r){function e(){return Math.round(t/2)}function a(){h.append("line").attr("x1",e()).attr("y1",0).attr("x2",e()).attr("y2",t).attr("stroke-width",14),h.append("line").attr("x1",0).attr("y1",e()).attr("x2",t).attr("y2",e()).attr("stroke-width",14)}function c(t,n){var r=(p.sequence(t.length),p.sum(t.length)),a=p.sum(n);return e()-e()*a/r}function u(t){t.forEach(function(n,r){h.append("circle").attr("cx",e()).attr("cy",e()).attr("r",c(t,r))})}function o(t){Math.round(e()/t.length),t.forEach(function(n,r){h.append("text").attr("class","line-text").attr("y",e()+4).attr("x",e()-c(t,r)+10).text(n.name()),h.append("text").attr("class","line-text").attr("y",e()+4).attr("x",e()+c(t,r)-10).attr("text-anchor","end").text(n.name())})}function i(t,n,r,e){var a,c,u,o,i,s;return a=13,c=n-a,u=t-a+1,o=t+a+1,i=n+a-a/2.5,s=t+1+","+c+" "+u+","+i+" "+o+","+i,(e||h).append("polygon").attr("points",s).attr("class",r).attr("stroke-width",1.5)}function s(t,n,r,e){return(e||h).append("circle").attr("cx",t).attr("cy",n).attr("class",r).attr("stroke-width",1.5).attr("r",10)}function f(t,n,a,u,o){var f;f=n.blips(),t.forEach(function(n,d){var l,p;l=c(t,d),p=d==t.length-1?0:c(t,d+1),f.filter(function(t){return t.cycle()==n}).forEach(function(t){var c,f,d=t.name().split(""),I=d.reduce(function(t,n){return t+n.charCodeAt(0)},0);chance=new Chance(I*n.name().length*t.number()),c=Math.PI*chance.integer({min:13,max:85})/180,f=chance.floating({min:p+25,max:l-10});var y=e()+f*Math.cos(c)*a,x=e()+f*Math.sin(c)*u,v=h.append("g").attr("class","blip-group");t.isNew()?i(y,x,o,v):s(y,x,o,v),m.push(function(){var n;n=h.append("text").attr("x",y+15).attr("y",x+4).attr("class","blip-name").attr("text-anchor","left").text(t.name()),v.on("mouseover",function(){n.style("display","block")}).on("mouseout",function(){n.style("display","none")})}),v.append("text").attr("x",y).attr("y",x+4).attr("class","blip-text").attr("text-anchor","middle").text(t.number()).append("svg:title").text(t.name()+(r&&t.description()?": "+t.description().replace(/(<([^>]+)>)/gi,""):""))})})}function d(n){function r(t,n,r,e,a){h.append("text").attr("x",r).attr("y",e).attr("class",a).attr("text-anchor",n).text(t)}r(n.I.name(),"end",t-10,10,"first"),r(n.II.name(),"start",10,10,"second"),r(n.III.name(),"start",10,t-10,"third"),r(n.IV.name(),"end",t-10,t-10,"fourth")}var l,p,h,m;return m=[],p=new tr.util.Fib,l={},l.svg=function(){return h},l.init=function(t){return h=d3.select(t||"body").append("svg"),l},l.plot=function(){var r,e;r=n.cycles().reverse(),e=n.quadrants(),h.attr("width",t).attr("height",t),u(r),a(),o(r),n.hasQuadrants()&&(d(e),f(r,e.I,1,-1,"first"),f(r,e.II,-1,-1,"second"),f(r,e.III,-1,1,"third"),f(r,e.IV,1,1,"fourth")),m.forEach(function(t){t()})},l},tr.graphing.RefTable=function(t){function n(){var n={};t.cycles().map(function(t){return{order:t.order(),name:t.name()}}).sort(function(t,n){return t.order===n.order?0:t.order<n.order?-1:1}).forEach(function(t){n[t.name]=[]});var r=[],e=t.quadrants();return Object.keys(e).forEach(function(t){r=r.concat(e[t].blips())}),r.forEach(function(t){n[t.cycle().name()].push(t)}),n}var r,e={};return e.init=function(t){return r=document.querySelector(t||"body"),e},e.render=function(){var t=n(),e='<table class="radar-ref-table">';Object.keys(t).forEach(function(n){e+='<tr class="radar-ref-status-group"><td colspan="3">'+n+"</td></tr>",t[n].forEach(function(t){e+="<tr><td>"+t.number()+"</td><td>"+t.name()+"</td><td>"+t.description()+"</td></tr>"})}),e+="</table>",r.innerHTML=e},e},tr.models.Blip=function(t,n,r,e){var a,c;return a={},c=-1,a.name=function(){return t},a.description=function(){return e||""},a.isNew=function(){return r},a.cycle=function(){return n},a.number=function(){return c},a.setNumber=function(t){c=t},a},tr.models.Cycle=function(t,n){var r={};return r.name=function(){return t},r.order=function(){return n},r},tr.models.Quadrant=function(t){var n,r;return n={},r=[],n.name=function(){return t},n.add=function(t){Array.isArray(t)?r=r.concat(t):r.push(t)},n.blips=function(){return r.slice(0)},n},tr.models.Radar=function(){function t(t){t.forEach(function(t){t.setNumber(++c)})}function n(){var t=[];for(var n in a)a.hasOwnProperty(n)&&null!=a[n]&&t.push(a[n]);return t}function r(){return n().reduce(function(t,n){return t.concat(n.blips())},[])}var e,a,c;return c=0,a={I:null,II:null,III:null,IV:null},e={},e.setFirstQuadrant=function(n){a.I=n,t(a.I.blips())},e.setSecondQuadrant=function(n){a.II=n,t(a.II.blips())},e.setThirdQuadrant=function(n){a.III=n,t(a.III.blips())},e.setFourthQuadrant=function(n){a.IV=n,t(a.IV.blips())},e.hasQuadrants=function(){return!!(a.I||a.II||a.III||a.IV)},e.cycles=function(){var t,n;n=[],t={},r().forEach(function(n){t[n.cycle().name()]=n.cycle()});for(var e in t)t.hasOwnProperty(e)&&n.push(t[e]);return n.slice(0).sort(function(t,n){return t.order()-n.order()})},e.quadrants=function(){return a},e},tr.util.Fib=function(){var t={};return t.sequence=function(t){for(var n=[0,1],r=2;r<t;r++)n[r]=n[r-2]+n[r-1];return n},t.sum=function(n){return 0===n?0:1===n?1:t.sequence(n+1).reduce(function(t,n){return t+n},0)},t};
2 //# sourceMappingURL=./tech-radar.min.js.map