From a7f770231d8967b9b7e21fd8be8cddf8d7ebe17a Mon Sep 17 00:00:00 2001 From: Mark Daggett Date: Wed, 23 Jul 2014 15:59:10 -0500 Subject: [PATCH] small update to allow the line label to have its own distinct classname by default. --- d4.js | 10 ++++++---- d4.min.js | 4 ++-- src/features/line-series-labels.js | 10 ++++++---- test/lib/d4.js | 10 ++++++---- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/d4.js b/d4.js index 8cb42920..5483ee2a 100644 --- a/d4.js +++ b/d4.js @@ -3206,8 +3206,8 @@ }.bind(this)); }, - pointLabelText: function(d) { - var str = this.x.$key + ': ' + d[this.x.$key]; + pointLabelText: function(d, datum) { + var str = datum.key + ' ' + this.x.$key + ': ' + d[this.x.$key]; str += ' ' + this.y.$key + ': ' + d[this.y.$key]; return str; }, @@ -3221,7 +3221,7 @@ label .style('display', null) .attr('transform', 'translate(5,' + offset + ')') - .text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d)); + .text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d, datum)); }, showDataPoint: function(d, datum) { @@ -3255,7 +3255,9 @@ .attr('x', d4.functor(scope.accessors.x).bind(this)) .attr('y', d4.functor(scope.accessors.y).bind(this)) .attr('data-key', d4.functor(scope.accessors.key).bind(this)) - .attr('class', d4.functor(scope.accessors.classes).bind(this)); + .attr('class', function(d, n) { + return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' seriesLabel'; + }.bind(this)); displayXValue.bind(this)(scope, data, selection); return label; diff --git a/d4.min.js b/d4.min.js index c6d4216d..bd9e7f29 100644 --- a/d4.min.js +++ b/d4.min.js @@ -9,5 +9,5 @@ (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors Underscore may be freely distributed under the MIT license. */ -(function(){"use strict";var t=this,e={},n=function(t){return t instanceof n?t:this instanceof n?(this.d4Wrapped=t,void 0):new n(t)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=n),exports.d4=n):t.d4=n,n.charts={},n.features={},n.parsers={},n.builders={};var r=n.each=n.forEach=function(t,n,r){var s,i,a=Array.prototype.forEach;if(null!==t)if(a&&t.forEach===a)t.forEach(n,r);else if(t.length===+t.length){for(s=0,i=t.length;i>s;s++)if(n.call(r,t[s],s,t)===e)return}else{var c=d3.keys(t);for(s=0,i=c.length;i>s;s++)if(n.call(r,t[c[s]],c[s],t)===e)return}},s=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},i=function(t,e,r,s){Object.defineProperty(t,e,{configurable:!0,get:function(){return n.functor(s)()},set:function(){a(" You cannot directly assign values to the {0} property. Instead use the {1}() function.",e,r)}})},a=n.err=function(){var t,e=Array.prototype.slice.call(arguments),n=e.shift();throw r(e,function(e,r){t=RegExp("\\{"+r+"\\}","gi"),n=n.replace(t,e)}),Error("[d4] "+n)},c=function(t){return r(["link"],function(e){(!t[e]||n.isNotFunction(t[e]))&&a("The supplied builder does not have a {0} function",e)}),t},u=function(t){return this.builder||(this.builder=c(t.bind(this)())),this},o=function(t,e,r){if(n.isNotFunction(r)){var s="$"+e;i(t,s,e,r)}},d=function(t,e,r,i){var a=r;n.isDefined(i)&&(a=i+s(r)),t[a]=function(n){return arguments.length?(o(t,r,n),e[r]=n,t):e[r]},o(t,r,e[r])},h=function(t,e,n,s){r(n,function(n){d(t,e,n,s)})},f=function(t){var e=t.accessors;e&&h(t,t.accessors,d3.keys(e))},l=function(t,e){r(d3.keys(e.axes),function(n){t[n]=function(r){return F.bind(e)(n,r),t},r(d3.keys(e.axes[n].accessors),function(r){t[n][r]=e.axes[n][r]})})},y=function(t){var e=d3.keys(d3.scale);e.push("time"),e.push("time.utc"),0>e.indexOf(t)&&a('The scale type: "{0}" is unrecognized. D4 only supports these scale types: {1}',t,e.sort().join(", "))},x=function(t,e,r){n.createAccessorProxy(e,t),e.scale=function(t){return arguments.length?(e.accessors.scale=t,r(),e):e.accessors.scale}},b=function(t,e,n){var s;switch(y(n.accessors.scale),!0){case"time"===n.accessors.scale:s=d3.time.scale();break;case"time.utc"===n.accessors.scale:s=d3.time.scale.utc();break;default:s=d3.scale[n.accessors.scale]()}f(n),e[t]=s,x(s,e.axes[t],function(){b(t,e,n)}),r(d3.keys(e.axes[t].accessors),function(n){i(e[t],"$"+n,e.axes[t][n],e.axes[t][n])})},v=function(t,e,r){e.axes[t]={accessors:n.extend({key:t,min:void 0,max:void 0},r)},b(t,e,e.axes[t])},p=function(t){r(d3.keys(t.axes),function(e){v(e,t,t.axes[e])}),n.isUndefined(t.axes.x)&&v("x",t,{scale:"ordinal"}),n.isUndefined(t.axes.y)&&v("y",t,{scale:"linear"})},g=function(t,e){var r=n.functor({link:function(t,e){n.builders[t.x.$scale+"ScaleForNestedData"](t,e,"x"),n.builders[t.y.$scale+"ScaleForNestedData"](t,e,"y")}}),s=n.merge({},t.accessors);delete t.accessors;var i=n.merge({axes:{},features:{},height:400,margin:{top:20,right:20,bottom:40,left:40},mixins:[],outerHeight:460,outerWidth:460,width:400},t);return i=n.merge(i,s),p(i),u.bind(i)(e||r),i.accessors=["width","height","valueKey"].concat(d3.keys(s)||[]),i},m=function(t,e){e&&r(d3.keys(t._proxiedFunctions),function(n){r(t._proxiedFunctions[n],function(t){e[n].apply(e,t)})})},k=function(t,e,r){var s=t.features[e];return n.isFunction(s.prepare)&&(r=s.prepare.bind(t)(r),n.isUndefined(r)&&a('"feature.prepare()" must return a data array. However, the prepare function for the "{0}" feature did not',e)),r},$=function(t,e){var n,r;t.mixins.forEach(function(s){n=k(t,s,e),r=t.features[s].render.bind(t)(t.features[s],n,t.chartArea),m(t.features[s],r)})},A=function(t,e){t.builder?(t.builder.link(t,e),$(t,e)):a("No builder defined")},S=function(t){this.svg=n.appendOnce(d3.select(t),"svg.d4.chart").attr("width",Math.max(0,this.width+this.margin.left+this.margin.right)).attr("height",Math.max(0,this.height+this.margin.top+this.margin.bottom)),n.appendOnce(this.svg,"defs"),n.appendOnce(this.svg,"g.margins").attr("transform","translate("+this.margin.left+","+this.margin.top+")"),this.chartArea=n.appendOnce(this.svg.select("g.margins"),"g.chartArea")},O=function(t,e){var r=n.parsers.nestedGroup().x(t.x.$key).y(t.y.$key).nestKey(t.x.$key).value(t.valueKey)(e);return r.data},w=function(t,e){var r,s,i=!1;return n.isUndefined(t.valueKey)&&(t.valueKey=t.y.$key),e.length>0&&(s=e[0],n.isArray(s)?i=!0:(r=d3.keys(s),0>=r.indexOf("key")+r.indexOf("values")&&(i=!0))),i?O(t,e):e},L=function(t){return function(e){e.each(function(e){e=w(t,e),S.bind(t,this)(),A(t,e)})}},C=function(t,e){return t.overrides?t.overrides(e):{}},M=function(t,e,r){n.isDefined(r)?(r=Math.max(Math.min(r,t.length),0),t.splice(r,0,e)):t.push(e)},z=function(t){t._proxiedFunctions={on:[]},t.on=function(){t._proxiedFunctions.on.push(Array.prototype.slice.call(arguments))}},B=function(t){f(t)},N=function(t){z(t),n.each(t.proxies,function(e){n.isUndefined(e.target)&&a("You included a feature which has a malformed proxy target.",t.name),n.createAccessorProxy(t,e.target,e.prefix)})},D=function(t){t||a("You need to supply an object or array of objects to mixin to the chart.");var e=n.flatten([t]);n.each(e,function(t){var e=t.name,r=C.bind(this)(t,e),s={proxies:[]};t[e]=n.merge(n.merge(s,t.feature(e)),r),n.extend(this.features,t),M(this.mixins,e,t.index),N(this.features[e]),B(this.features[e])}.bind(this))},K=function(t){var e=[];n.isUndefined(t)&&a("A string or array of names is required in order to mixout a chart feature."),e.push(t),n.each(n.flatten(e),function(t){delete this.features[t],this.mixins=this.mixins.filter(function(e){return e!==t})}.bind(this))},T=function(t,e){var r=this.features[t];n.isNotFunction(e)&&a("You must supply a continuation function in order to use a chart feature."),r?e.bind(this)(r):a('Could not find feature: "{0}", maybe you forgot to mix it in?',t)},F=function(t,e){var r=this.axes[t];n.isNotFunction(e)&&a("You must supply a continuation function in order to use a chart axis."),r?e.bind(this)(r):a('Could not find axis: "{0}", maybe you forgot to define it?',t)},P=function(t){var e,r,s=t,i="[\\x20\\t\\r\\n\\f]",a="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",c=a.replace("w","w#"),u="\\["+i+"*("+a+")"+i+"*(?:([*^$|!~]?=)"+i+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+c+")|)|)"+i+"*\\]",o=["TAG","ID","CLASS"],d={ID:RegExp("#("+a+")"),CLASS:RegExp("\\.("+a+")"),TAG:RegExp("^("+a.replace("w","w*")+")"),ATTR:RegExp(""+u)},h=function(t){for(e=!1,f[t]=[],r=!0;r;)r=d[t].exec(s),null!==r&&(e=r.shift(),f[t].push(r[0]),s=s.slice(e.length))},f={};return n.each(o,h),n.each(o,function(t){for(;s&&(f[t]=f[t].join(" "),e););}),f},R=function(t){var e=L(t);return h(e,t.margin,d3.keys(t.margin),"margin"),h(e,t,t.accessors),l(e,t),e.axes=function(n){return arguments.length?(n(t.axes),e):t.axes},e.builder=function(n){return t.builder=c(n.bind(t)()),e},e.clone=function(){var e=n.extend({},t);return R(e)},e.features=function(){return t.mixins},e.margin=function(r){return arguments.length?(t.margin=n.merge(t.margin,n.functor(r)()),e.height(e.outerHeight()-t.margin.top-t.margin.bottom),e.width(e.outerWidth()-t.margin.left-t.margin.right),e):t.margin},e.mixin=function(n){return D.bind(t)(n),e},e.mixout=function(n,r){return K.bind(t)(n,r),e},e.outerHeight=function(r){var s=n.functor(r)();return arguments.length?(t.outerHeight=s,e.height(s-t.margin.top-t.margin.bottom),e):t.outerHeight},e.outerWidth=function(r){var s=n.functor(r)();return arguments.length?(t.outerWidth=s,e.width(s-t.margin.left-t.margin.right),e):t.outerWidth},e.using=function(n,r){return T.bind(t)(n,r),e},e};n.appendOnce=function(t,e){var n,r=t.selectAll(e);return r.empty()&&(n=P(e),r=t.append(n.TAG).attr("class",n.CLASS.join(" ")),n.ID&&r.attr("id",n.ID.pop())),r},n.baseChart=function(t){var e=g(t&&t.config||{},t&&t.builder||void 0);return R(e)},n.builder=function(t,e){return n.builders[t]=e,n.builders[t]},n.chart=function(t,e){return n.charts[t]=e,n.charts[t]},n.createAccessorProxy=function(t,e,i){r(d3.keys(e),function(r){var a=r;n.isDefined(i)&&(a=i+s(r)),t[a]=function(){return arguments.length?(e[r].$dirty=!0,t[a].$dirty=!0,e[r].apply(e,arguments),t):e[r]()},e[r].$dirty=!1,t[a].$dirty=!1})},n.extend=function(t){return r(Array.prototype.slice.call(arguments,1),function(e){var r=function(t){var e=[];return n.each(t,function(t){var r=t;n.isObject(t)&&(r=n.extend({},t)),e.push(r)}),e};if(e)for(var s in e)if(e[s]&&e[s].constructor&&e[s].constructor===Object)t[s]=t[s]||{},n.extend(t[s],e[s]);else if(n.isArray(e[s])){var i=r(e[s].slice());t[s]=n.isArray(t[s])?t[s].concat(i):i}else t[s]=e[s]}),t},n.feature=function(t,e){return n.features[t]=e,n.features[t]},n.flatten=function(t){var e=t.reduce(function(t,e){return t=n.isArray(t)?t:[t],e=n.isArray(e)?e:[e],t.concat(e)});return n.isArray(e)?e:[e]},n.functor=function(t){return n.isFunction(t)?t:function(){return t}},n.isArray=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},n.isContinuousScale=function(t){return n.isDefined(t.rangeRound)},n.isDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)},n.isDefined=function(t){return!n.isUndefined(t)},n.isFunction=function(t){return!!(t&&t.constructor&&t.call&&t.apply)},n.isObject=function(t){return null!==t&&"object"==typeof t},n.isOrdinalScale=function(t){return n.isUndefined(t.rangeRound)},n.isNotFunction=function(t){return!n.isFunction(t)},n.isNotNull=function(t){return!n.isNull(t)},n.isNull=function(t){return null===t},n.isUndefined=function(t){return t===void 0},n.merge=function(t,e){return n.extend(n.extend({},t),e)},n.parser=function(t,e){return n.parsers[t]=e,n.parsers[t]}}).call(this),function(){"use strict";d4.helpers={};var t=function(t,e){var n=5,r=0,s=function(t,e){return!(t.righte.right||t.bottome.bottom)},i=function(t){var a,c,u,o=!1,d=0;t.each(function(){d>0&&(a=this.getBoundingClientRect(),c=u.getBoundingClientRect(),s(a,c)&&(e.bind(this)(c,a),o=!0)),d++,u=this}),o&&n>r&&(r++,i.bind(this)(t))};i.bind(this)(t)};d4.helpers.staggerTextVertically=function(e,n){var r=function(t,e){var r=d3.select(this),s=r.attr("data-last-vertical-offset")||1,i=t.top-e.top,a=(e.height-i+s)*n;r.attr("transform","translate(0,"+a+")"),r.attr("data-last-vertical-offset",Math.abs(a))};t.bind(this)(e,r)},d4.helpers.rotateText=function(t){return function(e){e.each(function(){var n=d3.transform(d3.functor(t).apply(this,arguments));e.attr("alignment-baseline","central"),e.style("dominant-baseline","central"),90>=n.rotate&&n.rotate>=-90?(e.attr("text-anchor","begin"),e.attr("transform",""+n)):(e.attr("text-anchor","end"),n.rotate=(n.rotate>0?-1:1)*(180-Math.abs(n.rotate)),e.attr("transform",""+n))})}},d4.helpers.staggerTextHorizontally=function(e,n){var r=function(t,e){var r=d3.select(this),s=r.attr("data-last-horizontal-offset")||1,i=t.left-e.left,a=(e.width-i+s)*n;r.attr("transform","translate("+a+", 0)"),r.attr("data-last-horizontal-offset",Math.abs(a))};t.bind(this)(e,r)},d4.helpers.textSize=function(t,e){var n={height:0,width:0,x:0,y:0};if(d4.isDefined(t)){var r=d3.select("body").append("svg").attr("class",""+e);r.append("text").attr("x",-5e3).text(t),n=r.node().getBBox(),r.remove()}return n},d4.helpers.wrapText=function(t,e){t.each(function(){var t,n=d3.select(this),r=n.text().split(/\s+/).reverse(),s=[],i=0,a=1.1,c=n.attr("x"),u=n.attr("y"),o=parseFloat(n.attr("dy")),d=n.text(null).append("tspan").attr("x",c).attr("y",u).attr("dy",o+"em");for(t=r.pop();t;)s.push(t),d.text(s.join(" ")),d.node().getComputedTextLength()>e-Math.abs(c)&&(s.pop(),d.text(s.join(" ")),s=[t],d=n.append("tspan").attr("x",c).attr("y",u).attr("dy",++i*a+o+"em").text(t)),t=r.pop()})}}.call(this),function(){"use strict";d4.chart("column",function(){return d4.baseChart().mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("donut",function(){return d4.baseChart({config:{accessors:{radius:function(){return Math.min(this.width,this.height)/2},arcWidth:function(t){return t/3}}}}).mixin([{name:"arcs",feature:d4.features.arcSeries},{name:"arcLabels",feature:d4.features.arcLabels}])})}.call(this),function(){"use strict";d4.chart("groupedColumn",function(){var t=function(){return{accessors:{x:function(t,e){var n=this.x.rangeBand()/this.groupsOf,r=this.x(t[this.x.$key])+n*e,s=.1*n;return r+n/2-s}}}};return d4.baseChart({config:{accessors:{groupsOf:1}}}).mixin([{name:"bars",feature:d4.features.groupedColumnSeries},{name:"barLabels",feature:d4.features.stackedLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("groupedRow",function(){var t=function(){return{accessors:{y:function(t,e){var n=this.y.rangeBand()/this.groupsOf,r=this.y(t[this.y.$key])+n*e,s=.1*n;return r+n/4+s}}}};return d4.baseChart({config:{accessors:{groupsOf:1},margin:{top:20,right:40,bottom:20,left:40},axes:{x:{scale:"linear"},y:{scale:"ordinal"}}}}).mixin([{name:"bars",feature:d4.features.groupedColumnSeries},{name:"barLabels",feature:d4.features.stackedLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("line",function(){return d4.baseChart().mixin([{name:"lineSeries",feature:d4.features.lineSeries},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis},{name:"lineSeriesLabels",feature:d4.features.lineSeriesLabels}])})}.call(this),function(){"use strict";d4.chart("row",function(){return d4.baseChart({config:{margin:{top:20,right:40,bottom:20,left:40},valueKey:"x",axes:{x:{scale:"linear"},y:{scale:"ordinal"}}}}).mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";var t=function(){var t=function(t,e){d4.builders[t.x.$scale+"ScaleForNestedData"](t,e,"x"),d4.builders[t.y.$scale+"ScaleForNestedData"](t,e,"y"),d4.builders[t.z.$scale+"ScaleForNestedData"](t,e,"z");var n=5,r=Math.max(n+1,(t.height-t.margin.top-t.margin.bottom)/10);t.z.range([n,r])},e={link:function(e,n){t.bind(this)(e,n)}};return e},e=function(t,e){var n=this[t];return n(e[n.$key])+n.rangeBand()/2},n=function(t,e){var n,r=this[t],s=Math.abs(r(e.y0)-r(e.y0+e.y))/2,i=10;return"x"===t&&(s*=-1,i*=-1),d4.isDefined(e.y0)?(n=e.y0+e.y,r(n)+s):r(e[r.$key])-i},r=function(){return{accessors:{x:function(t){return d4.isOrdinalScale(this.x)?e.bind(this)("x",t):n.bind(this)("x",t)},y:function(t){return d4.isOrdinalScale(this.y)?e.bind(this)("y",t):n.bind(this)("y",t)}}}},s=function(){return{accessors:{cx:function(t){return this.x(t[this.x.$key])},cy:function(t){return this.y(t[this.y.$key])},r:function(t){return this.z(t[this.z.$key])}}}};d4.chart("scatterPlot",function(){return d4.baseChart({builder:t,config:{axes:{x:{scale:"linear"},z:{scale:"linear"}}}}).mixin([{name:"circles",feature:d4.features.circleSeries,overrides:s},{name:"circleLabels",feature:d4.features.stackedLabels,overrides:r},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("stackedColumn",function(){var t=function(){var t=function(t){var e=[];return t.map(function(t){t.values.map(function(t){e.push(t)})}),e},e=function(t){return d3.nest().key(function(t){return t[this.x.$key]}.bind(this)).rollup(function(t){var e=d3.sum(t,function(t){return t[this.valueKey]}.bind(this)),n=d3.sum(t,function(t){return Math.max(0,t[this.valueKey])}.bind(this));return{text:e,size:n}}.bind(this)).entries(t)},n=function(n){return e.bind(this)(t(n)).map(function(t){var e={};return e[this.x.$key]=t.key,e.size=t.values.size,e[this.valueKey]=t.values.text,e}.bind(this))};return{accessors:{y:function(t){var e=5;return this.y(t.size)-e}},prepare:function(t){return n.bind(this)(t)}}};return d4.baseChart().mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"connectors",feature:d4.features.stackedColumnConnectors},{name:"columnTotals",feature:d4.features.columnLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("stackedRow",function(){var t=function(){var t=function(t){var e=[];return t.map(function(t){t.values.map(function(t){e.push(t)})}),e},e=function(t){return d3.nest().key(function(t){return t[this.y.$key]}.bind(this)).rollup(function(t){var e=d3.sum(t,function(t){return t[this.valueKey]}.bind(this)),n=d3.sum(t,function(t){return Math.max(0,t[this.valueKey])}.bind(this));return{text:e,size:n}}.bind(this)).entries(t)},n=function(n){return e.bind(this)(t(n)).map(function(t){var e={};return e[this.y.$key]=t.key,e.size=t.values.size,e[this.valueKey]=t.values.text,e}.bind(this))};return{accessors:{x:function(t){var e=5;return this.x(t.size)+e}},prepare:function(t){return n.bind(this)(t)}}};return d4.baseChart({config:{margin:{top:20,right:40,bottom:20,left:40},axes:{x:{scale:"linear"},y:{scale:"ordinal"}}}}).mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"connectors",feature:d4.features.stackedColumnConnectors},{name:"columnTotals",feature:d4.features.columnLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";var t=function(){return{accessors:{y:function(t){if(d4.isContinuousScale(this.y)){var e=t.y0+t.y-Math.min(0,t.y);return this.y(e)}return this.y(t[this.y.$key])},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key]);var e=t.y0+t.y-Math.max(0,t.y);return this.x(e)},width:function(t){return d4.isOrdinalScale(this.x)?this.x.rangeBand():Math.abs(this.x(t.y0)-this.x(t.y0+t.y))},height:function(t){return d4.isContinuousScale(this.y)?Math.abs(this.y(t.y0)-this.y(t.y0+t.y)):this.y.rangeBand()},classes:function(t,e,n){var r=t.y>0?"positive":"negative";return n>0&&0===t.y0&&(r="subtotal"),"bar fill item"+e+" "+r+" "+t[this.y.$key]}}}},e=function(){return{accessors:{y:function(t){if(d4.isContinuousScale(this.y)){var e=Math.abs(this.y(t.y0)-this.y(t.y0+t.y)),n=t.y0+t.y-Math.max(0,t.y);return this.y(n)-10-e}return this.y(t[this.y.$key])+this.y.rangeBand()/2},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key])+this.x.rangeBand()/2;var e=t.y0+t.y-Math.max(0,t.y),n=Math.abs(this.x(t.y0)-this.x(t.y0+t.y));return this.x(e)+10+n},text:function(t){return t[this.valueKey]}}}},n=function(){var t=function(t,e){var n;return"x"===e?[0,t.width]:(n=[0,t.height],d4.isOrdinalScale(t.x)?n.reverse():n)},e=function(e,n,r){var s=r.map(function(t){return t.key}.bind(this));e[n].domain(s).rangeRoundBands(t.bind(this)(e,n),e.xRoundBands||.3)},n=function(e,n,r){var s=d3.extent(d3.merge(r.map(function(t){return d3.extent(t.values,function(t){return t.y+t.y0})})));s[0]=Math.min(0,s[0]),e[n].domain(s),e[n].range(t.bind(this)(e,n)).clamp(!0).nice()},r=function(t,r){d4.isOrdinalScale(t.x)?(e.bind(this)(t,"x",r),n.bind(this)(t,"y",r)):(e.bind(this)(t,"y",r),n.bind(this)(t,"x",r))},s={link:function(t,e){r.bind(this)(t,e)}};return s};d4.chart("waterfall",function(){return d4.baseChart({builder:n}).mixin([{name:"bars",feature:d4.features.rectSeries,overrides:t},{name:"connectors",feature:d4.features.waterfallConnectors},{name:"columnLabels",feature:d4.features.stackedLabels,overrides:e},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.feature("arcLabels",function(t){var e=d3.svg.arc();return{accessors:{classes:function(t,e){return"arc stroke fill series"+e},duration:750,key:function(t,e){return(t.key||0)+e},text:function(t){return t.value},x:function(){return this.width/2},y:function(){return this.height/2}},proxies:[{target:e}],render:function(n,r,s){var i=function(t){return 180/Math.PI*(t.startAngle+t.endAngle)/2-90},a=function(t){var n=d3.interpolate(this._current,t);return this._current=n(0),function(r){return"translate("+e.centroid(n(r))+") rotate("+i(t)+")"}},c=d4.functor(this.radius).bind(this)(),u=d4.functor(n.accessors.x).bind(this)(),o=d4.functor(n.accessors.y).bind(this)();e.innerRadius(c).outerRadius(c+10);var d=s.selectAll("g."+t).data(r);d.enter().append("g").attr("class",t).attr("transform","translate("+u+","+o+")");var h=d.selectAll("text").data(function(t){return t.values},d4.functor(n.accessors.key).bind(this));return h.transition().duration(d4.functor(n.accessors.duration).bind(this)()).attrTween("transform",a),h.enter().append("text").attr("dy",5).attr("transform",function(t){return"translate("+e.centroid(t)+") rotate("+i(t)+")"}).style("text-anchor","start").text(d4.functor(n.accessors.text).bind(this)).attr("class",d4.functor(n.accessors.classes).bind(this)).attr("data-key",d4.functor(n.accessors.key).bind(this)).attr("d",e).each(function(t){this._current=t}),h.exit().remove(),d.exit().remove(),e}}})}.call(this),function(){"use strict";d4.feature("arcSeries",function(t){var e=d3.svg.arc();return{accessors:{classes:function(t,e){return"arc stroke fill series"+e},duration:750,key:function(t,e){return(t.key||0)+e},x:function(){return this.width/2},y:function(){return this.height/2}},proxies:[{target:e}],render:function(n,r,s){var i=function(t){var n=d3.interpolate(this._current,t);return this._current=n(0),function(t){return e(n(t))}},a=d4.functor(this.radius).bind(this)(),c=d4.functor(n.accessors.x).bind(this)(),u=d4.functor(n.accessors.y).bind(this)(),o=d4.functor(this.arcWidth).bind(this)(a);e.innerRadius(a).outerRadius(a-o);var d=s.selectAll("g."+t).data(r);d.enter().append("g").attr("class",t).attr("transform","translate("+c+","+u+")");var h=d.selectAll("path").data(function(t){return t.values},d4.functor(n.accessors.key).bind(this));return h.transition().duration(d4.functor(n.accessors.duration).bind(this)()).attrTween("d",i),h.enter().append("path").attr("class",d4.functor(n.accessors.classes).bind(this)).attr("data-key",d4.functor(n.accessors.key).bind(this)).attr("d",e).each(function(t){this._current=t}),h.exit().remove(),d.exit().remove(),e}}})}.call(this),function(){"use strict";d4.feature("arrow",function(t){return{accessors:{classes:"line",tipSize:6,x1:function(){return this.x(0)},x2:function(){return this.x(this.width)},y1:function(){return this.y(0)},y2:function(){return this.y(this.height)}},render:function(e,n,r){var s=this.svg.select("defs");d4.appendOnce(s,"marker#"+t+"-end").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",d4.functor(e.accessors.tipSize).bind(this)).attr("markerHeight",d4.functor(e.accessors.tipSize).bind(this)).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z"),d4.appendOnce(s,"marker#"+t+"-start").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",d4.functor(e.accessors.tipSize).bind(this)()).attr("markerHeight",d4.functor(e.accessors.tipSize).bind(this)).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z"),d4.appendOnce(r,"g."+t);var i=d4.appendOnce(this.svg.select("."+t),"line").attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x1",d4.functor(e.accessors.x1).bind(this)).attr("x2",d4.functor(e.accessors.x2).bind(this)).attr("y1",d4.functor(e.accessors.y1).bind(this)).attr("y2",d4.functor(e.accessors.y2).bind(this)).attr("marker-end","url(#"+t+"-end)");return i}}})}.call(this),function(){"use strict";d4.feature("brush",function(t){var e=d3.svg.brush(),n=function(t){return d4.isDefined(t.$scale)?t:d4.functor(t).bind(this)()},r=function(t){return d4.isNull(e.y())?function(e){var n=e[this.x.$key],r=n>=t[0]&&t[1]>=n;return r}.bind(this):d4.isNull(e.x())?function(e){var n=e[this.y.$key],r=n>=t[0]&&t[1]>=n;return r}.bind(this):d4.isNotNull(e.x())&&d4.isNotNull(e.y())?function(e){var n=t[0][0]<=e[this.x.$key]&&e[this.x.$key]<=t[1][0]&&t[0][1]<=e[this.y.$key]&&e[this.y.$key]<=t[1][1];return n}.bind(this):void 0},s={accessors:{brushable:function(){return d3.selectAll(".brushable")},brushend:function(){this.svg.classed("selecting",!d3.event.target.empty())},brushmove:function(){var e=d3.event.target.extent(),n=r.bind(this)(e);this.features[t].accessors.brushable().classed("selected",n)},brushstart:function(){this.svg.classed("selecting",!0)},clamp:e.clamp,clear:e.clear,extent:e.extent,empty:e.empty,event:e.event,selection:function(t){return t},x:function(){return null},y:function(){return null}},render:function(r,s,i){var a=n.bind(this)(r.accessors.x),c=n.bind(this)(r.accessors.y);null!==typeof a&&e.x(a),null!==typeof c&&e.y(c),e.on("brushstart",d4.functor(r.accessors.brushstart).bind(this)).on("brush",d4.functor(r.accessors.brushmove).bind(this)).on("brushend",d4.functor(r.accessors.brushend).bind(this)),d4.appendOnce(i,"g."+t).call(e),r.accessors.selection.bind(this)(i.select(".brush")),r.accessors.brush.bind(this)(e)}};return s})}.call(this),function(){"use strict";d4.feature("columnLabels",function(t){var e=5,n=function(){return d4.isContinuousScale(this.y)?"middle":"start"};return{accessors:{key:function(t,e){return(t.key||0)+e},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key])+this.x.rangeBand()/2;var e=Math.abs(this.x(t[this.x.$key])-this.x(0));return this.x(t[this.x.$key])-e/2},y:function(t){if(d4.isOrdinalScale(this.y))return this.y(t[this.y.$key])+this.y.rangeBand()/2+e;var n=Math.abs(this.y(t[this.y.$key])-this.y(0));return(0>t[this.y.$key]?this.y(t[this.y.$key])-n:this.y(t[this.y.$key]))-e},text:function(t){return t[this.valueKey]}},render:function(e,r,s){s.append("g").attr("class",t);var i=this.svg.select("."+t).selectAll("."+t).data(r,d4.functor(e.accessors.key).bind(this));return i.enter().append("text"),i.exit().remove(),i.attr("class","column-label").text(d4.functor(e.accessors.text).bind(this)).attr("text-anchor",n.bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)),i}}})}.call(this),function(){"use strict";d4.feature("grid",function(t){var e=d3.svg.axis(),n=d3.svg.axis();return{accessors:{formatXAxis:function(t){return t.orient("bottom")},formatYAxis:function(t){return t.orient("left")}},proxies:[{target:e,prefix:"x"},{target:n,prefix:"y"}],render:function(r,s,i){e.scale(this.x),n.scale(this.y);var a=d4.functor(r.accessors.formatXAxis).bind(this)(e),c=d4.functor(r.accessors.formatYAxis).bind(this)(n);i.append("g").attr("class","grid border "+t).attr("transform","translate(0,0)").append("rect").attr("x",0).attr("y",0).attr("width",this.width).attr("height",this.height),i.append("g").attr("class","x grid "+t).attr("transform","translate(0,"+this.height+")").call(a.tickSize(-this.height,0,0).tickFormat("")),i.append("g").attr("class","y grid "+t).attr("transform","translate(0,0)").call(c.tickSize(-this.width,0,0).tickFormat(""))}}})}.call(this),function(){"use strict";d4.feature("groupedColumnSeries",function(t){var e=function(t){return t>0?"positive":"negative"},n=function(t,e,n){var r=this[t],s=r.rangeBand()/this.groupsOf,i=r(e[r.$key])+s*n;return i},r=function(t){var e=this[t],n=e.rangeBand()/this.groupsOf,r=.1*n;return n-r},s=function(t,e){var n=this[t];return Math.abs(n(e[n.$key])-n(0))},i=function(t,e){var n,r=this[t];return"y"===t?0>e[r.$key]?r(0):r(e[r.$key]):(n=e[r.$key]-Math.max(0,e[r.$key]),r(n))};return{accessors:{classes:function(t,n){return"bar fill item"+n+" "+e(t[this.valueKey])+" "+t[this.valueKey]},height:function(t){return d4.isOrdinalScale(this.y)?r.bind(this)("y"):s.bind(this)("y",t)},key:function(t,e){return(t.key||0)+e},rx:0,ry:0,width:function(t){return d4.isOrdinalScale(this.x)?r.bind(this)("x"):s.bind(this)("x",t)},x:function(t,e){return d4.isOrdinalScale(this.x)?n.bind(this)("x",t,e):i.bind(this)("x",t,e)},y:function(t,e){return d4.isOrdinalScale(this.y)?n.bind(this)("y",t,e):i.bind(this)("y",t,e)}},render:function(e,n,r){r.append("g").attr("class",t);var s=this.svg.select("."+t).selectAll("g").data(n,d4.functor(e.accessors.key).bind(this));s.enter().append("g"),s.exit().remove(),s.attr("class",function(t,e){return"series"+e+" "+this.x.$key}.bind(this));var i=s.selectAll("rect").data(function(t){return t.values}.bind(this));return i.enter().append("rect").attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)).attr("ry",d4.functor(e.accessors.ry).bind(this)).attr("rx",d4.functor(e.accessors.rx).bind(this)).attr("width",d4.functor(e.accessors.width).bind(this)).attr("height",d4.functor(e.accessors.height).bind(this)),i}}})}.call(this),function(){"use strict";d4.feature("lineSeriesLabels",function(t){var e=function(e,n){var r=this.svg.select("."+t).selectAll("."+t+" circle.dataPoint").data(n);r.enter().append("circle"),r.exit().remove(),r.attr("data-key",function(t){return t.key}).style("display","none").attr("r",d4.functor(e.accessors.r).bind(this)()).attr("class",function(t,n){return d4.functor(e.accessors.classes).bind(this)(t,n)+" dataPoint"}.bind(this))},n=function(e,n){var r=this.svg.select("."+t).selectAll("."+t+" text.dataPoint").data(n);r.enter().append("text"),r.exit().remove(),r.attr("data-key",d4.functor(e.accessors.key).bind(this)).style("display","none").attr("class",function(t,n){return d4.functor(e.accessors.classes).bind(this)(t,n)+" dataPoint"}.bind(this))},r=function(e){this.svg.select("."+t).append("rect").attr("class","overlay").style("fill-opacity",0).attr("width",this.width).attr("height",this.height).on("mouseover",function(){this.svg.selectAll("."+t+" .dataPoint").style("display",null)}.bind(this)).on("mouseout",function(){this.svg.selectAll("."+t+" .dataPoint").style("display","none")}.bind(this)).on("mousemove",d4.functor(e.accessors.mouseMove).bind(this))},s=function(t,s){d4.functor(t.accessors.displayPointValue).bind(this)()&&(d4.isNotFunction(this.x.invert)?d4.err(" In order to track the x position of a line series your scale must have an invert() function. However, your {0} scale does not have the invert() function.",this.x.$scale):(n.bind(this)(t,s),e.bind(this)(t,s),r.bind(this)(t)))};return{accessors:{classes:function(t,e){return"stroke series"+e},displayPointValue:!1,key:function(t){return t.key},mouseMove:function(e){var n=function(t,e){return"time"===this.x.$scale?t.getTime()>=e[this.x.$key].getTime():t>=e[this.x.$key]},r=d3.bisector(function(t){return t[this.x.$key]}.bind(this)).right,s=this.svg.select("."+t+" rect.overlay")[0][0],i=this.x.invert(d3.mouse(s)[0]);d4.each(e,function(e,s){var a=r(e.values,i,1),c=e.values[a-1];if(n.bind(this)(i,c)){var u=e.values[a];u=d4.isUndefined(u)?e.values[e.values.length-1]:u;var o=i-c[this.x.$key]>u[this.x.$key]-i?u:c;d4.functor(this.features[t].accessors.showDataPoint).bind(this)(o,e,s),d4.functor(this.features[t].accessors.showDataLabel).bind(this)(o,e,s)}else{var d="."+t+' .dataPoint[data-key="'+e.key+'"]',h=this.svg.select(d);h.style("display","none")}}.bind(this))},pointLabelText:function(t){var e=this.x.$key+": "+t[this.x.$key];return e+=" "+this.y.$key+": "+t[this.y.$key]},r:4.5,showDataLabel:function(e,n,r){var s="."+t+' text.dataPoint[data-key="'+n.key+'"]',i=this.svg.select(s),a=20*r;i.style("display",null).attr("transform","translate(5,"+a+")").text(d4.functor(this.features[t].accessors.pointLabelText).bind(this)(e))},showDataPoint:function(e,n){var r="."+t+' circle.dataPoint[data-key="'+n.key+'"]',s=this.svg.select(r);s.style("display",null).attr("transform","translate("+this.x(e[this.x.$key])+","+this.y(e[this.y.$key])+")")},text:function(t){return t.key},x:function(t){return this.x(t.values[t.values.length-1][this.x.$key])},y:function(t){return this.y(t.values[t.values.length-1][this.y.$key])}},render:function(e,n,r){r.append("g").attr("class",t);var i=this.svg.select("."+t).selectAll("."+t).data(n);return i.enter().append("text"),i.exit().remove(),i.attr("class","line-series-label").text(d4.functor(e.accessors.text).bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)).attr("data-key",d4.functor(e.accessors.key).bind(this)).attr("class",d4.functor(e.accessors.classes).bind(this)),s.bind(this)(e,n,r),i -}}})}.call(this),function(){"use strict";d4.feature("lineSeries",function(t){var e=d3.svg.line();return e.interpolate("linear"),{accessors:{classes:function(t,e){return"line stroke series"+e},key:function(t,e){return(t.key||0)+e},x:function(t){return this.x(t[this.x.$key])},y:function(t){return this.y(t[this.y.$key])}},proxies:[{target:e}],render:function(n,r,s){s.append("g").attr("class",t),e.x(d4.functor(n.accessors.x).bind(this)).y(d4.functor(n.accessors.y).bind(this));var i=s.select("."+t).selectAll("g").data(r,d4.functor(n.accessors.key).bind(this));i.exit().remove(),i.enter().append("g").attr("data-key",function(t){return t.key}).attr("class",d4.functor(n.accessors.classes).bind(this)).append("path").attr("d",function(t){return e(t.values)})}}})}.call(this),function(){"use strict";d4.feature("referenceLine",function(t){return{accessors:{x1:function(){return this.x(this.x.domain()[0])},x2:function(){return this.x(this.x.domain()[1])},y1:function(){return this.y(this.y.domain()[1])},y2:function(){return this.y(this.y.domain()[0])},classes:function(){return"line"}},render:function(e,n,r){r.append("g").attr("class",t);var s=d4.appendOnce(this.svg.select("."+t),"line").attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x1",d4.functor(e.accessors.x1).bind(this)).attr("x2",d4.functor(e.accessors.x2).bind(this)).attr("y1",d4.functor(e.accessors.y1).bind(this)).attr("y2",d4.functor(e.accessors.y2).bind(this));return s}}})}.call(this),function(){"use strict";d4.feature("stackedColumnConnectors",function(t){var e=function(t){return t?0>t?-1:1:0},n=function(t,n,r){return e(t[r])===e(n[r])},r=function(t,e,r,s,i){var a=d4.isOrdinalScale(this.y)?this.x.$key:this.y.$key;return 0!==e&&n(s[r].values[e-1],t,a)?i.bind(this)():0};return{accessors:{x1:function(t){return d4.isOrdinalScale(this.x)?this.x(t[this.x.$key]):this.x(t.y0+t.y)},y1:function(t){return d4.isOrdinalScale(this.y)?this.y(t[this.y.$key]):this.y(t.y0+t.y)},size:function(){return d4.isOrdinalScale(this.x)?this.x.rangeBand():this.y.rangeBand()},classes:function(t,e){return"series"+e}},render:function(e,n,s){s.append("g").attr("class",t);var i=this.svg.select("."+t).selectAll("g").data(n).enter().append("g").attr("class",function(t,e){return"series"+e+" "+this.y.$key}.bind(this)),a=i.selectAll("lines").data(function(t){return t.values}.bind(this));return a.enter().append("line"),a.exit().remove(),a.attr("class",d4.functor(e.accessors.classes).bind(this)).attr("stroke-dasharray","5, 5").attr("x1",function(t,s,i){return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.x1).bind(this)(t)})}.bind(this)).attr("y1",function(t,s,i){var a=d4.isOrdinalScale(this.y)?d4.functor(e.accessors.size).bind(this)(t):0;return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.y1).bind(this)(t)+a})}.bind(this)).attr("x2",function(t,s,i){var a=d4.isOrdinalScale(this.x)?e.accessors.size.bind(this)(t):0;return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.x1).bind(this)(n[i].values[s-1])+a})}.bind(this)).attr("y2",function(t,s,i){return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.y1).bind(this)(n[i].values[s-1])})}.bind(this)),a}}})}.call(this),function(){"use strict";d4.feature("stackedLabels",function(t){var e=function(t){return d4.isDefined(t.y0)?!0:d4.isContinuousScale(this.y)},n=function(t){return e.bind(this)(t)?"middle":"start"},r=function(t,e){var n=this[t];return n(e[n.$key])+n.rangeBand()/2},s=function(t,e){var n,r=this[t],s=Math.abs(r(e.y0)-r(e.y0+e.y))/2,i=10;return"x"===t&&(s*=-1,i*=-1),d4.isDefined(e.y0)?(n=e.y0+e.y,(0>=n?r(e.y0):r(n))+s):(0>=e[r.$key]?r(0):r(e[r.$key]))-i};return{accessors:{classes:"column-label",key:function(t,e){return(t.key||0)+e},stagger:!0,text:function(t){if(!d4.isDefined(t.y0))return t[this.valueKey];if(d4.isOrdinalScale(this.x)){if(Math.abs(this.y(t.y0)-this.y(t.y0+t.y))>20)return t[this.valueKey]}else if(Math.abs(this.x(t.y0)-this.x(t.y0+t.y))>20)return t[this.valueKey]},textAnchor:function(t){return n.bind(this)(t)},x:function(t){return d4.isOrdinalScale(this.x)?r.bind(this)("x",t):s.bind(this)("x",t)},y:function(t){return d4.isOrdinalScale(this.y)?r.bind(this)("y",t):s.bind(this)("y",t)}},render:function(e,n,r){r.append("g").attr("class",t);var s=this.svg.select("."+t).selectAll("g").data(n,d4.functor(e.accessors.key).bind(this));s.enter().append("g").attr("class",function(t,e){return"series"+e+" "+this.x.$key}.bind(this)),s.exit().remove();var i=s.selectAll("text").data(function(t){return t.values}.bind(this));return i.enter().append("text").text(d4.functor(e.accessors.text).bind(this)).attr("text-anchor",d4.functor(e.accessors.textAnchor).bind(this)).attr("class",d4.functor(e.accessors.classes).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)),i.exit().remove(),d4.functor(e.accessors.stagger).bind(this)()&&(d4.isContinuousScale(this.y)?s.selectAll("text").call(d4.helpers.staggerTextVertically,-1):s.selectAll("text").call(d4.helpers.staggerTextHorizontally,1)),s.selectAll("text").call(function(t){var e;d4.each(t,function(t){d4.each(t,function(t){var n=d3.select(t);e=t.getBoundingClientRect(),null===n.attr("transform")&&n.attr("transform","translate(0,"+Math.floor(e.height/2)+")")})})}),i}}})}.call(this),function(){"use strict";var t=function(t){return t>0?"positive":"negative"},e=function(t,e){var n=this[t];return n(e[n.$key])},n=function(t){var e=this[t];return e.rangeBand()},r=function(t,e){var n=this[t];return d4.isDefined(e.y0)?Math.abs(n(e.y0)-n(e.y0+e.y)):Math.abs(n(e[n.$key])-n(0))},s=function(t,e){var n,r=this[t];return d4.isDefined(e.y0)?"y"===t?(n=e.y0+e.y,0>n?r(e.y0):r(n)):(n=e.y0+e.y-Math.max(0,e.y),r(n)):"y"===t?0>e[r.$key]?r(0):r(e[r.$key]):(n=e[r.$key]-Math.max(0,e[r.$key]),r(n))},i=function(e,n,r){return{accessors:{classes:function(e,n){return"bar fill item"+n+" "+t(e[this.valueKey])+" "+e[this.y.$key]},key:function(t,e){return(t.key||0)+e}},render:function(t,s,i){i.append("g").attr("class",e);var a=this.svg.select("."+e).selectAll("g").data(s,d4.functor(t.accessors.key).bind(this));a.enter().append("g").attr("class",function(t,e){return"series"+e+" "+this.y.$key}.bind(this)),a.exit().remove();var c=a.selectAll(n).data(function(t){return t.values});return c.enter().append(n).attr("class",d4.functor(t.accessors.classes).bind(this)),r.bind(this)(t,c),c.exit().remove(),c}}};d4.feature("circleSeries",function(t){var a={accessors:{cx:function(t){var i=0;return d4.isOrdinalScale(this.x)?(i=n.bind(this)("x"),e.bind(this)("x",t)+i/2):(i=r.bind(this)("x",t),s.bind(this)("x",t)+i/2)},cy:function(t){var i=0;return d4.isOrdinalScale(this.y)?(i=n.bind(this)("y"),e.bind(this)("y",t)+i/2):(i=r.bind(this)("y",t),s.bind(this)("y",t)+i/2)},r:function(t){var e,s;return e=d4.isOrdinalScale(this.x)?n.bind(this)("x"):r.bind(this)("x",t),s=d4.isOrdinalScale(this.y)?n.bind(this)("y"):r.bind(this)("y",t),Math.min(e,s)/2}}},c=function(t,e){e.attr("r",d4.functor(t.accessors.r).bind(this)).attr("cx",d4.functor(t.accessors.cx).bind(this)).attr("cy",d4.functor(t.accessors.cy).bind(this))},u=i.bind(this)(t,"circle",c);return d4.merge(u,a)}),d4.feature("ellipseSeries",function(t){var a={accessors:{cx:function(t){var i=0;return d4.isOrdinalScale(this.x)?(i=n.bind(this)("x"),e.bind(this)("x",t)+i/2):(i=r.bind(this)("x",t),s.bind(this)("x",t)+i/2)},cy:function(t){var i=0;return d4.isOrdinalScale(this.y)?(i=n.bind(this)("y"),e.bind(this)("y",t)+i/2):(i=r.bind(this)("y",t),s.bind(this)("y",t)+i/2)},rx:function(t){return d4.isOrdinalScale(this.x)?n.bind(this)("x")/2:r.bind(this)("x",t)/2},ry:function(t){return d4.isOrdinalScale(this.y)?n.bind(this)("y")/2:r.bind(this)("y",t)/2}}},c=function(t,e){e.attr("rx",d4.functor(t.accessors.rx).bind(this)).attr("ry",d4.functor(t.accessors.ry).bind(this)).attr("cx",d4.functor(t.accessors.cx).bind(this)).attr("cy",d4.functor(t.accessors.cy).bind(this))},u=i.bind(this)(t,"ellipse",c);return d4.merge(u,a)}),d4.feature("rectSeries",function(t){var a={accessors:{height:function(t){return d4.isOrdinalScale(this.y)?n.bind(this)("y"):r.bind(this)("y",t)},rx:0,ry:0,width:function(t){return d4.isOrdinalScale(this.x)?n.bind(this)("x"):r.bind(this)("x",t)},x:function(t){return d4.isOrdinalScale(this.x)?e.bind(this)("x",t):s.bind(this)("x",t)},y:function(t){return d4.isOrdinalScale(this.y)?e.bind(this)("y",t):s.bind(this)("y",t)}}},c=function(t,e){e.attr("x",d4.functor(t.accessors.x).bind(this)).attr("y",d4.functor(t.accessors.y).bind(this)).attr("ry",d4.functor(t.accessors.ry).bind(this)).attr("rx",d4.functor(t.accessors.rx).bind(this)).attr("width",d4.functor(t.accessors.width).bind(this)).attr("height",d4.functor(t.accessors.height).bind(this))},u=i.bind(this)(t,"rect",c);return d4.merge(u,a)})}.call(this),function(){"use strict";d4.feature("trendLine",function(t){return{accessors:{tipSize:6,text:function(t){return t[this.valueKey]},textX:function(){return this.x(this.width)},textY:function(){return this.x(this.height)},x1:function(){return this.x(this.x.$key)},x2:function(){return this.x(this.width)},y1:function(){return this.y(this.y.$key)},y2:function(){return this.y(this.height)}},render:function(e,n,r){var s=this.svg.select("defs");d4.appendOnce(s,"marker#"+t+"-start").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",d4.functor(e.accessors.tipSize).bind(this)()).attr("markerHeight",d4.functor(e.accessors.tipSize).bind(this)).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z"),d4.appendOnce(r,"g."+t);var i=d4.appendOnce(this.svg.select("."+t),"line.line").attr("x1",d4.functor(e.accessors.x1).bind(this)).attr("x2",d4.functor(e.accessors.x2).bind(this)).attr("y1",d4.functor(e.accessors.y1).bind(this)).attr("y2",d4.functor(e.accessors.y2).bind(this)).attr("marker-end","url(#"+t+"-start)");return d4.appendOnce(this.svg.select("."+t),"text.trendLine-label").text(d4.functor(e.accessors.text).bind(this)).attr("x",d4.functor(e.accessors.textX).bind(this)).attr("y",d4.functor(e.accessors.textY).bind(this)),i}}})}.call(this),function(){"use strict";d4.feature("waterfallConnectors",function(t){return{accessors:{classes:function(t,e){return"series"+e},span:function(){return d4.isOrdinalScale(this.x)?this.x.rangeBand():this.y.rangeBand()},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key]);var e=0,n=t.y0+t.y-Math.max(0,t.y);return t.y>0&&(e=Math.abs(this.x(t.y0)-this.x(t.y0+t.y))),this.x(n)+e},y:function(t){return d4.isOrdinalScale(this.x)?this.y(t.y0+t.y):this.y(t[this.y.$key])}},prepare:function(t){var e=t.map(function(t){return t.values[0]});return d4.flatten(e)},render:function(e,n,r){r.append("g").attr("class",t);var s=this.svg.select("."+t).selectAll("."+t).data(n);return s.enter().append("line"),s.exit().remove(),s.attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x1",function(t,r){return 0===r?0:d4.functor(e.accessors.x).bind(this)(n[r-1])}.bind(this)).attr("y1",function(t,r){return 0===r?0:d4.functor(e.accessors.y).bind(this)(n[r-1])}.bind(this)).attr("x2",function(t,r){return 0===r?0:d4.isOrdinalScale(this.x)?d4.functor(e.accessors.x).bind(this)(t)+d4.functor(e.accessors.span).bind(this)():d4.functor(e.accessors.x).bind(this)(n[r-1])}.bind(this)).attr("y2",function(t,r){return 0===r?0:d4.isOrdinalScale(this.x)?d4.functor(e.accessors.y).bind(this)(n[r-1]):d4.functor(e.accessors.y).bind(this)(t)+d4.functor(e.accessors.span).bind(this)(t)}.bind(this)),s}}})}.call(this),function(){"use strict";d4.feature("xAxis",function(t){var e=d3.svg.axis().orient("bottom").tickPadding(10).tickSize(0),n=function(t,e){var n=d4.helpers.textSize(t,e);return n.text=t,n},r=function(t,e,n){if(t.text){var r=this.svg.selectAll(".x.axis"),s=r.node().getBBox(),i=.8*t.height,a=r.append("text").text(t.text).attr("class",""+n);"bottom"===e.toLowerCase()?a.attr("transform","translate(0,"+(s.height+i)+")"):a.attr("transform","translate(0,"+(s.y-i/2)+")")}},s=function(t,e){switch(!0){case"top"===t.toLowerCase():e.attr("transform","translate(0,0)");break;case"bottom"===t.toLowerCase():e.attr("transform","translate(0,"+this.height+")")}},i={accessors:{align:"bottom",stagger:!0,subtitle:void 0,title:void 0},proxies:[{target:e}],render:function(i){i.scale(this.x);var a=n(d4.functor(i.accessors.title).bind(this)(),"title"),c=n(d4.functor(i.accessors.subtitle).bind(this)(),"subtitle"),u=d4.functor(i.accessors.align).bind(this)(),o=this.svg.select("g.margins").append("g").attr("class","x axis "+t).attr("data-scale",this.x.$scale).call(e);s.bind(this)(u,o),d4.functor(i.accessors.stagger).bind(this)()&&o.selectAll(".tick text").call(d4.helpers.staggerTextVertically,1),"top"===u?(r.bind(this)(c,u,"subtitle"),r.bind(this)(a,u,"title")):(r.bind(this)(a,u,"title"),r.bind(this)(c,u,"subtitle"))}};return i})}.call(this),function(){"use strict";d4.feature("yAxis",function(t){var e=d3.svg.axis().orient("left").tickPadding(10).tickSize(0),n=function(t,e){var n=d4.helpers.textSize(t,e);return n.text=t,n},r=function(t,e,n){if(t.text){var r=this.svg.selectAll(".y.axis"),s=r.node().getBBox(),i=.8*t.height,a=r.append("text").text(t.text).attr("class",""+n);"left"===e.toLowerCase()?a.call(d4.helpers.rotateText("rotate(90)translate(0,"+(Math.abs(s.x)+i)+")")):a.call(d4.helpers.rotateText("rotate(90)translate(0,"+(Math.abs(s.x)-(s.width+i))+")"))}},s=function(t,e){switch(!0){case"left"===t.toLowerCase():e.attr("transform","translate(0,0)");break;case"right"===t.toLowerCase():e.attr("transform","translate("+this.width+", 0)")}},i={accessors:{align:"left",stagger:!0,subtitle:void 0,title:void 0},proxies:[{target:e}],render:function(i){i.scale(this.y);var a=n(d4.functor(i.accessors.title).bind(this)(),"title"),c=n(d4.functor(i.accessors.subtitle).bind(this)(),"subtitle"),u=d4.functor(i.accessors.align).bind(this)(),o=this.svg.select("g.margins").append("g").attr("class","y axis "+t).attr("data-scale",this.y.$scale).call(e);o.selectAll(".tick text").call(d4.helpers.wrapText,this.margin[u]),s.bind(this)(u,o),d4.functor(i.accessors.stagger).bind(this)()&&this.svg.selectAll(".y.axis .tick text").call(d4.helpers.staggerTextHorizontally,-1),"left"===u?(r.bind(this)(a,u,"title"),r.bind(this)(c,u,"subtitle")):(r.bind(this)(c,u,"subtitle"),r.bind(this)(a,u,"title"))}};return i})}.call(this),function(){"use strict";d4.parser("nestedGroup",function(){var t={x:{key:"x",values:[]},y:{key:"y",values:[]},value:{key:"value",values:[]},data:[]};t.defined=function(){return!0},t.nestKey=function(){return t.x.key};var e=function(e){var n=[];return d4.each(e,function(e){t.defined(e)&&n.push(e)}.bind(this)),n},n=function(e,n){["x","y","value"].forEach(function(r){var s=n.map(function(t){return t[e[r].key]});t[r].values=d3.set(s).values()})},r=function(t,e,n){var r=d3.nest().key(function(e){return e[t]});return r.entries(n)},s=function(e,n){t[e].key=d4.functor(n)()},i=function(s){return s&&d4.extend(t.data,s),n(t,t.data),t.data=e(t.data),t.data=r(t.nestKey(),t.value.key,t.data),t};return i.nestKey=function(e){return t.nestKey=d4.functor(e).bind(t),i},i.defined=function(e){return t.defined=d4.functor(e).bind(t),i},d4.each(["x","y","value"],function(e){i[e]=function(n){return s.bind(t)(e,d4.functor(n)),i}}.bind(this)),i})}.call(this),function(){"use strict";d4.parser("nestedStack",function(){var t={x:{key:"x",values:[]},y:{key:"y",values:[]},value:{key:"value",values:[]},data:[]};t.defined=function(){return!0},t.nestKey=function(){return t.y.key};var e=function(e){var n=[];return d4.each(e,function(e){t.defined(e)&&n.push(e)}.bind(this)),n},n=function(e,n){["x","y","value"].forEach(function(r){var s=n.map(function(t){return t[e[r].key]});t[r].values=d3.set(s).values()})},r=function(t,e,n){var r=d3.nest().key(function(e){return e[t]});return r.entries(n)},s=function(e,n){var r={},s=d3.layout.stack().values(function(t){return t.values}).x(function(t){return t[e]}).y(function(e){return+e[t.value.key]}).out(function(t,n,s){t.y=s,t.y>=0?(t.y0=r[t[e]+"Pos"]=r[t[e]+"Pos"]||0,r[t[e]+"Pos"]+=s):(t.y0=r[t[e]+"Neg"]=r[t[e]+"Neg"]||0,r[t[e]+"Neg"]-=Math.abs(s))});s(n.reverse())},i=function(e,n){var r=d4.functor(n)();"x"===e&&"y"===r&&d4.err("You cannot use `y` as the key for an `x` dimension because it creates an ambiguous `y` property in the nested stack."),t[e].key=r},a=function(i){return i&&d4.extend(t.data,i),n(t,t.data),t.data=e(t.data),t.data=r(t.nestKey(),t.value.key,t.data),s(t.x.key,t.data),t};return a.nestKey=function(e){return t.nestKey=d4.functor(e).bind(t),a},a.defined=function(e){return t.defined=d4.functor(e).bind(t),a},d4.each(["x","y","value"],function(e){a[e]=function(n){return i.bind(t)(e,d4.functor(n)),a}}.bind(this)),a})}.call(this),function(){"use strict";d4.parser("waterfall",function(){var t={x:{key:"x",values:[]},y:{key:"y",values:[]},value:{key:"value",values:[]},data:[]};t.nestKey=function(){return t.x.key};var e=function(e,n){["x","y","value"].forEach(function(r){var s=n.map(function(t){return t[e[r].key]});t[r].values=d3.set(s).values()})},n=function(t,e,n){var r=d3.nest().key(function(e){return e[t]});return r.entries(n)},r=function(e,n){var r=0,s=function(t){return isNaN(t)?0:t},i=d3.layout.stack().values(function(t){return t.values}).x(function(t){return t[e]}).y(function(e){return+e[t.value.key]}).out(function(e,n,i){isNaN(i)?(isNaN(n)&&(n=r),e.y0=0,e.y=n,e[t.value.key]=n,r=n):(isNaN(n)?(e.y0=r,r+=i):e.y0=n,e.y=i,e[t.value.key]=s(e[t.value.key]))});i(n)},s=function(e,n){t[e].key=d4.functor(n)()},i=function(s){return s&&d4.extend(t.data,s),e(t,t.data),t.data=n(t.nestKey(),t.value.key,t.data),r(t.x.key,t.data),t};return i.nestKey=function(e){return t.nestKey=d4.functor(e).bind(t),i},d4.each(["x","y","value"],function(e){i[e]=function(n){return s.bind(t)(e,d4.functor(n)),i}}.bind(this)),i})}.call(this),function(){"use strict";var t=function(t,e){var n=t.map(function(t){return t.values.map(function(t){return t[e]}.bind(this))}.bind(this));return d3.merge(n)},e=function(t,e){switch(e){case"x":return[0,t.width];case"y":return[t.height,0];default:return[]}},n=function(t,n,r){var s=t[r].$key,i=d3.extent(d3.merge(n.map(function(t){return d3.extent(t.values,function(t){return d4.isDate(t[s])?t[s]:t[s]+(t.y0||0)})}))),a=t[r];if(!a.domain.$dirty)if(d4.isDate(i[0])){var c=a.$min||i[0],u=a.$max||i[1];a.domain([c,u])}else a.domain([Math.min(a.$min||0,i[0]),a.$max||i[1]]);return a.range.$dirty||a.range(e(t,r)),a.clamp.$dirty||a.clamp(!0),t[r].nice()};d4.builder("linearScaleForNestedData",n),d4.builder("timeScaleForNestedData",n),d4.builder("ordinalScaleForNestedData",function(n,r,s){var i=t(r,n[s].$key),a=n[s+"RoundBands"]=n[s+"RoundBands"]||.3,c=n[s];return c.domain.$dirty||c.domain(i),c.rangeRoundBands.$dirty||c.rangePoints.$dirty||c.rangeBands.$dirty||c.rangeRoundBands(e(n,s),a),c})}.call(this); \ No newline at end of file +(function(){"use strict";var t=this,e={},n=function(t){return t instanceof n?t:this instanceof n?(this.d4Wrapped=t,void 0):new n(t)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=n),exports.d4=n):t.d4=n,n.charts={},n.features={},n.parsers={},n.builders={};var r=n.each=n.forEach=function(t,n,r){var s,i,a=Array.prototype.forEach;if(null!==t)if(a&&t.forEach===a)t.forEach(n,r);else if(t.length===+t.length){for(s=0,i=t.length;i>s;s++)if(n.call(r,t[s],s,t)===e)return}else{var c=d3.keys(t);for(s=0,i=c.length;i>s;s++)if(n.call(r,t[c[s]],c[s],t)===e)return}},s=function(t){return t.charAt(0).toUpperCase()+t.slice(1)},i=function(t,e,r,s){Object.defineProperty(t,e,{configurable:!0,get:function(){return n.functor(s)()},set:function(){a(" You cannot directly assign values to the {0} property. Instead use the {1}() function.",e,r)}})},a=n.err=function(){var t,e=Array.prototype.slice.call(arguments),n=e.shift();throw r(e,function(e,r){t=RegExp("\\{"+r+"\\}","gi"),n=n.replace(t,e)}),Error("[d4] "+n)},c=function(t){return r(["link"],function(e){(!t[e]||n.isNotFunction(t[e]))&&a("The supplied builder does not have a {0} function",e)}),t},u=function(t){return this.builder||(this.builder=c(t.bind(this)())),this},o=function(t,e,r){if(n.isNotFunction(r)){var s="$"+e;i(t,s,e,r)}},d=function(t,e,r,i){var a=r;n.isDefined(i)&&(a=i+s(r)),t[a]=function(n){return arguments.length?(o(t,r,n),e[r]=n,t):e[r]},o(t,r,e[r])},h=function(t,e,n,s){r(n,function(n){d(t,e,n,s)})},f=function(t){var e=t.accessors;e&&h(t,t.accessors,d3.keys(e))},l=function(t,e){r(d3.keys(e.axes),function(n){t[n]=function(r){return F.bind(e)(n,r),t},r(d3.keys(e.axes[n].accessors),function(r){t[n][r]=e.axes[n][r]})})},y=function(t){var e=d3.keys(d3.scale);e.push("time"),e.push("time.utc"),0>e.indexOf(t)&&a('The scale type: "{0}" is unrecognized. D4 only supports these scale types: {1}',t,e.sort().join(", "))},x=function(t,e,r){n.createAccessorProxy(e,t),e.scale=function(t){return arguments.length?(e.accessors.scale=t,r(),e):e.accessors.scale}},b=function(t,e,n){var s;switch(y(n.accessors.scale),!0){case"time"===n.accessors.scale:s=d3.time.scale();break;case"time.utc"===n.accessors.scale:s=d3.time.scale.utc();break;default:s=d3.scale[n.accessors.scale]()}f(n),e[t]=s,x(s,e.axes[t],function(){b(t,e,n)}),r(d3.keys(e.axes[t].accessors),function(n){i(e[t],"$"+n,e.axes[t][n],e.axes[t][n])})},v=function(t,e,r){e.axes[t]={accessors:n.extend({key:t,min:void 0,max:void 0},r)},b(t,e,e.axes[t])},p=function(t){r(d3.keys(t.axes),function(e){v(e,t,t.axes[e])}),n.isUndefined(t.axes.x)&&v("x",t,{scale:"ordinal"}),n.isUndefined(t.axes.y)&&v("y",t,{scale:"linear"})},g=function(t,e){var r=n.functor({link:function(t,e){n.builders[t.x.$scale+"ScaleForNestedData"](t,e,"x"),n.builders[t.y.$scale+"ScaleForNestedData"](t,e,"y")}}),s=n.merge({},t.accessors);delete t.accessors;var i=n.merge({axes:{},features:{},height:400,margin:{top:20,right:20,bottom:40,left:40},mixins:[],outerHeight:460,outerWidth:460,width:400},t);return i=n.merge(i,s),p(i),u.bind(i)(e||r),i.accessors=["width","height","valueKey"].concat(d3.keys(s)||[]),i},m=function(t,e){e&&r(d3.keys(t._proxiedFunctions),function(n){r(t._proxiedFunctions[n],function(t){e[n].apply(e,t)})})},k=function(t,e,r){var s=t.features[e];return n.isFunction(s.prepare)&&(r=s.prepare.bind(t)(r),n.isUndefined(r)&&a('"feature.prepare()" must return a data array. However, the prepare function for the "{0}" feature did not',e)),r},$=function(t,e){var n,r;t.mixins.forEach(function(s){n=k(t,s,e),r=t.features[s].render.bind(t)(t.features[s],n,t.chartArea),m(t.features[s],r)})},A=function(t,e){t.builder?(t.builder.link(t,e),$(t,e)):a("No builder defined")},S=function(t){this.svg=n.appendOnce(d3.select(t),"svg.d4.chart").attr("width",Math.max(0,this.width+this.margin.left+this.margin.right)).attr("height",Math.max(0,this.height+this.margin.top+this.margin.bottom)),n.appendOnce(this.svg,"defs"),n.appendOnce(this.svg,"g.margins").attr("transform","translate("+this.margin.left+","+this.margin.top+")"),this.chartArea=n.appendOnce(this.svg.select("g.margins"),"g.chartArea")},O=function(t,e){var r=n.parsers.nestedGroup().x(t.x.$key).y(t.y.$key).nestKey(t.x.$key).value(t.valueKey)(e);return r.data},w=function(t,e){var r,s,i=!1;return n.isUndefined(t.valueKey)&&(t.valueKey=t.y.$key),e.length>0&&(s=e[0],n.isArray(s)?i=!0:(r=d3.keys(s),0>=r.indexOf("key")+r.indexOf("values")&&(i=!0))),i?O(t,e):e},L=function(t){return function(e){e.each(function(e){e=w(t,e),S.bind(t,this)(),A(t,e)})}},C=function(t,e){return t.overrides?t.overrides(e):{}},M=function(t,e,r){n.isDefined(r)?(r=Math.max(Math.min(r,t.length),0),t.splice(r,0,e)):t.push(e)},z=function(t){t._proxiedFunctions={on:[]},t.on=function(){t._proxiedFunctions.on.push(Array.prototype.slice.call(arguments))}},B=function(t){f(t)},N=function(t){z(t),n.each(t.proxies,function(e){n.isUndefined(e.target)&&a("You included a feature which has a malformed proxy target.",t.name),n.createAccessorProxy(t,e.target,e.prefix)})},D=function(t){t||a("You need to supply an object or array of objects to mixin to the chart.");var e=n.flatten([t]);n.each(e,function(t){var e=t.name,r=C.bind(this)(t,e),s={proxies:[]};t[e]=n.merge(n.merge(s,t.feature(e)),r),n.extend(this.features,t),M(this.mixins,e,t.index),N(this.features[e]),B(this.features[e])}.bind(this))},K=function(t){var e=[];n.isUndefined(t)&&a("A string or array of names is required in order to mixout a chart feature."),e.push(t),n.each(n.flatten(e),function(t){delete this.features[t],this.mixins=this.mixins.filter(function(e){return e!==t})}.bind(this))},T=function(t,e){var r=this.features[t];n.isNotFunction(e)&&a("You must supply a continuation function in order to use a chart feature."),r?e.bind(this)(r):a('Could not find feature: "{0}", maybe you forgot to mix it in?',t)},F=function(t,e){var r=this.axes[t];n.isNotFunction(e)&&a("You must supply a continuation function in order to use a chart axis."),r?e.bind(this)(r):a('Could not find axis: "{0}", maybe you forgot to define it?',t)},P=function(t){var e,r,s=t,i="[\\x20\\t\\r\\n\\f]",a="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",c=a.replace("w","w#"),u="\\["+i+"*("+a+")"+i+"*(?:([*^$|!~]?=)"+i+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+c+")|)|)"+i+"*\\]",o=["TAG","ID","CLASS"],d={ID:RegExp("#("+a+")"),CLASS:RegExp("\\.("+a+")"),TAG:RegExp("^("+a.replace("w","w*")+")"),ATTR:RegExp(""+u)},h=function(t){for(e=!1,f[t]=[],r=!0;r;)r=d[t].exec(s),null!==r&&(e=r.shift(),f[t].push(r[0]),s=s.slice(e.length))},f={};return n.each(o,h),n.each(o,function(t){for(;s&&(f[t]=f[t].join(" "),e););}),f},R=function(t){var e=L(t);return h(e,t.margin,d3.keys(t.margin),"margin"),h(e,t,t.accessors),l(e,t),e.axes=function(n){return arguments.length?(n(t.axes),e):t.axes},e.builder=function(n){return t.builder=c(n.bind(t)()),e},e.clone=function(){var e=n.extend({},t);return R(e)},e.features=function(){return t.mixins},e.margin=function(r){return arguments.length?(t.margin=n.merge(t.margin,n.functor(r)()),e.height(e.outerHeight()-t.margin.top-t.margin.bottom),e.width(e.outerWidth()-t.margin.left-t.margin.right),e):t.margin},e.mixin=function(n){return D.bind(t)(n),e},e.mixout=function(n,r){return K.bind(t)(n,r),e},e.outerHeight=function(r){var s=n.functor(r)();return arguments.length?(t.outerHeight=s,e.height(s-t.margin.top-t.margin.bottom),e):t.outerHeight},e.outerWidth=function(r){var s=n.functor(r)();return arguments.length?(t.outerWidth=s,e.width(s-t.margin.left-t.margin.right),e):t.outerWidth},e.using=function(n,r){return T.bind(t)(n,r),e},e};n.appendOnce=function(t,e){var n,r=t.selectAll(e);return r.empty()&&(n=P(e),r=t.append(n.TAG).attr("class",n.CLASS.join(" ")),n.ID&&r.attr("id",n.ID.pop())),r},n.baseChart=function(t){var e=g(t&&t.config||{},t&&t.builder||void 0);return R(e)},n.builder=function(t,e){return n.builders[t]=e,n.builders[t]},n.chart=function(t,e){return n.charts[t]=e,n.charts[t]},n.createAccessorProxy=function(t,e,i){r(d3.keys(e),function(r){var a=r;n.isDefined(i)&&(a=i+s(r)),t[a]=function(){return arguments.length?(e[r].$dirty=!0,t[a].$dirty=!0,e[r].apply(e,arguments),t):e[r]()},e[r].$dirty=!1,t[a].$dirty=!1})},n.extend=function(t){return r(Array.prototype.slice.call(arguments,1),function(e){var r=function(t){var e=[];return n.each(t,function(t){var r=t;n.isObject(t)&&(r=n.extend({},t)),e.push(r)}),e};if(e)for(var s in e)if(e[s]&&e[s].constructor&&e[s].constructor===Object)t[s]=t[s]||{},n.extend(t[s],e[s]);else if(n.isArray(e[s])){var i=r(e[s].slice());t[s]=n.isArray(t[s])?t[s].concat(i):i}else t[s]=e[s]}),t},n.feature=function(t,e){return n.features[t]=e,n.features[t]},n.flatten=function(t){var e=t.reduce(function(t,e){return t=n.isArray(t)?t:[t],e=n.isArray(e)?e:[e],t.concat(e)});return n.isArray(e)?e:[e]},n.functor=function(t){return n.isFunction(t)?t:function(){return t}},n.isArray=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},n.isContinuousScale=function(t){return n.isDefined(t.rangeRound)},n.isDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)},n.isDefined=function(t){return!n.isUndefined(t)},n.isFunction=function(t){return!!(t&&t.constructor&&t.call&&t.apply)},n.isObject=function(t){return null!==t&&"object"==typeof t},n.isOrdinalScale=function(t){return n.isUndefined(t.rangeRound)},n.isNotFunction=function(t){return!n.isFunction(t)},n.isNotNull=function(t){return!n.isNull(t)},n.isNull=function(t){return null===t},n.isUndefined=function(t){return t===void 0},n.merge=function(t,e){return n.extend(n.extend({},t),e)},n.parser=function(t,e){return n.parsers[t]=e,n.parsers[t]}}).call(this),function(){"use strict";d4.helpers={};var t=function(t,e){var n=5,r=0,s=function(t,e){return!(t.righte.right||t.bottome.bottom)},i=function(t){var a,c,u,o=!1,d=0;t.each(function(){d>0&&(a=this.getBoundingClientRect(),c=u.getBoundingClientRect(),s(a,c)&&(e.bind(this)(c,a),o=!0)),d++,u=this}),o&&n>r&&(r++,i.bind(this)(t))};i.bind(this)(t)};d4.helpers.staggerTextVertically=function(e,n){var r=function(t,e){var r=d3.select(this),s=r.attr("data-last-vertical-offset")||1,i=t.top-e.top,a=(e.height-i+s)*n;r.attr("transform","translate(0,"+a+")"),r.attr("data-last-vertical-offset",Math.abs(a))};t.bind(this)(e,r)},d4.helpers.rotateText=function(t){return function(e){e.each(function(){var n=d3.transform(d3.functor(t).apply(this,arguments));e.attr("alignment-baseline","central"),e.style("dominant-baseline","central"),90>=n.rotate&&n.rotate>=-90?(e.attr("text-anchor","begin"),e.attr("transform",""+n)):(e.attr("text-anchor","end"),n.rotate=(n.rotate>0?-1:1)*(180-Math.abs(n.rotate)),e.attr("transform",""+n))})}},d4.helpers.staggerTextHorizontally=function(e,n){var r=function(t,e){var r=d3.select(this),s=r.attr("data-last-horizontal-offset")||1,i=t.left-e.left,a=(e.width-i+s)*n;r.attr("transform","translate("+a+", 0)"),r.attr("data-last-horizontal-offset",Math.abs(a))};t.bind(this)(e,r)},d4.helpers.textSize=function(t,e){var n={height:0,width:0,x:0,y:0};if(d4.isDefined(t)){var r=d3.select("body").append("svg").attr("class",""+e);r.append("text").attr("x",-5e3).text(t),n=r.node().getBBox(),r.remove()}return n},d4.helpers.wrapText=function(t,e){t.each(function(){var t,n=d3.select(this),r=n.text().split(/\s+/).reverse(),s=[],i=0,a=1.1,c=n.attr("x"),u=n.attr("y"),o=parseFloat(n.attr("dy")),d=n.text(null).append("tspan").attr("x",c).attr("y",u).attr("dy",o+"em");for(t=r.pop();t;)s.push(t),d.text(s.join(" ")),d.node().getComputedTextLength()>e-Math.abs(c)&&(s.pop(),d.text(s.join(" ")),s=[t],d=n.append("tspan").attr("x",c).attr("y",u).attr("dy",++i*a+o+"em").text(t)),t=r.pop()})}}.call(this),function(){"use strict";d4.chart("column",function(){return d4.baseChart().mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("donut",function(){return d4.baseChart({config:{accessors:{radius:function(){return Math.min(this.width,this.height)/2},arcWidth:function(t){return t/3}}}}).mixin([{name:"arcs",feature:d4.features.arcSeries},{name:"arcLabels",feature:d4.features.arcLabels}])})}.call(this),function(){"use strict";d4.chart("groupedColumn",function(){var t=function(){return{accessors:{x:function(t,e){var n=this.x.rangeBand()/this.groupsOf,r=this.x(t[this.x.$key])+n*e,s=.1*n;return r+n/2-s}}}};return d4.baseChart({config:{accessors:{groupsOf:1}}}).mixin([{name:"bars",feature:d4.features.groupedColumnSeries},{name:"barLabels",feature:d4.features.stackedLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("groupedRow",function(){var t=function(){return{accessors:{y:function(t,e){var n=this.y.rangeBand()/this.groupsOf,r=this.y(t[this.y.$key])+n*e,s=.1*n;return r+n/4+s}}}};return d4.baseChart({config:{accessors:{groupsOf:1},margin:{top:20,right:40,bottom:20,left:40},axes:{x:{scale:"linear"},y:{scale:"ordinal"}}}}).mixin([{name:"bars",feature:d4.features.groupedColumnSeries},{name:"barLabels",feature:d4.features.stackedLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("line",function(){return d4.baseChart().mixin([{name:"lineSeries",feature:d4.features.lineSeries},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis},{name:"lineSeriesLabels",feature:d4.features.lineSeriesLabels}])})}.call(this),function(){"use strict";d4.chart("row",function(){return d4.baseChart({config:{margin:{top:20,right:40,bottom:20,left:40},valueKey:"x",axes:{x:{scale:"linear"},y:{scale:"ordinal"}}}}).mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";var t=function(){var t=function(t,e){d4.builders[t.x.$scale+"ScaleForNestedData"](t,e,"x"),d4.builders[t.y.$scale+"ScaleForNestedData"](t,e,"y"),d4.builders[t.z.$scale+"ScaleForNestedData"](t,e,"z");var n=5,r=Math.max(n+1,(t.height-t.margin.top-t.margin.bottom)/10);t.z.range([n,r])},e={link:function(e,n){t.bind(this)(e,n)}};return e},e=function(t,e){var n=this[t];return n(e[n.$key])+n.rangeBand()/2},n=function(t,e){var n,r=this[t],s=Math.abs(r(e.y0)-r(e.y0+e.y))/2,i=10;return"x"===t&&(s*=-1,i*=-1),d4.isDefined(e.y0)?(n=e.y0+e.y,r(n)+s):r(e[r.$key])-i},r=function(){return{accessors:{x:function(t){return d4.isOrdinalScale(this.x)?e.bind(this)("x",t):n.bind(this)("x",t)},y:function(t){return d4.isOrdinalScale(this.y)?e.bind(this)("y",t):n.bind(this)("y",t)}}}},s=function(){return{accessors:{cx:function(t){return this.x(t[this.x.$key])},cy:function(t){return this.y(t[this.y.$key])},r:function(t){return this.z(t[this.z.$key])}}}};d4.chart("scatterPlot",function(){return d4.baseChart({builder:t,config:{axes:{x:{scale:"linear"},z:{scale:"linear"}}}}).mixin([{name:"circles",feature:d4.features.circleSeries,overrides:s},{name:"circleLabels",feature:d4.features.stackedLabels,overrides:r},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("stackedColumn",function(){var t=function(){var t=function(t){var e=[];return t.map(function(t){t.values.map(function(t){e.push(t)})}),e},e=function(t){return d3.nest().key(function(t){return t[this.x.$key]}.bind(this)).rollup(function(t){var e=d3.sum(t,function(t){return t[this.valueKey]}.bind(this)),n=d3.sum(t,function(t){return Math.max(0,t[this.valueKey])}.bind(this));return{text:e,size:n}}.bind(this)).entries(t)},n=function(n){return e.bind(this)(t(n)).map(function(t){var e={};return e[this.x.$key]=t.key,e.size=t.values.size,e[this.valueKey]=t.values.text,e}.bind(this))};return{accessors:{y:function(t){var e=5;return this.y(t.size)-e}},prepare:function(t){return n.bind(this)(t)}}};return d4.baseChart().mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"connectors",feature:d4.features.stackedColumnConnectors},{name:"columnTotals",feature:d4.features.columnLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.chart("stackedRow",function(){var t=function(){var t=function(t){var e=[];return t.map(function(t){t.values.map(function(t){e.push(t)})}),e},e=function(t){return d3.nest().key(function(t){return t[this.y.$key]}.bind(this)).rollup(function(t){var e=d3.sum(t,function(t){return t[this.valueKey]}.bind(this)),n=d3.sum(t,function(t){return Math.max(0,t[this.valueKey])}.bind(this));return{text:e,size:n}}.bind(this)).entries(t)},n=function(n){return e.bind(this)(t(n)).map(function(t){var e={};return e[this.y.$key]=t.key,e.size=t.values.size,e[this.valueKey]=t.values.text,e}.bind(this))};return{accessors:{x:function(t){var e=5;return this.x(t.size)+e}},prepare:function(t){return n.bind(this)(t)}}};return d4.baseChart({config:{margin:{top:20,right:40,bottom:20,left:40},axes:{x:{scale:"linear"},y:{scale:"ordinal"}}}}).mixin([{name:"bars",feature:d4.features.rectSeries},{name:"barLabels",feature:d4.features.stackedLabels},{name:"connectors",feature:d4.features.stackedColumnConnectors},{name:"columnTotals",feature:d4.features.columnLabels,overrides:t},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";var t=function(){return{accessors:{y:function(t){if(d4.isContinuousScale(this.y)){var e=t.y0+t.y-Math.min(0,t.y);return this.y(e)}return this.y(t[this.y.$key])},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key]);var e=t.y0+t.y-Math.max(0,t.y);return this.x(e)},width:function(t){return d4.isOrdinalScale(this.x)?this.x.rangeBand():Math.abs(this.x(t.y0)-this.x(t.y0+t.y))},height:function(t){return d4.isContinuousScale(this.y)?Math.abs(this.y(t.y0)-this.y(t.y0+t.y)):this.y.rangeBand()},classes:function(t,e,n){var r=t.y>0?"positive":"negative";return n>0&&0===t.y0&&(r="subtotal"),"bar fill item"+e+" "+r+" "+t[this.y.$key]}}}},e=function(){return{accessors:{y:function(t){if(d4.isContinuousScale(this.y)){var e=Math.abs(this.y(t.y0)-this.y(t.y0+t.y)),n=t.y0+t.y-Math.max(0,t.y);return this.y(n)-10-e}return this.y(t[this.y.$key])+this.y.rangeBand()/2},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key])+this.x.rangeBand()/2;var e=t.y0+t.y-Math.max(0,t.y),n=Math.abs(this.x(t.y0)-this.x(t.y0+t.y));return this.x(e)+10+n},text:function(t){return t[this.valueKey]}}}},n=function(){var t=function(t,e){var n;return"x"===e?[0,t.width]:(n=[0,t.height],d4.isOrdinalScale(t.x)?n.reverse():n)},e=function(e,n,r){var s=r.map(function(t){return t.key}.bind(this));e[n].domain(s).rangeRoundBands(t.bind(this)(e,n),e.xRoundBands||.3)},n=function(e,n,r){var s=d3.extent(d3.merge(r.map(function(t){return d3.extent(t.values,function(t){return t.y+t.y0})})));s[0]=Math.min(0,s[0]),e[n].domain(s),e[n].range(t.bind(this)(e,n)).clamp(!0).nice()},r=function(t,r){d4.isOrdinalScale(t.x)?(e.bind(this)(t,"x",r),n.bind(this)(t,"y",r)):(e.bind(this)(t,"y",r),n.bind(this)(t,"x",r))},s={link:function(t,e){r.bind(this)(t,e)}};return s};d4.chart("waterfall",function(){return d4.baseChart({builder:n}).mixin([{name:"bars",feature:d4.features.rectSeries,overrides:t},{name:"connectors",feature:d4.features.waterfallConnectors},{name:"columnLabels",feature:d4.features.stackedLabels,overrides:e},{name:"xAxis",feature:d4.features.xAxis},{name:"yAxis",feature:d4.features.yAxis}])})}.call(this),function(){"use strict";d4.feature("arcLabels",function(t){var e=d3.svg.arc();return{accessors:{classes:function(t,e){return"arc stroke fill series"+e},duration:750,key:function(t,e){return(t.key||0)+e},text:function(t){return t.value},x:function(){return this.width/2},y:function(){return this.height/2}},proxies:[{target:e}],render:function(n,r,s){var i=function(t){return 180/Math.PI*(t.startAngle+t.endAngle)/2-90},a=function(t){var n=d3.interpolate(this._current,t);return this._current=n(0),function(r){return"translate("+e.centroid(n(r))+") rotate("+i(t)+")"}},c=d4.functor(this.radius).bind(this)(),u=d4.functor(n.accessors.x).bind(this)(),o=d4.functor(n.accessors.y).bind(this)();e.innerRadius(c).outerRadius(c+10);var d=s.selectAll("g."+t).data(r);d.enter().append("g").attr("class",t).attr("transform","translate("+u+","+o+")");var h=d.selectAll("text").data(function(t){return t.values},d4.functor(n.accessors.key).bind(this));return h.transition().duration(d4.functor(n.accessors.duration).bind(this)()).attrTween("transform",a),h.enter().append("text").attr("dy",5).attr("transform",function(t){return"translate("+e.centroid(t)+") rotate("+i(t)+")"}).style("text-anchor","start").text(d4.functor(n.accessors.text).bind(this)).attr("class",d4.functor(n.accessors.classes).bind(this)).attr("data-key",d4.functor(n.accessors.key).bind(this)).attr("d",e).each(function(t){this._current=t}),h.exit().remove(),d.exit().remove(),e}}})}.call(this),function(){"use strict";d4.feature("arcSeries",function(t){var e=d3.svg.arc();return{accessors:{classes:function(t,e){return"arc stroke fill series"+e},duration:750,key:function(t,e){return(t.key||0)+e},x:function(){return this.width/2},y:function(){return this.height/2}},proxies:[{target:e}],render:function(n,r,s){var i=function(t){var n=d3.interpolate(this._current,t);return this._current=n(0),function(t){return e(n(t))}},a=d4.functor(this.radius).bind(this)(),c=d4.functor(n.accessors.x).bind(this)(),u=d4.functor(n.accessors.y).bind(this)(),o=d4.functor(this.arcWidth).bind(this)(a);e.innerRadius(a).outerRadius(a-o);var d=s.selectAll("g."+t).data(r);d.enter().append("g").attr("class",t).attr("transform","translate("+c+","+u+")");var h=d.selectAll("path").data(function(t){return t.values},d4.functor(n.accessors.key).bind(this));return h.transition().duration(d4.functor(n.accessors.duration).bind(this)()).attrTween("d",i),h.enter().append("path").attr("class",d4.functor(n.accessors.classes).bind(this)).attr("data-key",d4.functor(n.accessors.key).bind(this)).attr("d",e).each(function(t){this._current=t}),h.exit().remove(),d.exit().remove(),e}}})}.call(this),function(){"use strict";d4.feature("arrow",function(t){return{accessors:{classes:"line",tipSize:6,x1:function(){return this.x(0)},x2:function(){return this.x(this.width)},y1:function(){return this.y(0)},y2:function(){return this.y(this.height)}},render:function(e,n,r){var s=this.svg.select("defs");d4.appendOnce(s,"marker#"+t+"-end").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",d4.functor(e.accessors.tipSize).bind(this)).attr("markerHeight",d4.functor(e.accessors.tipSize).bind(this)).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z"),d4.appendOnce(s,"marker#"+t+"-start").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",d4.functor(e.accessors.tipSize).bind(this)()).attr("markerHeight",d4.functor(e.accessors.tipSize).bind(this)).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z"),d4.appendOnce(r,"g."+t);var i=d4.appendOnce(this.svg.select("."+t),"line").attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x1",d4.functor(e.accessors.x1).bind(this)).attr("x2",d4.functor(e.accessors.x2).bind(this)).attr("y1",d4.functor(e.accessors.y1).bind(this)).attr("y2",d4.functor(e.accessors.y2).bind(this)).attr("marker-end","url(#"+t+"-end)");return i}}})}.call(this),function(){"use strict";d4.feature("brush",function(t){var e=d3.svg.brush(),n=function(t){return d4.isDefined(t.$scale)?t:d4.functor(t).bind(this)()},r=function(t){return d4.isNull(e.y())?function(e){var n=e[this.x.$key],r=n>=t[0]&&t[1]>=n;return r}.bind(this):d4.isNull(e.x())?function(e){var n=e[this.y.$key],r=n>=t[0]&&t[1]>=n;return r}.bind(this):d4.isNotNull(e.x())&&d4.isNotNull(e.y())?function(e){var n=t[0][0]<=e[this.x.$key]&&e[this.x.$key]<=t[1][0]&&t[0][1]<=e[this.y.$key]&&e[this.y.$key]<=t[1][1];return n}.bind(this):void 0},s={accessors:{brushable:function(){return d3.selectAll(".brushable")},brushend:function(){this.svg.classed("selecting",!d3.event.target.empty())},brushmove:function(){var e=d3.event.target.extent(),n=r.bind(this)(e);this.features[t].accessors.brushable().classed("selected",n)},brushstart:function(){this.svg.classed("selecting",!0)},clamp:e.clamp,clear:e.clear,extent:e.extent,empty:e.empty,event:e.event,selection:function(t){return t},x:function(){return null},y:function(){return null}},render:function(r,s,i){var a=n.bind(this)(r.accessors.x),c=n.bind(this)(r.accessors.y);null!==typeof a&&e.x(a),null!==typeof c&&e.y(c),e.on("brushstart",d4.functor(r.accessors.brushstart).bind(this)).on("brush",d4.functor(r.accessors.brushmove).bind(this)).on("brushend",d4.functor(r.accessors.brushend).bind(this)),d4.appendOnce(i,"g."+t).call(e),r.accessors.selection.bind(this)(i.select(".brush")),r.accessors.brush.bind(this)(e)}};return s})}.call(this),function(){"use strict";d4.feature("columnLabels",function(t){var e=5,n=function(){return d4.isContinuousScale(this.y)?"middle":"start"};return{accessors:{key:function(t,e){return(t.key||0)+e},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key])+this.x.rangeBand()/2;var e=Math.abs(this.x(t[this.x.$key])-this.x(0));return this.x(t[this.x.$key])-e/2},y:function(t){if(d4.isOrdinalScale(this.y))return this.y(t[this.y.$key])+this.y.rangeBand()/2+e;var n=Math.abs(this.y(t[this.y.$key])-this.y(0));return(0>t[this.y.$key]?this.y(t[this.y.$key])-n:this.y(t[this.y.$key]))-e},text:function(t){return t[this.valueKey]}},render:function(e,r,s){s.append("g").attr("class",t);var i=this.svg.select("."+t).selectAll("."+t).data(r,d4.functor(e.accessors.key).bind(this));return i.enter().append("text"),i.exit().remove(),i.attr("class","column-label").text(d4.functor(e.accessors.text).bind(this)).attr("text-anchor",n.bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)),i}}})}.call(this),function(){"use strict";d4.feature("grid",function(t){var e=d3.svg.axis(),n=d3.svg.axis();return{accessors:{formatXAxis:function(t){return t.orient("bottom")},formatYAxis:function(t){return t.orient("left")}},proxies:[{target:e,prefix:"x"},{target:n,prefix:"y"}],render:function(r,s,i){e.scale(this.x),n.scale(this.y);var a=d4.functor(r.accessors.formatXAxis).bind(this)(e),c=d4.functor(r.accessors.formatYAxis).bind(this)(n);i.append("g").attr("class","grid border "+t).attr("transform","translate(0,0)").append("rect").attr("x",0).attr("y",0).attr("width",this.width).attr("height",this.height),i.append("g").attr("class","x grid "+t).attr("transform","translate(0,"+this.height+")").call(a.tickSize(-this.height,0,0).tickFormat("")),i.append("g").attr("class","y grid "+t).attr("transform","translate(0,0)").call(c.tickSize(-this.width,0,0).tickFormat(""))}}})}.call(this),function(){"use strict";d4.feature("groupedColumnSeries",function(t){var e=function(t){return t>0?"positive":"negative"},n=function(t,e,n){var r=this[t],s=r.rangeBand()/this.groupsOf,i=r(e[r.$key])+s*n;return i},r=function(t){var e=this[t],n=e.rangeBand()/this.groupsOf,r=.1*n;return n-r},s=function(t,e){var n=this[t];return Math.abs(n(e[n.$key])-n(0))},i=function(t,e){var n,r=this[t];return"y"===t?0>e[r.$key]?r(0):r(e[r.$key]):(n=e[r.$key]-Math.max(0,e[r.$key]),r(n))};return{accessors:{classes:function(t,n){return"bar fill item"+n+" "+e(t[this.valueKey])+" "+t[this.valueKey]},height:function(t){return d4.isOrdinalScale(this.y)?r.bind(this)("y"):s.bind(this)("y",t)},key:function(t,e){return(t.key||0)+e},rx:0,ry:0,width:function(t){return d4.isOrdinalScale(this.x)?r.bind(this)("x"):s.bind(this)("x",t)},x:function(t,e){return d4.isOrdinalScale(this.x)?n.bind(this)("x",t,e):i.bind(this)("x",t,e)},y:function(t,e){return d4.isOrdinalScale(this.y)?n.bind(this)("y",t,e):i.bind(this)("y",t,e)}},render:function(e,n,r){r.append("g").attr("class",t);var s=this.svg.select("."+t).selectAll("g").data(n,d4.functor(e.accessors.key).bind(this));s.enter().append("g"),s.exit().remove(),s.attr("class",function(t,e){return"series"+e+" "+this.x.$key}.bind(this));var i=s.selectAll("rect").data(function(t){return t.values}.bind(this));return i.enter().append("rect").attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)).attr("ry",d4.functor(e.accessors.ry).bind(this)).attr("rx",d4.functor(e.accessors.rx).bind(this)).attr("width",d4.functor(e.accessors.width).bind(this)).attr("height",d4.functor(e.accessors.height).bind(this)),i}}})}.call(this),function(){"use strict";d4.feature("lineSeriesLabels",function(t){var e=function(e,n){var r=this.svg.select("."+t).selectAll("."+t+" circle.dataPoint").data(n);r.enter().append("circle"),r.exit().remove(),r.attr("data-key",function(t){return t.key}).style("display","none").attr("r",d4.functor(e.accessors.r).bind(this)()).attr("class",function(t,n){return d4.functor(e.accessors.classes).bind(this)(t,n)+" dataPoint"}.bind(this))},n=function(e,n){var r=this.svg.select("."+t).selectAll("."+t+" text.dataPoint").data(n);r.enter().append("text"),r.exit().remove(),r.attr("data-key",d4.functor(e.accessors.key).bind(this)).style("display","none").attr("class",function(t,n){return d4.functor(e.accessors.classes).bind(this)(t,n)+" dataPoint"}.bind(this))},r=function(e){this.svg.select("."+t).append("rect").attr("class","overlay").style("fill-opacity",0).attr("width",this.width).attr("height",this.height).on("mouseover",function(){this.svg.selectAll("."+t+" .dataPoint").style("display",null)}.bind(this)).on("mouseout",function(){this.svg.selectAll("."+t+" .dataPoint").style("display","none")}.bind(this)).on("mousemove",d4.functor(e.accessors.mouseMove).bind(this))},s=function(t,s){d4.functor(t.accessors.displayPointValue).bind(this)()&&(d4.isNotFunction(this.x.invert)?d4.err(" In order to track the x position of a line series your scale must have an invert() function. However, your {0} scale does not have the invert() function.",this.x.$scale):(n.bind(this)(t,s),e.bind(this)(t,s),r.bind(this)(t)))};return{accessors:{classes:function(t,e){return"stroke series"+e},displayPointValue:!1,key:function(t){return t.key},mouseMove:function(e){var n=function(t,e){return"time"===this.x.$scale?t.getTime()>=e[this.x.$key].getTime():t>=e[this.x.$key]},r=d3.bisector(function(t){return t[this.x.$key]}.bind(this)).right,s=this.svg.select("."+t+" rect.overlay")[0][0],i=this.x.invert(d3.mouse(s)[0]);d4.each(e,function(e,s){var a=r(e.values,i,1),c=e.values[a-1];if(n.bind(this)(i,c)){var u=e.values[a];u=d4.isUndefined(u)?e.values[e.values.length-1]:u;var o=i-c[this.x.$key]>u[this.x.$key]-i?u:c;d4.functor(this.features[t].accessors.showDataPoint).bind(this)(o,e,s),d4.functor(this.features[t].accessors.showDataLabel).bind(this)(o,e,s)}else{var d="."+t+' .dataPoint[data-key="'+e.key+'"]',h=this.svg.select(d);h.style("display","none")}}.bind(this))},pointLabelText:function(t,e){var n=e.key+" "+this.x.$key+": "+t[this.x.$key];return n+=" "+this.y.$key+": "+t[this.y.$key]},r:4.5,showDataLabel:function(e,n,r){var s="."+t+' text.dataPoint[data-key="'+n.key+'"]',i=this.svg.select(s),a=20*r;i.style("display",null).attr("transform","translate(5,"+a+")").text(d4.functor(this.features[t].accessors.pointLabelText).bind(this)(e,n))},showDataPoint:function(e,n){var r="."+t+' circle.dataPoint[data-key="'+n.key+'"]',s=this.svg.select(r);s.style("display",null).attr("transform","translate("+this.x(e[this.x.$key])+","+this.y(e[this.y.$key])+")")},text:function(t){return t.key},x:function(t){return this.x(t.values[t.values.length-1][this.x.$key])},y:function(t){return this.y(t.values[t.values.length-1][this.y.$key])}},render:function(e,n,r){r.append("g").attr("class",t);var i=this.svg.select("."+t).selectAll("."+t).data(n); +return i.enter().append("text"),i.exit().remove(),i.attr("class","line-series-label").text(d4.functor(e.accessors.text).bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)).attr("data-key",d4.functor(e.accessors.key).bind(this)).attr("class",function(t,n){return d4.functor(e.accessors.classes).bind(this)(t,n)+" seriesLabel"}.bind(this)),s.bind(this)(e,n,r),i}}})}.call(this),function(){"use strict";d4.feature("lineSeries",function(t){var e=d3.svg.line();return e.interpolate("linear"),{accessors:{classes:function(t,e){return"line stroke series"+e},key:function(t,e){return(t.key||0)+e},x:function(t){return this.x(t[this.x.$key])},y:function(t){return this.y(t[this.y.$key])}},proxies:[{target:e}],render:function(n,r,s){s.append("g").attr("class",t),e.x(d4.functor(n.accessors.x).bind(this)).y(d4.functor(n.accessors.y).bind(this));var i=s.select("."+t).selectAll("g").data(r,d4.functor(n.accessors.key).bind(this));i.exit().remove(),i.enter().append("g").attr("data-key",function(t){return t.key}).attr("class",d4.functor(n.accessors.classes).bind(this)).append("path").attr("d",function(t){return e(t.values)})}}})}.call(this),function(){"use strict";d4.feature("referenceLine",function(t){return{accessors:{x1:function(){return this.x(this.x.domain()[0])},x2:function(){return this.x(this.x.domain()[1])},y1:function(){return this.y(this.y.domain()[1])},y2:function(){return this.y(this.y.domain()[0])},classes:function(){return"line"}},render:function(e,n,r){r.append("g").attr("class",t);var s=d4.appendOnce(this.svg.select("."+t),"line").attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x1",d4.functor(e.accessors.x1).bind(this)).attr("x2",d4.functor(e.accessors.x2).bind(this)).attr("y1",d4.functor(e.accessors.y1).bind(this)).attr("y2",d4.functor(e.accessors.y2).bind(this));return s}}})}.call(this),function(){"use strict";d4.feature("stackedColumnConnectors",function(t){var e=function(t){return t?0>t?-1:1:0},n=function(t,n,r){return e(t[r])===e(n[r])},r=function(t,e,r,s,i){var a=d4.isOrdinalScale(this.y)?this.x.$key:this.y.$key;return 0!==e&&n(s[r].values[e-1],t,a)?i.bind(this)():0};return{accessors:{x1:function(t){return d4.isOrdinalScale(this.x)?this.x(t[this.x.$key]):this.x(t.y0+t.y)},y1:function(t){return d4.isOrdinalScale(this.y)?this.y(t[this.y.$key]):this.y(t.y0+t.y)},size:function(){return d4.isOrdinalScale(this.x)?this.x.rangeBand():this.y.rangeBand()},classes:function(t,e){return"series"+e}},render:function(e,n,s){s.append("g").attr("class",t);var i=this.svg.select("."+t).selectAll("g").data(n).enter().append("g").attr("class",function(t,e){return"series"+e+" "+this.y.$key}.bind(this)),a=i.selectAll("lines").data(function(t){return t.values}.bind(this));return a.enter().append("line"),a.exit().remove(),a.attr("class",d4.functor(e.accessors.classes).bind(this)).attr("stroke-dasharray","5, 5").attr("x1",function(t,s,i){return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.x1).bind(this)(t)})}.bind(this)).attr("y1",function(t,s,i){var a=d4.isOrdinalScale(this.y)?d4.functor(e.accessors.size).bind(this)(t):0;return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.y1).bind(this)(t)+a})}.bind(this)).attr("x2",function(t,s,i){var a=d4.isOrdinalScale(this.x)?e.accessors.size.bind(this)(t):0;return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.x1).bind(this)(n[i].values[s-1])+a})}.bind(this)).attr("y2",function(t,s,i){return r.bind(this)(t,s,i,n,function(){return d4.functor(e.accessors.y1).bind(this)(n[i].values[s-1])})}.bind(this)),a}}})}.call(this),function(){"use strict";d4.feature("stackedLabels",function(t){var e=function(t){return d4.isDefined(t.y0)?!0:d4.isContinuousScale(this.y)},n=function(t){return e.bind(this)(t)?"middle":"start"},r=function(t,e){var n=this[t];return n(e[n.$key])+n.rangeBand()/2},s=function(t,e){var n,r=this[t],s=Math.abs(r(e.y0)-r(e.y0+e.y))/2,i=10;return"x"===t&&(s*=-1,i*=-1),d4.isDefined(e.y0)?(n=e.y0+e.y,(0>=n?r(e.y0):r(n))+s):(0>=e[r.$key]?r(0):r(e[r.$key]))-i};return{accessors:{classes:"column-label",key:function(t,e){return(t.key||0)+e},stagger:!0,text:function(t){if(!d4.isDefined(t.y0))return t[this.valueKey];if(d4.isOrdinalScale(this.x)){if(Math.abs(this.y(t.y0)-this.y(t.y0+t.y))>20)return t[this.valueKey]}else if(Math.abs(this.x(t.y0)-this.x(t.y0+t.y))>20)return t[this.valueKey]},textAnchor:function(t){return n.bind(this)(t)},x:function(t){return d4.isOrdinalScale(this.x)?r.bind(this)("x",t):s.bind(this)("x",t)},y:function(t){return d4.isOrdinalScale(this.y)?r.bind(this)("y",t):s.bind(this)("y",t)}},render:function(e,n,r){r.append("g").attr("class",t);var s=this.svg.select("."+t).selectAll("g").data(n,d4.functor(e.accessors.key).bind(this));s.enter().append("g").attr("class",function(t,e){return"series"+e+" "+this.x.$key}.bind(this)),s.exit().remove();var i=s.selectAll("text").data(function(t){return t.values}.bind(this));return i.enter().append("text").text(d4.functor(e.accessors.text).bind(this)).attr("text-anchor",d4.functor(e.accessors.textAnchor).bind(this)).attr("class",d4.functor(e.accessors.classes).bind(this)).attr("y",d4.functor(e.accessors.y).bind(this)).attr("x",d4.functor(e.accessors.x).bind(this)),i.exit().remove(),d4.functor(e.accessors.stagger).bind(this)()&&(d4.isContinuousScale(this.y)?s.selectAll("text").call(d4.helpers.staggerTextVertically,-1):s.selectAll("text").call(d4.helpers.staggerTextHorizontally,1)),s.selectAll("text").call(function(t){var e;d4.each(t,function(t){d4.each(t,function(t){var n=d3.select(t);e=t.getBoundingClientRect(),null===n.attr("transform")&&n.attr("transform","translate(0,"+Math.floor(e.height/2)+")")})})}),i}}})}.call(this),function(){"use strict";var t=function(t){return t>0?"positive":"negative"},e=function(t,e){var n=this[t];return n(e[n.$key])},n=function(t){var e=this[t];return e.rangeBand()},r=function(t,e){var n=this[t];return d4.isDefined(e.y0)?Math.abs(n(e.y0)-n(e.y0+e.y)):Math.abs(n(e[n.$key])-n(0))},s=function(t,e){var n,r=this[t];return d4.isDefined(e.y0)?"y"===t?(n=e.y0+e.y,0>n?r(e.y0):r(n)):(n=e.y0+e.y-Math.max(0,e.y),r(n)):"y"===t?0>e[r.$key]?r(0):r(e[r.$key]):(n=e[r.$key]-Math.max(0,e[r.$key]),r(n))},i=function(e,n,r){return{accessors:{classes:function(e,n){return"bar fill item"+n+" "+t(e[this.valueKey])+" "+e[this.y.$key]},key:function(t,e){return(t.key||0)+e}},render:function(t,s,i){i.append("g").attr("class",e);var a=this.svg.select("."+e).selectAll("g").data(s,d4.functor(t.accessors.key).bind(this));a.enter().append("g").attr("class",function(t,e){return"series"+e+" "+this.y.$key}.bind(this)),a.exit().remove();var c=a.selectAll(n).data(function(t){return t.values});return c.enter().append(n).attr("class",d4.functor(t.accessors.classes).bind(this)),r.bind(this)(t,c),c.exit().remove(),c}}};d4.feature("circleSeries",function(t){var a={accessors:{cx:function(t){var i=0;return d4.isOrdinalScale(this.x)?(i=n.bind(this)("x"),e.bind(this)("x",t)+i/2):(i=r.bind(this)("x",t),s.bind(this)("x",t)+i/2)},cy:function(t){var i=0;return d4.isOrdinalScale(this.y)?(i=n.bind(this)("y"),e.bind(this)("y",t)+i/2):(i=r.bind(this)("y",t),s.bind(this)("y",t)+i/2)},r:function(t){var e,s;return e=d4.isOrdinalScale(this.x)?n.bind(this)("x"):r.bind(this)("x",t),s=d4.isOrdinalScale(this.y)?n.bind(this)("y"):r.bind(this)("y",t),Math.min(e,s)/2}}},c=function(t,e){e.attr("r",d4.functor(t.accessors.r).bind(this)).attr("cx",d4.functor(t.accessors.cx).bind(this)).attr("cy",d4.functor(t.accessors.cy).bind(this))},u=i.bind(this)(t,"circle",c);return d4.merge(u,a)}),d4.feature("ellipseSeries",function(t){var a={accessors:{cx:function(t){var i=0;return d4.isOrdinalScale(this.x)?(i=n.bind(this)("x"),e.bind(this)("x",t)+i/2):(i=r.bind(this)("x",t),s.bind(this)("x",t)+i/2)},cy:function(t){var i=0;return d4.isOrdinalScale(this.y)?(i=n.bind(this)("y"),e.bind(this)("y",t)+i/2):(i=r.bind(this)("y",t),s.bind(this)("y",t)+i/2)},rx:function(t){return d4.isOrdinalScale(this.x)?n.bind(this)("x")/2:r.bind(this)("x",t)/2},ry:function(t){return d4.isOrdinalScale(this.y)?n.bind(this)("y")/2:r.bind(this)("y",t)/2}}},c=function(t,e){e.attr("rx",d4.functor(t.accessors.rx).bind(this)).attr("ry",d4.functor(t.accessors.ry).bind(this)).attr("cx",d4.functor(t.accessors.cx).bind(this)).attr("cy",d4.functor(t.accessors.cy).bind(this))},u=i.bind(this)(t,"ellipse",c);return d4.merge(u,a)}),d4.feature("rectSeries",function(t){var a={accessors:{height:function(t){return d4.isOrdinalScale(this.y)?n.bind(this)("y"):r.bind(this)("y",t)},rx:0,ry:0,width:function(t){return d4.isOrdinalScale(this.x)?n.bind(this)("x"):r.bind(this)("x",t)},x:function(t){return d4.isOrdinalScale(this.x)?e.bind(this)("x",t):s.bind(this)("x",t)},y:function(t){return d4.isOrdinalScale(this.y)?e.bind(this)("y",t):s.bind(this)("y",t)}}},c=function(t,e){e.attr("x",d4.functor(t.accessors.x).bind(this)).attr("y",d4.functor(t.accessors.y).bind(this)).attr("ry",d4.functor(t.accessors.ry).bind(this)).attr("rx",d4.functor(t.accessors.rx).bind(this)).attr("width",d4.functor(t.accessors.width).bind(this)).attr("height",d4.functor(t.accessors.height).bind(this))},u=i.bind(this)(t,"rect",c);return d4.merge(u,a)})}.call(this),function(){"use strict";d4.feature("trendLine",function(t){return{accessors:{tipSize:6,text:function(t){return t[this.valueKey]},textX:function(){return this.x(this.width)},textY:function(){return this.x(this.height)},x1:function(){return this.x(this.x.$key)},x2:function(){return this.x(this.width)},y1:function(){return this.y(this.y.$key)},y2:function(){return this.y(this.height)}},render:function(e,n,r){var s=this.svg.select("defs");d4.appendOnce(s,"marker#"+t+"-start").attr("viewBox","0 0 10 10").attr("refX",10).attr("refY",5).attr("markerWidth",d4.functor(e.accessors.tipSize).bind(this)()).attr("markerHeight",d4.functor(e.accessors.tipSize).bind(this)).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z"),d4.appendOnce(r,"g."+t);var i=d4.appendOnce(this.svg.select("."+t),"line.line").attr("x1",d4.functor(e.accessors.x1).bind(this)).attr("x2",d4.functor(e.accessors.x2).bind(this)).attr("y1",d4.functor(e.accessors.y1).bind(this)).attr("y2",d4.functor(e.accessors.y2).bind(this)).attr("marker-end","url(#"+t+"-start)");return d4.appendOnce(this.svg.select("."+t),"text.trendLine-label").text(d4.functor(e.accessors.text).bind(this)).attr("x",d4.functor(e.accessors.textX).bind(this)).attr("y",d4.functor(e.accessors.textY).bind(this)),i}}})}.call(this),function(){"use strict";d4.feature("waterfallConnectors",function(t){return{accessors:{classes:function(t,e){return"series"+e},span:function(){return d4.isOrdinalScale(this.x)?this.x.rangeBand():this.y.rangeBand()},x:function(t){if(d4.isOrdinalScale(this.x))return this.x(t[this.x.$key]);var e=0,n=t.y0+t.y-Math.max(0,t.y);return t.y>0&&(e=Math.abs(this.x(t.y0)-this.x(t.y0+t.y))),this.x(n)+e},y:function(t){return d4.isOrdinalScale(this.x)?this.y(t.y0+t.y):this.y(t[this.y.$key])}},prepare:function(t){var e=t.map(function(t){return t.values[0]});return d4.flatten(e)},render:function(e,n,r){r.append("g").attr("class",t);var s=this.svg.select("."+t).selectAll("."+t).data(n);return s.enter().append("line"),s.exit().remove(),s.attr("class",d4.functor(e.accessors.classes).bind(this)).attr("x1",function(t,r){return 0===r?0:d4.functor(e.accessors.x).bind(this)(n[r-1])}.bind(this)).attr("y1",function(t,r){return 0===r?0:d4.functor(e.accessors.y).bind(this)(n[r-1])}.bind(this)).attr("x2",function(t,r){return 0===r?0:d4.isOrdinalScale(this.x)?d4.functor(e.accessors.x).bind(this)(t)+d4.functor(e.accessors.span).bind(this)():d4.functor(e.accessors.x).bind(this)(n[r-1])}.bind(this)).attr("y2",function(t,r){return 0===r?0:d4.isOrdinalScale(this.x)?d4.functor(e.accessors.y).bind(this)(n[r-1]):d4.functor(e.accessors.y).bind(this)(t)+d4.functor(e.accessors.span).bind(this)(t)}.bind(this)),s}}})}.call(this),function(){"use strict";d4.feature("xAxis",function(t){var e=d3.svg.axis().orient("bottom").tickPadding(10).tickSize(0),n=function(t,e){var n=d4.helpers.textSize(t,e);return n.text=t,n},r=function(t,e,n){if(t.text){var r=this.svg.selectAll(".x.axis"),s=r.node().getBBox(),i=.8*t.height,a=r.append("text").text(t.text).attr("class",""+n);"bottom"===e.toLowerCase()?a.attr("transform","translate(0,"+(s.height+i)+")"):a.attr("transform","translate(0,"+(s.y-i/2)+")")}},s=function(t,e){switch(!0){case"top"===t.toLowerCase():e.attr("transform","translate(0,0)");break;case"bottom"===t.toLowerCase():e.attr("transform","translate(0,"+this.height+")")}},i={accessors:{align:"bottom",stagger:!0,subtitle:void 0,title:void 0},proxies:[{target:e}],render:function(i){i.scale(this.x);var a=n(d4.functor(i.accessors.title).bind(this)(),"title"),c=n(d4.functor(i.accessors.subtitle).bind(this)(),"subtitle"),u=d4.functor(i.accessors.align).bind(this)(),o=this.svg.select("g.margins").append("g").attr("class","x axis "+t).attr("data-scale",this.x.$scale).call(e);s.bind(this)(u,o),d4.functor(i.accessors.stagger).bind(this)()&&o.selectAll(".tick text").call(d4.helpers.staggerTextVertically,1),"top"===u?(r.bind(this)(c,u,"subtitle"),r.bind(this)(a,u,"title")):(r.bind(this)(a,u,"title"),r.bind(this)(c,u,"subtitle"))}};return i})}.call(this),function(){"use strict";d4.feature("yAxis",function(t){var e=d3.svg.axis().orient("left").tickPadding(10).tickSize(0),n=function(t,e){var n=d4.helpers.textSize(t,e);return n.text=t,n},r=function(t,e,n){if(t.text){var r=this.svg.selectAll(".y.axis"),s=r.node().getBBox(),i=.8*t.height,a=r.append("text").text(t.text).attr("class",""+n);"left"===e.toLowerCase()?a.call(d4.helpers.rotateText("rotate(90)translate(0,"+(Math.abs(s.x)+i)+")")):a.call(d4.helpers.rotateText("rotate(90)translate(0,"+(Math.abs(s.x)-(s.width+i))+")"))}},s=function(t,e){switch(!0){case"left"===t.toLowerCase():e.attr("transform","translate(0,0)");break;case"right"===t.toLowerCase():e.attr("transform","translate("+this.width+", 0)")}},i={accessors:{align:"left",stagger:!0,subtitle:void 0,title:void 0},proxies:[{target:e}],render:function(i){i.scale(this.y);var a=n(d4.functor(i.accessors.title).bind(this)(),"title"),c=n(d4.functor(i.accessors.subtitle).bind(this)(),"subtitle"),u=d4.functor(i.accessors.align).bind(this)(),o=this.svg.select("g.margins").append("g").attr("class","y axis "+t).attr("data-scale",this.y.$scale).call(e);o.selectAll(".tick text").call(d4.helpers.wrapText,this.margin[u]),s.bind(this)(u,o),d4.functor(i.accessors.stagger).bind(this)()&&this.svg.selectAll(".y.axis .tick text").call(d4.helpers.staggerTextHorizontally,-1),"left"===u?(r.bind(this)(a,u,"title"),r.bind(this)(c,u,"subtitle")):(r.bind(this)(c,u,"subtitle"),r.bind(this)(a,u,"title"))}};return i})}.call(this),function(){"use strict";d4.parser("nestedGroup",function(){var t={x:{key:"x",values:[]},y:{key:"y",values:[]},value:{key:"value",values:[]},data:[]};t.defined=function(){return!0},t.nestKey=function(){return t.x.key};var e=function(e){var n=[];return d4.each(e,function(e){t.defined(e)&&n.push(e)}.bind(this)),n},n=function(e,n){["x","y","value"].forEach(function(r){var s=n.map(function(t){return t[e[r].key]});t[r].values=d3.set(s).values()})},r=function(t,e,n){var r=d3.nest().key(function(e){return e[t]});return r.entries(n)},s=function(e,n){t[e].key=d4.functor(n)()},i=function(s){return s&&d4.extend(t.data,s),n(t,t.data),t.data=e(t.data),t.data=r(t.nestKey(),t.value.key,t.data),t};return i.nestKey=function(e){return t.nestKey=d4.functor(e).bind(t),i},i.defined=function(e){return t.defined=d4.functor(e).bind(t),i},d4.each(["x","y","value"],function(e){i[e]=function(n){return s.bind(t)(e,d4.functor(n)),i}}.bind(this)),i})}.call(this),function(){"use strict";d4.parser("nestedStack",function(){var t={x:{key:"x",values:[]},y:{key:"y",values:[]},value:{key:"value",values:[]},data:[]};t.defined=function(){return!0},t.nestKey=function(){return t.y.key};var e=function(e){var n=[];return d4.each(e,function(e){t.defined(e)&&n.push(e)}.bind(this)),n},n=function(e,n){["x","y","value"].forEach(function(r){var s=n.map(function(t){return t[e[r].key]});t[r].values=d3.set(s).values()})},r=function(t,e,n){var r=d3.nest().key(function(e){return e[t]});return r.entries(n)},s=function(e,n){var r={},s=d3.layout.stack().values(function(t){return t.values}).x(function(t){return t[e]}).y(function(e){return+e[t.value.key]}).out(function(t,n,s){t.y=s,t.y>=0?(t.y0=r[t[e]+"Pos"]=r[t[e]+"Pos"]||0,r[t[e]+"Pos"]+=s):(t.y0=r[t[e]+"Neg"]=r[t[e]+"Neg"]||0,r[t[e]+"Neg"]-=Math.abs(s))});s(n.reverse())},i=function(e,n){var r=d4.functor(n)();"x"===e&&"y"===r&&d4.err("You cannot use `y` as the key for an `x` dimension because it creates an ambiguous `y` property in the nested stack."),t[e].key=r},a=function(i){return i&&d4.extend(t.data,i),n(t,t.data),t.data=e(t.data),t.data=r(t.nestKey(),t.value.key,t.data),s(t.x.key,t.data),t};return a.nestKey=function(e){return t.nestKey=d4.functor(e).bind(t),a},a.defined=function(e){return t.defined=d4.functor(e).bind(t),a},d4.each(["x","y","value"],function(e){a[e]=function(n){return i.bind(t)(e,d4.functor(n)),a}}.bind(this)),a})}.call(this),function(){"use strict";d4.parser("waterfall",function(){var t={x:{key:"x",values:[]},y:{key:"y",values:[]},value:{key:"value",values:[]},data:[]};t.nestKey=function(){return t.x.key};var e=function(e,n){["x","y","value"].forEach(function(r){var s=n.map(function(t){return t[e[r].key]});t[r].values=d3.set(s).values()})},n=function(t,e,n){var r=d3.nest().key(function(e){return e[t]});return r.entries(n)},r=function(e,n){var r=0,s=function(t){return isNaN(t)?0:t},i=d3.layout.stack().values(function(t){return t.values}).x(function(t){return t[e]}).y(function(e){return+e[t.value.key]}).out(function(e,n,i){isNaN(i)?(isNaN(n)&&(n=r),e.y0=0,e.y=n,e[t.value.key]=n,r=n):(isNaN(n)?(e.y0=r,r+=i):e.y0=n,e.y=i,e[t.value.key]=s(e[t.value.key]))});i(n)},s=function(e,n){t[e].key=d4.functor(n)()},i=function(s){return s&&d4.extend(t.data,s),e(t,t.data),t.data=n(t.nestKey(),t.value.key,t.data),r(t.x.key,t.data),t};return i.nestKey=function(e){return t.nestKey=d4.functor(e).bind(t),i},d4.each(["x","y","value"],function(e){i[e]=function(n){return s.bind(t)(e,d4.functor(n)),i}}.bind(this)),i})}.call(this),function(){"use strict";var t=function(t,e){var n=t.map(function(t){return t.values.map(function(t){return t[e]}.bind(this))}.bind(this));return d3.merge(n)},e=function(t,e){switch(e){case"x":return[0,t.width];case"y":return[t.height,0];default:return[]}},n=function(t,n,r){var s=t[r].$key,i=d3.extent(d3.merge(n.map(function(t){return d3.extent(t.values,function(t){return d4.isDate(t[s])?t[s]:t[s]+(t.y0||0)})}))),a=t[r];if(!a.domain.$dirty)if(d4.isDate(i[0])){var c=a.$min||i[0],u=a.$max||i[1];a.domain([c,u])}else a.domain([Math.min(a.$min||0,i[0]),a.$max||i[1]]);return a.range.$dirty||a.range(e(t,r)),a.clamp.$dirty||a.clamp(!0),t[r].nice()};d4.builder("linearScaleForNestedData",n),d4.builder("timeScaleForNestedData",n),d4.builder("ordinalScaleForNestedData",function(n,r,s){var i=t(r,n[s].$key),a=n[s+"RoundBands"]=n[s+"RoundBands"]||.3,c=n[s];return c.domain.$dirty||c.domain(i),c.rangeRoundBands.$dirty||c.rangePoints.$dirty||c.rangeBands.$dirty||c.rangeRoundBands(e(n,s),a),c})}.call(this); \ No newline at end of file diff --git a/src/features/line-series-labels.js b/src/features/line-series-labels.js index 8b34f483..3120d51b 100644 --- a/src/features/line-series-labels.js +++ b/src/features/line-series-labels.js @@ -105,8 +105,8 @@ }.bind(this)); }, - pointLabelText: function(d) { - var str = this.x.$key + ': ' + d[this.x.$key]; + pointLabelText: function(d, datum) { + var str = datum.key + ' ' + this.x.$key + ': ' + d[this.x.$key]; str += ' ' + this.y.$key + ': ' + d[this.y.$key]; return str; }, @@ -120,7 +120,7 @@ label .style('display', null) .attr('transform', 'translate(5,' + offset + ')') - .text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d)); + .text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d, datum)); }, showDataPoint: function(d, datum) { @@ -154,7 +154,9 @@ .attr('x', d4.functor(scope.accessors.x).bind(this)) .attr('y', d4.functor(scope.accessors.y).bind(this)) .attr('data-key', d4.functor(scope.accessors.key).bind(this)) - .attr('class', d4.functor(scope.accessors.classes).bind(this)); + .attr('class', function(d, n) { + return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' seriesLabel'; + }.bind(this)); displayXValue.bind(this)(scope, data, selection); return label; diff --git a/test/lib/d4.js b/test/lib/d4.js index f4271e8b..77e09a0f 100644 --- a/test/lib/d4.js +++ b/test/lib/d4.js @@ -3206,8 +3206,8 @@ }.bind(this)); }, - pointLabelText: function(d) { - var str = this.x.$key + ': ' + d[this.x.$key]; + pointLabelText: function(d, datum) { + var str = datum.key + ' ' + this.x.$key + ': ' + d[this.x.$key]; str += ' ' + this.y.$key + ': ' + d[this.y.$key]; return str; }, @@ -3221,7 +3221,7 @@ label .style('display', null) .attr('transform', 'translate(5,' + offset + ')') - .text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d)); + .text(d4.functor(this.features[name].accessors.pointLabelText).bind(this)(d, datum)); }, showDataPoint: function(d, datum) { @@ -3255,7 +3255,9 @@ .attr('x', d4.functor(scope.accessors.x).bind(this)) .attr('y', d4.functor(scope.accessors.y).bind(this)) .attr('data-key', d4.functor(scope.accessors.key).bind(this)) - .attr('class', d4.functor(scope.accessors.classes).bind(this)); + .attr('class', function(d, n) { + return d4.functor(scope.accessors.classes).bind(this)(d, n) + ' seriesLabel'; + }.bind(this)); displayXValue.bind(this)(scope, data, selection); return label;