diff --git a/src/Bailiwick/View.hs b/src/Bailiwick/View.hs index 4e94db71..4db5e23e 100644 --- a/src/Bailiwick/View.hs +++ b/src/Bailiwick/View.hs @@ -121,6 +121,29 @@ view st@State{..} = do isOpen <- foldDyn (const not) False $ isOpenE return (toolBarE, isOpen) return (leftmost [navBarE, headerE', toolBarE], isOpen') + elAttr "div" ("class" =: "export-dialog" <> "style" =: "display:none;") $ + divClass "export-dialog-main" $ + divClass "export-header" $ do + divClass "export-menu" $ do + elClass "button" "export-type" $ text "Share" + elClass "button" "export-type" $ text "Embed" + elClass "button" "export-type" $ text "Download" + elClass "button" "export-close" $ return () + --
=e.length)return t;var u=[],a=i[r++];return t.forEach(function(t,e){u.push({key:t,values:n(e,r)})}),a?u.sort(function(n,t){return a(n.key,t.key)}):u}(a(u.map,n,0),0)},r.key=function(n){return e.push(n),r},r.sortKeys=function(n){return i[e.length-1]=n,r},r.sortValues=function(t){return n=t,r},r.rollup=function(n){return t=n,r},r},u.set=function(n){var t=new T;if(n)for(var r=0,e=n.length;r 360?n-=360:n<0&&(n+=360),n<60?e+(i-e)*n/60:n<180?i:n<240?e+(i-e)*(240-n)/60:e}(n))}return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:t<0?0:t>1?1:t,e=2*(r=r<0?0:r>1?1:r)-(i=r<=.5?r*(1+t):r+t-r*t),new ft(u(n+120),u(n),u(n-120))}function Gn(n,t,r){return this instanceof Gn?(this.h=+n,this.c=+t,void(this.l=+r)):arguments.length<2?n instanceof Gn?new Gn(n.h,n.c,n.l):ut(n instanceof Jn?n.l:(n=dt((n=u.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new Gn(n,t,r)}Zn.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new Hn(this.h,this.s,this.l/n)},Zn.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new Hn(this.h,this.s,n*this.l)},Zn.rgb=function(){return Vn(this.h,this.s,this.l)},u.hcl=Gn;var Xn=Gn.prototype=new $n;function Kn(n,t,r){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new Jn(r,Math.cos(n*=Rn)*t,Math.sin(n)*t)}function Jn(n,t,r){return this instanceof Jn?(this.l=+n,this.a=+t,void(this.b=+r)):arguments.length<2?n instanceof Jn?new Jn(n.l,n.a,n.b):n instanceof Gn?Kn(n.h,n.c,n.l):dt((n=ft(n)).r,n.g,n.b):new Jn(n,t,r)}Xn.brighter=function(n){return new Gn(this.h,this.c,Math.min(100,this.l+Qn*(arguments.length?n:1)))},Xn.darker=function(n){return new Gn(this.h,this.c,Math.max(0,this.l-Qn*(arguments.length?n:1)))},Xn.rgb=function(){return Kn(this.h,this.c,this.l).rgb()},u.lab=Jn;var Qn=18,nt=.95047,tt=1,rt=1.08883,et=Jn.prototype=new $n;function it(n,t,r){var e=(n+16)/116,i=e+t/500,u=e-r/200;return new ft(ct(3.2404542*(i=at(i)*nt)-1.5371385*(e=at(e)*tt)-.4985314*(u=at(u)*rt)),ct(-.969266*i+1.8760108*e+.041556*u),ct(.0556434*i-.2040259*e+1.0572252*u))}function ut(n,t,r){return n>0?new Gn(Math.atan2(r,t)*Tn,Math.sqrt(t*t+r*r),n):new Gn(NaN,NaN,n)}function at(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function ot(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function ct(n){return Math.round(255*(n<=.00304?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function ft(n,t,r){return this instanceof ft?(this.r=~~n,this.g=~~t,void(this.b=~~r)):arguments.length<2?n instanceof ft?new ft(n.r,n.g,n.b):gt(""+n,ft,Vn):new ft(n,t,r)}function lt(n){return new ft(n>>16,n>>8&255,255&n)}function st(n){return lt(n)+""}et.brighter=function(n){return new Jn(Math.min(100,this.l+Qn*(arguments.length?n:1)),this.a,this.b)},et.darker=function(n){return new Jn(Math.max(0,this.l-Qn*(arguments.length?n:1)),this.a,this.b)},et.rgb=function(){return it(this.l,this.a,this.b)},u.rgb=ft;var ht=ft.prototype=new $n;function pt(n){return n<16?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function gt(n,t,r){var e,i,u,a=0,o=0,c=0;if(e=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(i=e[2].split(","),e[1]){case"hsl":return r(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(mt(i[0]),mt(i[1]),mt(i[2]))}return(u=bt.get(n))?t(u.r,u.g,u.b):(null==n||"#"!==n.charAt(0)||isNaN(u=parseInt(n.slice(1),16))||(4===n.length?(a=(3840&u)>>4,a|=a>>4,o=240&u,o|=o>>4,c=15&u,c|=c<<4):7===n.length&&(a=(16711680&u)>>16,o=(65280&u)>>8,c=255&u)),t(a,o,c))}function vt(n,t,r){var e,i,u=Math.min(n/=255,t/=255,r/=255),a=Math.max(n,t,r),o=a-u,c=(a+u)/2;return o?(i=c<.5?o/(a+u):o/(2-a-u),e=n==a?(t-r)/o+(t =s[0]&&c<=s[1]&&((o=f[u.bisect(h,c,1,g)-1]).y+=v,o.push(i[a]));return f}return i.value=function(n){return arguments.length?(t=n,i):t},i.range=function(n){return arguments.length?(r=_t(n),i):r},i.bins=function(n){return arguments.length?(e="number"==typeof n?function(t){return Ku(t,n)}:_t(n),i):e},i.frequency=function(t){return arguments.length?(n=!!t,i):n},i},u.layout.pack=function(){var n,t=u.layout.hierarchy().sort(Qu),r=0,e=[1,1];function i(i,u){var a=t.call(this,i,u),o=a[0],c=e[0],f=e[1],l=null==n?Math.sqrt:"function"==typeof n?n:function(){return n};if(o.x=o.y=0,Tu(o,function(n){n.r=+l(n.value)}),Tu(o,ea),r){var s=r*(n?1:Math.max(2*o.r/c,2*o.r/f))/2;Tu(o,function(n){n.r+=s}),Tu(o,ea),Tu(o,function(n){n.r-=s})}return function n(t,r,e,i){var u=t.children;t.x=r+=i*t.x;t.y=e+=i*t.y;t.r*=i;if(u)for(var a=-1,o=u.length;++a ' + func(text) + ' fred, barney, & pebbles1){y=p[0];var b=p[1],_=y[0]-b[0],x=y[1]-b[1];a=_*_+x*x}}function d(){var o,c,f,l,s=u.touches(t);vo.call(t);for(var h=0,p=s.length;h"===o?S+i+n:"^"===o?S.substring(0,A>>=1)+i+n+S.substring(A):i+(_?n:S+n))+r}}}u.formatPrefix=function(n,t){var r=0;return(n=+n)&&(n<0&&(n*=-1),t&&(n=u.round(n,Lt(n,t))),r=1+Math.floor(1e-12+Math.log(n)/Math.LN10),r=Math.max(-24,Math.min(24,3*Math.floor((r-1)/3)))),Rt[8+r/3]};var qt=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,It=u.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=u.round(n,Lt(n,t))).toFixed(Math.max(0,Math.min(20,Lt(n*(1+1e-15),t))))}});function Ot(n){return n+""}var Dt=u.time={},Pt=Date;function Ut(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}Ut.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Ft.setUTCDate.apply(this._,arguments)},setDay:function(){Ft.setUTCDay.apply(this._,arguments)},setFullYear:function(){Ft.setUTCFullYear.apply(this._,arguments)},setHours:function(){Ft.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Ft.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Ft.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Ft.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Ft.setUTCSeconds.apply(this._,arguments)},setTime:function(){Ft.setTime.apply(this._,arguments)}};var Ft=Date.prototype;function Bt(n,t,r){function e(t){var r=n(t),e=u(r,1);return t-ru&&(i=t.slice(u,i),o[a]?o[a]+=i:o[++a]=i),(r=r[0])===(e=e[0])?o[a]?o[a]+=e:o[++a]=e:(o[++a]=null,c.push({i:a,x:Xi(r,e)})),u=Qi.lastIndex;return u1&&i.push("H",e[0]);return i.join("")},"step-before":Va,"step-after":Ga,basis:Ja,"basis-open":function(n){if(n.length<4)return Ha(n);var t,r=[],e=-1,i=n.length,u=[0],a=[0];for(;++e<3;)t=n[e],u.push(t[0]),a.push(t[1]);r.push(Qa(ro,u)+","+Qa(ro,a)),--e;for(;++e9&&(i=3*t/Math.sqrt(i),a[o]=i*r,a[o+1]=i*e));o=-1;for(;++o<=c;)i=(n[Math.min(c,o+1)][0]-n[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),u.push([i||0,a[o]*i||0]);return u}(n))}});function Ha(n){return n.length>1?n.join("L"):n+"Z"}function Za(n){return n.join("L")+"Z"}function Va(n){for(var t=0,r=n.length,e=n[0],i=[e[0],",",e[1]];++t1?{floor:function(t){for(;o(t=n.floor(t));)t=Do(t-1);return t},ceil:function(t){for(;o(t=n.ceil(t));)t=Do(+t+1);return t}}:n))},e.ticks=function(n,t){var r=ga(e.domain()),u=null==n?i(r,10):"number"==typeof n?i(r,n):!n.range&&[{range:n},t];return u&&(n=u[0],t=u[1]),n.range(r[0],Do(+r[1]+1),t<1?1:t)},e.tickFormat=function(){return r},e.copy=function(){return Oo(n.copy(),t,r)},xa(e,n)}function Do(n){return new Date(n)}Ro.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Io:qo,Io.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Io.toString=qo.toString,Dt.second=Bt(function(n){return new Pt(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),Dt.seconds=Dt.second.range,Dt.seconds.utc=Dt.second.utc.range,Dt.minute=Bt(function(n){return new Pt(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),Dt.minutes=Dt.minute.range,Dt.minutes.utc=Dt.minute.utc.range,Dt.hour=Bt(function(n){var t=n.getTimezoneOffset()/60;return new Pt(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),Dt.hours=Dt.hour.range,Dt.hours.utc=Dt.hour.utc.range,Dt.month=Bt(function(n){return(n=Dt.day(n)).setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),Dt.months=Dt.month.range,Dt.months.utc=Dt.month.utc.range;var Po=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Uo=[[Dt.second,1],[Dt.second,5],[Dt.second,15],[Dt.second,30],[Dt.minute,1],[Dt.minute,5],[Dt.minute,15],[Dt.minute,30],[Dt.hour,1],[Dt.hour,3],[Dt.hour,6],[Dt.hour,12],[Dt.day,1],[Dt.day,2],[Dt.week,1],[Dt.month,1],[Dt.month,3],[Dt.year,1]],Fo=Ro.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Jr]]),Bo={range:function(n,t,r){return u.range(Math.ceil(n/r)*r,+t,r).map(Do)},floor:q,ceil:q};Uo.year=Dt.year,Dt.scale=function(){return Oo(u.scale.linear(),Uo,Fo)};var Wo=Uo.map(function(n){return[n[0].utc,n[1]]}),Yo=To.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Jr]]);function $o(n){return JSON.parse(n.responseText)}function Ho(n){var t=c.createRange();return t.selectNode(c.body),t.createContextualFragment(n.responseText)}Wo.year=Dt.year.utc,Dt.scale.utc=function(){return Oo(u.scale.linear(),Wo,Yo)},u.text=xt(function(n){return n.responseText}),u.json=function(n,t){return wt(n,"application/json",$o,t)},u.html=function(n,t){return wt(n,"text/html",Ho,t)},u.xml=xt(function(n){return n.responseXML}),this.d3=u,void 0===(i="function"==typeof(e=u)?e.call(t,r,t,n):e)||(n.exports=i)}()},function(n,t,r){(function(n,e){var i;
/**
- * Time series used on an indicator
- *
- **/
-
-
-
-
-
-var yearFormat = d3__WEBPACK_IMPORTED_MODULE_0___default.a.time.format('%Y').parse;
-var transforms = ["absolute", "indexed", "percapita"];
-var x = d3__WEBPACK_IMPORTED_MODULE_0___default.a.time.scale();
-var y = d3__WEBPACK_IMPORTED_MODULE_0___default.a.scale.linear();
-var clipHeight = 393;
-var clipWidth = 363;
-var margin = {
- top: 40,
- right: 40,
- bottom: 40,
- left: 80
-};
-var line = d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.line().x(function (d, i) {
- return x(d.date);
-}).y(function (d) {
- return y(d.v);
-}); // data: [{year, rawNum, indexNum, headlineDisp, indexDisp}]
-// @params: (data, current year, current indicator, transform, current area, current area type, chart ID)
-
-/* harmony default export */ __webpack_exports__["default"] = (function (element, params) {
- var setup = Object(_utils_chart_setup__WEBPACK_IMPORTED_MODULE_3__["default"])(element, params, margin, {
- 'default-timeseries': true,
- 'basic-barchart': false,
- 'area-treemap': false,
- 'overunder-barchart': false
- });
-
- if (setup === null) {
- return;
- }
-
- var cache = window.MBIECacheStorage,
- toCache = {},
- data = setup.data,
- year = setup.year,
- indicator = setup.indicator,
- transform = setup.transform,
- area = setup.area,
- areaLevel = setup.areaLevel,
- svg = setup.svg,
- width = setup.width,
- height = setup.height; // current data...
-
- var currentYear = svg.attr('data-year'),
- currentIndicator = svg.attr('data-indicator'),
- currentArea = svg.attr('data-area'),
- currentTransform = svg.attr('data-transform'),
- currentLevel = svg.attr('data-level');
- var legendDiv = d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(element).select('.legend');
- var legendWidth = window.innerWidth < 350 ? 320 : 420;
- var legendHeight = 50;
- var tooltipElem = d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(element).select(".tooltip"); /// Setup
-
- x.range([0, width]);
- y.range([height, 0]);
- var voronoi = d3__WEBPACK_IMPORTED_MODULE_0___default.a.geom.voronoi().x(function (d) {
- return x(d.date);
- }).y(function (d) {
- return y(d.v);
- }).clipExtent([[-margin.left, -margin.top], [width + margin.right, height + margin.bottom]]); /// Update
- // svg.selectAll('g').remove();
-
- var g = svg.selectAll('g').data([data]),
- gEnter = svg.select('.g-enter');
-
- if (gEnter.empty()) {
- gEnter = g.enter().append("g").attr('class', 'g-enter');
- }
-
- gEnter.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
- var years = [];
-
- if (!lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(cache.get(indicator), "years")) {
- years = lodash__WEBPACK_IMPORTED_MODULE_1___default.a.uniq(lodash__WEBPACK_IMPORTED_MODULE_1___default.a.reduce(data, function (result, value, key) {
- return lodash__WEBPACK_IMPORTED_MODULE_1___default.a.reduce(value[1], function (res, v, k) {
- res.push(v[0]);
- return res;
- }, result);
- }, [])).sort(function (a, b) {
- return d3__WEBPACK_IMPORTED_MODULE_0___default.a.ascending(a, b);
- }).map(function (y) {
- return yearFormat(y.toString());
- });
- toCache.years = years;
- } else {
- years = cache.get(indicator).years;
- }
-
- var areaKey = area + '-' + areaLevel + '-' + transform;
- var areas = [];
-
- if (!lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(cache.get(indicator), area) || lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(cache.get(indicator), area) && !lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(cache.get(indicator.area), areaKey)) {
- var transformPos = transforms.indexOf(transform);
- var pos = transformPos === -1 ? 1 : transformPos + 1;
- var dispPos = transformPos === -1 ? 3 : transformPos + 3;
- areas = data.map(function (a) {
- var area = {
- slug: a[0][0],
- name: a[0][1],
- level: a[0][2],
- dsArea: a[0],
- values: a[1].map(function (y) {
- var out = {};
- out.date = yearFormat(y[0].toString());
- out.v = Number(y[pos]);
- out.d = y[dispPos];
- return out;
- }).filter(function (d) {
- return d.v !== null;
- })
- }; // Used on mouse events on voroni
-
- area.values.forEach(function (o) {
- o.area = area;
- });
- return area;
- }).filter(function (a) {
- var valid = false;
-
- switch (a.name) {
- // case compareAreaName:
- // valid = true;
- // break;
- case area:
- valid = true;
- break;
-
- case 'New Zealand':
- valid = true;
- break;
-
- default:
- break;
- }
-
- return a.level === areaLevel || valid;
- });
- toCache[String(areaKey)] = areas;
- } else {
- areas = cache.get(indicator).areas[areaKey];
- }
-
- var xExtent = d3__WEBPACK_IMPORTED_MODULE_0___default.a.extent(years);
- x.domain(xExtent);
- var yExtent = d3__WEBPACK_IMPORTED_MODULE_0___default.a.extent(d3__WEBPACK_IMPORTED_MODULE_0___default.a.merge(areas.map(function (a) {
- return a.values.map(function (d) {
- return d.v;
- });
- }))); // TODO: activate when we have zoom
- // if (this.get("zoomedIn")) {
- // let areaVals = findAreaBounds(areas, areaName);
- // if (typeof compareAreaName != 'undefined') {
- // let compareVals = findAreaBounds(areas, compareAreaName);
- // yExtent = [Math.min(...[areaVals[0], compareVals[0]])
- // , Math.max(...[areaVals[1], compareVals[1]])];
- // } else {
- // yExtent = areaVals;
- // }
- // let diff = Math.abs(yExtent[1] - yExtent[0]);
- // yExtent[0] -= (.1 * diff);
- // yExtent[1] += (.1 * diff);
- // }
-
- y.domain(yExtent).nice();
- var tickFreq = Math.trunc(years.length / 9) + 1,
- ticks = years.filter(function (t, i) {
- return i % tickFreq === 0;
- });
-
- if (window.innerWidth < 600) {
- ticks = d3__WEBPACK_IMPORTED_MODULE_0___default.a.extent(years);
- }
- /*
- * Generate the vertical line for the selected year.
- * */
-
-
- var xAxisYears = d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.axis().scale(x).tickValues(years).orient("bottom");
- gEnter.append("g").attr("class", "axis axis--x-hidden").attr("transform", "translate(0," + height + ")").call(xAxisYears);
- var allTicks = svg.call(xAxisYears).selectAll(".tick"),
- lineXpos = 0;
- allTicks.each(function (data, i) {
- var tick = d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(this),
- date = new Date(data),
- fullYear = date.getFullYear(),
- targetYear = parseInt(year),
- transform = d3__WEBPACK_IMPORTED_MODULE_0___default.a.transform(tick.attr("transform")).translate;
-
- if (targetYear === fullYear) {
- lineXpos = transform[0];
- }
- });
-
- if (lineXpos <= 0) {
- lineXpos = 1;
- }
-
- var yearLine = gEnter.select(".year-line");
-
- if (yearLine.empty()) {
- yearLine = gEnter.append('line');
- } // gEnter.append("line")
-
-
- yearLine.attr("x1", lineXpos).attr("y1", 0).attr("x2", lineXpos).attr("y2", clipHeight).attr("stroke-width", 1).attr("stroke", "rgba(0,0,0,.5)").attr("z", 100).attr("class", "year-line");
- /*
- * End year line generation.
- * */
-
- var xAxis = d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.axis().scale(x).tickValues(ticks).orient("bottom");
- gEnter.append("g").attr("class", "axis axis--x").attr("transform", "translate(0," + height + ")").attr("z", 100).call(xAxis).append("text").attr("class", "caption").attr("y", 5).attr("x", width + 10).text("Year"); // TODO: formatting
-
- gEnter.append("g").attr("class", "axis axis--y").call(d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.axis().scale(y).orient("left").ticks(10) // .tickFormat(function (d) { return formatter(d); }))
- ).append("text").attr("class", "caption title").attr("y", -30).attr("x", 0).text(transform); // .text(
- // bailiwick.label(transform)
- // );
-
- svg.append("clipPath").attr("id", "clipper").append("rect").attr("x", 0).attr("y", 0).attr("width", clipWidth).attr("height", clipHeight);
- svg.selectAll(".axis--x g.tick text").attr("data-bailiwick-year", function (d) {
- return new Date(d).getFullYear();
- }); // .on("click", function (d) {
- // d3.event.preventDefault();
- // var year = (new Date(d)).getFullYear();
- // console.log('year clicked', year, this);
- // });
-
- var path = gEnter.append("g").attr("class", "areas").selectAll("path").data(areas);
- path.enter().append("path");
- path.attr("d", function (d) {
- d.line = this;
- return line(d.values);
- }); // Data has not actually changed - no path is empty
- // but need need to update highlighing so grab everything.
-
- g.selectAll('g.areas').selectAll('path').attr("class", function (d) {
- var className = '';
-
- switch (d.name) {
- case area:
- className = 'current-area';
- break;
-
- case 'New Zealand':
- className = 'new-zealand';
- break;
-
- default:
- className = "no-highlight";
- break;
- }
-
- return className + ' area'; // } else if (d.name === compareAreaName) {
- // return "compare-area";
- // } else if (d.name === hover) {
- // return "area--hover";
- }).attr("clip-path", "url(#clipper)");
- var focusElemEnter = gEnter.append("g").attr("transform", "translate(-100,-100)").attr("class", "focus");
- focusElemEnter.append("circle").attr("r", 3.5);
- focusElemEnter.append("text").attr("y", -10);
- var focusElem = g.selectAll('g.focus');
- var voronoiGroup = gEnter.append("g").attr("class", "voronoi").attr("clip-path", "url(#clipper)");
- var vg = voronoiGroup.selectAll("path").data(voronoi(d3__WEBPACK_IMPORTED_MODULE_0___default.a.nest().key(function (d) {
- return x(d.date) + "," + y(d.v);
- }).rollup(function (v) {
- return v[0];
- }).entries(d3__WEBPACK_IMPORTED_MODULE_0___default.a.merge(areas.map(function (d) {
- return d.values;
- }))).map(function (d, i) {
- return d.values;
- }))).enter().append("path").attr("d", function (d) {
- return !Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["present"])(d) ? "M" + d.join("L") + "Z" : "";
- }).attr("data-bailiwick-year", function (d) {
- return !Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["present"])(d) ? new Date(d['point'].date).getFullYear() : "";
- }).attr("data-bailiwick-area", function (d) {
- return !Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["present"])(d) ? d['point'].area.slug : "";
- }).datum(function (d) {
- return !Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["present"])(d) ? d.point : null;
- }).on("click", function (d) {
- var year = new Date(d.date).getFullYear(),
- area = d.area.slug; // console.log(year, d);
- // console.log(d3.event)
- // let filter = _this.get('bailiwick.indicator').get('years').filter(function (y) {
- // return y.get('name') === d[0];
- // });
- // if (filter.length === 1) {
- // _this.set('bailiwick.year', filter[0]);
- // }
- // _this.transitionTo({ 'year': filter[0], 'area': d.area.dsArea });
- }); // TODO: import Modernizr
-
- if (!Modernizr.touch) {
- vg.on('mouseover', function mouseover(d, i) {
- if (Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["none"])(d.area)) {
- return;
- }
-
- var xPos = x(d.date),
- yPos = y(d.v);
- d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(d.area.line).classed("area--hover", true);
- d.area.line.parentNode.appendChild(d.area.line);
- focusElem.attr("transform", "translate(" + xPos + "," + yPos + ")").style("visibility", "visible");
- tooltipElem.style("top", yPos - 90 + "px").style("left", xPos + "px").style("visibility", "inherit");
- var tooltipData = [d.area.name, d.d, d.date.getFullYear()],
- tooltip = tooltipElem.selectAll('p').data(tooltipData),
- tooltipEnter = tooltip.enter().append('p');
- tooltip.html(function (d) {
- return d;
- }).classed("number", function (d, i) {
- return i === 1;
- }).classed("local", function (d, i) {
- return i !== 0;
- }).classed("extra", function (d, i) {
- return i > 1;
- });
- tooltip.exit().remove();
- });
- vg.on('mouseout', function (d) {
- if (Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["none"])(d.area)) {
- return;
- }
-
- d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(d.area.line).classed("area--hover", false);
- focusElem.attr("transform", "translate(-100,-100)").style("visibility", "hidden");
- tooltipElem.style("visibility", "hidden");
- });
- } // update data attributes.
-
-
- svg.attr('data-year', year).attr('data-area', area).attr('data-transform', transform).attr('data-level', areaLevel).attr('data-indicator', indicator); // ----
- // Only update the legend if the area has changed.
- // ----
-
- if (currentArea === area) {
- return false;
- }
-
- var legendClasses = ["active", "other"];
- var legendLabels = ["New Zealand", "Other"];
-
- if (area !== "New Zealand") {
- legendLabels.push(area);
- legendClasses = ["nz", "other", "active"];
- } // if (present(compareAreaName) && compareAreaName !== "New Zealand" && compareAreaName !== areaName) {
- // legendLabels.push(compareAreaName);
- // legendClasses.push('compare');
- // }
-
-
- var legendData = d3__WEBPACK_IMPORTED_MODULE_0___default.a.zip(legendLabels, legendClasses);
- var legend = legendDiv.selectAll("svg").data([legendData]);
- var legendEnter = legend.enter().append("svg");
- legend.attr("width", legendWidth).attr("height", legendHeight);
- var legendG = legend.selectAll("g.key").data([legendData]);
- var legendGEnter = legendG.enter().append("g").attr("class", "key");
- legendG.attr("transform", "translate(" + (window.innerWidth < 350 ? 20 : margin.left) + "," + legendHeight / 3 + ")");
- var legendRects = legendG.selectAll("rect").data(legendData);
- var legendRectsEnter = legendRects.enter().append("rect").attr("height", 8).attr("width", 55);
- legendRects.attr("x", function (d, i) {
- return Math.floor(i / 2) * 140;
- }).attr("y", function (d, i) {
- return i % 2 * 20;
- }).attr("class", function (d) {
- return d[1];
- });
- legendRects.exit().remove();
- var legendTexts = legendG.selectAll("text").data(legendData);
- var legendTextsEnter = legendTexts.enter().append("text").attr("dx", "65px").attr("dy", "0.7em");
- legendTexts.attr("x", function (d, i) {
- return Math.floor(i / 2) * 140;
- }).attr("y", function (d, i) {
- return i % 2 * 20;
- }).text(function (d) {
- return d[0];
- });
- legendTexts.exit().remove(); /// Update cache if necessary
-
- if (!lodash__WEBPACK_IMPORTED_MODULE_1___default.a.isEmpty(toCache)) {
- var cachedIndicator = cache.get(indicator); // 1. Years
-
- if (!lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(cachedIndicator, "years") && lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(toCache, "years")) {
- cachedIndicator.years = toCache.years;
- } // 2. Areas
-
-
- if (lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(toCache, areaKey)) {
- var areasToCache = {};
-
- if (lodash__WEBPACK_IMPORTED_MODULE_1___default.a.hasIn(cachedIndicator, "areas")) {
- areasToCache = cachedIndicator.areas;
- }
-
- areasToCache[areaKey] = toCache[areaKey];
- cachedIndicator.areas = areasToCache;
- }
- }
-});
-
-/***/ }),
-
-/***/ "./js-src/charts/map-legend.js":
-/*!*************************************!*\
- !*** ./js-src/charts/map-legend.js ***!
- \*************************************/
-/*! exports provided: default */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "./node_modules/d3/d3.js");
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var _utils_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../utils/utils */ "./js-src/utils/utils.js");
-
-
-/* harmony default export */ __webpack_exports__["default"] = (function (width, height, scaledata) {
- // When we have comparision data, let's switch the scales.
- // if (none(this.get('bailiwick.compareArea'))) {
- // this.defaultScale();
- // } else {
- // this.compareScale();
- // }
- var base = d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(".indicator-map-legend");
- var svg = base.select('svg').empty() ? base.append('svg') : base.select('svg'); // var colors = getColours();
- // var positive = d3.scale([colors['background-rear-positive-light'], colors['background-rear-positive']]),
- // negative = d3.scale()
- // .domain([-1, 0])
- // .range([colors['background-rear-negative'], colors['background-rear-negative-light']]),
- // zero = d3.scale([colors['background-rear-positive-light'], colors['background-rear-negative-light']]);
- // console.log(positive, negative, zero);
- //
- // Default Scale.
- //
-
- var scaleType = 'diverging';
- var vals = d3__WEBPACK_IMPORTED_MODULE_0___default.a.values(scaledata);
- var extent = d3__WEBPACK_IMPORTED_MODULE_0___default.a.extent(vals, function (v) {
- return v[0];
- }); // var caption = this.getAttr("caption").get("text");
- // var formatter = this.getAttr("caption").get("formatter");
-
- var scale = d3__WEBPACK_IMPORTED_MODULE_0___default.a.scale.linear().domain(extent).range([0, 1]),
- scaleF = function scaleF(v) {
- return scale(v);
- },
- thresholdBase = scale.ticks(7),
- threshold = d3__WEBPACK_IMPORTED_MODULE_0___default.a.scale.threshold().domain(thresholdBase).range(thresholdBase.map(function (t) {
- return scaleF(t);
- })),
- linear = d3__WEBPACK_IMPORTED_MODULE_0___default.a.scale.linear().domain(thresholdBase).range(thresholdBase.map(function (t) {
- return scaleF(t);
- }));
-
- if (scaleType === "diverging" || scaleType !== "sequential" && extent[0] * extent[1] < 0) {
- var max = Math.max(Math.abs(extent[0]), Math.abs(extent[1]));
- scale = d3__WEBPACK_IMPORTED_MODULE_0___default.a.scale.linear().domain([-1 * max, 0, max]).range([-1, 0, 1]), thresholdBase = Object(_utils_utils__WEBPACK_IMPORTED_MODULE_1__["computeTicks"])(extent); // console.log('chroma', chroma)
- // scaleF = function(v) {
- // var s = scale(v);
- // if (s < 0) {
- // return negative(s);
- // } else if (s > 0) {
- // return positive(s);
- // }
- // return zero;
- // };
- // threshold = d3.scale.threshold()
- // .domain(thresholdBase)
- // .range(thresholdBase.map(function(t) {
- // return scaleF(t);
- // }));
- // linear = d3.scale.linear()
- // .domain(thresholdBase)
- // .range(thresholdBase.map(function(t) {
- // return scaleF(t);
- // }));
- } //
- // End Default scale
- //
-
-
- var domain = linear.domain();
- extent = d3__WEBPACK_IMPORTED_MODULE_0___default.a.extent(domain);
- var step = (extent[1] - extent[0]) / 100;
- var widthRange = window.innerWidth > 460 ? 380 : window.innerWidth - 120; // A position encoding for the key only.
-
- var x = d3__WEBPACK_IMPORTED_MODULE_0___default.a.scale.linear().domain(extent).range([0, widthRange]);
- var xAxis = d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.axis().scale(x).orient("bottom").tickSize(13).tickValues(window.innerWidth < 500 ? extent : domain); // .tickFormat(function(d) {
- // return d;
- // });
-
- svg.empty();
- svg.data([scaledata]).attr("width", width).attr("height", height);
- step = (width - 100) / 100;
- var sd = Array.from(Array(100).keys(), function (i) {
- return [i * step, scaledata[i][2]];
- });
- svg.selectAll('g').remove();
- var g = svg.selectAll("g").data([sd]).enter().append("g").attr("class", "key").attr("transform", "translate(50," + height * 1 / 3 + ")");
- var legend = g.selectAll("rect").data(sd).enter().append("rect").attr("height", 8).attr("x", function (d) {
- return d[0] % innerWidth;
- }).attr("width", step).style("fill", function (d) {
- return d[1];
- }).style("stroke", function (d) {
- return d[1];
- });
- g.selectAll(".caption").remove();
- var xa = g.call(xAxis);
- xa.append("text").attr("class", "caption").attr("y", -6).text("caption goes here");
-});
-
-/***/ }),
-
-/***/ "./js-src/charts/summary-timeseries.js":
-/*!*********************************************!*\
- !*** ./js-src/charts/summary-timeseries.js ***!
- \*********************************************/
-/*! exports provided: default */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "./node_modules/d3/d3.js");
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
-
-/* harmony default export */ __webpack_exports__["default"] = (function (element, labelledData, activeLabelName) {
- var base = d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(element).select('.d3-attach'),
- svg = base.select('svg').empty() ? base.append('svg') : base.select('svg'),
- yearFormat = d3__WEBPACK_IMPORTED_MODULE_0___default.a.time.format('%Y').parse,
- margin = {
- top: 15,
- right: 0,
- bottom: 30,
- left: 48
- },
- baseW = 225,
- baseH = 120,
- width = baseW - margin.left - margin.right,
- height = baseH - margin.top - margin.bottom;
- svg.attr('width', baseW);
- svg.attr('height', baseH);
- var data = labelledData.map(function (d) {
- return d[1];
- });
- var x = d3__WEBPACK_IMPORTED_MODULE_0___default.a.time.scale().range([0, width]);
- var y = d3__WEBPACK_IMPORTED_MODULE_0___default.a.scale.linear().range([height, 0]);
- var xAxis = d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.axis().scale(x).ticks(5).innerTickSize(3).outerTickSize(0).tickFormat(function (t) {
- return t.getFullYear().toString().replace(/^20/, "'");
- }).orient("bottom");
- var yAxis = d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.axis().scale(y).ticks([4]).outerTickSize(0).innerTickSize(-width).tickFormat(function (t) {
- return '$' + t / 1000 + ' k';
- }).orient("left");
- var line = d3__WEBPACK_IMPORTED_MODULE_0___default.a.svg.line().x(function (d) {
- return x(yearFormat(d[0].toString()));
- }).y(function (d) {
- return y(d[1]);
- });
- var g = svg.selectAll('g').data([data]);
- var gEnter = g.enter().append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")");
- var yMax = Math.ceil(d3__WEBPACK_IMPORTED_MODULE_0___default.a.max(d3__WEBPACK_IMPORTED_MODULE_0___default.a.merge(data), function (d) {
- return d[1];
- }) / 100000) * 100000;
- x.domain(d3__WEBPACK_IMPORTED_MODULE_0___default.a.extent(data[0], function (d) {
- return yearFormat(d[0].toString());
- }));
- y.domain([0, yMax]);
- gEnter.append("g").attr("class", "x axis").attr("transform", "translate(0," + height + ")").append("text").attr("x", 50).attr("dy", "2.5em").text("Year");
- g.selectAll("g.x").call(xAxis);
- gEnter.append("g").attr("class", "y axis").attr("transform", "translate(-7,0)");
- g.selectAll("g.y").call(yAxis);
- var linePlot = g.selectAll("path.line").data(labelledData);
- linePlot.enter().append("path");
- linePlot.attr("d", function (d) {
- return line(d[1]);
- }).attr("class", function (d, i) {
- if (activeLabelName === d[0]) {
- return "line active";
- }
-
- return "line";
- });
- linePlot.exit().remove();
-});
-
-/***/ }),
-
-/***/ "./js-src/index.js":
-/*!*************************!*\
- !*** ./js-src/index.js ***!
- \*************************/
-/*! no exports provided */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony import */ var _cache_cache_store__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cache/cache-store */ "./js-src/cache/cache-store.js");
-/* harmony import */ var _charts_indicator_timeseries__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./charts/indicator-timeseries */ "./js-src/charts/indicator-timeseries.js");
-/* harmony import */ var _charts_map_legend__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./charts/map-legend */ "./js-src/charts/map-legend.js");
-/* harmony import */ var _charts_summary_timeseries__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./charts/summary-timeseries */ "./js-src/charts/summary-timeseries.js");
-/* harmony import */ var _charts_indicator_barchart__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./charts/indicator-barchart */ "./js-src/charts/indicator-barchart.js");
-/* harmony import */ var _charts_indicator_over_under_barchart__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./charts/indicator-over-under-barchart */ "./js-src/charts/indicator-over-under-barchart.js");
-/* harmony import */ var _charts_indicator_area_treemap__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./charts/indicator-area-treemap */ "./js-src/charts/indicator-area-treemap.js");
-/* ///
- * Global Imports
- * /// */
-
-window.MBIECacheStorage = _cache_cache_store__WEBPACK_IMPORTED_MODULE_0__["default"].getInstance();
-
-
-
-
-
-
-/*
- * Reflex functions
- * ----------------:
- * Any functions that need to interact with Reflex must be made global.
- */
-
-window.updateIndicatorTimeSeries = _charts_indicator_timeseries__WEBPACK_IMPORTED_MODULE_1__["default"];
-window.updateMapLegend = _charts_map_legend__WEBPACK_IMPORTED_MODULE_2__["default"];
-window.updateTimeSeries = _charts_summary_timeseries__WEBPACK_IMPORTED_MODULE_3__["default"];
-window.updateAreaBarchart = _charts_indicator_barchart__WEBPACK_IMPORTED_MODULE_4__["default"];
-window.overUnderBarchart = _charts_indicator_over_under_barchart__WEBPACK_IMPORTED_MODULE_5__["default"];
-window.areaTreeMap = _charts_indicator_area_treemap__WEBPACK_IMPORTED_MODULE_6__["default"];
-
-/***/ }),
-
-/***/ "./js-src/utils/chart-setup.js":
-/*!*************************************!*\
- !*** ./js-src/utils/chart-setup.js ***!
- \*************************************/
-/*! exports provided: default */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "./node_modules/d3/d3.js");
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
-/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_1__);
-/* harmony import */ var _utils_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/utils */ "./js-src/utils/utils.js");
-
-
-
-/* harmony default export */ __webpack_exports__["default"] = (function (element, params, margin, chartInnerClasses) {
- var base = d3__WEBPACK_IMPORTED_MODULE_0___default.a.select(element).select('.d3-attach'),
- svg = null,
- width = parseInt(base.style("width")) - margin.left - margin.right,
- height = parseInt(base.style("height")) - margin.top - margin.bottom,
- data = params[0];
-
- if (!base.select('svg').empty()) {
- base.select('svg').remove();
- }
-
- svg = base.append('svg'); // set chart specific classes.
-
- d3__WEBPACK_IMPORTED_MODULE_0___default.a.select('.chart-inner').classed(chartInnerClasses);
- svg.attr("preserveAspectRatio", "xMinYMin meet").attr("viewBox", "0 0 481 474");
-
- if (Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(data) || isNaN(width) || isNaN(height)) {
- return null;
- }
-
- var year = params[1];
- var indicator = params[2];
- var transform = params[3];
- var area = params[4];
- var areaLevel = params[5];
- var cache = window.MBIECacheStorage; /// Cached data
-
- if (Object(_utils_utils__WEBPACK_IMPORTED_MODULE_2__["isEmpty"])(cache.get(indicator))) {
- cache.put(indicator, {});
- }
-
- return {
- data: data,
- year: year,
- indicator: indicator,
- transform: transform,
- area: area,
- areaLevel: areaLevel,
- svg: svg,
- width: width,
- height: height
- };
-});
-
-/***/ }),
-
-/***/ "./js-src/utils/formatting.js":
-/*!************************************!*\
- !*** ./js-src/utils/formatting.js ***!
- \************************************/
-/*! exports provided: default */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return formatting; });
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "./node_modules/d3/d3.js");
-/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
-
-
-var commasFormatter = function commasFormatter(value) {
- var f = "" + value;
-
- if (f.length > 4) {
- var val = d3__WEBPACK_IMPORTED_MODULE_0___default.a.format('.1r')(value);
-
- if (val.charAt(1) === '0') {
- return d3__WEBPACK_IMPORTED_MODULE_0___default.a.format('.1s')(val);
- }
-
- return d3__WEBPACK_IMPORTED_MODULE_0___default.a.format('.2s')(val);
- }
-
- return d3__WEBPACK_IMPORTED_MODULE_0___default.a.format('n')(value);
-};
-
-var moneyFormatter = d3__WEBPACK_IMPORTED_MODULE_0___default.a.format(',g');
-
-var percentageFormatter = function percentageFormatter(value) {
- var _int = parseInt(value);
-
- if (_int < 10) {
- return d3__WEBPACK_IMPORTED_MODULE_0___default.a.format('.1r')(value);
- }
-
- return d3__WEBPACK_IMPORTED_MODULE_0___default.a.format('.2r')(value);
-};
-
-function formatting(units, value) {
- switch (units) {
- case "million dollars":
- return moneyFormatter(value) + " M";
-
- case "dollars":
- return moneyFormatter(value);
-
- case "percentage":
- return percentageFormatter(value) + " %";
- }
-
- return commasFormatter(value);
-}
-
-/***/ }),
-
-/***/ "./js-src/utils/utils.js":
-/*!*******************************!*\
- !*** ./js-src/utils/utils.js ***!
- \*******************************/
-/*! exports provided: computeTicks, none, isEmpty, present, getColours */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "computeTicks", function() { return computeTicks; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "none", function() { return none; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isEmpty", function() { return isEmpty; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "present", function() { return present; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getColours", function() { return getColours; });
-/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js");
-/* harmony import */ var lodash__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash__WEBPACK_IMPORTED_MODULE_0__);
-
-/*
- * computeTicks:
- * -------------
- * @param extent - d3 extent
- * @return array of ticks.
- *
- * Given a d3 extent, will work out the ticks for a domain.
- */
-
-var computeTicks = function computeTicks(extent) {
- var nice = d3.scale.linear().domain(extent).nice().ticks();
-
- if (nice.length < 9) {
- return nice;
- } // else if (nice.length % 2 === 0) {
- // let diff = nice[nice.length - 1] - nice[nice.length - 2];
- // nice.push(nice[nice.length - 1] + diff);
- // }
-
-
- return nice.filter(function (d, i) {
- return i % 2 === 0;
- });
-};
-/*
- * getColours:
- * -----------
- * looks for elements in the page with a class of "colour" & builds
- * a map of colournames -> hex.
- */
-
-
-var getColours = function getColours() {
- var output = {};
- var colours = document.getElementsByClassName("colour-palette");
-
- if (colours.length === 0) {
- return output;
- }
-
- var children = document.getElementsByClassName("colour");
-
- if (children.length === 0) {
- return output;
- }
-
- lodash__WEBPACK_IMPORTED_MODULE_0___default.a.each(children, function (value, i) {
- var classNames = value.className,
- el = document.getElementsByClassName(classNames),
- bg = window.getComputedStyle(el[0], null).getPropertyValue('background-color');
- output[classNames.split(' ')[0]] = bg;
- });
-
- return output; // .each(function(i, el) {
- // console.log(i, el)
- // // let classNames = $(el).attr('class');
- // // self.set(classNames.split(' ')[0], $(el).css('background-color'));
- // });
-};
-/*
- * General util functions.
- */
-
-
-var none = function none(obj) {
- return obj === null || obj === undefined;
-},
- isEmpty = function isEmpty(obj) {
- return lodash__WEBPACK_IMPORTED_MODULE_0___default.a.isEmpty(obj);
-},
- present = function present(obj) {
- return isEmpty(obj) || typeof obj === 'string' && /\S/.test(obj) === false;
-};
-
-
-
-/***/ }),
-
-/***/ "./node_modules/cache/index.js":
-/*!*************************************!*\
- !*** ./node_modules/cache/index.js ***!
- \*************************************/
-/*! no static exports found */
-/***/ (function(module, exports) {
-
-
-// Copyright 2017 Sleepless Software Inc. All rights reserved.
-
-function Cache(ttl) {
-
- var me = this;
-
- me.now = function() { return (new Date()).getTime() }
- me.ttl = ttl || 0;
- me.data = {}
-
- me.get = function(key) {
- var val = null
- var obj = me.data[key]
- if(obj) {
- val = obj.val
- if(me.now() >= obj.expires) {
- val = null
- delete me.data[key]
- }
- }
- return val
- }
-
- me.del = function(key) {
- var oldval = me.get(key);
- delete me.data[key]
- return oldval
- }
-
- me.put = function(key, val, ttl) {
- if(ttl === undefined) {
- ttl = me.ttl;
- }
- var oldval = me.del(key);
- if(val !== null)
- me.data[ key ] = { expires: me.now() + ttl, val: val }
- return oldval
- }
-
-}
-
-module.exports = Cache;
-
-
-
-/***/ }),
-
-/***/ "./node_modules/chroma-js/chroma.js":
-/*!******************************************!*\
- !*** ./node_modules/chroma-js/chroma.js ***!
- \******************************************/
-/*! no static exports found */
-/***/ (function(module, exports, __webpack_require__) {
-
+ * @license
+ * Lodash