forked from mbostock/protovis
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathprotovis-r3.3.js
More file actions
455 lines (455 loc) · 188 KB
/
protovis-r3.3.js
File metadata and controls
455 lines (455 loc) · 188 KB
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
/*!
* Copyright 2002 - 2018 Webdetails, a Hitachi Vantara company. All rights reserved.
*
* This software was developed by Webdetails and is provided under the terms
* of the Mozilla Public License, Version 2.0, or any later version. You may not use
* this file except in compliance with the license. If you need a copy of the license,
* please go to http://mozilla.org/MPL/2.0/. The Initial Developer is Webdetails.
*
* Software distributed under the Mozilla Public License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
* the license for the specific language governing your rights and limitations.
*/
/*! Copyright 2010 Stanford Visualization Group, Mike Bostock, BSD license. */
/*! 4cffbc5 */
var a;if(!Array.prototype.map)Array.prototype.map=function(b,c){for(var e=this.length,d=new Array(e),f=0;f<e;f++)if(f in this)d[f]=b.call(c,this[f],f,this);return d};if(!Array.prototype.filter)Array.prototype.filter=function(b,c){for(var e=this.length,d=[],f=0;f<e;f++)if(f in this){var g=this[f];b.call(c,g,f,this)&&d.push(g)}return d};if(!Array.prototype.forEach)Array.prototype.forEach=function(b,c){for(var e=this.length>>>0,d=0;d<e;d++)d in this&&b.call(c,this[d],d,this)};
if(!Array.prototype.reduce)Array.prototype.reduce=function(b,c){var e=this.length;if(!e&&arguments.length==1)throw new Error("reduce: empty array, no initial value");var d=0;if(arguments.length<2)for(;;){if(d in this){c=this[d++];break}if(++d>=e)throw new Error("reduce: no values, no initial value");}for(;d<e;d++)if(d in this)c=b(c,this[d],d,this);return c};
if(!Array.prototype.indexOf)Array.prototype.indexOf=function(b,c){var e=this.length>>>0;for(c=!isFinite(c)||c<0?0:c>this.length?this.length:c;c<e;c++)if(this[c]===b)return c;return-1};if(!Date.now)Date.now=function(){return+new Date};if(!Object.create)Object.create=function(b){function c(){}c.prototype=b;return new c};var pv={};pv.version={major:3,minor:3};pv.identity=function(b){return b};pv.index=function(){return this.index};pv.child=function(){return this.childIndex};pv.parent=function(){return this.parent.index};
(function(){pv.extend=function(g){return Object.create(g.prototype||g)};pv.extendType=function(g,h){return(g.prototype=pv.extend(h)).constructor=g};pv.parse=function(g){for(var h=new RegExp("function\\s*(\\b\\w+)?\\s*\\([^)]*\\)\\s*","mg"),i=0,j="",k,n;k=h.exec(g);){k=k.index+k[0].length;if(g.charAt(k)!="{"){j+=g.substring(i,k)+"{return ";i=k;for(var o=0;o>=0&&k<g.length;k++){var r=g.charAt(k);switch(r){case '"':case "'":for(;++k<g.length&&(n=g.charAt(k))!=r;)n=="\\"&&k++;break;case "[":case "(":o++;
break;case "]":case ")":o--;break;case ";":case ",":o==0&&o--;break}}j+=pv.parse(g.substring(i,--k))+";}";i=k}h.lastIndex=k}j+=g.substring(i);return j};pv.error=function(g){typeof console==="undefined"||!console.error?alert(g):console.error(g)};pv.listen=function(g,h,i){i=pv.listener(i);if(h==="load"||h==="onload")return pv.listenForPageLoad(i);if(g.addEventListener)g.addEventListener(h,i,false);else{if(g===window)g=document.documentElement;g.attachEvent("on"+h,i)}return i};pv.unlisten=function(g,
h,i){if(i.$listener)i=i.$listener;g.removeEventListener?g.removeEventListener(h,i,false):g.detachEvent("on"+h,i)};pv.listenForPageLoad=function(g){if(document.readyState==="complete")g(null);else if(document.addEventListener)window.addEventListener("load",g,false);else document.attachEvent&&window.attachEvent("onload",g)};pv.listener=function(g){return g.$listener||(g.$listener=function(h){try{pv.event=h=h&&pv.fixEvent(h);return g.call(this,h)}catch(i){pv.error(i)}finally{delete pv.event}})};pv.fixEvent=
function(g){if(g.pageX==null&&g.clientX!=null){var h=g.target&&g.target.ownerDocument||document,i=h.documentElement;h=h.body;g.pageX=g.clientX*1+(i&&i.scrollLeft||h&&h.scrollLeft||0)-(i&&i.clientLeft||h&&h.clientLeft||0);g.pageY=g.clientY*1+(i&&i.scrollTop||h&&h.scrollTop||0)-(i&&i.clientTop||h&&h.clientTop||0)}return g};pv.ancestor=function(g,h){for(;h;){if(h===g)return true;h=h.parentNode}return false};pv.removeChildren=function(g){for(;g.lastChild;)g.removeChild(g.lastChild)};pv.getWindow=function(g){return g!=
null&&g==g.window?g:g.nodeType===9?g.defaultView||g.parentWindow:false};var b=/\-([a-z])/g;pv.hiphen2camel=function(g){if(b.test(g))return g.replace(b,function(h,i){return i.toUpperCase()});return g};var c=window.getComputedStyle;pv.css=function(g,h){return c?c.call(window,g,null).getPropertyValue(h):g.currentStyle[h==="float"?"styleFloat":pv.hiphen2camel(h)]};pv.cssStyle=function(g){var h;if(c){h=c.call(window,g,null);return function(i){return h.getPropertyValue(i)}}h=g.currentStyle;return function(i){return h[i===
"float"?"styleFloat":pv.hiphen2camel(i)]}};pv._getElementsByClass=function(g,h){if(h==null)h=document;var i=[];h=h.getElementsByTagName("*");var j=h.length;g=new RegExp("(^|\\s)"+g+"(\\s|$)");for(var k=0,n=0;k<j;k++)if(g.test(h[k].className)){i[n]=h[k];n++}return i};pv.getElementsByClassName=function(g,h){return g.getElementsByClassName?g.getElementsByClassName(h):pv._getElementsByClass(h,g)};pv.elementOffset=function(g){var h=g&&g.ownerDocument;if(h){var i=h.body;if(i!==g){var j;j=typeof g.getBoundingClientRect!==
"undefined"?g.getBoundingClientRect():{top:0,left:0};var k=pv.getWindow(h);h=h.documentElement;return{top:j.top+(k.pageYOffset||h.scrollTop)-(h.clientTop||i.clientTop||0)-(g.scrollTop||0),left:j.left+(k.pageXOffset||h.scrollLeft)-(h.clientLeft||i.clientLeft||0)-(g.scrollLeft||0)}}}};pv.renderer=function(){var g=document.svgImplementation||"nativesvg";pv.renderer=function(){return g};return g};var e=1;pv.id=function(){return e++};pv.functor=function(g){return typeof g==="function"?g:function(){return g}};
pv.stringLowerCase=function(g){return String(g).toLowerCase()};pv.get=function(g,h,i){var j;return g&&(j=g[h])!=null?j:i};var d=Object.prototype.hasOwnProperty;pv.lazyArrayOwn=function(g,h){var i;return g&&d.call(g,h)&&(i=g[h])?i:(g[h]=[])};pv.parseNumNonNeg=function(g,h){if(g!=null)if(typeof g==="string")g=+g;else if(typeof g!=="number")g=null;return g==null||isNaN(g)||g<0?h==null?0:h:g};var f=pv.epsilon=1.0E-6;pv.floatLess=function(g,h){return!pv.floatEqual(g,h)&&g<h};pv.floatLessOrEqual=function(g,
h){return g<h||pv.floatEqual(g,h)};pv.floatGreater=function(g,h){return!pv.floatEqual(g,h)&&g>h};pv.floatEqual=function(g,h){return Math.abs(h-g)<f};pv.floatZero=function(g){return Math.abs(g)<f};pv.floatBelongsOpen=function(g,h,i){return pv.floatLess(g,h)&&pv.floatLess(h,i)};pv.floatBelongsClosed=function(g,h,i){return pv.floatLessOrEqual(g,h)&&pv.floatLessOrEqual(h,i)}})();
pv.listen(window,"load",function(){pv.$={i:0,x:document.getElementsByTagName("script")};for(pv.$.xlen=pv.$.x.length;pv.$.i<pv.$.xlen;pv.$.i++){pv.$.s=pv.$.x[pv.$.i];if(pv.$.s.type=="text/javascript+protovis")try{window.eval(pv.parse(pv.$.s.text))}catch(b){pv.error(b)}}delete pv.$});pv.Format={};pv.Format.re=function(b){return b.replace(/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g,"\\$&")};pv.Format.pad=function(b,c,e){c=c-String(e).length;return c<1?e:(new Array(c+1)).join(b)+e};
pv.Format.date=function(b){function c(d){return b.replace(/%[a-zA-Z0-9]/g,function(f){switch(f){case "%a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][d.getDay()];case "%A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][d.getDay()];case "%h":case "%b":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][d.getMonth()];case "%B":return["January","February","March","April","May","June","July","August","September","October","November","December"][d.getMonth()];
case "%c":return d.toLocaleString();case "%C":return e("0",2,Math.floor(d.getFullYear()/100)%100);case "%d":return e("0",2,d.getDate());case "%x":case "%D":return e("0",2,d.getMonth()+1)+"/"+e("0",2,d.getDate())+"/"+e("0",2,d.getFullYear()%100);case "%e":return e(" ",2,d.getDate());case "%H":return e("0",2,d.getHours());case "%I":return(f=d.getHours()%12)?e("0",2,f):12;case "%m":return e("0",2,d.getMonth()+1);case "%M":return e("0",2,d.getMinutes());case "%n":return"\n";case "%p":return d.getHours()<
12?"AM":"PM";case "%T":case "%X":case "%r":f=d.getHours()%12;return(f?e("0",2,f):12)+":"+e("0",2,d.getMinutes())+":"+e("0",2,d.getSeconds())+" "+(d.getHours()<12?"AM":"PM");case "%R":return e("0",2,d.getHours())+":"+e("0",2,d.getMinutes());case "%S":return e("0",2,d.getSeconds());case "%Q":return e("0",3,d.getMilliseconds());case "%t":return"\t";case "%u":return(f=d.getDay())?f:1;case "%w":return d.getDay();case "%y":return e("0",2,d.getFullYear()%100);case "%Y":return d.getFullYear();case "%%":return"%"}return f})}
var e=pv.Format.pad;c.format=c;c.parse=function(d){var f=1970,g=0,h=1,i=0,j=0,k=0,n=[function(){}],o=pv.Format.re(b).replace(/%[a-zA-Z0-9]/g,function(r){switch(r){case "%b":n.push(function(l){g={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11}[l]});return"([A-Za-z]+)";case "%h":case "%B":n.push(function(l){g={January:0,February:1,March:2,April:3,May:4,June:5,July:6,August:7,September:8,October:9,November:10,December:11}[l]});return"([A-Za-z]+)";case "%e":case "%d":n.push(function(l){h=
l});return"([0-9]+)";case "%I":case "%H":n.push(function(l){i=l});return"([0-9]+)";case "%m":n.push(function(l){g=l-1});return"([0-9]+)";case "%M":n.push(function(l){j=l});return"([0-9]+)";case "%p":n.push(function(l){if(i==12){if(l=="am")i=0}else if(l=="pm")i=Number(i)+12});return"(am|pm)";case "%S":n.push(function(l){k=l});return"([0-9]+)";case "%y":n.push(function(l){l=Number(l);f=l+(0<=l&&l<69?2E3:l>=69&&l<100?1900:0)});return"([0-9]+)";case "%Y":n.push(function(l){f=l});return"([0-9]+)";case "%%":n.push(function(){});
return"%"}return r});(d=d.match(o))&&d.forEach(function(r,l){n[l](r)});return new Date(f,g,h,i,j,k)};return c};
pv.Format.time=function(b){function c(d){d=Number(d);switch(b){case "short":if(d>=31536E6)return(d/31536E6).toFixed(1)+" years";else if(d>=6048E5)return(d/6048E5).toFixed(1)+" weeks";else if(d>=864E5)return(d/864E5).toFixed(1)+" days";else if(d>=36E5)return(d/36E5).toFixed(1)+" hours";else if(d>=6E4)return(d/6E4).toFixed(1)+" minutes";return(d/1E3).toFixed(1)+" seconds";case "long":var f=[],g=d%36E5/6E4>>0;f.push(e("0",2,d%6E4/1E3>>0));if(d>=36E5){var h=d%864E5/36E5>>0;f.push(e("0",2,g));if(d>=864E5){f.push(e("0",
2,h));f.push(Math.floor(d/864E5).toFixed())}else f.push(h.toFixed())}else f.push(g.toFixed());return f.reverse().join(":")}}var e=pv.Format.pad;c.format=c;c.parse=function(d){switch(b){case "short":for(var f=/([0-9,.]+)\s*([a-z]+)/g,g,h=0;g=f.exec(d);){var i=parseFloat(g[0].replace(",","")),j=0;switch(g[2].toLowerCase()){case "year":case "years":j=31536E6;break;case "week":case "weeks":j=6048E5;break;case "day":case "days":j=864E5;break;case "hour":case "hours":j=36E5;break;case "minute":case "minutes":j=
6E4;break;case "second":case "seconds":j=1E3;break}h+=i*j}return h;case "long":g=d.replace(",","").split(":").reverse();h=0;if(g.length)h+=parseFloat(g[0])*1E3;if(g.length>1)h+=parseFloat(g[1])*6E4;if(g.length>2)h+=parseFloat(g[2])*36E5;if(g.length>3)h+=parseFloat(g[3])*864E5;return h}};return c};
pv.Format.number=function(){function b(p){if(Infinity>g)p=Math.round(p*h)/h;var q=String(Math.abs(p)).split("."),t=q[0];if(t.length>e)t=t.substring(t.length-e);if(k&&t.length<c)t=(new Array(c-t.length+1)).join(i)+t;if(t.length>3)t=t.replace(/\B(?=(?:\d{3})+(?!\d))/g,o);if(!k&&t.length<d)t=(new Array(d-t.length+1)).join(i)+t;q[0]=p<0?r+t+l:t;p=q[1]||"";if(p.length>g)p=q[1]=p.substr(0,g);if(p.length<f)q[1]=p+(new Array(f-p.length+1)).join(j);return q.join(n)}var c=0,e=Infinity,d=0,f=0,g=0,h=1,i="0",
j="0",k=true,n=".",o=",",r="\u2212",l="";b.format=b;b.parse=function(p){var q=pv.Format.re;p=String(p).split(n);if(p.length==1)p[1]="";p[0].replace(new RegExp("^("+q(i)+")*"),"");p[1].replace(new RegExp("("+q(j)+")*$"),"");q=p[0].replace(new RegExp(q(o),"g"),"");if(q.length>e)q=q.substring(q.length-e);p=p[1]?Number("0."+p[1]):0;if(Infinity>g)p=Math.round(p*h)/h;return Math.round(q)+p};b.integerDigits=function(p,q){if(arguments.length){c=Number(p);e=arguments.length>1?Number(q):c;d=c+Math.floor(c/
3)*o.length;return this}return[c,e]};b.fractionDigits=function(p,q){if(arguments.length){f=Number(p);g=arguments.length>1?Number(q):f;h=Math.pow(10,g);return this}return[f,g]};b.integerPad=function(p){if(arguments.length){i=String(p);k=/\d/.test(i);return this}return i};b.fractionPad=function(p){if(arguments.length){j=String(p);return this}return j};b.decimal=function(p){if(arguments.length){n=String(p);return this}return n};b.group=function(p){if(arguments.length){o=p?String(p):"";d=c+Math.floor(c/
3)*o.length;return this}return o};b.negativeAffix=function(p,q){if(arguments.length){r=String(p||"");l=String(q||"");return this}return[r,l]};return b};
(function(){var b;pv.Text={};pv.Text.createCache=function(){return new c};pv.Text.usingCache=function(d,f,g){if(!(d instanceof c))throw new Error("Not a valid cache.");var h=b;b=d;try{return f.call(g)}finally{b=h}};pv.Text.measure=function(d,f){d=d==null?"":String(d);var g=b&&b.get(f,d);if(!g){g=d?this.measureCore(d,f):{width:0,height:0};b&&b.put(f,d,g)}return g};pv.Text.measureWidth=function(d,f){return pv.Text.measure(d,f).width};pv.Text.fontHeight=function(d){return pv.Text.measure("M",d).height};
pv.Text.measureCore=function(){function d(){return g||(g=f())}function f(){var i=document.createElement("div");i.id="pvSVGText_"+(new Date).getTime();var j=i.style;j.position="absolute";j.visibility="hidden";j.width=0;j.height=0;j.left=0;j.top=0;j.lineHeight=1;j.textTransform="none";j.letterSpacing="normal";j.whiteSpace="nowrap";j=pv.SvgScene.create("svg");j.setAttribute("font-size","10px");j.setAttribute("font-family","sans-serif");i.appendChild(j);var k=pv.SvgScene.create("text");j.appendChild(k);
k.appendChild(document.createTextNode(""));document.body.appendChild(i);return k}var g,h="10px sans-serif";return function(i,j){j||(j=null);var k=d();if(h!==j){h=j;pv.SvgScene.setStyle(k,{font:j})}k.firstChild.nodeValue=String(i);var n;try{n=k.getBBox()}catch(o){typeof console.error==="function"&&console.error("GetBBox failed: ",o);throw o;}return{width:n.width,height:n.height}}}();var c=function(){this._fontsCache={}},e=Object.prototype.hasOwnProperty;c.prototype._getFont=function(d){d=d||"";return e.call(this._fontsCache,
d)?this._fontsCache[d]:(this._fontsCache[d]={})};c.prototype.get=function(d,f){f=f||"";d=this._getFont(d);return e.call(d,f)?d[f]:null};c.prototype.put=function(d,f,g){return this._getFont(d)[f||""]=g}})();pv.map=function(b,c){var e={};return c?b.map(function(d,f){e.index=f;return c.call(e,d)}):b.slice()};pv.repeat=function(b,c){if(arguments.length==1)c=2;return pv.blend(pv.range(c).map(function(){return b}))};
pv.array=function(b,c){var e=b>=0?new Array(b):[];if(c!==undefined)for(var d=0;d<b;d++)e[d]=c;return e};pv.cross=function(b,c){for(var e=[],d=0,f=b.length,g=c.length;d<f;d++)for(var h=0,i=b[d];h<g;h++)e.push([i,c[h]]);return e};pv.blend=function(b){return Array.prototype.concat.apply([],b)};
pv.transpose=function(b){var c=b.length,e=pv.max(b,function(h){return h.length});if(e>c){b.length=e;for(var d=c;d<e;d++)b[d]=new Array(c);for(d=0;d<c;d++)for(var f=d+1;f<e;f++){var g=b[d][f];b[d][f]=b[f][d];b[f][d]=g}}else{for(d=0;d<e;d++)b[d].length=c;for(d=0;d<c;d++)for(f=0;f<d;f++){g=b[d][f];b[d][f]=b[f][d];b[f][d]=g}}b.length=e;for(d=0;d<e;d++)b[d].length=c;return b};pv.normalize=function(b,c){b=pv.map(b,c);c=pv.sum(b);for(var e=0;e<b.length;e++)b[e]/=c;return b};
pv.permute=function(b,c,e){if(!e)e=pv.identity;var d=new Array(c.length),f={};c.forEach(function(g,h){f.index=g;d[h]=e.call(f,b[g])});return d};pv.numerate=function(b,c){if(!c)c=pv.identity;var e={},d={};b.forEach(function(f,g){d.index=g;e[c.call(d,f)]=g});return e};pv.uniq=function(b,c){if(!c)c=pv.identity;var e={},d=[],f={},g;b.forEach(function(h,i){f.index=i;g=c.call(f,h);g in e||(e[g]=d.push(g))});return d};pv.naturalOrder=function(b,c){return b<c?-1:b>c?1:0};
pv.reverseOrder=function(b,c){return c<b?-1:c>b?1:0};pv.search=function(b,c,e){if(!e)e=pv.identity;for(var d=0,f=b.length-1;d<=f;){var g=d+f>>1,h=e(b[g]);if(h<c)d=g+1;else if(h>c)f=g-1;else return g}return-d-1};pv.search.index=function(b,c,e){b=pv.search(b,c,e);return b<0?-b-1:b};
pv.range=function(b,c,e){if(arguments.length==1){c=b;b=0}if(e==undefined)e=1;if((c-b)/e==Infinity)throw new Error("range must be finite");var d=[],f=0,g;c-=(c-b)*1.0E-10;if(e<0)for(;(g=b+e*f++)>c;)d.push(g);else for(;(g=b+e*f++)<c;)d.push(g);return d};pv.random=function(b,c,e){if(arguments.length==1){c=b;b=0}if(e==undefined)e=1;return e?Math.floor(Math.random()*(c-b)/e)*e+b:Math.random()*(c-b)+b};
pv.sum=function(b,c){var e={};return b.reduce(c?function(d,f,g){e.index=g;return d+c.call(e,f)}:function(d,f){return d+f},0)};pv.max=function(b,c){if(c==pv.index)return b.length-1;return Math.max.apply(null,c?pv.map(b,c):b)};pv.max.index=function(b,c){if(!b.length)return-1;if(c==pv.index)return b.length-1;if(!c)c=pv.identity;for(var e=0,d=-Infinity,f={},g=0;g<b.length;g++){f.index=g;var h=c.call(f,b[g]);if(h>d){d=h;e=g}}return e};
pv.min=function(b,c){if(c==pv.index)return 0;return Math.min.apply(null,c?pv.map(b,c):b)};pv.min.index=function(b,c){if(!b.length)return-1;if(c==pv.index)return 0;if(!c)c=pv.identity;for(var e=0,d=Infinity,f={},g=0;g<b.length;g++){f.index=g;var h=c.call(f,b[g]);if(h<d){d=h;e=g}}return e};pv.mean=function(b,c){return pv.sum(b,c)/b.length};
pv.median=function(b,c){if(c==pv.index)return(b.length-1)/2;b=pv.map(b,c).sort(pv.naturalOrder);if(b.length%2)return b[Math.floor(b.length/2)];c=b.length/2;return(b[c-1]+b[c])/2};pv.variance=function(b,c){if(b.length<1)return NaN;if(b.length==1)return 0;var e=pv.mean(b,c),d=0,f={};if(!c)c=pv.identity;for(var g=0;g<b.length;g++){f.index=g;var h=c.call(f,b[g])-e;d+=h*h}return d};pv.deviation=function(b,c){return Math.sqrt(pv.variance(b,c)/(b.length-1))};pv.log=function(b,c){return Math.log(b)/Math.log(c)};
pv.logSymmetric=function(b,c){return b==0?0:b<0?-pv.log(-b,c):pv.log(b,c)};pv.logAdjusted=function(b,c){if(!isFinite(b))return b;var e=b<0;if(b<c)b+=(c-b)/c;return e?-pv.log(b,c):pv.log(b,c)};pv.logFloor=function(b,c){return b>0?Math.pow(c,Math.floor(pv.log(b,c))):-Math.pow(c,-Math.floor(-pv.log(-b,c)))};pv.logCeil=function(b,c){return b>0?Math.pow(c,Math.ceil(pv.log(b,c))):-Math.pow(c,-Math.ceil(-pv.log(-b,c)))};
(function(){var b=Math.PI/180,c=180/Math.PI;pv.radians=function(e){return b*e};pv.degrees=function(e){return c*e}})();pv.keys=function(b){var c=[];for(var e in b)c.push(e);return c};pv.entries=function(b){var c=[];for(var e in b)c.push({key:e,value:b[e]});return c};pv.values=function(b){var c=[];for(var e in b)c.push(b[e]);return c};pv.dict=function(b,c){for(var e={},d={},f=0;f<b.length;f++)if(f in b){var g=b[f];d.index=f;e[g]=c.call(d,g)}return e};pv.hasOwnProp=Object.prototype.hasOwnProperty;
pv.copyOwn=function(b,c){if(c){var e=pv.hasOwnProp;for(var d in c)if(e.call(c,d))b[d]=c[d]}return b};pv.dom=function(b){return new pv.Dom(b)};pv.Dom=function(b){this.$map=b};pv.Dom.prototype.$leaf=function(b){return typeof b!="object"};pv.Dom.prototype.leaf=function(b){if(arguments.length){this.$leaf=b;return this}return this.$leaf};
pv.Dom.prototype.root=function(b){function c(f){var g=new pv.Dom.Node;for(var h in f){var i=f[h];g.appendChild(e(i)?new pv.Dom.Node(i):c(i)).nodeName=h}return g}var e=this.$leaf,d=c(this.$map);d.nodeName=b;return d};pv.Dom.prototype.nodes=function(){return this.root().nodes()};pv.Dom.Node=function(b){if(b!==undefined)this.nodeValue=b};a=pv.Dom.Node.prototype;a.nodeValue=undefined;a.childNodes=[];a.parentNode=null;a.firstChild=null;a.lastChild=null;a.previousSibling=null;a.nextSibling=null;
a._firstDirtyChildIndex=Infinity;a._childIndex=-1;a.findChildIndex=function(b){if(!b)throw new Error("Argument 'n' required");if(b.parentNode===this){b=b.childIndex(true);if(b>-1)return b}throw new Error("child not found");};a._childRemoved=function(){};a._childAdded=function(){};a.removeChild=function(b){return this.removeAt(this.findChildIndex(b))};
a.appendChild=function(b){var c=b.parentNode;c&&c.removeChild(b);c=this.lastChild;b.parentNode=this;if(b.previousSibling=c){c.nextSibling=b;b._childIndex=c._childIndex+1}else{this.firstChild=b;b._childIndex=0}this.lastChild=b;c=pv.lazyArrayOwn(this,"childNodes").push(b);this._childAdded(b,c-1);return b};a.insertBefore=function(b,c){if(!c)return this.appendChild(b);c=this.findChildIndex(c);return this.insertAt(b,c)};
a.insertAt=function(b,c){if(c==null)return this.appendChild(b);var e=this.childNodes,d=e.length;if(c===d)return this.appendChild(b);if(c<0||c>d)throw new Error("Index out of range.");(d=b.parentNode)&&d.removeChild(b);d=c+1;if(d<this._firstDirtyChildIndex)this._firstDirtyChildIndex=d;d=e[c];b.parentNode=this;b.nextSibling=d;b._childIndex=c;var f=b.previousSibling=d.previousSibling;d.previousSibling=b;if(f)f.nextSibling=b;else{if(d===this.lastChild)this.lastChild=b;this.firstChild=b}e.splice(c,0,b);
this._childAdded(b,c);return b};a.removeAt=function(b){var c=this.childNodes,e=c.length;if(!(b<0||b>=e)){var d=c[b];c.splice(b,1);if(b<e-1&&b<this._firstDirtyChildIndex)this._firstDirtyChildIndex=b;c=d.previousSibling;e=d.nextSibling;if(c)c.nextSibling=e;else this.firstChild=e;if(e)e.previousSibling=c;else this.lastChild=c;d.nextSibling=d.previousSibling=d.parentNode=null;this._childRemoved(d,b);return d}};
a.replaceChild=function(b,c){var e=this.findChildIndex(c),d=b.parentNode;d&&d.removeChild(b);b.parentNode=this;b.nextSibling=c.nextSibling;b._childIndex=c._childIndex;if(d=b.previousSibling=c.previousSibling)d.nextSibling=b;else this.firstChild=b;if(d=c.nextSibling)d.previousSibling=b;else this.lastChild=b;this.childNodes[e]=b;this._childRemoved(c,e);this._childAdded(b,e);return c};
a.childIndex=function(b){var c=this.parentNode;if(c){var e=c._firstDirtyChildIndex;if(e<Infinity){var d=c.childNodes;if(!b)return d.indexOf(this);for(b=d.length;e<b;){d[e]._childIndex=e;e++}c._firstDirtyChildIndex=Infinity}return this._childIndex}return-1};a.visitBefore=function(b){function c(e,d){b(e,d);for(e=e.firstChild;e;e=e.nextSibling)c(e,d+1)}c(this,0)};a.visitAfter=function(b){function c(e,d){for(var f=e.firstChild;f;f=f.nextSibling)c(f,d+1);b(e,d)}c(this,0)};
a.sort=function(b){if(this.firstChild){this._firstDirtyChildIndex=Infinity;var c=this.childNodes;c.sort(b);var e=this.firstChild=c[0],d;delete e.previousSibling;e._childIndex=0;for(var f=1,g=c.length;f<g;f++){e.sort(b);d=c[f];d._childIndex=f;d.previousSibling=e;e=e.nextSibling=d}this.lastChild=e;delete e.nextSibling;e.sort(b)}return this};
a.reverse=function(){var b=[];this.visitAfter(function(c){this._firstDirtyChildIndex=Infinity;for(var e;e=c.lastChild;)b.push(c.removeChild(e));if(b.length)for(;e=b.pop();)c.insertBefore(e,c.firstChild)});return this};a.nodes=function(){var b=[];this.visitBefore(function(c){b.push(c)});return b};
a.toggle=function(b){if(b)return this.toggled?this.visitBefore(function(e){e.toggled&&e.toggle()}):this.visitAfter(function(e){e.toggled||e.toggle()});var c=this;if(c.toggled){for(;b=c.toggled.pop();)c.appendChild(b);delete c.toggled}else if(b=c.lastChild){c.toggled=[];do c.toggled.push(c.removeChild(b));while(b=c.lastChild)}};pv.nodes=function(b){for(var c=new pv.Dom.Node,e=0,d=b.length;e<d;e++)c.appendChild(new pv.Dom.Node(b[e]));return c.nodes()};pv.tree=function(b){return new pv.Tree(b)};
pv.Tree=function(b){this.array=b};pv.Tree.prototype.keys=function(b){this.k=b;return this};pv.Tree.prototype.value=function(b){this.v=b;return this};pv.Tree.prototype.map=function(){for(var b={},c={},e=0;e<this.array.length;e++){c.index=e;for(var d=this.array[e],f=this.k.call(c,d),g=b,h=0;h<f.length-1;h++)g=g[f[h]]||(g[f[h]]={});g[f[h]]=this.v?this.v.call(c,d):d}return b};pv.nest=function(b){return new pv.Nest(b)};pv.Nest=function(b){this.array=b;this.keys=[]};a=pv.Nest.prototype;
a.key=function(b){this.keys.push(b);return this};a.sortKeys=function(b){this.keys[this.keys.length-1].order=b||pv.naturalOrder;return this};a.sortValues=function(b){this.order=b||pv.naturalOrder;return this};a.map=function(){for(var b={},c=[],e,d=0;d<this.array.length;d++){var f=this.array[d],g=b;for(e=0;e<this.keys.length-1;e++){var h=this.keys[e](f);g[h]||(g[h]={});g=g[h]}h=this.keys[e](f);if(!g[h]){e=[];c.push(e);g[h]=e}g[h].push(f)}if(this.order)for(e=0;e<c.length;e++)c[e].sort(this.order);return b};
a.entries=function(){function b(e){var d=[];for(var f in e){var g=e[f];d.push({key:f,values:g instanceof Array?g:b(g)})}return d}function c(e,d){var f=this.keys[d].order;f&&e.sort(function(h,i){return f(h.key,i.key)});if(++d<this.keys.length)for(var g=0;g<e.length;g++)c.call(this,e[g].values,d);return e}return c.call(this,b(this.map()),0)};a.rollup=function(b){function c(e){for(var d in e){var f=e[d];if(f instanceof Array)e[d]=b(f);else c(f)}return e}return c(this.map())};pv.flatten=function(b){return new pv.Flatten(b)};
pv.Flatten=function(b){this.map=b;this.keys=[]};pv.Flatten.prototype.key=function(b,c){this.keys.push({name:b,value:c});delete this.$leaf;return this};pv.Flatten.prototype.leaf=function(b){this.keys.length=0;this.$leaf=b;return this};
pv.Flatten.prototype.array=function(){function b(h,i){if(i<d.length-1)for(var j in h){e.push(j);b(h[j],i+1);e.pop()}else c.push(e.concat(h))}var c=[],e=[],d=this.keys,f=this.$leaf;if(f){function g(h,i){if(f(h))c.push({keys:e.slice(),value:h});else for(var j in h){e.push(j);g(h[j],i+1);e.pop()}}g(this.map,0);return c}b(this.map,0);return c.map(function(h){for(var i={},j=0;j<d.length;j++){var k=d[j],n=h[j];i[k.name]=k.value?k.value.call(null,n):n}return i})};pv.Transform=function(){};
pv.Transform.prototype={k:1,x:0,y:0};pv.Transform.identity=new pv.Transform;pv.Transform.prototype.translate=function(b,c){var e=new pv.Transform;e.k=this.k;e.x=this.k*b+this.x;e.y=this.k*c+this.y;return e};pv.Transform.prototype.scale=function(b){var c=new pv.Transform;c.k=this.k*b;c.x=this.x;c.y=this.y;return c};pv.Transform.prototype.invert=function(){var b=new pv.Transform,c=1/this.k;b.k=c;b.x=-this.x*c;b.y=-this.y*c;return b};
pv.Transform.prototype.times=function(b){var c=new pv.Transform;c.k=this.k*b.k;c.x=this.k*b.x+this.x;c.y=this.k*b.y+this.y;return c};pv.Scale=function(){};
pv.Scale.interpolator=function(b,c){if(typeof b=="number")return function(f){return f*(c-b)+b};var e=b.type&&b.type!=="solid",d=c.type&&c.type!=="solid";if(e||d){b=e?b:pv.color(b).rgb();c=d?c:pv.color(c).rgb();return function(f){return f<0.5?b:c}}b=pv.color(b).rgb();c=pv.color(c).rgb();return function(f){var g=b.a*(1-f)+c.a*f;if(g<1.0E-5)g=0;return b.a==0?pv.rgb(c.r,c.g,c.b,g):c.a==0?pv.rgb(b.r,b.g,b.b,g):pv.rgb(Math.round(b.r*(1-f)+c.r*f),Math.round(b.g*(1-f)+c.g*f),Math.round(b.b*(1-f)+c.b*f),g)}};
pv.Scale.common={by:function(b){function c(){return e(b.apply(this,arguments))}var e=this;for(var d in e)c[d]=e[d];return c},by1:function(b){function c(f){return e(b.call(this,f))}var e=this;for(var d in e)c[d]=e[d];return c},transform:function(b){function c(){return b.call(this,e.apply(e,arguments))}var e=this;for(var d in e)c[d]=e[d];return c}};
(function(){function b(m,s,u,v){var y=u-s;if(!y||!isFinite(y)){s=[+s];s.step=s.base=s.mult=1;s.decPlaces=0;s.format=pv.Format.number().fractionDigits(0)}else{var z=pv.parseNumNonNeg(pv.get(v,"precision",0)),A=pv.parseNumNonNeg(pv.get(v,"precisionMin",0)),B=pv.parseNumNonNeg(pv.get(v,"precisionMax",Infinity)),D=pv.get(v,"roundInside",true);isFinite(z)||(z=0);isFinite(A)||(A=0);B||(B=Infinity);var G=pv.get(v,"numberExponentMin"),C=pv.get(v,"numberExponentMax");if(G!=null&&isFinite(G))A=Math.max(A,Math.pow(10,
Math.floor(G)));if(C!=null&&isFinite(C))B=Math.min(B,5*Math.pow(10,Math.floor(C)));if(D){if(A>y)A=y;if(B>y)B=y}if(B<A)B=A;if(z)z=Math.max(Math.min(z,B),A);else if(A===B)z=A;G=0;C=!!z;var H,I;if(C){v={base:Math.abs(z),mult:1,value:1};v.value=v.base}else{var J=pv.parseNumNonNeg(pv.get(v,"tickCountMax",Infinity));if(J<1)J=1;if(m==null)m=Math.min(10,J);else if(isFinite(m)){if(m>J)m=J}else m=isFinite(J)?J:10;v={base:isFinite(m)?pv.logFloor(y/m,10):0,mult:1,value:1};v.value=v.base;if(A>0){H=d(A,true);if(v.value<
H.value){c(v,H);G=-1}}if(isFinite(B)){I=d(B,false);if(H&&I.value<=H.value)I=null;else if(I.value<v.value){c(v,I);G=1}}if(G!==1&&isFinite(m)&&v.mult<10){y=y/v.base;if(m<y){m=m/y;if(m<=0.15)v.mult=10;else if(v.mult<5)if(m<=0.35)v.mult=5;else if(v.mult<2)if(m<=0.75)v.mult=2;if(v.mult>1){v.value=v.base*v.mult;if(H&&v.value<H.value){c(v,H);G=-1}else if(I&&I.value<v.value){c(v,I);G=1}else if(v.mult===10){v.base*=10;v.mult=1}}}}}for(var E;;){H=v.value;m=H*Math[D?"ceil":"floor"](s/H);y=H*Math[D?"floor":"ceil"](u/
H);if(E&&(y<m||I&&y-m>I.value)){v=E;break}A=Math.floor(pv.log(H,10)+1.0E-10);v.decPlaces=Math.max(0,-A);v.ticks=pv.range(m,y+H,H);if(C||G>0||v.ticks.length<=J)break;if(E&&E.ticks.length<=v.ticks.length){v=E;break}v=e(E=v)}s=v.ticks;s.step=v.value;s.base=v.base;s.mult=v.mult;s.decPlaces=v.decPlaces;s.format=pv.Format.number().fractionDigits(v.decPlaces)}return s}function c(m,s){m.base=s.base;m.mult=s.mult;m.value=s.value;return m}function e(m){m=c({},m);switch(m.mult){case 5:m.mult=1;m.base*=10;break;
case 2:m.mult=5;break;case 1:m.mult=2;break}m.value=m.base*m.mult;return m}function d(m,s){if(m<0)m=-m;var u=pv.logFloor(m,10),v=m/u;if(s)if(v>5){v=1;u*=10}else v=v>2?5:v>1?2:1;else v=v>=5?5:v>=2?2:1;return{base:u,mult:v,value:u*v,source:m}}function f(m){return new Date(m)}function g(m,s,u,v,y,z,A){var B=u-s;if(!B||!isFinite(B)){m=[f(s)];m.step=m.base=m.mult=1;m.format=pv.Format.date("%x")}else{v=o(pv.get(A,"precision"),v);var D=o(pv.get(A,"precisionMin"),0),G=o(pv.get(A,"precisionMax"),Infinity);
if(G<D)G=D;if(v)v=Math.max(Math.min(v,G),D);else if(D===G)v=D;var C=pv.parseNumNonNeg(pv.get(A,"tickCountMax",Infinity));if(C<2)C=2;m=Math.min(m==null?5:m,C);z={weekStart:z,roundInside:pv.get(A,"roundInside",1),alignmentValue:pv.get(A,"alignmentValue")};v=h(m,B,v,D,G,z);B=v.fixed;D=v.overflow;for(var H;;){v.ticks=m=v.comp.ticks(s,u,v.mult,z);if(H&&v.precMax&&m[m.length-1]-m[0]>v.precMax.value){v=H;break}if(B||D>0||v.ticks.length<=C)break;if(H&&H.ticks.length<=v.ticks.length){v=H;break}H=v;v=v.comp.resultAbove(v.mult)}m=
v.ticks;m.step=v.value;m.base=v.comp.value;m.mult=v.mult;m.format=k(y)||v.comp.format}return m}function h(m,s,u,v,y,z){var A=0,B=1,D=!!u,G,C;if(u){s=i(u,false);if(s.value!==u)m=s.comp.withPrecision(u);else{m=s.comp;B=s.mult}}else{if(isFinite(m)){m=t(s,m);B=m.multiple(s/m.value,z)}else{m=p();B=1}u=m.value*B;if(u<v)G=i(v,true);if(y<u)C=i(y,false);if(G&&u<G.value){m=G.comp;B=G.mult;A=-1}else if(C&&v<C.value&&C.value<u){m=C.comp;B=C.mult;A=+1}}return{comp:m,mult:B,value:m.value*B,source:u,overflow:A,
fixed:D,precMin:G,precMax:C}}function i(m,s){if(m==null||m<=0||!isFinite(m))return null;return(s?p:q)().castValue(m,s)}function j(m,s,u){this.value=m;this.mult=u.mult||1;this.base=this.mult===1?this.value:Math.floor(this.value/this.mult);x.forEach(function(v){if(u[v]!=null)this[v]=u[v]},this);if(u.floor)this.floorLocal=u.floor;this.format=k(u.format);this.first=pv.functor(u.first||0);this.prev=s;this.next=null;if(s)s.next=this}function k(m){return m==null?null:typeof m==="function"?m:pv.Format.date(m)}
function n(m,s){m=new Date(m.getFullYear(),m.getMonth(),1);if(s=s-m.getDay()){if(s<0)s+=7;m.setDate(m.getDate()+s)}return m}function o(m,s){if(typeof m==="string"){var u=+m;if(isNaN(u)){if(m)if(u=/^(\d*)([a-zA-Z]+)$/.exec(m))if(m=r(u[2]))m*=+u[1]||1}else m=u}if(typeof m!=="number"||m<0)m=s!=null?s:0;return m}function r(m){switch(m){case "year":case "y":return 31536E6;case "month":case "m":return 2592E6;case "week":case "w":return 6048E5;case "day":case "d":return 864E5;case "hour":case "h":return 36E5;
case "minute":case "M":return 6E4;case "second":case "s":return 1E3;case "millisecond":case "ms":return 1}}function l(m,s){var u=q();w.push(new j(m,u,s))}function p(){return w[0]}function q(){return w.length?w[w.length-1]:null}function t(m,s){if(s==null)s=1;var u=q(),v;do v=u;while(m<s*v.value&&(u=v.prev));return v}pv.Scale.quantitative=function(){function m(E){var F=pv.search(s,E);if(F<0)F=-F-2;F=Math.max(0,Math.min(y.length-1,F));return y[F]((B(E)-u[F])/(u[F+1]-u[F]))}var s=[0,1],u=[0,1],v=[0,1],
y=[pv.identity],z=Number,A=false,B=pv.identity,D=pv.identity,G=null,C,H,I=0,J;m.transform=function(E,F){B=function(K){return A?-E(-K):E(K)};D=function(K){return A?-F(-K):F(K)};u=s.map(B);return this};m.domain=function(E,F,K){if(arguments.length){var L;if(E instanceof Array){if(arguments.length<2)F=pv.identity;if(arguments.length<3)K=F;L=E.length&&F(E[0]);s=E.length?[pv.min(E,F),pv.max(E,K)]:[]}else{L=E;s=Array.prototype.slice.call(arguments).map(Number)}if(s.length){if(s.length==1)s=[s[0],s[0]]}else s=
[-Infinity,Infinity];A=(s[0]||s[s.length-1])<0;u=s.map(B);z=L instanceof Date?f:Number;return this}return s.map(z)};m.range=function(){if(arguments.length){v=Array.prototype.slice.call(arguments);if(v.length){if(v.length==1)v=[v[0],v[0]]}else v=[-Infinity,Infinity];y=[];for(var E=0;E<v.length-1;E++)y.push(pv.Scale.interpolator(v[E],v[E+1]));return this}return v};m.invert=function(E){var F=pv.search(v,E);if(F<0)F=-F-2;F=Math.max(0,Math.min(y.length-1,F));return z(D(u[F]+(E-v[F])/(v[F+1]-v[F])*(u[F+
1]-u[F])))};m.ticks=function(E,F){var K=s[0],L=s[s.length-1],M=L<K,N=M?L:K;K=M?K:L;J=z===f?g(E,N,K,H,C,I,F):b(E,N,K,F);return M?J.reverse():J};m.dateTickFormat=function(){if(arguments.length){C=arguments[0];return this}return C};m.dateTickPrecision=function(){if(arguments.length){H=o(arguments[0],0);return this}return H};m.dateTickWeekStart=function(E){if(arguments.length){switch((""+E).toLowerCase()){case "0":case "sunday":I=0;break;case "1":case "monday":I=1;break;case "2":case "tuesday":I=2;break;
case "3":case "wednesday":I=3;break;case "4":case "thursday":I=4;break;case "5":case "friday":I=5;break;case "6":case "saturday":I=6;break;default:I=0;break}return this}return I};m.tickFormatter=function(E){if(arguments.length){G=E;return this}return G};m.tickFormat=function(E,F){if(G){if(!J){J=[];J.step=J.base=J.mult=1;J.decPlaces=0;J.format=String}E=G.call(J,E,z!==Number?J.step:J.decPlaces,F!=null?F:-1)}else E=J?J.format(E):String(E);return E};m.nice=function(){if(s.length!=2)return this;var E=
s[0],F=s[s.length-1],K=F<E,L=K?F:E;E=K?E:F;F=E-L;if(!F||!isFinite(F))return this;F=Math.pow(10,Math.round(Math.log(F)/Math.log(10))-1);s=[Math.floor(L/F)*F,Math.ceil(E/F)*F];K&&s.reverse();u=s.map(B);return this};pv.copyOwn(m,pv.Scale.common);m.domain.apply(m,arguments);return m};var x=["get","set","multiple","multiples","thresholds","closeds","castValue"];j.prototype.increment=function(m,s){if(s==null)s=1;if(this.mult!==1)s*=this.mult;this.set(m,this.get(m)+s)};j.prototype.get=function(m){return m.getMilliseconds()};
j.prototype.set=function(m,s){m.setMilliseconds(s)};j.prototype.floorLocal=function(){};j.prototype.floor=function(m,s){var u=0;if(this.mult!==1){this.floorLocal(m,s);u=this.base}for(var v=this.prev;v;){v.mult===1&&v.value!==u&&v.clear(m,s);v=v.prev}};j.prototype.floorMultiple=function(m,s,u){var v=pv.get(u,"alignmentValue");u=v!=null?this.get(v):this.first(m,u);var y=this.get(m)-u,z=null;if(y){s=s*this.mult;if(v){for(z=new Date(v);z<m;)this.set(z,this.get(z)+s);for(;z>m;)this.set(z,this.get(z)-s);
u=this.get(z)}else{v=Math.floor(y/s)*s;u+=v}}this.set(m,u,z)};j.prototype.clear=function(m,s){this.set(m,this.first(m,s))};j.prototype.multiple=function(m){for(var s=this.multiples,u=this.thresholds,v=this.closeds,y=s.length,z=-1;++z<y;)if(v[z]?m<=u[z]:m<u[z])return s[z];throw new Error("Invalid configuration.");};j.prototype.resultAbove=function(m){return this.castValue(this.value*m+0.1,true)};j.prototype.castValue=function(m,s){var u=this.multiples;if(!u)return this._castValueResult(1,m,1);var v=
m/this.value,y=u.length,z;if(s){for(z=-1;++z<y;)if(v<=u[z])return this._castValueResult(u[z],m,0);return this.next?this.next.castValue(m,s):this._castValueResult(u[y-1],m,1)}for(z=y;z--;)if(u[z]<=v)return this._castValueResult(u[z],m,0);return this.prev?this.prev.castValue(m,s):this._castValueResult(u[0],m,-1)};j.prototype._castValueResult=function(m,s,u){return{comp:this,mult:m,value:this.value*m,source:s,overflow:u}};j.prototype.withPrecision=function(m){var s=this;if(this.value!==m)s=new j(m,null,
{mult:m,format:this.format});return s};j.prototype.ticks=function(m,s,u,v){var y=[],z=new Date(m);this.floor(z,v);u>1&&this.floorMultiple(z,u,v);if(pv.get(v,"roundInside",1)){m!==+z&&this.increment(z,u);do{y.push(new Date(z));this.increment(z,u)}while(z<=s)}else{y.push(new Date(z));do{this.increment(z,u);y.push(new Date(z))}while(z<s)}return y};pv.parseDatePrecision=o;var w=[];l(1,{format:"%S.%Qs",multiples:[1,5,25,50,100,250],thresholds:[10,50,100,200,1E3,Infinity],closeds:[1,1,1,1,1,1]});l(1E3,
{get:function(m){return m.getSeconds()},set:function(m,s){m.setSeconds(s)},format:"%I:%M:%S",multiples:[1,5,10,15],thresholds:[10,60,90,Infinity],closeds:[1,1,1,1]});l(6E4,{get:function(m){return m.getMinutes()},set:function(m,s){m.setMinutes(s)},format:"%I:%M %p",multiples:[1,5,10,15],thresholds:[10,15,30,Infinity],closeds:[1,1,1,1]});l(36E5,{get:function(m){return m.getHours()},set:function(m,s){m.setHours(s)},format:"%I:%M %p",multiples:[1,3,6],thresholds:[10,20,Infinity],closeds:[1,1,1]});l(864E5,
{get:function(m){return m.getDate()},set:function(m,s,u){var v=u?u.getMonth():m.getMonth();u=u?u.getFullYear():m.getFullYear();m.setFullYear(u,v,s)},format:"%m/%d",first:1,multiples:[1,2,3,5],thresholds:[10,15,30,Infinity],closeds:[1,0,0,1]});l(6048E5,{get:function(m){return m.getDate()},set:function(m,s,u){var v=u?u.getMonth():m.getMonth();u=u?u.getFullYear():m.getFullYear();m.setFullYear(u,v,s)},mult:7,floor:function(m,s){s=m.getDay()-pv.get(s,"weekStart",0);if(s!==0){if(s<0)s+=7;this.set(m,this.get(m)-
s)}},first:function(m,s){return this.get(n(m,pv.get(s,"weekStart",0)))},format:"%m/%d",multiples:[1,2,3],thresholds:[10,15,Infinity],closeds:[1,1,1]});l(2592E6,{get:function(m){return m.getMonth()},set:function(m,s){m.setMonth(s)},format:"%m/%Y",multiples:[1,2,3],thresholds:[12,24,Infinity],closeds:[1,1,1]});l(31536E6,{get:function(m){return m.getFullYear()},set:function(m,s){m.setFullYear(s)},format:"%Y",multiple:function(m){if(m<=10)return 1;var s=pv.logCeil(m/15,10);if(m/s<2)s/=5;else if(m/s<5)s/=
2;return s},castValue:function(m,s){var u=m/this.value,v;if(u<1){if(!s)return this.prev?this.prev.castValue(m,s):this._castValueResult(1,m,-1);v=1}else v=pv.logFloor(u,10);u=u/v;if(s)if(u>5){v*=10;u=1}else u=u>2?5:u>1?2:1;else if(u>5)u=5;else if(u>2)u=2;else if(u>1)u=1;else if(u<1)return this.prev?this.prev.castValue(m,s):this._castValueResult(v,m,-1);return this._castValueResult(v*u,m,0)}})})();pv.Scale.linear=function(){var b=pv.Scale.quantitative();b.domain.apply(b,arguments);return b};
pv.Scale.log=function(){var b=pv.Scale.quantitative(1,10),c,e,d=function(g){return Math.log(g)/e},f=function(g){return Math.pow(c,g)};b.ticks=function(){var g=b.domain(),h=g[0]<0,i=Math.floor(h?-d(-g[0]):d(g[0])),j=Math.ceil(h?-d(-g[1]):d(g[1])),k=[];if(h)for(k.push(-f(-i));i++<j;)for(h=c-1;h>0;h--)k.push(-f(-i)*h);else{for(;i<j;i++)for(h=1;h<c;h++)k.push(f(i)*h);k.push(f(i))}for(i=0;k[i]<g[0];i++);for(j=k.length;k[j-1]>g[1];j--);return k.slice(i,j)};b.tickFormat=function(g){return g.toPrecision(1)};
b.nice=function(){var g=b.domain();return b.domain(pv.logFloor(g[0],c),pv.logCeil(g[1],c))};b.base=function(g){if(arguments.length){c=Number(g);e=Math.log(c);b.transform(d,f);return this}return c};b.domain.apply(b,arguments);return b.base(10)};pv.Scale.root=function(){var b=pv.Scale.quantitative();b.power=function(c){if(arguments.length){var e=Number(c),d=1/e;b.transform(function(f){return Math.pow(f,d)},function(f){return Math.pow(f,e)});return this}return e};b.domain.apply(b,arguments);return b.power(2)};
pv.Scale.ordinal=function(){function b(f){f in e||(e[f]=c.push(f)-1);return d[e[f]%d.length]}var c=[],e={},d=[];b.domain=function(f,g){if(arguments.length){f=f instanceof Array?arguments.length>1?pv.map(f,g):f:Array.prototype.slice.call(arguments);c=[];for(var h={},i=0;i<f.length;i++){var j=f[i];if(!(j in h)){h[j]=true;c.push(j)}}e=pv.numerate(c);return this}return c};b.range=function(f,g){if(arguments.length){d=f instanceof Array?arguments.length>1?pv.map(f,g):f:Array.prototype.slice.call(arguments);
if(typeof d[0]=="string")d=d.map(pv.fillStyle);d.min=d[0];d.max=d[d.length-1];return this}return d};b.split=function(f,g){var h=g-f,i=this.domain().length,j=0;if(h===0)d=pv.array(i,f);else if(i){j=(g-f)/i;d=pv.range(f+j/2,g,j)}d.min=f;d.max=g;d.step=j;return this};b.splitBandedCenter=function(f,g,h){if(h==null)h=1;return this._splitBandedCore(f,g,function(i){var j=i.range/i.count;i.step=j;i.band=j*h;i.offset=j/2})};b.splitBandedCenterAbs=function(f,g,h,i){return this._splitBandedCore(f,g,function(j){var k;
if(h==null||i==null){k=j.range/j.count;if(h==null)if(i==null){h=k;i=0}else{i=Math.min(i,k);h=k-i}else{h=Math.min(h,k);i=k-h}}else k=h+i;j.step=k;j.band=h;j.offset=k/2})};b._splitBandedCore=function(f,g,h){var i={min:f,max:g,range:g-f,count:this.domain().length,offset:0,step:0,band:0},j;if(i.range===0){d=pv.array(i.count,f);j=0}else if(i.count){h(i);j=i.step-i.band;d=pv.range(f+i.offset,g,i.step)}d.offset=i.offset;d.step=i.step;d.band=i.band;d.margin=j;d.min=f;d.max=g;return this};b.splitBandedFlushCenter=
function(f,g,h){if(h==null)h=1;return this._splitBandedCore(f,g,function(i){var j=i.range,k=i.count,n=j*h/k;j=k>1?(j-k*n)/(k-1):0;i.band=n;i.step=j+n;i.offset=n/2})};b.splitFlush=function(f,g){var h=this.domain().length,i=(g-f)/(h-1);d=h==1?[(f+g)/2]:pv.range(f,g+i/2,i);d.min=f;d.max=g;return this};b.splitBanded=function(f,g,h){if(arguments.length<3)h=1;if(h<0){var i=this.domain().length;i=(g-f- -h*i)/(i+1);d=pv.range(f+i,g,i-h);d.band=-h}else{i=(g-f)/(this.domain().length+(1-h));d=pv.range(f+i*(1-
h),g,i);d.band=i*h;d.step=i;d.margin=i-d.band}d.min=f;d.max=g;return this};b.invertIndex=function(f,g){var h=this.domain().length;if(h===0)return-1;var i=this.range(),j=i.max-i.min;if(j===0)return 0;if(f>=i.max)return h;if(f<i.min)return 0;f=(f-i.min)/(j/h);return g?f:Math.round(f)};pv.copyOwn(b,pv.Scale.common);b.domain.apply(b,arguments);return b};
pv.Scale.quantile=function(){function b(h){return g(Math.max(0,Math.min(e,pv.search.index(d,h)-1))/e)}var c=-1,e=-1,d=[],f=[],g=pv.Scale.linear();b.quantiles=function(h){if(arguments.length){c=Number(h);if(c<0){d=[f[0]].concat(f);e=f.length-1}else{d=[];d[0]=f[0];for(var i=1;i<=c;i++)d[i]=f[~~(i*(f.length-1)/c)];e=c-1}return this}return d};b.domain=function(h,i){if(arguments.length){f=h instanceof Array?pv.map(h,i):Array.prototype.slice.call(arguments);f.sort(pv.naturalOrder);b.quantiles(c);return this}return f};
b.range=function(){if(arguments.length){g.range.apply(g,arguments);return this}return g.range()};pv.copyOwn(b,pv.Scale.common);b.domain.apply(b,arguments);return b};
pv.histogram=function(b,c){var e=true;return{bins:function(d){var f=pv.map(b,c),g=[];arguments.length||(d=pv.Scale.linear(f).ticks());for(var h=0;h<d.length-1;h++){var i=g[h]=[];i.x=d[h];i.dx=d[h+1]-d[h];i.y=0}for(h=0;h<f.length;h++){i=pv.search.index(d,f[h])-1;i=g[Math.max(0,Math.min(g.length-1,i))];i.y++;i.push(b[h])}if(!e)for(h=0;h<g.length;h++)g[h].y/=f.length;return g},frequency:function(d){if(arguments.length){e=Boolean(d);return this}return e}}};
(function(){pv.Shape=function(){};var b={x:1,y:1};pv.Shape.dist2=function(d,f,g){g=g||b;var h=d.x-f.x;d=d.y-f.y;h=h*h;d=d*d;return{cost:h+d,dist2:g.x*h+g.y*d}};var c=2*Math.PI,e=Math.atan2;pv.Shape.normalizeAngle=function(d){d%=c;if(pv.floatLess(d,0))d+=c;return d};pv.Shape.atan2Norm=function(d,f){d=e(d,f);if(pv.floatLess(d,0))d+=c;return d};pv.Shape.prototype.hasArea=function(){return true};pv.Shape.prototype.bbox=function(){return this._bbox||(this._bbox=this._calcBBox())};pv.Shape.prototype._calcBBox=
function(){var d,f,g,h;this.points().forEach(function(i){var j=i.x;i=i.y;if(d==null){d=g=j;f=h=i}else{if(j<d)d=j;else if(j>g)g=j;if(i<f)f=i;else if(i>h)h=i}});if(d!=null)return new pv.Shape.Rect(d,f,g-d,h-f)};pv.Shape.prototype.containsPoint=function(d,f){if(f){var g;if(!f.y)return g=this.bbox(),pv.floatBelongsClosed(g.x,d.x,g.x2);if(!f.x)return g=this.bbox(),pv.floatBelongsClosed(g.y,d.y,g.y2)}return this._containsPointCore(d)};pv.Shape.prototype._containsPointCore=function(){return false}})();
(function(){var b=pv.Shape.dist2,c=Math.cos,e=Math.sin,d=Math.sqrt;pv.vector=function(g,h){return new f(g,h)};pv.Vector=function(g,h){this.x=g;this.y=h};var f=pv.Shape.Point=pv.Vector;pv.Vector.prototype=pv.extend(pv.Shape);pv.Vector.prototype.perp=function(){return new f(-this.y,this.x)};pv.Vector.prototype.rotate=function(g){var h=c(g);g=e(g);return new f(h*this.x-g*this.y,g*this.x+h*this.y)};pv.Vector.prototype.norm=function(){var g=this.length();return this.times(g?1/g:1)};pv.Vector.prototype.length=
function(){return d(this.x*this.x+this.y*this.y)};pv.Vector.prototype.times=function(g){return new f(this.x*g,this.y*g)};pv.Vector.prototype.plus=function(g,h){return arguments.length===1?new f(this.x+g.x,this.y+g.y):new f(this.x+g,this.y+h)};pv.Vector.prototype.minus=function(g,h){return arguments.length===1?new f(this.x-g.x,this.y-g.y):new f(this.x-g,this.y-h)};pv.Vector.prototype.dot=function(g,h){return arguments.length==1?this.x*g.x+this.y*g.y:this.x*g+this.y*h};pv.Vector.prototype.hasArea=function(){return false};
pv.Vector.prototype.clone=function(){return new f(this.x,this.y)};pv.Vector.prototype.apply=function(g){return new f(g.x+g.k*this.x,g.y+g.k*this.y)};pv.Vector.prototype.intersectsRect=function(g){return pv.floatBelongsClosed(g.x,this.x,g.x2)&&pv.floatBelongsClosed(g.y,this.y,g.y2)};pv.Vector.prototype._containsPointCore=function(g){return this.x===g.x&&this.y===g.y};pv.Vector.prototype.points=function(){return[this]};pv.Vector.prototype.edges=function(){return[]};pv.Vector.prototype.center=function(){return this};
pv.Vector.prototype.distance2=function(g,h){return b(this,g,h)}})();
(function(){var b=pv.Shape.Point,c=pv.Shape.dist2;pv.Shape.Line=function(d,f,g,h){this.x=d||0;this.y=f||0;this.x2=g||0;this.y2=h||0};var e=pv.Shape.Line;e.prototype=pv.extend(pv.Shape);e.prototype.hasArea=function(){return false};e.prototype.clone=function(){return new e(this.x,this.y,this.x2,this.x2)};e.prototype.apply=function(d){return new e(d.x+d.k*this.x,d.y+d.k*this.y,d.x+d.k*this.x2,d.y+d.k*this.y2)};e.prototype.points=function(){return[new b(this.x,this.y),new b(this.x2,this.y2)]};e.prototype.edges=
function(){return[this]};e.prototype.center=function(){return new b((this.x+this.x2)/2,(this.y+this.y2)/2)};e.prototype.normal=function(d,f){d=this.points();var g=d[1].minus(d[0]).perp().norm();if(f)if(d[0].minus(f).dot(g)<0)g=g.times(-1);return g};e.prototype.intersectsRect=function(d){var f,g,h=this.points();g=h.length;for(f=0;f<g;f++)if(h[f].intersectsRect(d))return true;d=d.edges();g=d.length;for(f=0;f<g;f++)if(this.intersectsLine(d[f]))return true;return false};e.prototype._containsPointCore=
function(d){var f=this.x,g=this.x2,h=this.y,i=this.y2;return pv.floatBelongsClosed(f,d.x,g)&&(pv.floatEqual(f,g)?pv.floatBelongsClosed(Math.min(h,i),d.y,Math.max(h,i)):pv.floatZero((i-h)/(g-f)*(d.x-f)+h-d.y))};e.prototype.intersectsLine=function(d){var f=this,g=f.x2-f.x,h=f.y2-f.y,i=d.x2-d.x,j=d.y2-d.y,k=j*g-i*h;if(pv.floatZero(k))return false;var n=f.y-d.y;d=f.x-d.x;i=i*n-j*d;g=g*n-h*d;if(pv.floatZero(k))return pv.floatZero(i)&&pv.floatZero(g);if(!pv.floatBelongsClosed(0,i/k,1))return false;if(!pv.floatBelongsClosed(0,
g/k,1))return false;return true};e.prototype.distance2=function(d,f){var g=this,h={x:this.x2,y:this.y2},i=c(g,h).cost;if(pv.floatZero(i))return c(d,g,f);var j=h.x-g.x,k=h.y-g.y;i=((d.x-g.x)*j+(d.y-g.y)*k)/i;if(pv.floatLess(i,0))return c(d,g,f);if(pv.floatGreater(i,1))return c(d,h,f);return c(d,{x:g.x+i*j,y:g.y+i*k},f)}})();
(function(){var b=pv.Shape.Point,c=pv.Shape.Line;pv.Shape.Polygon=function(d){this._points=d||[]};var e=pv.Shape.Polygon;e.prototype=pv.extend(pv.Shape);e.prototype.points=function(){return this._points};e.prototype.clone=function(){return new e(this.points().slice())};e.prototype.apply=function(d){for(var f=this.points(),g=f.length,h=new Array(g),i=0;i<g;i++)h[i]=f[i].apply(d);return new e(h)};e.prototype.intersectsRect=function(d){var f,g,h=this.points();g=h.length;for(f=0;f<g;f++)if(h[f].intersectsRect(d))return true;
h=this.edges();g=h.length;for(f=0;f<g;f++)if(h[f].intersectsRect(d))return true;return false};e.prototype.edges=function(){var d=this._edges;if(!d){d=this._edges=[];var f=this.points(),g=f.length;if(g){for(var h=f[0],i=h,j,k=1;k<g;k++){j=f[k];d.push(new c(h.x,h.y,j.x,j.y));h=j}g>2&&d.push(new c(j.x,j.y,i.x,i.y))}}return d};e.prototype.distance2=function(d,f){var g={cost:Infinity,dist2:Infinity};this.edges().forEach(function(h){h=h.distance2(d,f);if(pv.floatLess(h.cost,g.cost))g=h},this);return g};
e.prototype.center=function(){for(var d=this.points(),f=0,g=0,h=0,i=d.length;h<i;h++){var j=d[h];f+=j.x;g+=j.y}return new b(f/i,g/i)};e.prototype._containsPointCore=function(d){var f=this.bbox();if(!f._containsPointCore(d))return false;var g=new c(f.x-f.dx*0.01,d.y,d.x,d.y),h=0;this.edges().forEach(function(i){i.intersectsLine(g)&&h++});return(h&1)===1}})();
(function(){var b=pv.Shape.Point,c=pv.Shape.Line;pv.Shape.Rect=function(d,f,g,h){this.x=d||0;this.y=f||0;this.dx=g||0;this.dy=h||0;if(this.dx<0){this.dx=Math.max(0,-this.dx);this.x-=this.dx}if(this.dy<0){this.dy=Math.max(0,-this.dy);this.y-=this.dy}this.x2=this.x+this.dx;this.y2=this.y+this.dy};var e=pv.Shape.Rect;e.prototype=pv.extend(pv.Shape.Polygon);e.prototype.clone=function(){var d=Object.create(e.prototype);d.x=this.x;d.y=this.y;d.dx=this.dx;d.dy=this.dy;d.x2=this.x2;d.y2=this.y2;return d};
e.prototype.apply=function(d){return new e(d.x+d.k*this.x,d.y+d.k*this.y,d.k*this.dx,d.k*this.dy)};e.prototype._containsPointCore=function(d){return pv.floatBelongsClosed(this.x,d.x,this.x2)&&pv.floatBelongsClosed(this.y,d.y,this.y2)};e.prototype.intersectsRect=function(d){return pv.floatGreater(this.x2,d.x)&&pv.floatLess(this.x,d.x2)&&pv.floatGreater(this.y2,d.y)&&pv.floatLess(this.y,d.y2)};e.prototype.edges=function(){if(!this._edges){var d=this.x,f=this.y,g=this.x2,h=this.y2;this._edges=[new c(d,
f,g,f),new c(g,f,g,h),new c(g,h,d,h),new c(d,h,d,f)]}return this._edges};e.prototype.center=function(){return new b(this.x+this.dx/2,this.y+this.dy/2)};e.prototype.points=function(){var d=this._points;if(!d){d=this.x;var f=this.y,g=this.x2,h=this.y2;d=this._points=[new b(d,f),new b(g,f),new b(g,h),new b(d,h)]}return d};e.prototype._calcBBox=function(){return this}})();
(function(){var b=pv.Shape.Point,c=pv.Shape.dist2,e=Math.sqrt,d=Math.abs,f=Math.pow;pv.Shape.Circle=function(h,i,j){this.x=h||0;this.y=i||0;this.radius=j||0};var g=pv.Shape.Circle;g.prototype=pv.extend(pv.Shape);g.prototype.clone=function(){return new g(this.x,this.y,this.radius)};g.prototype.apply=function(h){return new g(h.x+h.k*this.x,h.y+h.k*this.y,h.k*this.radius)};g.prototype.intersectsRect=function(h){var i=h.dx/2,j=h.dy/2,k=this.radius,n=d(this.x-h.x-i);h=d(this.y-h.y-j);if(n>i+k||h>j+k)return false;
if(n<=i||h<=j)return true;return f(n-i,2)+f(h-j,2)<=k*k};g.prototype.intersectLine=function(h,i){var j=h.x2-h.x,k=h.y2-h.y,n=this.x-h.x,o=this.y-h.y,r=j*j+k*k,l=this.radius,p=(j*n+k*o)/r;n=p*p-(n*n+o*o-l*l)/r;if(!(n<0)){r=e(n);o=p-r;p=p+r;r=[];if(i||o>=0&&o<=1)r.push(new b(h.x+j*o,h.y+k*o));if(n!==0)if(i||p>=0&&p<=1)r.push(new b(h.x+j*p,h.y+k*p));return r}};g.prototype.points=function(){return[this.center()]};g.prototype.center=function(){return new b(this.x,this.y)};g.prototype.normal=function(h){return h.minus(this.x,
this.y).norm()};g.prototype._containsPointCore=function(h){var i=h.x-this.x;h=h.y-this.y;var j=this.radius;return i*i+h*h<=j*j};g.prototype.distance2=function(h,i){var j=this.radius;j=h.minus(this).norm().times(j).plus(this);return c(h,j,i)};g.prototype._calcBBox=function(){var h=this.radius,i=2*h;return new pv.Shape.Rect(this.x-h,this.y-h,i,i)}})();
(function(){var b=pv.Shape.Point,c=pv.Shape.dist2,e=pv.Shape.normalizeAngle,d=pv.Shape.atan2Norm,f=Math.cos,g=Math.sin,h=Math.sqrt,i=Math.PI,j=2*i,k=i/2,n=3*i/2;pv.Shape.Arc=function(l,p,q,t,x){this.x=l;this.y=p;this.radius=q;pv.floatBelongsClosed(0,x,j)||(x=e(x));this.startAngle=e(t);this.angleSpan=x;this.endAngle=this.startAngle+this.angleSpan};var o=pv.Shape.Arc;o.prototype=pv.extend(pv.Shape);o.prototype.hasArea=function(){return false};o.prototype.clone=function(){var l=Object.create(o.prototype),
p=this;l.x=p.x;l.y=p.y;l.radius=p.radius;l.startAngle=p.startAngle;l.angleSpan=p.angleSpan;l.endAngle=p.endAngle;return l};o.prototype.apply=function(l){return new o(l.x+l.k*this.x,l.y+l.k*this.y,l.k*this.radius,this.startAngle,this.angleSpan)};o.prototype.containsAngle=function(l,p){pv.floatBelongsClosed(0,l,j)||(l=e(l));var q=this.startAngle,t=this.endAngle;if(p?pv.floatBelongsOpen(q,l,t):pv.floatBelongsClosed(q,l,t))return true;if(pv.floatLessOrEqual(t,j))return false;l+=j;return p?pv.floatBelongsOpen(q,
l,t):pv.floatBelongsClosed(q,l,t)};o.prototype._containsPointCore=function(l){var p=l.x-this.x;l=l.y-this.y;var q=h(p*p+l*l);return pv.floatEqual(q,this.radius)&&this.containsAngle(d(l,p))};o.prototype.intersectsRect=function(l){var p,q=this.points(),t=q.length;for(p=0;p<t;p++)if(q[p].intersectsRect(l))return true;l=l.edges();t=l.length;for(p=0;p<t;p++)if(this.intersectLine(l[p]))return true;return false};var r=pv.Shape.Circle.prototype.intersectLine;o.prototype.intersectLine=function(l,p){if(l=r.call(this,
l,p)){l=l.filter(function(q){return this._containsPointCore(q)},this);if(l.length)return l}};o.prototype.points=function(){function l(u){p.containsAngle(u,true)&&s.push(new b(q+x*f(u),t+x*g(u)))}var p=this,q=p.x,t=p.y,x=p.radius,w=p.startAngle,m=p.endAngle,s=[new b(q+x*f(w),t+x*g(w)),new b(q+x*f(m),t+x*g(m))];l(0);l(k);l(i);l(n);return s};o.prototype.center=function(){var l=this.y,p=this.radius,q=(this.startAngle+this.endAngle)/2;return new b(this.x+p*f(q),l+p*g(q))};o.prototype.normal=function(l,
p){l=l.minus(this.x,this.y).norm();if(p)if(this.center().minus(p).dot(l)<0)l=l.times(-1);return l};o.prototype.distance2=function(l,p){var q=d(l.y-this.y,l.x-this.x);if(this.containsAngle(q)){q=new b(this.x+this.radius*f(q),this.y+this.radius*g(q));return c(l,q,p)}var t=this.points();q=c(l,t[0],p);l=c(l,t[1],p);return pv.floatLess(q.cost,l.cost)?q:l}})();
(function(){var b=pv.Shape.Arc,c=pv.Shape.Line,e=pv.Shape.Point,d=Math.cos,f=Math.sin,g=Math.sqrt,h=Math.PI,i=2*h,j=h/2,k=3*h/2,n=pv.Shape.atan2Norm,o=pv.Shape.normalizeAngle;pv.Shape.Wedge=function(l,p,q,t,x,w){this.x=l;this.y=p;this.innerRadius=q;this.outerRadius=t;pv.floatBelongsClosed(0,w,i)||(w=o(w));this.startAngle=o(x);this.angleSpan=w;this.endAngle=this.startAngle+w};var r=pv.Shape.Wedge;r.prototype=pv.extend(pv.Shape);r.prototype.clone=function(){return new r(this.x,this.y,this.innerRadius,
this.outerRadius,this.startAngle,this.angleSpan)};r.prototype.apply=function(l){return new r(l.x+l.k*this.x,l.y+l.k*this.y,l.k*this.innerRadius,l.k*this.outerRadius,this.startAngle,this.angleSpan)};r.prototype.containsAngle=b.prototype.containsAngle;r.prototype._containsPointCore=function(l){var p=l.x-this.x;l=l.y-this.y;var q=g(p*p+l*l);return pv.floatBelongsClosed(this.innerRadius,q,this.outerRadius)&&this.containsAngle(n(l,p))};r.prototype.intersectsRect=function(l){var p,q,t;t=this.points();q=
t.length;for(p=0;p<q;p++)if(t[p].intersectsRect(l))return true;t=l.points();q=t.length;for(p=0;p<q;p++)if(this._containsPointCore(t[p]))return true;t=this.edges();q=t.length;for(p=0;p<q;p++)if(t[p].intersectsRect(l))return true;return false};r.prototype.points=function(){this._points||this.edges();return this._points};r.prototype.edges=function(){var l=this,p=l._edges;if(!p){var q=l.x,t=l.y,x=l.innerRadius,w=pv.floatGreater(x,0),m=l.outerRadius,s=l.startAngle,u=l.endAngle,v=l.angleSpan,y=d(s),z=f(s);
p=d(u);var A=f(u),B;if(w){u=new e(q+x*y,t+x*z);B=new e(q+x*p,t+x*A)}else u=B=new e(q,t);y=new e(q+m*y,t+m*z);z=new e(q+m*p,t+m*A);p=l._edges=[];w&&p.push(new b(q,t,x,s,v));p.push(new c(u.x,u.y,y.x,y.y),new b(q,t,m,s,v),new c(B.x,B.y,z.x,z.y));var D=l._points=[u,y,z];w&&D.push(B);function G(C){l.containsAngle(C,true)&&D.push(new e(q+m*d(C),t+m*f(C)))}G(0);G(j);G(h);G(k)}return p};r.prototype.distance2=function(l,p){var q={cost:Infinity,dist2:Infinity};this.edges().forEach(function(t){t=t.distance2(l,
p);if(pv.floatLess(t.cost,q.cost))q=t});return q};r.prototype.center=function(){var l=(this.startAngle+this.endAngle)/2,p=(this.innerRadius+this.outerRadius)/2;return new e(this.x+p*d(l),this.y+p*f(l))}})();
(function(){var b=Math.round,c=function(g){var h=parseFloat(g);return g[g.length-1]=="%"?b(h*2.55):h},e=/([a-z]+)\((.*)\)/i,d=function(g){if(g.charAt(0)==="#"){var h,i,j;if(g.length===4){h=g.charAt(1);h+=h;i=g.charAt(2);i+=i;j=g.charAt(3);j+=j}else if(g.length===7){h=g.substring(1,3);i=g.substring(3,5);j=g.substring(5,7)}return pv.rgb(parseInt(h,16),parseInt(i,16),parseInt(j,16),1)}if(h=e.exec(g)){j=h[2].split(",");var k=1;switch(h[1]){case "hsla":case "rgba":k=parseFloat(j[3]);if(!k)return pv.Color.transparent;
break}switch(h[1]){case "hsla":case "hsl":g=parseFloat(j[0]);h=parseFloat(j[1])/100;j=parseFloat(j[2])/100;return(new pv.Color.Hsl(g,h,j,k)).rgb();case "rgba":case "rgb":h=c(j[0]);i=c(j[1]);j=c(j[2]);return pv.rgb(h,i,j,k)}}return new pv.Color(g,1)},f={};pv.color=function(g){if(g.rgb)return g.rgb();var h=pv.Color.names[g];h||(h=f[g]||(f[g]=d(g)));return h}})();pv.Color=function(b,c){this.color=b;this.opacity=c;this.key="solid "+b+" alpha("+c+")"};pv.Color.prototype.hsl=function(){return this.rgb().hsl()};
pv.Color.prototype.brighter=function(b){return this.rgb().brighter(b)};pv.Color.prototype.darker=function(b){return this.rgb().darker(b)};pv.Color.prototype.relativeLuminance=function(b){b=this.alphaBlend(b);return 0.2126*correctSRgbComponent(b.r)+0.7152*correctSRgbComponent(b.g)+0.0722*correctSRgbComponent(b.b)};function correctSRgbComponent(b){b/=255;return b<=0.03928?b/12.92:Math.pow((b+0.055)/1.055,2.4)}
pv.Color.prototype.alphaBlend=function(b){var c=this.rgb(),e=c.a;if(e===1)return this;b=b?pv.color(b).alphaBlend():pv.Color.names.white;b=b.rgb();var d=1-e;return pv.rgb(e*c.r+d*b.r,e*c.g+d*b.g,e*c.b+d*b.b,1)};pv.Color.prototype.rgbDecimal=function(b){b=this.alphaBlend(b);return b.r<<16|b.g<<8|b.b};pv.Color.prototype.isDark=function(){return this.rgbDecimal()<8388607.5};
pv.Color.prototype.contrastRatioTo=function(b){var c=b.alphaBlend();b=this.alphaBlend(c);c=c.relativeLuminance();b=b.relativeLuminance();return(Math.max(c,b)+0.05)/(Math.min(c,b)+0.05)};pv.rgb=function(b,c,e,d){return new pv.Color.Rgb(b,c,e,arguments.length==4?d:1)};pv.Color.Rgb=function(b,c,e,d){pv.Color.call(this,d?"rgb("+b+","+c+","+e+")":"none",d);this.r=b;this.g=c;this.b=e;this.a=d};pv.Color.Rgb.prototype=pv.extend(pv.Color);a=pv.Color.Rgb.prototype;
a.red=function(b){return pv.rgb(b,this.g,this.b,this.a)};a.green=function(b){return pv.rgb(this.r,b,this.b,this.a)};a.blue=function(b){return pv.rgb(this.r,this.g,b,this.a)};a.alpha=function(b){return pv.rgb(this.r,this.g,this.b,b)};a.rgb=function(){return this};
a.brighter=function(b){b=Math.pow(0.7,b!=null?b:1);var c=this.r,e=this.g,d=this.b;if(!c&&!e&&!d)return pv.rgb(30,30,30,this.a);if(c&&c<30)c=30;if(e&&e<30)e=30;if(d&&d<30)d=30;return pv.rgb(Math.min(255,Math.floor(c/b)),Math.min(255,Math.floor(e/b)),Math.min(255,Math.floor(d/b)),this.a)};a.darker=function(b){b=Math.pow(0.7,b!=null?b:1);return pv.rgb(Math.max(0,Math.floor(b*this.r)),Math.max(0,Math.floor(b*this.g)),Math.max(0,Math.floor(b*this.b)),this.a)};
a.hsl=function(){var b=this.r/255,c=this.g/255,e=this.b/255,d=Math.max(b,c,e),f=Math.min(b,c,e),g=(d+f)/2,h;if(d===f)h=f=0;else{var i=d-f;f=g>0.5?i/(2-d-f):i/(d+f);switch(d){case b:h=(c-e)/i+(c<e?6:0);break;case c:h=(e-b)/i+2;break;case e:h=(b-c)/i+4;break}h/=6}return pv.hsl(h*360,f,g,this.a)};a.complementary=function(){return this.hsl().complementary().rgb()};pv.hsl=function(b,c,e,d){return new pv.Color.Hsl(b,c,e,arguments.length==4?d:1)};
pv.Color.Hsl=function(b,c,e,d){pv.Color.call(this,"hsl("+b+","+c*100+"%,"+e*100+"%)",d);this.h=b;this.s=c;this.l=e;this.a=d};pv.Color.Hsl.prototype=pv.extend(pv.Color);a=pv.Color.Hsl.prototype;a.hsl=function(){return this};a.hue=function(b){return pv.hsl(b,this.s,this.l,this.a)};a.saturation=function(b){return pv.hsl(this.h,b,this.l,this.a)};a.lightness=function(b){return pv.hsl(this.h,this.s,b,this.a)};a.alpha=function(b){return pv.hsl(this.h,this.s,this.l,b)};
a.complementary=function(){return pv.hsl((this.h+180)%360,1-this.s,1-this.l,this.a)};a.rgb=function(){function b(i){if(i>360)i-=360;else if(i<0)i+=360;if(i<60)return h+(g-h)*i/60;if(i<180)return g;if(i<240)return h+(g-h)*(240-i)/60;return h}function c(i){return Math.round(b(i)*255)}var e=this.h,d=this.s,f=this.l;e%=360;if(e<0)e+=360;d=Math.max(0,Math.min(d,1));f=Math.max(0,Math.min(f,1));var g=f<=0.5?f*(1+d):f+d-f*d,h=2*f-g;return pv.rgb(c(e+120),c(e),c(e-120),this.a)};
pv.Color.names={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",
darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",
ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",
lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",
moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",
seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32",transparent:pv.Color.transparent=pv.rgb(0,0,0,0)};
(function(){var b=pv.Color.names;b.none=b.transparent;for(var c in b)b[c]=pv.color(b[c])})();pv.colors=function(){var b=pv.Scale.ordinal();b.range.apply(b,arguments);return b};pv.Colors={};pv.Colors.category10=function(){var b=pv.colors("#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf");b.domain.apply(b,arguments);return b};
pv.Colors.category20=function(){var b=pv.colors("#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5");b.domain.apply(b,arguments);return b};
pv.Colors.category19=function(){var b=pv.colors("#9c9ede","#7375b5","#4a5584","#cedb9c","#b5cf6b","#8ca252","#637939","#e7cb94","#e7ba52","#bd9e39","#8c6d31","#e7969c","#d6616b","#ad494a","#843c39","#de9ed6","#ce6dbd","#a55194","#7b4173");b.domain.apply(b,arguments);return b};
(function(){function b(l){var p=e(l);if(!p.length)return null;var q=Math.PI,t,x=p[0];if(x.indexOf("to ")===0){if(t=/^to\s+(?:((top|bottom)(?:\s+(left|right))?)|((left|right)(?:\\s+(top|bottom))?))$/.exec(x)){if(t[1]){q=t[2];if(t[3])q+=" "+t[3]}else{q=t[5];if(t[6])q=t[6]+" "+q}q=pv.radians(h[q]);p.shift()}}else{t=parseFloat(x);if(!isNaN(t)){q=t;if(/^.*?deg$/.test(x))q=pv.radians(q);p.shift()}}p=d(p);switch(p.length){case 0:return null;case 1:return new pv.FillStyle.Solid(p[0].color,1)}return new pv.FillStyle.LinearGradient(q,
p,l)}function c(l){var p=e(l);if(!p.length)return null;p=d(p);switch(p.length){case 0:return null;case 1:return new pv.FillStyle.Solid(p[0].color,1)}return new pv.FillStyle.RadialGradient(50,50,p,l)}function e(l){var p={},q=0;l=l.replace(/\b\w+?\(.*?\)/g,function(x){var w="__color"+q++;p[w]=x;return w});var t=l.split(/\s*,\s*/);if(!t.length)return null;q&&t.forEach(function(x,w){if(p.hasOwnProperty(x))t[w]=p[x]});return t}function d(l){function p(A){var B=w.length;if(B){var D=x;A=(A-D)/(B+1);for(var G=
0;G<B;G++){D+=A;w[G].offset=D}w.length=0}}for(var q=[],t=+Infinity,x=-Infinity,w=[],m=0,s=l.length;m<s;){var u=/^(.+?)\s*([+\-]?[e\.\d]+%)?$/i.exec(l[m++]);if(u){var v={color:pv.color(u[1])};u=parseFloat(u[2]);if(isNaN(u))if(q.length){if(m===s)u=Math.max(x,100)}else u=0;q.push(v);if(isNaN(u))w.push(v);else{v.offset=u;p(u);if(u>x)x=u;else if(u<x)u=x;if(u<t)t=u}}}if(q.length>=2&&(t<0||x>100)){var y=[],z=[];q.forEach(function(A){y.push(A.offset);z.push(A.color)});l=pv.scale.linear().domain(y).range(z);
if(t<0){for(;q.length&&q[0].offset<=0;)q.shift();q.unshift({offset:0,color:l(0)})}if(x>100){for(;q.length&&q[q.length-1].offset>=100;)q.pop();q.push({offset:100,color:l(100)})}}return q}pv.fillStyle=function(l){if(l.type)return l;var p=l.key||l,q=f[p];return q=q?q.clone():(f[p]=g(l))};var f={},g=function(l){if(l.rgb)return new pv.FillStyle.Solid(l.color,l.opacity);var p=/^\s*([a-z\-]+)\(\s*(.*?)\s*\)\s*$/.exec(l);if(p)switch(p[1]){case "linear-gradient":return b(p[2]);case "radial-gradient":return c(p[2])}return new pv.FillStyle.Solid(pv.color(l))},
h={top:0,"top right":45,right:90,"bottom right":135,bottom:180,"bottom left":225,left:270,"top left":315},i=pv.FillStyle=function(l){this.key=this.type=l};pv.extendType(i,new pv.Color("none",1));i.prototype.rgb=function(){var l=pv.color(this.color);if(this.opacity!==l.opacity)l=l.alpha(this.opacity);return l};i.prototype.alphaBlend=function(l){return this.rgb().alphaBlend(l)};i.prototype.rgbDecimal=function(l){return this.rgb().rgbDecimal(l)};i.prototype.isDark=function(){return this.rgb().isDark()};
var j=pv.FillStyle.Solid=function(l,p){i.call(this,"solid");if(l.rgb){this.color=l.color;this.opacity=l.opacity}else{this.color=l;this.opacity=p}this.key+=" "+this.color+" alpha("+this.opacity+")"};pv.extendType(j,i);j.prototype.alpha=function(l){return new j(this.color,l)};j.prototype.brighter=function(l){return new j(this.rgb().brighter(l))};j.prototype.darker=function(l){return new j(this.rgb().darker(l))};j.prototype.complementary=function(){return new j(this.rgb().complementary())};j.prototype.clone=
function(){var l=pv.extend(j);l.type=this.type;l.key=this.key;l.color=this.color;l.opacity=this.opacity;return l};pv.FillStyle.transparent=new j(pv.Color.transparent);var k=0,n=pv.FillStyle.Gradient=function(l,p){i.call(this,l);this.id=++k;this.stops=p;if(p.length)this.color=p[0].color.color;this.key+=" stops("+p.map(function(q){var t=q.color;return t.color+" alpha("+t.opacity+") at("+q.offset+")"}).join(", ")+")"};pv.extendType(n,i);n.prototype.rgb=function(){return this.stops.length?this.stops[0].color:
undefined};n.prototype.alpha=function(l){return this._cloneWithStops(this.stops.map(function(p){return{offset:p.offset,color:p.color.alpha(l)}}))};n.prototype.darker=function(l){return this._cloneWithStops(this.stops.map(function(p){return{offset:p.offset,color:p.color.darker(l)}}))};n.prototype.brighter=function(l){return this._cloneWithStops(this.stops.map(function(p){return{offset:p.offset,color:p.color.brighter(l)}}))};n.prototype.complementary=function(){return this._cloneWithStops(this.stops.map(function(l){return{offset:l.offset,
color:l.color.complementary()}}))};n.prototype.alphaBlend=function(l){return this._cloneWithStops(this.stops.map(function(p){return{offset:p.offset,color:p.color.alphaBlend(l)}}))};n.prototype.clone=function(){var l=this.constructor,p=pv.extend(l);p.constructor=l;p.id=++k;p.type=this.type;p.key=this.key;l=this.stops;p.stops=l;if(l.length)p.color=l[0].color.color;this._initClone(p);return p};var o=pv.FillStyle.LinearGradient=function(l,p){n.call(this,"lineargradient",p);this.angle=l;this.key+=" angle("+
l+")"};pv.extendType(o,n);o.prototype._cloneWithStops=function(l){return new o(this.angle,l)};o.prototype._initClone=function(l){l.angle=this.angle};var r=pv.FillStyle.RadialGradient=function(l,p,q){n.call(this,"radialgradient",q);this.cx=l;this.cy=p;this.key+=" center("+l+","+p+")"};pv.extendType(r,n);r.prototype._cloneWithStops=function(l){return new r(this.cx,this.cy,l)};r.prototype._initClone=function(l){l.cx=this.cx;l.cy=this.cy}})();
pv.ramp=function(){var b=pv.Scale.linear();b.range.apply(b,arguments);return b};
pv.Scene=pv.SvgScene={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns",xlink:"http://www.w3.org/1999/xlink",xhtml:"http://www.w3.org/1999/xhtml",scale:1,events:["DOMMouseScroll","mousewheel","mousedown","mouseup","mouseover","mouseout","mousemove","click","dblclick","contextmenu"],mousePositionEventSet:{mousedown:1,mouseup:1,mouseover:1,mouseout:1,mousemove:1,click:1,dblclick:1,contextmenu:1},implicit:{svg:{"shape-rendering":"auto","pointer-events":"painted",x:0,y:0,dy:0,"text-anchor":"start",
transform:"translate(0,0)",fill:"none","fill-opacity":1,stroke:"none","stroke-opacity":1,"stroke-width":1.5,"stroke-linejoin":"miter","stroke-linecap":"butt","stroke-miterlimit":8,"stroke-dasharray":"none"},css:{font:"10px sans-serif"}}};pv.SvgScene.updateAll=function(b){if(b.length&&b[0].reverse&&b.type!=="line"&&b.type!=="area"){for(var c=Object.create(b),e=0,d=b.length-1;d>=0;e++,d--)c[e]=b[d];b=c}this.removeSiblings(this[b.type](b))};
pv.SvgScene.create=function(b){return document.createElementNS(this.svg,b)};pv.SvgScene.expect=function(b,c,e,d,f,g){var h;if(b){h=b.tagName;if(h==="defs"){if(b=b.nextSibling)h=b.tagName}else if(h==="a")b=b.firstChild}if(b){if(h!==c){c=this.create(c);b.parentNode.replaceChild(c,b);b=c}}else b=this.create(c);f&&this.setAttributes(b,f);g&&this.setStyle(b,g);return b};
pv.SvgScene.setAttributes=function(b,c){var e=this.implicit.svg,d=b.__attributes__;if(d===c)d=null;for(var f in c){var g=c[f];if(!d||g!==d[f])g==null||g==e[f]?b.removeAttribute(f):b.setAttribute(f,g)}b.__attributes__=c};pv.SvgScene.setStyle=function(b,c){var e=this.implicit.css,d=b.__style__;if(d===c)d=null;for(var f in c){var g=c[f];if(!d||g!==d[f])if(g==null||g==e[f])b.style.removeProperty(f);else b.style[f]=g}b.__style__=c};
pv.SvgScene.append=function(b,c,e){b.$scene={scenes:c,index:e};b=this.title(b,c[e]);b.parentNode||c.$g.appendChild(b);return b.nextSibling};
pv.SvgScene.title=function(b,c){var e=b.parentNode;if(e&&e.tagName!="a")e=null;if(c.title){if(!e){e=this.create("a");e.setAttributeNS(this.xlink,"xlink:href","");b.parentNode&&b.parentNode.replaceChild(e,b);e.appendChild(b)}e.setAttributeNS(this.xlink,"xlink:title",c.title);for(var d=null,f=b.firstChild;f!=null;f=f.nextSibling)if(f.nodeName=="title"){d=f;break}if(d)d.removeChild(d.firstChild);else{d=this.create("title");b.appendChild(d)}d.appendChild(document.createTextNode(c.title));return e}e&&
e.parentNode.replaceChild(b,e);return b};pv.SvgScene.dispatch=pv.listener(function(b){var c=b.target.$scene;if(c){var e=b.type;switch(e){case "DOMMouseScroll":e="mousewheel";b.wheel=-480*b.detail;break;case "mousewheel":b.wheel=(window.opera?12:1)*b.wheelDelta;break}if(pv.Mark.dispatch(e,c.scenes,c.index,b)){b.preventDefault();b.stopPropagation()}}});pv.SvgScene.removeSiblings=function(b){for(;b;){var c=b.nextSibling;b.nodeName!=="defs"&&b.parentNode.removeChild(b);b=c}};pv.SvgScene.undefined=function(){};
(function(){var b={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"},c={shortdash:[3,1],shortdot:[1,1],shortdashdot:[3,1,1,1],shortdashdotdot:[3,1,1,1,1,1],dot:[1,3],dash:[4,3],longdash:[8,3],dashdot:[4,3,1,3],longdashdot:[8,3,1,3],longdashdotdot:[8,3,1,3,1,3]};pv.SvgScene.isStandardDashStyle=function(e){return c.hasOwnProperty(e)};pv.SvgScene.translateDashStyleAlias=function(e){return b.hasOwnProperty(e)?
b[e]:e};pv.SvgScene.parseDasharray=function(e){var d=e.strokeDasharray;if(d&&d!=="none"){d=this.translateDashStyleAlias(d);var f=c[d];d=f?f:d.split(/[\s,]+/);var g=e.lineWidth,h=(e.lineCap||"butt")==="butt";d=d.map(function(i,j){i=+i;if(!h)if(j%2)i++;else i-=1;if(i<=0)i=0.001;return i*g/this.scale},this).join(" ")}else d=null;return d}})();
(function(){var b=/^url\(#/,c=1,e=Math.PI/2,d=e/2,f=Math.SQRT2/2,g=Math.abs,h=Math.sin,i=Math.cos,j=function(n){return g(n)<=1.0E-12?0:n};pv.SvgScene.addFillStyleDefinition=function(n,o){if(!(!o.type||o.type==="solid"||b.test(o.color))){var r=n.mark.root,l=r.__fillStyleMap__||(r.__fillStyleMap__={}),p=o.key,q=l[p];if(!q){q=l[p]="__pvGradient"+c++;n=k.call(this,n,o,q);r.scene.$defs.appendChild(n)}o.color="url(#"+q+")"}};var k=function(n,o,r){var l=o.type==="lineargradient";n=this.create(l?"linearGradient":
"radialGradient");n.setAttribute("id",r);if(l){r=o.angle-e;l=g(r%e)-d;var p=g(f*i(l));l=p*i(r);r=p*h(r);n.setAttribute("x1",j(0.5-l));n.setAttribute("y1",j(0.5-r));n.setAttribute("x2",j(0.5+l));n.setAttribute("y2",j(0.5+r))}o=o.stops;r=o.length;for(l=0;l<r;l++){p=o[l];var q=n.appendChild(this.create("stop")),t=p.color;q.setAttribute("offset",p.offset+"%");q.setAttribute("stop-color",t.color);q.setAttribute("stop-opacity",t.opacity+"")}return n}})();
pv.SvgScene.pathBasis=function(){function b(d,f,g,h,i){return{x:d[0]*f.left+d[1]*g.left+d[2]*h.left+d[3]*i.left,y:d[0]*f.top+d[1]*g.top+d[2]*h.top+d[3]*i.top}}var c=[[1/6,2/3,1/6,0],[0,2/3,1/3,0],[0,1/3,2/3,0],[0,1/6,2/3,1/6]],e=function(d,f,g,h){var i=b(c[1],d,f,g,h),j=b(c[2],d,f,g,h);d=b(c[3],d,f,g,h);return"C"+i.x+","+i.y+","+j.x+","+j.y+","+d.x+","+d.y};e.segment=function(d,f,g,h){var i=b(c[0],d,f,g,h),j=b(c[1],d,f,g,h),k=b(c[2],d,f,g,h);d=b(c[3],d,f,g,h);return["M"+i.x+","+i.y,"C"+j.x+","+j.y+
","+k.x+","+k.y+","+d.x+","+d.y]};return e}();pv.SvgScene.curveBasis=function(b,c,e){var d;if(c==null){d=b.length;c=0;e=d-1}else d=e-c+1;if(d<=2)return"";d="";var f=b[c],g=f,h=f,i=b[c+1];d+=this.pathBasis(f,g,h,i);for(c=c+2;c<=e;c++){f=g;g=h;h=i;i=b[c];d+=this.pathBasis(f,g,h,i)}d+=this.pathBasis(g,h,i,i);d+=this.pathBasis(h,i,i,i);return d};
pv.SvgScene.curveBasisSegments=function(b,c,e){var d;if(c==null){d=b.length;c=0;e=d-1}else d=e-c+1;if(d<=2)return"";d=[];var f=b[c],g=f,h=f,i=b[c+1],j=this.pathBasis.segment(f,g,h,i);f=g;g=h;h=i;i=b[c+2];j[1]+=this.pathBasis(f,g,h,i);d.push(j);for(c=c+3;c<=e;c++){f=g;g=h;h=i;i=b[c];d.push(this.pathBasis.segment(f,g,h,i))}b=this.pathBasis.segment(g,h,i,i);b[1]+=this.pathBasis(h,i,i,i);d.push(b);return d};
pv.SvgScene.curveHermite=function(b,c,e,d){var f;if(e==null){f=b.length;e=0}else f=d-e+1;d=c.length;if(d<1||f!==d&&f!==d+2)return"";var g=f!==d;f="";var h=b[e],i=b[e+1],j=c[0],k=j,n=e+1;if(g){f+="Q"+(i.left-j.x*2/3)+","+(i.top-j.y*2/3)+","+i.left+","+i.top;h=b[e+1];n=e+2}if(d>1){k=c[1];i=b[n];n++;f+="C"+(h.left+j.x)+","+(h.top+j.y)+","+(i.left-k.x)+","+(i.top-k.y)+","+i.left+","+i.top;for(e=2;e<d;e++,n++){i=b[n];k=c[e];f+="S"+(i.left-k.x)+","+(i.top-k.y)+","+i.left+","+i.top}}if(g){b=b[n];f+="Q"+
(i.left+k.x*2/3)+","+(i.top+k.y*2/3)+","+b.left+","+b.top}return f};
pv.SvgScene.curveHermiteSegments=function(b,c,e,d){var f;if(e==null){f=b.length;e=0}else f=d-e+1;d=c.length;if(d<1||f!==d&&f!==d+2)return[];var g=f!==d;f=[];var h=b[e],i=h,j=c[0],k=j,n=e+1;if(g){i=b[e+1];f.push(["M"+h.left+","+h.top,"Q"+(i.left-k.x*2/3)+","+(i.top-k.y*2/3)+","+i.left+","+i.top]);n=e+2}for(e=1;e<d;e++,n++){h=i;j=k;i=b[n];k=c[e];f.push(["M"+h.left+","+h.top,"C"+(h.left+j.x)+","+(h.top+j.y)+","+(i.left-k.x)+","+(i.top-k.y)+","+i.left+","+i.top])}if(g){b=b[n];f.push(["M"+i.left+","+i.top,
"Q"+(i.left+k.x*2/3)+","+(i.top+k.y*2/3)+","+b.left+","+b.top])}return f};pv.SvgScene.cardinalTangents=function(b,c,e,d){if(e==null){d=b.length;e=0;d=d-1}var f=[];c=(1-c)/2;var g=b[e],h=b[e+1],i=b[e+2];for(e=e+3;e<=d;e++){f.push({x:c*(i.left-g.left),y:c*(i.top-g.top)});g=h;h=i;i=b[e]}f.push({x:c*(i.left-g.left),y:c*(i.top-g.top)});return f};
pv.SvgScene.curveCardinal=function(b,c,e,d){var f;if(e==null){f=b.length;e=0;d=f-1}else f=d-e+1;if(f<=2)return"";return this.curveHermite(b,this.cardinalTangents(b,c,e,d),e,d)};pv.SvgScene.curveCardinalSegments=function(b,c,e,d){var f;if(e==null){f=b.length;e=0;d=f-1}else f=d-e+1;if(f<=2)return"";return this.curveHermiteSegments(b,this.cardinalTangents(b,c,e,d),e,d)};
pv.SvgScene.monotoneTangents=function(b,c,e){if(c==null){e=b.length;c=0}else e=e-c+1;var d=[],f=[],g=[],h=[],i=0,j;for(i=0;i<e-1;i++){j=c+i;var k=b[j+1].left-b[j].left;f[i]=Math.abs(k)<=1.0E-12?0:(b[j+1].top-b[j].top)/k}g[0]=f[0];h[0]=b[c+1].left-b[c].left;i=1;for(j=c+i;i<e-1;i++,j++){g[i]=(f[i-1]+f[i])/2;h[i]=(b[j+1].left-b[j-1].left)/2}g[i]=f[i-1];h[i]=b[j].left-b[j-1].left;for(i=0;i<e-1;i++)if(f[i]==0){g[i]=0;g[i+1]=0}for(i=0;i<e-1;i++)if(!(Math.abs(g[i])<1.0E-5||Math.abs(g[i+1])<1.0E-5)){b=g[i]/
f[i];c=g[i+1]/f[i];j=b*b+c*c;if(j>9){j=3/Math.sqrt(j);g[i]=j*b*f[i];g[i+1]=j*c*f[i]}}for(i=0;i<e;i++){f=1+g[i]*g[i];d.push({x:h[i]/3/f,y:g[i]*h[i]/3/f})}return d};pv.SvgScene.curveMonotone=function(b,c,e){var d;if(c==null){d=b.length;c=0;e=d-1}else d=e-c+1;if(d<=2)return"";return this.curveHermite(b,this.monotoneTangents(b,c,e),c,e)};
pv.SvgScene.curveMonotoneSegments=function(b,c,e){var d;if(c==null){d=b.length;c=0;e=d-1}else d=e-c+1;if(d<=2)return"";return this.curveHermiteSegments(b,this.monotoneTangents(b,c,e),c,e)};pv.SvgScene.area=function(b){var c=b.$g.firstChild,e=b.length;if(!e)return c;var d=b[0];if(d.segmented==="smart")return this.areaSegmentedSmart(c,b);if(d.segmented)return this.areaSegmentedFull(c,b);return this.areaFixed(c,b,0,e-1,true)};
pv.SvgScene.areaFixed=function(b,c,e,d,f){if(d-e+1===1)return this.lineAreaDotAlone(b,c,e);var g=c[e];if(!g.visible)return b;var h=g.fillStyle,i=g.strokeStyle;if(!h.opacity&&!i.opacity)return b;this.addFillStyleDefinition(c,h);this.addFillStyleDefinition(c,i);var j=false,k=false,n=false,o=false,r=false;switch(g.interpolate){case "basis":j=true;break;case "cardinal":k=true;break;case "monotone":n=true;break;case "step-after":o=true;break;case "step-before":r=true;break}k=j||k||n;j=[];var l;for(n=e;n<=
d;n++){l=c[n];if(l.width||l.height){for(var p=n+1;p<=d;p++){l=c[p];if(!l.width&&!l.height)break}n>e&&!o&&n--;p<=d&&!r&&p++;j.push((k&&p-n>2?this.areaPathCurve:this.areaPathStraight).call(this,c,n,p-1,g));n=p-1}}if(!j.length)return b;d=i.opacity;b=this.expect(b,"path",c,e,{"shape-rendering":g.antialias?null:"crispEdges","pointer-events":f?g.events:"none",cursor:g.cursor,d:"M"+j.join("ZM")+"Z",fill:h.color,"fill-opacity":h.opacity||null,stroke:i.color,"stroke-opacity":d||null,"stroke-width":d?g.lineWidth/
this.scale:null,"stroke-linecap":g.lineCap,"stroke-linejoin":g.lineJoin,"stroke-miterlimit":g.strokeMiterLimit,"stroke-dasharray":d?this.parseDasharray(g):null});g.svg&&this.setAttributes(b,g.svg);g.css&&this.setStyle(b,g.css);return this.append(b,c,e)};
pv.SvgScene.areaSegmentedSmart=function(b,c){return this.eachLineAreaSegment(b,c,function(e,d,f,g){var h=this.areaSegmentPaths(d,f,g),i=h.top,j=h.bottom;return this.eachLineAreaSegment(e,d,{breakOnKeyChange:true,from:f,to:g},function(k,n,o,r,l,p){l=n[o];var q=l.fillStyle,t=l.strokeStyle;this.addFillStyleDefinition(n,q);this.addFillStyleDefinition(n,t);if(o===r)return this.lineAreaDotAlone(k,n,o);r=this.areaJoinPaths(i,j,o-o,r-o-1);var x=t.opacity;p={"shape-rendering":l.antialias?null:"crispEdges",
"pointer-events":p,cursor:l.cursor,d:r,fill:q.color,"fill-opacity":q.opacity||null,stroke:t.color,"stroke-opacity":x||null,"stroke-width":x?l.lineWidth/this.scale:null,"stroke-linecap":l.lineCap,"stroke-linejoin":l.lineJoin,"stroke-miterlimit":l.strokeMiterLimit,"stroke-dasharray":x?this.parseDasharray(l):null};k=this.expect(k,"path",n,o,p,l.css);return this.append(k,n,o)})})};
pv.SvgScene.areaSegmentPaths=function(b,c,e){return this.areaSegmentCurvePaths(b,c,e)||this.areaSegmentStraightPaths(b,c,e)};
pv.SvgScene.areaSegmentCurvePaths=function(b,c,e){var d=e-c+1,f=b[c],g=f.interpolate==="basis",h=!g&&f.interpolate==="cardinal";if(g||h||f.interpolate=="monotone"){for(var i=[],j=[],k=0;k<d;k++){var n=b[e-k];i.push(b[c+k]);j.push({left:n.left+n.width,top:n.top+n.height})}if(g){b=this.curveBasisSegments(i);f=this.curveBasisSegments(j)}else if(h){b=this.curveCardinalSegments(i,f.tension);f=this.curveCardinalSegments(j,f.tension)}else{b=this.curveMonotoneSegments(i);f=this.curveMonotoneSegments(j)}if(b||
b.length)return{from:c,top:b,bottom:f}}};pv.SvgScene.areaSegmentStraightPaths=function(b,c,e){for(var d=[],f=[],g=e,h=c;c<g;c++,e--){var i=b[c],j=b[e],k=["M"+i.left+","+i.top];j=["M"+(j.left+j.width)+","+(j.top+j.height)];var n=b[c+1],o=b[e-1];switch(i.interpolate){case "step-before":k.push("V"+n.top+"H"+n.left);break;case "step-after":k.push("H"+n.left+"V"+n.top);break;default:k.push("L"+n.left+","+n.top)}j.push("L"+(o.left+o.width)+","+(o.top+o.height));d.push(k);f.push(j)}return{from:h,top:d,bottom:f}};
pv.SvgScene.areaJoinPaths=function(b,c,e,d){for(var f="",g="",h=e,i=b.length-1-d;h<=d;h++,i++){var j=b[h],k=c[i];if(h===e){j=j.join("");k="L"+k[0].substr(1)+k[1]}else{j=j[1];k=k[1]}f+=j;g+=k}return f+g+"Z"};
pv.SvgScene.areaSegmentedFull=function(b,c){var e=c.length,d,f,g=this.areaSegmentCurvePaths(c,0,e-1);if(g){d=g.top;f=g.bottom}for(g=0;g<e-1;g++){var h=c[g],i=c[g+1];if(h.visible&&i.visible){var j=h.fillStyle,k=h.strokeStyle;if(j.opacity||k.opacity){if(d){i=d[g].join("");var n="L"+f[e-g-2].join("").substr(1);i=i+n+"Z"}else{n=h;var o=i;switch(h.interpolate){case "step-before":n=i;break;case "step-after":o=h;break}i="M"+h.left+","+n.top+"L"+i.left+","+o.top+"L"+(i.left+i.width)+","+(o.top+o.height)+
"L"+(h.left+h.width)+","+(n.top+n.height)+"Z"}b=this.expect(b,"path",c,g,{"shape-rendering":h.antialias?null:"crispEdges","pointer-events":h.events,cursor:h.cursor,d:i,fill:j.color,"fill-opacity":j.opacity||null,stroke:k.color,"stroke-opacity":k.opacity||null,"stroke-width":k.opacity?h.lineWidth/this.scale:null});h.svg&&this.setAttributes(b,h.svg);h.css&&this.setStyle(b,h.css);b=this.append(b,c,g)}}}return b};
pv.SvgScene.areaPathStraight=function(b,c,e,d){for(var f=[],g=[],h=e;c<=h;c++,e--){var i=b[c],j=b[e];i=i.left+","+i.top;j=j.left+j.width+","+(j.top+j.height);if(c<h){var k=b[c+1],n=b[e-1];switch(d.interpolate){case "step-before":i+="V"+k.top;j+="H"+(n.left+n.width);break;case "step-after":i+="H"+k.left;j+="V"+(n.top+n.height);break}}f.push(i);g.push(j)}return f.concat(g).join("L")};
pv.SvgScene.areaPathCurve=function(b,c,e,d){for(var f=[],g=[],h=e;c<=h;c++,e--){var i=b[e];f.push(b[c]);g.push({left:i.left+i.width,top:i.top+i.height})}switch(d.interpolate){case "basis":b=this.curveBasis(f);d=this.curveBasis(g);break;case "cardinal":b=this.curveCardinal(f,d.tension);d=this.curveCardinal(g,d.tension);break;default:b=this.curveMonotone(f);d=this.curveMonotone(g)}return f[0].left+","+f[0].top+b+"L"+g[0].left+","+g[0].top+d};pv.SvgScene.minBarWidth=1;pv.SvgScene.minBarHeight=1;
pv.SvgScene.minBarLineWidth=0.2;
pv.SvgScene.bar=function(b){for(var c=b.$g.firstChild,e=0;e<b.length;e++){var d=b[e];if(!(!d.visible||Math.abs(d.width)<=1.0E-10||Math.abs(d.height)<=1.0E-10)){if(d.width<this.minBarWidth)d.width=this.minBarWidth;if(d.height<this.minBarHeight)d.height=this.minBarHeight;var f=d.fillStyle,g=d.strokeStyle;if(f.opacity||g.opacity){this.addFillStyleDefinition(b,f);this.addFillStyleDefinition(b,g);var h;if(g.opacity){h=d.lineWidth;h=h<1.0E-10?0:Math.max(this.minBarLineWidth,h/this.scale)}else h=null;c=
this.expect(c,"rect",b,e,{"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events,cursor:d.cursor,x:d.left,y:d.top,width:Math.max(1.0E-10,d.width),height:Math.max(1.0E-10,d.height),fill:f.color,"fill-opacity":f.opacity||null,stroke:g.color,"stroke-opacity":g.opacity||null,"stroke-width":h,"stroke-linecap":d.lineCap,"stroke-dasharray":g.opacity?this.parseDasharray(d):null});d.svg&&this.setAttributes(c,d.svg);d.css&&this.setStyle(c,d.css);c=this.append(c,b,e)}}}return c};
pv.SvgScene.dot=function(b){for(var c=b.$g.firstChild,e=0,d=b.length;e<d;e++){var f=b[e];if(f.visible){var g=f.fillStyle,h=g.opacity,i=f.strokeStyle,j=i.opacity;if(h||j){this.addFillStyleDefinition(b,g);this.addFillStyleDefinition(b,i);g={"shape-rendering":f.antialias?null:"crispEdges","pointer-events":f.events,cursor:f.cursor,fill:g.color,"fill-opacity":h||null,stroke:i.color,"stroke-opacity":j||null,"stroke-width":j?f.lineWidth/this.scale:null,"stroke-linecap":f.lineCap,"stroke-dasharray":j?this.parseDasharray(f):
null};h=f.shape||"circle";i=f.aspectRatio;j=f.shapeAngle;var k=null;if(h==="circle"||!this.hasSymbol(h))if(i===1){h="circle";g.cx=f.left;g.cy=f.top;g.r=f.shapeRadius}else{h="ellipse";g.cx=g.cy=0;k="translate("+f.left+","+f.top+") ";if(j)k+="rotate("+pv.degrees(j)+") ";g.rx=f._width/2;g.ry=f._height/2}else{var n=f.shapeRadius;n=k=n;if(i>0&&i!==1){var o=1/Math.sqrt(i);k*=i*o;n*=o}g.d=this.renderSymbol(h,f,k,n);h="path";k="translate("+f.left+","+f.top+") ";if(j)k+="rotate("+pv.degrees(j)+") "}if(k)g.transform=
k;c=this.expect(c,h,b,e,g);f.svg&&this.setAttributes(c,f.svg);f.css&&this.setStyle(c,f.css);c=this.append(c,b,e)}}}return c};
(function(b){var c={};b.registerSymbol=function(d,f){c[d.toLowerCase()]=f;return b};b.renderSymbol=function(d,f,g,h){return c[d].call(b,f,d,g,h)};b.hasSymbol=function(d){return c.hasOwnProperty(d)};b.symbols=function(){return pv.keys(c)};var e=2/Math.sqrt(3);b.registerSymbol("circle",function(){throw new Error("Not implemented as a symbol");}).registerSymbol("cross",function(d,f,g,h){d=-g;f=-h;return"M"+d+","+f+"L"+g+","+h+"M"+g+","+f+"L"+d+","+h}).registerSymbol("triangle",function(d,f,g,h){d=g*
e;f=-h;return"M0,"+h+"L"+d+","+f+" "+-d+","+f+"Z"}).registerSymbol("diamond",function(d,f,g,h){d=g*Math.SQRT2;h=h*Math.SQRT2;return"M0,"+-h+"L"+d+",0 0,"+h+" "+-d+",0Z"}).registerSymbol("square",function(d,f,g,h){d=-g;f=-h;return"M"+d+","+f+"L"+g+","+f+" "+g+","+h+" "+d+","+h+"Z"}).registerSymbol("tick",function(d,f,g,h){return"M0,0L0,"+-h*h}).registerSymbol("bar",function(d,f,g,h){d=h*h/2;return"M0,"+d+"L0,"+-d})})(pv.SvgScene);
pv.SvgScene.image=function(b){for(var c=b.$g.firstChild,e=0;e<b.length;e++){var d=b[e];if(d.visible){c=this.fill(c,b,e);if(d.image){c=this.expect(c,"foreignObject",b,e,{cursor:d.cursor,x:d.left,y:d.top,width:d.width,height:d.height});d.svg&&this.setAttributes(c,d.svg);d.css&&this.setStyle(c,d.css);var f=c.firstChild||c.appendChild(document.createElementNS(this.xhtml,"canvas"));f.$scene={scenes:b,index:e};f.style.width=d.width;f.style.height=d.height;f.width=d.imageWidth;f.height=d.imageHeight;f.getContext("2d").putImageData(d.image,
0,0)}else{c=this.expect(c,"image",b,e,{preserveAspectRatio:"none",cursor:d.cursor,x:d.left,y:d.top,width:d.width,height:d.height});d.svg&&this.setAttributes(c,d.svg);d.css&&this.setStyle(c,d.css);c.setAttributeNS(this.xlink,"xlink:href",d.url)}c=this.append(c,b,e);c=this.stroke(c,b,e)}}return c};
pv.SvgScene.label=function(b){for(var c=b.$g.firstChild,e=0;e<b.length;e++){var d=b[e];if(d.visible){var f=d.textStyle;if(f.opacity&&d.text){var g=0,h=0,i=0,j="start";switch(d.textBaseline){case "middle":i=".35em";break;case "top":i=".71em";h=d.textMargin;break;case "bottom":h="-"+d.textMargin;break}switch(d.textAlign){case "right":j="end";g="-"+d.textMargin;break;case "center":j="middle";break;case "left":g=d.textMargin;break}c=this.expect(c,"text",b,e,{"pointer-events":d.events,cursor:d.cursor,
x:g,y:h,dy:i,transform:"translate("+d.left+","+d.top+")"+(d.textAngle?" rotate("+180*d.textAngle/Math.PI+")":"")+(this.scale!=1?" scale("+1/this.scale+")":""),fill:f.color,"fill-opacity":f.opacity||null,"text-anchor":j},{font:d.font,"text-shadow":d.textShadow,"text-decoration":d.textDecoration});d.svg&&this.setAttributes(c,d.svg);d.css&&this.setStyle(c,d.css);if(c.firstChild)c.firstChild.nodeValue=d.text;else c.appendChild(document.createTextNode(d.text));c=this.append(c,b,e)}}}return c};
pv.SvgScene.line=function(b){var c=b.$g.firstChild,e=b.length;if(!e)return c;var d=b[0];if(d.segmented==="smart")return this.lineSegmentedSmart(c,b);if(e<2)return c;if(d.segmented)return this.lineSegmentedFull(c,b);return this.lineFixed(c,b)};
pv.SvgScene.lineFixed=function(b,c){var e=c.length;if(e===1)return this.lineAreaDotAlone(b,c,0);var d=c[0];if(!d.visible)return b;var f=d.fillStyle,g=d.strokeStyle;if(!f.opacity&&!g.opacity)return b;this.addFillStyleDefinition(c,f);this.addFillStyleDefinition(c,g);var h="M"+d.left+","+d.top,i=e>2;if(i)switch(d.interpolate){case "basis":h+=this.curveBasis(c);break;case "cardinal":h+=this.curveCardinal(c,d.tension);break;case "monotone":h+=this.curveMonotone(c);break;default:i=false}if(!i)for(i=1;i<
e;i++)h+=this.lineSegmentPath(c[i-1],c[i]);e=g.opacity;f={"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events,cursor:d.cursor,d:h,fill:f.color,"fill-opacity":f.opacity||null,stroke:g.color,"stroke-opacity":e||null,"stroke-width":e?d.lineWidth/this.scale:null,"stroke-linecap":d.lineCap,"stroke-linejoin":d.lineJoin,"stroke-miterlimit":d.strokeMiterLimit,"stroke-dasharray":e?this.parseDasharray(d):null};b=this.expect(b,"path",c,0,f,d.css);d.svg&&this.setAttributes(b,d.svg);return this.append(b,
c,0)};
pv.SvgScene.lineSegmentedSmart=function(b,c){return this.eachLineAreaSegment(b,c,function(e,d,f,g){var h=this.lineSegmentPaths(d,f,g);return this.eachLineAreaSegment(e,d,{breakOnKeyChange:true,from:f,to:g},function(i,j,k,n,o,r){o=j[k];var l=o.fillStyle;this.addFillStyleDefinition(j,l);var p=o.strokeStyle;this.addFillStyleDefinition(j,p);if(k===n)return this.lineAreaDotAlone(i,j,k);n=this.lineJoinPaths(h,k-k,n-k-1);var q=p.opacity;r={"shape-rendering":o.antialias?null:"crispEdges","pointer-events":r,cursor:o.cursor,
d:n,fill:l.color,"fill-opacity":l.opacity||null,stroke:p.color,"stroke-opacity":q||null,"stroke-width":q?o.lineWidth/this.scale:null,"stroke-linecap":o.lineCap,"stroke-linejoin":o.lineJoin,"stroke-miterlimit":o.strokeMiterLimit,"stroke-dasharray":q?this.parseDasharray(o):null};i=this.expect(i,"path",j,k,r,o.css);return this.append(i,j,k)})})};
pv.SvgScene.lineSegmentedFull=function(b,c){var e=c[0],d;switch(e.interpolate){case "basis":d=this.curveBasisSegments(c);break;case "cardinal":d=this.curveCardinalSegments(c,e.tension);break;case "monotone":d=this.curveMonotoneSegments(c);break}e=0;for(var f=c.length-1;e<f;e++){var g=c[e],h=c[e+1];if(g.visible&&h.visible){var i=g.strokeStyle,j=pv.FillStyle.transparent;if(i.opacity){if(g.interpolate=="linear"&&g.lineJoin=="miter"){j=i;i=pv.FillStyle.transparent;h=this.pathJoin(c[e-1],g,h,c[e+2])}else h=
d?d[e].join(""):"M"+g.left+","+g.top+this.lineSegmentPath(g,h);b=this.expect(b,"path",c,e,{"shape-rendering":g.antialias?null:"crispEdges","pointer-events":g.events,cursor:g.cursor,d:h,fill:j.color,"fill-opacity":j.opacity||null,stroke:i.color,"stroke-opacity":i.opacity||null,"stroke-width":i.opacity?g.lineWidth/this.scale:null,"stroke-linejoin":g.lineJoin});g.svg&&this.setAttributes(b,g.svg);g.css&&this.setStyle(b,g.css);b=this.append(b,c,e)}}}return b};
pv.SvgScene.lineSegmentPath=function(b,c){var e=1;switch(b.interpolate){case "polar-reverse":e=0;case "polar":var d=c.left-b.left,f=c.top-b.top;b=1-b.eccentricity;d=Math.sqrt(d*d+f*f)/(2*b);if(b<=0||b>1)break;return"A"+d+","+d+" 0 0,"+e+" "+c.left+","+c.top;case "step-before":return"V"+c.top+"H"+c.left;case "step-after":return"H"+c.left+"V"+c.top}return"L"+c.left+","+c.top};
pv.SvgScene.lineSegmentPaths=function(b,c,e){var d=b[c],f;switch(d.interpolate){case "basis":f=this.curveBasisSegments(b,c,e);break;case "cardinal":f=this.curveCardinalSegments(b,d.tension,c,e);break;case "monotone":f=this.curveMonotoneSegments(b,c,e);break}if(!f||!f.length){f=[];for(c=c+1;c<=e;c++){d=b[c-1];f.push(["M"+d.left+","+d.top,this.lineSegmentPath(d,b[c])])}}return f};pv.strokeMiterLimit=4;
pv.SvgScene.pathJoin=function(b,c,e,d){var f=[],g,h=c.lineWidth/this.scale,i=pv.vector(c.left,c.top),j=pv.vector(e.left,e.top),k=j.minus(i),n=k.perp().norm(),o=n.times(h/2),r=i.plus(o),l=i.minus(o),p=j.plus(o);o=j.minus(o);if(!b||!b.visible)f.push(l,r);else{var q=pv.vector(b.left,b.top),t=i.minus(q),x=t.perp().norm().plus(n).norm();q=this.lineIntersect(i,x,r,k);x=this.lineIntersect(i,x,l,k);g=q.minus(x).length();b=(h+b.lineWidth/this.scale)/2;g=g/b;c=c.strokeMiterLimit||pv.strokeMiterLimit;if(g<=
c)f.push(x,q);else{c=k.times(-1);c=t.norm().plus(c.norm()).norm();i=i.plus(c.times(b/2));c.dot(n)>=0?f.push(x,i,r):f.push(l,i,q)}}if(!d||!d.visible)f.push(p,o);else{i=pv.vector(d.left,d.top).minus(j);l=i.perp().norm().plus(n).norm();r=this.lineIntersect(j,l,p,k);l=this.lineIntersect(j,l,o,k);g=r.minus(l).length();d=(d.lineWidth/this.scale+h)/2;g=g/d;c=e.strokeMiterLimit||pv.strokeMiterLimit;if(g<=c)f.push(r,l);else{e=i.times(-1);k=k.norm().plus(e.norm()).norm();j=j.plus(k.times(d/2));k.dot(n)>=0?
f.push(p,j,l):f.push(r,j,o)}}n=f.shift();return"M"+n.x+","+n.y+"L"+f.map(function(w){return w.x+","+w.y}).join(" ")};pv.SvgScene.lineIntersect=function(b,c,e,d){return b.plus(c.times(e.minus(b).dot(d.perp())/c.dot(d.perp())))};pv.SvgScene.lineJoinPaths=function(b,c,e){var d=b[c].join("");for(c=c+1;c<=e;c++)d+=b[c][1];return d};pv.SvgScene.lineAreaDotAlone=function(b){return b};pv.Scene.eventsToNumber={"":0,none:0,painted:1,all:2};pv.Scene.numberToEvents=["none","painted","all"];
pv.SvgScene.eachLineAreaSegment=function(b,c,e,d){if(typeof e==="function"){d=e;e=null}var f=pv.get(e,"breakOnKeyChange",false),g=pv.get(e,"from")||0,h=pv.get(e,"to",c.length-1),i,j;if(f){i=[];j=[]}for(var k=g;k<=h;){var n=c[k];if(this.isSceneVisible(n)){g=this.eventsToNumber[n.events]||0;f&&this.lineAreaSceneKey(n,i);var o;for(n=k;;){var r=n+1;if(r>h){o=r;break}var l=c[r];if(!this.isSceneVisible(l)){o=r+1;break}g=Math.max(g,this.eventsToNumber[l.events]||0);n=r;if(f){this.lineAreaSceneKey(l,j);if(!this.equalSceneKeys(i,
j)){o=n;break}}}b=d.call(this,b,c,k,n,e,this.numberToEvents[g]);k=o}else k++}return b};pv.SvgScene.lineAreaSceneKey=function(b,c){c[0]=b.fillStyle.key;c[1]=b.strokeStyle.key;c[2]=b.lineWidth;c[3]=b.strokeDasharray||"none";c[4]=b.interpolate;return c};pv.SvgScene.isSceneVisible=function(b){return b.visible&&(b.fillStyle.opacity>0||b.strokeStyle.opacity>0)};pv.SvgScene.equalSceneKeys=function(b,c){for(var e=0,d=b.length;e<d;e++)if(b[e]!==c[e])return false;return true};
pv.SvgScene.panel=function(b){for(var c=b.$g,e=c&&c.firstChild,d=0,f=b.length;d<f;d++){var g=b[d];if(g.visible){if(!b.parent){var h=g.canvas;this.applyCanvasStyle(h);if(c&&c.parentNode!==h)e=(c=h.firstChild)&&c.firstChild;if(c){if(e&&e.tagName==="defs")e=e.nextSibling}else{c=this.createRootPanelElement();e=null;this.initRootPanelElement(c,b.mark);h.appendChild(c);b.$defs=c.appendChild(this.create("defs"));b.$g=c}c.setAttribute("width",g.width+g.left+g.right);c.setAttribute("height",g.height+g.top+
g.bottom)}h=null;if(g.overflow==="hidden"){e=this.addPanelClipPath(c,e,b,d,g);h=e.g;b.$g=c=h;e=e.next}e=this.fill(e,b,d);var i=this.scale,j=g.transform,k=g.left+j.x,n=g.top+j.y;this.scale*=j.k;if(g.children.length){g={transform:"translate("+k+","+n+")"+(j.k!=1?" scale("+j.k+")":"")};j=this.getSortedChildScenes(b,d);k=0;for(n=j.length;k<n;k++){var o=j[k];o.$g=e=this.expect(e,"g",b,d,g);this.updateAll(o);e.parentNode||c.appendChild(e);e=e.nextSibling}}this.scale=i;e=this.stroke(e,b,d);if(h){b.$g=c=
h.parentNode;e=h.nextSibling}}}return e};pv.SvgScene.applyCanvasStyle=function(b){b.style.display="inline-block"};pv.SvgScene.createRootPanelElement=function(){return this.create("svg")};pv.SvgScene.initRootPanelElement=function(b,c){b.setAttribute("font-size","10px");b.setAttribute("font-family","sans-serif");b.setAttribute("fill","none");b.setAttribute("stroke","none");b.setAttribute("stroke-width",1.5);this.disableElementSelection(b);this.listenRootPanelElement(b,c)};
pv.SvgScene.listenRootPanelElement=function(b,c){for(var e=0,d=this.events,f=d.length;e<f;e++){b.addEventListener(d[e],this.dispatch,false);c._registerBoundEvent(b,d[e],this.dispatch,false)}};
pv.SvgScene.disableElementSelection=function(b){b.setAttribute("style","-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;");if(typeof b.onselectstart!=="undefined"){b.setAttribute("unselectable","on");b.onselectstart=function(){return false}}};
pv.SvgScene.addPanelClipPath=function(b,c,e,d,f){var g=pv.id().toString(36);c=this.expect(c,"g",e,d,{"clip-path":"url(#"+g+")"});e=this.expect(c.firstChild,"clipPath",e,d,{id:g});d=e.firstChild||e.appendChild(this.create("rect"));d.setAttribute("x",f.left);d.setAttribute("y",f.top);d.setAttribute("width",f.width);d.setAttribute("height",f.height);e.parentNode||c.appendChild(e);c.parentNode||b.appendChild(c);return{g:c,next:e.nextSibling}};
pv.SvgScene.getSortedChildScenes=function(b,c){c=b[c].children;if(b.mark._zOrderChildCount){c=c.slice(0);c.sort(function(e,d){var f=e.mark._zOrder-d.mark._zOrder;if(f===0)f=e.childIndex-d.childIndex;return f})}return c};
pv.SvgScene.fill=function(b,c,e){var d=c[e],f=d.fillStyle;if(f.opacity||d.events=="all"){this.addFillStyleDefinition(c,f);b=this.expect(b,"rect",c,e,{"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events,cursor:d.cursor,x:d.left,y:d.top,width:d.width,height:d.height,fill:f.color,"fill-opacity":f.opacity,stroke:null});b=this.append(b,c,e)}return b};
pv.SvgScene.stroke=function(b,c,e){var d=c[e],f=d.strokeStyle;if(f.opacity||d.events=="all"){b=this.expect(b,"rect",c,e,{"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events=="all"?"stroke":d.events,cursor:d.cursor,x:d.left,y:d.top,width:Math.max(1.0E-10,d.width),height:Math.max(1.0E-10,d.height),fill:null,stroke:f.color,"stroke-opacity":f.opacity,"stroke-width":d.lineWidth/this.scale,"stroke-linecap":d.lineCap,"stroke-dasharray":f.opacity?this.parseDasharray(d):null});b=this.append(b,
c,e)}return b};pv.SvgScene.minRuleLineWidth=1;
pv.SvgScene.rule=function(b){for(var c=b.$g.firstChild,e=0;e<b.length;e++){var d=b[e];if(d.visible){var f=d.strokeStyle;if(f.opacity){var g=d.lineWidth;g=g<1.0E-10?0:Math.max(this.minRuleLineWidth,g/this.scale);c=this.expect(c,"line",b,e,{"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events,cursor:d.cursor,x1:d.left,y1:d.top,x2:d.left+d.width,y2:d.top+d.height,stroke:f.color,"stroke-opacity":f.opacity,"stroke-width":g,"stroke-linecap":d.lineCap,"stroke-dasharray":f.opacity?this.parseDasharray(d):
null});d.svg&&this.setAttributes(c,d.svg);d.css&&this.setStyle(c,d.css);c=this.append(c,b,e)}}}return c};
pv.SvgScene.wedge=function(b){for(var c=b.$g.firstChild,e=0;e<b.length;e++){var d=b[e];if(d.visible){var f=d.fillStyle,g=d.strokeStyle;if(f.opacity||g.opacity){var h=d.innerRadius,i=d.outerRadius,j=Math.abs(d.angle);if(j>=2*Math.PI)h=h?"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"M0,"+h+"A"+h+","+h+" 0 1,1 0,"+-h+"A"+h+","+h+" 0 1,1 0,"+h+"Z":"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"Z";else{var k=Math.min(d.startAngle,d.endAngle),n=Math.max(d.startAngle,d.endAngle),
o=Math.cos(k),r=Math.cos(n);k=Math.sin(k);n=Math.sin(n);h=h?"M"+i*o+","+i*k+"A"+i+","+i+" 0 "+(j<Math.PI?"0":"1")+",1 "+i*r+","+i*n+"L"+h*r+","+h*n+"A"+h+","+h+" 0 "+(j<Math.PI?"0":"1")+",0 "+h*o+","+h*k+"Z":"M"+i*o+","+i*k+"A"+i+","+i+" 0 "+(j<Math.PI?"0":"1")+",1 "+i*r+","+i*n+"L0,0Z"}this.addFillStyleDefinition(b,f);this.addFillStyleDefinition(b,g);c=this.expect(c,"path",b,e,{"shape-rendering":d.antialias?null:"crispEdges","pointer-events":d.events,cursor:d.cursor,transform:"translate("+d.left+
","+d.top+")",d:h,fill:f.color,"fill-rule":"evenodd","fill-opacity":f.opacity||null,stroke:g.color,"stroke-opacity":g.opacity||null,"stroke-width":g.opacity?d.lineWidth/this.scale:null,"stroke-linejoin":d.lineJoin,"stroke-miterlimit":d.strokeMiterLimit,"stroke-linecap":d.lineCap,"stroke-dasharray":g.opacity?this.parseDasharray(d):null});d.svg&&this.setAttributes(c,d.svg);d.css&&this.setStyle(c,d.css);c=this.append(c,b,e)}}}return c};
pv.Mark=function(){this.$properties=[];this.$propertiesMap={};this.$handlers={}};pv.Mark.prototype.properties={};pv.Mark.cast={};pv.Mark.prototype.property=function(b,c){if(!this.hasOwnProperty("properties"))this.properties=pv.extend(this.properties);this.properties[b]=true;pv.Mark.prototype.propertyMethod(b,false,pv.Mark.cast[b]=c);return this};
pv.Mark.prototype.localProperty=function(b,c){if(!this.hasOwnProperty("properties"))this.properties=pv.extend(this.properties);this.properties[b]=true;var e=pv.Mark.cast[b];if(c)pv.Mark.cast[b]=e=c;this.propertyMethod(b,false,e);return this};pv.Mark.prototype.def=function(b,c){this.propertyMethod(b,true);return this[b](arguments.length>1?c:null)};
pv.Mark.prototype.propertyMethod=function(b,c,e){e||(e=pv.Mark.cast[b]);this[b]=function(d,f){if(c&&this.scene){var g=this.scene.defs;if(arguments.length){g[b]={id:d==null?0:pv.id(),value:d!=null&&e?e(d):d};return this}return(g=g[b])?g.value:null}if(arguments.length){this.setPropertyValue(b,d,c,e,false,f);return this}g=this.instance();if(pv.propBuildMark===this&&pv.propBuilt[b]!==1){pv.propBuilt[b]=1;return g[b]=this.evalProperty(this.binds.properties[b])}return g[b]}};
pv.Mark.funPropertyCaller=function(b,c){function e(){var f=b.apply(this,d);return f!=null?c(f):f}var d=pv.Mark.stack;return e};
pv.Mark.prototype.setPropertyValue=function(b,c,e,d,f,g){e=!e<<1|typeof c==="function";if(e&1&&d)c=pv.Mark.funPropertyCaller(c,d);else if(c!=null&&d)c=d(c);var h=this.$propertiesMap;d=this.$properties;c={name:b,id:pv.id(),value:c,type:e,tag:g,proto:null,root:null,_proto:null};c.root=c;g=h[b];h[b]=c;if(g){b=0;for(h=d.length;b<h;b++)if(d[b]===g){d.splice(b,1);break}}d.push(c);if(f&&g&&e===3){c.proto=g;c.root=g.root}return c};
pv.Mark.prototype.intercept=function(b,c,e){this.setPropertyValue(b,c,false,pv.get(e,"noCast")?null:pv.Mark.cast[b],true,pv.get(e,"tag"));return this};pv.Mark.prototype.propertyValue=function(b,c){var e=this.$propertiesMap[b];if(e)return e.value;if(c){if(this.proto){c=this.proto._propertyValueRecursive(b);if(c!==undefined)return c}return this.defaults._propertyValueRecursive(b)}};pv.Mark.prototype._propertyValueRecursive=function(b){var c=this.$propertiesMap[b];if(c)return c.value;if(this.proto)return this.proto._propertyValueRecursive(b)};
pv.Mark.stack=[];pv.Mark.prototype.property("data").property("visible",Boolean).property("css",Object).property("svg",Object).property("left",Number).property("right",Number).property("top",Number).property("bottom",Number).property("cursor",String).property("title",String).property("reverse",Boolean).property("antialias",Boolean).property("events",pv.stringLowerCase).property("id",String);a=pv.Mark.prototype;a.childIndex=-1;a.index=-1;a.scale=1;a._zOrder=0;a.defaults=(new pv.Mark).data(function(b){return[b]}).visible(true).antialias(true).events("painted");
a.extend=function(b){this.proto=b;this.target=b.target;return this};a.add=function(b){return this.parent.add(b).extend(this)};a.zOrder=function(b){if(!arguments.length)return this._zOrder;b=+b||0;if(this._zOrder!==b){var c=this.parent;c&&this._zOrder!==0&&c._zOrderChildCount--;this._zOrder=b;c&&this._zOrder!==0&&c._zOrderChildCount++}return this};
a.anchor=function(b){return(new pv.Anchor(this)).name(b||"center").data(function(){return this.scene.target.map(function(c){return c.data})}).visible(function(){return this.scene.target[this.index].visible}).id(function(){return this.scene.target[this.index].id}).left(function(){var c=this.scene.target[this.index],e=c.width||0;switch(this.name()){case "bottom":case "top":case "center":return c.left+e/2;case "left":return null}return c.left+e}).top(function(){var c=this.scene.target[this.index],e=
c.height||0;switch(this.name()){case "left":case "right":case "center":return c.top+e/2;case "top":return null}return c.top+e}).right(function(){var c=this.scene.target[this.index];return this.name()=="left"?c.right+(c.width||0):null}).bottom(function(){var c=this.scene.target[this.index];return this.name()=="top"?c.bottom+(c.height||0):null}).textAlign(function(){switch(this.name()){case "bottom":case "top":case "center":return"center";case "right":return"right"}return"left"}).textBaseline(function(){switch(this.name()){case "right":case "left":case "center":return"middle";
case "top":return"top"}return"bottom"})};a.anchorTarget=function(){return this.target};a.margin=function(b){return this.left(b).right(b).top(b).bottom(b)};a.instance=function(b){var c=this.scene||this.parent.instance(-1).children[this.childIndex];b=b==null||this.hasOwnProperty("index")?this.index:b;return c[b<0?c.length-1:b]};
a.instances=function(b){for(var c=this,e=[],d;!(d=c.scene);){e.push({index:b.parentIndex,childIndex:c.childIndex});b=b.parent;c=c.parent}for(b=e.length;b--;){c=e[b];d=d[c.index].children[c.childIndex]}if(this.hasOwnProperty("index")){e=pv.extend(d[this.index]);e.right=e.top=e.left=e.bottom=0;return[e]}return d};a.first=function(){return this.scene[0]};a.last=function(){return this.scene[this.scene.length-1]};a.sibling=function(){return this.index==0?null:this.scene[this.index-1]};
a.cousin=function(){var b=this.parent;return(b=b&&b.sibling())&&b.children?b.children[this.childIndex][this.index]:null};a._renderId=0;a.renderId=function(){return this.root._renderId};a.render=function(){var b=this.root;if(this.parent&&!b.scene)b.render();else{b._renderId++;this.renderCore()}};
a.renderCore=function(){function b(k,n,o){k.scale=o;if(n<i){var r=n>=d.length;r&&d.unshift(null);if(k.hasOwnProperty("index"))c(k,n,o,r);else{for(var l=0,p=k.scene.length;l<p;l++){k.index=l;c(k,n,o,r)}delete k.index}r&&d.shift()}else{k.build();pv.Scene.scale=o;pv.Scene.updateAll(k.scene)}delete k.scale}function c(k,n,o,r){var l=k.scene[k.index];if(l.visible){var p=k.children,q=l.children,t=g[n],x=p[t];x.scene||t++;for(k=0;k<t;k++)p[k].scene=q[k];if(r)d[0]=l.data;b(x,n+1,o*l.transform.k);for(k=0;k<
t;k++)p[k].scene=undefined}}for(var e=this.parent,d=pv.Mark.stack,f=d.length,g=[],h=this;h.parent;h=h.parent)g.unshift(h.childIndex);var i=g.length;for(this.bind();e&&!e.hasOwnProperty("index");)e=e.parent;try{this.context(e?e.scene:undefined,e?e.index:-1,function(){b(this.root,0,1)})}catch(j){if(d.length>f)d.length=f;throw j;}};
a.bind=function(){function b(o){do for(var r=o.$properties,l=r.length;l--;){var p=r[l],q=p.name;if(c[q]){var t=e[q];if(t.type===3){t._proto=p;t=e[q]=p.root;t._proto=null}}else{c[q]=p;e[q]=p.root;p.root._proto=null;switch(q){case "data":d=p;break;case "visible":case "id":f.push(p);break;default:g[p.type].push(p);break}}}while(o=o.proto)}var c={},e={},d,f=[],g=[[],[],[],[]];b(this);b(this.defaults);var h=g[0],i=g[1].reverse(),j=g[2];g[3].reverse();var k=this;do for(var n in k.properties)n in c||j.push(c[n]=
{name:n,type:2,value:null});while(k=k.proto);if(h.length||i.length){h=h.concat(i);i=0;for(j=h.length;i<j;i++)this.propertyMethod(h[i].name,true)}else h=[];this.binds={properties:c,data:d,defs:h,required:f,optional:pv.blend(g)}};
a.build=function(){var b=pv.Mark.stack,c=this.scene;if(!c){c=this.scene=[];c.mark=this;c.type=this.type;c.childIndex=this.childIndex;var e=this.parent;if(e){c.parent=e.scene;c.parentIndex=e.index}}if(this.target)c.target=this.target.instances(c);e=this.binds.defs;if(e.length)for(var d=c.defs||(c.defs={}),f=0,g=e.length;f<g;f++){var h=e[f],i=d[h.name];if(!i||h.id>i.id)d[h.name]={id:0,value:h.type&1?h.value.apply(this,b):h.value}}e=this.evalProperty(this.binds.data);d=e.length;if(c.length=d){g=pv.Mark.prototype;
b.unshift(null);h=pv.propBuildMark;i=pv.propBuilt;pv.propBuildMark=this;try{for(f=0;f<d;f++){g.index=this.index=f;pv.propBuilt={};var j=c[f];if(j)j._state&&delete j._state;else j=c[f]={};j.data=b[0]=e[f];this.preBuildInstance(j);this.buildInstance(j)}}finally{g.index=-1;delete this.index;b.shift();pv.propBuildMark=h;pv.propBuilt=i}}return this};a.instanceState=function(b){b||(b=this.instance());return b?b._state||(b._state={}):null};a.preBuildInstance=function(){};
a.buildInstance=function(b){this.buildProperties(b,this.binds.required);if(b.visible){this.buildProperties(b,this.binds.optional);this.buildImplied(b)}};
(function(){var b,c=pv.Mark.stack,e=[function(d){return this.scene.defs[d.name].value},null,function(d){return d.value},function(d){b=d.proto||d._proto;return d.value.apply(this,c)}];e[1]=e[0];pv.Mark.prototype.buildProperties=function(d,f){var g=pv.propBuilt,h=!g;if(h){pv.propBuildMark=this;pv.propBuilt=g={}}for(var i=b,j=0,k=f.length;j<k;j++){var n=f[j],o=n.name;if(!(o in g)){g[o]=1;d[o]=e[n.type].call(this,n)}}b=i;if(h)pv.propBuildMark=pv.propBuilt=null};pv.Mark.prototype.evalProperty=function(d){var f=
b;d=e[d.type].call(this,d);b=f;return d};pv.Mark.prototype.evalInPropertyContext=function(d,f){var g=b;b=f;d=d.apply(this,c);b=g;return d};pv.Mark.prototype.delegate=function(d,f){if(b&&(!f||b.tag===f)){f=this.evalProperty(b);if(f!==undefined)return f}return d};pv.Mark.prototype.delegateExcept=function(d,f){if(b&&(!f||b.tag!==f)){f=this.evalProperty(b);if(f!==undefined)return f}return d};pv.Mark.prototype.hasDelegate=function(d){return!!b&&(!d||b.tag===d)}})();a=pv.Mark.prototype;
a.buildImplied=function(b){var c=b.left,e=b.right,d=b.top,f=b.bottom,g=this.properties,h=g.width?b.width:0,i=g.height?b.height:0,j,k;if(h==null||e==null||c==null){j=this.parent&&this.parent.instance();k=true;var n=j?j.width:h+c+e;if(h==null)h=n-(e=e||0)-(c=c||0);else if(e==null)if(c==null)c=e=(n-h)/2;else e=n-h-c;else c=n-h-e}if(i==null||f==null||d==null){k||(j=this.parent&&this.parent.instance());j=j?j.height:i+d+f;if(i==null)i=j-(d=d||0)-(f=f||0);else if(f==null)f=d==null?(d=(j-i)/2):j-i-d;else d=
j-i-f}b.left=c;b.right=e;b.top=d;b.bottom=f;if(g.width)b.width=h;if(g.height)b.height=i;if(g.textStyle&&!b.textStyle)b.textStyle=pv.FillStyle.transparent;if(g.fillStyle&&!b.fillStyle)b.fillStyle=pv.FillStyle.transparent;if(g.strokeStyle&&!b.strokeStyle)b.strokeStyle=pv.FillStyle.transparent};
a.mouse=function(){var b=this.root.canvas(),c=pv.event,e=c&&c.pageX||0;c=c&&c.pageY||0;var d=pv.elementOffset(b);if(d){b=pv.cssStyle(b);e-=d.left+parseFloat(b("paddingLeft")||0);c-=d.top+parseFloat(b("paddingTop")||0)}b=pv.Transform.identity;var f=this.properties.transform?this:this.parent;d=[];do d.push(f);while(f=f.parent);for(;f=d.pop();){f=f.instance();b=b.translate(f.left,f.top).times(f.transform)}b=b.invert();return pv.vector(e*b.k+b.x,c*b.k+b.y)};
a.event=function(b,c){c=pv.functor(c);var e=this.$handlers[b];if(e)if(e instanceof Array)e.push(c);else e=[e,c];else e=c;this.$hasHandlers=true;this.$handlers[b]=e;return this};
a.context=function(b,c,e){function d(o,r){pv.Mark.scene=o;g.index=r;if(o){var l=o.mark,p=l,q=[];do{q.push(p);h.push(o[r].data);p.index=r;p.scene=o;if(p=p.parent){r=o.parentIndex;o=o.parent}}while(p);o=1;r=q.length-1;if(r>0){do{p=q[r--];p.scale=o;o*=p.scene[p.index].transform.k}while(r)}l.scale=o;q=l.children;var t;if(q&&(t=q.length)>0){p=l.scene[l.index];o*=p.transform.k;l=p.children;for(r=t;r--;){p=q[r];p.scene=l[r];p.scale=o}}}}function f(o){if(o){var r=o.mark,l=r.children;if(l)for(var p=l.length;p--;){o=
l[p];o.scene=undefined;o.scale=1}o=r;l=0;do{l++;delete o.index;if(r=o.parent){o.scene=undefined;o.scale=1}}while(o=r);if(l)h.length-=l}}var g=pv.Mark.prototype,h=pv.Mark.stack,i=pv.Mark.scene,j=g.index;if(b&&b===i&&c===j)try{e.apply(this,h)}catch(k){pv.error(k);throw k;}finally{pv.Mark.scene=i;g.index=j}else{f(i,j);d(b,c);try{e.apply(this,h)}catch(n){pv.error(n);throw n;}finally{f(b,c);d(i,j)}}};
a.getEventHandler=function(b,c,e,d){var f=this.$handlers[b];if(f)return[f,c,e,d];return this.getParentEventHandler(b,c,e,d)};a.getParentEventHandler=function(b,c,e,d){if(e=c.parent)return e.mark.getEventHandler(b,e,c.parentIndex,d)};
pv.Mark.dispatch=function(b,c,e,d){var f=c.mark.root;if(f.$transition)return true;var g;if(f=f.$interceptors&&f.$interceptors[b])for(var h=0,i=f.length;h<i;h++){if(g=f[h](b,d))break;if(g===false)return true}if(!g){g=c.mark.getEventHandler(b,c,e,d);if(!g)return false}return this.handle.apply(this,g)};
pv.Mark.handle=function(b,c,e,d){var f=c.mark;f.context(c,e,function(){var g=pv.Mark.stack.concat(d),h,i,j;if(b instanceof Array){var k;h=0;for(i=b.length;h<i;h++)if((j=b[h].apply(f,g))&&j.render)(k||(k=[])).push(j);if(k){h=0;for(i=k.length;h<i;h++)k[h].render()}}else(j=b.apply(f,g))&&j.render&&j.render()});return true};a=pv.Mark.prototype;a.addEventInterceptor=function(b,c,e){var d=this.root;if(d){d=d.$interceptors||(d.$interceptors={});b=d[b]||(d[b]=[]);e?b.unshift(c):b.push(c)}};
a.eachInstance=function(b,c){function e(h,i,j){var k=h.length;if(k>0){var n;i===g||(n=f[i]);for(var o=0;o<k;o++){var r=h[o];if(r.visible)if(i===g)b.call(c,h,o,j);else{var l=r.children[n];if(l){r=j.times(r.transform).translate(r.left,r.top);e(l,i+1,r)}}}}}for(var d=this,f=[];d.parent;){f.unshift(d.childIndex);d=d.parent}if(d=d.scene){var g=f.length;e(d,0,pv.Transform.identity)}};
a.toScreenTransform=function(){var b=pv.Transform.identity;if(this instanceof pv.Panel)b=b.translate(this.left(),this.top()).times(this.transform());var c=this.parent;if(c){do b=b.translate(c.left(),c.top()).times(c.transform());while(c=c.parent)}return b};a.transition=function(){return new pv.Transition(this)};a.on=function(b){return this["$"+b]=new pv.Transient(this)};
a.getShape=function(b,c,e){var d=b[c];if(!d.visible)return null;if(e==null)e=0;var f="_shape_inset_"+e;return d[f]||(d[f]=this.getShapeCore(b,c,e))};a.getShapeCore=function(b,c,e){var d=b[c];b=d.left;c=d.top;var f=d.width;d=d.height;if(e>0&&e<=1){var g=e*f;e=e*d;b+=g;c+=e;f-=g*2;d-=e*2}return new pv.Shape.Rect(b,c,f,d)};a.pointingRadiusMax=function(b){if(arguments.length){b=+b;this._pointingRadiusMax=isNaN(b)||b<0?0:b;return this}return this._pointingRadiusMax};a._pointingRadiusMax=Infinity;
pv.Anchor=function(b){pv.Mark.call(this);this.target=b;this.parent=b.parent};pv.Anchor.prototype=pv.extend(pv.Mark).property("name",String);pv.Anchor.prototype.extend=function(b){this.proto=b;return this};pv.Area=function(){pv.Mark.call(this)};pv.Area.castSegmented=function(b){if(!b)return"";b=String(b).toLowerCase();switch(b){case "smart":case "full":break;default:b="full"}return b};
pv.Area.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("lineJoin",pv.stringLowerCase).property("strokeMiterLimit",Number).property("lineCap",pv.stringLowerCase).property("strokeDasharray",pv.stringLowerCase).property("strokeStyle",pv.fillStyle).property("fillStyle",pv.fillStyle).property("segmented",pv.Area.castSegmented).property("interpolate",pv.stringLowerCase).property("tension",Number);pv.Area.prototype.type="area";
pv.Area.prototype.defaults=(new pv.Area).extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(pv.Colors.category20().by(pv.parent)).interpolate("linear").tension(0.7).lineJoin("miter").strokeMiterLimit(8).lineCap("butt").strokeDasharray("none");pv.Area.prototype.buildImplied=function(b){if(b.height==null)b.height=0;if(b.width==null)b.width=0;pv.Mark.prototype.buildImplied.call(this,b)};
pv.Area.fixed={lineWidth:1,lineJoin:1,strokeMiterLimit:1,lineCap:1,strokeStyle:1,strokeDasharray:1,fillStyle:1,segmented:1,interpolate:1,tension:1};a=pv.Area.prototype;a.bind=function(){pv.Mark.prototype.bind.call(this);var b=this.binds,c=b.required;b=b.optional;for(var e=0,d=b.length;e<d;e++){var f=b[e];f.fixed=f.name in pv.Area.fixed;if(f.name=="segmented"){c.push(f);b.splice(e,1);e--;d--}}this.binds.$required=c;this.binds.$optional=b};
a.buildInstance=function(b){var c=this.binds;if(this.index){var e=c.fixed;if(!e){e=c.fixed=[];function d(i){return!i.fixed||(e.push(i),false)}c.required=c.required.filter(d);if(!this.scene[0].segmented)c.optional=c.optional.filter(d)}if(c=e.length)for(var f=this.scene[0],g=0;g<c;g++){var h=e[g].name;b[h]=f[h]}}else{c.required=c.$required;c.optional=c.$optional;c.fixed=null}pv.Mark.prototype.buildInstance.call(this,b)};a.anchor=function(b){return pv.Mark.prototype.anchor.call(this,b).interpolate(function(){return this.scene.target[this.index].interpolate}).eccentricity(function(){return this.scene.target[this.index].eccentricity}).tension(function(){return this.scene.target[this.index].tension})};
a.getEventHandler=function(b,c,e,d){var f=c[e];if(!(pv.Scene.mousePositionEventSet[b]===1&&(!f.segmented||f.segmented==="smart")))return pv.Mark.prototype.getEventHandler.call(this,b,c,e,d);f=b==="mousemove"?this.$handlers.mouseover:null;var g=this.$handlers[b],h=g||f,i;if(h){i=this.getNearestInstanceToMouse(c,e);if(f&&!this.filterMouseMove(c,i)){f=null;h=g}}if(!h)return this.getParentEventHandler(b,c,e,d);if(g&&f)h=[].concat(g,f);return[h,c,i,d]};
a.filterMouseMove=function(b,c){var e=this._mouseOverScene;if(!e||e!==b||this._mouseOverIndex!==c){this._mouseOverScene=b;this._mouseOverIndex=c;return true}};a.getNearestInstanceToMouse=function(b,c){for(var e=this.mouse(),d=Infinity,f=null,g=c,h=b.length;g<h;g++){var i=this.getShape(b,g);if(i){if(i.containsPoint(e))return g;i=i.distance2(e).dist2;if(i<d){d=i;f=g}}}return f!=null?f:c};
a.getShapeCore=function(b,c){var e=b[c],d=e.width||0,f=e.height||0,g=e.left;e=e.top;var h=c+1<b.length?b[c+1]:null;if(!h||!h.visible)return new pv.Shape.Line(g,e,g+d,e+f);b=h.left;c=h.top;var i=h.height||0;h=h.width||0;return new pv.Shape.Polygon([new pv.Vector(g,e),new pv.Vector(b,c),new pv.Vector(b+h,c+i),new pv.Vector(g+d,e+f)])};pv.Bar=function(){pv.Mark.call(this)};
pv.Bar.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.fillStyle).property("fillStyle",pv.fillStyle).property("lineCap",pv.stringLowerCase).property("strokeDasharray",pv.stringLowerCase);pv.Bar.prototype.type="bar";pv.Bar.prototype.defaults=(new pv.Bar).extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(pv.Colors.category20().by(pv.parent)).lineCap("butt").strokeDasharray("none");pv.Dot=function(){pv.Mark.call(this)};
pv.Dot.prototype=pv.extend(pv.Mark).property("shape",pv.stringLowerCase).property("shapeAngle",Number).property("shapeRadius",Number).property("shapeSize",Number).property("aspectRatio",Number).property("lineWidth",Number).property("strokeStyle",pv.fillStyle).property("lineCap",pv.stringLowerCase).property("strokeDasharray",pv.stringLowerCase).property("fillStyle",pv.fillStyle);a=pv.Dot.prototype;a.type="dot";a.defaults=(new pv.Dot).extend(pv.Mark.prototype.defaults).shape("circle").aspectRatio(1).lineWidth(1.5).strokeStyle(pv.Colors.category10().by(pv.parent)).lineCap("butt").strokeDasharray("none");
a.anchor=function(b){return pv.Mark.prototype.anchor.call(this,b).left(function(){var c=this.scene.target[this.index];switch(this.name()){case "bottom":case "top":case "center":return c.left;case "left":return null}return c.left+c._width/2}).right(function(){var c=this.scene.target[this.index];return this.name()=="left"?c.right+c._width/2:null}).top(function(){var c=this.scene.target[this.index];switch(this.name()){case "left":case "right":case "center":return c.top;case "top":return null}return c.top+
c._height/2}).bottom(function(){var c=this.scene.target[this.index];return this.name()=="top"?c.bottom+c._height/2:null}).textAlign(function(){switch(this.name()){case "left":return"right";case "bottom":case "top":case "center":return"center"}return"left"}).textBaseline(function(){switch(this.name()){case "right":case "left":case "center":return"middle";case "bottom":return"top"}return"bottom"})};
a.buildImplied=function(b){var c=b.shapeRadius,e=b.shapeSize,d=b.aspectRatio||1;if(c==null)if(e==null){b.shapeSize=20.25;c=b.shapeRadius=4.5}else c=b.shapeRadius=Math.sqrt(e);else if(e==null)b.shapeSize=c*c;if(d===1||d<0)c=d=2*c;else{c=2*c/Math.sqrt(d);d=d*c}b._height=c;b._width=d;pv.Mark.prototype.buildImplied.call(this,b)};a.width=function(){return this.instance()._width};a.height=function(){return this.instance()._height};
a.getShapeCore=function(b,c){b=b[c];c=b._width;var e=b._height,d=b.left,f=b.top;switch(b.shape){case "diamond":c*=Math.SQRT2;e*=Math.SQRT2;case "square":case "cross":return new pv.Shape.Rect(d-e/2,f-c/2,e,c)}return new pv.Shape.Circle(d,f,b.shapeRadius)};pv.Label=function(){pv.Mark.call(this)};
pv.Label.prototype=pv.extend(pv.Mark).property("text",String).property("font",String).property("textAngle",Number).property("textStyle",pv.color).property("textAlign",pv.stringLowerCase).property("textBaseline",pv.stringLowerCase).property("textMargin",Number).property("textDecoration",String).property("textShadow",String);pv.Label.prototype.type="label";pv.Label.prototype.defaults=(new pv.Label).extend(pv.Mark.prototype.defaults).events("none").text(pv.identity).font("10px sans-serif").textAngle(0).textStyle("black").textAlign("left").textBaseline("bottom").textMargin(3);
pv.Label.prototype.getShapeCore=function(b,c,e){b=b[c];var d=pv.Text.measure(b.text,b.font);c=b.left;var f=b.top,g=d.width;d=d.height;if(e>0&&e<=1){var h=e*g;e=e*d;c+=h;f+=e;g-=h*2;d-=e*2}return pv.Label.getPolygon(g,d,b.textAlign,b.textBaseline,b.textAngle,b.textMargin).apply(pv.Transform.identity.translate(c,f))};
pv.Label.getPolygon=function(b,c,e,d,f,g){var h,i;switch(d){case "middle":i=c/2;break;case "top":i=g+c;break;case "bottom":i=-g;break}switch(e){case "right":h=-g-b;break;case "center":h=-b/2;break;case "left":h=g;break}e=new pv.Vector(h,i);b=e.plus(b,0);d=b.plus(0,-c);c=e.plus(0,-c);if(f!==0){e=e.rotate(f);b=b.rotate(f);c=c.rotate(f);d=d.rotate(f)}return new pv.Shape.Polygon([e,b,d,c])};pv.Line=function(){pv.Mark.call(this)};
pv.Line.prototype=pv.extend(pv.Mark).property("lineWidth",Number).property("lineJoin",pv.stringLowerCase).property("strokeMiterLimit",Number).property("lineCap",pv.stringLowerCase).property("strokeStyle",pv.fillStyle).property("strokeDasharray",pv.stringLowerCase).property("fillStyle",pv.fillStyle).property("segmented",pv.Area.castSegmented).property("interpolate",pv.stringLowerCase).property("eccentricity",Number).property("tension",Number);a=pv.Line.prototype;a.type="line";a.defaults=(new pv.Line).extend(pv.Mark.prototype.defaults).lineWidth(1.5).strokeStyle(pv.Colors.category10().by(pv.parent)).interpolate("linear").eccentricity(0).tension(0.7).lineJoin("miter").strokeMiterLimit(8).lineCap("butt").strokeDasharray("none");
a.bind=pv.Area.prototype.bind;a.buildInstance=pv.Area.prototype.buildInstance;a.getEventHandler=pv.Area.prototype.getEventHandler;a.getNearestInstanceToMouse=pv.Area.prototype.getNearestInstanceToMouse;a.filterMouseMove=pv.Area.prototype.filterMouseMove;
a.anchor=function(b){return pv.Area.prototype.anchor.call(this,b).textAlign(function(){switch(this.name()){case "left":return"right";case "bottom":case "top":case "center":return"center";case "right":return"left"}}).textBaseline(function(){switch(this.name()){case "right":case "left":case "center":return"middle";case "top":return"bottom";case "bottom":return"top"}})};
a.getShapeCore=function(b,c){var e=b[c];b=c+1<b.length?b[c+1]:null;if(b==null||!b.visible)return new pv.Shape.Point(e.left,e.top);return new pv.Shape.Line(e.left,e.top,b.left,b.top)};pv.Rule=function(){pv.Mark.call(this)};pv.Rule.prototype=pv.extend(pv.Mark).property("width",Number).property("height",Number).property("lineWidth",Number).property("strokeStyle",pv.fillStyle).property("lineCap",pv.stringLowerCase).property("strokeDasharray",pv.stringLowerCase);a=pv.Rule.prototype;a.type="rule";
a.defaults=(new pv.Rule).extend(pv.Mark.prototype.defaults).lineWidth(1).strokeStyle("black").antialias(false).lineCap("butt").strokeDasharray("none");a.anchor=pv.Line.prototype.anchor;a.buildImplied=function(b){var c=b.left,e=b.right;if(b.width!=null||c==null&&e==null||e!=null&&c!=null)b.height=0;else b.width=0;pv.Mark.prototype.buildImplied.call(this,b)};a.getShapeCore=function(b,c){b=b[c];return new pv.Shape.Line(b.left,b.top,b.left+b.width,b.top+b.height)};
pv.Panel=function(){pv.Bar.call(this);this.children=[];this.root=this;this.$dom=pv.$&&pv.$.s};pv.Panel.prototype=pv.extend(pv.Bar).property("transform").property("overflow",pv.stringLowerCase).property("canvas",function(b){return typeof b==="string"?document.getElementById(b):b});a=pv.Panel.prototype;a.type="panel";a.isPointingBarrier=false;a._zOrderChildCount=0;a.defaults=(new pv.Panel).extend(pv.Bar.prototype.defaults).fillStyle(null).overflow("visible");
a.anchor=function(b){b=pv.Bar.prototype.anchor.call(this,b);b.parent=this;return b};a.add=function(b){b=new b;b.parent=this;b.root=this.root;b.childIndex=this.children.length;this.children.push(b);(+b._zOrder||0)!==0&&this._zOrderChildCount++;return b};a.bind=function(){pv.Mark.prototype.bind.call(this);for(var b=this.children,c=0,e=b.length;c<e;c++)b[c].bind()};
a.buildInstance=function(b){pv.Bar.prototype.buildInstance.call(this,b);if(b.visible){var c=this.scale*b.transform.k;pv.Mark.prototype.index=-1;for(var e=this.children,d=b.children||(b.children=[]),f=0,g=e.length;f<g;f++){b=e[f];b.scene=d[f];b.scale=c;b.build()}for(f=g;f--;){b=e[f];d[f]=b.scene;delete b.scene;delete b.scale}d.length=g}};
a.buildImplied=function(b){if(!this.parent&&!this._buildRootInstanceImplied(b))b.visible=false;else{if(!b.transform)b.transform=pv.Transform.identity;pv.Mark.prototype.buildImplied.call(this,b)}};a._buildRootInstanceImplied=function(b){var c=b.canvas;if(c){if(!this._rootInstanceStealCanvas(b,c))return false;this._rootInstanceInitCanvas(b,c)}else b.canvas=this._rootInstanceGetInlineCanvas(b);return true};
a._rootInstanceStealCanvas=function(b,c){b=c.$panel;if(b!==this){if(b){if(this.$lastCreateId)return false;b._disposeRootPanel();this._updateCreateId(c)}c.$panel=this;pv.removeChildren(c)}else this._updateCreateId(c);return true};a._registerBoundEvent=function(b,c,e,d){if(b.removeEventListener)(this._boundEvents||(this._boundEvents=[])).push([b,c,e,d])};
a.dispose=function(){var b=this.root,c=b.scene;b._disposeRootPanel();var e=c?b.canvas():null;b.canvas(null);if(e)e.$panel=null;b.binds=null;if(c){c.$defs=null;c.$g=null;b.scene=null}};a._disposeRootPanel=function(){var b=this.$transition;b&&b.stop();if(b=this._boundEvents){this._boundEvents=null;for(var c=0,e=b.length;c<e;c++){var d=b[c];d[0].removeEventListener(d[1],d[2],d[3])}}};
a._rootInstanceInitCanvas=function(b,c){var e,d;if(b.width==null){d=pv.cssStyle(c);e=parseFloat(d("width")||0);b.width=e-b.left-b.right}if(b.height==null){d||(d=pv.cssStyle(c));c=parseFloat(d("height")||0);b.height=c-b.top-b.bottom}};
a._rootInstanceGetInlineCanvas=function(){var b=this.$canvas||(this.$canvas=[]),c;if(!(c=b[this.index])){c=b[this.index]=document.createElement("span");if(this.$dom)this.$dom.parentNode.insertBefore(c,this.$dom);else{for(b=document.body;b.lastChild&&b.lastChild.tagName;)b=b.lastChild;if(b!=document.body)b=b.parentNode;b.appendChild(c)}}return c};a._updateCreateId=function(b){this.$lastCreateId=b.$pvCreateId=(b.$pvCreateId||0)+1};pv.Image=function(){pv.Bar.call(this)};
pv.Image.prototype=pv.extend(pv.Bar).property("url",String).property("imageWidth",Number).property("imageHeight",Number);a=pv.Image.prototype;a.type="image";a.defaults=(new pv.Image).extend(pv.Bar.prototype.defaults).fillStyle(null);a.image=function(b){this.$image=function(){var c=b.apply(this,arguments);return c==null?pv.Color.transparent:typeof c=="string"?pv.color(c):c};return this};
a.bind=function(){pv.Bar.prototype.bind.call(this);var b=this.binds,c=this;do b.image=c.$image;while(!b.image&&(c=c.proto))};
a.buildImplied=function(b){pv.Bar.prototype.buildImplied.call(this,b);if(b.visible){if(b.imageWidth==null)b.imageWidth=b.width;if(b.imageHeight==null)b.imageHeight=b.height;if(b.url==null&&this.binds.image){var c=this.$canvas||(this.$canvas=document.createElement("canvas")),e=c.getContext("2d"),d=b.imageWidth,f=b.imageHeight,g=pv.Mark.stack;c.width=d;c.height=f;b=(b.image=e.createImageData(d,f)).data;g.unshift(null,null);for(e=c=0;c<f;c++){g[1]=c;for(var h=0;h<d;h++){g[0]=h;var i=this.binds.image.apply(this,
g);b[e++]=i.r;b[e++]=i.g;b[e++]=i.b;b[e++]=255*i.a}}g.splice(0,2)}}};pv.Wedge=function(){pv.Mark.call(this)};
pv.Wedge.prototype=pv.extend(pv.Mark).property("startAngle",Number).property("endAngle",Number).property("angle",Number).property("innerRadius",Number).property("outerRadius",Number).property("lineWidth",Number).property("strokeStyle",pv.fillStyle).property("lineJoin",pv.stringLowerCase).property("strokeMiterLimit",Number).property("lineCap",pv.stringLowerCase).property("strokeDasharray",pv.stringLowerCase).property("fillStyle",pv.fillStyle);a=pv.Wedge.prototype;a.type="wedge";
a.defaults=(new pv.Wedge).extend(pv.Mark.prototype.defaults).startAngle(function(){var b=this.sibling();return b?b.endAngle:-Math.PI/2}).innerRadius(0).lineWidth(1.5).strokeStyle(null).fillStyle(pv.Colors.category20().by(pv.index)).lineJoin("miter").strokeMiterLimit(8).lineCap("butt").strokeDasharray("none");a.midRadius=function(){return(this.innerRadius()+this.outerRadius())/2};a.midAngle=function(){return(this.startAngle()+this.endAngle())/2};
a.anchor=function(b){function c(f){return f.innerRadius||f.angle<2*Math.PI}function e(f){return(f.innerRadius+f.outerRadius)/2}function d(f){return(f.startAngle+f.endAngle)/2}return pv.Mark.prototype.anchor.call(this,b).left(function(){var f=this.scene.target[this.index];if(c(f))switch(this.name()){case "outer":return f.left+f.outerRadius*Math.cos(d(f));case "inner":return f.left+f.innerRadius*Math.cos(d(f));case "start":return f.left+e(f)*Math.cos(f.startAngle);case "center":return f.left+e(f)*Math.cos(d(f));
case "end":return f.left+e(f)*Math.cos(f.endAngle)}return f.left}).top(function(){var f=this.scene.target[this.index];if(c(f))switch(this.name()){case "outer":return f.top+f.outerRadius*Math.sin(d(f));case "inner":return f.top+f.innerRadius*Math.sin(d(f));case "start":return f.top+e(f)*Math.sin(f.startAngle);case "center":return f.top+e(f)*Math.sin(d(f));case "end":return f.top+e(f)*Math.sin(f.endAngle)}return f.top}).textAlign(function(){var f=this.scene.target[this.index];if(c(f))switch(this.name()){case "outer":return pv.Wedge.upright(d(f))?
"right":"left";case "inner":return pv.Wedge.upright(d(f))?"left":"right"}return"center"}).textBaseline(function(){var f=this.scene.target[this.index];if(c(f))switch(this.name()){case "start":return pv.Wedge.upright(f.startAngle)?"top":"bottom";case "end":return pv.Wedge.upright(f.endAngle)?"bottom":"top"}return"middle"}).textAngle(function(){var f=this.scene.target[this.index],g=0;if(c(f))switch(this.name()){case "center":case "inner":case "outer":g=d(f);break;case "start":g=f.startAngle;break;case "end":g=
f.endAngle;break}return pv.Wedge.upright(g)?g:g+Math.PI})};pv.Wedge.upright=function(b){b%=2*Math.PI;b=b<0?2*Math.PI+b:b;return b<Math.PI/2||b>=3*Math.PI/2};pv.Wedge.prototype.buildImplied=function(b){if(b.angle==null)b.angle=b.endAngle-b.startAngle;else if(b.endAngle==null)b.endAngle=b.startAngle+b.angle;pv.Mark.prototype.buildImplied.call(this,b)};pv.Wedge.prototype.getShapeCore=function(b,c){b=b[c];return new pv.Shape.Wedge(b.left,b.top,b.innerRadius,b.outerRadius,b.startAngle,b.angle)};
pv.Ease=function(){function b(p){return function(q){return 1-p(1-q)}}function c(p){return function(q){return 0.5*(q<0.5?p(2*q):2-p(2-2*q))}}function e(p){return function(q){return q<0?0:q>1?1:Math.pow(q,p)}}function d(p){return 1-Math.cos(p*Math.PI/2)}function f(p){return p?Math.pow(2,10*(p-1))-0.001:0}function g(p){return-(Math.sqrt(1-p*p)-1)}function h(p,q){var t;q||(q=0.45);if(!p||p<1){p=1;t=q/4}else t=q/(2*Math.PI)*Math.asin(1/p);return function(x){return x<=0||x>=1?x:-(p*Math.pow(2,10*--x)*Math.sin((x-
t)*2*Math.PI/q))}}function i(p){p||(p=1.70158);return function(q){return q*q*((p+1)*q-p)}}function j(p){return p<1/2.75?7.5625*p*p:p<2/2.75?7.5625*(p-=1.5/2.75)*p+0.75:p<2.5/2.75?7.5625*(p-=2.25/2.75)*p+0.9375:7.5625*(p-=2.625/2.75)*p+0.984375}var k=e(2),n=e(3),o=h(),r=i(),l={linear:pv.identity,"quad-in":k,"quad-out":b(k),"quad-in-out":c(k),"quad-out-in":c(b(k)),"cubic-in":n,"cubic-out":b(n),"cubic-in-out":c(n),"cubic-out-in":c(b(n)),"sin-in":d,"sin-out":b(d),"sin-in-out":c(d),"sin-out-in":c(b(d)),
"exp-in":f,"exp-out":b(f),"exp-in-out":c(f),"exp-out-in":c(b(f)),"circle-in":g,"circle-out":b(g),"circle-in-out":c(g),"circle-out-in":c(b(g)),"elastic-in":o,"elastic-out":b(o),"elastic-in-out":c(o),"elastic-out-in":c(b(o)),"back-in":r,"back-out":b(r),"back-in-out":c(r),"back-out-in":c(b(r)),"bounce-in":j,"bounce-out":b(j),"bounce-in-out":c(j),"bounce-out-in":c(b(j))};pv.ease=function(p){return l[p]};return{reverse:b,reflect:c,linear:function(){return pv.identity},sin:function(){return d},exp:function(){return f},
circle:function(){return g},elastic:h,back:i,bounce:j,poly:e}}();pv.Transient=function(b){pv.Mark.call(this);this.fillStyle(null).strokeStyle(null).textStyle(null);this.on=function(c){return b.on(c)}};pv.Transient.prototype=pv.extend(pv.Mark);
(function(){function b(j){for(var k={},n=j.length;n--;){var o=j[n],r=o.id;if(r)k[r]=o}return k}function c(j,k,n,o){var r;if(k in h){var l=pv.Scale.interpolator(n[k],o[k]);r=function(p){n[k]=l(p)}}else r=function(p){if(p>0.5)n[k]=o[k]};r.next=j.head;j.head=r}function e(j,k,n){for(var o in k)o!=="children"&&k[o]!=n[o]&&c(j,o,k,n);if(k=k.children){n=n.children;o=0;for(var r=k.length;o<r;o++)f(j,k[o],n[o])}}function d(j,k,n,o){var r=Object.create(j[k]),l=j.mark,p=l.root.scene,q;if(o.target&&(q=o.target[o.length])){j=
Object.create(j);j.target=Object.create(o.target);j.target[k]=q}n||(n=i);var t=n.$properties,x=n.$propertiesMap;t=l.binds.optional.filter(function(w){return!(w.name in x)}).concat(t);l.context(j,k,function(){this.buildProperties(r,t);this.buildImplied(r)});l.root.scene=p;return r}function f(j,k,n){for(var o=k.mark,r=b(k),l=b(n),p,q,t=0,x=k.length;t<x;t++){p=k[t];q=p.id?l[p.id]:n[t];p.index=t;if(p.visible){if(!(q&&q.visible)){var w=d(k,t,o.$exit,n);p.transition=q?2:(n.push(w),1);q=w}e(j,p,q)}}t=0;
for(x=n.length;t<x;t++){q=n[t];p=q.id?r[q.id]:k[t];if(!(p&&p.visible)&&q.visible){l=d(n,t,o.$enter,k);if(p)k[p.index]=l;else k.push(l);e(j,l,q)}}}function g(j){for(var k=0,n=0;k<j.length;k++){var o=j[k];if(o.transition!=1){j[n++]=o;if(o.transition==2)o.visible=false;o.children&&o.children.forEach(g)}}j.length=n}var h={top:1,left:1,right:1,bottom:1,width:1,height:1,innerRadius:1,outerRadius:1,radius:1,shapeRadius:1,shapeSize:1,startAngle:1,endAngle:1,angle:1,fillStyle:1,strokeStyle:1,lineWidth:1,eccentricity:1,
tension:1,textAngle:1,textStyle:1,textMargin:1},i=new pv.Transient;pv.Transition=function(j){function k(x){var w=j.root.$transition===n;if(w)j.root.$transition=null;if(l!=null){clearInterval(l);l=null}w&&t(j.scene);if(p){w=p;p=null;w(x)}return x}var n=this,o=pv.ease("cubic-in-out"),r=250,l,p,q,t=function(x){if(!q){q=true;g(x)}};n.ease=function(x){return arguments.length?(o=typeof x=="function"?x:pv.ease(x),n):o};n.duration=function(x){return arguments.length?(r=Number(x),n):r};n.start=function(x){if(j.parent)throw new Error("Animated partial rendering is not supported.");
p=x;x=j.root;if(x.$transition)try{x.$transition.stop()}catch(w){return k(false)}var m,s;x.$transition=n;x._renderId++;var u=j.scene;j.scene=null;x=pv.Mark.prototype.index;try{j.bind();j.build();var v=j.scene;j.scene=u;pv.Mark.prototype.index=x;s=Date.now();m={};f(m,u,v)}catch(y){pv.Mark.prototype.index=x;return k(false)}if(!m.head)return k(true);var z=function(){var A=Math.max(0,Math.min(1,(Date.now()-s)/r)),B=o(A),D=m.head;do D(B);while(D=D.next);if(A===1){t(j.scene);pv.Scene.updateAll(u);k(true)}else pv.Scene.updateAll(u)};
l=setInterval(function(){try{z()}catch(A){k(false)}},24)};n.stop=function(){k(true)}}})();pv.simulation=function(b){return new pv.Simulation(b)};pv.Simulation=function(b){for(var c=0;c<b.length;c++)this.particle(b[c])};a=pv.Simulation.prototype;a.particle=function(b){b.next=this.particles;if(isNaN(b.px))b.px=b.x;if(isNaN(b.py))b.py=b.y;if(isNaN(b.fx))b.fx=0;if(isNaN(b.fy))b.fy=0;this.particles=b;return this};a.force=function(b){b.next=this.forces;this.forces=b;return this};
a.constraint=function(b){b.next=this.constraints;this.constraints=b;return this};a.stabilize=function(b){var c;arguments.length||(b=3);for(var e=0;e<b;e++){var d=new pv.Quadtree(this.particles);for(c=this.constraints;c;c=c.next)c.apply(this.particles,d)}for(c=this.particles;c;c=c.next){c.px=c.x;c.py=c.y}return this};
a.step=function(){var b;for(b=this.particles;b;b=b.next){var c=b.px,e=b.py;b.px=b.x;b.py=b.y;b.x+=b.vx=b.x-c+b.fx;b.y+=b.vy=b.y-e+b.fy}c=new pv.Quadtree(this.particles);for(b=this.constraints;b;b=b.next)b.apply(this.particles,c);for(b=this.particles;b;b=b.next)b.fx=b.fy=0;for(b=this.forces;b;b=b.next)b.apply(this.particles,c)};
pv.Quadtree=function(b){function c(k,n,o,r,l,p){if(!(isNaN(n.x)||isNaN(n.y)))if(k.leaf)if(k.p){if(!(Math.abs(k.p.x-n.x)+Math.abs(k.p.y-n.y)<0.01)){var q=k.p;k.p=null;e(k,q,o,r,l,p)}e(k,n,o,r,l,p)}else k.p=n;else e(k,n,o,r,l,p)}function e(k,n,o,r,l,p){var q=(o+l)*0.5,t=(r+p)*0.5,x=n.x>=q,w=n.y>=t;k.leaf=false;switch((w<<1)+x){case 0:k=k.c1||(k.c1=new pv.Quadtree.Node);break;case 1:k=k.c2||(k.c2=new pv.Quadtree.Node);break;case 2:k=k.c3||(k.c3=new pv.Quadtree.Node);break;case 3:k=k.c4||(k.c4=new pv.Quadtree.Node);
break}if(x)o=q;else l=q;if(w)r=t;else p=t;c(k,n,o,r,l,p)}var d,f=Number.POSITIVE_INFINITY,g=f,h=Number.NEGATIVE_INFINITY,i=h;for(d=b;d;d=d.next){if(d.x<f)f=d.x;if(d.y<g)g=d.y;if(d.x>h)h=d.x;if(d.y>i)i=d.y}d=h-f;var j=i-g;if(d>j)i=g+d;else h=f+j;this.xMin=f;this.yMin=g;this.xMax=h;this.yMax=i;this.root=new pv.Quadtree.Node;for(d=b;d;d=d.next)c(this.root,d,f,g,h,i)};pv.Quadtree.Node=function(){this.leaf=true;this.p=this.c4=this.c3=this.c2=this.c1=null};pv.Force={};
pv.Force.charge=function(b){function c(k){function n(l){c(l);k.cn+=l.cn;o+=l.cn*l.cx;r+=l.cn*l.cy}var o=0,r=0;k.cn=0;if(!k.leaf){k.c1&&n(k.c1);k.c2&&n(k.c2);k.c3&&n(k.c3);k.c4&&n(k.c4)}if(k.p){k.cn+=b;o+=b*k.p.x;r+=b*k.p.y}k.cx=o/k.cn;k.cy=r/k.cn}function e(k,n,o,r,l,p){var q=k.cx-n.x,t=k.cy-n.y,x=1/Math.sqrt(q*q+t*t);if(k.leaf&&k.p!=n||(l-o)*x<i){if(!(x<h)){if(x>f)x=f;k=k.cn*x*x*x;q=q*k;t=t*k;n.fx+=q;n.fy+=t}}else if(!k.leaf){var w=(o+l)*0.5,m=(r+p)*0.5;k.c1&&e(k.c1,n,o,r,w,m);k.c2&&e(k.c2,n,w,r,
l,m);k.c3&&e(k.c3,n,o,m,w,p);k.c4&&e(k.c4,n,w,m,l,p);if(!(x<h)){if(x>f)x=f;if(k.p&&k.p!=n){k=b*x*x*x;q=q*k;t=t*k;n.fx+=q;n.fy+=t}}}}var d=2,f=1/d,g=500,h=1/g,i=0.9,j={};arguments.length||(b=-40);j.constant=function(k){if(arguments.length){b=Number(k);return j}return b};j.domain=function(k,n){if(arguments.length){d=Number(k);f=1/d;g=Number(n);h=1/g;return j}return[d,g]};j.theta=function(k){if(arguments.length){i=Number(k);return j}return i};j.apply=function(k,n){c(n.root);for(k=k;k;k=k.next)e(n.root,
k,n.xMin,n.yMin,n.xMax,n.yMax)};return j};pv.Force.drag=function(b){var c={};arguments.length||(b=0.1);c.constant=function(e){if(arguments.length){b=e;return c}return b};c.apply=function(e){if(b)for(e=e;e;e=e.next){e.fx-=b*e.vx;e.fy-=b*e.vy}};return c};
pv.Force.spring=function(b){var c=0.1,e=20,d,f,g={};arguments.length||(b=0.1);g.links=function(h){if(arguments.length){d=h;f=h.map(function(i){return 1/Math.sqrt(Math.max(i.sourceNode.linkDegree,i.targetNode.linkDegree))});return g}return d};g.constant=function(h){if(arguments.length){b=Number(h);return g}return b};g.damping=function(h){if(arguments.length){c=Number(h);return g}return c};g.length=function(h){if(arguments.length){e=Number(h);return g}return e};g.apply=function(){for(var h=0;h<d.length;h++){var i=
d[h].sourceNode,j=d[h].targetNode,k=i.x-j.x,n=i.y-j.y,o=Math.sqrt(k*k+n*n),r=o?1/o:1;r=(b*f[h]*(o-e)+c*f[h]*(k*(i.vx-j.vx)+n*(i.vy-j.vy))*r)*r;k=-r*(o?k:0.01*(0.5-Math.random()));n=-r*(o?n:0.01*(0.5-Math.random()));i.fx+=k;i.fy+=n;j.fx-=k;j.fy-=n}};return g};pv.Constraint={};
pv.Constraint.collision=function(b){function c(k,n,o,r,l,p){if(!k.leaf){var q=(o+l)*0.5,t=(r+p)*0.5,x=t<i,w=q>f,m=q<h;if(t>g){k.c1&&w&&c(k.c1,n,o,r,q,t);k.c2&&m&&c(k.c2,n,q,r,l,t)}if(x){k.c3&&w&&c(k.c3,n,o,t,q,p);k.c4&&m&&c(k.c4,n,q,t,l,p)}}if(k.p&&k.p!=n){o=n.x-k.p.x;r=n.y-k.p.y;l=Math.sqrt(o*o+r*r);p=d+b(k.p);if(l<p){l=(l-p)/l*0.5;o*=l;r*=l;n.x-=o;n.y-=r;k.p.x+=o;k.p.y+=r}}}var e=1,d,f,g,h,i,j={};arguments.length||(d=10);j.repeat=function(k){if(arguments.length){e=Number(k);return j}return e};j.apply=
function(k,n){var o,r,l=-Infinity;for(o=k;o;o=o.next){r=b(o);if(r>l)l=r}for(var p=0;p<e;p++)for(o=k;o;o=o.next){r=(d=b(o))+l;f=o.x-r;h=o.x+r;g=o.y-r;i=o.y+r;c(n.root,o,n.xMin,n.yMin,n.xMax,n.yMax)}};return j};pv.Constraint.position=function(b){var c=1,e={};arguments.length||(b=function(d){return d.fix});e.alpha=function(d){if(arguments.length){c=Number(d);return e}return c};e.apply=function(d){for(d=d;d;d=d.next){var f=b(d);if(f){d.x+=(f.x-d.x)*c;d.y+=(f.y-d.y)*c;d.fx=d.fy=d.vx=d.vy=0}}};return e};
pv.Constraint.bound=function(){var b={},c,e;b.x=function(d,f){if(arguments.length){c={min:Math.min(d,f),max:Math.max(d,f)};return this}return c};b.y=function(d,f){if(arguments.length){e={min:Math.min(d,f),max:Math.max(d,f)};return this}return e};b.apply=function(d){if(c)for(var f=d;f;f=f.next)f.x=f.x<c.min?c.min:f.x>c.max?c.max:f.x;if(e)for(f=d;f;f=f.next)f.y=f.y<e.min?e.min:f.y>e.max?e.max:f.y};return b};pv.Layout=function(){pv.Panel.call(this)};pv.Layout.prototype=pv.extend(pv.Panel);
pv.Layout.prototype.property=pv.Mark.prototype.localProperty;
pv.Layout.Network=function(){pv.Layout.call(this);var b=this;this.$id=pv.id();(this.node=(new pv.Mark).data(function(){return b.nodes()}).strokeStyle("#1f77b4").fillStyle("#fff").left(function(c){return c.x}).top(function(c){return c.y})).parent=this;this.link=(new pv.Mark).extend(this.node).data(function(c){return[c.sourceNode,c.targetNode]}).fillStyle(null).lineWidth(function(c,e){return e.linkValue*1.5}).strokeStyle("rgba(0,0,0,.2)");this.link.add=function(c){return b.add(pv.Panel).data(function(){return b.links()}).add(c).extend(this)};
(this.label=(new pv.Mark).extend(this.node).textMargin(7).textBaseline("middle").text(function(c){return c.nodeName||c.nodeValue}).textAngle(function(c){c=c.midAngle;return pv.Wedge.upright(c)?c:c+Math.PI}).textAlign(function(c){return pv.Wedge.upright(c.midAngle)?"left":"right"})).parent=this};
pv.Layout.Network.prototype=pv.extend(pv.Layout).property("nodes",function(b){return b.map(function(c,e){if(typeof c!="object")c={nodeValue:c};c.index=e;return c})}).property("links",function(b){return b.map(function(c){if(isNaN(c.linkValue))c.linkValue=isNaN(c.value)?1:c.value;return c})});pv.Layout.Network.prototype.reset=function(){this.$id=pv.id();return this};pv.Layout.Network.prototype.buildProperties=function(b,c){if((b.$id||0)<this.$id)pv.Layout.prototype.buildProperties.call(this,b,c)};
pv.Layout.Network.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);if(b.$id>=this.$id)return true;b.$id=this.$id;b.nodes.forEach(function(c){c.linkDegree=0});b.links.forEach(function(c){var e=c.linkValue;(c.sourceNode||(c.sourceNode=b.nodes[c.source])).linkDegree+=e;(c.targetNode||(c.targetNode=b.nodes[c.target])).linkDegree+=e})};pv.Layout.Hierarchy=function(){pv.Layout.Network.call(this);this.link.strokeStyle("#ccc")};pv.Layout.Hierarchy.prototype=pv.extend(pv.Layout.Network);
pv.Layout.Hierarchy.prototype.buildImplied=function(b){if(!b.links)b.links=pv.Layout.Hierarchy.links.call(this);pv.Layout.Network.prototype.buildImplied.call(this,b)};pv.Layout.Hierarchy.links=function(){return this.nodes().filter(function(b){return b.parentNode}).map(function(b){return{sourceNode:b,targetNode:b.parentNode,linkValue:1}})};
pv.Layout.Hierarchy.NodeLink={buildImplied:function(b){function c(l){return l.parentNode?l.depth*(o-n)+n:0}function e(l){return l.parentNode?(l.breadth-0.25)*2*Math.PI:0}function d(l){switch(h){case "left":return l.depth*j;case "right":return j-l.depth*j;case "top":return l.breadth*j;case "bottom":return j-l.breadth*j;case "radial":return j/2+c(l)*Math.cos(l.midAngle)}}function f(l){switch(h){case "left":return l.breadth*k;case "right":return k-l.breadth*k;case "top":return l.depth*k;case "bottom":return k-
l.depth*k;case "radial":return k/2+c(l)*Math.sin(l.midAngle)}}var g=b.nodes,h=b.orient,i=/^(top|bottom)$/.test(h),j=b.width,k=b.height;if(h=="radial"){var n=b.innerRadius,o=b.outerRadius;if(n==null)n=0;if(o==null)o=Math.min(j,k)/2}for(b=0;b<g.length;b++){var r=g[b];r.midAngle=h=="radial"?e(r):i?Math.PI/2:0;r.x=d(r);r.y=f(r);if(r.firstChild)r.midAngle+=Math.PI}}};
pv.Layout.Hierarchy.Fill={constructor:function(){this.node.strokeStyle("#fff").fillStyle("#ccc").width(function(b){return b.dx}).height(function(b){return b.dy}).innerRadius(function(b){return b.innerRadius}).outerRadius(function(b){return b.outerRadius}).startAngle(function(b){return b.startAngle}).angle(function(b){return b.angle});this.label.textAlign("center").left(function(b){return b.x+b.dx/2}).top(function(b){return b.y+b.dy/2});delete this.link},buildImplied:function(b){function c(m,s){return(m+
s)/(1+s)}function e(m){switch(o){case "left":return c(m.minDepth,q)*l;case "right":return(1-c(m.maxDepth,q))*l;case "top":return m.minBreadth*l;case "bottom":return(1-m.maxBreadth)*l;case "radial":return l/2}}function d(m){switch(o){case "left":return m.minBreadth*p;case "right":return(1-m.maxBreadth)*p;case "top":return c(m.minDepth,q)*p;case "bottom":return(1-c(m.maxDepth,q))*p;case "radial":return p/2}}function f(m){switch(o){case "left":case "right":return(m.maxDepth-m.minDepth)/(1+q)*l;case "top":case "bottom":return(m.maxBreadth-
m.minBreadth)*l;case "radial":return m.parentNode?(m.innerRadius+m.outerRadius)*Math.cos(m.midAngle):0}}function g(m){switch(o){case "left":case "right":return(m.maxBreadth-m.minBreadth)*p;case "top":case "bottom":return(m.maxDepth-m.minDepth)/(1+q)*p;case "radial":return m.parentNode?(m.innerRadius+m.outerRadius)*Math.sin(m.midAngle):0}}function h(m){return Math.max(0,c(m.minDepth,q/2))*(x-t)+t}function i(m){return c(m.maxDepth,q/2)*(x-t)+t}function j(m){return(m.parentNode?m.minBreadth-0.25:0)*
2*Math.PI}function k(m){return(m.parentNode?m.maxBreadth-m.minBreadth:1)*2*Math.PI}var n=b.nodes,o=b.orient,r=/^(top|bottom)$/.test(o),l=b.width,p=b.height,q=-n[0].minDepth;if(o=="radial"){var t=b.innerRadius,x=b.outerRadius;if(t==null)t=0;if(t)q*=2;if(x==null)x=Math.min(l,p)/2}for(b=0;b<n.length;b++){var w=n[b];w.x=e(w);w.y=d(w);if(o=="radial"){w.innerRadius=h(w);w.outerRadius=i(w);w.startAngle=j(w);w.angle=k(w);w.midAngle=w.startAngle+w.angle/2}else w.midAngle=r?-Math.PI/2:0;w.dx=f(w);w.dy=g(w)}}};
pv.Layout.Grid=function(){pv.Layout.call(this);var b=this;(this.cell=(new pv.Mark).data(function(){return b.scene[b.index].$grid}).width(function(){return b.width()/b.cols()}).height(function(){return b.height()/b.rows()}).left(function(){return this.width()*(this.index%b.cols())}).top(function(){return this.height()*Math.floor(this.index/b.cols())})).parent=this};pv.Layout.Grid.prototype=pv.extend(pv.Layout).property("rows").property("cols");pv.Layout.Grid.prototype.defaults=(new pv.Layout.Grid).extend(pv.Layout.prototype.defaults).rows(1).cols(1);
pv.Layout.Grid.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);var c=b.rows,e=b.cols;if(typeof e=="object")c=pv.transpose(e);if(typeof c=="object"){b.$grid=pv.blend(c);b.rows=c.length;b.cols=c[0]?c[0].length:0}else b.$grid=pv.repeat([b.data],c*e)};
pv.Layout.Stack=function(){function b(h){return function(){return d[h](this.parent.index,this.index)}}pv.Layout.call(this);var c=this,e=function(){return null},d={t:e,l:e,r:e,b:e,w:e,h:e},f,g=c.buildImplied;this.buildImplied=function(h){g.call(this,h);var i=h.layers,j=i.length,k,n=h.orient,o=/^(top|bottom)\b/.test(n),r=this.parent[o?"height":"width"](),l=[],p=[],q=[],t=pv.Mark.stack,x={parent:{parent:this}};t.unshift(null);f=[];for(var w=0;w<j;w++){q[w]=[];p[w]=[];x.parent.index=w;t[0]=i[w];f[w]=
this.$values.apply(x.parent,t);if(!w)k=f[w].length;t.unshift(null);for(var m=0;m<k;m++){t[0]=f[w][m];x.index=m;w||(l[m]=this.$x.apply(x,t));q[w][m]=this.$y.apply(x,t)}t.shift()}t.shift();switch(h.order){case "inside-out":var s=q.map(function(A){return pv.max.index(A)});x=pv.range(j).sort(function(A,B){return s[A]-s[B]});i=q.map(function(A){return pv.sum(A)});var u=t=0,v=[],y=[];for(w=0;w<j;w++){m=x[w];if(t<u){t+=i[m];v.push(m)}else{u+=i[m];y.push(m)}}i=y.reverse().concat(v);break;case "reverse":i=
pv.range(j-1,-1,-1);break;default:i=pv.range(j);break}switch(h.offset){case "silohouette":for(m=0;m<k;m++){for(w=x=0;w<j;w++)x+=q[w][m];p[i[0]][m]=(r-x)/2}break;case "wiggle":for(w=x=0;w<j;w++)x+=q[w][0];p[i[0]][0]=x=(r-x)/2;for(m=1;m<k;m++){t=r=0;u=l[m]-l[m-1];for(w=0;w<j;w++)r+=q[w][m];for(w=0;w<j;w++){v=(q[i[w]][m]-q[i[w]][m-1])/(2*u);for(h=0;h<w;h++)v+=(q[i[h]][m]-q[i[h]][m-1])/u;t+=v*q[i[w]][m]}p[i[0]][m]=x-=r?t/r*u:0}break;case "expand":for(m=0;m<k;m++){for(w=h=p[i[0]][m]=0;w<j;w++)h+=q[w][m];
if(h){h=r/h;for(w=0;w<j;w++)q[w][m]*=h}else{h=r/j;for(w=0;w<j;w++)q[w][m]=h}}break;default:for(m=0;m<k;m++)p[i[0]][m]=0;break}for(m=0;m<k;m++){x=p[i[0]][m];for(w=1;w<j;w++){x+=q[i[w-1]][m];p[i[w]][m]=x}}w=n.indexOf("-");j=o?"h":"w";o=w<0?o?"l":"b":n.charAt(w+1);n=n.charAt(0);for(var z in d)d[z]=e;d[o]=function(A,B){return l[B]};d[n]=function(A,B){return p[A][B]};d[j]=function(A,B){return q[A][B]}};this.layer=(new pv.Mark).data(function(){return f[this.parent.index]}).top(b("t")).left(b("l")).right(b("r")).bottom(b("b")).width(b("w")).height(b("h"));
this.layer.add=function(h){return c.add(pv.Panel).data(function(){return c.layers()}).add(h).extend(this)}};pv.Layout.Stack.prototype=pv.extend(pv.Layout).property("orient",String).property("offset",String).property("order",String).property("layers");a=pv.Layout.Stack.prototype;a.defaults=(new pv.Layout.Stack).extend(pv.Layout.prototype.defaults).orient("bottom-left").offset("zero").layers([[]]);a.$x=pv.Layout.Stack.prototype.$y=function(){return 0};a.x=function(b){this.$x=pv.functor(b);return this};
a.y=function(b){this.$y=pv.functor(b);return this};a.$values=pv.identity;a.values=function(b){this.$values=pv.functor(b);return this};
pv.Layout.Band=function(){function b(j){return function(){return d[j](this.index,this.parent.index)}}pv.Layout.call(this);var c=this,e=c.buildImplied,d,f,g=(new pv.Mark).data(function(){return f[this.parent.index]}).top(b("t")).left(b("l")).right(b("r")).bottom(b("b")).width(b("w")).height(b("h")).antialias(b("antialias"));this.buildImplied=function(j){e.call(this,j);d=Object.create(pv.Layout.Band.$baseItemProps);f=[];var k=j.layers,n=k.length;if(n>0){var o=j.orient,r=/^(top|bottom)\b/.test(o),l=
this.parent[r?"height":"width"]();k=this._readData(k,f,j);var p=k.length;j.bandOrder==="reverse"&&k.reverse();if(j.order==="reverse"){f.reverse();for(var q=0;q<p;q++)k[q].items.reverse()}switch(j.layout){case "grouped":this._calcGrouped(k,n,l,j);break;case "stacked":this._calcStacked(k,n,l,j);break}l=j.hZero||0;j=j.layout==="stacked";for(q=0;q<p;q++)for(var t=k[q],x=j?Math.max(0,t.vertiMargin)/2:0,w=0;w<n;w++){var m=t.items[w];if(m.zero){m.h=l;m.y-=x+l/2}}this._bindItemProps(k,d,o,r)}};var h=this.item=
{end:this,add:function(j){return c.add(pv.Panel).data(function(){return c.layers()}).add(j).extend(g)},order:function(j){c.order(j);return this},w:function(j){c.$iw=pv.functor(j);return this},h:function(j){c.$ih=pv.functor(j);return this},horizontalRatio:function(j){c.$ihorizRatio=pv.functor(j);return this},verticalMargin:function(j){c.$ivertiMargin=pv.functor(j);return this}},i=this.band={end:this,w:function(j){c.$bw=pv.functor(j);return this},x:function(j){c.$bx=pv.functor(j);return this},order:function(j){c.bandOrder(j);
return this},differentialControl:function(j){c.$bDiffControl=pv.functor(j);return this}};this.band.item=h;this.item.band=i};pv.Layout.Band.$baseItemProps=function(){var b=function(){return null};return{t:b,l:b,r:b,b:b,w:b,h:b}}();
pv.Layout.Band.prototype=pv.extend(pv.Layout).property("orient",String).property("layout",String).property("layers").property("yZero",Number).property("hZero",Number).property("verticalMode",String).property("horizontalMode",String).property("order",String).property("bandOrder",String);a=pv.Layout.Band.prototype;a.defaults=(new pv.Layout.Band).extend(pv.Layout.prototype.defaults).orient("bottom-left").layout("grouped").yZero(0).hZero(1.5).layers([[]]);
a.$bx=pv.Layout.Band.prototype.$bw=pv.Layout.Band.prototype.$bDiffControl=pv.Layout.Band.prototype.$iw=pv.Layout.Band.prototype.$ih=pv.Layout.Band.prototype.$ivertiMargin=pv.functor(0);a.$ihorizRatio=pv.functor(0.9);a.$values=pv.identity;a.values=function(b){this.$values=pv.functor(b);return this};
pv.Layout.prototype._readData=function(b,c,e){var d=b.length,f=[],g,h=pv.Mark.stack,i=e.hZero,j={parent:{parent:this}};h.unshift(null);for(var k=0;k<d;k++){j.parent.index=k;h[0]=b[k];var n=c[k]=this.$values.apply(j.parent,h);if(!k)g=n.length;h.unshift(null);for(var o=0;o<g;o++){h[0]=n[o];j.index=o;var r=f[o];r||(r=f[o]={horizRatio:this.$ihorizRatio.apply(j,h),vertiMargin:this.$ivertiMargin.apply(j,h),w:this.$bw.apply(j,h),x:this.$bx.apply(j,h),diffControl:this.$bDiffControl?this.$bDiffControl.apply(j,
h):0,items:[]});var l=this.$ih.apply(j,h),p=l!=null?Math.abs(l):l;r.items[k]={y:e.yZero||0,x:0,w:this.$iw.apply(j,h),h:p,zero:p!=null&&p<=i,dir:l<0?-1:1}}h.shift()}h.shift();return f};a=pv.Layout.Band.prototype;
a._normalizeBands=function(b,c,e,d){var f=b.length,g;if(d.verticalMode==="expand")for(var h=0;h<f;h++){g=b[h].items;for(var i=null,j=0,k=0;k<c;k++){var n=g[k];n.dir=1;n=n.h;if(n!=null){j++;i+=n}}if(j)if(i){i=e/i;for(k=0;k<c;k++){n=g[k].h;if(n!=null){g[k].h=n*i;g[k].zero=g[k].h<=d.hZero}}}else if(i==0)for(k=0;k<c;k++)g[k].h=0;else{i=e/j;for(k=0;k<c;k++){n=g[k].h;if(n!=null)g[k].h=i}}}return g};
a._calcGrouped=function(b,c,e,d){e=this._normalizeBands(b,c,e,d);for(var f=0,g=b.length;f<g;f++){var h=b[f];e=h.items;for(var i=h.w,j=h.horizRatio,k=0,n=0;n<c;n++)k+=e[n].w;if(c===1)j=1;else j>0&&j<=1||(j=1);if(i==null)h.w=k/j;else if(d.horizontalMode==="expand"){i=j*i;if(k){k=i/k;for(n=0;n<c;n++)e[n].w*=k}else{k=i/c;for(n=0;n<c;n++)e[n].w=k}k=i}n=k/j;h=h.x-n/2;j=c>1?(n-k)/(c-1):0;for(n=0;n<c;n++){k=e[n];k.x=h;h+=k.w+j;if(k.dir<0)k.y-=k.h}}};
a._calcStacked=function(b,c,e,d){var f=this._normalizeBands(b,c,e,d);c=d=d.yZero;e=0;for(var g=b.length;e<g;e++){f=b[e];var h=f.x,i=f.diffControl,j=i<0,k=Math.max(0,f.vertiMargin);f=f.items;var n=this._layoutItemsOfDir(+1,j,f,k,h,c),o=null;if(n.existsOtherDir)o=this._layoutItemsOfDir(-1,j,f,k,h,c);if(i){if(Math.abs(i)===1){f=c;c=n.yOffset;if(o)c-=f-o.yOffset}}else c=d}};
a._layoutItemsOfDir=function(b,c,e,d,f,g){for(var h=false,i=d/2,j=c?-b:b,k=0,n=e.length;k<n;k+=1){var o=e[c?n-k-1:k];if(o.dir===b){var r=o.h||0;if(j>0){o.y=g+i;g+=r}else{o.y=g-(r-i);g-=r}r=r-d;o.h=r>0?r:0;o.x=f-o.w/2}else h=true}return{existsOtherDir:h,yOffset:g}};
a._bindItemProps=function(b,c,e,d){var f=e.indexOf("-"),g=d?"h":"w",h=d?"w":"h";d=f<0?d?"l":"b":e.charAt(f+1);e=e.charAt(0);c[d]=function(i,j){return b[i].items[j].x};c[e]=function(i,j){return b[i].items[j].y};c[h]=function(i,j){return b[i].items[j].w};c[g]=function(i,j){return b[i].items[j].h||0};c.antialias=function(i,j){return b[i].items[j].zero}};
pv.Layout.Treemap=function(){pv.Layout.Hierarchy.call(this);this.node.strokeStyle("#fff").fillStyle("rgba(31, 119, 180, .25)").width(function(b){return b.dx}).height(function(b){return b.dy});this.label.visible(function(b){return!b.firstChild}).left(function(b){return b.x+b.dx/2}).top(function(b){return b.y+b.dy/2}).textAlign("center").textAngle(function(b){return b.dx>b.dy?0:-Math.PI/2});(this.leaf=(new pv.Mark).extend(this.node).fillStyle(null).strokeStyle(null).visible(function(b){return!b.firstChild})).parent=
this;delete this.link};pv.Layout.Treemap.prototype=pv.extend(pv.Layout.Hierarchy).property("round",Boolean).property("mode",String).property("order",String);a=pv.Layout.Treemap.prototype;a.defaults=(new pv.Layout.Treemap).extend(pv.Layout.Hierarchy.prototype.defaults).mode("squarify").order("ascending");a.$size=function(b){return Number(b.nodeValue)};a.$padLeft=pv.Layout.Treemap.prototype.$padRight=pv.Layout.Treemap.prototype.$padBottom=pv.Layout.Treemap.prototype.$padTop=function(){return 0};
a.size=function(b){this.$size=pv.functor(b);return this};a.padding=function(b){b=pv.functor(b);return this.paddingLeft(b).paddingRight(b).paddingTop(b).paddingBottom(b)};a.paddingLeft=function(b){if(arguments.length){this.$padLeft=pv.functor(b);return this}return this.$padLeft};a.paddingRight=function(b){if(arguments.length){this.$padRight=pv.functor(b);return this}return this.$padRight};a.paddingBottom=function(b){if(arguments.length){this.$padBottom=pv.functor(b);return this}return this.$padBottom};
a.paddingTop=function(b){if(arguments.length){this.$padTop=pv.functor(b);return this}return this.$padTop};
a.buildImplied=function(b){function c(n,o,r,l,p,q,t){for(var x=0,w=0;x<n.length;x++){var m=n[x];if(r){m.x=l+w;m.y=p;w+=m.dx=j(q*m.size/o);m.dy=t}else{m.x=l;m.y=p+w;m.dx=q;w+=m.dy=j(t*m.size/o)}}if(m)if(r)m.dx+=q-w;else m.dy+=t-w}function e(n,o){for(var r=-Infinity,l=Infinity,p=0,q=0;q<n.length;q++){var t=n[q].size;if(t<l)l=t;if(t>r)r=t;p+=t}p*=p;o*=o;return Math.max(o*r/p,p/(o*l))}function d(n,o){function r(u){var v=t==w,y=pv.sum(u,i),z=w?j(y/w):0;c(u,y,v,p,q,v?t:z,v?z:x);if(v){q+=z;x-=z}else{p+=
z;t-=z}w=Math.min(t,x);return v}var l=n.parentNode,p=n.x,q=n.y,t=n.dx,x=n.dy;if(l){p+=l.paddingLeft;q+=l.paddingTop;t+=-l.paddingLeft-l.paddingRight;x+=-l.paddingTop-l.paddingBottom}if(k!="squarify")c(n.childNodes,n.size,k=="slice"?true:k=="dice"?false:o&1,p,q,t,x);else{l=[];o=Infinity;var w=Math.min(t,x),m=t*x/n.size;if(!(n.size<=0)){n.visitBefore(function(u){u.size*=m});for(n=n.childNodes.slice();n.length;){var s=n[n.length-1];if(s.size){l.push(s);m=e(l,w);if(m<=o){n.pop();o=m}else{l.pop();r(l);
l.length=0;o=Infinity}}else n.pop()}if(r(l))for(o=0;o<l.length;o++)l[o].dy+=x;else for(o=0;o<l.length;o++)l[o].dx+=t}}}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var f=this,g=b.nodes[0],h=pv.Mark.stack,i=function(n){return n.size},j=b.round?Math.round:Number,k=b.mode;h.unshift(null);try{g.visitAfter(function(n,o){n.depth=o;n.x=n.y=n.dx=n.dy=0;h[0]=n;if(n.firstChild){n.size=pv.sum(n.childNodes,i);n.paddingRight=+f.$padRight.apply(f,h)||0;n.paddingLeft=+f.$padLeft.apply(f,h)||0;n.paddingBottom=
+f.$padBottom.apply(f,h)||0;n.paddingTop=+f.$padTop.apply(f,h)||0}else n.size=f.$size.apply(f,h)})}finally{h.shift()}switch(b.order){case "ascending":g.sort(function(n,o){return n.size-o.size});break;case "descending":g.sort(function(n,o){return o.size-n.size});break;case "reverse":g.reverse();break}g.x=0;g.y=0;g.dx=b.width;g.dy=b.height;g.visitBefore(d)}};pv.Layout.Tree=function(){pv.Layout.Hierarchy.call(this)};
pv.Layout.Tree.prototype=pv.extend(pv.Layout.Hierarchy).property("group",Number).property("breadth",Number).property("depth",Number).property("orient",String);pv.Layout.Tree.prototype.defaults=(new pv.Layout.Tree).extend(pv.Layout.Hierarchy.prototype.defaults).group(1).breadth(15).depth(60).orient("top");
pv.Layout.Tree.prototype.buildImplied=function(b){function c(m){var s,u,v;if(m.firstChild){s=m.firstChild;u=m.lastChild;for(var y=v=s;y;y=y.nextSibling){c(y);v=d(y,v)}i(m);u=0.5*(s.prelim+u.prelim);if(s=m.previousSibling){m.prelim=s.prelim+k(m.depth,true);m.mod=m.prelim-u}else m.prelim=u}else if(s=m.previousSibling)m.prelim=s.prelim+k(m.depth,true)}function e(m,s,u){m.breadth=m.prelim+s;s+=m.mod;for(m=m.firstChild;m;m=m.nextSibling)e(m,s,u)}function d(m,s){var u=m.previousSibling;if(u){var v=m,y=
m,z=u;u=m.parentNode.firstChild;var A=v.mod,B=y.mod,D=z.mod,G=u.mod;z=g(z);for(v=f(v);z&&v;){z=z;v=v;u=f(u);y=g(y);y.ancestor=m;var C=z.prelim+D-(v.prelim+A)+k(z.depth,false);if(C>0){h(j(z,m,s),m,C);A+=C;B+=C}D+=z.mod;A+=v.mod;G+=u.mod;B+=y.mod;z=g(z);v=f(v)}if(z&&!g(y)){y.thread=z;y.mod+=D-B}if(v&&!f(u)){u.thread=v;u.mod+=A-G;s=m}}return s}function f(m){return m.firstChild||m.thread}function g(m){return m.lastChild||m.thread}function h(m,s,u){var v=s.number-m.number;s.change-=u/v;s.shift+=u;m.change+=
u/v;s.prelim+=u;s.mod+=u}function i(m){var s=0,u=0;for(m=m.lastChild;m;m=m.previousSibling){m.prelim+=s;m.mod+=s;u+=m.change;s+=m.shift+u}}function j(m,s,u){return m.ancestor.parentNode==s.parentNode?m.ancestor:u}function k(m,s){return(s?1:t+1)/(l=="radial"?m:1)}function n(m){return l=="radial"?m.breadth/p:0}function o(m){switch(l){case "left":return m.depth;case "right":return x-m.depth;case "top":case "bottom":return m.breadth+x/2;case "radial":return x/2+m.depth*Math.cos(n(m))}}function r(m){switch(l){case "left":case "right":return m.breadth+
w/2;case "top":return m.depth;case "bottom":return w-m.depth;case "radial":return w/2+m.depth*Math.sin(n(m))}}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var l=b.orient,p=b.depth,q=b.breadth,t=b.group,x=b.width,w=b.height;b=b.nodes[0];b.visitAfter(function(m,s){m.ancestor=m;m.prelim=0;m.mod=0;m.change=0;m.shift=0;m.number=m.previousSibling?m.previousSibling.number+1:0;m.depth=s});c(b);e(b,-b.prelim,0);b.visitAfter(function(m){m.breadth*=q;m.depth*=p;m.midAngle=n(m);m.x=o(m);m.y=r(m);
if(m.firstChild)m.midAngle+=Math.PI;delete m.breadth;delete m.depth;delete m.ancestor;delete m.prelim;delete m.mod;delete m.change;delete m.shift;delete m.number;delete m.thread})}};pv.Layout.Indent=function(){pv.Layout.Hierarchy.call(this);this.link.interpolate("step-after")};pv.Layout.Indent.prototype=pv.extend(pv.Layout.Hierarchy).property("depth",Number).property("breadth",Number);pv.Layout.Indent.prototype.defaults=(new pv.Layout.Indent).extend(pv.Layout.Hierarchy.prototype.defaults).depth(15).breadth(15);
pv.Layout.Indent.prototype.buildImplied=function(b){function c(h,i,j){h.x=f+j++*d;h.y=g+i++*e;h.midAngle=0;for(h=h.firstChild;h;h=h.nextSibling)i=c(h,i,j);return i}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var e=b.breadth,d=b.depth,f=0,g=0;c(b.nodes[0],1,1)}};pv.Layout.Pack=function(){pv.Layout.Hierarchy.call(this);this.node.shapeRadius(function(b){return b.radius}).strokeStyle("rgb(31, 119, 180)").fillStyle("rgba(31, 119, 180, .25)");this.label.textAlign("center");delete this.link};
pv.Layout.Pack.prototype=pv.extend(pv.Layout.Hierarchy).property("spacing",Number).property("order",String);pv.Layout.Pack.prototype.defaults=(new pv.Layout.Pack).extend(pv.Layout.Hierarchy.prototype.defaults).spacing(1).order("ascending");pv.Layout.Pack.prototype.$radius=function(){return 1};pv.Layout.Pack.prototype.size=function(b){this.$radius=typeof b=="function"?function(){return Math.sqrt(b.apply(this,arguments))}:(b=Math.sqrt(b),function(){return b});return this};
pv.Layout.Pack.prototype.buildImplied=function(b){function c(o){var r=pv.Mark.stack;r.unshift(null);for(var l=0,p=o.length;l<p;l++){var q=o[l];if(!q.firstChild)q.radius=h.$radius.apply(h,(r[0]=q,r))}r.shift()}function e(o){var r=[];for(o=o.firstChild;o;o=o.nextSibling){if(o.firstChild)o.radius=e(o);o.n=o.p=o;r.push(o)}switch(b.order){case "ascending":r.sort(function(l,p){return l.radius-p.radius});break;case "descending":r.sort(function(l,p){return p.radius-l.radius});break;case "reverse":r.reverse();
break}return d(r)}function d(o){function r(C){t=Math.min(C.x-C.radius,t);x=Math.max(C.x+C.radius,x);w=Math.min(C.y-C.radius,w);m=Math.max(C.y+C.radius,m)}function l(C,H){var I=C.n;C.n=H;H.p=C;H.n=I;I.p=H}function p(C,H){C.n=H;H.p=C}function q(C,H){var I=H.x-C.x,J=H.y-C.y;C=C.radius+H.radius;return C*C-I*I-J*J>0.001}var t=Infinity,x=-Infinity,w=Infinity,m=-Infinity,s,u,v,y,z;s=o[0];s.x=-s.radius;s.y=0;r(s);if(o.length>1){u=o[1];u.x=u.radius;u.y=0;r(u);if(o.length>2){v=o[2];f(s,u,v);r(v);l(s,v);s.p=
v;l(v,u);u=s.n;for(var A=3;A<o.length;A++){f(s,u,v=o[A]);var B=0,D=1,G=1;for(y=u.n;y!=u;y=y.n,D++)if(q(y,v)){B=1;break}if(B==1)for(z=s.p;z!=y.p;z=z.p,G++)if(q(z,v)){if(G<D){B=-1;y=z}break}if(B==0){l(s,v);u=v;r(v)}else if(B>0){p(s,y);u=y;A--}else if(B<0){p(y,u);s=y;A--}}}}s=(t+x)/2;u=(w+m)/2;for(A=v=0;A<o.length;A++){y=o[A];y.x-=s;y.y-=u;v=Math.max(v,y.radius+Math.sqrt(y.x*y.x+y.y*y.y))}return v+b.spacing}function f(o,r,l){var p=r.radius+l.radius,q=o.radius+l.radius,t=r.x-o.x;r=r.y-o.y;var x=Math.sqrt(t*
t+r*r),w=(q*q+x*x-p*p)/(2*q*x);p=Math.acos(w);w=w*q;q=Math.sin(p)*q;t/=x;r/=x;l.x=o.x+w*t+q*r;l.y=o.y+w*r-q*t}function g(o,r,l,p){for(var q=o.firstChild;q;q=q.nextSibling){q.x+=o.x;q.y+=o.y;g(q,r,l,p)}o.x=r+p*o.x;o.y=l+p*o.y;o.radius*=p}if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var h=this,i=b.nodes,j=i[0];c(i);j.x=0;j.y=0;j.radius=e(j);i=this.width();var k=this.height(),n=1/Math.max(2*j.radius/i,2*j.radius/k);g(j,i/2,k/2,n)}};
pv.Layout.Force=function(){pv.Layout.Network.call(this);this.link.lineWidth(function(b,c){return Math.sqrt(c.linkValue)*1.5});this.label.textAlign("center")};
pv.Layout.Force.prototype=pv.extend(pv.Layout.Network).property("bound",Boolean).property("iterations",Number).property("dragConstant",Number).property("chargeConstant",Number).property("chargeMinDistance",Number).property("chargeMaxDistance",Number).property("chargeTheta",Number).property("springConstant",Number).property("springDamping",Number).property("springLength",Number);pv.Layout.Force.prototype.defaults=(new pv.Layout.Force).extend(pv.Layout.Network.prototype.defaults).dragConstant(0.1).chargeConstant(-40).chargeMinDistance(2).chargeMaxDistance(500).chargeTheta(0.9).springConstant(0.1).springDamping(0.3).springLength(20);
pv.Layout.Force.prototype.buildImplied=function(b){function c(n){return n.fix?1:n.vx*n.vx+n.vy*n.vy}if(pv.Layout.Network.prototype.buildImplied.call(this,b)){if(b=b.$force){b.next=this.binds.$force;this.binds.$force=b}}else{for(var e=this,d=b.nodes,f=b.links,g=b.iterations,h=b.width,i=b.height,j=0,k;j<d.length;j++){k=d[j];if(isNaN(k.x))k.x=h/2+40*Math.random()-20;if(isNaN(k.y))k.y=i/2+40*Math.random()-20}k=pv.simulation(d);k.force(pv.Force.drag(b.dragConstant));k.force(pv.Force.charge(b.chargeConstant).domain(b.chargeMinDistance,
b.chargeMaxDistance).theta(b.chargeTheta));k.force(pv.Force.spring(b.springConstant).damping(b.springDamping).length(b.springLength).links(f));k.constraint(pv.Constraint.position());b.bound&&k.constraint(pv.Constraint.bound().x(6,h-6).y(6,i-6));if(g==null){k.step();k.step();b.$force=this.binds.$force={next:this.binds.$force,nodes:d,min:1.0E-4*(f.length+1),sim:k};if(!this.$timer)this.$timer=setInterval(function(){for(var n=false,o=e.binds.$force;o;o=o.next)if(pv.max(o.nodes,c)>o.min){o.sim.step();
n=true}n&&e.render()},42)}else for(j=0;j<g;j++)k.step()}};pv.Layout.Cluster=function(){pv.Layout.Hierarchy.call(this);var b,c=this.buildImplied;this.buildImplied=function(e){c.call(this,e);b=/^(top|bottom)$/.test(e.orient)?"step-before":/^(left|right)$/.test(e.orient)?"step-after":"linear"};this.link.interpolate(function(){return b})};
pv.Layout.Cluster.prototype=pv.extend(pv.Layout.Hierarchy).property("group",Number).property("orient",String).property("innerRadius",Number).property("outerRadius",Number);pv.Layout.Cluster.prototype.defaults=(new pv.Layout.Cluster).extend(pv.Layout.Hierarchy.prototype.defaults).group(0).orient("top");
pv.Layout.Cluster.prototype.buildImplied=function(b){if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var c=b.nodes[0],e=b.group,d,f,g=0,h=0.5-e/2,i=undefined;c.visitAfter(function(j){if(j.firstChild)j.depth=1+pv.max(j.childNodes,function(k){return k.depth});else{if(e&&i!=j.parentNode){i=j.parentNode;g+=e}g++;j.depth=0}});d=1/g;f=1/c.depth;i=undefined;c.visitAfter(function(j){if(j.firstChild)j.breadth=pv.mean(j.childNodes,function(k){return k.breadth});else{if(e&&i!=j.parentNode){i=j.parentNode;
h+=e}j.breadth=d*h++}j.depth=1-j.depth*f});c.visitAfter(function(j){j.minBreadth=j.firstChild?j.firstChild.minBreadth:j.breadth-d/2;j.maxBreadth=j.firstChild?j.lastChild.maxBreadth:j.breadth+d/2});c.visitBefore(function(j){j.minDepth=j.parentNode?j.parentNode.maxDepth:0;j.maxDepth=j.parentNode?j.depth+c.depth:j.minDepth+2*c.depth});c.minDepth=-f;pv.Layout.Hierarchy.NodeLink.buildImplied.call(this,b)}};pv.Layout.Cluster.Fill=function(){pv.Layout.Cluster.call(this);pv.Layout.Hierarchy.Fill.constructor.call(this)};
pv.Layout.Cluster.Fill.prototype=pv.extend(pv.Layout.Cluster);pv.Layout.Cluster.Fill.prototype.buildImplied=function(b){pv.Layout.Cluster.prototype.buildImplied.call(this,b)||pv.Layout.Hierarchy.Fill.buildImplied.call(this,b)};pv.Layout.Partition=function(){pv.Layout.Hierarchy.call(this)};pv.Layout.Partition.prototype=pv.extend(pv.Layout.Hierarchy).property("order",String).property("orient",String).property("innerRadius",Number).property("outerRadius",Number);
pv.Layout.Partition.prototype.defaults=(new pv.Layout.Partition).extend(pv.Layout.Hierarchy.prototype.defaults).orient("top");pv.Layout.Partition.prototype.$size=function(){return 1};pv.Layout.Partition.prototype.size=function(b){this.$size=b;return this};
pv.Layout.Partition.prototype.buildImplied=function(b){if(!pv.Layout.Hierarchy.prototype.buildImplied.call(this,b)){var c=this,e=b.nodes[0],d=pv.Mark.stack,f=0;d.unshift(null);e.visitAfter(function(g,h){if(h>f)f=h;g.size=g.firstChild?pv.sum(g.childNodes,function(i){return i.size}):c.$size.apply(c,(d[0]=g,d))});d.shift();switch(b.order){case "ascending":e.sort(function(g,h){return g.size-h.size});break;case "descending":e.sort(function(g,h){return h.size-g.size});break}e.minBreadth=0;e.breadth=0.5;
e.maxBreadth=1;e.visitBefore(function(g){for(var h=g.minBreadth,i=g.maxBreadth-h,j=g.firstChild;j;j=j.nextSibling){j.minBreadth=h;h+=j.size/g.size*i;j.maxBreadth=h;j.breadth=(h+j.minBreadth)/2}});e.visitAfter(function(g,h){g.minDepth=(h-1)/f;g.maxDepth=g.depth=h/f});pv.Layout.Hierarchy.NodeLink.buildImplied.call(this,b)}};pv.Layout.Partition.Fill=function(){pv.Layout.Partition.call(this);pv.Layout.Hierarchy.Fill.constructor.call(this)};pv.Layout.Partition.Fill.prototype=pv.extend(pv.Layout.Partition);
pv.Layout.Partition.Fill.prototype.buildImplied=function(b){pv.Layout.Partition.prototype.buildImplied.call(this,b)||pv.Layout.Hierarchy.Fill.buildImplied.call(this,b)};pv.Layout.Arc=function(){pv.Layout.Network.call(this);var b,c,e,d=this.buildImplied;this.buildImplied=function(f){d.call(this,f);c=f.directed;b=f.orient=="radial"?"linear":"polar";e=f.orient=="right"||f.orient=="top"};this.link.data(function(f){var g=f.sourceNode;f=f.targetNode;return e!=(c||g.breadth<f.breadth)?[g,f]:[f,g]}).interpolate(function(){return b})};
pv.Layout.Arc.prototype=pv.extend(pv.Layout.Network).property("orient",String).property("directed",Boolean);pv.Layout.Arc.prototype.defaults=(new pv.Layout.Arc).extend(pv.Layout.Network.prototype.defaults).orient("bottom");pv.Layout.Arc.prototype.sort=function(b){this.$sort=b;return this};
pv.Layout.Arc.prototype.buildImplied=function(b){function c(l){switch(g){case "top":return-Math.PI/2;case "bottom":return Math.PI/2;case "left":return Math.PI;case "right":return 0;case "radial":return(l-0.25)*2*Math.PI}}function e(l){switch(g){case "top":case "bottom":return l*j;case "left":return 0;case "right":return j;case "radial":return j/2+n*Math.cos(c(l))}}function d(l){switch(g){case "top":return 0;case "bottom":return k;case "left":case "right":return l*k;case "radial":return k/2+n*Math.sin(c(l))}}
if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var f=b.nodes,g=b.orient,h=this.$sort,i=pv.range(f.length),j=b.width,k=b.height,n=Math.min(j,k)/2;h&&i.sort(function(l,p){return h(f[l],f[p])});for(b=0;b<f.length;b++){var o=f[i[b]],r=o.breadth=(b+0.5)/f.length;o.x=e(r);o.y=d(r);o.midAngle=c(r)}}};
pv.Layout.Horizon=function(){pv.Layout.call(this);var b=this,c,e,d,f,g,h,i=this.buildImplied;this.buildImplied=function(j){i.call(this,j);c=j.bands;e=j.mode;d=Math.round((e=="color"?0.5:1)*j.height);f=j.backgroundStyle;g=pv.ramp(f,j.negativeStyle).domain(0,c);h=pv.ramp(f,j.positiveStyle).domain(0,c)};c=(new pv.Panel).data(function(){return pv.range(c*2)}).overflow("hidden").height(function(){return d}).top(function(j){return e=="color"?(j&1)*d:0}).fillStyle(function(j){return j?null:f});this.band=
(new pv.Mark).top(function(j,k){return e=="mirror"&&k&1?(k+1>>1)*d:null}).bottom(function(j,k){return e=="mirror"?k&1?null:(k+1>>1)*-d:(k&1||-1)*(k+1>>1)*d}).fillStyle(function(j,k){return(k&1?g:h)((k>>1)+1)});this.band.add=function(j){return b.add(pv.Panel).extend(c).add(j).extend(this)}};pv.Layout.Horizon.prototype=pv.extend(pv.Layout).property("bands",Number).property("mode",String).property("backgroundStyle",pv.fillStyle).property("positiveStyle",pv.fillStyle).property("negativeStyle",pv.fillStyle);
pv.Layout.Horizon.prototype.defaults=(new pv.Layout.Horizon).extend(pv.Layout.prototype.defaults).bands(2).mode("offset").backgroundStyle("white").positiveStyle("#1f77b4").negativeStyle("#d62728");
pv.Layout.Rollup=function(){pv.Layout.Network.call(this);var b=this,c,e,d=b.buildImplied;this.buildImplied=function(f){d.call(this,f);c=f.$rollup.nodes;e=f.$rollup.links};this.node.data(function(){return c}).shapeSize(function(f){return f.nodes.length*20});this.link.interpolate("polar").eccentricity(0.8);this.link.add=function(f){return b.add(pv.Panel).data(function(){return e}).add(f).extend(this)}};pv.Layout.Rollup.prototype=pv.extend(pv.Layout.Network).property("directed",Boolean);
pv.Layout.Rollup.prototype.x=function(b){this.$x=pv.functor(b);return this};pv.Layout.Rollup.prototype.y=function(b){this.$y=pv.functor(b);return this};
pv.Layout.Rollup.prototype.buildImplied=function(b){function c(p){return h[p]+","+i[p]}if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var e=b.nodes,d=b.links,f=b.directed,g=e.length,h=[],i=[],j=0,k={},n={},o=pv.Mark.stack,r={parent:this};o.unshift(null);for(var l=0;l<g;l++){r.index=l;o[0]=e[l];h[l]=this.$x.apply(r,o);i[l]=this.$y.apply(r,o)}o.shift();for(l=0;l<e.length;l++){g=c(l);o=k[g];if(!o){o=k[g]=Object.create(e[l]);o.index=j++;o.x=h[l];o.y=i[l];o.nodes=[]}o.nodes.push(e[l])}for(l=
0;l<d.length;l++){j=d[l].targetNode;e=k[c(d[l].sourceNode.index)];j=k[c(j.index)];g=!f&&e.index>j.index?j.index+","+e.index:e.index+","+j.index;(o=n[g])||(o=n[g]={sourceNode:e,targetNode:j,linkValue:0,links:[]});o.links.push(d[l]);o.linkValue+=d[l].linkValue}b.$rollup={nodes:pv.values(k),links:pv.values(n)}}};
pv.Layout.Matrix=function(){pv.Layout.Network.call(this);var b,c,e,d,f,g=this.buildImplied;this.buildImplied=function(h){g.call(this,h);b=h.nodes.length;c=h.width/b;e=h.height/b;d=h.$matrix.labels;f=h.$matrix.pairs};this.link.data(function(){return f}).left(function(){return c*(this.index%b)}).top(function(){return e*Math.floor(this.index/b)}).width(function(){return c}).height(function(){return e}).lineWidth(1.5).strokeStyle("#fff").fillStyle(function(h){return h.linkValue?"#555":"#eee"}).parent=
this;delete this.link.add;this.label.data(function(){return d}).left(function(){return this.index&1?c*((this.index>>1)+0.5):0}).top(function(){return this.index&1?0:e*((this.index>>1)+0.5)}).textMargin(4).textAlign(function(){return this.index&1?"left":"right"}).textAngle(function(){return this.index&1?-Math.PI/2:0});delete this.node};pv.Layout.Matrix.prototype=pv.extend(pv.Layout.Network).property("directed",Boolean);pv.Layout.Matrix.prototype.sort=function(b){this.$sort=b;return this};
pv.Layout.Matrix.prototype.buildImplied=function(b){if(!pv.Layout.Network.prototype.buildImplied.call(this,b)){var c=b.nodes,e=b.links,d=this.$sort,f=c.length,g=pv.range(f),h=[],i=[],j={};b.$matrix={labels:h,pairs:i};d&&g.sort(function(l,p){return d(c[l],c[p])});for(var k=0;k<f;k++)for(var n=0;n<f;n++){var o=g[k],r=g[n];i.push(j[o+"."+r]={row:k,col:n,sourceNode:c[o],targetNode:c[r],linkValue:0})}for(k=0;k<f;k++){o=g[k];h.push(c[o],c[o])}for(k=0;k<e.length;k++){h=e[k];f=h.sourceNode.index;g=h.targetNode.index;
h=h.linkValue;j[f+"."+g].linkValue+=h;b.directed||(j[g+"."+f].linkValue+=h)}}};
pv.Layout.Bullet=function(){pv.Layout.call(this);var b=this,c=b.buildImplied,e=b.x=pv.Scale.linear(),d,f,g,h,i;this.buildImplied=function(j){c.call(this,i=j);d=j.orient;f=/^left|right$/.test(d);g=pv.ramp("#bbb","#eee").domain(0,Math.max(1,i.ranges.length-1));h=pv.ramp("steelblue","lightsteelblue").domain(0,Math.max(1,i.measures.length-1))};(this.range=new pv.Mark).data(function(){return i.ranges}).reverse(true).left(function(){return d=="left"?0:null}).top(function(){return d=="top"?0:null}).right(function(){return d==
"right"?0:null}).bottom(function(){return d=="bottom"?0:null}).width(function(j){return f?e(j):null}).height(function(j){return f?null:e(j)}).fillStyle(function(){return g(this.index)}).antialias(false).parent=b;(this.measure=new pv.Mark).extend(this.range).data(function(){return i.measures}).left(function(){return d=="left"?0:f?null:this.parent.width()/3.25}).top(function(){return d=="top"?0:f?this.parent.height()/3.25:null}).right(function(){return d=="right"?0:f?null:this.parent.width()/3.25}).bottom(function(){return d==
"bottom"?0:f?this.parent.height()/3.25:null}).fillStyle(function(){return h(this.index)}).parent=b;(this.marker=new pv.Mark).data(function(){return i.markers}).left(function(j){return d=="left"?e(j):f?null:this.parent.width()/2}).top(function(j){return d=="top"?e(j):f?this.parent.height()/2:null}).right(function(j){return d=="right"?e(j):null}).bottom(function(j){return d=="bottom"?e(j):null}).strokeStyle("black").shape("bar").shapeAngle(function(){return f?0:Math.PI/2}).parent=b;(this.tick=new pv.Mark).data(function(){return e.ticks(7)}).left(function(j){return d==
"left"?e(j):null}).top(function(j){return d=="top"?e(j):null}).right(function(j){return d=="right"?e(j):f?null:-6}).bottom(function(j){return d=="bottom"?e(j):f?-8:null}).height(function(){return f?6:null}).width(function(){return f?null:6}).parent=b};pv.Layout.Bullet.prototype=pv.extend(pv.Layout).property("orient",String).property("ranges").property("markers").property("measures").property("minimum").property("maximum");pv.Layout.Bullet.prototype.defaults=(new pv.Layout.Bullet).extend(pv.Layout.prototype.defaults).orient("left").ranges([]).markers([]).measures([]);
pv.Layout.Bullet.prototype._originIsZero=true;pv.Layout.Bullet.prototype.originIsZero=function(b){if(arguments.length)return this._originIsZero=!!b;return this._originIsZero};
pv.Layout.Bullet.prototype.buildImplied=function(b){pv.Layout.prototype.buildImplied.call(this,b);var c=this.parent[/^left|right$/.test(b.orient)?"width":"height"](),e,d=b.maximum,f=b.minimum;if(d==null){e=[].concat(b.ranges,b.markers,b.measures);d=pv.max(e)}else d=+d;if(f==null){e||(e=[].concat(b.ranges,b.markers,b.measures));f=pv.min(e);f=0.95*f}else f=+f;if(f>d||d-f<1.0E-10)f=Math.abs(d)<1.0E-10?-0.1:0.99*d;if(this._originIsZero&&f*d>0)if(f>0)f=0;else d=0;b.minimum=f;b.maximum=d;this.x.domain(f,
d).range(0,c)};pv.Behavior={};
pv.Behavior.dragBase=function(b){function c(r){if(!n){n=true;this.addEventInterceptor("click",h,true)}if(!i){var l=this.root.scene.$g;i=[[l,"mousemove",pv.listen(l,"mousemove",e)],[l,"mouseup",pv.listen(l,"mouseup",d)],[document,"mousemove",pv.listen(document,"mousemove",e)],[document,"mouseup",pv.listen(document,"mouseup",d)]]}var p=arguments[arguments.length-1];j=p.target;k=false;p.stopPropagation();l=this.mouse();var q=this.scene,t=this.index;o=q[t].drag={phase:"start",m:l,m1:l,m2:null,d:r,scene:q,
index:t};p=f(p,o);b.dragstart.call(this,p);p=o.m;if(p!==l){l.x=p.x;l.y=p.y}}function e(r){if(o){o.phase="move";r.stopPropagation();r=f(r,o);var l=o.scene;l.mark.context(l,o.index,function(){var p=o.m2||o.m1,q=this.mouse();if(!(p&&q.distance2(p).dist2<=2)){o.m=o.m2=q;b.drag.call(this,r);p=o.m;if(p!==q){q.x=p.x;q.y=p.y}}})}}function d(r){if(o){o.phase="end";var l=o.m2;l=l&&o.m1.distance2(l).dist2>0.1;o.canceled=!l;(k=l&&j===r.target)||(j=null);r.stopPropagation();r=f(r,o);if(i){i.forEach(function(q){pv.unlisten.apply(pv,
q)});i=null}l=o.scene;var p=o.index;try{l.mark.context(l,p,function(){b.dragend.call(this,r)})}finally{o=null;delete l[p].drag}}}function f(r,l){try{r.drag=l;return r}catch(p){}l={};for(var q in r){var t=r[q];l[q]=typeof t!=="function"?t:g(t,r)}l._sourceEvent=r;return l}function g(r,l){return function(){return r.apply(l,arguments)}}function h(r,l){if(k&&j===l.target){k=false;j=null;return false}}var i,j,k,n,o;b.autoRender=true;b.positionConstraint=null;b.bound=function(r,l){return Math.max(o.min[l],
Math.min(o.max[l],r))};c.autoRender=function(r){if(arguments.length){b.autoRender=!!r;return c}return b.autoRender};c.positionConstraint=function(r){if(arguments.length){b.positionConstraint=r;return c}return b.positionConstraint};return c};
pv.Behavior.drag=function(){var b=null,c=1,e=1,d,f={dragstart:function(h){var i=h.drag;i.type="drag";var j=i.d,k=pv.vector(j.x,j.y);j.fix=k;j.drag=i;d=k.minus(i.m1);k=this.parent;i.max={x:k.width()-(j.dx||0),y:k.height()-(j.dy||0)};i.min={x:0,y:0};f.autoRender&&this.render();pv.Mark.dispatch("dragstart",i.scene,i.index,h)},drag:function(h){var i=h.drag,j=i.d;i.m=d.plus(i.m2);var k=f.positionConstraint;k&&k(i);k=i.m;if(c)j.x=j.fix.x=f.bound(k.x,"x");if(e)j.y=j.fix.y=f.bound(k.y,"y");f.autoRender&&
this.render();pv.Mark.dispatch("drag",i.scene,i.index,h)},dragend:function(h){var i=h.drag,j=i.d;d=j.fix=null;f.autoRender&&this.render();try{pv.Mark.dispatch("dragend",i.scene,i.index,h)}finally{delete j.drag}}},g=pv.Behavior.dragBase(f);g.collapse=function(h){if(arguments.length){b=String(h);switch(b){case "y":c=1;e=0;break;case "x":c=0;e=1;break;default:e=c=1;break}return g}return b};return g};
pv.Behavior.point=function(b){function c(w,m){if(w.visible)for(var s=w.children.length-1;s>=0;s--)if(e(w.children[s],m))return true}function e(w,m){var s=w.mark,u=s.type==="panel",v,y;if(s.$handlers.point){var z=(u&&s.parent||s).mouse(),A;y=s._pointingRadiusMax;var B=y*y;for(y=w.length;y--;)if(A=d(w,y))if(f(w,y,z,m,A,B)){v=true;break}}if(u){s.scene=w;u=!!(s.isPointingBarrier&&s.parent);try{for(y=w.length;y--;){s.index=y;if(!u||s.getShape(w,y).containsPoint(s.parent.mouse()))if(c(w[y],m))return true}}finally{delete s.scene;
delete s.index}}return v}function d(w,m){m=w[m];if(!m.visible)return 0;if(!o)return 1;w=w.mark.properties;if(!w.fillStyle&&!w.strokeStyle)return 1;w=Math.max(m.fillStyle?m.fillStyle.opacity:0,m.strokeStyle?m.strokeStyle.opacity:0);return w<0.02?0:w>0.98?1:0.5}function f(w,m,s,u,v,y){function z(){if(G&&y<=0)return-1;C=A.distance2(s,l);if(G&&pv.floatLess(y,C.cost))return-2;if(t&&!D&&pv.floatLess(q,C.dist2))return-3;if(B===u.hasArea){if(D<u.inside)return-4;if(D>u.inside)return+1}else{if(n){if(!D&&u.inside)return-5;
if(D&&!u.inside)return+2}if(!B&&u.inside===2){if(D===2)return+3;if(D===0&&pv.floatLess(3,C.cost))return-6}else if(B&&D===2){if(u.inside===2)return-7;if(u.inside===0&&pv.floatLess(3,u.cost))return+4}}if(!(n&&D)){if(pv.floatLess(u.dist2,C.dist2))return-8;if(pv.floatLess(C.dist2,u.dist2))return+5}if(n&&pv.floatLess(C.cost,u.cost))return+6;return-9}var A=w.mark.getShape(w,m),B=A.hasArea(),D=!A.containsPoint(s,l)?0:!n||A.containsPoint(s)?2:1,G=isFinite(y)&&D<2,C,H=z();j&&function(){if(H<-3||H>0){var I=
w&&w.mark;console.log("POINT "+(H>0?"choose":"skip")+" ("+H+") "+(I?I.type+" "+m:"none")+" in="+D+" d2="+(C&&C.dist2)+" cost="+(C&&C.cost)+" opaq="+(v===1))}}();if(H>0){u.hasArea=B;u.inside=D;u.dist2=C.dist2;u.cost=C.cost;u.scenes=w;u.index=m;u.shape=A;if(B&&D===2&&v===1)return true}}function g(){var w=pv.event;j&&console.log("POINT MOUSE MOVE BEG");try{var m={cost:Infinity,dist2:Infinity,inside:0,hasArea:false,x:w.pageX||0,y:w.pageY||0};if(!(k&&x&&pv.Shape.dist2(m,k).cost<x)){c(this.scene[this.index],
m);if(!m.inside&&!isFinite(m.cost))m=null;w.pointFrom=k;w.pointTo=m;if(k){if(m&&k.scenes==m.scenes&&k.index==m.index)return;w.isPointSwitch=!!m;pv.Mark.dispatch("unpoint",k.scenes,k.index,w)}if(k=m){pv.Mark.dispatch("point",m.scenes,m.index,w);if(!p)if(this.type==="panel"){p=this;this.event("mouseout",function(){h.call(this.scene.$g)});r&&p.addEventInterceptor("click",i)}else pv.listen(this.root.canvas(),"mouseout",h)}}}finally{j&&console.log("POINT MOUSE MOVE END")}}function h(){var w=pv.event;if(k&&
!pv.ancestor(this,w.relatedTarget)){pv.Mark.dispatch("unpoint",k.scenes,k.index,w);k=null}}function i(w,m){if(k){var s=k.scenes;if(w=s.mark.$handlers[w])return[w,s,k.index,m]}}if(typeof b!=="object")b={radius:b};var j=0,k,n=null,o=!!pv.get(b,"painted",false),r=!!pv.get(b,"stealClick",false),l={x:1,y:1},p=null,q=function(){var w=pv.parseNumNonNeg(pv.get(b,"radius"),30);return w*w}(),t=isFinite(q),x=function(){var w=pv.parseNumNonNeg(pv.get(b,"radiusHyst"),0);isFinite(w)||(w=4);return w*w}();g.collapse=
function(w){if(arguments.length){n=String(w);switch(n){case "y":l.x=1;l.y=0;break;case "x":l.x=0;l.y=1;break;default:l.x=1;l.y=1;n=null;break}return g}return n};b&&b.collapse!=null&&g.collapse(b.collapse);b=null;return g};
pv.Behavior.select=function(){var b=null,c=1,e=1,d=false,f={dragstart:function(h){var i=h.drag;i.type="select";i.dxmin=0;i.dymin=0;var j=i.d;j.drag=i;i.max={x:this.width(),y:this.height()};i.min={x:0,y:0};var k=f.positionConstraint;if(k){i.m=i.m.clone();k(i)}k=i.m;if(c){j.x=f.bound(k.x,"x");if(!d)j.dx=Math.max(0,i.dxmin)}if(e){j.y=f.bound(k.y,"y");if(!d)j.dy=Math.max(0,i.dymin)}pv.Mark.dispatch("selectstart",i.scene,i.index,h)},drag:function(h){var i=h.drag,j=i.m1,k=i.d;i.max.x=this.width();i.max.y=
this.height();var n=f.positionConstraint;if(n){i.m=i.m.clone();n(i)}n=i.m;if(c){var o=Math.min(j.x,n.x);o=f.bound(o,"x");k.x=o;if(!d){var r=Math.max(n.x,j.x);r=f.bound(r,"x");k.dx=Math.max(0,i.dxmin,r-o)}}if(e){o=Math.min(j.y,n.y);o=f.bound(o,"y");k.y=o;if(!d){j=Math.max(n.y,j.y);j=f.bound(j,"y");k.dy=Math.max(0,i.dymin,j-o)}}f.autoRender&&this.render();pv.Mark.dispatch("select",i.scene,i.index,h)},dragend:function(h){var i=h.drag;try{pv.Mark.dispatch("selectend",i.scene,i.index,h)}finally{delete i.d.drag}}},
g=pv.Behavior.dragBase(f);g.collapse=function(h){if(arguments.length){b=String(h);switch(b){case "y":c=1;e=0;break;case "x":c=0;e=1;break;default:e=c=1;break}return g}return b};g.preserveLength=function(h){if(arguments.length){d=!!h;return g}return d};return g};
pv.Behavior.resize=function(b){var c=false,e=b==="left"||b==="right",d={dragstart:function(g){var h=g.drag;h.type="resize";var i=h.m1,j=h.d;j.drag=h;switch(b){case "left":i.x=j.x+j.dx;break;case "right":i.x=j.x;break;case "top":i.y=j.y+j.dy;break;case "bottom":i.y=j.y;break}i=this.parent;h.max={x:i.width(),y:i.height()};h.min={x:0,y:0};pv.Mark.dispatch("resizestart",h.scene,h.index,g)},drag:function(g){var h=g.drag,i=h.m1,j=d.positionConstraint;if(j){h.m=h.m.clone();j(h)}var k=h.m;j=h.d;if(!c||e){var n=
Math.min(i.x,k.x),o=Math.max(k.x,i.x);n=d.bound(n,"x");o=d.bound(o,"x");j.x=n;j.dx=o-n}if(!c||!e){n=Math.min(i.y,k.y);i=Math.max(k.y,i.y);n=d.bound(n,"y");i=d.bound(i,"y");j.y=n;j.dy=i-n}d.autoRender&&this.render();pv.Mark.dispatch("resize",h.scene,h.index,g)},dragend:function(g){var h=g.drag;h.max=null;try{pv.Mark.dispatch("resizeend",h.scene,h.index,g)}finally{delete h.d.drag}}},f=pv.Behavior.dragBase(d);f.preserveOrtho=function(g){if(arguments.length){c=!!g;return f}return c};return f};
pv.Behavior.pan=function(){function b(){f=this.index;d=this.scene;h=pv.vector(pv.event.pageX,pv.event.pageY);g=this.transform();i=1/(g.k*this.scale);if(j)j={x:(1-g.k)*this.width(),y:(1-g.k)*this.height()}}function c(k){if(d){d.mark.context(d,f,function(){var n=g.translate((pv.event.pageX-h.x)*i,(pv.event.pageY-h.y)*i);if(j){n.x=Math.max(j.x,Math.min(0,n.x));n.y=Math.max(j.y,Math.min(0,n.y))}this.transform(n).render()});pv.Mark.dispatch("pan",d,f,k)}}function e(){d=null}var d,f,g,h,i,j;b.bound=function(k){if(arguments.length){j=
Boolean(k);return this}return Boolean(j)};pv.listen(window,"mousemove",c);pv.listen(window,"mouseup",e);return b};
pv.Behavior.zoom=function(b){function c(d){var f=this.mouse(),g=pv.event.wheel*b;f=this.transform().translate(f.x,f.y).scale(g<0?1E3/(1E3-g):(1E3+g)/1E3).translate(-f.x,-f.y);if(e){f.k=Math.max(1,f.k);f.x=Math.max((1-f.k)*this.width(),Math.min(0,f.x));f.y=Math.max((1-f.k)*this.height(),Math.min(0,f.y))}this.transform(f).render();pv.Mark.dispatch("zoom",this.scene,this.index,d)}var e;arguments.length||(b=1/48);c.bound=function(d){if(arguments.length){e=Boolean(d);return this}return Boolean(e)};return c};
pv.Geo=function(){};
pv.Geo.projections={mercator:{project:function(b){return{x:b.lng/180,y:b.lat>85?1:b.lat<-85?-1:Math.log(Math.tan(Math.PI/4+pv.radians(b.lat)/2))/Math.PI}},invert:function(b){return{lng:b.x*180,lat:pv.degrees(2*Math.atan(Math.exp(b.y*Math.PI))-Math.PI/2)}}},"gall-peters":{project:function(b){return{x:b.lng/180,y:Math.sin(pv.radians(b.lat))}},invert:function(b){return{lng:b.x*180,lat:pv.degrees(Math.asin(b.y))}}},sinusoidal:{project:function(b){return{x:pv.radians(b.lng)*Math.cos(pv.radians(b.lat))/Math.PI,
y:b.lat/90}},invert:function(b){return{lng:pv.degrees(b.x*Math.PI/Math.cos(b.y*Math.PI/2)),lat:b.y*90}}},aitoff:{project:function(b){var c=pv.radians(b.lng);b=pv.radians(b.lat);var e=Math.acos(Math.cos(b)*Math.cos(c/2));return{x:2*(e?Math.cos(b)*Math.sin(c/2)*e/Math.sin(e):0)/Math.PI,y:2*(e?Math.sin(b)*e/Math.sin(e):0)/Math.PI}},invert:function(b){var c=b.y*Math.PI/2;return{lng:pv.degrees(b.x*Math.PI/2/Math.cos(c)),lat:pv.degrees(c)}}},hammer:{project:function(b){var c=pv.radians(b.lng);b=pv.radians(b.lat);
var e=Math.sqrt(1+Math.cos(b)*Math.cos(c/2));return{x:2*Math.SQRT2*Math.cos(b)*Math.sin(c/2)/e/3,y:Math.SQRT2*Math.sin(b)/e/1.5}},invert:function(b){var c=b.x*3;b=b.y*1.5;var e=Math.sqrt(1-c*c/16-b*b/4);return{lng:pv.degrees(2*Math.atan2(e*c,2*(2*e*e-1))),lat:pv.degrees(Math.asin(e*b))}}},identity:{project:function(b){return{x:b.lng/180,y:b.lat/90}},invert:function(b){return{lng:b.x*180,lat:b.y*90}}}};
pv.Geo.scale=function(b){function c(l){if(!o||l.lng!=o.lng||l.lat!=o.lat){o=l;l=e(l);r={x:j(l.x),y:k(l.y)}}return r}function e(l){return i.project({lng:l.lng-n.lng,lat:l.lat})}function d(l){l=i.invert(l);l.lng+=n.lng;return l}var f={x:0,y:0},g={x:1,y:1},h=[],i=pv.Geo.projections.identity,j=pv.Scale.linear(-1,1).range(0,1),k=pv.Scale.linear(-1,1).range(1,0),n={lng:0,lat:0},o,r;c.x=function(l){return c(l).x};c.y=function(l){return c(l).y};c.ticks={lng:function(l){var p;if(h.length>1){var q=pv.Scale.linear();
if(l==undefined)l=10;p=q.domain(h,function(t){return t.lat}).ticks(l);l=q.domain(h,function(t){return t.lng}).ticks(l)}else{p=pv.range(-80,81,10);l=pv.range(-180,181,10)}return l.map(function(t){return p.map(function(x){return{lat:x,lng:t}})})},lat:function(l){return pv.transpose(c.ticks.lng(l))}};c.invert=function(l){return d({x:j.invert(l.x),y:k.invert(l.y)})};c.domain=function(l,p){if(arguments.length){h=l instanceof Array?arguments.length>1?pv.map(l,p):l:Array.prototype.slice.call(arguments);
if(h.length>1){var q=h.map(function(x){return x.lng}),t=h.map(function(x){return x.lat});n={lng:(pv.max(q)+pv.min(q))/2,lat:(pv.max(t)+pv.min(t))/2};q=h.map(e);j.domain(q,function(x){return x.x});k.domain(q,function(x){return x.y})}else{n={lng:0,lat:0};j.domain(-1,1);k.domain(-1,1)}o=null;return this}return h};c.range=function(l,p){if(arguments.length){if(typeof l=="object"){f={x:Number(l.x),y:Number(l.y)};g={x:Number(p.x),y:Number(p.y)}}else{f={x:0,y:0};g={x:Number(l),y:Number(p)}}j.range(f.x,g.x);
k.range(g.y,f.y);o=null;return this}return[f,g]};c.projection=function(l){if(arguments.length){i=typeof l=="string"?pv.Geo.projections[l]||pv.Geo.projections.identity:l;return this.domain(h)}return l};pv.copyOwn(c,pv.Scale.common);arguments.length&&c.projection(b);return c};