/protovis-r3.0.js
http://protovis-js.googlecode.com/ · JavaScript · 1 lines · 1 code · 0 blank · 0 comment · 1 complexity · fab7b43a036b10da96d566b3b9a73d27 MD5 · raw file
Large files are truncated click here to view the full file
- if(!Array.prototype.map){Array.prototype.map=function(c,d){var e=this.length;var a=new Array(e);for(var b=0;b<e;b++){if(b in this){a[b]=c.call(d,this[b],b,this)}}return a}}if(!Array.prototype.filter){Array.prototype.filter=function(d,e){var g=this.length;var a=new Array();for(var c=0;c<g;c++){if(c in this){var b=this[c];if(d.call(e,b,c,this)){a.push(b)}}}return a}}if(!Array.prototype.forEach){Array.prototype.forEach=function(b,c){var d=this.length>>>0;for(var a=0;a<d;a++){if(a in this){b.call(c,this[a],a,this)}}}}if(!Array.prototype.reduce){Array.prototype.reduce=function(d,b){var a=this.length;if(!a&&(arguments.length==1)){throw new Error("reduce: empty array, no initial value")}var c=0;if(arguments.length<2){while(true){if(c in this){b=this[c++];break}if(++c>=a){throw new Error("reduce: no values, no initial value")}}}for(;c<a;c++){if(c in this){b=d(b,this[c],c,this)}}return b}}Date.__parse__=Date.parse;Date.parse=function(j,i){if(arguments.length==1){return Date.__parse__(j)}var h=1970,g=0,b=1,d=0,c=0,a=0;var f=[function(){}];i=i.replace(/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g,"\\$&");i=i.replace(/%[a-zA-Z0-9]/g,function(k){switch(k){case"%b":f.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":f.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":f.push(function(l){b=l});return"([0-9]+)";case"%H":f.push(function(l){d=l});return"([0-9]+)";case"%m":f.push(function(l){g=l-1});return"([0-9]+)";case"%M":f.push(function(l){c=l});return"([0-9]+)";case"%S":f.push(function(l){a=l});return"([0-9]+)";case"%y":f.push(function(l){l=Number(l);h=l+(((0<=l)&&(l<69))?2000:(((l>=69)&&(l<100)?1900:0)))});return"([0-9]+)";case"%Y":f.push(function(l){h=l});return"([0-9]+)";case"%%":f.push(function(){});return"%"}return k});var e=j.match(i);if(e){e.forEach(function(k,l){f[l](k)})}return new Date(h,g,b,d,c,a)};if(Date.prototype.toLocaleFormat){Date.prototype.format=Date.prototype.toLocaleFormat}else{Date.prototype.format=function(b){function a(e,d){return(e<10)?(d||"0")+e:e}var c=this;return b.replace(/%[a-zA-Z0-9]/g,function(f){switch(f){case"%a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat",][c.getDay()];case"%A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday",][c.getDay()];case"%h":case"%b":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec",][c.getMonth()];case"%B":return["January","February","March","April","May","June","July","August","September","October","November","December",][c.getMonth()];case"%c":return c.toLocaleString();case"%C":return a(Math.floor(c.getFullYear()/100)%100);case"%d":return a(c.getDate());case"%x":case"%D":return a(c.getMonth()+1)+"/"+a(c.getDate())+"/"+a(c.getFullYear()%100);case"%e":return a(c.getDate()," ");case"%H":return a(c.getHours());case"%I":var e=c.getHours()%12;return e?a(e):12;case"%m":return a(c.getMonth()+1);case"%M":return a(c.getMinutes());case"%n":return"\n";case"%p":return c.getHours()<12?"AM":"PM";case"%T":case"%X":case"%r":var e=c.getHours()%12;return(e?a(e):12)+":"+a(c.getMinutes())+":"+a(c.getSeconds())+" "+(c.getHours()<12?"AM":"PM");case"%R":return a(c.getHours())+":"+a(c.getMinutes());case"%S":return a(c.getSeconds());case"%t":return"\t";case"%u":var d=c.getDay();return d?d:1;case"%w":return c.getDay();case"%y":return a(c.getFullYear()%100);case"%Y":return c.getFullYear();case"%%":return"%"}return f})}};var pv = function() {var pv={};pv.extend=function(b){function a(){}a.prototype=b.prototype||b;return new a()};try{eval("pv.parse = function(x) x;")}catch(e){pv.parse=function(l){var h=new RegExp("function(\\s+\\w+)?\\([^)]*\\)\\s*","mg"),a,f=0;var g="";while(a=h.exec(l)){var b=a.index+a[0].length;if(l.charAt(b--)!="{"){g+=l.substring(f,b)+"{return ";f=b;for(var k=0;k>=0&&b<l.length;b++){var n=l.charAt(b);switch(n){case'"':case"'":while(++b<l.length&&(d=l.charAt(b))!=n){if(d=="\\"){b++}}break;case"[":case"(":k++;break;case"]":case")":k--;break;case";":case",":if(k==0){k--}break}}g+=pv.parse(l.substring(f,--b))+";}";f=b}h.lastIndex=b}g+=l.substring(f);return g}}pv.identity=function(a){return a};pv.index=function(){return this.index};pv.child=function(){return this.childIndex};pv.parent=function(){return this.parent.index};pv.range=function(h,c,f){if(arguments.length==1){c=h;h=0}if(f==undefined){f=1}else{if(!f){throw new Error("step must be non-zero")}}var g=[],b=0,a;if(f<0){while((a=h+f*b++)>c){g.push(a)}}else{while((a=h+f*b++)<c){g.push(a)}}return g};pv.random=function(b,a,c){if(arguments.length==1){a=b;b=0}if(c==undefined){c=1}return c?(Math.floor(Math.random()*(a-b)/c)*c+b):(Math.random()*(a-b)+b)};pv.repeat=function(b,a){if(arguments.length==1){a=2}return pv.blend(pv.range(a).map(function(){return b}))};pv.cross=function(h,g){var p=[];for(var l=0,o=h.length,f=g.length;l<o;l++){for(var k=0,c=h[l];k<f;k++){p.push([c,g[k]])}}return p};pv.blend=function(a){return Array.prototype.concat.apply([],a)};pv.transpose=function(g){var h=g.length,a=pv.max(g,function(i){return i.length});if(a>h){g.length=a;for(var f=h;f<a;f++){g[f]=new Array(h)}for(var f=0;f<h;f++){for(var b=f+1;b<a;b++){var c=g[f][b];g[f][b]=g[b][f];g[b][f]=c}}}else{for(var f=0;f<a;f++){g[f].length=h}for(var f=0;f<h;f++){for(var b=0;b<f;b++){var c=g[f][b];g[f][b]=g[b][f];g[b][f]=c}}}g.length=a;for(var f=0;f<a;f++){g[f].length=h}return g};pv.keys=function(b){var c=[];for(var a in b){c.push(a)}return c};pv.entries=function(b){var c=[];for(var a in b){c.push({key:a,value:b[a]})}return c};pv.values=function(b){var c=[];for(var a in b){c.push(b[a])}return c};function map(c,a){var b={};return a?c.map(function(g,f){b.index=f;return a.call(b,g)}):c.slice()}pv.normalize=function(h,g){var b=map(h,g),c=pv.sum(b);for(var a=0;a<b.length;a++){b[a]/=c}return b};pv.sum=function(c,a){var b={};return c.reduce(a?function(g,h,f){b.index=f;return g+a.call(b,h)}:function(f,g){return f+g},0)};pv.max=function(b,a){if(a==pv.index){return b.length-1}return Math.max.apply(null,a?map(b,a):b)};pv.max.index=function(k,g){if(g==pv.index){return k.length-1}if(!g){g=pv.identity}var b=-1,j=-Infinity,h={};for(var c=0;c<k.length;c++){h.index=c;var a=g.call(h,k[c]);if(a>j){j=a;b=c}}return b};pv.min=function(b,a){if(a==pv.index){return 0}return Math.min.apply(null,a?map(b,a):b)};pv.min.index=function(k,h){if(h==pv.index){return 0}if(!h){h=pv.identity}var g=-1,b=Infinity,j={};for(var c=0;c<k.length;c++){j.index=c;var a=h.call(j,k[c]);if(a<b){b=a;g=c}}return g};pv.mean=function(b,a){return pv.sum(b,a)/b.length};pv.median=function(c,b){if(b==pv.index){return(c.length-1)/2}c=map(c,b).sort(pv.naturalOrder);if(c.length%2){return c[Math.floor(c.length/2)]}var a=c.length/2;return(c[a-1]+c[a])/2};pv.dict=function(g,h){var a={},j={};for(var c=0;c<g.length;c++){if(c in g){var b=g[c];j.index=c;a[b]=h.call(j,b)}}return a};pv.permute=function(h,a,b){if(!b){b=pv.identity}var c=new Array(a.length),g={};a.forEach(function(f,k){g.index=f;c[k]=b.call(g,h[f])});return c};pv.numerate=function(a,b){if(!b){b=pv.identity}var c={},g={};a.forEach(function(f,h){g.index=h;c[b.call(g,f)]=h});return c};pv.naturalOrder=function(f,c){return(f<c)?-1:((f>c)?1:0)};pv.reverseOrder=function(c,f){return(f<c)?-1:((f>c)?1:0)};pv.css=function(b,a){return window.getComputedStyle?window.getComputedStyle(b,null).getPropertyValue(a):b.currentStyle[a]};pv.ns={svg:"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/xmlns",xlink:"http://www.w3.org/1999/xlink"};pv.version={major:3,minor:0};pv.error=function(a){(typeof console=="undefined")?alert(a):console.error(a)};pv.listen=function(c,a,b){return c.addEventListener?c.addEventListener(a,b,false):c.attachEvent("on"+a,b)};pv.log=function(c,a){return Math.log(c)/Math.log(a)};pv.logSymmetric=function(c,a){return(c==0)?0:((c<0)?-pv.log(-c,a):pv.log(c,a))};pv.logAdjusted=function(c,a){var f=c<0;if(c<a){c+=(a-c)/a}return f?-pv.log(c,a):pv.log(c,a)};pv.logFloor=function(c,a){return(c>0)?Math.pow(a,Math.floor(pv.log(c,a))):-Math.pow(a,-Math.floor(-pv.log(-c,a)))};pv.logCeil=function(c,a){return(c>0)?Math.pow(a,Math.ceil(pv.log(c,a))):-Math.pow(a,-Math.ceil(-pv.log(-c,a)))};pv.search=function(h,g){var a=0,f=h.length-1;while(a<=f){var b=(a+f)>>1,c=h[b];if(c<g){a=b+1}else{if(c>g){f=b-1}else{return b}}}return -a-1};pv.tree=function(a){return new pv.Tree(a)};pv.Tree=function(a){this.array=a};pv.Tree.prototype.keys=function(a){this.k=a;return this};pv.Tree.prototype.value=function(a){this.v=a;return this};pv.Tree.prototype.map=function(){var h={},k={};for(var b=0;b<this.array.length;b++){k.index=b;var g=this.array[b],f=this.k.call(k,g),c=h;for(var a=0;a<f.length-1;a++){c=c[f[a]]||(c[f[a]]={})}c[f[a]]=this.v?this.v.call(k,g):g}return h};pv.nest=function(a){return new pv.Nest(a)};pv.Nest=function(a){this.array=a;this.keys=[]};pv.Nest.prototype.key=function(a){this.keys.push(a);return this};pv.Nest.prototype.sortKeys=function(a){this.keys[this.keys.length-1].order=a||pv.naturalOrder;return this};pv.Nest.prototype.sortValues=function(a){this.order=a||pv.naturalOrder;return this};pv.Nest.prototype.map=function(){var o={},h=[];for(var n,l=0;l<this.array.length;l++){var c=this.array[l];var b=o;for(n=0;n<this.keys.length-1;n++){var g=this.keys[n](c);if(!b[g]){b[g]={}}b=b[g]}g=this.keys[n](c);if(!b[g]){var f=[];h.push(f);b[g]=f}b[g].push(c)}if(this.order){for(var n=0;n<h.length;n++){h[n].sort(this.order)}}return o};pv.Nest.prototype.entries=function(){function a(g){var h=[];for(var f in g){var c=g[f];h.push({key:f,values:(c instanceof Array)?c:a(c)})}return h}function b(h,f){var g=this.keys[f].order;if(g){h.sort(function(j,i){return g(j.key,i.key)})}if(++f<this.keys.length){for(var c=0;c<h.length;c++){b.call(this,h[c].values,f)}}return h}return b.call(this,a(this.map()),0)};pv.Nest.prototype.rollup=function(b){function a(g){for(var c in g){var f=g[c];if(f instanceof Array){g[c]=b(f)}else{a(f)}}return g}return a(this.map())};pv.flatten=function(a){return new pv.Flatten(a)};pv.Flatten=function(a){this.map=a;this.keys=[]};pv.Flatten.prototype.key=function(a,b){this.keys.push({name:a,value:b});return this};pv.Flatten.prototype.array=function(){var b=[],a=[],f=this.keys;function c(j,h){if(h<f.length-1){for(var g in j){a.push(g);c(j[g],h+1);a.pop()}}else{b.push(a.concat(j))}}c(this.map,0);return b.map(function(h){var g={};for(var n=0;n<f.length;n++){var l=f[n],j=h[n];g[l.name]=l.value?l.value.call(null,j):j}return g})};pv.vector=function(a,b){return new pv.Vector(a,b)};pv.Vector=function(a,b){this.x=a;this.y=b};pv.Vector.prototype.perp=function(){return new pv.Vector(-this.y,this.x)};pv.Vector.prototype.norm=function(){var a=this.length();return this.times(a?(1/a):1)};pv.Vector.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};pv.Vector.prototype.times=function(a){return new pv.Vector(this.x*a,this.y*a)};pv.Vector.prototype.plus=function(a,b){return(arguments.length==1)?new pv.Vector(this.x+a.x,this.y+a.y):new pv.Vector(this.x+a,this.y+b)};pv.Vector.prototype.minus=function(a,b){return(arguments.length==1)?new pv.Vector(this.x-a.x,this.y-a.y):new pv.Vector(this.x-a,this.y-b)};pv.Vector.prototype.dot=function(a,b){return(arguments.length==1)?this.x*a.x+this.y*a.y:this.x*a+this.y*b};pv.Scale=function(){};pv.Scale.interpolator=function(b,a){if(typeof b=="number"){return function(c){return c*(a-b)+b}}b=pv.color(b).rgb();a=pv.color(a).rgb();return function(f){var c=b.a*(1-f)+a.a*f;if(c<0.00001){c=0}return(b.a==0)?pv.rgb(a.r,a.g,a.b,c):((a.a==0)?pv.rgb(b.r,b.g,b.b,c):pv.rgb(Math.round(b.r*(1-f)+a.r*f),Math.round(b.g*(1-f)+a.g*f),Math.round(b.b*(1-f)+a.b*f),c))}};pv.Scale.linear=function(){var f=[0,1],b=[0,1],a=[pv.identity];function c(g){var h=pv.search(f,g);if(h<0){h=-h-2}h=Math.max(0,Math.min(a.length-1,h));return a[h]((g-f[h])/(f[h+1]-f[h]))}c.domain=function(i,h,g){if(arguments.length){if(i instanceof Array){if(arguments.length<2){h=pv.identity}if(arguments.length<3){g=h}f=[pv.min(i,h),pv.max(i,g)]}else{f=Array.prototype.slice.call(arguments)}return this}return f};c.range=function(){if(arguments.length){b=Array.prototype.slice.call(arguments);a=[];for(var g=0;g<b.length-1;g++){a.push(pv.Scale.interpolator(b[g],b[g+1]))}return this}return b};c.invert=function(h){var g=pv.search(b,h);if(g<0){g=-g-2}g=Math.max(0,Math.min(a.length-1,g));return(h-b[g])/(b[g+1]-b[g])*(f[g+1]-f[g])+f[g]};c.ticks=function(){var i=f[0],g=f[f.length-1],j=g-i,k=pv.logCeil(j/10,10);if(j/k<2){k/=5}else{if(j/k<5){k/=2}}var l=Math.ceil(i/k)*k,h=Math.floor(g/k)*k;return pv.range(l,h+k,k)};c.nice=function(){var h=f[0],g=f[f.length-1],i=Math.pow(10,Math.round(Math.log(g-h)/Math.log(10))-1);f=[Math.floor(h/i)*i,Math.ceil(g/i)*i];return this};c.by=function(g){function h(){return c(g.apply(this,arguments))}for(var i in c){h[i]=c[i]}return h};c.domain.apply(c,arguments);return c};pv.Scale.log=function(){var k=[1,10],c=[0,1],a=10,h=[0,1],f=[pv.identity];function j(b){var i=pv.search(k,b);if(i<0){i=-i-2}i=Math.max(0,Math.min(f.length-1,i));return f[i]((g(b)-c[i])/(c[i+1]-c[i]))}function g(b){return pv.logSymmetric(b,a)}j.domain=function(l,i,b){if(arguments.length){if(l instanceof Array){if(arguments.length<2){i=pv.identity}if(arguments.length<3){b=i}k=[pv.min(l,i),pv.max(l,b)]}else{k=Array.prototype.slice.call(arguments)}c=k.map(g);return this}return k};j.range=function(){if(arguments.length){h=Array.prototype.slice.call(arguments);f=[];for(var b=0;b<h.length-1;b++){f.push(pv.Scale.interpolator(h[b],h[b+1]))}return this}return h};j.invert=function(l){var b=pv.search(h,l);if(b<0){b=-b-2}b=Math.max(0,Math.min(f.length-1,b));var i=c[b]+(l-h[b])/(h[b+1]-h[b])*(c[b+1]-c[b]);return(i<0)?-Math.pow(a,-i):Math.pow(a,i)};j.ticks=function(){var p=Math.floor(c[0]),l=Math.ceil(c[1]),o=[];for(var n=p;n<l;n++){var b=Math.pow(a,n);for(var m=1;m<a;m++){o.push(b*m)}}o.push(Math.pow(a,l));if(o[0]<k[0]){o.shift()}if(o[o.length-1]>k[1]){o.pop()}return o};j.nice=function(){k=[pv.logFloor(k[0],a),pv.logCeil(k[1],a)];c=k.map(g);return this};j.base=function(b){if(arguments.length){a=b;c=k.map(g);return this}return a};j.by=function(b){function i(){return j(b.apply(this,arguments))}for(var l in j){i[l]=j[l]}return i};j.domain.apply(j,arguments);return j};pv.Scale.ordinal=function(){var g=[],a={},b=[],f=0;function c(h){if(!(h in a)){a[h]=g.push(h)-1}return b[a[h]%b.length]}c.domain=function(m,k){if(arguments.length){m=(m instanceof Array)?((arguments.length>1)?m.map(k):m):Array.prototype.slice.call(arguments);g=[];var h={};for(var i=0;i<m.length;i++){var l=m[i];if(!(l in h)){h[l]=true;g.push(l)}}a=pv.numerate(g);return this}return g};c.range=function(i,h){if(arguments.length){b=(i instanceof Array)?((arguments.length>1)?i.map(h):i):Array.prototype.slice.call(arguments);if(typeof b[0]=="string"){b=b.map(pv.color)}return this}return b};c.split=function(i,h){var j=(h-i)/this.domain().length;b=pv.range(i+j/2,h,j);return this};c.splitFlush=function(i,h){var k=this.domain().length,j=(h-i)/(k-1);b=(k==1)?[(i+h)/2]:pv.range(i,h+j/2,j);return this};c.splitBanded=function(i,h,o){if(arguments.length<3){o=1}if(o<0){var p=this.domain().length,l=-o*p,j=h-i-l,m=j/(p+1);b=pv.range(i+m,h,m-o);b.band=-o}else{var k=(h-i)/(this.domain().length+(1-o));b=pv.range(i+k*(1-o),h,k);b.band=k*o}return this};c.by=function(h){function i(){return c(h.apply(this,arguments))}for(var j in c){i[j]=c[j]}return i};c.domain.apply(c,arguments);return c};pv.color=function(o){if(!o||(o=="transparent")){return pv.rgb(0,0,0,0)}if(o instanceof pv.Color){return o}var q=/([a-z]+)\((.*)\)/i.exec(o);if(q){var p=q[2].split(","),n=1;switch(q[1]){case"hsla":case"rgba":n=parseFloat(p[3]);break}switch(q[1]){case"hsla":case"hsl":var j=parseFloat(p[0]),t=parseFloat(p[1])/100,f=parseFloat(p[2])/100;return(new pv.Color.Hsl(j,t,f,n)).rgb();case"rgba":case"rgb":function i(b){var a=parseFloat(b);return(b[b.length-1]=="%")?Math.round(a*2.55):a}var c=i(p[0]),k=i(p[1]),m=i(p[2]);return pv.rgb(c,k,m,n)}}o=pv.Color.names[o]||o;if(o.charAt(0)=="#"){var c,k,m;if(o.length==4){c=o.charAt(1);c+=c;k=o.charAt(2);k+=k;m=o.charAt(3);m+=m}else{if(o.length==7){c=o.substring(1,3);k=o.substring(3,5);m=o.substring(5,7)}}return pv.rgb(parseInt(c,16),parseInt(k,16),parseInt(m,16),1)}return new pv.Color(o,1)};pv.Color=function(a,b){this.color=a;this.opacity=b};pv.Color.prototype.brighter=function(a){return this.rgb().brighter(a)};pv.Color.prototype.darker=function(a){return this.rgb().darker(a)};pv.rgb=function(i,h,c,f){return new pv.Color.Rgb(i,h,c,(arguments.length==4)?f:1)};pv.Color.Rgb=function(i,h,c,f){pv.Color.call(this,f?("rgb("+i+","+h+","+c+")"):"none",f);this.r=i;this.g=h;this.b=c;this.a=f};pv.Color.Rgb.prototype=pv.extend(pv.Color);pv.Color.Rgb.prototype.red=function(a){return pv.rgb(a,this.g,this.b,this.a)};pv.Color.Rgb.prototype.green=function(a){return pv.rgb(this.r,a,this.b,this.a)};pv.Color.Rgb.prototype.blue=function(a){return pv.rgb(this.r,this.g,a,this.a)};pv.Color.Rgb.prototype.alpha=function(b){return pv.rgb(this.r,this.g,this.b,b)};pv.Color.Rgb.prototype.rgb=function(){return this};pv.Color.Rgb.prototype.brighter=function(c){c=Math.pow(0.7,arguments.length?c:1);var j=this.r,h=this.g,a=this.b,f=30;if(!j&&!h&&!a){return pv.rgb(f,f,f,this.a)}if(j&&(j<f)){j=f}if(h&&(h<f)){h=f}if(a&&(a<f)){a=f}return pv.rgb(Math.min(255,Math.floor(j/c)),Math.min(255,Math.floor(h/c)),Math.min(255,Math.floor(a/c)),this.a)};pv.Color.Rgb.prototype.darker=function(a){a=Math.pow(0.7,arguments.length?a:1);return pv.rgb(Math.max(0,Math.floor(a*this.r)),Math.max(0,Math.floor(a*this.g)),Math.max(0,Math.floor(a*this.b)),this.a)};pv.hsl=function(g,f,c,b){return new pv.Color.Hsl(g,f,c,(arguments.length==4)?b:1)};pv.Color.Hsl=function(g,f,c,b){pv.Color.call(this,"hsl("+g+","+(f*100)+"%,"+(c*100)+"%)",b);this.h=g;this.s=f;this.l=c;this.a=b};pv.Color.Hsl.prototype=pv.extend(pv.Color);pv.Color.Hsl.prototype.hue=function(a){return pv.hsl(a,this.s,this.l,this.a)};pv.Color.Hsl.prototype.saturation=function(a){return pv.hsl(this.h,a,this.l,this.a)};pv.Color.Hsl.prototype.lightness=function(a){return pv.hsl(this.h,this.s,a,this.a)};pv.Color.Hsl.prototype.alpha=function(b){return pv.hsl(this.h,this.s,this.l,b)};pv.Color.Hsl.prototype.rgb=function(){var i=this.h,g=this.s,a=this.l;i=i%360;if(i<0){i+=360}g=Math.max(0,Math.min(g,1));a=Math.max(0,Math.min(a,1));var c=(a<=0.5)?(a*(1+g)):(a+g-a*g);var f=2*a-c;function b(k){if(k>360){k-=360}else{if(k<0){k+=360}}if(k<60){return f+(c-f)*k/60}if(k<180){return c}if(k<240){return f+(c-f)*(240-k)/60}return f}function j(k){return Math.round(b(k)*255)}return pv.rgb(j(i+120),j(i),j(i-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"};pv.colors=function(){var a=pv.Scale.ordinal();a.range.apply(a,arguments);return a};pv.Colors={};pv.Colors.category10=function(){var a=pv.colors("#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf");a.domain.apply(a,arguments);return a};pv.Colors.category20=function(){var a=pv.colors("#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5");a.domain.apply(a,arguments);return a};pv.Colors.category19=function(){var a=pv.colors("#9c9ede","#7375b5","#4a5584","#cedb9c","#b5cf6b","#8ca252","#637939","#e7cb94","#e7ba52","#bd9e39","#8c6d31","#e7969c","#d6616b","#ad494a","#843c39","#de9ed6","#ce6dbd","#a55194","#7b4173");a.domain.apply(a,arguments);return a};pv.ramp=function(c,a){var b=pv.Scale.linear();b.range.apply(b,arguments);return b};pv.Scene=pv.SvgScene={};pv.SvgScene.updateAll=function(a){if(!a.length){return}if((a[0].reverse)&&(a.type!="line")&&(a.type!="area")){var f=pv.extend(a);for(var c=0,b=a.length-1;b>=0;c++,b--){f[c]=a[b]}a=f}this[a.type](a)};pv.SvgScene.create=function(a){return document.createElementNS(pv.ns.svg,a)};pv.SvgScene.title=function(g,f){var b=g.parentNode,c=String(f.title);if(b&&(b.tagName!="a")){b=null}if(c){if(!b){b=this.create("a");if(g.parentNode){g.parentNode.replaceChild(b,g)}b.appendChild(g)}b.setAttributeNS(pv.ns.xlink,"title",c)}else{if(b){b.removeAttributeNS(pv.ns.xlink,"title")}else{b=g}}return b};pv.SvgScene.parentNode=function(a){return a.parent[a.parentIndex].scene.g};pv.SvgScene.cache=function(c,b,a){if(!c.scene){return(c.scene={})[a]=this.create(b)}var f=c.scene[a];if(f){while(f.lastChild){f.removeChild(f.lastChild)}return f}return c.scene[a]=this.create(b)};pv.SvgScene.group=function(a){var b=this.cache(a,"g","g");if(!b.parentNode){this.parentNode(a).appendChild(b)}return b};pv.SvgScene.listen=function(c,a,b){c.$scene={scenes:a,index:b}};var pv_SvgScene_mouseover;pv.SvgScene.dispatch=function(b){var a;if(pv_SvgScene_mouseover){a=pv_SvgScene_mouseover;if(b.type=="mouseover"){a.scenes.mark.dispatch("mouseout",a.scenes,a.index);a=b.target.$scene}else{if(b.type=="mouseout"){pv_SvgScene_mouseover=null}}}else{a=b.target.$scene}if(a){if(b.type=="mouseover"){pv_SvgScene_mouseover=a}a.scenes.mark.dispatch(b.type,a.scenes,a.index);b.preventDefault()}};pv.SvgScene.area=function(a){var b=this.cache(a,"polygon","area"),n=a.scene.g;b.setAttribute("display","none");if(n){n.setAttribute("display","none")}if(!a.length){return}var u=a[0];if(u.segmented){this.areaSegment(a);return}if(!u.visible){return}var r=pv.color(u.fillStyle),t=pv.color(u.strokeStyle);if(!r.opacity&&!t.opacity){return}var q="",p="";for(var m=0,k=a.length-1;k>=0;m++,k--){var l=a[m],h=a[k];q+=l.left+","+l.top+" ";p+=(h.left+h.width)+","+(h.top+h.height)+" ";if(m<a.length-1){var f=a[m+1],c=a[k-1];switch(u.interpolate){case"step-before":q+=l.left+","+f.top+" ";p+=(c.left+c.width)+","+(h.top+h.height)+" ";break;case"step-after":q+=f.left+","+l.top+" ";p+=(h.left+h.width)+","+(c.top+c.height)+" ";break}}}b.removeAttribute("display");b.setAttribute("cursor",u.cursor);b.setAttribute("points",q+p);b.setAttribute("fill",r.color);b.setAttribute("fill-opacity",r.opacity);b.setAttribute("stroke",t.color);b.setAttribute("stroke-opacity",t.opacity);b.setAttribute("stroke-width",u.lineWidth);var o=this.title(b,u);if(!o.parentNode){this.listen(b,a,0);this.parentNode(a).appendChild(o)}};pv.SvgScene.areaSegment=function(a){var j=this.group(a),q=a[0];for(var f=0,c=a.length-1;f<c;f++){var l=a[f],k=a[f+1];if(!l.visible||!k.visible){continue}var o=pv.color(l.fillStyle),m=pv.color(l.strokeStyle);if(!o.opacity&&!m.opacity){continue}var b=l.left+","+l.top+" "+k.left+","+k.top+" "+(k.left+k.width)+","+(k.top+k.height)+" "+(l.left+l.width)+","+(l.top+l.height);var h=this.cache(l,"polygon","segment");h.setAttribute("cursor",l.cursor);h.setAttribute("points",b);h.setAttribute("fill",o.color);h.setAttribute("fill-opacity",o.opacity);h.setAttribute("stroke",m.color);h.setAttribute("stroke-opacity",m.opacity);h.setAttribute("stroke-width",l.lineWidth);this.listen(h,a,f);j.appendChild(this.title(h,l))}j.removeAttribute("display")};pv.SvgScene.bar=function(a){var h=this.group(a);for(var b=0;b<a.length;b++){var c=a[b];if(!c.visible){continue}var k=pv.color(c.fillStyle),j=pv.color(c.strokeStyle);if(!k.opacity&&!j.opacity){continue}var f=this.cache(c,"rect","bar");f.setAttribute("cursor",c.cursor);f.setAttribute("x",c.left);f.setAttribute("y",c.top);f.setAttribute("width",Math.max(1e-10,c.width));f.setAttribute("height",Math.max(1e-10,c.height));f.setAttribute("fill",k.color);f.setAttribute("fill-opacity",k.opacity);f.setAttribute("stroke",j.color);f.setAttribute("stroke-opacity",j.opacity);f.setAttribute("stroke-width",c.lineWidth);this.listen(f,a,b);h.appendChild(this.title(f,c))}};pv.SvgScene.dot=function(b){var l=this.group(b);for(var f=0;f<b.length;f++){var t=b[f];if(!t.visible){continue}var p=pv.color(t.fillStyle),q=pv.color(t.strokeStyle);if(!p.opacity&&!q.opacity){continue}var m=Math.sqrt(t.size),n="",k="";switch(t.shape){case"cross":n="M"+-m+","+-m+"L"+m+","+m+"M"+m+","+-m+"L"+-m+","+m;break;case"triangle":var j=m,o=m*2/Math.sqrt(3);n="M0,"+j+"L"+o+","+-j+" "+-o+","+-j+"Z";break;case"diamond":m*=Math.sqrt(2);n="M0,"+-m+"L"+m+",0 0,"+m+" "+-m+",0Z";break;case"square":n="M"+-m+","+-m+"L"+m+","+-m+" "+m+","+m+" "+-m+","+m+"Z";break;case"tick":n="M0,0L0,"+-t.size;break;default:function a(g){return"M0,"+g+"A"+g+","+g+" 0 1,1 0,"+(-g)+"A"+g+","+g+" 0 1,1 0,"+g+"Z"}if(t.lineWidth/2>m){k=a(t.lineWidth)}n=a(m);break}var c="translate("+t.left+","+t.top+")"+(t.angle?" rotate("+180*t.angle/Math.PI+")":"");var r=this.cache(t,"path","fill");r.setAttribute("d",n);r.setAttribute("transform",c);r.setAttribute("fill",p.color);r.setAttribute("fill-opacity",p.opacity);r.setAttribute("cursor",t.cursor);if(k){r.setAttribute("stroke","none")}else{r.setAttribute("stroke",q.color);r.setAttribute("stroke-opacity",q.opacity);r.setAttribute("stroke-width",t.lineWidth)}this.listen(r,b,f);l.appendChild(this.title(r,t));if(k){r=this.cache(t,"path","stroke");r.setAttribute("d",k);r.setAttribute("transform",c);r.setAttribute("fill",q.color);r.setAttribute("fill-opacity",q.opacity);r.setAttribute("cursor",t.cursor);this.listen(r,b,f);l.appendChild(this.title(r,t))}}};pv.SvgScene.image=function(a){var f=this.group(a);for(var c=0;c<a.length;c++){var m=a[c];if(!m.visible){continue}var h=f;if(m.left||m.top){h=this.cache(m,"g","g");h.setAttribute("transform","translate("+m.left+","+m.top+")");f.appendChild(h)}var l=pv.color(m.fillStyle);if(l.opacity){var j=this.cache(m,"rect","fill");j.setAttribute("width",m.width);j.setAttribute("height",m.height);j.setAttribute("fill",l.color);j.setAttribute("fill-opacity",l.opacity);h.appendChild(j)}var b=this.cache(m,"image","image");b.setAttribute("preserveAspectRatio","none");b.setAttribute("width",m.width);b.setAttribute("height",m.height);b.setAttributeNS(pv.ns.xlink,"href",m.url);this.listen(b,a,c);h.appendChild(b);var k=pv.color(m.strokeStyle);if(k.opacity||m.cursor||m.title){var j=this.cache(m,"rect","stroke");j.setAttribute("width",m.width);j.setAttribute("height",m.height);j.setAttribute("fill","none");j.setAttribute("pointer-events","all");j.setAttribute("stroke",k.color);j.setAttribute("stroke-opacity",k.opacity);j.setAttribute("stroke-width",m.lineWidth);j.setAttribute("cursor",m.cursor);this.listen(j,a,c);h.appendChild(this.title(j,m))}}};pv.SvgScene.label=function(a){var f=this.group(a);for(var c=0;c<a.length;c++){var n=a[c];if(!n.visible){continue}var l=pv.color(n.textStyle);if(!l.opacity){continue}var j=0,h=0,m=0,b="start";switch(n.textBaseline){case"middle":m=".35em";break;case"top":m=".71em";h=n.textMargin;break;case"bottom":h="-"+n.textMargin;break}switch(n.textAlign){case"right":b="end";j="-"+n.textMargin;break;case"center":b="middle";break;case"left":j=n.textMargin;break}var k=this.cache(n,"text","text");k.setAttribute("pointer-events","none");k.setAttribute("x",j);k.setAttribute("y",h);k.setAttribute("dy",m);k.setAttribute("text-anchor",b);k.setAttribute("transform","translate("+n.left+","+n.top+")"+(n.textAngle?" rotate("+180*n.textAngle/Math.PI+")":""));k.setAttribute("fill",l.color);k.setAttribute("fill-opacity",l.opacity);k.style.font=n.font;k.style.textShadow=n.textShadow;k.appendChild(document.createTextNode(n.text));f.appendChild(k)}};pv.SvgScene.line=function(a){var o=this.cache(a,"polyline","line"),j=a.scene.g;o.setAttribute("display","none");if(j){j.setAttribute("display","none")}if(a.length<2){return}var n=a[0];if(n.segmented){this.lineSegment(a);return}if(!n.visible){return}var l=pv.color(n.fillStyle),m=pv.color(n.strokeStyle);if(!l.opacity&&!m.opacity){return}var b="";for(var h=0;h<a.length;h++){var f=a[h];b+=f.left+","+f.top+" ";if(h<a.length-1){var c=a[h+1];switch(n.interpolate){case"step-before":b+=f.left+","+c.top+" ";break;case"step-after":b+=c.left+","+f.top+" ";break}}}o.removeAttribute("display");o.setAttribute("cursor",n.cursor);o.setAttribute("points",b);o.setAttribute("fill",l.color);o.setAttribute("fill-opacity",l.opacity);o.setAttribute("stroke",m.color);o.setAttribute("stroke-opacity",m.opacity);o.setAttribute("stroke-width",n.lineWidth);var k=this.title(o,n);if(!k.parentNode){this.listen(o,a,0);this.parentNode(a).appendChild(k)}};pv.SvgScene.lineSegment=function(f){var B=this.group(f);for(var A=0,z=f.length-1;A<z;A++){var q=f[A],m=f[A+1];if(!q.visible||!m.visible){continue}var t=pv.color(q.strokeStyle);if(!t.opacity){continue}function C(g,c,b,a){return g.plus(c.times(b.minus(g).dot(a.perp())/c.dot(a.perp())))}var l=pv.vector(q.left,q.top),j=pv.vector(m.left,m.top),y=j.minus(l),x=y.perp().norm(),u=x.times(q.lineWidth/2),G=l.plus(u),F=j.plus(u),E=j.minus(u),D=l.minus(u);if(A>0){var s=f[A-1];if(s.visible){var r=l.minus(s.left,s.top).perp().norm().plus(x);D=C(l,r,D,y);G=C(l,r,G,y)}}if(A<(z-1)){var h=f[A+2];if(h.visible){var o=pv.vector(h.left,h.top).minus(j).perp().norm().plus(x);E=C(j,o,E,y);F=C(j,o,F,y)}}var y=G.x+","+G.y+" "+F.x+","+F.y+" "+E.x+","+E.y+" "+D.x+","+D.y;var k=this.cache(q,"polygon","segment");k.setAttribute("cursor",q.cursor);k.setAttribute("points",y);k.setAttribute("fill",t.color);k.setAttribute("fill-opacity",t.opacity);this.listen(k,f,A);B.appendChild(this.title(k,q))}B.removeAttribute("display")};pv.SvgScene.panel=function(a){var n=a.parent&&this.group(a),f={};var k;for(var c=0;c<a.length;c++){var q=a[c];if(!q.visible){continue}if(!a.parent){q.canvas.style.display="inline-block";if(q.canvas.firstChild){var h=q.canvas.firstChild;if(h.marker!=f){while(h.lastChild){h.removeChild(h.lastChild)}k=null}}else{var h=q.canvas.appendChild(this.cache(q,"svg","svg"));h.setAttribute("width",q.width+q.left+q.right);h.setAttribute("height",q.height+q.top+q.bottom);h.onclick=h.onmousedown=h.onmouseup=h.onmousemove=h.onmouseout=h.onmouseover=pv.SvgScene.dispatch;k=null}h.marker=f;n=h}var l=n;if(q.left||q.top){if(k&&(k.left==q.left)&&(k.top==q.top)){l=k.scene.g}else{l=this.cache(q,"g","panel");l.setAttribute("transform","translate("+q.left+","+q.top+")");k=q}}(q.scene||(q.scene={})).g=l;var p=pv.color(q.fillStyle);if(p.opacity||q.cursor||q.title){var m=this.cache(q,"rect","fill");m.setAttribute("width",q.width);m.setAttribute("height",q.height);m.setAttribute("cursor",q.cursor);m.setAttribute("pointer-events","all");m.setAttribute("fill",p.color);m.setAttribute("fill-opacity",p.opacity);this.listen(m,a,c);l.appendChild(this.title(m,q))}for(var b=0;b<q.children.length;b++){this.updateAll(q.children[b])}var o=pv.color(q.strokeStyle);if(o.opacity){var m=this.cache(q,"rect","stroke");m.setAttribute("width",Math.max(1e-10,q.width));m.setAttribute("height",Math.max(1e-10,q.height));m.setAttribute("cursor",q.cursor);m.setAttribute("fill","none");m.setAttribute("stroke",o.color);m.setAttribute("stroke-opacity",o.opacity);m.setAttribute("stroke-width",q.lineWidth);this.listen(m,a,c);l.appendChild(this.title(m,q))}if(q.scene.panel){n.appendChild(l)}}};pv.SvgScene.rule=function(a){var h=this.group(a);for(var c=0;c<a.length;c++){var f=a[c];if(!f.visible){continue}var j=pv.color(f.strokeStyle);if(!j.opacity){continue}var b=this.cache(f,"line","rule");b.setAttribute("cursor",f.cursor);b.setAttribute("x1",f.left);b.setAttribute("y1",f.top);b.setAttribute("x2",f.left+f.width);b.setAttribute("y2",f.top+f.height);b.setAttribute("stroke",j.color);b.setAttribute("stroke-opacity",j.opacity);b.setAttribute("stroke-width",f.lineWidth);this.listen(b,a,c);h.appendChild(this.title(b,f))}};pv.SvgScene.wedge=function(b){var m=this.group(b);for(var l=0;l<b.length;l++){var x=b[l];if(!x.visible){continue}var u=pv.color(x.fillStyle),v=pv.color(x.strokeStyle);if(!u.opacity&&!v.opacity){continue}var h=x.innerRadius,f=x.outerRadius,q=Math.abs(x.angle),c;if(q>=2*Math.PI){if(h){c="M0,"+f+"A"+f+","+f+" 0 1,1 0,"+(-f)+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+h+"A"+h+","+h+" 0 1,1 0,"+(-h)+"A"+h+","+h+" 0 1,1 0,"+h+"Z"}else{c="M0,"+f+"A"+f+","+f+" 0 1,1 0,"+(-f)+"A"+f+","+f+" 0 1,1 0,"+f+"Z"}}else{var o=Math.min(x.startAngle,x.endAngle),n=Math.max(x.startAngle,x.endAngle),k=Math.cos(o),j=Math.cos(n),t=Math.sin(o),r=Math.sin(n);if(h){c="M"+f*k+","+f*t+"A"+f+","+f+" 0 "+((q<Math.PI)?"0":"1")+",1 "+f*j+","+f*r+"L"+h*j+","+h*r+"A"+h+","+h+" 0 "+((q<Math.PI)?"0":"1")+",0 "+h*k+","+h*t+"Z"}else{c="M"+f*k+","+f*t+"A"+f+","+f+" 0 "+((q<Math.PI)?"0":"1")+",1 "+f*j+","+f*r+"L0,0Z"}}var w=this.cache(x,"path","wedge");w.setAttribute("fill-rule","evenodd");w.setAttribute("cursor",x.cursor);w.setAttribute("transform","translate("+x.left+","+x.top+")");w.setAttribute("d",c);w.setAttribute("fill",u.color);w.setAttribute("fill-opacity",u.opacity);w.setAttribute("stroke",v.color);w.setAttribute("stroke-opacity",v.opacity);w.setAttribute("stroke-width",x.lineWidth);m.appendChild(this.title(w,x));this.listen(w,b,l)}};pv.Mark=function(){this.$properties=[]};pv.Mark.prototype.properties={};pv.Mark.prototype.property=function(a){if(!this.hasOwnProperty("properties")){this.properties=pv.extend(this.properties)}this.properties[a]=true;pv.Mark.prototype[a]=function(b){if(arguments.length){this.$properties.push({name:a,type:(typeof b=="function")?3:2,value:b});return this}return this.scene[this.index][a]};return this};pv.Mark.prototype.property("data").property("visible").property("left").property("right").property("top").property("bottom").property("cursor").property("title").property("reverse");pv.Mark.prototype.childIndex=-1;pv.Mark.prototype.index=-1;pv.Mark.prototype.defaults=new pv.Mark().data(function(a){return[a]}).visible(true).reverse(false).cursor("").title("");var defaultFillStyle=pv.Colors.category20().by(pv.parent),defaultStrokeStyle=pv.Colors.category10().by(pv.parent);pv.Mark.prototype.extend=function(a){this.proto=a;return this};pv.Mark.prototype.add=function(a){return this.parent.add(a).extend(this)};pv.Mark.prototype.def=function(a,b){this.$properties.push({name:a,type:(typeof b=="function")?1:0,value:b});return this};pv.Mark.prototype.anchor=function(b){var a=new pv.Anchor().extend(this).name(b);a.parent=this.parent;return a};pv.Mark.prototype.anchorTarget=function(){var a=this;while(!(a instanceof pv.Anchor)){a=a.proto;if(!a){return null}}return a.proto};pv.Mark.prototype.first=function(){return this.scene[0]};pv.Mark.prototype.last=function(){return this.scene[this.scene.length-1]};pv.Mark.prototype.sibling=function(){return(this.index==0)?null:this.scene[this.index-1]};pv.Mark.prototype.cousin=function(){var b=this.parent,a=b&&b.sibling();return(a&&a.children)?a.children[this.childIndex][this.index]:null};pv.Mark.prototype.render=function(){this.bind();this.build();pv.Scene.updateAll(this.scene)};function argv(b){var a=[];while(b){a.push(b.scene[b.index].data);b=b.parent}return a}pv.Mark.prototype.bind=function(){var a={},l=[[],[],[],[]],k,f;function n(s){do{var q=s.$properties;for(var o=q.length-1;o>=0;o--){var r=q[o];if(!(r.name in a)){a[r.name]=1;switch(r.name){case"data":k=r;break;case"visible":f=r;break;default:l[r.type].push(r);break}}}}while(s=s.proto)}function c(i){return function(p){var o=this.scene.defs;if(arguments.length){if(p==undefined){delete o.locked[i]}else{o.locked[i]=true}o.values[i]=p;return this}else{return o.values[i]}}}n(this);n(this.defaults);l[1].reverse();l[3].reverse();var g=this;do{for(var b in g.properties){if(!(b in a)){a[b]=1;l[2].push({name:b,type:2,value:null})}}}while(g=g.proto);var h=l[0].concat(l[1]);for(var j=0;j<h.length;j++){var m=h[j];this[m.name]=c(m.name)}this.binds={data:k,visible:f,defs:h,properties:pv.blend(l)}};pv.Mark.prototype.build=function(){var g=this.scene;if(!g){g=this.scene=[];g.mark=this;g.type=this.type;g.childIndex=this.childIndex;if(this.parent){g.parent=this.parent.scene;g.parentIndex=this.parent.index}}var j=this.root.scene.data;if(!j){this.root.scene.data=j=argv(this.parent)}if(this.binds.defs.length){var b=g.defs;if(!b){g.defs=b={values:{},locked:{}}}for(var f=0;f<this.binds.defs.length;f++){var h=this.binds.defs[f];if(!(h.name in b.locked)){var k=h.value;if(h.type==1){property=h.name;k=k.apply(this,j)}b.values[h.name]=k}}}var c=this.binds.data;switch(c.type){case 0:case 1:c=b.values.data;break;case 2:c=c.value;break;case 3:property="data";c=c.value.apply(this,j);break}j.unshift(null);g.length=c.length;for(var f=0;f<c.length;f++){pv.Mark.prototype.index=this.index=f;var l=g[f];if(!l){g[f]=l={}}l.data=j[0]=c[f];var a=this.binds.visible;switch(a.type){case 0:case 1:a=b.values.visible;break;case 2:a=a.value;break;case 3:property="visible";a=a.value.apply(this,j);break}if(l.visible=a){this.buildInstance(l)}}j.shift();delete this.index;pv.Mark.prototype.index=-1;if(!this.parent){g.data=null}return this};pv.Mark.prototype.buildProperties=function(f,c){for(var b=0,h=c.length;b<h;b++){var g=c[b],a=g.value;switch(g.type){case 0:case 1:a=this.scene.defs.values[g.name];break;case 3:property=g.name;a=a.apply(this,this.root.scene.data);break}f[g.name]=a}};pv.Mark.prototype.buildInstance=function(a){this.buildProperties(a,this.binds.properties);this.buildImplied(a)};pv.Mark.prototype.buildImplied=function(o){var g=o.left;var a=o.right;var n=o.top;var j=o.bottom;var f=this.properties;var k=f.width?o.width:0;var i=f.height?o.height:0;var c=this.parent?this.parent.width():(k+g+a);if(k==null){k=c-(a=a||0)-(g=g||0)}else{if(a==null){a=c-k-(g=g||0)}else{if(g==null){g=c-k-(a=a||0)}}}var m=this.parent?this.parent.height():(i+n+j);if(i==null){i=m-(n=n||0)-(j=j||0)}else{if(j==null){j=m-i-(n=n||0)}else{if(n==null){n=m-i-(j=j||0)}}}o.left=g;o.right=a;o.top=n;o.bottom=j;if(f.width){o.width=k}if(f.height){o.height=i}};var property;var pageX=0,pageY=0;pv.listen(window,"mousemove",function(a){pageX=a.pageX;pageY=a.pageY});pv.Mark.prototype.mouse=function(){var a=0,f=0,c=(this instanceof pv.Panel)?this:this.parent;do{a+=c.left();f+=c.top()}while(c=c.parent);var b=this.root.canvas();do{a+=b.offsetLeft;f+=b.offsetTop}while(b=b.offsetParent);return pv.vector(pageX-a,pageY-f)};pv.Mark.prototype.event=function(b,a){if(!this.$handlers){this.$handlers={}}this.$handlers[b]=a;return this};pv.Mark.prototype.dispatch=function(f,a,c){var b=this.$handlers&&this.$handlers[f];if(!b){if(this.parent){this.parent.dispatch(f,a.parent,a.parentIndex)}return}try{var g=this;do{g.index=c;g.scene=a;c=a.parentIndex;a=a.parent}while(g=g.parent);try{g=b.apply(this,this.root.scene.data=argv(this))}finally{this.root.scene.data=null}if(g instanceof pv.Mark){g.render()}}finally{var g=this;do{if(g.parent){delete g.scene}delete g.index}while(g=g.parent)}};pv.Anchor=function(){pv.Mark.call(this)};pv.Anchor.prototype=pv.extend(pv.Mark).property("name");pv.Area=function(){pv.Mark.call(this)};pv.Area.prototype=pv.extend(pv.Mark).property("width").property("height").property("lineWidth").property("strokeStyle").property("fillStyle").property("segmented").property("interpolate");pv.Area.prototype.type="area";pv.Area.prototype.defaults=new pv.Area().extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(defaultFillStyle).interpolate("linear");pv.Area.prototype.anchor=function(a){var b=this;return pv.Mark.prototype.anchor.call(this,a).left(function(){switch(this.name()){case"bottom":case"top":case"center":return b.left()+b.width()/2;case"right":return b.left()+b.width()}return null}).right(function(){switch(this.name()){case"bottom":case"top":case"center":return b.right()+b.width()/2;case"left":return b.right()+b.width()}return null}).top(function(){switch(this.name()){case"left":case"right":case"center":return b.top()+b.height()/2;case"bottom":return b.top()+b.height()}return null}).bottom(function(){switch(this.name()){case"left":case"right":case"center":return b.bottom()+b.height()/2;case"top":return b.bottom()+b.height()}return 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"})};pv.Area.prototype.buildImplied=function(a){if(a.height==null){a.height=0}if(a.width==null){a.width=0}pv.Mark.prototype.buildImplied.call(this,a)};var pv_Area_specials={left:1,top:1,right:1,bottom:1,width:1,height:1,name:1};pv.Area.prototype.bind=function(){pv.Mark.prototype.bind.call(this);var f=this.binds,c=f.properties,a=f.specials=[];for(var b=0,h=c.length;b<h;b++){var g=c[b];if(g.name in pv_Area_specials){a.push(g)}}};pv.Area.prototype.buildInstance=function(a){if(this.index&&!this.scene[0].segmented){this.buildProperties(a,this.binds.specials);this.buildImplied(a)}else{pv.Mark.prototype.buildInstance.call(this,a)}};pv.Bar=function(){pv.Mark.call(this)};pv.Bar.prototype=pv.extend(pv.Mark).property("width").property("height").property("lineWidth").property("strokeStyle").property("fillStyle");pv.Bar.prototype.type="bar";pv.Bar.prototype.defaults=new pv.Bar().extend(pv.Mark.prototype.defaults).lineWidth(1.5).fillStyle(defaultFillStyle);pv.Bar.prototype.anchor=function(a){var b=this;return pv.Mark.prototype.anchor.call(this,a).left(function(){switch(this.name()){case"bottom":case"top":case"center":return b.left()+(this.properties.width?0:(b.width()/2));case"right":return b.left()+b.width()}return null}).right(function(){switch(this.name()){case"bottom":case"top":case"center":return b.right()+(this.properties.width?0:(b.width()/2));case"left":return b.right()+b.width()}return null}).top(function(){switch(this.name()){case"left":case"right":case"center":return b.top()+(this.properties.height?0:(b.height()/2));case"bottom":return b.top()+b.height()}return null}).bottom(function(){switch(this.name()){case"left":case"right":case"center":return b.bottom()+(this.properties.height?0:(b.height()/2));case"top":return b.bottom()+b.height()}return 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"})};pv.Dot=function(){pv.Mark.call(this)};pv.Dot.prototype=pv.extend(pv.Mark).property("size").property("shape").property("angle").property("lineWidth").property("strokeStyle").property("fillStyle");pv.Dot.prototype.type="dot";pv.Dot.prototype.defaults=new pv.Dot().extend(pv.Mark.prototype.defaults).size(20).shape("circle").lineWidth(1.5).strokeStyle(defaultStrokeStyle);pv.Dot.prototype.anchor=function(b){var a=this;return pv.Mark.prototype.anchor.call(this,b).left(function(c){switch(this.name()){case"bottom":case"top":case"center":return a.left();case"right":return a.left()+a.radius()}return null}).right(function(c){switch(this.name()){case"bottom":case"top":case"center":return a.right();case"left":return a.right()+a.radius()}return null}).top(function(c){switch(this.name()){case"left":case"right":case"center":return a.top();case"bottom":return a.top()+a.radius()}return null}).bottom(function(c){switch(this.name()){case"left":case"right":case"center":return a.bottom();case"top":return a.bottom()+a.radius()}return null}).textAlign(function(c){switch(this.name()){case"left":return"right";case"bottom":case"top":case"center":return"center"}return"left"}).textBaseline(function(c){switch(this.name()){case"right":case"left":case"center":return"middle";case"bottom":return"top"}return"bottom"})};pv.Dot.prototype.radius=function(){return Math.sqrt(this.size())};pv.Label=function(){pv.Mark.call(this)};pv.Label.prototype=pv.extend(pv.Mark).property("text").property("font").property("textAngle").property("textStyle").property("textAlign").property("textBaseline").property("textMargin").property("textShadow");pv.Label.prototype.type="label";pv.Label.prototype.defaults=new pv.Label().extend(pv.Mark.prototype.defaults).text(pv.identity).font("10px sans-serif").textAngle(0).textStyle("black").textAlign("left").textBaseline("bottom").textMargin(3);pv.Line=function(){pv.Mark.call(this)};pv.Line.prototype=pv.extend(pv.Mark).property("lineWidth").property("strokeStyle").property("fillStyle").property("segmented").property("interpolate");pv.Line.prototype.type="line";pv.Line.prototype.defaults=new pv.Line().extend(pv.Mark.prototype.defaults).lineWidth(1.5).strokeStyle(defaultStrokeStyle).interpolate("linear");var pv_Line_specials={left:1,top:1,right:1,bottom:1,name:1};pv.Line.prototype.bind=function(){pv.Mark.prototype.bind.call(this);var f=this.binds,c=f.properties,a=f.specials=[];for(var b=0,h=c.length;b<h;b++){var g=c[b];if(g.name in pv_Line_specials){a.push(g)}}};pv.Line.prototype.buildInstance=function(a){if(this.index&&!this.scene[0].segmented){this.buildProperties(a,this.binds.specials);this.buildImplied(a)}else{pv.Mark.prototype.buildInstance.call(this,a)}};pv.Rule=function(){pv.Mark.call(this)};pv.Rule.prototype=pv.extend(pv.Mark).property("width").property("height").property("lineWidth").property("strokeStyle");pv.Rule.prototype.type="rule";pv.Rule.prototype.defaults=new pv.Rule().extend(pv.Mark.prototype.defaults).lineWidth(1).strokeStyle("black");pv.Rule.prototype.anchor=function(a){return pv.Bar.prototype.anchor.call(this,a).textAlign(function(b){switch(this.name()){case"left":return"right";case"bottom":case"top":case"center":return"center";case"right":return"left"}}).textBaseline(function(b){switch(this.name()){case"right":case"left":case"center":return"middle";case"top":return"bottom";case"bottom":return"top"}})};pv.Rule.prototype.buildImplied=function(g){var c=g.left,h=g.right,f=g.top,a=g.bottom;if((g.width!=null)||((c==null)&&(h==null))||((h!=null)&&(c!=null))){g.height=0}else{g.width=0}pv.Mark.prototype.buildImplied.call(this,g)};pv.Panel=function(){pv.Bar.call(this);this.children=[];this.root=this;this.$dom=pv.Panel.$dom};pv.Panel.prototype=pv.extend(pv.Bar).property("canvas");pv.Panel.prototype.type="panel";pv.Panel.prototype.defaults=new pv.Panel().extend(pv.Bar.prototype.defaults).fillStyle(null);pv.Panel.prototype.anchor=function(b){function c(){return 0}c.prototype=this;c.prototype.left=c.prototype.right=c.prototype.top=c.prototype.bottom=c;var a=pv.Bar.prototype.anchor.call(new c(),b).data(function(f){return[f]});a.parent=this;return a};pv.Panel.prototype.add=function(a){var b=new a();b.parent=this;b.root=this.root;b.childIndex=this.children.length;this.children.push(b);return b};pv.Panel.prototype.bind=function(){pv.Mark.prototype.bind.call(this);for(var a=0;a<this.children.length;a++){this.children[a].bind()}};pv.Panel.prototype.buildInstance=function(b){pv.Bar.prototype.buildInstance.call(this,b);if(!b.children){b.children=[]}for(var a=0;a<this.children.length;a++){this.children[a].scene=b.children[a];this.children[a].build()}for(var a=0;a<this.children.length;a++){b.children[a]=this.children[a].scene;delete this.children[a].scene}b.children.length=this.children.length};pv.Panel.prototype.buildImplied=function(f){if(!this.parent){var i=f.canvas;if(i){if(typeof i=="string"){i=document.getElementById(i)}if(i.$panel!=this){i.$panel=this;i.innerHTML=""}var a,b;if(f.width==null){a=parseFloat(pv.css(i,"width"));f.width=a-f.left-f.right}if(f.height==null){b=parseFloat(pv.css(i,"height"));f.height=b-f.top-f.bottom}}else{if(f.$canvas){i=f.$canvas}else{function g(){var c=document.body;while(c.lastChild&&c.lastChild.tagName){c=c.lastChild}return(c==document.body)?c:c.parentNode}i=f.$canvas=document.createElement("span");this.$dom?this.$dom.pare…