-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathpolychart2.min.js
304 lines (304 loc) · 152 KB
/
polychart2.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
window.polyjs=function(X){if(!X){var c={};(function(){var n=[].indexOf||function(c){for(var l=0,d=this.length;l<d;l++)if(l in this&&this[l]===c)return l;return-1};c.groupBy=function(n,l){return _.groupBy(n,c.stringify(l))};c.stringify=function(c){return function(l){return _.reduce(c,function(d,b){return""+d+b+":"+l[b]+";"},"")}};c.cross=function(n,l){var d,b,a,e,h,k,m,t,p,r;null==l&&(l=[]);a=_.difference(_.keys(n),l);if(0===a.length)return[{}];d=[];e=a[0];a=c.cross(n,l.concat(e));r=n[e];k=0;for(t=
r.length;k<t;k++)for(h=r[k],m=0,p=a.length;m<p;m++)b=a[m],b=_.clone(b),b[e]=h,d.push(b);return d};c.filter=function(c,l,d){var b,a,e,h;a=[];e=0;for(h=c.length;e<h;e++)b=c[e],b[l]===d&&a.push(b);return a};c.intersect=function(c,l){var d,b,a,e,h;b=function(a){var b,e,p,r,f;e=[];f=c[a]["in"];p=0;for(r=f.length;p<r;p++)b=f[p],0<=n.call(l[a]["in"],b)&&e.push(b);return{"in":e}};d=function(a){var b,e,p,r,f;e=function(g){return g[a].lt?{type:"lt",val:g[a].lt}:g[a].le?{type:"le",val:g[a].le}:{type:null,val:null}};
b=function(g){return g[a].gt?{type:"gt",val:g[a].gt}:g[a].ge?{type:"ge",val:g[a].ge}:{type:null,val:null}};b=[b(c),b(l)];r=[e(c),e(l)];b.sort(function(g,f){return f.val-g.val});r.sort(function(f,a){return f.val-a.val});e={};b[0].type&&b[0].val&&(f=b[0],p=f.type,f=f.val,b[0].val===b[1].val&&b[0].type!==b[1].type&&(p="lt"),e[p]=f);r[0].type&&r[0].val&&(f=r[0],p=f.type,f=f.val,r[0].val===r[1].val&&r[0].type!==r[1].type&&(p="lt"),e[p]=f);if(b[0].type&&r[0].type&&(b[0].val>r[0].val||b[0].val===r[0].val&&
("lt"===b[0].key||"gt"===r[0].key)))throw"No intersection found!";return e};e={};for(a in c)h=c[a],e[a]=a in l?"in"in c[a]?b(a):d(a):h;for(a in l)h=l[a],a in e||(e[a]=h);return e};c.linear=function(n,l,d,b){if(_.isFinite(n)&&_.isFinite(l)&&_.isFinite(d)&&_.isFinite(b))return function(a){return(b-l)/(d-n)*(a-n)+l};throw c.error.input("Attempting to create linear function from infinity");};c.median=function(c,l){var d;null==l&&(l=!1);l||(c=_.sortBy(c,function(b){return b}));d=c.length/2;return 0!==
d%1?c[Math.floor(d)]:(c[d-1]+c[d])/2};c.counter=function(){var c;c=0;return function(){return c++}};c.sample=function(c,l){return _.pick(c,_.shuffle(_.keys(c)).splice(0,l))};c.compare=function(c,l){var d,b,a,e,h,k,m,t,p;p=_.sortBy(c,function(a){return a});t=_.sortBy(l,function(a){return a});b=[];a=[];d=[];for(m=h=0;m<p.length||h<t.length;)if(k=p[m],e=t[h],m>=p.length)d.push(e),h+=1;else if(h>=t.length)b.push(k),m+=1;else if(k<e)b.push(k),m+=1;else if(k>e)d.push(e),h+=1;else if(k===e)a.push(k),m+=
1,h+=1;else throw DataError("Unknown data encounted");return{deleted:b,kept:a,added:d}};c.flatten=function(n){var l,d,b,a;l=[];if(null!=n)if(_.isObject(n))if("scalefn"===n.t)"novalue"!==n.f&&l.push(n.v);else for(d in n)b=n[d],l=l.concat(c.flatten(b));else if(_.isArray(n))for(d=0,a=n.length;d<a;d++)b=n[d],l=l.concat(c.flatten(b));else l.push(n);return l};c.getLabel=function(c,l){return _.chain(c).map(function(c){return c.mapping[l]}).without(null,void 0).uniq().value().join(" | ")};c.strSize=function(c){c=
(c+"").length;return 10>c?6*c:5*(c-10)+60};c.sortArrays=function(c,l){var d;d=_.zip.apply(_,l);d.sort(function(b,a){return c(b[0],a[0])});return _.zip.apply(_,d)};c.isDefined=function(n){return _.isObject(n)?"scalefn"===n.t&&"novalue"!==n.f?c.isDefined(n.v):!0:void 0!==n&&null!==n&&!(_.isNumber(n)&&_.isNaN(n))};c.isURI=function(c){var l;return _.isString(c)?(l=RegExp("^(https?:\\/\\/)?((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|((\\d{1,3}\\.){3}\\d{1,3}))(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*(\\?[;&a-z\\d%_.~+=-]*)?(\\#[-a-z\\d_]*)?$",
"i"),l.test(c)):!1}}).call(this);(function(){c["const"]={aes:"x y color size opacity shape id text".split(" "),pivot_aes:["row","column","value"],noDomain:["id","text","tooltip"],noLegend:["x","y","id","text","tooltip"],trans:{bin:["key","binwidth"],lag:["key","lag"]},stat:{count:["key"],unique:["key"],sum:["key"],mean:["key"],box:["key"],median:["key"]},timerange:"second minute hour day week month twomonth quarter sixmonth year twoyear fiveyear decade".split(" "),approxTimeInSeconds:{second:1,minute:60,
hour:3600,day:86400,week:604800,month:2592E3,twomonth:5184E3,quarter:10368E3,sixmonth:15552E3,year:31536E3,twoyear:63072E3,fiveyear:157766400},sort:{key:null,sort:null,limit:null,asc:!1},scaleFns:{novalue:function(){return{v:null,f:"novalue",t:"scalefn"}},max:function(c){return{v:c,f:"max",t:"scalefn"}},min:function(c){return{v:c,f:"min",t:"scalefn"}},upper:function(c,s,l){return{v:c,n:s,m:l,f:"upper",t:"scalefn"}},lower:function(c,s,l){return{v:c,n:s,m:l,f:"lower",t:"scalefn"}},middle:function(c){return{v:c,
f:"middle",t:"scalefn"}},jitter:function(c){return{v:c,f:"jitter",t:"scalefn"}},identity:function(c){return{v:c,f:"identity",t:"scalefn"}}},epsilon:Math.pow(10,-7),defaults:{x:{v:null,f:"novalue",t:"scalefn"},y:{v:null,f:"novalue",t:"scalefn"},color:"steelblue",size:2,opacity:0.7}}}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m={}.hasOwnProperty,t=function(a,b){function f(){this.constructor=a}for(var g in b)m.call(b,g)&&(a[g]=b[g]);f.prototype=b.prototype;a.prototype=new f;a.__super__=b.prototype;
return a};s=function(a){function b(f){this.message=f;this.name="DefinitionError"}t(b,a);return b}(Error);l=function(a){function b(f){this.message=f;this.name="DependencyError"}t(b,a);return b}(Error);b=function(a){function b(f){this.message=f;this.name="ModeError"}t(b,a);return b}(Error);n=function(a){function b(f){this.message=f;this.name="DataError"}t(b,a);return b}(Error);k=function(a){function b(f){this.message=f;this.name="UnknownInput"}t(b,a);return b}(Error);a=function(a){function b(f){this.message=
f;this.name="ModeError"}t(b,a);return b}(Error);e=function(a){function b(f){this.message=f;this.name="ScaleError"}t(b,a);return b}(Error);d=function(a){function b(f){this.message=f;this.name="MissingData"}t(b,a);return b}(Error);h=function(a){function b(f){this.message=f;this.name="Type"}t(b,a);return b}(Error);c.error=function(a){return Error(a)};c.error.data=function(a){return new n(a)};c.error.depn=function(a){return new l(a)};c.error.defn=function(a){return new s(a)};c.error.mode=function(a){return new b(a)};
c.error.impl=function(b){return new a(b)};c.error.input=function(a){return new k(a)};c.error.scale=function(a){return new e(a)};c.error.missing=function(a){return new d(a)};c.error.type=function(a){return new h(a)}}).call(this);(function(){var n,s,l,d,b,a,e={}.hasOwnProperty,h=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a},k=function(a,b){return function(){return a.apply(b,arguments)}};
d=function(){function a(){}a.prototype.render=function(){return c.error.impl()};a.prototype.dispose=function(){return c.error.impl()};return a}();s=function(a){function e(){return b=e.__super__.constructor.apply(this,arguments)}h(e,a);e.prototype.getDimension=function(){throw c.error.impl();};return e}(d);l=function(b){function e(){return a=e.__super__.constructor.apply(this,arguments)}h(e,b);e.prototype.getDimension=function(){throw c.error.impl();};e.prototype.make=function(){throw c.error.impl();
};return e}(d);n=function(a){function b(a){this.type=null!=a?a:null;this.dispose=k(this.dispose,this);this.geoms={};this.pts={}}h(b,a);b.prototype.set=function(a){return this.geoms=a};b.prototype.render=function(a){var b,f,g,q,e,v,d;e={};g=c.compare(_.keys(this.pts),_.keys(this.geoms));f=g.deleted;q=g.kept;b=g.added;v=0;for(d=f.length;v<d;v++)g=f[v],this._delete(a,this.pts[g]);f=0;for(v=b.length;f<v;f++)g=b[f],e[g]=this._add(a,this.geoms[g]);b=0;for(f=q.length;b<f;b++)g=q[b],e[g]=this._modify(a,this.pts[g],
this.geoms[g]);return this.pts=e};b.prototype._delete=function(a,b){var f,g,q;q=[];for(f in b)g=b[f],q.push(a.remove(g));return q};b.prototype._modify=function(a,b,f){var g,q,e,c;e={};c=f.marks;for(q in c){g=c[q];try{e[q]=b[q]?b[q].data("m").type===g.type?a.animate(b[q],g,f.evtData,f.tooltip):(a.remove(b[q]),a.add(g,f.evtData,f.tooltip,this.type)):a.add(g,f.evtData,f.tooltip,this.type)}catch(d){if(g=d,"MissingData"===g.name)console.log(g.message);else throw g;}}return e};b.prototype._add=function(a,
b){var f,g,q,e;q={};e=b.marks;for(g in e){f=e[g];try{q[g]=a.add(f,b.evtData,b.tooltip,this.type)}catch(c){if(f=c,"MissingData"===f.name)console.log(f.message);else throw f;}}return q};b.prototype.dispose=function(a){var b,f,g;g=this.pts;for(b in g)f=g[b],this._delete(a,f);return this.pts={}};return b}(d);c.Renderable=d;c.Guide=s;c.GuideSet=l;c.Geometry=n}).call(this);(function(){var n,s,l=[].slice,d=[].indexOf||function(b){for(var a=0,e=this.length;a<e;a++)if(a in this&&this[a]===b)return a;return-1};
n=function(){function b(a,b,c){a.getContext?this.context=a.getContext("2d"):a.polyGeom=this;a.width=b;a.height=c;this.items=[];this._counter=0}b.prototype._makeItem=function(a,b){var c;c=new s(a,this._newId(),this,b);this.items.unshift(c);return c};b.prototype._newId=function(){return this._counter+=1};b.prototype.rect=function(){var a;a=1<=arguments.length?l.call(arguments,0):[];return this._makeItem("rect",a)};b.prototype.circle=function(){var a;a=1<=arguments.length?l.call(arguments,0):[];return this._makeItem("circle",
a)};b.prototype.path=function(){var a;a=1<=arguments.length?l.call(arguments,0):[];return this._makeItem("path",a)};b.prototype.text=function(){var a;a=1<=arguments.length?l.call(arguments,0):[];return this._makeItem("text",a)};b.prototype.remove=function(a){var b,c,d,m,t;t=this.items;b=d=0;for(m=t.length;d<m;b=++d)if(c=t[b],c.id===a)return this.items.splice(b,1)};b.prototype.toBack=function(a){var b;b=this.remove(a)[0];a=this.items.pop();this.items.push(b);return this.items.push(a)};b.prototype.toFront=
function(a){a=this.remove(a)[0];return this.items.unshift(a)};b.prototype._resetContext=function(){this.context.fillStyle="#000000";this.context.strokeStyle="#000000";this.context.globalAlpha=1;return this.context.lineWidth=0.5};b.prototype._stringToHex=function(a){switch(a){case "black":return"#000000";case "white":return"#ffffff";case "steelblue":return"#4692B4";default:return a}};return b}();s=function(){function b(a,b,c,d){this.type=a;this.id=b;this.canvas=c;this._attr={};this._interact={};this.attr(d)}
b.prototype.attr=function(){var a,b,d;a=1<=arguments.length?l.call(arguments,0):[];if(0<a.length&&_.isArray(a[0]))switch(b=a[0],this.type){case "rect":this._attr=_.extend(this._attr,{x:b[0],y:b[1],width:b[2],height:b[3]});break;case "circle":this._attr=_.extend(this._attr,{x:b[0],y:b[1],r:b[2]});break;case "path":this._attr=_.extend(this._attr,{path:b[0]});break;case "text":this._attr=_.extend(this._attr,{x:b[0],y:b[1],text:b[2],"font-size":"12pt","text-anchor":"middle"});break;default:throw c.error.defn("Unknown geometry type!");
}else if(1===a.length&&_.isObject(a[0]))for(b in d=a[0],d)a=d[b],this._attr[b]=a;else 2===a.length&&(null!=a[0]&&null!=a[1])&&(this._attr[a[0]]=a[1]);return this};b.prototype.remove=function(){return this.canvas.remove(this.id)};b.prototype.toBack=function(){return this.canvas.toBack(this.id)};b.prototype.toFront=function(){return this.canvas.toFront(this.id)};b.prototype.getBBox=function(){var a,b,c,k,m,t,p;if("text"===this.type){b=null!=(a=parseInt(this._attr["font-size"].slice(0,-2)))?a:12;k=0;
c=1.04*b;p=this._attr.text;m=0;for(t=p.length;m<t;m++)a=p[m],k=0<=d.call(",.1",a)?k+b/4:k+b;return{height:c,width:k}}if("rect"===this.type)return{height:this._attr.height,width:this._attr.width};if("circle"===this.type)return{height:this._attr.r,width:this._attr.r}};b.prototype.transform=function(a){if("s"===a[0]&&(a=a.slice(1),"font-size"in this._attr&&(this._attr["font-size"]=this._attr["font-size"].slice(0,-2)*a+"pt"),"width"in this._attr&&(this._attr.width*=a),"height"in this._attr))return this._attr.height*=
a};b.prototype.animate=function(){var a;a=1<=arguments.length?l.call(arguments,0):[];this._attr.animate=a;return this};b.prototype.click=function(a){return this._interact.click=a};b.prototype.drag=function(a,b,c){return this._interact.drag={onmove:a,onstart:b,onend:c}};b.prototype.hover=function(a){return this._interact.hover=a};b.prototype.data=function(a,b){var c;null==(c=this._interact).data&&(c.data={});return this._interact.data[a]=b};b.prototype.touchstart=function(a){return this._interact.touchstart=
a};b.prototype.touchend=function(a){return this._interact.touchend=a};b.prototype.touchmove=function(a){return this._interact.touchmove=a};b.prototype.touchcancel=function(a){return this._interact.touchcancel=a};return b}();c.canvas=function(b,a,c){return new n(b,a,c)}}).call(this);(function(){var n,s;c.offset=function(c){var d,b,a;d={top:0,left:0};if(b=c&&c.ownerDocument)return a=b.documentElement,"undefined"!==typeof c.getBoundingClientRect&&(d=c.getBoundingClientRect()),c=null!==b&&b===b.window?
b:9===b.nodeType&&b.defaultView,{top:d.top+c.pageYOffset-a.clientTop,left:d.left+c.pageXOffset-a.clientLeft}};c.getXY=function(c,d){var b,a;-1!==d.type.indexOf("mouse")?(a=d.clientX,b=d.clientY):-1!==d.type.indexOf("touch")&&(b=d.changedTouches[0],a=b.clientX,b=b.clientY);return{x:a+(document.documentElement&&document.documentElement.scrollLeft||document.body.scrollLeft)-c.left,y:b+(document.documentElement&&document.documentElement.scrollTop||document.body.scrollTop)-c.top}};c.touchToMouse=function(c,
d,b){var a,e,h;null==b&&(b=!1);a=d.lastEvent;h=0<a.touches.length&&a.touches[0]||0<a.changedTouches.length&&a.changedTouches[0];e=document.createEvent("MouseEvent");e.initMouseEvent(c,a.bubbles,a.cancelable,a.view,a.detail,h.screenX,h.screenY,h.clientX,h.clientY,a.ctrlKey,a.altKey,a.shiftKey,a.metaKey,1,a.target);return b?(window.clearTimeout(d.pressTimer),d.pressTimer=window.setTimeout(function(){return a.target.dispatchEvent(e)},b)):a.target.dispatchEvent(e)};n={lastStart:0,lastTouch:0,lastEvent:null,
pressTimer:0};s=window.alert;c.touch=function(l,d,b,a){d.tooltip=d.data("t");d.evtData=d.data("e");n.lastEvent=b;b.preventDefault();if("touchstart"===l)return n.lastStart=b.timeStamp,c.touchToMouse("mousedown",n),n.pressTimer=window.setTimeout(function(){return c.touchToMouse("mouseover",n)},800),window.alert=function(){var a;window.clearTimeout(n.pressTimer);a=arguments;return window.setTimeout(function(){s.apply(window,a);return window.alert=s},100)};if("touchmove"===l){l=a.paper.getById(b.target.raphaelid);
a=c.offset(a.dom);a=c.getXY(a,b);if(600<b.timeStamp-n.lastStart&&l.isPointInside(a.x,a.y))return c.touchToMouse("mouseover",n);window.clearTimeout(n.pressTimer);return c.touchToMouse("mouseout",n)}if("touchend"===l){if(window.clearTimeout(n.pressTimer),c.touchToMouse("mouseup",n),c.touchToMouse("mouseout",n,400),800>b.timeStamp-n.lastStart)return c.touchToMouse("click",n)}else if("touchcancel"===l)return window.clearTimeout(n.pressTimer),c.touchToMouse("mouseout",n),c.touchToMouse("mouseup",n,300)}}).call(this);
(function(){var n,s,l;c.format=function(d,b){switch(d){case "cat":return c.format.identity;case "num":return c.format.number(b);case "date":return c.format.date(b);case "none":return c.format.identity}};c.format.identity=function(c){return c};n={0:"",3:"k",6:"m",9:"b",12:"t"};l=function(c,b){return _.isUndefined(n[b])?c+"e"+(0<b?"+":"-")+Math.abs(b):c+n[b]};s=function(c){var b,a,e;if(!isFinite(c))return c;a=""+c;b=Math.abs(c);1E4<=b&&(e=(""+b).split(/\./),b=e[0].length%3||3,e[0]=a.slice(0,b+(0>c))+
e[0].slice(b).replace(/(\d{3})/g,",$1"),a=e.join("."));return a};c.format.getExp=function(c){return Math.floor(Math.log(Math.abs(0===c?1:c))/Math.LN10)};c.format.number=function(d){return function(b){var a,e;e=0;a=null!=d?d:c.format.getExp(b);null==d||2!==a&&5!==a&&8!==a&&11!==a?-1===a?(a=0,e=null!=d?1:2):-2===a?(a=0,e=null!=d?2:3):1===a||2===a?a=0:3<a&&6>a?a=3:6<a&&9>a?a=6:9<a&&12>a?a=9:12<a&&15>a?a=12:e=null!=d?0:1:(a+=1,e=1);b=Math.round(b/Math.pow(10,a-e));b/=Math.pow(10,e);b=b.toFixed(e);return l(s(b),
a)}};c.format.date=function(d){return-1!==_.indexOf(c["const"].timerange,d)?"second"===d?function(b){return moment.unix(b).format("h:mm:ss a")}:"minute"===d?function(b){return moment.unix(b).format("h:mm a")}:"hour"===d?function(b){return moment.unix(b).format("MMM D h a")}:"day"===d||"week"===d?function(b){return moment.unix(b).format("MMM D")}:"month"===d||"twomonth"===d||"quarter"===d||"sixmonth"===d?function(b){return moment.unix(b).format("YYYY/MM")}:function(b){return moment.unix(b).format("YYYY")}:
function(b){return moment.unix(b).format(d)}};c.format._number_instance=c.format.number();c.format.value=function(d){return _.isNumber(d)?c.format._number_instance(d):d}}).call(this);(function(){var n,s;c.type={};c.type.impute=function(c){var d,b,a,e,h,k;h=b=e=d=0;for(k=c.length;h<k;h++)a=c[h],null!=a&&(b++,isNaN(a)&&isNaN(a.replace(/\$|\,/g,""))||e++,a=moment(a),null!=a&&a.isValid()&&d++);return e>0.95*b?"num":d>0.95*b?"date":"cat"};c.type.coerce=function(c,d){if(_.isUndefined(c)||_.isNull(c)||"cat"===
d.type)return c;if("num"===d.type)return isNaN(c)?+(""+c).replace(/\$|\,/g,""):+c;if("date"===d.type)return!_.isNumber(c)&&_.isEmpty(c)?null:d.format?"unix"===d.format?moment.unix(c).unix():moment(c,d.format).unix():isFinite(c)&&c>=Math.pow(10,9)?moment.unix(c).unix():moment(c).unix()};c.type.compare=function(c){switch(c){case "cat":return n;default:return s}};n=function(c,d){var b,a;if(c===d)return 0;_.isString(c)||(c=""+c);_.isString(d)||(d=""+d);b=c.toLowerCase();a=d.toLowerCase();return b===a?
c<d?-1:c>d?1:0:b<a?-1:b>a?1:0};s=function(c,d){return c===d?0:null===c?1:null===d?-1:c<d?-1:c>d?1:0}}).call(this);(function(){var n,s,l,d,b,a,e=function(a,b){return function(){return a.apply(b,arguments)}},h={}.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var e in b)h.call(b,e)&&(a[e]=b[e]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};c.spec={};c.spec.toStrictMode=function(a){var b,e,d,f,g,q,u,v;a=_.clone(a);null==a.layers&&a.layer&&(a.layers=[a.layer]);
null==a.guides&&a.guide&&(a.guides=a.guide);null==a.guides&&(a.guides={});if(a.layers)for(q=a.layers,b=e=0,f=q.length;e<f;b=++e){d=q[b];v=c["const"].aes;g=0;for(u=v.length;g<u;g++)b=v[g],d[b]&&_.isString(d[b])&&(d[b]={"var":d[b]});null==d.sample&&(d.sample=500)}if(a.facet)for(d=["var","x","y"],q=0,b=d.length;q<b;q++)f=d[q],(e=a.facet[f])&&_.isString(e)&&(a.facet[f]={"var":e});else a.facet={type:"none"};a.coord||(a.coord={type:"cartesian",flip:!1});_.isString(a.dom)&&(a.dom=document.getElementById(a.dom));
return a};c.spec.check=function(a){var b,e,d,f,g;if(null==a.layers||0===a.layers.length)throw c.error.defn("No layers are defined in the specification.");g=a.layers;b=d=0;for(f=g.length;d<f;b=++d){e=g[b];if(null==e.data)throw c.error.defn("Layer "+(b+1)+" does not have data to plot!");if(!e.data.isData)throw c.error.defn("Data must be a Polychart Data object.");}if((null==a.render||!1!==a.render)&&!a.dom)throw c.error.defn("No DOM element specified. Where to make plot?");return a};s=function(){function a(){this["return"]=
e(this["return"],this);this.reset=e(this.reset,this);this.processGrouping=e(this.processGrouping,this);this.processMapping=e(this.processMapping,this);this.addSort=e(this.addSort,this);this.extractFilters=e(this.extractFilters,this);this.translate=e(this.translate,this)}a.prototype.translate=function(a,b){};a.prototype.extractFilters=function(a){var b,e,f,g,q;null==a&&(a={});q=[];for(f in a){e=a[f];g=_.clone(e);b=c.parser.getExpression(f);e=b.exprType;b=b.expr;g.expr=b;if("stat"===e)throw c.error.defn("Aggregate statistics in filters not allowed.");
"trans"===e&&this.trans.push(b);q.push(this.filters.push(g))}return q};a.prototype.addSort=function(a,b){var e,f,g,q,d;q=c.parser.getExpression(a.sort);(f=q.statInfo())?(g=f.fname,f=f.args):(g=null,f=[]);g={key:b,sort:q.expr,stat:g,args:f,limit:a.limit,asc:null!=(e=a.asc)?e:!1};q=0;for(d=f.length;q<d;q++)e=f[q],"ident"!==e.expr[0]&&this.trans.push(e);return this.sort.push(g)};a.prototype.processMapping=function(a){var b,e,f,g,q,d;b=c.parser.getExpression(a["var"]);g=b.exprType;f=b.expr;b=b.statInfo;
a["var"]=f.name;this.select.push(f);"trans"===g&&this.trans.push(f);if("stat"===g){b=b();g=b.fname;e=b.args;q=0;for(d=e.length;q<d;q++)b=e[q],"ident"!==b.expr[0]&&this.trans.push(b);this.stat.push({name:g,args:e,expr:f})}else this.groups.push(f);if("sort"in a)return this.addSort(a,f)};a.prototype.processGrouping=function(a){var b;b=c.parser.getExpression(a["var"]);a=b.exprType;b=b.expr;if("trans"===a)this.trans.push(b);else if("stat"===a)throw c.error.defn("Facet variable should not contain statistics!");
this.select.push(b);return this.groups.push(b)};a.prototype.reset=function(){this.filters=[];this.trans=[];this.stat=[];this.select=[];this.groups=[];return this.sort=[]};a.prototype["return"]=function(){var a;a=function(a,b){var f,g,c,e;null==b&&(b=function(a){return a.name});f={};c=0;for(e=a.length;c<e;c++)g=a[c],f[b(g)]=g;return _.values(f)};return{select:a(this.select),trans:a(this.trans),sort:this.sort,filter:this.filters,stats:{stats:a(this.stat,function(a){return a.expr.name}),groups:a(this.groups)}}};
return a}();n=function(a){function b(){this.pickAesthetics=e(this.pickAesthetics,this);this.translate=e(this.translate,this);return d=b.__super__.constructor.apply(this,arguments)}k(b,a);b.prototype.translate=function(a,b){var f,g,q;null==b&&(b=[]);this.reset();this.extractFilters(null!=(f=a.filter)?f:{});f=this.pickAesthetics(a,c["const"].aes);for(q in f)g=f[q],this.processMapping(g);f=0;for(g=b.length;f<g;f++)q=b[f],this.processGrouping(q);return this["return"]()};b.prototype.pickAesthetics=function(a,
b){var f,g;f=_.pick(a,b);for(g in f)"var"in f[g]||delete f[g];return f};return b}(s);l=function(a){function c(){this.pickAesthetics=e(this.pickAesthetics,this);this.translate=e(this.translate,this);return b=c.__super__.constructor.apply(this,arguments)}k(c,a);c.prototype.translate=function(a){var b,f,g;this.reset();this.extractFilters(null!=(b=a.filter)?b:{});a=this.pickAesthetics(a);f=0;for(g=a.length;f<g;f++)b=a[f],this.processMapping(b);return this["return"]()};c.prototype.pickAesthetics=function(a){var b,
f,g,c,e,d;a=_.pick(a,["columns","rows","values"]);b=[];for(g in a)for(c=a[g],e=0,d=c.length;e<d;e++)f=c[e],"var"in f&&b.push(f);return b};return c}(s);s=function(b){function c(){this.pickAesthetics=e(this.pickAesthetics,this);this.translate=e(this.translate,this);return a=c.__super__.constructor.apply(this,arguments)}k(c,b);c.prototype.translate=function(a){var b,f;this.reset();this.extractFilters(null!=(b=a.filter)?b:{});a=this.pickAesthetics(a);for(f in a)b=a[f],this.processMapping(b);return this["return"]()};
c.prototype.pickAesthetics=function(a){var b;a=_.pick(a,["value"]);for(b in a)"var"in a[b]||delete a[b];return a};return c}(s);n=new n;l=new l;s=new s;c.spec.layerToData=n.translate;c.spec.pivotToData=l.translate;c.spec.numeralToData=s.translate}).call(this);(function(){c.xhr=function(c,s,l){var d;d=new XMLHttpRequest;3>arguments.length?(l=s,s=null):s&&d.overrideMimeType&&d.overrideMimeType(s);d.open("GET",c,!0);s&&d.setRequestHeader("Accept",s);d.onreadystatechange=function(){var b;if(4===d.readyState)return b=
d.status,b=!b&&d.response||200<=b&&300>b||304===b?d:null,l(b)};return d.send(null)};c.text=function(n,s,l){3>arguments.length&&(l=s,s=null);return c.xhr(n,s,function(c){return l(c&&c.responseText)})};c.json=function(n,s){return c.text(n,"application/json",function(c){return s(c?JSON.parse(c):null)})};c.dsv=function(n,s){var l,d,b,a,e,h,k;k=RegExp("\r\n|["+n+"\r\n]","g");h=RegExp('["'+n+"\n]");l=n.charCodeAt(0);b=function(b){return b.map(a).join(n)};a=function(a){var b;return null!=(b=h.test(a))?b:
'"'+a.replace(/\"/g,'""')+{'"':a}};e=null;d=function(a,b){return c.text(a,s,function(a){return b(a&&d.parse(a))})};d.parse=function(a){return d.parseRows(a,function(a,b){var c,f,g;if(b){g={};c=-1;for(f=e.length;++c<f;)g[e[c]]=a[c];return g}e=a;return null})};d.parseRows=function(a,b){var c,e,f,g,q,d,v,h;e={};c={};d=[];q=0;g=v=null;k.lastIndex=0;for(h=function(){var b,f,q;if(k.lastIndex>=a.length)return c;if(g)return g=!1,e;q=k.lastIndex;if(34===a.charCodeAt(q)){for(f=q;f++<a.length;)if(34===a.charCodeAt(f)){if(34!==
a.charCodeAt(f+1))break;f++}k.lastIndex=f+2;b=a.charCodeAt(f+1);13===b?(g=!0,10===a.charCodeAt(f+2)&&k.lastIndex++):10===b&&(g=!0);return a.substring(q+1,f).replace(/""/g,'"')}if(b=k.exec(a))return g=b[0].charCodeAt(0)!==l,a.substring(q,b.index);k.lastIndex=a.length;return a.substring(q)};(v=h())!==c;){for(f=[];v!==e&&v!==c;)f.push(v),v=h();b&&!(f=b(f,q++))||d.push(f)}return d};d.format=function(a){return a.map(b).join("\n")};return d};c.csv=c.dsv(",","text/csv")}).call(this);(function(){var n,s,
l,d,b,a,e,h,k,m,t,p,r,f,g,q,u,v,D,C,z,J,G,B,F,x,H,I,P,R,S,A,da,ea,Y,K,Q,fa,ga,U,Z,ha,V,E,L,ia,T,y,aa,ba,ja,W,ka,M,N,X,ca,w=function(a,b){return function(){return a.apply(b,arguments)}},ma={}.hasOwnProperty,O=function(a,b){function f(){this.constructor=a}for(var g in b)ma.call(b,g)&&(a[g]=b[g]);f.prototype=b.prototype;a.prototype=new f;a.__super__=b.prototype;return a},na=[].slice,la=[].indexOf||function(a){for(var b=0,f=this.length;b<f;b++)if(b in this&&this[b]===a)return b;return-1};x=function(a){return a.replace(/[\[\]\\]/g,
function(a){return"\\"+a})};W=function(a){return a.replace(/\\./g,function(a){return a.slice(1)})};F=function(a){return"["+x(a)+"]"};ja=function(a){var b;b=a.length;"["===a[0]&&"]"===a[b-1]&&(a=a.slice(1,+(b-2)+1||9E9),a=W(a));return a};fa=function(a){return'"'+a.replace(/["\\]/g,function(a){return"\\"+a})+'"'};ka=function(a){var b,f,g,c,q;b=a.length;q=['"',"'"];g=0;for(c=q.length;g<c;g++)if(f=q[g],a[0]===f&&a[b-1]===f){a=a.slice(1,+(b-2)+1||9E9);a=W(a);break}return a};U=function(a,b){return""+a+
"("+b+")"};Z=function(a){return"["+a+"]"};e=function(){return function(a){this.message=a}}();a=function(){function a(b){this.name=b;this._unify=w(this._unify,this);this._runify=w(this._runify,this);this._known_unify=w(this._known_unify,this);this.unify=w(this.unify,this);this.mismatch=w(this.mismatch,this);this.error=w(this.error,this)}a.prototype.error=function(a,b){var f,g,c,q,d;d=[];c=0;for(q=a.length;c<q;c++)g=a[c],f=g[0],g=g[1],d.push("("+f+" vs. "+g+")");d.reverse();f=d.join(" in ");throw new e(b+
": "+f);};a.prototype.mismatch=function(a){return this.error(a,"Type mismatch")};a.prototype.unify=function(a){return a._known_unify(this)};a.prototype._known_unify=function(a){this._runify([],a);return this};a.prototype._runify=function(a,b){return this._unify(a.concat([[this.toString(),b.toString()]]),b)};a.prototype._unify=function(a,b){if(this.name!==b.name)return this.mismatch(a)};return a}();J=function(a){function b(){this._unify=w(this._unify,this);this.unify=w(this.unify,this);this.toString=
w(this.toString,this);b.__super__.constructor.call(this,"?");this.found=null}O(b,a);b.prototype.toString=function(){return null===this.found?"?":this.found.toString()};b.prototype.unify=function(a){return this._known_unify(a)};b.prototype._unify=function(a,b){return null===this.found?this.found=b:this.found._unify(a,b)};return b}(a);n=function(a){function b(){this.toString=w(this.toString,this);return X=b.__super__.constructor.apply(this,arguments)}O(b,a);b.prototype.toString=function(){return""+
this.name};return b}(a);k=function(a){function b(a,f){this.domains=a;this.range=f;this._unify=w(this._unify,this);this.toString=w(this.toString,this);b.__super__.constructor.call(this,"->")}O(b,a);b.prototype.toString=function(){var a,b,f,g,c;g=this.domains;c=[];b=0;for(f=g.length;b<f;b++)a=g[b],c.push(a.toString());return"(["+c.join(", ")+"] -> "+this.range+")"};b.prototype._unify=function(a,f){var g,c,q,e,d;b.__super__._unify.call(this,a,f);this.domains.length!==f.domains.length&&this.error(a,"function domains differ in length");
d=_.zip(this.domains,f.domains);q=0;for(e=d.length;q<e;q++)c=d[q],g=c[0],c=c[1],g._runify(a,c);return this.range._runify(a,f.range)};return b}(a);a.Base=_.object(function(){var a,b;a={cat:"cat",num:"num",date:"date",stat:"stat"};b=[];for(Y in a)ga=a[Y],b.push([Y,new n(ga)]);return b}());D=function(){function a(b){this.toString=w(this.toString,this);this.get=w(this.get,this);this.peek=w(this.peek,this);this.empty=w(this.empty,this);var f,g,c,q;q=[];g=0;for(c=b.length;g<c;g++)f=b[g],q.push(f);this.buffer=
q.reverse()}a.prototype.empty=function(){return 0===this.buffer.length};a.prototype.peek=function(){return this.empty()?null:this.buffer[this.buffer.length-1]};a.prototype.get=function(){return this.empty()?null:this.buffer.pop()};a.prototype.toString=function(){return U("Stream",Z(na.call(this.buffer).reverse()))};return a}();z=function(){function a(b){this.tag=b;this.contents=w(this.contents,this);this.toString=w(this.toString,this)}a.Tag={symbol:"symbol",literal:"literal",infixsymbol:"infixsymbol",
keyword:"keyword",lparen:"(",rparen:")",comma:","};a.prototype.toString=function(){return"<"+this.contents().toString()+">"};a.prototype.contents=function(){return[this.tag]};return a}();C=function(a){function b(a){this.name=a;this.contents=w(this.contents,this);this.name=ja(this.name);b.__super__.constructor.call(this,z.Tag.symbol)}O(b,a);b.prototype.contents=function(){return b.__super__.contents.call(this).concat([this.name])};return b}(z);g=function(b){function f(b,g){this.val=b;this.type=g;this.contents=
w(this.contents,this);f.__super__.constructor.call(this,z.Tag.literal);this.type===a.Base.cat&&(this.val=ka(this.val))}O(f,b);f.prototype.contents=function(){return f.__super__.contents.call(this).concat([this.val])};return f}(z);p=function(a){function b(a){this.op=a;this.contents=w(this.contents,this);b.__super__.constructor.call(this,z.Tag.infixsymbol)}O(b,a);b.prototype.contents=function(){return b.__super__.contents.call(this).concat([this.op])};return b}(z);r=function(a){function b(a){this.name=
a;this.contents=w(this.contents,this);b.__super__.constructor.call(this,z.Tag.keyword)}O(b,a);b.prototype.contents=function(){return b.__super__.contents.call(this).concat([this.name])};return b}(z);h=function(){var a,b,f,g;f=[z.Tag.lparen,z.Tag.rparen,z.Tag.comma];g=[];a=0;for(b=f.length;a<b;a++)V=f[a],g.push(new z(V));return g}();f=h[0];v=h[1];l=h[2];S="++ * / % + - >= > <= < != ==".split(" ");R=function(a,b){return S.indexOf(a)<=S.indexOf(b)};h=function(){var a,b,f;f=[];a=0;for(b=S.length;a<b;a++)ha=
S[a],f.push(ha.replace(/[+*]/g,function(a){return"(\\"+a+")"}));return f}();h=RegExp("^("+h.join("|")+")");da=["if","then","else"];ba=[[/^\(/,function(){return f}],[/^\)/,function(){return v}],[/^,/,function(){return l}],[/^[+-]?(0x[0-9a-fA-F]+|0?\.\d+|[1-9]\d*(\.\d+)?|0)([eE][+-]?\d+)?/,function(b){return new g(b,a.Base.num)}],[/^(([\w|\.]|[^\u0000-\u0080])+|\[((\\.)|[^\\\[\]])+\])/,function(a){return 0<=la.call(da,a)?new r(a):new C(a)}],[/^('((\\.)|[^\\'])*'|"((\\.)|[^\\"])+")/,function(b){return new g(b,
a.Base.cat)}],[h,function(a){return new p(a)}]];ea=function(a){var b,f,g,q;g=0;for(q=ba.length;g<q;g++)if(f=ba[g],b=f[0],f=f[1],b=b.exec(a))return g=b[0],[a.slice(g.length),f(g)];throw c.error.defn("There is an error in your specification at "+a);};aa=function(a){var b,f;for(f=[];;){a=a.replace(/^\s+/,"");if(!a)break;b=ea(a);a=b[0];b=b[1];f.push(b)}return f};h=function(){function a(){}a.prototype.toString=function(){return U(this.constructor.name,this.contents())};return a}();m=function(a){function b(a){this.name=
a;this.visit=w(this.visit,this);this.pretty=w(this.pretty,this);this.contents=w(this.contents,this)}O(b,a);b.prototype.contents=function(){return[this.name]};b.prototype.pretty=function(){return F(this.name)};b.prototype.visit=function(a){return a.ident(this,this.name)};return b}(h);b=function(b){function f(a,b){this.val=a;this.vtype=b;this.visit=w(this.visit,this);this.pretty=w(this.pretty,this);this.contents=w(this.contents,this)}O(f,b);f.prototype.contents=function(){return[this.val]};f.prototype.pretty=
function(){return this.vtype===a.Base.cat?fa(this.val):this.val};f.prototype.visit=function(a){return a["const"](this,this.val,this.vtype)};return f}(h);s=function(a){function b(a,f){this.fname=a;this.args=f;this.visit=w(this.visit,this);this.pretty=w(this.pretty,this);this.contents=w(this.contents,this)}O(b,a);b.prototype.contents=function(){return[this.fname,Z(this.args)]};b.prototype.pretty=function(){var a,b=this.fname,f,g,c,q;c=this.args;q=[];f=0;for(g=c.length;f<g;f++)a=c[f],q.push(a.pretty());
return U(b,q)};b.prototype.visit=function(a){var b;return a.call(this,this.fname,function(){var f,g,c,q;c=this.args;q=[];f=0;for(g=c.length;f<g;f++)b=c[f],q.push(b.visit(a));return q}.call(this))};return b}(h);t=function(a){function b(a,f,g){this.opsym=a;this.lhs=f;this.rhs=g;this.visit=w(this.visit,this);this.pretty=w(this.pretty,this);this.contents=w(this.contents,this)}O(b,a);b.prototype.contents=function(){return[this.lhs,this.opsym,this.rhs]};b.prototype.pretty=function(){return"("+[this.lhs.pretty(),
this.opsym,this.rhs.pretty()].join(" ")+")"};b.prototype.visit=function(a){return a.infixop(this,this.opsym,this.lhs.visit(a),this.rhs.visit(a))};return b}(h);d=function(a){function b(a,f,g){this.condition=a;this.consequent=f;this.alternative=g;this.visit=w(this.visit,this);this.pretty=w(this.pretty,this);this.contents=w(this.contents,this)}O(b,a);b.prototype.contents=function(){return[this.condition,this.consequent,this.alternative]};b.prototype.pretty=function(){return"(if "+this.condition.pretty()+
" "+("then "+this.consequent.pretty()+" else "+this.alternative.pretty()+")")};b.prototype.visit=function(a){return a.conditional(this,this.condition.visit(a),this.consequent.visit(a),this.alternative.visit(a))};return b}(h);q=function(){function a(){this.finish=w(this.finish,this);this.push=w(this.push,this);this._reduce=w(this._reduce,this);this.ops=[]}a.prototype._reduce=function(a,b){for(var f,g;0!==this.ops.length;)if(g=this.ops.pop(),f=g[0],g=g[1],b(g))a=new t(g,f,a);else{this.ops.push([f,g]);
break}return a};a.prototype.push=function(a,b){a=this._reduce(a,function(a){return R(a,b)});return this.ops.push([a,b])};a.prototype.finish=function(a){return this._reduce(a,function(a){return!0})};return a}();G=function(a,b){if(a!==b)throw c.error.defn("Expected "+b+" but received "+a);};B=function(a,b){return G(a.tag,b)};u=function(){function a(b){this.stream=b;this.parseFinish=w(this.parseFinish,this);this.parseInfix=w(this.parseInfix,this);this.parseCallArgs=w(this.parseCallArgs,this);this.parseCall=
w(this.parseCall,this);this.parseAtomCall=w(this.parseAtomCall,this);this.parseParenExpr=w(this.parseParenExpr,this);this.parseConditional=w(this.parseConditional,this);this.parseKeyword=w(this.parseKeyword,this);this.parseKeywordExpr=w(this.parseKeywordExpr,this);this.parseExpr=w(this.parseExpr,this);this.parseSubExpr=w(this.parseSubExpr,this);this.parseTopExpr=w(this.parseTopExpr,this);this.parseFail=w(this.parseFail,this);this.expect=w(this.expect,this);this.ops=new q}a.prototype.expect=function(a,
b){var f,g,c,q,e;g=this.stream.peek();if(null!==g)for(c=0,q=b.length;c<q;c++)if(f=b[c],V=f[0],f=f[1],e=g.tag,0<=la.call(V,e))return f();return a()};a.prototype.parseFail=function(){throw c.error.defn("There is an error in your specification at "+this.stream.toString());};a.prototype.parseTopExpr=function(){var a;a=this.parseExpr();null!==this.stream.peek()&&this.parseFail();return a};a.prototype.parseSubExpr=function(){return(new a(this.stream)).parseExpr()};a.prototype.parseExpr=function(){var a;
a=this.expect(this.parseFail,[[[z.Tag.lparen],this.parseParenExpr],[[z.Tag.keyword],this.parseKeywordExpr],[[z.Tag.literal,z.Tag.symbol],this.parseAtomCall]]);return this.expect(this.parseFinish(a),[[[z.Tag.infixsymbol],this.parseInfix(a)]])};a.prototype.parseKeywordExpr=function(){var a;a=this.stream.peek();B(a,z.Tag.keyword);switch(a.name){case "if":return this.parseConditional();default:return this.parseFail()}};a.prototype.parseKeyword=function(a){var b;b=this.stream.get();B(b,z.Tag.keyword);
return G(b.name,a)};a.prototype.parseConditional=function(){var a,b,f;this.parseKeyword("if");b=this.parseSubExpr();this.parseKeyword("then");f=this.parseSubExpr();this.parseKeyword("else");a=this.parseSubExpr();return new d(b,f,a)};a.prototype.parseParenExpr=function(){var a;G(this.stream.get(),f);a=this.parseSubExpr();G(this.stream.get(),v);return a};a.prototype.parseAtomCall=function(){var a,f;f=this.stream.get();a=f.tag===z.Tag.literal?new b(f.val,f.type):f.tag===z.Tag.symbol?new m(f.name):G(!1,
!0);return this.expect(function(){return a},[[[z.Tag.lparen],this.parseCall(f)]])};a.prototype.parseCall=function(a){var b=this;return function(g){var c;B(a,z.Tag.symbol);G(b.stream.get(),f);c=a.name;g=b.expect(b.parseCallArgs([]),[[[z.Tag.rparen],function(){b.stream.get();return[]}]]);return new s(c,g)}};a.prototype.parseCallArgs=function(a){var b=this;return function(){var f,g;f=b.parseSubExpr();g=a.concat([f]);return b.expect(b.parseFail,[[[z.Tag.rparen],function(){b.stream.get();return g}],[[z.Tag.comma],
function(){b.stream.get();return b.parseCallArgs(g)()}]])}};a.prototype.parseInfix=function(a){var b=this;return function(){var f;f=b.stream.get();B(f,z.Tag.infixsymbol);b.ops.push(a,f.op);return b.parseExpr()}};a.prototype.parseFinish=function(a){var b=this;return function(){return b.ops.finish(a)}};return a}();Q=function(a){a=new D(aa(a));return(new u(a)).parseTopExpr()};I=function(b,f,g){var q;q=function(a,f){var g,q;if(!(a in b))throw c.error.defn("Unknown function name: "+a);"++"===a&&2===f.length&&
(f[1]===y&&f[0]===E&&(a="++_num1"),f[0]===y&&f[1]===E&&(a="++_num2"));"bin"===a&&(2===f.length&&f[0]===L)&&(a="bin_date");"min"!==a&&"max"!==a||(1!==f.length||f[0]!==L)||(a+="_date");"count"!==a&&"unique"!==a&&"lag"!==a||1!==f.length||(f[0]===E?a+="_cat":f[0]===L&&(a+="_date"));"parseDate"===a&&1===f.length&&(a="parseDateDefault");g=b[a];q=new J;g.unify(new k(f,q));return q.found};return g.visit({ident:function(a,b){if(b in f)return f[b];throw c.error.defn("Unknown column name: "+b);},"const":function(a,
b,f){return f},call:function(a,b,f){return q(b,f)},infixop:function(a,b,f,g){return q(b,[f,g])},conditional:function(b,f,g,c){f.unify(a.Base.num);g.unify(c);return g}})};E=a.Base.cat;y=a.Base.num;L=a.Base.date;K=new k([y,y],y);A={"++":new k([E,E],E),"++_num1":new k([E,y],E),"++_num2":new k([y,E],E)};ca="* / % + - >= > <= < != == =".split(" ");M=0;for(N=ca.length;M<N;M++)h=ca[M],A[h]=K;N=["sum","mean","box","median"];K=0;for(M=N.length;K<M;K++)h=N[K],A[h]=new k([y],a.Base.stat);N=["min","max"];K=0;
for(M=N.length;K<M;K++)h=N[K],A[h]=new k([y],a.Base.stat),A[h+"_date"]=new k([L],a.Base.stat);N=["count","unique"];K=0;for(M=N.length;K<M;K++)h=N[K],A[h]=new k([y],a.Base.stat),A[h+"_cat"]=new k([E],a.Base.stat),A[h+"_date"]=new k([L],a.Base.stat);N=["lag"];M=0;for(K=N.length;M<K;M++)h=N[M],A[h]=new k([y,y],y),A[h+"_cat"]=new k([E,y],E),A[h+"_date"]=new k([L,y],L);A.log=new k([y],y);A.substr=new k([E,y,y],E);A.length=new k([E],y);A.upper=new k([E],E);A.lower=new k([E],E);A.indexOf=new k([E,E],y);
A.parseNum=new k([E],y);A.parseDate=new k([E,E],L);A.parseDateDefault=new k([E],L);A.year=new k([L],y);A.month=new k([L],y);A.dayOfMonth=new k([L],y);A.dayOfYear=new k([L],y);A.dayOfWeek=new k([L],y);A.hour=new k([L],y);A.minute=new k([L],y);A.second=new k([L],y);A.bin=new k([y,y],y);A.bin_date=new k([L,E],L);H=function(a){return a.visit({ident:function(a,b){return["ident",{name:b}]},"const":function(a,b,f){return["const",{value:b,type:f.name}]},call:function(a,b,f){return["call",{fname:b,args:f}]},
infixop:function(a,b,f,g){return["infixop",{opname:b,lhs:f,rhs:g}]},conditional:function(a,b,f,g){return["conditional",{cond:b,conseq:f,altern:g}]}})};T=_.clone(A);T.sum=new k([y],a.Base.stat);T.log=new k([y],y);T.nameCollision=new k([E],y);ia={x:y,nameCollision:E};P=function(a){var b;try{if(b=Q(a),"name"in b)return b.name}catch(f){}return a};c.parser={tj:function(a){a=Q(a);return H(a)},tc:function(a){a=Q(a);return I(T,ia,a)},ttc:function(){var b,f,g,c;f=a.Base.cat;g=a.Base.num;c=new J;b=new k([f,
g,c,g],g);f=new k([f,g,f,c],g);return b.unify(f)},createColTypeEnv:function(b){var f,g,c;f={};for(g in b)c=b[g],f[g]=a.Base[c.type];return f},getExpression:function(a){var b,f,g,c;"count(*)"===a&&(a="count(1)");b=Q(a);f=function(a){return{name:a.pretty(),expr:H(a)}};g=function(){};a=f(b);return{exprType:"ident"===a.expr[0]?"ident":!_.has(b,"fname")||"sum"!==(c=b.fname)&&"count"!==c&&"unique"!==c&&"mean"!==c&&"box"!==c&&"median"!==c&&"min"!==c&&"max"!==c?"trans":(g=function(){var a,g=b.fname,c,q,e,
d;e=b.args;d=[];q=0;for(c=e.length;q<c;q++)a=e[q],d.push(f(a));return{fname:g,args:d}},"stat"),expr:a,statInfo:g}},getType:function(a,b,f){null==f&&(f=!0);a=I(A,b,Q(a));return f&&"stat"===a.name?"num":a.name},tokenize:aa,parse:Q,bracket:F,unbracket:P,normalize:function(a){return P(Q(a).pretty())},escape:x,unescape:W}}).call(this);(function(){var n,s,l,d,b,a={}.hasOwnProperty,e=function(b,c){function e(){this.constructor=b}for(var d in c)a.call(c,d)&&(b[d]=c[d]);e.prototype=c.prototype;b.prototype=
new e;b.__super__=c.prototype;return b},h=function(a,b){return function(){return a.apply(b,arguments)}};s=function(){function a(b){var c;this.spec=b;null==this.spec&&(this.spec={});this.flip=null!=(c=this.spec.flip)?c:!1;this.scales=null;b=this.flip?["y","x"]:["x","y"];this.x=b[0];this.y=b[1]}a.prototype.make=function(a){return this.dims=a};a.prototype.setScales=function(a){return this.scales={x:a.x.f,y:a.y.f}};a.prototype.clipping=function(a){return[a.x,a.y,this.dims.eachWidth,this.dims.eachHeight]};
a.prototype.getScale=function(a){};a.prototype.ranges=function(){};return a}();n=function(a){function b(){return d=b.__super__.constructor.apply(this,arguments)}e(b,a);b.prototype.type="cartesian";b.prototype.getScale=function(a){if("x"===a||"y"===a)return this.scales[this[a]];throw c.error.input("Coordinates only keep x & y scales");};b.prototype.ranges=function(){var a;a={};a[this.x]={min:0,max:this.dims.eachWidth};a[this.y]={min:this.dims.eachHeight,max:0};return a};b.prototype.axisType=function(a){return this[a]};
b.prototype.getXY=function(a,b){var c,f;if(a)return c={x:_.isArray(b.x)?_.map(b.x,this.scales.x):this.scales.x(b.x),y:_.isArray(b.y)?_.map(b.y,this.scales.y):this.scales.y(b.y)},{x:c[this.x],y:c[this.y]};c=this.scales[this.x];f=this.scales[this.y];return{x:_.isArray(b.x)?_.map(b.x,c):c(b.x),y:_.isArray(b.y)?_.map(b.y,f):f(b.y)}};b.prototype.getAes=function(a,b,c){return{x:c.x(a[this.x],b[this.x]),y:c.y(a[this.y],b[this.y])}};return b}(s);l=function(a){function d(){this.getXY=h(this.getXY,this);return b=
d.__super__.constructor.apply(this,arguments)}e(d,a);d.prototype.type="polar";d.prototype.make=function(a){this.dims=a;this.cx=this.dims.eachWidth/2;return this.cy=this.dims.eachHeight/2};d.prototype.getScale=function(a){if("r"===a)return this.scales[this.x];if("t"===a)return this.scales[this.y];throw c.error.input("Coordinates only keep r & t scales");};d.prototype.ranges=function(){var a,b,c;b=[this.x,this.y];a=b[0];c=b[1];b={};b[c]={min:0,max:2*Math.PI};b[a]={min:0,max:Math.min(this.dims.eachWidth,
this.dims.eachHeight)/2-10};return b};d.prototype.axisType=function(a){return"x"===this[a]?"r":"t"};d.prototype.getXY=function(a,b){var c,f,g,q,e,d,h,k,m,l,G,B,F,x,H=this;l=function(a,b){return H.cx+a*Math.cos(b-Math.PI/2)};G=function(a,b){return H.cy+a*Math.sin(b-Math.PI/2)};q=[this.x,this.y];e=q[0];h=q[1];if(a){if(_.isArray(b[e])){q={x:[],y:[],r:[],t:[]};F=b[e];f=c=0;for(B=F.length;c<B;f=++c)d=F[f],d=this.scales[e](d),k=this.scales[h](b[h][f]),q.x.push(l(d,k)),q.y.push(G(d,k)),q.r.push(d),q.t.push(k);
return q}d=this.scales[e](b[e]);k=this.scales[h](b[h]);return{x:l(d,k),y:G(d,k),r:d,t:k}}g=function(a){return _.isObject(a)&&"scalefn"===a.t&&"identity"===a.f};c=function(a,b){var f,c;f=g(a);c=g(b);if(f&&!c)return{x:a.v,y:G(H.scales[e](b),0)};if(f&&c)return{x:a.v,y:b.v};if(!f&&c)return{y:b.v,x:G(H.scales[h](a),0)};d=H.scales[e](b);k=H.scales[h](a);return{x:l(d,k),y:G(d,k)}};if(_.isArray(b.x)){q={x:[],y:[]};x=b.x;f=B=0;for(F=x.length;B<F;f=++B)m=x[f],f=b.y[f],m=c(m,f),f=m.x,m=m.y,q.x.push(f),q.y.push(m);
return q}return c(b.x,b.y)};return d}(s);c.coord={cartesian:function(a){return new n(a)},polar:function(a){return new l(a)}};c.coord.make=function(a){if(null==a||null==a.type)return c.coord.cartesian();switch(a.type){case "cartesian":return c.coord.cartesian(a);case "polar":return c.coord.polar(a);default:throw c.error.defn("No such coordinate type "+a.type+".");}}}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;
return-1};d=c["const"].aes;c.domain={};c.domain.make=function(a,b,e,f){var g,q,d;g=[];for(d in a)q=a[d],g.push(h(q.geoms,b[d],e,f));return c.domain.merge(g)};c.domain.compare=function(a){return a?"cat"===a.type?function(b,c){b=_.indexOf(a.levels,b);c=_.indexOf(a.levels,c);return-1===b?1:-1===c?-1:b<c?-1:b>c?1:0}:c.type.compare(a.type):function(a){return a}};l=function(){return function(a){this.type=a.type;this.min=a.min;this.max=a.max;this.bw=a.bw}}();s=function(){return function(a){this.type=a.type;
this.min=a.min;this.max=a.max;this.bw=a.bw}}();n=function(){return function(a){this.type=a.type;this.levels=a.levels;this.sorted=a.sorted}}();e=function(a){"cat"!==a.type&&a.max===a.min&&(a.bw?(a.max+=a.bw,a.min-=a.bw):0===a.max?a.max+=1:(a.max*=1.1,a.min/=1.1));switch(a.type){case "num":return new l(a);case "date":return new s(a);case "cat":return new n(a)}};c.domain.single=function(a,b,d){var f,g,q,u,v,h,k,m,l,G,B,F,x,H,I,P,R,n,A;if(0===a.length)throw c.error.input("Dataset is none?");g=function(a){return null!=
d?d[a]:null};switch(b.type){case "num":return f=null!=(u=g("bw"))?u:b.bw,1<a.length?(b=null!=(v=g("min"))?v:_.min(a),q=null!=(F=g("max"))?F:_.max(a)+(null!=f?f:0)):1===a.length?f?(b=null!=(x=g("min"))?x:a[0],q=null!=(H=g("max"))?H:a[0]+f):(b=null!=(I=g("min"))?I:a[0]-1,q=null!=(P=g("max"))?P:a[0]+1):(b=null!=(R=g("min"))?R:0,q=null!=(n=null!=(A=g("max"))?A:f)?n:1),e({type:"num",min:b,max:q,bw:f});case "date":return f=null!=(h=g("bw"))?h:b.bw,b=null!=(k=g("min"))?k:_.min(a),q=g("max"),null==q&&(q=
_.max(a),q=function(){switch(f){case "week":return moment.unix(q).add("days",7).unix();case "twomonth":return moment.unix(q).add("months",2).unix();case "quarter":return moment.unix(q).add("months",4).unix();case "sixmonth":return moment.unix(q).add("months",6).unix();case "twoyear":return moment.unix(q).add("years",2).unix();case "fiveyear":return moment.unix(q).add("years",5).unix();case "decade":return moment.unix(q).add("years",10).unix();default:return moment.unix(q).add(f+"s",1).unix()}}()),
e({type:"date",min:b,max:q,bw:f});case "cat":return e({type:"cat",levels:null!=(m=null!=(l=g("levels"))?l:b.levels)?m:_.uniq(a),sorted:null!=(G=null!=(B=g("levels"))?B:b.sorted)?G:!1})}};h=function(b,d,h,f){var g,q,u,v,k;q={};for(g in d)v=d[g],u=h[g],0<=m.call(c["const"].noDomain,g)||(f?q[g]=e(h[g]):(k=a(b,g),q[g]=c.domain.single(k,v,u)));return q};a=function(a,b){var e,f,g,q,d;q=[];for(f in a)for(g in e=a[f],d=e.marks,d)e=d[g],q=q.concat(c.flatten(e[b]));d=[];g=0;for(e=q.length;g<e;g++)f=q[g],c.isDefined(f)&&
d.push(f);return d};c.domain.merge=function(a){var b,c,f,g,q;f={};g=0;for(q=d.length;g<q;g++)b=d[g],c=_.without(_.pluck(a,b),void 0),0<c.length&&(f[b]=k(c));return f};b={num:function(a){var b,d;b=_.compact(_.uniq(_.map(a,function(a){return a.bw})));if(1<b.length)throw c.error.data("Not all layers have the same binwidth.");b=null!=(d=b[0])?d:void 0;d=_.min(_.map(a,function(a){return a.min}));a=_.max(_.map(a,function(a){return a.max}));return e({type:"num",min:d,max:a,bw:b})},date:function(a){var b,
d;b=_.compact(_.uniq(_.map(a,function(a){return a.bw})));if(1<b.length)throw c.error.data("Not all layers have the same binwidth.");b=null!=(d=b[0])?d:void 0;d=_.min(_.map(a,function(a){return a.min}));a=_.max(_.map(a,function(a){return a.max}));return e({type:"date",min:d,max:a,bw:b})},cat:function(a){var b,d,f,g,q,u,v,h;g=[];q=0;for(v=a.length;q<v;q++)if(d=a[q],d.sorted){b=!0;u=0;for(h=g.length;u<h;u++)f=g[u],_.isEqual(f,d.levels)&&(b=!1);b&&g.push(d.levels)}a=_.chain(a).filter(function(a){return!a.sorted}).map(function(a){return a.levels}).value();
if(1<g.length&&_.intersection.apply(this,g))throw c.error.data("You are trying to combine incompatible sorted domains in the same axis.");g=[_.flatten(g,!0)];a=_.union.apply(this,g.concat(a));0===g[0].length&&(a=a.sort());return e({type:"cat",levels:a,sorted:0!==g[0].length})}};k=function(a){var e;e=_.uniq(_.map(a,function(a){return a.type}));if(1<e.length)throw c.error.data("You are trying to merge data of different types in the same axis or legend.");return b[e[0]](a)}}).call(this);(function(){var n,
s,l,d;c.tick={};c.tick.make=function(b,a,e){var h,k,m,n,p,r,f,g;p=null;h=function(a){return a};null!=a.ticks?r="num"===e?_.filter(a.ticks,function(a){return a>=b.min&&a<=b.max}):a.ticks:(h=null!=(r=a.numticks)?r:5,h=d[e](b,h),r=h.ticks,p=h.step);h=a.labels?function(b){var f;return null!=(f=a.labels[b])?f:b}:a.formatter?a.formatter:c.format(e.split("-")[0],p);p={};e=l(e,h);if(r)for(k=f=0,g=r.length-1;0<=g?f<=g:f>=g;k=0<=g?++f:--f)n=0===k?null:r[k-1],m=k===r.length-1?null:r[k+1],k=r[k],m=e(k,n,m),p[m.value]=
m;return{ticks:p,ticksFormatter:h}};n=function(){return function(b){this.location=b.location;this.value=b.value;this.index=b.index;this.evtData=b.evtData}}();l=function(b,a){var c;c=0;return function(d,k,m){var l;"cat"===b?l={"in":[d]}:(l={},null!=k&&(l.ge=k),null!=m&&(l.le=m));return new n({location:d,value:a(d),index:c++,evtData:l})}};s=function(b,a){var c,d;d=Math.pow(10,Math.floor(Math.log(b/a)/Math.LN10));c=a/b*d;0.15>c?d*=10:0.35>=c?d*=5:0.75>=c&&(d*=2);return d};d={none:function(){return{}},
cat:function(b,a){var c,d,k,m,l,p,r;k=Math.max(1,Math.round(b.levels.length/a));m=[];r=b.levels;c=l=0;for(p=r.length;l<p;c=++l)d=r[c],0===c%k&&m.push(d);return{ticks:m}},num:function(b,a){var c,d,k,m;k=b.min;d=b.max;if(c=b.bw){for(;(d-k)/c>1.4*a;)c*=2;m=k}else c=s(d-k,a),m=Math.ceil(k/c)*c;for(k=[];m<=d;)k.push(m),m+=c;return{ticks:k,step:Math.floor(Math.log(c)/Math.LN10)}},"num-log":function(b,a){var d,h,k,m,l,p,r,f,g;f=[];p=b.min;l=b.max;h=function(a){return Math.log(a)/Math.LN10};d=function(a){return Math.exp(a*
Math.LN10)};m=Math.max(h(p),0);k=h(l);r=s(k-m,a);for(g=Math.ceil(m/r)*r;g<k+c["const"].epsilon;){if(!(0!==g%1&&0.1>=g%1)){if(g%1>c["const"].epsilon){if(m=Math.floor(g)+h(10*(g%1)),0===m%1){g+=r;continue}}else m=g;m=d(m);m<p||m>l||f.push(m)}g+=r}return{ticks:f}},date:function(b,a){var d,h,k,m,l,p,r;m=b.min;k=b.max;if(d=b.bw)for(l=d;"decade"!==l&&(k-m)/c["const"].approxTimeInSeconds[l]>1.4*a;)l=c["const"].timerange[_.indexOf(c["const"].timerange,l)+1];else for(h in d=(k-m)/a,l="decade",r=c["const"].approxTimeInSeconds,
r)if(p=r[h],d<1.4*p){l=h;break}p=[];h=moment.unix(m).startOf(l);d=function(){switch(l){case "twomonth":return["months",2];case "quarter":return["months",4];case "sixmonth":return["months",6];case "twoyear":return["years",2];case "fiveyear":return["years",5];case "decade":return["years",10];default:return[l+"s",1]}}();for(h.unix()<m&&h.add(d[0],d[1]);h.unix()<=k;)p.push(h.unix()),h.add(d[0],d[1]);return{ticks:p,step:l}}}}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m,t=function(a,b){return function(){return a.apply(b,
arguments)}},p={}.hasOwnProperty,r=function(a,b){function c(){this.constructor=a}for(var d in b)p.call(b,d)&&(a[d]=b[d]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};a=c["const"].scaleFns;n=function(a){function b(){this.render=t(this.render,this);this.make=t(this.make,this);this.position="none";this.title=this.titletext=null}r(b,a);b.prototype.make=function(a){var b,f,g,c;b=a.guideSpec;g=a.title;f=a.position;this.size=a.size;this.color=a.color;a=function(a,f){var g;
return null!=(g=b[a])?g:f};this.titletext=a("title",g);this.position=null!=(c=a("position",f))?c:this.defaultPosition;if("out"===this.position)return this.position="bottom"};b.prototype.render=function(a,b,f){if("none"!==this.position)return null!=this.title&&a.remove(this.title),this.title=a.add(this._makeTitle(b,f),null,null,"guide-"+this.titleType);if(null!=this.title)return a.remove(this.title)};b.prototype.dispose=function(a){a.remove(this.title);return this.title=null};b.prototype._makeTitle=
function(){throw c.error.impl();};b.prototype.getDimension=function(){var a;a={};"none"!==this.position&&(a[this.position]=10);return a};return b}(c.Guide);l=function(b){function g(){return e=g.__super__.constructor.apply(this,arguments)}r(g,b);g.prototype.defaultPosition="bottom";g.prototype.titleType="titleH";g.prototype._makeTitle=function(b,f){var g,c,d,e,h;g="top"===this.position?b.paddingTop+b.guideTop-(null!=(c=f.top)?c:0)-2:b.height-b.paddingBottom-b.guideBottom+(null!=(d=f.bottom)?d:0);return{type:"text",
x:a.identity(b.paddingLeft+b.guideLeft+(b.width-b.paddingLeft-b.guideLeft-b.paddingRight-b.guideRight)/2),y:a.identity(g),color:a.identity(null!=(e=this.color)?e:"black"),size:a.identity(null!=(h=this.size)?h:12),text:this.titletext,"text-anchor":"middle"}};return g}(n);b=function(b){function g(){return h=g.__super__.constructor.apply(this,arguments)}r(g,b);g.prototype.defaultPosition="left";g.prototype.titleType="titleV";g.prototype._makeTitle=function(b,f){var g,c,d,e,h;g="left"===this.position?
b.paddingLeft+b.guideLeft-(null!=(c=f.left)?c:0)-7:b.width-b.paddingRight-b.guideRight+(null!=(d=f.right)?d:0);c=b.paddingTop+b.guideTop+(b.height-b.paddingTop-b.guideTop-b.paddingBottom-b.guideBottom)/2;return{type:"text",x:a.identity(g),y:a.identity(c),color:a.identity(null!=(e=this.color)?e:"black"),size:a.identity(null!=(h=this.size)?h:12),text:this.titletext,"text-anchor":"middle",transform:"r270"}};return g}(n);d=function(b){function g(){return k=g.__super__.constructor.apply(this,arguments)}
r(g,b);g.prototype.titleType="title";g.prototype._makeTitle=function(b,f){var g,c;return{type:"text",x:a.identity(b.width/2),y:a.identity(20),color:a.identity(null!=(g=this.color)?g:"black"),size:a.identity(null!=(c=this.size)?c:12),text:this.titletext,"font-size":"13px","font-weight":"bold","text-anchor":"middle"}};return g}(n);s=function(b){function g(){this.render=t(this.render,this);this.make=t(this.make,this);return m=g.__super__.constructor.apply(this,arguments)}r(g,b);g.prototype.make=function(a){var b;
b=a.title;this.size=a.size;this.color=a.color;return this.titletext=b};g.prototype.render=function(a,b,f){return null!=this.title?this.title=a.animate(this.title,this._makeTitle(b,f)):this.title=a.add(this._makeTitle(b,f),null,null,"guide-facet-title")};g.prototype._makeTitle=function(b,f){var g,c;return{type:"text",x:a.identity(f.x+b.eachWidth/2),y:a.identity(f.y-7),color:a.identity(null!=(g=this.color)?g:"black"),size:a.identity(null!=(c=this.size)?c:12),text:this.titletext,"text-anchor":"middle"}};
return g}(n);null==c.guide&&(c.guide={});c.guide.title=function(a){return"y"===a||"r"===a?new b:"main"===a?new d:"facet"===a?new s:new l}}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m,t,p={}.hasOwnProperty,r=function(a,b){function f(){this.constructor=a}for(var g in b)p.call(b,g)&&(a[g]=b[g]);f.prototype=b.prototype;a.prototype=new f;a.__super__=b.prototype;return a},f=function(a,b){return function(){return a.apply(b,arguments)}},g=[].indexOf||function(a){for(var b=0,f=this.length;b<f;b++)if(b in
this&&this[b]===a)return b;return-1};e=c["const"].scaleFns;n=function(a){function b(){this.axesGeoms={}}r(b,a);b.prototype.make=function(a){var b,f,g,d;this.domains=a.domains;this.coord=a.coord;this.scales=a.scales;this.specs=a.specs;this.labels=a.labels;return this.axes={x:c.guide.axis(this.coord.axisType("x"),{domain:this.domains.x,type:this.scales.x.tickType(),guideSpec:null!=(b=this.specs.x)?b:{},key:null!=(f=this.labels.x)?f:"x"}),y:c.guide.axis(this.coord.axisType("y"),{domain:this.domains.y,
type:this.scales.y.tickType(),guideSpec:null!=(g=this.specs.y)?g:{},key:null!=(d=this.labels.y)?d:"y"})}};b.prototype.getDimension=function(a){var b,f,g;a={};g=this.axes;for(f in g)b=g[f],b=b.getDimension(),"left"===b.position?a.left=b.width:"right"===b.position?a.right=b.width:"bottom"===b.position?a.bottom=b.height:"top"===b.position&&(a.top=b.height);return a};b.prototype.render=function(a,b,f){var g,d,e,q,u,h,k,I,m,r,l,p,n,t,s,K;h=_.keys(f.indices);e=c.compare(_.keys(this.axesGeoms),h).deleted;
u=0;for(r=e.length;u<r;u++)for(q in d=e[u],l=this.axesGeoms[d],l)d=l[q],d.dispose(b());e={top:0,left:0,right:a.eachWidth,bottom:a.eachHeight,width:a.eachWidth,height:a.eachHeight};q=f.edge(this.axes.x.position);u=f.edge(this.axes.y.position);r={renderLabel:!1,renderTick:!1};l={renderLabel:!1,renderTick:!1};"r"===this.axes.x.type&&(r.renderLine=!1);"r"===this.axes.y.type&&(l.renderLine=!1);n=0;for(t=h.length;n<t;n++)for(d=h[n],I=f.getOffset(a,d),null==(p=this.axesGeoms)[d]&&(p[d]={x:new c.Geometry("guide"),
y:new c.Geometry("guide")}),m=b(I,!1,!1),I=q(d)?{}:r,this.axesGeoms[d].x.set(this.axes.x.calculate(e,this.coord,I)),this.axesGeoms[d].x.render(m),I=u(d)?{}:l,this.axesGeoms[d].y.set(this.axes.y.calculate(e,this.coord,I)),this.axesGeoms[d].y.render(m),s=["x","y"],I=0,m=s.length;I<m;I++)for(k in g=s[I],K=this.axesGeoms[d][g].pts,K)g=K[k],g.grid&&g.grid.toBack()};b.prototype.dispose=function(a){var b,f,g;g=this.axesGeoms;for(f in g)b=g[f],b.x.dispose(a),b.y.dispose(a);return this.axesGeoms={}};return b}(c.GuideSet);
s=function(a){function b(a){this.calculate=f(this.calculate,this);var d,e,q,u,h;d=a.domain;u=a.type;e=a.guideSpec;a=a.key;q=function(a,b){var f;return null!=(f=e[a])?f:b};this.position=q("position",this.defaultPosition);if(h=this.position,0>g.call(this.validPositions,h))throw c.error.defn("X-axis position can't be "+this.position+".");this.titletext=q("title",a);this.renderTick=q("renderTick",this.renderTickDefault);this.renderGrid=q("renderGrid",this.renderGridDefault);this.renderLabel=q("renderLabel",
this.renderLabelDefault);this.renderLine=q("renderLine",this.renderLineDefault);this.gridColor=q("gridColor",this.gridColor);d=c.tick.make(d,e,u);this.ticks=d.ticks;this.ticksFormatter=d.ticksFormatter;this.maxwidth=_.max(_.map(this.ticks,function(a){return c.strSize(a.value)}));this.maxwidth=Math.max(this.maxwidth,0)}r(b,a);b.prototype.renderTickDefault=!0;b.prototype.renderGridDefault=!0;b.prototype.renderLabelDefault=!0;b.prototype.renderLineDefault=!0;b.prototype.calculate=function(a,b,f){var g,
c,d,e,q,u,h;this.coord=b;if("none"===this.position)return{};null==f&&(f={});a.centerx=a.left+a.width/2;a.centery=a.top+a.height/2;a.radius=Math.min(a.width,a.height)/2-10;b={};this.renderLine&&(b.line={marks:{0:this._renderline(a)}});e=this.ticks;for(g in e)d=e[g],c={},this.renderTick&&(null!=(q=f.renderTick)?q:1)&&(c.tick=this._makeTick(a,d)),this.renderLabel&&(null!=(u=f.renderLabel)?u:1)&&(c.text=this._makeLabel(a,d)),this.renderGrid&&(null!=(h=f.renderGrid)?h:1)&&(c.grid=this._makeGrid(a,d)),
b[g]={marks:c};return b};b.prototype._makeTick=function(a){if(!a)throw c.error.impl();a.type="path";a.stroke=e.identity("#666");a.color=e.identity("#666");return a};b.prototype._makeLabel=function(a){if(!a)throw c.error.impl();a.type="text";a.stroke=e.identity("#666");a.color=e.identity("#666");return a};b.prototype._makeGrid=function(a){if(!a)throw c.error.impl();a.stroke=null!=this.gridColor?this.gridColor:"#EFEFEF";return a};return b}(c.Guide);b=function(a){function b(){return h=b.__super__.constructor.apply(this,
arguments)}r(b,a);b.prototype.type="x";b.prototype.renderGridDefault=!1;b.prototype.defaultPosition="bottom";b.prototype.validPositions=["top","bottom","none"];b.prototype._renderline=function(a){var b,f;f="top"===this.position?e.identity(a.top):e.identity(a.bottom);b=e.identity(a.left);a=e.identity(a.left+a.width);return{type:"path",y:[f,f],x:[b,a],stroke:e.identity("#666")}};b.prototype._makeTick=function(a,f){var g,c;"top"===this.position?(g=e.identity(a.top),c=e.identity(a.top-5)):(g=e.identity(a.bottom),
c=e.identity(a.bottom+5));return b.__super__._makeTick.call(this,{x:[f.location,f.location],y:[g,c]})};b.prototype._makeLabel=function(a,f){var g;g="top"===this.position?e.identity(a.top-15):e.identity(a.bottom+15);return b.__super__._makeLabel.call(this,{x:f.location,y:g,text:f.value,"text-anchor":"middle"})};b.prototype._makeGrid=function(a,f){var g,c;g=e.identity(a.top);c=e.identity(a.bottom);return b.__super__._makeGrid.call(this,{type:"path",x:[f.location,f.location],y:[g,c]})};b.prototype.getDimension=
function(){var a;return{position:null!=(a=this.position)?a:"bottom",height:30,width:"all"}};return b}(s);a=function(a){function b(){return k=b.__super__.constructor.apply(this,arguments)}r(b,a);b.prototype.type="y";b.prototype.renderLineDefault=!1;b.prototype.renderTickDefault=!1;b.prototype.defaultPosition="left";b.prototype.validPositions=["left","right","none"];b.prototype._renderline=function(a){var b,f;b="left"===this.position?e.identity(a.left):e.identity(a.right);f=e.identity(a.top);a=e.identity(a.top+
a.height);return{type:"path",x:[b,b],y:[f,a],stroke:e.identity("#666")}};b.prototype._makeTick=function(a,f){var g,c;"left"===this.position?(g=e.identity(a.left),c=e.identity(a.left-5)):(g=e.identity(a.right),c=e.identity(a.right+5));return b.__super__._makeTick.call(this,{x:[g,c],y:[f.location,f.location]})};b.prototype._makeLabel=function(a,f){var g;g="left"===this.position?e.identity(a.left-7):e.identity(a.right+7);return b.__super__._makeLabel.call(this,{x:g,y:f.location,text:f.value,"text-anchor":"left"===
this.position?"end":"start"})};b.prototype._makeGrid=function(a,f){var g,c;g=e.identity(a.left);c=e.identity(a.right);return b.__super__._makeGrid.call(this,{type:"path",y:[f.location,f.location],x:[g,c]})};b.prototype.getDimension=function(){var a;return{position:null!=(a=this.position)?a:"right",height:"all",width:5+this.maxwidth}};return b}(s);l=function(a){function b(){return m=b.__super__.constructor.apply(this,arguments)}r(b,a);b.prototype.type="r";b.prototype.defaultPosition="left";b.prototype.validPositions=
["left","right","none"];b.prototype._renderline=function(a){var b,f;b=e.identity(a.left);f=e.identity(a.top);a=e.identity(a.top+a.height/2);return{type:"path",x:[b,b],y:[f,a],stroke:e.identity("#666")}};b.prototype._makeTick=function(a,f){return b.__super__._makeTick.call(this,{x:[e.identity(a.left),e.identity(a.left-5)],y:[f.location,f.location]})};b.prototype._makeLabel=function(a,f){return b.__super__._makeLabel.call(this,{x:e.identity(a.left-7),y:f.location,text:f.value,"text-anchor":"end"})};
b.prototype._makeGrid=function(a,f){return b.__super__._makeGrid.call(this,{type:"circle",x:e.identity(a.centerx),y:e.identity(a.centery),size:e.identity(this.coord.getScale("r")(f.location)),color:e.identity("none"),"fill-opacity":0,"stroke-width":1})};b.prototype.getDimension=function(){return{position:"left",height:"all",width:5+this.maxwidth}};return b}(s);d=function(a){function b(){return t=b.__super__.constructor.apply(this,arguments)}r(b,a);b.prototype.type="t";b.prototype.defaultPosition=
"out";b.prototype.validPositions=["out","none"];b.prototype._renderline=function(a){return{type:"circle",x:e.identity(a.centerx),y:e.identity(a.centery),size:e.identity(a.radius),color:e.identity("none"),stroke:e.identity("#666"),"stroke-width":1}};b.prototype._makeTick=function(a,f){return b.__super__._makeTick.call(this,{x:[f.location,f.location],y:[e.max(0),e.max(3)]})};b.prototype._makeLabel=function(a,f){return b.__super__._makeLabel.call(this,{x:f.location,y:e.max(12),text:f.value,"text-anchor":"middle"})};
b.prototype._makeGrid=function(a,f){var g,c,d,q;c=e.identity(a.centerx);q=e.identity(a.centery);g=this.coord.getScale("t")(f.location)-Math.PI/2;d=e.identity(a.centerx+a.radius*Math.cos(g));g=e.identity(a.centery+a.radius*Math.sin(g));return b.__super__._makeGrid.call(this,{type:"path",y:[q,g],x:[c,d]})};b.prototype.getDimension=function(){return{}};return b}(s);null==c.guide&&(c.guide={});c.guide.axis=function(f,g){if("x"===f)return new b(g);if("y"===f)return new a(g);if("r"===f)return new l(g);
if("t"===f)return new d(g)};c.guide.axes=function(a){return new n(a)}}).call(this);(function(){var n,s,l,d,b,a,e,h={}.hasOwnProperty,k=function(a,b){function f(){this.constructor=a}for(var g in b)h.call(b,g)&&(a[g]=b[g]);f.prototype=b.prototype;a.prototype=new f;a.__super__=b.prototype;return a},m=[].indexOf||function(a){for(var b=0,f=this.length;b<f;b++)if(b in this&&this[b]===a)return b;return-1},t=function(a,b){return function(){return a.apply(b,arguments)}};b=c["const"].scaleFns;c.guide.legends=
function(){return new l};c.guide.legend=function(a,b){return"left"===b||"right"===b?new d(a):new n(a)};l=function(a){function b(){this.legends=[];this.deletedLegends=[]}k(b,a);b.prototype.make=function(a){var b,d,e,h,k,m,l,p,r,B,n,x;e=a.domains;p=a.layers;h=a.guideSpec;n=a.scales;l=a.layerMapping;this.position=a.position;d=a.dims;null==this.postion&&(this.postion="right");if("none"!==this.position){b=this._mergeAes(e,p);for(m=0;m<this.legends.length;){r=this.legends[m];B=!0;for(k=0;k<b.length;){a=
b[k];if(_.isEqual(a,r.aes)){b.splice(k,1);B=!1;break}k++}B?(this.deletedLegends.push(r),this.legends.splice(m,1)):m++}r=0;for(k=b.length;r<k;r++)a=b[r],this.legends.push(c.guide.legend(a,this.position));m=this.legends;B=[];b=0;for(k=m.length;b<k;b++)r=m[b],a=r.aes[0],B.push(r.make({domain:e[a],position:this.position,guideSpec:null!=(x=h[a])?x:{},type:n[a].tickType(),mapping:l,keys:c.getLabel(p,a),dims:d}));return B}};b.prototype._mergeAes=function(a,b){var d,e,h,k,l,r,p;l=[];for(d in a)if(!(0<=m.call(c["const"].noLegend,
d)||(h=_.map(b,function(a){return a.mapping[d]}),_.all(h,_.isUndefined)))){k=!1;r=0;for(p=l.length;r<p;r++)if(e=l[r],_.isEqual(e.mapped,h)){e.aes.push(d);k=!0;break}k||l.push({aes:[d],mapped:h})}return _.pluck(l,"aes")};b.prototype.getDimension=function(a){var b,c,d;b={};if("left"===(c=this.position)||"right"===c)b[this.position]=this._leftrightWidth(a);else if("top"===(d=this.position)||"bottom"===d)b[this.position]=this._topbottomHeight(a);return b};b.prototype._leftrightWidth=function(a){var b,
c,d,e,h,k,m,l;e=a.chartHeight;h=0;b=10;c=0;l=this.legends;k=0;for(m=l.length;k<m;k++)d=l[k],d=d.getDimension(a),d.height+c>e&&(b+=h+5,h=c=0),d.width>h&&(h=d.width),c+=d.height;return b+h};b.prototype._topbottomHeight=function(a){var b,c,d,e,h;c=10;h=this.legends;d=0;for(e=h.length;d<e;d++)b=h[d],b=b.getDimension(a),c+=b.height+10;return c};b.prototype.render=function(a,b,c){var d,e,h,k,m;e=b();m=this.deletedLegends;h=0;for(k=m.length;h<k;h++)d=m[h],d.dispose(e);this.deletedLegends=[];if("left"===
this.position||"right"===this.position)return this._renderV(a,b,c);if("top"===this.position||"bottom"===this.position)return this._renderH(a,b,c)};b.prototype._renderV=function(a,b,c){var d,e,h,k,m,l,r,p,n,x,H,I,P;d=a.paddingTop+a.guideTop;e="left"===this.position?a.paddingLeft:a.width-a.guideRight-a.paddingRight;m=0;k=a.height-a.guideTop-a.paddingTop;p=10;r="right"===this.position?c.right:0;I=this.legends;P=[];x=0;for(H=I.length;x<H;x++)h=I[x],l=h.getDimension(a),l.height+c.y>k&&(r+=m+5,m=p=0),l.width>
m&&(m=l.width),n={x:r+e,y:p+d},h.render(b(n,!1,!1),m),P.push(p+=l.height);return P};b.prototype._renderH=function(a,b,c){var d,e,h,k,m,l;d=a.paddingLeft;e="top"===this.position?a.paddingTop:a.height-a.guideBottom-a.paddingBottom;e={x:d,y:"top"===this.position?c.top+e:c.bottom+e+10};m=this.legends;l=[];h=0;for(k=m.length;h<k;h++)c=m[h],d=c.getDimension(a),c.render(b(e,!1,!1)),l.push(e.y+=d.height+10);return l};b.prototype.dispose=function(a){var b,c,d,e,h;e=this.legends;h=[];c=0;for(d=e.length;c<d;c++)b=
e[c],h.push(b.dispose(a));return h};return b}(c.GuideSet);s=function(a){function d(a){this.aes=a;this._makeEvtData=t(this._makeEvtData,this);this._makeTick=t(this._makeTick,this);this.geometry=new c.Geometry("guide")}k(d,a);d.prototype.TITLEHEIGHT=15;d.prototype.TICKHEIGHT=12;d.prototype.SPACING=10;d.prototype.make=function(a){var b,d,e,h,k;b=a.domain;e=a.type;d=a.guideSpec;this.mapping=a.mapping;this.position=a.position;a=a.keys;this.titletext=null!=(h=d.title)?h:a;return k=c.tick.make(b,d,e),this.ticks=
k.ticks,k};d.prototype.calculate=function(){var a,b,c,d,e;b={};b.title={marks:{0:this._makeTitle(this.titletext)},evtData:{aes:this.aes[0],value:"legendTitle"}};e=this.ticks;for(c in e)a=e[c],d={},d.tick=this._makeTick(a),d.text=this._makeLabel(a),a=this._makeEvtData(a),b[c]={marks:d,evtData:a};return b};d.prototype.render=function(a){this.geometry.set(this.calculate());return this.geometry.render(a)};d.prototype.dispose=function(a){return this.geometry.dispose(a)};d.prototype._makeTitle=function(a,
c){null==c&&(c={x:0,y:0});return{type:"text",x:b.identity(c.x+5),y:b.identity(c.y),color:b.identity("black"),text:a,"text-anchor":"start"}};d.prototype._makeLabel=function(a,c){c||(c={x:0,y:15+12*a.index});return{type:"text",x:b.identity(c.x+20),y:b.identity(c.y+1),color:b.identity("black"),text:a.value,"text-anchor":"start"}};d.prototype._makeTick=function(a,g){var d,e,h,k;g||(g={x:0,y:15+12*a.index});e={type:"circle",x:b.identity(g.x+10),y:b.identity(g.y),color:b.identity("steelblue")};k=this.mapping;
for(d in k)h=k[d],0<=m.call(c["const"].noLegend,d)||(h=h[0],0<=m.call(this.aes,d)?e[d]=a.location:null!=h.type&&"const"===h.type?e[d]=b.identity(h.value):_.isObject(h)?e[d]=b.identity(c["const"].defaults[d]):e[d]=b.identity(h));_.isObject(e.size)&&(e.size=b.identity(5));return e};d.prototype._makeEvtData=function(a){var b,c,d,e,h,k,l;c={};l=this.mapping;for(b in l)for(e=l[b],h=0,k=e.length;h<k;h++)d=e[h],0<=m.call(this.aes,b)&&"map"===d.type&&(c[d.value]=_.extend(a.evtData,{value:a.location,aes:b}));
return c};return d}(c.Guide);d=function(b){function d(){return a=d.__super__.constructor.apply(this,arguments)}k(d,b);d.prototype.make=function(a){var b;d.__super__.make.call(this,a);this.height=this.TITLEHEIGHT+this.SPACING+this.TICKHEIGHT*_.size(this.ticks);b=c.strSize(this.titletext);a=_.max(_.map(this.ticks,function(a){return c.strSize(a.value)}));return this.maxwidth=Math.max(b,a)};d.prototype.getDimension=function(){return{position:this.position,height:this.height,width:15+this.maxwidth}};return d}(s);
n=function(a){function b(){return e=b.__super__.constructor.apply(this,arguments)}k(b,a);b.prototype.TICKSPACING=25;b.prototype.make=function(a){var g,d,e,h;b.__super__.make.call(this,a);this.maxwidth=a.dims.width;this.height=this.TITLEHEIGHT+this.SPACING;a=0;this.height+=this.TICKHEIGHT;h=this.ticks;d=0;for(e=h.length;d<e;d++)g=h[d],g=c.strSize(g.value)+this.TICKSPACING,a+g<this.maxwidth?a+=g:(this.height+=this.TICKHEIGHT,a=g);return null};b.prototype.calculate=function(){var a,b,d,e,h,k,m;b={};
b.title={marks:{0:this._makeTitle(this.titletext)}};h={x:0,y:this.TITLEHEIGHT};m=this.ticks;for(d in m)k=m[d],e={},e.tick=this._makeTick(k,h),e.text=this._makeLabel(k,h),a=this._makeEvtData(k,h),b[d]={marks:e,evtData:a},a=c.strSize(k.value)+this.TICKSPACING,h.x+a<this.maxwidth?h.x+=a:(h.x=0,h.y+=this.TICKHEIGHT);return b};b.prototype.getDimension=function(){return{position:this.position,height:this.height,width:"all"}};return b}(s)}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m,t,p,r,f,g,q,u,v=
function(a,b){return function(){return a.apply(b,arguments)}},D={}.hasOwnProperty,C=function(a,b){function c(){this.constructor=a}for(var f in b)D.call(b,f)&&(a[f]=b[f]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};m=function(){function a(b){this.f=null}a.prototype.make=function(a){this.domain=a;this.compare=c.domain.compare(a);if(!a)return this._makeNone();switch(a.type){case "num":return this._makeNum();case "date":return this._makeDate();case "cat":return this._makeCat()}};
a.prototype._makeNone=function(){throw c.error.impl("You are using a scale that does not support null values");};a.prototype._makeNum=function(){throw c.error.impl("You are using a scale that does not support numbers");};a.prototype._makeDate=function(){throw c.error.impl("You are using a scale that does not support dates");};a.prototype._makeCat=function(){throw c.error.impl("You are using a scale that does not support categories");};a.prototype.tickType=function(){if(!this.domain)return this._tickNone();
switch(this.domain.type){case "num":return this._tickNum();case "date":return this._tickDate();case "cat":return this._tickCat()}};a.prototype._tickNone=function(){return"none"};a.prototype._tickNum=function(){return"num"};a.prototype._tickDate=function(){return"date"};a.prototype._tickCat=function(){return"cat"};a.prototype._identityWrapper=function(a){return function(b){return _.isObject(b)&&"scalefn"===b.t&&"identity"===b.f?b.v:a(b)}};return a}();n=function(a){function b(a){this._catWrapper=v(this._catWrapper,
this);this._dateWrapper=v(this._dateWrapper,this);this._numWrapper=v(this._numWrapper,this);this.finv=this.f=null}C(b,a);b.prototype.make=function(a,c,f){this.range=c;this.space=f;_.isNumber(this.space)||(this.space=0.05);return b.__super__.make.call(this,a)};b.prototype._makeNone=function(){var a,b=this;a=(this.range.max-this.range.min)*this.space;this.f=this._NaNCheckWrap(function(c){var f;if(_.isObject(c))switch(f=function(b){return(this.range.max-this.range.min-2*a)/b},c.f){case "identity":return c.v;
case "middle":return b.range.max/2+b.range.min/2;case "max":return b.range.max;case "min":return b.range.min;case "novalue":return b.range.max/2+b.range.min/2;case "upper":return c.m?b.range.min+a+(c.n+1)*f(c.m):b.range.max-a;case "lower":return c.m?b.range.min+a+c.n*f(c.m):b.range.min+a}else return b.range.max/2+b.range.min/2});return this.finv=function(){return{}}};b.prototype._NaNCheckWrap=function(a){return function(b){if(c.isDefined(b)){b=a(b);if(isNaN(b)||Infinity===b||-Infinity===b)throw c.error.scale("Scale outputed a value that is not finite.");
return b}}};b.prototype._numWrapper=function(a,b){var f=this;return this._NaNCheckWrap(function(g){var d,e,q;if(_.isObject(g)){if("scalefn"===g.t)switch(g.f){case "identity":return g.v;case "middle":return b(g.v+a.bw/2);case "max":return f.range.max+g.v;case "min":return f.range.min+g.v;case "upper":case "lower":q=b(g.v+a.bw);d=b(g.v);e=(q-d)*f.space;if("upper"===g.f&&!g.m)return q-e;if("lower"===g.f&&!g.m)return d+e;q=(q-d-2*e)/g.m;if("upper"===g.f)return d+e+(g.n+1)*q;if("lower"===g.f)return d+
e+g.n*q}throw c.error.input("Unknown object "+g+" is passed to a scale");}return b(g)})};b.prototype._dateWrapper=function(a,b){var f=this;return this._NaNCheckWrap(function(g){var d,e,q,h;if(_.isObject(g)){if("scalefn"===g.t)switch(g.f){case "identity":return g.v;case "max":return f.range.max+g.v;case "min":return f.range.min+g.v;case "upper":case "middle":case "lower":h=function(a,b,c){var f;null==c&&(c=0);f=moment.unix(g.v).startOf(b);f[b](a*Math.floor(f[b]()/a)+a*c);return f.unix()};q=b(function(){switch(a.bw){case "week":return moment.unix(g.v).day(7).unix();
case "twomonth":return h(2,"month");case "quarter":return h(4,"month");case "sixmonth":return h(6,"month");case "twoyear":return h(2,"year");case "fiveyear":return h(5,"year");case "decade":return h(10,"year");default:return moment.unix(g.v).endOf(a.bw).unix()}}());d=b(function(){switch(a.bw){case "week":return moment.unix(g.v).day(0).unix();case "twomonth":return h(2,"month",1);case "quarter":return h(4,"month",1);case "sixmonth":return h(6,"month",1);case "twoyear":return h(2,"year",1);case "fiveyear":return h(5,
"year",1);case "decade":return h(10,"year",1);default:return moment.unix(g.v).startOf(a.bw).unix()}}());e=(q-d)*f.space;if("middle"===g.f)return q/2+d/2;if("upper"===g.f&&!g.m)return q-e;if("lower"===g.f&&!g.m)return d+e;q=(q-d-2*e)/g.m;if("upper"===g.f)return d+e+(g.n+1)*q;if("lower"===g.f)return d+e+g.n*q}throw c.error.input("Unknown object "+g+" is passed to a scale");}return b(g)})};b.prototype._catWrapper=function(a,b){var f=this;return this._NaNCheckWrap(function(g){var d,e,q;e=a*f.space;if(_.isObject(g)){if("scalefn"===
g.t)switch(g.f){case "identity":return g.v;case "max":return f.range.max+g.v;case "min":return f.range.min+g.v;case "upper":case "middle":case "lower":q=b(g.v)+a;d=b(g.v);if("middle"===g.f)return q/2+d/2;if("upper"===g.f&&!g.m)return q-e;if("lower"===g.f&&!g.m)return d+e;q=(q-d-2*e)/g.m;if("upper"===g.f)return d+e+(g.n+1)*q;if("lower"===g.f)return d+e+g.n*q}throw c.error.input("Unknown object "+g+" is passed to a scale");}return b(g)+a/2})};return b}(m);a=function(a){function b(){return t=b.__super__.constructor.apply(this,
arguments)}C(b,a);b.prototype._makeNum=function(){var a,b;b=c.linear(this.domain.min,this.range.min,this.domain.max,this.range.max);a=c.linear(this.range.min,this.domain.min,this.range.max,this.domain.max);this.f=this._numWrapper(this.domain,b);return this.finv=function(b,c){var f;f=[a(b),a(c)];return{ge:_.min(f),le:_.max(f)}}};b.prototype._makeDate=function(){var a,b;b=c.linear(this.domain.min,this.range.min,this.domain.max,this.range.max);a=c.linear(this.range.min,this.domain.min,this.range.max,
this.domain.max);this.f=this._dateWrapper(this.domain,b);return this.finv=function(b,c){var f;f=[a(b),a(c)];return{ge:_.min(f),le:_.max(f)}}};b.prototype._makeCat=function(){var a,b=this;a=(this.range.max-this.range.min)/this.domain.levels.length;this.f=this._catWrapper(a,function(c){c=_.indexOf(b.domain.levels,c);return-1===c?null:b.range.min+c*a});return this.finv=function(c,f){var g;f<c&&(g=[f,c],c=g[0],f=g[1]);return{"in":b.domain.levels.slice(Math.floor(c/a),+Math.floor(f/a)+1||9E9)}}};return b}(n);
e=function(a){function b(){return p=b.__super__.constructor.apply(this,arguments)}C(b,a);b.prototype._makeNum=function(){var a,b,f,g;if(0>this.domain.min)throw c.error.input("Log scale cannot handle zero or negative input.");a=Math.log;f=c.linear(a(this.domain.min),this.range.min,a(this.domain.max),this.range.max);this.f=this._numWrapper(this.domain,function(b){return f(a(b))});g=c.linear(this.range.min,a(this.domain.min),this.range.max,a(this.domain.max));b=function(a){return Math.exp(g(a))};return this.finv=
function(a,c){var f;f=[b(a),b(c)];return{ge:_.min(f),le:_.max(f)}}};b.prototype._tickNum=function(){return"num-log"};return b}(n);n=function(a){function b(){this._makeDate=v(this._makeDate,this);this._makeNum=v(this._makeNum,this);return r=b.__super__.constructor.apply(this,arguments)}C(b,a);b.prototype._makeNum=function(){var a,b,f;a=0===this.domain.min?0:1;b=Math.sqrt;f=c.linear(b(this.domain.min),a,b(this.domain.max),10);return this.f=this._identityWrapper(function(a){return f(b(a))})};b.prototype._makeDate=
function(){return this._makeNum()};return b}(m);h=function(a){function b(){this._makeDate=v(this._makeDate,this);this._makeNum=v(this._makeNum,this);return f=b.__super__.constructor.apply(this,arguments)}C(b,a);b.prototype._makeNum=function(){return this.f=this._identityWrapper(c.linear(this.domain.min,0===this.domain.min?0:0.1,this.domain.max,1))};b.prototype._makeDate=function(){return this._makeNum()};return b}(m);k=function(a){function b(){this._makeCat=v(this._makeCat,this);return g=b.__super__.constructor.apply(this,
arguments)}C(b,a);b.prototype._makeCat=function(){var a,b,c,f=this;c=this.domain.levels.length;if(9>=c)return a="#E41A1C #377EB8 #4DAF4A #984EA3 #FF7F00 #FFFF33 #A65628 #F781BF #999999".split(" "),this.f=function(b){b=_.indexOf(f.domain.levels,b);return a[b]};b=function(a){return _.indexOf(f.domain.levels,a)/c+1/(2*c)};return this.f=function(a){return"undefined"!==typeof Raphael&&null!==Raphael?Raphael.hsl(b(a),0.5,0.5):"hsl("+b(a)+",0.5,0.5)"}};return b}(m);l=function(a){function b(a){this._makeDate=
v(this._makeDate,this);this._makeNum=v(this._makeNum,this);this.lower=a.lower;this.upper=a.upper}C(b,a);b.prototype._makeNum=function(){var a,b,f,g,d;f="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.lower):this.lower;d="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.upper):this.upper;g=c.linear(this.domain.min,f.r,this.domain.max,d.r);b=c.linear(this.domain.min,f.g,this.domain.max,d.g);a=c.linear(this.domain.min,f.b,this.domain.max,d.b);return this.f=this._identityWrapper(function(c){return"undefined"!==
typeof Raphael&&null!==Raphael?Raphael.rgb(g(c),b(c),a(c)):"rgb("+g(c)+","+b(c)+","+a(c)+")"})};b.prototype._makeDate=function(){return this._makeNum()};return b}(m);d=function(a){function b(a){this._makeDate=v(this._makeDate,this);this._makeCat=v(this._makeCat,this);this._makeNum=v(this._makeNum,this);this.lower=a.lower;this.middle=a.middle;this.upper=a.upper;this.midpoint=a.midpoint;null==this.midpoint&&(this.midpoint=0)}C(b,a);b.prototype._makeNum=function(){var a,b,f,g,d,e,q,h,k,m=this;d="undefined"!==
typeof Raphael&&null!==Raphael?Raphael.color(this.lower):this.lower;e="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.middle):this.middle;k="undefined"!==typeof Raphael&&null!==Raphael?Raphael.color(this.upper):this.upper;q=c.linear(this.domain.min,d.r,this.midpoint,e.r);f=c.linear(this.domain.min,d.g,this.midpoint,e.g);a=c.linear(this.domain.min,d.b,this.midpoint,e.b);h=c.linear(this.midpoint,e.r,this.domain.max,k.r);g=c.linear(this.midpoint,e.g,this.domain.max,k.g);b=c.linear(this.midpoint,
e.b,this.domain.max,k.b);return this.f=this._identityWrapper(function(c){return c<m.midpoint?"undefined"!==typeof Raphael&&null!==Raphael?Raphael.rgb(q(c),f(c),a(c)):"rgb("+q(c)+","+f(c)+","+a(c)+")":"undefined"!==typeof Raphael&&null!==Raphael?Raphael.rgb(h(c),g(c),b(c)):"rgb("+h(c)+","+g(c)+","+b(c)+")"})};b.prototype._makeCat=function(){};b.prototype._makeDate=function(){return this._makeNum()};return b}(m);s=function(a){function b(a){this["function"]=a["function"]}C(b,a);b.prototype.make=function(a){this.domain=
a;this.compare=c.domain.compare(a);return this.f=this._identityWrapper(this["function"])};return b}(m);(function(a){function b(){return q=b.__super__.constructor.apply(this,arguments)}C(b,a);b.prototype._makeCat=function(){};return b})(m);b=function(a){function b(){return u=b.__super__.constructor.apply(this,arguments)}C(b,a);b.prototype.make=function(a){this.domain=a;this.compare=function(a,b){return 0};return this.f=this._identityWrapper(function(a){return a})};return b}(m);c.scale={};c.scale.Base=
m;c.scale.classes={linear:a,log:e,area:n,palette:k,gradient:l,gradient2:d,identity:b,opacity:h,custom:s};c.scale.make=function(a){if(a.type in c.scale.classes)return new c.scale.classes[a.type](a);throw c.error.defn("No such scale "+a.type+".");}}).call(this);(function(){var n,s=[].indexOf||function(c){for(var d=0,b=this.length;d<b;d++)if(d in this&&this[d]===c)return d;return-1};c.scaleset=function(c,d,b){return new n(c,d,b)};n=function(){function l(d,b){this.coord=b;this.ranges=d;this.axes=c.guide.axes();
this.legends=c.guide.legends()}l.prototype.make=function(c,b,a){this.guideSpec=c;this.layers=a;this.domains=b;this.scales=this._makeScales(c,b,this.ranges);this.reverse={x:this.scales.x.finv,y:this.scales.y.finv};return this.layerMapping=this._mapLayers(a)};l.prototype.setRanges=function(c){var b,a,e,h;this.ranges=c;e=["x","y"];h=[];b=0;for(a=e.length;b<a;b++)c=e[b],h.push(this.scales[c].make(this.domains[c],this.ranges[c],this.getSpec(c).padding));return h};l.prototype._makeScales=function(d,b,a){var e,
h,k,m,l,p,n,f;h=function(a){var b,f;if(d&&null!=d[a]&&null!=d[a].scale){if(_.isFunction(d[a].scale))return{type:"custom","function":d[a].scale};b=function(){switch(a){case "x":return["linear","log"];case "y":return["linear","log"];case "color":return["palette","gradient","gradient2"];case "size":return["linear","log"];case "opacity":return["opacity"];case "shape":return["linear","log","area"];case "id":return["identity"];case "text":return["identity"];default:return[]}}();if(f=d[a].scale.type,0<=
s.call(b,f))return d[a].scale;throw c.error.scale("Aesthetic "+a+" cannot have scale "+d[a].scale.type);}return null};e={};e.x=c.scale.make(null!=(k=h("x"))?k:{type:"linear"});e.x.make(b.x,a.x,this.getSpec("x").padding);e.y=c.scale.make(null!=(m=h("y"))?m:{type:"linear"});e.y.make(b.y,a.y,this.getSpec("y").padding);null!=b.color&&("cat"===b.color.type?e.color=c.scale.make(null!=(l=h("color"))?l:{type:"palette"}):(a={type:"gradient",upper:"steelblue",lower:"red"},e.color=c.scale.make(null!=(p=h("color"))?
p:a)),e.color.make(b.color));null!=b.size&&(e.size=c.scale.make(null!=(n=h("size"))?n:{type:"area"}),e.size.make(b.size));null!=b.opacity&&(e.opacity=c.scale.make(null!=(f=h("opacity"))?f:{type:"opacity"}),e.opacity.make(b.opacity));e.text=c.scale.make({type:"identity"});e.text.make();return e};l.prototype.fromPixels=function(c,b){var a,e,h,k,m,l,p;null!=c&&null!=b&&(a=this.coord.getAes(c,b,this.reverse),h=a.x,k=a.y);e={};p=this.layerMapping.x;m=0;for(l=p.length;m<l;m++)a=p[m],null!=a.type&&"map"===
a.type&&(e[a.value]=null!=h?h:null);l=this.layerMapping.y;h=0;for(m=l.length;h<m;h++)a=l[h],null!=a.type&&"map"===a.type&&(e[a.value]=null!=k?k:null);return e};l.prototype.getSpec=function(c){return null!=this.guideSpec&&null!=this.guideSpec[c]?this.guideSpec[c]:{}};l.prototype.makeGuides=function(c,b){var a,e;this.makeAxes();this.makeTitles(null!=(a=c.title)?a:"");this.makeLegends(null!=(e=c.legendPosition)?e:"right",b);return{axes:this.axes,legends:this.legends,title:this.title}};l.prototype.renderGuides=
function(c,b,a){this.axes.render(c,b,a);this.renderTitles(c,b);return this.renderLegends(c,b)};l.prototype.disposeGuides=function(c){this.axes.dispose(c);this.legends.dispose(c);this.titles.x.dispose(c);this.titles.y.dispose(c);this.titles.main.dispose(c);return this.titles={}};l.prototype.makeTitles=function(d){null==this.titles&&(this.titles={x:c.guide.title(this.coord.axisType("x")),y:c.guide.title(this.coord.axisType("y")),main:c.guide.title("main")});this.titles.main.make({title:d,guideSpec:{},
position:"top"});this.titles.x.make({guideSpec:this.getSpec("x"),title:c.getLabel(this.layers,"x")});this.titles.y.make({guideSpec:this.getSpec("y"),title:c.getLabel(this.layers,"y")})};l.prototype.titleOffset=function(c){var b,a,e,h,k,m,l;c={};m=this.titles;for(a in m)for(b=m[a],e=b.getDimension(),l=["left","right","top"," bottom"],h=0,k=l.length;h<k;h++)b=l[h],e[b]&&(null==c[b]&&(c[b]=0),c[b]+=e[b]);return c};l.prototype.renderTitles=function(c,b){var a;b=b({},!1,!1);a=this.axesOffset(c);this.titles.x.render(b,
c,a);this.titles.y.render(b,c,a);this.titles.main.render(b,c,a)};l.prototype.makeAxes=function(){var d;return this.axes.make({domains:{x:this.domains.x,y:this.domains.y},coord:this.coord,scales:this.scales,specs:null!=(d=this.guideSpec)?d:{},labels:{x:c.getLabel(this.layers,"x"),y:c.getLabel(this.layers,"y")}})};l.prototype.axesOffset=function(c){return this.axes.getDimension(c)};l.prototype._mapLayers=function(d){var b,a,e,h,k;a={};k=c["const"].aes;e=0;for(h=k.length;e<h;e++)b=k[e],a[b]=_.map(d,
function(a){return null!=a.mapping[b]?{type:"map",value:a.mapping[b]}:null!=a.consts[b]?{type:"const",value:a.consts[b]}:a.defaults[b]});return a};l.prototype.makeLegends=function(c,b){null==c&&(c="right");return this.legends.make({domains:this.domains,layers:this.layers,guideSpec:this.guideSpec,scales:this.scales,layerMapping:this.layerMapping,position:c,dims:b})};l.prototype.legendOffset=function(c){return this.legends.getDimension(c)};l.prototype.renderLegends=function(c,b){var a,e,h,k,m,l,p,n,
f;h={left:0,right:0,top:0,bottom:0};a=this.axesOffset(c);k=this.titleOffset(c);p=["left","right","top","bottom"];m=0;for(l=p.length;m<l;m++)e=p[m],h[e]+=null!=(n=a[e])?n:0,h[e]+=null!=(f=k[e])?f:0;this.legends.render(c,b,h)};return l}()}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m={}.hasOwnProperty,t=function(a,b){function c(){this.constructor=a}for(var d in b)m.call(b,d)&&(a[d]=b[d]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a},p=[].indexOf||function(a){for(var b=
0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},r=function(a,b){return function(){return a.apply(b,arguments)}};c.data=function(a){var b,d;d=void 0;_.isObject(a)&&"data"in a&&(7>(b=_.keys(a).length)&&"meta"in a||5>b)?(b=a.data,d=a.meta):b=a;switch(h(b)){case "json-object":case "json-grid":case "json-array":return c.data.json(b,d,void 0);case "url":return c.data.url(b,d,void 0);case "csv":return c.data.csv(b,d);case "api":return c.data.api(b);default:throw c.error.data("Unknown data format.");
}};c.data.json=function(a,b,c){return new d({data:a,meta:b,type:c})};c.data.csv=function(a,b){return new d({data:a,meta:b,csv:"csv"})};c.data.url=function(a,b,c){return new l({url:a,computeBackend:b,limit:c})};c.data.api=function(a){return new s({apiFun:a})};h=function(a){if(_.isArray(a))return _.isArray(a[0])?"json-grid":"json-array";if(_.isObject(a))return"json-object";if(_.isString(a))return c.isURI(a)?"url":"csv";if(_.isFunction(a))return"api";throw c.error.data("Unknown data format.");};b=function(a,
b){var d,e,h,k,m,l,p;if(0<a.length){h=_.union(_.keys(b),_.keys(a[0]));d=a.slice(0,100);k=0;for(m=h.length;k<m;k++)e=h[k],null==b[e]&&(b[e]={}),b[e].type||(b[e].type=c.type.impute(_.pluck(d,e)));k=0;for(l=a.length;k<l;k++)for(d=a[k],m=0,p=h.length;m<p;m++)e=h[m],d[e]=c.type.coerce(d[e],b[e]);e=h;h=a}else e=_.keys(b),h=[];return{key:e,raw:h,meta:b}};a=function(a,b){var d,e,h,k,m,l,p,n,r,t,x;l=[];if(0<a.length){k=b&&_.isArray(b)?b:b&&_.isObject(b)?_.keys(b):_.keys(a[0]);if(_.isArray(b)||!_.isObject(b))b=
{};d=a.slice(0,100);e=m=0;for(p=k.length;m<p;e=++m)h=k[e],null==b[h]&&(b[h]={}),b[h].type||(b[h].type=c.type.impute(_.pluck(d,e)));n=0;for(t=a.length;n<t;n++){d=a[n];m={};e=r=0;for(x=d.length;r<x;e=++r)p=d[e],h=k[e],m[h]=c.type.coerce(p,b[h]);l.push(m)}h=k;e=l}else h=_.keys(b),e=[];return{key:h,raw:e,meta:b}};k=function(a,b){var d,e,h,k,m,l,p,n,r;h=_.keys(a);m=[];l=0;for(e=h.length;l<e;l++)d=h[l],null==b[d]&&(b[d]={}),b[d].type||(b[d].type=c.type.impute(a[d].slice(0,100)));if(0<h.length&&(e=a[h[0]].length,
0<e))for(d=l=0,r=e-1;0<=r?l<=r:l>=r;d=0<=r?++l:--l){k={};p=0;for(n=h.length;p<n;p++)e=h[p],k[e]=c.type.coerce(a[e][d],b[e]);m.push(k)}return{key:h,raw:m,meta:b}};e=function(a,g){return b(c.csv.parse(a),g)};n=function(){function a(){this.raw=null;this.meta={};this.key=[];this.subscribed=[];this.computeBackend=!1}a.prototype.isData=!0;a.prototype.update=function(){var a,b,c,f,d;f=this.subscribed;d=[];b=0;for(c=f.length;b<c;b++)a=f[b],d.push(a());return d};a.prototype.subscribe=function(a){if(-1===_.indexOf(this.subscribed,
a))return this.subscribed.push(a)};a.prototype.unsubscribe=function(a){return this.subscribed.splice(_.indexOf(this.subscribed,a),1)};a.prototype.keys=function(){return this.key};a.prototype.rename=function(){return!1};a.prototype.renameMany=function(){return!1};a.prototype.remove=function(){return!1};a.prototype.filter=function(){return!1};a.prototype.sort=function(){return!1};a.prototype.derive=function(){return!1};a.prototype.get=function(a){if(this.raw)return _.pluck(this.raw,a);throw c.error.data("Data has not been fetched or is undefined.");
};a.prototype.len=function(){if(this.raw)return this.raw.length;throw c.error.data("Data has not been fetched or is undefined.");};a.prototype.getObject=function(a){if(this.raw)return this.raw[a];throw c.error.data("Data has not been fetched or is undefined.");};a.prototype.max=function(a){return _.max(this.get(a))};a.prototype.min=function(a){return _.min(this.get(a))};a.prototype.getMeta=function(a){if(this.meta)return this.meta[a]};a.prototype.type=function(a){if(a in this.meta)return a=this.meta[a].type,
"num"===a?"number":a;throw c.error.defn("Data does not have column "+a+".");};return a}();d=function(f){function g(a){g.__super__.constructor.call(this);this._setData(a)}t(g,f);g.prototype.getData=function(a,b){if(null==b)a(null,this);else return c.data.frontendProcess(b,this,function(b,c){c.raw=c.data;return a(b,c)})};g.prototype.update=function(a){this._setData(a);return g.__super__.update.call(this)};g.prototype._setData=function(f){var g,d,m;_.isObject(f)&&4>_.keys(f).length&&"data"in f?(g=f.data,
d=null!=(m=f.meta)?m:{}):(g=f,d={});m=function(){var m;switch(null!=(m=f.type)?m:h(g)){case "json-object":return k(g,d);case "json-grid":return a(g,d);case "json-array":return b(g,d);case "csv":return e(g,d);default:throw c.error.data("Unknown data format.");}}();this.key=m.key;this.raw=m.raw;this.meta=m.meta;return this.data=this.raw};g.prototype._checkRename=function(a,b){if(""===b)throw c.error.defn("Column names cannot be an empty string");if(-1===_.indexOf(this.key,a))throw c.error.defn("The key "+
a+" doesn't exist!");if(-1!==_.indexOf(this.key,b))throw c.error.defn("The key "+b+" already exists!");};g.prototype.rename=function(a,b,c){var f,g,d;null==c&&(c=!1);a=a.toString();b=b.toString();if(a===b)return!0;c||this._checkRename(a,b);d=this.raw;f=0;for(g=d.length;f<g;f++)c=d[f],c[b]=c[a],delete c[a];c=_.indexOf(this.key,a);this.key[c]=b;this.meta[b]=this.meta[a];delete this.meta[a];return!0};g.prototype.renameMany=function(a){var b,c;for(b in a)c=a[b],b!==c&&this._checkRename(b,c);for(b in a)c=
a[b],b!==c&&this.rename(b,c,!0);return!0};g.prototype.remove=function(a){var b,c,f,g;b=_.indexOf(this.key,a);if("-1"===b)return!1;this.key.splice(b,1);delete this.meta[a];g=this.raw;c=0;for(f=g.length;c<f;c++)b=g[c],delete b[a];return!0};g.prototype.filter=function(a){var b,f,g,d,e;a=_.isFunction(a)?a:_.isString(a)?new Function("d","with(d) { return "+a+";}"):function(){return!0};f=[];e=this.raw;g=0;for(d=e.length;g<d;g++)b=e[g],a(b)&&f.push(b);return c.data.json(f,this.meta)};g.prototype.sort=function(a,
b){var f,g,d;d=this.type(a);f=_.clone(this.raw);g=c.type.compare(d);f.sort(function(b,c){return g(b[a],c[a])});b&&f.reverse();return c.data.json(f,this.meta)};g.prototype.derive=function(a,b,f){var g,d,e,h,k,m,l,n;null==f&&(f={});d=f.dryrun;g=f.context;null==b&&(b=_uniqueId("var_"));null==g&&(g={});_.isFunction(a)?(f=a,e=!1):(e=!0,f=new Function("d","with(this) { with(d) { return "+(a||'""')+";}}"));n=this.raw;m=0;for(l=n.length;m<l;m++){h=n[m];k=f.call(g,h);if(_.isFunction(k))throw c.error.defn("Derivation function returned another function.");
h[b]=k}if(d)return{success:!0,values:_.pluck(this.raw.slice(0,11),b)};0<=p.call(this.key,b)||this.key.push(b);this.meta[b]={type:c.type.impute(_.pluck(this.raw.slice(0,101),b)),derived:!0};e&&(this.meta[b].formula=a);return b};return g}(n);l=function(f){function g(a){this.getData=r(this.getData,this);g.__super__.constructor.call(this);this.url=a.url;this.computeBackend=a.computeBackend;this.limit=a.limit;null==this.computeBackend&&(this.computeBackend=!1)}t(g,f);g.prototype.getData=function(f,g){var d,
m,l=this;if(null==this.raw||this.computeBackend)return d=-1===_.indexOf(this.url,"?")?"?":"&",m=this.url,this.limit&&(m+=""+d+"limit="+this.limit),g&&(m+="&spec="+encodeURIComponent(JSON.stringify(g))),c.text(m,function(g){var d,m,p;try{g=JSON.parse(g)}catch(n){}_.isObject(g)&&4>_.keys(g).length&&"data"in g?(d=g.data,m=null!=(p=g.meta)?p:{}):(d=g,m={});g=function(){switch(h(d)){case "json-object":return k(d,m);case "json-grid":return a(d,m);case "json-array":return b(d,m);case "csv":return e(d,m);
default:throw c.error.data("Unknown data format.");}}();l.key=g.key;l.raw=g.raw;l.meta=g.meta;l.data=l.raw;return f(null,l)});if(null==g)return f(null,this);c.data.frontendProcess(g,this,function(a,b){b.raw=b.data;return f(a,b)})};g.prototype.update=function(a){this.raw=null;return g.__super__.update.call(this)};g.prototype.renameMany=function(a){return 0===_.keys(a).length};return g}(n);s=function(f){function g(a){this.getData=r(this.getData,this);g.__super__.constructor.call(this);this.apiFun=a.apiFun;
this.computeBackend=!0}t(g,f);g.prototype.getData=function(f,g){var d=this;return this.apiFun(g,function(g,m){var l,p,n,r,t;if(null!=g)return f(g,null);if(_.isString(m))try{m=JSON.parse(m)}catch(x){p=x}p=null;try{l=m.data,n=null!=(r=m.meta)?r:{},t=function(){switch(h(l)){case "json-object":return k(l,n);case "json-grid":return a(l,n);case "json-array":return b(l,n);case "csv":return e(l,n);default:throw c.error.data("Unknown data format.");}}(),d.key=t.key,d.raw=t.raw,d.meta=t.meta,d.data=d.raw}catch(H){p=
H}return f(p,d)})};g.prototype.update=function(a){this.raw=null;return g.__super__.update.call(this)};g.prototype.renameMany=function(a){return 0===_.keys(a).length};return g}(n)}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m,t,p=function(a,b){return function(){return a.apply(b,arguments)}},r=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};n=function(){function a(b,f,d,e){this.parseMethod=null!=e?e:c.spec.layerToData;this._wrap=p(this._wrap,
this);this.make=p(this.make,this);this.layerMeta=_.extend({},b.meta,{_additionalInfo:b.additionalInfo});this.dataObj=b.data;this.prevSpec=null;this.strictmode=d;this.statData=null;this.metaData={}}a.prototype.make=function(a,b,c){var f,d;d=this._wrap(c);this.strictmode&&d({data:this.dataObj.raw,meta:this.dataObj.meta});if(this.dataObj.computeBackend)return f=this.parseMethod(a,b),this.layerMeta&&(f.meta=this.layerMeta),s(f,this.dataObj,d);f=this.parseMethod(a,b);return this.dataObj.getData(function(a,
b){var c,g,e,h;if(null!=a)return d(a,null);if(0<=r.call(f.select,"count(*)")){h=b.data;g=0;for(e=h.length;g<e;g++)c=h[g],c["count(*)"]=1;b.meta["count(*)"]={};b.meta["count(*)"].type="num";f.stats.stats.push({key:"count(*)",name:"count(*)",stat:"count"})}return k(f,b,d)})};a.prototype._wrap=function(a){var b=this;return function(c,f){var d,e;if(null!=c)return a(c,null,null);d=f.data;e=f.meta;b.statData=d;b.metaData=e;return a(null,b.statData,b.metaData)}};return a}();c.DataProcess=n;c.data.process=
function(a,b,c,d){a=new n(b,c);a.process(d);return a};a={ident:function(a){return function(b){if(a in b)return b[a];throw c.error.defn("Referencing unknown column: "+a);}},"const":function(a){return function(){return a}},conditional:function(a,b,c){return function(d){return a(d)?b(d):c(d)}},infixop:{"+":function(a,b){return function(c){return a(c)+b(c)}},"-":function(a,b){return function(c){return a(c)-b(c)}},"*":function(a,b){return function(c){return a(c)*b(c)}},"/":function(a,b){return function(c){return a(c)/
b(c)}},"%":function(a,b){return function(c){return a(c)%b(c)}},">":function(a,b){return function(c){return a(c)>b(c)}},">=":function(a,b){return function(c){return a(c)>=b(c)}},"<":function(a,b){return function(c){return a(c)<b(c)}},"<=":function(a,b){return function(c){return a(c)<=b(c)}},"!=":function(a,b){return function(c){return a(c)!==b(c)}},"==":function(a,b){return function(c){return a(c)===b(c)}},"=":function(a,b){return function(c){return a(c)===b(c)}},"++":function(a,b){return function(c){return a(c)+
b(c)}}},trans:{substr:function(a){return function(b){var c,d;d=a[0](b).toString();c=a[1](b);b=a[2](b);return d.substr(c,b)}},length:function(a){return function(b){b=a[0](b).toString();return _.size(b)}},upper:function(a){return function(b){return a[0](b).toString().toUpperCase()}},lower:function(a){return function(b){return a[0](b).toString().toLowerCase()}},indexOf:function(a){return function(b){var c;c=a[0](b).toString();b=a[1](b).toString();return c.indexOf(b)}},parseNum:function(a){return function(b){return+a[0](b).toString()}},
parseDateDefault:function(a){return function(b){b=a[0](b);return moment(b).unix()}},parseDate:function(a){return function(b){var c;c=a[0](b);b=a[1](b);return moment(c,b).unix()}},year:function(a){return function(b){b=a[0](b);return moment.unix(b).year()}},month:function(a){return function(b){b=a[0](b);return moment.unix(b).month()+1}},dayOfMonth:function(a){return function(b){b=a[0](b);return moment.unix(b).date()}},dayOfYear:function(a){return function(b){b=a[0](b);return moment.unix(b).dayOfYear()}},
dayOfWeek:function(a){return function(b){b=a[0](b);return moment.unix(b).day()}},hour:function(a){return function(b){b=a[0](b);return moment.unix(b).hour()}},minute:function(a){return function(b){b=a[0](b);return moment.unix(b).minute()}},second:function(a){return function(b){b=a[0](b);return moment.unix(b).second()}},log:function(a){return function(b){return Math.log(a[0](b))}},lag:function(a){var b;b=[];return function(d){var e,h;h=a[0](d);d=a[1](d);e=_.size(b);if(0===e){var k;k=[];for(e=1;1<=d?
e<=d:e>=d;1<=d?++e:--e)k.push(void 0);b=k}else if(e!==d)throw c.error.defn("Lag period needs to be constant, but isn't!");b.push(h);return b.shift()}},bin:function(a){return function(b){var c,d;c=a[0](b);b=a[1](b);if(_.isNumber(b))return Math.floor(c/b)*b;d=function(a,b){var d;d=moment.unix(c).startOf(b);d[b](a*Math.floor(d[b]()/a));return d.unix()};switch(b){case "week":return moment.unix(c).day(0).unix();case "twomonth":return d(2,"month");case "quarter":return d(4,"month");case "sixmonth":return d(6,
"month");case "twoyear":return d(2,"year");case "fiveyear":return d(5,"year");case "decade":return d(10,"year");default:return moment.unix(c).startOf(b).unix()}}}}};b=function(d){var e,h,k,m,l,p,n;l=d[0];d=d[1];if("ident"===l)d=a.ident(d.name);else if("const"===l)d=(n=c.type.coerce(d.value,{type:d.type}),a["const"](n));else if("infixop"===l)d=(m=b(d.lhs),p=b(d.rhs),a.infixop[d.opname](m,p));else if("conditional"===l)d=(h=b(d.cond),k=b(d.conseq),e=b(d.altern),a.conditional(h,k,e));else if("call"===
l){m=d.args;p=[];h=0;for(k=m.length;h<k;h++)e=m[h],p.push(b(e));d=a.trans[d.fname](p)}else d=void 0;if(d)return d;throw c.error.defn("Unknown operation of type: "+l);};h={lt:function(a,b){return a<b},le:function(a,b){return a<=b},gt:function(a,b){return a>b},ge:function(a,b){return a>=b},"in":function(a,b){return 0<=r.call(b,a)}};e=function(a){var b;b=[];_.each(a,function(a){var d,f;d=c.parser.unbracket(a.expr.name);f=_.pick(a,"lt","gt","le","ge","in");return _.each(f,function(c,f){if(f in h)return a=
function(a){return h[f](a[d],c)},b.push(a)})});return function(a){var c,d,f;d=0;for(f=b.length;d<f;d++)if(c=b[d],!c(a))return!1;return!0}};t={sum:function(a){return _.reduce(_.without(a,void 0,null),function(a,b){return a+b},0)},mean:function(a){a=_.without(a,void 0,null);return _.reduce(a,function(a,b){return a+b},0)/a.length},count:function(a){return _.without(a,void 0,null).length},unique:function(a){return _.uniq(_.without(a,void 0,null)).length},min:function(a){return _.min(a)},max:function(a){return _.max(a)},
median:function(a){return c.median(a)},box:function(a){var b,d,e,h,k,m;d=a.length;return 5<d?(h=d/2,a=_.sortBy(a,function(a){return a}),b=Math.ceil(h)/2,0!==b%1?(b=Math.floor(b),h=a[b],d=a[d-1-b]):(h=(a[b]+a[b-1])/2,d=(a[d-b]+a[d-b-1])/2),b=d-h,e=h-1.5*b,k=d+1.5*b,b=_.groupBy(a,function(a){return a>=e&&a<=k}),{q1:_.min(b["true"]),q2:h,q3:c.median(a,!0),q4:d,q5:_.max(b["true"]),outliers:null!=(m=b["false"])?m:[]}):{outliers:a}}};d=function(a,b){var d,e,h;h={};_.each(b.stats,function(a){var b,d,f,e;
e=a.name;b=a.expr;a=a.args;d=t[e];f=c.parser.unbracket(a[0].name);return h[b.name]=function(a){return d(_.pluck(a,f))}});e=c.groupBy(a,function(){var a,f,e,h;e=b.groups;h=[];a=0;for(f=e.length;a<f;a++)d=e[a],h.push(c.parser.unbracket(d.name));return h}());return _.map(e,function(a){var d,e,f,k,m;e={};m=b.groups;f=0;for(k=m.length;f<k;f++)d=m[f].name,d=c.parser.unbracket(d),e[d]=a[0][d];for(d in h)f=h[d],e[d]=f(a);return e})};l=function(a,b){var e,h,k,m,l,p,n,r;k=a.key;p=a.sort;r=a.stat;e=a.args;m=
a.limit;h=a.asc;r&&(e={stats:[{name:r,expr:p,args:e}],groups:[k]},b=d(b,e));l=h?1:-1;n=c.parser.unbracket(p.name);b.sort(function(a,b){return a[n]===b[n]?0:a[n]>=b[n]?1*l:-1*l});m&&(b=b.slice(0,+(m-1)+1||9E9));h=_.uniq(_.pluck(b,c.parser.unbracket(k.name)));return{meta:{levels:h,sorted:!0},filter:{expr:k,"in":h}}};m=function(a){var b;b=c.parser.createColTypeEnv(a);return function(a){var d,e,f;d=a.expr;f=d[0];e=d[1];d=null;"call"===f&&"bin"===e.fname&&(e=e.args[1],f=e[0],e=e[1],"const"===f&&(d=c.type.coerce(e.value,
{type:e.type})));return{type:c.parser.getType(a.name,b),bw:d}}};k=function(a,g,h){var k,p,n,r,t,s,G,B,F,x,H;G=null!=(p=_.clone(g.meta))?p:{};t=m(G);p=function(a,b){var c;null==b&&(b={});return G[a.name]=_.extend(null!=(c=G[a.name])?c:{},t(a),b)};g=_.clone(g.raw);k=function(a,b){var c,d,e,f;f=[];d=0;for(e=g.length;d<e;d++)c=g[d],f.push(c[a]=b(c));return f};if(a.trans)for(H=a.trans,B=0,x=H.length;B<x;B++)n=H[B],k(n.name,b(n.expr)),p(n);a.filter&&(g=_.filter(g,e(a.filter)));if(a.sort){k=[];H=a.sort;
B=0;for(x=H.length;B<x;B++)s=H[B],n=s.key,r=l(s,g),s=r.meta,r=r.filter,k.push(r),p(n,s);g=_.filter(g,e(k))}if(a.stats&&a.stats.stats&&0<a.stats.stats.length)for(g=d(g,a.stats),x=a.stats.stats,k=0,B=x.length;k<B;k++)n=x[k],n=n.expr,p(n);a=null!=(F=a.select)?F:[];F=0;for(p=a.length;F<p;F++)if(n=a[F],n=c.parser.unbracket(n.name),null==G[n]&&"count(*)"!==n)throw c.error.defn("You referenced a data column "+n+" that doesn't exist.");return h(null,{data:g,meta:G})};s=function(a,b,c){return b.getData(c,
a)};c.data.frontendProcess=k;c.data.createFunction=b}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m,t,p,r,f,g,q,u,v,D,C,z,J,G=[].indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1},B={}.hasOwnProperty,F=function(a,b){function c(){this.constructor=a}for(var d in b)B.call(b,d)&&(a[d]=b[d]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};t=c["const"].aes;r=c["const"].scaleFns;p={x:r.novalue(),y:r.novalue(),color:"steelblue",
size:5,opacity:0.9,shape:1};d=function(){function a(b,d,e){var f;this.spec=b;this.guideSpec=e;this.mapping={};this.consts={};e=0;for(f=t.length;e<f;e++)d=t[e],b[d]&&(b[d]["var"]&&(this.mapping[d]=c.parser.unbracket(b[d]["var"])),b[d]["const"]&&(this.consts[d]=b[d]["const"]))}a.prototype.defaults=p;a.prototype.calculate=function(a,b){var c,d,e;this.statData=a;this.meta=b;this._calcGeoms();this.geoms=this._sample(this.geoms);b={};e=this.mapping;for(c in e)d=e[c],b[c]=this.meta[d];return{geoms:this.geoms,
meta:b}};a.prototype._calcGeoms=function(){throw c.error.impl();};a.prototype._tooltip=function(a){var b=this;return"function"===typeof this.spec.tooltip?function(c){return b.spec.tooltip(a)}:null!=this.spec.tooltip?function(a){return b.spec.tooltip}:function(d){var e,f,g,h,k,m;k="";h=[];m=b.mapping;for(e in m)g=m[e],-1===h.indexOf(g)&&(h.push(g),f=null!=d&&null!=d[e]?c.format(d[e].domain.type,d[e].domain.bw):function(a){return a},k+="\n"+g+": "+f(a[g]));return k.substr(1)}};a.prototype._sample=function(a){if(!1===
this.spec.sample)return a;if(_.isNumber(this.spec.sample))return c.sample(a,this.spec.sample);throw c.error.defn("A layer's 'sample' definition should be an integer, not "+this.spec.sample);};a.prototype._getValue=function(a,b){return this.mapping[b]?a[this.mapping[b]]:this.consts[b]?r.identity(this.consts[b]):"x"===b||"y"===b?this.defaults[b]:r.identity(this.defaults[b])};a.prototype._getIdFunc=function(){var a=this;return null!=this.mapping.id?function(b){return a._getValue(b,"id")}:c.counter()};
a.prototype._fillZeros=function(a,b){var c,d,e;c=function(){var b,c,e;e=[];b=0;for(c=a.length;b<c;b++)d=a[b],e.push(this._getValue(d,"x"));return e}.call(this);e=_.difference(b,c);return{x:c.concat(e),y:function(){var b,c,e;e=[];b=0;for(c=a.length;b<c;b++)d=a[b],e.push(this._getValue(d,"y"));return e}.call(this).concat(function(){var a,b,c;c=[];a=0;for(b=e.length;a<b;a++)c.push(void 0);return c}())}};a.prototype._stack=function(a){var b,d,e,f,g,h,k=this;a=c.groupBy(this.statData,a);h=[];for(e in a)b=
a[e],f=0,g=null!=this.mapping.y?function(a){return a[k.mapping.y]}:function(a){return 0},h.push(function(){var a,c,e;e=[];a=0;for(c=b.length;a<c;a++)d=b[a],d.$lower=f,f+=parseFloat(g(d)),e.push(d.$upper=f);return e}());return h};a.prototype._dodge=function(a){var b,d,e,f,g,h,k,m,l,n,p,q,r=this;e=_.without(_.keys(this.mapping),"x","y","id");_.toArray(_.pick(this.mapping,e));p=c.groupBy(this.statData,a);q=[];for(g in p){d=p[g];k={};h=1;l=0;for(n=e.length;l<n;l++)b=e[l],a=_.uniq(function(){var a,c,e;
e=[];a=0;for(c=d.length;a<c;a++)f=d[a],e.push(this._getValue(f,b));return e}.call(this)),h*=a.length,a.sort(c.type.compare(this.meta[this.mapping[b]].type)),k[b]=a;m=function(a){var c,d,f,g;c=h;f=d=0;for(g=e.length;f<g;f++)b=e[f],c/=k[b].length,d+=c*_.indexOf(k[b],r._getValue(a,b));return d};q.push(function(){var a,b,c;c=[];a=0;for(b=d.length;a<b;a++)f=d[a],f.$n=m(f),c.push(f.$m=h);return c}())}return q};a.prototype._inLevels=function(a){var b,c,d,e,f,g;e=["x","y"];c=0;for(d=e.length;c<d;c++)if(b=
e[c],null!=(null!=(f=this.guideSpec[b])?f.levels:void 0)&&(g=a[this.spec[b]["var"]],0>G.call(this.guideSpec[b].levels,g)))return!1;return!0};return a}();e=function(a){function b(){return f=b.__super__.constructor.apply(this,arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,b,c,d,e,f,g,h,k;b=this._getIdFunc();this.geoms={};h=this.statData;k=[];f=0;for(g=h.length;f<g;f++){c=h[f];a={};for(d in c)e=c[d],a[d]={"in":[e]};k.push(this.geoms[b(c)]={marks:{0:{type:"circle",x:this._getValue(c,"x"),y:this._getValue(c,
"y"),color:this._getValue(c,"color"),size:this._getValue(c,"size"),opacity:this._inLevels(c)?this._getValue(c,"opacity"):0}},evtData:a,tooltip:this._tooltip(c)})}return k};return b}(d);a=function(a){function b(){return g=b.__super__.constructor.apply(this,arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,b,d,e,f,g,h,k,m,l,n,p=this;e=function(){var a,b,c,d;c=_.without(_.keys(this.mapping),"x","y");d=[];a=0;for(b=c.length;a<b;a++)g=c[a],d.push(this.mapping[g]);return d}.call(this);b=c.groupBy(this.statData,
e);f=this._getIdFunc();this.geoms={};n=[];for(g in b){a=b[g];k=a[0];d={};m=0;for(l=e.length;m<l;m++)h=e[m],d[h]={"in":[k[h]]};n.push(this.geoms[f(k)]={marks:{0:{type:"path",x:_.map(a,function(a){return p._getValue(a,"x")}),y:_.map(a,function(a){return p._getValue(a,"y")}),color:this._getValue(k,"color"),opacity:this._getValue(k,"opacity"),size:this._getValue(k,"size")}},evtData:d})}return n};return b}(d);b=function(a){function b(){return q=b.__super__.constructor.apply(this,arguments)}F(b,a);b.prototype.defaults=
{x:r.novalue(),y:r.novalue(),color:"steelblue",size:1,opacity:0.9,shape:1};b.prototype._calcGeoms=function(){var a,b,d,e,f,g,h,k,m,l,n,p,q,r,x,t;a=_.uniq(function(){var a,b,c,d;c=this.statData;d=[];a=0;for(b=c.length;a<b;a++)h=c[a],d.push(this._getValue(h,"x"));return d}.call(this));f=function(){var a,b,c,d;c=_.without(_.keys(this.mapping),"x","y");d=[];a=0;for(b=c.length;a<b;a++)k=c[a],d.push(this.mapping[k]);return d}.call(this);d=_.pairs(c.groupBy(this.statData,f));g=this._getIdFunc();this.geoms=
{};n=1===_.max(d,function(a){return a[1].length})[1].length;t=[];e=p=0;for(r=d.length;p<r;e=++p){l=d[e];m=l[0];b=l[1];n&&e+1<d.length&&b.push(d[e+1][1][0]);l=b[0];e={};q=0;for(x=f.length;q<x;q++)m=f[q],e[m]={"in":[l[m]]};b=this._fillZeros(b,a);m=b.x;b=b.y;t.push(this.geoms[g(l)]={marks:{0:{type:"line",x:m,y:b,color:this._getValue(l,"color"),opacity:this._getValue(l,"opacity"),size:this._getValue(l,"size")}},evtData:e})}return t};return b}(d);h=function(a){function b(){return u=b.__super__.constructor.apply(this,
arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,c,d,e,f,g;b.__super__._calcGeoms.call(this);f=this.geoms;g=[];for(c in f)a=f[c],g.push(function(){var b,c;b=a.marks;c=[];for(d in b)e=b[d],c.push(e.type="spline");return c}());return g};return b}(b);s=function(a){function b(){return v=b.__super__.constructor.apply(this,arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,b;if(this.mapping.y&&"cat"===this.meta[this.mapping.y].type)throw c.error.defn("The dependent variable of a bar chart cannot be categorical!");
if(this.mapping.x&&(a=this.meta[this.mapping.x],"cat"!==a.type&&!a.bw&&!a.binned&&"num"===a.type&&null==this.guideSpec.x.bw))throw c.error.type("Bar chart x-values need to be binned. Set binwidth or use the bin() transform!");this.position=null!=(b=this.spec.position)?b:"stack";if("stack"===this.position)return this._calcGeomsStack();if("dodge"===this.position)return this._calcGeomsDodge();throw c.error.defn("Bar chart position "+this.position+" is unknown.");};b.prototype._calcGeomsDodge=function(){var a,
b,c,d,e,f,g,h,k,m;a=null!=this.mapping.x?[this.mapping.x]:[];this._dodge(a);this._stack(a.concat("$n"));this.geoms={};b=this._getIdFunc();k=this.statData;m=[];g=0;for(h=k.length;g<h;g++){c=k[g];a={};for(d in c)e=c[d],"y"!==d&&(a[d]={"in":[e]});e=r.lower(this._getValue(c,"x"),c.$n,c.$m);f=r.upper(this._getValue(c,"x"),c.$n,c.$m);m.push(this.geoms[b(c)]={marks:{0:{type:"rect",x:[e,f],y:[c.$lower,c.$upper],color:this._getValue(c,"color"),opacity:this._inLevels(c)?this._getValue(c,"opacity"):0}},evtData:a,
tooltip:this._tooltip(c)})}return m};b.prototype._calcGeomsStack=function(){var a,b,c,d,e,f,g,h,k;this._stack(null!=this.mapping.x?[this.mapping.x]:[]);b=this._getIdFunc();this.geoms={};h=this.statData;k=[];f=0;for(g=h.length;f<g;f++){c=h[f];a={};for(d in c)e=c[d],"y"!==d&&(a[d]={"in":[e]});k.push(this.geoms[b(c)]={marks:{0:{type:"rect",x:[r.lower(this._getValue(c,"x")),r.upper(this._getValue(c,"x"))],y:[c.$lower,c.$upper],color:this._getValue(c,"color"),opacity:this._inLevels(c)?this._getValue(c,
"opacity"):0}},evtData:a,tooltip:this._tooltip(c)})}return k};return b}(d);n=function(a){function b(){return D=b.__super__.constructor.apply(this,arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,b,d,e,f,g,h,k,m,l,n,p,q,r,t,x;a=function(){var a,b,d,e;d=this.statData;e=[];a=0;for(b=d.length;a<b;a++)k=d[a],c.isDefined(this._getValue(k,"y"))&&c.isDefined(p=this._getValue(k,"x"))&&e.push(p);return e}.call(this);a=_.uniq(a);b={};e=0;for(f=a.length;e<f;e++)l=a[e],b[l]=0;g=function(){var a,b,c,d;
c=_.without(_.keys(this.mapping),"x","y");d=[];a=0;for(b=c.length;a<b;a++)m=c[a],d.push(this.mapping[m]);return d}.call(this);e=c.groupBy(this.statData,g);h=this._getIdFunc();this.geoms={};x=[];for(m in e){d=e[m];n=d[0];f={};q=0;for(r=g.length;q<r;q++)l=g[q],f[l]={"in":[n[l]]};l=function(){var c,d,e;e=[];c=0;for(d=a.length;c<d;c++)p=a[c],e.push(b[p]);return e}();r=0;for(t=d.length;r<t;r++)k=d[r],p=this._getValue(k,"x"),q=this._getValue(k,"y"),b[p]+=q;d=function(){var c,d,e;e=[];c=0;for(d=a.length;c<
d;c++)p=a[c],e.push(b[p]);return e}();x.push(this.geoms[h(n)]={marks:{0:{type:"area",x:a,y:{bottom:l,top:d},color:this._getValue(n,"color"),opacity:this._getValue(n,"opacity")}},evtData:f})}return x};return b}(d);k=function(a){function b(){return C=b.__super__.constructor.apply(this,arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,b,c,d,e,f,g,h,k;b=this._getIdFunc();this.geoms={};h=this.statData;k=[];f=0;for(g=h.length;f<g;f++){c=h[f];a={};for(d in c)e=c[d],a[d]={"in":[e]};k.push(this.geoms[b(c)]=
{marks:{0:{type:"text",x:this._getValue(c,"x"),y:this._getValue(c,"y"),text:this._getValue(c,"text"),color:this._getValue(c,"color"),size:this._getValue(c,"size"),opacity:this._getValue(c,"opacity"),"text-anchor":"center"}},evtData:a})}return k};return b}(d);m=function(a){function b(){return z=b.__super__.constructor.apply(this,arguments)}F(b,a);b.prototype._calcGeoms=function(){var a,b,c,d,e,f,g,h,k;b=this._getIdFunc();this.geoms={};h=this.statData;k=[];f=0;for(g=h.length;f<g;f++){c=h[f];a={};this._getValue(c,
"x");this._getValue(c,"y");for(d in c)e=c[d],"y"!==d&&"x"!==d&&(a[d]={"in":[e]});k.push(this.geoms[b(c)]={marks:{0:{type:"rect",x:[r.lower(this._getValue(c,"x")),r.upper(this._getValue(c,"x"))],y:[r.lower(this._getValue(c,"y")),r.upper(this._getValue(c,"y"))],color:this._getValue(c,"color"),size:this._getValue(c,"size"),opacity:this._getValue(c,"opacity")}},evtData:a,tooltip:this._tooltip(c)})}return k};return b}(d);l=function(a){function b(){return J=b.__super__.constructor.apply(this,arguments)}
F(b,a);b.prototype._calcGeoms=function(){var a,b,c,d,e,f,g,h,k,m,l,p,n,q,t,x;c=this._getIdFunc();this.geoms={};t=this.statData;x=[];p=0;for(n=t.length;p<n;p++){e=t[p];b={};for(f in e)a=e[f],"y"!==f&&(b[f]={"in":[a]});k=this._getValue(e,"x");l=this._getValue(e,"y");a=this._getValue(e,"color");d=this._getValue(e,"size");g=this._inLevels(e)?this._getValue(e,"opacity"):0;h=r.lower(k);m=r.upper(k);k=r.middle(k);b={marks:{},evtData:b};l.q1&&(b.marks={iqr:{type:"rect",x:[h,m],y:[l.q2,l.q4],stroke:a,color:r.identity("white"),
size:d,opacity:g,"stroke-width":"1px"},q1:{type:"pline",x:[h,m],y:[l.q1,l.q1],color:a,size:d,opacity:g},lower:{type:"pline",x:[k,k],y:[l.q1,l.q2],color:a,size:d,opacity:g},q5:{type:"pline",x:[h,m],y:[l.q5,l.q5],color:a,size:d,opacity:g},upper:{type:"pline",x:[k,k],y:[l.q4,l.q5],color:a,size:d,opacity:g},middle:{type:"pline",x:[h,m],y:[l.q3,l.q3],color:a,size:d,opacity:g}});q=l.outliers;d=m=0;for(l=q.length;m<l;d=++m)h=q[d],b.marks[d]={type:"circle",x:k,y:h,color:a,size:r.identity(3),opacity:g};x.push(this.geoms[c(e)]=
b)}return x};return b}(d);c.layer={};c.layer.Base=d;c.layer.classes={point:e,text:k,line:b,path:a,area:n,bar:s,tile:m,box:l,spline:h};c.layer.make=function(a,b,d){var e;e=a.type;if(e in c.layer.classes)return new c.layer.classes[e](a,b,d);throw c.error.defn("No such layer "+a.type+".");}}).call(this);(function(){var n,s={}.hasOwnProperty,l=function(c,b){function a(){this.constructor=c}for(var e in b)s.call(b,e)&&(c[e]=b[e]);a.prototype=b.prototype;c.prototype=new a;c.__super__=b.prototype;return c};
c.pane={};c.pane.make=function(c,b){return new n(c,b)};n=function(d){function b(a,b){this.titleObj=b;this.index=a;this.title=this.layers=null}l(b,d);b.prototype.make=function(a,b,d){var k,m,l,p,n;this.layers=d;if(!this.geoms)for(this.geoms={},p=this.layers,d=l=0,p=p.length;l<p;d=++l)this.geoms[d]=new c.Geometry;this.metas={};n=this.layers;d=l=0;for(p=n.length;l<p;d=++l)k=n[d],m=k.calculate(b[d].statData,b[d].metaData),k=m.geoms,m=m.meta,this.geoms[d].set(k),this.metas[d]=m;null==this.title&&(this.title=
this._makeTitle(a));this.title.make(this.titleObj);return this.domains=this._makeDomains(a,this.geoms,this.metas)};b.prototype._makeTitle=function(){return c.guide.title("facet")};b.prototype._makeDomains=function(a,b,d){return c.domain.make(b,d,a.guides,a.strict)};b.prototype.render=function(a,b,c,d){var m;this.title.render(a({},!1,!1),d,b);b=a(b,c,!0);c=this.geoms;d=[];for(m in c)a=c[m],d.push(a.render(b));return d};b.prototype.dispose=function(a){var b,c,d;d=this.geoms;for(c in d)b=d[c],b.dispose(a);
this.geoms={};return this.title.dispose(a)};return b}(c.Renderable)}).call(this);(function(){c.dim={};c.dim.make=function(c,s,l){var d,b,a,e,h,k,m,t;c={width:null!=(b=c.width)?b:400,height:null!=(a=c.height)?a:400,paddingLeft:null!=(e=c.paddingLeft)?e:10,paddingRight:null!=(d=c.paddingRight)?d:10,paddingTop:null!=(h=c.paddingTop)?h:10,paddingBottom:null!=(k=c.paddingBottom)?k:10,horizontalSpacing:null!=(m=c.horizontalSpacing)?m:10,verticalSpacing:null!=(t=c.verticalSpacing)?t:20,guideTop:10,guideRight:0,
guideLeft:5,guideBottom:5};d=s.axesOffset(c);b=d.left;a=d.right;e=d.top;d=d.bottom;c.guideLeft+=null!=b?b:0;c.guideRight+=null!=a?a:0;c.guideBottom+=null!=d?d:0;c.guideTop+=null!=e?e:0;d=s.titleOffset(c);b=d.left;a=d.right;e=d.top;d=d.bottom;c.guideLeft+=null!=b?b:0;c.guideRight+=null!=a?a:0;c.guideBottom+=null!=d?d:0;c.guideTop+=null!=e?e:0;s=s.legendOffset(c);b=s.left;a=s.right;e=s.top;d=s.bottom;c.guideLeft+=null!=b?b:0;c.guideRight+=null!=a?a:0;c.guideBottom+=null!=d?d:0;c.guideTop+=null!=e?e:
0;s=0.4*c.width;b=0.4*c.height;c.guideLeft>s&&(c.guideLeft=s);c.guideRight>s&&(c.guideRight=s);c.guideTop>b&&(c.guideTop=b);c.guideBottom>b&&(c.guideBottom=b);c.chartHeight=c.height-c.paddingTop-c.paddingBottom-c.guideTop-c.guideBottom;c.chartWidth=c.width-c.paddingLeft-c.paddingRight-c.guideLeft-c.guideRight;null!=l.cols&&1<l.cols?(c.eachWidth=c.chartWidth-c.horizontalSpacing*l.cols,c.eachWidth/=l.cols):c.eachWidth=c.chartWidth;null!=l.rows&&1<l.rows?(c.eachHeight=c.chartHeight-c.verticalSpacing*
(l.rows+1),c.eachHeight/=l.rows):c.eachHeight=c.chartHeight-c.verticalSpacing;return c};c.dim.guess=function(c,s){var l,d,b,a,e,h,k,m,t;l={width:null!=(d=c.width)?d:400,height:null!=(b=c.height)?b:400,paddingLeft:null!=(a=c.paddingLeft)?a:10,paddingRight:null!=(e=c.paddingRight)?e:10,paddingTop:null!=(h=c.paddingTop)?h:10,paddingBottom:null!=(k=c.paddingBottom)?k:10,guideLeft:30,guideRight:40,guideTop:10,guideBottom:30,horizontalSpacing:null!=(m=c.horizontalSpacing)?m:10,verticalSpacing:null!=(t=
c.verticalSpacing)?t:10};l.chartHeight=l.height-l.paddingTop-l.paddingBottom-l.guideTop-l.guideBottom;l.chartWidth=l.width-l.paddingLeft-l.paddingRight-l.guideLeft-l.guideRight;l.eachWidth=null!=s.cols&&1<s.cols?l.chartWidth-l.horizontalSpacing*(s.cols-1):l.chartWidth;l.eachHeight=null!=s.rows&&1<s.rows?l.chartHeight-l.verticalSpacing*(s.rows-1):l.chartHeight;return l}}).call(this);(function(){var n,s,l,d,b,a,e,h,k,m,t,p,r,f,g,q,u,v,D,C,z={}.hasOwnProperty,J=function(a,b){function c(){this.constructor=
a}for(var d in b)z.call(b,d)&&(a[d]=b[d]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};c.paper=function(a,b,d,e,f){var g;null==f&&(f=!0);g="undefined"!==typeof Raphael&&null!==Raphael?Raphael(a,b,d):c.canvas(a,b,d);a=e.graph;e=e.numeral;b=g.rect(0,0,b,d).attr({fill:"white",opacity:0,"stroke-width":0});null!=a?(b.click(a.handleEvent("reset")),c.mouseEvents(a,b,f),c.touchEvents(a.handleEvent,b,!0)):null!=e&&b.click(e.handleEvent("reset"));return g};c.mouseEvents=function(a,
b,d){var e,f,g,h,k,m;g=a.handleEvent("select");d&&(h=null);m=f=k=e=null;return b.drag(function(b,g,l,p){if(null!=m&&null!=k){if(e={x:k.x+b,y:k.y+g},f=a.facet.getFacetInfo(a.dims,e.x,e.y),null!=h&&null!=f&&f.col===m.col&&f.row===m.row&&d)return l={x:Math.min(k.x,e.x),y:Math.min(k.y,e.y),width:Math.abs(k.x-e.x),height:Math.abs(k.y-e.y)},h=h.attr(l)}else if(b=c.offset(a.dom),k={x:l-b.left,y:p-b.top},m=a.facet.getFacetInfo(a.dims,k.x,k.y),null!=m&&d)return h=a.paper.rect(k.x,k.y,0,0,2),h=h.attr({fill:"black",
opacity:0.2})},function(){return e=k=null},function(){if(null!=k&&null!=e)return null!=h&&d&&(h=h.hide(),h.remove()),g({start:k,end:e})})};c.touchEvents=function(a,b,c){null==c&&(c=!0);if(c)return b.touchstart(a("touchstart")),b.touchend(a("touchend")),b.touchmove(a("touchmove")),b.touchcancel(a("touchcancel"))};c.render=function(a,b,d,e){return function(f,g,h){null==f&&(f={});null==g&&(g=!1);null==h&&(h=!0);if(null==e.type)throw c.error.unknown("Coordinate don't have at type?");if(null==m[e.type])throw c.error.input("Unknown coordinate type "+
e.type);return{add:function(k,l,p,q){var r;if(null==m[e.type][k.type])throw c.error.input("Coord "+e.type+" has no mark "+k.type);r=m[e.type][k.type].render(b,d,e,f,k,h);r.data("m",k);l&&0<_.keys(l).length&&r.data("e",l);p&&r.data("t",p);null!=g&&r.attr("clip-rect",g);"guide"===q?(r.click(a("guide-click")),r.hover(a("gover"),a("gout"))):"guide-title"===q||"guide-titleH"===q||"guide-titleV"===q?(r.click(a(q)),r.hover(a("tover"),a("tout"))):(r.click(a("click")),r.hover(a("mover"),a("mout")));c.touchEvents(a,
r,!0);return r},remove:function(a){return a.remove()},animate:function(a,b,c,k){m[e.type][b.type].animate(a,d,e,f,b,h);null!=g&&a.attr("clip-rect",g);c&&0<_.keys(c).length&&a.data("e",c);k&&a.data("t",k);a.data("m",b);return a}}}};h=function(){function a(){}a.prototype.render=function(a,b,c,d,e,f){var g;a=this._make(a);c=this.attr(b,c,d,e,f);for(g in c)b=c[g],a.attr(g,b);return a};a.prototype._make=function(){throw c.error.impl();};a.prototype.animate=function(a,b,c,d,e,f){return a.animate(this.attr(b,
c,d,e,f),300)};a.prototype.attr=function(a,b,d,e,f){throw c.error.impl();};a.prototype._cantRender=function(a){throw c.error.missingdata();};a.prototype._makePath=function(a,b,c){null==c&&(c="L ");return("spline"===c?_.map(a,function(a,c){return(0===c?"M "+a+" "+b[c]+" R ":"")+(""+a+" "+b[c])}):_.map(a,function(a,d){return(0===d?"M ":c)+a+" "+b[d]})).join(" ")};a.prototype._maybeApply=function(a,b,c){b=b[c];return _.isObject(b)&&"identity"===b.f?b.v:null!=a[c]?a[c].f(b):b};a.prototype._applyOffset=
function(a,b,c){var d;if(!c)return{x:a,y:b};null==c.x&&(c.x=0);null==c.y&&(c.y=0);return{x:_.isArray(a)?function(){var b,e,f;f=[];b=0;for(e=a.length;b<e;b++)d=a[b],f.push(d+c.x);return f}():a+c.x,y:_.isArray(b)?function(){var a,e,f;f=[];a=0;for(e=b.length;a<e;a++)d=b[a],f.push(d+c.y);return f}():b+c.y}};a.prototype._shared=function(a,b,c){var d,e=this;d=function(d){if(null!=b[d]&&null==c[d])return c[d]=e._maybeApply(a,b,d)};d("opacity");d("stroke-width");d("stroke-dasharray");d("stroke-dashoffset");
d("transform");d("font-size");d("font-weight");d("font-family");return c};a.prototype._checkPointUndefined=function(a,b,d){null==d&&(d="Point");if(void 0===a||void 0===b)throw c.error.missing(""+d+" cannot be plotted due to undefined data.");};a.prototype._checkArrayUndefined=function(a,b,d){var e;null==d&&(d="Line");if(_.all(function(){var c,d,f;f=[];e=c=0;for(d=a.length-1;0<=d?c<=d:c>=d;e=0<=d?++c:--c)f.push(void 0===a[e]||void 0===b[e]);return f}()))throw c.error.missing(""+d+" cannot be plotted due to too many missing points.");
};a.prototype._checkArrayNaN=function(a,b){var c,d;d=_.map(_.zip(a,b),function(a,b){return isNaN(a[0])||isNaN(a[1])?void 0:a});return{x:function(){var a,b,e;e=[];a=0;for(b=d.length;a<b;a++)c=d[a],null!=c&&e.push(c[0]);return e}(),y:function(){var a,b,e;e=[];a=0;for(b=d.length;a<b;a++)c=d[a],null!=c&&e.push(c[1]);return e}()}};return a}();n=function(a){function b(){return t=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype.animate=function(a,b,c,d,e,f){var g,h;h=a.data("m");g=this.attr(b,
c,d,e,f);if(_.isEqual(h.x,e.x))return a.animate(g,300);b=this.attr(b,c,d,h,f);return a.animate(b,300,function(){return a.attr(g)})};return b}(h);s=function(a){function b(){return p=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.circle()};b.prototype.attr=function(a,b,c,d,e){e=b.getXY(e,d);b=e.x;e=e.y;this._checkPointUndefined(b,e,"Circle");c=this._applyOffset(b,e,c);b=c.x;e=c.y;c=this._maybeApply(a,d,d.stroke?"stroke":"color");c={cx:b,cy:e,r:this._maybeApply(a,
d,"size"),stroke:c};(b=this._maybeApply(a,d,"color"))&&"none"!==b&&(c.fill=b);return this._shared(a,d,c)};return b}(h);b=function(a){function b(){return r=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.path()};b.prototype.attr=function(a,b,c,d,e){var f;e=b.getXY(e,d);b=e.x;e=e.y;this._checkArrayUndefined(b,e,"Path");c=this._applyOffset(b,e,c);b=c.x;e=c.y;f=this._maybeApply(a,d,d.stroke?"stroke":"color");c=this._maybeApply(a,d,d.size?"size":"stroke-width");
return this._shared(a,d,{path:this._makePath(b,e),stroke:f,"stroke-width":c})};return b}(h);d=function(a){function b(){return f=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.path()};b.prototype.attr=function(a,b,d,e,f){var g,h;g=c.sortArrays(a.x.compare,[e.x,e.y]);e.x=g[0];e.y=g[1];f=b.getXY(f,e);b=f.x;f=f.y;this._checkArrayUndefined(b,f,"Line");g=0;for(h=b.length;g<h;++g);d=this._applyOffset(b,f,d);b=d.x;f=d.y;d=this._checkArrayNaN(b,f);b=d.x;f=d.y;g=
this._maybeApply(a,e,e.stroke?"stroke":"color");d=this._maybeApply(a,e,e.size?"size":"stroke-width");return this._shared(a,e,{path:this._makePath(b,f),stroke:g,"stroke-width":d})};return b}(n);k=function(a){function b(){return g=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype.attr=function(a,b,d,e,f){var g,h;g=c.sortArrays(a.x.compare,[e.x,e.y]);e.x=g[0];e.y=g[1];f=b.getXY(f,e);b=f.x;f=f.y;this._checkArrayUndefined(b,f,"Spline");g=0;for(h=b.length;g<h;++g);d=this._applyOffset(b,f,
d);b=d.x;f=d.y;d=this._checkArrayNaN(b,f);b=d.x;f=d.y;g=this._maybeApply(a,e,e.stroke?"stroke":"color");d=this._maybeApply(a,e,e.size?"size":"stroke-width");return this._shared(a,e,{path:this._makePath(b,f,"spline"),stroke:g,"stroke-width":d})};return b}(d);a=function(a){function b(){return q=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype.attr=function(a,b,d,e,f){var g,h,k,m,l;m=b.getXY(f,e);f=m.x;l=m.y;b=m.r;m=m.t;this._checkArrayUndefined(f,l,"Line");l=this._applyOffset(f,l,d);
f=l.x;l=l.y;var p,q;if(_.max(b)-_.min(b)<c["const"].epsilon)for(b=b[0],d="M "+f[0]+" "+l[0],h=p=1,q=f.length-1;1<=q?p<=q:p>=q;h=1<=q?++p:--p)k=Math.abs(m[h]-m[h-1])>Math.PI?1:0,g=0<m[h]-m[h-1]?1:0,d+="A "+b+" "+b+" 0 "+k+" "+g+" "+f[h]+" "+l[h];else d=this._makePath(f,l);b=this._maybeApply(a,e,e.stroke?"stroke":"color");return this._shared(a,e,{path:d,stroke:b})};return b}(d);n=function(a){function b(){return u=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.path()};
b.prototype.attr=function(a,b,d,e,f){var g,h,k;g=c.sortArrays(a.x.compare,[e.x,e.y.top]);h=g[0];k=g[1];g=b.getXY(f,{x:h,y:k});g=this._applyOffset(g.x,g.y,d);k=c.sortArrays(function(b,c){return-a.x.compare(b,c)},[e.x,e.y.bottom]);h=k[0];k=k[1];b=b.getXY(f,{x:h,y:k});b=this._applyOffset(b.x,b.y,d);h=g.x.concat(b.x);k=g.y.concat(b.y);return this._shared(a,e,{path:this._makePath(h,k),stroke:this._maybeApply(a,e,"color"),fill:this._maybeApply(a,e,"color"),"stroke-width":"0px"})};return b}(n);e=function(a){function b(){return v=
b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.rect()};b.prototype.attr=function(a,b,c,d,e){e=b.getXY(e,d);b=e.x;e=e.y;this._checkPointUndefined(b[0],e[0],"Bar");this._checkPointUndefined(b[1],e[1],"Bar");c=this._applyOffset(b,e,c);b=c.x;e=c.y;c=this._maybeApply(a,d,d.stroke?"stroke":"color");return this._shared(a,d,{x:_.min(b),y:_.min(e),width:Math.abs(b[1]-b[0]),height:Math.abs(e[1]-e[0]),fill:this._maybeApply(a,d,"color"),stroke:c,"stroke-width":this._maybeApply(a,
d,"stroke-width")})};return b}(h);l=function(a){function b(){return D=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.path()};b.prototype.attr=function(a,b,d,e,f){var g,h,k,m;g=e.x;h=g[0];g=g[1];m=e.y;k=m[0];m=m[1];this._checkPointUndefined(h,k,"Bar");this._checkPointUndefined(g,m,"Bar");e.x=[h,h,g,g];e.y=[k,m,m,k];g=b.getXY(f,e);h=g.x;k=g.y;f=g.r;g=g.t;d=this._applyOffset(h,k,d);h=d.x;k=d.y;b.flip&&(h.push(h.splice(0,1)[0]),k.push(k.splice(0,1)[0]),f.push(f.splice(0,
1)[0]),g.push(g.splice(0,1)[0]));2*Math.PI-Math.abs(g[1]-g[0])<c["const"].epsilon?(b="M "+h[0]+" "+k[0]+" A "+f[0]+" "+f[0]+" 0 1 1 "+h[0]+" "+(k[0]+2*f[0])+" A "+f[1]+" "+f[1]+" 0 1 1 "+h[1]+" "+k[1],b+="M "+h[2]+" "+k[2]+" A "+f[2]+" "+f[2]+" 0 1 0 "+h[2]+" "+(k[2]+2*f[2])+" A "+f[3]+" "+f[3]+" 0 1 0 "+h[3]+" "+k[3]+" Z"):(d=Math.abs(g[1]-g[0])>Math.PI?1:0,b="M "+h[0]+" "+k[0]+" A "+f[0]+" "+f[1]+" 0 "+d+" 1 "+h[1]+" "+k[1],d=Math.abs(g[3]-g[2])>Math.PI?1:0,b+="L "+h[2]+" "+k[2]+" A "+f[2]+" "+
f[3]+" 0 "+d+" 0 "+h[3]+" "+k[3]+" Z");d=this._maybeApply(a,e,e.stroke?"stroke":"color");return this._shared(a,e,{path:b,fill:this._maybeApply(a,e,"color"),stroke:d,"stroke-width":this._maybeApply(a,e,"stroke-width")})};return b}(h);h=function(a){function b(){return C=b.__super__.constructor.apply(this,arguments)}J(b,a);b.prototype._make=function(a){return a.text()};b.prototype.attr=function(a,b,c,d,e){var f;e=b.getXY(e,d);b=e.x;e=e.y;this._checkPointUndefined(b,e,"Text");c=this._applyOffset(b,e,
c);b=c.x;e=c.y;return this._shared(a,d,{x:b,y:e,r:10,text:this._maybeApply(a,d,"text"),"font-size":this._maybeApply(a,d,"size"),"text-anchor":null!=(f=d["text-anchor"])?f:"left",fill:this._maybeApply(a,d,"color")||"black"})};return b}(h);m={cartesian:{circle:new s,line:new d,pline:new d,area:new n,path:new b,text:new h,rect:new e,spline:new k},polar:{circle:new s,path:new b,line:new d,pline:new a,area:new n,text:new h,rect:new l,spline:new k}}}).call(this);(function(){var n=[].indexOf||function(c){for(var l=
0,d=this.length;l<d;l++)if(l in this&&this[l]===c)return l;return-1};c.handler={};c.handler.tooltip=function(){var n,l,d,b,a,e,h;a={};l=n=b=d=null;h=function(b){b=c.getXY(d,b);if(null!=a.text)return e(a,b)};e=function(a,b){var c,d,e,f,g,h;d=[b.x,b.y];f=d[0];d=d[1];if(null!=a.text)return e=a.text.getBBox().height,f={x:f,y:d-e/2-20},a.text.attr(f),e=a.text.getBBox(),g=e.x,h=e.y,c=e.width,e=e.height,c={x:g-5,y:h-5,width:c+10,height:e+10},0>c.y&&(c.y=h+30+e,f.y=d+e/2+15),c.x+c.width>n&&(d=c.x+c.width-
n,c.x-=d/2,f.x-=d/2),c.x<l&&(f.x+=l-c.x,c.x=l),a.text.attr(f),a.box.attr(c),a};return function(k,m,t,p){var r,f;d=c.offset(p.dom);b=m.paper;n=p.dims.chartWidth+p.dims.guideLeft+p.dims.paddingLeft;l=p.dims.guideLeft+p.dims.paddingLeft;if("mover"===k||"mout"===k)if(null!=a.text&&(a.text.remove(),a.box.remove()),a={},"mover"===k&&m.tooltip)return k=c.getXY(d,t),m.getBBox(),t=[k.x,k.y],r=t[0],t=t[1],a.text=b.text(r,t,m.tooltip(p.scaleSet.scales)).attr({"text-anchor":"middle",fill:"white"}),p=a.text.getBBox(),
p=p.height,a.text.attr({y:t-p/2-20}),p=a.text.getBBox(),r=p.x,f=p.y,t=p.width,p=p.height,a.box=b.rect(r-5,f-5,t+10,p+10,10),a.box.attr({fill:"#213"}),a.text.toFront(),a=e(a,k),m.mousemove(h)}};c.handler.drilldown=function(s,l,d){var b,a;null==d&&(d={});if(!_.isArray(l))throw c.error.input("Parameter `levels` should be an array.");if(0>n.call(c["const"].aes,s))throw c.error.input("Unknown aesthetic "+s+".");b=0;a=[d];return function(c,d,k,m){var n,p;if("reset"===c&&0<b){d=m.spec;a.pop();c=a.unshift();
b--;p=d.layers;k=0;for(n=p.length;k<n;k++)d=p[k],d.filter=c,d[s]=l[b],d.id=l[b];return m.make(m.spec)}if("click"===c&&b<l.length-1&&(c=d.evtData,d=m.spec,k=c[l[b]])){c={};c[l[b]]=k;b++;c=_.extend(_.clone(a[a.length-1]),c);p=d.layers;k=0;for(n=p.length;k<n;k++)d=p[k],d.filter=c,d[s]=l[b],d.id=l[b];a.push(c);return m.make(m.spec)}}};c.handler.zoom=function(n,l){var d,b,a,e,h,k;null==l&&(l={x:!0,y:!0});if(null==n)throw c.error.input("Initial specification missing.");b={x:_.clone(null!=(e=n.guides)?e.x:
void 0),y:_.clone(null!=(h=n.guides)?h.y:void 0)};a=void 0;d=["x","y"];k=function(a){return function(b,c,d,e){return"reset"===b?_.isFunction(a)?a("resetZoom",c,d,e):a.handle("resetZoom",c,d,e):_.isFunction(a)?a(b,c,d,e):a.handle(b,c,d,e)}};return function(e,h,p,r){var f,g,q,n,s,D,C,z,J;null==a&&(a=_.clone(r.handlers));if("cartesian"===r.coord.type){if("resetZoom"===e){f=r.spec;g=0;for(q=d.length;g<q;g++)p=d[g],f.guides[p]=_.clone(b[p]);r.handlers=_.clone(a);r.make(r.spec)}if("select"===e){h=h.evtData;
f=r.spec.guides;C=r.spec.layers;J=[];q=0;for(s=C.length;q<s;q++){g=C[q];n=0;for(D=d.length;n<D;n++)p=d[n],l[p]&&null!=g[p]&&(e=c.parser.unbracket(g[p]["var"]),("num"===(z=r.axes.domains[p].type)||"date"===z)&&h[e].le-h[e].ge>c["const"].epsilon&&(null==f[p]&&(f[p]={min:null,max:null}),f[p].min=h[e].ge,f[p].max=h[e].le),"cat"===r.axes.domains[p].type&&0!==h[e]["in"].length&&(null==f[p]&&(f[p]={levels:null}),f[p].levels=h[e]["in"]));r.handlers=_.map(r.handlers,k);J.push(r.make(r.spec))}return J}}}}}).call(this);
(function(){var n,s=[].indexOf||function(c){for(var d=0,b=this.length;d<b;d++)if(d in this&&this[d]===c)return d;return-1};c.facet={};c.facet.make=function(){return new n};n=function(){function l(){this.type="none";this.mapping={};this.specgroups=[];this.groups=[];this.panes={};this.deletedPanes=[]}l.prototype.make=function(d){var b,a;this.spec=d;d=this._getMappings(this.spec.facet);this.type=d.type;this.mapping=a=d.mapping;this.groups=_.values(this.mapping);this.specgroups={};for(b in a)d=a[b],this.spec.facet[b]&&
(d=c.parser.normalize(d),this.specgroups[d]=this.spec.facet[b]);this.spec.facet.formatter&&(this.formatter=this.spec.facet.formatter);this.style={};this.spec.facet.size&&(this.style.size=this.spec.facet.size);if(this.spec.facet.color)return this.style.color=this.spec.facet.color};l.prototype.calculate=function(d,b){var a,e,h,k,m;a=this._makeIndices(d,this.specgroups);this.values=a.values;this.indices=a.indices;"none"===this.type?this.rows=this.cols=1:(this.cols=this.spec.facet.cols,this.rows=this.spec.facet.rows,
"wrap"===this.type?(a=this.values[this.mapping["var"]].length,this.cols||this.rows||(this.cols=Math.min(3,a)),this.cols?this.rows=Math.ceil(a/this.cols):this.rows&&(this.cols=Math.ceil(a/this.rows))):(this.rows=this.mapping.y?this.values[this.mapping.y].length:1,this.cols=this.mapping.x?this.values[this.mapping.x].length:1));this.datas=this._groupData(d,this.indices);a=c.compare(_.keys(this.panes),_.keys(this.indices));e=a.deleted;a=a.added;k=0;for(m=e.length;k<m;k++)h=e[k],this.deletedPanes.push(this.panes[h]),
delete this.panes[h];k=0;for(m=a.length;k<m;k++)h=a[k],e=this.formatter?this.formatter(this.indices[h]):h,this.panes[h]=c.pane.make(this.indices[h],_.extend({title:e},this.style));a=this.indices;e=[];for(h in a)e.push(this.panes[h].make(this.spec,this.datas[h],b));return e};l.prototype.render=function(c,b,a){var e,h,k,m,l,p;if(0<this.deletedPanes.length){e=c({},!1,!1);p=this.deletedPanes;k=0;for(l=p.length;k<l;k++)m=p[k],m.dispose(e);this.deletedPanes=[]}l=this.panes;p=[];for(h in l)m=l[h],k=this.getOffset(b,
h),e=a.clipping(k),p.push(m.render(c,k,e,b));return p};l.prototype.dispose=function(c){var b,a,e,h;e=this.panes;for(b in e)a=e[b],this.deletedPanes.push(a),delete this.panes[b];if(c){h=this.deletedPanes;b=0;for(e=h.length;b<e;b++)a=h[b],a.dispose(c);return this.deletedPanes=[]}};l.prototype.getGrid=function(){return{cols:this.cols,rows:this.rows}};l.prototype.getOffset=function(c,b){var a;a=this._getRowCol(b);return{x:c.paddingLeft+c.guideLeft+(c.eachWidth+c.horizontalSpacing)*a.col,y:c.paddingTop+
c.guideTop+(c.eachHeight+c.verticalSpacing)*a.row+c.verticalSpacing}};l.prototype.edge=function(c){var b,a,e,h,k,m,l,p,r=this;if("none"===this.type)return function(){return!0};"grid"===this.type?(p=function(a){return _.indexOf(r.values[r.mapping.y],r.indices[a][r.mapping.y])},b=function(a){return _.indexOf(r.values[r.mapping.x],r.indices[a][r.mapping.x])}):(b=function(a){return _.indexOf(r.values[r.mapping["var"]],r.indices[a][r.mapping["var"]])%r.cols},p=function(a){return Math.floor(_.indexOf(r.values[r.mapping["var"]],
r.indices[a][r.mapping["var"]])/r.cols)});if("none"===c)return function(){return!1};if("out"===c)return function(){return!0};e="top"===c||"bottom"===c?b:p;l="top"===c?p:"bottom"===c?function(a){return-p(a)}:"left"===c?b:"right"===c?function(a){return-b(a)}:void 0;c={};for(h in this.indices)if(m=e(h),k=l(h),!c[m]||k<c[m].v)c[m]={v:k,k:h};a=_.pluck(c,"k");return function(b){return 0<=s.call(a,b)}};l.prototype.getEvtData=function(c,b){var a,e,h,k;h={};k=this.mapping;for(a in k)e=k[a],h[e]="x"===a||"y"===
a?{"in":this.values[e][c]}:{"in":this.values[e][this.rows*b+c]};return h};l.prototype.getFacetInfo=function(d,b,a,e){var h,k,m;if(e){if(null==e.col||null==e.row)throw c.error.impl("Preset rows & columns are not present.");h=e.col;m=e.row}else h=(b-d.paddingLeft-d.guideLeft)/(d.eachWidth+d.horizontalSpacing),h=Math.floor(h),m=(a-d.paddingTop-d.guideTop-d.verticalSpacing)/(d.eachHeight+d.verticalSpacing),m=Math.floor(m);if(0>h||h>=this.cols||0>m||m>=this.rows)return null;k={x:d.paddingLeft+d.guideLeft+
(d.eachWidth+d.horizontalSpacing)*h,y:d.paddingTop+d.guideTop+(d.eachHeight+d.verticalSpacing)*m+d.verticalSpacing};b={x:b-k.x,y:a-k.y};if(!e&&(b.x>d.eachWidth||b.y>d.eachHeight))return null;b.x=Math.max(Math.min(b.x,d.eachWidth),0);b.y=Math.max(Math.min(b.y,d.eachHeight),0);return{row:m,col:h,offset:k,adjusted:b,evtData:this.getEvtData(h,m)}};l.prototype._getMappings=function(d){var b;b={type:"none",mapping:{}};if(_.isObject(d))if("wrap"===d.type){b.type="wrap";if(!d["var"])throw c.error.defn("You didn't specify a variable to facet on.");
d["var"]&&(b.mapping["var"]=c.parser.normalize(d["var"]["var"]))}else if("grid"===d.type){b.type="grid";if(!d.x&&d.y)throw c.error.defn("You didn't specify a variable to facet on.");d.x&&(b.mapping.x=c.parser.normalize(d.x["var"]));d.y&&(b.mapping.y=c.parser.normalize(d.y["var"]))}return b};l.prototype._makeIndices=function(d,b){var a,e,h,k,m,l,p,r;r={};for(a in b)if(e=b[a],m=c.parser.normalize(e["var"]),e.levels)r[m]=e.levels;else{l=[];for(h in d){e=d[h];if(k=e.metaData[m])!k||"num"!==(p=k.type)&&
"date"!==p||c.type.compare(k.type);l=_.uniq(_.union(l,_.pluck(e.statData,m)))}r[m]=l}a=c.cross(r);h={};k=_.pluck(b,"var");l=[];p=0;for(e=k.length;p<e;p++)m=k[p],l.push(c.parser.normalize(m));m=c.stringify(l);e=0;for(k=a.length;e<k;e++)p=a[e],h[m(p)]=p;return{values:r,indices:h}};l.prototype._groupData=function(d,b){var a,e,h,k,m,l,p;e=c.groupProcessedData(d,this.groups);a={};p=this.indices;for(h in p){k=p[h];for(m=e;!0===m.grouped;)l=k[m.key],m=m.values[l];a[h]=m}return a};l.prototype._getRowCol=
function(c){var b;b={row:0,col:0};"wrap"===this.type?(c=this.indices[c][this.mapping["var"]],c=_.indexOf(this.values[this.mapping["var"]],c),b.col=c%this.cols,b.row=Math.floor(c/this.cols)):"grid"===this.type&&(b.row=_.indexOf(this.values[this.mapping.y],this.indices[c][this.mapping.y]),b.col=_.indexOf(this.values[this.mapping.x],this.indices[c][this.mapping.x]));return b};return l}();c.groupProcessedData=function(l,d){var b,a,e,h,k,m,n,p,r;if(0===d.length)return l;b=d.splice(0,1)[0];m=[];for(e in l)a=
l[e],b in a.metaData&&(m=_.union(m,_.uniq(_.pluck(a.statData,b))));k={grouped:!0,key:b,values:{}};p=0;for(r=m.length;p<r;p++){n=m[p];h={};for(e in l)a=l[e],h[e]={metaData:a.metaData},h[e].statData=b in a.metaData?c.filter(a.statData,b,n):_.clone(a.statData);k.values[n]=c.groupProcessedData(h,_.clone(d))}return k}}).call(this);(function(){var n,s,l,d=function(b,a){return function(){return b.apply(a,arguments)}};l=function(b){var a,d,h,k,l,n,p,r,f,g;l=["row","column","value"];d=0;for(k=l.length;d<k;d++)a=
l[d],b[a+"s"]||(b[a+"s"]=[],null!=b[a]&&b[a+"s"].push(b[a]));f=["rows","columns","values"];l=0;for(p=f.length;l<p;l++)for(a=f[l],g=b[a],d=n=0,r=g.length;n<r;d=++n)k=g[d],_.isString(k)&&(b[a][d]={"var":k});null==b.full&&(b.full=!1);null==b.formatter&&(b.formatter={});d=b.formatter;for(h in d)a=d[h],h=c.parser.normalize(h),b.formatter[h]=a;return b};s=function(){function b(a,b,h){var k,l,n,p,r;this.statData=a;this.ticks=b;this.spec=h;this.get=d(this.get,this);this.makeFormatters=d(this.makeFormatters,
this);this.makeHeaders=d(this.makeHeaders,this);this.rows=function(){var a,b,d,e;d=this.spec.rows;e=[];a=0;for(b=d.length;a<b;a++)k=d[a],e.push(c.parser.unbracket(k["var"]));return e}.call(this);this.columns=function(){var a,b,d,e;d=this.spec.columns;e=[];a=0;for(b=d.length;a<b;a++)k=d[a],e.push(c.parser.unbracket(k["var"]));return e}.call(this);b=this.rows.concat(this.columns);a=this.columns;this.dataIndexByRows={};this.dataIndexByCols={};n=function(a,b,c){var d,e,h,k,l;a=e=a;h=0;for(k=b.length;h<
k;h++)d=b[h],null==a[l=c[d]]&&(a[l]={}),e=a,a=e[c[d]];return e[c[d]]=c};r=this.statData;l=0;for(p=r.length;l<p;l++)h=r[l],n(this.dataIndexByRows,b,h),n(this.dataIndexByCols,a,h)}b.prototype.makeHeaders=function(){var a,b,c=this;a=this.spec.full;b=function(d,l,n,p){var r,f,g;if(0===n.length)return d.push(l);r=n[0];f=n.slice(1);g=_.keys(p);return _.each(c.ticks[r].ticks,function(c,h){var n;if(a||_.contains(g,""+c.location))return n=_.clone(l),n[r]=c.value,b(d,n,f,p[c.location])})};this.rowHeaders=[];
this.colHeaders=[];b(this.rowHeaders,{},this.rows,this.dataIndexByRows);b(this.colHeaders,{},this.columns,this.dataIndexByCols);return{rowHeaders:this.rowHeaders,colHeaders:this.colHeaders}};b.prototype.makeFormatters=function(){var a,b,d,k,l,n,p;n=this.spec.values;p=[];k=0;for(l=n.length;k<l;k++)d=n[k],p.push(c.parser.unbracket(d["var"]));d={};l=0;for(n=p.length;l<n;l++)k=p[l],d[k]=k in this.spec.formatter?this.spec.formatter[k]:(b=c.format.getExp(_.min(_.pluck(this.statData,k))),a=b,c.format.number(a));
p=this.columns.concat(this.rows);a=0;for(b=p.length;a<b;a++)k=p[a],k in this.spec.formatter&&(d[k]=this.spec.formatter[k]);return d};b.prototype.get=function(a,b,c){var d,l,n,p,r;l=this.dataIndexByRows;r=this.rows;n=0;for(p=r.length;n<p;n++)d=r[n],d=this.ticks[d].ticks[a[d]].location,null!=l&&null!=l[d]&&(l=l[d]);p=this.columns;a=0;for(n=p.length;a<n;a++)d=p[a],d=this.ticks[d].ticks[b[d]].location,null!=l&&null!=l[d]&&(l=l[d]);if(null!=l&&null!=l[c])return l[c]};return b}();n=function(){function b(a,
b,h){this.callback=b;this.prepare=h;this.render=d(this.render,this);this.generateTicks=d(this.generateTicks,this);if(null==a)throw c.error.defn("No pivot table specification is passed in!");this.make(a)}b.prototype.make=function(a){this.spec=l(a);return(new c.DataProcess(this.spec,[],this.spec.strict,c.spec.pivotToData)).make(this.spec,[],this.render)};b.prototype.generateTicks=function(a,b,d){var k,l,n,p,r,f,g,q,s,v,D;f={};v=["rows","columns"];g=0;for(q=v.length;g<q;g++)for(k=v[g],D=a[k],k=0,s=D.length;k<
s;k++)r=D[k],r=c.parser.unbracket(r["var"]),p=d[r],n=_.pluck(b,r),n=c.domain.single(n,d[r],{}),p="cat"===p.type?{ticks:n.levels}:"num"===p.type?{numticks:(n.max-n.min)/p.bw}:(l=c["const"].approxTimeInSeconds[p.bw],{numticks:(n.max-n.min)/l}),n=c.tick.make(n,p,d[r].type),f[r]=n;return f};b.prototype.render=function(a,b,d){var k,l,n,p,r,f,g,q,u,v,D,C;a=this.generateTicks(this.spec,b,d);b=new s(b,a,this.spec);d=b.makeHeaders();a=d.rowHeaders;d=d.colHeaders;g=b.makeFormatters();k=this.spec.columns.length;
l=this.spec.rows.length;n=this.spec.values.length;if(!$)throw c.error.depn("Pivot Tables require jQuery!");C=$("<table></table>").attr("border","1px solid black");C.attr("cellspacing",0);C.attr("cellpadding",0);for(q=0;q<k;){D=$("<tr></tr>");r=c.parser.unbracket(this.spec.columns[q]["var"]);0===q&&1<l&&(u=$("<td></td>"),u.attr("rowspan",k),u.attr("colspan",l-1),D.append(u));D.append($("<th>"+r+":</th>").attr("align","right"));for(u=0;u<d.length;){p=d[u][r];for(f=1;u+f<d.length&&p===d[u+f][r];)f++;
g[r]&&(p=g[r](p));p=$("<td class='heading'>"+p+"</td>").attr("colspan",f*n);p.attr("align","center");D.append(p);u+=f}C.append(D);q++}D=$("<tr></tr>");0===l&&(u=$("<td class='spacing'></td>"),u.attr("rowspan",a.length+1),D.append(u));for(q=0;q<l;)r=c.parser.unbracket(this.spec.rows[q]["var"]),D.append($("<th>"+r+"</th>").attr("align","center")),q++;for(q=0;q<d.length;){k=this.spec.values;u=0;for(r=k.length;u<r;u++)p=k[u],p=$("<td class='heading'>"+c.parser.unbracket(p["var"])+"</td>"),p.attr("align",
"center"),D.append(p);q++}C.append(D);for(q=0;q<a.length;){D=$("<tr></tr>");l=this.spec.rows;u=0;for(k=l.length;u<k;u++)if(r=l[u],r=c.parser.unbracket(r["var"]),p=a[q][r],0===q||p!==a[q-1][r]){for(n=1;q+n<a.length&&p===a[q+n][r];)n++;g[r]&&(p=g[r](p));p=$("<td class='heading'>"+p+"</td>").attr("rowspan",n);p.attr("align","center");p.attr("valign","middle");D.append(p)}for(u=0;u<d.length;){r=d[u];k=a[q];f=this.spec.values;l=0;for(n=f.length;l<n;l++)p=f[l],v=c.parser.unbracket(p["var"]),p=(p=b.get(k,
r,v))?g[v](p):"-",D.append($("<td class='value'>"+p+"</td>").attr("align","right"));u++}C.append(D);q++}this.prepare&&this.prepare(this);this.spec.width&&C.attr("width",this.spec.width);this.spec.height&&C.attr("height",this.spec.height);this.dom=_.isString(this.spec.dom)?$("#"+this.spec.dom):$(this.spec.dom);this.dom.empty();this.dom.append(C);if(this.callback)return this.callback(null,this)};return b}();c.pivot=function(b,a,c){return new n(b,a,c)}}).call(this);(function(){var n,s,l=function(b,a){return function(){return b.apply(a,
arguments)}},d=[].indexOf||function(b){for(var a=0,c=this.length;a<c;a++)if(a in this&&this[a]===b)return a;return-1};s=function(b){_.isString(b.value)&&(b.value={"var":b.value});return b};n=function(){function b(a,b,d){this.render=l(this.render,this);this.handleEvent=l(this.handleEvent,this);if(null==a)throw c.error.defn("No numeral specification is passed in!");this.handlers=[];this.callback=b;this.prepare=d;this.make(a)}b.prototype.make=function(a){if(!a.value)throw c.error.defn("No value defined in numeral.");
this.spec=s(a);return(new c.DataProcess(this.spec,[],this.spec.strict,c.spec.numeralToData)).make(this.spec,[],this.render)};b.prototype.handleEvent=function(a){var b;b=this;return _.throttle(function(d){var k,l,n,p,r;"guide-title"===a&&(d=c.event.make(a,this),d.dispatch(b.dom));p=b.handlers;r=[];l=0;for(n=p.length;l<n;l++)k=p[l],_.isFunction(k)?r.push(k(a,this,d,b)):r.push(k.handle(a,this,d,b));return r},300)};b.prototype.addHandler=function(a){if(0>d.call(this.handlers,a))return this.handlers.push(a)};
b.prototype.render=function(a,b,d){var k,l,n,p;if(null!=a)console.error(a);else{a=c.parser.normalize(this.spec.value["var"]);this.value=b[0][a];this.title=null!=(n=this.spec.title)?n:a;b=0<(l=this.value)&&1>l?void 0:0===this.value%1?0:-1;this.value=c.format.number(b)(this.value);if(_.isNaN(this.value)||"NaN"===this.value)this.value="Not a Number";null!=this.prepare&&this.prepare(this);this.dom=this.spec.dom;this.width=null!=(k=this.spec.width)?k:200;this.height=null!=(p=this.spec.height)?p:100;null==
this.paper&&(this.paper=this._makePaper(this.dom,this.width,this.height,this));null==this.titleObj&&(this.titleObj=this.paper.text(this.width/2,10,""));this.titleObj.attr({text:this.title,"font-size":"12px"});this.titleObj.click(this.handleEvent("guide-title"));this.titleObj.hover(this.handleEvent("tover"),this.handleEvent("tout"));null==this.textObj&&(this.textObj=this.paper.text(this.width/2,this.height/2,""));this.textObj.attr({x:this.width/2,y:7+this.height/2,text:this.value});k=this.textObj.getBBox();
l=k.width;k=k.height;l=Math.min(0.9*this.width/l,0.9*(this.height-14)/k);this.textObj.transform("s"+l);this.callback&&this.callback(null,this)}};b.prototype._makePaper=function(a,b,d,k){return c.paper(a,b,d,{numeral:k},!1)};return b}();c.numeral=function(b,a,d){try{return new n(b,a,d)}catch(h){console.log(h);if(null!=a)return a(h,null);throw c.error.defn("Bad specification.");}}}).call(this);(function(){var n,s,l,d={}.hasOwnProperty,b=function(a,b){function c(){this.constructor=a}for(var k in b)d.call(b,
k)&&(a[k]=b[k]);c.prototype=b.prototype;a.prototype=new c;a.__super__=b.prototype;return a};s=function(){function a(a,b,c){null==a&&(a="polyjsEvent");this.eventName=a;this.cancelable=this.bubbles=!0;this.detail={type:c,data:b}}a.prototype.dispatch=function(a){var b;b=new CustomEvent(this.eventName,{detail:this.detail});if(null!=a)return a.dispatchEvent(b)};return a}();l=function(a){function c(a,b){c.__super__.constructor.call(this,"title-click",a,b)}b(c,a);return c}(s);n=function(a){function c(a,
b){c.__super__.constructor.call(this,"legend-click",a,b)}b(c,a);return c}(s);c.event={};c.event.make=function(a,b){if("guide-title"===a||"guide-titleH"===a||"guide-titleV"===a)return new l(b,a);if("legend-label"===a||"legend-title"===a)return new n(b,a);throw c.error.defn("No such event "+a+".");}}).call(this);(function(){var n,s=function(c,b){return function(){return c.apply(b,arguments)}},l=[].indexOf||function(c){for(var b=0,a=this.length;b<a;b++)if(b in this&&this[b]===c)return b;return-1};n=
function(){function d(b,a,d){null==a&&(a=null);null==d&&(d=null);this.handleEvent=s(this.handleEvent,this);this.render=s(this.render,this);this.mergeDomains=s(this.mergeDomains,this);this.merge=s(this.merge,this);this.maybeDispose=s(this.maybeDispose,this);if(null==b)throw c.error.defn("No graph specification is passed in!");this.handlers=[];this.coord=this.paper=this.dims=this.legends=this.axes=this.scaleSet=null;this.facet=c.facet.make();this.dataSubscribed=[];this.callback=a;this.prepare=d;this.showTooltip=
!(null!=b.tooltip&&!b.tooltip);this.showZoom=!(null!=b.zoom&&!b.zoom);this.make(b);this.showTooltip&&this.addHandler(c.handler.tooltip());this.showZoom&&this.addHandler(c.handler.zoom(b))}d.prototype.maybeDispose=function(b){var a;a=c.render(this.handleEvent,this.paper,this.scaleSet.scales,this.coord);a=a();if(this.coord&&!_.isEqual(this.coord.spec,b.coord))return this.scaleSet&&(this.scaleSet.disposeGuides(a),this.scaleSet=null),this.coord=null};d.prototype.make=function(b){var a,d,h,k,l,n,p,r,f,
g=this;null!=b?(b=c.spec.toStrictMode(b),c.spec.check(b),this.spec=b):b=this.spec;this.scaleSet&&this.maybeDispose(b);null==this.coord&&(this.coord=c.coord.make(this.spec.coord));this.facet.make(b);d=this.handleEvent("data");h=function(){var a,c,d,e;d=b.layers;e=[];k=a=0;for(c=d.length;a<c;k=++a)l=d[k],e.push(l.data);return e}();f=_.difference(h,this.dataSubscribed);p=0;for(r=f.length;p<r;p++)a=f[p],a.subscribe(d);this.dataSubscribed=h;n=_.after(b.layers.length,this.merge);this.dataprocess={};this.processedData=
{};return _.each(b.layers,function(a,d){var e;b=g.spec.layers[d];e=_.values(g.facet.specgroups);g.dataprocess[d]=new c.DataProcess(b,e,b.strict);return g.dataprocess[d].make(b,e,function(a,b,e){if(null!=a)if(console.error(a),null!=g.callback)g.callback(a,null);else throw c.error.defn("Error processing data!");g.processedData[d]={statData:b,metaData:e};return n()})})};d.prototype.merge=function(){var b=this;this.layers=_.map(this.spec.layers,function(a){return c.layer.make(a,b.spec.strict,b.spec.guides)});
this.facet.calculate(this.processedData,this.layers);this.mergeDomains();return this.render()};d.prototype.mergeDomains=function(){var b,a,d;b=_.map(this.facet.panes,function(a){return a.domains});b=c.domain.merge(b);this.scaleSet||(a=c.dim.guess(this.spec,this.facet.getGrid()),this.coord.make(a),d=this.coord.ranges(),this.scaleSet=c.scaleset(d,this.coord));this.scaleSet.make(this.spec.guides,b,this.layers);this.dims=this._makeDimensions(this.spec,this.scaleSet,this.facet,a);this.coord.make(this.dims);
this.ranges=this.coord.ranges();return this.scaleSet.setRanges(this.ranges)};d.prototype.render=function(){var b,a;if(null==this.spec.render||!1!==this.spec.render)if(b=this.scaleSet.scales,this.coord.setScales(b),this.scaleSet.coord=this.coord,a=this.scaleSet.makeGuides(this.spec,this.dims),this.axes=a.axes,this.titles=a.titles,this.legends=a.legends,null!=this.prepare&&this.prepare(this),this.dom=this.spec.dom,null==this.paper&&(this.paper=this._makePaper(this.dom,this.dims.width,this.dims.height,
this)),b=c.render(this.handleEvent,this.paper,b,this.coord),this.facet.render(b,this.dims,this.coord),this.scaleSet.renderGuides(this.dims,b,this.facet),null!=this.callback)return this.callback(null,this)};d.prototype.addHandler=function(b){if(0>l.call(this.handlers,b))return this.handlers.push(b)};d.prototype.removeHandler=function(b){return this.handlers.splice(_.indexOf(this.handlers,b),1)};d.prototype.handleEvent=function(b){var a;a=this;return _.throttle(function(d){var h,k,l,n,p;if("touchstart"===
b||"touchmove"===b||"touchend"===b||"touchcancel"===b)c.touch(b,this,d,a);else if("select"===b){k=d.start;h=d.end;k=a.facet.getFacetInfo(a.dims,k.x,k.y);if(!k)return;n=k.col;p=k.row;l=k.adjusted;k=_.clone(l);l=a.facet.getFacetInfo(a.dims,h.x,h.y,{col:n,row:p}).adjusted;h=_.clone(l);this.evtData="cartesian"===a.coord.type?a.scaleSet.fromPixels(k,h):null}else if("data"===b)this.evtData={};else if("reset"===b||"click"===b||"mover"===b||"mout"===b||"tover"===b||"tout"===b||"gover"===b||"gout"===b||"guide-click"===
b)this.tooltip=this.data("t"),this.evtData=this.data("e"),"guide-click"===b&&"text"===this.type&&null!=this.evtData&&(d="legendTitle"===this.evtData.value?c.event.make("legend-title",this):c.event.make("legend-label",this),d.dispatch(a.dom));else if("guide-title"===b||"guide-titleH"===b||"guide-titleV"===b)this.tooltip=this.data("t"),this.evtData=this.data("e"),d=c.event.make(b,this),d.dispatch(a.dom);p=a.handlers;l=[];k=0;for(n=p.length;k<n;k++)h=p[k],_.isFunction(h)?l.push(h(b,this,d,a)):l.push(h.handle(b,
this,d,a));return l},300)};d.prototype._makeScaleSet=function(b,a,d){b=this.coord.ranges();return c.scaleset(b,this.coord)};d.prototype._makeDimensions=function(b,a,d,h){a.makeGuides(b,h);return c.dim.make(b,a,d.getGrid())};d.prototype._makePaper=function(b,a,d,h){return c.paper(b,a,d,{graph:h},this.showZoom)};return d}();c.chart=function(d,b,a,e){null==e&&(e=!0);if(e)return new n(d,b,a);try{return new n(d,b,a)}catch(h){if(null!=b)return b(h,null);throw c.error.defn("Bad specification.");}}}).call(this)}return{data:c.data,
chart:c.chart,pivot:c.pivot,numeral:c.numeral,handler:c.handler,parser:{bracket:c.parser.bracket,unbracket:c.parser.unbracket,parse:c.parser.parse,getExpression:c.parser.getExpression,escape:c.parser.escape,unescape:c.parser.unescape},debug:c}}(window.polyjs);