From 11f33ecb811c6a81b87b728f3fc52f5dcca91a6d Mon Sep 17 00:00:00 2001 From: Jude N Date: Sat, 13 May 2017 23:50:50 +0000 Subject: [PATCH] checkpoint - got CSV access working --- README.md | 2 +- bower.json | 3 ++- examples/tech-radar.min.js | 2 +- examples/tech-radar.min.js.map | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c133843..5e17f06 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Check the example [here](http://brunotrecenti.com/tech-radar/) ### How To Use -The package has two dependencies [d3](http://d3js.org/) and [chancejs](http://chancejs.com/) that needs to be loaded separatedely for now, in the future there's a plan to add and maintain those dependencies. +The package has three dependencies [d3](http://d3js.org/), [d3-queue](https://github.com/d3/d3-queue) and [chancejs](http://chancejs.com/) that needs to be loaded separatedely for now, in the future there's a plan to add and maintain those dependencies. Please view the file `examples/index.html` for general usages. diff --git a/bower.json b/bower.json index 48945d0..d63b30a 100644 --- a/bower.json +++ b/bower.json @@ -9,6 +9,7 @@ "private": true, "dependencies": { "d3": "~3.4.2", - "chance": "~0.5.4" + "chance": "~0.5.4", + "d3-queue": "~3.0.5" } } diff --git a/examples/tech-radar.min.js b/examples/tech-radar.min.js index 4f576e2..b833b23 100644 --- a/examples/tech-radar.min.js +++ b/examples/tech-radar.min.js @@ -1,2 +1,2 @@ -var tr=tr||{};tr.models={},tr.graphing={},tr.util={},tr.graphing.Radar=function(t,n){function r(){return Math.round(t/2)}function e(){p.append("line").attr("x1",r()).attr("y1",0).attr("x2",r()).attr("y2",t).attr("stroke-width",14),p.append("line").attr("x1",0).attr("y1",r()).attr("x2",t).attr("y2",r()).attr("stroke-width",14)}function a(t,n){var e=(l.sequence(t.length),l.sum(t.length)),a=l.sum(n);return r()-r()*a/e}function u(t){t.forEach(function(n,e){p.append("circle").attr("cx",r()).attr("cy",r()).attr("r",a(t,e))})}function c(t){var n;n=Math.round(r()/t.length),t.forEach(function(n,e){p.append("text").attr("class","line-text").attr("y",r()+4).attr("x",r()-a(t,e)+10).text(n.name()),p.append("text").attr("class","line-text").attr("y",r()+4).attr("x",r()+a(t,e)-10).attr("text-anchor","end").text(n.name())})}function o(t,n,r,e){var a,u,c,o,i,s;return a=13,u=n-a,c=t-a+1,o=t+a+1,i=n+a-a/2.5,s=t+1+","+u+" "+c+","+i+" "+o+","+i,(e||p).append("polygon").attr("points",s).attr("class",r).attr("stroke-width",1.5)}function i(t,n,r,e){return(e||p).append("circle").attr("cx",t).attr("cy",n).attr("class",r).attr("stroke-width",1.5).attr("r",10)}function s(t,n,e,u,c){var s;s=n.blips(),t.forEach(function(n,f){var d,l,I;d=a(t,f),l=f==t.length-1?0:a(t,f+1);var I=s.filter(function(t){return t.cycle()==n});I.forEach(function(t){var a,s,f=t.name().split(""),I=f.reduce(function(t,n){return t+n.charCodeAt(0)},0);chance=new Chance(I*n.name().length*t.number()),a=Math.PI*chance.integer({min:13,max:85})/180,s=chance.floating({min:l+25,max:d-10});var m=r()+s*Math.cos(a)*e,y=r()+s*Math.sin(a)*u,v=p.append("g").attr("class","blip-group");t.isNew()?o(m,y,c,v):i(m,y,c,v),h.push(function(){var n;n=p.append("text").attr("x",m+15).attr("y",y+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",m).attr("y",y+4).attr("class","blip-text").attr("text-anchor","middle").text(t.number())})})}function f(n){function r(t,n,r,e,a){p.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 d,l,p,h;return h=[],l=new tr.util.Fib,d={},d.svg=function(){return p},d.init=function(t){return p=d3.select(t||"body").append("svg"),d},d.plot=function(){var r,a;r=n.cycles().reverse(),a=n.quadrants(),p.attr("width",t).attr("height",t),u(r),e(),c(r),n.hasQuadrants()&&(f(a),s(r,a.I,1,-1,"first"),s(r,a.II,-1,-1,"second"),s(r,a.III,-1,1,"third"),s(r,a.IV,1,1,"fourth")),h.forEach(function(t){t()})},d},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';Object.keys(t).forEach(function(n){e+=''+n+"",t[n].forEach(function(t){e+=""+t.number()+""+t.name()+""+t.description()+""})}),e+="",r.innerHTML=e},e},tr.models.Blip=function(t,n,r,e){var a,u;return a={},u=-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 u},a.setNumber=function(t){u=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(++u)})}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,u;return u=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;t>r;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}; +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';Object.keys(t).forEach(function(n){e+=''+n+"",t[n].forEach(function(t){e+=""+t.number()+""+t.name()+""+t.description()+""})}),e+="",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