From 7c2271fa05fe309263486ae6c9179dc237d2c13c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Aug 2015 15:29:27 -0400 Subject: [PATCH] update to include CI's --- app.css | 36 +- app.js | 6 +- app_ddi.js | 38 +- data/fearonLaitinNewPreprocess3.json | 2 +- images/Thumbs.db | Bin 0 -> 31232 bytes plots.js | 303 +- tworavens/LICENSE | 26 + tworavens/README.md | 17 + tworavens/app.css | 362 ++ tworavens/app.js | 837 +++ tworavens/app_ddi.js | 3062 +++++++++ tworavens/bar.js | 32 + tworavens/d3.v3.js | 8783 ++++++++++++++++++++++++++ tworavens/d3.v3.min.js | 5 + tworavens/gui.html | 347 + tworavens/install.pl | 267 + tworavens/plots.js | 1319 ++++ tworavens/tworavens-rapache.conf | 27 + 18 files changed, 15337 insertions(+), 132 deletions(-) create mode 100644 images/Thumbs.db create mode 100644 tworavens/LICENSE create mode 100644 tworavens/README.md create mode 100644 tworavens/app.css create mode 100644 tworavens/app.js create mode 100644 tworavens/app_ddi.js create mode 100644 tworavens/bar.js create mode 100644 tworavens/d3.v3.js create mode 100644 tworavens/d3.v3.min.js create mode 100644 tworavens/gui.html create mode 100644 tworavens/install.pl create mode 100644 tworavens/plots.js create mode 100644 tworavens/tworavens-rapache.conf diff --git a/app.css b/app.css index c2bc074..e489764 100644 --- a/app.css +++ b/app.css @@ -352,11 +352,39 @@ td { #carouselRight {position:absolute;top:50%;right:calc(16px + 20%);z-index:30;font-size:2em;} .lowerError { - fill: LightSteelBlue; - stroke-width: 0; + /*fill: #2d6ca2;*/ + fill: #4682b4; + + /*fill: darkgrey;*/ + /*stroke-width: 1; + stroke-color: black;*/ } .upperError { - fill: #2d5474; - stroke-width: 0; + /*fill: #2d5474;*/ + fill: silver; + /*fill: #ffbf87;*/ + + /*fill: grey;*/ + /*fill:#b2b2ff;*/ + fill-opacity: 0.65; + /*stroke-width: 1; + stroke-color: black;*/ +} + +.line { + /*fill: #80A0BB;*/ + /*fill: #7D9CB7;*/ + + /*fill: #2d6ca2;*/ + fill: #4682b4; + + /*fill: silver;*/ + /*fill: #2d6ca2;*/ + /*fill: grey;*/ + /*fill-opacity: 0.3;*/ } + +.nofill { + fill: none; +} \ No newline at end of file diff --git a/app.js b/app.js index 287fa83..d7e67da 100644 --- a/app.js +++ b/app.js @@ -515,10 +515,10 @@ function layout() { g.append('svg:circle') .attr('class', 'node') .attr('r', allR) - .style('fill', function(d) { + .style('fill', "yellow")// { // console.log(d); - var myIndex = findNodeIndex(d.name); - return (d === selected_node) ? d3.rgb(d.nodeCol).brighter().toString() : d.nodeCol; }) + //var myIndex = findNodeIndex(d.name); + //return (d === selected_node) ? d3.rgb(d.nodeCol).brighter().toString() : d.nodeCol; }) .style('opacity', "0.5") // .style( fill: url(#fade); ) .style('stroke', function(d) { diff --git a/app_ddi.js b/app_ddi.js index 78b46e5..c38ae0f 100644 --- a/app_ddi.js +++ b/app_ddi.js @@ -17,6 +17,7 @@ var production=false; +var private=true; if(production && fileid=="") { alert("Error: No fileid has been provided."); @@ -283,7 +284,7 @@ readPreprocess(url=pURL, p=preprocess, v=null, callback=function(){ allNodes.push(obj1); }; //, - + console.log("we are here"); console.log(allNodes); // Reading the zelig models and populating the model list in the right panel. d3.json("data/zelig5models.json", function(error, json) { @@ -798,7 +799,7 @@ function layout(v) { .attr("id", function(d){ return "timeArc".concat(d.id); }) - .style("fill", timeColor) + .style("fill", "yellow") .attr("fill-opacity", 0) .on('mouseover', function(d){ d3.select(this).transition() .attr("fill-opacity", .3) @@ -2170,11 +2171,17 @@ function varSummary(d) { var summarydata = [], tmpDataset = [], t1 = ["Mean:","Median:","Most Freq:","Occurrences:", "Median Freq:", "Occurrences:", "Least Freq:", "Occurrences:", "Stand.Dev:","Minimum:","Maximum:","Invalid:","Valid:","Uniques:","Herfindahl:"], - t2 = [(+d.mean).toPrecision(4).toString(),(+d.median).toPrecision(4).toString(),d.mode,rint(d.freqmode),d.mid, rint(d.freqmid), d.fewest, rint(d.freqfewest),(+d.sd).toPrecision(4).toString(),(+d.min).toPrecision(4).toString(),(+d.max).toPrecision(4).toString(),rint(d.invalid),rint(d.valid),rint(d.uniques),(+d.herfindahl).toPrecision(4).toString()], + t2 = [(+d.mean).toPrecision(4).toString() ,(+d.median).toPrecision(4).toString(),d.mode,rint(d.freqmode),d.mid, rint(d.freqmid), d.fewest, rint(d.freqfewest),(+d.sd).toPrecision(4).toString(),(+d.min).toPrecision(4).toString(),(+d.max).toPrecision(4).toString(),rint(d.invalid),rint(d.valid),rint(d.uniques),(+d.herfindahl).toPrecision(4).toString()], i, j; - + if (private) { + if (d.meanCI) { + t2 = [(+d.mean).toPrecision(4).toString() + " (" + (+d.meanCI.lowerBound).toPrecision(4).toString() + " - " + (+d.meanCI.upperBound).toPrecision(4).toString() + ")" ,(+d.median).toPrecision(4).toString(),d.mode,rint(d.freqmode),d.mid, rint(d.freqmid), d.fewest, rint(d.freqfewest),(+d.sd).toPrecision(4).toString(),(+d.min).toPrecision(4).toString(),(+d.max).toPrecision(4).toString(),rint(d.invalid),rint(d.valid),rint(d.uniques),(+d.herfindahl).toPrecision(4).toString()], + i, j; + } + } + for (i = 0; i < t1.length; i++) { - if(t2[i]=="NaN" | t2[i]=="NA" | t2[i]=="") continue; + if(t2[i].indexOf("NaN") > -1 | t2[i]=="NA" | t2[i]=="") continue; tmpDataset=[]; tmpDataset.push(t1[i]); tmpDataset.push(t2[i]); @@ -2182,7 +2189,7 @@ function varSummary(d) { }; // console.log(summarydata); - d3.select("#tab3") + d3.select("#tab3") //tab when you mouseover a pebble .select("p") .html("
" +d.name+ "
" +d.labl+ "
") .append("table") @@ -2204,10 +2211,10 @@ function varSummary(d) { .remove(); } else if (d.plottype === "continuous") { - density(d, div="varSummary"); + density(d, div="varSummary", private); } else if (d.plottype === "bar") { - bars(d, div="varSummary"); + bars(d, div="varSummary", private); } else { var plotsvg = d3.select("#tab3") // no graph to draw, but still need to remove previous graph @@ -2235,7 +2242,14 @@ function popoverContent(d) { if(d.labl != "") { outtext = outtext + "

" + d.labl + "

"; } - if (d.mean != "NA") { outtext = outtext + "

" + (+d.mean).toPrecision(4).toString() + "

"; + if (d.mean != "NA") { + outtext = outtext + "

" + (+d.mean).toPrecision(4).toString() + if (private) { + if (d.meanCI) { + outtext += " (" + (+d.meanCI.lowerBound).toPrecision(4).toString() + " - " + (+d.meanCI.upperBound).toPrecision(4).toString() + ")" + } + } + outtext += "

"; } if (d.median != "NA") { outtext = outtext + "

" + (+d.median).toPrecision(4).toString() + "

"; @@ -2336,13 +2350,13 @@ function panelPlots() { allNodes[idArray[i]].subsetplot=false; if (allNodes[idArray[i]].plottype === "continuous" & allNodes[idArray[i]].setxplot==false) { allNodes[idArray[i]].setxplot=true; - density(allNodes[idArray[i]], div="setx"); + density(allNodes[idArray[i]], div="setx", private); allNodes[idArray[i]].subsetplot=true; - density(allNodes[idArray[i]], div="subset"); + density(allNodes[idArray[i]], div="subset", private); } else if (allNodes[idArray[i]].plottype === "bar" & allNodes[idArray[i]].setxplot==false) { allNodes[idArray[i]].setxplot=true; - bars(allNodes[idArray[i]], div="setx"); + bars(allNodes[idArray[i]], div="setx", private); allNodes[idArray[i]].subsetplot=true; barsSubset(allNodes[idArray[i]]); } diff --git a/data/fearonLaitinNewPreprocess3.json b/data/fearonLaitinNewPreprocess3.json index fc2148e..3aeacbb 100644 --- a/data/fearonLaitinNewPreprocess3.json +++ b/data/fearonLaitinNewPreprocess3.json @@ -1 +1 @@ -{"ccode":{"plottype":"continuous","plotx":[-113.352184018798,-89.2969928343577,-65.2418016499169,-41.1866104654762,-17.1314192810354,6.92377190340532,30.9789630878461,55.0341542722868,79.0893454567276,103.144536641168,127.199727825609,151.25491901005,175.310110194491,199.365301378931,223.420492563372,247.475683747813,271.530874932254,295.586066116694,319.641257301135,343.696448485576,367.751639670017,391.806830854457,415.862022038898,439.917213223339,463.97240440778,488.02759559222,512.082786776661,536.137977961102,560.193169145543,584.248360329983,608.303551514424,632.358742698865,656.413933883306,680.469125067746,704.524316252187,728.579507436628,752.634698621069,776.689889805509,800.74508098995,824.800272174391,848.855463358832,872.910654543272,896.965845727713,921.021036912154,945.076228096595,969.131419281035,993.186610465476,1017.24180164992,1041.29699283436,1065.3521840188],"ploty":[1.28948763455544e-06,7.77346821359187e-06,3.36131633687972e-05,0.000106529424448849,0.0002554277889438,0.000481526131769224,0.000747949862147683,0.00100604227721003,0.00120376316558131,0.00128391859229442,0.00123500690724131,0.00111734285183577,0.0010150456932042,0.000960670328308937,0.000904629949134055,0.000817500670741316,0.000778234671998686,0.000876908136227006,0.00108869455161458,0.00128399336325335,0.00134909216770709,0.00131659244673784,0.00131202885481215,0.00136170234679394,0.00138022472097999,0.00132732066908842,0.00123836777253931,0.00114903330098791,0.00107690155257646,0.00105677319532716,0.00113082382043057,0.00127863595576224,0.00140743390776556,0.00143773383466028,0.00136053534439603,0.00122955928071625,0.00111869338642414,0.00105239852206042,0.000975891422838848,0.000823791970169336,0.000613773790886401,0.00043423005130618,0.000333155817938031,0.000269408806290706,0.000193552761148369,0.000110296640317649,4.78653484760454e-05,1.55029072201053e-05,3.66725820980367e-06,6.21798951614823e-07],"varnamesSumStat":"ccode","median":"451","mean":"450.62223903177","mode":"2","max":"950","min":"2","invalid":0,"valid":6610,"sd":"248.143183365732","uniques":161,"herfindahl":0.00716156925393835,"freqmode":55,"fewest":"316","mid":"600","freqfewest":"7","freqmid":"44","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"ccode","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"country":{"plottype":"bar","plotvalues":{"AFGHANISTAN":55,"ALBANIA":55,"ALGERIA":38,"ANGOLA":25,"ARGENTINA":55,"ARMENIA":9,"AUSTRALIA":55,"AUSTRIA":55,"AZERBAIJAN":9,"BAHRAIN":29,"BANGLADESH":28,"BELARUS":9,"BELGIUM":55,"BENIN":40,"BHUTAN":29,"BOLIVIA":55,"BOSNIA":8,"BOTSWANA":34,"BRAZIL":55,"BULGARIA":55,"BURKINA FASO":40,"BURMA":52,"BURUNDI":38,"CAMBODIA":47,"CAMEROON":40,"CANADA":55,"CENTRAL AFRICAN REP.":40,"CHAD":40,"CHILE":55,"CHINA":55,"COLOMBIA":55,"CONGO":40,"COSTARICA":55,"CROATIA":8,"CUBA":55,"CYPRUS":40,"CZECHOSLOVAKIA":48,"CZECHREP":7,"DEM. REP. CONGO":40,"DENMARK":55,"DJIBOUTI":23,"DOMINICAN REP.":55,"ECUADOR":55,"EGYPT":55,"EL SALVADOR":55,"ERITREA":7,"ESTONIA":9,"ETHIOPIA":55,"FIJI":30,"FINLAND":55,"FRANCE":55,"GABON":40,"GAMBIA":35,"GEORGIA":9,"GERMAN DEM. REP.":42,"GERMANYFED. REP.":55,"GHANA":43,"GREECE":55,"GUATEMALA":55,"GUINEA":42,"GUINEA BISSAU":26,"GUYANA":34,"HAITI":55,"HONDURAS":55,"HUNGARY":55,"INDIA":53,"INDONESIA":51,"IRAN":55,"IRAQ":55,"IRELAND":55,"ISRAEL":52,"ITALY":55,"IVORY COAST":40,"JAMAICA":38,"JAPAN":55,"JORDAN":54,"KAZAKHSTAN":9,"KENYA":37,"KOREA, S.":51,"KUWAIT":39,"KYRGYZSTAN":9,"LAOS":47,"LATVIA":9,"LEBANON":54,"LESOTHO":34,"LIBERIA":55,"LIBYA":49,"LITHUANIA":9,"MACEDONIA":7,"MADAGASCAR":40,"MALAWI":36,"MALAYSIA":43,"MALI":40,"MAURITANIA":40,"MAURITIUS":32,"MEXICO":55,"MOLDOVA":9,"MONGOLIA":55,"MOROCCO":44,"MOZAMBIQUE":25,"N. KOREA":52,"NAMIBIA":10,"NEPAL":55,"NETHERLANDS":55,"NEW ZEALAND":55,"NICARAGUA":55,"NIGER":40,"NIGERIA":40,"NORWAY":55,"OMAN":29,"PAKISTAN":53,"PANAMA":55,"PAPUA N.G.":25,"PARAGUAY":55,"PERU":55,"PHILIPPINES":54,"POLAND":55,"PORTUGAL":55,"ROMANIA":55,"RUSSIA":55,"RWANDA":38,"SAUDI ARABIA":55,"SENEGAL":40,"SIERRA LEONE":39,"SINGAPORE":35,"SLOVAKIA":7,"SLOVENIA":8,"SOMALIA":40,"SOUTH AFRICA":55,"SPAIN":55,"SRI LANKA":52,"SUDAN":44,"SWAZILAND":32,"SWEDEN":55,"SWITZERLAND":55,"SYRIA":54,"TAIWAN":51,"TAJIKISTAN":9,"TANZANIA":39,"THAILAND":55,"TOGO":40,"TRINIDAD & TOBAGO":38,"TUNISIA":44,"TURKEY":55,"TURKMENISTAN":9,"U. ARAB EMIRATES":29,"UGANDA":38,"UK":55,"UKRAINE":9,"URUGUAY":55,"USA":55,"UZBEKISTAN":9,"VENEZUELA":55,"VIETNAM":46,"VIETNAM, S.":22,"YEMEN":10,"YEMEN ARAB REP.":46,"YEMEN PEOP. REP.":24,"YUGOSLAVIA":55,"ZAMBIA":36,"ZIMBABWE":35},"varnamesSumStat":"country","median":"NA","mean":"NA","mode":"USA","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":161,"herfindahl":0.00716156925393835,"freqmode":55,"fewest":"CZECHREP","mid":"MOROCCO","freqfewest":"7","freqmid":"44","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"country","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"cname":{"plottype":"bar","plotvalues":{"AFGHANIS":55,"ALBANIA":55,"ALGERIA":38,"ANGOLA":25,"ARGENTIN":55,"ARMENIA":9,"AUSTRALI":55,"AUSTRIA":55,"AZERBAIJ":9,"BAHRAIN":29,"BANGLADE":28,"BELARUS":9,"BELGIUM":55,"BENIN":40,"BHUTAN":29,"BOLIVIA":55,"BOSNIA":8,"BOTSWANA":34,"BRAZIL":55,"BULGARIA":55,"BURKINA ":40,"BURMA":52,"BURUNDI":38,"CAMBODIA":47,"CAMEROON":40,"CANADA":55,"CENTRAL ":40,"CHAD":40,"CHILE":55,"CHINA":55,"COLOMBIA":55,"CONGO":40,"COSTARIC":55,"CROATIA":8,"CUBA":55,"CYPRUS":40,"CZECHOSL":48,"CZECHREP":7,"DEM. REP":40,"DENMARK":55,"DJIBOUTI":23,"DOMINICA":55,"ECUADOR":55,"EGYPT":55,"EL SALVA":55,"ERITREA":7,"ESTONIA":9,"ETHIOPIA":55,"FIJI":30,"FINLAND":55,"FRANCE":55,"GABON":40,"GAMBIA":35,"GEORGIA":9,"GERMAN D":42,"GERMANYF":55,"GHANA":43,"GREECE":55,"GUATEMAL":55,"GUINEA":42,"GUINEA B":26,"GUYANA":34,"HAITI":55,"HONDURAS":55,"HUNGARY":55,"INDIA":53,"INDONESI":51,"IRAN":55,"IRAQ":55,"IRELAND":55,"ISRAEL":52,"ITALY":55,"IVORY CO":40,"JAMAICA":38,"JAPAN":55,"JORDAN":54,"KAZAKHST":9,"KENYA":37,"KOREA, S":51,"KUWAIT":39,"KYRGYZST":9,"LAOS":47,"LATVIA":9,"LEBANON":54,"LESOTHO":34,"LIBERIA":55,"LIBYA":49,"LITHUANI":9,"MACEDONI":7,"MADAGASC":40,"MALAWI":36,"MALAYSIA":43,"MALI":40,"MAURITAN":40,"MAURITIU":32,"MEXICO":55,"MOLDOVA":9,"MONGOLIA":55,"MOROCCO":44,"MOZAMBIQ":25,"N. KOREA":52,"NAMIBIA":10,"NEPAL":55,"NETHERLA":55,"NEW ZEAL":55,"NICARAGU":55,"NIGER":40,"NIGERIA":40,"NORWAY":55,"OMAN":29,"PAKISTAN":53,"PANAMA":55,"PAPUA N.":25,"PARAGUAY":55,"PERU":55,"PHILIPPI":54,"POLAND":55,"PORTUGAL":55,"ROMANIA":55,"RUSSIA":55,"RWANDA":38,"SAUDI AR":55,"SENEGAL":40,"SIERRA L":39,"SINGAPOR":35,"SLOVAKIA":7,"SLOVENIA":8,"SOMALIA":40,"SOUTH AF":55,"SPAIN":55,"SRI LANK":52,"SUDAN":44,"SWAZILAN":32,"SWEDEN":55,"SWITZERL":55,"SYRIA":54,"TAIWAN":51,"TAJIKIST":9,"TANZANIA":39,"THAILAND":55,"TOGO":40,"TRINIDAD":38,"TUNISIA":44,"TURKEY":55,"TURKMENI":9,"U. ARAB ":29,"UGANDA":38,"UK":55,"UKRAINE":9,"URUGUAY":55,"USA":55,"UZBEKIST":9,"VENEZUEL":55,"VIETNAM":46,"VIETNAM,":22,"YEMEN":10,"YEMEN AR":46,"YEMEN PE":24,"YUGOSLAV":55,"ZAMBIA":36,"ZIMBABWE":35},"varnamesSumStat":"cname","median":"NA","mean":"NA","mode":"USA","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":161,"herfindahl":0.00716156925393835,"freqmode":55,"fewest":"CZECHREP","mid":"MOROCCO","freqfewest":"7","freqmid":"44","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"cname","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"cmark":{"plottype":"bar","plotvalues":{"0":6449,"1":161},"varnamesSumStat":"cmark","median":"0","mean":"0.024357034795764","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.154166680316136","uniques":2,"herfindahl":0.952472460696556,"freqmode":6449,"fewest":"1","mid":"NA","freqfewest":"161","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"cmark","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"year":{"plottype":"continuous","plotx":[1937.99231500584,1939.38038378111,1940.76845255638,1942.15652133166,1943.54459010693,1944.9326588822,1946.32072765747,1947.70879643274,1949.09686520801,1950.48493398329,1951.87300275856,1953.26107153383,1954.6491403091,1956.03720908437,1957.42527785965,1958.81334663492,1960.20141541019,1961.58948418546,1962.97755296073,1964.365621736,1965.75369051128,1967.14175928655,1968.52982806182,1969.91789683709,1971.30596561236,1972.69403438764,1974.08210316291,1975.47017193818,1976.85824071345,1978.24630948872,1979.634378264,1981.02244703927,1982.41051581454,1983.79858458981,1985.18665336508,1986.57472214035,1987.96279091563,1989.3508596909,1990.73892846617,1992.12699724144,1993.51506601671,1994.90313479199,1996.29120356726,1997.67927234253,1999.0673411178,2000.45540989307,2001.84347866834,2003.23154744362,2004.61961621889,2006.00768499416],"ploty":[2.4615494919606e-05,0.000134312419250629,0.000532160103209718,0.0015561495211806,0.00343564267787795,0.00591527966326217,0.0083012797227244,0.0100305654253793,0.0110401975404856,0.011583235906882,0.0119228401466712,0.0122198391554691,0.0125572713651366,0.0129989737154941,0.0136239016520534,0.0144814114923857,0.0155007352768974,0.0165007331486998,0.0173332801876797,0.0179757346415986,0.0184770130124159,0.018882871139569,0.0192279076640635,0.0195434282825182,0.0198420784926995,0.0201141667865439,0.0203450224392878,0.0205230192271391,0.0206409831332737,0.0207041721871288,0.0207303776864925,0.0207390854222137,0.0207434578085856,0.0207519813477241,0.020779586807111,0.0208677786779391,0.0210939754684569,0.0215250693196225,0.0221252773942338,0.0227265845000946,0.0230940701364217,0.0229100995944009,0.0216094123753058,0.0185002264930784,0.0135550973442489,0.00803969984552511,0.00369694355260443,0.00127792615498628,0.000325037488374505,5.99060394929591e-05],"varnamesSumStat":"year","median":"1977","mean":"1975.54780635401","mode":"1993","max":"1999","min":"1945","invalid":0,"valid":6610,"sd":"15.0747840386954","uniques":55,"herfindahl":0.0191868095147635,"freqmode":156,"fewest":"1945","mid":"1972","freqfewest":"63","freqmid":"133","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"year","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"wars":{"plottype":"bar","plotvalues":{"0":5692,"1":829,"2":72,"3":15,"4":2},"varnamesSumStat":"wars","median":"0","mean":"0.155219364599092","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.412533428847871","uniques":5,"herfindahl":0.757379892474841,"freqmode":5692,"fewest":"4","mid":"2","freqfewest":"2","freqmid":"72","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"wars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"war":{"plottype":"bar","plotvalues":{"0":5692,"1":918},"varnamesSumStat":"war","median":"0","mean":"0.138880484114977","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.345847929987619","uniques":2,"herfindahl":0.760814609506066,"freqmode":5692,"fewest":"1","mid":"NA","freqfewest":"918","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"war","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"warl":{"plottype":"bar","plotvalues":{"0":5720,"1":890},"varnamesSumStat":"warl","median":"0","mean":"0.13464447806354","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.341369261049802","uniques":2,"herfindahl":0.766969314818926,"freqmode":5720,"fewest":"1","mid":"NA","freqfewest":"890","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"warl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"onset":{"plottype":"bar","plotvalues":{"0":6499,"1":110,"4":1},"varnamesSumStat":"onset","median":"0","mean":"0.0172465960665658","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.136994238573717","uniques":3,"herfindahl":0.966973480331685,"freqmode":6499,"fewest":"4","mid":"1","freqfewest":"1","freqmid":"110","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"onset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"ethonset":{"plottype":"bar","plotvalues":{"0":6535,"1":74,"4":1},"varnamesSumStat":"ethonset","median":"0","mean":"0.0118003025718608","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.116097052965513","uniques":3,"herfindahl":0.977561206717004,"freqmode":6535,"fewest":"4","mid":"1","freqfewest":"1","freqmid":"74","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"ethonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"durest":{"plottype":"continuous","plotx":[-7.64145863086174,-6.24792970715309,-4.85440078344445,-3.46087185973581,-2.06734293602717,-0.673814012318526,0.719714911390117,2.11324383509876,3.5067727588074,4.90030168251604,6.29383060622468,7.68735952993333,9.08088845364197,10.4744173773506,11.8679463010593,13.2614752247679,14.6550041484765,16.0485330721852,17.4420619958938,18.8355909196025,20.2291198433111,21.6226487670197,23.0161776907284,24.409706614437,25.8032355381457,27.1967644618543,28.590293385563,29.9838223092716,31.3773512329802,32.7708801566889,34.1644090803975,35.5579380041062,36.9514669278148,38.3449958515235,39.7385247752321,41.1320536989407,42.5255826226494,43.919111546358,45.3126404700667,46.7061693937753,48.0996983174839,49.4932272411926,50.8867561649012,52.2802850886099,53.6738140123185,55.0673429360272,56.4608718597358,57.8544007834444,59.2479297071531,60.6414586308617],"ploty":[0.000359856431758564,0.00142743141534836,0.00453476208180597,0.0116020530772251,0.0239883430601341,0.0404174102561498,0.0562507752516278,0.0660030764935081,0.0672747447646726,0.0620232797655893,0.0539656203816805,0.0457282931588073,0.0383668347602499,0.0323739621639462,0.0281210744921442,0.0253780395468113,0.0230727435452966,0.0200636033069731,0.0161704073578408,0.0122435536349433,0.00923387884618484,0.00741693896994567,0.00640885122880311,0.00567737466940853,0.0049776739300711,0.00441279027467066,0.00418389859871628,0.00434317246009446,0.00475110483170572,0.00515449066517661,0.00526200483337976,0.00484607880941219,0.00389716192434194,0.00267609061274038,0.00155830536698036,0.000808447995759434,0.000499698222903328,0.00057522134925087,0.000917010216188562,0.00136423807564292,0.00174697825003353,0.00194574729481813,0.0019136490805756,0.00165594375922656,0.00123410841783453,0.000770711514277606,0.000394181909815744,0.000162654971594967,5.37765663030252e-05,1.4154436577632e-05],"varnamesSumStat":"durest","median":"6","mean":"9.18018018018018","mode":"1","max":"52","min":"1","invalid":6499,"valid":111,"sd":"10.095181747383","uniques":28,"herfindahl":0.076860644428212,"freqmode":20,"fewest":"29","mid":"35","freqfewest":"1","freqmid":"2","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"durest","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"aim":{"plottype":"bar","plotvalues":{"1":61,"2":14,"3":35},"varnamesSumStat":"aim","median":"1","mean":"1.76363636363636","mode":"1","max":"3","min":"1","invalid":6500,"valid":110,"sd":"0.907939220445594","uniques":3,"herfindahl":0.42495867768595,"freqmode":61,"fewest":"2","mid":"3","freqfewest":"14","freqmid":"35","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"aim","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"casename":{"plottype":"bar","plotvalues":{"":6499,"?":1,"Abkhazia":1,"AFDL (Kabila)":1,"ALF, ARDUF (Afars)":1,"ANC, PAC, Azapo":1,"Anya Nya":1,"Baluchistan":1,"Bangladesh":1,"Biafra":1,"BRA (Bougainville)":1,"Castro":1,"Chechnya":1,"Chechnya II":1,"Chittagong Hills/Shanti Bahini":1,"Contras":1,"CPB, Karens, etc.":1,"CPN-M/UPF (Maoists)":1,"Croatia/Krajina":1,"Cypriots, Turkey":1,"Darul Islam":1,"Darul Islam, PRRI, Permesta":1,"Dniestr Rep.":1,"DSE":1,"E. Timor":1,"Eritrea, Tigray, etc.":1,"ERP/Montoneros":1,"Faction of Socialist Party":1,"Factional fighting":2,"FARC, ELN, etc":1,"Febreristas, Libs, Comms":1,"Fedeyeen/Syria v. govt":1,"FIS":1,"FLEC (Cabinda)":1,"FLNC":1,"FMLN":1,"FROLINAT, various ...":1,"FRUD":1,"FSLN":1,"FUNK":1,"GAM (Aceh)":1,"Huks":1,"Hutu groups v. govt":1,"Hutu uprising":1,"IRA":1,"JVP":1,"JVP II":1,"Kabylie":1,"Kashmir":1,"Katanga, Kasai, CNL":1,"KDP, PUK (Kurds)":1,"KDPI (Kurds)":1,"Khmer Rouge, FUNCINPEC, etc":1,"Khomeini":1,"Krajina":1,"La Violencia":1,"LRA, West Nile, etc.":1,"LTTE, etc.":1,"MFDC (Casamance)":1,"Mil. coup":3,"Mil. faction":1,"Militia-ized party politics":1,"MNLF, MILF":1,"MNR":1,"MQM:Sindhis v. Mohajirs":1,"Mujahideen":1,"N.East rebels":1,"Nagorno-Karabagh":1,"Nasserites v. Chamoun":1,"Ndebele guer's":1,"NLA":1,"NLF":1,"NPA":1,"NPFL (Taylor), INPFL (Johnson)":1,"NRA, etc.":1,"OPM (West Papua)":1,"Opp. coalition":1,"Org. massacres on both sides":1,"Pathet Lao":1,"PKK":1,"PLA":1,"Polisario":1,"post-Barre war":1,"Post-rev strife":1,"RCD, etc v. govt":1,"RENAMO":1,"Rep. S. Moluccas":1,"Rep. Srpska/Croats":1,"Royalists":1,"RPF, genocide":1,"RUF, AFRC, etc.":1,"Sendero Luminoso":1,"Shammar":1,"Sikhs":1,"South Yemen":1,"SPLA, etc.":1,"SSDF, SNM (Isaaqs)":1,"Tibet":2,"Tuaregs":1,"Ukraine/UPA":1,"UNITA":1,"URNG, various":1,"UTO":1,"v. Rhee":1,"v. Taliban":1,"various militias":1,"Xinjiang":1,"ZANU, ZAPU":1},"varnamesSumStat":"casename","median":"NA","mean":"NA","mode":"Mil. coup","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":107,"herfindahl":0.00982063144225306,"freqmode":3,"fewest":"Castro","mid":"Castro","freqfewest":"1","freqmid":"1","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"casename","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"ended":{"plottype":"bar","plotvalues":{"0":25,"1":86},"varnamesSumStat":"ended","median":"1","mean":"0.774774774774775","mode":"1","max":"1","min":"0","invalid":6499,"valid":111,"sd":"0.419625042252218","uniques":2,"herfindahl":0.651002353705056,"freqmode":86,"fewest":"0","mid":"NA","freqfewest":"25","freqmid":"55.5","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"ended","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ethwar":{"plottype":"bar","plotvalues":{"0":36,"1":20,"2":55},"varnamesSumStat":"ethwar","median":"1","mean":"1.17117117117117","mode":"2","max":"2","min":"0","invalid":6499,"valid":111,"sd":"0.893144331956934","uniques":3,"herfindahl":0.383166950734518,"freqmode":55,"fewest":"1","mid":"0","freqfewest":"20","freqmid":"36","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"ethwar","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"waryrs":{"plottype":"bar","plotvalues":{"":6499,"1945-49":1,"1946-50":2,"1946-52":1,"1947-47":1,"1948- ":1,"1948-48":2,"1948-62":1,"1949-50":1,"1950-50":1,"1950-51":1,"1952- ":1,"1952-52":1,"1953-53":1,"1955-55":1,"1956-59":1,"1958-58":1,"1958-59":1,"1958-60":1,"1959-59":1,"1960-65":1,"1960-73":1,"1960-75":1,"1961-74":1,"1962-63":1,"1962-65":1,"1962-69":1,"1963- ":1,"1963-72":1,"1965- ":2,"1965-65":1,"1967-70":1,"1968- ":1,"1968-96":1,"1969-99":1,"1970-70":1,"1970-75":1,"1971-71":2,"1972-72":1,"1972-79":1,"1972-94":1,"1973-77":2,"1974-74":1,"1974-92":1,"1975- ":1,"1975-88":1,"1975-90":1,"1975-99":1,"1976-95":1,"1976-97":1,"1977-78":1,"1977-80":1,"1978-79":2,"1978-92":2,"1979-92":1,"1979-93":1,"1981-87":1,"1981-88":1,"1981-91":1,"1981-95":1,"1982-93":1,"1983- ":2,"1983-87":1,"1983-94":1,"1984-99":1,"1986-87":1,"1987-89":1,"1988-88":1,"1988-98":1,"1989- ":2,"1989-94":1,"1989-96":1,"1990- ":1,"1991- ":4,"1991-91":1,"1991-95":1,"1992- ":3,"1992-92":1,"1992-94":2,"1992-95":2,"1992-97":1,"1993- ":2,"1993-94":1,"1993-99":1,"1994-94":1,"1994-96":1,"1994-98":1,"1996-97":2,"1997- ":2,"1998- ":1,"1998-99":2,"1999- ":1},"varnamesSumStat":"waryrs","median":"NA","mean":"NA","mode":"1991- ","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":91,"herfindahl":0.0129047966885805,"freqmode":4,"fewest":"1958-59","mid":"1958-59","freqfewest":"1","freqmid":"1","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"waryrs","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"pop":{"plottype":"continuous","plotx":[-5841.53611798006,19678.9633154069,45199.4627487938,70719.9621821807,96240.4616155677,121760.961048955,147281.460482342,172801.959915729,198322.459349115,223842.958782502,249363.458215889,274883.957649276,300404.457082663,325924.95651605,351445.455949437,376965.955382824,402486.454816211,428006.954249598,453527.453682985,479047.953116372,504568.452549759,530088.951983146,555609.451416533,581129.950849919,606650.450283306,632170.949716693,657691.44915008,683211.948583467,708732.448016854,734252.947450241,759773.446883628,785293.946317015,810814.445750402,836334.945183789,861855.444617176,887375.944050563,912896.44348395,938416.942917337,963937.442350724,989457.941784111,1014978.4412175,1040498.94065088,1066019.44008427,1091539.93951766,1117060.43895105,1142580.93838443,1168101.43781782,1193621.93725121,1219142.43668459,1244662.93611798],"ploty":[6.53549026373353e-07,1.22589166813707e-05,2.20446863315443e-06,6.45081571122456e-07,5.5371613859585e-07,6.14978868823323e-07,3.83824962532738e-07,1.74197066149676e-07,1.68762299157126e-07,1.1145944706913e-07,1.4017780308438e-07,6.80399637095414e-08,2.3721896406493e-14,8.73869574293408e-22,3.46170608149145e-08,2.48800442357399e-08,1.17278008093651e-08,1.4844316007773e-08,2.367916761624e-08,1.2398547656904e-08,2.81225684540388e-09,5.0874589792783e-09,3.7357101852572e-08,3.3152708602396e-08,8.90695417688232e-09,1.22739888570981e-08,5.4422825158724e-08,3.10090596269383e-08,2.48583863339823e-09,4.86516213587357e-08,3.84638792075386e-09,9.75963257800802e-09,4.87364574019001e-09,1.01520165952959e-08,2.79509692096553e-08,1.32088724934111e-08,3.56613060303228e-08,3.61807292295146e-09,2.50823437653522e-08,5.9896349272898e-09,8.16203542487203e-10,8.62565887131091e-09,2.51678613674441e-08,8.02879599964503e-11,1.95672771152759e-08,5.78064464398109e-10,1.50023840950814e-09,1.34695710969777e-08,8.4926349485328e-09,1.73714393711047e-09],"varnamesSumStat":"pop","median":"8137","mean":"31786.9182555417","mode":"766","max":"1238599.4","min":"222","invalid":177,"valid":6433,"sd":"102560.817464774","uniques":5744,"herfindahl":0.000193241319019767,"freqmode":5,"fewest":"140969","mid":"140969","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"pop","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"lpop":{"plottype":"continuous","plotx":[4.75499424840934,4.95748771786202,5.1599811873147,5.36247465676738,5.56496812622006,5.76746159567274,5.96995506512542,6.1724485345781,6.37494200403078,6.57743547348346,6.77992894293614,6.98242241238882,7.1849158818415,7.38740935129418,7.58990282074686,7.79239629019954,7.99488975965222,8.1973832291049,8.39987669855758,8.60237016801026,8.80486363746294,9.00735710691562,9.2098505763683,9.41234404582098,9.61483751527366,9.81733098472634,10.019824454179,10.2223179236317,10.4248113930844,10.6273048625371,10.8297983319897,11.0322918014424,11.2347852708951,11.4372787403478,11.6397722098005,11.8422656792531,12.0447591487058,12.2472526181585,12.4497460876112,12.6522395570639,12.8547330265165,13.0572264959692,13.2597199654219,13.4622134348746,13.6647069043273,13.8672003737799,14.0696938432326,14.2721873126853,14.474680782138,14.6771742515907],"ploty":[8.44004323666611e-06,0.000117350501101024,0.000773879604704037,0.00267476559240506,0.00577776543745082,0.0104938496441943,0.0198830526433037,0.0362631028427677,0.0583354205690329,0.0790272582054362,0.0938040305380795,0.107766145621065,0.12299789322428,0.141968230790061,0.167211702534847,0.197345046777753,0.229854160811883,0.26000629139273,0.275052169186251,0.269487887315931,0.275463517863244,0.297432534674987,0.291043953817482,0.259806926541828,0.244284095519169,0.232466619344363,0.201469292675213,0.161311504575729,0.133814137926397,0.127038229753059,0.129084013316596,0.11047002919774,0.0772096343730981,0.0583659660547757,0.0495127880389617,0.0403646927702503,0.0327716420910693,0.0279072012066265,0.0212491951099039,0.0127452667686758,0.00876160983454511,0.0101333102712563,0.0133003710435286,0.0149291371179561,0.0142351940974085,0.0111235153857295,0.00597211628277935,0.0018441689544589,0.000287845903308384,2.08764233035242e-05],"varnamesSumStat":"lpop","median":"9.004177","mean":"9.06276189945593","mode":"6.641","max":"14.029491","min":"5.4026775","invalid":177,"valid":6433,"sd":"1.45479327068009","uniques":5744,"herfindahl":0.000193241319019767,"freqmode":5,"fewest":"11.8563","mid":"11.8563","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lpop","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"polity2":{"plottype":"continuous","plotx":[-13.5047593991578,-12.9535447298044,-12.4023300604511,-11.8511153910977,-11.2999007217443,-10.7486860523909,-10.1974713830375,-9.64625671368416,-9.09504204433078,-8.5438273749774,-7.99261270562402,-7.44139803627064,-6.89018336691726,-6.33896869756388,-5.7877540282105,-5.23653935885712,-4.68532468950374,-4.13411002015035,-3.58289535079697,-3.03168068144359,-2.48046601209021,-1.92925134273683,-1.37803667338345,-0.826822004030072,-0.275607334676691,0.275607334676691,0.82682200403007,1.37803667338345,1.92925134273683,2.48046601209021,3.03168068144359,3.58289535079697,4.13411002015035,4.68532468950374,5.23653935885712,5.78775402821049,6.33896869756388,6.89018336691726,7.44139803627064,7.99261270562402,8.5438273749774,9.09504204433078,9.64625671368416,10.1974713830375,10.7486860523909,11.2999007217443,11.8511153910977,12.4023300604511,12.9535447298044,13.5047593991578],"ploty":[0.000133336466229905,0.000529236052757236,0.00173213625984351,0.00472407404149915,0.0108401241571101,0.0211063799974061,0.0353615815694273,0.05199870813438,0.0689703434585355,0.084939936084736,0.0985030257460344,0.106352333637232,0.104196408550788,0.0910114950115064,0.0712115335921763,0.0517246829508084,0.0373101181082504,0.0287984594897801,0.0245931095884593,0.0226722621916625,0.0217005874084044,0.0211848044948443,0.0209876662294835,0.0208138682912195,0.0202000282595024,0.0189284069526459,0.0172720705490821,0.0157888500924283,0.0149654879370071,0.0150908328896952,0.0162746582499011,0.018361757954345,0.0208975510869133,0.0234038897243911,0.0257430528660836,0.0282131078270718,0.0313620691418716,0.0358070538206141,0.0422790115253027,0.0515663985725993,0.0634934721869158,0.0751024885945271,0.0804875508864962,0.0744676695294445,0.0576571036472443,0.0366822412015105,0.018965423087333,0.0079289822401883,0.00267183441492309,0.000722890019738561],"varnamesSumStat":"polity2","median":"-3","mean":"-0.413013594012525","mode":"-7","max":"10","min":"-10","invalid":63,"valid":6547,"sd":"7.5249377770853","uniques":21,"herfindahl":0.10433514205621,"freqmode":1346,"fewest":"3","mid":"-3","freqfewest":"58","freqmid":"181","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"polity2","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"gdpen":{"plottype":"continuous","plotx":[-1.2127845521873,0.199635225452997,1.61205500309329,3.02447478073359,4.43689455837389,5.84931433601419,7.26173411365449,8.67415389129478,10.0865736689351,11.4989934465754,12.9114132242157,14.323833001856,15.7362527794963,17.1486725571366,18.5610923347769,19.9735121124172,21.3859318900575,22.7983516676978,24.2107714453381,25.6231912229784,27.0356110006187,28.448030778259,29.8604505558993,31.2728703335396,32.6852901111799,34.0977098888201,35.5101296664605,36.9225494441007,38.334969221741,39.7473889993813,41.1598087770216,42.5722285546619,43.9846483323022,45.3970681099425,46.8094878875828,48.2219076652231,49.6343274428634,51.0467472205037,52.459166998144,53.8715867757843,55.2840065534246,56.6964263310649,58.1088461087052,59.5212658863455,60.9336856639858,62.3461054416261,63.7585252192664,65.1709449969067,66.583364774547,67.9957845521873],"ploty":[0.000124803746424797,0.153403082823391,0.214248804435505,0.103279674812367,0.0602455243891747,0.0365493261878481,0.0310083143924521,0.0176240318534116,0.018550184872553,0.0158808140189367,0.0134340949106002,0.011139451785296,0.00651011852590708,0.00334452980181746,0.00180541046003036,0.000725170612901691,0.000436746701116166,2.22555660562337e-06,0.000232384762564075,0.000344035656775049,0.000200432452017594,0.000142864757697886,0.000277137942483031,0.000185262801824838,4.73560410868486e-05,1.80013962349674e-05,0.000203232649990313,0.000112295406400364,0.000170730294278997,0.000339693901039959,0.00014360495708144,4.53460628283766e-05,0.000115846193880952,4.27634050554728e-06,0.00026398570476067,1.1999401184329e-06,3.81165436854938e-11,1.31913317695831e-05,8.03418300621983e-05,0.000146042326777527,7.8765326092043e-07,5.92374009711741e-08,0.00011509384599416,5.02274326943454e-06,4.29413763755696e-12,1.25557265015243e-18,5.4414889881135e-15,1.95400480031731e-07,0.000136833709012363,1.93252160329344e-06],"varnamesSumStat":"gdpen","median":"2.028","mean":"3.69377028234373","mode":"0.882","max":"66.735","min":"0.048","invalid":227,"valid":6383,"sd":"4.49472631264387","uniques":4427,"herfindahl":0.000329997855566185,"freqmode":8,"fewest":"7.626","mid":"7.626","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"gdpen","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"gdptype":{"plottype":"bar","plotvalues":{"0":4243,"2":1116,"3":491,"4":533},"varnamesSumStat":"gdptype","median":"0","mean":"0.914460285132383","mode":"0","max":"4","min":"0","invalid":227,"valid":6383,"sd":"1.37541739288513","uniques":4,"herfindahl":0.485330631957061,"freqmode":4243,"fewest":"3","mid":"NA","freqfewest":"491","freqmid":"824.5","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"gdptype","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"gdpenl":{"plottype":"continuous","plotx":[-1.193959991112,0.217691437096656,1.62934286530531,3.04099429351396,4.45264572172261,5.86429714993127,7.27594857813992,8.68760000634857,10.0992514345572,11.5109028627659,12.9225542909745,14.3342057191832,15.7458571473918,17.1575085756005,18.5691600038091,19.9808114320178,21.3924628602265,22.8041142884351,24.2157657166438,25.6274171448524,27.0390685730611,28.4507200012697,29.8623714294784,31.274022857687,32.6856742858957,34.0973257141043,35.508977142313,36.9206285705216,38.3322799987303,39.7439314269389,41.1555828551476,42.5672342833562,43.9788857115649,45.3905371397735,46.8021885679822,48.2138399961909,49.6254914243995,51.0371428526082,52.4487942808168,53.8604457090255,55.2720971372341,56.6837485654428,58.0953999936514,59.5070514218601,60.9187028500687,62.3303542782774,63.742005706486,65.1536571346947,66.5653085629033,67.976959991112],"ploty":[0.000136943175339789,0.162130101814454,0.211536035911728,0.101803010340786,0.059158118113393,0.0367182784039028,0.0307295362035432,0.0174467663157847,0.0182683386403709,0.0153923587122281,0.0132154789669886,0.010785806031443,0.00545385784915851,0.00327254404455349,0.00160766752405042,0.000675243975948178,0.000320754937553758,1.92381015284579e-06,0.000234748407388672,0.000343191535130304,0.000198719238754183,0.000142190169164284,0.000278735055152705,0.000183368782247833,4.57807440938901e-05,1.71226303789557e-05,0.000204835149855024,0.0001111550065297,0.000168531261584287,0.000456892130728915,0.000150252780877863,4.28540789346561e-05,0.000116802797616145,3.90452173516518e-06,0.000267754149538206,1.05923552828011e-06,2.12465454588222e-11,1.16891472024571e-05,8.23897093337237e-05,0.000148503653382381,7.56543066291535e-07,3.90247133348052e-08,0.000114029214636136,4.88509497870162e-06,2.85638205717404e-12,0,5.01007726095297e-15,3.01630394634559e-07,0.000271566097332841,4.10639885941328e-06],"varnamesSumStat":"gdpenl","median":"1.995","mean":"3.65111658559548","mode":"0.512","max":"66.735","min":"0.048","invalid":237,"valid":6373,"sd":"4.53664523239271","uniques":3848,"herfindahl":0.000395394533894008,"freqmode":10,"fewest":"8.025","mid":"8.025","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"gdpenl","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"lgdpenl1":{"plottype":"continuous","plotx":[3.37606778883341,3.54397698112592,3.71188617341843,3.87979536571095,4.04770455800346,4.21561375029598,4.38352294258849,4.551432134881,4.71934132717352,4.88725051946603,5.05515971175855,5.22306890405106,5.39097809634357,5.55888728863609,5.7267964809286,5.89470567322112,6.06261486551363,6.23052405780614,6.39843325009866,6.56634244239117,6.73425163468369,6.9021608269762,7.07007001926871,7.23797921156123,7.40588840385374,7.57379759614626,7.74170678843877,7.90961598073128,8.0775251730238,8.24543436531631,8.41334355760883,8.58125274990134,8.74916194219385,8.91707113448637,9.08498032677888,9.2528895190714,9.42079871136391,9.58870790365642,9.75661709594894,9.92452628824145,10.092435480534,10.2603446728265,10.428253865119,10.5961630574115,10.764072249704,10.9319814419965,11.099890634289,11.2677998265816,11.4357090188741,11.6036182111666],"ploty":[1.35757710948905e-05,0.000193146658575634,0.000999567227018421,0.00193798602471149,0.001869742870589,0.00228814188728488,0.00294905752039788,0.00294627948649862,0.00407468795034586,0.00632114493678651,0.00887741513683729,0.0143602311716739,0.0244609631128496,0.0368164984489829,0.0518536259188924,0.0796410369681579,0.132296009012578,0.198935265593742,0.254157556006355,0.296925475387211,0.33471065073369,0.353597913922982,0.342147530743302,0.316687532951512,0.310403326146311,0.316807983651347,0.318136674708902,0.310994675709324,0.29935678531876,0.286129630805377,0.255456942399265,0.225670651817472,0.213325628463577,0.198215695064565,0.179743128362275,0.172212761141951,0.158833411213322,0.120603184448847,0.0659577351149517,0.0251172802896755,0.00905137757866878,0.00604956489525672,0.00585010697576981,0.00564278075576189,0.00412190593640558,0.00250040736458905,0.00148461974083356,0.000611382026533822,0.000118150524838585,9.00112352918133e-06],"varnamesSumStat":"lgdpenl1","median":"7.598399","mean":"7.65122400075318","mode":"6.628","max":"11.108485","min":"3.871201","invalid":237,"valid":6373,"sd":"1.05737022623801","uniques":4293,"herfindahl":0.000345413158727133,"freqmode":9,"fewest":"8.99032","mid":"8.99032","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lgdpenl1","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"lpopl1":{"plottype":"continuous","plotx":[4.75790676749327,4.96028135861599,5.16265594973872,5.36503054086144,5.56740513198416,5.76977972310689,5.97215431422961,6.17452890535233,6.37690349647506,6.57927808759778,6.78165267872051,6.98402726984323,7.18640186096595,7.38877645208868,7.5911510432114,7.79352563433412,7.99590022545685,8.19827481657957,8.4006494077023,8.60302399882502,8.80539858994774,9.00777318107047,9.21014777219319,9.41252236331592,9.61489695443864,9.81727154556136,10.0196461366841,10.2220207278068,10.4243953189295,10.6267699100523,10.829144501175,11.0315190922977,11.2338936834204,11.4362682745432,11.6386428656659,11.8410174567886,12.0433920479113,12.245766639034,12.4481412301568,12.6505158212795,12.8528904124022,13.0552650035249,13.2576395946477,13.4600141857704,13.6623887768931,13.8647633680158,14.0671379591386,14.2695125502613,14.471887141384,14.6742617325067],"ploty":[1.19810852095881e-05,0.000161118747667962,0.00101814084495624,0.00332761782693292,0.0067090751929085,0.0114414253271991,0.0209821607463517,0.0378378144106037,0.0604260299706084,0.0809601375637657,0.0952024860617118,0.108875233240058,0.123987415349666,0.142831540797052,0.167659361612202,0.198101759526522,0.232032565529293,0.262726720752351,0.276712408522885,0.269688737386618,0.275081190369961,0.29693904712267,0.29048052811914,0.258899267358508,0.242920571587933,0.230626311107902,0.199101397918939,0.158789764037152,0.131590918839416,0.125473351840071,0.128064057447992,0.109893082389298,0.0769970527901738,0.0579414094404461,0.0488943984364688,0.0399784328450456,0.0325128699437715,0.0275613873752962,0.0209964561127598,0.0127505005847092,0.00886091366882683,0.0101827971814598,0.0132680176091528,0.0147415442395494,0.0139722609799756,0.0109346685229676,0.00589250861622062,0.0018232159368494,0.000284118323096925,2.04829640522541e-05],"varnamesSumStat":"lpopl1","median":"8.991189","mean":"9.04888348191344","mode":"6.641","max":"14.029491","min":"5.4026775","invalid":25,"valid":6585,"sd":"1.45751184555433","uniques":5740,"herfindahl":0.000197660521340868,"freqmode":5,"fewest":"11.8631","mid":"11.8631","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lpopl1","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"region":{"plottype":"bar","plotvalues":{"0":1155,"2":646,"3":1096,"5":910,"6":1593,"7":1210},"varnamesSumStat":"region","median":"5","mean":"4.10862329803328","mode":"6","max":"7","min":"0","invalid":0,"valid":6610,"sd":"2.46795189877614","uniques":6,"herfindahl":0.178119293876925,"freqmode":1593,"fewest":"2","mid":"NA","freqfewest":"646","freqmid":"1125.5","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"region","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"western":{"plottype":"bar","plotvalues":{"0":5455,"1":1155},"varnamesSumStat":"western","median":"0","mean":"0.174735249621785","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.379769221137619","uniques":2,"herfindahl":0.711594315677205,"freqmode":5455,"fewest":"1","mid":"NA","freqfewest":"1155","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"western","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"eeurop":{"plottype":"bar","plotvalues":{"0":5964,"1":646},"varnamesSumStat":"eeurop","median":"0","mean":"0.0977307110438729","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.296972661177269","uniques":2,"herfindahl":0.823641161674536,"freqmode":5964,"fewest":"1","mid":"NA","freqfewest":"646","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"eeurop","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"lamerica":{"plottype":"bar","plotvalues":{"0":5400,"1":1210},"varnamesSumStat":"lamerica","median":"0","mean":"0.183055975794251","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.386741662124369","uniques":2,"herfindahl":0.700907028959469,"freqmode":5400,"fewest":"1","mid":"NA","freqfewest":"1210","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"lamerica","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ssafrica":{"plottype":"bar","plotvalues":{"0":5017,"1":1593},"varnamesSumStat":"ssafrica","median":"0","mean":"0.240998487140696","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.427721747724266","uniques":2,"herfindahl":0.634163567326816,"freqmode":5017,"fewest":"1","mid":"NA","freqfewest":"1593","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"ssafrica","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"asia":{"plottype":"bar","plotvalues":{"0":5514,"1":1096},"varnamesSumStat":"asia","median":"0","mean":"0.165809379727685","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.371937572514737","uniques":2,"herfindahl":0.723366741355989,"freqmode":5514,"fewest":"1","mid":"NA","freqfewest":"1096","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"asia","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"nafrme":{"plottype":"bar","plotvalues":{"0":5700,"1":910},"varnamesSumStat":"nafrme","median":"0","mean":"0.13767019667171","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.344579564928933","uniques":2,"herfindahl":0.762565772759835,"freqmode":5700,"fewest":"1","mid":"NA","freqfewest":"910","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"nafrme","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"colbrit":{"plottype":"bar","plotvalues":{"0":4714,"1":1896},"varnamesSumStat":"colbrit","median":"0","mean":"0.286838124054463","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.452319540458622","uniques":2,"herfindahl":0.590875970713241,"freqmode":4714,"fewest":"1","mid":"NA","freqfewest":"1896","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colbrit","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"colfra":{"plottype":"bar","plotvalues":{"0":5479,"1":1131},"varnamesSumStat":"colfra","median":"0","mean":"0.171104387291982","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.376628644316776","uniques":2,"herfindahl":0.716344648117165,"freqmode":5479,"fewest":"1","mid":"NA","freqfewest":"1131","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colfra","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"mtnest":{"plottype":"continuous","plotx":[-8.84624382427484,-6.56068295389628,-4.27512208351771,-1.98956121313915,0.295999657239419,2.58156052761798,4.86712139799655,7.15268226837511,9.43824313875368,11.7238040091322,14.0093648795108,16.2949257498894,18.5804866202679,20.8660474906465,23.1516083610251,25.4371692314036,27.7227301017822,30.0082909721608,32.2938518425393,34.5794127129179,36.8649735832964,39.150534453675,41.4360953240536,43.7216561944321,46.0072170648107,48.2927779351893,50.5783388055678,52.8638996759464,55.149460546325,57.4350214167035,59.7205822870821,62.0061431574607,64.2917040278392,66.5772648982178,68.8628257685964,71.1483866389749,73.4339475093535,75.719508379732,78.0050692501106,80.2906301204892,82.5761909908677,84.8617518612463,87.1473127316249,89.4328736020034,91.718434472382,94.0039953427606,96.2895562131391,98.5751170835177,100.860677953896,103.146238824275],"ploty":[0.000322223779745127,0.00254984715167125,0.011454939183237,0.0294814301888881,0.0452681995734643,0.0450596744997267,0.0349552719156166,0.0273775839023195,0.0237901750464843,0.0212965352589242,0.0189507214254041,0.0162758862829616,0.0142201901478008,0.0133030440456647,0.0115540766289265,0.00928559157922139,0.00801649781698081,0.00716187018679604,0.0071662570440446,0.00881933383319414,0.00973681250774167,0.00792014180940939,0.0055119520286673,0.00451926481446108,0.00420702499694448,0.00347986533032633,0.0028073000487121,0.00315337871694223,0.00403882071541982,0.00403895509094311,0.0028732481799344,0.00200255789207371,0.00233340390685949,0.00318796987078481,0.00396423024700346,0.00457064434475296,0.00429897617198597,0.00288054345982073,0.00149667470644116,0.00101727778887467,0.000887621639978242,0.000548247822441141,0.0002243175404624,0.000190665571047301,0.000408927627799879,0.000590264007067649,0.000472546023433356,0.000208284118145119,5.03784702403109e-05,6.74220880868022e-06],"varnamesSumStat":"mtnest","median":"10.3","mean":"18.0883285855371","mode":"0","max":"94.299995","min":"0","invalid":0,"valid":6610,"sd":"20.9664781171357","uniques":114,"herfindahl":0.0322517800700813,"freqmode":1025,"fewest":"2.16045","mid":"23.9","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"mtnest","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"lmtnest":{"plottype":"continuous","plotx":[-0.652661272008823,-0.533021430294177,-0.413381588579531,-0.293741746864885,-0.174101905150239,-0.0544620634355933,0.0651777782790525,0.184817619993698,0.304457461708344,0.42409730342299,0.543737145137636,0.663376986852282,0.783016828566927,0.902656670281573,1.02229651199622,1.14193635371086,1.26157619542551,1.38121603714016,1.5008558788548,1.62049572056945,1.74013556228409,1.85977540399874,1.97941524571339,2.09905508742803,2.21869492914268,2.33833477085732,2.45797461257197,2.57761445428662,2.69725429600126,2.81689413771591,2.93653397943055,3.0561738211452,3.17581366285984,3.29545350457449,3.41509334628914,3.53473318800378,3.65437302971843,3.77401287143307,3.89365271314772,4.01329255486236,4.13293239657701,4.25257223829166,4.3722120800063,4.49185192172095,4.61149176343559,4.73113160515024,4.85077144686489,4.97041128857953,5.09005113029418,5.20969097200882],"ploty":[0.00328512650674904,0.0147061563209667,0.0488497143695789,0.120620274917264,0.222148514340619,0.307305253705824,0.324387649576515,0.271410187494105,0.196607505929684,0.143946161811792,0.120159609415085,0.11082708302771,0.107460696156097,0.113413992703652,0.130887828638677,0.150980118773207,0.1600951272666,0.153712909594096,0.141221773215532,0.136680479792053,0.14580775939728,0.163662122391728,0.184047319838279,0.206132304498018,0.229204713993974,0.248002607259006,0.259433852002652,0.266831092609942,0.272674698640842,0.275161757185669,0.273739602345376,0.269704311403904,0.26336724268068,0.257385798660017,0.256533048410265,0.258674288611181,0.253840486467816,0.237230392453505,0.216257985655299,0.199986553161698,0.186591100494472,0.165441722728687,0.130115064524056,0.0866360149250198,0.0477807762677148,0.021699229838666,0.00810770675783886,0.00247884507848913,0.00061160612653518,0.000119441234094587],"varnamesSumStat":"lmtnest","median":"2.4248028","mean":"2.1766899741997","mode":"0","max":"4.5570297","min":"0","invalid":0,"valid":6610,"sd":"1.40399115173584","uniques":112,"herfindahl":0.0323301466397816,"freqmode":1025,"fewest":"1.15071","mid":"3.21487","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lmtnest","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"elevdiff":{"plottype":"continuous","plotx":[-782.272637379509,-565.547223608917,-348.821809838325,-132.096396067733,84.6290177028595,301.354431473452,518.079845244044,734.805259014636,951.530672785228,1168.25608655582,1384.98150032641,1601.706914097,1818.4323278676,2035.15774163819,2251.88315540878,2468.60856917937,2685.33398294997,2902.05939672056,3118.78481049115,3335.51022426174,3552.23563803233,3768.96105180293,3985.68646557352,4202.41187934411,4419.1372931147,4635.86270688529,4852.58812065589,5069.31353442648,5286.03894819707,5502.76436196766,5719.48977573826,5936.21518950885,6152.94060327944,6369.66601705003,6586.39143082062,6803.11684459122,7019.84225836181,7236.5676721324,7453.29308590299,7670.01849967359,7886.74391344418,8103.46932721477,8320.19474098536,8536.92015475596,8753.64556852655,8970.37098229714,9187.09639606773,9403.82180983832,9620.54722360892,9837.27263737951],"ploty":[1.9401563270221e-07,1.82095680754924e-06,1.00632424179643e-05,3.32639754557923e-05,6.95638580392455e-05,0.000102160741296869,0.00012582897623351,0.000148609468288042,0.000162211445284601,0.000157024076687572,0.000148028768800368,0.000153313552622676,0.000172877683831853,0.000198506887681873,0.000233525702858853,0.000275537323609925,0.00030067875198534,0.000287088712172547,0.000233568217857329,0.000174491342442659,0.000147009804137533,0.000137763839421861,0.000119547604649211,9.6862770957646e-05,8.3035005648743e-05,8.1882032302786e-05,8.61570100175693e-05,8.11766667961722e-05,6.83524718333582e-05,6.93868698050135e-05,8.21402676961925e-05,8.06690923318444e-05,6.57300849734573e-05,5.26229890974437e-05,4.62927515689597e-05,4.81761272674022e-05,5.01519466586139e-05,4.13369452437191e-05,2.47728593358212e-05,1.06028998368687e-05,3.94563940455213e-06,5.91777388649653e-06,1.76693684920106e-05,3.39344599438517e-05,4.03127614402488e-05,3.13677510723085e-05,1.64470587606032e-05,5.6514400050835e-06,1.19253086175527e-06,1.479565129255e-07],"varnamesSumStat":"elevdiff","median":"2762","mean":"3186.0897514575","mode":"3014","max":"9002","min":"53","invalid":92,"valid":6518,"sd":"2022.48452690662","uniques":155,"herfindahl":0.0075251285627141,"freqmode":109,"fewest":"1487","mid":"1810","freqfewest":"7","freqmid":"47","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"elevdiff","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"Oil":{"plottype":"bar","plotvalues":{"0":5754,"1":856},"varnamesSumStat":"Oil","median":"0","mean":"0.129500756429652","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.335778747993689","uniques":2,"herfindahl":0.7745393789724,"freqmode":5754,"fewest":"1","mid":"NA","freqfewest":"856","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"Oil","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ncontig":{"plottype":"bar","plotvalues":{"0":5464,"1":1146},"varnamesSumStat":"ncontig","median":"0","mean":"0.173373676248109","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.378598639053372","uniques":2,"herfindahl":0.71336951073535,"freqmode":5464,"fewest":"1","mid":"NA","freqfewest":"1146","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"ncontig","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ethfrac":{"plottype":"continuous","plotx":[-0.131642721280174,-0.107370880411595,-0.0830990395430167,-0.0588271986744382,-0.0345553578058596,-0.0102835169372811,0.0139883239312974,0.0382601647998759,0.0625320056684544,0.086803846537033,0.111075687405611,0.13534752827419,0.159619369142769,0.183891210011347,0.208163050879926,0.232434891748504,0.256706732617083,0.280978573485661,0.30525041435424,0.329522255222818,0.353794096091397,0.378065936959975,0.402337777828554,0.426609618697132,0.450881459565711,0.475153300434289,0.499425141302868,0.523696982171446,0.547968823040025,0.572240663908603,0.596512504777182,0.62078434564576,0.645056186514339,0.669328027382917,0.693599868251496,0.717871709120074,0.742143549988653,0.766415390857231,0.79068723172581,0.814959072594388,0.839230913462967,0.863502754331545,0.887774595200124,0.912046436068703,0.936318276937281,0.960590117805859,0.984861958674438,1.00913379954302,1.0334056404116,1.05767748128017],"ploty":[0.00396655953122504,0.0203205133328029,0.079539307729589,0.239900940596468,0.563229077218956,1.04201109399517,1.5435532592293,1.87375256497697,1.93323035409598,1.79090575718764,1.59190942011339,1.4280564245933,1.31008147677334,1.22221213071379,1.16158617528517,1.1258529148171,1.09519308177722,1.04837480443887,0.982963871224332,0.905086368334049,0.81533631559096,0.719582839609385,0.640415595489774,0.601671370299872,0.605945374556763,0.636017922046404,0.67192368010804,0.700738600191469,0.720671874513854,0.749301346026579,0.823384643105577,0.969202145494586,1.16007179909486,1.31831464856378,1.37703447948294,1.32652922596384,1.19360304599851,1.01257220857125,0.831410346725686,0.702232402621903,0.639526007460296,0.604850168851525,0.540937958260432,0.421451896580193,0.271844547008918,0.141140681688846,0.0580830087855045,0.0187645891368509,0.00472251209800278,0.000918968620538465],"varnamesSumStat":"ethfrac","median":"0.32545453","mean":"0.38535469357761","mode":"0.357","max":"0.92503476","min":"0.001","invalid":0,"valid":6610,"sd":"0.285338222147506","uniques":162,"herfindahl":0.00712737542942546,"freqmode":55,"fewest":"0.322181","mid":"0.534009","freqfewest":"7","freqmid":"44","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"ethfrac","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"ef":{"plottype":"continuous","plotx":[-0.123305147909748,-0.0978233263420034,-0.0723415047742586,-0.0468596832065138,-0.021377861638769,0.00410395992897586,0.0295857814967207,0.0550676030644655,0.0805494246322103,0.106031246199955,0.1315130677677,0.156994889335445,0.18247671090319,0.207958532470934,0.233440354038679,0.258922175606424,0.284403997174169,0.309885818741914,0.335367640309659,0.360849461877403,0.386331283445148,0.411813105012893,0.437294926580638,0.462776748148383,0.488258569716128,0.513740391283872,0.539222212851617,0.564704034419362,0.590185855987107,0.615667677554852,0.641149499122597,0.666631320690341,0.692113142258086,0.717594963825831,0.743076785393576,0.768558606961321,0.794040428529065,0.81952225009681,0.845004071664555,0.8704858932323,0.895967714800045,0.92144953636779,0.946931357935535,0.972413179503279,0.997895001071024,1.02337682263877,1.04885864420651,1.07434046577426,1.099822287342,1.12530410890975],"ploty":[0.00268107834949284,0.0150291408829736,0.0596863548772082,0.170623206111097,0.360431558337922,0.584799699263036,0.771987376921582,0.899221625442944,1.00822848964417,1.14364572212257,1.29446113681165,1.39155400552405,1.370495818668,1.24911567389251,1.11683882387845,1.03437563059979,0.983297653293618,0.923399843157077,0.849954675663545,0.777947583109897,0.715545535242351,0.688410958775813,0.759506164799444,0.967215870265168,1.23370896938696,1.40811801249281,1.41913069332013,1.32247171009346,1.21504465105374,1.14919075483096,1.11153477237675,1.07625921591433,1.06834289996574,1.12688950775256,1.21553726489725,1.23532799235628,1.1399909768481,0.988473720565673,0.858023499989028,0.751847728945723,0.626806803303465,0.472952861468152,0.320739200899734,0.197685235906035,0.111555783674445,0.0569557154452532,0.0249959302266331,0.0087408624095717,0.00228122355363367,0.000427022232061164],"varnamesSumStat":"ef","median":"0.4928","mean":"0.459328534749294","mode":"0.0396","max":"1","min":"0.001998961","invalid":92,"valid":6518,"sd":"0.268797001327038","uniques":159,"herfindahl":0.00739383307593643,"freqmode":110,"fewest":"0.321595","mid":"0.4787","freqfewest":"7","freqmid":"44","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"ef","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"plural":{"plottype":"continuous","plotx":[-0.11041666836265,-0.0854404778172355,-0.0604642872718212,-0.035488096726407,-0.0105119061809927,0.0144642843644216,0.0394404749098359,0.0644166654552502,0.0893928560006644,0.114369046546079,0.139345237091493,0.164321427636907,0.189297618182322,0.214273808727736,0.23924999927315,0.264226189818564,0.289202380363979,0.314178570909393,0.339154761454807,0.364130952000221,0.389107142545636,0.41408333309105,0.439059523636464,0.464035714181879,0.489011904727293,0.513988095272707,0.538964285818121,0.563940476363536,0.58891666690895,0.613892857454364,0.638869047999779,0.663845238545193,0.688821429090607,0.713797619636021,0.738773810181436,0.76375000072685,0.788726191272264,0.813702381817679,0.838678572363093,0.863654762908507,0.888630953453921,0.913607143999336,0.93858333454475,0.963559525090164,0.988535715635579,1.01351190618099,1.03848809672641,1.06346428727182,1.08844047781724,1.11341666836265],"ploty":[0.000445360340379923,0.00255720351558399,0.0095306547232087,0.0231884000710527,0.0369516621306814,0.0395133772923249,0.0333058290782285,0.0389431513531302,0.0756641581514104,0.146539070406164,0.241680585437492,0.34750762083438,0.448726233572331,0.532692485242008,0.610935059865416,0.697966859359264,0.756671329726097,0.764420901457121,0.798800126088936,0.928513748583448,1.07997557591187,1.12384332569116,1.05598334178031,0.994814747556531,1.00711341804402,1.03784067038688,1.04286248958173,1.05593055928726,1.11177129431101,1.19732752369842,1.25357616597635,1.20861871729811,1.05443890538975,0.903329158631611,0.882143630048198,0.986796081311142,1.14230764779219,1.31891457682004,1.5278941122781,1.78469057394808,2.05405058276422,2.20969364635907,2.13045009285187,1.80630162722119,1.31074481752738,0.772324373289532,0.346507539503276,0.112556149061073,0.0254747854153835,0.00390550993520539],"varnamesSumStat":"plural","median":"0.68","mean":"0.659971709531014","mode":"0.68","max":"0.999","min":"0.004","invalid":0,"valid":6610,"sd":"0.246130721833427","uniques":99,"herfindahl":0.0167702170415247,"freqmode":264,"fewest":"0.812","mid":"0.691","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"plural","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"second":{"plottype":"continuous","plotx":[-0.0516576199575032,-0.0405695538367887,-0.0294814877160743,-0.0183934215953599,-0.0073053554746455,0.00378271064606892,0.0148707767667833,0.0259588428874977,0.0370469090082122,0.0481349751289266,0.059223041249641,0.0703111073703554,0.0813991734910698,0.0924872396117842,0.103575305732499,0.114663371853213,0.125751437973927,0.136839504094642,0.147927570215356,0.159015636336071,0.170103702456785,0.1811917685775,0.192279834698214,0.203367900818928,0.214455966939643,0.225544033060357,0.236632099181072,0.247720165301786,0.2588082314225,0.269896297543215,0.280984363663929,0.292072429784644,0.303160495905358,0.314248562026072,0.325336628146787,0.336424694267501,0.347512760388216,0.35860082650893,0.369688892629645,0.380776958750359,0.391865024871073,0.402953090991788,0.414041157112502,0.425129223233217,0.436217289353931,0.447305355474646,0.45839342159536,0.469481487716074,0.480569553836789,0.491657619957503],"ploty":[0.0104381427084967,0.068034902999386,0.303554335196287,0.926198116280293,1.97249032857676,3.02187690904545,3.52600219860764,3.47891457902067,3.32305481740405,3.29700407609655,3.32690183052745,3.37885761003565,3.45181124559092,3.37890403192811,3.05054410361045,2.7431768998393,2.83889457857788,3.26871064250755,3.57115208805996,3.49922828315026,3.25460981664485,3.06972797572322,2.8881538677784,2.60905679190147,2.33667439697368,2.23002589305901,2.25777855369579,2.18020967680968,1.84346902500466,1.44486002035531,1.28136878307705,1.33178832129637,1.32236323649335,1.09964865394585,0.799024556982128,0.646135259637041,0.699419562696485,0.841905033609559,0.944510849433645,0.968099117854149,0.928243588872859,0.811112388094088,0.628015967229057,0.473818972643354,0.386847641233748,0.296234792499783,0.172810173667547,0.0696762690856342,0.0187698917999343,0.0033777228397614],"varnamesSumStat":"second","median":"0.14","mean":"0.153893207261725","mode":"0.15","max":"0.44","min":"0","invalid":0,"valid":6610,"sd":"0.111124781644906","uniques":95,"herfindahl":0.0177409646137402,"freqmode":292,"fewest":"0.101","mid":"0.125","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"second","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"numlang":{"plottype":"continuous","plotx":[-1.42838037195227,-0.410895458811357,0.606589454329552,1.62407436747046,2.64155928061137,3.65904419375228,4.67652910689319,5.6940140200341,6.711498933175,7.72898384631591,8.74646875945682,9.76395367259773,10.7814385857386,11.7989234988795,12.8164084120205,13.8338933251614,14.8513782383023,15.8688631514432,16.8863480645841,17.903832977725,18.9213178908659,19.9388028040068,20.9562877171477,21.9737726302886,22.9912575434295,24.0087424565705,25.0262273697114,26.0437122828523,27.0611971959932,28.0786821091341,29.096167022275,30.1136519354159,31.1311368485568,32.1486217616977,33.1661066748386,34.1835915879795,35.2010765011204,36.2185614142614,37.2360463274023,38.2535312405432,39.2710161536841,40.288501066825,41.3059859799659,42.3234708931068,43.3409558062477,44.3584407193886,45.3759256325295,46.3934105456704,47.4108954588114,48.4283803719523],"ploty":[0.000984024001802016,0.0194923886025214,0.0918604111606038,0.146792915367358,0.148794553318147,0.108274593410464,0.0640753444484864,0.049312154079643,0.0355137489281739,0.0296914113468514,0.0330892633785861,0.0280525342316239,0.0240764767161123,0.0261808927558134,0.0235905769061945,0.0161187685662674,0.0125193743009062,0.0121171821126323,0.010653219705456,0.0105908566720587,0.014917500354844,0.0139466857591708,0.0184996646545534,0.0111726133096808,0.00361080021702514,0.00342184721646788,0.00429134350199596,0.00732661336101478,0.00540659939396888,0.00144707307523084,0.000111169489058106,1.97699769386642e-06,7.45807881642762e-09,5.61113546796444e-12,9.41108136173401e-16,0,0,0,0,0,3.89442023859445e-18,7.61317293652197e-14,2.21000387293886e-10,1.44905207296511e-07,1.89394291795661e-05,0.000514021857805456,0.00293415608841259,0.00350318892897785,0.000875489145374482,4.58487559851879e-05],"varnamesSumStat":"numlang","median":"4","mean":"6.84841149773071","mode":"3","max":"46","min":"1","invalid":0,"valid":6610,"sd":"7.21425041402589","uniques":25,"herfindahl":0.0982391782496149,"freqmode":1146,"fewest":"18","mid":"11","freqfewest":"25","freqmid":"147","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"numlang","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"relfrac":{"plottype":"continuous","plotx":[-0.101660415576437,-0.0815355006549493,-0.0614105857334621,-0.0412856708119749,-0.0211607558904877,-0.00103584096900047,0.0190890739524867,0.0392139888739739,0.0593389037954611,0.0794638187169484,0.0995887336384356,0.119713648559923,0.13983856348141,0.159963478402897,0.180088393324384,0.200213308245872,0.220338223167359,0.240463138088846,0.260588053010333,0.28071296793182,0.300837882853308,0.320962797774795,0.341087712696282,0.361212627617769,0.381337542539256,0.401462457460744,0.421587372382231,0.441712287303718,0.461837202225205,0.481962117146693,0.50208703206818,0.522211946989667,0.542336861911154,0.562461776832641,0.582586691754128,0.602711606675616,0.622836521597103,0.64296143651859,0.663086351440077,0.683211266361565,0.703336181283052,0.723461096204539,0.743586011126026,0.763710926047513,0.783835840969,0.803960755890488,0.824085670811975,0.844210585733462,0.864335500654949,0.884460415576437],"ploty":[0.001890589038154,0.0100927492168246,0.0392946415906407,0.11426718398331,0.257314897327359,0.471998718770701,0.746960967817145,1.06449336885043,1.3826882499626,1.61688584578258,1.68381109586708,1.59913916116528,1.50374758037596,1.529398264333,1.64792883574012,1.71824584602397,1.66905682504378,1.5380123127075,1.36947193003653,1.21000772139451,1.13991659832955,1.18215698388123,1.24196363335756,1.20110830811911,1.04888290182229,0.913561238968641,0.951452991545376,1.17632460881739,1.42624419559613,1.52588713022767,1.4497192202961,1.30579141372728,1.20475035407365,1.19472468785283,1.2914227505732,1.45432167394028,1.54718431183111,1.46042877370658,1.2457541789023,1.02173108960651,0.833277763446157,0.685469495020902,0.593715400458947,0.533204077345091,0.437146387384773,0.287968194798301,0.142316238337368,0.0511684327913142,0.0131932318157659,0.00241969058364214],"varnamesSumStat":"relfrac","median":"0.35759997","mean":"0.367376836265658","mode":"0.095","max":"0.7828","min":"0","invalid":0,"valid":6610,"sd":"0.21868974010331","uniques":124,"herfindahl":0.0116336820615168,"freqmode":236,"fewest":"0.6676","mid":"0.4168","freqfewest":"7","freqmid":"54","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"relfrac","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"plurrel":{"plottype":"continuous","plotx":[15.5223323567678,17.4397881789405,19.3572440011133,21.274699823286,23.1921556454588,25.1096114676315,27.0270672898042,28.944523111977,30.8619789341497,32.7794347563225,34.6968905784952,36.614346400668,38.5318022228407,40.4492580450135,42.3667138671862,44.2841696893589,46.2016255115317,48.1190813337044,50.0365371558772,51.9539929780499,53.8714488002227,55.7889046223954,57.7063604445681,59.6238162667409,61.5412720889136,63.4587279110864,65.3761837332591,67.2936395554319,69.2110953776046,71.1285511997773,73.0460070219501,74.9634628441228,76.8809186662956,78.7983744884683,80.7158303106411,82.6332861328138,84.5507419549865,86.4681977771593,88.385653599332,90.3031094215048,92.2205652436775,94.1380210658503,96.055476888023,97.9729327101958,99.8903885323685,101.807844354541,103.725300176714,105.642755998887,107.560211821059,109.477667643232],"ploty":[1.30094996866629e-05,7.14534952836797e-05,0.000274647060910863,0.000744500299076006,0.00144504227255296,0.00208432500931149,0.00245334768466343,0.00278206214625052,0.0034567541461954,0.00459741512963922,0.0061368676703507,0.00782769740893991,0.00898410763581545,0.00905469018947276,0.00870031501422662,0.00939732349111226,0.0117047537726766,0.0143058693752085,0.0149029390673019,0.0126755412084719,0.00946958322409162,0.00760041290844668,0.00758715943182569,0.0084784077089856,0.00925243905845249,0.00976251417674518,0.0105608973137941,0.0117363587039499,0.012474795572241,0.0123211946308812,0.0120867149186108,0.0127156809048412,0.014028002706327,0.0152172728072168,0.0161244944894463,0.0175195715960721,0.019948861512651,0.0228582125735657,0.025220362998257,0.0265745302684538,0.0271972907464334,0.0268919825408612,0.0243281438352452,0.0188732846327521,0.0120315067908365,0.00614231728143621,0.00245951277317847,0.000754243158702324,0.00017282461088888,2.89392250693646e-05],"varnamesSumStat":"plurrel","median":"78","mean":"72.7807866868381","mode":"50","max":"100","min":"25","invalid":0,"valid":6610,"sd":"20.388158576094","uniques":53,"herfindahl":0.0319623913705224,"freqmode":524,"fewest":"71","mid":"76","freqfewest":"8","freqmid":"90","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"plurrel","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"minrelpc":{"plottype":"continuous","plotx":[-6.01686087648239,-4.75086655499331,-3.48487223350423,-2.21887791201516,-0.95288359052608,0.313110730962998,1.57910505245207,2.84509937394115,4.11109369543023,5.37708801691931,6.64308233840838,7.90907665989746,9.17507098138654,10.4410653028756,11.7070596243647,12.9730539458538,14.2390482673428,15.5050425888319,16.771036910321,18.0370312318101,19.3030255532992,20.5690198747882,21.8350141962773,23.1010085177664,24.3670028392555,25.6329971607445,26.8989914822336,28.1649858037227,29.4309801252118,30.6969744467008,31.9629687681899,33.228963089679,34.4949574111681,35.7609517326572,37.0269460541462,38.2929403756353,39.5589346971244,40.8249290186135,42.0909233401025,43.3569176615916,44.6229119830807,45.8889063045698,47.1549006260589,48.4208949475479,49.686889269037,50.9528835905261,52.2188779120152,53.4848722335042,54.7508665549933,56.0168608764824],"ploty":[7.0436401811617e-05,0.000432873798439075,0.00185574914038901,0.00562338206733756,0.0123013683047599,0.0204024130609166,0.0277378287595902,0.0335362288366692,0.0368375169865706,0.035423522968054,0.0297433528532958,0.0242663013262585,0.0219690709562367,0.0219741969869864,0.0238532150083953,0.0284413233302343,0.0333594262011402,0.0340390747983579,0.0306647328025846,0.0279693944842757,0.0273085396722322,0.0253772180507053,0.0215294707016368,0.019068445049716,0.0189872768251618,0.0187444135949333,0.0170763496133156,0.0149897900763019,0.0130416892852226,0.011453865152512,0.0113645652361373,0.0130012195094781,0.0141955623387845,0.013409513617912,0.0126248457192256,0.0142051414529056,0.0162093319902337,0.0147263817573269,0.00996242347537021,0.00580517723529776,0.0044221628474665,0.00484616460098681,0.00531912544924059,0.00495290426057112,0.00376656095529259,0.00227079413830341,0.00104466791135427,0.000352798880059691,8.52355517396922e-05,1.44330161602003e-05],"varnamesSumStat":"minrelpc","median":"16","mean":"18.2706505295008","mode":"20","max":"50","min":"0","invalid":0,"valid":6610,"sd":"12.9433441114193","uniques":45,"herfindahl":0.0437865426472978,"freqmode":599,"fewest":"39","mid":"22","freqfewest":"7","freqmid":"95","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"minrelpc","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"muslim":{"plottype":"continuous","plotx":[-17.3455740853733,-14.5967751431132,-11.8479762008531,-9.09917725859292,-6.35037831633278,-3.60157937407265,-0.852780431812509,1.89601851044763,4.64481745270776,7.3936163949679,10.142415337228,12.8912142794882,15.6400132217483,18.3888121640084,21.1376111062686,23.8864100485287,26.6352089907889,29.384007933049,32.1328068753091,34.8816058175693,37.6304047598294,40.3792037020895,43.1280026443497,45.8768015866098,48.6256005288699,51.3743994711301,54.1231984133902,56.8719973556503,59.6207962979105,62.3695952401706,65.1183941824307,67.8671931246909,70.615992066951,73.3647910092112,76.1135899514713,78.8623888937314,81.6111878359916,84.3599867782517,87.1087857205118,89.857584662772,92.6063836050321,95.3551825472922,98.1039814895524,100.852780431813,103.601579374073,106.350378316333,109.099177258593,111.847976200853,114.596775143113,117.345574085373],"ploty":[0.000343046781530974,0.00130074863615317,0.00396361318093077,0.00968817258569682,0.0190205448825322,0.0300994940281264,0.038573100651331,0.0403802797637699,0.0351746195486412,0.0264150533789426,0.0182137800774419,0.0125133748587894,0.00896404717499099,0.00650920414758519,0.00453069433328065,0.00297196505698632,0.00193605943098305,0.00138667438119014,0.00114773161254336,0.00106532419351674,0.00111549325972399,0.00136261385856252,0.00181867965593553,0.00234093188100626,0.00268463270893323,0.00268992098812526,0.00240866507609668,0.00204298289275795,0.00178422895887855,0.00171744393000283,0.00181479082018208,0.0019532531679196,0.00198965695868539,0.0019045155048207,0.0018642717123242,0.0021116419656917,0.00280138235379452,0.00393457463605805,0.00542390011204631,0.00713944560315525,0.00881884077859595,0.0099389655145324,0.00987237524114523,0.00837896037637898,0.00593926814305201,0.0034665104520227,0.00165070559697272,0.000637099836712126,0.000198649012556429,5.00670025695037e-05],"varnamesSumStat":"muslim","median":"2.1","mean":"25.592049924357","mode":"0","max":"100","min":"0","invalid":0,"valid":6610,"sd":"37.4449222755913","uniques":63,"herfindahl":0.127924270062551,"freqmode":2265,"fewest":"48","mid":"1.9","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"muslim","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"nwstate":{"plottype":"bar","plotvalues":{"0":6414,"1":196},"varnamesSumStat":"nwstate","median":"0","mean":"0.0296520423600605","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.169638298512456","uniques":2,"herfindahl":0.942454402512125,"freqmode":6414,"fewest":"1","mid":"NA","freqfewest":"196","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"nwstate","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"polity2l":{"plottype":"continuous","plotx":[-13.5006904490495,-12.9496418592924,-12.3985932695352,-11.8475446797781,-11.296496090021,-10.7454475002639,-10.1943989105067,-9.64335032074962,-9.0923017309925,-8.54125314123538,-7.99020455147826,-7.43915596172114,-6.88810737196402,-6.33705878220689,-5.78601019244977,-5.23496160269265,-4.68391301293553,-4.13286442317841,-3.58181583342129,-3.03076724366417,-2.47971865390705,-1.92867006414992,-1.3776214743928,-0.826572884635681,-0.27552429487856,0.275524294878561,0.826572884635683,1.3776214743928,1.92867006414993,2.47971865390705,3.03076724366417,3.58181583342129,4.13286442317841,4.68391301293553,5.23496160269265,5.78601019244978,6.3370587822069,6.88810737196402,7.43915596172114,7.99020455147826,8.54125314123538,9.0923017309925,9.64335032074963,10.1943989105067,10.7454475002639,11.296496090021,11.8475446797781,12.3985932695352,12.9496418592924,13.5006904490495],"ploty":[0.000136743815168839,0.000542248534202707,0.0017722906380832,0.00482701998318868,0.0110516120134757,0.0214690892300264,0.0358922282548551,0.0526797350783772,0.0697600632692643,0.085785514245377,0.0993312543692595,0.107060820983131,0.104702553809576,0.0913068269559652,0.0713777204085588,0.0518743622949543,0.037510732360842,0.0290581746410163,0.0248790835622553,0.0229288414995326,0.0218738201801199,0.0212586734929474,0.0209965299021883,0.0208130443385005,0.0202254124870869,0.0189888294714023,0.0173696140571458,0.0159267919128148,0.0151334529168576,0.0152590678473957,0.016411584897516,0.0184454246741412,0.0209024264354768,0.0232879375738732,0.0254664253358589,0.027772909125819,0.0308002411153332,0.0351719355542708,0.0415786195574558,0.0507663400585052,0.0625797480160503,0.0741375615835891,0.0796017583477803,0.0737885176632324,0.0572175798575958,0.0364432639484036,0.0188559678843416,0.00788296938773396,0.00265609017662026,0.000718416375624402],"varnamesSumStat":"polity2l","median":"-3","mean":"-0.479896040360801","mode":"-7","max":"10","min":"-10","invalid":69,"valid":6541,"sd":"7.51482333625505","uniques":21,"herfindahl":0.104190773328426,"freqmode":1349,"fewest":"3","mid":"-3","freqfewest":"57","freqmid":"187","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"polity2l","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"instab":{"plottype":"bar","plotvalues":{"0":5630,"1":966},"varnamesSumStat":"instab","median":"0","mean":"0.146452395391146","mode":"0","max":"1","min":"0","invalid":14,"valid":6596,"sd":"0.353585980559955","uniques":2,"herfindahl":0.749991817449317,"freqmode":5630,"fewest":"1","mid":"NA","freqfewest":"966","freqmid":"3298","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"instab","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"anocl":{"plottype":"bar","plotvalues":{"0":5065,"1":1476},"varnamesSumStat":"anocl","median":"0","mean":"0.225653569790552","mode":"0","max":"1","min":"0","invalid":69,"valid":6541,"sd":"0.418043961771816","uniques":2,"herfindahl":0.650531927537335,"freqmode":5065,"fewest":"1","mid":"NA","freqfewest":"1476","freqmid":"3270.5","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"anocl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"deml":{"plottype":"bar","plotvalues":{"0":4368,"1":2173},"varnamesSumStat":"deml","median":"0","mean":"0.332212199969424","mode":"0","max":"1","min":"0","invalid":69,"valid":6541,"sd":"0.471042647495314","uniques":2,"herfindahl":0.556305491678201,"freqmode":4368,"fewest":"1","mid":"NA","freqfewest":"2173","freqmid":"3270.5","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"deml","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"empethfrac":{"plottype":"continuous","plotx":[-0.133366641689911,-0.108408368559711,-0.0834500954295102,-0.0584918222993097,-0.0335335491691093,-0.0085752760389088,0.0163829970912917,0.0413412702214921,0.0662995433516926,0.091257816481893,0.116216089612093,0.141174362742294,0.166132635872494,0.191090909002695,0.216049182132895,0.241007455263096,0.265965728393296,0.290924001523497,0.315882274653697,0.340840547783897,0.365798820914098,0.390757094044298,0.415715367174499,0.440673640304699,0.4656319134349,0.4905901865651,0.515548459695301,0.540506732825501,0.565465005955702,0.590423279085902,0.615381552216102,0.640339825346303,0.665298098476503,0.690256371606704,0.715214644736904,0.740172917867105,0.765131190997305,0.790089464127506,0.815047737257706,0.840006010387906,0.864964283518107,0.889922556648307,0.914880829778508,0.939839102908708,0.964797376038909,0.989755649169109,1.01471392229931,1.03967219542951,1.06463046855971,1.08958874168991],"ploty":[0.00361460169477862,0.019101751218742,0.0766906628522993,0.235757836455765,0.560018833509033,1.04068508855493,1.53786517274657,1.85234960102912,1.8925811780906,1.74167169989726,1.54782034847336,1.39304665175855,1.27987121206254,1.19298209148995,1.13057305600968,1.08637469729036,1.03949329385955,0.976257390338998,0.902363716419965,0.82531202307448,0.744901059460034,0.668956579666047,0.619027285764015,0.60897366991738,0.629553236364973,0.659510230252521,0.683031770508224,0.698237667419467,0.721918799656056,0.788603877521259,0.927529756936516,1.12117950149382,1.29535943134851,1.37451771848082,1.34003542524136,1.21918424494084,1.05070822538582,0.882793502132294,0.762855588887269,0.701262392966657,0.661157061515673,0.589889133239058,0.462319924493156,0.302421865435965,0.160099617500876,0.0673733194056647,0.0222874558934285,0.00574969740428529,0.00115136051813253,0.000178232531874608],"varnamesSumStat":"empethfrac","median":"0.3475368","mean":"0.393774033387746","mode":"0.755","max":"0.9552221","min":"0.001","invalid":0,"valid":6610,"sd":"0.289046683343799","uniques":311,"herfindahl":0.0067945921573923,"freqmode":55,"fewest":"0.493672","mid":"0.261047","freqfewest":"1","freqmid":"9","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"empethfrac","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"empwarl":{"plottype":"bar","plotvalues":{"0":5673,"1":937},"varnamesSumStat":"empwarl","median":"0","mean":"0.141754916792738","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.348824982847671","uniques":2,"herfindahl":0.756679079284356,"freqmode":5673,"fewest":"1","mid":"NA","freqfewest":"937","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"empwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"emponset":{"plottype":"bar","plotvalues":{"0":6486,"1":123,"4":1},"varnamesSumStat":"emponset","median":"0","mean":"0.0192133131618759","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.143745326542379","uniques":3,"herfindahl":0.963179293281852,"freqmode":6486,"fewest":"4","mid":"1","freqfewest":"1","freqmid":"123","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"emponset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"empgdpenl":{"plottype":"continuous","plotx":[-1.1639069356152,0.246517837267057,1.65694261014931,3.06736738303156,4.47779215591382,5.88821692879607,7.29864170167832,8.70906647456057,10.1194912474428,11.5299160203251,12.9403407932073,14.3507655660896,15.7611903389718,17.1716151118541,18.5820398847363,19.9924646576186,21.4028894305009,22.8133142033831,24.2237389762654,25.6341637491476,27.0445885220299,28.4550132949121,29.8654380677944,31.2758628406766,32.6862876135589,34.0967123864411,35.5071371593234,36.9175619322056,38.3279867050879,39.7384114779701,41.1488362508524,42.5592610237346,43.9696857966169,45.3801105694992,46.7905353423814,48.2009601152637,49.6113848881459,51.0218096610282,52.4322344339104,53.8426592067927,55.2530839796749,56.6635087525572,58.0739335254394,59.4843582983217,60.8947830712039,62.3052078440862,63.7156326169684,65.1260573898507,66.5364821627329,67.9469069356152],"ploty":[0.000139677897072745,0.172193156139941,0.211634410942692,0.10053895257166,0.0549843130489727,0.0347882385787671,0.0302179043816396,0.0171778836677901,0.0181819845806934,0.015353337900595,0.0132604144813054,0.0107405496804951,0.00540629826784187,0.0032537030920371,0.00158645064904955,0.000677306966047469,0.00032336538245312,1.52422351712339e-06,0.000237855636207898,0.000340937255037517,0.000195454596168453,0.000140760852039054,0.000280423274249742,0.000179561256657136,4.31549815590407e-05,1.57191772162223e-05,0.000206703377039787,0.000109248657192312,0.000164508026102675,0.000459925423188049,0.000152688996711151,3.83604682274168e-05,0.000118095690800886,3.26096073134981e-06,0.000273584339667872,9.29649936400031e-07,8.61091371411405e-12,9.33170104844097e-06,8.53300615894682e-05,0.000150932397926699,7.08605835275092e-07,1.8116512718564e-08,0.00011129046044863,4.82845469459543e-06,2.09243381994609e-12,7.0004157295461e-19,3.81533003288613e-16,1.359582474576e-07,0.000271656936579766,3.9653388706289e-06],"varnamesSumStat":"empgdpenl","median":"1.94","mean":"3.6202228153962","mode":"0.756","max":"66.735","min":"0.048","invalid":237,"valid":6373,"sd":"4.53721829326117","uniques":4343,"herfindahl":0.000342113895538778,"freqmode":9,"fewest":"8.025","mid":"8.025","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"empgdpenl","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"emplpopl":{"plottype":"continuous","plotx":[4.7463427323063,4.94918932486522,5.15203591742415,5.35488250998308,5.557729102542,5.76057569510093,5.96342228765986,6.16626888021878,6.36911547277771,6.57196206533664,6.77480865789556,6.97765525045449,7.18050184301342,7.38334843557234,7.58619502813127,7.7890416206902,7.99188821324912,8.19473480580805,8.39758139836698,8.6004279909259,8.80327458348483,9.00612117604376,9.20896776860268,9.41181436116161,9.61466095372054,9.81750754627946,10.0203541388384,10.2232007313973,10.4260473239562,10.6288939165152,10.8317405090741,11.034587101633,11.2374336941919,11.4402802867509,11.6431268793098,11.8459734718687,12.0488200644277,12.2516666569866,12.4545132495455,12.6573598421044,12.8602064346634,13.0630530272223,13.2658996197812,13.4687462123401,13.6715928048991,13.874439397458,14.0772859900169,14.2801325825758,14.4829791751348,14.6858257676937],"ploty":[1.19299731913036e-05,0.000154807116142951,0.000969771946774307,0.00320046214562409,0.00655124977075774,0.0112526442889898,0.0205860046532028,0.0371494797673795,0.0594942398452504,0.0801980340092052,0.0947603995977915,0.108441620970856,0.123583387976424,0.142376993239423,0.167105863308585,0.19746655988888,0.231307796786736,0.261951078286568,0.276040433659711,0.268609972765457,0.26849076593757,0.282262720656418,0.277745928223319,0.254976644201148,0.243042966787011,0.232816855134646,0.206853631444389,0.170482908585566,0.136876785854991,0.119837125647834,0.118593459261674,0.105909970754701,0.0793587130827088,0.0623100739154044,0.0534186140634861,0.045262046654892,0.0379053694886215,0.0308560163538543,0.0218803579572853,0.0128274203914391,0.00902537400935918,0.0106790677429971,0.0140986504507711,0.0154185860959582,0.0141268859099741,0.0107271007369002,0.00566666447377499,0.00173624276874602,0.000273181360127123,2.04415017293797e-05],"varnamesSumStat":"emplpopl","median":"8.991189","mean":"9.0659021264085","mode":"6.641","max":"14.029491","min":"5.4026775","invalid":25,"valid":6585,"sd":"1.47349068581842","uniques":5750,"herfindahl":0.000197060921112789,"freqmode":5,"fewest":"11.8631","mid":"11.8631","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"emplpopl","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"emplmtnest":{"plottype":"continuous","plotx":[-0.648633141160152,-0.529157712949534,-0.409682284738915,-0.290206856528297,-0.170731428317678,-0.0512560001070596,0.0682194281035589,0.187694856314177,0.307170284524796,0.426645712735414,0.546121140946033,0.665596569156651,0.78507199736727,0.904547425577888,1.02402285378851,1.14349828199913,1.26297371020974,1.38244913842036,1.50192456663098,1.6213999948416,1.74087542305222,1.86035085126284,1.97982627947345,2.09930170768407,2.21877713589469,2.33825256410531,2.45772799231593,2.57720342052655,2.69667884873716,2.81615427694778,2.9356297051584,3.05510513336902,3.17458056157964,3.29405598979026,3.41353141800088,3.53300684621149,3.65248227442211,3.77195770263273,3.89143313084335,4.01090855905397,4.13038398726459,4.2498594154752,4.36933484368582,4.48881027189644,4.60828570010706,4.72776112831768,4.8472365565283,4.96671198473892,5.08618741294953,5.20566284116015],"ploty":[0.00322417904545324,0.0145567113947425,0.0486001167655358,0.120223323447931,0.221137205617013,0.304635195034526,0.31934620008081,0.264498536110089,0.188713721755497,0.13530929350633,0.111118143244843,0.102705685027911,0.101740112823293,0.110489603826974,0.130047513984871,0.151148804503849,0.160380636435719,0.153641831814061,0.140764754269534,0.13622717752939,0.146204864941703,0.166077213689594,0.18921271035858,0.213498271521069,0.237170368737048,0.255108184062988,0.265253127417342,0.271790802084337,0.277193237979921,0.279249464017746,0.277382427755458,0.273001145221091,0.266140479750264,0.259280566987131,0.257633952632793,0.259541654667967,0.254850019058231,0.238260044290459,0.217040041961648,0.200554404336625,0.187268141316361,0.166452044509052,0.131307341027805,0.0876509347915759,0.0484115111801774,0.0219916064177596,0.0082087072204266,0.00250318760819085,0.000614632752419647,0.000119105598554613],"varnamesSumStat":"emplmtnest","median":"2.4248028","mean":"2.19375288740696","mode":"0","max":"4.5570297","min":"0","invalid":0,"valid":6610,"sd":"1.39532592168142","uniques":143,"herfindahl":0.0310692321952939,"freqmode":1004,"fewest":"3.21157","mid":"2.30259","freqfewest":"1","freqmid":"40","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"emplmtnest","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"empncontig":{"plottype":"bar","plotvalues":{"0":5447,"1":1163},"varnamesSumStat":"empncontig","median":"0","mean":"0.175945537065053","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.380802630140611","uniques":2,"herfindahl":0.710022589896114,"freqmode":5447,"fewest":"1","mid":"NA","freqfewest":"1163","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"empncontig","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"empolity2l":{"plottype":"continuous","plotx":[-13.494128869954,-12.9433480997518,-12.3925673295496,-11.8417865593474,-11.2910057891452,-10.740225018943,-10.1894442487408,-9.63866347853859,-9.08788270833638,-8.53710193813418,-7.98632116793197,-7.43554039772977,-6.88475962752756,-6.33397885732536,-5.78319808712315,-5.23241731692095,-4.68163654671874,-4.13085577651654,-3.58007500631433,-3.02929423611213,-2.47851346590992,-1.92773269570772,-1.37695192550551,-0.826171155303308,-0.275390385101105,0.275390385101101,0.826171155303307,1.37695192550551,1.92773269570772,2.47851346590992,3.02929423611213,3.58007500631433,4.13085577651654,4.68163654671874,5.23241731692095,5.78319808712315,6.33397885732536,6.88475962752756,7.43554039772977,7.98632116793197,8.53710193813418,9.08788270833638,9.63866347853859,10.1894442487408,10.740225018943,11.2910057891452,11.8417865593474,12.3925673295496,12.9433480997518,13.494128869954],"ploty":[0.00014634370468922,0.000580767006222805,0.00189504456618004,0.00514117016282609,0.0116789328407813,0.0224595915396321,0.0371342934365779,0.0539481774462644,0.0709142448732319,0.0869075689200218,0.100607535649051,0.108535754886888,0.106239560760771,0.0927701040413482,0.0728160659051658,0.0534554197509013,0.0392828668314942,0.0308437918959869,0.0263904054819771,0.0239701153428584,0.022440299450171,0.0214855656296301,0.0210474785010781,0.0208060755877677,0.0202247621426276,0.0190341603158954,0.0174941527828451,0.0161432586501008,0.0154114102787,0.0155286508647872,0.0165909277155029,0.0184613279786411,0.0206994139697958,0.0228454080536319,0.0248257228040373,0.0270381379705472,0.0300876726129389,0.0345185469245581,0.0408552004851138,0.0496561075368415,0.0607112378614373,0.0713474526133717,0.0761632210286431,0.0703631897151172,0.0544521533958594,0.0346400911121726,0.0179080446076038,0.00747576297039516,0.00251600247629425,0.000679693359933159],"varnamesSumStat":"empolity2l","median":"-4","mean":"-0.678644246717378","mode":"-7","max":"10","min":"-10","invalid":234,"valid":6376,"sd":"7.46250810884598","uniques":135,"herfindahl":0.100637004907046,"freqmode":1335,"fewest":"7.68712","mid":"7.68712","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"empolity2l","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"sdwars":{"plottype":"bar","plotvalues":{"0":5779,"1":775,"2":47,"3":9},"varnamesSumStat":"sdwars","median":"0","mean":"0.135552193645991","mode":"0","max":"3","min":"0","invalid":0,"valid":6610,"sd":"0.373616423663424","uniques":4,"herfindahl":0.778167128611351,"freqmode":5779,"fewest":"3","mid":"NA","freqfewest":"9","freqmid":"411","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"sdwars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"sdonset":{"plottype":"bar","plotvalues":{"0":6488,"1":120,"2":2},"varnamesSumStat":"sdonset","median":"0","mean":"0.0187594553706505","mode":"0","max":"2","min":"0","invalid":0,"valid":6610,"sd":"0.137896913355496","uniques":3,"herfindahl":0.963756560110409,"freqmode":6488,"fewest":"2","mid":"1","freqfewest":"2","freqmid":"120","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"sdonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"colwars":{"plottype":"bar","plotvalues":{"0":4888,"1":533,"2":15},"varnamesSumStat":"colwars","median":"0","mean":"0.103568800588668","mode":"0","max":"2","min":"0","invalid":1174,"valid":5436,"sd":"0.313654532316676","uniques":3,"herfindahl":0.818165125419559,"freqmode":4888,"fewest":"2","mid":"1","freqfewest":"15","freqmid":"533","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"colwars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"colonset":{"plottype":"bar","plotvalues":{"0":5360,"1":76},"varnamesSumStat":"colonset","median":"0","mean":"0.013980868285504","mode":"0","max":"1","min":"0","invalid":1174,"valid":5436,"sd":"0.11742205934276","uniques":2,"herfindahl":0.972429192785025,"freqmode":5360,"fewest":"1","mid":"NA","freqfewest":"76","freqmid":"2718","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"cowwars":{"plottype":"bar","plotvalues":{"0":5073,"1":412,"2":27,"3":6},"varnamesSumStat":"cowwars","median":"0","mean":"0.0877129394708228","mode":"0","max":"3","min":"0","invalid":1092,"valid":5518,"sd":"0.310398288607461","uniques":4,"herfindahl":0.850813266437916,"freqmode":5073,"fewest":"3","mid":"NA","freqfewest":"6","freqmid":"219.5","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"cowwars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"cowonset":{"plottype":"bar","plotvalues":{"0":5426,"1":91,"2":1},"varnamesSumStat":"cowonset","median":"0","mean":"0.0168539325842697","mode":"0","max":"2","min":"0","invalid":1092,"valid":5518,"sd":"0.130136070412808","uniques":3,"herfindahl":0.967204566005012,"freqmode":5426,"fewest":"2","mid":"1","freqfewest":"1","freqmid":"91","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"cowonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"cowwarl":{"plottype":"bar","plotvalues":{"0":5229,"1":445},"varnamesSumStat":"cowwarl","median":"0","mean":"0.0784279168135354","mode":"0","max":"1","min":"0","invalid":936,"valid":5674,"sd":"0.268867475160833","uniques":2,"herfindahl":0.855446042644351,"freqmode":5229,"fewest":"1","mid":"NA","freqfewest":"445","freqmid":"2837","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"cowwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"sdwarl":{"plottype":"bar","plotvalues":{"0":5789,"1":821},"varnamesSumStat":"sdwarl","median":"0","mean":"0.124205748865356","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.329841082929536","uniques":2,"herfindahl":0.782442638371696,"freqmode":5789,"fewest":"1","mid":"NA","freqfewest":"821","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"sdwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"colwarl":{"plottype":"bar","plotvalues":{"0":4902,"1":534},"varnamesSumStat":"colwarl","median":"0","mean":"0.098233995584989","mode":"0","max":"1","min":"0","invalid":1174,"valid":5436,"sd":"0.297658153785077","uniques":2,"herfindahl":0.822831844607205,"freqmode":4902,"fewest":"1","mid":"NA","freqfewest":"534","freqmid":"2718","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"}} +{"ccode":{"plottype":"continuous","plotx":[-113.352184018798,-89.2969928343577,-65.2418016499169,-41.1866104654762,-17.1314192810354,6.92377190340532,30.9789630878461,55.0341542722868,79.0893454567276,103.144536641168,127.199727825609,151.25491901005,175.310110194491,199.365301378931,223.420492563372,247.475683747813,271.530874932254,295.586066116694,319.641257301135,343.696448485576,367.751639670017,391.806830854457,415.862022038898,439.917213223339,463.97240440778,488.02759559222,512.082786776661,536.137977961102,560.193169145543,584.248360329983,608.303551514424,632.358742698865,656.413933883306,680.469125067746,704.524316252187,728.579507436628,752.634698621069,776.689889805509,800.74508098995,824.800272174391,848.855463358832,872.910654543272,896.965845727713,921.021036912154,945.076228096595,969.131419281035,993.186610465476,1017.24180164992,1041.29699283436,1065.3521840188],"ploty":[1.28948763455544e-06,7.77346821359187e-06,3.36131633687972e-05,0.000106529424448849,0.0002554277889438,0.000481526131769224,0.000747949862147683,0.00100604227721003,0.00120376316558131,0.00128391859229442,0.00123500690724131,0.00111734285183577,0.0010150456932042,0.000960670328308937,0.000904629949134055,0.000817500670741316,0.000778234671998686,0.000876908136227006,0.00108869455161458,0.00128399336325335,0.00134909216770709,0.00131659244673784,0.00131202885481215,0.00136170234679394,0.00138022472097999,0.00132732066908842,0.00123836777253931,0.00114903330098791,0.00107690155257646,0.00105677319532716,0.00113082382043057,0.00127863595576224,0.00140743390776556,0.00143773383466028,0.00136053534439603,0.00122955928071625,0.00111869338642414,0.00105239852206042,0.000975891422838848,0.000823791970169336,0.000613773790886401,0.00043423005130618,0.000333155817938031,0.000269408806290706,0.000193552761148369,0.000110296640317649,4.78653484760454e-05,1.55029072201053e-05,3.66725820980367e-06,6.21798951614823e-07],"varnamesSumStat":"ccode","median":"451","mean":"450.62223903177","mode":"2","max":"950","min":"2","invalid":0,"valid":6610,"sd":"248.143183365732","uniques":161,"herfindahl":0.00716156925393835,"freqmode":55,"fewest":"316","mid":"600","freqfewest":"7","freqmid":"44","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"ccode","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"country":{"plottype":"bar","plotvalues":{"AFGHANISTAN":55,"ALBANIA":55,"ALGERIA":38,"ANGOLA":25,"ARGENTINA":55,"ARMENIA":9,"AUSTRALIA":55,"AUSTRIA":55,"AZERBAIJAN":9,"BAHRAIN":29,"BANGLADESH":28,"BELARUS":9,"BELGIUM":55,"BENIN":40,"BHUTAN":29,"BOLIVIA":55,"BOSNIA":8,"BOTSWANA":34,"BRAZIL":55,"BULGARIA":55,"BURKINA FASO":40,"BURMA":52,"BURUNDI":38,"CAMBODIA":47,"CAMEROON":40,"CANADA":55,"CENTRAL AFRICAN REP.":40,"CHAD":40,"CHILE":55,"CHINA":55,"COLOMBIA":55,"CONGO":40,"COSTARICA":55,"CROATIA":8,"CUBA":55,"CYPRUS":40,"CZECHOSLOVAKIA":48,"CZECHREP":7,"DEM. REP. CONGO":40,"DENMARK":55,"DJIBOUTI":23,"DOMINICAN REP.":55,"ECUADOR":55,"EGYPT":55,"EL SALVADOR":55,"ERITREA":7,"ESTONIA":9,"ETHIOPIA":55,"FIJI":30,"FINLAND":55,"FRANCE":55,"GABON":40,"GAMBIA":35,"GEORGIA":9,"GERMAN DEM. REP.":42,"GERMANYFED. REP.":55,"GHANA":43,"GREECE":55,"GUATEMALA":55,"GUINEA":42,"GUINEA BISSAU":26,"GUYANA":34,"HAITI":55,"HONDURAS":55,"HUNGARY":55,"INDIA":53,"INDONESIA":51,"IRAN":55,"IRAQ":55,"IRELAND":55,"ISRAEL":52,"ITALY":55,"IVORY COAST":40,"JAMAICA":38,"JAPAN":55,"JORDAN":54,"KAZAKHSTAN":9,"KENYA":37,"KOREA, S.":51,"KUWAIT":39,"KYRGYZSTAN":9,"LAOS":47,"LATVIA":9,"LEBANON":54,"LESOTHO":34,"LIBERIA":55,"LIBYA":49,"LITHUANIA":9,"MACEDONIA":7,"MADAGASCAR":40,"MALAWI":36,"MALAYSIA":43,"MALI":40,"MAURITANIA":40,"MAURITIUS":32,"MEXICO":55,"MOLDOVA":9,"MONGOLIA":55,"MOROCCO":44,"MOZAMBIQUE":25,"N. KOREA":52,"NAMIBIA":10,"NEPAL":55,"NETHERLANDS":55,"NEW ZEALAND":55,"NICARAGUA":55,"NIGER":40,"NIGERIA":40,"NORWAY":55,"OMAN":29,"PAKISTAN":53,"PANAMA":55,"PAPUA N.G.":25,"PARAGUAY":55,"PERU":55,"PHILIPPINES":54,"POLAND":55,"PORTUGAL":55,"ROMANIA":55,"RUSSIA":55,"RWANDA":38,"SAUDI ARABIA":55,"SENEGAL":40,"SIERRA LEONE":39,"SINGAPORE":35,"SLOVAKIA":7,"SLOVENIA":8,"SOMALIA":40,"SOUTH AFRICA":55,"SPAIN":55,"SRI LANKA":52,"SUDAN":44,"SWAZILAND":32,"SWEDEN":55,"SWITZERLAND":55,"SYRIA":54,"TAIWAN":51,"TAJIKISTAN":9,"TANZANIA":39,"THAILAND":55,"TOGO":40,"TRINIDAD & TOBAGO":38,"TUNISIA":44,"TURKEY":55,"TURKMENISTAN":9,"U. ARAB EMIRATES":29,"UGANDA":38,"UK":55,"UKRAINE":9,"URUGUAY":55,"USA":55,"UZBEKISTAN":9,"VENEZUELA":55,"VIETNAM":46,"VIETNAM, S.":22,"YEMEN":10,"YEMEN ARAB REP.":46,"YEMEN PEOP. REP.":24,"YUGOSLAVIA":55,"ZAMBIA":36,"ZIMBABWE":35},"varnamesSumStat":"country","median":"NA","mean":"NA","mode":"USA","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":161,"herfindahl":0.00716156925393835,"freqmode":55,"fewest":"CZECHREP","mid":"MOROCCO","freqfewest":"7","freqmid":"44","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"country","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"cname":{"plottype":"bar","plotvalues":{"AFGHANIS":55,"ALBANIA":55,"ALGERIA":38,"ANGOLA":25,"ARGENTIN":55,"ARMENIA":9,"AUSTRALI":55,"AUSTRIA":55,"AZERBAIJ":9,"BAHRAIN":29,"BANGLADE":28,"BELARUS":9,"BELGIUM":55,"BENIN":40,"BHUTAN":29,"BOLIVIA":55,"BOSNIA":8,"BOTSWANA":34,"BRAZIL":55,"BULGARIA":55,"BURKINA ":40,"BURMA":52,"BURUNDI":38,"CAMBODIA":47,"CAMEROON":40,"CANADA":55,"CENTRAL ":40,"CHAD":40,"CHILE":55,"CHINA":55,"COLOMBIA":55,"CONGO":40,"COSTARIC":55,"CROATIA":8,"CUBA":55,"CYPRUS":40,"CZECHOSL":48,"CZECHREP":7,"DEM. REP":40,"DENMARK":55,"DJIBOUTI":23,"DOMINICA":55,"ECUADOR":55,"EGYPT":55,"EL SALVA":55,"ERITREA":7,"ESTONIA":9,"ETHIOPIA":55,"FIJI":30,"FINLAND":55,"FRANCE":55,"GABON":40,"GAMBIA":35,"GEORGIA":9,"GERMAN D":42,"GERMANYF":55,"GHANA":43,"GREECE":55,"GUATEMAL":55,"GUINEA":42,"GUINEA B":26,"GUYANA":34,"HAITI":55,"HONDURAS":55,"HUNGARY":55,"INDIA":53,"INDONESI":51,"IRAN":55,"IRAQ":55,"IRELAND":55,"ISRAEL":52,"ITALY":55,"IVORY CO":40,"JAMAICA":38,"JAPAN":55,"JORDAN":54,"KAZAKHST":9,"KENYA":37,"KOREA, S":51,"KUWAIT":39,"KYRGYZST":9,"LAOS":47,"LATVIA":9,"LEBANON":54,"LESOTHO":34,"LIBERIA":55,"LIBYA":49,"LITHUANI":9,"MACEDONI":7,"MADAGASC":40,"MALAWI":36,"MALAYSIA":43,"MALI":40,"MAURITAN":40,"MAURITIU":32,"MEXICO":55,"MOLDOVA":9,"MONGOLIA":55,"MOROCCO":44,"MOZAMBIQ":25,"N. KOREA":52,"NAMIBIA":10,"NEPAL":55,"NETHERLA":55,"NEW ZEAL":55,"NICARAGU":55,"NIGER":40,"NIGERIA":40,"NORWAY":55,"OMAN":29,"PAKISTAN":53,"PANAMA":55,"PAPUA N.":25,"PARAGUAY":55,"PERU":55,"PHILIPPI":54,"POLAND":55,"PORTUGAL":55,"ROMANIA":55,"RUSSIA":55,"RWANDA":38,"SAUDI AR":55,"SENEGAL":40,"SIERRA L":39,"SINGAPOR":35,"SLOVAKIA":7,"SLOVENIA":8,"SOMALIA":40,"SOUTH AF":55,"SPAIN":55,"SRI LANK":52,"SUDAN":44,"SWAZILAN":32,"SWEDEN":55,"SWITZERL":55,"SYRIA":54,"TAIWAN":51,"TAJIKIST":9,"TANZANIA":39,"THAILAND":55,"TOGO":40,"TRINIDAD":38,"TUNISIA":44,"TURKEY":55,"TURKMENI":9,"U. ARAB ":29,"UGANDA":38,"UK":55,"UKRAINE":9,"URUGUAY":55,"USA":55,"UZBEKIST":9,"VENEZUEL":55,"VIETNAM":46,"VIETNAM,":22,"YEMEN":10,"YEMEN AR":46,"YEMEN PE":24,"YUGOSLAV":55,"ZAMBIA":36,"ZIMBABWE":35},"varnamesSumStat":"cname","median":"NA","mean":"NA","mode":"USA","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":161,"herfindahl":0.00716156925393835,"freqmode":55,"fewest":"CZECHREP","mid":"MOROCCO","freqfewest":"7","freqmid":"44","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"cname","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"cmark":{"plottype":"bar","plotvalues":{"0":6449,"1":161},"varnamesSumStat":"cmark","median":"0","mean":"0.024357034795764","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.154166680316136","uniques":2,"herfindahl":0.952472460696556,"freqmode":6449,"fewest":"1","mid":"NA","freqfewest":"161","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"cmark","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"year":{"plottype":"continuous","plotx":[1937.99231500584,1939.38038378111,1940.76845255638,1942.15652133166,1943.54459010693,1944.9326588822,1946.32072765747,1947.70879643274,1949.09686520801,1950.48493398329,1951.87300275856,1953.26107153383,1954.6491403091,1956.03720908437,1957.42527785965,1958.81334663492,1960.20141541019,1961.58948418546,1962.97755296073,1964.365621736,1965.75369051128,1967.14175928655,1968.52982806182,1969.91789683709,1971.30596561236,1972.69403438764,1974.08210316291,1975.47017193818,1976.85824071345,1978.24630948872,1979.634378264,1981.02244703927,1982.41051581454,1983.79858458981,1985.18665336508,1986.57472214035,1987.96279091563,1989.3508596909,1990.73892846617,1992.12699724144,1993.51506601671,1994.90313479199,1996.29120356726,1997.67927234253,1999.0673411178,2000.45540989307,2001.84347866834,2003.23154744362,2004.61961621889,2006.00768499416],"ploty":[2.4615494919606e-05,0.000134312419250629,0.000532160103209718,0.0015561495211806,0.00343564267787795,0.00591527966326217,0.0083012797227244,0.0100305654253793,0.0110401975404856,0.011583235906882,0.0119228401466712,0.0122198391554691,0.0125572713651366,0.0129989737154941,0.0136239016520534,0.0144814114923857,0.0155007352768974,0.0165007331486998,0.0173332801876797,0.0179757346415986,0.0184770130124159,0.018882871139569,0.0192279076640635,0.0195434282825182,0.0198420784926995,0.0201141667865439,0.0203450224392878,0.0205230192271391,0.0206409831332737,0.0207041721871288,0.0207303776864925,0.0207390854222137,0.0207434578085856,0.0207519813477241,0.020779586807111,0.0208677786779391,0.0210939754684569,0.0215250693196225,0.0221252773942338,0.0227265845000946,0.0230940701364217,0.0229100995944009,0.0216094123753058,0.0185002264930784,0.0135550973442489,0.00803969984552511,0.00369694355260443,0.00127792615498628,0.000325037488374505,5.99060394929591e-05],"varnamesSumStat":"year","median":"1977","mean":"1975.54780635401","mode":"1993","max":"1999","min":"1945","invalid":0,"valid":6610,"sd":"15.0747840386954","uniques":55,"herfindahl":0.0191868095147635,"freqmode":156,"fewest":"1945","mid":"1972","freqfewest":"63","freqmid":"133","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"year","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"wars":{"plottype":"bar","plotvalues":{"0":5692,"1":829,"2":72,"3":15,"4":2},"varnamesSumStat":"wars","median":"0","mean":"0.155219364599092","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.412533428847871","uniques":5,"herfindahl":0.757379892474841,"freqmode":5692,"fewest":"4","mid":"2","freqfewest":"2","freqmid":"72","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"wars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"war":{"plottype":"bar","plotvalues":{"0":5692,"1":918},"varnamesSumStat":"war","median":"0","mean":"0.138880484114977","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.345847929987619","uniques":2,"herfindahl":0.760814609506066,"freqmode":5692,"fewest":"1","mid":"NA","freqfewest":"918","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"war","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"warl":{"plottype":"bar","plotvalues":{"0":5720,"1":890},"varnamesSumStat":"warl","median":"0","mean":"0.13464447806354","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.341369261049802","uniques":2,"herfindahl":0.766969314818926,"freqmode":5720,"fewest":"1","mid":"NA","freqfewest":"890","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"warl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"onset":{"plottype":"bar","plotvalues":{"0":6499,"1":110,"4":1},"varnamesSumStat":"onset","median":"0","mean":"0.0172465960665658","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.136994238573717","uniques":3,"herfindahl":0.966973480331685,"freqmode":6499,"fewest":"4","mid":"1","freqfewest":"1","freqmid":"110","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"onset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"ethonset":{"plottype":"bar","plotvalues":{"0":6535,"1":74,"4":1},"varnamesSumStat":"ethonset","median":"0","mean":"0.0118003025718608","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.116097052965513","uniques":3,"herfindahl":0.977561206717004,"freqmode":6535,"fewest":"4","mid":"1","freqfewest":"1","freqmid":"74","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"ethonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"durest":{"plottype":"continuous","plotx":[-7.64145863086174,-6.24792970715309,-4.85440078344445,-3.46087185973581,-2.06734293602717,-0.673814012318526,0.719714911390117,2.11324383509876,3.5067727588074,4.90030168251604,6.29383060622468,7.68735952993333,9.08088845364197,10.4744173773506,11.8679463010593,13.2614752247679,14.6550041484765,16.0485330721852,17.4420619958938,18.8355909196025,20.2291198433111,21.6226487670197,23.0161776907284,24.409706614437,25.8032355381457,27.1967644618543,28.590293385563,29.9838223092716,31.3773512329802,32.7708801566889,34.1644090803975,35.5579380041062,36.9514669278148,38.3449958515235,39.7385247752321,41.1320536989407,42.5255826226494,43.919111546358,45.3126404700667,46.7061693937753,48.0996983174839,49.4932272411926,50.8867561649012,52.2802850886099,53.6738140123185,55.0673429360272,56.4608718597358,57.8544007834444,59.2479297071531,60.6414586308617],"ploty":[0.000359856431758564,0.00142743141534836,0.00453476208180597,0.0116020530772251,0.0239883430601341,0.0404174102561498,0.0562507752516278,0.0660030764935081,0.0672747447646726,0.0620232797655893,0.0539656203816805,0.0457282931588073,0.0383668347602499,0.0323739621639462,0.0281210744921442,0.0253780395468113,0.0230727435452966,0.0200636033069731,0.0161704073578408,0.0122435536349433,0.00923387884618484,0.00741693896994567,0.00640885122880311,0.00567737466940853,0.0049776739300711,0.00441279027467066,0.00418389859871628,0.00434317246009446,0.00475110483170572,0.00515449066517661,0.00526200483337976,0.00484607880941219,0.00389716192434194,0.00267609061274038,0.00155830536698036,0.000808447995759434,0.000499698222903328,0.00057522134925087,0.000917010216188562,0.00136423807564292,0.00174697825003353,0.00194574729481813,0.0019136490805756,0.00165594375922656,0.00123410841783453,0.000770711514277606,0.000394181909815744,0.000162654971594967,5.37765663030252e-05,1.4154436577632e-05],"varnamesSumStat":"durest","median":"6","mean":"9.18018018018018","mode":"1","max":"52","min":"1","invalid":6499,"valid":111,"sd":"10.095181747383","uniques":28,"herfindahl":0.076860644428212,"freqmode":20,"fewest":"29","mid":"35","freqfewest":"1","freqmid":"2","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"durest","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"aim":{"plottype":"bar","plotvalues":{"1":61,"2":14,"3":35},"varnamesSumStat":"aim","median":"1","mean":"1.76363636363636","mode":"1","max":"3","min":"1","invalid":6500,"valid":110,"sd":"0.907939220445594","uniques":3,"herfindahl":0.42495867768595,"freqmode":61,"fewest":"2","mid":"3","freqfewest":"14","freqmid":"35","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"aim","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"casename":{"plottype":"bar","plotvalues":{"":6499,"?":1,"Abkhazia":1,"AFDL (Kabila)":1,"ALF, ARDUF (Afars)":1,"ANC, PAC, Azapo":1,"Anya Nya":1,"Baluchistan":1,"Bangladesh":1,"Biafra":1,"BRA (Bougainville)":1,"Castro":1,"Chechnya":1,"Chechnya II":1,"Chittagong Hills/Shanti Bahini":1,"Contras":1,"CPB, Karens, etc.":1,"CPN-M/UPF (Maoists)":1,"Croatia/Krajina":1,"Cypriots, Turkey":1,"Darul Islam":1,"Darul Islam, PRRI, Permesta":1,"Dniestr Rep.":1,"DSE":1,"E. Timor":1,"Eritrea, Tigray, etc.":1,"ERP/Montoneros":1,"Faction of Socialist Party":1,"Factional fighting":2,"FARC, ELN, etc":1,"Febreristas, Libs, Comms":1,"Fedeyeen/Syria v. govt":1,"FIS":1,"FLEC (Cabinda)":1,"FLNC":1,"FMLN":1,"FROLINAT, various ...":1,"FRUD":1,"FSLN":1,"FUNK":1,"GAM (Aceh)":1,"Huks":1,"Hutu groups v. govt":1,"Hutu uprising":1,"IRA":1,"JVP":1,"JVP II":1,"Kabylie":1,"Kashmir":1,"Katanga, Kasai, CNL":1,"KDP, PUK (Kurds)":1,"KDPI (Kurds)":1,"Khmer Rouge, FUNCINPEC, etc":1,"Khomeini":1,"Krajina":1,"La Violencia":1,"LRA, West Nile, etc.":1,"LTTE, etc.":1,"MFDC (Casamance)":1,"Mil. coup":3,"Mil. faction":1,"Militia-ized party politics":1,"MNLF, MILF":1,"MNR":1,"MQM:Sindhis v. Mohajirs":1,"Mujahideen":1,"N.East rebels":1,"Nagorno-Karabagh":1,"Nasserites v. Chamoun":1,"Ndebele guer's":1,"NLA":1,"NLF":1,"NPA":1,"NPFL (Taylor), INPFL (Johnson)":1,"NRA, etc.":1,"OPM (West Papua)":1,"Opp. coalition":1,"Org. massacres on both sides":1,"Pathet Lao":1,"PKK":1,"PLA":1,"Polisario":1,"post-Barre war":1,"Post-rev strife":1,"RCD, etc v. govt":1,"RENAMO":1,"Rep. S. Moluccas":1,"Rep. Srpska/Croats":1,"Royalists":1,"RPF, genocide":1,"RUF, AFRC, etc.":1,"Sendero Luminoso":1,"Shammar":1,"Sikhs":1,"South Yemen":1,"SPLA, etc.":1,"SSDF, SNM (Isaaqs)":1,"Tibet":2,"Tuaregs":1,"Ukraine/UPA":1,"UNITA":1,"URNG, various":1,"UTO":1,"v. Rhee":1,"v. Taliban":1,"various militias":1,"Xinjiang":1,"ZANU, ZAPU":1},"varnamesSumStat":"casename","median":"NA","mean":"NA","mode":"Mil. coup","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":107,"herfindahl":0.00982063144225306,"freqmode":3,"fewest":"Castro","mid":"Castro","freqfewest":"1","freqmid":"1","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"casename","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"ended":{"plottype":"bar","plotvalues":{"0":25,"1":86},"varnamesSumStat":"ended","median":"1","mean":"0.774774774774775","mode":"1","max":"1","min":"0","invalid":6499,"valid":111,"sd":"0.419625042252218","uniques":2,"herfindahl":0.651002353705056,"freqmode":86,"fewest":"0","mid":"NA","freqfewest":"25","freqmid":"55.5","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"ended","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ethwar":{"plottype":"bar","plotvalues":{"0":36,"1":20,"2":55},"varnamesSumStat":"ethwar","median":"1","mean":"1.17117117117117","mode":"2","max":"2","min":"0","invalid":6499,"valid":111,"sd":"0.893144331956934","uniques":3,"herfindahl":0.383166950734518,"freqmode":55,"fewest":"1","mid":"0","freqfewest":"20","freqmid":"36","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"ethwar","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"waryrs":{"plottype":"bar","plotvalues":{"":6499,"1945-49":1,"1946-50":2,"1946-52":1,"1947-47":1,"1948- ":1,"1948-48":2,"1948-62":1,"1949-50":1,"1950-50":1,"1950-51":1,"1952- ":1,"1952-52":1,"1953-53":1,"1955-55":1,"1956-59":1,"1958-58":1,"1958-59":1,"1958-60":1,"1959-59":1,"1960-65":1,"1960-73":1,"1960-75":1,"1961-74":1,"1962-63":1,"1962-65":1,"1962-69":1,"1963- ":1,"1963-72":1,"1965- ":2,"1965-65":1,"1967-70":1,"1968- ":1,"1968-96":1,"1969-99":1,"1970-70":1,"1970-75":1,"1971-71":2,"1972-72":1,"1972-79":1,"1972-94":1,"1973-77":2,"1974-74":1,"1974-92":1,"1975- ":1,"1975-88":1,"1975-90":1,"1975-99":1,"1976-95":1,"1976-97":1,"1977-78":1,"1977-80":1,"1978-79":2,"1978-92":2,"1979-92":1,"1979-93":1,"1981-87":1,"1981-88":1,"1981-91":1,"1981-95":1,"1982-93":1,"1983- ":2,"1983-87":1,"1983-94":1,"1984-99":1,"1986-87":1,"1987-89":1,"1988-88":1,"1988-98":1,"1989- ":2,"1989-94":1,"1989-96":1,"1990- ":1,"1991- ":4,"1991-91":1,"1991-95":1,"1992- ":3,"1992-92":1,"1992-94":2,"1992-95":2,"1992-97":1,"1993- ":2,"1993-94":1,"1993-99":1,"1994-94":1,"1994-96":1,"1994-98":1,"1996-97":2,"1997- ":2,"1998- ":1,"1998-99":2,"1999- ":1},"varnamesSumStat":"waryrs","median":"NA","mean":"NA","mode":"1991- ","max":"NA","min":"NA","invalid":0,"valid":6610,"sd":"NA","uniques":91,"herfindahl":0.0129047966885805,"freqmode":4,"fewest":"1958-59","mid":"1958-59","freqfewest":"1","freqmid":"1","numchar":"character","nature":"nominal","binary":"no","interval":"discrete","varnamesTypes":"waryrs","defaultInterval":"discrete","defaultNumchar":"character","defaultNature":"nominal","defaultBinary":"no"},"pop":{"plottype":"continuous","plotx":[-5841.53611798006,19678.9633154069,45199.4627487938,70719.9621821807,96240.4616155677,121760.961048955,147281.460482342,172801.959915729,198322.459349115,223842.958782502,249363.458215889,274883.957649276,300404.457082663,325924.95651605,351445.455949437,376965.955382824,402486.454816211,428006.954249598,453527.453682985,479047.953116372,504568.452549759,530088.951983146,555609.451416533,581129.950849919,606650.450283306,632170.949716693,657691.44915008,683211.948583467,708732.448016854,734252.947450241,759773.446883628,785293.946317015,810814.445750402,836334.945183789,861855.444617176,887375.944050563,912896.44348395,938416.942917337,963937.442350724,989457.941784111,1014978.4412175,1040498.94065088,1066019.44008427,1091539.93951766,1117060.43895105,1142580.93838443,1168101.43781782,1193621.93725121,1219142.43668459,1244662.93611798],"ploty":[6.53549026373353e-07,1.22589166813707e-05,2.20446863315443e-06,6.45081571122456e-07,5.5371613859585e-07,6.14978868823323e-07,3.83824962532738e-07,1.74197066149676e-07,1.68762299157126e-07,1.1145944706913e-07,1.4017780308438e-07,6.80399637095414e-08,2.3721896406493e-14,8.73869574293408e-22,3.46170608149145e-08,2.48800442357399e-08,1.17278008093651e-08,1.4844316007773e-08,2.367916761624e-08,1.2398547656904e-08,2.81225684540388e-09,5.0874589792783e-09,3.7357101852572e-08,3.3152708602396e-08,8.90695417688232e-09,1.22739888570981e-08,5.4422825158724e-08,3.10090596269383e-08,2.48583863339823e-09,4.86516213587357e-08,3.84638792075386e-09,9.75963257800802e-09,4.87364574019001e-09,1.01520165952959e-08,2.79509692096553e-08,1.32088724934111e-08,3.56613060303228e-08,3.61807292295146e-09,2.50823437653522e-08,5.9896349272898e-09,8.16203542487203e-10,8.62565887131091e-09,2.51678613674441e-08,8.02879599964503e-11,1.95672771152759e-08,5.78064464398109e-10,1.50023840950814e-09,1.34695710969777e-08,8.4926349485328e-09,1.73714393711047e-09],"varnamesSumStat":"pop","median":"8137","mean":"31786.9182555417","mode":"766","max":"1238599.4","min":"222","invalid":177,"valid":6433,"sd":"102560.817464774","uniques":5744,"herfindahl":0.000193241319019767,"freqmode":5,"fewest":"140969","mid":"140969","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"pop","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"lpop":{"plottype":"continuous","plotx":[4.75499424840934,4.95748771786202,5.1599811873147,5.36247465676738,5.56496812622006,5.76746159567274,5.96995506512542,6.1724485345781,6.37494200403078,6.57743547348346,6.77992894293614,6.98242241238882,7.1849158818415,7.38740935129418,7.58990282074686,7.79239629019954,7.99488975965222,8.1973832291049,8.39987669855758,8.60237016801026,8.80486363746294,9.00735710691562,9.2098505763683,9.41234404582098,9.61483751527366,9.81733098472634,10.019824454179,10.2223179236317,10.4248113930844,10.6273048625371,10.8297983319897,11.0322918014424,11.2347852708951,11.4372787403478,11.6397722098005,11.8422656792531,12.0447591487058,12.2472526181585,12.4497460876112,12.6522395570639,12.8547330265165,13.0572264959692,13.2597199654219,13.4622134348746,13.6647069043273,13.8672003737799,14.0696938432326,14.2721873126853,14.474680782138,14.6771742515907],"ploty":[8.44004323666611e-06,0.000117350501101024,0.000773879604704037,0.00267476559240506,0.00577776543745082,0.0104938496441943,0.0198830526433037,0.0362631028427677,0.0583354205690329,0.0790272582054362,0.0938040305380795,0.107766145621065,0.12299789322428,0.141968230790061,0.167211702534847,0.197345046777753,0.229854160811883,0.26000629139273,0.275052169186251,0.269487887315931,0.275463517863244,0.297432534674987,0.291043953817482,0.259806926541828,0.244284095519169,0.232466619344363,0.201469292675213,0.161311504575729,0.133814137926397,0.127038229753059,0.129084013316596,0.11047002919774,0.0772096343730981,0.0583659660547757,0.0495127880389617,0.0403646927702503,0.0327716420910693,0.0279072012066265,0.0212491951099039,0.0127452667686758,0.00876160983454511,0.0101333102712563,0.0133003710435286,0.0149291371179561,0.0142351940974085,0.0111235153857295,0.00597211628277935,0.0018441689544589,0.000287845903308384,2.08764233035242e-05],"varnamesSumStat":"lpop","median":"9.004177","mean":"9.06276189945593","mode":"6.641","max":"14.029491","min":"5.4026775","invalid":177,"valid":6433,"sd":"1.45479327068009","uniques":5744,"herfindahl":0.000193241319019767,"freqmode":5,"fewest":"11.8563","mid":"11.8563","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lpop","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"polity2":{"plottype":"continuous","plotx":[-13.5047593991578,-12.9535447298044,-12.4023300604511,-11.8511153910977,-11.2999007217443,-10.7486860523909,-10.1974713830375,-9.64625671368416,-9.09504204433078,-8.5438273749774,-7.99261270562402,-7.44139803627064,-6.89018336691726,-6.33896869756388,-5.7877540282105,-5.23653935885712,-4.68532468950374,-4.13411002015035,-3.58289535079697,-3.03168068144359,-2.48046601209021,-1.92925134273683,-1.37803667338345,-0.826822004030072,-0.275607334676691,0.275607334676691,0.82682200403007,1.37803667338345,1.92925134273683,2.48046601209021,3.03168068144359,3.58289535079697,4.13411002015035,4.68532468950374,5.23653935885712,5.78775402821049,6.33896869756388,6.89018336691726,7.44139803627064,7.99261270562402,8.5438273749774,9.09504204433078,9.64625671368416,10.1974713830375,10.7486860523909,11.2999007217443,11.8511153910977,12.4023300604511,12.9535447298044,13.5047593991578],"ploty":[0.000133336466229905,0.000529236052757236,0.00173213625984351,0.00472407404149915,0.0108401241571101,0.0211063799974061,0.0353615815694273,0.05199870813438,0.0689703434585355,0.084939936084736,0.0985030257460344,0.106352333637232,0.104196408550788,0.0910114950115064,0.0712115335921763,0.0517246829508084,0.0373101181082504,0.0287984594897801,0.0245931095884593,0.0226722621916625,0.0217005874084044,0.0211848044948443,0.0209876662294835,0.0208138682912195,0.0202000282595024,0.0189284069526459,0.0172720705490821,0.0157888500924283,0.0149654879370071,0.0150908328896952,0.0162746582499011,0.018361757954345,0.0208975510869133,0.0234038897243911,0.0257430528660836,0.0282131078270718,0.0313620691418716,0.0358070538206141,0.0422790115253027,0.0515663985725993,0.0634934721869158,0.0751024885945271,0.0804875508864962,0.0744676695294445,0.0576571036472443,0.0366822412015105,0.018965423087333,0.0079289822401883,0.00267183441492309,0.000722890019738561],"varnamesSumStat":"polity2","median":"-3","mean":"-0.413013594012525", "meanCI": {"lowerBound": "-1.2", "upperBound": "0.4"}, "mode":"-7","max":"10","min":"-10","invalid":63,"valid":6547,"sd":"7.5249377770853","uniques":21,"herfindahl":0.10433514205621,"freqmode":1346,"fewest":"3","mid":"-3","freqfewest":"58","freqmid":"181","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"polity2","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"gdpen":{"plottype":"continuous","plotx":[-1.2127845521873,0.199635225452997,1.61205500309329,3.02447478073359,4.43689455837389,5.84931433601419,7.26173411365449,8.67415389129478,10.0865736689351,11.4989934465754,12.9114132242157,14.323833001856,15.7362527794963,17.1486725571366,18.5610923347769,19.9735121124172,21.3859318900575,22.7983516676978,24.2107714453381,25.6231912229784,27.0356110006187,28.448030778259,29.8604505558993,31.2728703335396,32.6852901111799,34.0977098888201,35.5101296664605,36.9225494441007,38.334969221741,39.7473889993813,41.1598087770216,42.5722285546619,43.9846483323022,45.3970681099425,46.8094878875828,48.2219076652231,49.6343274428634,51.0467472205037,52.459166998144,53.8715867757843,55.2840065534246,56.6964263310649,58.1088461087052,59.5212658863455,60.9336856639858,62.3461054416261,63.7585252192664,65.1709449969067,66.583364774547,67.9957845521873],"ploty":[0.000124803746424797,0.153403082823391,0.214248804435505,0.103279674812367,0.0602455243891747,0.0365493261878481,0.0310083143924521,0.0176240318534116,0.018550184872553,0.0158808140189367,0.0134340949106002,0.011139451785296,0.00651011852590708,0.00334452980181746,0.00180541046003036,0.000725170612901691,0.000436746701116166,2.22555660562337e-06,0.000232384762564075,0.000344035656775049,0.000200432452017594,0.000142864757697886,0.000277137942483031,0.000185262801824838,4.73560410868486e-05,1.80013962349674e-05,0.000203232649990313,0.000112295406400364,0.000170730294278997,0.000339693901039959,0.00014360495708144,4.53460628283766e-05,0.000115846193880952,4.27634050554728e-06,0.00026398570476067,1.1999401184329e-06,3.81165436854938e-11,1.31913317695831e-05,8.03418300621983e-05,0.000146042326777527,7.8765326092043e-07,5.92374009711741e-08,0.00011509384599416,5.02274326943454e-06,4.29413763755696e-12,1.25557265015243e-18,5.4414889881135e-15,1.95400480031731e-07,0.000136833709012363,1.93252160329344e-06],"varnamesSumStat":"gdpen","median":"2.028","mean":"3.69377028234373","mode":"0.882","max":"66.735","min":"0.048","invalid":227,"valid":6383,"sd":"4.49472631264387","uniques":4427,"herfindahl":0.000329997855566185,"freqmode":8,"fewest":"7.626","mid":"7.626","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"gdpen","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"gdptype":{"plottype":"bar","plotvalues":{"0":4243,"2":1116,"3":491,"4":533},"varnamesSumStat":"gdptype","median":"0","mean":"0.914460285132383","mode":"0","max":"4","min":"0","invalid":227,"valid":6383,"sd":"1.37541739288513","uniques":4,"herfindahl":0.485330631957061,"freqmode":4243,"fewest":"3","mid":"NA","freqfewest":"491","freqmid":"824.5","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"gdptype","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"gdpenl":{"plottype":"continuous","plotx":[-1.193959991112,0.217691437096656,1.62934286530531,3.04099429351396,4.45264572172261,5.86429714993127,7.27594857813992,8.68760000634857,10.0992514345572,11.5109028627659,12.9225542909745,14.3342057191832,15.7458571473918,17.1575085756005,18.5691600038091,19.9808114320178,21.3924628602265,22.8041142884351,24.2157657166438,25.6274171448524,27.0390685730611,28.4507200012697,29.8623714294784,31.274022857687,32.6856742858957,34.0973257141043,35.508977142313,36.9206285705216,38.3322799987303,39.7439314269389,41.1555828551476,42.5672342833562,43.9788857115649,45.3905371397735,46.8021885679822,48.2138399961909,49.6254914243995,51.0371428526082,52.4487942808168,53.8604457090255,55.2720971372341,56.6837485654428,58.0953999936514,59.5070514218601,60.9187028500687,62.3303542782774,63.742005706486,65.1536571346947,66.5653085629033,67.976959991112],"ploty":[0.000136943175339789,0.162130101814454,0.211536035911728,0.101803010340786,0.059158118113393,0.0367182784039028,0.0307295362035432,0.0174467663157847,0.0182683386403709,0.0153923587122281,0.0132154789669886,0.010785806031443,0.00545385784915851,0.00327254404455349,0.00160766752405042,0.000675243975948178,0.000320754937553758,1.92381015284579e-06,0.000234748407388672,0.000343191535130304,0.000198719238754183,0.000142190169164284,0.000278735055152705,0.000183368782247833,4.57807440938901e-05,1.71226303789557e-05,0.000204835149855024,0.0001111550065297,0.000168531261584287,0.000456892130728915,0.000150252780877863,4.28540789346561e-05,0.000116802797616145,3.90452173516518e-06,0.000267754149538206,1.05923552828011e-06,2.12465454588222e-11,1.16891472024571e-05,8.23897093337237e-05,0.000148503653382381,7.56543066291535e-07,3.90247133348052e-08,0.000114029214636136,4.88509497870162e-06,2.85638205717404e-12,0,5.01007726095297e-15,3.01630394634559e-07,0.000271566097332841,4.10639885941328e-06],"varnamesSumStat":"gdpenl","median":"1.995","mean":"3.65111658559548","mode":"0.512","max":"66.735","min":"0.048","invalid":237,"valid":6373,"sd":"4.53664523239271","uniques":3848,"herfindahl":0.000395394533894008,"freqmode":10,"fewest":"8.025","mid":"8.025","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"gdpenl","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"lgdpenl1":{"plottype":"continuous","plotx":[3.37606778883341,3.54397698112592,3.71188617341843,3.87979536571095,4.04770455800346,4.21561375029598,4.38352294258849,4.551432134881,4.71934132717352,4.88725051946603,5.05515971175855,5.22306890405106,5.39097809634357,5.55888728863609,5.7267964809286,5.89470567322112,6.06261486551363,6.23052405780614,6.39843325009866,6.56634244239117,6.73425163468369,6.9021608269762,7.07007001926871,7.23797921156123,7.40588840385374,7.57379759614626,7.74170678843877,7.90961598073128,8.0775251730238,8.24543436531631,8.41334355760883,8.58125274990134,8.74916194219385,8.91707113448637,9.08498032677888,9.2528895190714,9.42079871136391,9.58870790365642,9.75661709594894,9.92452628824145,10.092435480534,10.2603446728265,10.428253865119,10.5961630574115,10.764072249704,10.9319814419965,11.099890634289,11.2677998265816,11.4357090188741,11.6036182111666],"ploty":[1.35757710948905e-05,0.000193146658575634,0.000999567227018421,0.00193798602471149,0.001869742870589,0.00228814188728488,0.00294905752039788,0.00294627948649862,0.00407468795034586,0.00632114493678651,0.00887741513683729,0.0143602311716739,0.0244609631128496,0.0368164984489829,0.0518536259188924,0.0796410369681579,0.132296009012578,0.198935265593742,0.254157556006355,0.296925475387211,0.33471065073369,0.353597913922982,0.342147530743302,0.316687532951512,0.310403326146311,0.316807983651347,0.318136674708902,0.310994675709324,0.29935678531876,0.286129630805377,0.255456942399265,0.225670651817472,0.213325628463577,0.198215695064565,0.179743128362275,0.172212761141951,0.158833411213322,0.120603184448847,0.0659577351149517,0.0251172802896755,0.00905137757866878,0.00604956489525672,0.00585010697576981,0.00564278075576189,0.00412190593640558,0.00250040736458905,0.00148461974083356,0.000611382026533822,0.000118150524838585,9.00112352918133e-06],"varnamesSumStat":"lgdpenl1","median":"7.598399","mean":"7.65122400075318","mode":"6.628","max":"11.108485","min":"3.871201","invalid":237,"valid":6373,"sd":"1.05737022623801","uniques":4293,"herfindahl":0.000345413158727133,"freqmode":9,"fewest":"8.99032","mid":"8.99032","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lgdpenl1","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"lpopl1":{"plottype":"continuous","plotx":[4.75790676749327,4.96028135861599,5.16265594973872,5.36503054086144,5.56740513198416,5.76977972310689,5.97215431422961,6.17452890535233,6.37690349647506,6.57927808759778,6.78165267872051,6.98402726984323,7.18640186096595,7.38877645208868,7.5911510432114,7.79352563433412,7.99590022545685,8.19827481657957,8.4006494077023,8.60302399882502,8.80539858994774,9.00777318107047,9.21014777219319,9.41252236331592,9.61489695443864,9.81727154556136,10.0196461366841,10.2220207278068,10.4243953189295,10.6267699100523,10.829144501175,11.0315190922977,11.2338936834204,11.4362682745432,11.6386428656659,11.8410174567886,12.0433920479113,12.245766639034,12.4481412301568,12.6505158212795,12.8528904124022,13.0552650035249,13.2576395946477,13.4600141857704,13.6623887768931,13.8647633680158,14.0671379591386,14.2695125502613,14.471887141384,14.6742617325067],"ploty":[1.19810852095881e-05,0.000161118747667962,0.00101814084495624,0.00332761782693292,0.0067090751929085,0.0114414253271991,0.0209821607463517,0.0378378144106037,0.0604260299706084,0.0809601375637657,0.0952024860617118,0.108875233240058,0.123987415349666,0.142831540797052,0.167659361612202,0.198101759526522,0.232032565529293,0.262726720752351,0.276712408522885,0.269688737386618,0.275081190369961,0.29693904712267,0.29048052811914,0.258899267358508,0.242920571587933,0.230626311107902,0.199101397918939,0.158789764037152,0.131590918839416,0.125473351840071,0.128064057447992,0.109893082389298,0.0769970527901738,0.0579414094404461,0.0488943984364688,0.0399784328450456,0.0325128699437715,0.0275613873752962,0.0209964561127598,0.0127505005847092,0.00886091366882683,0.0101827971814598,0.0132680176091528,0.0147415442395494,0.0139722609799756,0.0109346685229676,0.00589250861622062,0.0018232159368494,0.000284118323096925,2.04829640522541e-05],"varnamesSumStat":"lpopl1","median":"8.991189","mean":"9.04888348191344","mode":"6.641","max":"14.029491","min":"5.4026775","invalid":25,"valid":6585,"sd":"1.45751184555433","uniques":5740,"herfindahl":0.000197660521340868,"freqmode":5,"fewest":"11.8631","mid":"11.8631","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lpopl1","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"region":{"plottype":"bar","plotvalues":{"0":1155,"2":646,"3":1096,"5":910,"6":1593,"7":1210},"varnamesSumStat":"region","median":"5","mean":"4.10862329803328","mode":"6","max":"7","min":"0","invalid":0,"valid":6610,"sd":"2.46795189877614","uniques":6,"herfindahl":0.178119293876925,"freqmode":1593,"fewest":"2","mid":"NA","freqfewest":"646","freqmid":"1125.5","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"region","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"western":{"plottype":"bar","plotvalues":{"0":5455,"1":1155},"varnamesSumStat":"western","median":"0","mean":"0.174735249621785","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.379769221137619","uniques":2,"herfindahl":0.711594315677205,"freqmode":5455,"fewest":"1","mid":"NA","freqfewest":"1155","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"western","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"eeurop":{"plottype":"bar","plotvalues":{"0":5964,"1":646},"varnamesSumStat":"eeurop","median":"0","mean":"0.0977307110438729","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.296972661177269","uniques":2,"herfindahl":0.823641161674536,"freqmode":5964,"fewest":"1","mid":"NA","freqfewest":"646","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"eeurop","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"lamerica":{"plottype":"bar","plotvalues":{"0":5400,"1":1210},"varnamesSumStat":"lamerica","median":"0","mean":"0.183055975794251","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.386741662124369","uniques":2,"herfindahl":0.700907028959469,"freqmode":5400,"fewest":"1","mid":"NA","freqfewest":"1210","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"lamerica","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ssafrica":{"plottype":"bar","plotvalues":{"0":5017,"1":1593},"varnamesSumStat":"ssafrica","median":"0","mean":"0.240998487140696","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.427721747724266","uniques":2,"herfindahl":0.634163567326816,"freqmode":5017,"fewest":"1","mid":"NA","freqfewest":"1593","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"ssafrica","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"asia":{"plottype":"bar","plotvalues":{"0":5514,"1":1096},"varnamesSumStat":"asia","median":"0","mean":"0.165809379727685","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.371937572514737","uniques":2,"herfindahl":0.723366741355989,"freqmode":5514,"fewest":"1","mid":"NA","freqfewest":"1096","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"asia","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"nafrme":{"plottype":"bar","plotvalues":{"0":5700,"1":910},"varnamesSumStat":"nafrme","median":"0","mean":"0.13767019667171","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.344579564928933","uniques":2,"herfindahl":0.762565772759835,"freqmode":5700,"fewest":"1","mid":"NA","freqfewest":"910","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"nafrme","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"colbrit":{"plottype":"bar","plotvalues":{"0":4714,"1":1896},"varnamesSumStat":"colbrit","median":"0","mean":"0.286838124054463","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.452319540458622","uniques":2,"herfindahl":0.590875970713241,"freqmode":4714,"fewest":"1","mid":"NA","freqfewest":"1896","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colbrit","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"colfra":{"plottype":"bar","plotvalues":{"0":5479,"1":1131},"varnamesSumStat":"colfra","median":"0","mean":"0.171104387291982","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.376628644316776","uniques":2,"herfindahl":0.716344648117165,"freqmode":5479,"fewest":"1","mid":"NA","freqfewest":"1131","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colfra","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"mtnest":{"plottype":"continuous","plotx":[-8.84624382427484,-6.56068295389628,-4.27512208351771,-1.98956121313915,0.295999657239419,2.58156052761798,4.86712139799655,7.15268226837511,9.43824313875368,11.7238040091322,14.0093648795108,16.2949257498894,18.5804866202679,20.8660474906465,23.1516083610251,25.4371692314036,27.7227301017822,30.0082909721608,32.2938518425393,34.5794127129179,36.8649735832964,39.150534453675,41.4360953240536,43.7216561944321,46.0072170648107,48.2927779351893,50.5783388055678,52.8638996759464,55.149460546325,57.4350214167035,59.7205822870821,62.0061431574607,64.2917040278392,66.5772648982178,68.8628257685964,71.1483866389749,73.4339475093535,75.719508379732,78.0050692501106,80.2906301204892,82.5761909908677,84.8617518612463,87.1473127316249,89.4328736020034,91.718434472382,94.0039953427606,96.2895562131391,98.5751170835177,100.860677953896,103.146238824275],"ploty":[0.000322223779745127,0.00254984715167125,0.011454939183237,0.0294814301888881,0.0452681995734643,0.0450596744997267,0.0349552719156166,0.0273775839023195,0.0237901750464843,0.0212965352589242,0.0189507214254041,0.0162758862829616,0.0142201901478008,0.0133030440456647,0.0115540766289265,0.00928559157922139,0.00801649781698081,0.00716187018679604,0.0071662570440446,0.00881933383319414,0.00973681250774167,0.00792014180940939,0.0055119520286673,0.00451926481446108,0.00420702499694448,0.00347986533032633,0.0028073000487121,0.00315337871694223,0.00403882071541982,0.00403895509094311,0.0028732481799344,0.00200255789207371,0.00233340390685949,0.00318796987078481,0.00396423024700346,0.00457064434475296,0.00429897617198597,0.00288054345982073,0.00149667470644116,0.00101727778887467,0.000887621639978242,0.000548247822441141,0.0002243175404624,0.000190665571047301,0.000408927627799879,0.000590264007067649,0.000472546023433356,0.000208284118145119,5.03784702403109e-05,6.74220880868022e-06],"varnamesSumStat":"mtnest","median":"10.3","mean":"18.0883285855371","mode":"0","max":"94.299995","min":"0","invalid":0,"valid":6610,"sd":"20.9664781171357","uniques":114,"herfindahl":0.0322517800700813,"freqmode":1025,"fewest":"2.16045","mid":"23.9","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"mtnest","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"lmtnest":{"plottype":"continuous","plotx":[-0.652661272008823,-0.533021430294177,-0.413381588579531,-0.293741746864885,-0.174101905150239,-0.0544620634355933,0.0651777782790525,0.184817619993698,0.304457461708344,0.42409730342299,0.543737145137636,0.663376986852282,0.783016828566927,0.902656670281573,1.02229651199622,1.14193635371086,1.26157619542551,1.38121603714016,1.5008558788548,1.62049572056945,1.74013556228409,1.85977540399874,1.97941524571339,2.09905508742803,2.21869492914268,2.33833477085732,2.45797461257197,2.57761445428662,2.69725429600126,2.81689413771591,2.93653397943055,3.0561738211452,3.17581366285984,3.29545350457449,3.41509334628914,3.53473318800378,3.65437302971843,3.77401287143307,3.89365271314772,4.01329255486236,4.13293239657701,4.25257223829166,4.3722120800063,4.49185192172095,4.61149176343559,4.73113160515024,4.85077144686489,4.97041128857953,5.09005113029418,5.20969097200882],"ploty":[0.00328512650674904,0.0147061563209667,0.0488497143695789,0.120620274917264,0.222148514340619,0.307305253705824,0.324387649576515,0.271410187494105,0.196607505929684,0.143946161811792,0.120159609415085,0.11082708302771,0.107460696156097,0.113413992703652,0.130887828638677,0.150980118773207,0.1600951272666,0.153712909594096,0.141221773215532,0.136680479792053,0.14580775939728,0.163662122391728,0.184047319838279,0.206132304498018,0.229204713993974,0.248002607259006,0.259433852002652,0.266831092609942,0.272674698640842,0.275161757185669,0.273739602345376,0.269704311403904,0.26336724268068,0.257385798660017,0.256533048410265,0.258674288611181,0.253840486467816,0.237230392453505,0.216257985655299,0.199986553161698,0.186591100494472,0.165441722728687,0.130115064524056,0.0866360149250198,0.0477807762677148,0.021699229838666,0.00810770675783886,0.00247884507848913,0.00061160612653518,0.000119441234094587],"varnamesSumStat":"lmtnest","median":"2.4248028","mean":"2.1766899741997","mode":"0","max":"4.5570297","min":"0","invalid":0,"valid":6610,"sd":"1.40399115173584","uniques":112,"herfindahl":0.0323301466397816,"freqmode":1025,"fewest":"1.15071","mid":"3.21487","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"lmtnest","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"elevdiff":{"plottype":"continuous","plotx":[-782.272637379509,-565.547223608917,-348.821809838325,-132.096396067733,84.6290177028595,301.354431473452,518.079845244044,734.805259014636,951.530672785228,1168.25608655582,1384.98150032641,1601.706914097,1818.4323278676,2035.15774163819,2251.88315540878,2468.60856917937,2685.33398294997,2902.05939672056,3118.78481049115,3335.51022426174,3552.23563803233,3768.96105180293,3985.68646557352,4202.41187934411,4419.1372931147,4635.86270688529,4852.58812065589,5069.31353442648,5286.03894819707,5502.76436196766,5719.48977573826,5936.21518950885,6152.94060327944,6369.66601705003,6586.39143082062,6803.11684459122,7019.84225836181,7236.5676721324,7453.29308590299,7670.01849967359,7886.74391344418,8103.46932721477,8320.19474098536,8536.92015475596,8753.64556852655,8970.37098229714,9187.09639606773,9403.82180983832,9620.54722360892,9837.27263737951],"ploty":[1.9401563270221e-07,1.82095680754924e-06,1.00632424179643e-05,3.32639754557923e-05,6.95638580392455e-05,0.000102160741296869,0.00012582897623351,0.000148609468288042,0.000162211445284601,0.000157024076687572,0.000148028768800368,0.000153313552622676,0.000172877683831853,0.000198506887681873,0.000233525702858853,0.000275537323609925,0.00030067875198534,0.000287088712172547,0.000233568217857329,0.000174491342442659,0.000147009804137533,0.000137763839421861,0.000119547604649211,9.6862770957646e-05,8.3035005648743e-05,8.1882032302786e-05,8.61570100175693e-05,8.11766667961722e-05,6.83524718333582e-05,6.93868698050135e-05,8.21402676961925e-05,8.06690923318444e-05,6.57300849734573e-05,5.26229890974437e-05,4.62927515689597e-05,4.81761272674022e-05,5.01519466586139e-05,4.13369452437191e-05,2.47728593358212e-05,1.06028998368687e-05,3.94563940455213e-06,5.91777388649653e-06,1.76693684920106e-05,3.39344599438517e-05,4.03127614402488e-05,3.13677510723085e-05,1.64470587606032e-05,5.6514400050835e-06,1.19253086175527e-06,1.479565129255e-07],"varnamesSumStat":"elevdiff","median":"2762","mean":"3186.0897514575","mode":"3014","max":"9002","min":"53","invalid":92,"valid":6518,"sd":"2022.48452690662","uniques":155,"herfindahl":0.0075251285627141,"freqmode":109,"fewest":"1487","mid":"1810","freqfewest":"7","freqmid":"47","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"elevdiff","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"Oil":{"plottype":"bar","plotvalues":{"0":5754,"1":856},"varnamesSumStat":"Oil","median":"0","mean":"0.129500756429652","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.335778747993689","uniques":2,"herfindahl":0.7745393789724,"freqmode":5754,"fewest":"1","mid":"NA","freqfewest":"856","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"Oil","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ncontig":{"plottype":"bar","plotvalues":{"0":5464,"1":1146},"varnamesSumStat":"ncontig","median":"0","mean":"0.173373676248109","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.378598639053372","uniques":2,"herfindahl":0.71336951073535,"freqmode":5464,"fewest":"1","mid":"NA","freqfewest":"1146","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"ncontig","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"ethfrac":{"plottype":"continuous","plotx":[-0.131642721280174,-0.107370880411595,-0.0830990395430167,-0.0588271986744382,-0.0345553578058596,-0.0102835169372811,0.0139883239312974,0.0382601647998759,0.0625320056684544,0.086803846537033,0.111075687405611,0.13534752827419,0.159619369142769,0.183891210011347,0.208163050879926,0.232434891748504,0.256706732617083,0.280978573485661,0.30525041435424,0.329522255222818,0.353794096091397,0.378065936959975,0.402337777828554,0.426609618697132,0.450881459565711,0.475153300434289,0.499425141302868,0.523696982171446,0.547968823040025,0.572240663908603,0.596512504777182,0.62078434564576,0.645056186514339,0.669328027382917,0.693599868251496,0.717871709120074,0.742143549988653,0.766415390857231,0.79068723172581,0.814959072594388,0.839230913462967,0.863502754331545,0.887774595200124,0.912046436068703,0.936318276937281,0.960590117805859,0.984861958674438,1.00913379954302,1.0334056404116,1.05767748128017],"ploty":[0.00396655953122504,0.0203205133328029,0.079539307729589,0.239900940596468,0.563229077218956,1.04201109399517,1.5435532592293,1.87375256497697,1.93323035409598,1.79090575718764,1.59190942011339,1.4280564245933,1.31008147677334,1.22221213071379,1.16158617528517,1.1258529148171,1.09519308177722,1.04837480443887,0.982963871224332,0.905086368334049,0.81533631559096,0.719582839609385,0.640415595489774,0.601671370299872,0.605945374556763,0.636017922046404,0.67192368010804,0.700738600191469,0.720671874513854,0.749301346026579,0.823384643105577,0.969202145494586,1.16007179909486,1.31831464856378,1.37703447948294,1.32652922596384,1.19360304599851,1.01257220857125,0.831410346725686,0.702232402621903,0.639526007460296,0.604850168851525,0.540937958260432,0.421451896580193,0.271844547008918,0.141140681688846,0.0580830087855045,0.0187645891368509,0.00472251209800278,0.000918968620538465],"varnamesSumStat":"ethfrac","median":"0.32545453","mean":"0.38535469357761","mode":"0.357","max":"0.92503476","min":"0.001","invalid":0,"valid":6610,"sd":"0.285338222147506","uniques":162,"herfindahl":0.00712737542942546,"freqmode":55,"fewest":"0.322181","mid":"0.534009","freqfewest":"7","freqmid":"44","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"ethfrac","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"ef":{"plottype":"continuous","plotx":[-0.123305147909748,-0.0978233263420034,-0.0723415047742586,-0.0468596832065138,-0.021377861638769,0.00410395992897586,0.0295857814967207,0.0550676030644655,0.0805494246322103,0.106031246199955,0.1315130677677,0.156994889335445,0.18247671090319,0.207958532470934,0.233440354038679,0.258922175606424,0.284403997174169,0.309885818741914,0.335367640309659,0.360849461877403,0.386331283445148,0.411813105012893,0.437294926580638,0.462776748148383,0.488258569716128,0.513740391283872,0.539222212851617,0.564704034419362,0.590185855987107,0.615667677554852,0.641149499122597,0.666631320690341,0.692113142258086,0.717594963825831,0.743076785393576,0.768558606961321,0.794040428529065,0.81952225009681,0.845004071664555,0.8704858932323,0.895967714800045,0.92144953636779,0.946931357935535,0.972413179503279,0.997895001071024,1.02337682263877,1.04885864420651,1.07434046577426,1.099822287342,1.12530410890975],"ploty":[0.00268107834949284,0.0150291408829736,0.0596863548772082,0.170623206111097,0.360431558337922,0.584799699263036,0.771987376921582,0.899221625442944,1.00822848964417,1.14364572212257,1.29446113681165,1.39155400552405,1.370495818668,1.24911567389251,1.11683882387845,1.03437563059979,0.983297653293618,0.923399843157077,0.849954675663545,0.777947583109897,0.715545535242351,0.688410958775813,0.759506164799444,0.967215870265168,1.23370896938696,1.40811801249281,1.41913069332013,1.32247171009346,1.21504465105374,1.14919075483096,1.11153477237675,1.07625921591433,1.06834289996574,1.12688950775256,1.21553726489725,1.23532799235628,1.1399909768481,0.988473720565673,0.858023499989028,0.751847728945723,0.626806803303465,0.472952861468152,0.320739200899734,0.197685235906035,0.111555783674445,0.0569557154452532,0.0249959302266331,0.0087408624095717,0.00228122355363367,0.000427022232061164],"varnamesSumStat":"ef","median":"0.4928","mean":"0.459328534749294","mode":"0.0396","max":"1","min":"0.001998961","invalid":92,"valid":6518,"sd":"0.268797001327038","uniques":159,"herfindahl":0.00739383307593643,"freqmode":110,"fewest":"0.321595","mid":"0.4787","freqfewest":"7","freqmid":"44","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"ef","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"plural":{"plottype":"continuous","plotx":[-0.11041666836265,-0.0854404778172355,-0.0604642872718212,-0.035488096726407,-0.0105119061809927,0.0144642843644216,0.0394404749098359,0.0644166654552502,0.0893928560006644,0.114369046546079,0.139345237091493,0.164321427636907,0.189297618182322,0.214273808727736,0.23924999927315,0.264226189818564,0.289202380363979,0.314178570909393,0.339154761454807,0.364130952000221,0.389107142545636,0.41408333309105,0.439059523636464,0.464035714181879,0.489011904727293,0.513988095272707,0.538964285818121,0.563940476363536,0.58891666690895,0.613892857454364,0.638869047999779,0.663845238545193,0.688821429090607,0.713797619636021,0.738773810181436,0.76375000072685,0.788726191272264,0.813702381817679,0.838678572363093,0.863654762908507,0.888630953453921,0.913607143999336,0.93858333454475,0.963559525090164,0.988535715635579,1.01351190618099,1.03848809672641,1.06346428727182,1.08844047781724,1.11341666836265],"ploty":[0.000445360340379923,0.00255720351558399,0.0095306547232087,0.0231884000710527,0.0369516621306814,0.0395133772923249,0.0333058290782285,0.0389431513531302,0.0756641581514104,0.146539070406164,0.241680585437492,0.34750762083438,0.448726233572331,0.532692485242008,0.610935059865416,0.697966859359264,0.756671329726097,0.764420901457121,0.798800126088936,0.928513748583448,1.07997557591187,1.12384332569116,1.05598334178031,0.994814747556531,1.00711341804402,1.03784067038688,1.04286248958173,1.05593055928726,1.11177129431101,1.19732752369842,1.25357616597635,1.20861871729811,1.05443890538975,0.903329158631611,0.882143630048198,0.986796081311142,1.14230764779219,1.31891457682004,1.5278941122781,1.78469057394808,2.05405058276422,2.20969364635907,2.13045009285187,1.80630162722119,1.31074481752738,0.772324373289532,0.346507539503276,0.112556149061073,0.0254747854153835,0.00390550993520539],"varnamesSumStat":"plural","median":"0.68","mean":"0.659971709531014","mode":"0.68","max":"0.999","min":"0.004","invalid":0,"valid":6610,"sd":"0.246130721833427","uniques":99,"herfindahl":0.0167702170415247,"freqmode":264,"fewest":"0.812","mid":"0.691","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"plural","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"second":{"plottype":"continuous","plotx":[-0.0516576199575032,-0.0405695538367887,-0.0294814877160743,-0.0183934215953599,-0.0073053554746455,0.00378271064606892,0.0148707767667833,0.0259588428874977,0.0370469090082122,0.0481349751289266,0.059223041249641,0.0703111073703554,0.0813991734910698,0.0924872396117842,0.103575305732499,0.114663371853213,0.125751437973927,0.136839504094642,0.147927570215356,0.159015636336071,0.170103702456785,0.1811917685775,0.192279834698214,0.203367900818928,0.214455966939643,0.225544033060357,0.236632099181072,0.247720165301786,0.2588082314225,0.269896297543215,0.280984363663929,0.292072429784644,0.303160495905358,0.314248562026072,0.325336628146787,0.336424694267501,0.347512760388216,0.35860082650893,0.369688892629645,0.380776958750359,0.391865024871073,0.402953090991788,0.414041157112502,0.425129223233217,0.436217289353931,0.447305355474646,0.45839342159536,0.469481487716074,0.480569553836789,0.491657619957503],"ploty":[0.0104381427084967,0.068034902999386,0.303554335196287,0.926198116280293,1.97249032857676,3.02187690904545,3.52600219860764,3.47891457902067,3.32305481740405,3.29700407609655,3.32690183052745,3.37885761003565,3.45181124559092,3.37890403192811,3.05054410361045,2.7431768998393,2.83889457857788,3.26871064250755,3.57115208805996,3.49922828315026,3.25460981664485,3.06972797572322,2.8881538677784,2.60905679190147,2.33667439697368,2.23002589305901,2.25777855369579,2.18020967680968,1.84346902500466,1.44486002035531,1.28136878307705,1.33178832129637,1.32236323649335,1.09964865394585,0.799024556982128,0.646135259637041,0.699419562696485,0.841905033609559,0.944510849433645,0.968099117854149,0.928243588872859,0.811112388094088,0.628015967229057,0.473818972643354,0.386847641233748,0.296234792499783,0.172810173667547,0.0696762690856342,0.0187698917999343,0.0033777228397614],"varnamesSumStat":"second","median":"0.14","mean":"0.153893207261725","mode":"0.15","max":"0.44","min":"0","invalid":0,"valid":6610,"sd":"0.111124781644906","uniques":95,"herfindahl":0.0177409646137402,"freqmode":292,"fewest":"0.101","mid":"0.125","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"second","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"numlang":{"plottype":"continuous","plotx":[-1.42838037195227,-0.410895458811357,0.606589454329552,1.62407436747046,2.64155928061137,3.65904419375228,4.67652910689319,5.6940140200341,6.711498933175,7.72898384631591,8.74646875945682,9.76395367259773,10.7814385857386,11.7989234988795,12.8164084120205,13.8338933251614,14.8513782383023,15.8688631514432,16.8863480645841,17.903832977725,18.9213178908659,19.9388028040068,20.9562877171477,21.9737726302886,22.9912575434295,24.0087424565705,25.0262273697114,26.0437122828523,27.0611971959932,28.0786821091341,29.096167022275,30.1136519354159,31.1311368485568,32.1486217616977,33.1661066748386,34.1835915879795,35.2010765011204,36.2185614142614,37.2360463274023,38.2535312405432,39.2710161536841,40.288501066825,41.3059859799659,42.3234708931068,43.3409558062477,44.3584407193886,45.3759256325295,46.3934105456704,47.4108954588114,48.4283803719523],"ploty":[0.000984024001802016,0.0194923886025214,0.0918604111606038,0.146792915367358,0.148794553318147,0.108274593410464,0.0640753444484864,0.049312154079643,0.0355137489281739,0.0296914113468514,0.0330892633785861,0.0280525342316239,0.0240764767161123,0.0261808927558134,0.0235905769061945,0.0161187685662674,0.0125193743009062,0.0121171821126323,0.010653219705456,0.0105908566720587,0.014917500354844,0.0139466857591708,0.0184996646545534,0.0111726133096808,0.00361080021702514,0.00342184721646788,0.00429134350199596,0.00732661336101478,0.00540659939396888,0.00144707307523084,0.000111169489058106,1.97699769386642e-06,7.45807881642762e-09,5.61113546796444e-12,9.41108136173401e-16,0,0,0,0,0,3.89442023859445e-18,7.61317293652197e-14,2.21000387293886e-10,1.44905207296511e-07,1.89394291795661e-05,0.000514021857805456,0.00293415608841259,0.00350318892897785,0.000875489145374482,4.58487559851879e-05],"varnamesSumStat":"numlang","median":"4","mean":"6.84841149773071","mode":"3","max":"46","min":"1","invalid":0,"valid":6610,"sd":"7.21425041402589","uniques":25,"herfindahl":0.0982391782496149,"freqmode":1146,"fewest":"18","mid":"11","freqfewest":"25","freqmid":"147","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"numlang","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"relfrac":{"plottype":"continuous","plotx":[-0.101660415576437,-0.0815355006549493,-0.0614105857334621,-0.0412856708119749,-0.0211607558904877,-0.00103584096900047,0.0190890739524867,0.0392139888739739,0.0593389037954611,0.0794638187169484,0.0995887336384356,0.119713648559923,0.13983856348141,0.159963478402897,0.180088393324384,0.200213308245872,0.220338223167359,0.240463138088846,0.260588053010333,0.28071296793182,0.300837882853308,0.320962797774795,0.341087712696282,0.361212627617769,0.381337542539256,0.401462457460744,0.421587372382231,0.441712287303718,0.461837202225205,0.481962117146693,0.50208703206818,0.522211946989667,0.542336861911154,0.562461776832641,0.582586691754128,0.602711606675616,0.622836521597103,0.64296143651859,0.663086351440077,0.683211266361565,0.703336181283052,0.723461096204539,0.743586011126026,0.763710926047513,0.783835840969,0.803960755890488,0.824085670811975,0.844210585733462,0.864335500654949,0.884460415576437],"ploty":[0.001890589038154,0.0100927492168246,0.0392946415906407,0.11426718398331,0.257314897327359,0.471998718770701,0.746960967817145,1.06449336885043,1.3826882499626,1.61688584578258,1.68381109586708,1.59913916116528,1.50374758037596,1.529398264333,1.64792883574012,1.71824584602397,1.66905682504378,1.5380123127075,1.36947193003653,1.21000772139451,1.13991659832955,1.18215698388123,1.24196363335756,1.20110830811911,1.04888290182229,0.913561238968641,0.951452991545376,1.17632460881739,1.42624419559613,1.52588713022767,1.4497192202961,1.30579141372728,1.20475035407365,1.19472468785283,1.2914227505732,1.45432167394028,1.54718431183111,1.46042877370658,1.2457541789023,1.02173108960651,0.833277763446157,0.685469495020902,0.593715400458947,0.533204077345091,0.437146387384773,0.287968194798301,0.142316238337368,0.0511684327913142,0.0131932318157659,0.00241969058364214],"varnamesSumStat":"relfrac","median":"0.35759997","mean":"0.367376836265658","mode":"0.095","max":"0.7828","min":"0","invalid":0,"valid":6610,"sd":"0.21868974010331","uniques":124,"herfindahl":0.0116336820615168,"freqmode":236,"fewest":"0.6676","mid":"0.4168","freqfewest":"7","freqmid":"54","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"relfrac","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"plurrel":{"plottype":"continuous","plotx":[15.5223323567678,17.4397881789405,19.3572440011133,21.274699823286,23.1921556454588,25.1096114676315,27.0270672898042,28.944523111977,30.8619789341497,32.7794347563225,34.6968905784952,36.614346400668,38.5318022228407,40.4492580450135,42.3667138671862,44.2841696893589,46.2016255115317,48.1190813337044,50.0365371558772,51.9539929780499,53.8714488002227,55.7889046223954,57.7063604445681,59.6238162667409,61.5412720889136,63.4587279110864,65.3761837332591,67.2936395554319,69.2110953776046,71.1285511997773,73.0460070219501,74.9634628441228,76.8809186662956,78.7983744884683,80.7158303106411,82.6332861328138,84.5507419549865,86.4681977771593,88.385653599332,90.3031094215048,92.2205652436775,94.1380210658503,96.055476888023,97.9729327101958,99.8903885323685,101.807844354541,103.725300176714,105.642755998887,107.560211821059,109.477667643232],"ploty":[1.30094996866629e-05,7.14534952836797e-05,0.000274647060910863,0.000744500299076006,0.00144504227255296,0.00208432500931149,0.00245334768466343,0.00278206214625052,0.0034567541461954,0.00459741512963922,0.0061368676703507,0.00782769740893991,0.00898410763581545,0.00905469018947276,0.00870031501422662,0.00939732349111226,0.0117047537726766,0.0143058693752085,0.0149029390673019,0.0126755412084719,0.00946958322409162,0.00760041290844668,0.00758715943182569,0.0084784077089856,0.00925243905845249,0.00976251417674518,0.0105608973137941,0.0117363587039499,0.012474795572241,0.0123211946308812,0.0120867149186108,0.0127156809048412,0.014028002706327,0.0152172728072168,0.0161244944894463,0.0175195715960721,0.019948861512651,0.0228582125735657,0.025220362998257,0.0265745302684538,0.0271972907464334,0.0268919825408612,0.0243281438352452,0.0188732846327521,0.0120315067908365,0.00614231728143621,0.00245951277317847,0.000754243158702324,0.00017282461088888,2.89392250693646e-05],"varnamesSumStat":"plurrel","median":"78","mean":"72.7807866868381","mode":"50","max":"100","min":"25","invalid":0,"valid":6610,"sd":"20.388158576094","uniques":53,"herfindahl":0.0319623913705224,"freqmode":524,"fewest":"71","mid":"76","freqfewest":"8","freqmid":"90","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"plurrel","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"minrelpc":{"plottype":"continuous","plotx":[-6.01686087648239,-4.75086655499331,-3.48487223350423,-2.21887791201516,-0.95288359052608,0.313110730962998,1.57910505245207,2.84509937394115,4.11109369543023,5.37708801691931,6.64308233840838,7.90907665989746,9.17507098138654,10.4410653028756,11.7070596243647,12.9730539458538,14.2390482673428,15.5050425888319,16.771036910321,18.0370312318101,19.3030255532992,20.5690198747882,21.8350141962773,23.1010085177664,24.3670028392555,25.6329971607445,26.8989914822336,28.1649858037227,29.4309801252118,30.6969744467008,31.9629687681899,33.228963089679,34.4949574111681,35.7609517326572,37.0269460541462,38.2929403756353,39.5589346971244,40.8249290186135,42.0909233401025,43.3569176615916,44.6229119830807,45.8889063045698,47.1549006260589,48.4208949475479,49.686889269037,50.9528835905261,52.2188779120152,53.4848722335042,54.7508665549933,56.0168608764824],"ploty":[7.0436401811617e-05,0.000432873798439075,0.00185574914038901,0.00562338206733756,0.0123013683047599,0.0204024130609166,0.0277378287595902,0.0335362288366692,0.0368375169865706,0.035423522968054,0.0297433528532958,0.0242663013262585,0.0219690709562367,0.0219741969869864,0.0238532150083953,0.0284413233302343,0.0333594262011402,0.0340390747983579,0.0306647328025846,0.0279693944842757,0.0273085396722322,0.0253772180507053,0.0215294707016368,0.019068445049716,0.0189872768251618,0.0187444135949333,0.0170763496133156,0.0149897900763019,0.0130416892852226,0.011453865152512,0.0113645652361373,0.0130012195094781,0.0141955623387845,0.013409513617912,0.0126248457192256,0.0142051414529056,0.0162093319902337,0.0147263817573269,0.00996242347537021,0.00580517723529776,0.0044221628474665,0.00484616460098681,0.00531912544924059,0.00495290426057112,0.00376656095529259,0.00227079413830341,0.00104466791135427,0.000352798880059691,8.52355517396922e-05,1.44330161602003e-05],"varnamesSumStat":"minrelpc","median":"16","mean":"18.2706505295008","mode":"20","max":"50","min":"0","invalid":0,"valid":6610,"sd":"12.9433441114193","uniques":45,"herfindahl":0.0437865426472978,"freqmode":599,"fewest":"39","mid":"22","freqfewest":"7","freqmid":"95","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"minrelpc","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"muslim":{"plottype":"continuous","plotx":[-17.3455740853733,-14.5967751431132,-11.8479762008531,-9.09917725859292,-6.35037831633278,-3.60157937407265,-0.852780431812509,1.89601851044763,4.64481745270776,7.3936163949679,10.142415337228,12.8912142794882,15.6400132217483,18.3888121640084,21.1376111062686,23.8864100485287,26.6352089907889,29.384007933049,32.1328068753091,34.8816058175693,37.6304047598294,40.3792037020895,43.1280026443497,45.8768015866098,48.6256005288699,51.3743994711301,54.1231984133902,56.8719973556503,59.6207962979105,62.3695952401706,65.1183941824307,67.8671931246909,70.615992066951,73.3647910092112,76.1135899514713,78.8623888937314,81.6111878359916,84.3599867782517,87.1087857205118,89.857584662772,92.6063836050321,95.3551825472922,98.1039814895524,100.852780431813,103.601579374073,106.350378316333,109.099177258593,111.847976200853,114.596775143113,117.345574085373],"ploty":[0.000343046781530974,0.00130074863615317,0.00396361318093077,0.00968817258569682,0.0190205448825322,0.0300994940281264,0.038573100651331,0.0403802797637699,0.0351746195486412,0.0264150533789426,0.0182137800774419,0.0125133748587894,0.00896404717499099,0.00650920414758519,0.00453069433328065,0.00297196505698632,0.00193605943098305,0.00138667438119014,0.00114773161254336,0.00106532419351674,0.00111549325972399,0.00136261385856252,0.00181867965593553,0.00234093188100626,0.00268463270893323,0.00268992098812526,0.00240866507609668,0.00204298289275795,0.00178422895887855,0.00171744393000283,0.00181479082018208,0.0019532531679196,0.00198965695868539,0.0019045155048207,0.0018642717123242,0.0021116419656917,0.00280138235379452,0.00393457463605805,0.00542390011204631,0.00713944560315525,0.00881884077859595,0.0099389655145324,0.00987237524114523,0.00837896037637898,0.00593926814305201,0.0034665104520227,0.00165070559697272,0.000637099836712126,0.000198649012556429,5.00670025695037e-05],"varnamesSumStat":"muslim","median":"2.1","mean":"25.592049924357","mode":"0","max":"100","min":"0","invalid":0,"valid":6610,"sd":"37.4449222755913","uniques":63,"herfindahl":0.127924270062551,"freqmode":2265,"fewest":"48","mid":"1.9","freqfewest":"7","freqmid":"55","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"muslim","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"nwstate":{"plottype":"bar","plotvalues":{"0":6414,"1":196},"varnamesSumStat":"nwstate","median":"0","mean":"0.0296520423600605","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.169638298512456","uniques":2,"herfindahl":0.942454402512125,"freqmode":6414,"fewest":"1","mid":"NA","freqfewest":"196","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"nwstate","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"polity2l":{"plottype":"continuous","plotx":[-13.5006904490495,-12.9496418592924,-12.3985932695352,-11.8475446797781,-11.296496090021,-10.7454475002639,-10.1943989105067,-9.64335032074962,-9.0923017309925,-8.54125314123538,-7.99020455147826,-7.43915596172114,-6.88810737196402,-6.33705878220689,-5.78601019244977,-5.23496160269265,-4.68391301293553,-4.13286442317841,-3.58181583342129,-3.03076724366417,-2.47971865390705,-1.92867006414992,-1.3776214743928,-0.826572884635681,-0.27552429487856,0.275524294878561,0.826572884635683,1.3776214743928,1.92867006414993,2.47971865390705,3.03076724366417,3.58181583342129,4.13286442317841,4.68391301293553,5.23496160269265,5.78601019244978,6.3370587822069,6.88810737196402,7.43915596172114,7.99020455147826,8.54125314123538,9.0923017309925,9.64335032074963,10.1943989105067,10.7454475002639,11.296496090021,11.8475446797781,12.3985932695352,12.9496418592924,13.5006904490495],"ploty":[0.000136743815168839,0.000542248534202707,0.0017722906380832,0.00482701998318868,0.0110516120134757,0.0214690892300264,0.0358922282548551,0.0526797350783772,0.0697600632692643,0.085785514245377,0.0993312543692595,0.107060820983131,0.104702553809576,0.0913068269559652,0.0713777204085588,0.0518743622949543,0.037510732360842,0.0290581746410163,0.0248790835622553,0.0229288414995326,0.0218738201801199,0.0212586734929474,0.0209965299021883,0.0208130443385005,0.0202254124870869,0.0189888294714023,0.0173696140571458,0.0159267919128148,0.0151334529168576,0.0152590678473957,0.016411584897516,0.0184454246741412,0.0209024264354768,0.0232879375738732,0.0254664253358589,0.027772909125819,0.0308002411153332,0.0351719355542708,0.0415786195574558,0.0507663400585052,0.0625797480160503,0.0741375615835891,0.0796017583477803,0.0737885176632324,0.0572175798575958,0.0364432639484036,0.0188559678843416,0.00788296938773396,0.00265609017662026,0.000718416375624402],"varnamesSumStat":"polity2l","median":"-3","mean":"-0.479896040360801","mode":"-7","max":"10","min":"-10","invalid":69,"valid":6541,"sd":"7.51482333625505","uniques":21,"herfindahl":0.104190773328426,"freqmode":1349,"fewest":"3","mid":"-3","freqfewest":"57","freqmid":"187","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"polity2l","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"instab":{"plottype":"bar","plotvalues":{"0":5630,"1":966},"varnamesSumStat":"instab","median":"0","mean":"0.146452395391146","mode":"0","max":"1","min":"0","invalid":14,"valid":6596,"sd":"0.353585980559955","uniques":2,"herfindahl":0.749991817449317,"freqmode":5630,"fewest":"1","mid":"NA","freqfewest":"966","freqmid":"3298","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"instab","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"anocl":{"plottype":"bar","plotvalues":{"0":5065,"1":1476},"varnamesSumStat":"anocl","median":"0","mean":"0.225653569790552","mode":"0","max":"1","min":"0","invalid":69,"valid":6541,"sd":"0.418043961771816","uniques":2,"herfindahl":0.650531927537335,"freqmode":5065,"fewest":"1","mid":"NA","freqfewest":"1476","freqmid":"3270.5","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"anocl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"deml":{"plottype":"bar","plotvalues":{"0":4368,"1":2173},"varnamesSumStat":"deml","median":"0","mean":"0.332212199969424","mode":"0","max":"1","min":"0","invalid":69,"valid":6541,"sd":"0.471042647495314","uniques":2,"herfindahl":0.556305491678201,"freqmode":4368,"fewest":"1","mid":"NA","freqfewest":"2173","freqmid":"3270.5","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"deml","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"empethfrac":{"plottype":"continuous","plotx":[-0.133366641689911,-0.108408368559711,-0.0834500954295102,-0.0584918222993097,-0.0335335491691093,-0.0085752760389088,0.0163829970912917,0.0413412702214921,0.0662995433516926,0.091257816481893,0.116216089612093,0.141174362742294,0.166132635872494,0.191090909002695,0.216049182132895,0.241007455263096,0.265965728393296,0.290924001523497,0.315882274653697,0.340840547783897,0.365798820914098,0.390757094044298,0.415715367174499,0.440673640304699,0.4656319134349,0.4905901865651,0.515548459695301,0.540506732825501,0.565465005955702,0.590423279085902,0.615381552216102,0.640339825346303,0.665298098476503,0.690256371606704,0.715214644736904,0.740172917867105,0.765131190997305,0.790089464127506,0.815047737257706,0.840006010387906,0.864964283518107,0.889922556648307,0.914880829778508,0.939839102908708,0.964797376038909,0.989755649169109,1.01471392229931,1.03967219542951,1.06463046855971,1.08958874168991],"ploty":[0.00361460169477862,0.019101751218742,0.0766906628522993,0.235757836455765,0.560018833509033,1.04068508855493,1.53786517274657,1.85234960102912,1.8925811780906,1.74167169989726,1.54782034847336,1.39304665175855,1.27987121206254,1.19298209148995,1.13057305600968,1.08637469729036,1.03949329385955,0.976257390338998,0.902363716419965,0.82531202307448,0.744901059460034,0.668956579666047,0.619027285764015,0.60897366991738,0.629553236364973,0.659510230252521,0.683031770508224,0.698237667419467,0.721918799656056,0.788603877521259,0.927529756936516,1.12117950149382,1.29535943134851,1.37451771848082,1.34003542524136,1.21918424494084,1.05070822538582,0.882793502132294,0.762855588887269,0.701262392966657,0.661157061515673,0.589889133239058,0.462319924493156,0.302421865435965,0.160099617500876,0.0673733194056647,0.0222874558934285,0.00574969740428529,0.00115136051813253,0.000178232531874608],"varnamesSumStat":"empethfrac","median":"0.3475368","mean":"0.393774033387746","mode":"0.755","max":"0.9552221","min":"0.001","invalid":0,"valid":6610,"sd":"0.289046683343799","uniques":311,"herfindahl":0.0067945921573923,"freqmode":55,"fewest":"0.493672","mid":"0.261047","freqfewest":"1","freqmid":"9","numchar":"numeric","nature":"percent","binary":"no","interval":"continuous","varnamesTypes":"empethfrac","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"percent","defaultBinary":"no"},"empwarl":{"plottype":"bar","plotvalues":{"0":5673,"1":937},"varnamesSumStat":"empwarl","median":"0","mean":"0.141754916792738","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.348824982847671","uniques":2,"herfindahl":0.756679079284356,"freqmode":5673,"fewest":"1","mid":"NA","freqfewest":"937","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"empwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"emponset":{"plottype":"bar","plotvalues":{"0":6486,"1":123,"4":1},"varnamesSumStat":"emponset","median":"0","mean":"0.0192133131618759","mode":"0","max":"4","min":"0","invalid":0,"valid":6610,"sd":"0.143745326542379","uniques":3,"herfindahl":0.963179293281852,"freqmode":6486,"fewest":"4","mid":"1","freqfewest":"1","freqmid":"123","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"emponset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"empgdpenl":{"plottype":"continuous","plotx":[-1.1639069356152,0.246517837267057,1.65694261014931,3.06736738303156,4.47779215591382,5.88821692879607,7.29864170167832,8.70906647456057,10.1194912474428,11.5299160203251,12.9403407932073,14.3507655660896,15.7611903389718,17.1716151118541,18.5820398847363,19.9924646576186,21.4028894305009,22.8133142033831,24.2237389762654,25.6341637491476,27.0445885220299,28.4550132949121,29.8654380677944,31.2758628406766,32.6862876135589,34.0967123864411,35.5071371593234,36.9175619322056,38.3279867050879,39.7384114779701,41.1488362508524,42.5592610237346,43.9696857966169,45.3801105694992,46.7905353423814,48.2009601152637,49.6113848881459,51.0218096610282,52.4322344339104,53.8426592067927,55.2530839796749,56.6635087525572,58.0739335254394,59.4843582983217,60.8947830712039,62.3052078440862,63.7156326169684,65.1260573898507,66.5364821627329,67.9469069356152],"ploty":[0.000139677897072745,0.172193156139941,0.211634410942692,0.10053895257166,0.0549843130489727,0.0347882385787671,0.0302179043816396,0.0171778836677901,0.0181819845806934,0.015353337900595,0.0132604144813054,0.0107405496804951,0.00540629826784187,0.0032537030920371,0.00158645064904955,0.000677306966047469,0.00032336538245312,1.52422351712339e-06,0.000237855636207898,0.000340937255037517,0.000195454596168453,0.000140760852039054,0.000280423274249742,0.000179561256657136,4.31549815590407e-05,1.57191772162223e-05,0.000206703377039787,0.000109248657192312,0.000164508026102675,0.000459925423188049,0.000152688996711151,3.83604682274168e-05,0.000118095690800886,3.26096073134981e-06,0.000273584339667872,9.29649936400031e-07,8.61091371411405e-12,9.33170104844097e-06,8.53300615894682e-05,0.000150932397926699,7.08605835275092e-07,1.8116512718564e-08,0.00011129046044863,4.82845469459543e-06,2.09243381994609e-12,7.0004157295461e-19,3.81533003288613e-16,1.359582474576e-07,0.000271656936579766,3.9653388706289e-06],"varnamesSumStat":"empgdpenl","median":"1.94","mean":"3.6202228153962","mode":"0.756","max":"66.735","min":"0.048","invalid":237,"valid":6373,"sd":"4.53721829326117","uniques":4343,"herfindahl":0.000342113895538778,"freqmode":9,"fewest":"8.025","mid":"8.025","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"empgdpenl","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"emplpopl":{"plottype":"continuous","plotx":[4.7463427323063,4.94918932486522,5.15203591742415,5.35488250998308,5.557729102542,5.76057569510093,5.96342228765986,6.16626888021878,6.36911547277771,6.57196206533664,6.77480865789556,6.97765525045449,7.18050184301342,7.38334843557234,7.58619502813127,7.7890416206902,7.99188821324912,8.19473480580805,8.39758139836698,8.6004279909259,8.80327458348483,9.00612117604376,9.20896776860268,9.41181436116161,9.61466095372054,9.81750754627946,10.0203541388384,10.2232007313973,10.4260473239562,10.6288939165152,10.8317405090741,11.034587101633,11.2374336941919,11.4402802867509,11.6431268793098,11.8459734718687,12.0488200644277,12.2516666569866,12.4545132495455,12.6573598421044,12.8602064346634,13.0630530272223,13.2658996197812,13.4687462123401,13.6715928048991,13.874439397458,14.0772859900169,14.2801325825758,14.4829791751348,14.6858257676937],"ploty":[1.19299731913036e-05,0.000154807116142951,0.000969771946774307,0.00320046214562409,0.00655124977075774,0.0112526442889898,0.0205860046532028,0.0371494797673795,0.0594942398452504,0.0801980340092052,0.0947603995977915,0.108441620970856,0.123583387976424,0.142376993239423,0.167105863308585,0.19746655988888,0.231307796786736,0.261951078286568,0.276040433659711,0.268609972765457,0.26849076593757,0.282262720656418,0.277745928223319,0.254976644201148,0.243042966787011,0.232816855134646,0.206853631444389,0.170482908585566,0.136876785854991,0.119837125647834,0.118593459261674,0.105909970754701,0.0793587130827088,0.0623100739154044,0.0534186140634861,0.045262046654892,0.0379053694886215,0.0308560163538543,0.0218803579572853,0.0128274203914391,0.00902537400935918,0.0106790677429971,0.0140986504507711,0.0154185860959582,0.0141268859099741,0.0107271007369002,0.00566666447377499,0.00173624276874602,0.000273181360127123,2.04415017293797e-05],"varnamesSumStat":"emplpopl","median":"8.991189","mean":"9.0659021264085","mode":"6.641","max":"14.029491","min":"5.4026775","invalid":25,"valid":6585,"sd":"1.47349068581842","uniques":5750,"herfindahl":0.000197060921112789,"freqmode":5,"fewest":"11.8631","mid":"11.8631","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"emplpopl","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"emplmtnest":{"plottype":"continuous","plotx":[-0.648633141160152,-0.529157712949534,-0.409682284738915,-0.290206856528297,-0.170731428317678,-0.0512560001070596,0.0682194281035589,0.187694856314177,0.307170284524796,0.426645712735414,0.546121140946033,0.665596569156651,0.78507199736727,0.904547425577888,1.02402285378851,1.14349828199913,1.26297371020974,1.38244913842036,1.50192456663098,1.6213999948416,1.74087542305222,1.86035085126284,1.97982627947345,2.09930170768407,2.21877713589469,2.33825256410531,2.45772799231593,2.57720342052655,2.69667884873716,2.81615427694778,2.9356297051584,3.05510513336902,3.17458056157964,3.29405598979026,3.41353141800088,3.53300684621149,3.65248227442211,3.77195770263273,3.89143313084335,4.01090855905397,4.13038398726459,4.2498594154752,4.36933484368582,4.48881027189644,4.60828570010706,4.72776112831768,4.8472365565283,4.96671198473892,5.08618741294953,5.20566284116015],"ploty":[0.00322417904545324,0.0145567113947425,0.0486001167655358,0.120223323447931,0.221137205617013,0.304635195034526,0.31934620008081,0.264498536110089,0.188713721755497,0.13530929350633,0.111118143244843,0.102705685027911,0.101740112823293,0.110489603826974,0.130047513984871,0.151148804503849,0.160380636435719,0.153641831814061,0.140764754269534,0.13622717752939,0.146204864941703,0.166077213689594,0.18921271035858,0.213498271521069,0.237170368737048,0.255108184062988,0.265253127417342,0.271790802084337,0.277193237979921,0.279249464017746,0.277382427755458,0.273001145221091,0.266140479750264,0.259280566987131,0.257633952632793,0.259541654667967,0.254850019058231,0.238260044290459,0.217040041961648,0.200554404336625,0.187268141316361,0.166452044509052,0.131307341027805,0.0876509347915759,0.0484115111801774,0.0219916064177596,0.0082087072204266,0.00250318760819085,0.000614632752419647,0.000119105598554613],"varnamesSumStat":"emplmtnest","median":"2.4248028","mean":"2.19375288740696","mode":"0","max":"4.5570297","min":"0","invalid":0,"valid":6610,"sd":"1.39532592168142","uniques":143,"herfindahl":0.0310692321952939,"freqmode":1004,"fewest":"3.21157","mid":"2.30259","freqfewest":"1","freqmid":"40","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"emplmtnest","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"empncontig":{"plottype":"bar","plotvalues":{"0":5447,"1":1163},"varnamesSumStat":"empncontig","median":"0","mean":"0.175945537065053","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.380802630140611","uniques":2,"herfindahl":0.710022589896114,"freqmode":5447,"fewest":"1","mid":"NA","freqfewest":"1163","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"empncontig","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"empolity2l":{"plottype":"continuous","plotx":[-13.494128869954,-12.9433480997518,-12.3925673295496,-11.8417865593474,-11.2910057891452,-10.740225018943,-10.1894442487408,-9.63866347853859,-9.08788270833638,-8.53710193813418,-7.98632116793197,-7.43554039772977,-6.88475962752756,-6.33397885732536,-5.78319808712315,-5.23241731692095,-4.68163654671874,-4.13085577651654,-3.58007500631433,-3.02929423611213,-2.47851346590992,-1.92773269570772,-1.37695192550551,-0.826171155303308,-0.275390385101105,0.275390385101101,0.826171155303307,1.37695192550551,1.92773269570772,2.47851346590992,3.02929423611213,3.58007500631433,4.13085577651654,4.68163654671874,5.23241731692095,5.78319808712315,6.33397885732536,6.88475962752756,7.43554039772977,7.98632116793197,8.53710193813418,9.08788270833638,9.63866347853859,10.1894442487408,10.740225018943,11.2910057891452,11.8417865593474,12.3925673295496,12.9433480997518,13.494128869954],"ploty":[0.00014634370468922,0.000580767006222805,0.00189504456618004,0.00514117016282609,0.0116789328407813,0.0224595915396321,0.0371342934365779,0.0539481774462644,0.0709142448732319,0.0869075689200218,0.100607535649051,0.108535754886888,0.106239560760771,0.0927701040413482,0.0728160659051658,0.0534554197509013,0.0392828668314942,0.0308437918959869,0.0263904054819771,0.0239701153428584,0.022440299450171,0.0214855656296301,0.0210474785010781,0.0208060755877677,0.0202247621426276,0.0190341603158954,0.0174941527828451,0.0161432586501008,0.0154114102787,0.0155286508647872,0.0165909277155029,0.0184613279786411,0.0206994139697958,0.0228454080536319,0.0248257228040373,0.0270381379705472,0.0300876726129389,0.0345185469245581,0.0408552004851138,0.0496561075368415,0.0607112378614373,0.0713474526133717,0.0761632210286431,0.0703631897151172,0.0544521533958594,0.0346400911121726,0.0179080446076038,0.00747576297039516,0.00251600247629425,0.000679693359933159],"varnamesSumStat":"empolity2l","median":"-4","mean":"-0.678644246717378","mode":"-7","max":"10","min":"-10","invalid":234,"valid":6376,"sd":"7.46250810884598","uniques":135,"herfindahl":0.100637004907046,"freqmode":1335,"fewest":"7.68712","mid":"7.68712","freqfewest":"1","freqmid":"1","numchar":"numeric","nature":"ratio","binary":"no","interval":"continuous","varnamesTypes":"empolity2l","defaultInterval":"continuous","defaultNumchar":"numeric","defaultNature":"ratio","defaultBinary":"no"},"sdwars":{"plottype":"bar","plotvalues":{"0":5779,"1":775,"2":47,"3":9},"varnamesSumStat":"sdwars","median":"0","mean":"0.135552193645991","mode":"0","max":"3","min":"0","invalid":0,"valid":6610,"sd":"0.373616423663424","uniques":4,"herfindahl":0.778167128611351,"freqmode":5779,"fewest":"3","mid":"NA","freqfewest":"9","freqmid":"411","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"sdwars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"sdonset":{"plottype":"bar","plotvalues":{"0":6488,"1":120,"2":2},"varnamesSumStat":"sdonset","median":"0","mean":"0.0187594553706505","mode":"0","max":"2","min":"0","invalid":0,"valid":6610,"sd":"0.137896913355496","uniques":3,"herfindahl":0.963756560110409,"freqmode":6488,"fewest":"2","mid":"1","freqfewest":"2","freqmid":"120","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"sdonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"colwars":{"plottype":"bar","plotvalues":{"0":4888,"1":533,"2":15},"varnamesSumStat":"colwars","median":"0","mean":"0.103568800588668","mode":"0","max":"2","min":"0","invalid":1174,"valid":5436,"sd":"0.313654532316676","uniques":3,"herfindahl":0.818165125419559,"freqmode":4888,"fewest":"2","mid":"1","freqfewest":"15","freqmid":"533","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"colwars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"colonset":{"plottype":"bar","plotvalues":{"0":5360,"1":76},"varnamesSumStat":"colonset","median":"0","mean":"0.013980868285504","mode":"0","max":"1","min":"0","invalid":1174,"valid":5436,"sd":"0.11742205934276","uniques":2,"herfindahl":0.972429192785025,"freqmode":5360,"fewest":"1","mid":"NA","freqfewest":"76","freqmid":"2718","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"cowwars":{"plottype":"bar","plotvalues":{"0":5073,"1":412,"2":27,"3":6},"varnamesSumStat":"cowwars","median":"0","mean":"0.0877129394708228","mode":"0","max":"3","min":"0","invalid":1092,"valid":5518,"sd":"0.310398288607461","uniques":4,"herfindahl":0.850813266437916,"freqmode":5073,"fewest":"3","mid":"NA","freqfewest":"6","freqmid":"219.5","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"cowwars","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"cowonset":{"plottype":"bar","plotvalues":{"0":5426,"1":91,"2":1},"varnamesSumStat":"cowonset","median":"0","mean":"0.0168539325842697","mode":"0","max":"2","min":"0","invalid":1092,"valid":5518,"sd":"0.130136070412808","uniques":3,"herfindahl":0.967204566005012,"freqmode":5426,"fewest":"2","mid":"1","freqfewest":"1","freqmid":"91","numchar":"numeric","nature":"ordinal","binary":"no","interval":"discrete","varnamesTypes":"cowonset","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"no"},"cowwarl":{"plottype":"bar","plotvalues":{"0":5229,"1":445},"varnamesSumStat":"cowwarl","median":"0","mean":"0.0784279168135354","mode":"0","max":"1","min":"0","invalid":936,"valid":5674,"sd":"0.268867475160833","uniques":2,"herfindahl":0.855446042644351,"freqmode":5229,"fewest":"1","mid":"NA","freqfewest":"445","freqmid":"2837","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"cowwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"sdwarl":{"plottype":"bar","plotvalues":{"0":5789,"1":821},"varnamesSumStat":"sdwarl","median":"0","mean":"0.124205748865356","mode":"0","max":"1","min":"0","invalid":0,"valid":6610,"sd":"0.329841082929536","uniques":2,"herfindahl":0.782442638371696,"freqmode":5789,"fewest":"1","mid":"NA","freqfewest":"821","freqmid":"3305","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"sdwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"},"colwarl":{"plottype":"bar","plotvalues":{"0":4902,"1":534},"varnamesSumStat":"colwarl","median":"0","mean":"0.098233995584989","mode":"0","max":"1","min":"0","invalid":1174,"valid":5436,"sd":"0.297658153785077","uniques":2,"herfindahl":0.822831844607205,"freqmode":4902,"fewest":"1","mid":"NA","freqfewest":"534","freqmid":"2718","numchar":"numeric","nature":"ordinal","binary":"yes","interval":"discrete","varnamesTypes":"colwarl","defaultInterval":"discrete","defaultNumchar":"numeric","defaultNature":"ordinal","defaultBinary":"yes"}} diff --git a/images/Thumbs.db b/images/Thumbs.db new file mode 100644 index 0000000000000000000000000000000000000000..ace22476a178f0270ffa1686eff9d90e34d0bda3 GIT binary patch literal 31232 zcmeFXWpv)awk7zPnVFd#+c7gUGc!ZXF~3*x{ ztzP|SW?p%1ODgG;R8^g^nu*Cv^4FCrKE&x0L_y7n15CR|qKn#Ec04V@60OSBD08j#;0zeIb z1^_JpIso(l7yvK=cz+HPuw@3o0^lP6Rsd`O*a2_=-~_-0fExf00A2um0RGj+_jdkQ z`DYKPf*gUr&%jtnfE<9W3&;!TssDVz20{J%oPYNR|EnS_DzGuxKMwXj4*$B26&Nv2 zkP!ebkSWLn05`}S7*%edo(BLsaAX3q{MY6G)0Q6aLjV0({!bVD2NjS&-Jf?u1j@gj z&jB(6o@NR>i3NC*k3hX8P-6=0vjTXxqW`!6&j*75PQClV_xJdZulm2&VgQG&??wxh ze?6c5A5VU7zXk9-cA)(%z}`pTo!;N#-Ln7V^1svm55TR={;mE0ec%1p{{R1a;N3^R z+ppZe*~9L3YY%m^waI^MZU0sK|Fs_Y*Z8OZ+xXM@E}TZR;PJlAzpaB%WhG@KL119- z&J8GUOCT{2Bm@K`1SAY3Bn%u36bu{!98eID5#I|k+CMgk|F-$(!T=_3?=K7- zgF`?i2q-8>APRu_0_Q=HXi(^6A4Q-sR7_yVoiSMh<8xst zME`VPsZN|zvYEOB!NFtW;Nsy^QPa@U(X(@Ka&hzUiit}|N=eJes;O&eYH91}nweWz zT3OrJx_)+Z_we-c4h{(o`x^c&A|Wv;IVCkMJtHr_pzvo=aY<=abxrNxy84F3&aUpB z-oE~U!O5xVnc2Ddg~g4{t?ixNz5Rp3i_5F)o7=nlhsXDJy|?pU<)1_GKeP)CXcsu- z`?$Qf3k=-jz2Rt(P-GvW(M42XOq?;uSp#7)MdNe-bih%tsh(q*x=g@hQ?hSRUA#B# zA1(XOH7w|Vt7ZS*u>aPsMGztc7%+GcXdofbQta z^cXIY5-|&%t;T)pX(rNjLxB3?`(BNd4IGnfY+8c$>BGZL+SQNxgC3Aq-|^FCc0?=r zWG=B#ZEfunzX;J-`t7e2o`sJF@k@OKw2+uKa)dz?p8`)-Eu14aP>^N7Oza6nm$K?0 z3Ad}UuaKo^C=;NSWcRzbE6&$wDu-gc2v1L8g+yr~#D?>SOLbCTDhK@UOWBy8j1t~J z7wTXh@6{|#3UrZF+K89=B>5z|)wec6twLwnuPq?CU6oyRBg@36t=ES)(9y(y?u-@% zbHo=3tf{4FY^i8N37wFO5DP<Z0K^Y$aI+Pg$DMNvkDZOM9EuXWqHTy&%idcNIGBJts+9D;xst-N*;}at8(cibm(kZ%-kx8F;d)wuKKg7TOWipTl8SXgEYAx;#s&Ut&pYr zVF;C>2WG8=3(Fl|EfC%Fh#C%2DB^?(t$6xz2THDAB=rsu?UA~<@mA=IVTvH|1fBxN zx43_fI3uE$u}bGj^{dpl#? z`r`g*He0-@BnGsz@(qNez{<)Z>U1)0BEo%5@X!O2a4V~A>Fg|(rVJC{44nG2y~iKN z&CS!!Wq4)LIIIK-kzKBmIKad|k~zO_p+woxVjWb{Cx#(w46Hx3UYxrv6ICOOOCb0-h{@8iG&(7XqB77= zdhVHj9Qg*~pL=})-VIAB1_SLuomv_XHov5g+ZL2G8lQk0m_lkEm>{!mMK~E5K4jlN z_EXaTyXD~`QtRJnq;V7kY$!Yz6iTb&W9c&Yd*?hhY-@7LOFt!J0bdYFD2Vi&Ce(gc zM{pQhxgs(>J3m(ogtJFGk}aRuu^V#ly21UbQ4R5->Ba1Z-|B2{>Yy*D=ss2Y?-OtB zvFa+FZyt9((;91>4A|G901?WqIKEk_P>Pyh741*gO--CGJ=+POZ#C#5R?BN&DnK2i z@o`{~0q)*{p+);2Yj{5!s`5FQqp#5+7Wq5Gg7-f&OEJx2;h1yP%+&f3yks2J6S2iJxdCZ8&A`b%Ck9F(GBL&Nm(U+xJXeg?(2I$ z>1T`96}YrA$C}ks6q+Dd%|l_F^tYYhD1EMGbKgLr{$@n^I=brAav;EEx`bk z&H(OiqpxAhi{-!4irnG?#;&Tu;6>IFLoN56M0lVpbPkB2rgyQObp#K-5!M8_UJ-j- zWV!c=?9*k$b}GO~*RsO?OvekV62ZRZi&bqPNag?QdgyI#=c%``nr(uq^%q*tse52& zfVdZ``um`w7~%HafiRI<{^HUSrTdOVvn`radjQT31kXv7+fkoxw&y4R=C;v>0YL)m zYVJYsC8+e9&7 zLX~_RA1CDViF=R4Ejc+5GS0al-beHC?hWMCmR`ZT<5*7hQEn49-*d^8F#Ko=*QVZ-om8#=$w@ghZ^aC1E4ojljKK z)Z&LoQ&yNL?v}MdgT9-9r|n9!PDZMz(RN1y0o_0mh3u|a6wtaXsL8>**U)X1P?1*avg(d*X(5NWFw^{WWgd{broT( z6aTG?wiTga&1B2PH&EY}f1`g|IX#FrFXG=phZ_nN3sRldqMa1oZ;>Wd^#S|lwP}5F zN>MlXYfw6h(`89g@ne+p(J^n9W?}T@N>G7GpQEFSq1=`b@=eLfr*u=6=>^7h86 zsM9?DjHx2wT@Z??A`JBotC2Sl$-wLWt7Q#?pyU0k(w)>5J6Ns+*1)smMRHpZzmRhY zA4(0XS)Jku14@$Fgx`~Y70MUOEgTw)rU?u>+FvaxW#?;HUmT~8o820@KIGfnF_R>u z5u1iy7Er!{@J4TA`5|J#~HE6YGP>ZbuqLh2&P%IkCgOdo|2 zyKraW*uu5v`=SH^@y#Vu^+~t)<<`ba$7bJqMT&WaHq>sDrljWxBu<0~DAXUXrc%qUs-syNrVD5K155RoU5o%PFGZi9DXnGGAv7wf4l z?7I-!sgQN5PzF7AMq&Fw5WoF77&XXhRizh=8B24W`}+}#VpyQzxG53imAc{v;H9f< z{@An|(|7kTg=t^yghD_jzzF&C6SY&9P-X1*>QwASOf$3fO2?s`IlwFW_%6Fn6|!|D zY7YslSGQ!G%nDQLX#f7!@SwJ%jCs}GzwR2P3?m|esSM>~bpPylr*wr?sN)`;xu^eG zZH(~x*`Gz=mncHGLq2-@5v3Kk1!-__a1bjuY4E-zEx7EzoF+ZNuYwwdvjmyW;_W{I zAmTQC5Ex|u9H!-TMS0u^yGohdz;L~>(7G&!U{Cwlg=)ix`RTm8y84*IkBnA3g3YK> zkf>gegh41`s#CPR7p#oD1~Z$83W!Ry6b(_19k+b$*=D-?k@zRVpld8W^=ka+s9W=O z1&qFIg+Z;yDR#Rz(1`-?;uFD_d$Uxck1b+mF!51aF!5@GDY-5;uCLT{bCTLKX{7Np za>O5-NPT$-e{^Ncx3vA8%DXzvA~y&7QSc)o$7Q%LR0AsQJSQ2~71YGMy{`zDxf`q4ZyqgK@bDlJF6%Ix!%K63TNZtI_#s3Vk=j zX6Lz!=fJxjkdmJnY^zNi(`h^m<+-Pz_J^2fvp6vR_2+>Ly)I(Li;8B;sn18VQ>357 ziPF&LmCwRVB~JnnuWCg|(ItEp^bLP)(lra*&P=gyeGCK6en!45WpVma2Z`-cg|$q9 z(9jsyf@%B2f>5FWJ7)VisBJ3~i#} zmC1`lajVwBS`g-SL+T`b_$=#L74fB3YElVn#PoWF&pFYKvQNrxB<2~kgayi-R zDh+)45a5NiF<^|BR&5ea5R9{|_%T6vlub9~Q6af7_4e~e`bB%Xo!F+@>iBCOq3<3; zEJ?{3kxFiW+d5nN(}f6We43T0C%|6a`1kvqTEySE)k6lo$P;Gux?~v}b)0y$9eTx` zIBY`~_*_$HPH?;0I$Ha=Ato&kXyK05H;`B}^j6LoCCJ4)(B zC)@I_dwg^-Fh6IECEa6H61>`Bbg*JPU#VX$|2Tf3F#B?RNf5d`+)a5&OH~bo3b4Cx zxS-%5UikQwB73zbq0b0#)0~xqJ0W^iTrOar%(&OHw%8kWrqki3Q?UFx(YxJv20pnj zwG$F8$4A8Qy)es&|FKJp>*Wkh&{zq*85o1W8{1OTw*LG0sagT#dxvar$Hp>1RSy}L z&*+JZ+kQ+7eu8-teIVI;or9RpNHJ~ESd;0}$FD$u$)|@1;?wanmh|K|tJOVUjcO&D zEWfVx|7bsD`nN|uz;mzyhr3t$sgKc%`n!G4(LWEpD(R0s1v>>%tRFj|1nGEF z?XYz)a#8pImGn4_K8B`3)=q?ZhWdouMIIAMGZ`HTe& zppX&@(4Hgr(R`MR?G_hNi??Huzqkp#t=`S?$qF+-3CWXkTTA6Vo+M z?0qxQUd3iAq=XDoCmR4&_&tC)g?qi@qeqAjS06hOiZgH>3!?SV;&T4rEo$-5dmC@Z zlym#36Oz(K-@R!HSgi!BG`?_4`msWuAJGdkj z#V83a=w2E=1-OJ>^?(l5244d?V((-x3`bp>Vv8}=8 zetx%m_EvfK+Q?__yy2SqPkyusHfMc(oyJOb^}tSIy;%aZ=PMyv@R+`-0*(CZVBIDE zK?SlL&iA{9F(OZpb2|vR2#>m4Z;WV~j$i6ye{Rxa5G%^It?U+WXMXBw>|N?Z#5(h{ z_w5@9t?ZeO0Hu1sjzXG6Xg1DV(L3l*uM=3ul^0}S%&SqO(5lfcgG@*7+>>0ow}6ls zw}R~L{_%@uTd~BQ(mQQ+^`p2jx+Sj7KhVaVwoJzTk!uzeAL~jX33okK{yE-v>h;Q> z%}D6kV(zu)0;lUBJ7Kzu!3U1I3#EsGBoJ#Ntnh@&k@|J}Lp~)y9t=p!#Dj zsa=cWmk*PR!j~zlI(e!+ZOt-xG|RKeSbHS6&+4nVQ#H5Ix6O;8txnEqTaFxWAjG^9 zqAueLZMER6B+cX1f@$*YTdDjB39R_sY?Nnzq4&&byzJh83y?P68EGi!eU|UBm|_|8B`EX-h%8DjZ+Vd(8;p9YqNG2|&N^JLu+F-MLL7hbzdNQ9Tdh{zr;y6TDUx^%iAr$q@>fgqxoz|kk zO;;VY(#?F&o`oj9)?2$3&8yaoY-#JiqLa(jb?MG*UWqbM4lW>W!VPsmx8hULko$0?I9f zsOwP~(;Q^p#5stP%J9|?o`KC`TS$@@Xu~$Nfjp`oQ7=bXx{a%_w@CNMTNheu?B?ak zb;yw7bXg&cgII8bv?^TcjfFd~cCfQSUuZ8!ZkKG(xcrVIQ|!A4_d-c8nqX)WN1?p6 zc`x#o3w@5u5-0C`YFo;@>Ic!w5~9nST4w)NEeKRBjNRjGjmE-+*?%69`B^tzK4CoC zemIy-|94&6CBR`BY$b6jN?seW_(1C zQGg(}FUPWOzvB#vEka_@79ZFbV~2Li^9Hh7=(DBtg7i^m2OJYY^hoa}G_(>8 zo~aCFFMYFZ@#PBlFTMqa59L-z>Fq=3ra3w%*jx#(Bx- z=PDK>YsKA76mpX*h+I@wJG;3Hlr%7-dD63rj7ZsRsTH6 zl`n`B*ckvVGaw{Y*-;6XZelt0;V+~K3$&sB$x`)h@3@$i2R8-LVM|{}EV6HmMBP-` z>)dW4o-60b56g7|lqQeV%Pd0deef*gQtb@(oe|u@7p5uMr=>@4!dj=BQmGWx=*Go6 z-^zz;z7_}-10$K5Y0PbX5yFNykgu4(?nEiCV60Wn;)j?YKMbmTyO*U^_M5(uT4h;* z5+hm+*~@)75B7b~T58uSOa5c`BJ-YRfW1QmZ~Yobc)RDC+3YGxQv~%(I_vSaDqy!r ziKR$`SL=_AkbN`u%T#3C=y|s>FSmNx>YFf{nIUYqXrk6R1y~~%IV`X&>Ta&MZB6J# z^-q`_UQTLf$9B_IdpikGcRAoM8xj;{hKP%35>NK&S1>hcoPZDqQg_V~@Am)v2BJ^M zcmsWYp@j&VxlzJc8mW`74)c@)YuKh0jcbk%&f-dMioZOe#|zY~%U?aJs>xm)@4*jf zHA)zMpy9j2Mwr@xfcT;4wb%lk>*0$02BON>Btk5JZSVCn6|`SCnQ{=Ul{n>B*scUNTZ6S~&-%HLQ>89J1^xK$S$YPf}fjHCFk_vo0&6n+ORMT z2ufoM0yZC^eJjEtdsDNmnKP{Omhht*7#mt?7)U}ZZqmC#E4%Bn zaSyFJ!xgz1!nV(Vd^D^z`Ua{^Ug;?hOE8Y#qSm>p4Idl)?i_L2iubH}eixBjdwvp? z(3{=MMk<8>qQ0 z4Y2ut+spqyet~2LYtgRZkGzx!&@X4G!g&U+;W7~lcOD|x4oI}XAQasGy^J9xxO*4w z=j56YNdiwp7L-A5ymnlPb>}`sMUUbfQQtfvm511iQq=?|Rf#TIWn?_>t3#=B!@R(F z-{1ZoZy;i$i%RPAxlYdWyI7`XYe(^4u2fww*+Uu(d+5%)USIiK=Zwc{y>GBucqe~m z#6-xY=frWNx50ADZF|}!bH}L-OI8QtY8WyIBa-+8B6|qiaWY8 zl;v%1HQNvyDulAOk@C&C;H6l<`KqQ<_!seHe=+pRSr+D~3tN_1)Lg!bXgL)Q)OnqI z&5C`+8z`LjqpO-fx~7r=#+pJK#NHal7sLy$sJxgD9^GO4qCNR*pMo7E2?#8RoOmBK zE4xsFn9t9;QOY@U>d2)tn3)IBwp@RmuIvgrSK}^?de8lxFi;}W=u0?C-k*$8tzI)P zzvQ6^C@37W+^$s^RQ1qvSb4R2TlnYt-~X}y|62e3`ETE&=+?+vPf;~td{b7GLW0MC z|MUwe|r%vDuN6jU)vcmNzgT8Su#0N>TbB0QS_ACa*t z%ZQ7pdm5e?z-VJh%}G+w%3>TSWT+nyNkqWI!>VEyhC?yX)1x!|F+GM)38%6}N5Dtd zyJn;QBd(Cwn`Zq#ZDz`Z*Oz@uCDGm*U;ElkuMG`2(yFQr|)KGX9YoQtJ$L{M7#yICMFlKA{8q6@i@EN z+iA+YCOr{YC(SJ_ZBlV__q8=O#C}&JT#v8_K+AFL^Sf{KlL`o|C`d`|K?gP4B_$`zd0+3Ng|h^|4}yZUG%gMyVe{92bcL^|tgI|a ze2I|lba5^WG9kcwR8jDXcV{BLUN927a+1v@(XZNkM?-`U;8#e$g0z-I-8k-nV~0#sm( ziA;{?|FCP0u}^c_FDA*Sv6w{fXF*awk8E^(z2jhE@gyf^Mkj~#_xC4{)ta1~nVw$l z?(Y69p$!<+4U&U{gA6xIG*#jIzy2`@LO5EVjHR44G$P$gyM@u!N4 z3a!s>ZblJCV&7xxEulN#f5C8lwk8A*V+i4glj{hzxw+}b&c?O`xz;AV$Z>dhNM&PV zLq|nLHR8ks^mb!squbH+gt8-rc4_XQEFmG`C;?k6>*}d(7#Oir#z*eWR(b3V%u&}Vwb-X|5{bfwyY>-MZH8oYO@_&0xfkh~mfW-~~ zp#|lHrazuv?hIKMb zA58Tf+XVN7BH&;OzTTUO-Kqx!gaxOirOA}*)m3Or8BvCXh2fwO^Up(XK*K#Uk@N8I z%#Mtlpy;wjM`M%bn2-qw2y~B*o|bKQl2l=%qI|%wYE{Y>M6#`nAmVdxPEAY01(vs+ zqa_tPJ3F!e$N&>hzMU{NHYR3NT~)Qz&CdAo`rv|_6OtV;E$Ont!W|NJGj!GEe5u&z zPrB*%8(&FkM1C8%ef}JxkpwmEm=lzlALJjIGu=y%FflpV7-m*(^7i^dFPFmj%~**c z^#1%_JnyW z$;XO;;nz^L<%mnZU4cn&6kdz-$lkSu#V^fr!^QdeGSfuBdEvf~G48`Y?4bI77X=AP z_7u>6?%b((tgNiOA_UnI!36?Hs`J(*+HHO3(pn zE-XCo`@V$Jo)X9P3CYOFV1NG3eJ+T5t(QkIsM%sT#*;tnABqg>cFHe(07yTci~!ib1Lx%>4o1AYBbDr#zEfiL$?46<*V zk<5$Hcx=5G+bnn~9VYDk;PJ^~T{#&U8E=7%f-pKE9UoLeij}_e&a8BGnbB_6;o;(9 zN+YMLzV06#8TDNWF4s9`(``ym)hQ||-SwS~k=qF;eO+8!^hd^J3847e7;yel3mKl9 z%53D2o|$=+Q&cqfuuyH~0z}86br`?MLGkPXPMdL4V!&b1S&Yt7ii(LT75@C`9!jFX zfTV?212M5Pl$z+U)+!(dM2iFvRDB$~;bZX&$@Ie^df`NRw*Ox~x5K10z@>{a88%zTco$GNR@yK9h5GsPC&@^*kiP|BT5sm$ zN3h^vAT%^I2NnzjHdfYVzn7c20sq&BqJu~r=6Q8<)oM!@V48*g(yDYnzq)z~j&@KD z;G9b5aka$9?+$r>{=%v04hs*z7}UJ#zTJ<;!>-N4ZruQcr2x59rU3~lsW&Gem{%eq zAz`5qaa5(!k z4m-`@?Azt_KyX`5r}cJ9OzL#ALhO#5QNrJkr>(wEl7M&T$-CqjXgL9x&GtmD*jLq~ z*SX}l%z)m$@S4v$2yT$FdMDbd{ojRKyv?kv?hZD4BAX}_@iRmo*lA40?64FD!ROoj z+o)@_rP%KSfq>e8{PWCjv-{g9~HxpoEry!+HT8;e>C`Y3a#y-Ee`1p~X{h2_d1d2?-+I_D38%9@27eXlJ?&juY zNq+tog_qX@IV!|SB2LUv2BeFttDAzn{9*Lk8fxev^01E~;deW0Ykdz7k2iW2mT@9y za9e!6I)@p6H9jGT818COo_D>vxx4@LS{e>P`-}0lH`bMvjm^MGAu+JL++K*VU^kHz z3t@&R!yhE^*<`yv9wI0>cq{dT-fn6}#$p(6wsSN{Cl|P-4!87&v_V*VKRA+8uC#VB zkK_5=ka}tuH8r&iY6cE}NIE?rvW{*Q$MjYTn)M=Lg+NVH=jG?$ zxy=uowUX2O)c?Dt|HTm+kFoLDbw(QYOEbi@$ZAYOA(FWJ=1c|8G#e1W5*Zb8|EGX8Se-$2Bq$ zZ<$ou5o)0e3p+c%T*psRc7(~Ut}T~TCIhC9J(6&4u-a&Va#>SSQkMN1{JeSyZ}SFt zF(Ozlnfaxqw-AU#oZ@SCL~UF4?v)h*oUf{0bJ|dY0n*CC_QAayTU%RwqDMHBHukU& z_4$&~RTA|woui{MI?zMQ%g@U|j~Dno9`En>>%c{82)ob#tG8pMB)w;AZAQ4OzwF0L zOUEVqY{iZuBh%9tT7W*8?sri~LOZ|n7cP9`U}CBm#`}apEe~rq`~ot+m6DX~C1=cG zic3hClrS=SBMVYRkk&M{u#oU+RH*s$hpu+mRSoPzu=~rS+t02_#&PUbNlD3>A2vEV zfgCPUi}y{8;sypUfk5J92snfjfWQ$NYDK!T+bI9MJ6ZB*%*ep6mh!casH(c$iWPdT zhv)>S4_seg@8Omn8OlIU+qn9QOw_2sJ}svyrJzH6T`mPA7%0~Fa|#LyV-7vv|$$BpsJ zv$KuhPJUDP5jA}KEqyx0v3aorhX&VAWplDvOASz!PDKGXFnm>6Ma5H?>LU~#`TY`U z-p~8W=olDR0{v3f&ocokWf@|CEZ+|iGpKdGag2>Ahik@!4VJsO{$ZnF;1 zqm}vjds~BYPO%U+ugh&gBfp12{81=%2$sz9iT?T#HgmGw-Cd#l)*5kbhpXL@lQ2X) z)(?OiXt&Dtoejlj=}fd<@s}mx{DgaA&A+s?rSNj?2h+BXI$fC zAi>X77)${f_anGqro2M;q4eJ9_srw3f>ogBgFnFik1{Z|VfaZ#Z+={$;6 zg^A3%!_k_ir>9TJX=_=IWaSkU-nhLk3wS%hZD9dnz&7|xc`X{@VaMF~IIWYr`|5Wf z(cpJK*0#^!h+qeEL&EI#85kHqV|lQ7Vl08u*2=4>c>TOsW3vjRI40s!QeVeeh=OXF zY62nw6P*EOPYnO({WxR1X(;Qx>4Jg+b1A95tDBy=)TEG*5HxQ1I51=q!R0(4SO1Ed zlyS%L;bf`qZ3^(lRMIW9f`WdI`uh6*SxS<4Fcb#D_F&X$6wg&ev~k{hN0A7O30J<4 z*EZw7NM<~M;p(pZ+luy1NM|dJ+79^Kk5LC}n9iq^gmlJFsogAYH6+%v{pw76-~~dU z`cVbEua)Do3TfoXs+^si=1-1}mcaMG&7-fcKXYNa`~;jK(IN+qiYmfS!EbeScQ-zF zrw8PW!oB-zZT?n-1u4OdP;M?<3V4#*!V1CiWyQs`ON!rleJ7RiTcinzh#Z$2-Q>of zYeQ;kYF2?jg`flH3xi5b{KFMcTc{iCo8&(_Z+0sJg;mE>Z59YiiCloq`T{Wu9hee! z-$Bv<@$$!+-L4cFPWzZIAuQZ33iwv&!V8(}o11JXXlOrP|JN@NSwL#3t*4ht9LQe9yrDq(0dMpgulJ?$E**cb|zCV(bU}hGt#z2$nOANVRLiJSWr}S^c9eX z_yTEfX|s%-TMyvxVga_>M8=pyU+;Ng+QekgNN63t+gerS@+UZ0j9Px2y4J(rH@K;Z zFBWuteVwAhzuf=Uy=76Z|L*@Qb*d%z@5|x6?@n7VU`p_GvqR}I!tIDU!4Gk}!jK3; zAk>&5A|j}!ekvSQ+08Kt0O9NONJ&j?szpRZ#3*v~7kx4nNP`z zG;BugoVjYNu~1;97mlFB(9+UAgUV&M%BWa2h^=jHiJe_t`GR`g^Ggw#yjsG-dKmx@ z;lYYfa+mre(t}T=dK{G|CkE__4+G}s7v)&L-1?4S7*__^qy2r%ys{{p+2Xdgx3}q; z83Z86jpi6?*k*$PfioKiyk5$-kv-5&8B{rp& z=4N+c3`B6})a^tCS52XOFX^aKr41eS6WtDu%ow9db`OejvYUm3pfxXY z>(@t!fe&5dzhOL1m(w3XX|9jPdjNf4uH8SJ`K84nCMt>!uw;}V@hpHGg9A3yV*lyW zV|6M^WX~k~DHelf$m8Q|DY z`{BN1MnHt{nx2>)#!yO=H;M%#JOj#X$2`D?^qPm3KhayGDnioBV%CU!0`k|v=PcZm z9;+Z7Eq_pC6x)`K_kEd8wPvIeM$y=B=Op+7x5J72KHS?H-SCJAU3r9N@_vlcY=Fi1 zZ13-TCUzDV83D3s;fF~`X^43(KR^bWGWHhevME8tf_rZ0JKwrhmWnN7cLtQh)GgAR zI}!Ohz?m=)zm~#CD=DF%kKmCpkkZi|Bmp5Qwt1<>M$J;{1jr{jiWI*;DpnBcWSaFx zrGrly9ZK0aNxTxUTaPnoXv}bVdwY8U2_3R{GswB%=TFJ}4WoozH8dZHDqW-YNw*_r3DcUwcR8`I(s;8g0VP?pWT=#acTgK<})}oA?-= zeF!UmY9Qcqt1r7pF5-oykilMp(8&sOqHAt!d=4pcdMEMjo~fCb9N6?ns!0nr0cXzf zn>X{AnuTAvD=7PIvb%d5uI33tOstD}{pn2DQa?^JL%LYreiHZfg157$ zVSfXmcFK~2N6-YG`2(qz*T>IB_8aRR!PG!d`dV;p}E2Uf(gP8W_h6IP&CizE5#%`a#-dqs4u?J-l1G)nf86fdMedM8Ee@RNhw7XRW zW9>|!lEd`5IppZ=?+el4Bw=dmKSUTgO#}gop{6jt*yl5 z`1st1+tbFrEFRbA_1RU)I4N*)FlPZ+SlD{#D*CV|m)E1pHtbg7^0WKxM5V=$u&@fK zrZ%v|H|RU_G(c_>jO#oC(qE>R)26d8x#?e=OPGgMjI=ph**ni~9l(;o7)4KBU!E!< z7g{m74s1G5?nn35>36?v8pAb*hli(0WQJ`vuLd&W)K?MMaHAF#LOSe>l$DiT0E+Wf zP*9L1nWC@(glulJ+G0o-CVy(u&{HGo5ba)xOu}f4#3lfC~KqZj}@y)Hd_{aAlPx;N#x;@^qJu z20}nU;Hih}iy`FM%&Dx*etUg7`-)7!dF-(Z4dw4Eh+ge&mKc%-?VZgU2Q8MkeX=-NXidYd8&QE~Y`mjsjd;ffN(6*Vx*uB}` z-%sR3rKC!1zgY9F8kvCauokNQ$Doa^Ew-(V&G!PwVL(ed>H_p{btnGk>nSCjaZ`PZ zkOmJV!6TSsy07ob46xku^j*-G7tmaUbAQK4R&%rKA_#}zu~`;x@9s|O`;u@*fQ4`H z<9FC?kF-0sy|_D78n#%rn>rcPJ8kqeHa1!Tde%ucz}RiEiNZJG@YVDc6-Na*OFN8# zB>@A#={MkL=8#LrVsk94A0I#Sy?SH=)Ga_H7`nxn8A~}6RR>fMuT1AUaOR(>%H$x* zeKHNCd?a*Li~y-)1YShm638mvq_@Z-3MO z@i+KBL<%*8!pPysT;Q!gRGkekY+`hLBH){5d;kh*kEzQhAn>9I@SR}11?!}G->1L5 zfTH$&VQMgM5gQcf&If#C*A6W9m8U?F29=Z?$Pv~*EtIr_3vIy|fk zQ5OBH%#k6-g}Z|oPuQ*$a4wSC!Igm`Y2*w!x}LAkUL`SYfL>cg28IL$4hCC{4Nxyn zgepuNoVFkWkt1+;YhhGaU?I^N5QaiE%XQt%lmK-VcN<7XL_I+&Pj;NRBhw?CtB1H89AA>r+e)!D^mF=$W2hLf}`ECtXw>TDuh<*-d1KdE+#&dUfmy7Sy1eOiGDWqbWQ_|A3fvc|@ zzI~I~257R7m7^Vd@ii@owLt+`vogScWKaTbBPMyvc0NxIr z53Zgu{)-P@7{l_@r%y2yw0>t(v4W4qlbL^1C5Sj|)mdKekS=<}B!Xn0p?9i129xNT z{|o~3wn=t3lU>B`*wS%>#d0_eYqA0hj%h=u%d>CSn!U9cf+lWGg54GU>=D;OS@=xe zt1>@dZGU}TSZ+HxgA0|2s0E_nF-cP#`>h}Ya(l=v1@J3}?uXMh9D`}$As$2uvfu;$ zE!Gp{F~vij>1e_s)t`-mhOz zda=X;f}U?LcP-AN8}on6IP00AqW56=4#G8yyrP2^#V&wl*eG8gDl=1tiB0_CPs17E z}z~gGtCN zWC#{(giIM^@kM@~<$Bx42YK-@R?nb4% zSqVtculBzFe%kC+g10@M&FuB>KV)}<0nN+;RW==ii&jbHYnp(7O55u~jZGq6W;e*o z8Zq($1~Pq*!wVd>@3%>pwOXVctjk?qN3t?R{&f}T1kr`Ve6|Mz&L#pF5j!<+ot(lc zm2rO+vV3Kl-xGw^#Jup4Q@_Vq-w^TH!>vNY%^ogy7VBT>gNAR4*FADI=$A>WOCg1S z-Q}s2;mpndmV^g%lTI`(i-0%Q6n1j@M}y}#=cl_ftIKr3nNS@fB=8+H)|#s>z`rHy zg7H#QQ|m`q7WxeJ0NxAH1_|^G#PqG+wlovQYQ^89GquStq4Dn`{O#S`oaY*G>t*+7Dy zOqd)D4h-yYiyO7LO@c^kt_Ad|J50*J1x@kAFd0S|aY-P{A;jyLZUQ_UuN(CrL}_%; zX&W8@!h%o;)_%nIk$c7YH^fzAw=}E%9Wa$10!sIh7{C1*x#6nJZ zGWkr-ashUFD`d5Xb)ugv-_V7hZ3ye%0{F{+VjsOBTZVyMnbMrTE+h|J4T9A^`&mxGHXCYW_Nq;Ip!9 zB4iov;$*B&0TiX~E+ntE;}7*ZDDXJ&zalPoVppGX@2dg^E5jp(t3lFvd3o6D+SJM& z3jNIDCgN2pgzLQW*fiw#Zv^QfvY<9TVwh9IdI%rdRz_)bVGAg6Cxql?(S$_kv@W&q z=`a+M(Jv<2*xHF%PYT)`TC|4fezkA}JzyF2U-!MN zDP!rYhw+ww$7~)^uM1UJpx@_sY*vs3a{2}ImIgVc3*-IVY+o^Ra8NW?gLk4jTW{B& z0@lA-k4P}1z>~Tl0zn0&oSe75K(y3QSO3w;O6z)sroZ+To5l@TiNGsb_9aDMM5&Y) zHXHt_$d3u_s1!UrEU$oxScd}s!vNAqvD7^-ESW)zexreqOr@~k1tVRYE{+m(s2}oB zFHH%=f^=YMbB^jo<#zE3SbT7ksFw}+b;&2c0MD@2A5Vca@Fp3DMvg=+0xvwh{1`%c zel@53MMoGyApA{|Nt15<&1GrIZGYT^4?_nGQ0;U(G}a%n#@nsAKFFNIg4~XFIztf{ z81=OMD>mW5#{9%z1rz&Wq(Dyg5gW594Z=)i85X44mPfa}VIJfld|NSyZ8t^#YK!2FtpW4|p+8_TD>9M?#(IM>i8eTdQCjdXZ zp_Bz-WmrAr#5eyOk)=~WuSx%wkf3Vf>FHTgOP!dQ*wQ^P+R+in6`@9)GtvMpy@SGf zI!yU2 zHb4;l2QkUsrR4%dGpd@clWUuQ{x>gu0}(GVcD8e`3PBreWn5cZTf)q?EuDpK2o3

MKuoU z0nyM%*;3I9Z5dO0=cG+MaQeZqwgH0qYmh2q!BW47zaU=Da-y3k7?_cZ&P%`oHBV!B$?7cA zkF~w6ls^5TGNX7eG0GLK@<@Tx(L(bFjqFSSDVK2`zShM;lh3HODKCP4I`ToV(C;g@ zm338eFb+Ugx3qrr;m}pdd4B$?!)x%@uXS=m|EMWOa@gZqqSN5kY|UY(is-eusry=z zV{^2f6E_{`?i~q`8997YQ3r%iCT*E|Nac28uZ{+g#GPDSSA)jnRNr`3%&LOeRBqlM9fCah$E`=q9IjE-(Z@gFf@Nb zf^AVGA}S4X^Mw?7bFhnB;Q2X9_I{7dF^DB{+EtzQJAPsEgrzae5a)U-D9F4j^F*S9d$P^fBm;k{8H70e^6;mle zf?mMBrBlWk0==oMFt?oL^dBiiutwsv=#3?&0U;>9e%CE;IOOS@_kj6{<;%MtKYpZx$8%9b&XPS_Vr!SY*6OijYKJpq(EQ&$Slim3RthlhV!WnlmF$-O z+`_hP5Qy{PCqs{Fjx_12sA?M^4!H~T(HW}aNpJNez`?BSMLL?cOpBxT*DBH;X9Rx$ zSl-;Bp~eAqYL2S}i}&Bc%to^1Wq{NJ^;P0)fGnai%pTNORXwFKgEYbj6g?A~ z$2Pr7WAh1wW|iN_R+?e-kbVV_G(^;=R(R;{^+)2LOl@uZNZuf~2(6CFnZON7FBk>tX3gzYv4-cfgK>@?W9W>)u=X#%zP$L_5KoSIn9=qa zO6iLIaGF)teA62#&lGFpVvnWie%Np32%-Sve(2k`(5$6@_jB@iyGe-MhfR%H2mL>j7r*45KLl<4@Yg+0PpGa z6h2a|H>4>KsJjTUM^E~Wj+_c+-T+XViFn5_3_q|dih`vBmBI(mX)xlytE;#%4LEss z(ByTR+s@PqZ#_J&e&FWf5(o*RcOT@?q~+6eZPft?)wnyktVIFlad7KZ~4f|4idYU|s z12))jGA3-7QUZ_CRQ`z36w3pIPVX8Hn-xw0VNqxV9Dr23(a+g0j=~zAW>tInLGoAjtXp84y_%Nxl@8 zgw;j;_PClQ@QtEu2bcsN0DA5CKqQAi&8+w1t+d{Tdx1rp^Wl17;@9Zt=t`ewml${e zrYSTMBt8t9{c@X?Us)zzY>~Jo9>)ekU@gdkIJHPY!QGQ$M~l7lS8)$QiWUoQPPLe2 zu;Ayh#(IG0PL_#>hv%aRfyBG#pdC43tjckLelx}wp`oEX2(7|TC*G|70Es@{o$^^F zH|kmYJ;;~7J73<}saH}_i6W*&w3>W3l@o_r)U#VOQp?!HdIbPrMgjw~}p?P9EQ9K>Q zT{bqcId&CAA@;!A8*v$pe-c>Jf~*%i4n7HAh!I&`1%x$OFvs=M9)H2kd;T@~)oGAB zkY%qaaQ~*qdF!v>lesExbz2Z~_4=~?K zQ%ge(;7MzNFfkRhJI@02+Y4P{LxxNM_iXD3#{N3}?T^SAD`N1T1J4Eos2nT?s5qVi z1MhG-?1>MnWx@xvQd5Fnv( z1#G$!@Z(Y5PtqLM9hc+Ow=!V7}WMnICoxHXC02=jo32prQbX%2>^H>Y-r2)})Sx?skI_1l9zA2H`$ z7M~nt1+OWwGlg@Af}PzS9%&IKv*wKphQ!8czfuyPmd$ulNC=w4J4zl}_Xn++%G_Zj zo>UdJDaF9fL($-KoMXN!9;-zk9>NVX{KDG&ViRlVJyzhmV~6>IutAdHSJ zJYmVDJ@T8>$dZLUE3D;wqa*3#f{B`Ytb5!keVIN&p6zwTsbU0cCOsH=iisJ~1y5@S zuvusyz)uB_y2?h88y&F9>(bA~IsjaZItyDIYVRX}9{7bVE=TmXR@H@GhD!^UeT=q6 zt#N`ZT!TaMR8J6D*DRl6V`F=x9_YoQ0uK)<#wJ$rXdYSL-?{0v>3h$YyCsrAa@`Sn zKp1A~dt$K`6!eJj`tt@j{7n`KJAkvJN(Amnc8<h6TwGcN;7}VkOsc+F zrg0X-$+*^!fr6^hgJP@v<#NNolRmbsP5?DtYZsru!(+&k?YbSGlht^+Z^x^ zkR%uVuywcc>!}wHdFNMpKb*J>G|U?cd~Ymb&*vwf`0irEsHB42THJS^Ls>PM(p@M5 zABECHN^lIS?S2HX=3K&&u0N^~24B|w&zR{nwL+wY1d4V~i0tEL? z>OsetjZal4+XWhVZ;yVzJ4;jRDNBDN4TP)cFRJWA5Uh@U&dx`^BtQsQmF&>_2oRIu zQbeBsS?^-q_wTC4XU$e)EMD=Yu%`hCk>cu^a{P!%%JI z^Bd@xtr&dIge8Z6R;!Y9VBRJj#EEPcX8D~@=(6d0RhZjAPoEkw%rGy2a+i{V}w@C7Mq zyHnavcCm4~(Q_-RVf1DC($TSGnzVtlMu(dkDq+-k_9aLqK>lms#{Kb#ctR9K1;9n+&_Yb zw4Yb3%rkUcvRD@wU31q5tEz=i!Ugkbt_YJ;LA1yHAU83~sz*?&+9PO@=8o}Jr0nh_ z>fxGV*)YrV5!A6QP;I+JhgoACaV;Dj^)=c5eRRqcq~CgL<~%rrAWfuT$Kgh_z>(tUWw}wiy5UKv1awOu+^j zA3=xF5BSj3e>Woku1>7w=85oM?;wTztVnd?1+)dzVl_F?OK>X#DT33>*%B9y;;U#} zT~FVam3W(jpPohb7MfsmBs-X5_tZ6C@01eD(Qq_CE(m<~TJ~$UAMn9FgC1p_CtluK z4Vm2^#iPOIbTu$#)LsHKR{R($ay{IG=q!!NB(Y=aPZ$U<-O1%Q13yukAtt9{=Tp}o zmOp~37xS((xhpy0Wi)GM!j`4ZLp~HI(je1q9q*j+-Y&mvDSI#~H#%GrZHw=-M&NF$ z&_|6nKa857x!F#d){eVIxR+6bXIJU!SnH_C3t{rY&pQCn|*eO!|>Jg%7seyZG0or}z(7lv#{j zaTZy+W&ohRgHd;I>!gi(>g)Kapl*ria9ya#XgJm#oRuE(zE{lNXJ-ZP2=Oa zXosQpqv)ERpg8-Blft~ZNnPo()2zP9vVD;Z78CNKb>7QKN}V%X%ym8Ydtog|FgaEA zGz))0CoPZ!x5C*lNQ+rng2c6p*9 zlE3@no2rK$zeT18{E6}^Em~%C?1Q{39kD#mGWqdR>6Da(>j9@`0}Ov|mEY-Rix82D zXoFPEw9}ynNq?#_;+YYV6~dmj*7oq!4qDQ8@c#W$`@2z$H$S@DlS$3P{a;2Ix@ugj zQ(Rm5QOU+pK7!(dPw>G5hPItdDKw+u(FM!n>EIwC6w1hNZCz>uFC&zw56G0+MrJ~2 z+j=1pA!i%heS?!nMGuN;i}%R9Bd^pw(ps_Zyj784_iezeXF>W{$%dpH-D+trj3|>$ z^-8tc4n~@xAyncIRw!aa9Nfxc<9TF{pq8kI7J}%NC<+s+!)JQ4*P*mlzlgcb)u#uR zNIS zRiYbTPyT2uug;0(tNzS^JHNHa+|qdoCawO(yEN(Ajjo4{!l>~k`buX7E3a$^-PYNT zDk2iysyC)hjAP)QFMQ37hI}DHJtwZxzK%w`qgEADVZAIzURs|S(?`4FXd}V7aKSIX zIwIT79kP`LA^EnfiH9P$re#HM^33|Xji6Sa6v0ob;Q$&^(Fvp?6q2vVasr612x{}qZO@u77!r)1yeR8XDOH*v7T~jWqOU?8a%WtvA4I%>S zM8RedMy6euxv?>6IyNnj%e^KI#oK7FCrxpG&^}# zuwgXp+Y3#b`|Y~2X83Mo7nT>&*6G}K{UbWnNsh47^_OcZ)79q!E029gYdeNdX2_}) z*s=Wmw?B8}5fN*6x9#m6#MTpI&Iq)3I(~OeuZF6)9HS2Aa`r?`9u;y!98s@!RgVdd zs_Xov$Vmzb%s#?oj5;A}IM^c%H@%~D2Ky(vefE@LGNHenPKxs|K3zBRD|?%vBHw zpDD^4b2pFjP+!MFCM`QwhwSLK>&7IaQo(ksl$zhJFytRtj~`GFYskQR=P?)XhA*wAwqX$Iq(CWRD#C zmN+f(WCa4G0~W4KVv3njorMnr#*9iT9c7u_i`&of$O^r`Weded845T-QHJMqk{^Z_ z_(#uE-pu2GnOzu!=kbr&@x$g&BgxhNW) ze!nvzq>J6;$o!q5rT6xI)D?-&4^M@z2a4m8L}P1ywdMm1#a>#Ohh2Jk)KMZNm+VN} zwxZw^5%c1PgXVMBxtx&CK&ZX7djye?l;58!=Jj3nbJrRQ}Vfc9_(Mcxjn6;WUY(r>X<|7#+{o~`5#D+sM~JFGh+lKaV_G;$F4FTLt&L38co zdOwq3*B1=;ULH`afv}$HV}ig>3ZcTGNr-kkL-8V5ZH$tuB9k7b#WN?p| zehXHV1=1HNdBdRHRZ}JXeZry@M~5 z6I}g(jEoAda=WeozFH}czCH3BSnN8!IJ@k3S|mLGJaWgzL%Cv*tE;o6ym`mRM4`@7 zgsn28Bzv7`LVtc6-LL&2+GVfoK^Fap!o+RN0bmcQmp_~XcBaIn{42fF4EJG|!P{3+ zn!)WB+b8mmu`O{nyEYCuLj`3O3qmcDXx%xDpSO8?{?Q!KHtDb?)1!9NNMUq9znCx zjAF+tc}Hc1YkwMOJm9VXubLQ7)`uH@0~?DL`<%Z4ltVUTHVkWnE& z3*snkxJS1ZWWI``&ZO&lY$_egq73h8HO#t3nN}Sg_gB@2#^{f=d?wCas(=}~0E&Vm zyOC~;rBf2DQ=!;b`Pl|`8(aLGmUC(_bCWW|Pi#DEU+gf2eJQotAbE{T?O}Yn>bUuJ zCUq%3gs<cif&jW5R3e;`ix(hSD}D*qicwtYqvIShJ)(oih0H`p~jsYriQ( zU1{2(#z^a;j%Dkj+=yb37(f_rgNr4k(=8HsL) zNE;|{%3qc`EsRT5uh)j-dHfH(`+$QLh@!bXhBMzvwkhB1Wb^R5LKO7wCvxzOE4>9F z`UH2r{m@vs_aN@JAR~j6HGcIctB6-MyidnRSMj(HkX8}5)3%LqvwTNx9K(67J_sR4 z^cUCQ?LA{Hh@0^sf09bbKH4SeTh%1Uou3p|9|?Hi%YV}>A+~1{60mAq>>DSq!jp-= zP`!umUaH_ZFg;)4D}VkKl|*&{map!?BrYR9twcWVV7!(8c10{MAWnmbHAjXUOW8H1 z8_9GnQJ*X}Y391LluouA_qA%~X>vqiN%W9Kj`@FL@^^TsZJ%)Z)IG^pnp$t( zT6#8s4MAKK)@sLc=+idSuC!*iZq}N=gbLNHML?}n<=OV_2WAs!k@&dPd8l&ioZAdv zq4$Q;hL?XQWru zB=%AUj2IIWR-Hz$XD?i2@XN#T+}A;q=*i|LnsXoHLN9i&3yOHp8HsHYRC%7^Qz#|O zoIE`$<6dHo9GjOjC1toopRGuQ{`(vsvGd=2g-APlUSv?-GE2>82~aJxFXbIQvM2NZib)^mf2AWN3KhP#|s zLFo2pEMt+|@6%rPaU+92nrc;}^sXxt63mh0gU-}Sn7KECBJB238fLbqdUJTy^z}<; z%6hxvqx_|@*2mwDhS}g@3 zZRR;R2+eDgOzm4tEPI?*vPMd_I=4zc`4WB8+2|EM%S+U7 zU;D$GRT-=#uIwOvWvsN)Wr}ErPL!ZSy>)-A?g0%a$N7N`iFV+fF zMS8GUJ1Vn5H8!e7j)sCxvx|*1LiexQz&PKJ_Jmgb=E0~(cgoFKs4z7ai4V2$7 zj#E{Cil-DwQs`6$TSSX)nX9!jI4FCN8cmuvS3mC*I;*z8+<1r0WxuI?cA;nHzBJ`afs&?nd{K4L$&ZbvM;M)LlWL~D9Y~Tc*!kBD-WTU( zdZTZ~O6*5Sw&RyqXG$o;v-r49%~;X93{5RX1W`QSDijn8?-pgeH=2e^yofuo1ivSx z_=@Dv^_$aYqTk-+g?h^|1#k5*eOYq>y|f@s-cgYW)ZlJP^F`W@%JSVWm4Ai#cDJXt z4>^7mn;Kf0wLue;11S@bN!kjWbl16Luwir2u|ZqCkUZ&4N?kl;MlxhMv~^%eho$jC z@j&!jp_D!w*-o z`o;iTkLZ8`R)qR^VUBrqZgByJd*3u7X&?Of(&w`ygLl)X5W%upzB7&HhZ>VLD4X;< zsTC#S6*VOO>Om$-Bt6w14Cx?JxDVESk#e){P2h@2lrih%p0Gv1%*@UUXM-+bFioTv z!3$1=_xYxPU0>_ksUdcU&^Nm~cQa>~T~c|Wcn>N~%#t1k5VnhL!PPa!*HoeL_<6-} zhQLqAQ8*xP%Z#NP;3nT_nbvs(*?hexH@UXH!<^$2@+fP`&D^HTY{c_%4>Kvao|l)` za@6VL8$YzCU7XLjVO!?Fu@unraz(MB`hzqB; zU;$0^0H+F3H}8pVGEE+f%!$!{&Y}`~)Q=7`0^J4eFAv)1<+~*biz=6X#ARx_HWT{$ z;rc--%!9W4Ow?zl=%^HuXre1QWjtq>%sUi2*w_2UOveVT{E5LKVwKBp!_}%qPm-e& zMY3s9iM|PRQzA2C+0L9}pQGMgl*m)d>)3@6LD9PJZ8IY*<>$RWM2Qi7iliqk-#Vx- zD&f`lIPjuqpMR;(&mx*rffK+TZiriB)khHim3A#0_hT~Lc1YOT!a3hchf_bmf*DP1 z?6c`lY!`6r;b@ZsHLDE)NQ(?ah`$q7aS?eqG>IzlX0^9!;xMxXKGECbE=toh^g+qh zhdf;}A^Outj7JcyeX5#{C6hnc;i-r5`T5t52BAIKWeQF%80TJ(LLV>+AS|bs(k~V;!PE%_G0wZ#s26 zJAp1Xa!pdUx(m=ZXa=iQPFa}DuPeklXrYiCe!tB_rGa766$_Rddqr7Tg^XYxj2Ehy5V9qcVfi+DE80Udmz3aX3L;|pycPftK1@ z(PEmnBpb%=yn)vRmj#ug_JuzPyM8p&_-^sDnlJvOSDv;T;WVXnjY-UBgCQnWoFN^# zgshajpLoaWfR3($RtnA6EF2>>@QK%2;7FO45|1HU;nRG;>(C_{uUi1p#vB|S;HwrO zw^>jlj{HwXt9g#Rc@uNx$0d##Mwd88b0(I7N*N`Ig(e~ainK*IGqQf)G7XzCo}Vqm ztdJGl)?SEH|xguW$-$e7BM`C95j-EgM=Q%3A*zHTyNrGehxM6ulp z+(ATy>Oa}hfh9^2vVC~rNFP&rqn5}@gOsS5>G46_D&%>z zX$7<~J6`!#ng0Jo0{!ure7}6L%_`f!?Lq%ogz5?YeJ23l{d0GWfoih??X z2t$?7=TSvbOa#HG@9WQ)5jg2c1LOrDJv0zhU>!=d0urf+68MEy!9x5Bwsc<4~LX0wG@Eu4ophM`L5)025&+{46pOSmuj`6D( zy^AgkZ+kYd1}71&4S z{G7n#uVNHnZr$i72>Jo+1njHj_jma}{6tT}YbT$mO|`#THfjNMV6)lK15 & node.numchar==="numeric") | (yVals.length>5 & node.numchar==="character")) {plotXaxis=false;} - var maxY = d3.max(yVals); + var maxY = d3.max(yVals); // in the future, set maxY to the value of the maximum confidence limit var minX = d3.min(xVals); var maxX = d3.max(xVals); @@ -518,69 +539,127 @@ function bars(node, div) { return y(d); }) .attr("fill", "#1f77b4"); + - // draw error bars - if (yVals.length <= 20) { //do not display error bars if the number of bins exceeds 20 - plotsvg.selectAll("line") - .data(yVals) - .enter() - .append("line") - .style("stroke", "black") - .attr("x1", function(d, i){ - return x(xVals[i]-0.5+barPadding) + rectWidth/2 - }) - .attr("y1", function(d) { - return y(maxY - d) - .1*y(d); - }) - .attr("x2", function(d, i){ - return x(xVals[i]-0.5+barPadding) + rectWidth/2 - }) - .attr("y2", function(d) { - return y(maxY - d) + .1*y(d); - }) - - //draw top ticks on error bars - //need to fix the height of the graphs - the tops of error bars are getting cut off - plotsvg.selectAll(".topTick") - .data(yVals) - .enter() - .append("line") - .attr("class", "topTick") - .style("stroke", "black") - .attr("x1", function(d, i){ - return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth - }) - .attr("y1", function(d) { - return y(maxY - d) - .1*y(d); - }) - .attr("x2", function(d, i){ - return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth - }) - .attr("y2", function(d) { - return y(maxY - d) - .1*y(d); - }); + // draw error bars, threshold line and extra bin + if (private) { + if (yVals.length <= 20) { //do not display vertical portions of error bars if the number of bins exceeds 20 + plotsvg.selectAll("line") + .data(yVals) + .enter() + .append("line") + .style("stroke", "black") + .attr("x1", function(d, i){ + return x(xVals[i]-0.5+barPadding) + rectWidth/2 + }) + .attr("y1", function(d) { + return y(maxY - d) - .1*y(d); + }) + .attr("x2", function(d, i){ + return x(xVals[i]-0.5+barPadding) + rectWidth/2 + }) + .attr("y2", function(d) { + return y(maxY - d) + .1*y(d); + }) + + //draw top ticks on error bars + //need to fix the height of the graphs - the tops of error bars are getting cut off + plotsvg.selectAll(".topTick") + .data(yVals) + .enter() + .append("line") + .attr("class", "topTick") + .style("stroke", "black") + .attr("x1", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding)//make tick bigger to increase visibility + } else { + return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth + } + }) + .attr("y1", function(d) { + return y(maxY - d) - .1*y(d); + }) + .attr("x2", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding) + rectWidth //make tick bigger to increase visibility + } else { + return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth + } + }) + .attr("y2", function(d) { + return y(maxY - d) - .1*y(d); + }); + + // draw bottom ticks of error bars + plotsvg.selectAll(".bottomTick") + .data(yVals) + .enter() + .append("line") + .attr("class", "bottomTick") + .style("stroke", "black") + .attr("x1", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding) + } else { + return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth + } + }) + .attr("y1", function(d) { + return y(maxY - d) + .1*y(d); + }) + .attr("x2", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding) + rectWidth + } else { + return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth + } + }) + .attr("y2", function(d) { + return y(maxY - d) + .1*y(d); + }) + } + else { + plotsvg.selectAll(".denseError") + .data(yVals) + .enter() + .append("rect") + .attr("class", "denseError") + .attr("x", function(d, i) { + return x(xVals[i]-0.5+barPadding); + }) + .attr("y", function(d) { + return y(maxY - d) - .1*y(d); + }) + .attr("width", rectWidth) + .attr("height", function(d) { + return (y(maxY - d) + .1*y(d))-(y(maxY - d) - .1*y(d)); + }) + .attr("fill", "silver"); + } + + //if statement for stability histograms + //extra stability bin + var excl = 30; + plotsvg.append("rect") + .attr("x", x(maxX+0.5-barPadding)) + .attr("y", y(maxY) - excl) + .attr("width", rectWidth) + .attr("height", excl) + .attr("fill", "silver") + + //threshold line + // var threshold = 25; + + // plotsvg.append("line") + // .style("stroke", "black") + // .attr("x1", x(minX-0.5+barPadding)) + // .attr("y1", y(maxY) - threshold) + // .attr("x2", x(maxX+0.5-barPadding)+rectWidth) + // .attr("y2", y(maxY) - threshold) + } - // draw bottom ticks of error bars - plotsvg.selectAll(".bottomTick") - .data(yVals) - .enter() - .append("line") - .attr("class", "bottomTick") - .style("stroke", "black") - .attr("x1", function(d, i){ - return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth - }) - .attr("y1", function(d) { - return y(maxY - d) + .1*y(d); - }) - .attr("x2", function(d, i){ - return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth - }) - .attr("y2", function(d) { - return y(maxY - d) + .1*y(d); - }) - }; - + if(plotXaxis) { plotsvg.append("g") .attr("class", "x axis") @@ -1178,7 +1257,7 @@ function barsNode(node, obj) { .attr("y", function(d) { return y(maxY - d); }) - .attr("width", x(minX + 0.5 - 2*barPadding) ) // the "width" is the coordinate of the end of the first bar + .attr("width", x(minX + 0.5 - 2*barPadding)) // the "width" is the coordinate of the end of the first bar .attr("height", function(d) { return y(d); }) diff --git a/tworavens/LICENSE b/tworavens/LICENSE new file mode 100644 index 0000000..0bc47f3 --- /dev/null +++ b/tworavens/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2013, Michael Bostock +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* The name Michael Bostock may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tworavens/README.md b/tworavens/README.md new file mode 100644 index 0000000..15057ad --- /dev/null +++ b/tworavens/README.md @@ -0,0 +1,17 @@ + + +This is Jessica's branch for visualizations. + +**TwoRavens** is a system of interlocking statistical tools for data exploration, analysis, and meta-analysis. The first to be released is an interface for quantitative analysis, that allows users at all levels of statistical expertise to explore their data, describe their substantive understanding of the data, and appropriately construct statistical models. This integrates with Dataverse ([Project](http://datascience.iq.harvard.edu/about-dataverse)|[GitHub](https://github.com/IQSS/dataverse)) and Zelig ([Project](http://zeligproject.org)|[GitHub](https://github.com/IQSS/Zelig)), through a portable, lightweight, browser-based and gesture-driven interface, allowing users to run statistical models available in Zelig on data archived in Dataverse. + +Project page and publications available at: +http://datascience.iq.harvard.edu/about-tworavens + +To demo TwoRavens using replication data from Fearon and Laitin's 2003 article, *Ethnicity, Insurgency, and Civil War*: +https://dataverse-demo.iq.harvard.edu/dataexplore/gui.html?dfId=470& + +

+ +![Example Page](images/example2Rpage.png) + + diff --git a/tworavens/app.css b/tworavens/app.css new file mode 100644 index 0000000..c2bc074 --- /dev/null +++ b/tworavens/app.css @@ -0,0 +1,362 @@ +svg { + background-color: #FFF; + cursor: default; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + -o-user-select: none; + user-select: none; +} + +#subset { + /*position: absolute;*/ + float:left;margin-right:.5em; + width: 100%; + height: 100%; + padding: 10px; + overflow:scroll; + background-color: white; + /*-webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; + -webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4); + -moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4); + box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);*/ + pointer-events: none; +} + +#setx { + /*position: absolute;*/ + float:left;margin-right:.5em; + width: 100%; + height: 100%; + padding: 10px; + overflow:scroll; + background-color: white; + /*-webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; + -webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4); + -moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4); + box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);*/ +/* pointer-events: none;*/ +} + +.hidden { + display: none; +} + +.arc path { + stroke: #fff; +} + +svg:not(.active):not(.ctrl) { + cursor: crosshair; +} + +path.link { + fill: none; + stroke: #000; + stroke-width: 2px; + cursor: default; +} + +svg:not(.active):not(.ctrl) path.link { + cursor: pointer; +} + +path.link.selected { + stroke-dasharray: 10,3; +} + +path.link.dragline { + pointer-events: none; +} + +path.link.hidden { + stroke-width: 0; +} + +circle.node { + stroke-width: 1.5px; + cursor: pointer; +} + +text { + font: 12px sans-serif; + pointer-events: none; +} + +text.id { + text-anchor: middle; + font-weight: bold; +} + +.left { + width: 33.3%; + height:600px; + box-sizing: border-box; margin: 0; + overflow:scroll; +} +#main svg { + width:100%; + height:600px; +} +#main.svg-leftpanel svg, #main.svg-rightpanel svg {width: 100%;} /* This is size when left/right panel minimized. Was: calc(100% - 300px);}*/ +#main.svg-leftpanel.svg-rightpanel svg {width: 100%;} /* Was: calc(100% - 300px);} /* +/* Above changes fix issue when screen gets very small, and right margin is fixed at 300px, obscuring central display, even while left tab is shrinking below 300px */ + + +/* #main.svg-marg-left svg {margin-left:0px;} +#main.svg-marg-right svg {margin-right:0px;} */ + +#option.navbar { + padding:.5em; + margin-bottom:0; +} +#option { + position:relative; +} + +div.popover.variables { + max-width:none; + width:300px; +} +div.popover.variables div.popover-content.form-horizontal { + padding:0; +} +div.popover.variables div.popover-content.form-horizontal .form-group { + margin-bottom:0; +} + +#leftpanel { + border:1px solid #ADADAD; + width: 20%; + height:578px; + position:absolute;top:10px;left:10px; + background:#F9F9F9; + padding-right:16px;padding-left:0;padding-top:0; + z-index:25; +} +#leftpanel #leftContentArea div {display:none;} +#leftpanel #leftContentArea div.active {display:block;} +#leftpanel.expandpanel {width:40%;} +#leftpanel.closepanel {width:1px;} +#leftpanel.closepanel #leftpaneltitle, #leftpanel.closepanel div.btn-toolbar, #leftpanel.closepanel div.row-fluid.closepanel {display:none;} + +#rightpanel { + border:1px solid #ADADAD; + width:20%; + height:578px; + position:absolute;top:10px;right:10px; + background:#F9F9F9; + padding-left:16px;padding-right:0;padding-top:0; + z-index:25; +} +#rightpanel #rightContentArea div {display:none;} +#rightpanel #rightContentArea div.active {display:block;} +#rightpanel.expandpanel {width:40%;} +#rightpanel.closepanel {width:1px;} +#rightpanel.closepanel #rightpaneltitle, #rightpanel.closepanel div.btn-group-justified, #rightpanel.closepanel div.row-fluid.closepanel {display:none;} + +div.sidepanel div.panelbar { + position:absolute; +} +#leftpanel div#toggleLpanelicon.panelbar { + left:calc(100% - 16px); +} +#rightpanel div#toggleRpanelicon.panelbar { + right:calc(100% - 16px); +} +div.sidepanel div.panelbar span { + display: block; + width:16px; + height:576px; + text-align: center; + padding-top:258px; + font-size:.75em; + color:#ADADAD; + background:#eee; +} + +#main { + border:1px solid #ADADAD; + width: 100%; + margin-bottom:50px; /* This is the hard coded height of the ticker div. Was 160px; which gave too much padding and empty bottom space.*/ + position: relative; +} + +#spacetools { + z-index: 17; +} +.spaceTool { + top:0; + right:21%; + margin-right:10px; + margin-top:10px; + position:absolute; +} +.spaceTool button:first-child { + margin-right:1em; +} +.spaceTool button span { + font-size:1em; + color:#818181; + pointer-events:none; +} + +#transformations { + z-index:33; + height:8%; + width:14%; + right:200px; + top:14px; + position:absolute; +} +#transformations ul, #transformations ul li { + list-style:none; + margin-left:0; + padding-left:0; +} +#transformations ul li { + padding:1px 4px; + text-align: left; +} +#transSel li:hover { background-color:rgba(250, 128, 114, 0.5); cursor:pointer;} +#transList li:hover { background-color:rgba(250, 128, 114, 0.5); cursor:pointer;} + +.legendary { + width:10%; + position:absolute; + bottom:0; + right:21%; + margin-right:10px; + margin-bottom:10px; +} +.legendary .clearfix { + margin-bottom:4px; +} +.legendary .rectColor { + float:left; + width:20px; + height:20px; + margin-right:4px; + /*opacity: 0.5;*/ +} +.legendary .rectColor circle { + opacity: 0.5; +} +.legendary .rectLabel { + float:left; +} + +.logbox { + width:15%; + position:absolute; + bottom:0; + left:21%; + margin-left:10px; + margin-bottom:10px; +} +.logbox .clearfix { + margin-bottom:4px; +} +.logbox .rectColor { + float:left; + width:20px; + height:20px; + margin-left:4px; + opacity: 0.5; +} +.logbox .rectLabel { + float:left; +} + +#sandbox { + width:500px; + height:400px; +} + +/* p { padding-left: 15px; } */ + +path { + fill: steelblue; +} + +.axis path, +.axis line { + fill: none; + stroke: #000; + shape-rendering: crispEdges; +} + +.brush .extent { + stroke: #fff; + fill-opacity: .125; + shape-rendering: crispEdges; +} + +.handle { + fill: #fff; + stroke: #000; + stroke-opacity: .5; + stroke-width: 1.25px; + pointer-events: fill; +} + +table, th, td { + border-collapse: collapse;text-align:right; +} +td { + padding:4px; +} + +/* Carousel */ +.carousel-indicators { + top:20px; + bottom:auto; +} +.carousel-indicators li { + border: 1px solid #818181; +} +.carousel-indicators li.active { + background-color: #818181; +} +.carousel-indicators li#create, .carousel-indicators li#delete { + border: 0; + border-radius: 0; + background-color: inherit; + text-indent:0; + font-size:12px; + width:12px; + height:12px; + line-height:12px; +} +.carousel-indicators li#create .glyphicon { + top:0; +} + +.carousel-linked-nav, +.item img { + display: block; + margin: 0 auto; +} + +.carousel-linked-nav { + width:200px; + margin: 10px auto; +} +.carousel-linked-nav li {position:relative;} + +#carouselLeft {position:absolute;top:50%;left:calc(16px + 20%);z-index:30;font-size:2em;} +#carouselRight {position:absolute;top:50%;right:calc(16px + 20%);z-index:30;font-size:2em;} + +.lowerError { + fill: LightSteelBlue; + stroke-width: 0; +} + +.upperError { + fill: #2d5474; + stroke-width: 0; +} diff --git a/tworavens/app.js b/tworavens/app.js new file mode 100644 index 0000000..d7e67da --- /dev/null +++ b/tworavens/app.js @@ -0,0 +1,837 @@ + +////////// +// Globals + +// set up SVG for D3 + +//var leftpanel = d3.select("body") +//.append('svg'); + + +var svg = d3.select("#main.left") +.append('svg'); +//.attr('width', width) +//.attr('height', height); +var tempWidth = d3.select("#main.left").style("width") +var width = tempWidth.substring(0,(tempWidth.length-2)); + +var tempHeight = d3.select("#main.left").style("height") +var height = tempHeight.substring(0,(tempHeight.length-2)); + +//console.log(width) +//console.log(height) + +var placeholder = d3.select("#rightpanel.left") +.append('svg'); + +// .attr('y',-1800) +//.attr('width', 200) +//.attr('height', 200); + +//var varpanel = d3.select("#leftpanel.left") +//.append('svg') + + + +var forcetoggle=true; +var estimated=false; + +// this is the initial color scale that is used to establish the initial colors of the nodes. allNodes.push() below establishes a field for the master node array allNodes called "nodeCol" and assigns a color from this scale to that field. everything there after should refer to the nodeCol and not the color scale, this enables us to update colors and pass the variable type to R based on its coloring +var colors = d3.scale.category10(); + +var colorTime=false; +var timeColor = d3.rgb("black"); + +var colorCS=false; +var csColor = d3.rgb("white"); + +var varColor = d3.rgb("aliceblue"); +var selVarColor = d3.rgb("salmon"); + + + // Radius of circle +var allR = 40; + + //Width and height for histgrams +var barwidth = 1.3*allR; +var barheight = 0.5*allR; +var barPadding = 0.35; +var barnumber =7; + + +var arc0 = d3.svg.arc() + .innerRadius(allR + 5) + .outerRadius(allR + 20) + .startAngle(0) + .endAngle(3.2); + +var arc1 = d3.svg.arc() + .innerRadius(allR + 5) + .outerRadius(allR + 20) + .startAngle(0) + .endAngle(1); + +var arc2 = d3.svg.arc() + .innerRadius(allR + 5) + .outerRadius(allR + 20) + .startAngle(1.1) + .endAngle(2.1); + +var arc3 = d3.svg.arc() + .innerRadius(allR + 5) + .outerRadius(allR + 20) + .startAngle(2.2) + .endAngle(3.2); + + + + // From .csv +var lastNodeId = 0; +var dataset2 = []; +var valueKey = []; +var hold = []; +var allNodes = []; + +d3.tsv("data/use_ex1_short.tsv", function(data) { + dataset2=data; + valueKey = d3.keys(data[0]); // the variables names + + for (var i = 0; i < valueKey.length; i++) { + myvalues=[]; + for (var k =0; k 2) {return varColor;} + else {return selVarColor;} + }); + + layout(); + + }); // end data load + + +function layout() { + var myValues=[]; + + var nodes = [allNodes[0], allNodes[1], allNodes[2]]; + // var update = function () { + // console.log(nodes); + // if(nodes.length < 3) {return;} + + // these are the initial links (arrows drawn) among the nodes + var links = [ + {source: nodes[1], target: nodes[0], left: false, right: true }, + {source: nodes[0], target: nodes[2], left: false, right: true } + ]; + + // init D3 force layout + var force = d3.layout.force() + .nodes(nodes) + .links(links) + .size([width, height]) + .linkDistance(150) + .charge(-800) + .on('tick',tick); // .start() is important to initialize the layout + + // define arrow markers for graph links + svg.append('svg:defs').append('svg:marker') + .attr('id', 'end-arrow') + .attr('viewBox', '0 -5 10 10') + .attr('refX', 6) + .attr('markerWidth', 3) + .attr('markerHeight', 3) + .attr('orient', 'auto') + .append('svg:path') + .attr('d', 'M0,-5L10,0L0,5') + .attr('fill', '#000'); + + svg.append('svg:defs').append('svg:marker') + .attr('id', 'start-arrow') + .attr('viewBox', '0 -5 10 10') + .attr('refX', 4) + .attr('markerWidth', 3) + .attr('markerHeight', 3) + .attr('orient', 'auto') + .append('svg:path') + .attr('d', 'M10,-5L0,0L10,5') + .attr('fill', '#000'); + + // line displayed when dragging new nodes + var drag_line = svg.append('svg:path') + .attr('class', 'link dragline hidden') + .attr('d', 'M0,0L0,0'); + + // handles to link and node element groups + var path = svg.append('svg:g').selectAll('path'), + circle = svg.append('svg:g').selectAll('g'); + + // mouse event vars + var selected_node = null, + selected_link = null, + mousedown_link = null, + mousedown_node = null, + mouseup_node = null; + + function resetMouseVars() { + mousedown_node = null; + mouseup_node = null; + mousedown_link = null; + } + + // update force layout (called automatically each iteration) + function tick() { + // draw directed edges with proper padding from node centers + path.attr('d', function(d) { + var deltaX = d.target.x - d.source.x, + deltaY = d.target.y - d.source.y, + dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY), + normX = deltaX / dist, + normY = deltaY / dist, + sourcePadding = d.left ? allR+5 : allR, + targetPadding = d.right ? allR+5 : allR, + sourceX = d.source.x + (sourcePadding * normX), + sourceY = d.source.y + (sourcePadding * normY), + targetX = d.target.x - (targetPadding * normX), + targetY = d.target.y - (targetPadding * normY); + return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY; + }); + + // if(forcetoggle){ + circle.attr('transform', function(d) { + return 'translate(' + d.x + ',' + d.y + ')'; + }); + // }; + + } + + + // add a listerner to leftpanel.left. every time a variable is clicked, nodes updates and background color changes + d3.select("#leftpanel.left").selectAll("p") + .on("click", function(){ + d3.select(this) + .style('background-color',function(d) { + var myText = d3.select(this).text(); + var myColor = d3.select(this).style('background-color'); + if(d3.rgb(myColor).toString() === varColor.toString()) { + if(nodes.length==0) { + nodes.push(findNode(myText)); + nodes[0].reflexive=true; + } + else {nodes.push(findNode(myText));} + return selVarColor; + } + else { + nodes.splice(findNode(myText)["index"], 1); + spliceLinksForNode(findNode(myText)); + return varColor; + } + + }); + restart(); + }); + + // update graph (called when needed) + function restart() { + // nodes.id is pegged to allNodes, i.e. the order in which variables are read in + // nodes.index is floating and depends on updates to nodes. a variables index changes when new variables are added. + // many changes have been made below from nodes.id to nodes.index. + // console.log(nodes); + + + if(forcetoggle) + { + force.gravity(0.1); + force.charge(-800) + force.resume(); + } + else + { + force.gravity(0); + force.charge(0) + force.stop(); + } + + // path (link) group + path = path.data(links); + + // update existing links + path.classed('selected', function(d) { return d === selected_link; }) + .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; }) + .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; }); + + + // add new links + path.enter().append('svg:path') + .attr('class', 'link') + .classed('selected', function(d) { return d === selected_link; }) + .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; }) + .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; }) + .on('mousedown', function(d) { + if(d3.event.ctrlKey) return; + + // select link + mousedown_link = d; + if(mousedown_link === selected_link) selected_link = null; + else selected_link = mousedown_link; + selected_node = null; + restart(); + }); + + // remove old links + path.exit().remove(); + + + + + + // circle (node) group + // NB: the function arg is crucial here! nodes are known by id, not by index! + // VJD: these nodes are known by index, an attribute of each object in the array. it's confusing, but the id, as an attribute, is pegged to allNodes. + circle = circle.data(nodes, function(d) {return d.id; }); + + // update existing nodes (reflexive & selected visual states) + //d3.rgb is the function adjusting the color here. + circle.selectAll('circle') + .classed('reflexive', function(d) { return d.reflexive; }) + .style('fill', function(d){ + var myIndex = findNodeIndex(d.name); + return (d === selected_node) ? d3.rgb(d.nodeCol).brighter() : d3.rgb(d.nodeCol); // IF d is equal to selected_node return brighter color ELSE return normal color + }) + .on('click',function() { + d3.select(this) + .style('fill', function(d) { + if(colorCS) { + colorCS=false; + d.nodeCol = d3.rgb(csColor); + // console.log(d.id); d.id is literally the id number colors() is literally a scale declared at the top + return (d3.rgb(csColor)); + // here you want to do: colors(d.id) = csColor + } + else if(colorTime){ + colorTime=false; + d.nodeCol = d3.rgb(timeColor); + return (d3.rgb(timeColor)); + } + else if(d === selected_node){ + return (d3.rgb(d.nodeCol).brighter()); + } + else { + return(d3.rgb(d.nodeCol)); + } + + }); + }); + + /* + + // circle (node) group + // NB: the function arg is crucial here! nodes are known by id, not by index! + circle = circle.data(nodes, function(d) { return d.id; }); + // update existing nodes (reflexive & selected visual states) + circle.selectAll('circle') + .style('fill', function(d) { return (d === selected_node) ? d3.rgb(colors(d.id)).brighter().toString() : colors(d.id); }) // IF d is equal to selected_node return brighter color ELSE return normal color + .classed('reflexive', function(d) { return d.reflexive; }); */ + + + + // add new nodes + + var g = circle.enter().append('svg:g'); + + g.selectAll("rect") + .data(function(d){return allNodes[d.id].count;}) // notice the change to allNodes to maintain consistent indexing + .enter() + .append("rect") + .attr("x", function(d, i) { + return i * (barwidth / barnumber) - 0.5 * barwidth; //barnumber should become local to each variable + }) + .attr("y", function(d) { + return - d * barheight; //Height minus data value + }) + .attr("width", barwidth / barnumber - barPadding) //barnumber should become local to each variable + .attr("height", function(d) { + return d * barheight; //data is scaled [0,1] + }) + .attr("fill", "#4F4F4F") + // .call(xAxis) + ; + + + + + g.append("path") + .attr("d", arc1) + .style("fill", "steelblue") + .attr("fill-opacity", 0) + .on('mouseover', function(d){ + if(estimated){ + if(nodes[d.index].reflexive){ + d3.select(this).transition() .attr("fill-opacity", .9) + .delay(0) + .duration(100); //.attr('transform', 'scale(2)'); + } + } + }) + .on('mousedown',function(d){ + var test=0; + placeholder.selectAll("image").data([0]) + .enter() + .append("svg:image") + .attr("xlink:href", "data/gr1.jpeg") + .attr("width", 200) + .attr("height", 200); + }) + .on('mouseout', function(d){ + if(nodes[d.index].reflexive){ + d3.select(this).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); //.attr('transform', 'scale(2)'); + } + }); + + g.append("path") + .attr("d", arc2) + .style("fill", "steelblue") + .attr("fill-opacity", 0) + .on('mouseover', function(d){ + if(estimated){ + if(nodes[d.index].reflexive){ + d3.select(this).transition() + .attr("fill-opacity", .9) + .delay(0) + .duration(100); //.attr('transform', 'scale(2)'); + } + } + }) + .on('mousedown',function(d){ + var test=0; + placeholder.selectAll("image").data([0]) + .enter() + .append("svg:image") + .attr("xlink:href", "data/gr7.jpeg") + .attr("width", 200) + .attr("height", 200); + }) + .on('mouseout', function(d){ + if(nodes[d.index].reflexive){ + d3.select(this).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); //.attr('transform', 'scale(2)'); + } + }); + + g.append("path") + .attr("d", arc3) + .style("fill", "steelblue") //function(d) { return (d === selected_node) ? d3.rgb(colors(d.id)).brighter().toString() : colors(d.id); }) + .attr("fill-opacity", 0) + .on('mouseover', function(d){ + if(estimated){ + if(nodes[d.index].reflexive){ + d3.select(this).transition() .attr("fill-opacity", .9) + .delay(0) + .duration(100); + } + } + }) + .on('mousedown',function(d){ + var test=0; + placeholder.selectAll("image").data([0]) + .enter() + .append("svg:image") + .attr("xlink:href", "data/gr8.jpeg") + .attr("width", 200) + .attr("height", 200); + }) + .on('mouseout', function(d){ + if(nodes[d.index].reflexive){ + d3.select(this).transition() .attr("fill-opacity", 0) + .delay(100) + .duration(500); //.attr('transform', 'scale(2)'); + } + }); + + // allowing graphics to adjust for size + d3.select("#rightpanel.left").selectAll("image") + .on("mouseover", function() { + + d3.select("#rightpanel.left").style("width", "600px"); + + myWidth = d3.select("#rightpanel.left").style("width"); + myWidth = myWidth.substring(0,(myWidth.length-2)); + + myHeight = d3.select("#rightpanel.left").style("height"); + myHeight = myHeight.substring(0,(myHeight.length-2)); + + // console.log(d3.select(this).attr("width")); + d3.select(this) + .attr("width", myWidth) + .attr("height", myHeight); + }) + .on("mouseout", function() { + d3.select("#rightpanel.left").style("width", "200px"); + + d3.select(this) + .attr("width", 200) + .attr("height", 200); + }); + + + g.append('svg:circle') + .attr('class', 'node') + .attr('r', allR) + .style('fill', "yellow")// { + // console.log(d); + //var myIndex = findNodeIndex(d.name); + //return (d === selected_node) ? d3.rgb(d.nodeCol).brighter().toString() : d.nodeCol; }) + .style('opacity', "0.5") + // .style( fill: url(#fade); ) + .style('stroke', function(d) { + var myIndex = findNodeIndex(d.name); + return d3.rgb(d.nodeCol).darker().toString(); }) + .classed('reflexive', function(d) { return d.reflexive; }) + .on('mouseover', function(d) { + if(!mousedown_node || d === mousedown_node) return; + // enlarge target node + d3.select(this).attr('transform', 'scale(1.1)'); + }) + .on('mouseout', function(d) { + if(!mousedown_node || d === mousedown_node) return; + // unenlarge target node + d3.select(this).attr('transform', ''); + }) + .on('mousedown', function(d) { + if(d3.event.ctrlKey) return; + + // select node + mousedown_node = d; + if(mousedown_node === selected_node) selected_node = null; + else selected_node = mousedown_node; + selected_link = null; + + // reposition drag line + drag_line + .style('marker-end', 'url(#end-arrow)') + .classed('hidden', false) + .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y); + + restart(); + }) + .on('mouseup', function(d) { + if(!mousedown_node) return; + + // needed by FF + drag_line + .classed('hidden', true) + .style('marker-end', ''); + + // check for drag-to-self + mouseup_node = d; + if(mouseup_node === mousedown_node) { resetMouseVars(); return; } + + // unenlarge target node + d3.select(this).attr('transform', ''); + + // add link to graph (update if exists) + // NB: links are strictly source < target; arrows separately specified by booleans + var source, target, direction; + if(mousedown_node.id < mouseup_node.id) { + source = mousedown_node; + target = mouseup_node; + direction = 'right'; + } else { + source = mouseup_node; + target = mousedown_node; + direction = 'left'; + } + + + + var link; + link = links.filter(function(l) { + return (l.source === source && l.target === target); + })[0]; + + if(link) { + link[direction] = true; + } else { + link = {source: source, target: target, left: false, right: false}; + link[direction] = true; + links.push(link); + } + + // select new link + selected_link = link; + selected_node = null; + restart(); + }); + + // show node Names + g.append('svg:text') + .attr('x', 0) + .attr('y', 15) + .attr('class', 'id') + .text(function(d) { return d.name; }); + + // remove old nodes + circle.exit().remove(); + + // set the graph in motion + if(forcetoggle){ + force.start(); + } + + if(forcetoggle) + { + force.gravity(0.1); + force.charge(-800) + force.resume(); + } + else + { + force.gravity(0); + force.charge(0) + force.stop(); + } + } //end restart function + + + function mousedown() { + // prevent I-bar on drag + d3.event.preventDefault(); + + // because :active only works in WebKit? + svg.classed('active', true); + + if(d3.event.ctrlKey || mousedown_node || mousedown_link) return; + + // insert new node at point + // var point = d3.mouse(this), + // node = {id: ++lastNodeId, reflexive: false}; + // node.x = point[0]; + // node.y = point[1]; + // nodes.push(node); + + restart(); + } + + function mousemove() { + if(!mousedown_node) return; + + // update drag line + drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]); + + restart(); + } + + function mouseup() { + if(mousedown_node) { + // hide drag line + drag_line + .classed('hidden', true) + .style('marker-end', ''); + } + + // because :active only works in WebKit? + svg.classed('active', false); + + // clear mouse event vars + resetMouseVars(); + } + + function spliceLinksForNode(node) { + var toSplice = links.filter(function(l) { + return (l.source === node || l.target === node); + }); + toSplice.map(function(l) { + links.splice(links.indexOf(l), 1); + }); + } + + // only respond once per keydown + var lastKeyDown = -1; + + function keydown() { + d3.event.preventDefault(); + + if(lastKeyDown !== -1) return; + lastKeyDown = d3.event.keyCode; + + // ctrl + if(d3.event.keyCode === 17) { + if(forcetoggle){ + circle.call(force.drag); + } + svg.classed('ctrl', true); + } + + if(!selected_node && !selected_link) return; + switch(d3.event.keyCode) { + case 8: // backspace + case 46: // delete + /* can no longer delete nodes, only links. node deletion is handled in #leftpanel + if(selected_node) { + nodes.splice(nodes.indexOf(selected_node), 1); + spliceLinksForNode(selected_node); + } else if(selected_link) { */ + links.splice(links.indexOf(selected_link), 1); + //} + selected_link = null; + selected_node = null; + restart(); + break; + case 66: // B + if(selected_link) { + // set link direction to both left and right + selected_link.left = true; + selected_link.right = true; + } + restart(); + break; + case 76: // L + if(selected_link) { + // set link direction to left only + selected_link.left = true; + selected_link.right = false; + } + restart(); + break; + case 82: // R + if(selected_node) { + // toggle node reflexivity + selected_node.reflexive = !selected_node.reflexive; + } else if(selected_link) { + // set link direction to right only + selected_link.left = false; + selected_link.right = true; + } + restart(); + break; + } + } + + function keyup() { + lastKeyDown = -1; + + // ctrl + if(d3.event.keyCode === 17) { + circle + .on('mousedown.drag', null) + .on('touchstart.drag', null); + svg.classed('ctrl', false); + } + } + + // app starts here + + svg.on('mousedown', mousedown) + .on('mousemove', mousemove) + .on('mouseup', mouseup); + d3.select(window) + .on('keydown', keydown) + .on('keyup', keyup); + restart(); // this is the call the restart that initializes the force.layout() + + // } // end update + +} // end layout + + +// expanding #rightpanel when hovering +/*$(window).load(function(){ + $('.rightpanel').hover(function() { + $(this).animate({ + width: 500, margin: 0 + }, 'fast'); + $(this).animate().css('box-shadow','0 0 5px #000'); + $(this).css({ + zIndex: 100 + }); + }, function() { + $(this).animate().css('box-shadow', 'none') + $(this).animate({ + width: 210, margin:0 + }, 'fast'); + $(this).css({ + zIndex: 1 + }); + }); + }); +*/ + + +var findNodeIndex = function(nodeName) { + for (var i in allNodes) { + if(allNodes[i]["name"] === nodeName) {return allNodes[i]["id"];} + }; +} + +var findNode = function(nodeName) { + for (var i in allNodes) {if (allNodes[i]["name"] === nodeName) return allNodes[i]}; +} + + +// functions called by buttons +function forceSwitch() { + forcetoggle = !forcetoggle; +} + +function estimate() { + // write links to file & run R CMD + estimated=true; +} + +function time() { + colorTime = true; +} + +function cs() { + colorCS = true; +} + + + + + + + + + + + + diff --git a/tworavens/app_ddi.js b/tworavens/app_ddi.js new file mode 100644 index 0000000..6581c6e --- /dev/null +++ b/tworavens/app_ddi.js @@ -0,0 +1,3062 @@ +////////// +// Globals + +// hostname default - the app will use it to obtain the variable metadata +// (ddi) and pre-processed data info if the file id is supplied as an +// argument (for ex., gui.html?dfId=17), but hostname isn't. +// Edit it to suit your installation. +// (NOTE that if the file id isn't supplied, the app will default to the +// local files specified below!) +// NEW: it is also possible now to supply complete urls for the ddi and +// the tab-delimited data file; the parameters are ddiurl and dataurl. +// These new parameters are optional. If they are not supplied, the app +// will go the old route - will try to cook standard dataverse urls +// for both the data and metadata, if the file id is supplied; or the +// local files if nothing is supplied. +// -- L.A. + + +var production=false; + +if(production && fileid=="") { + alert("Error: No fileid has been provided."); + throw new Error("Error: No fileid has been provided."); +} + +if (!hostname && !production) { + hostname="localhost:8080"; +} else if (!hostname && production) { + hostname="dataverse-demo.iq.harvard.edu"; //this will change when/if the production host changes +} + +if (fileid && !dataurl) { + // file id supplied; we are going to assume that we are dealing with + // a dataverse and cook a standard dataverse data access url, + // with the fileid supplied and the hostname we have + // either supplied or configured: + dataurl = "https://"+hostname+"/api/access/datafile/"+fileid; + dataurl = dataurl+"?key="+apikey; + // (it is also possible to supply dataurl to the script directly, + // as an argument -- L.A.) +} + +if (!production) { + // base URL for the R apps: + var rappURL = "http://0.0.0.0:8000/custom/"; +} else { + var rappURL = "https://dataverse-demo.iq.harvard.edu/custom/"; //this will change when/if the production host changes +} + +// space index +var myspace = 0; +var svg = d3.select("#main.left div.carousel-inner").attr('id', 'innercarousel') +.append('div').attr('class', 'item active').attr('id', 'm0').append('svg').attr('id', 'whitespace'); + +var logArray = []; + + +//.attr('width', width) +//.attr('height', height); +var tempWidth = d3.select("#main.left").style("width") +var width = tempWidth.substring(0,(tempWidth.length-2)); + +var tempHeight = d3.select("#main.left").style("height") +var height = tempHeight.substring(0,(tempHeight.length-2)); + +var forcetoggle=["true"]; +var estimated=false; +var estimateLadda = Ladda.create(document.getElementById("btnEstimate")); +var selectLadda = Ladda.create(document.getElementById("btnSelect")); +var rightClickLast = false; + + +// this is the initial color scale that is used to establish the initial colors of the nodes. allNodes.push() below establishes a field for the master node array allNodes called "nodeCol" and assigns a color from this scale to that field. everything there after should refer to the nodeCol and not the color scale, this enables us to update colors and pass the variable type to R based on its coloring +var colors = d3.scale.category20(); + +var colorTime=false; +var timeColor = '#2d6ca2'; + +var colorCS=false; +var csColor = '#419641'; + +var depVar=false; +var dvColor = '#28a4c9'; + +var nomColor = '#ff6600'; + +var subsetdiv=false; +var setxdiv=false; + + +var varColor = '#f0f8ff'; //d3.rgb("aliceblue"); +var selVarColor = '#fa8072'; //d3.rgb("salmon"); +var taggedColor = '#f5f5f5'; //d3.rgb("whitesmoke"); +var d3Color = '#1f77b4'; // d3's default blue +var grayColor = '#c0c0c0'; + +var lefttab = "tab1"; //global for current tab in left panel +var righttab = "btnModels"; // global for current tab in right panel + +var zparams = { zdata:[], zedges:[], ztime:[], znom:[], zcross:[], zmodel:"", zvars:[], zdv:[], zdataurl:"", zsubset:[], zsetx:[], zmodelcount:0, zplot:[], zsessionid:"", zdatacite:""}; + + +// Radius of circle +var allR = 40; + +//Width and height for histgrams +var barwidth = 1.3*allR; +var barheight = 0.5*allR; +var barPadding = 0.35; +var barnumber =7; + + +var arc0 = d3.svg.arc() +.innerRadius(allR + 5) +.outerRadius(allR + 20) +.startAngle(0) +.endAngle(3.2); + +var arc1 = d3.svg.arc() +.innerRadius(allR + 5) +.outerRadius(allR + 20) +.startAngle(0) +.endAngle(1); + +var arc2 = d3.svg.arc() +.innerRadius(allR + 5) +.outerRadius(allR + 20) +.startAngle(1.1) +.endAngle(2.2); + +var arc3 = d3.svg.arc() +.innerRadius(allR + 5) +.outerRadius(allR + 20) +.startAngle(2.3) +.endAngle(3.3); + +var arc4 = d3.svg.arc() +.innerRadius(allR + 5) +.outerRadius(allR + 20) +.startAngle(4.3) +.endAngle(5.3); + + + +// From .csv +var dataset2 = []; +var valueKey = []; +var lablArray = []; +var hold = []; +var allNodes = []; +var allResults = []; +var subsetNodes = []; +var links = []; +var nodes = []; +var transformVar = ""; +var summaryHold = false; +var selInteract = false; +var modelCount = 0; +var callHistory = []; // unique to the space. saves transform and subset calls. +var citetoggle = false; + + +// transformation toolbar options +var transformList = ["log(d)", "exp(d)", "d^2", "sqrt(d)", "interact(d,e)"]; + +// arry of objects containing allNode, zparams, transform vars +var spaces = []; +var trans = []; //var list for each space contain variables in original data plus trans in that space + +// end of (most) global declarations (minus functions) + + +// collapsable user log +$('#collapseLog').on('shown.bs.collapse', function () { + d3.select("#collapseLog div.panel-body").selectAll("p") + .data(logArray) + .enter() + .append("p") + .text(function(d){ + return d; + }); + //$("#logicon").removeClass("glyphicon-chevron-up").addClass("glyphicon-chevron-down"); + }); + +$('#collapseLog').on('hidden.bs.collapse', function () { + d3.select("#collapseLog div.panel-body").selectAll("p") + .remove(); + //$("#logicon").removeClass("glyphicon-chevron-down").addClass("glyphicon-chevron-up"); + }); + + +// text for the about box +// note that .textContent is the new way to write text to a div +$('#about div.panel-body').text('The Norse god Odin had two talking ravens as advisors, who would fly out into the world and report back all they observed. In the Norse, their names were "Thought" and "Memory". In our coming release, our thought-raven automatically advises on statistical model selection, while our memory-raven accumulates previous statistical models from Dataverse, to provide cummulative guidance and meta-analysis.'); //This is the first public release of a new, interactive Web application to explore data, view descriptive statistics, and estimate statistical models."; + + + + +// +// read DDI metadata with d3: +var metadataurl = ""; +if (ddiurl) { + // a complete ddiurl is supplied: + metadataurl=ddiurl; +} else if (fileid) { + // file id supplied; we're going to cook a standard dataverse + // metadata url, with the file id provided and the hostname + // supplied or configured: + metadataurl="https://"+hostname+"/api/meta/datafile/"+fileid; +} else { + // neither a full ddi url, nor file id supplied; use one of the sample DDIs that come with + // the app, in the data directory: + // metadataurl="data/qog137.xml"; // quality of government + metadataurl="data/fearonLaitin.xml"; // This is Fearon Laitin + //metadataurl="data/strezhnev_voeten_2013.xml"; // This is Strezhnev Voeten + //metadataurl="data/19.xml"; // Fearon from DVN Demo + //metadataurl="data/76.xml"; // Collier from DVN Demo + //metadataurl="data/79.xml"; // two vars from DVN Demo + //metadataurl="data/000.xml"; // one var in metadata + //metadataurl="data/0000.xml"; // zero vars in metadata +} + +// Reading the pre-processed metadata: +// Pre-processed data: +var pURL = ""; +if (dataurl) { + // data url is supplied + pURL = dataurl+"&format=prep"; +} else { + // no dataurl/file id supplied; use one of the sample data files distributed with the + // app in the "data" directory: + //pURL = "data/preprocess2429360.txt"; // This is the Strezhnev Voeten JSON data + // pURL = "data/fearonLaitin.json"; // This is the Fearon Laitin JSON data + pURL = "data/fearonLaitinNewPreprocess3.json"; // This is the revised (May 29, 2015) Fearon Laitin JSON data + // pURL = "data/qog_pp.json"; // This is Qual of Gov +} + +var preprocess = {}; +var mods = new Object; + +// this is the function and callback routine that loads all external data: metadata (DVN's ddi), preprocessed (for plotting distributions), and zeligmodels (produced by Zelig) and initiates the data download to the server +readPreprocess(url=pURL, p=preprocess, v=null, callback=function(){ + d3.xml(metadataurl, "application/xml", function(xml) { + var vars = xml.documentElement.getElementsByTagName("var"); + var temp = xml.documentElement.getElementsByTagName("fileName"); + zparams.zdata = temp[0].childNodes[0].nodeValue; + var cite = xml.documentElement.getElementsByTagName("biblCit"); + zparams.zdatacite=cite[0].childNodes[0].nodeValue; + + // dataset name trimmed to 12 chars + var dataname = zparams.zdata.replace( /\.(.*)/, "") ; // regular expression to drop any file extension + // Put dataset name, from meta-data, into top panel + d3.select("#dataName") + .html(dataname); + + $('#cite div.panel-body').text(zparams.zdatacite); + + // Put dataset name, from meta-data, into page title + d3.select("title").html("TwoRavens " +dataname) + //d3.select("#title").html("blah"); + + // temporary values for hold that correspond to histogram bins + hold = [.6, .2, .9, .8, .1, .3, .4]; + var myvalues = [0, 0, 0, 0, 0]; + + for (i=0;i 2) {return varColor;} + else {return hexToRgba(selVarColor);} + }) + .attr("data-container", "body") + .attr("data-toggle", "popover") + .attr("data-trigger", "hover") + .attr("data-placement", "right") + .attr("data-html", "true") + .attr("onmouseover", "$(this).popover('toggle');") + .attr("onmouseout", "$(this).popover('toggle');") + .attr("data-original-title", "Summary Statistics"); + + d3.select("#models") + .style('height', 2000) + .style('overfill', 'scroll'); + + var modellist = Object.keys(mods); + + d3.select("#models").selectAll("p") + .data(modellist) + .enter() + .append("p") + .attr("id", function(d){ + return "_model_".concat(d); + }) + .text(function(d){return d;}) + .style('background-color',function(d) { + return varColor; + }) + .attr("data-container", "body") + .attr("data-toggle", "popover") + .attr("data-trigger", "hover") + .attr("data-placement", "top") + .attr("data-html", "true") + .attr("onmouseover", "$(this).popover('toggle');") + .attr("onmouseout", "$(this).popover('toggle');") + .attr("data-original-title", "Model Description") + .attr("data-content", function(d){ + return mods[d]; + }); + + if(typeof callback === "function") { + callback(); // this calls layout() because at this point all scaffolding is up and ready + } +} + + +function layout(v) { + var myValues=[]; + nodes = []; + links = []; + + if(v === "add" | v === "move") { + d3.select("#tab1").selectAll("p").style('background-color',varColor); + for(var j =0; j < zparams.zvars.length; j++ ) { + var ii = findNodeIndex(zparams.zvars[j]); + if(allNodes[ii].grayout) {continue;} + nodes.push(allNodes[ii]); + var selectMe = zparams.zvars[j].replace(/\W/g, "_"); + selectMe = "#".concat(selectMe); + d3.select(selectMe).style('background-color',function(){ + return hexToRgba(nodes[j].strokeColor); + }); + } + + for(var j=0; j < zparams.zedges.length; j++) { + var mysrc = nodeIndex(zparams.zedges[j][0]); + var mytgt = nodeIndex(zparams.zedges[j][1]); + links.push({source:nodes[mysrc], target:nodes[mytgt], left:false, right:true}); + } + } + else { + if(allNodes.length > 2) { + nodes = [allNodes[0], allNodes[1], allNodes[2]]; + links = [ + {source: nodes[1], target: nodes[0], left: false, right: true }, + {source: nodes[0], target: nodes[2], left: false, right: true } + ]; + } + else if(allNodes.length === 2) { + nodes = [allNodes[0], allNodes[1]]; + links = [{source: nodes[1], target: nodes[0], left: false, right: true }]; + } + else if(allNodes.length === 1){ + nodes = [allNodes[0]]; + } + else { + alert("There are zero variables in the metadata."); + return; + } + } + + panelPlots(); // after nodes is populated, add subset and setx panels + populatePopover(); // pipes in the summary stats shown on mouseovers + + + // init D3 force layout + var force = d3.layout.force() + .nodes(nodes) + .links(links) + .size([width, height]) + .linkDistance(150) + .charge(-800) + .on('tick',tick); // .start() is important to initialize the layout + + // define arrow markers for graph links + svg.append('svg:defs').append('svg:marker') + .attr('id', 'end-arrow') + .attr('viewBox', '0 -5 10 10') + .attr('refX', 6) + .attr('markerWidth', 3) + .attr('markerHeight', 3) + .attr('orient', 'auto') + .append('svg:path') + .attr('d', 'M0,-5L10,0L0,5') + .style('fill', '#000'); + + svg.append('svg:defs').append('svg:marker') + .attr('id', 'start-arrow') + .attr('viewBox', '0 -5 10 10') + .attr('refX', 4) + .attr('markerWidth', 3) + .attr('markerHeight', 3) + .attr('orient', 'auto') + .append('svg:path') + .attr('d', 'M10,-5L0,0L10,5') + .style('fill', '#000'); + + // line displayed when dragging new nodes + var drag_line = svg.append('svg:path') + .attr('class', 'link dragline hidden') + .attr('d', 'M0,0L0,0'); + + // handles to link and node element groups + var path = svg.append('svg:g').selectAll('path'), + circle = svg.append('svg:g').selectAll('g'); + + // mouse event vars + var selected_node = null, + selected_link = null, + mousedown_link = null, + mousedown_node = null, + mouseup_node = null; + + function resetMouseVars() { + mousedown_node = null; + mouseup_node = null; + mousedown_link = null; + } + + // update force layout (called automatically each iteration) + function tick() { + // draw directed edges with proper padding from node centers + path.attr('d', function(d) { + var deltaX = d.target.x - d.source.x, + deltaY = d.target.y - d.source.y, + dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY), + normX = deltaX / dist, + normY = deltaY / dist, + sourcePadding = d.left ? allR+5 : allR, + targetPadding = d.right ? allR+5 : allR, + sourceX = d.source.x + (sourcePadding * normX), + sourceY = d.source.y + (sourcePadding * normY), + targetX = d.target.x - (targetPadding * normX), + targetY = d.target.y - (targetPadding * normY); + return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY; + }); + + // if(forcetoggle){ + circle.attr('transform', function(d) { + return 'translate(' + d.x + ',' + d.y + ')'; + }); + // }; + + } + + + // add listeners to leftpanel.left. every time a variable is clicked, nodes updates and background color changes. mouseover shows summary stats or model description. + d3.select("#tab1").selectAll("p") + .on("mouseover", function(d) { + // REMOVED THIS TOOLTIP CODE AND MADE A BOOTSTRAP POPOVER COMPONENT + $("body div.popover") + .addClass("variables"); + $("body div.popover div.popover-content") + .addClass("form-horizontal"); + }) + .on("mouseout", function() { + //Remove the tooltip + //d3.select("#tooltip").style("display", "none"); + }) + .on("click", function varClick(){ + if(allNodes[findNodeIndex(this.id)].grayout) {return null;} + d3.select(this) + .style('background-color',function(d) { + var myText = d3.select(this).text(); + var myColor = d3.select(this).style('background-color'); + var mySC = allNodes[findNodeIndex(myText)].strokeColor; + + zparams.zvars = []; //empty the zvars array + if(d3.rgb(myColor).toString() === varColor.toString()) { // we are adding a var + if(nodes.length==0) { + nodes.push(findNode(myText)); + nodes[0].reflexive=true; + } + else {nodes.push(findNode(myText));} + return hexToRgba(selVarColor); + } + else { // dropping a variable + + nodes.splice(findNode(myText)["index"], 1); + spliceLinksForNode(findNode(myText)); + + if(mySC==dvColor) { + var dvIndex = zparams.zdv.indexOf(myText); + if (dvIndex > -1) { zparams.zdv.splice(dvIndex, 1); } + //zparams.zdv=""; + } + else if(mySC==csColor) { + var csIndex = zparams.zcross.indexOf(myText); + if (csIndex > -1) { zparams.zcross.splice(csIndex, 1); } + } + else if(mySC==timeColor) { + var timeIndex = zparams.ztime.indexOf(myText); + if (timeIndex > -1) { zparams.ztime.splice(timeIndex, 1); } + } + else if(mySC==nomColor) { + var nomIndex = zparams.znom.indexOf(myText); + if (nomIndex > -1) { zparams.znom.splice(dvIndex, 1); } + } + + nodeReset(allNodes[findNodeIndex(myText)]); + borderState(); + legend(); + return varColor; + } + }); + panelPlots(); + restart(); + }); + + d3.select("#models").selectAll("p") // models tab + .on("mouseover", function(d) { + // REMOVED THIS TOOLTIP CODE AND MADE A BOOTSTRAP POPOVER COMPONENT + }) + .on("mouseout", function() { + //Remove the tooltip + //d3.select("#tooltip").style("display", "none"); + }) + // d3.select("#Display_content") + .on("click", function(){ + var myColor = d3.select(this).style('background-color'); + d3.select("#models").selectAll("p") + .style('background-color',varColor); + d3.select(this) + .style('background-color',function(d) { + if(d3.rgb(myColor).toString() === varColor.toString()) { + zparams.zmodel = d.toString(); + return hexToRgba(selVarColor); + } + else { + zparams.zmodel = ""; + return varColor; + } + }); + restart(); + }); + + + + + // update graph (called when needed) + function restart() { + // nodes.id is pegged to allNodes, i.e. the order in which variables are read in + // nodes.index is floating and depends on updates to nodes. a variables index changes when new variables are added. + + circle.call(force.drag); + if(forcetoggle[0]==="true") + { + force.gravity(0.1); + force.charge(-800); + force.linkStrength(1); + // force.resume(); + + // circle + // .on('mousedown.drag', null) + // .on('touchstart.drag', null); + } + else + { + force.gravity(0); + force.charge(0); + force.linkStrength(0); + //force.stop(); + // force.resume(); + } + force.resume(); + + // path (link) group + path = path.data(links); + + // update existing links + // VJD: dashed links between pebbles are "selected". this is disabled for now + path.classed('selected', function(d) { return;})//return d === selected_link; }) + .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; }) + .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; }); + + + // add new links + path.enter().append('svg:path') + .attr('class', 'link') + .classed('selected', function(d) { return;})//return d === selected_link; }) + .style('marker-start', function(d) { return d.left ? 'url(#start-arrow)' : ''; }) + .style('marker-end', function(d) { return d.right ? 'url(#end-arrow)' : ''; }) + .on('mousedown', function(d) { // do we ever need to select a link? make it delete.. + var obj1 = JSON.stringify(d); + for(var j =0; j < links.length; j++) { + if(obj1 === JSON.stringify(links[j])) { + links.splice(j,1); + } + } + }); + + // remove old links + path.exit().remove(); + + // circle (node) group + circle = circle.data(nodes, function(d) {return d.id; }); + + + // update existing nodes (reflexive & selected visual states) + //d3.rgb is the function adjusting the color here. + circle.selectAll('circle') + .classed('reflexive', function(d) { return d.reflexive; }) + .style('fill', function(d){ + return d3.rgb(d.nodeCol); + //return (d === selected_node) ? d3.rgb(d.nodeCol).brighter() : d3.rgb(d.nodeCol); // IF d is equal to selected_node return brighter color ELSE return normal color + }) + .style('stroke', function(d){ + return (d3.rgb(d.strokeColor)); + }) + .style('stroke-width', function(d){ + return (d.strokeWidth); + }); + + // add new nodes + + var g = circle.enter() + .append('svg:g') + .attr("id", function(d) { + var myname = d.name+"biggroup"; + return (myname); + }); + + // add plot + g.each(function(d) { + d3.select(this); + if(d.plottype === "continuous") { + densityNode(d, obj=this); + } + else if (d.plottype === "bar") { + barsNode(d, obj=this); + } + }); + + // add arc tags + g.append("path") + .attr("d", arc1) + .attr("id", function(d){ + return "timeArc".concat(d.id); + }) + .style("fill", "yellow") + .attr("fill-opacity", 0) + .on('mouseover', function(d){ + d3.select(this).transition() .attr("fill-opacity", .3) + .delay(0) + .duration(100); //.attr('transform', 'scale(2)'); + d3.select("#timeText".concat(d.id)).transition() + .attr("fill-opacity", .9) + .delay(0) + .duration(100); + }) + .on('mouseout', function(d){ + d3.select(this).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#timeText".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + }) + .on('click', function(d){ + setColors(d, timeColor); + legend(timeColor); + restart(); + }); + g.append("text") + .attr("id", function(d){ + return "timeText".concat(d.id); + }) + .attr("x", 6) + .attr("dy", 11.5) + .attr("fill-opacity", 0) + .append("textPath") + .attr("xlink:href", function(d){ + return "#timeArc".concat(d.id); + }) + .text("Time"); + + + + g.append("path") + .attr("id", function(d){ + return "csArc".concat(d.id); + }) + .attr("d", arc2) + .style("fill", csColor) + .attr("fill-opacity", 0) + .on('mouseover', function(d){ + d3.select(this).transition() + .attr("fill-opacity", .3) + .delay(0) + .duration(100); + d3.select("#csText".concat(d.id)).transition() + .attr("fill-opacity", .9) + .delay(0) + .duration(100); + }) + .on('mouseout', function(d){ + d3.select(this).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#csText".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + }) + .on('click', function(d){ + setColors(d, csColor); + legend(csColor); + restart(); + }); + g.append("text") + .attr("id", function(d){ + return "csText".concat(d.id); + }) + .attr("x", 6) + .attr("dy", 11.5) + .attr("fill-opacity", 0) + .append("textPath") + .attr("xlink:href", function(d){ + return "#csArc".concat(d.id); + }) + .text("Cross Sec"); + + + g.append("path") + .attr("id", function(d){ + return "dvArc".concat(d.id); + }) + .attr("d", arc3) + .style("fill", dvColor) + .attr("fill-opacity", 0) + .on('mouseover', function(d){ + d3.select(this).transition() .attr("fill-opacity", .3) + .delay(0) + .duration(100); + d3.select("#dvText".concat(d.id)).transition() .attr("fill-opacity", .9) + .delay(0) + .duration(100); + }) + .on('mouseout', function(d){ + d3.select(this).transition() .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#dvText".concat(d.id)).transition() .attr("fill-opacity", 0) + .delay(100) + .duration(500); + }) + .on('click', function(d){ + setColors(d, dvColor); + legend(dvColor); + restart(); + }); + g.append("text") + .attr("id", function(d){ + return "dvText".concat(d.id); + }) + .attr("x", 6) + .attr("dy", 11.5) + .attr("fill-opacity", 0) + .append("textPath") + .attr("xlink:href", function(d){ + return "#dvArc".concat(d.id); + }) + .text("Dep Var"); + + g.append("path") + .attr("id", function(d){ + return "nomArc".concat(d.id); + }) + .attr("d", arc4) + .style("fill", nomColor) + .attr("fill-opacity", 0) + .on('mouseover', function(d){ + if(d.defaultNumchar=="character") {return;} + d3.select(this).transition() .attr("fill-opacity", .3) + .delay(0) + .duration(100); + d3.select("#nomText".concat(d.id)).transition() .attr("fill-opacity", .9) + .delay(0) + .duration(100); + }) + .on('mouseout', function(d){ + if(d.defaultNumchar=="character") {return;} + d3.select(this).transition() .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#nomText".concat(d.id)).transition() .attr("fill-opacity", 0) + .delay(100) + .duration(500); + }) + .on('click', function(d){ + if(d.defaultNumchar=="character") {return;} + setColors(d, nomColor); + legend(nomColor); + restart(); + }); + g.append("text") + .attr("id", function(d){ + return "nomText".concat(d.id); + }) + .attr("x", 6) + .attr("dy", 11.5) + .attr("fill-opacity", 0) + .append("textPath") + .attr("xlink:href", function(d){ + return "#nomArc".concat(d.id); + }) + .text("Nominal"); + + g.append('svg:circle') + .attr('class', 'node') + .attr('r', allR) + .style('pointer-events', 'inherit') + .style('fill', function(d) { + // return (d === selected_node) ? d3.rgb(d.nodeCol).brighter().toString() : d.nodeCol; }) + return d.nodeCol; }) + .style('opacity', "0.5") + .style('stroke', function(d) { + return d3.rgb(d.strokeColor).toString(); }) + .classed('reflexive', function(d) { return d.reflexive; }) + .on('mouseover', function(d) { + // if(!mousedown_node || d === mousedown_node) return; + }) + .on('mouseout', function(d) { + // if(!mousedown_node || d === mousedown_node) return; + // unenlarge target node + //tooltip.style("visibility", "hidden"); + // d3.select(this).attr('transform', ''); + }) + // .on('mousedown', function(d) { + // }) + .on('dblclick', function(d){ + d3.event.stopPropagation(); // stop click from bubbling + summaryHold = true; +// document.getElementById('transformations').setAttribute("style", "display:block"); + }) + .on('contextmenu', function(d) { // right click on node + d3.event.preventDefault(); + d3.event.stopPropagation(); // stop right click from bubbling + rightClickLast=true; + + mousedown_node = d; + if(mousedown_node === selected_node) selected_node = null; + else selected_node = mousedown_node; + selected_link = null; + + // reposition drag line + drag_line + .style('marker-end', 'url(#end-arrow)') + .classed('hidden', false) + .attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + mousedown_node.x + ',' + mousedown_node.y); + + svg.on('mousemove', mousemove); + restart(); + }) + .on('mouseup', function(d) { + d3.event.stopPropagation(); // stop mouseup from bubbling + + if(rightClickLast) { + rightClickLast=false; + return; + } + + if(!mousedown_node) return; + + // needed by FF + drag_line + .classed('hidden', true) + .style('marker-end', ''); + + // check for drag-to-self + mouseup_node = d; + if(mouseup_node === mousedown_node) { resetMouseVars(); return; } + + // unenlarge target node + d3.select(this).attr('transform', ''); + + // add link to graph (update if exists) + // NB: links are strictly source < target; arrows separately specified by booleans + var source, target, direction; + if(mousedown_node.id < mouseup_node.id) { + source = mousedown_node; + target = mouseup_node; + direction = 'right'; + } else { + source = mouseup_node; + target = mousedown_node; + direction = 'left'; + } + + var link; + link = links.filter(function(l) { + return (l.source === source && l.target === target); + })[0]; + if(link) { + link[direction] = true; + } else { + link = {source: source, target: target, left: false, right: false}; + link[direction] = true; + links.push(link); + } + + // select new link + selected_link = link; + selected_node = null; + svg.on('mousemove', null); + + resetMouseVars(); + restart(); + }); + + + // show node Names + g.append('svg:text') + .attr('x', 0) + .attr('y', 15) + .attr('class', 'id') + .text(function(d) {return d.name; }); + + + // show summary stats on mouseover + // SVG doesn't support text wrapping, use html instead + g.selectAll("circle.node") + .on("mouseover", function(d) { + tabLeft("tab3"); + varSummary(d); + document.getElementById('transformations').setAttribute("style", "display:block"); + var select = document.getElementById("transSel"); + select.selectedIndex = d.id; + transformVar = valueKey[d.id]; + + d3.select("#dvArc".concat(d.id)).transition() .attr("fill-opacity", .1) + .delay(0) + .duration(100); + d3.select("#dvText".concat(d.id)).transition() .attr("fill-opacity", .5) + .delay(0) + .duration(100); + if(d.defaultNumchar=="numeric") { + d3.select("#nomArc".concat(d.id)).transition() .attr("fill-opacity", .1) + .delay(0) + .duration(100); + d3.select("#nomText".concat(d.id)).transition() .attr("fill-opacity", .5) + .delay(0) + .duration(100); + } + d3.select("#csArc".concat(d.id)).transition() .attr("fill-opacity", .1) + .delay(0) + .duration(100); + d3.select("#csText".concat(d.id)).transition() .attr("fill-opacity", .5) + .delay(0) + .duration(100); + d3.select("#timeArc".concat(d.id)).transition() .attr("fill-opacity", .1) + .delay(0) + .duration(100); + d3.select("#timeText".concat(d.id)).transition() .attr("fill-opacity", .5) + .delay(0) + .duration(100); + }) + // popup(d, xPos, yPos); + + .on("mouseout", function(d) { + if(summaryHold===false) { tabLeft(lefttab); } + + d3.select("#csArc".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#csText".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#timeArc".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#timeText".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#dvArc".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#dvText".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#nomArc".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + d3.select("#nomText".concat(d.id)).transition() + .attr("fill-opacity", 0) + .delay(100) + .duration(500); + + + }); + + // populating transformation dropdown + var t = []; + for(var j =0; j < nodes.length; j++ ) { + t.push(nodes[j].name); + } + + // the transformation variable list is silently updated as pebbles are added/removed + d3.select("#transSel") + .selectAll('li') + .remove(); + + d3.select("#transSel") + .selectAll('li') + .data(t) //set to variables in model space as they're added + .enter() + .append("li") + .text(function(d) {return d; }); + + $('#transSel li').click(function(event) { + + // if 'interaction' is the selected function, don't show the function list again + if(selInteract === true) { + var n = $('#tInput').val().concat($(this).text()); + $('#tInput').val(n); + event.stopPropagation(); + var t = transParse(n=n); + if(t === null) {return;} + $(this).parent().fadeOut(100); + transform(n=t.slice(0, t.length-1), t=t[t.length-1], typeTransform=false); + return; + } + + $('#tInput').val($(this).text()); + $(this).parent().fadeOut(100); + $('#transList').fadeIn(100); + event.stopPropagation(); + }); + + // remove old nodes + circle.exit().remove(); + force.start(); + } //end restart function + + + function mousedown(d) { + // prevent I-bar on drag + d3.event.preventDefault(); + + // because :active only works in WebKit? + svg.classed('active', true); + + if(d3.event.ctrlKey || mousedown_node || mousedown_link) { + return; + } + + restart(); + } + + function mousemove(d) { + if(!mousedown_node) return; + + // update drag line + drag_line.attr('d', 'M' + mousedown_node.x + ',' + mousedown_node.y + 'L' + d3.mouse(this)[0] + ',' + d3.mouse(this)[1]); + } + + function mouseup(d) { + if(mousedown_node) { + // hide drag line + drag_line + .classed('hidden', true) + .style('marker-end', ''); + } + // because :active only works in WebKit? + svg.classed('active', false); + + // clear mouse event vars + resetMouseVars(); + } + + // app starts here + + svg.attr('id', function(){ + return "whitespace".concat(myspace); + }) + .on('mousedown', function() { + mousedown(this); + }) + .on('mouseup', function() { + mouseup(this); + }); + + d3.select(window) + .on('click',function(){ //NOTE: all clicks will bubble here unless event.stopPropagation() + $('#transList').fadeOut(100); + $('#transSel').fadeOut(100); + }); + + restart(); // this is the call the restart that initializes the force.layout() + fakeClick(); +} // end layout + + +// returns id +var findNodeIndex = function(nodeName) { + for (var i in allNodes) { + if(allNodes[i]["name"] === nodeName) {return allNodes[i]["id"];} + }; +} + +var nodeIndex = function(nodeName) { + for (var i in nodes) { + if(nodes[i]["name"] === nodeName) {return i;} + } +} + +var findNode = function(nodeName) { + for (var i in allNodes) {if (allNodes[i]["name"] === nodeName) return allNodes[i]}; +} + + +// function called by force button +function forceSwitch() { + if(forcetoggle[0]==="true") { forcetoggle = ["false"];} + else {forcetoggle = ["true"]} + + if(forcetoggle[0]==="false") { + document.getElementById('btnForce').setAttribute("class", "btn active"); + } + else { + document.getElementById('btnForce').setAttribute("class", "btn btn-default"); + fakeClick(); + } +} + + +function spliceLinksForNode(node) { + var toSplice = links.filter(function(l) { + return (l.source === node || l.target === node); + }); + toSplice.map(function(l) { + links.splice(links.indexOf(l), 1); + }); +} + +function zPop() { + if (dataurl) { + zparams.zdataurl = dataurl; + } + + zparams.zmodelcount = modelCount; + + zparams.zedges = []; + zparams.zvars = []; + + for(var j =0; j < nodes.length; j++ ) { //populate zvars array + zparams.zvars.push(nodes[j].name); + var temp = nodes[j].id; + //var temp = findNodeIndex(nodes[j].name); + //console.log("node ",nodes[j].id); + //console.log("temp ", temp); + + zparams.zsetx[j] = allNodes[temp].setxvals; + zparams.zsubset[j] = allNodes[temp].subsetrange; + } + + for(var j =0; j < links.length; j++ ) { //populate zedges array + var srctgt = []; + //correct the source target ordering for Zelig + if(links[j].left===false) { + srctgt = [links[j].source.name, links[j].target.name]; + } + else { + srctgt = [links[j].target.name, links[j].source.name]; + } + zparams.zedges.push(srctgt); + } +} + +function estimate(btn) { + + if(production && zparams.zsessionid=="") { + alert("Warning: Data download is not complete. Try again soon."); + return; + } + + zPop(); + // write links to file & run R CMD + + //package the output as JSON + // add call history and package the zparams object as JSON + zparams.callHistory=callHistory; + var jsonout = JSON.stringify(zparams); + + //var base = rappURL+"zeligapp?solaJSON=" + urlcall = rappURL+"zeligapp"; //base.concat(jsonout); + var solajsonout = "solaJSON="+jsonout; + console.log("urlcall out: ", urlcall); + console.log("POST out: ", solajsonout); + + + zparams.allVars = valueKey.slice(10,25); // this is because the URL is too long... + var jsonout = JSON.stringify(zparams); + //var selectorBase = rappURL+"selectorapp?solaJSON="; + var selectorurlcall = rappURL+"selectorapp"; //.concat(jsonout); + + function estimateSuccess(btn,json) { + estimateLadda.stop(); // stop spinner + allResults.push(json); + console.log(allResults); + console.log("json in: ", json); + + var myparent = document.getElementById("results"); + if(estimated==false) { + myparent.removeChild(document.getElementById("resultsHolder")); + } + + estimated=true; + d3.select("#results") + .style("display", "block"); + + d3.select("#resultsView") + .style("display", "block"); + + d3.select("#modelView") + .style("display", "block"); + + + // programmatic click on Results button + $("#btnResults").trigger("click"); + + + modelCount = modelCount+1; + var model = "Model".concat(modelCount); + + function modCol() { + d3.select("#modelView") + .selectAll("p") + .style('background-color', hexToRgba(varColor)); + } + + modCol(); + + d3.select("#modelView") + .insert("p",":first-child") // top stack for results + .attr("id",model) + .text(model) + .style('background-color', hexToRgba(selVarColor)) + .on("click", function(){ + var a = this.style.backgroundColor.replace(/\s*/g, ""); + var b = hexToRgba(selVarColor).replace(/\s*/g, ""); + if(a.substr(0,17)===b.substr(0,17)) { + return; //escapes the function early if the displayed model is clicked + } + modCol(); + d3.select(this) + .style('background-color', hexToRgba(selVarColor)); + viz(this.id); + }); + + var rCall = []; + rCall[0] = json.call; + logArray.push("estimate: ".concat(rCall[0])); + showLog(); + + viz(model); + } + + function estimateFail(btn) { + estimateLadda.stop(); // stop spinner + estimated=true; + } + + function selectorSuccess(btn, json) { + d3.select("#ticker") + .text("Suggested variables and percent improvement on RMSE: " + json.vars); + console.log("selectorSuccess: ", json); + } + + function selectorFail(btn) { + alert("Selector Fail"); + } + + estimateLadda.start(); // start spinner + makeCorsRequest(urlcall,btn, estimateSuccess, estimateFail, solajsonout); + //makeCorsRequest(selectorurlcall, btn, selectorSuccess, selectorFail, solajsonout); + + +} + + +function dataDownload() { + zPop(); + // write links to file & run R CMD + + //package the output as JSON + // add call history and package the zparams object as JSON + var jsonout = JSON.stringify(zparams); + var btn="nobutton"; + + //var base = rappURL+"zeligapp?solaJSON=" + urlcall = rappURL+"dataapp"; //base.concat(jsonout); + var solajsonout = "solaJSON="+jsonout; + console.log("urlcall out: ", urlcall); + console.log("POST out: ", solajsonout); + + function downloadSuccess(btn, json) { + console.log("dataDownload json in: ", json); + zparams.zsessionid=json.sessionid[0]; + + // set the link URL + if(production){ + var logURL=rappURL+"log_dir/log_"+zparams.zsessionid+".txt"; + document.getElementById("logID").href=logURL; + } + else{ + var logURL="rook/log_"+zparams.zsessionid+".txt"; + document.getElementById("logID").href=logURL; + } + + } + + function downloadFail(btn) { + console.log("Data have not been downloaded"); + } + + makeCorsRequest(urlcall,btn, downloadSuccess, downloadFail, solajsonout); +} + + + +function viz(m) { + var mym = +m.substr(5,5) - 1; + + function removeKids(parent) { + while (parent.firstChild) { + parent.removeChild(parent.firstChild); + } + } + + var myparent = document.getElementById("resultsView"); + removeKids(myparent); + + var json = allResults[mym]; + + // pipe in figures to right panel + var filelist = new Array; + for(var i in json.images) { + var zfig = document.createElement("img"); + zfig.setAttribute("src", json.images[i]); + zfig.setAttribute('width', 200); + zfig.setAttribute('height', 200); + document.getElementById("resultsView").appendChild(zfig); + // filelist.push(json[i]); + } + + // var rCall = []; + // rCall[0] = json.call; + // logArray.push("estimate: ".concat(rCall[0])); + // showLog(); + + + // write the results table + var resultsArray = []; + for (var key in json.sumInfo) { + if(key=="colnames") {continue;} + + var obj = json.sumInfo[key]; + resultsArray.push(obj); + /* SO says this is important check, but I don't see how it helps here... + for (var prop in obj) { + // important check that this is objects own property + // not from prototype prop inherited + if(obj.hasOwnProperty(prop)){ + alert(prop + " = " + obj[prop]); + } + } */ + } + + var table = d3.select("#resultsView") + .append("p") +// .html("

Results
") + .append("table"); + + var thead = table.append("thead"); + thead.append("tr") + .selectAll("th") + .data(json.sumInfo.colnames) + .enter() + .append("th") + .text(function(d) { return d;}); + + var tbody = table.append("tbody"); + tbody.selectAll("tr") + .data(resultsArray) + .enter().append("tr") + .selectAll("td") + .data(function(d){return d;}) + .enter().append("td") + .text(function(d){ + var myNum = Number(d); + if(isNaN(myNum)) { return d;} + return myNum.toPrecision(3); + }) + .on("mouseover", function(){d3.select(this).style("background-color", "aliceblue")}) // for no discernable reason + .on("mouseout", function(){d3.select(this).style("background-color", "#F9F9F9")}) ; //(but maybe we'll think of one) + + d3.select("#resultsView") + .append("p") + .html(function() { + return "Formula: ".concat(json.call[0]); + }); +} + +// this function parses the transformation input. variable names are often nested inside one another, e.g., ethwar, war, wars, and so this is handled +function transParse(n) { + + var out2 = []; + var t2=n; + var k2=0; + var subMe2 = "_transvar".concat(k2); + var indexed = []; + + // out2 is all matched variables, indexed is an array, each element is an object that contains the matched variables starting index and finishing index. e.g., n="wars+2", out2=[war, wars], indexed=[{0,2},{0,3}] + for(var i in valueKey) { + var m2 = n.match(valueKey[i]); + if(m2 !== null) { + out2.push(m2[0]); + } + + var re = new RegExp(valueKey[i], "g") + var s = n.search(re); + if(s != -1) { + indexed.push({from:s, to:s+valueKey[i].length}); + } + } + + // nested loop not good, but indexed is not likely to be very large. + // if a variable is nested, it is removed from out2 + // notice, loop is backwards so that index changes don't affect the splice + console.log("indexed ", indexed); + for(var i=indexed.length-1; i>-1; i--) { + for(var j=indexed.length-1; j>-1; j--) { + if(i===j) {continue;} + if((indexed[i].from >= indexed[j].from) & (indexed[i].to <= indexed[j].to)) { + console.log(i, " is nested in ", j); + out2.splice(i, 1); + } + } + } + + for(var i in out2) { + t2 = t2.replace(out2[i], subMe2); //something that'll never be a variable name + k2 = k2+1; + subMe2 = "_transvar".concat(k2); + } + + if(out2.length > 0) { + out2.push(t2); + console.log("new out ", out2); + return(out2); + } + else { + alert("No variable name found. Perhaps check your spelling?"); + return null; + } +} + +function transform(n,t, typeTransform) { + + if(production && zparams.zsessionid=="") { + alert("Warning: Data download is not complete. Try again soon."); + return; + } + + if(!typeTransform){ + t = t.replace("+", "_plus_"); // can't send the plus operator + } + + console.log(n); + console.log(t); + + var btn = document.getElementById('btnEstimate'); + + + var myn = allNodes[findNodeIndex(n[0])]; + if(typeof myn==="undefined") {var myn = allNodes[findNodeIndex(n)];} + + var outtypes = {varnamesTypes:n, interval:myn.interval, numchar:myn.numchar, nature:myn.nature, binary:myn.binary}; + + // if typeTransform but we already have the metadata + if(typeTransform) { + if(myn.nature=="nominal" & typeof myn.plotvalues !=="undefined") { + myn.plottype="bar"; + barsNode(myn); + populatePopover(); + panelPlots(); + return; + } + else if (myn.nature!="nominal" & typeof myn.plotx !=="undefined") { + myn.plottype="continuous"; + densityNode(myn); + populatePopover(); + panelPlots(); + return; + } + } + + //package the output as JSON + var transformstuff = {zdataurl:dataurl, zvars:n, zsessionid:zparams.zsessionid, transform:t, callHistory:callHistory, typeTransform:typeTransform, typeStuff:outtypes}; + var jsonout = JSON.stringify(transformstuff); + //var base = rappURL+"transformapp?solaJSON=" + + urlcall = rappURL+"transformapp"; //base.concat(jsonout); + var solajsonout = "solaJSON="+jsonout; + console.log("urlcall out: ", urlcall); + console.log("POST out: ", solajsonout); + + + + function transformSuccess(btn, json) { + estimateLadda.stop(); + console.log("json in: ", json); + + if(json.typeTransform[0]) { + + d3.json(json.url, function(error, json) { + if (error) return console.warn(error); + var jsondata = json; + + for(var key in jsondata) { + var myIndex = findNodeIndex(key); + jQuery.extend(true, allNodes[myIndex], jsondata[key]); + + if(allNodes[myIndex].plottype === "continuous") { + densityNode(allNodes[myIndex]); + } + else if (allNodes[myIndex].plottype === "bar") { + barsNode(allNodes[myIndex]); + } + } + + fakeClick(); + populatePopover(); + panelPlots(); + console.log(allNodes[myIndex]); + }); + } + else { + + callHistory.push({func:"transform", zvars:n, transform:t}); + + var subseted = false; + var rCall = []; + rCall[0] = json.call; + var newVar = rCall[0][0]; + trans.push(newVar); + + d3.json(json.url, function(error, json) { + if (error) return console.warn(error); + var jsondata = json; + + for(var key in jsondata) { + var myIndex = findNodeIndex(key); + if(typeof myIndex !== "undefined") { + alert("Invalid transformation: this variable name already exists."); + return; + } + // add transformed variable to the current space + var i = allNodes.length; + var obj1 = {id:i, reflexive: false, "name": key, "labl": "transformlabel", data: [5,15,20,0,5,15,20], count: [.6, .2, .9, .8, .1, .3, .4], "nodeCol":colors(i), "baseCol":colors(i), "strokeColor":selVarColor, "strokeWidth":"1", "subsetplot":false, "subsetrange":["", ""],"setxplot":false, "setxvals":["", ""], "grayout":false, "defaultInterval":jsondata[key]["interval"], "defaultNumchar":jsondata[key]["numchar"], "defaultNature":jsondata[key]["nature"], "defaultBinary":jsondata[key]["binary"]}; + + jQuery.extend(true, obj1, jsondata[key]); + allNodes.push(obj1); + + scaffoldingPush(rCall[0]); + valueKey.push(newVar); + nodes.push(allNodes[i]); + fakeClick(); + panelPlots(); + + if(allNodes[i].plottype === "continuous") { + densityNode(allNodes[i]); + } + else if (allNodes[i].plottype === "bar") { + barsNode(allNodes[i]); + } + }//for + + + }); + + // update the log + logArray.push("transform: ".concat(rCall[0])); + showLog(); + + // NOTE: below is the carousel portion that needs to be revised as of May 29 2015 + + // add transformed variable to all spaces + // check if myspace callHistory contains a subset + for(var k0=0; k0 -1) { zparams.zdv.splice(dvIndex, 1); } + } + else if(mySC==csColor) { + var csIndex = zparams.zcross.indexOf(myText); + if (csIndex > -1) { zparams.zcross.splice(csIndex, 1); } + } + else if(mySC==timeColor) { + var timeIndex = zparams.ztime.indexOf(myText); + if (timeIndex > -1) { zparams.ztime.splice(dvIndex, 1); } + } + else if(mySC==nomColor) { + var nomIndex = zparams.znom.indexOf(myText); + if (nomIndex > -1) { zparams.znom.splice(dvIndex, 1); } + } + + nodeReset(allNodes[findNodeIndex(myText)]); + borderState(); + return varColor; + } + }); + fakeClick(); + panelPlots(); + }); + populatePopover(); // pipes in the summary stats + + // drop down menu for tranformation toolbar + d3.select("#transSel") + .data(v) + .append("option") + .text(function(d) {return d; }); +} + +// below from http://www.html5rocks.com/en/tutorials/cors/ for cross-origin resource sharing +// Create the XHR object. +function createCORSRequest(method, url, callback) { + var xhr = new XMLHttpRequest(); + if ("withCredentials" in xhr) { + // XHR for Chrome/Firefox/Opera/Safari. + xhr.open(method, url, true); + } else if (typeof XDomainRequest != "undefined") { + // XDomainRequest for IE. + xhr = new XDomainRequest(); + xhr.open(method, url); + } else { + // CORS not supported. + xhr = null; + } +// xhr.setRequestHeader('Content-Type', 'text/plain'); + xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); + return xhr; + +} + + +// Make the actual CORS request. +function makeCorsRequest(url,btn,callback, warningcallback, jsonstring) { + var xhr = createCORSRequest('POST', url); + if (!xhr) { + alert('CORS not supported'); + return; + } + // Response handlers for asynchronous load + // onload or onreadystatechange? + + xhr.onload = function() { + + var text = xhr.responseText; + console.log("text ", text); + + try { + var json = JSON.parse(text); // should wrap in try / catch + var names = Object.keys(json); + } + catch(err) { + estimateLadda.stop(); + selectLadda.stop(); + console.log(err); + alert('Error: Could not parse incoming JSON.'); + } + + if (names[0] == "warning"){ + warningcallback(btn); + alert("Warning: " + json.warning); + }else{ + callback(btn, json); + } + }; + xhr.onerror = function() { + // note: xhr.readystate should be 4, and status should be 200. a status of 0 occurs when the url becomes too large + if(xhr.status==0) { + alert('There was an error making the request. xmlhttprequest status is 0.'); + } + else if(xhr.readyState!=4) { + alert('There was an error making the request. xmlhttprequest readystate is not 4.'); + } + else { + alert('Woops, there was an error making the request.'); + } + console.log(xhr); + estimateLadda.stop(); + selectLadda.stop(); + }; + xhr.send(jsonstring); +} + + +function legend(c) { // this could be made smarter + if (zparams.ztime.length!=0 | zparams.zcross.length!=0 | zparams.zdv.length!=0 | zparams.znom.length!=0) { + document.getElementById("legend").setAttribute("style", "display:block"); + } + else { + document.getElementById("legend").setAttribute("style", "display:none"); + } + + + if(zparams.ztime.length==0) { + document.getElementById("timeButton").setAttribute("class", "clearfix hide"); + } + else { + document.getElementById("timeButton").setAttribute("class", "clearfix show"); + } + if(zparams.zcross.length==0) { + document.getElementById("csButton").setAttribute("class", "clearfix hide"); + } + else { + document.getElementById("csButton").setAttribute("class", "clearfix show"); + } + if(zparams.zdv.length==0) { + document.getElementById("dvButton").setAttribute("class", "clearfix hide"); + } + else { + document.getElementById("dvButton").setAttribute("class", "clearfix show"); + } + if(zparams.znom.length==0) { + document.getElementById("nomButton").setAttribute("class", "clearfix hide"); + } + else { + document.getElementById("nomButton").setAttribute("class", "clearfix show"); + } + + borderState(); +} + + +function reset() { + location.reload(); +} + +// programmatically deselecting every selected variable... +function erase() { + leftpanelMedium(); + rightpanelMedium(); + document.getElementById("legend").setAttribute("style", "display:none"); + + tabLeft('tab1'); + + jQuery.fn.d3Click = function () { + this.children().each(function (i, e) { + var mycol = d3.rgb(this.style.backgroundColor); + if(mycol.toString()===varColor.toString()) {return;} + var evt = document.createEvent("MouseEvents"); + evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + + e.dispatchEvent(evt); + }); + }; + $("#tab1").d3Click(); +} + + +function deselect(d) { + console.log(d); +} + +// http://www.tutorials2learn.com/tutorials/scripts/javascript/xml-parser-javascript.html +function loadXMLDoc(XMLname) +{ + var xmlDoc; + if (window.XMLHttpRequest) + { + xmlDoc=new window.XMLHttpRequest(); + xmlDoc.open("GET",XMLname,false); + xmlDoc.send(""); + return xmlDoc.responseXML; + } + // IE 5 and IE 6 + else if (ActiveXObject("Microsoft.XMLDOM")) + { + xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async=false; + xmlDoc.load(XMLname); + return xmlDoc; + } + alert("Error loading document!"); + return null; +} + + +function tabLeft(tab) { + + if(tab!="tab3") {lefttab=tab;} + var tabi = tab.substring(3); + + document.getElementById('tab1').style.display = 'none'; + document.getElementById('tab2').style.display = 'none'; + document.getElementById('tab3').style.display = 'none'; + + if(tab==="tab1") { + summaryHold = false; + document.getElementById('btnSubset').setAttribute("class", "btn btn-default"); + document.getElementById('btnVariables').setAttribute("class", "btn active"); + document.getElementById("btnSelect").style.display = 'none'; + + d3.select("#leftpanel") + .attr("class", "sidepanel container clearfix"); + } + else if (tab==="tab2") { + summaryHold = false; + document.getElementById('btnVariables').setAttribute("class", "btn btn-default"); + document.getElementById('btnSubset').setAttribute("class", "btn active"); + + d3.select("#leftpanel") + .attr("class", function(d){ + if(this.getAttribute("class")==="sidepanel container clearfix expandpanel") { + document.getElementById("btnSelect").style.display = 'none'; + return "sidepanel container clearfix"; + } + else { + document.getElementById("btnSelect").style.display = 'block'; + return "sidepanel container clearfix expandpanel"; + } + }); + } + else { + document.getElementById('btnSubset').setAttribute("class", "btn btn-default"); + document.getElementById('btnVariables').setAttribute("class", "btn btn-default"); + + d3.select("#leftpanel") + .attr("class", "sidepanel container clearfix"); + } + + document.getElementById(tab).style.display = 'block'; +} + +function tabRight(tabid) { + + document.getElementById('models').style.display = 'none'; + document.getElementById('setx').style.display = 'none'; + document.getElementById('results').style.display = 'none'; + + if(tabid=="btnModels") { + document.getElementById('btnSetx').setAttribute("class", "btn btn-default"); + document.getElementById('btnResults').setAttribute("class", "btn btn-default"); + document.getElementById('btnModels').setAttribute("class", "btn active"); + document.getElementById('models').style.display = 'block'; + + d3.select("#rightpanel") + .attr("class", "sidepanel container clearfix"); + } + else if (tabid=="btnSetx") { + document.getElementById('btnModels').setAttribute("class", "btn btn-default"); + document.getElementById('btnResults').setAttribute("class", "btn btn-default"); + document.getElementById('btnSetx').setAttribute("class", "btn active"); + document.getElementById('setx').style.display = 'block'; + + if(righttab=="btnSetx" | d3.select("#rightpanel").attr("class")=="sidepanel container clearfix") {toggleR()}; + } + else if (tabid=="btnResults") { + document.getElementById('btnModels').setAttribute("class", "btn btn-default"); + document.getElementById('btnSetx').setAttribute("class", "btn btn-default"); + document.getElementById('btnResults').setAttribute("class", "btn active"); + document.getElementById('results').style.display = 'block'; + + if(estimated===false) { + d3.select("#rightpanel") + .attr("class", "sidepanel container clearfix"); + } + else if(righttab=="btnResults" | d3.select("#rightpanel").attr("class")=="sidepanel container clearfix") {toggleR()}; + } + + righttab=tabid; // a global that may be of use + + function toggleR() { + d3.select("#rightpanel") + .attr("class", function(d){ + if(this.getAttribute("class")==="sidepanel container clearfix expandpanel") { + return "sidepanel container clearfix"; + } + else { + return "sidepanel container clearfix expandpanel"; + } + }); + } +} + + +function varSummary(d) { + + var rint = d3.format("r"); + + var summarydata = [], + tmpDataset = [], t1 = ["Mean:","Median:","Most Freq:","Occurrences:", "Median Freq:", "Occurrences:", "Least Freq:", "Occurrences:", "Stand.Dev:","Minimum:","Maximum:","Invalid:","Valid:","Uniques:","Herfindahl:"], + t2 = [(+d.mean).toPrecision(4).toString(),(+d.median).toPrecision(4).toString(),d.mode,rint(d.freqmode),d.mid, rint(d.freqmid), d.fewest, rint(d.freqfewest),(+d.sd).toPrecision(4).toString(),(+d.min).toPrecision(4).toString(),(+d.max).toPrecision(4).toString(),rint(d.invalid),rint(d.valid),rint(d.uniques),(+d.herfindahl).toPrecision(4).toString()], + i, j; + + for (i = 0; i < t1.length; i++) { + if(t2[i]=="NaN" | t2[i]=="NA" | t2[i]=="") continue; + tmpDataset=[]; + tmpDataset.push(t1[i]); + tmpDataset.push(t2[i]); + summarydata.push(tmpDataset); + }; + + // console.log(summarydata); + d3.select("#tab3") + .select("p") + .html("
" +d.name+ "
" +d.labl+ "
") + .append("table") + .selectAll("tr") + .data(summarydata) + .enter().append("tr") + .selectAll("td") + .data(function(d){return d;}) + .enter().append("td") + .text(function(d){return d;}) + .on("mouseover", function(){d3.select(this).style("background-color", "aliceblue")}) // for no discernable reason + .on("mouseout", function(){d3.select(this).style("background-color", "#F9F9F9")}) ; //(but maybe we'll think of one) +// .style("font-size", "12px"); + + + if(typeof d.plottype === "undefined") { // .properties is undefined for some vars + var plotsvg = d3.select("#tab3") + .selectAll("svg") + .remove(); + } + else if (d.plottype === "continuous") { + density(d, div="varSummary"); + } + else if (d.plottype === "bar") { + bars(d, div="varSummary"); + } + else { + var plotsvg = d3.select("#tab3") // no graph to draw, but still need to remove previous graph + .selectAll("svg") + .remove(); + }; + +} + +function populatePopover () { + + d3.select("#tab1").selectAll("p") + .attr("data-content", function(d) { + var onNode = findNodeIndex(d); + return popoverContent(allNodes[onNode]); + }); +} + +function popoverContent(d) { + + var rint = d3.format("r"); + + var outtext = ""; + + if(d.labl != "") { outtext = outtext + "

" + d.labl + "

"; + } + + if (d.mean != "NA") { outtext = outtext + "

" + (+d.mean).toPrecision(4).toString() + "

"; + } + + if (d.median != "NA") { outtext = outtext + "

" + (+d.median).toPrecision(4).toString() + "

"; + } + + if (d.mode != "NA") { outtext = outtext + "

" + d.mode + "

"; + } + + if (d.freqmode != "NA") { outtext = outtext + "

" + rint(d.freqmode) + "

"; + } + + if (d.mid != "NA") { outtext = outtext + "

" + d.mid + "

"; + } + + if (d.freqmid != "NA") { outtext = outtext + "

" + rint(d.freqmid) + "

"; + } + if (d.fewest != "NA") { outtext = outtext + "

" + d.fewest + "

"; + } + + if (d.freqfewest != "NA") { outtext = outtext + "

" + rint(d.freqfewest) + "

"; + } + + if (d.sd != "NA") { outtext = outtext + "

" + (+d.sd).toPrecision(4).toString() + "

"; + } + + if (d.max != "NA") { outtext = outtext + "

" + (+d.max).toPrecision(4).toString() + "

"; + } + + if (d.min != "NA") { outtext = outtext + "

" + (+d.min).toPrecision(4).toString() + "

"; + } + if (d.invalid != "NA") { outtext = outtext + "

" + rint(d.invalid) + "

"; + } + if (d.valid != "NA") { outtext = outtext + "

" + rint(d.valid) + "

" ; + } + + if (d.uniques != "NA") { outtext = outtext + "

" + rint(d.uniques) + "

"; + } + if (d.herfindahl != "NA") { outtext = outtext + "

" + (+d.herfindahl).toPrecision(4).toString() + "

"; + } + + return outtext; +} + +function popupX(d) { + + var tsf = d3.format(".4r"); + var rint = d3.format("r"); + + //Create the tooltip label + d3.select("#tooltip") + .style("left", tempX + "px") + .style("top", tempY + "px") + .select("#tooltiptext") + .html("

" + tsf(d.mean) + "

" + + + "

" + tsf(d.median) + "

" + + + "

" + d.mode + "

" + + + "

" + tsf(d.sd) + "

" + + + "

" + tsf(d.max) + "

" + + + "

" + tsf(d.min) + "

" + + + "

" + rint(d.valid) + "

" + + + "

" + rint(d.invalid) + "

" + ); + + /*.html("Median: " + d.median + "
Mode: " + d.mode + "
Maximum: " + d.max + "
Minimum: " + d.min + "
Mean: " + d.mean + "
Invalid: " + d.invalid + "
Valid: " + d.valid + "
Stand Dev: " + d.sd);*/ + + //d3.select("#tooltip") + //.style("display", "inline") + //.select("#tooltip h3.popover-title") + //.html("Summary Statistics"); + +} + + +function panelPlots() { + + // build arrays from nodes in main + var varArray = []; + var idArray = []; + + for(var j=0; j < nodes.length; j++ ) { + varArray.push(nodes[j].name.replace(/\(|\)/g, "")); + idArray.push(nodes[j].id); + } + + //remove all plots, could be smarter here + d3.select("#setx").selectAll("svg").remove(); + d3.select("#tab2").selectAll("svg").remove(); + + for (var i = 0; i < varArray.length; i++) { + allNodes[idArray[i]].setxplot=false; + allNodes[idArray[i]].subsetplot=false; + if (allNodes[idArray[i]].plottype === "continuous" & allNodes[idArray[i]].setxplot==false) { + allNodes[idArray[i]].setxplot=true; + density(allNodes[idArray[i]], div="setx"); + allNodes[idArray[i]].subsetplot=true; + density(allNodes[idArray[i]], div="subset"); + } + else if (allNodes[idArray[i]].plottype === "bar" & allNodes[idArray[i]].setxplot==false) { + allNodes[idArray[i]].setxplot=true; + bars(allNodes[idArray[i]], div="setx"); + allNodes[idArray[i]].subsetplot=true; + barsSubset(allNodes[idArray[i]]); + } + } + + + d3.select("#setx").selectAll("svg") + .each(function(){ + d3.select(this); + var regstr = /(.+)_setx_(\d+)/; + var myname = regstr.exec(this.id); + var nodeid = myname[2]; + myname = myname[1]; + var j = varArray.indexOf(myname); + + if(j == -1) { + allNodes[nodeid].setxplot=false; + var temp = "#".concat(myname,"_setx_",nodeid); + d3.select(temp) + .remove(); + + allNodes[nodeid].subsetplot=false; + var temp = "#".concat(myname,"_tab2_",nodeid); + d3.select(temp) + .remove(); + } + }); +} + +// easy functions to collapse panels to base +function rightpanelMedium() { + d3.select("#rightpanel") + .attr("class", "sidepanel container clearfix"); +} +function leftpanelMedium() { + d3.select("#leftpanel") + .attr("class", "sidepanel container clearfix"); +} + +// function to convert color codes +function hexToRgba(hex) { + var h=hex.replace('#', ''); + + var bigint = parseInt(h, 16); + var r = (bigint >> 16) & 255; + var g = (bigint >> 8) & 255; + var b = bigint & 255; + var a = '0.5'; + + return "rgba(" + r + "," + g + "," + b + "," + a + ")"; +} + +// function takes a node and a color and updates zparams +function setColors (n, c) { + + if(n.strokeWidth=='1') { // adding time, cs, dv, nom to a node with no stroke + n.strokeWidth = '4'; + n.strokeColor = c; + n.nodeCol = taggedColor; + if(dvColor==c) { + // check if array, if not, make it an array + // console.log(Object.prototype.toString.call(zparams.zdv)); + zparams.zdv = Object.prototype.toString.call(zparams.zdv) == "[object Array]" ? zparams.zdv : []; + zparams.zdv.push(n.name); + } + else if(csColor==c) { + zparams.zcross = Object.prototype.toString.call(zparams.zcross) == "[object Array]" ? zparams.zcross : []; + zparams.zcross.push(n.name); + } + else if(timeColor==c) { + zparams.ztime = Object.prototype.toString.call(zparams.ztime) == "[object Array]" ? zparams.ztime : []; + zparams.ztime.push(n.name); + } + else if(nomColor==c) { + zparams.znom = Object.prototype.toString.call(zparams.znom) == "[object Array]" ? zparams.znom : []; + zparams.znom.push(n.name); + allNodes[findNodeIndex(n.name)].nature="nominal"; + transform(n.name, t=null, typeTransform=true); + } + + d3.select("#tab1").select("p#".concat(n.name)) + .style('background-color', hexToRgba(c)); + } + else if (n.strokeWidth=='4') { + if(c==n.strokeColor) { // deselecting time, cs, dv, nom + n.strokeWidth = '1'; + n.strokeColor = selVarColor; + n.nodeCol=colors(n.id); + d3.select("#tab1").select("p#".concat(n.name)) + .style('background-color', hexToRgba(selVarColor)); + + if(dvColor==c) { + var dvIndex = zparams.zdv.indexOf(n.name); + if (dvIndex > -1) { zparams.zdv.splice(dvIndex, 1); } + } + else if(csColor==c) { + var csIndex = zparams.zcross.indexOf(n.name); + if (csIndex > -1) { zparams.zcross.splice(csIndex, 1); } + } + else if(timeColor==c) { + var timeIndex = zparams.ztime.indexOf(n.name); + if (timeIndex > -1) { zparams.ztime.splice(timeIndex, 1); } + } + else if(nomColor==c) { + var nomIndex = zparams.znom.indexOf(n.name); + if (nomIndex > -1) { zparams.znom.splice(nomIndex, 1); + allNodes[findNodeIndex(n.name)].nature=allNodes[findNodeIndex(n.name)].defaultNature; + transform(n.name, t=null, typeTransform=true); + } + } + } + else { // deselecting time, cs, dv, nom AND changing it to time, cs, dv, nom + if(dvColor==n.strokeColor) { + var dvIndex = zparams.zdv.indexOf(n.name); + if (dvIndex > -1) { zparams.zdv.splice(dvIndex, 1); } + } + else if(csColor==n.strokeColor) { + var csIndex = zparams.zcross.indexOf(n.name); + if (csIndex > -1) { zparams.zcross.splice(csIndex, 1); } + } + else if(timeColor==n.strokeColor) { + var timeIndex = zparams.ztime.indexOf(n.name); + if (timeIndex > -1) { zparams.ztime.splice(timeIndex, 1); } + } + else if(nomColor==n.strokeColor) { + var nomIndex = zparams.znom.indexOf(n.name); + if (nomIndex > -1) { + zparams.znom.splice(nomIndex, 1); + allNodes[findNodeIndex(n.name)].nature=allNodes[findNodeIndex(n.name)].defaultNature; + transform(n.name, t=null, typeTransform=true); + } + } + n.strokeColor = c; + d3.select("#tab1").select("p#".concat(n.name)) + .style('background-color', hexToRgba(c)); + + if(dvColor==c) {zparams.zdv.push(n.name);} + else if(csColor==c) {zparams.zcross.push(n.name);} + else if(timeColor==c) {zparams.ztime.push(n.name);} + else if(nomColor==c) { + zparams.znom.push(n.name); + allNodes[findNodeIndex(n.name)].nature="nominal"; + transform(n.name, t=null, typeTransform=true); + } + } + } +} + + +function borderState () { + if(zparams.zdv.length>0) {$('#dvButton .rectColor svg circle').attr('stroke', dvColor);} + else {$('#dvButton').css('border-color', '#ccc');} + if(zparams.zcross.length>0) {$('#csButton .rectColor svg circle').attr('stroke', csColor);} + else {$('#csButton').css('border-color', '#ccc');} + if(zparams.ztime.length>0) {$('#timeButton .rectColor svg circle').attr('stroke', timeColor);} + else {$('#timeButton').css('border-color', '#ccc');} + if(zparams.znom.length>0) {$('#nomButton .rectColor svg circle').attr('stroke', nomColor);} + else {$('#nomButton').css('border-color', '#ccc');} +} + +// small appearance resets, but perhaps this will become a hard reset back to all original allNode values? +function nodeReset (n) { + n.strokeColor=selVarColor; + n.strokeWidth="1"; + n.nodeCol=n.baseCol; +} + +function subsetSelect(btn) { + + if (dataurl) { + zparams.zdataurl = dataurl; + } + + if(production && zparams.zsessionid=="") { + alert("Warning: Data download is not complete. Try again soon."); + return; + } + + zparams.zvars = []; + zparams.zplot = []; + + var subsetEmpty = true; + + // is this the same as zPop()? + for(var j =0; j < nodes.length; j++ ) { //populate zvars and zsubset arrays + zparams.zvars.push(nodes[j].name); + var temp = nodes[j].id; + zparams.zsubset[j] = allNodes[temp].subsetrange; + zparams.zplot.push(allNodes[temp].plottype); + if(zparams.zsubset[j][1] != "") {subsetEmpty=false;} //only need to check one + } + + if(subsetEmpty==true) { + alert("Warning: No new subset selected."); + return; + } + + var outtypes = []; + for(var j=0; j < allNodes.length; j++) { + outtypes.push({varnamesTypes:allNodes[j].name, nature:allNodes[j].nature, numchar:allNodes[j].numchar, binary:allNodes[j].binary, interval:allNodes[j].interval}); + } + + var subsetstuff = {zdataurl:zparams.zdataurl, zvars:zparams.zvars, zsubset:zparams.zsubset, zsessionid:zparams.zsessionid, zplot:zparams.zplot, callHistory:callHistory, typeStuff:outtypes}; + + var jsonout = JSON.stringify(subsetstuff); + //var base = rappURL+"subsetapp?solaJSON=" + urlcall = rappURL+"subsetapp"; //base.concat(jsonout); + var solajsonout = "solaJSON="+jsonout; + console.log("urlcall out: ", urlcall); + console.log("POST out: ", solajsonout); + + + function subsetSelectSuccess(btn,json) { + + selectLadda.stop(); // stop motion + $("#btnVariables").trigger("click"); // programmatic clicks + $("#btnModels").trigger("click"); + + var grayOuts = []; + + var rCall = []; + rCall[0] = json.call; + + // store contents of the pre-subset space + zPop(); + var myNodes = jQuery.extend(true, [], allNodes); + var myParams = jQuery.extend(true, {}, zparams); + var myTrans = jQuery.extend(true, [], trans); + var myForce = jQuery.extend(true, [], forcetoggle); + var myPreprocess = jQuery.extend(true, {}, preprocess); + var myLog = jQuery.extend(true, [], logArray); + var myHistory = jQuery.extend(true, [], callHistory); + + spaces[myspace] = {"allNodes":myNodes, "zparams":myParams, "trans":myTrans, "force":myForce, "preprocess":myPreprocess, "logArray":myLog, "callHistory":myHistory}; + + // remove pre-subset svg + var selectMe = "#m".concat(myspace); + d3.select(selectMe).attr('class', 'item'); + selectMe = "#whitespace".concat(myspace); + d3.select(selectMe).remove(); + + selectMe = "navdot".concat(myspace); + var mynavdot = document.getElementById(selectMe); + mynavdot.removeAttribute("class"); + + myspace = spaces.length; + callHistory.push({func:"subset", zvars:jQuery.extend(true, [],zparams.zvars), zsubset:jQuery.extend(true, [],zparams.zsubset), zplot:jQuery.extend(true, [],zparams.zplot)}); + + + selectMe = "navdot".concat(myspace-1); + mynavdot = document.getElementById(selectMe); + + var newnavdot = document.createElement("li"); + newnavdot.setAttribute("class", "active"); + selectMe = "navdot".concat(myspace); + newnavdot.setAttribute("id", selectMe); + mynavdot.parentNode.insertBefore(newnavdot, mynavdot.nextSibling); + + + // this is to be used to gray out and remove listeners for variables that have been subsetted out of the data + function varOut(v) { + // if in nodes, remove + // gray out in left panel + // make unclickable in left panel + for(var i=0; i < v.length; i++) { + var selectMe=v[i].replace(/\W/g, "_"); + document.getElementById(selectMe).style.color=hexToRgba(grayColor); + selectMe = "p#".concat(selectMe); + d3.select(selectMe) + .on("click", null); + } + } + + logArray.push("subset: ".concat(rCall[0])); + showLog(); + reWriteLog(); + + d3.select("#innercarousel") + .append('div') + .attr('class', 'item active') + .attr('id', function(){ + return "m".concat(myspace.toString()); + }) + .append('svg') + .attr('id', 'whitespace'); + svg = d3.select("#whitespace"); + + + d3.json(json.url, function(error, json) { + if (error) return console.warn(error); + var jsondata = json; + + for(var key in jsondata) { + var myIndex = findNodeIndex(key); + jQuery.extend(true, allNodes[myIndex], jsondata[key]); + + allNodes[myIndex].subsetplot=false; + allNodes[myIndex].subsetrange=["",""]; + allNodes[myIndex].setxplot=false; + allNodes[myIndex].setxvals=["",""]; + + if(allNodes[myIndex].valid==0) { + grayOuts.push(allNodes[myIndex].name); + allNodes[myIndex].grayout=true; + } + } + + rePlot(); + populatePopover(); + layout(v="add"); + + }); + + varOut(grayOuts); + } + + + function subsetSelectFail(btn) { + selectLadda.stop(); //stop motion + } + + selectLadda.start(); //start button motion + makeCorsRequest(urlcall,btn, subsetSelectSuccess, subsetSelectFail, solajsonout); + +} + +function readPreprocess(url, p, v, callback) { + console.log(url); + d3.json(url, function(error, json) { + if (error) return console.warn(error); + var jsondata = json; + + //copying the object + for(var key in jsondata) { + p[key] = jsondata[key]; + } + + if(typeof callback === "function") { + callback(); + } + }); +} + + +function delSpace() { + if (spaces.length===0 | (spaces.length===1 & myspace===0)) {return;} + var lastSpace = false; + if(myspace >= spaces.length-1) { lastSpace=true; } + spaces.splice(myspace, 1); + + // remove current whitespace + var selectMe = "#m".concat(myspace); + d3.select(selectMe).attr('class', 'item'); + selectMe = "#whitespace".concat(myspace); + d3.select(selectMe).remove(); + + // remove last navdot + selectMe = "navdot".concat(spaces.length); + var mynavdot = document.getElementById(selectMe); + mynavdot.parentElement.removeChild(mynavdot); // remove from parent to remove the pointer to the child + + // remove last inner carousel m + selectMe = "m".concat(spaces.length); + var mynavdot = document.getElementById(selectMe); + mynavdot.parentElement.removeChild(mynavdot); + + if(lastSpace) { myspace = myspace-1; } + + selectMe = "navdot".concat(myspace); + newnavdot = document.getElementById(selectMe); + newnavdot.setAttribute("class", "active"); + + // add whitespace back in to current inner carousel m + selectMe = "#m".concat(myspace); + d3.select(selectMe).attr('class', 'item active') + .append('svg').attr('id', function(){ + return "whitespace".concat(myspace); + }); + + allNodes = jQuery.extend(true, [], spaces[myspace].allNodes); + zparams = jQuery.extend(true, {}, spaces[myspace].zparams); + trans = jQuery.extend(true, [], spaces[myspace].trans); + forcetoggle = jQuery.extend(true, [], spaces[myspace].force); + preprocess = jQuery.extend(true, {}, spaces[myspace].preprocess); + + selectMe = "#whitespace".concat(myspace); + svg = d3.select(selectMe); + + layout(v="move"); +} + + +// for the following three functions, the general idea is to store the new information for the current space, and then move myspace according (right: +1, left: -1, addSpace: spaces.length) +function addSpace() { + + zPop(); + + // everything we need to save the image of the current space. + var myNodes = jQuery.extend(true, [], allNodes); // very important. this clones the allNodes object, and may slow us down in the future. if user hits plus 4 times, we'll have four copies of the same space in memory. certainly a way to optimize this + var myParams = jQuery.extend(true, {}, zparams); + var myTrans = jQuery.extend(true, [], trans); + var myForce = jQuery.extend(true, [], forcetoggle); + var myPreprocess = jQuery.extend(true, {}, preprocess); + var myLog = jQuery.extend(true, [], logArray); + var myHistory = jQuery.extend(true, [], callHistory); + + + spaces[myspace] = {"allNodes":myNodes, "zparams":myParams, "trans":myTrans, "force":myForce, "preprocess":myPreprocess, "logArray":myLog, "callHistory":myHistory}; + + var selectMe = "#m".concat(myspace); + d3.select(selectMe).attr('class', 'item'); + selectMe = "#whitespace".concat(myspace); + d3.select(selectMe).remove(); + + selectMe = "navdot".concat(myspace); + var mynavdot = document.getElementById(selectMe); + mynavdot.removeAttribute("class"); + + myspace = spaces.length; + + selectMe = "navdot".concat(myspace-1); + mynavdot = document.getElementById(selectMe); + + var newnavdot = document.createElement("li"); + newnavdot.setAttribute("class", "active"); + selectMe = "navdot".concat(myspace); + newnavdot.setAttribute("id", selectMe); + mynavdot.parentNode.insertBefore(newnavdot, mynavdot.nextSibling); + + d3.select("#innercarousel") + .append('div') + .attr('class', 'item active') + .attr('id', function(){ + return "m".concat(myspace.toString()); + }) + .append('svg') + .attr('id', 'whitespace'); + svg = d3.select("#whitespace"); + + layout(v="add"); + +} + +function left() { + + zPop(); + + var myNodes = jQuery.extend(true, [], allNodes); // very important. this clones the allNodes object, and may slow us down in the future. if user hits plus 4 times, we'll have four copies of the same space in memory. certainly a way to optimize this + var myParams = jQuery.extend(true, {}, zparams); + var myTrans = jQuery.extend(true, [], trans); + var myForce = jQuery.extend(true, [], forcetoggle); + var myPreprocess = jQuery.extend(true, {}, preprocess); + var myLog = jQuery.extend(true, [], logArray); + var myHistory = jQuery.extend(true, [], callHistory); + + if(typeof spaces[myspace] === "undefined") { + spaces.push({"allNodes":myNodes, "zparams":myParams, "trans":myTrans, "force":myForce, "preprocess":myPreprocess, "logArray":myLog, "callHistory":myHistory}); + } + else { + spaces[myspace] = {"allNodes":myNodes, "zparams":myParams, "trans":myTrans, "force":myForce, "preprocess":myPreprocess, "logArray":myLog, "callHistory":myHistory}; + } + + if(myspace===0) { + myspace=spaces.length-1; // move to last when left is click at 0 + } + else { + myspace = myspace-1; + } + + selectMe = "#m".concat(myspace); + d3.select(selectMe) + .append('svg').attr('id', function(){ + return "whitespace".concat(myspace); + }); + + allNodes = jQuery.extend(true, [], spaces[myspace].allNodes); + zparams = jQuery.extend(true, {}, spaces[myspace].zparams); + trans = jQuery.extend(true, [], spaces[myspace].trans); + forcetoggle = jQuery.extend(true, [], spaces[myspace].force); + preprocess = jQuery.extend(true, {}, spaces[myspace].preprocess); + logArray = jQuery.extend(true, [], spaces[myspace].logArray); + callHistory = jQuery.extend(true, [], spaces[myspace].callHistory); + + selectMe = "#whitespace".concat(myspace); + svg = d3.select(selectMe); + + rePlot(); + layout(v="move"); + + selectMe = "navdot".concat(myspace); + newnavdot = document.getElementById(selectMe); + newnavdot.setAttribute("class", "active"); + + if(myspace===spaces.length-1) { + myspace=0; + } + else { + myspace = myspace+1; + } + + selectMe = "navdot".concat(myspace); + var mynavdot = document.getElementById(selectMe); + mynavdot.removeAttribute("class", "active"); + + selectMe = "#whitespace".concat(myspace); + d3.select(selectMe).remove(); + + if(myspace===0) { + myspace=spaces.length-1; // move to last when left is click at 0 + } + else { + myspace = myspace-1; + } + + + if(forcetoggle[0]==="false") { + document.getElementById('btnForce').setAttribute("class", "btn active"); + } + else { + document.getElementById('btnForce').setAttribute("class", "btn btn-default"); + } + + d3.select("#models").selectAll("p").style("background-color", varColor); + selectMe = "#_model_".concat(zparams.zmodel); + d3.select(selectMe).style("background-color", hexToRgba(selVarColor)); + + selectMe = "#whitespace".concat(myspace); + svg = d3.select(selectMe); + + legend(); + showLog(); + reWriteLog(); + + // event.preventDefault(); + +} + +function right() { + zPop(); + var myNodes = jQuery.extend(true, [], allNodes); + var myParams = jQuery.extend(true, {}, zparams); + var myTrans = jQuery.extend(true, [], trans); + var myForce = jQuery.extend(true, [], forcetoggle); + var myPreprocess = jQuery.extend(true, {}, preprocess); + var myLog = jQuery.extend(true, [], logArray); + var myHistory = jQuery.extend(true, [], callHistory); + + spaces[myspace] = {"allNodes":myNodes, "zparams":myParams, "trans":myTrans, "force":myForce, "preprocess":myPreprocess, "logArray":myLog,"callHistory":myHistory}; + + + if(myspace===spaces.length-1) { + myspace=0; // move to last when left is click at 0 + } + else { + myspace = myspace+1; + } + + selectMe = "#m".concat(myspace); + d3.select(selectMe) + .append('svg').attr('id', function(){ + return "whitespace".concat(myspace); + }); + + allNodes = jQuery.extend(true, [], spaces[myspace].allNodes); + zparams = jQuery.extend(true, {}, spaces[myspace].zparams); + trans = jQuery.extend(true, [], spaces[myspace].trans); + forcetoggle = jQuery.extend(true, [], spaces[myspace].force); + preprocess = jQuery.extend(true, {}, spaces[myspace].preprocess); + logArray = jQuery.extend(true, [], spaces[myspace].logArray); + callHistory = jQuery.extend(true, [], spaces[myspace].callHistory); + + selectMe = "#whitespace".concat(myspace); + svg = d3.select(selectMe); + + rePlot(); + layout(v="move"); + + if(myspace===0) { + myspace=spaces.length-1; + } + else { + myspace = myspace-1; + } + + selectMe = "navdot".concat(myspace); + var mynavdot = document.getElementById(selectMe); + mynavdot.removeAttribute("class", "active"); + + selectMe = "#whitespace".concat(myspace); + d3.select(selectMe).remove(); + + if(myspace===spaces.length-1) { + myspace=0; // move to last when left is click at 0 + } + else { + myspace = myspace+1; + } + + selectMe = "navdot".concat(myspace); + var newnavdot = document.getElementById(selectMe); + newnavdot.setAttribute("class", "active"); + + if(forcetoggle[0]==="false") { + document.getElementById('btnForce').setAttribute("class", "btn active"); + } + else { + document.getElementById('btnForce').setAttribute("class", "btn btn-default"); + } + + d3.select("#models").selectAll("p").style("background-color", varColor); + selectMe = "#_model_".concat(zparams.zmodel); + d3.select(selectMe).style("background-color", hexToRgba(selVarColor)); + + selectMe = "#whitespace".concat(myspace); + svg = d3.select(selectMe); + + legend(); + showLog(); + reWriteLog(); + + // event.preventDefault(); +} + + +function about() { + $('#about').show(); +} + +function closeabout() { + $('#about').hide(); +} + +function opencite() { + $('#cite').show(); +} + +function closecite(toggle) { + if(toggle==false) { + $('#cite').hide(); + } +} + +function clickcite(toggle) { + if(toggle==false) { + $('#cite').show(); + return true; + }else { + $('#cite').hide(); + return false; + } +} +// function to remove all the children svgs inside subset and setx divs +function rePlot() { + + d3.select("#tab2") + .selectAll("svg") + .remove(); + + d3.select("#setx") + .selectAll("svg") + .remove(); + + // make this smarter + for(var i = 0; i 0) { + document.getElementById('logdiv').setAttribute("style", "display:block"); + d3.select("#collapseLog div.panel-body").selectAll("p") + .data(logArray) + .enter() + .append("p") + .text(function(d){ + return d; + }); + } + else { + document.getElementById('logdiv').setAttribute("style", "display:none"); + } +} + +function reWriteLog() { + d3.select("#collapseLog div.panel-body").selectAll("p") + .remove(); + d3.select("#collapseLog div.panel-body").selectAll("p") + .data(logArray) + .enter() + .append("p") + .text(function(d){ + return d; + }); +} + + +// acts as if the user clicked in whitespace. useful when restart() is outside of scope +function fakeClick() { + var myws = "#whitespace".concat(myspace); + // d3 and programmatic events don't mesh well, here's a SO workaround that looks good but uses jquery... + jQuery.fn.d3Click = function () { + this.each(function (i, e) { + var evt = document.createEvent("MouseEvents"); + evt.initMouseEvent("mousedown", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + + e.dispatchEvent(evt); + }); + }; + $(myws).d3Click(); + + d3.select(myws) + .classed('active', false); // remove active class +} + + diff --git a/tworavens/bar.js b/tworavens/bar.js new file mode 100644 index 0000000..059ea56 --- /dev/null +++ b/tworavens/bar.js @@ -0,0 +1,32 @@ + //Width and height +var barwidth = 40; +var barheight = 20; +var barPadding = 0.25; + + +var dataset = [ 5, 10, 13, 19, 21, 25, 22, 18, 15, 13, + 11, 12]; //, 15, 20, 18, 17, 16, 18, 23, 25 ]; + +//Create SVG element +var svg = d3.select("body") .append("svg") + .attr("width", barwidth) + .attr("height", barheight); + +svg.selectAll("rect") + .data(dataset) + .enter() + .append("rect") + .attr("x", function(d, i) { + return i * (barwidth / dataset.length); + }) + .attr("y", function(d) { + return barheight - d; //Height minus data value + }) + .attr("width", barwidth / dataset.length - barPadding) + .attr("height", function(d) { + return d; //Just the data value + }) + .attr("fill", "#4F4F4F") + ; + + diff --git a/tworavens/d3.v3.js b/tworavens/d3.v3.js new file mode 100644 index 0000000..3da97d6 --- /dev/null +++ b/tworavens/d3.v3.js @@ -0,0 +1,8783 @@ +d3 = function() { + var d3 = { + version: "3.2.1" + }; + if (!Date.now) Date.now = function() { + return +new Date(); + }; + var d3_document = document, d3_documentElement = d3_document.documentElement, d3_window = window; + try { + d3_document.createElement("div").style.setProperty("opacity", 0, ""); + } catch (error) { + var d3_style_prototype = d3_window.CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty; + d3_style_prototype.setProperty = function(name, value, priority) { + d3_style_setProperty.call(this, name, value + "", priority); + }; + } + d3.ascending = function(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; + }; + d3.descending = function(a, b) { + return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; + }; + d3.min = function(array, f) { + var i = -1, n = array.length, a, b; + if (arguments.length === 1) { + while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; + while (++i < n) if ((b = array[i]) != null && a > b) a = b; + } else { + while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; + while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b; + } + return a; + }; + d3.max = function(array, f) { + var i = -1, n = array.length, a, b; + if (arguments.length === 1) { + while (++i < n && !((a = array[i]) != null && a <= a)) a = undefined; + while (++i < n) if ((b = array[i]) != null && b > a) a = b; + } else { + while (++i < n && !((a = f.call(array, array[i], i)) != null && a <= a)) a = undefined; + while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b; + } + return a; + }; + d3.extent = function(array, f) { + var i = -1, n = array.length, a, b, c; + if (arguments.length === 1) { + while (++i < n && !((a = c = array[i]) != null && a <= a)) a = c = undefined; + while (++i < n) if ((b = array[i]) != null) { + if (a > b) a = b; + if (c < b) c = b; + } + } else { + while (++i < n && !((a = c = f.call(array, array[i], i)) != null && a <= a)) a = undefined; + while (++i < n) if ((b = f.call(array, array[i], i)) != null) { + if (a > b) a = b; + if (c < b) c = b; + } + } + return [ a, c ]; + }; + d3.sum = function(array, f) { + var s = 0, n = array.length, a, i = -1; + if (arguments.length === 1) { + while (++i < n) if (!isNaN(a = +array[i])) s += a; + } else { + while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a; + } + return s; + }; + function d3_number(x) { + return x != null && !isNaN(x); + } + d3.mean = function(array, f) { + var n = array.length, a, m = 0, i = -1, j = 0; + if (arguments.length === 1) { + while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j; + } else { + while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j; + } + return j ? m : undefined; + }; + d3.quantile = function(values, p) { + var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h; + return e ? v + e * (values[h] - v) : v; + }; + d3.median = function(array, f) { + if (arguments.length > 1) array = array.map(f); + array = array.filter(d3_number); + return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined; + }; + d3.bisector = function(f) { + return { + left: function(a, x, lo, hi) { + if (arguments.length < 3) lo = 0; + if (arguments.length < 4) hi = a.length; + while (lo < hi) { + var mid = lo + hi >>> 1; + if (f.call(a, a[mid], mid) < x) lo = mid + 1; else hi = mid; + } + return lo; + }, + right: function(a, x, lo, hi) { + if (arguments.length < 3) lo = 0; + if (arguments.length < 4) hi = a.length; + while (lo < hi) { + var mid = lo + hi >>> 1; + if (x < f.call(a, a[mid], mid)) hi = mid; else lo = mid + 1; + } + return lo; + } + }; + }; + var d3_bisector = d3.bisector(function(d) { + return d; + }); + d3.bisectLeft = d3_bisector.left; + d3.bisect = d3.bisectRight = d3_bisector.right; + d3.shuffle = function(array) { + var m = array.length, t, i; + while (m) { + i = Math.random() * m-- | 0; + t = array[m], array[m] = array[i], array[i] = t; + } + return array; + }; + d3.permute = function(array, indexes) { + var permutes = [], i = -1, n = indexes.length; + while (++i < n) permutes[i] = array[indexes[i]]; + return permutes; + }; + d3.zip = function() { + if (!(n = arguments.length)) return []; + for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) { + for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) { + zip[j] = arguments[j][i]; + } + } + return zips; + }; + function d3_zipLength(d) { + return d.length; + } + d3.transpose = function(matrix) { + return d3.zip.apply(d3, matrix); + }; + d3.keys = function(map) { + var keys = []; + for (var key in map) keys.push(key); + return keys; + }; + d3.values = function(map) { + var values = []; + for (var key in map) values.push(map[key]); + return values; + }; + d3.entries = function(map) { + var entries = []; + for (var key in map) entries.push({ + key: key, + value: map[key] + }); + return entries; + }; + d3.merge = function(arrays) { + return Array.prototype.concat.apply([], arrays); + }; + d3.range = function(start, stop, step) { + if (arguments.length < 3) { + step = 1; + if (arguments.length < 2) { + stop = start; + start = 0; + } + } + if ((stop - start) / step === Infinity) throw new Error("infinite range"); + var range = [], k = d3_range_integerScale(Math.abs(step)), i = -1, j; + start *= k, stop *= k, step *= k; + if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k); + return range; + }; + function d3_range_integerScale(x) { + var k = 1; + while (x * k % 1) k *= 10; + return k; + } + function d3_class(ctor, properties) { + try { + for (var key in properties) { + Object.defineProperty(ctor.prototype, key, { + value: properties[key], + enumerable: false + }); + } + } catch (e) { + ctor.prototype = properties; + } + } + d3.map = function(object) { + var map = new d3_Map(); + for (var key in object) map.set(key, object[key]); + return map; + }; + function d3_Map() {} + d3_class(d3_Map, { + has: function(key) { + return d3_map_prefix + key in this; + }, + get: function(key) { + return this[d3_map_prefix + key]; + }, + set: function(key, value) { + return this[d3_map_prefix + key] = value; + }, + remove: function(key) { + key = d3_map_prefix + key; + return key in this && delete this[key]; + }, + keys: function() { + var keys = []; + this.forEach(function(key) { + keys.push(key); + }); + return keys; + }, + values: function() { + var values = []; + this.forEach(function(key, value) { + values.push(value); + }); + return values; + }, + entries: function() { + var entries = []; + this.forEach(function(key, value) { + entries.push({ + key: key, + value: value + }); + }); + return entries; + }, + forEach: function(f) { + for (var key in this) { + if (key.charCodeAt(0) === d3_map_prefixCode) { + f.call(this, key.substring(1), this[key]); + } + } + } + }); + var d3_map_prefix = "\0", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); + d3.nest = function() { + var nest = {}, keys = [], sortKeys = [], sortValues, rollup; + function map(mapType, array, depth) { + if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array; + var i = -1, n = array.length, key = keys[depth++], keyValue, object, setter, valuesByKey = new d3_Map(), values; + while (++i < n) { + if (values = valuesByKey.get(keyValue = key(object = array[i]))) { + values.push(object); + } else { + valuesByKey.set(keyValue, [ object ]); + } + } + if (mapType) { + object = mapType(); + setter = function(keyValue, values) { + object.set(keyValue, map(mapType, values, depth)); + }; + } else { + object = {}; + setter = function(keyValue, values) { + object[keyValue] = map(mapType, values, depth); + }; + } + valuesByKey.forEach(setter); + return object; + } + function entries(map, depth) { + if (depth >= keys.length) return map; + var array = [], sortKey = sortKeys[depth++]; + map.forEach(function(key, keyMap) { + array.push({ + key: key, + values: entries(keyMap, depth) + }); + }); + return sortKey ? array.sort(function(a, b) { + return sortKey(a.key, b.key); + }) : array; + } + nest.map = function(array, mapType) { + return map(mapType, array, 0); + }; + nest.entries = function(array) { + return entries(map(d3.map, array, 0), 0); + }; + nest.key = function(d) { + keys.push(d); + return nest; + }; + nest.sortKeys = function(order) { + sortKeys[keys.length - 1] = order; + return nest; + }; + nest.sortValues = function(order) { + sortValues = order; + return nest; + }; + nest.rollup = function(f) { + rollup = f; + return nest; + }; + return nest; + }; + d3.set = function(array) { + var set = new d3_Set(); + if (array) for (var i = 0; i < array.length; i++) set.add(array[i]); + return set; + }; + function d3_Set() {} + d3_class(d3_Set, { + has: function(value) { + return d3_map_prefix + value in this; + }, + add: function(value) { + this[d3_map_prefix + value] = true; + return value; + }, + remove: function(value) { + value = d3_map_prefix + value; + return value in this && delete this[value]; + }, + values: function() { + var values = []; + this.forEach(function(value) { + values.push(value); + }); + return values; + }, + forEach: function(f) { + for (var value in this) { + if (value.charCodeAt(0) === d3_map_prefixCode) { + f.call(this, value.substring(1)); + } + } + } + }); + d3.behavior = {}; + d3.rebind = function(target, source) { + var i = 1, n = arguments.length, method; + while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]); + return target; + }; + function d3_rebind(target, source, method) { + return function() { + var value = method.apply(source, arguments); + return value === source ? target : value; + }; + } + d3.dispatch = function() { + var dispatch = new d3_dispatch(), i = -1, n = arguments.length; + while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); + return dispatch; + }; + function d3_dispatch() {} + d3_dispatch.prototype.on = function(type, listener) { + var i = type.indexOf("."), name = ""; + if (i >= 0) { + name = type.substring(i + 1); + type = type.substring(0, i); + } + if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); + if (arguments.length === 2) { + if (listener == null) for (type in this) { + if (this.hasOwnProperty(type)) this[type].on(name, null); + } + return this; + } + }; + function d3_dispatch_event(dispatch) { + var listeners = [], listenerByName = new d3_Map(); + function event() { + var z = listeners, i = -1, n = z.length, l; + while (++i < n) if (l = z[i].on) l.apply(this, arguments); + return dispatch; + } + event.on = function(name, listener) { + var l = listenerByName.get(name), i; + if (arguments.length < 2) return l && l.on; + if (l) { + l.on = null; + listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); + listenerByName.remove(name); + } + if (listener) listeners.push(listenerByName.set(name, { + on: listener + })); + return dispatch; + }; + return event; + } + d3.event = null; + function d3_eventCancel() { + d3.event.stopPropagation(); + d3.event.preventDefault(); + } + function d3_eventSource() { + var e = d3.event, s; + while (s = e.sourceEvent) e = s; + return e; + } + function d3_eventSuppress(target, type) { + function off() { + target.on(type, null); + } + target.on(type, function() { + d3_eventCancel(); + off(); + }, true); + setTimeout(off, 0); + } + function d3_eventDispatch(target) { + var dispatch = new d3_dispatch(), i = 0, n = arguments.length; + while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); + dispatch.of = function(thiz, argumentz) { + return function(e1) { + try { + var e0 = e1.sourceEvent = d3.event; + e1.target = target; + d3.event = e1; + dispatch[e1.type].apply(thiz, argumentz); + } finally { + d3.event = e0; + } + }; + }; + return dispatch; + } + d3.mouse = function(container) { + return d3_mousePoint(container, d3_eventSource()); + }; + var d3_mouse_bug44083 = /WebKit/.test(d3_window.navigator.userAgent) ? -1 : 0; + function d3_mousePoint(container, e) { + var svg = container.ownerSVGElement || container; + if (svg.createSVGPoint) { + var point = svg.createSVGPoint(); + if (d3_mouse_bug44083 < 0 && (d3_window.scrollX || d3_window.scrollY)) { + svg = d3.select("body").append("svg").style({ + position: "absolute", + top: 0, + left: 0, + margin: 0, + padding: 0, + border: "none" + }, "important"); + var ctm = svg[0][0].getScreenCTM(); + d3_mouse_bug44083 = !(ctm.f || ctm.e); + svg.remove(); + } + if (d3_mouse_bug44083) { + point.x = e.pageX; + point.y = e.pageY; + } else { + point.x = e.clientX; + point.y = e.clientY; + } + point = point.matrixTransform(container.getScreenCTM().inverse()); + return [ point.x, point.y ]; + } + var rect = container.getBoundingClientRect(); + return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; + } + var d3_array = d3_arraySlice; + function d3_arrayCopy(pseudoarray) { + var i = -1, n = pseudoarray.length, array = []; + while (++i < n) array.push(pseudoarray[i]); + return array; + } + function d3_arraySlice(pseudoarray) { + return Array.prototype.slice.call(pseudoarray); + } + try { + d3_array(d3_documentElement.childNodes)[0].nodeType; + } catch (e) { + d3_array = d3_arrayCopy; + } + var d3_arraySubclass = [].__proto__ ? function(array, prototype) { + array.__proto__ = prototype; + } : function(array, prototype) { + for (var property in prototype) array[property] = prototype[property]; + }; + d3.touches = function(container, touches) { + if (arguments.length < 2) touches = d3_eventSource().touches; + return touches ? d3_array(touches).map(function(touch) { + var point = d3_mousePoint(container, touch); + point.identifier = touch.identifier; + return point; + }) : []; + }; + function d3_vendorSymbol(object, name) { + if (name in object) return name; + name = name.charAt(0).toUpperCase() + name.substring(1); + for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { + var prefixName = d3_vendorPrefixes[i] + name; + if (prefixName in object) return prefixName; + } + } + var d3_vendorPrefixes = [ "webkit", "ms", "moz", "Moz", "o", "O" ]; + var d3_event_userSelectProperty = d3_vendorSymbol(d3_documentElement.style, "userSelect"), d3_event_userSelectSuppress = d3_event_userSelectProperty ? function() { + var style = d3_documentElement.style, select = style[d3_event_userSelectProperty]; + style[d3_event_userSelectProperty] = "none"; + return function() { + style[d3_event_userSelectProperty] = select; + }; + } : function(type) { + var w = d3.select(d3_window).on("selectstart." + type, d3_eventCancel); + return function() { + w.on("selectstart." + type, null); + }; + }; + d3.behavior.drag = function() { + var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null; + function drag() { + this.on("mousedown.drag", mousedown).on("touchstart.drag", mousedown); + } + function mousedown() { + var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null, offset, origin_ = point(), moved = 0, selectEnable = d3_event_userSelectSuppress(touchId != null ? "drag-" + touchId : "drag"); + var w = d3.select(d3_window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true); + if (origin) { + offset = origin.apply(target, arguments); + offset = [ offset.x - origin_[0], offset.y - origin_[1] ]; + } else { + offset = [ 0, 0 ]; + } + event_({ + type: "dragstart" + }); + function point() { + var p = target.parentNode; + return touchId != null ? d3.touches(p).filter(function(p) { + return p.identifier === touchId; + })[0] : d3.mouse(p); + } + function dragmove() { + if (!target.parentNode) return dragend(); + var p = point(), dx = p[0] - origin_[0], dy = p[1] - origin_[1]; + moved |= dx | dy; + origin_ = p; + d3_eventCancel(); + event_({ + type: "drag", + x: p[0] + offset[0], + y: p[1] + offset[1], + dx: dx, + dy: dy + }); + } + function dragend() { + event_({ + type: "dragend" + }); + if (moved) { + d3_eventCancel(); + if (d3.event.target === eventTarget) d3_eventSuppress(w, "click"); + } + w.on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", null).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", null); + selectEnable(); + } + } + drag.origin = function(x) { + if (!arguments.length) return origin; + origin = x; + return drag; + }; + return d3.rebind(drag, event, "on"); + }; + function d3_selection(groups) { + d3_arraySubclass(groups, d3_selectionPrototype); + return groups; + } + var d3_select = function(s, n) { + return n.querySelector(s); + }, d3_selectAll = function(s, n) { + return n.querySelectorAll(s); + }, d3_selectMatcher = d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) { + return d3_selectMatcher.call(n, s); + }; + if (typeof Sizzle === "function") { + d3_select = function(s, n) { + return Sizzle(s, n)[0] || null; + }; + d3_selectAll = function(s, n) { + return Sizzle.uniqueSort(Sizzle(s, n)); + }; + d3_selectMatches = Sizzle.matchesSelector; + } + d3.selection = function() { + return d3_selectionRoot; + }; + var d3_selectionPrototype = d3.selection.prototype = []; + d3_selectionPrototype.select = function(selector) { + var subgroups = [], subgroup, subnode, group, node; + if (typeof selector !== "function") selector = d3_selection_selector(selector); + for (var j = -1, m = this.length; ++j < m; ) { + subgroups.push(subgroup = []); + subgroup.parentNode = (group = this[j]).parentNode; + for (var i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + subgroup.push(subnode = selector.call(node, node.__data__, i)); + if (subnode && "__data__" in node) subnode.__data__ = node.__data__; + } else { + subgroup.push(null); + } + } + } + return d3_selection(subgroups); + }; + function d3_selection_selector(selector) { + return function() { + return d3_select(selector, this); + }; + } + d3_selectionPrototype.selectAll = function(selector) { + var subgroups = [], subgroup, node; + if (typeof selector !== "function") selector = d3_selection_selectorAll(selector); + for (var j = -1, m = this.length; ++j < m; ) { + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i))); + subgroup.parentNode = node; + } + } + } + return d3_selection(subgroups); + }; + function d3_selection_selectorAll(selector) { + return function() { + return d3_selectAll(selector, this); + }; + } + var d3_nsPrefix = { + svg: "http://www.w3.org/2000/svg", + xhtml: "http://www.w3.org/1999/xhtml", + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" + }; + d3.ns = { + prefix: d3_nsPrefix, + qualify: function(name) { + var i = name.indexOf(":"), prefix = name; + if (i >= 0) { + prefix = name.substring(0, i); + name = name.substring(i + 1); + } + return d3_nsPrefix.hasOwnProperty(prefix) ? { + space: d3_nsPrefix[prefix], + local: name + } : name; + } + }; + d3_selectionPrototype.attr = function(name, value) { + if (arguments.length < 2) { + if (typeof name === "string") { + var node = this.node(); + name = d3.ns.qualify(name); + return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); + } + for (value in name) this.each(d3_selection_attr(value, name[value])); + return this; + } + return this.each(d3_selection_attr(name, value)); + }; + function d3_selection_attr(name, value) { + name = d3.ns.qualify(name); + function attrNull() { + this.removeAttribute(name); + } + function attrNullNS() { + this.removeAttributeNS(name.space, name.local); + } + function attrConstant() { + this.setAttribute(name, value); + } + function attrConstantNS() { + this.setAttributeNS(name.space, name.local, value); + } + function attrFunction() { + var x = value.apply(this, arguments); + if (x == null) this.removeAttribute(name); else this.setAttribute(name, x); + } + function attrFunctionNS() { + var x = value.apply(this, arguments); + if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x); + } + return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; + } + function d3_collapse(s) { + return s.trim().replace(/\s+/g, " "); + } + d3.requote = function(s) { + return s.replace(d3_requote_re, "\\$&"); + }; + var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; + d3_selectionPrototype.classed = function(name, value) { + if (arguments.length < 2) { + if (typeof name === "string") { + var node = this.node(), n = (name = name.trim().split(/^|\s+/g)).length, i = -1; + if (value = node.classList) { + while (++i < n) if (!value.contains(name[i])) return false; + } else { + value = node.getAttribute("class"); + while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; + } + return true; + } + for (value in name) this.each(d3_selection_classed(value, name[value])); + return this; + } + return this.each(d3_selection_classed(name, value)); + }; + function d3_selection_classedRe(name) { + return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); + } + function d3_selection_classed(name, value) { + name = name.trim().split(/\s+/).map(d3_selection_classedName); + var n = name.length; + function classedConstant() { + var i = -1; + while (++i < n) name[i](this, value); + } + function classedFunction() { + var i = -1, x = value.apply(this, arguments); + while (++i < n) name[i](this, x); + } + return typeof value === "function" ? classedFunction : classedConstant; + } + function d3_selection_classedName(name) { + var re = d3_selection_classedRe(name); + return function(node, value) { + if (c = node.classList) return value ? c.add(name) : c.remove(name); + var c = node.getAttribute("class") || ""; + if (value) { + re.lastIndex = 0; + if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); + } else { + node.setAttribute("class", d3_collapse(c.replace(re, " "))); + } + }; + } + d3_selectionPrototype.style = function(name, value, priority) { + var n = arguments.length; + if (n < 3) { + if (typeof name !== "string") { + if (n < 2) value = ""; + for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); + return this; + } + if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name); + priority = ""; + } + return this.each(d3_selection_style(name, value, priority)); + }; + function d3_selection_style(name, value, priority) { + function styleNull() { + this.style.removeProperty(name); + } + function styleConstant() { + this.style.setProperty(name, value, priority); + } + function styleFunction() { + var x = value.apply(this, arguments); + if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority); + } + return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; + } + d3_selectionPrototype.property = function(name, value) { + if (arguments.length < 2) { + if (typeof name === "string") return this.node()[name]; + for (value in name) this.each(d3_selection_property(value, name[value])); + return this; + } + return this.each(d3_selection_property(name, value)); + }; + function d3_selection_property(name, value) { + function propertyNull() { + delete this[name]; + } + function propertyConstant() { + this[name] = value; + } + function propertyFunction() { + var x = value.apply(this, arguments); + if (x == null) delete this[name]; else this[name] = x; + } + return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; + } + d3_selectionPrototype.text = function(value) { + return arguments.length ? this.each(typeof value === "function" ? function() { + var v = value.apply(this, arguments); + this.textContent = v == null ? "" : v; + } : value == null ? function() { + this.textContent = ""; + } : function() { + this.textContent = value; + }) : this.node().textContent; + }; + d3_selectionPrototype.html = function(value) { + return arguments.length ? this.each(typeof value === "function" ? function() { + var v = value.apply(this, arguments); + this.innerHTML = v == null ? "" : v; + } : value == null ? function() { + this.innerHTML = ""; + } : function() { + this.innerHTML = value; + }) : this.node().innerHTML; + }; + d3_selectionPrototype.append = function(name) { + name = d3.ns.qualify(name); + function append() { + return this.appendChild(d3_document.createElementNS(this.namespaceURI, name)); + } + function appendNS() { + return this.appendChild(d3_document.createElementNS(name.space, name.local)); + } + return this.select(name.local ? appendNS : append); + }; + d3_selectionPrototype.insert = function(name, before) { + name = d3.ns.qualify(name); + if (typeof before !== "function") before = d3_selection_selector(before); + function insert(d, i) { + return this.insertBefore(d3_document.createElementNS(this.namespaceURI, name), before.call(this, d, i)); + } + function insertNS(d, i) { + return this.insertBefore(d3_document.createElementNS(name.space, name.local), before.call(this, d, i)); + } + return this.select(name.local ? insertNS : insert); + }; + d3_selectionPrototype.remove = function() { + return this.each(function() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); + }); + }; + d3_selectionPrototype.data = function(value, key) { + var i = -1, n = this.length, group, node; + if (!arguments.length) { + value = new Array(n = (group = this[0]).length); + while (++i < n) { + if (node = group[i]) { + value[i] = node.__data__; + } + } + return value; + } + function bind(group, groupData) { + var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; + if (key) { + var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue; + for (i = -1; ++i < n; ) { + keyValue = key.call(node = group[i], node.__data__, i); + if (nodeByKeyValue.has(keyValue)) { + exitNodes[i] = node; + } else { + nodeByKeyValue.set(keyValue, node); + } + keyValues.push(keyValue); + } + for (i = -1; ++i < m; ) { + keyValue = key.call(groupData, nodeData = groupData[i], i); + if (node = nodeByKeyValue.get(keyValue)) { + updateNodes[i] = node; + node.__data__ = nodeData; + } else if (!dataByKeyValue.has(keyValue)) { + enterNodes[i] = d3_selection_dataNode(nodeData); + } + dataByKeyValue.set(keyValue, nodeData); + nodeByKeyValue.remove(keyValue); + } + for (i = -1; ++i < n; ) { + if (nodeByKeyValue.has(keyValues[i])) { + exitNodes[i] = group[i]; + } + } + } else { + for (i = -1; ++i < n0; ) { + node = group[i]; + nodeData = groupData[i]; + if (node) { + node.__data__ = nodeData; + updateNodes[i] = node; + } else { + enterNodes[i] = d3_selection_dataNode(nodeData); + } + } + for (;i < m; ++i) { + enterNodes[i] = d3_selection_dataNode(groupData[i]); + } + for (;i < n; ++i) { + exitNodes[i] = group[i]; + } + } + enterNodes.update = updateNodes; + enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode; + enter.push(enterNodes); + update.push(updateNodes); + exit.push(exitNodes); + } + var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]); + if (typeof value === "function") { + while (++i < n) { + bind(group = this[i], value.call(group, group.parentNode.__data__, i)); + } + } else { + while (++i < n) { + bind(group = this[i], value); + } + } + update.enter = function() { + return enter; + }; + update.exit = function() { + return exit; + }; + return update; + }; + function d3_selection_dataNode(data) { + return { + __data__: data + }; + } + d3_selectionPrototype.datum = function(value) { + return arguments.length ? this.property("__data__", value) : this.property("__data__"); + }; + d3_selectionPrototype.filter = function(filter) { + var subgroups = [], subgroup, group, node; + if (typeof filter !== "function") filter = d3_selection_filter(filter); + for (var j = 0, m = this.length; j < m; j++) { + subgroups.push(subgroup = []); + subgroup.parentNode = (group = this[j]).parentNode; + for (var i = 0, n = group.length; i < n; i++) { + if ((node = group[i]) && filter.call(node, node.__data__, i)) { + subgroup.push(node); + } + } + } + return d3_selection(subgroups); + }; + function d3_selection_filter(selector) { + return function() { + return d3_selectMatches(this, selector); + }; + } + d3_selectionPrototype.order = function() { + for (var j = -1, m = this.length; ++j < m; ) { + for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) { + if (node = group[i]) { + if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next); + next = node; + } + } + } + return this; + }; + d3_selectionPrototype.sort = function(comparator) { + comparator = d3_selection_sortComparator.apply(this, arguments); + for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator); + return this.order(); + }; + function d3_selection_sortComparator(comparator) { + if (!arguments.length) comparator = d3.ascending; + return function(a, b) { + return !a - !b || comparator(a.__data__, b.__data__); + }; + } + function d3_noop() {} + d3_selectionPrototype.on = function(type, listener, capture) { + var n = arguments.length; + if (n < 3) { + if (typeof type !== "string") { + if (n < 2) listener = false; + for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); + return this; + } + if (n < 2) return (n = this.node()["__on" + type]) && n._; + capture = false; + } + return this.each(d3_selection_on(type, listener, capture)); + }; + function d3_selection_on(type, listener, capture) { + var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; + if (i > 0) type = type.substring(0, i); + var filter = d3_selection_onFilters.get(type); + if (filter) type = filter, wrap = d3_selection_onFilter; + function onRemove() { + var l = this[name]; + if (l) { + this.removeEventListener(type, l, l.$); + delete this[name]; + } + } + function onAdd() { + var l = wrap(listener, d3_array(arguments)); + onRemove.call(this); + this.addEventListener(type, this[name] = l, l.$ = capture); + l._ = listener; + } + function removeAll() { + var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match; + for (var name in this) { + if (match = name.match(re)) { + var l = this[name]; + this.removeEventListener(match[1], l, l.$); + delete this[name]; + } + } + } + return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll; + } + var d3_selection_onFilters = d3.map({ + mouseenter: "mouseover", + mouseleave: "mouseout" + }); + d3_selection_onFilters.forEach(function(k) { + if ("on" + k in d3_document) d3_selection_onFilters.remove(k); + }); + function d3_selection_onListener(listener, argumentz) { + return function(e) { + var o = d3.event; + d3.event = e; + argumentz[0] = this.__data__; + try { + listener.apply(this, argumentz); + } finally { + d3.event = o; + } + }; + } + function d3_selection_onFilter(listener, argumentz) { + var l = d3_selection_onListener(listener, argumentz); + return function(e) { + var target = this, related = e.relatedTarget; + if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) { + l.call(target, e); + } + }; + } + d3_selectionPrototype.each = function(callback) { + return d3_selection_each(this, function(node, i, j) { + callback.call(node, node.__data__, i, j); + }); + }; + function d3_selection_each(groups, callback) { + for (var j = 0, m = groups.length; j < m; j++) { + for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { + if (node = group[i]) callback(node, i, j); + } + } + return groups; + } + d3_selectionPrototype.call = function(callback) { + var args = d3_array(arguments); + callback.apply(args[0] = this, args); + return this; + }; + d3_selectionPrototype.empty = function() { + return !this.node(); + }; + d3_selectionPrototype.node = function() { + for (var j = 0, m = this.length; j < m; j++) { + for (var group = this[j], i = 0, n = group.length; i < n; i++) { + var node = group[i]; + if (node) return node; + } + } + return null; + }; + d3_selectionPrototype.size = function() { + var n = 0; + this.each(function() { + ++n; + }); + return n; + }; + function d3_selection_enter(selection) { + d3_arraySubclass(selection, d3_selection_enterPrototype); + return selection; + } + var d3_selection_enterPrototype = []; + d3.selection.enter = d3_selection_enter; + d3.selection.enter.prototype = d3_selection_enterPrototype; + d3_selection_enterPrototype.append = d3_selectionPrototype.append; + d3_selection_enterPrototype.insert = d3_selectionPrototype.insert; + d3_selection_enterPrototype.empty = d3_selectionPrototype.empty; + d3_selection_enterPrototype.node = d3_selectionPrototype.node; + d3_selection_enterPrototype.call = d3_selectionPrototype.call; + d3_selection_enterPrototype.size = d3_selectionPrototype.size; + d3_selection_enterPrototype.select = function(selector) { + var subgroups = [], subgroup, subnode, upgroup, group, node; + for (var j = -1, m = this.length; ++j < m; ) { + upgroup = (group = this[j]).update; + subgroups.push(subgroup = []); + subgroup.parentNode = group.parentNode; + for (var i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i)); + subnode.__data__ = node.__data__; + } else { + subgroup.push(null); + } + } + } + return d3_selection(subgroups); + }; + d3_selectionPrototype.transition = function() { + var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = Object.create(d3_transitionInherit); + transition.time = Date.now(); + for (var j = -1, m = this.length; ++j < m; ) { + subgroups.push(subgroup = []); + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) d3_transitionNode(node, i, id, transition); + subgroup.push(node); + } + } + return d3_transition(subgroups, id); + }; + d3.select = function(node) { + var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ]; + group.parentNode = d3_documentElement; + return d3_selection([ group ]); + }; + d3.selectAll = function(nodes) { + var group = d3_array(typeof nodes === "string" ? d3_selectAll(nodes, d3_document) : nodes); + group.parentNode = d3_documentElement; + return d3_selection([ group ]); + }; + var d3_selectionRoot = d3.select(d3_documentElement); + d3.behavior.zoom = function() { + var translate = [ 0, 0 ], translate0, scale = 1, distance0, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime; + function zoom() { + this.on("mousedown.zoom", mousedown).on("mousemove.zoom", mousemove).on(d3_behavior_zoomWheel + ".zoom", mousewheel).on("dblclick.zoom", dblclick).on("touchstart.zoom", touchstart).on("touchmove.zoom", touchmove).on("touchend.zoom", touchstart); + } + zoom.translate = function(x) { + if (!arguments.length) return translate; + translate = x.map(Number); + rescale(); + return zoom; + }; + zoom.scale = function(x) { + if (!arguments.length) return scale; + scale = +x; + rescale(); + return zoom; + }; + zoom.scaleExtent = function(x) { + if (!arguments.length) return scaleExtent; + scaleExtent = x == null ? d3_behavior_zoomInfinity : x.map(Number); + return zoom; + }; + zoom.x = function(z) { + if (!arguments.length) return x1; + x1 = z; + x0 = z.copy(); + translate = [ 0, 0 ]; + scale = 1; + return zoom; + }; + zoom.y = function(z) { + if (!arguments.length) return y1; + y1 = z; + y0 = z.copy(); + translate = [ 0, 0 ]; + scale = 1; + return zoom; + }; + function location(p) { + return [ (p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale ]; + } + function point(l) { + return [ l[0] * scale + translate[0], l[1] * scale + translate[1] ]; + } + function scaleTo(s) { + scale = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s)); + } + function translateTo(p, l) { + l = point(l); + translate[0] += p[0] - l[0]; + translate[1] += p[1] - l[1]; + } + function rescale() { + if (x1) x1.domain(x0.range().map(function(x) { + return (x - translate[0]) / scale; + }).map(x0.invert)); + if (y1) y1.domain(y0.range().map(function(y) { + return (y - translate[1]) / scale; + }).map(y0.invert)); + } + function dispatch(event) { + rescale(); + d3.event.preventDefault(); + event({ + type: "zoom", + scale: scale, + translate: translate + }); + } + function mousedown() { + var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(d3_window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target)), selectEnable = d3_event_userSelectSuppress("zoom"); + function mousemove() { + moved = 1; + translateTo(d3.mouse(target), l); + dispatch(event_); + } + function mouseup() { + if (moved) d3_eventCancel(); + w.on("mousemove.zoom", null).on("mouseup.zoom", null); + selectEnable(); + if (moved && d3.event.target === eventTarget) d3_eventSuppress(w, "click.zoom"); + } + } + function mousewheel() { + if (!translate0) translate0 = location(d3.mouse(this)); + scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * scale); + translateTo(d3.mouse(this), translate0); + dispatch(event.of(this, arguments)); + } + function mousemove() { + translate0 = null; + } + function dblclick() { + var p = d3.mouse(this), l = location(p), k = Math.log(scale) / Math.LN2; + scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1)); + translateTo(p, l); + dispatch(event.of(this, arguments)); + } + function touchstart() { + var touches = d3.touches(this), now = Date.now(); + scale0 = scale; + translate0 = {}; + distance0 = 0; + touches.forEach(function(t) { + translate0[t.identifier] = location(t); + }); + if (touches.length === 1) { + if (now - touchtime < 500) { + var p = touches[0], l = location(touches[0]); + scaleTo(scale * 2); + translateTo(p, l); + dispatch(event.of(this, arguments)); + } + touchtime = now; + } else if (touches.length > 1) { + var p = touches[0], q = touches[1], dx = p[0] - q[0], dy = p[1] - q[1]; + distance0 = dx * dx + dy * dy; + } + } + function touchmove() { + var touches = d3.touches(this), p0 = touches[0], l0 = translate0[p0.identifier]; + if (p1 = touches[1]) { + var p1, l1 = translate0[p1.identifier], scale1 = d3.event.scale; + if (scale1 == null) { + var distance1 = (distance1 = p1[0] - p0[0]) * distance1 + (distance1 = p1[1] - p0[1]) * distance1; + scale1 = distance0 && Math.sqrt(distance1 / distance0); + } + p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ]; + l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ]; + scaleTo(scale1 * scale0); + } + translateTo(p0, l0); + touchtime = null; + dispatch(event.of(this, arguments)); + } + return d3.rebind(zoom, event, "on"); + }; + var d3_behavior_zoomInfinity = [ 0, Infinity ]; + var d3_behavior_zoomDelta, d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { + return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); + }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { + return d3.event.wheelDelta; + }, "mousewheel") : (d3_behavior_zoomDelta = function() { + return -d3.event.detail; + }, "MozMousePixelScroll"); + function d3_Color() {} + d3_Color.prototype.toString = function() { + return this.rgb() + ""; + }; + d3.hsl = function(h, s, l) { + return arguments.length === 1 ? h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : d3_hsl(+h, +s, +l); + }; + function d3_hsl(h, s, l) { + return new d3_Hsl(h, s, l); + } + function d3_Hsl(h, s, l) { + this.h = h; + this.s = s; + this.l = l; + } + var d3_hslPrototype = d3_Hsl.prototype = new d3_Color(); + d3_hslPrototype.brighter = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + return d3_hsl(this.h, this.s, this.l / k); + }; + d3_hslPrototype.darker = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + return d3_hsl(this.h, this.s, k * this.l); + }; + d3_hslPrototype.rgb = function() { + return d3_hsl_rgb(this.h, this.s, this.l); + }; + function d3_hsl_rgb(h, s, l) { + var m1, m2; + h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h; + s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s; + l = l < 0 ? 0 : l > 1 ? 1 : l; + m2 = l <= .5 ? l * (1 + s) : l + s - l * s; + m1 = 2 * l - m2; + function v(h) { + if (h > 360) h -= 360; else if (h < 0) h += 360; + if (h < 60) return m1 + (m2 - m1) * h / 60; + if (h < 180) return m2; + if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60; + return m1; + } + function vv(h) { + return Math.round(v(h) * 255); + } + return d3_rgb(vv(h + 120), vv(h), vv(h - 120)); + } + var π = Math.PI, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π; + function d3_sgn(x) { + return x > 0 ? 1 : x < 0 ? -1 : 0; + } + function d3_acos(x) { + return x > 1 ? 0 : x < -1 ? π : Math.acos(x); + } + function d3_asin(x) { + return x > 1 ? π / 2 : x < -1 ? -π / 2 : Math.asin(x); + } + function d3_sinh(x) { + return (Math.exp(x) - Math.exp(-x)) / 2; + } + function d3_cosh(x) { + return (Math.exp(x) + Math.exp(-x)) / 2; + } + function d3_haversin(x) { + return (x = Math.sin(x / 2)) * x; + } + d3.hcl = function(h, c, l) { + return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l); + }; + function d3_hcl(h, c, l) { + return new d3_Hcl(h, c, l); + } + function d3_Hcl(h, c, l) { + this.h = h; + this.c = c; + this.l = l; + } + var d3_hclPrototype = d3_Hcl.prototype = new d3_Color(); + d3_hclPrototype.brighter = function(k) { + return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); + }; + d3_hclPrototype.darker = function(k) { + return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); + }; + d3_hclPrototype.rgb = function() { + return d3_hcl_lab(this.h, this.c, this.l).rgb(); + }; + function d3_hcl_lab(h, c, l) { + if (isNaN(h)) h = 0; + if (isNaN(c)) c = 0; + return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); + } + d3.lab = function(l, a, b) { + return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b); + }; + function d3_lab(l, a, b) { + return new d3_Lab(l, a, b); + } + function d3_Lab(l, a, b) { + this.l = l; + this.a = a; + this.b = b; + } + var d3_lab_K = 18; + var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; + var d3_labPrototype = d3_Lab.prototype = new d3_Color(); + d3_labPrototype.brighter = function(k) { + return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); + }; + d3_labPrototype.darker = function(k) { + return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); + }; + d3_labPrototype.rgb = function() { + return d3_lab_rgb(this.l, this.a, this.b); + }; + function d3_lab_rgb(l, a, b) { + var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; + x = d3_lab_xyz(x) * d3_lab_X; + y = d3_lab_xyz(y) * d3_lab_Y; + z = d3_lab_xyz(z) * d3_lab_Z; + return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); + } + function d3_lab_hcl(l, a, b) { + return l > 0 ? d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : d3_hcl(NaN, NaN, l); + } + function d3_lab_xyz(x) { + return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; + } + function d3_xyz_lab(x) { + return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; + } + function d3_xyz_rgb(r) { + return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); + } + d3.rgb = function(r, g, b) { + return arguments.length === 1 ? r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : d3_rgb(~~r, ~~g, ~~b); + }; + function d3_rgb(r, g, b) { + return new d3_Rgb(r, g, b); + } + function d3_Rgb(r, g, b) { + this.r = r; + this.g = g; + this.b = b; + } + var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color(); + d3_rgbPrototype.brighter = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + var r = this.r, g = this.g, b = this.b, i = 30; + if (!r && !g && !b) return d3_rgb(i, i, i); + if (r && r < i) r = i; + if (g && g < i) g = i; + if (b && b < i) b = i; + return d3_rgb(Math.min(255, Math.floor(r / k)), Math.min(255, Math.floor(g / k)), Math.min(255, Math.floor(b / k))); + }; + d3_rgbPrototype.darker = function(k) { + k = Math.pow(.7, arguments.length ? k : 1); + return d3_rgb(Math.floor(k * this.r), Math.floor(k * this.g), Math.floor(k * this.b)); + }; + d3_rgbPrototype.hsl = function() { + return d3_rgb_hsl(this.r, this.g, this.b); + }; + d3_rgbPrototype.toString = function() { + return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b); + }; + function d3_rgb_hex(v) { + return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); + } + function d3_rgb_parse(format, rgb, hsl) { + var r = 0, g = 0, b = 0, m1, m2, name; + m1 = /([a-z]+)\((.*)\)/i.exec(format); + if (m1) { + m2 = m1[2].split(","); + switch (m1[1]) { + case "hsl": + { + return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); + } + + case "rgb": + { + return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); + } + } + } + if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b); + if (format != null && format.charAt(0) === "#") { + if (format.length === 4) { + r = format.charAt(1); + r += r; + g = format.charAt(2); + g += g; + b = format.charAt(3); + b += b; + } else if (format.length === 7) { + r = format.substring(1, 3); + g = format.substring(3, 5); + b = format.substring(5, 7); + } + r = parseInt(r, 16); + g = parseInt(g, 16); + b = parseInt(b, 16); + } + return rgb(r, g, b); + } + function d3_rgb_hsl(r, g, b) { + var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2; + if (d) { + s = l < .5 ? d / (max + min) : d / (2 - max - min); + if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4; + h *= 60; + } else { + h = NaN; + s = l > 0 && l < 1 ? 0 : h; + } + return d3_hsl(h, s, l); + } + function d3_rgb_lab(r, g, b) { + r = d3_rgb_xyz(r); + g = d3_rgb_xyz(g); + b = d3_rgb_xyz(b); + var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); + return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); + } + function d3_rgb_xyz(r) { + return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); + } + function d3_rgb_parseNumber(c) { + var f = parseFloat(c); + return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; + } + var d3_rgb_names = d3.map({ + 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" + }); + d3_rgb_names.forEach(function(key, value) { + d3_rgb_names.set(key, d3_rgb_parse(value, d3_rgb, d3_hsl_rgb)); + }); + function d3_functor(v) { + return typeof v === "function" ? v : function() { + return v; + }; + } + d3.functor = d3_functor; + function d3_identity(d) { + return d; + } + d3.xhr = d3_xhrType(d3_identity); + function d3_xhrType(response) { + return function(url, mimeType, callback) { + if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, + mimeType = null; + return d3_xhr(url, mimeType, response, callback); + }; + } + function d3_xhr(url, mimeType, response, callback) { + var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, request = new XMLHttpRequest(), responseType = null; + if (d3_window.XDomainRequest && !("withCredentials" in request) && /^(http(s)?:)?\/\//.test(url)) request = new XDomainRequest(); + "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() { + request.readyState > 3 && respond(); + }; + function respond() { + var status = request.status, result; + if (!status && request.responseText || status >= 200 && status < 300 || status === 304) { + try { + result = response.call(xhr, request); + } catch (e) { + dispatch.error.call(xhr, e); + return; + } + dispatch.load.call(xhr, result); + } else { + dispatch.error.call(xhr, request); + } + } + request.onprogress = function(event) { + var o = d3.event; + d3.event = event; + try { + dispatch.progress.call(xhr, request); + } finally { + d3.event = o; + } + }; + xhr.header = function(name, value) { + name = (name + "").toLowerCase(); + if (arguments.length < 2) return headers[name]; + if (value == null) delete headers[name]; else headers[name] = value + ""; + return xhr; + }; + xhr.mimeType = function(value) { + if (!arguments.length) return mimeType; + mimeType = value == null ? null : value + ""; + return xhr; + }; + xhr.responseType = function(value) { + if (!arguments.length) return responseType; + responseType = value; + return xhr; + }; + xhr.response = function(value) { + response = value; + return xhr; + }; + [ "get", "post" ].forEach(function(method) { + xhr[method] = function() { + return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments))); + }; + }); + xhr.send = function(method, data, callback) { + if (arguments.length === 2 && typeof data === "function") callback = data, data = null; + request.open(method, url, true); + if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*"; + if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]); + if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType); + if (responseType != null) request.responseType = responseType; + if (callback != null) xhr.on("error", callback).on("load", function(request) { + callback(null, request); + }); + request.send(data == null ? null : data); + return xhr; + }; + xhr.abort = function() { + request.abort(); + return xhr; + }; + d3.rebind(xhr, dispatch, "on"); + return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback)); + } + function d3_xhr_fixCallback(callback) { + return callback.length === 1 ? function(error, request) { + callback(error == null ? request : null); + } : callback; + } + d3.dsv = function(delimiter, mimeType) { + var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); + function dsv(url, row, callback) { + if (arguments.length < 3) callback = row, row = null; + var xhr = d3.xhr(url, mimeType, callback); + xhr.row = function(_) { + return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row; + }; + return xhr.row(row); + } + function response(request) { + return dsv.parse(request.responseText); + } + function typedResponse(f) { + return function(request) { + return dsv.parse(request.responseText, f); + }; + } + dsv.parse = function(text, f) { + var o; + return dsv.parseRows(text, function(row, i) { + if (o) return o(row, i - 1); + var a = new Function("d", "return {" + row.map(function(name, i) { + return JSON.stringify(name) + ": d[" + i + "]"; + }).join(",") + "}"); + o = f ? function(row, i) { + return f(a(row), i); + } : a; + }); + }; + dsv.parseRows = function(text, f) { + var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol; + function token() { + if (I >= N) return EOF; + if (eol) return eol = false, EOL; + var j = I; + if (text.charCodeAt(j) === 34) { + var i = j; + while (i++ < N) { + if (text.charCodeAt(i) === 34) { + if (text.charCodeAt(i + 1) !== 34) break; + ++i; + } + } + I = i + 2; + var c = text.charCodeAt(i + 1); + if (c === 13) { + eol = true; + if (text.charCodeAt(i + 2) === 10) ++I; + } else if (c === 10) { + eol = true; + } + return text.substring(j + 1, i).replace(/""/g, '"'); + } + while (I < N) { + var c = text.charCodeAt(I++), k = 1; + if (c === 10) eol = true; else if (c === 13) { + eol = true; + if (text.charCodeAt(I) === 10) ++I, ++k; + } else if (c !== delimiterCode) continue; + return text.substring(j, I - k); + } + return text.substring(j); + } + while ((t = token()) !== EOF) { + var a = []; + while (t !== EOL && t !== EOF) { + a.push(t); + t = token(); + } + if (f && !(a = f(a, n++))) continue; + rows.push(a); + } + return rows; + }; + dsv.format = function(rows) { + if (Array.isArray(rows[0])) return dsv.formatRows(rows); + var fieldSet = new d3_Set(), fields = []; + rows.forEach(function(row) { + for (var field in row) { + if (!fieldSet.has(field)) { + fields.push(fieldSet.add(field)); + } + } + }); + return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) { + return fields.map(function(field) { + return formatValue(row[field]); + }).join(delimiter); + })).join("\n"); + }; + dsv.formatRows = function(rows) { + return rows.map(formatRow).join("\n"); + }; + function formatRow(row) { + return row.map(formatValue).join(delimiter); + } + function formatValue(text) { + return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; + } + return dsv; + }; + d3.csv = d3.dsv(",", "text/csv"); + d3.tsv = d3.dsv(" ", "text/tab-separated-values"); + var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout; + d3.timer = function(callback, delay, then) { + if (arguments.length < 3) { + if (arguments.length < 2) delay = 0; else if (!isFinite(delay)) return; + then = Date.now(); + } + var time = then + delay; + var timer = { + callback: callback, + time: time, + next: null + }; + if (d3_timer_queueTail) d3_timer_queueTail.next = timer; else d3_timer_queueHead = timer; + d3_timer_queueTail = timer; + if (!d3_timer_interval) { + d3_timer_timeout = clearTimeout(d3_timer_timeout); + d3_timer_interval = 1; + d3_timer_frame(d3_timer_step); + } + }; + function d3_timer_step() { + var now = d3_timer_mark(), delay = d3_timer_sweep() - now; + if (delay > 24) { + if (isFinite(delay)) { + clearTimeout(d3_timer_timeout); + d3_timer_timeout = setTimeout(d3_timer_step, delay); + } + d3_timer_interval = 0; + } else { + d3_timer_interval = 1; + d3_timer_frame(d3_timer_step); + } + } + d3.timer.flush = function() { + d3_timer_mark(); + d3_timer_sweep(); + }; + function d3_timer_mark() { + var now = Date.now(), timer = d3_timer_queueHead; + while (timer) { + if (now >= timer.time) timer.flush = timer.callback(now - timer.time); + timer = timer.next; + } + return now; + } + function d3_timer_sweep() { + var t0, t1 = d3_timer_queueHead, time = Infinity; + while (t1) { + if (t1.flush) { + t1 = t0 ? t0.next = t1.next : d3_timer_queueHead = t1.next; + } else { + if (t1.time < time) time = t1.time; + t1 = (t0 = t1).next; + } + } + d3_timer_queueTail = t0; + return time; + } + var d3_timer_frame = d3_window[d3_vendorSymbol(d3_window, "requestAnimationFrame")] || function(callback) { + setTimeout(callback, 17); + }; + var d3_format_decimalPoint = ".", d3_format_thousandsSeparator = ",", d3_format_grouping = [ 3, 3 ]; + var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix); + d3.formatPrefix = function(value, precision) { + var i = 0; + if (value) { + if (value < 0) value *= -1; + if (precision) value = d3.round(value, d3_format_precision(value, precision)); + i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10); + i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3)); + } + return d3_formatPrefixes[8 + i / 3]; + }; + function d3_formatPrefix(d, i) { + var k = Math.pow(10, Math.abs(8 - i) * 3); + return { + scale: i > 8 ? function(d) { + return d / k; + } : function(d) { + return d * k; + }, + symbol: d + }; + } + d3.round = function(x, n) { + return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); + }; + d3.format = function(specifier) { + var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "", basePrefix = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, suffix = "", integer = false; + if (precision) precision = +precision.substring(1); + if (zfill || fill === "0" && align === "=") { + zfill = fill = "0"; + align = "="; + if (comma) width -= Math.floor((width - 1) / 4); + } + switch (type) { + case "n": + comma = true; + type = "g"; + break; + + case "%": + scale = 100; + suffix = "%"; + type = "f"; + break; + + case "p": + scale = 100; + suffix = "%"; + type = "r"; + break; + + case "b": + case "o": + case "x": + case "X": + if (basePrefix) basePrefix = "0" + type.toLowerCase(); + + case "c": + case "d": + integer = true; + precision = 0; + break; + + case "s": + scale = -1; + type = "r"; + break; + } + if (basePrefix === "#") basePrefix = ""; + if (type == "r" && !precision) type = "g"; + if (precision != null) { + if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); + } + type = d3_format_types.get(type) || d3_format_typeDefault; + var zcomma = zfill && comma; + return function(value) { + if (integer && value % 1) return ""; + var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign; + if (scale < 0) { + var prefix = d3.formatPrefix(value, precision); + value = prefix.scale(value); + suffix = prefix.symbol; + } else { + value *= scale; + } + value = type(value, precision); + if (!zfill && comma) value = d3_format_group(value); + var length = basePrefix.length + value.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; + if (zcomma) value = d3_format_group(padding + value); + if (d3_format_decimalPoint) value.replace(".", d3_format_decimalPoint); + negative += basePrefix; + return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + suffix; + }; + }; + var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i; + var d3_format_types = d3.map({ + b: function(x) { + return x.toString(2); + }, + c: function(x) { + return String.fromCharCode(x); + }, + o: function(x) { + return x.toString(8); + }, + x: function(x) { + return x.toString(16); + }, + X: function(x) { + return x.toString(16).toUpperCase(); + }, + g: function(x, p) { + return x.toPrecision(p); + }, + e: function(x, p) { + return x.toExponential(p); + }, + f: function(x, p) { + return x.toFixed(p); + }, + r: function(x, p) { + return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); + } + }); + function d3_format_precision(x, p) { + return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); + } + function d3_format_typeDefault(x) { + return x + ""; + } + var d3_format_group = d3_identity; + if (d3_format_grouping) { + var d3_format_groupingLength = d3_format_grouping.length; + d3_format_group = function(value) { + var i = value.lastIndexOf("."), f = i >= 0 ? "." + value.substring(i + 1) : (i = value.length, + ""), t = [], j = 0, g = d3_format_grouping[0]; + while (i > 0 && g > 0) { + t.push(value.substring(i -= g, i + g)); + g = d3_format_grouping[j = (j + 1) % d3_format_groupingLength]; + } + return t.reverse().join(d3_format_thousandsSeparator || "") + f; + }; + } + d3.geo = {}; + function d3_adder() {} + d3_adder.prototype = { + s: 0, + t: 0, + add: function(y) { + d3_adderSum(y, this.t, d3_adderTemp); + d3_adderSum(d3_adderTemp.s, this.s, this); + if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t; + }, + reset: function() { + this.s = this.t = 0; + }, + valueOf: function() { + return this.s; + } + }; + var d3_adderTemp = new d3_adder(); + function d3_adderSum(a, b, o) { + var x = o.s = a + b, bv = x - a, av = x - bv; + o.t = a - av + (b - bv); + } + d3.geo.stream = function(object, listener) { + if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { + d3_geo_streamObjectType[object.type](object, listener); + } else { + d3_geo_streamGeometry(object, listener); + } + }; + function d3_geo_streamGeometry(geometry, listener) { + if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { + d3_geo_streamGeometryType[geometry.type](geometry, listener); + } + } + var d3_geo_streamObjectType = { + Feature: function(feature, listener) { + d3_geo_streamGeometry(feature.geometry, listener); + }, + FeatureCollection: function(object, listener) { + var features = object.features, i = -1, n = features.length; + while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); + } + }; + var d3_geo_streamGeometryType = { + Sphere: function(object, listener) { + listener.sphere(); + }, + Point: function(object, listener) { + var coordinate = object.coordinates; + listener.point(coordinate[0], coordinate[1]); + }, + MultiPoint: function(object, listener) { + var coordinates = object.coordinates, i = -1, n = coordinates.length, coordinate; + while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]); + }, + LineString: function(object, listener) { + d3_geo_streamLine(object.coordinates, listener, 0); + }, + MultiLineString: function(object, listener) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); + }, + Polygon: function(object, listener) { + d3_geo_streamPolygon(object.coordinates, listener); + }, + MultiPolygon: function(object, listener) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); + }, + GeometryCollection: function(object, listener) { + var geometries = object.geometries, i = -1, n = geometries.length; + while (++i < n) d3_geo_streamGeometry(geometries[i], listener); + } + }; + function d3_geo_streamLine(coordinates, listener, closed) { + var i = -1, n = coordinates.length - closed, coordinate; + listener.lineStart(); + while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]); + listener.lineEnd(); + } + function d3_geo_streamPolygon(coordinates, listener) { + var i = -1, n = coordinates.length; + listener.polygonStart(); + while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); + listener.polygonEnd(); + } + d3.geo.area = function(object) { + d3_geo_areaSum = 0; + d3.geo.stream(object, d3_geo_area); + return d3_geo_areaSum; + }; + var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder(); + var d3_geo_area = { + sphere: function() { + d3_geo_areaSum += 4 * π; + }, + point: d3_noop, + lineStart: d3_noop, + lineEnd: d3_noop, + polygonStart: function() { + d3_geo_areaRingSum.reset(); + d3_geo_area.lineStart = d3_geo_areaRingStart; + }, + polygonEnd: function() { + var area = 2 * d3_geo_areaRingSum; + d3_geo_areaSum += area < 0 ? 4 * π + area : area; + d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; + } + }; + function d3_geo_areaRingStart() { + var λ00, φ00, λ0, cosφ0, sinφ0; + d3_geo_area.point = function(λ, φ) { + d3_geo_area.point = nextPoint; + λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), + sinφ0 = Math.sin(φ); + }; + function nextPoint(λ, φ) { + λ *= d3_radians; + φ = φ * d3_radians / 2 + π / 4; + var dλ = λ - λ0, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(dλ), v = k * Math.sin(dλ); + d3_geo_areaRingSum.add(Math.atan2(v, u)); + λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; + } + d3_geo_area.lineEnd = function() { + nextPoint(λ00, φ00); + }; + } + function d3_geo_cartesian(spherical) { + var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ); + return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ]; + } + function d3_geo_cartesianDot(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; + } + function d3_geo_cartesianCross(a, b) { + return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ]; + } + function d3_geo_cartesianAdd(a, b) { + a[0] += b[0]; + a[1] += b[1]; + a[2] += b[2]; + } + function d3_geo_cartesianScale(vector, k) { + return [ vector[0] * k, vector[1] * k, vector[2] * k ]; + } + function d3_geo_cartesianNormalize(d) { + var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); + d[0] /= l; + d[1] /= l; + d[2] /= l; + } + function d3_geo_spherical(cartesian) { + return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ]; + } + function d3_geo_sphericalEqual(a, b) { + return Math.abs(a[0] - b[0]) < ε && Math.abs(a[1] - b[1]) < ε; + } + d3.geo.bounds = function() { + var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range; + var bound = { + point: point, + lineStart: lineStart, + lineEnd: lineEnd, + polygonStart: function() { + bound.point = ringPoint; + bound.lineStart = ringStart; + bound.lineEnd = ringEnd; + dλSum = 0; + d3_geo_area.polygonStart(); + }, + polygonEnd: function() { + d3_geo_area.polygonEnd(); + bound.point = point; + bound.lineStart = lineStart; + bound.lineEnd = lineEnd; + if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90; + range[0] = λ0, range[1] = λ1; + } + }; + function point(λ, φ) { + ranges.push(range = [ λ0 = λ, λ1 = λ ]); + if (φ < φ0) φ0 = φ; + if (φ > φ1) φ1 = φ; + } + function linePoint(λ, φ) { + var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]); + if (p0) { + var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal); + d3_geo_cartesianNormalize(inflection); + inflection = d3_geo_spherical(inflection); + var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = Math.abs(dλ) > 180; + if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) { + var φi = inflection[1] * d3_degrees; + if (φi > φ1) φ1 = φi; + } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) { + var φi = -inflection[1] * d3_degrees; + if (φi < φ0) φ0 = φi; + } else { + if (φ < φ0) φ0 = φ; + if (φ > φ1) φ1 = φ; + } + if (antimeridian) { + if (λ < λ_) { + if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; + } else { + if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; + } + } else { + if (λ1 >= λ0) { + if (λ < λ0) λ0 = λ; + if (λ > λ1) λ1 = λ; + } else { + if (λ > λ_) { + if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; + } else { + if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; + } + } + } + } else { + point(λ, φ); + } + p0 = p, λ_ = λ; + } + function lineStart() { + bound.point = linePoint; + } + function lineEnd() { + range[0] = λ0, range[1] = λ1; + bound.point = point; + p0 = null; + } + function ringPoint(λ, φ) { + if (p0) { + var dλ = λ - λ_; + dλSum += Math.abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ; + } else λ__ = λ, φ__ = φ; + d3_geo_area.point(λ, φ); + linePoint(λ, φ); + } + function ringStart() { + d3_geo_area.lineStart(); + } + function ringEnd() { + ringPoint(λ__, φ__); + d3_geo_area.lineEnd(); + if (Math.abs(dλSum) > ε) λ0 = -(λ1 = 180); + range[0] = λ0, range[1] = λ1; + p0 = null; + } + function angle(λ0, λ1) { + return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1; + } + function compareRanges(a, b) { + return a[0] - b[0]; + } + function withinRange(x, range) { + return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; + } + return function(feature) { + φ1 = λ1 = -(λ0 = φ0 = Infinity); + ranges = []; + d3.geo.stream(feature, bound); + var n = ranges.length; + if (n) { + ranges.sort(compareRanges); + for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) { + b = ranges[i]; + if (withinRange(b[0], a) || withinRange(b[1], a)) { + if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; + if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; + } else { + merged.push(a = b); + } + } + var best = -Infinity, dλ; + for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) { + b = merged[i]; + if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1]; + } + } + ranges = range = null; + return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ]; + }; + }(); + d3.geo.centroid = function(object) { + d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; + d3.geo.stream(object, d3_geo_centroid); + var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z; + if (m < ε2) { + x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1; + if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0; + m = x * x + y * y + z * z; + if (m < ε2) return [ NaN, NaN ]; + } + return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ]; + }; + var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2; + var d3_geo_centroid = { + sphere: d3_noop, + point: d3_geo_centroidPoint, + lineStart: d3_geo_centroidLineStart, + lineEnd: d3_geo_centroidLineEnd, + polygonStart: function() { + d3_geo_centroid.lineStart = d3_geo_centroidRingStart; + }, + polygonEnd: function() { + d3_geo_centroid.lineStart = d3_geo_centroidLineStart; + } + }; + function d3_geo_centroidPoint(λ, φ) { + λ *= d3_radians; + var cosφ = Math.cos(φ *= d3_radians); + d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)); + } + function d3_geo_centroidPointXYZ(x, y, z) { + ++d3_geo_centroidW0; + d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0; + d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0; + d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0; + } + function d3_geo_centroidLineStart() { + var x0, y0, z0; + d3_geo_centroid.point = function(λ, φ) { + λ *= d3_radians; + var cosφ = Math.cos(φ *= d3_radians); + x0 = cosφ * Math.cos(λ); + y0 = cosφ * Math.sin(λ); + z0 = Math.sin(φ); + d3_geo_centroid.point = nextPoint; + d3_geo_centroidPointXYZ(x0, y0, z0); + }; + function nextPoint(λ, φ) { + λ *= d3_radians; + var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z); + d3_geo_centroidW1 += w; + d3_geo_centroidX1 += w * (x0 + (x0 = x)); + d3_geo_centroidY1 += w * (y0 + (y0 = y)); + d3_geo_centroidZ1 += w * (z0 + (z0 = z)); + d3_geo_centroidPointXYZ(x0, y0, z0); + } + } + function d3_geo_centroidLineEnd() { + d3_geo_centroid.point = d3_geo_centroidPoint; + } + function d3_geo_centroidRingStart() { + var λ00, φ00, x0, y0, z0; + d3_geo_centroid.point = function(λ, φ) { + λ00 = λ, φ00 = φ; + d3_geo_centroid.point = nextPoint; + λ *= d3_radians; + var cosφ = Math.cos(φ *= d3_radians); + x0 = cosφ * Math.cos(λ); + y0 = cosφ * Math.sin(λ); + z0 = Math.sin(φ); + d3_geo_centroidPointXYZ(x0, y0, z0); + }; + d3_geo_centroid.lineEnd = function() { + nextPoint(λ00, φ00); + d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; + d3_geo_centroid.point = d3_geo_centroidPoint; + }; + function nextPoint(λ, φ) { + λ *= d3_radians; + var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u); + d3_geo_centroidX2 += v * cx; + d3_geo_centroidY2 += v * cy; + d3_geo_centroidZ2 += v * cz; + d3_geo_centroidW1 += w; + d3_geo_centroidX1 += w * (x0 + (x0 = x)); + d3_geo_centroidY1 += w * (y0 + (y0 = y)); + d3_geo_centroidZ1 += w * (z0 + (z0 = z)); + d3_geo_centroidPointXYZ(x0, y0, z0); + } + } + function d3_true() { + return true; + } + function d3_geo_clipPolygon(segments, compare, inside, interpolate, listener) { + var subject = [], clip = []; + segments.forEach(function(segment) { + if ((n = segment.length - 1) <= 0) return; + var n, p0 = segment[0], p1 = segment[n]; + if (d3_geo_sphericalEqual(p0, p1)) { + listener.lineStart(); + for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); + listener.lineEnd(); + return; + } + var a = { + point: p0, + points: segment, + other: null, + visited: false, + entry: true, + subject: true + }, b = { + point: p0, + points: [ p0 ], + other: a, + visited: false, + entry: false, + subject: false + }; + a.other = b; + subject.push(a); + clip.push(b); + a = { + point: p1, + points: [ p1 ], + other: null, + visited: false, + entry: false, + subject: true + }; + b = { + point: p1, + points: [ p1 ], + other: a, + visited: false, + entry: true, + subject: false + }; + a.other = b; + subject.push(a); + clip.push(b); + }); + clip.sort(compare); + d3_geo_clipPolygonLinkCircular(subject); + d3_geo_clipPolygonLinkCircular(clip); + if (!subject.length) return; + if (inside) for (var i = 1, e = !inside(clip[0].point), n = clip.length; i < n; ++i) { + clip[i].entry = e = !e; + } + var start = subject[0], current, points, point; + while (1) { + current = start; + while (current.visited) if ((current = current.next) === start) return; + points = current.points; + listener.lineStart(); + do { + current.visited = current.other.visited = true; + if (current.entry) { + if (current.subject) { + for (var i = 0; i < points.length; i++) listener.point((point = points[i])[0], point[1]); + } else { + interpolate(current.point, current.next.point, 1, listener); + } + current = current.next; + } else { + if (current.subject) { + points = current.prev.points; + for (var i = points.length; --i >= 0; ) listener.point((point = points[i])[0], point[1]); + } else { + interpolate(current.point, current.prev.point, -1, listener); + } + current = current.prev; + } + current = current.other; + points = current.points; + } while (!current.visited); + listener.lineEnd(); + } + } + function d3_geo_clipPolygonLinkCircular(array) { + if (!(n = array.length)) return; + var n, i = 0, a = array[0], b; + while (++i < n) { + a.next = b = array[i]; + b.prev = a; + a = b; + } + a.next = b = array[0]; + b.prev = a; + } + function d3_geo_clip(pointVisible, clipLine, interpolate, polygonContains) { + return function(listener) { + var line = clipLine(listener); + var clip = { + point: point, + lineStart: lineStart, + lineEnd: lineEnd, + polygonStart: function() { + clip.point = pointRing; + clip.lineStart = ringStart; + clip.lineEnd = ringEnd; + segments = []; + polygon = []; + listener.polygonStart(); + }, + polygonEnd: function() { + clip.point = point; + clip.lineStart = lineStart; + clip.lineEnd = lineEnd; + segments = d3.merge(segments); + if (segments.length) { + d3_geo_clipPolygon(segments, d3_geo_clipSort, null, interpolate, listener); + } else if (polygonContains(polygon)) { + listener.lineStart(); + interpolate(null, null, 1, listener); + listener.lineEnd(); + } + listener.polygonEnd(); + segments = polygon = null; + }, + sphere: function() { + listener.polygonStart(); + listener.lineStart(); + interpolate(null, null, 1, listener); + listener.lineEnd(); + listener.polygonEnd(); + } + }; + function point(λ, φ) { + if (pointVisible(λ, φ)) listener.point(λ, φ); + } + function pointLine(λ, φ) { + line.point(λ, φ); + } + function lineStart() { + clip.point = pointLine; + line.lineStart(); + } + function lineEnd() { + clip.point = point; + line.lineEnd(); + } + var segments; + var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygon, ring; + function pointRing(λ, φ) { + ringListener.point(λ, φ); + ring.push([ λ, φ ]); + } + function ringStart() { + ringListener.lineStart(); + ring = []; + } + function ringEnd() { + pointRing(ring[0][0], ring[0][1]); + ringListener.lineEnd(); + var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length; + ring.pop(); + polygon.push(ring); + ring = null; + if (!n) return; + if (clean & 1) { + segment = ringSegments[0]; + var n = segment.length - 1, i = -1, point; + listener.lineStart(); + while (++i < n) listener.point((point = segment[i])[0], point[1]); + listener.lineEnd(); + return; + } + if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); + segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); + } + return clip; + }; + } + function d3_geo_clipSegmentLength1(segment) { + return segment.length > 1; + } + function d3_geo_clipBufferListener() { + var lines = [], line; + return { + lineStart: function() { + lines.push(line = []); + }, + point: function(λ, φ) { + line.push([ λ, φ ]); + }, + lineEnd: d3_noop, + buffer: function() { + var buffer = lines; + lines = []; + line = null; + return buffer; + }, + rejoin: function() { + if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); + } + }; + } + function d3_geo_clipSort(a, b) { + return ((a = a.point)[0] < 0 ? a[1] - π / 2 - ε : π / 2 - a[1]) - ((b = b.point)[0] < 0 ? b[1] - π / 2 - ε : π / 2 - b[1]); + } + function d3_geo_pointInPolygon(point, polygon) { + var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, polar = false, southPole = false, winding = 0; + d3_geo_areaRingSum.reset(); + for (var i = 0, n = polygon.length; i < n; ++i) { + var ring = polygon[i], m = ring.length; + if (!m) continue; + var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; + while (true) { + if (j === m) j = 0; + point = ring[j]; + var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, antimeridian = Math.abs(dλ) > π, k = sinφ0 * sinφ; + d3_geo_areaRingSum.add(Math.atan2(k * Math.sin(dλ), cosφ0 * cosφ + k * Math.cos(dλ))); + if (Math.abs(φ) < ε) southPole = true; + polarAngle += antimeridian ? dλ + (dλ >= 0 ? 2 : -2) * π : dλ; + if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { + var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); + d3_geo_cartesianNormalize(arc); + var intersection = d3_geo_cartesianCross(meridianNormal, arc); + d3_geo_cartesianNormalize(intersection); + var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); + if (parallel > φarc) { + winding += antimeridian ^ dλ >= 0 ? 1 : -1; + } + } + if (!j++) break; + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; + } + if (Math.abs(polarAngle) > ε) polar = true; + } + return (!southPole && !polar && d3_geo_areaRingSum < 0 || polarAngle < -ε) ^ winding & 1; + } + var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, d3_geo_clipAntimeridianPolygonContains); + function d3_geo_clipAntimeridianLine(listener) { + var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; + return { + lineStart: function() { + listener.lineStart(); + clean = 1; + }, + point: function(λ1, φ1) { + var sλ1 = λ1 > 0 ? π : -π, dλ = Math.abs(λ1 - λ0); + if (Math.abs(dλ - π) < ε) { + listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? π / 2 : -π / 2); + listener.point(sλ0, φ0); + listener.lineEnd(); + listener.lineStart(); + listener.point(sλ1, φ0); + listener.point(λ1, φ0); + clean = 0; + } else if (sλ0 !== sλ1 && dλ >= π) { + if (Math.abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; + if (Math.abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; + φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1); + listener.point(sλ0, φ0); + listener.lineEnd(); + listener.lineStart(); + listener.point(sλ1, φ0); + clean = 0; + } + listener.point(λ0 = λ1, φ0 = φ1); + sλ0 = sλ1; + }, + lineEnd: function() { + listener.lineEnd(); + λ0 = φ0 = NaN; + }, + clean: function() { + return 2 - clean; + } + }; + } + function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) { + var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1); + return Math.abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2; + } + function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { + var φ; + if (from == null) { + φ = direction * π / 2; + listener.point(-π, φ); + listener.point(0, φ); + listener.point(π, φ); + listener.point(π, 0); + listener.point(π, -φ); + listener.point(0, -φ); + listener.point(-π, -φ); + listener.point(-π, 0); + listener.point(-π, φ); + } else if (Math.abs(from[0] - to[0]) > ε) { + var s = (from[0] < to[0] ? 1 : -1) * π; + φ = direction * s / 2; + listener.point(-s, φ); + listener.point(0, φ); + listener.point(s, φ); + } else { + listener.point(to[0], to[1]); + } + } + var d3_geo_clipAntimeridianPoint = [ -π, 0 ]; + function d3_geo_clipAntimeridianPolygonContains(polygon) { + return d3_geo_pointInPolygon(d3_geo_clipAntimeridianPoint, polygon); + } + function d3_geo_clipCircle(radius) { + var cr = Math.cos(radius), smallRadius = cr > 0, point = [ radius, 0 ], notHemisphere = Math.abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); + return d3_geo_clip(visible, clipLine, interpolate, polygonContains); + function visible(λ, φ) { + return Math.cos(λ) * Math.cos(φ) > cr; + } + function clipLine(listener) { + var point0, c0, v0, v00, clean; + return { + lineStart: function() { + v00 = v0 = false; + clean = 1; + }, + point: function(λ, φ) { + var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; + if (!point0 && (v00 = v0 = v)) listener.lineStart(); + if (v !== v0) { + point2 = intersect(point0, point1); + if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { + point1[0] += ε; + point1[1] += ε; + v = visible(point1[0], point1[1]); + } + } + if (v !== v0) { + clean = 0; + if (v) { + listener.lineStart(); + point2 = intersect(point1, point0); + listener.point(point2[0], point2[1]); + } else { + point2 = intersect(point0, point1); + listener.point(point2[0], point2[1]); + listener.lineEnd(); + } + point0 = point2; + } else if (notHemisphere && point0 && smallRadius ^ v) { + var t; + if (!(c & c0) && (t = intersect(point1, point0, true))) { + clean = 0; + if (smallRadius) { + listener.lineStart(); + listener.point(t[0][0], t[0][1]); + listener.point(t[1][0], t[1][1]); + listener.lineEnd(); + } else { + listener.point(t[1][0], t[1][1]); + listener.lineEnd(); + listener.lineStart(); + listener.point(t[0][0], t[0][1]); + } + } + } + if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { + listener.point(point1[0], point1[1]); + } + point0 = point1, v0 = v, c0 = c; + }, + lineEnd: function() { + if (v0) listener.lineEnd(); + point0 = null; + }, + clean: function() { + return clean | (v00 && v0) << 1; + } + }; + } + function intersect(a, b, two) { + var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b); + var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; + if (!determinant) return !two && a; + var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); + d3_geo_cartesianAdd(A, B); + var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); + if (t2 < 0) return; + var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu); + d3_geo_cartesianAdd(q, A); + q = d3_geo_spherical(q); + if (!two) return q; + var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z; + if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; + var δλ = λ1 - λ0, polar = Math.abs(δλ - π) < ε, meridian = polar || δλ < ε; + if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; + if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (Math.abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { + var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); + d3_geo_cartesianAdd(q1, A); + return [ q, d3_geo_spherical(q1) ]; + } + } + function code(λ, φ) { + var r = smallRadius ? radius : π - radius, code = 0; + if (λ < -r) code |= 1; else if (λ > r) code |= 2; + if (φ < -r) code |= 4; else if (φ > r) code |= 8; + return code; + } + function polygonContains(polygon) { + return d3_geo_pointInPolygon(point, polygon); + } + } + var d3_geo_clipViewMAX = 1e9; + function d3_geo_clipView(x0, y0, x1, y1) { + return function(listener) { + var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), segments, polygon, ring; + var clip = { + point: point, + lineStart: lineStart, + lineEnd: lineEnd, + polygonStart: function() { + listener = bufferListener; + segments = []; + polygon = []; + }, + polygonEnd: function() { + listener = listener_; + if ((segments = d3.merge(segments)).length) { + listener.polygonStart(); + d3_geo_clipPolygon(segments, compare, inside, interpolate, listener); + listener.polygonEnd(); + } else if (insidePolygon([ x0, y0 ])) { + listener.polygonStart(), listener.lineStart(); + interpolate(null, null, 1, listener); + listener.lineEnd(), listener.polygonEnd(); + } + segments = polygon = ring = null; + } + }; + function inside(point) { + var a = corner(point, -1), i = insidePolygon([ a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0 ]); + return i; + } + function insidePolygon(p) { + var wn = 0, n = polygon.length, y = p[1]; + for (var i = 0; i < n; ++i) { + for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { + b = v[j]; + if (a[1] <= y) { + if (b[1] > y && isLeft(a, b, p) > 0) ++wn; + } else { + if (b[1] <= y && isLeft(a, b, p) < 0) --wn; + } + a = b; + } + } + return wn !== 0; + } + function isLeft(a, b, c) { + return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); + } + function interpolate(from, to, direction, listener) { + var a = 0, a1 = 0; + if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { + do { + listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); + } while ((a = (a + direction + 4) % 4) !== a1); + } else { + listener.point(to[0], to[1]); + } + } + function visible(x, y) { + return x0 <= x && x <= x1 && y0 <= y && y <= y1; + } + function point(x, y) { + if (visible(x, y)) listener.point(x, y); + } + var x__, y__, v__, x_, y_, v_, first; + function lineStart() { + clip.point = linePoint; + if (polygon) polygon.push(ring = []); + first = true; + v_ = false; + x_ = y_ = NaN; + } + function lineEnd() { + if (segments) { + linePoint(x__, y__); + if (v__ && v_) bufferListener.rejoin(); + segments.push(bufferListener.buffer()); + } + clip.point = point; + if (v_) listener.lineEnd(); + } + function linePoint(x, y) { + x = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, x)); + y = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, y)); + var v = visible(x, y); + if (polygon) ring.push([ x, y ]); + if (first) { + x__ = x, y__ = y, v__ = v; + first = false; + if (v) { + listener.lineStart(); + listener.point(x, y); + } + } else { + if (v && v_) listener.point(x, y); else { + var a = [ x_, y_ ], b = [ x, y ]; + if (clipLine(a, b)) { + if (!v_) { + listener.lineStart(); + listener.point(a[0], a[1]); + } + listener.point(b[0], b[1]); + if (!v) listener.lineEnd(); + } else if (v) { + listener.lineStart(); + listener.point(x, y); + } + } + } + x_ = x, y_ = y, v_ = v; + } + return clip; + }; + function corner(p, direction) { + return Math.abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : Math.abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : Math.abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2; + } + function compare(a, b) { + return comparePoints(a.point, b.point); + } + function comparePoints(a, b) { + var ca = corner(a, 1), cb = corner(b, 1); + return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; + } + function clipLine(a, b) { + var dx = b[0] - a[0], dy = b[1] - a[1], t = [ 0, 1 ]; + if (Math.abs(dx) < ε && Math.abs(dy) < ε) return x0 <= a[0] && a[0] <= x1 && y0 <= a[1] && a[1] <= y1; + if (d3_geo_clipViewT(x0 - a[0], dx, t) && d3_geo_clipViewT(a[0] - x1, -dx, t) && d3_geo_clipViewT(y0 - a[1], dy, t) && d3_geo_clipViewT(a[1] - y1, -dy, t)) { + if (t[1] < 1) { + b[0] = a[0] + t[1] * dx; + b[1] = a[1] + t[1] * dy; + } + if (t[0] > 0) { + a[0] += t[0] * dx; + a[1] += t[0] * dy; + } + return true; + } + return false; + } + } + function d3_geo_clipViewT(num, denominator, t) { + if (Math.abs(denominator) < ε) return num <= 0; + var u = num / denominator; + if (denominator > 0) { + if (u > t[1]) return false; + if (u > t[0]) t[0] = u; + } else { + if (u < t[0]) return false; + if (u < t[1]) t[1] = u; + } + return true; + } + function d3_geo_compose(a, b) { + function compose(x, y) { + return x = a(x, y), b(x[0], x[1]); + } + if (a.invert && b.invert) compose.invert = function(x, y) { + return x = b.invert(x, y), x && a.invert(x[0], x[1]); + }; + return compose; + } + function d3_geo_conic(projectAt) { + var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1); + p.parallels = function(_) { + if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ]; + return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180); + }; + return p; + } + function d3_geo_conicEqualArea(φ0, φ1) { + var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n; + function forward(λ, φ) { + var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n; + return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ]; + } + forward.invert = function(x, y) { + var ρ0_y = ρ0 - y; + return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ]; + }; + return forward; + } + (d3.geo.conicEqualArea = function() { + return d3_geo_conic(d3_geo_conicEqualArea); + }).raw = d3_geo_conicEqualArea; + d3.geo.albers = function() { + return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070); + }; + d3.geo.albersUsa = function() { + var lower48 = d3.geo.albers(); + var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]); + var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]); + var point, pointStream = { + point: function(x, y) { + point = [ x, y ]; + } + }, lower48Point, alaskaPoint, hawaiiPoint; + function albersUsa(coordinates) { + var x = coordinates[0], y = coordinates[1]; + point = null; + (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y); + return point; + } + albersUsa.invert = function(coordinates) { + var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k; + return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates); + }; + albersUsa.stream = function(stream) { + var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream); + return { + point: function(x, y) { + lower48Stream.point(x, y); + alaskaStream.point(x, y); + hawaiiStream.point(x, y); + }, + sphere: function() { + lower48Stream.sphere(); + alaskaStream.sphere(); + hawaiiStream.sphere(); + }, + lineStart: function() { + lower48Stream.lineStart(); + alaskaStream.lineStart(); + hawaiiStream.lineStart(); + }, + lineEnd: function() { + lower48Stream.lineEnd(); + alaskaStream.lineEnd(); + hawaiiStream.lineEnd(); + }, + polygonStart: function() { + lower48Stream.polygonStart(); + alaskaStream.polygonStart(); + hawaiiStream.polygonStart(); + }, + polygonEnd: function() { + lower48Stream.polygonEnd(); + alaskaStream.polygonEnd(); + hawaiiStream.polygonEnd(); + } + }; + }; + albersUsa.precision = function(_) { + if (!arguments.length) return lower48.precision(); + lower48.precision(_); + alaska.precision(_); + hawaii.precision(_); + return albersUsa; + }; + albersUsa.scale = function(_) { + if (!arguments.length) return lower48.scale(); + lower48.scale(_); + alaska.scale(_ * .35); + hawaii.scale(_); + return albersUsa.translate(lower48.translate()); + }; + albersUsa.translate = function(_) { + if (!arguments.length) return lower48.translate(); + var k = lower48.scale(), x = +_[0], y = +_[1]; + lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point; + alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; + hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; + return albersUsa; + }; + return albersUsa.scale(1070); + }; + var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { + point: d3_noop, + lineStart: d3_noop, + lineEnd: d3_noop, + polygonStart: function() { + d3_geo_pathAreaPolygon = 0; + d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; + }, + polygonEnd: function() { + d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; + d3_geo_pathAreaSum += Math.abs(d3_geo_pathAreaPolygon / 2); + } + }; + function d3_geo_pathAreaRingStart() { + var x00, y00, x0, y0; + d3_geo_pathArea.point = function(x, y) { + d3_geo_pathArea.point = nextPoint; + x00 = x0 = x, y00 = y0 = y; + }; + function nextPoint(x, y) { + d3_geo_pathAreaPolygon += y0 * x - x0 * y; + x0 = x, y0 = y; + } + d3_geo_pathArea.lineEnd = function() { + nextPoint(x00, y00); + }; + } + var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1; + var d3_geo_pathBounds = { + point: d3_geo_pathBoundsPoint, + lineStart: d3_noop, + lineEnd: d3_noop, + polygonStart: d3_noop, + polygonEnd: d3_noop + }; + function d3_geo_pathBoundsPoint(x, y) { + if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x; + if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x; + if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y; + if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y; + } + function d3_geo_pathBuffer() { + var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = []; + var stream = { + point: point, + lineStart: function() { + stream.point = pointLineStart; + }, + lineEnd: lineEnd, + polygonStart: function() { + stream.lineEnd = lineEndPolygon; + }, + polygonEnd: function() { + stream.lineEnd = lineEnd; + stream.point = point; + }, + pointRadius: function(_) { + pointCircle = d3_geo_pathBufferCircle(_); + return stream; + }, + result: function() { + if (buffer.length) { + var result = buffer.join(""); + buffer = []; + return result; + } + } + }; + function point(x, y) { + buffer.push("M", x, ",", y, pointCircle); + } + function pointLineStart(x, y) { + buffer.push("M", x, ",", y); + stream.point = pointLine; + } + function pointLine(x, y) { + buffer.push("L", x, ",", y); + } + function lineEnd() { + stream.point = point; + } + function lineEndPolygon() { + buffer.push("Z"); + } + return stream; + } + function d3_geo_pathBufferCircle(radius) { + return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z"; + } + var d3_geo_pathCentroid = { + point: d3_geo_pathCentroidPoint, + lineStart: d3_geo_pathCentroidLineStart, + lineEnd: d3_geo_pathCentroidLineEnd, + polygonStart: function() { + d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; + }, + polygonEnd: function() { + d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; + d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; + d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; + } + }; + function d3_geo_pathCentroidPoint(x, y) { + d3_geo_centroidX0 += x; + d3_geo_centroidY0 += y; + ++d3_geo_centroidZ0; + } + function d3_geo_pathCentroidLineStart() { + var x0, y0; + d3_geo_pathCentroid.point = function(x, y) { + d3_geo_pathCentroid.point = nextPoint; + d3_geo_pathCentroidPoint(x0 = x, y0 = y); + }; + function nextPoint(x, y) { + var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); + d3_geo_centroidX1 += z * (x0 + x) / 2; + d3_geo_centroidY1 += z * (y0 + y) / 2; + d3_geo_centroidZ1 += z; + d3_geo_pathCentroidPoint(x0 = x, y0 = y); + } + } + function d3_geo_pathCentroidLineEnd() { + d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; + } + function d3_geo_pathCentroidRingStart() { + var x00, y00, x0, y0; + d3_geo_pathCentroid.point = function(x, y) { + d3_geo_pathCentroid.point = nextPoint; + d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y); + }; + function nextPoint(x, y) { + var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); + d3_geo_centroidX1 += z * (x0 + x) / 2; + d3_geo_centroidY1 += z * (y0 + y) / 2; + d3_geo_centroidZ1 += z; + z = y0 * x - x0 * y; + d3_geo_centroidX2 += z * (x0 + x); + d3_geo_centroidY2 += z * (y0 + y); + d3_geo_centroidZ2 += z * 3; + d3_geo_pathCentroidPoint(x0 = x, y0 = y); + } + d3_geo_pathCentroid.lineEnd = function() { + nextPoint(x00, y00); + }; + } + function d3_geo_pathContext(context) { + var pointRadius = 4.5; + var stream = { + point: point, + lineStart: function() { + stream.point = pointLineStart; + }, + lineEnd: lineEnd, + polygonStart: function() { + stream.lineEnd = lineEndPolygon; + }, + polygonEnd: function() { + stream.lineEnd = lineEnd; + stream.point = point; + }, + pointRadius: function(_) { + pointRadius = _; + return stream; + }, + result: d3_noop + }; + function point(x, y) { + context.moveTo(x, y); + context.arc(x, y, pointRadius, 0, 2 * π); + } + function pointLineStart(x, y) { + context.moveTo(x, y); + stream.point = pointLine; + } + function pointLine(x, y) { + context.lineTo(x, y); + } + function lineEnd() { + stream.point = point; + } + function lineEndPolygon() { + context.closePath(); + } + return stream; + } + function d3_geo_resample(project) { + var δ2 = .5, maxDepth = 16; + function resample(stream) { + var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0; + var resample = { + point: point, + lineStart: lineStart, + lineEnd: lineEnd, + polygonStart: function() { + stream.polygonStart(); + resample.lineStart = ringStart; + }, + polygonEnd: function() { + stream.polygonEnd(); + resample.lineStart = lineStart; + } + }; + function point(x, y) { + x = project(x, y); + stream.point(x[0], x[1]); + } + function lineStart() { + x0 = NaN; + resample.point = linePoint; + stream.lineStart(); + } + function linePoint(λ, φ) { + var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ), buffer = []; + resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, buffer); + streamLine(buffer, stream); + stream.point(x0, y0); + } + function lineEnd() { + resample.point = point; + stream.lineEnd(); + } + function ringStart() { + lineStart(); + resample.point = ringPoint; + resample.lineEnd = ringEnd; + } + function ringPoint(λ, φ) { + linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; + resample.point = linePoint; + } + function ringEnd() { + var buffer = []; + resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, buffer); + streamLine(buffer, stream); + resample.lineEnd = lineEnd; + lineEnd(); + } + function streamLine(line, stream) { + for (var i = 0, n = line.length, point; i < n; ++i) { + stream.point((point = line[i])[0], point[1]); + } + } + return resample; + } + function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, buffer) { + var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; + if (d2 > 4 * δ2 && depth--) { + var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = Math.abs(Math.abs(c) - 1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2, tooFar = false; + if (dz * dz / d2 > δ2 || Math.abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || (tooFar = dx2 * dx2 + dy2 * dy2 > 256 * δ2)) { + var s0 = resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, buffer); + buffer.push(p); + var s1 = resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, buffer); + return !tooFar || s0 || s1 || (buffer.pop(), false); + } + } + } + resample.precision = function(_) { + if (!arguments.length) return Math.sqrt(δ2); + maxDepth = (δ2 = _ * _) > 0 && 16; + return resample; + }; + return resample; + } + d3.geo.path = function() { + var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream; + function path(object) { + if (object) { + if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); + if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream); + d3.geo.stream(object, cacheStream); + } + return contextStream.result(); + } + path.area = function(object) { + d3_geo_pathAreaSum = 0; + d3.geo.stream(object, projectStream(d3_geo_pathArea)); + return d3_geo_pathAreaSum; + }; + path.centroid = function(object) { + d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; + d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); + return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ]; + }; + path.bounds = function(object) { + d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity); + d3.geo.stream(object, projectStream(d3_geo_pathBounds)); + return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ]; + }; + path.projection = function(_) { + if (!arguments.length) return projection; + projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; + return reset(); + }; + path.context = function(_) { + if (!arguments.length) return context; + contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_); + if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); + return reset(); + }; + path.pointRadius = function(_) { + if (!arguments.length) return pointRadius; + pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); + return path; + }; + function reset() { + cacheStream = null; + return path; + } + return path.projection(d3.geo.albersUsa()).context(null); + }; + function d3_geo_pathProjectStream(project) { + var resample = d3_geo_resample(function(λ, φ) { + return project([ λ * d3_degrees, φ * d3_degrees ]); + }); + return function(stream) { + stream = resample(stream); + return { + point: function(λ, φ) { + stream.point(λ * d3_radians, φ * d3_radians); + }, + sphere: function() { + stream.sphere(); + }, + lineStart: function() { + stream.lineStart(); + }, + lineEnd: function() { + stream.lineEnd(); + }, + polygonStart: function() { + stream.polygonStart(); + }, + polygonEnd: function() { + stream.polygonEnd(); + } + }; + }; + } + d3.geo.projection = d3_geo_projection; + d3.geo.projectionMutator = d3_geo_projectionMutator; + function d3_geo_projection(project) { + return d3_geo_projectionMutator(function() { + return project; + })(); + } + function d3_geo_projectionMutator(projectAt) { + var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) { + x = project(x, y); + return [ x[0] * k + δx, δy - x[1] * k ]; + }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream; + function projection(point) { + point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); + return [ point[0] * k + δx, δy - point[1] * k ]; + } + function invert(point) { + point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); + return point && [ point[0] * d3_degrees, point[1] * d3_degrees ]; + } + projection.stream = function(output) { + if (stream) stream.valid = false; + stream = d3_geo_projectionRadiansRotate(rotate, preclip(projectResample(postclip(output)))); + stream.valid = true; + return stream; + }; + projection.clipAngle = function(_) { + if (!arguments.length) return clipAngle; + preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); + return invalidate(); + }; + projection.clipExtent = function(_) { + if (!arguments.length) return clipExtent; + clipExtent = _; + postclip = _ == null ? d3_identity : d3_geo_clipView(_[0][0], _[0][1], _[1][0], _[1][1]); + return invalidate(); + }; + projection.scale = function(_) { + if (!arguments.length) return k; + k = +_; + return reset(); + }; + projection.translate = function(_) { + if (!arguments.length) return [ x, y ]; + x = +_[0]; + y = +_[1]; + return reset(); + }; + projection.center = function(_) { + if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ]; + λ = _[0] % 360 * d3_radians; + φ = _[1] % 360 * d3_radians; + return reset(); + }; + projection.rotate = function(_) { + if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ]; + δλ = _[0] % 360 * d3_radians; + δφ = _[1] % 360 * d3_radians; + δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; + return reset(); + }; + d3.rebind(projection, projectResample, "precision"); + function reset() { + projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project); + var center = project(λ, φ); + δx = x - center[0] * k; + δy = y + center[1] * k; + return invalidate(); + } + function invalidate() { + if (stream) { + stream.valid = false; + stream = null; + } + return projection; + } + return function() { + project = projectAt.apply(this, arguments); + projection.invert = project.invert && invert; + return reset(); + }; + } + function d3_geo_projectionRadiansRotate(rotate, stream) { + return { + point: function(x, y) { + y = rotate(x * d3_radians, y * d3_radians), x = y[0]; + stream.point(x > π ? x - 2 * π : x < -π ? x + 2 * π : x, y[1]); + }, + sphere: function() { + stream.sphere(); + }, + lineStart: function() { + stream.lineStart(); + }, + lineEnd: function() { + stream.lineEnd(); + }, + polygonStart: function() { + stream.polygonStart(); + }, + polygonEnd: function() { + stream.polygonEnd(); + } + }; + } + function d3_geo_equirectangular(λ, φ) { + return [ λ, φ ]; + } + (d3.geo.equirectangular = function() { + return d3_geo_projection(d3_geo_equirectangular); + }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; + d3.geo.rotation = function(rotate) { + rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); + function forward(coordinates) { + coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); + return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; + } + forward.invert = function(coordinates) { + coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); + return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; + }; + return forward; + }; + function d3_geo_rotation(δλ, δφ, δγ) { + return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_equirectangular; + } + function d3_geo_forwardRotationλ(δλ) { + return function(λ, φ) { + return λ += δλ, [ λ > π ? λ - 2 * π : λ < -π ? λ + 2 * π : λ, φ ]; + }; + } + function d3_geo_rotationλ(δλ) { + var rotation = d3_geo_forwardRotationλ(δλ); + rotation.invert = d3_geo_forwardRotationλ(-δλ); + return rotation; + } + function d3_geo_rotationφγ(δφ, δγ) { + var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ); + function rotation(λ, φ) { + var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ; + return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ]; + } + rotation.invert = function(λ, φ) { + var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ; + return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ]; + }; + return rotation; + } + d3.geo.circle = function() { + var origin = [ 0, 0 ], angle, precision = 6, interpolate; + function circle() { + var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = []; + interpolate(null, null, 1, { + point: function(x, y) { + ring.push(x = rotate(x, y)); + x[0] *= d3_degrees, x[1] *= d3_degrees; + } + }); + return { + type: "Polygon", + coordinates: [ ring ] + }; + } + circle.origin = function(x) { + if (!arguments.length) return origin; + origin = x; + return circle; + }; + circle.angle = function(x) { + if (!arguments.length) return angle; + interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); + return circle; + }; + circle.precision = function(_) { + if (!arguments.length) return precision; + interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); + return circle; + }; + return circle.angle(90); + }; + function d3_geo_circleInterpolate(radius, precision) { + var cr = Math.cos(radius), sr = Math.sin(radius); + return function(from, to, direction, listener) { + if (from != null) { + from = d3_geo_circleAngle(cr, from); + to = d3_geo_circleAngle(cr, to); + if (direction > 0 ? from < to : from > to) from += direction * 2 * π; + } else { + from = radius + direction * 2 * π; + to = radius; + } + var point; + for (var step = direction * precision, t = from; direction > 0 ? t > to : t < to; t -= step) { + listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]); + } + }; + } + function d3_geo_circleAngle(cr, point) { + var a = d3_geo_cartesian(point); + a[0] -= cr; + d3_geo_cartesianNormalize(a); + var angle = d3_acos(-a[1]); + return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); + } + d3.geo.distance = function(a, b) { + var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t; + return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ); + }; + d3.geo.graticule = function() { + var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5; + function graticule() { + return { + type: "MultiLineString", + coordinates: lines() + }; + } + function lines() { + return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { + return Math.abs(x % DX) > ε; + }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { + return Math.abs(y % DY) > ε; + }).map(y)); + } + graticule.lines = function() { + return lines().map(function(coordinates) { + return { + type: "LineString", + coordinates: coordinates + }; + }); + }; + graticule.outline = function() { + return { + type: "Polygon", + coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ] + }; + }; + graticule.extent = function(_) { + if (!arguments.length) return graticule.minorExtent(); + return graticule.majorExtent(_).minorExtent(_); + }; + graticule.majorExtent = function(_) { + if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ]; + X0 = +_[0][0], X1 = +_[1][0]; + Y0 = +_[0][1], Y1 = +_[1][1]; + if (X0 > X1) _ = X0, X0 = X1, X1 = _; + if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; + return graticule.precision(precision); + }; + graticule.minorExtent = function(_) { + if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; + x0 = +_[0][0], x1 = +_[1][0]; + y0 = +_[0][1], y1 = +_[1][1]; + if (x0 > x1) _ = x0, x0 = x1, x1 = _; + if (y0 > y1) _ = y0, y0 = y1, y1 = _; + return graticule.precision(precision); + }; + graticule.step = function(_) { + if (!arguments.length) return graticule.minorStep(); + return graticule.majorStep(_).minorStep(_); + }; + graticule.majorStep = function(_) { + if (!arguments.length) return [ DX, DY ]; + DX = +_[0], DY = +_[1]; + return graticule; + }; + graticule.minorStep = function(_) { + if (!arguments.length) return [ dx, dy ]; + dx = +_[0], dy = +_[1]; + return graticule; + }; + graticule.precision = function(_) { + if (!arguments.length) return precision; + precision = +_; + x = d3_geo_graticuleX(y0, y1, 90); + y = d3_geo_graticuleY(x0, x1, precision); + X = d3_geo_graticuleX(Y0, Y1, 90); + Y = d3_geo_graticuleY(X0, X1, precision); + return graticule; + }; + return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]); + }; + function d3_geo_graticuleX(y0, y1, dy) { + var y = d3.range(y0, y1 - ε, dy).concat(y1); + return function(x) { + return y.map(function(y) { + return [ x, y ]; + }); + }; + } + function d3_geo_graticuleY(x0, x1, dx) { + var x = d3.range(x0, x1 - ε, dx).concat(x1); + return function(y) { + return x.map(function(x) { + return [ x, y ]; + }); + }; + } + function d3_source(d) { + return d.source; + } + function d3_target(d) { + return d.target; + } + d3.geo.greatArc = function() { + var source = d3_source, source_, target = d3_target, target_; + function greatArc() { + return { + type: "LineString", + coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ] + }; + } + greatArc.distance = function() { + return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments)); + }; + greatArc.source = function(_) { + if (!arguments.length) return source; + source = _, source_ = typeof _ === "function" ? null : _; + return greatArc; + }; + greatArc.target = function(_) { + if (!arguments.length) return target; + target = _, target_ = typeof _ === "function" ? null : _; + return greatArc; + }; + greatArc.precision = function() { + return arguments.length ? greatArc : 0; + }; + return greatArc; + }; + d3.geo.interpolate = function(source, target) { + return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); + }; + function d3_geo_interpolate(x0, y0, x1, y1) { + var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d); + var interpolate = d ? function(t) { + var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; + return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; + } : function() { + return [ x0 * d3_degrees, y0 * d3_degrees ]; + }; + interpolate.distance = d; + return interpolate; + } + d3.geo.length = function(object) { + d3_geo_lengthSum = 0; + d3.geo.stream(object, d3_geo_length); + return d3_geo_lengthSum; + }; + var d3_geo_lengthSum; + var d3_geo_length = { + sphere: d3_noop, + point: d3_noop, + lineStart: d3_geo_lengthLineStart, + lineEnd: d3_noop, + polygonStart: d3_noop, + polygonEnd: d3_noop + }; + function d3_geo_lengthLineStart() { + var λ0, sinφ0, cosφ0; + d3_geo_length.point = function(λ, φ) { + λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ); + d3_geo_length.point = nextPoint; + }; + d3_geo_length.lineEnd = function() { + d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; + }; + function nextPoint(λ, φ) { + var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = Math.abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t); + d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ); + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ; + } + } + function d3_geo_azimuthal(scale, angle) { + function azimuthal(λ, φ) { + var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ); + return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ]; + } + azimuthal.invert = function(x, y) { + var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c); + return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ]; + }; + return azimuthal; + } + var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) { + return Math.sqrt(2 / (1 + cosλcosφ)); + }, function(ρ) { + return 2 * Math.asin(ρ / 2); + }); + (d3.geo.azimuthalEqualArea = function() { + return d3_geo_projection(d3_geo_azimuthalEqualArea); + }).raw = d3_geo_azimuthalEqualArea; + var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) { + var c = Math.acos(cosλcosφ); + return c && c / Math.sin(c); + }, d3_identity); + (d3.geo.azimuthalEquidistant = function() { + return d3_geo_projection(d3_geo_azimuthalEquidistant); + }).raw = d3_geo_azimuthalEquidistant; + function d3_geo_conicConformal(φ0, φ1) { + var cosφ0 = Math.cos(φ0), t = function(φ) { + return Math.tan(π / 4 + φ / 2); + }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n; + if (!n) return d3_geo_mercator; + function forward(λ, φ) { + var ρ = Math.abs(Math.abs(φ) - π / 2) < ε ? 0 : F / Math.pow(t(φ), n); + return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ]; + } + forward.invert = function(x, y) { + var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y); + return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - π / 2 ]; + }; + return forward; + } + (d3.geo.conicConformal = function() { + return d3_geo_conic(d3_geo_conicConformal); + }).raw = d3_geo_conicConformal; + function d3_geo_conicEquidistant(φ0, φ1) { + var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0; + if (Math.abs(n) < ε) return d3_geo_equirectangular; + function forward(λ, φ) { + var ρ = G - φ; + return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ]; + } + forward.invert = function(x, y) { + var ρ0_y = G - y; + return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ]; + }; + return forward; + } + (d3.geo.conicEquidistant = function() { + return d3_geo_conic(d3_geo_conicEquidistant); + }).raw = d3_geo_conicEquidistant; + var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) { + return 1 / cosλcosφ; + }, Math.atan); + (d3.geo.gnomonic = function() { + return d3_geo_projection(d3_geo_gnomonic); + }).raw = d3_geo_gnomonic; + function d3_geo_mercator(λ, φ) { + return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ]; + } + d3_geo_mercator.invert = function(x, y) { + return [ x, 2 * Math.atan(Math.exp(y)) - π / 2 ]; + }; + function d3_geo_mercatorProjection(project) { + var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto; + m.scale = function() { + var v = scale.apply(m, arguments); + return v === m ? clipAuto ? m.clipExtent(null) : m : v; + }; + m.translate = function() { + var v = translate.apply(m, arguments); + return v === m ? clipAuto ? m.clipExtent(null) : m : v; + }; + m.clipExtent = function(_) { + var v = clipExtent.apply(m, arguments); + if (v === m) { + if (clipAuto = _ == null) { + var k = π * scale(), t = translate(); + clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]); + } + } else if (clipAuto) { + v = null; + } + return v; + }; + return m.clipExtent(null); + } + (d3.geo.mercator = function() { + return d3_geo_mercatorProjection(d3_geo_mercator); + }).raw = d3_geo_mercator; + var d3_geo_orthographic = d3_geo_azimuthal(function() { + return 1; + }, Math.asin); + (d3.geo.orthographic = function() { + return d3_geo_projection(d3_geo_orthographic); + }).raw = d3_geo_orthographic; + var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) { + return 1 / (1 + cosλcosφ); + }, function(ρ) { + return 2 * Math.atan(ρ); + }); + (d3.geo.stereographic = function() { + return d3_geo_projection(d3_geo_stereographic); + }).raw = d3_geo_stereographic; + function d3_geo_transverseMercator(λ, φ) { + var B = Math.cos(φ) * Math.sin(λ); + return [ Math.log((1 + B) / (1 - B)) / 2, Math.atan2(Math.tan(φ), Math.cos(λ)) ]; + } + d3_geo_transverseMercator.invert = function(x, y) { + return [ Math.atan2(d3_sinh(x), Math.cos(y)), d3_asin(Math.sin(y) / d3_cosh(x)) ]; + }; + (d3.geo.transverseMercator = function() { + return d3_geo_mercatorProjection(d3_geo_transverseMercator); + }).raw = d3_geo_transverseMercator; + d3.geom = {}; + d3.svg = {}; + function d3_svg_line(projection) { + var x = d3_svg_lineX, y = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; + function line(data) { + var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); + function segment() { + segments.push("M", interpolate(projection(points), tension)); + } + while (++i < n) { + if (defined.call(this, d = data[i], i)) { + points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); + } else if (points.length) { + segment(); + points = []; + } + } + if (points.length) segment(); + return segments.length ? segments.join("") : null; + } + line.x = function(_) { + if (!arguments.length) return x; + x = _; + return line; + }; + line.y = function(_) { + if (!arguments.length) return y; + y = _; + return line; + }; + line.defined = function(_) { + if (!arguments.length) return defined; + defined = _; + return line; + }; + line.interpolate = function(_) { + if (!arguments.length) return interpolateKey; + if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; + return line; + }; + line.tension = function(_) { + if (!arguments.length) return tension; + tension = _; + return line; + }; + return line; + } + d3.svg.line = function() { + return d3_svg_line(d3_identity); + }; + function d3_svg_lineX(d) { + return d[0]; + } + function d3_svg_lineY(d) { + return d[1]; + } + var d3_svg_lineInterpolators = d3.map({ + linear: d3_svg_lineLinear, + "linear-closed": d3_svg_lineLinearClosed, + step: d3_svg_lineStep, + "step-before": d3_svg_lineStepBefore, + "step-after": d3_svg_lineStepAfter, + basis: d3_svg_lineBasis, + "basis-open": d3_svg_lineBasisOpen, + "basis-closed": d3_svg_lineBasisClosed, + bundle: d3_svg_lineBundle, + cardinal: d3_svg_lineCardinal, + "cardinal-open": d3_svg_lineCardinalOpen, + "cardinal-closed": d3_svg_lineCardinalClosed, + monotone: d3_svg_lineMonotone + }); + d3_svg_lineInterpolators.forEach(function(key, value) { + value.key = key; + value.closed = /-closed$/.test(key); + }); + function d3_svg_lineLinear(points) { + return points.join("L"); + } + function d3_svg_lineLinearClosed(points) { + return d3_svg_lineLinear(points) + "Z"; + } + function d3_svg_lineStep(points) { + var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; + while (++i < n) path.push("H", (p[0] + (p = points[i])[0]) / 2, "V", p[1]); + if (n > 1) path.push("H", p[0]); + return path.join(""); + } + function d3_svg_lineStepBefore(points) { + var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; + while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]); + return path.join(""); + } + function d3_svg_lineStepAfter(points) { + var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; + while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]); + return path.join(""); + } + function d3_svg_lineCardinalOpen(points, tension) { + return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension)); + } + function d3_svg_lineCardinalClosed(points, tension) { + return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), + points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); + } + function d3_svg_lineCardinal(points, tension) { + return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); + } + function d3_svg_lineHermite(points, tangents) { + if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) { + return d3_svg_lineLinear(points); + } + var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1; + if (quad) { + path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1]; + p0 = points[1]; + pi = 2; + } + if (tangents.length > 1) { + t = tangents[1]; + p = points[pi]; + pi++; + path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; + for (var i = 2; i < tangents.length; i++, pi++) { + p = points[pi]; + t = tangents[i]; + path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1]; + } + } + if (quad) { + var lp = points[pi]; + path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1]; + } + return path; + } + function d3_svg_lineCardinalTangents(points, tension) { + var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length; + while (++i < n) { + p0 = p1; + p1 = p2; + p2 = points[i]; + tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]); + } + return tangents; + } + function d3_svg_lineBasis(points) { + if (points.length < 3) return d3_svg_lineLinear(points); + var i = 1, n = points.length, pi = points[0], x0 = pi[0], y0 = pi[1], px = [ x0, x0, x0, (pi = points[1])[0] ], py = [ y0, y0, y0, pi[1] ], path = [ x0, ",", y0 ]; + d3_svg_lineBasisBezier(path, px, py); + while (++i < n) { + pi = points[i]; + px.shift(); + px.push(pi[0]); + py.shift(); + py.push(pi[1]); + d3_svg_lineBasisBezier(path, px, py); + } + i = -1; + while (++i < 2) { + px.shift(); + px.push(pi[0]); + py.shift(); + py.push(pi[1]); + d3_svg_lineBasisBezier(path, px, py); + } + return path.join(""); + } + function d3_svg_lineBasisOpen(points) { + if (points.length < 4) return d3_svg_lineLinear(points); + var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ]; + while (++i < 3) { + pi = points[i]; + px.push(pi[0]); + py.push(pi[1]); + } + path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)); + --i; + while (++i < n) { + pi = points[i]; + px.shift(); + px.push(pi[0]); + py.shift(); + py.push(pi[1]); + d3_svg_lineBasisBezier(path, px, py); + } + return path.join(""); + } + function d3_svg_lineBasisClosed(points) { + var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = []; + while (++i < 4) { + pi = points[i % n]; + px.push(pi[0]); + py.push(pi[1]); + } + path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ]; + --i; + while (++i < m) { + pi = points[i % n]; + px.shift(); + px.push(pi[0]); + py.shift(); + py.push(pi[1]); + d3_svg_lineBasisBezier(path, px, py); + } + return path.join(""); + } + function d3_svg_lineBundle(points, tension) { + var n = points.length - 1; + if (n) { + var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t; + while (++i <= n) { + p = points[i]; + t = i / n; + p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx); + p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy); + } + } + return d3_svg_lineBasis(points); + } + function d3_svg_lineDot4(a, b) { + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; + } + var d3_svg_lineBasisBezier1 = [ 0, 2 / 3, 1 / 3, 0 ], d3_svg_lineBasisBezier2 = [ 0, 1 / 3, 2 / 3, 0 ], d3_svg_lineBasisBezier3 = [ 0, 1 / 6, 2 / 3, 1 / 6 ]; + function d3_svg_lineBasisBezier(path, x, y) { + path.push("C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y)); + } + function d3_svg_lineSlope(p0, p1) { + return (p1[1] - p0[1]) / (p1[0] - p0[0]); + } + function d3_svg_lineFiniteDifferences(points) { + var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1); + while (++i < j) { + m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2; + } + m[i] = d; + return m; + } + function d3_svg_lineMonotoneTangents(points) { + var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; + while (++i < j) { + d = d3_svg_lineSlope(points[i], points[i + 1]); + if (Math.abs(d) < 1e-6) { + m[i] = m[i + 1] = 0; + } else { + a = m[i] / d; + b = m[i + 1] / d; + s = a * a + b * b; + if (s > 9) { + s = d * 3 / Math.sqrt(s); + m[i] = s * a; + m[i + 1] = s * b; + } + } + } + i = -1; + while (++i <= j) { + s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i])); + tangents.push([ s || 0, m[i] * s || 0 ]); + } + return tangents; + } + function d3_svg_lineMonotone(points) { + return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points)); + } + d3.geom.hull = function(vertices) { + var x = d3_svg_lineX, y = d3_svg_lineY; + if (arguments.length) return hull(vertices); + function hull(data) { + if (data.length < 3) return []; + var fx = d3_functor(x), fy = d3_functor(y), n = data.length, vertices, plen = n - 1, points = [], stack = [], d, i, j, h = 0, x1, y1, x2, y2, u, v, a, sp; + if (fx === d3_svg_lineX && y === d3_svg_lineY) vertices = data; else for (i = 0, + vertices = []; i < n; ++i) { + vertices.push([ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]); + } + for (i = 1; i < n; ++i) { + if (vertices[i][1] < vertices[h][1] || vertices[i][1] == vertices[h][1] && vertices[i][0] < vertices[h][0]) h = i; + } + for (i = 0; i < n; ++i) { + if (i === h) continue; + y1 = vertices[i][1] - vertices[h][1]; + x1 = vertices[i][0] - vertices[h][0]; + points.push({ + angle: Math.atan2(y1, x1), + index: i + }); + } + points.sort(function(a, b) { + return a.angle - b.angle; + }); + a = points[0].angle; + v = points[0].index; + u = 0; + for (i = 1; i < plen; ++i) { + j = points[i].index; + if (a == points[i].angle) { + x1 = vertices[v][0] - vertices[h][0]; + y1 = vertices[v][1] - vertices[h][1]; + x2 = vertices[j][0] - vertices[h][0]; + y2 = vertices[j][1] - vertices[h][1]; + if (x1 * x1 + y1 * y1 >= x2 * x2 + y2 * y2) { + points[i].index = -1; + continue; + } else { + points[u].index = -1; + } + } + a = points[i].angle; + u = i; + v = j; + } + stack.push(h); + for (i = 0, j = 0; i < 2; ++j) { + if (points[j].index > -1) { + stack.push(points[j].index); + i++; + } + } + sp = stack.length; + for (;j < plen; ++j) { + if (points[j].index < 0) continue; + while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) { + --sp; + } + stack[sp++] = points[j].index; + } + var poly = []; + for (i = sp - 1; i >= 0; --i) poly.push(data[stack[i]]); + return poly; + } + hull.x = function(_) { + return arguments.length ? (x = _, hull) : x; + }; + hull.y = function(_) { + return arguments.length ? (y = _, hull) : y; + }; + return hull; + }; + function d3_geom_hullCCW(i1, i2, i3, v) { + var t, a, b, c, d, e, f; + t = v[i1]; + a = t[0]; + b = t[1]; + t = v[i2]; + c = t[0]; + d = t[1]; + t = v[i3]; + e = t[0]; + f = t[1]; + return (f - b) * (c - a) - (d - b) * (e - a) > 0; + } + d3.geom.polygon = function(coordinates) { + coordinates.area = function() { + var i = 0, n = coordinates.length, area = coordinates[n - 1][1] * coordinates[0][0] - coordinates[n - 1][0] * coordinates[0][1]; + while (++i < n) { + area += coordinates[i - 1][1] * coordinates[i][0] - coordinates[i - 1][0] * coordinates[i][1]; + } + return area * .5; + }; + coordinates.centroid = function(k) { + var i = -1, n = coordinates.length, x = 0, y = 0, a, b = coordinates[n - 1], c; + if (!arguments.length) k = -1 / (6 * coordinates.area()); + while (++i < n) { + a = b; + b = coordinates[i]; + c = a[0] * b[1] - b[0] * a[1]; + x += (a[0] + b[0]) * c; + y += (a[1] + b[1]) * c; + } + return [ x * k, y * k ]; + }; + coordinates.clip = function(subject) { + var input, i = -1, n = coordinates.length, j, m, a = coordinates[n - 1], b, c, d; + while (++i < n) { + input = subject.slice(); + subject.length = 0; + b = coordinates[i]; + c = input[(m = input.length) - 1]; + j = -1; + while (++j < m) { + d = input[j]; + if (d3_geom_polygonInside(d, a, b)) { + if (!d3_geom_polygonInside(c, a, b)) { + subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } + subject.push(d); + } else if (d3_geom_polygonInside(c, a, b)) { + subject.push(d3_geom_polygonIntersect(c, d, a, b)); + } + c = d; + } + a = b; + } + return subject; + }; + return coordinates; + }; + function d3_geom_polygonInside(p, a, b) { + return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); + } + function d3_geom_polygonIntersect(c, d, a, b) { + var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); + return [ x1 + ua * x21, y1 + ua * y21 ]; + } + d3.geom.delaunay = function(vertices) { + var edges = vertices.map(function() { + return []; + }), triangles = []; + d3_geom_voronoiTessellate(vertices, function(e) { + edges[e.region.l.index].push(vertices[e.region.r.index]); + }); + edges.forEach(function(edge, i) { + var v = vertices[i], cx = v[0], cy = v[1]; + edge.forEach(function(v) { + v.angle = Math.atan2(v[0] - cx, v[1] - cy); + }); + edge.sort(function(a, b) { + return a.angle - b.angle; + }); + for (var j = 0, m = edge.length - 1; j < m; j++) { + triangles.push([ v, edge[j], edge[j + 1] ]); + } + }); + return triangles; + }; + d3.geom.voronoi = function(points) { + var x = d3_svg_lineX, y = d3_svg_lineY, clipPolygon = null; + if (arguments.length) return voronoi(points); + function voronoi(data) { + var points, polygons = data.map(function() { + return []; + }), fx = d3_functor(x), fy = d3_functor(y), d, i, n = data.length, Z = 1e6; + if (fx === d3_svg_lineX && fy === d3_svg_lineY) points = data; else for (points = new Array(n), + i = 0; i < n; ++i) { + points[i] = [ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]; + } + d3_geom_voronoiTessellate(points, function(e) { + var s1, s2, x1, x2, y1, y2; + if (e.a === 1 && e.b >= 0) { + s1 = e.ep.r; + s2 = e.ep.l; + } else { + s1 = e.ep.l; + s2 = e.ep.r; + } + if (e.a === 1) { + y1 = s1 ? s1.y : -Z; + x1 = e.c - e.b * y1; + y2 = s2 ? s2.y : Z; + x2 = e.c - e.b * y2; + } else { + x1 = s1 ? s1.x : -Z; + y1 = e.c - e.a * x1; + x2 = s2 ? s2.x : Z; + y2 = e.c - e.a * x2; + } + var v1 = [ x1, y1 ], v2 = [ x2, y2 ]; + polygons[e.region.l.index].push(v1, v2); + polygons[e.region.r.index].push(v1, v2); + }); + polygons = polygons.map(function(polygon, i) { + var cx = points[i][0], cy = points[i][1], angle = polygon.map(function(v) { + return Math.atan2(v[0] - cx, v[1] - cy); + }), order = d3.range(polygon.length).sort(function(a, b) { + return angle[a] - angle[b]; + }); + return order.filter(function(d, i) { + return !i || angle[d] - angle[order[i - 1]] > ε; + }).map(function(d) { + return polygon[d]; + }); + }); + polygons.forEach(function(polygon, i) { + var n = polygon.length; + if (!n) return polygon.push([ -Z, -Z ], [ -Z, Z ], [ Z, Z ], [ Z, -Z ]); + if (n > 2) return; + var p0 = points[i], p1 = polygon[0], p2 = polygon[1], x0 = p0[0], y0 = p0[1], x1 = p1[0], y1 = p1[1], x2 = p2[0], y2 = p2[1], dx = Math.abs(x2 - x1), dy = y2 - y1; + if (Math.abs(dy) < ε) { + var y = y0 < y1 ? -Z : Z; + polygon.push([ -Z, y ], [ Z, y ]); + } else if (dx < ε) { + var x = x0 < x1 ? -Z : Z; + polygon.push([ x, -Z ], [ x, Z ]); + } else { + var y = (x2 - x1) * (y1 - y0) < (x1 - x0) * (y2 - y1) ? Z : -Z, z = Math.abs(dy) - dx; + if (Math.abs(z) < ε) { + polygon.push([ dy < 0 ? y : -y, y ]); + } else { + if (z > 0) y *= -1; + polygon.push([ -Z, y ], [ Z, y ]); + } + } + }); + if (clipPolygon) for (i = 0; i < n; ++i) clipPolygon.clip(polygons[i]); + for (i = 0; i < n; ++i) polygons[i].point = data[i]; + return polygons; + } + voronoi.x = function(_) { + return arguments.length ? (x = _, voronoi) : x; + }; + voronoi.y = function(_) { + return arguments.length ? (y = _, voronoi) : y; + }; + voronoi.clipExtent = function(_) { + if (!arguments.length) return clipPolygon && [ clipPolygon[0], clipPolygon[2] ]; + if (_ == null) clipPolygon = null; else { + var x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], y2 = +_[1][1]; + clipPolygon = d3.geom.polygon([ [ x1, y1 ], [ x1, y2 ], [ x2, y2 ], [ x2, y1 ] ]); + } + return voronoi; + }; + voronoi.size = function(_) { + if (!arguments.length) return clipPolygon && clipPolygon[2]; + return voronoi.clipExtent(_ && [ [ 0, 0 ], _ ]); + }; + voronoi.links = function(data) { + var points, graph = data.map(function() { + return []; + }), links = [], fx = d3_functor(x), fy = d3_functor(y), d, i, n = data.length; + if (fx === d3_svg_lineX && fy === d3_svg_lineY) points = data; else for (points = new Array(n), + i = 0; i < n; ++i) { + points[i] = [ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]; + } + d3_geom_voronoiTessellate(points, function(e) { + var l = e.region.l.index, r = e.region.r.index; + if (graph[l][r]) return; + graph[l][r] = graph[r][l] = true; + links.push({ + source: data[l], + target: data[r] + }); + }); + return links; + }; + voronoi.triangles = function(data) { + if (x === d3_svg_lineX && y === d3_svg_lineY) return d3.geom.delaunay(data); + var points = new Array(n), fx = d3_functor(x), fy = d3_functor(y), d, i = -1, n = data.length; + while (++i < n) { + (points[i] = [ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]).data = d; + } + return d3.geom.delaunay(points).map(function(triangle) { + return triangle.map(function(point) { + return point.data; + }); + }); + }; + return voronoi; + }; + var d3_geom_voronoiOpposite = { + l: "r", + r: "l" + }; + function d3_geom_voronoiTessellate(points, callback) { + var Sites = { + list: points.map(function(v, i) { + return { + index: i, + x: v[0], + y: v[1] + }; + }).sort(function(a, b) { + return a.y < b.y ? -1 : a.y > b.y ? 1 : a.x < b.x ? -1 : a.x > b.x ? 1 : 0; + }), + bottomSite: null + }; + var EdgeList = { + list: [], + leftEnd: null, + rightEnd: null, + init: function() { + EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l"); + EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l"); + EdgeList.leftEnd.r = EdgeList.rightEnd; + EdgeList.rightEnd.l = EdgeList.leftEnd; + EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd); + }, + createHalfEdge: function(edge, side) { + return { + edge: edge, + side: side, + vertex: null, + l: null, + r: null + }; + }, + insert: function(lb, he) { + he.l = lb; + he.r = lb.r; + lb.r.l = he; + lb.r = he; + }, + leftBound: function(p) { + var he = EdgeList.leftEnd; + do { + he = he.r; + } while (he != EdgeList.rightEnd && Geom.rightOf(he, p)); + he = he.l; + return he; + }, + del: function(he) { + he.l.r = he.r; + he.r.l = he.l; + he.edge = null; + }, + right: function(he) { + return he.r; + }, + left: function(he) { + return he.l; + }, + leftRegion: function(he) { + return he.edge == null ? Sites.bottomSite : he.edge.region[he.side]; + }, + rightRegion: function(he) { + return he.edge == null ? Sites.bottomSite : he.edge.region[d3_geom_voronoiOpposite[he.side]]; + } + }; + var Geom = { + bisect: function(s1, s2) { + var newEdge = { + region: { + l: s1, + r: s2 + }, + ep: { + l: null, + r: null + } + }; + var dx = s2.x - s1.x, dy = s2.y - s1.y, adx = dx > 0 ? dx : -dx, ady = dy > 0 ? dy : -dy; + newEdge.c = s1.x * dx + s1.y * dy + (dx * dx + dy * dy) * .5; + if (adx > ady) { + newEdge.a = 1; + newEdge.b = dy / dx; + newEdge.c /= dx; + } else { + newEdge.b = 1; + newEdge.a = dx / dy; + newEdge.c /= dy; + } + return newEdge; + }, + intersect: function(el1, el2) { + var e1 = el1.edge, e2 = el2.edge; + if (!e1 || !e2 || e1.region.r == e2.region.r) { + return null; + } + var d = e1.a * e2.b - e1.b * e2.a; + if (Math.abs(d) < 1e-10) { + return null; + } + var xint = (e1.c * e2.b - e2.c * e1.b) / d, yint = (e2.c * e1.a - e1.c * e2.a) / d, e1r = e1.region.r, e2r = e2.region.r, el, e; + if (e1r.y < e2r.y || e1r.y == e2r.y && e1r.x < e2r.x) { + el = el1; + e = e1; + } else { + el = el2; + e = e2; + } + var rightOfSite = xint >= e.region.r.x; + if (rightOfSite && el.side === "l" || !rightOfSite && el.side === "r") { + return null; + } + return { + x: xint, + y: yint + }; + }, + rightOf: function(he, p) { + var e = he.edge, topsite = e.region.r, rightOfSite = p.x > topsite.x; + if (rightOfSite && he.side === "l") { + return 1; + } + if (!rightOfSite && he.side === "r") { + return 0; + } + if (e.a === 1) { + var dyp = p.y - topsite.y, dxp = p.x - topsite.x, fast = 0, above = 0; + if (!rightOfSite && e.b < 0 || rightOfSite && e.b >= 0) { + above = fast = dyp >= e.b * dxp; + } else { + above = p.x + p.y * e.b > e.c; + if (e.b < 0) { + above = !above; + } + if (!above) { + fast = 1; + } + } + if (!fast) { + var dxs = topsite.x - e.region.l.x; + above = e.b * (dxp * dxp - dyp * dyp) < dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b); + if (e.b < 0) { + above = !above; + } + } + } else { + var yl = e.c - e.a * p.x, t1 = p.y - yl, t2 = p.x - topsite.x, t3 = yl - topsite.y; + above = t1 * t1 > t2 * t2 + t3 * t3; + } + return he.side === "l" ? above : !above; + }, + endPoint: function(edge, side, site) { + edge.ep[side] = site; + if (!edge.ep[d3_geom_voronoiOpposite[side]]) return; + callback(edge); + }, + distance: function(s, t) { + var dx = s.x - t.x, dy = s.y - t.y; + return Math.sqrt(dx * dx + dy * dy); + } + }; + var EventQueue = { + list: [], + insert: function(he, site, offset) { + he.vertex = site; + he.ystar = site.y + offset; + for (var i = 0, list = EventQueue.list, l = list.length; i < l; i++) { + var next = list[i]; + if (he.ystar > next.ystar || he.ystar == next.ystar && site.x > next.vertex.x) { + continue; + } else { + break; + } + } + list.splice(i, 0, he); + }, + del: function(he) { + for (var i = 0, ls = EventQueue.list, l = ls.length; i < l && ls[i] != he; ++i) {} + ls.splice(i, 1); + }, + empty: function() { + return EventQueue.list.length === 0; + }, + nextEvent: function(he) { + for (var i = 0, ls = EventQueue.list, l = ls.length; i < l; ++i) { + if (ls[i] == he) return ls[i + 1]; + } + return null; + }, + min: function() { + var elem = EventQueue.list[0]; + return { + x: elem.vertex.x, + y: elem.ystar + }; + }, + extractMin: function() { + return EventQueue.list.shift(); + } + }; + EdgeList.init(); + Sites.bottomSite = Sites.list.shift(); + var newSite = Sites.list.shift(), newIntStar; + var lbnd, rbnd, llbnd, rrbnd, bisector; + var bot, top, temp, p, v; + var e, pm; + while (true) { + if (!EventQueue.empty()) { + newIntStar = EventQueue.min(); + } + if (newSite && (EventQueue.empty() || newSite.y < newIntStar.y || newSite.y == newIntStar.y && newSite.x < newIntStar.x)) { + lbnd = EdgeList.leftBound(newSite); + rbnd = EdgeList.right(lbnd); + bot = EdgeList.rightRegion(lbnd); + e = Geom.bisect(bot, newSite); + bisector = EdgeList.createHalfEdge(e, "l"); + EdgeList.insert(lbnd, bisector); + p = Geom.intersect(lbnd, bisector); + if (p) { + EventQueue.del(lbnd); + EventQueue.insert(lbnd, p, Geom.distance(p, newSite)); + } + lbnd = bisector; + bisector = EdgeList.createHalfEdge(e, "r"); + EdgeList.insert(lbnd, bisector); + p = Geom.intersect(bisector, rbnd); + if (p) { + EventQueue.insert(bisector, p, Geom.distance(p, newSite)); + } + newSite = Sites.list.shift(); + } else if (!EventQueue.empty()) { + lbnd = EventQueue.extractMin(); + llbnd = EdgeList.left(lbnd); + rbnd = EdgeList.right(lbnd); + rrbnd = EdgeList.right(rbnd); + bot = EdgeList.leftRegion(lbnd); + top = EdgeList.rightRegion(rbnd); + v = lbnd.vertex; + Geom.endPoint(lbnd.edge, lbnd.side, v); + Geom.endPoint(rbnd.edge, rbnd.side, v); + EdgeList.del(lbnd); + EventQueue.del(rbnd); + EdgeList.del(rbnd); + pm = "l"; + if (bot.y > top.y) { + temp = bot; + bot = top; + top = temp; + pm = "r"; + } + e = Geom.bisect(bot, top); + bisector = EdgeList.createHalfEdge(e, pm); + EdgeList.insert(llbnd, bisector); + Geom.endPoint(e, d3_geom_voronoiOpposite[pm], v); + p = Geom.intersect(llbnd, bisector); + if (p) { + EventQueue.del(llbnd); + EventQueue.insert(llbnd, p, Geom.distance(p, bot)); + } + p = Geom.intersect(bisector, rrbnd); + if (p) { + EventQueue.insert(bisector, p, Geom.distance(p, bot)); + } + } else { + break; + } + } + for (lbnd = EdgeList.right(EdgeList.leftEnd); lbnd != EdgeList.rightEnd; lbnd = EdgeList.right(lbnd)) { + callback(lbnd.edge); + } + } + d3.geom.quadtree = function(points, x1, y1, x2, y2) { + var x = d3_svg_lineX, y = d3_svg_lineY, compat; + if (compat = arguments.length) { + x = d3_geom_quadtreeCompatX; + y = d3_geom_quadtreeCompatY; + if (compat === 3) { + y2 = y1; + x2 = x1; + y1 = x1 = 0; + } + return quadtree(points); + } + function quadtree(data) { + var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_; + if (x1 != null) { + x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; + } else { + x2_ = y2_ = -(x1_ = y1_ = Infinity); + xs = [], ys = []; + n = data.length; + if (compat) for (i = 0; i < n; ++i) { + d = data[i]; + if (d.x < x1_) x1_ = d.x; + if (d.y < y1_) y1_ = d.y; + if (d.x > x2_) x2_ = d.x; + if (d.y > y2_) y2_ = d.y; + xs.push(d.x); + ys.push(d.y); + } else for (i = 0; i < n; ++i) { + var x_ = +fx(d = data[i], i), y_ = +fy(d, i); + if (x_ < x1_) x1_ = x_; + if (y_ < y1_) y1_ = y_; + if (x_ > x2_) x2_ = x_; + if (y_ > y2_) y2_ = y_; + xs.push(x_); + ys.push(y_); + } + } + var dx = x2_ - x1_, dy = y2_ - y1_; + if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy; + function insert(n, d, x, y, x1, y1, x2, y2) { + if (isNaN(x) || isNaN(y)) return; + if (n.leaf) { + var nx = n.x, ny = n.y; + if (nx != null) { + if (Math.abs(nx - x) + Math.abs(ny - y) < .01) { + insertChild(n, d, x, y, x1, y1, x2, y2); + } else { + var nPoint = n.point; + n.x = n.y = n.point = null; + insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); + insertChild(n, d, x, y, x1, y1, x2, y2); + } + } else { + n.x = x, n.y = y, n.point = d; + } + } else { + insertChild(n, d, x, y, x1, y1, x2, y2); + } + } + function insertChild(n, d, x, y, x1, y1, x2, y2) { + var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = x >= sx, bottom = y >= sy, i = (bottom << 1) + right; + n.leaf = false; + n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); + if (right) x1 = sx; else x2 = sx; + if (bottom) y1 = sy; else y2 = sy; + insert(n, d, x, y, x1, y1, x2, y2); + } + var root = d3_geom_quadtreeNode(); + root.add = function(d) { + insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); + }; + root.visit = function(f) { + d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); + }; + i = -1; + if (x1 == null) { + while (++i < n) { + insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); + } + --i; + } else data.forEach(root.add); + xs = ys = data = d = null; + return root; + } + quadtree.x = function(_) { + return arguments.length ? (x = _, quadtree) : x; + }; + quadtree.y = function(_) { + return arguments.length ? (y = _, quadtree) : y; + }; + quadtree.extent = function(_) { + if (!arguments.length) return x1 == null ? null : [ [ x1, y1 ], [ x2, y2 ] ]; + if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = +_[0][0], y1 = +_[0][1], x2 = +_[1][0], + y2 = +_[1][1]; + return quadtree; + }; + quadtree.size = function(_) { + if (!arguments.length) return x1 == null ? null : [ x2 - x1, y2 - y1 ]; + if (_ == null) x1 = y1 = x2 = y2 = null; else x1 = y1 = 0, x2 = +_[0], y2 = +_[1]; + return quadtree; + }; + return quadtree; + }; + function d3_geom_quadtreeCompatX(d) { + return d.x; + } + function d3_geom_quadtreeCompatY(d) { + return d.y; + } + function d3_geom_quadtreeNode() { + return { + leaf: true, + nodes: [], + point: null, + x: null, + y: null + }; + } + function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) { + if (!f(node, x1, y1, x2, y2)) { + var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes; + if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy); + if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy); + if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2); + if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); + } + } + d3.interpolateRgb = d3_interpolateRgb; + function d3_interpolateRgb(a, b) { + a = d3.rgb(a); + b = d3.rgb(b); + var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab; + return function(t) { + return "#" + d3_rgb_hex(Math.round(ar + br * t)) + d3_rgb_hex(Math.round(ag + bg * t)) + d3_rgb_hex(Math.round(ab + bb * t)); + }; + } + d3.transform = function(string) { + var g = d3_document.createElementNS(d3.ns.prefix.svg, "g"); + return (d3.transform = function(string) { + if (string != null) { + g.setAttribute("transform", string); + var t = g.transform.baseVal.consolidate(); + } + return new d3_transform(t ? t.matrix : d3_transformIdentity); + })(string); + }; + function d3_transform(m) { + var r0 = [ m.a, m.b ], r1 = [ m.c, m.d ], kx = d3_transformNormalize(r0), kz = d3_transformDot(r0, r1), ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0; + if (r0[0] * r1[1] < r1[0] * r0[1]) { + r0[0] *= -1; + r0[1] *= -1; + kx *= -1; + kz *= -1; + } + this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees; + this.translate = [ m.e, m.f ]; + this.scale = [ kx, ky ]; + this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0; + } + d3_transform.prototype.toString = function() { + return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; + }; + function d3_transformDot(a, b) { + return a[0] * b[0] + a[1] * b[1]; + } + function d3_transformNormalize(a) { + var k = Math.sqrt(d3_transformDot(a, a)); + if (k) { + a[0] /= k; + a[1] /= k; + } + return k; + } + function d3_transformCombine(a, b, k) { + a[0] += k * b[0]; + a[1] += k * b[1]; + return a; + } + var d3_transformIdentity = { + a: 1, + b: 0, + c: 0, + d: 1, + e: 0, + f: 0 + }; + d3.interpolateNumber = d3_interpolateNumber; + function d3_interpolateNumber(a, b) { + b -= a = +a; + return function(t) { + return a + b * t; + }; + } + d3.interpolateTransform = d3_interpolateTransform; + function d3_interpolateTransform(a, b) { + var s = [], q = [], n, A = d3.transform(a), B = d3.transform(b), ta = A.translate, tb = B.translate, ra = A.rotate, rb = B.rotate, wa = A.skew, wb = B.skew, ka = A.scale, kb = B.scale; + if (ta[0] != tb[0] || ta[1] != tb[1]) { + s.push("translate(", null, ",", null, ")"); + q.push({ + i: 1, + x: d3_interpolateNumber(ta[0], tb[0]) + }, { + i: 3, + x: d3_interpolateNumber(ta[1], tb[1]) + }); + } else if (tb[0] || tb[1]) { + s.push("translate(" + tb + ")"); + } else { + s.push(""); + } + if (ra != rb) { + if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; + q.push({ + i: s.push(s.pop() + "rotate(", null, ")") - 2, + x: d3_interpolateNumber(ra, rb) + }); + } else if (rb) { + s.push(s.pop() + "rotate(" + rb + ")"); + } + if (wa != wb) { + q.push({ + i: s.push(s.pop() + "skewX(", null, ")") - 2, + x: d3_interpolateNumber(wa, wb) + }); + } else if (wb) { + s.push(s.pop() + "skewX(" + wb + ")"); + } + if (ka[0] != kb[0] || ka[1] != kb[1]) { + n = s.push(s.pop() + "scale(", null, ",", null, ")"); + q.push({ + i: n - 4, + x: d3_interpolateNumber(ka[0], kb[0]) + }, { + i: n - 2, + x: d3_interpolateNumber(ka[1], kb[1]) + }); + } else if (kb[0] != 1 || kb[1] != 1) { + s.push(s.pop() + "scale(" + kb + ")"); + } + n = q.length; + return function(t) { + var i = -1, o; + while (++i < n) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + } + d3.interpolateObject = d3_interpolateObject; + function d3_interpolateObject(a, b) { + var i = {}, c = {}, k; + for (k in a) { + if (k in b) { + i[k] = d3_interpolateByName(k)(a[k], b[k]); + } else { + c[k] = a[k]; + } + } + for (k in b) { + if (!(k in a)) { + c[k] = b[k]; + } + } + return function(t) { + for (k in i) c[k] = i[k](t); + return c; + }; + } + d3.interpolateString = d3_interpolateString; + function d3_interpolateString(a, b) { + var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o; + a = a + "", b = b + ""; + d3_interpolate_number.lastIndex = 0; + for (i = 0; m = d3_interpolate_number.exec(b); ++i) { + if (m.index) s.push(b.substring(s0, s1 = m.index)); + q.push({ + i: s.length, + x: m[0] + }); + s.push(null); + s0 = d3_interpolate_number.lastIndex; + } + if (s0 < b.length) s.push(b.substring(s0)); + for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { + o = q[i]; + if (o.x == m[0]) { + if (o.i) { + if (s[o.i + 1] == null) { + s[o.i - 1] += o.x; + s.splice(o.i, 1); + for (j = i + 1; j < n; ++j) q[j].i--; + } else { + s[o.i - 1] += o.x + s[o.i + 1]; + s.splice(o.i, 2); + for (j = i + 1; j < n; ++j) q[j].i -= 2; + } + } else { + if (s[o.i + 1] == null) { + s[o.i] = o.x; + } else { + s[o.i] = o.x + s[o.i + 1]; + s.splice(o.i + 1, 1); + for (j = i + 1; j < n; ++j) q[j].i--; + } + } + q.splice(i, 1); + n--; + i--; + } else { + o.x = d3_interpolateNumber(parseFloat(m[0]), parseFloat(o.x)); + } + } + while (i < n) { + o = q.pop(); + if (s[o.i + 1] == null) { + s[o.i] = o.x; + } else { + s[o.i] = o.x + s[o.i + 1]; + s.splice(o.i + 1, 1); + } + n--; + } + if (s.length === 1) { + return s[0] == null ? (o = q[0].x, function(t) { + return o(t) + ""; + }) : function() { + return b; + }; + } + return function(t) { + for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t); + return s.join(""); + }; + } + var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; + d3.interpolate = d3_interpolate; + function d3_interpolate(a, b) { + var i = d3.interpolators.length, f; + while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; + return f; + } + function d3_interpolateByName(name) { + return name == "transform" ? d3_interpolateTransform : d3_interpolate; + } + d3.interpolators = [ function(a, b) { + var t = typeof b; + return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_Color ? d3_interpolateRgb : t === "object" ? Array.isArray(b) ? d3_interpolateArray : d3_interpolateObject : d3_interpolateNumber)(a, b); + } ]; + d3.interpolateArray = d3_interpolateArray; + function d3_interpolateArray(a, b) { + var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i; + for (i = 0; i < n0; ++i) x.push(d3_interpolate(a[i], b[i])); + for (;i < na; ++i) c[i] = a[i]; + for (;i < nb; ++i) c[i] = b[i]; + return function(t) { + for (i = 0; i < n0; ++i) c[i] = x[i](t); + return c; + }; + } + var d3_ease_default = function() { + return d3_identity; + }; + var d3_ease = d3.map({ + linear: d3_ease_default, + poly: d3_ease_poly, + quad: function() { + return d3_ease_quad; + }, + cubic: function() { + return d3_ease_cubic; + }, + sin: function() { + return d3_ease_sin; + }, + exp: function() { + return d3_ease_exp; + }, + circle: function() { + return d3_ease_circle; + }, + elastic: d3_ease_elastic, + back: d3_ease_back, + bounce: function() { + return d3_ease_bounce; + } + }); + var d3_ease_mode = d3.map({ + "in": d3_identity, + out: d3_ease_reverse, + "in-out": d3_ease_reflect, + "out-in": function(f) { + return d3_ease_reflect(d3_ease_reverse(f)); + } + }); + d3.ease = function(name) { + var i = name.indexOf("-"), t = i >= 0 ? name.substring(0, i) : name, m = i >= 0 ? name.substring(i + 1) : "in"; + t = d3_ease.get(t) || d3_ease_default; + m = d3_ease_mode.get(m) || d3_identity; + return d3_ease_clamp(m(t.apply(null, Array.prototype.slice.call(arguments, 1)))); + }; + function d3_ease_clamp(f) { + return function(t) { + return t <= 0 ? 0 : t >= 1 ? 1 : f(t); + }; + } + function d3_ease_reverse(f) { + return function(t) { + return 1 - f(1 - t); + }; + } + function d3_ease_reflect(f) { + return function(t) { + return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t)); + }; + } + function d3_ease_quad(t) { + return t * t; + } + function d3_ease_cubic(t) { + return t * t * t; + } + function d3_ease_cubicInOut(t) { + if (t <= 0) return 0; + if (t >= 1) return 1; + var t2 = t * t, t3 = t2 * t; + return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75); + } + function d3_ease_poly(e) { + return function(t) { + return Math.pow(t, e); + }; + } + function d3_ease_sin(t) { + return 1 - Math.cos(t * π / 2); + } + function d3_ease_exp(t) { + return Math.pow(2, 10 * (t - 1)); + } + function d3_ease_circle(t) { + return 1 - Math.sqrt(1 - t * t); + } + function d3_ease_elastic(a, p) { + var s; + if (arguments.length < 2) p = .45; + if (arguments.length) s = p / (2 * π) * Math.asin(1 / a); else a = 1, s = p / 4; + return function(t) { + return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * π / p); + }; + } + function d3_ease_back(s) { + if (!s) s = 1.70158; + return function(t) { + return t * t * ((s + 1) * t - s); + }; + } + function d3_ease_bounce(t) { + return t < 1 / 2.75 ? 7.5625 * t * t : t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75 : t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375 : 7.5625 * (t -= 2.625 / 2.75) * t + .984375; + } + d3.interpolateHcl = d3_interpolateHcl; + function d3_interpolateHcl(a, b) { + a = d3.hcl(a); + b = d3.hcl(b); + var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; + if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac; + if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; + return function(t) { + return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; + }; + } + d3.interpolateHsl = d3_interpolateHsl; + function d3_interpolateHsl(a, b) { + a = d3.hsl(a); + b = d3.hsl(b); + var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al; + if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as; + if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; + return function(t) { + return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + ""; + }; + } + d3.interpolateLab = d3_interpolateLab; + function d3_interpolateLab(a, b) { + a = d3.lab(a); + b = d3.lab(b); + var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; + return function(t) { + return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; + }; + } + d3.interpolateRound = d3_interpolateRound; + function d3_interpolateRound(a, b) { + b -= a; + return function(t) { + return Math.round(a + b * t); + }; + } + function d3_uninterpolateNumber(a, b) { + b = b - (a = +a) ? 1 / (b - a) : 0; + return function(x) { + return (x - a) * b; + }; + } + function d3_uninterpolateClamp(a, b) { + b = b - (a = +a) ? 1 / (b - a) : 0; + return function(x) { + return Math.max(0, Math.min(1, (x - a) * b)); + }; + } + d3.layout = {}; + d3.layout.bundle = function() { + return function(links) { + var paths = [], i = -1, n = links.length; + while (++i < n) paths.push(d3_layout_bundlePath(links[i])); + return paths; + }; + }; + function d3_layout_bundlePath(link) { + var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ]; + while (start !== lca) { + start = start.parent; + points.push(start); + } + var k = points.length; + while (end !== lca) { + points.splice(k, 0, end); + end = end.parent; + } + return points; + } + function d3_layout_bundleAncestors(node) { + var ancestors = [], parent = node.parent; + while (parent != null) { + ancestors.push(node); + node = parent; + parent = parent.parent; + } + ancestors.push(node); + return ancestors; + } + function d3_layout_bundleLeastCommonAncestor(a, b) { + if (a === b) return a; + var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null; + while (aNode === bNode) { + sharedNode = aNode; + aNode = aNodes.pop(); + bNode = bNodes.pop(); + } + return sharedNode; + } + d3.layout.chord = function() { + var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; + function relayout() { + var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; + chords = []; + groups = []; + k = 0, i = -1; + while (++i < n) { + x = 0, j = -1; + while (++j < n) { + x += matrix[i][j]; + } + groupSums.push(x); + subgroupIndex.push(d3.range(n)); + k += x; + } + if (sortGroups) { + groupIndex.sort(function(a, b) { + return sortGroups(groupSums[a], groupSums[b]); + }); + } + if (sortSubgroups) { + subgroupIndex.forEach(function(d, i) { + d.sort(function(a, b) { + return sortSubgroups(matrix[i][a], matrix[i][b]); + }); + }); + } + k = (2 * π - padding * n) / k; + x = 0, i = -1; + while (++i < n) { + x0 = x, j = -1; + while (++j < n) { + var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k; + subgroups[di + "-" + dj] = { + index: di, + subindex: dj, + startAngle: a0, + endAngle: a1, + value: v + }; + } + groups[di] = { + index: di, + startAngle: x0, + endAngle: x, + value: (x - x0) / k + }; + x += padding; + } + i = -1; + while (++i < n) { + j = i - 1; + while (++j < n) { + var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i]; + if (source.value || target.value) { + chords.push(source.value < target.value ? { + source: target, + target: source + } : { + source: source, + target: target + }); + } + } + } + if (sortChords) resort(); + } + function resort() { + chords.sort(function(a, b) { + return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2); + }); + } + chord.matrix = function(x) { + if (!arguments.length) return matrix; + n = (matrix = x) && matrix.length; + chords = groups = null; + return chord; + }; + chord.padding = function(x) { + if (!arguments.length) return padding; + padding = x; + chords = groups = null; + return chord; + }; + chord.sortGroups = function(x) { + if (!arguments.length) return sortGroups; + sortGroups = x; + chords = groups = null; + return chord; + }; + chord.sortSubgroups = function(x) { + if (!arguments.length) return sortSubgroups; + sortSubgroups = x; + chords = null; + return chord; + }; + chord.sortChords = function(x) { + if (!arguments.length) return sortChords; + sortChords = x; + if (chords) resort(); + return chord; + }; + chord.chords = function() { + if (!chords) relayout(); + return chords; + }; + chord.groups = function() { + if (!groups) relayout(); + return groups; + }; + return chord; + }; + d3.layout.force = function() { + var force = {}, event = d3.dispatch("start", "tick", "end"), size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, gravity = .1, theta = .8, nodes = [], links = [], distances, strengths, charges; + function repulse(node) { + return function(quad, x1, _, x2) { + if (quad.point !== node) { + var dx = quad.cx - node.x, dy = quad.cy - node.y, dn = 1 / Math.sqrt(dx * dx + dy * dy); + if ((x2 - x1) * dn < theta) { + var k = quad.charge * dn * dn; + node.px -= dx * k; + node.py -= dy * k; + return true; + } + if (quad.point && isFinite(dn)) { + var k = quad.pointCharge * dn * dn; + node.px -= dx * k; + node.py -= dy * k; + } + } + return !quad.charge; + }; + } + force.tick = function() { + if ((alpha *= .99) < .005) { + event.end({ + type: "end", + alpha: alpha = 0 + }); + return true; + } + var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; + for (i = 0; i < m; ++i) { + o = links[i]; + s = o.source; + t = o.target; + x = t.x - s.x; + y = t.y - s.y; + if (l = x * x + y * y) { + l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; + x *= l; + y *= l; + t.x -= x * (k = s.weight / (t.weight + s.weight)); + t.y -= y * k; + s.x += x * (k = 1 - k); + s.y += y * k; + } + } + if (k = alpha * gravity) { + x = size[0] / 2; + y = size[1] / 2; + i = -1; + if (k) while (++i < n) { + o = nodes[i]; + o.x += (x - o.x) * k; + o.y += (y - o.y) * k; + } + } + if (charge) { + d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges); + i = -1; + while (++i < n) { + if (!(o = nodes[i]).fixed) { + q.visit(repulse(o)); + } + } + } + i = -1; + while (++i < n) { + o = nodes[i]; + if (o.fixed) { + o.x = o.px; + o.y = o.py; + } else { + o.x -= (o.px - (o.px = o.x)) * friction; + o.y -= (o.py - (o.py = o.y)) * friction; + } + } + event.tick({ + type: "tick", + alpha: alpha + }); + }; + force.nodes = function(x) { + if (!arguments.length) return nodes; + nodes = x; + return force; + }; + force.links = function(x) { + if (!arguments.length) return links; + links = x; + return force; + }; + force.size = function(x) { + if (!arguments.length) return size; + size = x; + return force; + }; + force.linkDistance = function(x) { + if (!arguments.length) return linkDistance; + linkDistance = typeof x === "function" ? x : +x; + return force; + }; + force.distance = force.linkDistance; + force.linkStrength = function(x) { + if (!arguments.length) return linkStrength; + linkStrength = typeof x === "function" ? x : +x; + return force; + }; + force.friction = function(x) { + if (!arguments.length) return friction; + friction = +x; + return force; + }; + force.charge = function(x) { + if (!arguments.length) return charge; + charge = typeof x === "function" ? x : +x; + return force; + }; + force.gravity = function(x) { + if (!arguments.length) return gravity; + gravity = +x; + return force; + }; + force.theta = function(x) { + if (!arguments.length) return theta; + theta = +x; + return force; + }; + force.alpha = function(x) { + if (!arguments.length) return alpha; + x = +x; + if (alpha) { + if (x > 0) alpha = x; else alpha = 0; + } else if (x > 0) { + event.start({ + type: "start", + alpha: alpha = x + }); + d3.timer(force.tick); + } + return force; + }; + force.start = function() { + var i, j, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o; + for (i = 0; i < n; ++i) { + (o = nodes[i]).index = i; + o.weight = 0; + } + for (i = 0; i < m; ++i) { + o = links[i]; + if (typeof o.source == "number") o.source = nodes[o.source]; + if (typeof o.target == "number") o.target = nodes[o.target]; + ++o.source.weight; + ++o.target.weight; + } + for (i = 0; i < n; ++i) { + o = nodes[i]; + if (isNaN(o.x)) o.x = position("x", w); + if (isNaN(o.y)) o.y = position("y", h); + if (isNaN(o.px)) o.px = o.x; + if (isNaN(o.py)) o.py = o.y; + } + distances = []; + if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance; + strengths = []; + if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength; + charges = []; + if (typeof charge === "function") for (i = 0; i < n; ++i) charges[i] = +charge.call(this, nodes[i], i); else for (i = 0; i < n; ++i) charges[i] = charge; + function position(dimension, size) { + var neighbors = neighbor(i), j = -1, m = neighbors.length, x; + while (++j < m) if (!isNaN(x = neighbors[j][dimension])) return x; + return Math.random() * size; + } + function neighbor() { + if (!neighbors) { + neighbors = []; + for (j = 0; j < n; ++j) { + neighbors[j] = []; + } + for (j = 0; j < m; ++j) { + var o = links[j]; + neighbors[o.source.index].push(o.target); + neighbors[o.target.index].push(o.source); + } + } + return neighbors[i]; + } + return force.resume(); + }; + force.resume = function() { + return force.alpha(.1); + }; + force.stop = function() { + return force.alpha(0); + }; + force.drag = function() { + if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend); + if (!arguments.length) return drag; + this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); + }; + function dragmove(d) { + d.px = d3.event.x, d.py = d3.event.y; + force.resume(); + } + return d3.rebind(force, event, "on"); + }; + function d3_layout_forceDragstart(d) { + d.fixed |= 2; + } + function d3_layout_forceDragend(d) { + d.fixed &= ~6; + } + function d3_layout_forceMouseover(d) { + d.fixed |= 4; + d.px = d.x, d.py = d.y; + } + function d3_layout_forceMouseout(d) { + d.fixed &= ~4; + } + function d3_layout_forceAccumulate(quad, alpha, charges) { + var cx = 0, cy = 0; + quad.charge = 0; + if (!quad.leaf) { + var nodes = quad.nodes, n = nodes.length, i = -1, c; + while (++i < n) { + c = nodes[i]; + if (c == null) continue; + d3_layout_forceAccumulate(c, alpha, charges); + quad.charge += c.charge; + cx += c.charge * c.cx; + cy += c.charge * c.cy; + } + } + if (quad.point) { + if (!quad.leaf) { + quad.point.x += Math.random() - .5; + quad.point.y += Math.random() - .5; + } + var k = alpha * charges[quad.point.index]; + quad.charge += quad.pointCharge = k; + cx += k * quad.point.x; + cy += k * quad.point.y; + } + quad.cx = cx / quad.charge; + quad.cy = cy / quad.charge; + } + var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1; + d3.layout.hierarchy = function() { + var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; + function recurse(node, depth, nodes) { + var childs = children.call(hierarchy, node, depth); + node.depth = depth; + nodes.push(node); + if (childs && (n = childs.length)) { + var i = -1, n, c = node.children = [], v = 0, j = depth + 1, d; + while (++i < n) { + d = recurse(childs[i], j, nodes); + d.parent = node; + c.push(d); + v += d.value; + } + if (sort) c.sort(sort); + if (value) node.value = v; + } else if (value) { + node.value = +value.call(hierarchy, node, depth) || 0; + } + return node; + } + function revalue(node, depth) { + var children = node.children, v = 0; + if (children && (n = children.length)) { + var i = -1, n, j = depth + 1; + while (++i < n) v += revalue(children[i], j); + } else if (value) { + v = +value.call(hierarchy, node, depth) || 0; + } + if (value) node.value = v; + return v; + } + function hierarchy(d) { + var nodes = []; + recurse(d, 0, nodes); + return nodes; + } + hierarchy.sort = function(x) { + if (!arguments.length) return sort; + sort = x; + return hierarchy; + }; + hierarchy.children = function(x) { + if (!arguments.length) return children; + children = x; + return hierarchy; + }; + hierarchy.value = function(x) { + if (!arguments.length) return value; + value = x; + return hierarchy; + }; + hierarchy.revalue = function(root) { + revalue(root, 0); + return root; + }; + return hierarchy; + }; + function d3_layout_hierarchyRebind(object, hierarchy) { + d3.rebind(object, hierarchy, "sort", "children", "value"); + object.nodes = object; + object.links = d3_layout_hierarchyLinks; + return object; + } + function d3_layout_hierarchyChildren(d) { + return d.children; + } + function d3_layout_hierarchyValue(d) { + return d.value; + } + function d3_layout_hierarchySort(a, b) { + return b.value - a.value; + } + function d3_layout_hierarchyLinks(nodes) { + return d3.merge(nodes.map(function(parent) { + return (parent.children || []).map(function(child) { + return { + source: parent, + target: child + }; + }); + })); + } + d3.layout.partition = function() { + var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; + function position(node, x, dx, dy) { + var children = node.children; + node.x = x; + node.y = node.depth * dy; + node.dx = dx; + node.dy = dy; + if (children && (n = children.length)) { + var i = -1, n, c, d; + dx = node.value ? dx / node.value : 0; + while (++i < n) { + position(c = children[i], x, d = c.value * dx, dy); + x += d; + } + } + } + function depth(node) { + var children = node.children, d = 0; + if (children && (n = children.length)) { + var i = -1, n; + while (++i < n) d = Math.max(d, depth(children[i])); + } + return 1 + d; + } + function partition(d, i) { + var nodes = hierarchy.call(this, d, i); + position(nodes[0], 0, size[0], size[1] / depth(nodes[0])); + return nodes; + } + partition.size = function(x) { + if (!arguments.length) return size; + size = x; + return partition; + }; + return d3_layout_hierarchyRebind(partition, hierarchy); + }; + d3.layout.pie = function() { + var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = 2 * π; + function pie(data) { + var values = data.map(function(d, i) { + return +value.call(pie, d, i); + }); + var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle); + var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values); + var index = d3.range(data.length); + if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { + return values[j] - values[i]; + } : function(i, j) { + return sort(data[i], data[j]); + }); + var arcs = []; + index.forEach(function(i) { + var d; + arcs[i] = { + data: data[i], + value: d = values[i], + startAngle: a, + endAngle: a += d * k + }; + }); + return arcs; + } + pie.value = function(x) { + if (!arguments.length) return value; + value = x; + return pie; + }; + pie.sort = function(x) { + if (!arguments.length) return sort; + sort = x; + return pie; + }; + pie.startAngle = function(x) { + if (!arguments.length) return startAngle; + startAngle = x; + return pie; + }; + pie.endAngle = function(x) { + if (!arguments.length) return endAngle; + endAngle = x; + return pie; + }; + return pie; + }; + var d3_layout_pieSortByValue = {}; + d3.layout.stack = function() { + var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; + function stack(data, index) { + var series = data.map(function(d, i) { + return values.call(stack, d, i); + }); + var points = series.map(function(d) { + return d.map(function(v, i) { + return [ x.call(stack, v, i), y.call(stack, v, i) ]; + }); + }); + var orders = order.call(stack, points, index); + series = d3.permute(series, orders); + points = d3.permute(points, orders); + var offsets = offset.call(stack, points, index); + var n = series.length, m = series[0].length, i, j, o; + for (j = 0; j < m; ++j) { + out.call(stack, series[0][j], o = offsets[j], points[0][j][1]); + for (i = 1; i < n; ++i) { + out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]); + } + } + return data; + } + stack.values = function(x) { + if (!arguments.length) return values; + values = x; + return stack; + }; + stack.order = function(x) { + if (!arguments.length) return order; + order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault; + return stack; + }; + stack.offset = function(x) { + if (!arguments.length) return offset; + offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero; + return stack; + }; + stack.x = function(z) { + if (!arguments.length) return x; + x = z; + return stack; + }; + stack.y = function(z) { + if (!arguments.length) return y; + y = z; + return stack; + }; + stack.out = function(z) { + if (!arguments.length) return out; + out = z; + return stack; + }; + return stack; + }; + function d3_layout_stackX(d) { + return d.x; + } + function d3_layout_stackY(d) { + return d.y; + } + function d3_layout_stackOut(d, y0, y) { + d.y0 = y0; + d.y = y; + } + var d3_layout_stackOrders = d3.map({ + "inside-out": function(data) { + var n = data.length, i, j, max = data.map(d3_layout_stackMaxIndex), sums = data.map(d3_layout_stackReduceSum), index = d3.range(n).sort(function(a, b) { + return max[a] - max[b]; + }), top = 0, bottom = 0, tops = [], bottoms = []; + for (i = 0; i < n; ++i) { + j = index[i]; + if (top < bottom) { + top += sums[j]; + tops.push(j); + } else { + bottom += sums[j]; + bottoms.push(j); + } + } + return bottoms.reverse().concat(tops); + }, + reverse: function(data) { + return d3.range(data.length).reverse(); + }, + "default": d3_layout_stackOrderDefault + }); + var d3_layout_stackOffsets = d3.map({ + silhouette: function(data) { + var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = []; + for (j = 0; j < m; ++j) { + for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; + if (o > max) max = o; + sums.push(o); + } + for (j = 0; j < m; ++j) { + y0[j] = (max - sums[j]) / 2; + } + return y0; + }, + wiggle: function(data) { + var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = []; + y0[0] = o = o0 = 0; + for (j = 1; j < m; ++j) { + for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1]; + for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) { + for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) { + s3 += (data[k][j][1] - data[k][j - 1][1]) / dx; + } + s2 += s3 * data[i][j][1]; + } + y0[j] = o -= s1 ? s2 / s1 * dx : 0; + if (o < o0) o0 = o; + } + for (j = 0; j < m; ++j) y0[j] -= o0; + return y0; + }, + expand: function(data) { + var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = []; + for (j = 0; j < m; ++j) { + for (i = 0, o = 0; i < n; i++) o += data[i][j][1]; + if (o) for (i = 0; i < n; i++) data[i][j][1] /= o; else for (i = 0; i < n; i++) data[i][j][1] = k; + } + for (j = 0; j < m; ++j) y0[j] = 0; + return y0; + }, + zero: d3_layout_stackOffsetZero + }); + function d3_layout_stackOrderDefault(data) { + return d3.range(data.length); + } + function d3_layout_stackOffsetZero(data) { + var j = -1, m = data[0].length, y0 = []; + while (++j < m) y0[j] = 0; + return y0; + } + function d3_layout_stackMaxIndex(array) { + var i = 1, j = 0, v = array[0][1], k, n = array.length; + for (;i < n; ++i) { + if ((k = array[i][1]) > v) { + j = i; + v = k; + } + } + return j; + } + function d3_layout_stackReduceSum(d) { + return d.reduce(d3_layout_stackSum, 0); + } + function d3_layout_stackSum(p, d) { + return p + d[1]; + } + d3.layout.histogram = function() { + var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; + function histogram(data, i) { + var bins = [], values = data.map(valuer, this), range = ranger.call(this, values, i), thresholds = binner.call(this, range, values, i), bin, i = -1, n = values.length, m = thresholds.length - 1, k = frequency ? 1 : 1 / n, x; + while (++i < m) { + bin = bins[i] = []; + bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); + bin.y = 0; + } + if (m > 0) { + i = -1; + while (++i < n) { + x = values[i]; + if (x >= range[0] && x <= range[1]) { + bin = bins[d3.bisect(thresholds, x, 1, m) - 1]; + bin.y += k; + bin.push(data[i]); + } + } + } + return bins; + } + histogram.value = function(x) { + if (!arguments.length) return valuer; + valuer = x; + return histogram; + }; + histogram.range = function(x) { + if (!arguments.length) return ranger; + ranger = d3_functor(x); + return histogram; + }; + histogram.bins = function(x) { + if (!arguments.length) return binner; + binner = typeof x === "number" ? function(range) { + return d3_layout_histogramBinFixed(range, x); + } : d3_functor(x); + return histogram; + }; + histogram.frequency = function(x) { + if (!arguments.length) return frequency; + frequency = !!x; + return histogram; + }; + return histogram; + }; + function d3_layout_histogramBinSturges(range, values) { + return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1)); + } + function d3_layout_histogramBinFixed(range, n) { + var x = -1, b = +range[0], m = (range[1] - b) / n, f = []; + while (++x <= n) f[x] = m * x + b; + return f; + } + function d3_layout_histogramRange(values) { + return [ d3.min(values), d3.max(values) ]; + } + d3.layout.tree = function() { + var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; + function tree(d, i) { + var nodes = hierarchy.call(this, d, i), root = nodes[0]; + function firstWalk(node, previousSibling) { + var children = node.children, layout = node._tree; + if (children && (n = children.length)) { + var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1; + while (++i < n) { + child = children[i]; + firstWalk(child, previousChild); + ancestor = apportion(child, previousChild, ancestor); + previousChild = child; + } + d3_layout_treeShift(node); + var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim); + if (previousSibling) { + layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); + layout.mod = layout.prelim - midpoint; + } else { + layout.prelim = midpoint; + } + } else { + if (previousSibling) { + layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling); + } + } + } + function secondWalk(node, x) { + node.x = node._tree.prelim + x; + var children = node.children; + if (children && (n = children.length)) { + var i = -1, n; + x += node._tree.mod; + while (++i < n) { + secondWalk(children[i], x); + } + } + } + function apportion(node, previousSibling, ancestor) { + if (previousSibling) { + var vip = node, vop = node, vim = previousSibling, vom = node.parent.children[0], sip = vip._tree.mod, sop = vop._tree.mod, sim = vim._tree.mod, som = vom._tree.mod, shift; + while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) { + vom = d3_layout_treeLeft(vom); + vop = d3_layout_treeRight(vop); + vop._tree.ancestor = node; + shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip); + if (shift > 0) { + d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift); + sip += shift; + sop += shift; + } + sim += vim._tree.mod; + sip += vip._tree.mod; + som += vom._tree.mod; + sop += vop._tree.mod; + } + if (vim && !d3_layout_treeRight(vop)) { + vop._tree.thread = vim; + vop._tree.mod += sim - sop; + } + if (vip && !d3_layout_treeLeft(vom)) { + vom._tree.thread = vip; + vom._tree.mod += sip - som; + ancestor = node; + } + } + return ancestor; + } + d3_layout_treeVisitAfter(root, function(node, previousSibling) { + node._tree = { + ancestor: node, + prelim: 0, + mod: 0, + change: 0, + shift: 0, + number: previousSibling ? previousSibling._tree.number + 1 : 0 + }; + }); + firstWalk(root); + secondWalk(root, -root._tree.prelim); + var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost), right = d3_layout_treeSearch(root, d3_layout_treeRightmost), deep = d3_layout_treeSearch(root, d3_layout_treeDeepest), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2, y1 = deep.depth || 1; + d3_layout_treeVisitAfter(root, nodeSize ? function(node) { + node.x *= size[0]; + node.y = node.depth * size[1]; + delete node._tree; + } : function(node) { + node.x = (node.x - x0) / (x1 - x0) * size[0]; + node.y = node.depth / y1 * size[1]; + delete node._tree; + }); + return nodes; + } + tree.separation = function(x) { + if (!arguments.length) return separation; + separation = x; + return tree; + }; + tree.size = function(x) { + if (!arguments.length) return nodeSize ? null : size; + nodeSize = (size = x) == null; + return tree; + }; + tree.nodeSize = function(x) { + if (!arguments.length) return nodeSize ? size : null; + nodeSize = (size = x) != null; + return tree; + }; + return d3_layout_hierarchyRebind(tree, hierarchy); + }; + function d3_layout_treeSeparation(a, b) { + return a.parent == b.parent ? 1 : 2; + } + function d3_layout_treeLeft(node) { + var children = node.children; + return children && children.length ? children[0] : node._tree.thread; + } + function d3_layout_treeRight(node) { + var children = node.children, n; + return children && (n = children.length) ? children[n - 1] : node._tree.thread; + } + function d3_layout_treeSearch(node, compare) { + var children = node.children; + if (children && (n = children.length)) { + var child, n, i = -1; + while (++i < n) { + if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) { + node = child; + } + } + } + return node; + } + function d3_layout_treeRightmost(a, b) { + return a.x - b.x; + } + function d3_layout_treeLeftmost(a, b) { + return b.x - a.x; + } + function d3_layout_treeDeepest(a, b) { + return a.depth - b.depth; + } + function d3_layout_treeVisitAfter(node, callback) { + function visit(node, previousSibling) { + var children = node.children; + if (children && (n = children.length)) { + var child, previousChild = null, i = -1, n; + while (++i < n) { + child = children[i]; + visit(child, previousChild); + previousChild = child; + } + } + callback(node, previousSibling); + } + visit(node, null); + } + function d3_layout_treeShift(node) { + var shift = 0, change = 0, children = node.children, i = children.length, child; + while (--i >= 0) { + child = children[i]._tree; + child.prelim += shift; + child.mod += shift; + shift += child.shift + (change += child.change); + } + } + function d3_layout_treeMove(ancestor, node, shift) { + ancestor = ancestor._tree; + node = node._tree; + var change = shift / (node.number - ancestor.number); + ancestor.change += change; + node.change -= change; + node.shift += shift; + node.prelim += shift; + node.mod += shift; + } + function d3_layout_treeAncestor(vim, node, ancestor) { + return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor; + } + d3.layout.pack = function() { + var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; + function pack(d, i) { + var nodes = hierarchy.call(this, d, i), root = nodes[0], w = size[0], h = size[1], r = radius || Math.sqrt; + root.x = root.y = 0; + d3_layout_treeVisitAfter(root, function(d) { + d.r = r(d.value); + }); + d3_layout_treeVisitAfter(root, d3_layout_packSiblings); + if (padding) { + var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; + d3_layout_treeVisitAfter(root, function(d) { + d.r += dr; + }); + d3_layout_treeVisitAfter(root, d3_layout_packSiblings); + d3_layout_treeVisitAfter(root, function(d) { + d.r -= dr; + }); + } + d3_layout_packTransform(root, w / 2, h / 2, radius ? 1 : 1 / Math.max(2 * root.r / w, 2 * root.r / h)); + return nodes; + } + pack.size = function(_) { + if (!arguments.length) return size; + size = _; + return pack; + }; + pack.radius = function(_) { + if (!arguments.length) return radius; + radius = _; + return pack; + }; + pack.padding = function(_) { + if (!arguments.length) return padding; + padding = +_; + return pack; + }; + return d3_layout_hierarchyRebind(pack, hierarchy); + }; + function d3_layout_packSort(a, b) { + return a.value - b.value; + } + function d3_layout_packInsert(a, b) { + var c = a._pack_next; + a._pack_next = b; + b._pack_prev = a; + b._pack_next = c; + c._pack_prev = b; + } + function d3_layout_packSplice(a, b) { + a._pack_next = b; + b._pack_prev = a; + } + function d3_layout_packIntersects(a, b) { + var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r; + return .999 * dr * dr > dx * dx + dy * dy; + } + function d3_layout_packSiblings(node) { + if (!(nodes = node.children) || !(n = nodes.length)) return; + var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; + function bound(node) { + xMin = Math.min(node.x - node.r, xMin); + xMax = Math.max(node.x + node.r, xMax); + yMin = Math.min(node.y - node.r, yMin); + yMax = Math.max(node.y + node.r, yMax); + } + nodes.forEach(d3_layout_packLink); + a = nodes[0]; + a.x = -a.r; + a.y = 0; + bound(a); + if (n > 1) { + b = nodes[1]; + b.x = b.r; + b.y = 0; + bound(b); + if (n > 2) { + c = nodes[2]; + d3_layout_packPlace(a, b, c); + bound(c); + d3_layout_packInsert(a, c); + a._pack_prev = c; + d3_layout_packInsert(c, b); + b = a._pack_next; + for (i = 3; i < n; i++) { + d3_layout_packPlace(a, b, c = nodes[i]); + var isect = 0, s1 = 1, s2 = 1; + for (j = b._pack_next; j !== b; j = j._pack_next, s1++) { + if (d3_layout_packIntersects(j, c)) { + isect = 1; + break; + } + } + if (isect == 1) { + for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) { + if (d3_layout_packIntersects(k, c)) { + break; + } + } + } + if (isect) { + if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b); + i--; + } else { + d3_layout_packInsert(a, c); + b = c; + bound(c); + } + } + } + } + var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; + for (i = 0; i < n; i++) { + c = nodes[i]; + c.x -= cx; + c.y -= cy; + cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); + } + node.r = cr; + nodes.forEach(d3_layout_packUnlink); + } + function d3_layout_packLink(node) { + node._pack_next = node._pack_prev = node; + } + function d3_layout_packUnlink(node) { + delete node._pack_next; + delete node._pack_prev; + } + function d3_layout_packTransform(node, x, y, k) { + var children = node.children; + node.x = x += k * node.x; + node.y = y += k * node.y; + node.r *= k; + if (children) { + var i = -1, n = children.length; + while (++i < n) d3_layout_packTransform(children[i], x, y, k); + } + } + function d3_layout_packPlace(a, b, c) { + var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y; + if (db && (dx || dy)) { + var da = b.r + c.r, dc = dx * dx + dy * dy; + da *= da; + db *= db; + var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); + c.x = a.x + x * dx + y * dy; + c.y = a.y + x * dy - y * dx; + } else { + c.x = a.x + db; + c.y = a.y; + } + } + d3.layout.cluster = function() { + var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; + function cluster(d, i) { + var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; + d3_layout_treeVisitAfter(root, function(node) { + var children = node.children; + if (children && children.length) { + node.x = d3_layout_clusterX(children); + node.y = d3_layout_clusterY(children); + } else { + node.x = previousNode ? x += separation(node, previousNode) : 0; + node.y = 0; + previousNode = node; + } + }); + var left = d3_layout_clusterLeft(root), right = d3_layout_clusterRight(root), x0 = left.x - separation(left, right) / 2, x1 = right.x + separation(right, left) / 2; + d3_layout_treeVisitAfter(root, nodeSize ? function(node) { + node.x = (node.x - root.x) * size[0]; + node.y = (root.y - node.y) * size[1]; + } : function(node) { + node.x = (node.x - x0) / (x1 - x0) * size[0]; + node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1]; + }); + return nodes; + } + cluster.separation = function(x) { + if (!arguments.length) return separation; + separation = x; + return cluster; + }; + cluster.size = function(x) { + if (!arguments.length) return nodeSize ? null : size; + nodeSize = (size = x) == null; + return cluster; + }; + cluster.nodeSize = function(x) { + if (!arguments.length) return nodeSize ? size : null; + nodeSize = (size = x) != null; + return cluster; + }; + return d3_layout_hierarchyRebind(cluster, hierarchy); + }; + function d3_layout_clusterY(children) { + return 1 + d3.max(children, function(child) { + return child.y; + }); + } + function d3_layout_clusterX(children) { + return children.reduce(function(x, child) { + return x + child.x; + }, 0) / children.length; + } + function d3_layout_clusterLeft(node) { + var children = node.children; + return children && children.length ? d3_layout_clusterLeft(children[0]) : node; + } + function d3_layout_clusterRight(node) { + var children = node.children, n; + return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node; + } + d3.layout.treemap = function() { + var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5)); + function scale(children, k) { + var i = -1, n = children.length, child, area; + while (++i < n) { + area = (child = children[i]).value * (k < 0 ? 0 : k); + child.area = isNaN(area) || area <= 0 ? 0 : area; + } + } + function squarify(node) { + var children = node.children; + if (children && children.length) { + var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), n; + scale(remaining, rect.dx * rect.dy / node.value); + row.area = 0; + while ((n = remaining.length) > 0) { + row.push(child = remaining[n - 1]); + row.area += child.area; + if (mode !== "squarify" || (score = worst(row, u)) <= best) { + remaining.pop(); + best = score; + } else { + row.area -= row.pop().area; + position(row, u, rect, false); + u = Math.min(rect.dx, rect.dy); + row.length = row.area = 0; + best = Infinity; + } + } + if (row.length) { + position(row, u, rect, true); + row.length = row.area = 0; + } + children.forEach(squarify); + } + } + function stickify(node) { + var children = node.children; + if (children && children.length) { + var rect = pad(node), remaining = children.slice(), child, row = []; + scale(remaining, rect.dx * rect.dy / node.value); + row.area = 0; + while (child = remaining.pop()) { + row.push(child); + row.area += child.area; + if (child.z != null) { + position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length); + row.length = row.area = 0; + } + } + children.forEach(stickify); + } + } + function worst(row, u) { + var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length; + while (++i < n) { + if (!(r = row[i].area)) continue; + if (r < rmin) rmin = r; + if (r > rmax) rmax = r; + } + s *= s; + u *= u; + return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity; + } + function position(row, u, rect, flush) { + var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o; + if (u == rect.dx) { + if (flush || v > rect.dy) v = rect.dy; + while (++i < n) { + o = row[i]; + o.x = x; + o.y = y; + o.dy = v; + x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0); + } + o.z = true; + o.dx += rect.x + rect.dx - x; + rect.y += v; + rect.dy -= v; + } else { + if (flush || v > rect.dx) v = rect.dx; + while (++i < n) { + o = row[i]; + o.x = x; + o.y = y; + o.dx = v; + y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0); + } + o.z = false; + o.dy += rect.y + rect.dy - y; + rect.x += v; + rect.dx -= v; + } + } + function treemap(d) { + var nodes = stickies || hierarchy(d), root = nodes[0]; + root.x = 0; + root.y = 0; + root.dx = size[0]; + root.dy = size[1]; + if (stickies) hierarchy.revalue(root); + scale([ root ], root.dx * root.dy / root.value); + (stickies ? stickify : squarify)(root); + if (sticky) stickies = nodes; + return nodes; + } + treemap.size = function(x) { + if (!arguments.length) return size; + size = x; + return treemap; + }; + treemap.padding = function(x) { + if (!arguments.length) return padding; + function padFunction(node) { + var p = x.call(treemap, node, node.depth); + return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p); + } + function padConstant(node) { + return d3_layout_treemapPad(node, x); + } + var type; + pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ], + padConstant) : padConstant; + return treemap; + }; + treemap.round = function(x) { + if (!arguments.length) return round != Number; + round = x ? Math.round : Number; + return treemap; + }; + treemap.sticky = function(x) { + if (!arguments.length) return sticky; + sticky = x; + stickies = null; + return treemap; + }; + treemap.ratio = function(x) { + if (!arguments.length) return ratio; + ratio = x; + return treemap; + }; + treemap.mode = function(x) { + if (!arguments.length) return mode; + mode = x + ""; + return treemap; + }; + return d3_layout_hierarchyRebind(treemap, hierarchy); + }; + function d3_layout_treemapPadNull(node) { + return { + x: node.x, + y: node.y, + dx: node.dx, + dy: node.dy + }; + } + function d3_layout_treemapPad(node, padding) { + var x = node.x + padding[3], y = node.y + padding[0], dx = node.dx - padding[1] - padding[3], dy = node.dy - padding[0] - padding[2]; + if (dx < 0) { + x += dx / 2; + dx = 0; + } + if (dy < 0) { + y += dy / 2; + dy = 0; + } + return { + x: x, + y: y, + dx: dx, + dy: dy + }; + } + d3.random = { + normal: function(µ, σ) { + var n = arguments.length; + if (n < 2) σ = 1; + if (n < 1) µ = 0; + return function() { + var x, y, r; + do { + x = Math.random() * 2 - 1; + y = Math.random() * 2 - 1; + r = x * x + y * y; + } while (!r || r > 1); + return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); + }; + }, + logNormal: function() { + var random = d3.random.normal.apply(d3, arguments); + return function() { + return Math.exp(random()); + }; + }, + irwinHall: function(m) { + return function() { + for (var s = 0, j = 0; j < m; j++) s += Math.random(); + return s / m; + }; + } + }; + d3.scale = {}; + function d3_scaleExtent(domain) { + var start = domain[0], stop = domain[domain.length - 1]; + return start < stop ? [ start, stop ] : [ stop, start ]; + } + function d3_scaleRange(scale) { + return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range()); + } + function d3_scale_bilinear(domain, range, uninterpolate, interpolate) { + var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]); + return function(x) { + return i(u(x)); + }; + } + function d3_scale_nice(domain, nice) { + var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx; + if (x1 < x0) { + dx = i0, i0 = i1, i1 = dx; + dx = x0, x0 = x1, x1 = dx; + } + domain[i0] = nice.floor(x0); + domain[i1] = nice.ceil(x1); + return domain; + } + function d3_scale_niceStep(step) { + return step ? { + floor: function(x) { + return Math.floor(x / step) * step; + }, + ceil: function(x) { + return Math.ceil(x / step) * step; + } + } : d3_scale_niceIdentity; + } + var d3_scale_niceIdentity = { + floor: d3_identity, + ceil: d3_identity + }; + function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { + var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; + if (domain[k] < domain[0]) { + domain = domain.slice().reverse(); + range = range.slice().reverse(); + } + while (++j <= k) { + u.push(uninterpolate(domain[j - 1], domain[j])); + i.push(interpolate(range[j - 1], range[j])); + } + return function(x) { + var j = d3.bisect(domain, x, 1, k) - 1; + return i[j](u[j](x)); + }; + } + d3.scale.linear = function() { + return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3_interpolate, false); + }; + function d3_scale_linear(domain, range, interpolate, clamp) { + var output, input; + function rescale() { + var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber; + output = linear(domain, range, uninterpolate, interpolate); + input = linear(range, domain, uninterpolate, d3_interpolate); + return scale; + } + function scale(x) { + return output(x); + } + scale.invert = function(y) { + return input(y); + }; + scale.domain = function(x) { + if (!arguments.length) return domain; + domain = x.map(Number); + return rescale(); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + return rescale(); + }; + scale.rangeRound = function(x) { + return scale.range(x).interpolate(d3_interpolateRound); + }; + scale.clamp = function(x) { + if (!arguments.length) return clamp; + clamp = x; + return rescale(); + }; + scale.interpolate = function(x) { + if (!arguments.length) return interpolate; + interpolate = x; + return rescale(); + }; + scale.ticks = function(m) { + return d3_scale_linearTicks(domain, m); + }; + scale.tickFormat = function(m, format) { + return d3_scale_linearTickFormat(domain, m, format); + }; + scale.nice = function(m) { + d3_scale_linearNice(domain, m); + return rescale(); + }; + scale.copy = function() { + return d3_scale_linear(domain, range, interpolate, clamp); + }; + return rescale(); + } + function d3_scale_linearRebind(scale, linear) { + return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); + } + function d3_scale_linearNice(domain, m) { + return d3_scale_nice(domain, d3_scale_niceStep(m ? d3_scale_linearTickRange(domain, m)[2] : d3_scale_linearNiceStep(domain))); + } + function d3_scale_linearNiceStep(domain) { + var extent = d3_scaleExtent(domain), span = extent[1] - extent[0]; + return Math.pow(10, Math.round(Math.log(span) / Math.LN10) - 1); + } + function d3_scale_linearTickRange(domain, m) { + var extent = d3_scaleExtent(domain), span = extent[1] - extent[0], step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)), err = m / span * step; + if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; + extent[0] = Math.ceil(extent[0] / step) * step; + extent[1] = Math.floor(extent[1] / step) * step + step * .5; + extent[2] = step; + return extent; + } + function d3_scale_linearTicks(domain, m) { + return d3.range.apply(d3, d3_scale_linearTickRange(domain, m)); + } + function d3_scale_linearTickFormat(domain, m, format) { + var precision = -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01); + return d3.format(format ? format.replace(d3_format_re, function(a, b, c, d, e, f, g, h, i, j) { + return [ b, c, d, e, f, g, h, i || "." + (precision - (j === "%") * 2), j ].join(""); + }) : ",." + precision + "f"); + } + d3.scale.log = function() { + return d3_scale_log(d3.scale.linear().domain([ 0, Math.LN10 ]), 10, d3_scale_logp, d3_scale_powp, [ 1, 10 ]); + }; + function d3_scale_log(linear, base, log, pow, domain) { + function scale(x) { + return linear(log(x)); + } + scale.invert = function(x) { + return pow(linear.invert(x)); + }; + scale.domain = function(x) { + if (!arguments.length) return domain; + if (x[0] < 0) log = d3_scale_logn, pow = d3_scale_pown; else log = d3_scale_logp, + pow = d3_scale_powp; + linear.domain((domain = x.map(Number)).map(log)); + return scale; + }; + scale.base = function(_) { + if (!arguments.length) return base; + base = +_; + return scale; + }; + scale.nice = function() { + function floor(x) { + return Math.pow(base, Math.floor(Math.log(x) / Math.log(base))); + } + function ceil(x) { + return Math.pow(base, Math.ceil(Math.log(x) / Math.log(base))); + } + linear.domain(d3_scale_nice(domain, log === d3_scale_logp ? { + floor: floor, + ceil: ceil + } : { + floor: function(x) { + return -ceil(-x); + }, + ceil: function(x) { + return -floor(-x); + } + }).map(log)); + return scale; + }; + scale.ticks = function() { + var extent = d3_scaleExtent(linear.domain()), ticks = []; + if (extent.every(isFinite)) { + var b = Math.log(base), i = Math.floor(extent[0] / b), j = Math.ceil(extent[1] / b), u = pow(extent[0]), v = pow(extent[1]), n = base % 1 ? 2 : base; + if (log === d3_scale_logn) { + ticks.push(-Math.pow(base, -i)); + for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(-Math.pow(base, -i) * k); + } else { + for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(Math.pow(base, i) * k); + ticks.push(Math.pow(base, i)); + } + for (i = 0; ticks[i] < u; i++) {} + for (j = ticks.length; ticks[j - 1] > v; j--) {} + ticks = ticks.slice(i, j); + } + return ticks; + }; + scale.tickFormat = function(n, format) { + if (!arguments.length) return d3_scale_logFormat; + if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format); + var b = Math.log(base), k = Math.max(.1, n / scale.ticks().length), f = log === d3_scale_logn ? (e = -1e-12, + Math.floor) : (e = 1e-12, Math.ceil), e; + return function(d) { + return d / pow(b * f(log(d) / b + e)) <= k ? format(d) : ""; + }; + }; + scale.copy = function() { + return d3_scale_log(linear.copy(), base, log, pow, domain); + }; + return d3_scale_linearRebind(scale, linear); + } + var d3_scale_logFormat = d3.format(".0e"); + function d3_scale_logp(x) { + return Math.log(x < 0 ? 0 : x); + } + function d3_scale_powp(x) { + return Math.exp(x); + } + function d3_scale_logn(x) { + return -Math.log(x > 0 ? 0 : -x); + } + function d3_scale_pown(x) { + return -Math.exp(-x); + } + d3.scale.pow = function() { + return d3_scale_pow(d3.scale.linear(), 1, [ 0, 1 ]); + }; + function d3_scale_pow(linear, exponent, domain) { + var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent); + function scale(x) { + return linear(powp(x)); + } + scale.invert = function(x) { + return powb(linear.invert(x)); + }; + scale.domain = function(x) { + if (!arguments.length) return domain; + linear.domain((domain = x.map(Number)).map(powp)); + return scale; + }; + scale.ticks = function(m) { + return d3_scale_linearTicks(domain, m); + }; + scale.tickFormat = function(m, format) { + return d3_scale_linearTickFormat(domain, m, format); + }; + scale.nice = function(m) { + return scale.domain(d3_scale_linearNice(domain, m)); + }; + scale.exponent = function(x) { + if (!arguments.length) return exponent; + powp = d3_scale_powPow(exponent = x); + powb = d3_scale_powPow(1 / exponent); + linear.domain(domain.map(powp)); + return scale; + }; + scale.copy = function() { + return d3_scale_pow(linear.copy(), exponent, domain); + }; + return d3_scale_linearRebind(scale, linear); + } + function d3_scale_powPow(e) { + return function(x) { + return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e); + }; + } + d3.scale.sqrt = function() { + return d3.scale.pow().exponent(.5); + }; + d3.scale.ordinal = function() { + return d3_scale_ordinal([], { + t: "range", + a: [ [] ] + }); + }; + function d3_scale_ordinal(domain, ranger) { + var index, range, rangeBand; + function scale(x) { + return range[((index.get(x) || index.set(x, domain.push(x))) - 1) % range.length]; + } + function steps(start, step) { + return d3.range(domain.length).map(function(i) { + return start + step * i; + }); + } + scale.domain = function(x) { + if (!arguments.length) return domain; + domain = []; + index = new d3_Map(); + var i = -1, n = x.length, xi; + while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi)); + return scale[ranger.t].apply(scale, ranger.a); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + rangeBand = 0; + ranger = { + t: "range", + a: arguments + }; + return scale; + }; + scale.rangePoints = function(x, padding) { + if (arguments.length < 2) padding = 0; + var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding); + range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); + rangeBand = 0; + ranger = { + t: "rangePoints", + a: arguments + }; + return scale; + }; + scale.rangeBands = function(x, padding, outerPadding) { + if (arguments.length < 2) padding = 0; + if (arguments.length < 3) outerPadding = padding; + var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); + range = steps(start + step * outerPadding, step); + if (reverse) range.reverse(); + rangeBand = step * (1 - padding); + ranger = { + t: "rangeBands", + a: arguments + }; + return scale; + }; + scale.rangeRoundBands = function(x, padding, outerPadding) { + if (arguments.length < 2) padding = 0; + if (arguments.length < 3) outerPadding = padding; + var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), error = stop - start - (domain.length - padding) * step; + range = steps(start + Math.round(error / 2), step); + if (reverse) range.reverse(); + rangeBand = Math.round(step * (1 - padding)); + ranger = { + t: "rangeRoundBands", + a: arguments + }; + return scale; + }; + scale.rangeBand = function() { + return rangeBand; + }; + scale.rangeExtent = function() { + return d3_scaleExtent(ranger.a[0]); + }; + scale.copy = function() { + return d3_scale_ordinal(domain, ranger); + }; + return scale.domain(domain); + } + d3.scale.category10 = function() { + return d3.scale.ordinal().range(d3_category10); + }; + d3.scale.category20 = function() { + return d3.scale.ordinal().range(d3_category20); + }; + d3.scale.category20b = function() { + return d3.scale.ordinal().range(d3_category20b); + }; + d3.scale.category20c = function() { + return d3.scale.ordinal().range(d3_category20c); + }; + var d3_category10 = [ "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf" ]; + var d3_category20 = [ "#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5", "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5" ]; + var d3_category20b = [ "#393b79", "#5254a3", "#6b6ecf", "#9c9ede", "#637939", "#8ca252", "#b5cf6b", "#cedb9c", "#8c6d31", "#bd9e39", "#e7ba52", "#e7cb94", "#843c39", "#ad494a", "#d6616b", "#e7969c", "#7b4173", "#a55194", "#ce6dbd", "#de9ed6" ]; + var d3_category20c = [ "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476", "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9" ]; + d3.scale.quantile = function() { + return d3_scale_quantile([], []); + }; + function d3_scale_quantile(domain, range) { + var thresholds; + function rescale() { + var k = 0, q = range.length; + thresholds = []; + while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q); + return scale; + } + function scale(x) { + if (!isNaN(x = +x)) return range[d3.bisect(thresholds, x)]; + } + scale.domain = function(x) { + if (!arguments.length) return domain; + domain = x.filter(function(d) { + return !isNaN(d); + }).sort(d3.ascending); + return rescale(); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + return rescale(); + }; + scale.quantiles = function() { + return thresholds; + }; + scale.copy = function() { + return d3_scale_quantile(domain, range); + }; + return rescale(); + } + d3.scale.quantize = function() { + return d3_scale_quantize(0, 1, [ 0, 1 ]); + }; + function d3_scale_quantize(x0, x1, range) { + var kx, i; + function scale(x) { + return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))]; + } + function rescale() { + kx = range.length / (x1 - x0); + i = range.length - 1; + return scale; + } + scale.domain = function(x) { + if (!arguments.length) return [ x0, x1 ]; + x0 = +x[0]; + x1 = +x[x.length - 1]; + return rescale(); + }; + scale.range = function(x) { + if (!arguments.length) return range; + range = x; + return rescale(); + }; + scale.copy = function() { + return d3_scale_quantize(x0, x1, range); + }; + scale.invertExtent = function(y) { + y = range.indexOf(y); + y = y < 0 ? NaN : y / kx + x0; + return [ y, y + 1 / kx ]; + }; + return rescale(); + } + d3.scale.threshold = function() { + return d3_scale_threshold([ .5 ], [ 0, 1 ]); + }; + function d3_scale_threshold(domain, range) { + function scale(x) { + if (x <= x) return range[d3.bisect(domain, x)]; + } + scale.domain = function(_) { + if (!arguments.length) return domain; + domain = _; + return scale; + }; + scale.range = function(_) { + if (!arguments.length) return range; + range = _; + return scale; + }; + scale.invertExtent = function(y) { + y = range.indexOf(y); + return [ domain[y - 1], domain[y] ]; + }; + scale.copy = function() { + return d3_scale_threshold(domain, range); + }; + return scale; + } + d3.scale.identity = function() { + return d3_scale_identity([ 0, 1 ]); + }; + function d3_scale_identity(domain) { + function identity(x) { + return +x; + } + identity.invert = identity; + identity.domain = identity.range = function(x) { + if (!arguments.length) return domain; + domain = x.map(identity); + return identity; + }; + identity.ticks = function(m) { + return d3_scale_linearTicks(domain, m); + }; + identity.tickFormat = function(m, format) { + return d3_scale_linearTickFormat(domain, m, format); + }; + identity.copy = function() { + return d3_scale_identity(domain); + }; + return identity; + } + d3.svg.arc = function() { + var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; + function arc() { + var r0 = innerRadius.apply(this, arguments), r1 = outerRadius.apply(this, arguments), a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset, a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset, da = (a1 < a0 && (da = a0, + a0 = a1, a1 = da), a1 - a0), df = da < π ? "0" : "1", c0 = Math.cos(a0), s0 = Math.sin(a0), c1 = Math.cos(a1), s1 = Math.sin(a1); + return da >= d3_svg_arcMax ? r0 ? "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "M0," + r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + -r0 + "A" + r0 + "," + r0 + " 0 1,0 0," + r0 + "Z" : "M0," + r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + -r1 + "A" + r1 + "," + r1 + " 0 1,1 0," + r1 + "Z" : r0 ? "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L" + r0 * c1 + "," + r0 * s1 + "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0 + "Z" : "M" + r1 * c0 + "," + r1 * s0 + "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1 + "L0,0" + "Z"; + } + arc.innerRadius = function(v) { + if (!arguments.length) return innerRadius; + innerRadius = d3_functor(v); + return arc; + }; + arc.outerRadius = function(v) { + if (!arguments.length) return outerRadius; + outerRadius = d3_functor(v); + return arc; + }; + arc.startAngle = function(v) { + if (!arguments.length) return startAngle; + startAngle = d3_functor(v); + return arc; + }; + arc.endAngle = function(v) { + if (!arguments.length) return endAngle; + endAngle = d3_functor(v); + return arc; + }; + arc.centroid = function() { + var r = (innerRadius.apply(this, arguments) + outerRadius.apply(this, arguments)) / 2, a = (startAngle.apply(this, arguments) + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset; + return [ Math.cos(a) * r, Math.sin(a) * r ]; + }; + return arc; + }; + var d3_svg_arcOffset = -π / 2, d3_svg_arcMax = 2 * π - 1e-6; + function d3_svg_arcInnerRadius(d) { + return d.innerRadius; + } + function d3_svg_arcOuterRadius(d) { + return d.outerRadius; + } + function d3_svg_arcStartAngle(d) { + return d.startAngle; + } + function d3_svg_arcEndAngle(d) { + return d.endAngle; + } + d3.svg.line.radial = function() { + var line = d3_svg_line(d3_svg_lineRadial); + line.radius = line.x, delete line.x; + line.angle = line.y, delete line.y; + return line; + }; + function d3_svg_lineRadial(points) { + var point, i = -1, n = points.length, r, a; + while (++i < n) { + point = points[i]; + r = point[0]; + a = point[1] + d3_svg_arcOffset; + point[0] = r * Math.cos(a); + point[1] = r * Math.sin(a); + } + return points; + } + function d3_svg_area(projection) { + var x0 = d3_svg_lineX, x1 = d3_svg_lineX, y0 = 0, y1 = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; + function area(data) { + var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { + return x; + } : d3_functor(x1), fy1 = y0 === y1 ? function() { + return y; + } : d3_functor(y1), x, y; + function segment() { + segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); + } + while (++i < n) { + if (defined.call(this, d = data[i], i)) { + points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); + points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); + } else if (points0.length) { + segment(); + points0 = []; + points1 = []; + } + } + if (points0.length) segment(); + return segments.length ? segments.join("") : null; + } + area.x = function(_) { + if (!arguments.length) return x1; + x0 = x1 = _; + return area; + }; + area.x0 = function(_) { + if (!arguments.length) return x0; + x0 = _; + return area; + }; + area.x1 = function(_) { + if (!arguments.length) return x1; + x1 = _; + return area; + }; + area.y = function(_) { + if (!arguments.length) return y1; + y0 = y1 = _; + return area; + }; + area.y0 = function(_) { + if (!arguments.length) return y0; + y0 = _; + return area; + }; + area.y1 = function(_) { + if (!arguments.length) return y1; + y1 = _; + return area; + }; + area.defined = function(_) { + if (!arguments.length) return defined; + defined = _; + return area; + }; + area.interpolate = function(_) { + if (!arguments.length) return interpolateKey; + if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; + interpolateReverse = interpolate.reverse || interpolate; + L = interpolate.closed ? "M" : "L"; + return area; + }; + area.tension = function(_) { + if (!arguments.length) return tension; + tension = _; + return area; + }; + return area; + } + d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; + d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; + d3.svg.area = function() { + return d3_svg_area(d3_identity); + }; + d3.svg.area.radial = function() { + var area = d3_svg_area(d3_svg_lineRadial); + area.radius = area.x, delete area.x; + area.innerRadius = area.x0, delete area.x0; + area.outerRadius = area.x1, delete area.x1; + area.angle = area.y, delete area.y; + area.startAngle = area.y0, delete area.y0; + area.endAngle = area.y1, delete area.y1; + return area; + }; + d3.svg.chord = function() { + var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; + function chord(d, i) { + var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i); + return "M" + s.p0 + arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t) ? curve(s.r, s.p1, s.r, s.p0) : curve(s.r, s.p1, t.r, t.p0) + arc(t.r, t.p1, t.a1 - t.a0) + curve(t.r, t.p1, s.r, s.p0)) + "Z"; + } + function subgroup(self, f, d, i) { + var subgroup = f.call(self, d, i), r = radius.call(self, subgroup, i), a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset, a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset; + return { + r: r, + a0: a0, + a1: a1, + p0: [ r * Math.cos(a0), r * Math.sin(a0) ], + p1: [ r * Math.cos(a1), r * Math.sin(a1) ] + }; + } + function equals(a, b) { + return a.a0 == b.a0 && a.a1 == b.a1; + } + function arc(r, p, a) { + return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p; + } + function curve(r0, p0, r1, p1) { + return "Q 0,0 " + p1; + } + chord.radius = function(v) { + if (!arguments.length) return radius; + radius = d3_functor(v); + return chord; + }; + chord.source = function(v) { + if (!arguments.length) return source; + source = d3_functor(v); + return chord; + }; + chord.target = function(v) { + if (!arguments.length) return target; + target = d3_functor(v); + return chord; + }; + chord.startAngle = function(v) { + if (!arguments.length) return startAngle; + startAngle = d3_functor(v); + return chord; + }; + chord.endAngle = function(v) { + if (!arguments.length) return endAngle; + endAngle = d3_functor(v); + return chord; + }; + return chord; + }; + function d3_svg_chordRadius(d) { + return d.radius; + } + d3.svg.diagonal = function() { + var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection; + function diagonal(d, i) { + var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, { + x: p0.x, + y: m + }, { + x: p3.x, + y: m + }, p3 ]; + p = p.map(projection); + return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3]; + } + diagonal.source = function(x) { + if (!arguments.length) return source; + source = d3_functor(x); + return diagonal; + }; + diagonal.target = function(x) { + if (!arguments.length) return target; + target = d3_functor(x); + return diagonal; + }; + diagonal.projection = function(x) { + if (!arguments.length) return projection; + projection = x; + return diagonal; + }; + return diagonal; + }; + function d3_svg_diagonalProjection(d) { + return [ d.x, d.y ]; + } + d3.svg.diagonal.radial = function() { + var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection; + diagonal.projection = function(x) { + return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection; + }; + return diagonal; + }; + function d3_svg_diagonalRadialProjection(projection) { + return function() { + var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset; + return [ r * Math.cos(a), r * Math.sin(a) ]; + }; + } + d3.svg.symbol = function() { + var type = d3_svg_symbolType, size = d3_svg_symbolSize; + function symbol(d, i) { + return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); + } + symbol.type = function(x) { + if (!arguments.length) return type; + type = d3_functor(x); + return symbol; + }; + symbol.size = function(x) { + if (!arguments.length) return size; + size = d3_functor(x); + return symbol; + }; + return symbol; + }; + function d3_svg_symbolSize() { + return 64; + } + function d3_svg_symbolType() { + return "circle"; + } + function d3_svg_symbolCircle(size) { + var r = Math.sqrt(size / π); + return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; + } + var d3_svg_symbols = d3.map({ + circle: d3_svg_symbolCircle, + cross: function(size) { + var r = Math.sqrt(size / 5) / 2; + return "M" + -3 * r + "," + -r + "H" + -r + "V" + -3 * r + "H" + r + "V" + -r + "H" + 3 * r + "V" + r + "H" + r + "V" + 3 * r + "H" + -r + "V" + r + "H" + -3 * r + "Z"; + }, + diamond: function(size) { + var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30; + return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z"; + }, + square: function(size) { + var r = Math.sqrt(size) / 2; + return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z"; + }, + "triangle-down": function(size) { + var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; + return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z"; + }, + "triangle-up": function(size) { + var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2; + return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z"; + } + }); + d3.svg.symbolTypes = d3_svg_symbols.keys(); + var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); + function d3_transition(groups, id) { + d3_arraySubclass(groups, d3_transitionPrototype); + groups.id = id; + return groups; + } + var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit = { + ease: d3_ease_cubicInOut, + delay: 0, + duration: 250 + }; + d3_transitionPrototype.call = d3_selectionPrototype.call; + d3_transitionPrototype.empty = d3_selectionPrototype.empty; + d3_transitionPrototype.node = d3_selectionPrototype.node; + d3.transition = function(selection) { + return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition(); + }; + d3.transition.prototype = d3_transitionPrototype; + d3_transitionPrototype.select = function(selector) { + var id = this.id, subgroups = [], subgroup, subnode, node; + if (typeof selector !== "function") selector = d3_selection_selector(selector); + for (var j = -1, m = this.length; ++j < m; ) { + subgroups.push(subgroup = []); + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + d3_transitionNode(subnode, i, id, node.__transition__[id]); + subgroup.push(subnode); + } else { + subgroup.push(null); + } + } + } + return d3_transition(subgroups, id); + }; + d3_transitionPrototype.selectAll = function(selector) { + var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition; + if (typeof selector !== "function") selector = d3_selection_selectorAll(selector); + for (var j = -1, m = this.length; ++j < m; ) { + for (var group = this[j], i = -1, n = group.length; ++i < n; ) { + if (node = group[i]) { + transition = node.__transition__[id]; + subnodes = selector.call(node, node.__data__, i); + subgroups.push(subgroup = []); + for (var k = -1, o = subnodes.length; ++k < o; ) { + if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition); + subgroup.push(subnode); + } + } + } + } + return d3_transition(subgroups, id); + }; + d3_transitionPrototype.filter = function(filter) { + var subgroups = [], subgroup, group, node; + if (typeof filter !== "function") filter = d3_selection_filter(filter); + for (var j = 0, m = this.length; j < m; j++) { + subgroups.push(subgroup = []); + for (var group = this[j], i = 0, n = group.length; i < n; i++) { + if ((node = group[i]) && filter.call(node, node.__data__, i)) { + subgroup.push(node); + } + } + } + return d3_transition(subgroups, this.id, this.time).ease(this.ease()); + }; + d3_transitionPrototype.tween = function(name, tween) { + var id = this.id; + if (arguments.length < 2) return this.node().__transition__[id].tween.get(name); + return d3_selection_each(this, tween == null ? function(node) { + node.__transition__[id].tween.remove(name); + } : function(node) { + node.__transition__[id].tween.set(name, tween); + }); + }; + function d3_transition_tween(groups, name, value, tween) { + var id = groups.id; + return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { + node.__transition__[id].tween.set(name, tween(value.call(node, node.__data__, i, j))); + } : (value = tween(value), function(node) { + node.__transition__[id].tween.set(name, value); + })); + } + d3_transitionPrototype.attr = function(nameNS, value) { + if (arguments.length < 2) { + for (value in nameNS) this.attr(value, nameNS[value]); + return this; + } + var interpolate = d3_interpolateByName(nameNS), name = d3.ns.qualify(nameNS); + function attrNull() { + this.removeAttribute(name); + } + function attrNullNS() { + this.removeAttributeNS(name.space, name.local); + } + function attrTween(b) { + return b == null ? attrNull : (b += "", function() { + var a = this.getAttribute(name), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.setAttribute(name, i(t)); + }); + }); + } + function attrTweenNS(b) { + return b == null ? attrNullNS : (b += "", function() { + var a = this.getAttributeNS(name.space, name.local), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.setAttributeNS(name.space, name.local, i(t)); + }); + }); + } + return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween); + }; + d3_transitionPrototype.attrTween = function(nameNS, tween) { + var name = d3.ns.qualify(nameNS); + function attrTween(d, i) { + var f = tween.call(this, d, i, this.getAttribute(name)); + return f && function(t) { + this.setAttribute(name, f(t)); + }; + } + function attrTweenNS(d, i) { + var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); + return f && function(t) { + this.setAttributeNS(name.space, name.local, f(t)); + }; + } + return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); + }; + d3_transitionPrototype.style = function(name, value, priority) { + var n = arguments.length; + if (n < 3) { + if (typeof name !== "string") { + if (n < 2) value = ""; + for (priority in name) this.style(priority, name[priority], value); + return this; + } + priority = ""; + } + var interpolate = d3_interpolateByName(name); + function styleNull() { + this.style.removeProperty(name); + } + function styleString(b) { + return b == null ? styleNull : (b += "", function() { + var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.style.setProperty(name, i(t), priority); + }); + }); + } + return d3_transition_tween(this, "style." + name, value, styleString); + }; + d3_transitionPrototype.styleTween = function(name, tween, priority) { + if (arguments.length < 3) priority = ""; + function styleTween(d, i) { + var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name)); + return f && function(t) { + this.style.setProperty(name, f(t), priority); + }; + } + return this.tween("style." + name, styleTween); + }; + d3_transitionPrototype.text = function(value) { + return d3_transition_tween(this, "text", value, d3_transition_text); + }; + function d3_transition_text(b) { + if (b == null) b = ""; + return function() { + this.textContent = b; + }; + } + d3_transitionPrototype.remove = function() { + return this.each("end.transition", function() { + var p; + if (!this.__transition__ && (p = this.parentNode)) p.removeChild(this); + }); + }; + d3_transitionPrototype.ease = function(value) { + var id = this.id; + if (arguments.length < 1) return this.node().__transition__[id].ease; + if (typeof value !== "function") value = d3.ease.apply(d3, arguments); + return d3_selection_each(this, function(node) { + node.__transition__[id].ease = value; + }); + }; + d3_transitionPrototype.delay = function(value) { + var id = this.id; + return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { + node.__transition__[id].delay = value.call(node, node.__data__, i, j) | 0; + } : (value |= 0, function(node) { + node.__transition__[id].delay = value; + })); + }; + d3_transitionPrototype.duration = function(value) { + var id = this.id; + return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { + node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j) | 0); + } : (value = Math.max(1, value | 0), function(node) { + node.__transition__[id].duration = value; + })); + }; + d3_transitionPrototype.each = function(type, listener) { + var id = this.id; + if (arguments.length < 2) { + var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; + d3_transitionInheritId = id; + d3_selection_each(this, function(node, i, j) { + d3_transitionInherit = node.__transition__[id]; + type.call(node, node.__data__, i, j); + }); + d3_transitionInherit = inherit; + d3_transitionInheritId = inheritId; + } else { + d3_selection_each(this, function(node) { + node.__transition__[id].event.on(type, listener); + }); + } + return this; + }; + d3_transitionPrototype.transition = function() { + var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition; + for (var j = 0, m = this.length; j < m; j++) { + subgroups.push(subgroup = []); + for (var group = this[j], i = 0, n = group.length; i < n; i++) { + if (node = group[i]) { + transition = Object.create(node.__transition__[id0]); + transition.delay += transition.duration; + d3_transitionNode(node, i, id1, transition); + } + subgroup.push(node); + } + } + return d3_transition(subgroups, id1); + }; + function d3_transitionNode(node, i, id, inherit) { + var lock = node.__transition__ || (node.__transition__ = { + active: 0, + count: 0 + }), transition = lock[id]; + if (!transition) { + var time = inherit.time; + transition = lock[id] = { + tween: new d3_Map(), + event: d3.dispatch("start", "end"), + time: time, + ease: inherit.ease, + delay: inherit.delay, + duration: inherit.duration + }; + ++lock.count; + d3.timer(function(elapsed) { + var d = node.__data__, ease = transition.ease, event = transition.event, delay = transition.delay, duration = transition.duration, tweened = []; + return delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time), 1; + function start(elapsed) { + if (lock.active > id) return stop(); + lock.active = id; + event.start.call(node, d, i); + transition.tween.forEach(function(key, value) { + if (value = value.call(node, d, i)) { + tweened.push(value); + } + }); + if (!tick(elapsed)) d3.timer(tick, 0, time); + return 1; + } + function tick(elapsed) { + if (lock.active !== id) return stop(); + var t = (elapsed - delay) / duration, e = ease(t), n = tweened.length; + while (n > 0) { + tweened[--n].call(node, e); + } + if (t >= 1) { + stop(); + event.end.call(node, d, i); + return 1; + } + } + function stop() { + if (--lock.count) delete lock[id]; else delete node.__transition__; + return 1; + } + }, 0, time); + return transition; + } + } + d3.svg.axis = function() { + var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, tickMajorSize = 6, tickMinorSize = 6, tickEndSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_, tickSubdivide = 0; + function axis(g) { + g.each(function() { + var g = d3.select(this); + var ticks = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain() : tickValues, tickFormat = tickFormat_ == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : String : tickFormat_; + var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide), subtick = g.selectAll(".tick.minor").data(subticks, String), subtickEnter = subtick.enter().insert("line", ".tick").attr("class", "tick minor").style("opacity", 1e-6), subtickExit = d3.transition(subtick.exit()).style("opacity", 1e-6).remove(), subtickUpdate = d3.transition(subtick).style("opacity", 1); + var tick = g.selectAll(".tick.major").data(ticks, String), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick major").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform; + var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), + d3.transition(path)); + var scale1 = scale.copy(), scale0 = this.__chart__ || scale1; + this.__chart__ = scale1; + tickEnter.append("line"); + tickEnter.append("text"); + var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); + switch (orient) { + case "bottom": + { + tickTransform = d3_svg_axisX; + subtickEnter.attr("y2", tickMinorSize); + subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize); + lineEnter.attr("y2", tickMajorSize); + textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding); + lineUpdate.attr("x2", 0).attr("y2", tickMajorSize); + textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding); + text.attr("dy", ".71em").style("text-anchor", "middle"); + pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize); + break; + } + + case "top": + { + tickTransform = d3_svg_axisX; + subtickEnter.attr("y2", -tickMinorSize); + subtickUpdate.attr("x2", 0).attr("y2", -tickMinorSize); + lineEnter.attr("y2", -tickMajorSize); + textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); + lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize); + textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); + text.attr("dy", "0em").style("text-anchor", "middle"); + pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize); + break; + } + + case "left": + { + tickTransform = d3_svg_axisY; + subtickEnter.attr("x2", -tickMinorSize); + subtickUpdate.attr("x2", -tickMinorSize).attr("y2", 0); + lineEnter.attr("x2", -tickMajorSize); + textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)); + lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0); + textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0); + text.attr("dy", ".32em").style("text-anchor", "end"); + pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize); + break; + } + + case "right": + { + tickTransform = d3_svg_axisY; + subtickEnter.attr("x2", tickMinorSize); + subtickUpdate.attr("x2", tickMinorSize).attr("y2", 0); + lineEnter.attr("x2", tickMajorSize); + textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding); + lineUpdate.attr("x2", tickMajorSize).attr("y2", 0); + textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0); + text.attr("dy", ".32em").style("text-anchor", "start"); + pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize); + break; + } + } + if (scale.ticks) { + tickEnter.call(tickTransform, scale0); + tickUpdate.call(tickTransform, scale1); + tickExit.call(tickTransform, scale1); + subtickEnter.call(tickTransform, scale0); + subtickUpdate.call(tickTransform, scale1); + subtickExit.call(tickTransform, scale1); + } else { + var dx = scale1.rangeBand() / 2, x = function(d) { + return scale1(d) + dx; + }; + tickEnter.call(tickTransform, x); + tickUpdate.call(tickTransform, x); + } + }); + } + axis.scale = function(x) { + if (!arguments.length) return scale; + scale = x; + return axis; + }; + axis.orient = function(x) { + if (!arguments.length) return orient; + orient = x in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient; + return axis; + }; + axis.ticks = function() { + if (!arguments.length) return tickArguments_; + tickArguments_ = arguments; + return axis; + }; + axis.tickValues = function(x) { + if (!arguments.length) return tickValues; + tickValues = x; + return axis; + }; + axis.tickFormat = function(x) { + if (!arguments.length) return tickFormat_; + tickFormat_ = x; + return axis; + }; + axis.tickSize = function(x, y) { + if (!arguments.length) return tickMajorSize; + var n = arguments.length - 1; + tickMajorSize = +x; + tickMinorSize = n > 1 ? +y : tickMajorSize; + tickEndSize = n > 0 ? +arguments[n] : tickMajorSize; + return axis; + }; + axis.tickPadding = function(x) { + if (!arguments.length) return tickPadding; + tickPadding = +x; + return axis; + }; + axis.tickSubdivide = function(x) { + if (!arguments.length) return tickSubdivide; + tickSubdivide = +x; + return axis; + }; + return axis; + }; + var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = { + top: 1, + right: 1, + bottom: 1, + left: 1 + }; + function d3_svg_axisX(selection, x) { + selection.attr("transform", function(d) { + return "translate(" + x(d) + ",0)"; + }); + } + function d3_svg_axisY(selection, y) { + selection.attr("transform", function(d) { + return "translate(0," + y(d) + ")"; + }); + } + function d3_svg_axisSubdivide(scale, ticks, m) { + subticks = []; + if (m && ticks.length > 1) { + var extent = d3_scaleExtent(scale.domain()), subticks, i = -1, n = ticks.length, d = (ticks[1] - ticks[0]) / ++m, j, v; + while (++i < n) { + for (j = m; --j > 0; ) { + if ((v = +ticks[i] - j * d) >= extent[0]) { + subticks.push(v); + } + } + } + for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1]; ) { + subticks.push(v); + } + } + return subticks; + } + d3.svg.brush = function() { + var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, resizes = d3_svg_brushResizes[0], extent = [ [ 0, 0 ], [ 0, 0 ] ], clamp = [ true, true ], extentDomain; + function brush(g) { + g.each(function() { + var g = d3.select(this), bg = g.selectAll(".background").data([ 0 ]), fg = g.selectAll(".extent").data([ 0 ]), tz = g.selectAll(".resize").data(resizes, String), e; + g.style("pointer-events", "all").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); + bg.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); + fg.enter().append("rect").attr("class", "extent").style("cursor", "move"); + tz.enter().append("g").attr("class", function(d) { + return "resize " + d; + }).style("cursor", function(d) { + return d3_svg_brushCursor[d]; + }).append("rect").attr("x", function(d) { + return /[ew]$/.test(d) ? -3 : null; + }).attr("y", function(d) { + return /^[ns]/.test(d) ? -3 : null; + }).attr("width", 6).attr("height", 6).style("visibility", "hidden"); + tz.style("display", brush.empty() ? "none" : null); + tz.exit().remove(); + if (x) { + e = d3_scaleRange(x); + bg.attr("x", e[0]).attr("width", e[1] - e[0]); + redrawX(g); + } + if (y) { + e = d3_scaleRange(y); + bg.attr("y", e[0]).attr("height", e[1] - e[0]); + redrawY(g); + } + redraw(g); + }); + } + function redraw(g) { + g.selectAll(".resize").attr("transform", function(d) { + return "translate(" + extent[+/e$/.test(d)][0] + "," + extent[+/^s/.test(d)][1] + ")"; + }); + } + function redrawX(g) { + g.select(".extent").attr("x", extent[0][0]); + g.selectAll(".extent,.n>rect,.s>rect").attr("width", extent[1][0] - extent[0][0]); + } + function redrawY(g) { + g.select(".extent").attr("y", extent[0][1]); + g.selectAll(".extent,.e>rect,.w>rect").attr("height", extent[1][1] - extent[0][1]); + } + function brushstart() { + var target = this, eventTarget = d3.select(d3.event.target), event_ = event.of(target, arguments), g = d3.select(target), resizing = eventTarget.datum(), resizingX = !/^(n|s)$/.test(resizing) && x, resizingY = !/^(e|w)$/.test(resizing) && y, dragging = eventTarget.classed("extent"), center, origin = mouse(), offset; + var w = d3.select(d3_window).on("mousemove.brush", brushmove).on("mouseup.brush", brushend).on("touchmove.brush", brushmove).on("touchend.brush", brushend).on("keydown.brush", keydown).on("keyup.brush", keyup); + if (dragging) { + origin[0] = extent[0][0] - origin[0]; + origin[1] = extent[0][1] - origin[1]; + } else if (resizing) { + var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing); + offset = [ extent[1 - ex][0] - origin[0], extent[1 - ey][1] - origin[1] ]; + origin[0] = extent[ex][0]; + origin[1] = extent[ey][1]; + } else if (d3.event.altKey) center = origin.slice(); + g.style("pointer-events", "none").selectAll(".resize").style("display", null); + d3.select("body").style("cursor", eventTarget.style("cursor")); + event_({ + type: "brushstart" + }); + brushmove(); + d3_eventCancel(); + function mouse() { + var touches = d3.event.changedTouches; + return touches ? d3.touches(target, touches)[0] : d3.mouse(target); + } + function keydown() { + if (d3.event.keyCode == 32) { + if (!dragging) { + center = null; + origin[0] -= extent[1][0]; + origin[1] -= extent[1][1]; + dragging = 2; + } + d3_eventCancel(); + } + } + function keyup() { + if (d3.event.keyCode == 32 && dragging == 2) { + origin[0] += extent[1][0]; + origin[1] += extent[1][1]; + dragging = 0; + d3_eventCancel(); + } + } + function brushmove() { + var point = mouse(), moved = false; + if (offset) { + point[0] += offset[0]; + point[1] += offset[1]; + } + if (!dragging) { + if (d3.event.altKey) { + if (!center) center = [ (extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2 ]; + origin[0] = extent[+(point[0] < center[0])][0]; + origin[1] = extent[+(point[1] < center[1])][1]; + } else center = null; + } + if (resizingX && move1(point, x, 0)) { + redrawX(g); + moved = true; + } + if (resizingY && move1(point, y, 1)) { + redrawY(g); + moved = true; + } + if (moved) { + redraw(g); + event_({ + type: "brush", + mode: dragging ? "move" : "resize" + }); + } + } + function move1(point, scale, i) { + var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], size = extent[1][i] - extent[0][i], min, max; + if (dragging) { + r0 -= position; + r1 -= size + position; + } + min = clamp[i] ? Math.max(r0, Math.min(r1, point[i])) : point[i]; + if (dragging) { + max = (min += position) + size; + } else { + if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); + if (position < min) { + max = min; + min = position; + } else { + max = position; + } + } + if (extent[0][i] !== min || extent[1][i] !== max) { + extentDomain = null; + extent[0][i] = min; + extent[1][i] = max; + return true; + } + } + function brushend() { + brushmove(); + g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null); + d3.select("body").style("cursor", null); + w.on("mousemove.brush", null).on("mouseup.brush", null).on("touchmove.brush", null).on("touchend.brush", null).on("keydown.brush", null).on("keyup.brush", null); + event_({ + type: "brushend" + }); + d3_eventCancel(); + } + } + brush.x = function(z) { + if (!arguments.length) return x; + x = z; + resizes = d3_svg_brushResizes[!x << 1 | !y]; + return brush; + }; + brush.y = function(z) { + if (!arguments.length) return y; + y = z; + resizes = d3_svg_brushResizes[!x << 1 | !y]; + return brush; + }; + brush.clamp = function(z) { + if (!arguments.length) return x && y ? clamp : x || y ? clamp[+!x] : null; + if (x && y) clamp = [ !!z[0], !!z[1] ]; else if (x || y) clamp[+!x] = !!z; + return brush; + }; + brush.extent = function(z) { + var x0, x1, y0, y1, t; + if (!arguments.length) { + z = extentDomain || extent; + if (x) { + x0 = z[0][0], x1 = z[1][0]; + if (!extentDomain) { + x0 = extent[0][0], x1 = extent[1][0]; + if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1); + if (x1 < x0) t = x0, x0 = x1, x1 = t; + } + } + if (y) { + y0 = z[0][1], y1 = z[1][1]; + if (!extentDomain) { + y0 = extent[0][1], y1 = extent[1][1]; + if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1); + if (y1 < y0) t = y0, y0 = y1, y1 = t; + } + } + return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ]; + } + extentDomain = [ [ 0, 0 ], [ 0, 0 ] ]; + if (x) { + x0 = z[0], x1 = z[1]; + if (y) x0 = x0[0], x1 = x1[0]; + extentDomain[0][0] = x0, extentDomain[1][0] = x1; + if (x.invert) x0 = x(x0), x1 = x(x1); + if (x1 < x0) t = x0, x0 = x1, x1 = t; + extent[0][0] = x0 | 0, extent[1][0] = x1 | 0; + } + if (y) { + y0 = z[0], y1 = z[1]; + if (x) y0 = y0[1], y1 = y1[1]; + extentDomain[0][1] = y0, extentDomain[1][1] = y1; + if (y.invert) y0 = y(y0), y1 = y(y1); + if (y1 < y0) t = y0, y0 = y1, y1 = t; + extent[0][1] = y0 | 0, extent[1][1] = y1 | 0; + } + return brush; + }; + brush.clear = function() { + extentDomain = null; + extent[0][0] = extent[0][1] = extent[1][0] = extent[1][1] = 0; + return brush; + }; + brush.empty = function() { + return x && extent[0][0] === extent[1][0] || y && extent[0][1] === extent[1][1]; + }; + return d3.rebind(brush, event, "on"); + }; + var d3_svg_brushCursor = { + n: "ns-resize", + e: "ew-resize", + s: "ns-resize", + w: "ew-resize", + nw: "nwse-resize", + ne: "nesw-resize", + se: "nwse-resize", + sw: "nesw-resize" + }; + var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ]; + d3.time = {}; + var d3_time = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; + function d3_time_utc() { + this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); + } + d3_time_utc.prototype = { + getDate: function() { + return this._.getUTCDate(); + }, + getDay: function() { + return this._.getUTCDay(); + }, + getFullYear: function() { + return this._.getUTCFullYear(); + }, + getHours: function() { + return this._.getUTCHours(); + }, + getMilliseconds: function() { + return this._.getUTCMilliseconds(); + }, + getMinutes: function() { + return this._.getUTCMinutes(); + }, + getMonth: function() { + return this._.getUTCMonth(); + }, + getSeconds: function() { + return this._.getUTCSeconds(); + }, + getTime: function() { + return this._.getTime(); + }, + getTimezoneOffset: function() { + return 0; + }, + valueOf: function() { + return this._.valueOf(); + }, + setDate: function() { + d3_time_prototype.setUTCDate.apply(this._, arguments); + }, + setDay: function() { + d3_time_prototype.setUTCDay.apply(this._, arguments); + }, + setFullYear: function() { + d3_time_prototype.setUTCFullYear.apply(this._, arguments); + }, + setHours: function() { + d3_time_prototype.setUTCHours.apply(this._, arguments); + }, + setMilliseconds: function() { + d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); + }, + setMinutes: function() { + d3_time_prototype.setUTCMinutes.apply(this._, arguments); + }, + setMonth: function() { + d3_time_prototype.setUTCMonth.apply(this._, arguments); + }, + setSeconds: function() { + d3_time_prototype.setUTCSeconds.apply(this._, arguments); + }, + setTime: function() { + d3_time_prototype.setTime.apply(this._, arguments); + } + }; + var d3_time_prototype = Date.prototype; + var d3_time_formatDateTime = "%a %b %e %X %Y", d3_time_formatDate = "%m/%d/%Y", d3_time_formatTime = "%H:%M:%S"; + var d3_time_days = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], d3_time_dayAbbreviations = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], d3_time_monthAbbreviations = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; + function d3_time_interval(local, step, number) { + function round(date) { + var d0 = local(date), d1 = offset(d0, 1); + return date - d0 < d1 - date ? d0 : d1; + } + function ceil(date) { + step(date = local(new d3_time(date - 1)), 1); + return date; + } + function offset(date, k) { + step(date = new d3_time(+date), k); + return date; + } + function range(t0, t1, dt) { + var time = ceil(t0), times = []; + if (dt > 1) { + while (time < t1) { + if (!(number(time) % dt)) times.push(new Date(+time)); + step(time, 1); + } + } else { + while (time < t1) times.push(new Date(+time)), step(time, 1); + } + return times; + } + function range_utc(t0, t1, dt) { + try { + d3_time = d3_time_utc; + var utc = new d3_time_utc(); + utc._ = t0; + return range(utc, t1, dt); + } finally { + d3_time = Date; + } + } + local.floor = local; + local.round = round; + local.ceil = ceil; + local.offset = offset; + local.range = range; + var utc = local.utc = d3_time_interval_utc(local); + utc.floor = utc; + utc.round = d3_time_interval_utc(round); + utc.ceil = d3_time_interval_utc(ceil); + utc.offset = d3_time_interval_utc(offset); + utc.range = range_utc; + return local; + } + function d3_time_interval_utc(method) { + return function(date, k) { + try { + d3_time = d3_time_utc; + var utc = new d3_time_utc(); + utc._ = date; + return method(utc, k)._; + } finally { + d3_time = Date; + } + }; + } + d3.time.year = d3_time_interval(function(date) { + date = d3.time.day(date); + date.setMonth(0, 1); + return date; + }, function(date, offset) { + date.setFullYear(date.getFullYear() + offset); + }, function(date) { + return date.getFullYear(); + }); + d3.time.years = d3.time.year.range; + d3.time.years.utc = d3.time.year.utc.range; + d3.time.day = d3_time_interval(function(date) { + var day = new d3_time(2e3, 0); + day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); + return day; + }, function(date, offset) { + date.setDate(date.getDate() + offset); + }, function(date) { + return date.getDate() - 1; + }); + d3.time.days = d3.time.day.range; + d3.time.days.utc = d3.time.day.utc.range; + d3.time.dayOfYear = function(date) { + var year = d3.time.year(date); + return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); + }; + d3_time_daySymbols.forEach(function(day, i) { + day = day.toLowerCase(); + i = 7 - i; + var interval = d3.time[day] = d3_time_interval(function(date) { + (date = d3.time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7); + return date; + }, function(date, offset) { + date.setDate(date.getDate() + Math.floor(offset) * 7); + }, function(date) { + var day = d3.time.year(date).getDay(); + return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i); + }); + d3.time[day + "s"] = interval.range; + d3.time[day + "s"].utc = interval.utc.range; + d3.time[day + "OfYear"] = function(date) { + var day = d3.time.year(date).getDay(); + return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7); + }; + }); + d3.time.week = d3.time.sunday; + d3.time.weeks = d3.time.sunday.range; + d3.time.weeks.utc = d3.time.sunday.utc.range; + d3.time.weekOfYear = d3.time.sundayOfYear; + d3.time.format = function(template) { + var n = template.length; + function format(date) { + var string = [], i = -1, j = 0, c, p, f; + while (++i < n) { + if (template.charCodeAt(i) === 37) { + string.push(template.substring(j, i)); + if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); + if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); + string.push(c); + j = i + 1; + } + } + string.push(template.substring(j, i)); + return string.join(""); + } + format.parse = function(string) { + var d = { + y: 1900, + m: 0, + d: 1, + H: 0, + M: 0, + S: 0, + L: 0 + }, i = d3_time_parse(d, template, string, 0); + if (i != string.length) return null; + if ("p" in d) d.H = d.H % 12 + d.p * 12; + var date = new d3_time(); + if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) { + date.setFullYear(d.y, 0, 1); + date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); + } else date.setFullYear(d.y, d.m, d.d); + date.setHours(d.H, d.M, d.S, d.L); + return date; + }; + format.toString = function() { + return template; + }; + return format; + }; + function d3_time_parse(date, template, string, j) { + var c, p, i = 0, n = template.length, m = string.length; + while (i < n) { + if (j >= m) return -1; + c = template.charCodeAt(i++); + if (c === 37) { + p = d3_time_parsers[template.charAt(i++)]; + if (!p || (j = p(date, string, j)) < 0) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + return j; + } + function d3_time_formatRe(names) { + return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); + } + function d3_time_formatLookup(names) { + var map = new d3_Map(), i = -1, n = names.length; + while (++i < n) map.set(names[i].toLowerCase(), i); + return map; + } + function d3_time_formatPad(value, fill, width) { + var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); + } + var d3_time_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayLookup = d3_time_formatLookup(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(d3_time_dayAbbreviations), d3_time_dayAbbrevLookup = d3_time_formatLookup(d3_time_dayAbbreviations), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevRe = d3_time_formatRe(d3_time_monthAbbreviations), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_monthAbbreviations), d3_time_percentRe = /^%/; + var d3_time_formatPads = { + "-": "", + _: " ", + "0": "0" + }; + var d3_time_formats = { + a: function(d) { + return d3_time_dayAbbreviations[d.getDay()]; + }, + A: function(d) { + return d3_time_days[d.getDay()]; + }, + b: function(d) { + return d3_time_monthAbbreviations[d.getMonth()]; + }, + B: function(d) { + return d3_time_months[d.getMonth()]; + }, + c: d3.time.format(d3_time_formatDateTime), + d: function(d, p) { + return d3_time_formatPad(d.getDate(), p, 2); + }, + e: function(d, p) { + return d3_time_formatPad(d.getDate(), p, 2); + }, + H: function(d, p) { + return d3_time_formatPad(d.getHours(), p, 2); + }, + I: function(d, p) { + return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); + }, + j: function(d, p) { + return d3_time_formatPad(1 + d3.time.dayOfYear(d), p, 3); + }, + L: function(d, p) { + return d3_time_formatPad(d.getMilliseconds(), p, 3); + }, + m: function(d, p) { + return d3_time_formatPad(d.getMonth() + 1, p, 2); + }, + M: function(d, p) { + return d3_time_formatPad(d.getMinutes(), p, 2); + }, + p: function(d) { + return d.getHours() >= 12 ? "PM" : "AM"; + }, + S: function(d, p) { + return d3_time_formatPad(d.getSeconds(), p, 2); + }, + U: function(d, p) { + return d3_time_formatPad(d3.time.sundayOfYear(d), p, 2); + }, + w: function(d) { + return d.getDay(); + }, + W: function(d, p) { + return d3_time_formatPad(d3.time.mondayOfYear(d), p, 2); + }, + x: d3.time.format(d3_time_formatDate), + X: d3.time.format(d3_time_formatTime), + y: function(d, p) { + return d3_time_formatPad(d.getFullYear() % 100, p, 2); + }, + Y: function(d, p) { + return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); + }, + Z: d3_time_zone, + "%": function() { + return "%"; + } + }; + var d3_time_parsers = { + a: d3_time_parseWeekdayAbbrev, + A: d3_time_parseWeekday, + b: d3_time_parseMonthAbbrev, + B: d3_time_parseMonth, + c: d3_time_parseLocaleFull, + d: d3_time_parseDay, + e: d3_time_parseDay, + H: d3_time_parseHour24, + I: d3_time_parseHour24, + j: d3_time_parseDayOfYear, + L: d3_time_parseMilliseconds, + m: d3_time_parseMonthNumber, + M: d3_time_parseMinutes, + p: d3_time_parseAmPm, + S: d3_time_parseSeconds, + U: d3_time_parseWeekNumberSunday, + w: d3_time_parseWeekdayNumber, + W: d3_time_parseWeekNumberMonday, + x: d3_time_parseLocaleDate, + X: d3_time_parseLocaleTime, + y: d3_time_parseYear, + Y: d3_time_parseFullYear, + "%": d3_time_parseLiteralPercent + }; + function d3_time_parseWeekdayAbbrev(date, string, i) { + d3_time_dayAbbrevRe.lastIndex = 0; + var n = d3_time_dayAbbrevRe.exec(string.substring(i)); + return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function d3_time_parseWeekday(date, string, i) { + d3_time_dayRe.lastIndex = 0; + var n = d3_time_dayRe.exec(string.substring(i)); + return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function d3_time_parseWeekdayNumber(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 1)); + return n ? (date.w = +n[0], i + n[0].length) : -1; + } + function d3_time_parseWeekNumberSunday(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i)); + return n ? (date.U = +n[0], i + n[0].length) : -1; + } + function d3_time_parseWeekNumberMonday(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i)); + return n ? (date.W = +n[0], i + n[0].length) : -1; + } + function d3_time_parseMonthAbbrev(date, string, i) { + d3_time_monthAbbrevRe.lastIndex = 0; + var n = d3_time_monthAbbrevRe.exec(string.substring(i)); + return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function d3_time_parseMonth(date, string, i) { + d3_time_monthRe.lastIndex = 0; + var n = d3_time_monthRe.exec(string.substring(i)); + return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function d3_time_parseLocaleFull(date, string, i) { + return d3_time_parse(date, d3_time_formats.c.toString(), string, i); + } + function d3_time_parseLocaleDate(date, string, i) { + return d3_time_parse(date, d3_time_formats.x.toString(), string, i); + } + function d3_time_parseLocaleTime(date, string, i) { + return d3_time_parse(date, d3_time_formats.X.toString(), string, i); + } + function d3_time_parseFullYear(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 4)); + return n ? (date.y = +n[0], i + n[0].length) : -1; + } + function d3_time_parseYear(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1; + } + function d3_time_expandYear(d) { + return d + (d > 68 ? 1900 : 2e3); + } + function d3_time_parseMonthNumber(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + return n ? (date.m = n[0] - 1, i + n[0].length) : -1; + } + function d3_time_parseDay(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + return n ? (date.d = +n[0], i + n[0].length) : -1; + } + function d3_time_parseDayOfYear(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 3)); + return n ? (date.j = +n[0], i + n[0].length) : -1; + } + function d3_time_parseHour24(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + return n ? (date.H = +n[0], i + n[0].length) : -1; + } + function d3_time_parseMinutes(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + return n ? (date.M = +n[0], i + n[0].length) : -1; + } + function d3_time_parseSeconds(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 2)); + return n ? (date.S = +n[0], i + n[0].length) : -1; + } + function d3_time_parseMilliseconds(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 3)); + return n ? (date.L = +n[0], i + n[0].length) : -1; + } + var d3_time_numberRe = /^\s*\d+/; + function d3_time_parseAmPm(date, string, i) { + var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase()); + return n == null ? -1 : (date.p = n, i); + } + var d3_time_amPmLookup = d3.map({ + am: 0, + pm: 1 + }); + function d3_time_zone(d) { + var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(Math.abs(z) / 60), zm = Math.abs(z) % 60; + return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); + } + function d3_time_parseLiteralPercent(date, string, i) { + d3_time_percentRe.lastIndex = 0; + var n = d3_time_percentRe.exec(string.substring(i, i + 1)); + return n ? i + n[0].length : -1; + } + d3.time.format.utc = function(template) { + var local = d3.time.format(template); + function format(date) { + try { + d3_time = d3_time_utc; + var utc = new d3_time(); + utc._ = date; + return local(utc); + } finally { + d3_time = Date; + } + } + format.parse = function(string) { + try { + d3_time = d3_time_utc; + var date = local.parse(string); + return date && date._; + } finally { + d3_time = Date; + } + }; + format.toString = local.toString; + return format; + }; + var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ"); + d3.time.format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso; + function d3_time_formatIsoNative(date) { + return date.toISOString(); + } + d3_time_formatIsoNative.parse = function(string) { + var date = new Date(string); + return isNaN(date) ? null : date; + }; + d3_time_formatIsoNative.toString = d3_time_formatIso.toString; + d3.time.second = d3_time_interval(function(date) { + return new d3_time(Math.floor(date / 1e3) * 1e3); + }, function(date, offset) { + date.setTime(date.getTime() + Math.floor(offset) * 1e3); + }, function(date) { + return date.getSeconds(); + }); + d3.time.seconds = d3.time.second.range; + d3.time.seconds.utc = d3.time.second.utc.range; + d3.time.minute = d3_time_interval(function(date) { + return new d3_time(Math.floor(date / 6e4) * 6e4); + }, function(date, offset) { + date.setTime(date.getTime() + Math.floor(offset) * 6e4); + }, function(date) { + return date.getMinutes(); + }); + d3.time.minutes = d3.time.minute.range; + d3.time.minutes.utc = d3.time.minute.utc.range; + d3.time.hour = d3_time_interval(function(date) { + var timezone = date.getTimezoneOffset() / 60; + return new d3_time((Math.floor(date / 36e5 - timezone) + timezone) * 36e5); + }, function(date, offset) { + date.setTime(date.getTime() + Math.floor(offset) * 36e5); + }, function(date) { + return date.getHours(); + }); + d3.time.hours = d3.time.hour.range; + d3.time.hours.utc = d3.time.hour.utc.range; + d3.time.month = d3_time_interval(function(date) { + date = d3.time.day(date); + date.setDate(1); + return date; + }, function(date, offset) { + date.setMonth(date.getMonth() + offset); + }, function(date) { + return date.getMonth(); + }); + d3.time.months = d3.time.month.range; + d3.time.months.utc = d3.time.month.utc.range; + function d3_time_scale(linear, methods, format) { + function scale(x) { + return linear(x); + } + scale.invert = function(x) { + return d3_time_scaleDate(linear.invert(x)); + }; + scale.domain = function(x) { + if (!arguments.length) return linear.domain().map(d3_time_scaleDate); + linear.domain(x); + return scale; + }; + scale.nice = function(m) { + return scale.domain(d3_scale_nice(scale.domain(), m)); + }; + scale.ticks = function(m, k) { + var extent = d3_scaleExtent(scale.domain()); + if (typeof m !== "function") { + var span = extent[1] - extent[0], target = span / m, i = d3.bisect(d3_time_scaleSteps, target); + if (i == d3_time_scaleSteps.length) return methods.year(extent, m); + if (!i) return linear.ticks(m).map(d3_time_scaleDate); + if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i; + m = methods[i]; + k = m[1]; + m = m[0].range; + } + return m(extent[0], new Date(+extent[1] + 1), k); + }; + scale.tickFormat = function() { + return format; + }; + scale.copy = function() { + return d3_time_scale(linear.copy(), methods, format); + }; + return d3_scale_linearRebind(scale, linear); + } + function d3_time_scaleDate(t) { + return new Date(t); + } + function d3_time_scaleFormat(formats) { + return function(date) { + var i = formats.length - 1, f = formats[i]; + while (!f[1](date)) f = formats[--i]; + return f[0](date); + }; + } + function d3_time_scaleSetYear(y) { + var d = new Date(y, 0, 1); + d.setFullYear(y); + return d; + } + function d3_time_scaleGetYear(d) { + var y = d.getFullYear(), d0 = d3_time_scaleSetYear(y), d1 = d3_time_scaleSetYear(y + 1); + return y + (d - d0) / (d1 - d0); + } + var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; + var d3_time_scaleLocalMethods = [ [ d3.time.second, 1 ], [ d3.time.second, 5 ], [ d3.time.second, 15 ], [ d3.time.second, 30 ], [ d3.time.minute, 1 ], [ d3.time.minute, 5 ], [ d3.time.minute, 15 ], [ d3.time.minute, 30 ], [ d3.time.hour, 1 ], [ d3.time.hour, 3 ], [ d3.time.hour, 6 ], [ d3.time.hour, 12 ], [ d3.time.day, 1 ], [ d3.time.day, 2 ], [ d3.time.week, 1 ], [ d3.time.month, 1 ], [ d3.time.month, 3 ], [ d3.time.year, 1 ] ]; + var d3_time_scaleLocalFormats = [ [ d3.time.format("%Y"), d3_true ], [ d3.time.format("%B"), function(d) { + return d.getMonth(); + } ], [ d3.time.format("%b %d"), function(d) { + return d.getDate() != 1; + } ], [ d3.time.format("%a %d"), function(d) { + return d.getDay() && d.getDate() != 1; + } ], [ d3.time.format("%I %p"), function(d) { + return d.getHours(); + } ], [ d3.time.format("%I:%M"), function(d) { + return d.getMinutes(); + } ], [ d3.time.format(":%S"), function(d) { + return d.getSeconds(); + } ], [ d3.time.format(".%L"), function(d) { + return d.getMilliseconds(); + } ] ]; + var d3_time_scaleLinear = d3.scale.linear(), d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats); + d3_time_scaleLocalMethods.year = function(extent, m) { + return d3_time_scaleLinear.domain(extent.map(d3_time_scaleGetYear)).ticks(m).map(d3_time_scaleSetYear); + }; + d3.time.scale = function() { + return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat); + }; + var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) { + return [ m[0].utc, m[1] ]; + }); + var d3_time_scaleUTCFormats = [ [ d3.time.format.utc("%Y"), d3_true ], [ d3.time.format.utc("%B"), function(d) { + return d.getUTCMonth(); + } ], [ d3.time.format.utc("%b %d"), function(d) { + return d.getUTCDate() != 1; + } ], [ d3.time.format.utc("%a %d"), function(d) { + return d.getUTCDay() && d.getUTCDate() != 1; + } ], [ d3.time.format.utc("%I %p"), function(d) { + return d.getUTCHours(); + } ], [ d3.time.format.utc("%I:%M"), function(d) { + return d.getUTCMinutes(); + } ], [ d3.time.format.utc(":%S"), function(d) { + return d.getUTCSeconds(); + } ], [ d3.time.format.utc(".%L"), function(d) { + return d.getUTCMilliseconds(); + } ] ]; + var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats); + function d3_time_scaleUTCSetYear(y) { + var d = new Date(Date.UTC(y, 0, 1)); + d.setUTCFullYear(y); + return d; + } + function d3_time_scaleUTCGetYear(d) { + var y = d.getUTCFullYear(), d0 = d3_time_scaleUTCSetYear(y), d1 = d3_time_scaleUTCSetYear(y + 1); + return y + (d - d0) / (d1 - d0); + } + d3_time_scaleUTCMethods.year = function(extent, m) { + return d3_time_scaleLinear.domain(extent.map(d3_time_scaleUTCGetYear)).ticks(m).map(d3_time_scaleUTCSetYear); + }; + d3.time.scale.utc = function() { + return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat); + }; + d3.text = d3_xhrType(function(request) { + return request.responseText; + }); + d3.json = function(url, callback) { + return d3_xhr(url, "application/json", d3_json, callback); + }; + function d3_json(request) { + return JSON.parse(request.responseText); + } + d3.html = function(url, callback) { + return d3_xhr(url, "text/html", d3_html, callback); + }; + function d3_html(request) { + var range = d3_document.createRange(); + range.selectNode(d3_document.body); + return range.createContextualFragment(request.responseText); + } + d3.xml = d3_xhrType(function(request) { + return request.responseXML; + }); + return d3; +}(); \ No newline at end of file diff --git a/tworavens/d3.v3.min.js b/tworavens/d3.v3.min.js new file mode 100644 index 0000000..cc2a678 --- /dev/null +++ b/tworavens/d3.v3.min.js @@ -0,0 +1,5 @@ +d3=function(){function n(n){return null!=n&&!isNaN(n)}function t(n){return n.length}function e(n){for(var t=1;n*t%1;)t*=10;return t}function r(n,t){try{for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}catch(r){n.prototype=t}}function i(){}function u(){}function a(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function o(){}function c(n){function t(){for(var t,r=e,i=-1,u=r.length;++iAa&&(xa.scrollX||xa.scrollY)){e=va.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var i=e[0][0].getScreenCTM();Aa=!(i.f||i.e),e.remove()}return Aa?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var u=n.getBoundingClientRect();return[t.clientX-u.left-n.clientLeft,t.clientY-u.top-n.clientTop]}function p(n){for(var t=-1,e=n.length,r=[];++te;++e){var i=Ca[e]+t;if(i in n)return i}}function v(n){return Ta(n,Pa),n}function y(n){return function(){return ja(n,this)}}function M(n){return function(){return La(n,this)}}function x(n,t){function e(){this.removeAttribute(n)}function r(){this.removeAttributeNS(n.space,n.local)}function i(){this.setAttribute(n,t)}function u(){this.setAttributeNS(n.space,n.local,t)}function a(){var e=t.apply(this,arguments);null==e?this.removeAttribute(n):this.setAttribute(n,e)}function o(){var e=t.apply(this,arguments);null==e?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,e)}return n=va.ns.qualify(n),null==t?n.local?r:e:"function"==typeof t?n.local?o:a:n.local?u:i}function b(n){return n.trim().replace(/\s+/g," ")}function _(n){return RegExp("(?:^|\\s+)"+va.requote(n)+"(?:\\s+|$)","g")}function w(n,t){function e(){for(var e=-1;++e0&&(n=n.substring(0,o));var l=Ya.get(n);return l&&(n=l,c=D),o?t?i:r:t?T:u}function z(n,t){return function(e){var r=va.event;va.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{va.event=r}}}function D(n,t){var e=z(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||r.compareDocumentPosition(t)&8)||e.call(t,n)}}function j(n,t){for(var e=0,r=n.length;r>e;e++)for(var i,u=n[e],a=0,o=u.length;o>a;a++)(i=u[a])&&t(i,a,e);return n}function L(n){return Ta(n,Ua),n}function H(){}function F(n,t,e){return new P(n,t,e)}function P(n,t,e){this.h=n,this.s=t,this.l=e}function O(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?u+(a-u)*n/60:180>n?a:240>n?u+(a-u)*(240-n)/60:u}function i(n){return Math.round(r(n)*255)}var u,a;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,a=.5>=e?e*(1+t):e+t-e*t,u=2*e-a,et(i(n+120),i(n),i(n-120))}function R(n){return n>0?1:0>n?-1:0}function Y(n){return n>1?0:-1>n?$a:Math.acos(n)}function U(n){return n>1?$a/2:-1>n?-$a/2:Math.asin(n)}function I(n){return(Math.exp(n)-Math.exp(-n))/2}function V(n){return(Math.exp(n)+Math.exp(-n))/2}function X(n){return(n=Math.sin(n/2))*n}function Z(n,t,e){return new B(n,t,e)}function B(n,t,e){this.h=n,this.c=t,this.l=e}function $(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),W(e,Math.cos(n*=Ga)*t,Math.sin(n)*t)}function W(n,t,e){return new J(n,t,e)}function J(n,t,e){this.l=n,this.a=t,this.b=e}function G(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return i=Q(i)*to,r=Q(r)*eo,u=Q(u)*ro,et(tt(3.2404542*i-1.5371385*r-.4985314*u),tt(-.969266*i+1.8760108*r+.041556*u),tt(.0556434*i-.2040259*r+1.0572252*u))}function K(n,t,e){return n>0?Z(Math.atan2(e,t)*Ka,Math.sqrt(t*t+e*e),n):Z(0/0,0/0,n)}function Q(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function nt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function tt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function et(n,t,e){return new rt(n,t,e)}function rt(n,t,e){this.r=n,this.g=t,this.b=e}function it(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function ut(n,t,e){var r,i,u,a=0,o=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(lt(i[0]),lt(i[1]),lt(i[2]))}return(u=ao.get(n))?t(u.r,u.g,u.b):(null!=n&&n.charAt(0)==="#"&&(n.length===4?(a=n.charAt(1),a+=a,o=n.charAt(2),o+=o,c=n.charAt(3),c+=c):n.length===7&&(a=n.substring(1,3),o=n.substring(3,5),c=n.substring(5,7)),a=parseInt(a,16),o=parseInt(o,16),c=parseInt(c,16)),t(a,o,c))}function at(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),a=Math.max(n,t,e),o=a-u,c=(a+u)/2;return o?(i=.5>c?o/(a+u):o/(2-a-u),r=n==a?(t-e)/o+(e>t?6:0):t==a?(e-n)/o+2:(n-t)/o+4,r*=60):(r=0/0,i=c>0&&1>c?0:r),F(r,i,c)}function ot(n,t,e){n=ct(n),t=ct(t),e=ct(e);var r=nt((.4124564*n+.3575761*t+.1804375*e)/to),i=nt((.2126729*n+.7151522*t+.072175*e)/eo),u=nt((.0193339*n+.119192*t+.9503041*e)/ro);return W(116*i-16,500*(r-i),200*(i-u))}function ct(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function lt(n){var t=parseFloat(n);return n.charAt(n.length-1)==="%"?Math.round(2.55*t):t}function ft(n){return"function"==typeof n?n:function(){return n}}function st(n){return n}function ht(n){return function(t,e,r){return arguments.length===2&&"function"==typeof e&&(r=e,e=null),gt(t,e,n,r)}}function gt(n,t,e,r){function i(){var n,t=c.status;if(!t&&c.responseText||t>=200&&300>t||304===t){try{n=e.call(u,c)}catch(r){return a.error.call(u,r),void 0}a.load.call(u,n)}else a.error.call(u,c)}var u={},a=va.dispatch("progress","load","error"),o={},c=new XMLHttpRequest,l=null;return!xa.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=i:c.onreadystatechange=function(){c.readyState>3&&i()},c.onprogress=function(n){var t=va.event;va.event=n;try{a.progress.call(u,c)}finally{va.event=t}},u.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?o[n]:(null==t?delete o[n]:o[n]=t+"",u)},u.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",u):t},u.responseType=function(n){return arguments.length?(l=n,u):l},u.response=function(n){return e=n,u},["get","post"].forEach(function(n){u[n]=function(){return u.send.apply(u,[n].concat(Na(arguments)))}}),u.send=function(e,r,i){if(arguments.length===2&&"function"==typeof r&&(i=r,r=null),c.open(e,n,!0),null==t||"accept"in o||(o.accept=t+",*/*"),c.setRequestHeader)for(var a in o)c.setRequestHeader(a,o[a]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=l&&(c.responseType=l),null!=i&&u.on("error",i).on("load",function(n){i(null,n)}),c.send(null==r?null:r),u},u.abort=function(){return c.abort(),u},va.rebind(u,a,"on"),null==r?u:u.get(pt(r))}function pt(n){return n.length===1?function(t,e){n(null==t?e:null)}:n}function dt(){var n=mt(),t=vt()-n;t>24?(isFinite(t)&&(clearTimeout(fo),fo=setTimeout(dt,t)),lo=0):(lo=1,so(dt))}function mt(){for(var n=Date.now(),t=oo;t;)n>=t.time&&(t.flush=t.callback(n-t.time)),t=t.next;return n}function vt(){for(var n,t=oo,e=1/0;t;)t.flush?t=n?n.next=t.next:oo=t.next:(t.time8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Mt(n,t){return t-(n?Math.ceil(Math.log(n)/Math.LN10):1)}function xt(n){return n+""}function bt(){}function _t(n,t,e){var r=e.s=n+t,i=r-n,u=r-i;e.t=n-u+(t-i)}function wt(n,t){n&&wo.hasOwnProperty(n.type)&&wo[n.type](n,t)}function St(n,t,e){var r,i=-1,u=n.length-e;for(t.lineStart();++io;++o)i.point((e=n[o])[0],e[1]);return i.lineEnd(),void 0}var c={point:e,points:n,other:null,visited:!1,entry:!0,subject:!0},l={point:e,points:[e],other:c,visited:!1,entry:!1,subject:!1};c.other=l,u.push(c),a.push(l),c={point:r,points:[r],other:null,visited:!1,entry:!1,subject:!0},l={point:r,points:[r],other:c,visited:!1,entry:!0,subject:!1},c.other=l,u.push(c),a.push(l)}}),a.sort(t),Ut(u),Ut(a),u.length){if(e)for(var o=1,c=!e(a[0].point),l=a.length;l>o;++o)a[o].entry=c=!c;for(var f,s,h,g=u[0];;){for(f=g;f.visited;)if((f=f.next)===g)return;s=f.points,i.lineStart();do{if(f.visited=f.other.visited=!0,f.entry){if(f.subject)for(var o=0;o=0;)i.point((h=s[o])[0],h[1])}else r(f.point,f.prev.point,-1,i);f=f.prev}f=f.other,s=f.points}while(!f.visited);i.lineEnd()}}}function Ut(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r1&&2&t&&e.push(e.pop().concat(e.shift())),h.push(e.filter(Vt))}}var h,g,p,d=t(i),m={point:u,lineStart:o,lineEnd:c,polygonStart:function(){m.point=l,m.lineStart=f,m.lineEnd=s,h=[],g=[],i.polygonStart()},polygonEnd:function(){m.point=u,m.lineStart=o,m.lineEnd=c,h=va.merge(h),h.length?Yt(h,Zt,null,e,i):r(g)&&(i.lineStart(),e(null,null,1,i),i.lineEnd()),i.polygonEnd(),h=g=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},v=Xt(),y=t(v);return m}}function Vt(n){return n.length>1}function Xt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:T,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Zt(n,t){return((n=n.point)[0]<0?n[1]-$a/2-Wa:$a/2-n[1])-((t=t.point)[0]<0?t[1]-$a/2-Wa:$a/2-t[1])}function Bt(n,t){var e=n[0],r=n[1],i=[Math.sin(e),-Math.cos(e),0],u=0,a=!1,o=!1,c=0;Eo.reset();for(var l=0,f=t.length;f>l;++l){var s=t[l],h=s.length;if(h){for(var g=s[0],p=g[0],d=g[1]/2+$a/4,m=Math.sin(d),v=Math.cos(d),y=1;;){y===h&&(y=0),n=s[y];var M=n[0],x=n[1]/2+$a/4,b=Math.sin(x),_=Math.cos(x),w=M-p,S=Math.abs(w)>$a,E=m*b;if(Eo.add(Math.atan2(E*Math.sin(w),v*_+E*Math.cos(w))),Math.abs(x)=0?2:-2)*$a:w,S^p>=e^M>=e){var k=qt(At(g),At(n));zt(k);var A=qt(i,k);zt(A);var N=(S^w>=0?-1:1)*U(A[2]);r>N&&(c+=S^w>=0?1:-1)}if(!y++)break;p=M,m=b,v=_,g=n}Math.abs(u)>Wa&&(a=!0)}}return(!o&&!a&&0>Eo||-Wa>u)^1&c}function $t(n){var t,e=0/0,r=0/0,i=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(u,a){var o=u>0?$a:-$a,c=Math.abs(u-e);Math.abs(c-$a)0?$a/2:-$a/2),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(o,r),n.point(u,r),t=0):i!==o&&c>=$a&&(Math.abs(e-i)Wa?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*a)):(t+r)/2}function Jt(n,t,e,r){var i;if(null==n)i=e*$a/2,r.point(-$a,i),r.point(0,i),r.point($a,i),r.point($a,0),r.point($a,-i),r.point(0,-i),r.point(-$a,-i),r.point(-$a,0),r.point(-$a,i);else if(Math.abs(n[0]-t[0])>Wa){var u=(n[0]a}function e(n){var e,u,a,c,f;return{lineStart:function(){c=a=!1,f=1},point:function(s,h){var g,p=[s,h],d=t(s,h),m=o?d?0:i(s,h):d?i(s+(0>s?$a:-$a),h):0;if(!e&&(c=a=d)&&n.lineStart(),d!==a&&(g=r(e,p),(jt(e,g)||jt(p,g))&&(p[0]+=Wa,p[1]+=Wa,d=t(p[0],p[1]))),d!==a)f=0,d?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(l&&e&&o^d){var v;m&u||!(v=r(p,e,!0))||(f=0,o?(n.lineStart(),n.point(v[0][0],v[0][1]),n.point(v[1][0],v[1][1]),n.lineEnd()):(n.point(v[1][0],v[1][1]),n.lineEnd(),n.lineStart(),n.point(v[0][0],v[0][1])))}!d||e&&jt(e,p)||n.point(p[0],p[1]),e=p,a=d,u=m},lineEnd:function(){a&&n.lineEnd(),e=null},clean:function(){return f|(c&&a)<<1}}}function r(n,t,e){var r=At(n),i=At(t),u=[1,0,0],o=qt(r,i),c=Nt(o,o),l=o[0],f=c-l*l;if(!f)return!e&&n;var s=a*c/f,h=-a*l/f,g=qt(u,o),p=Ct(u,s),d=Ct(o,h);Tt(p,d);var m=g,v=Nt(p,m),y=Nt(m,m),M=v*v-y*(Nt(p,p)-1);if(!(0>M)){var x=Math.sqrt(M),b=Ct(m,(-v-x)/y);if(Tt(b,p),b=Dt(b),!e)return b;var _,w=n[0],S=t[0],E=n[1],k=t[1];w>S&&(_=w,w=S,S=_);var A=S-w,N=Math.abs(A-$a)A;if(!N&&E>k&&(_=E,E=k,k=_),q?N?E+k>0^b[1]<(Math.abs(b[0]-w)$a^(w<=b[0]&&b[0]<=S)){var T=Ct(m,(-v+x)/y);return Tt(T,p),[b,Dt(T)]}}}function i(t,e){var r=o?n:$a-n,i=0;return-r>t?i|=1:t>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}function u(n){return Bt(c,n)}var a=Math.cos(n),o=a>0,c=[n,0],l=Math.abs(a)>Wa,f=we(n,6*Ga);return It(t,e,f,u)}function Qt(n,t,e,r){function i(r,i){return Math.abs(r[0]-n)0?0:3:Math.abs(r[0]-e)0?2:1:Math.abs(r[1]-t)0?1:0:i>0?3:2}function u(n,t){return a(n.point,t.point)}function a(n,t){var e=i(n,1),r=i(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}function o(i,u){var a=u[0]-i[0],o=u[1]-i[1],c=[0,1];return Math.abs(a)0&&(i[0]+=c[0]*a,i[1]+=c[0]*o),!0):!1}return function(c){function l(u){var a=i(u,-1),o=f([0===a||3===a?n:e,a>1?r:t]);return o}function f(n){for(var t=0,e=M.length,r=n[1],i=0;e>i;++i)for(var u,a=1,o=M[i],c=o.length,l=o[0];c>a;++a)u=o[a],l[1]<=r?u[1]>r&&s(l,u,n)>0&&++t:u[1]<=r&&s(l,u,n)<0&&--t,l=u;return 0!==t}function s(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(e[0]-n[0])*(t[1]-n[1])}function h(u,o,c,l){var f=0,s=0;if(null==u||(f=i(u,c))!==(s=i(o,c))||a(u,o)<0^c>0){do l.point(0===f||3===f?n:e,f>1?r:t);while((f=(f+c+4)%4)!==s)}else l.point(o[0],o[1])}function g(i,u){return i>=n&&e>=i&&u>=t&&r>=u}function p(n,t){g(n,t)&&c.point(n,t)}function d(){T.point=v,M&&M.push(x=[]),A=!0,k=!1,S=E=0/0}function m(){y&&(v(b,_),w&&k&&q.rejoin(),y.push(q.buffer())),T.point=p,k&&c.lineEnd()}function v(n,t){n=Math.max(-Yo,Math.min(Yo,n)),t=Math.max(-Yo,Math.min(Yo,t));var e=g(n,t);if(M&&x.push([n,t]),A)b=n,_=t,w=e,A=!1,e&&(c.lineStart(),c.point(n,t));else if(e&&k)c.point(n,t);else{var r=[S,E],i=[n,t];o(r,i)?(k||(c.lineStart(),c.point(r[0],r[1])),c.point(i[0],i[1]),e||c.lineEnd()):e&&(c.lineStart(),c.point(n,t))}S=n,E=t,k=e}var y,M,x,b,_,w,S,E,k,A,N=c,q=Xt(),T={point:p,lineStart:d,lineEnd:m,polygonStart:function(){c=q,y=[],M=[]},polygonEnd:function(){c=N,(y=va.merge(y)).length?(c.polygonStart(),Yt(y,u,l,h,c),c.polygonEnd()):f([n,t])&&(c.polygonStart(),c.lineStart(),h(null,null,1,c),c.lineEnd(),c.polygonEnd()),y=M=x=null}};return T}}function ne(n,t,e){if(Math.abs(t)=n;var r=n/t;if(t>0){if(r>e[1])return!1;r>e[0]&&(e[0]=r)}else{if(rn&&(Vo=n),n>Zo&&(Zo=n),Xo>t&&(Xo=t),t>Bo&&(Bo=t)}function ae(){function n(n,t){a.push("M",n,",",t,u)}function t(n,t){a.push("M",n,",",t),o.point=e}function e(n,t){a.push("L",n,",",t)}function r(){o.point=n}function i(){a.push("Z")}var u=oe(4.5),a=[],o={point:n,lineStart:function(){o.point=t},lineEnd:r,polygonStart:function(){o.lineEnd=i},polygonEnd:function(){o.lineEnd=r,o.point=n},pointRadius:function(n){return u=oe(n),o},result:function(){if(a.length){var n=a.join("");return a=[],n}}};return o}function oe(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function ce(n,t){qo+=n,To+=t,++Co}function le(){function n(n,r){var i=n-t,u=r-e,a=Math.sqrt(i*i+u*u);zo+=a*(t+n)/2,Do+=a*(e+r)/2,jo+=a,ce(t=n,e=r)}var t,e;Jo.point=function(r,i){Jo.point=n,ce(t=r,e=i)}}function fe(){Jo.point=ce}function se(){function n(n,t){var e=n-r,u=t-i,a=Math.sqrt(e*e+u*u);zo+=a*(r+n)/2,Do+=a*(i+t)/2,jo+=a,a=i*n-r*t,Lo+=a*(r+n),Ho+=a*(i+t),Fo+=3*a,ce(r=n,i=t)}var t,e,r,i;Jo.point=function(u,a){Jo.point=n,ce(t=r=u,e=i=a)},Jo.lineEnd=function(){n(t,e)}}function he(n){function t(t,e){n.moveTo(t,e),n.arc(t,e,a,0,2*$a)}function e(t,e){n.moveTo(t,e),o.point=r}function r(t,e){n.lineTo(t,e)}function i(){o.point=t}function u(){n.closePath()}var a=4.5,o={point:t,lineStart:function(){o.point=e},lineEnd:i,polygonStart:function(){o.lineEnd=u},polygonEnd:function(){o.lineEnd=i,o.point=t},pointRadius:function(n){return a=n,o},result:T};return o}function ge(n){function t(t){function r(e,r){e=n(e,r),t.point(e[0],e[1])}function u(){x=0/0,E.point=a,t.lineStart()}function a(r,u){var a=At([r,u]),o=n(r,u),c=[];e(x,b,M,_,w,S,x=o[0],b=o[1],M=r,_=a[0],w=a[1],S=a[2],i,c),s(c,t),t.point(x,b)}function o(){E.point=r,t.lineEnd()}function c(){u(),E.point=l,E.lineEnd=f}function l(n,t){a(h=n,g=t),p=x,d=b,m=_,v=w,y=S,E.point=a}function f(){var n=[];e(x,b,M,_,w,S,p,d,h,m,v,y,i,n),s(n,t),E.lineEnd=o,o()}function s(n,t){for(var e,r=0,i=n.length;i>r;++r)t.point((e=n[r])[0],e[1])}var h,g,p,d,m,v,y,M,x,b,_,w,S,E={point:r,lineStart:u,lineEnd:o,polygonStart:function(){t.polygonStart(),E.lineStart=c},polygonEnd:function(){t.polygonEnd(),E.lineStart=u}};return E}function e(t,i,u,a,o,c,l,f,s,h,g,p,d,m){var v=l-t,y=f-i,M=v*v+y*y;if(M>4*r&&d--){var x=a+h,b=o+g,_=c+p,w=Math.sqrt(x*x+b*b+_*_),S=Math.asin(_/=w),E=Math.abs(Math.abs(_)-1)r||Math.abs((v*q+y*T)/M-.5)>.3||(z=q*q+T*T>256*r)){var D=e(t,i,u,a,o,c,A,N,E,x/=w,b/=w,_,d,m);m.push(k);var j=e(A,N,E,x,b,_,l,f,s,h,g,p,d,m);return!z||D||j||(m.pop(),!1)}}}var r=.5,i=16;return t.precision=function(n){return arguments.length?(i=(r=n*n)>0&&16,t):Math.sqrt(r)},t}function pe(n){var t=ge(function(t,e){return n([t*Ka,e*Ka])});return function(n){return n=t(n),{point:function(t,e){n.point(t*Ga,e*Ga)},sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}}function de(n){return me(function(){return n})()}function me(n){function t(n){return n=o(n[0]*Ga,n[1]*Ga),[n[0]*h+c,l-n[1]*h]}function e(n){return n=o.invert((n[0]-c)/h,(l-n[1])/h),n&&[n[0]*Ka,n[1]*Ka]}function r(){o=te(a=Me(v,y,M),u);var n=u(d,m);return c=g-n[0]*h,l=p+n[1]*h,i()}function i(){return f&&(f.valid=!1,f=null),t}var u,a,o,c,l,f,s=ge(function(n,t){return n=u(n,t),[n[0]*h+c,l-n[1]*h]}),h=150,g=480,p=250,d=0,m=0,v=0,y=0,M=0,x=Oo,b=st,_=null,w=null;return t.stream=function(n){return f&&(f.valid=!1),f=ve(a,x(s(b(n)))),f.valid=!0,f},t.clipAngle=function(n){return arguments.length?(x=null==n?(_=n,Oo):Kt((_=+n)*Ga),i()):_},t.clipExtent=function(n){return arguments.length?(w=n,b=null==n?st:Qt(n[0][0],n[0][1],n[1][0],n[1][1]),i()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(d=n[0]%360*Ga,m=n[1]%360*Ga,r()):[d*Ka,m*Ka]},t.rotate=function(n){return arguments.length?(v=n[0]%360*Ga,y=n[1]%360*Ga,M=n.length>2?n[2]%360*Ga:0,r()):[v*Ka,y*Ka,M*Ka]},va.rebind(t,s,"precision"),function(){return u=n.apply(this,arguments),t.invert=u.invert&&e,r()}}function ve(n,t){return{point:function(e,r){r=n(e*Ga,r*Ga),e=r[0],t.point(e>$a?e-2*$a:-$a>e?e+2*$a:e,r[1])},sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}function ye(n,t){return[n,t]}function Me(n,t,e){return n?t||e?te(be(n),_e(t,e)):be(n):t||e?_e(t,e):ye}function xe(n){return function(t,e){return t+=n,[t>$a?t-2*$a:-$a>t?t+2*$a:t,e]}}function be(n){var t=xe(n);return t.invert=xe(-n),t}function _e(n,t){function e(n,t){var e=Math.cos(t),o=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),f=l*r+o*i;return[Math.atan2(c*u-f*a,o*r-l*i),U(f*u+c*a)]}var r=Math.cos(n),i=Math.sin(n),u=Math.cos(t),a=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),o=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),f=l*u-c*a;return[Math.atan2(c*u+l*a,o*r+f*i),U(f*r-o*i)]},e}function we(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,a,o){null!=i?(i=Se(e,i),u=Se(e,u),(a>0?u>i:i>u)&&(i+=2*a*$a)):(i=n+2*a*$a,u=n);for(var c,l=a*t,f=i;a>0?f>u:u>f;f-=l)o.point((c=Dt([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function Se(n,t){var e=At(t);e[0]-=n,zt(e);var r=Y(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Wa)%(2*Math.PI)}function Ee(n,t,e){var r=va.range(n,t-Wa,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function ke(n,t,e){var r=va.range(n,t-Wa,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function Ae(n){return n.source}function Ne(n){return n.target}function qe(n,t,e,r){var i=Math.cos(t),u=Math.sin(t),a=Math.cos(r),o=Math.sin(r),c=i*Math.cos(n),l=i*Math.sin(n),f=a*Math.cos(e),s=a*Math.sin(e),h=2*Math.asin(Math.sqrt(X(r-t)+i*a*X(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*f,i=e*l+t*s,a=e*u+t*o;return[Math.atan2(i,r)*Ka,Math.atan2(a,Math.sqrt(r*r+i*i))*Ka]}:function(){return[n*Ka,t*Ka]};return p.distance=h,p}function Te(){function n(n,i){var u=Math.sin(i*=Ga),a=Math.cos(i),o=Math.abs((n*=Ga)-t),c=Math.cos(o);Go+=Math.atan2(Math.sqrt((o=a*Math.sin(o))*o+(o=r*u-e*a*c)*o),e*u+r*a*c),t=n,e=u,r=a}var t,e,r;Ko.point=function(i,u){t=i*Ga,e=Math.sin(u*=Ga),r=Math.cos(u),Ko.point=n},Ko.lineEnd=function(){Ko.point=Ko.lineEnd=T}}function Ce(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),a=Math.cos(i);return[Math.atan2(n*u,r*a),Math.asin(r&&e*u/r)]},e}function ze(n,t){function e(n,t){var e=Math.abs(Math.abs(t)-$a/2)1&&i.push("H",r[0]),i.join("")}function Ie(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1){o=t[1],u=n[c],c++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1];for(var l=2;l9&&(i=3*t/Math.sqrt(i),a[o]=i*e,a[o+1]=i*r));for(o=-1;++o<=c;)i=(n[Math.min(c,o+1)][0]-n[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),u.push([i||0,a[o]*i||0]); +return u}function ur(n){return n.length<3?Re(n):n[0]+$e(n,ir(n))}function ar(n,t,e,r){var i,u,a,o,c,l,f;return i=r[n],u=i[0],a=i[1],i=r[t],o=i[0],c=i[1],i=r[e],l=i[0],f=i[1],(f-a)*(o-u)-(c-a)*(l-u)>0}function or(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function cr(n,t,e,r){var i=n[0],u=e[0],a=t[0]-i,o=r[0]-u,c=n[1],l=e[1],f=t[1]-c,s=r[1]-l,h=(o*(c-l)-s*(i-u))/(s*a-o*f);return[i+h*a,c+h*f]}function lr(n,t){var e={list:n.map(function(n,t){return{index:t,x:n[0],y:n[1]}}).sort(function(n,t){return n.yt.y?1:n.xt.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(n,t){return{edge:n,side:t,vertex:null,l:null,r:null}},insert:function(n,t){t.l=n,t.r=n.r,n.r.l=t,n.r=t},leftBound:function(n){var t=r.leftEnd;do t=t.r;while(t!=r.rightEnd&&i.rightOf(t,n));return t=t.l},del:function(n){n.l.r=n.r,n.r.l=n.l,n.edge=null},right:function(n){return n.r},left:function(n){return n.l},leftRegion:function(n){return n.edge==null?e.bottomSite:n.edge.region[n.side]},rightRegion:function(n){return n.edge==null?e.bottomSite:n.edge.region[cc[n.side]]}},i={bisect:function(n,t){var e={region:{l:n,r:t},ep:{l:null,r:null}},r=t.x-n.x,i=t.y-n.y,u=r>0?r:-r,a=i>0?i:-i;return e.c=n.x*r+n.y*i+.5*(r*r+i*i),u>a?(e.a=1,e.b=i/r,e.c/=r):(e.b=1,e.a=r/i,e.c/=i),e},intersect:function(n,t){var e=n.edge,r=t.edge;if(!e||!r||e.region.r==r.region.r)return null;var i=e.a*r.b-e.b*r.a;if(Math.abs(i)<1e-10)return null;var u,a,o=(e.c*r.b-r.c*e.b)/i,c=(r.c*e.a-e.c*r.a)/i,l=e.region.r,f=r.region.r;l.y=a.region.r.x;return s&&u.side==="l"||!s&&u.side==="r"?null:{x:o,y:c}},rightOf:function(n,t){var e=n.edge,r=e.region.r,i=t.x>r.x;if(i&&n.side==="l")return 1;if(!i&&n.side==="r")return 0;if(e.a===1){var u=t.y-r.y,a=t.x-r.x,o=0,c=0;if(!i&&e.b<0||i&&e.b>=0?c=o=u>=e.b*a:(c=t.x+t.y*e.b>e.c,e.b<0&&(c=!c),c||(o=1)),!o){var l=r.x-e.region.l.x;c=e.b*(a*a-u*u)h*h+g*g}return n.side==="l"?c:!c},endPoint:function(n,e,r){n.ep[e]=r,n.ep[cc[e]]&&t(n)},distance:function(n,t){var e=n.x-t.x,r=n.y-t.y;return Math.sqrt(e*e+r*r)}},u={list:[],insert:function(n,t,e){n.vertex=t,n.ystar=t.y+e;for(var r=0,i=u.list,a=i.length;a>r;r++){var o=i[r];if(!(n.ystar>o.ystar||n.ystar==o.ystar&&t.x>o.vertex.x))break}i.splice(r,0,n)},del:function(n){for(var t=0,e=u.list,r=e.length;r>t&&e[t]!=n;++t);e.splice(t,1)},empty:function(){return u.list.length===0},nextEvent:function(n){for(var t=0,e=u.list,r=e.length;r>t;++t)if(e[t]==n)return e[t+1];return null},min:function(){var n=u.list[0];return{x:n.vertex.x,y:n.ystar}},extractMin:function(){return u.list.shift()}};r.init(),e.bottomSite=e.list.shift();for(var a,o,c,l,f,s,h,g,p,d,m,v,y,M=e.list.shift();;)if(u.empty()||(a=u.min()),M&&(u.empty()||M.yg.y&&(p=h,h=g,g=p,y="r"),v=i.bisect(h,g),s=r.createHalfEdge(v,y),r.insert(l,s),i.endPoint(v,cc[y],m),d=i.intersect(l,s),d&&(u.del(l),u.insert(l,d,i.distance(d,h))),d=i.intersect(s,f),d&&u.insert(s,d,i.distance(d,h))}for(o=r.right(r.leftEnd);o!=r.rightEnd;o=r.right(o))t(o.edge)}function fr(n){return n.x}function sr(n){return n.y}function hr(){return{leaf:!0,nodes:[],point:null,x:null,y:null}}function gr(n,t,e,r,i,u){if(!n(t,e,r,i,u)){var a=.5*(e+i),o=.5*(r+u),c=t.nodes;c[0]&&gr(n,c[0],e,r,a,o),c[1]&&gr(n,c[1],a,r,i,o),c[2]&&gr(n,c[2],e,o,a,u),c[3]&&gr(n,c[3],a,o,i,u)}}function pr(n,t){n=va.rgb(n),t=va.rgb(t);var e=n.r,r=n.g,i=n.b,u=t.r-e,a=t.g-r,o=t.b-i;return function(n){return"#"+it(Math.round(e+u*n))+it(Math.round(r+a*n))+it(Math.round(i+o*n))}}function dr(n){var t=[n.a,n.b],e=[n.c,n.d],r=vr(t),i=mr(t,e),u=vr(yr(e,t,-i))||0;t[0]*e[1]180?f+=360:f-l>180&&(l+=360),i.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:Mr(l,f)})):f&&r.push(r.pop()+"rotate("+f+")"),s!=h?i.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:Mr(s,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),i.push({i:e-4,x:Mr(g[0],p[0])},{i:e-2,x:Mr(g[1],p[1])})):(p[0]!=1||p[1]!=1)&&r.push(r.pop()+"scale("+p+")"),e=i.length,function(n){for(var t,u=-1;++ur;++r)if(a=f[r],a.x==e[0]){if(a.i)if(l[a.i+1]==null)for(l[a.i-1]+=a.x,l.splice(a.i,1),i=r+1;u>i;++i)f[i].i--;else for(l[a.i-1]+=a.x+l[a.i+1],l.splice(a.i,2),i=r+1;u>i;++i)f[i].i-=2;else if(l[a.i+1]==null)l[a.i]=a.x;else for(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1),i=r+1;u>i;++i)f[i].i--;f.splice(r,1),u--,r--}else a.x=Mr(parseFloat(e[0]),parseFloat(a.x));for(;u>r;)a=f.pop(),l[a.i+1]==null?l[a.i]=a.x:(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1)),u--;return l.length===1?l[0]==null?(a=f[0].x,function(n){return a(n)+""}):function(){return t}:function(n){for(r=0;u>r;++r)l[(a=f[r]).i]=a.x(n);return l.join("")}}function wr(n,t){for(var e,r=va.interpolators.length;--r>=0&&!(e=va.interpolators[r](n,t)););return e}function Sr(n){return"transform"==n?xr:wr}function Er(n,t){var e,r=[],i=[],u=n.length,a=t.length,o=Math.min(n.length,t.length);for(e=0;o>e;++e)r.push(wr(n[e],t[e]));for(;u>e;++e)i[e]=n[e];for(;a>e;++e)i[e]=t[e];return function(n){for(e=0;o>e;++e)i[e]=r[e](n);return i}}function kr(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function Ar(n){return function(t){return 1-n(1-t)}}function Nr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function qr(n){return n*n}function Tr(n){return n*n*n}function Cr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function zr(n){return function(t){return Math.pow(t,n)}}function Dr(n){return 1-Math.cos(n*$a/2)}function jr(n){return Math.pow(2,10*(n-1))}function Lr(n){return 1-Math.sqrt(1-n*n)}function Hr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/(2*$a)*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,10*-r)*Math.sin(2*(r-e)*$a/t)}}function Fr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Pr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Or(n,t){n=va.hcl(n),t=va.hcl(t);var e=n.h,r=n.c,i=n.l,u=t.h-e,a=t.c-r,o=t.l-i;return isNaN(a)&&(a=0,r=isNaN(r)?t.c:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return $(e+u*n,r+a*n,i+o*n)+""}}function Rr(n,t){n=va.hsl(n),t=va.hsl(t);var e=n.h,r=n.s,i=n.l,u=t.h-e,a=t.s-r,o=t.l-i;return isNaN(a)&&(a=0,r=isNaN(r)?t.s:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return O(e+u*n,r+a*n,i+o*n)+""}}function Yr(n,t){n=va.lab(n),t=va.lab(t);var e=n.l,r=n.a,i=n.b,u=t.l-e,a=t.a-r,o=t.b-i;return function(n){return G(e+u*n,r+a*n,i+o*n)+""}}function Ur(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Ir(n,t){return t=t-(n=+n)?1/(t-n):0,function(e){return(e-n)*t}}function Vr(n,t){return t=t-(n=+n)?1/(t-n):0,function(e){return Math.max(0,Math.min(1,(e-n)*t))}}function Xr(n){for(var t=n.source,e=n.target,r=Br(t,e),i=[t];t!==r;)t=t.parent,i.push(t);for(var u=i.length;e!==r;)i.splice(u,0,e),e=e.parent;return i}function Zr(n){for(var t=[],e=n.parent;null!=e;)t.push(n),n=e,e=e.parent;return t.push(n),t}function Br(n,t){if(n===t)return n;for(var e=Zr(n),r=Zr(t),i=e.pop(),u=r.pop(),a=null;i===u;)a=i,i=e.pop(),u=r.pop();return a}function $r(n){n.fixed|=2}function Wr(n){n.fixed&=-7}function Jr(n){n.fixed|=4,n.px=n.x,n.py=n.y}function Gr(n){n.fixed&=-5}function Kr(n,t,e){var r=0,i=0;if(n.charge=0,!n.leaf)for(var u,a=n.nodes,o=a.length,c=-1;++ce;++e)(t=n[e][1])>i&&(r=e,i=t);return r}function fi(n){return n.reduce(si,0)}function si(n,t){return n+t[1]}function hi(n,t){return gi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function gi(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function pi(n){return[va.min(n),va.max(n)]}function di(n,t){return n.parent==t.parent?1:2}function mi(n){var t=n.children;return t&&t.length?t[0]:n._tree.thread}function vi(n){var t,e=n.children;return e&&(t=e.length)?e[t-1]:n._tree.thread}function yi(n,t){var e=n.children;if(e&&(i=e.length))for(var r,i,u=-1;++u0&&(n=r);return n}function Mi(n,t){return n.x-t.x}function xi(n,t){return t.x-n.x}function bi(n,t){return n.depth-t.depth}function _i(n,t){function e(n,r){var i=n.children;if(i&&(a=i.length))for(var u,a,o=null,c=-1;++c=0;)t=i[u]._tree,t.prelim+=e,t.mod+=e,e+=t.shift+(r+=t.change)}function Si(n,t,e){n=n._tree,t=t._tree;var r=e/(t.number-n.number);n.change+=r,t.change-=r,t.shift+=e,t.prelim+=e,t.mod+=e}function Ei(n,t,e){return n._tree.ancestor.parent==t.parent?n._tree.ancestor:e}function ki(n,t){return n.value-t.value}function Ai(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Ni(n,t){n._pack_next=t,t._pack_prev=n}function qi(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return.999*i*i>e*e+r*r}function Ti(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,i,u,a,o,c,l,f=1/0,s=-1/0,h=1/0,g=-1/0;if(e.forEach(Ci),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(i=e[1],i.x=i.r,i.y=0,t(i),l>2))for(u=e[2],ji(r,i,u),t(u),Ai(r,u),r._pack_prev=u,Ai(u,i),i=r._pack_next,a=3;l>a;a++){ji(r,i,u=e[a]);var p=0,d=1,m=1;for(o=i._pack_next;o!==i;o=o._pack_next,d++)if(qi(o,u)){p=1;break}if(1==p)for(c=r._pack_prev;c!==o._pack_prev&&!qi(c,u);c=c._pack_prev,m++);p?(m>d||d==m&&i.ra;a++)u=e[a],u.x-=v,u.y-=y,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));n.r=M,e.forEach(zi)}}function Ci(n){n._pack_next=n._pack_prev=n}function zi(n){delete n._pack_next,delete n._pack_prev}function Di(n,t,e,r){var i=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,i)for(var u=-1,a=i.length;++ui&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Yi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Ui(n){return n.rangeExtent?n.rangeExtent():Yi(n.range())}function Ii(n,t,e,r){var i=e(n[0],n[1]),u=r(t[0],t[1]);return function(n){return u(i(n))}}function Vi(n,t){var e,r=0,i=n.length-1,u=n[r],a=n[i];return u>a&&(e=r,r=i,i=e,e=u,u=a,a=e),n[r]=t.floor(u),n[i]=t.ceil(a),n}function Xi(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:Mc}function Zi(n,t,e,r){var i=[],u=[],a=0,o=Math.min(n.length,t.length)-1;for(n[o]2?Zi:Ii,c=r?Vr:Ir;return a=i(n,t,c,e),o=i(t,n,c,wr),u}function u(n){return a(n)}var a,o;return u.invert=function(n){return o(n)},u.domain=function(t){return arguments.length?(n=t.map(Number),i()):n},u.range=function(n){return arguments.length?(t=n,i()):t},u.rangeRound=function(n){return u.range(n).interpolate(Ur)},u.clamp=function(n){return arguments.length?(r=n,i()):r},u.interpolate=function(n){return arguments.length?(e=n,i()):e},u.ticks=function(t){return Ki(n,t)},u.tickFormat=function(t,e){return Qi(n,t,e)},u.nice=function(t){return Wi(n,t),i()},u.copy=function(){return Bi(n,t,e,r)},i()}function $i(n,t){return va.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Wi(n,t){return Vi(n,Xi(t?Gi(n,t)[2]:Ji(n)))}function Ji(n){var t=Yi(n),e=t[1]-t[0];return Math.pow(10,Math.round(Math.log(e)/Math.LN10)-1)}function Gi(n,t){var e=Yi(n),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),u=t/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Ki(n,t){return va.range.apply(va,Gi(n,t))}function Qi(n,t,e){var r=-Math.floor(Math.log(Gi(n,t)[2])/Math.LN10+.01);return va.format(e?e.replace(vo,function(n,t,e,i,u,a,o,c,l,f){return[t,e,i,u,a,o,c,l||"."+(r-2*("%"===f)),f].join("")}):",."+r+"f")}function nu(n,t,e,r,i){function u(t){return n(e(t))}return u.invert=function(t){return r(n.invert(t))},u.domain=function(t){return arguments.length?(t[0]<0?(e=ru,r=iu):(e=tu,r=eu),n.domain((i=t.map(Number)).map(e)),u):i},u.base=function(n){return arguments.length?(t=+n,u):t},u.nice=function(){function r(n){return Math.pow(t,Math.floor(Math.log(n)/Math.log(t)))}function a(n){return Math.pow(t,Math.ceil(Math.log(n)/Math.log(t)))}return n.domain(Vi(i,e===tu?{floor:r,ceil:a}:{floor:function(n){return-a(-n)},ceil:function(n){return-r(-n)}}).map(e)),u},u.ticks=function(){var i=Yi(n.domain()),u=[];if(i.every(isFinite)){var a=Math.log(t),o=Math.floor(i[0]/a),c=Math.ceil(i[1]/a),l=r(i[0]),f=r(i[1]),s=t%1?2:t;if(e===ru)for(u.push(-Math.pow(t,-o));o++0;h--)u.push(-Math.pow(t,-o)*h);else{for(;c>o;o++)for(var h=1;s>h;h++)u.push(Math.pow(t,o)*h);u.push(Math.pow(t,o))}for(o=0;u[o]f;c--);u=u.slice(o,c)}return u},u.tickFormat=function(n,i){if(!arguments.length)return xc;arguments.length<2?i=xc:"function"!=typeof i&&(i=va.format(i));var a,o=Math.log(t),c=Math.max(.1,n/u.ticks().length),l=e===ru?(a=-1e-12,Math.floor):(a=1e-12,Math.ceil);return function(n){return n/r(o*l(e(n)/o+a))<=c?i(n):""}},u.copy=function(){return nu(n.copy(),t,e,r,i)},$i(u,n)}function tu(n){return Math.log(0>n?0:n)}function eu(n){return Math.exp(n)}function ru(n){return-Math.log(n>0?0:-n)}function iu(n){return-Math.exp(-n)}function uu(n,t,e){function r(t){return n(i(t))}var i=au(t),u=au(1/t);return r.invert=function(t){return u(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(i)),r):e},r.ticks=function(n){return Ki(e,n)},r.tickFormat=function(n,t){return Qi(e,n,t)},r.nice=function(n){return r.domain(Wi(e,n))},r.exponent=function(a){return arguments.length?(i=au(t=a),u=au(1/t),n.domain(e.map(i)),r):t},r.copy=function(){return uu(n.copy(),t,e)},$i(r,n)}function au(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function ou(n,t){function e(t){return a[((u.get(t)||u.set(t,n.push(t)))-1)%a.length]}function r(t,e){return va.range(n.length).map(function(n){return t+e*n})}var u,a,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new i;for(var a,o=-1,c=r.length;++ot?0/0:t/u+n,[t,t+1/u]},i()}function fu(n,t){function e(e){return e>=e?t[va.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return fu(n,t)},e}function su(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Ki(n,t)},t.tickFormat=function(t,e){return Qi(n,t,e)},t.copy=function(){return su(n)},t}function hu(n){return n.innerRadius}function gu(n){return n.outerRadius}function pu(n){return n.startAngle}function du(n){return n.endAngle}function mu(n){for(var t,e,r,i=-1,u=n.length;++ie?l():(u.active=e,h.start.call(n,f,t),a.tween.forEach(function(e,r){(r=r.call(n,f,t))&&d.push(r)}),c(r)||va.timer(c,0,o),1)}function c(r){if(u.active!==e)return l();for(var i=(r-g)/p,a=s(i),o=d.length;o>0;)d[--o].call(n,a);return i>=1?(l(),h.end.call(n,f,t),1):void 0}function l(){return--u.count?delete u[e]:delete n.__transition__,1}var f=n.__data__,s=a.ease,h=a.event,g=a.delay,p=a.duration,d=[];return r>=g?i(r):va.timer(i,g,o),1},0,o),a}}function Nu(n,t){n.attr("transform",function(n){return"translate("+t(n)+",0)"})}function qu(n,t){n.attr("transform",function(n){return"translate(0,"+t(n)+")"})}function Tu(n,t,e){if(r=[],e&&t.length>1){for(var r,i,u,a=Yi(n.domain()),o=-1,c=t.length,l=(t[1]-t[0])/++e;++o0;)(u=+t[o]-i*l)>=a[0]&&r.push(u);for(--o,i=0;++i1?Date.UTC.apply(this,arguments):arguments[0])}function zu(n,t,e){function r(t){var e=n(t),r=u(e,1);return r-t>t-e?e:r}function i(e){return t(e=n(new Pc(e-1)),1),e}function u(n,e){return t(n=new Pc(+n),e),n}function a(n,r,u){var a=i(n),o=[];if(u>1)for(;r>a;)e(a)%u||o.push(new Date(+a)),t(a,1);else for(;r>a;)o.push(new Date(+a)),t(a,1);return o}function o(n,t,e){try{Pc=Cu;var r=new Cu;return r._=n,a(r,t,e)}finally{Pc=Date}}n.floor=n,n.round=r,n.ceil=i,n.offset=u,n.range=a;var c=n.utc=Du(n);return c.floor=c,c.round=Du(r),c.ceil=Du(i),c.offset=Du(u),c.range=o,n}function Du(n){return function(t,e){try{Pc=Cu;var r=new Cu;return r._=t,n(r,e)._}finally{Pc=Date}}}function ju(n,t,e,r){for(var i,u,a=0,o=t.length,c=e.length;o>a;){if(r>=c)return-1;if(i=t.charCodeAt(a++),37===i){if(u=ul[t.charAt(a++)],!u||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function Lu(n){return RegExp("^(?:"+n.map(va.requote).join("|")+")","i")}function Hu(n){for(var t=new i,e=-1,r=n.length;++en?"-":"",i=(r?-n:n)+"",u=i.length;return r+(e>u?Array(e-u+1).join(t)+i:i)}function Pu(n,t,e){Jc.lastIndex=0;var r=Jc.exec(t.substring(e));return r?(n.w=Gc.get(r[0].toLowerCase()),e+r[0].length):-1}function Ou(n,t,e){$c.lastIndex=0;var r=$c.exec(t.substring(e));return r?(n.w=Wc.get(r[0].toLowerCase()),e+r[0].length):-1}function Ru(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+1));return r?(n.w=+r[0],e+r[0].length):-1}function Yu(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e));return r?(n.U=+r[0],e+r[0].length):-1}function Uu(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e));return r?(n.W=+r[0],e+r[0].length):-1}function Iu(n,t,e){nl.lastIndex=0;var r=nl.exec(t.substring(e));return r?(n.m=tl.get(r[0].toLowerCase()),e+r[0].length):-1}function Vu(n,t,e){Kc.lastIndex=0;var r=Kc.exec(t.substring(e));return r?(n.m=Qc.get(r[0].toLowerCase()),e+r[0].length):-1}function Xu(n,t,e){return ju(n,""+il.c,t,e)}function Zu(n,t,e){return ju(n,""+il.x,t,e)}function Bu(n,t,e){return ju(n,""+il.X,t,e)}function $u(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+4));return r?(n.y=+r[0],e+r[0].length):-1}function Wu(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+2));return r?(n.y=Ju(+r[0]),e+r[0].length):-1}function Ju(n){return n+(n>68?1900:2e3)}function Gu(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Ku(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function Qu(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function na(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function ta(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function ea(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ra(n,t,e){al.lastIndex=0;var r=al.exec(t.substring(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ia(n,t,e){var r=ol.get(t.substring(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}function ua(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return e+Fu(r,"0",2)+Fu(i,"0",2)}function aa(n,t,e){el.lastIndex=0;var r=el.exec(t.substring(e,e+1));return r?e+r[0].length:-1}function oa(n){return n.toISOString()}function ca(n,t,e){function r(t){return n(t)}return r.invert=function(t){return la(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain(t),r):n.domain().map(la)},r.nice=function(n){return r.domain(Vi(r.domain(),n))},r.ticks=function(e,i){var u=Yi(r.domain());if("function"!=typeof e){var a=u[1]-u[0],o=a/e,c=va.bisect(ll,o);if(c==ll.length)return t.year(u,e);if(!c)return n.ticks(e).map(la);Math.log(o/ll[c-1])n?-1:n>t?1:n>=t?0:0/0},va.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},va.min=function(n,t){var e,r,i=-1,u=n.length;if(arguments.length===1){for(;++i=e);)e=void 0;for(;++ir&&(e=r)}else{for(;++i=e);)e=void 0;for(;++ir&&(e=r)}return e},va.max=function(n,t){var e,r,i=-1,u=n.length;if(arguments.length===1){for(;++i=e);)e=void 0;for(;++ie&&(e=r)}else{for(;++i=e);)e=void 0;for(;++ie&&(e=r)}return e},va.extent=function(n,t){var e,r,i,u=-1,a=n.length;if(arguments.length===1){for(;++u=e);)e=i=void 0;for(;++ur&&(e=r),r>i&&(i=r))}else{for(;++u=e);)e=void 0;for(;++ur&&(e=r),r>i&&(i=r))}return[e,i]},va.sum=function(n,t){var e,r=0,i=n.length,u=-1;if(arguments.length===1)for(;++u1&&(t=t.map(e)),t=t.filter(n),t.length?va.quantile(t.sort(va.ascending),.5):void 0},va.bisector=function(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n.call(t,t[u],u)r;){var u=r+i>>>1;er)for(;(i=n+r*++o)>t;)u.push(i/a);else for(;(i=n+r*++o)=a.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,f,s,h,g=-1,p=o.length,d=a[c++],m=new i;++g=a.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)}) +}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,u={},a=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(va.map,e,0),0)},u.key=function(n){return a.push(n),u},u.sortKeys=function(n){return o[a.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},va.set=function(n){var t=new u;if(n)for(var e=0;e=0&&(r=n.substring(e+1),n=n.substring(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(arguments.length===2){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},va.event=null,va.mouse=function(n){return g(n,f())};var Aa=/WebKit/.test(xa.navigator.userAgent)?-1:0,Na=d;try{Na(Ma.childNodes)[0].nodeType}catch(qa){Na=p}var Ta=[].__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]};va.touches=function(n,t){return arguments.length<2&&(t=f().touches),t?Na(t).map(function(t){var e=g(n,t);return e.identifier=t.identifier,e}):[]};var Ca=["webkit","ms","moz","Moz","o","O"],za=m(Ma.style,"userSelect"),Da=za?function(){var n=Ma.style,t=n[za];return n[za]="none",function(){n[za]=t}}:function(n){var t=va.select(xa).on("selectstart."+n,l);return function(){t.on("selectstart."+n,null)}};va.behavior.drag=function(){function n(){this.on("mousedown.drag",t).on("touchstart.drag",t)}function t(){function n(){var n=a.parentNode;return null!=f?va.touches(n).filter(function(n){return n.identifier===f})[0]:va.mouse(n)}function t(){if(!a.parentNode)return i();var t=n(),e=t[0]-h[0],r=t[1]-h[1];g|=e|r,h=t,l(),o({type:"drag",x:t[0]+u[0],y:t[1]+u[1],dx:e,dy:r})}function i(){o({type:"dragend"}),g&&(l(),va.event.target===c&&s(d,"click")),d.on(null!=f?"touchmove.drag-"+f:"mousemove.drag",null).on(null!=f?"touchend.drag-"+f:"mouseup.drag",null),p()}var u,a=this,o=e.of(a,arguments),c=va.event.target,f=va.event.touches?va.event.changedTouches[0].identifier:null,h=n(),g=0,p=Da(null!=f?"drag-"+f:"drag"),d=va.select(xa).on(null!=f?"touchmove.drag-"+f:"mousemove.drag",t).on(null!=f?"touchend.drag-"+f:"mouseup.drag",i,!0);r?(u=r.apply(a,arguments),u=[u.x-h[0],u.y-h[1]]):u=[0,0],o({type:"dragstart"})}var e=h(n,"drag","dragstart","dragend"),r=null;return n.origin=function(t){return arguments.length?(r=t,n):r},va.rebind(n,e,"on")};var ja=function(n,t){return t.querySelector(n)},La=function(n,t){return t.querySelectorAll(n)},Ha=Ma[m(Ma,"matchesSelector")],Fa=function(n,t){return Ha.call(n,t)};"function"==typeof Sizzle&&(ja=function(n,t){return Sizzle(n,t)[0]||null},La=function(n,t){return Sizzle.uniqueSort(Sizzle(n,t))},Fa=Sizzle.matchesSelector),va.selection=function(){return Ia};var Pa=va.selection.prototype=[];Pa.select=function(n){var t,e,r,i,u=[];"function"!=typeof n&&(n=y(n));for(var a=-1,o=this.length;++a=0&&(e=n.substring(0,t),n=n.substring(t+1)),Oa.hasOwnProperty(e)?{space:Oa[e],local:n}:n}},Pa.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=va.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(x(t,n[t]));return this}return this.each(x(n,t))},va.requote=function(n){return n.replace(Ra,"\\$&")};var Ra=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;Pa.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=n.trim().split(/^|\s+/g)).length,i=-1;if(t=e.classList){for(;++ir){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(E(e,n[e],t));return this}if(2>r)return xa.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(E(n,t,e))},Pa.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(k(t,n[t]));return this}return this.each(k(n,t))},Pa.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},Pa.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},Pa.append=function(n){function t(){return this.appendChild(ya.createElementNS(this.namespaceURI,n))}function e(){return this.appendChild(ya.createElementNS(n.space,n.local))}return n=va.ns.qualify(n),this.select(n.local?e:t)},Pa.insert=function(n,t){function e(e,r){return this.insertBefore(ya.createElementNS(this.namespaceURI,n),t.call(this,e,r))}function r(e,r){return this.insertBefore(ya.createElementNS(n.space,n.local),t.call(this,e,r))}return n=va.ns.qualify(n),"function"!=typeof t&&(t=y(t)),this.select(n.local?r:e)},Pa.remove=function(){return this.each(function(){var n=this.parentNode;n&&n.removeChild(this)})},Pa.data=function(n,t){function e(n,e){var r,u,a,o=n.length,s=e.length,h=Math.min(o,s),g=Array(s),p=Array(s),d=Array(o);if(t){var m,v=new i,y=new i,M=[];for(r=-1;++rr;++r)p[r]=A(e[r]);for(;o>r;++r)d[r]=n[r]}p.update=g,p.parentNode=g.parentNode=d.parentNode=n.parentNode,c.push(p),l.push(g),f.push(d)}var r,u,a=-1,o=this.length;if(!arguments.length){for(n=Array(o=(r=this[0]).length);++au;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var o=0,c=e.length;c>o;o++)(r=e[o])&&n.call(r,r.__data__,o)&&t.push(r)}return v(i)},Pa.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},Pa.sort=function(n){n=q.apply(this,arguments);for(var t=-1,e=this.length;++tr){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(C(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(C(n,t,e))};var Ya=va.map({mouseenter:"mouseover",mouseleave:"mouseout"});Ya.forEach(function(n){"on"+n in ya&&Ya.remove(n)}),Pa.each=function(n){return j(this,function(t,e,r){n.call(t,t.__data__,e,r)})},Pa.call=function(n){var t=Na(arguments);return n.apply(t[0]=this,t),this},Pa.empty=function(){return!this.node()},Pa.node=function(){for(var n=0,t=this.length;t>n;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},Pa.size=function(){var n=0;return this.each(function(){++n}),n};var Ua=[];va.selection.enter=L,va.selection.enter.prototype=Ua,Ua.append=Pa.append,Ua.insert=Pa.insert,Ua.empty=Pa.empty,Ua.node=Pa.node,Ua.call=Pa.call,Ua.size=Pa.size,Ua.select=function(n){for(var t,e,r,i,u,a=[],o=-1,c=this.length;++oe-w){var u=n[0],o=t(n[0]);r(2*E),i(u,o),a(A.of(this,arguments))}w=e}else if(n.length>1){var u=n[0],c=n[1],l=u[0]-c[0],f=u[1]-c[1];v=l*l+f*f}}function d(){var n=va.touches(this),t=n[0],e=m[t.identifier];if(u=n[1]){var u,o=m[u.identifier],c=va.event.scale;if(null==c){var l=(l=u[0]-t[0])*l+(l=u[1]-t[1])*l;c=v&&Math.sqrt(l/v)}t=[(t[0]+u[0])/2,(t[1]+u[1])/2],e=[(e[0]+o[0])/2,(e[1]+o[1])/2],r(c*y)}i(t,e),w=null,a(A.of(this,arguments))}var m,v,y,M,x,b,_,w,S=[0,0],E=1,k=Xa,A=h(n,"zoom");return n.translate=function(t){return arguments.length?(S=t.map(Number),u(),n):S},n.scale=function(t){return arguments.length?(E=+t,u(),n):E},n.scaleExtent=function(t){return arguments.length?(k=null==t?Xa:t.map(Number),n):k},n.x=function(t){return arguments.length?(x=t,M=t.copy(),S=[0,0],E=1,n):x},n.y=function(t){return arguments.length?(_=t,b=t.copy(),S=[0,0],E=1,n):_},va.rebind(n,A,"on")};var Va,Xa=[0,1/0],Za="onwheel"in ya?(Va=function(){return-va.event.deltaY*(va.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ya?(Va=function(){return va.event.wheelDelta},"mousewheel"):(Va=function(){return-va.event.detail},"MozMousePixelScroll");H.prototype.toString=function(){return this.rgb()+""},va.hsl=function(n,t,e){return arguments.length===1?n instanceof P?F(n.h,n.s,n.l):ut(""+n,at,F):F(+n,+t,+e)};var Ba=P.prototype=new H;Ba.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),F(this.h,this.s,this.l/n)},Ba.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),F(this.h,this.s,n*this.l)},Ba.rgb=function(){return O(this.h,this.s,this.l)};var $a=Math.PI,Wa=1e-6,Ja=Wa*Wa,Ga=$a/180,Ka=180/$a;va.hcl=function(n,t,e){return arguments.length===1?n instanceof B?Z(n.h,n.c,n.l):n instanceof J?K(n.l,n.a,n.b):K((n=ot((n=va.rgb(n)).r,n.g,n.b)).l,n.a,n.b):Z(+n,+t,+e)};var Qa=B.prototype=new H;Qa.brighter=function(n){return Z(this.h,this.c,Math.min(100,this.l+no*(arguments.length?n:1)))},Qa.darker=function(n){return Z(this.h,this.c,Math.max(0,this.l-no*(arguments.length?n:1)))},Qa.rgb=function(){return $(this.h,this.c,this.l).rgb()},va.lab=function(n,t,e){return arguments.length===1?n instanceof J?W(n.l,n.a,n.b):n instanceof B?$(n.l,n.c,n.h):ot((n=va.rgb(n)).r,n.g,n.b):W(+n,+t,+e)};var no=18,to=.95047,eo=1,ro=1.08883,io=J.prototype=new H;io.brighter=function(n){return W(Math.min(100,this.l+no*(arguments.length?n:1)),this.a,this.b)},io.darker=function(n){return W(Math.max(0,this.l-no*(arguments.length?n:1)),this.a,this.b)},io.rgb=function(){return G(this.l,this.a,this.b)},va.rgb=function(n,t,e){return arguments.length===1?n instanceof rt?et(n.r,n.g,n.b):ut(""+n,et,O):et(~~n,~~t,~~e)};var uo=rt.prototype=new H;uo.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&i>t&&(t=i),e&&i>e&&(e=i),r&&i>r&&(r=i),et(Math.min(255,Math.floor(t/n)),Math.min(255,Math.floor(e/n)),Math.min(255,Math.floor(r/n)))):et(i,i,i)},uo.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),et(Math.floor(n*this.r),Math.floor(n*this.g),Math.floor(n*this.b))},uo.hsl=function(){return at(this.r,this.g,this.b)},uo.toString=function(){return"#"+it(this.r)+it(this.g)+it(this.b)};var ao=va.map({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"});ao.forEach(function(n,t){ao.set(n,ut(t,et,O))}),va.functor=ft,va.xhr=ht(st),va.dsv=function(n,t){function e(n,e,u){arguments.length<3&&(u=e,e=null);var a=va.xhr(n,t,u);return a.row=function(n){return arguments.length?a.response((e=n)==null?r:i(n)):e},a.row(e)}function r(n){return e.parse(n.responseText)}function i(n){return function(t){return e.parse(t.responseText,n)}}function a(t){return t.map(o).join(n)}function o(n){return c.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var c=RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var i=Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(i(n),e)}:i})},e.parseRows=function(n,t){function e(){if(f>=c)return a;if(i)return i=!1,u;var t=f;if(n.charCodeAt(t)===34){for(var e=t;e++f;){var r=n.charCodeAt(f++),o=1;if(10===r)i=!0;else if(13===r)i=!0,n.charCodeAt(f)===10&&(++f,++o);else if(r!==l)continue;return n.substring(t,f-o)}return n.substring(t)}for(var r,i,u={},a={},o=[],c=n.length,f=0,s=0;(r=e())!==a;){for(var h=[];r!==u&&r!==a;)h.push(r),r=e();(!t||(h=t(h,s++)))&&o.push(h)}return o},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new u,i=[];return t.forEach(function(n){for(var t in n)r.has(t)||i.push(r.add(t))}),[i.map(o).join(n)].concat(t.map(function(t){return i.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(a).join("\n")},e},va.csv=va.dsv(",","text/csv"),va.tsv=va.dsv(" ","text/tab-separated-values");var oo,co,lo,fo;va.timer=function(n,t,e){if(arguments.length<3){if(arguments.length<2)t=0;else if(!isFinite(t))return;e=Date.now()}var r=e+t,i={callback:n,time:r,next:null};co?co.next=i:oo=i,co=i,lo||(fo=clearTimeout(fo),lo=1,so(dt))},va.timer.flush=function(){mt(),vt()};var so=xa[m(xa,"requestAnimationFrame")]||function(n){setTimeout(n,17)},ho=".",go=",",po=[3,3],mo=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(yt);va.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=va.round(n,Mt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,Math.floor((0>=e?e+1:e-1)/3)*3))),mo[8+e/3]},va.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)},va.format=function(n){var t=vo.exec(n),e=t[1]||" ",r=t[2]||">",i=t[3]||"",u=t[4]||"",a=t[5],o=+t[6],c=t[7],l=t[8],f=t[9],s=1,h="",g=!1;switch(l&&(l=+l.substring(1)),(a||"0"===e&&"="===r)&&(a=e="0",r="=",c&&(o-=Math.floor((o-1)/4))),f){case"n":c=!0,f="g";break;case"%":s=100,h="%",f="f";break;case"p":s=100,h="%",f="r";break;case"b":case"o":case"x":case"X":u&&(u="0"+f.toLowerCase());case"c":case"d":g=!0,l=0;break;case"s":s=-1,f="r"}"#"===u&&(u=""),"r"!=f||l||(f="g"),null!=l&&("g"==f?l=Math.max(1,Math.min(21,l)):("e"==f||"f"==f)&&(l=Math.max(0,Math.min(20,l)))),f=yo.get(f)||xt;var p=a&&c;return function(n){if(g&&n%1)return"";var t=0>n||0===n&&0>1/n?(n=-n,"-"):i;if(0>s){var d=va.formatPrefix(n,l);n=d.scale(n),h=d.symbol}else n*=s;n=f(n,l),!a&&c&&(n=Mo(n));var m=u.length+n.length+(p?0:t.length),v=o>m?Array(m=o-m+1).join(e):"";return p&&(n=Mo(v+n)),ho&&n.replace(".",ho),t+=u,("<"===r?t+n+v:">"===r?v+t+n:"^"===r?v.substring(0,m>>=1)+t+n+v.substring(m):t+(p?n:v+n))+h}};var vo=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,yo=va.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=va.round(n,Mt(n,t))).toFixed(Math.max(0,Math.min(20,Mt(n*(1+1e-15),t))))}}),Mo=st;if(po){var xo=po.length;Mo=function(n){for(var t=n.lastIndexOf("."),e=t>=0?"."+n.substring(t+1):(t=n.length,""),r=[],i=0,u=po[0];t>0&&u>0;)r.push(n.substring(t-=u,t+u)),u=po[i=(i+1)%xo];return r.reverse().join(go||"")+e}}va.geo={},bt.prototype={s:0,t:0,add:function(n){_t(n,this.t,bo),_t(bo.s,this.s,this),this.s?this.t+=bo.t:this.s=bo.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var bo=new bt;va.geo.stream=function(n,t){n&&_o.hasOwnProperty(n.type)?_o[n.type](n,t):wt(n,t)};var _o={Feature:function(n,t){wt(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++rn?4*$a+n:n,ko.lineStart=ko.lineEnd=ko.point=T}};va.geo.bounds=function(){function n(n,t){M.push(x=[f=n,h=n]),s>t&&(s=t),t>g&&(g=t)}function t(t,e){var r=At([t*Ga,e*Ga]);if(v){var i=qt(v,r),u=[i[1],-i[0],0],a=qt(u,i);zt(a),a=Dt(a);var c=t-p,l=c>0?1:-1,d=a[0]*Ka*l,m=Math.abs(c)>180;if(m^(d>l*p&&l*t>d)){var y=a[1]*Ka;y>g&&(g=y)}else if(d=(d+360)%360-180,m^(d>l*p&&l*t>d)){var y=-a[1]*Ka;s>y&&(s=y)}else s>e&&(s=e),e>g&&(g=e);m?p>t?o(f,t)>o(f,h)&&(h=t):o(t,h)>o(f,h)&&(f=t):h>=f?(f>t&&(f=t),t>h&&(h=t)):t>p?o(f,t)>o(f,h)&&(h=t):o(t,h)>o(f,h)&&(f=t)}else n(t,e);v=r,p=t}function e(){b.point=t}function r(){x[0]=f,x[1]=h,b.point=n,v=null}function i(n,e){if(v){var r=n-p;y+=Math.abs(r)>180?r+(r>0?360:-360):r}else d=n,m=e;ko.point(n,e),t(n,e)}function u(){ko.lineStart()}function a(){i(d,m),ko.lineEnd(),Math.abs(y)>Wa&&(f=-(h=180)),x[0]=f,x[1]=h,v=null}function o(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nEo?(f=-(h=180),s=-(g=90)):y>Wa?g=90:-Wa>y&&(s=-90),x[0]=f,x[1]=h}};return function(n){g=h=-(f=s=1/0),M=[],va.geo.stream(n,b);var t=M.length;if(t){M.sort(c);for(var e,r=1,i=M[0],u=[i];t>r;++r)e=M[r],l(e[0],i)||l(e[1],i)?(o(i[0],e[1])>o(i[0],i[1])&&(i[1]=e[1]),o(e[0],i[1])>o(i[0],i[1])&&(i[0]=e[0])):u.push(i=e);for(var a,e,p=-1/0,t=u.length-1,r=0,i=u[t];t>=r;i=e,++r)e=u[r],(a=o(i[1],e[0]))>p&&(p=a,f=e[0],h=i[1])}return M=x=null,1/0===f||1/0===s?[[0/0,0/0],[0/0,0/0]]:[[f,s],[h,g]]}}(),va.geo.centroid=function(n){Ao=No=qo=To=Co=zo=Do=jo=Lo=Ho=Fo=0,va.geo.stream(n,Po);var t=Lo,e=Ho,r=Fo,i=t*t+e*e+r*r;return Ja>i&&(t=zo,e=Do,r=jo,Wa>No&&(t=qo,e=To,r=Co),i=t*t+e*e+r*r,Ja>i)?[0/0,0/0]:[Math.atan2(e,t)*Ka,U(r/Math.sqrt(i))*Ka]};var Ao,No,qo,To,Co,zo,Do,jo,Lo,Ho,Fo,Po={sphere:T,point:Lt,lineStart:Ft,lineEnd:Pt,polygonStart:function(){Po.lineStart=Ot},polygonEnd:function(){Po.lineStart=Ft}},Oo=It(Rt,$t,Jt,Gt),Ro=[-$a,0],Yo=1e9;(va.geo.conicEqualArea=function(){return ee(re)}).raw=re,va.geo.albers=function(){return va.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},va.geo.albersUsa=function(){function n(n){var u=n[0],a=n[1];return t=null,e(u,a),t||(r(u,a),t)||i(u,a),t}var t,e,r,i,u=va.geo.albers(),a=va.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),o=va.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=u.scale(),e=u.translate(),r=(n[0]-e[0])/t,i=(n[1]-e[1])/t;return(i>=.12&&.234>i&&r>=-.425&&-.214>r?a:i>=.166&&.234>i&&r>=-.214&&-.115>r?o:u).invert(n)},n.stream=function(n){var t=u.stream(n),e=a.stream(n),r=o.stream(n);return{point:function(n,i){t.point(n,i),e.point(n,i),r.point(n,i)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(u.precision(t),a.precision(t),o.precision(t),n):u.precision()},n.scale=function(t){return arguments.length?(u.scale(t),a.scale(.35*t),o.scale(t),n.translate(u.translate())):u.scale()},n.translate=function(t){if(!arguments.length)return u.translate();var l=u.scale(),f=+t[0],s=+t[1];return e=u.translate(t).clipExtent([[f-.455*l,s-.238*l],[f+.455*l,s+.238*l]]).stream(c).point,r=a.translate([f-.307*l,s+.201*l]).clipExtent([[f-.425*l+Wa,s+.12*l+Wa],[f-.214*l-Wa,s+.234*l-Wa]]).stream(c).point,i=o.translate([f-.205*l,s+.212*l]).clipExtent([[f-.214*l+Wa,s+.166*l+Wa],[f-.115*l-Wa,s+.234*l-Wa]]).stream(c).point,n},n.scale(1070)};var Uo,Io,Vo,Xo,Zo,Bo,$o={point:T,lineStart:T,lineEnd:T,polygonStart:function(){Io=0,$o.lineStart=ie},polygonEnd:function(){$o.lineStart=$o.lineEnd=$o.point=T,Uo+=Math.abs(Io/2)}},Wo={point:ue,lineStart:T,lineEnd:T,polygonStart:T,polygonEnd:T},Jo={point:ce,lineStart:le,lineEnd:fe,polygonStart:function(){Jo.lineStart=se},polygonEnd:function(){Jo.point=ce,Jo.lineStart=le,Jo.lineEnd=fe}};va.geo.path=function(){function n(n){return n&&("function"==typeof o&&u.pointRadius(+o.apply(this,arguments)),a&&a.valid||(a=i(u)),va.geo.stream(n,a)),u.result()}function t(){return a=null,n}var e,r,i,u,a,o=4.5;return n.area=function(n){return Uo=0,va.geo.stream(n,i($o)),Uo},n.centroid=function(n){return qo=To=Co=zo=Do=jo=Lo=Ho=Fo=0,va.geo.stream(n,i(Jo)),Fo?[Lo/Fo,Ho/Fo]:jo?[zo/jo,Do/jo]:Co?[qo/Co,To/Co]:[0/0,0/0]},n.bounds=function(n){return Zo=Bo=-(Vo=Xo=1/0),va.geo.stream(n,i(Wo)),[[Vo,Xo],[Zo,Bo]]},n.projection=function(n){return arguments.length?(i=(e=n)?n.stream||pe(n):st,t()):e},n.context=function(n){return arguments.length?(u=(r=n)==null?new ae:new he(n),"function"!=typeof o&&u.pointRadius(o),t()):r},n.pointRadius=function(t){return arguments.length?(o="function"==typeof t?t:(u.pointRadius(+t),+t),n):o},n.projection(va.geo.albersUsa()).context(null)},va.geo.projection=de,va.geo.projectionMutator=me,(va.geo.equirectangular=function(){return de(ye)}).raw=ye.invert=ye,va.geo.rotation=function(n){function t(t){return t=n(t[0]*Ga,t[1]*Ga),t[0]*=Ka,t[1]*=Ka,t}return n=Me(n[0]%360*Ga,n[1]*Ga,n.length>2?n[2]*Ga:0),t.invert=function(t){return t=n.invert(t[0]*Ga,t[1]*Ga),t[0]*=Ka,t[1]*=Ka,t},t},va.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=Me(-n[0]*Ga,-n[1]*Ga,0).invert,i=[];return e(null,null,1,{point:function(n,e){i.push(n=t(n,e)),n[0]*=Ka,n[1]*=Ka}}),{type:"Polygon",coordinates:[i]}}var t,e,r=[0,0],i=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=we((t=+r)*Ga,i*Ga),n):t},n.precision=function(r){return arguments.length?(e=we(t*Ga,(i=+r)*Ga),n):i},n.angle(90)},va.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Ga,i=n[1]*Ga,u=t[1]*Ga,a=Math.sin(r),o=Math.cos(r),c=Math.sin(i),l=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*a)*e+(e=l*f-c*s*o)*e),c*f+l*s*o)},va.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return va.range(Math.ceil(u/m)*m,i,m).map(h).concat(va.range(Math.ceil(l/v)*v,c,v).map(g)).concat(va.range(Math.ceil(r/p)*p,e,p).filter(function(n){return Math.abs(n%m)>Wa}).map(f)).concat(va.range(Math.ceil(o/d)*d,a,d).filter(function(n){return Math.abs(n%v)>Wa}).map(s))}var e,r,i,u,a,o,c,l,f,s,h,g,p=10,d=p,m=90,v=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(g(c).slice(1),h(i).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(u=+t[0][0],i=+t[1][0],l=+t[0][1],c=+t[1][1],u>i&&(t=u,u=i,i=t),l>c&&(t=l,l=c,c=t),n.precision(y)):[[u,l],[i,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],o=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),o>a&&(t=o,o=a,a=t),n.precision(y)):[[r,o],[e,a]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(m=+t[0],v=+t[1],n):[m,v]},n.minorStep=function(t){return arguments.length?(p=+t[0],d=+t[1],n):[p,d]},n.precision=function(t){return arguments.length?(y=+t,f=Ee(o,a,90),s=ke(r,e,y),h=Ee(l,c,90),g=ke(u,i,y),n):y},n.majorExtent([[-180,-90+Wa],[180,90-Wa]]).minorExtent([[-180,-80-Wa],[180,80+Wa]])},va.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||i.apply(this,arguments)]}}var t,e,r=Ae,i=Ne;return n.distance=function(){return va.geo.distance(t||r.apply(this,arguments),e||i.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,n):i},n.precision=function(){return arguments.length?n:0},n},va.geo.interpolate=function(n,t){return qe(n[0]*Ga,n[1]*Ga,t[0]*Ga,t[1]*Ga)},va.geo.length=function(n){return Go=0,va.geo.stream(n,Ko),Go};var Go,Ko={sphere:T,point:T,lineStart:Te,lineEnd:T,polygonStart:T,polygonEnd:T},Qo=Ce(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(va.geo.azimuthalEqualArea=function(){return de(Qo)}).raw=Qo;var nc=Ce(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},st);(va.geo.azimuthalEquidistant=function(){return de(nc)}).raw=nc,(va.geo.conicConformal=function(){return ee(ze)}).raw=ze,(va.geo.conicEquidistant=function(){return ee(De)}).raw=De;var tc=Ce(function(n){return 1/n},Math.atan);(va.geo.gnomonic=function(){return de(tc)}).raw=tc,je.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-$a/2]},(va.geo.mercator=function(){return Le(je)}).raw=je;var ec=Ce(function(){return 1},Math.asin);(va.geo.orthographic=function(){return de(ec)}).raw=ec;var rc=Ce(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(va.geo.stereographic=function(){return de(rc)}).raw=rc,He.invert=function(n,t){return[Math.atan2(I(n),Math.cos(t)),U(Math.sin(t)/V(n))]},(va.geo.transverseMercator=function(){return Le(He)}).raw=He,va.geom={},va.svg={},va.svg.line=function(){return Fe(st)};var ic=va.map({linear:Re,"linear-closed":Ye,step:Ue,"step-before":Ie,"step-after":Ve,basis:Je,"basis-open":Ge,"basis-closed":Ke,bundle:Qe,cardinal:Be,"cardinal-open":Xe,"cardinal-closed":Ze,monotone:ur}); +ic.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var uc=[0,2/3,1/3,0],ac=[0,1/3,2/3,0],oc=[0,1/6,2/3,1/6];va.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,i,u,a,o,c,l,f,s,h,g,p,d=ft(e),m=ft(r),v=n.length,y=v-1,M=[],x=[],b=0;if(d===Pe&&r===Oe)t=n;else for(u=0,t=[];v>u;++u)t.push([+d.call(this,i=n[u],u),+m.call(this,i,u)]);for(u=1;v>u;++u)(t[u][1]u;++u)u!==b&&(c=t[u][1]-t[b][1],o=t[u][0]-t[b][0],M.push({angle:Math.atan2(c,o),index:u}));for(M.sort(function(n,t){return n.angle-t.angle}),g=M[0].angle,h=M[0].index,s=0,u=1;y>u;++u){if(a=M[u].index,g==M[u].angle){if(o=t[h][0]-t[b][0],c=t[h][1]-t[b][1],l=t[a][0]-t[b][0],f=t[a][1]-t[b][1],o*o+c*c>=l*l+f*f){M[u].index=-1;continue}M[s].index=-1}g=M[u].angle,s=u,h=a}for(x.push(b),u=0,a=0;2>u;++a)M[a].index>-1&&(x.push(M[a].index),u++);for(p=x.length;y>a;++a)if(!(M[a].index<0)){for(;!ar(x[p-2],x[p-1],M[a].index,t);)--p;x[p++]=M[a].index}var _=[];for(u=p-1;u>=0;--u)_.push(n[x[u]]);return _}var e=Pe,r=Oe;return arguments.length?t(n):(t.x=function(n){return arguments.length?(e=n,t):e},t.y=function(n){return arguments.length?(r=n,t):r},t)},va.geom.polygon=function(n){return n.area=function(){for(var t=0,e=n.length,r=n[e-1][1]*n[0][0]-n[e-1][0]*n[0][1];++to;o++)e.push([i,t[o],t[o+1]])}),e},va.geom.voronoi=function(n){function t(n){var t,u,a,o=n.map(function(){return[]}),c=ft(e),l=ft(r),f=n.length,s=1e6;if(c===Pe&&l===Oe)t=n;else for(t=Array(f),a=0;f>a;++a)t[a]=[+c.call(this,u=n[a],a),+l.call(this,u,a)];if(lr(t,function(n){var t,e,r,i,u,a;n.a===1&&n.b>=0?(t=n.ep.r,e=n.ep.l):(t=n.ep.l,e=n.ep.r),n.a===1?(u=t?t.y:-s,r=n.c-n.b*u,a=e?e.y:s,i=n.c-n.b*a):(r=t?t.x:-s,u=n.c-n.a*r,i=e?e.x:s,a=n.c-n.a*i);var c=[r,u],l=[i,a];o[n.region.l.index].push(c,l),o[n.region.r.index].push(c,l)}),o=o.map(function(n,e){var r=t[e][0],i=t[e][1],u=n.map(function(n){return Math.atan2(n[0]-r,n[1]-i)}),a=va.range(n.length).sort(function(n,t){return u[n]-u[t]});return a.filter(function(n,t){return!t||u[n]-u[a[t-1]]>Wa}).map(function(t){return n[t]})}),o.forEach(function(n,e){var r=n.length;if(!r)return n.push([-s,-s],[-s,s],[s,s],[s,-s]);if(!(r>2)){var i=t[e],u=n[0],a=n[1],o=i[0],c=i[1],l=u[0],f=u[1],h=a[0],g=a[1],p=Math.abs(h-l),d=g-f;if(Math.abs(d)c?-s:s;n.push([-s,m],[s,m])}else if(Wa>p){var v=l>o?-s:s;n.push([v,-s],[v,s])}else{var m=(l-o)*(g-f)>(h-l)*(f-c)?s:-s,y=Math.abs(d)-p;Math.abs(y)d?m:-m,m]):(y>0&&(m*=-1),n.push([-s,m],[s,m]))}}}),i)for(a=0;f>a;++a)i.clip(o[a]);for(a=0;f>a;++a)o[a].point=n[a];return o}var e=Pe,r=Oe,i=null;return arguments.length?t(n):(t.x=function(n){return arguments.length?(e=n,t):e},t.y=function(n){return arguments.length?(r=n,t):r},t.clipExtent=function(n){if(!arguments.length)return i&&[i[0],i[2]];if(null==n)i=null;else{var e=+n[0][0],r=+n[0][1],u=+n[1][0],a=+n[1][1];i=va.geom.polygon([[e,r],[e,a],[u,a],[u,r]])}return t},t.size=function(n){return arguments.length?t.clipExtent(n&&[[0,0],n]):i&&i[2]},t.links=function(n){var t,i,u,a=n.map(function(){return[]}),o=[],c=ft(e),l=ft(r),f=n.length;if(c===Pe&&l===Oe)t=n;else for(t=Array(f),u=0;f>u;++u)t[u]=[+c.call(this,i=n[u],u),+l.call(this,i,u)];return lr(t,function(t){var e=t.region.l.index,r=t.region.r.index;a[e][r]||(a[e][r]=a[r][e]=!0,o.push({source:n[e],target:n[r]}))}),o},t.triangles=function(n){if(e===Pe&&r===Oe)return va.geom.delaunay(n);for(var t,i=Array(c),u=ft(e),a=ft(r),o=-1,c=n.length;++o=l,h=r>=f,g=(h<<1)+s;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=hr()),s?i=l:o=l,h?a=f:c=f,u(n,t,e,r,i,a,o,c)}var f,s,h,g,p,d,m,v,y,M=ft(o),x=ft(c);if(null!=t)d=t,m=e,v=r,y=i;else if(v=y=-(d=m=1/0),s=[],h=[],p=n.length,a)for(g=0;p>g;++g)f=n[g],f.xv&&(v=f.x),f.y>y&&(y=f.y),s.push(f.x),h.push(f.y);else for(g=0;p>g;++g){var b=+M(f=n[g],g),_=+x(f,g);d>b&&(d=b),m>_&&(m=_),b>v&&(v=b),_>y&&(y=_),s.push(b),h.push(_)}var w=v-d,S=y-m;w>S?y=m+w:v=d+S;var E=hr();if(E.add=function(n){u(E,n,+M(n,++g),+x(n,g),d,m,v,y)},E.visit=function(n){gr(n,E,d,m,v,y)},g=-1,null==t){for(;++g=0?n.substring(0,t):n,r=t>=0?n.substring(t+1):"in";return e=hc.get(e)||sc,r=gc.get(r)||st,kr(r(e.apply(null,Array.prototype.slice.call(arguments,1))))},va.interpolateHcl=Or,va.interpolateHsl=Rr,va.interpolateLab=Yr,va.interpolateRound=Ur,va.layout={},va.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++e(i-e)*o){var c=t.charge*o*o;return n.px-=u*c,n.py-=a*c,!0}if(t.point&&isFinite(o)){var c=t.pointCharge*o*o;n.px-=u*c,n.py-=a*c}}return!t.charge}}function t(n){n.px=va.event.x,n.py=va.event.y,o.resume()}var e,r,i,u,a,o={},c=va.dispatch("start","tick","end"),l=[1,1],f=.9,s=pc,h=dc,g=-30,p=.1,d=.8,m=[],v=[];return o.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,o,s,h,d,y,M,x,b=m.length,_=v.length;for(e=0;_>e;++e)o=v[e],s=o.source,h=o.target,M=h.x-s.x,x=h.y-s.y,(d=M*M+x*x)&&(d=r*u[e]*((d=Math.sqrt(d))-i[e])/d,M*=d,x*=d,h.x-=M*(y=s.weight/(h.weight+s.weight)),h.y-=x*y,s.x+=M*(y=1-y),s.y+=x*y);if((y=r*p)&&(M=l[0]/2,x=l[1]/2,e=-1,y))for(;++e0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),va.timer(o.tick)),o):r},o.start=function(){function n(n,r){for(var i,u=t(e),a=-1,o=u.length;++ar;++r)c[r]=[];for(r=0;d>r;++r){var n=v[r];c[n.source.index].push(n.target),c[n.target.index].push(n.source)}}return c[e]}var e,r,c,f,p=m.length,d=v.length,y=l[0],M=l[1];for(e=0;p>e;++e)(f=m[e]).index=e,f.weight=0;for(e=0;d>e;++e)f=v[e],typeof f.source=="number"&&(f.source=m[f.source]),typeof f.target=="number"&&(f.target=m[f.target]),++f.source.weight,++f.target.weight;for(e=0;p>e;++e)f=m[e],isNaN(f.x)&&(f.x=n("x",y)),isNaN(f.y)&&(f.y=n("y",M)),isNaN(f.px)&&(f.px=f.x),isNaN(f.py)&&(f.py=f.y);if(i=[],"function"==typeof s)for(e=0;d>e;++e)i[e]=+s.call(this,v[e],e);else for(e=0;d>e;++e)i[e]=s;if(u=[],"function"==typeof h)for(e=0;d>e;++e)u[e]=+h.call(this,v[e],e);else for(e=0;d>e;++e)u[e]=h;if(a=[],"function"==typeof g)for(e=0;p>e;++e)a[e]=+g.call(this,m[e],e);else for(e=0;p>e;++e)a[e]=g;return o.resume()},o.resume=function(){return o.alpha(.1)},o.stop=function(){return o.alpha(0)},o.drag=function(){return e||(e=va.behavior.drag().origin(st).on("dragstart.force",$r).on("drag.force",t).on("dragend.force",Wr)),arguments.length?(this.on("mouseover.force",Jr).on("mouseout.force",Gr).call(e),void 0):e},va.rebind(o,c,"on")};var pc=20,dc=1;va.layout.hierarchy=function(){function n(t,a,o){var c=i.call(e,t,a);if(t.depth=a,o.push(t),c&&(l=c.length)){for(var l,f,s=-1,h=t.children=[],g=0,p=a+1;++sg;++g)for(i.call(n,l[0][g],p=d[g],f[0][g][1]),h=1;m>h;++h)i.call(n,l[h][g],p+=f[h-1][g][1],f[h][g][1]);return o}var t=st,e=oi,r=ci,i=ai,u=ii,a=ui;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:vc.get(t)||oi,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:yc.get(t)||ci,n):r},n.x=function(t){return arguments.length?(u=t,n):u},n.y=function(t){return arguments.length?(a=t,n):a},n.out=function(t){return arguments.length?(i=t,n):i},n};var vc=va.map({"inside-out":function(n){var t,e,r=n.length,i=n.map(li),u=n.map(fi),a=va.range(r).sort(function(n,t){return i[n]-i[t]}),o=0,c=0,l=[],f=[];for(t=0;r>t;++t)e=a[t],c>o?(o+=u[e],l.push(e)):(c+=u[e],f.push(e));return f.reverse().concat(l)},reverse:function(n){return va.range(n.length).reverse()},"default":oi}),yc=va.map({silhouette:function(n){var t,e,r,i=n.length,u=n[0].length,a=[],o=0,c=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];r>o&&(o=r),a.push(r)}for(e=0;u>e;++e)c[e]=(o-a[e])/2;return c},wiggle:function(n){var t,e,r,i,u,a,o,c,l,f=n.length,s=n[0],h=s.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,i=0;f>t;++t)i+=n[t][e][1];for(t=0,u=0,o=s[e][0]-s[e-1][0];f>t;++t){for(r=0,a=(n[t][e][1]-n[t][e-1][1])/(2*o);t>r;++r)a+=(n[r][e][1]-n[r][e-1][1])/o;u+=a*n[t][e][1]}g[e]=c-=i?u/i*o:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,i=n.length,u=n[0].length,a=1/i,o=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];if(r)for(t=0;i>t;t++)n[t][e][1]/=r;else for(t=0;i>t;t++)n[t][e][1]=a}for(e=0;u>e;++e)o[e]=0;return o},zero:ci});va.layout.histogram=function(){function n(n,u){for(var a,o,c=[],l=n.map(e,this),f=r.call(this,l,u),s=i.call(this,f,l,u),u=-1,h=l.length,g=s.length-1,p=t?1:1/h;++u0)for(u=-1;++u=f[0]&&o<=f[1]&&(a=c[va.bisect(s,o,1,g)-1],a.y+=p,a.push(n[u]));return c}var t=!0,e=Number,r=pi,i=hi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=ft(t),n):r},n.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return gi(n,t)}:ft(t),n):i},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},va.layout.tree=function(){function n(n,u){function a(n,t){var r=n.children,i=n._tree;if(r&&(u=r.length)){for(var u,o,l,f=r[0],s=f,h=-1;++h0&&(Si(Ei(o,n,r),n,i),l+=i,f+=i),s+=o._tree.mod,l+=u._tree.mod,h+=c._tree.mod,f+=a._tree.mod;o&&!vi(a)&&(a._tree.thread=o,a._tree.mod+=s-f),u&&!mi(c)&&(c._tree.thread=u,c._tree.mod+=l-h,r=n)}return r}var l=t.call(this,n,u),f=l[0];_i(f,function(n,t){n._tree={ancestor:n,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),a(f),o(f,-f._tree.prelim);var s=yi(f,xi),h=yi(f,Mi),g=yi(f,bi),p=s.x-e(s,h)/2,d=h.x+e(h,s)/2,m=g.depth||1;return _i(f,i?function(n){n.x*=r[0],n.y=n.depth*r[1],delete n._tree}:function(n){n.x=(n.x-p)/(d-p)*r[0],n.y=n.depth/m*r[1],delete n._tree}),l}var t=va.layout.hierarchy().sort(null).value(null),e=di,r=[1,1],i=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(i=(r=t)==null,n):i?null:r},n.nodeSize=function(t){return arguments.length?(i=(r=t)!=null,n):i?r:null},Qr(n,t)},va.layout.pack=function(){function n(n,u){var a=e.call(this,n,u),o=a[0],c=i[0],l=i[1],f=t||Math.sqrt;if(o.x=o.y=0,_i(o,function(n){n.r=f(n.value)}),_i(o,Ti),r){var s=r*(t?1:Math.max(2*o.r/c,2*o.r/l))/2;_i(o,function(n){n.r+=s}),_i(o,Ti),_i(o,function(n){n.r-=s})}return Di(o,c/2,l/2,t?1:1/Math.max(2*o.r/c,2*o.r/l)),a}var t,e=va.layout.hierarchy().sort(ki),r=0,i=[1,1];return n.size=function(t){return arguments.length?(i=t,n):i},n.radius=function(e){return arguments.length?(t=e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Qr(n,e)},va.layout.cluster=function(){function n(n,u){var a,o=t.call(this,n,u),c=o[0],l=0;_i(c,function(n){var t=n.children;t&&t.length?(n.x=Hi(t),n.y=Li(t)):(n.x=a?l+=e(n,a):0,n.y=0,a=n)});var f=Fi(c),s=Pi(c),h=f.x-e(f,s)/2,g=s.x+e(s,f)/2;return _i(c,i?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),o}var t=va.layout.hierarchy().sort(null).value(null),e=di,r=[1,1],i=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(i=(r=t)==null,n):i?null:r},n.nodeSize=function(t){return arguments.length?(i=(r=t)!=null,n):i?r:null},Qr(n,t)},va.layout.treemap=function(){function n(n,t){for(var e,r,i=-1,u=n.length;++it?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var u=e.children;if(u&&u.length){var a,o,c,l=s(e),f=[],h=u.slice(),p=1/0,d="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?e.depth&1?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),f.area=0;(c=h.length)>0;)f.push(a=h[c-1]),f.area+=a.area,"squarify"!==g||(o=r(f,d))<=p?(h.pop(),p=o):(f.area-=f.pop().area,i(f,d,l,!1),d=Math.min(l.dx,l.dy),f.length=f.area=0,p=1/0);f.length&&(i(f,d,l,!0),f.length=f.area=0),u.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var u,a=s(t),o=r.slice(),c=[];for(n(o,a.dx*a.dy/t.value),c.area=0;u=o.pop();)c.push(u),c.area+=u.area,u.z!=null&&(i(c,u.z?a.dx:a.dy,a,!o.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,i=0,u=1/0,a=-1,o=n.length;++ae&&(u=e),e>i&&(i=e));return r*=r,t*=t,r?Math.max(t*i*p/r,r/(t*u*p)):1/0}function i(n,t,e,r){var i,u=-1,a=n.length,o=e.x,l=e.y,f=t?c(n.area/t):0;if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ue.dx)&&(f=e.dx);++ue&&(t=1),1>e&&(n=0),function(){var e,r,i;do e=Math.random()*2-1,r=Math.random()*2-1,i=e*e+r*r;while(!i||i>1);return n+t*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=va.random.normal.apply(va,arguments);return function(){return Math.exp(n())}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t/n}}},va.scale={};var Mc={floor:st,ceil:st};va.scale.linear=function(){return Bi([0,1],[0,1],wr,!1)},va.scale.log=function(){return nu(va.scale.linear().domain([0,Math.LN10]),10,tu,eu,[1,10])};var xc=va.format(".0e");va.scale.pow=function(){return uu(va.scale.linear(),1,[0,1])},va.scale.sqrt=function(){return va.scale.pow().exponent(.5)},va.scale.ordinal=function(){return ou([],{t:"range",a:[[]]})},va.scale.category10=function(){return va.scale.ordinal().range(bc)},va.scale.category20=function(){return va.scale.ordinal().range(_c)},va.scale.category20b=function(){return va.scale.ordinal().range(wc)},va.scale.category20c=function(){return va.scale.ordinal().range(Sc)};var bc=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],_c=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],wc=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Sc=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];va.scale.quantile=function(){return cu([],[])},va.scale.quantize=function(){return lu(0,1,[0,1])},va.scale.threshold=function(){return fu([.5],[0,1])},va.scale.identity=function(){return su([0,1])},va.svg.arc=function(){function n(){var n=t.apply(this,arguments),u=e.apply(this,arguments),a=r.apply(this,arguments)+Ec,o=i.apply(this,arguments)+Ec,c=(a>o&&(c=a,a=o,o=c),o-a),l=$a>c?"0":"1",f=Math.cos(a),s=Math.sin(a),h=Math.cos(o),g=Math.sin(o);return c>=kc?n?"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"M0,"+n+"A"+n+","+n+" 0 1,0 0,"+-n+"A"+n+","+n+" 0 1,0 0,"+n+"Z":"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"Z":n?"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L"+n*h+","+n*g+"A"+n+","+n+" 0 "+l+",0 "+n*f+","+n*s+"Z":"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L0,0"+"Z"}var t=hu,e=gu,r=pu,i=du;return n.innerRadius=function(e){return arguments.length?(t=ft(e),n):t},n.outerRadius=function(t){return arguments.length?(e=ft(t),n):e},n.startAngle=function(t){return arguments.length?(r=ft(t),n):r},n.endAngle=function(t){return arguments.length?(i=ft(t),n):i},n.centroid=function(){var n=(t.apply(this,arguments)+e.apply(this,arguments))/2,u=(r.apply(this,arguments)+i.apply(this,arguments))/2+Ec;return[Math.cos(u)*n,Math.sin(u)*n]},n};var Ec=-$a/2,kc=2*$a-1e-6;va.svg.line.radial=function(){var n=Fe(mu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},Ie.reverse=Ve,Ve.reverse=Ie,va.svg.area=function(){return vu(st)},va.svg.area.radial=function(){var n=vu(mu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},va.svg.chord=function(){function n(n,o){var c=t(this,u,n,o),l=t(this,a,n,o);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?i(c.r,c.p1,c.r,c.p0):i(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+i(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var i=t.call(n,e,r),u=o.call(n,i,r),a=c.call(n,i,r)+Ec,f=l.call(n,i,r)+Ec;return{r:u,a0:a,a1:f,p0:[u*Math.cos(a),u*Math.sin(a)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>$a)+",1 "+t}function i(n,t,e,r){return"Q 0,0 "+r}var u=Ae,a=Ne,o=yu,c=pu,l=du;return n.radius=function(t){return arguments.length?(o=ft(t),n):o},n.source=function(t){return arguments.length?(u=ft(t),n):u},n.target=function(t){return arguments.length?(a=ft(t),n):a},n.startAngle=function(t){return arguments.length?(c=ft(t),n):c},n.endAngle=function(t){return arguments.length?(l=ft(t),n):l},n},va.svg.diagonal=function(){function n(n,i){var u=t.call(this,n,i),a=e.call(this,n,i),o=(u.y+a.y)/2,c=[u,{x:u.x,y:o},{x:a.x,y:o},a];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=Ae,e=Ne,r=Mu;return n.source=function(e){return arguments.length?(t=ft(e),n):t},n.target=function(t){return arguments.length?(e=ft(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},va.svg.diagonal.radial=function(){var n=va.svg.diagonal(),t=Mu,e=n.projection;return n.projection=function(n){return arguments.length?e(xu(t=n)):t},n},va.svg.symbol=function(){function n(n,r){return(Ac.get(t.call(this,n,r))||wu)(e.call(this,n,r))}var t=_u,e=bu;return n.type=function(e){return arguments.length?(t=ft(e),n):t},n.size=function(t){return arguments.length?(e=ft(t),n):e},n};var Ac=va.map({circle:wu,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Tc)),e=t*Tc;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/qc),e=t*qc/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/qc),e=t*qc/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});va.svg.symbolTypes=Ac.keys();var Nc,qc=Math.sqrt(3),Tc=Math.tan(30*Ga),Cc=[],zc=0,Dc={ease:Cr,delay:0,duration:250};Cc.call=Pa.call,Cc.empty=Pa.empty,Cc.node=Pa.node,va.transition=function(n){return arguments.length?Nc?n.transition():n:Ia.transition()},va.transition.prototype=Cc,Cc.select=function(n){var t,e,r,i=this.id,u=[];"function"!=typeof n&&(n=y(n));for(var a=-1,o=this.length;++au;u++){i.push(t=[]);for(var e=this[u],o=0,c=e.length;c>o;o++)(r=e[o])&&n.call(r,r.__data__,o)&&t.push(r)}return Su(i,this.id,this.time).ease(this.ease())},Cc.tween=function(n,t){var e=this.id;return arguments.length<2?this.node().__transition__[e].tween.get(n):j(this,null==t?function(t){t.__transition__[e].tween.remove(n)}:function(r){r.__transition__[e].tween.set(n,t)})},Cc.attr=function(n,t){function e(){this.removeAttribute(o)}function r(){this.removeAttributeNS(o.space,o.local)}function i(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(o);return e!==n&&(t=a(e,n),function(n){this.setAttribute(o,t(n))})})}function u(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(o.space,o.local);return e!==n&&(t=a(e,n),function(n){this.setAttributeNS(o.space,o.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var a=Sr(n),o=va.ns.qualify(n);return Eu(this,"attr."+n,t,o.local?u:i)},Cc.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(i));return r&&function(n){this.setAttribute(i,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(i.space,i.local));return r&&function(n){this.setAttributeNS(i.space,i.local,r(n))}}var i=va.ns.qualify(n);return this.tween("attr."+n,i.local?r:e)},Cc.style=function(n,t,e){function r(){this.style.removeProperty(n)}function i(t){return null==t?r:(t+="",function(){var r,i=xa.getComputedStyle(this,null).getPropertyValue(n);return i!==t&&(r=a(i,t),function(t){this.style.setProperty(n,r(t),e)})})}var u=arguments.length;if(3>u){if("string"!=typeof n){2>u&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}var a=Sr(n);return Eu(this,"style."+n,t,i)},Cc.styleTween=function(n,t,e){function r(r,i){var u=t.call(this,r,i,xa.getComputedStyle(this,null).getPropertyValue(n));return u&&function(t){this.style.setProperty(n,u(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},Cc.text=function(n){return Eu(this,"text",n,ku)},Cc.remove=function(){return this.each("end.transition",function(){var n;!this.__transition__&&(n=this.parentNode)&&n.removeChild(this)})},Cc.ease=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].ease:("function"!=typeof n&&(n=va.ease.apply(va,arguments)),j(this,function(e){e.__transition__[t].ease=n}))},Cc.delay=function(n){var t=this.id;return j(this,"function"==typeof n?function(e,r,i){e.__transition__[t].delay=n.call(e,e.__data__,r,i)|0}:(n|=0,function(e){e.__transition__[t].delay=n}))},Cc.duration=function(n){var t=this.id;return j(this,"function"==typeof n?function(e,r,i){e.__transition__[t].duration=Math.max(1,n.call(e,e.__data__,r,i)|0)}:(n=Math.max(1,0|n),function(e){e.__transition__[t].duration=n}))},Cc.each=function(n,t){var e=this.id;if(arguments.length<2){var r=Dc,i=Nc;Nc=e,j(this,function(t,r,i){Dc=t.__transition__[e],n.call(t,t.__data__,r,i)}),Dc=r,Nc=i}else j(this,function(r){r.__transition__[e].event.on(n,t)});return this},Cc.transition=function(){for(var n,t,e,r,i=this.id,u=++zc,a=[],o=0,c=this.length;c>o;o++){a.push(n=[]);for(var t=this[o],l=0,f=t.length;f>l;l++)(e=t[l])&&(r=Object.create(e.__transition__[i]),r.delay+=r.duration,Au(e,l,u,r)),n.push(e)}return Su(a,u)},va.svg.axis=function(){function n(n){n.each(function(){var n,s=va.select(this),h=null==l?e.ticks?e.ticks.apply(e,c):e.domain():l,g=null==t?e.tickFormat?e.tickFormat.apply(e,c):String:t,p=Tu(e,h,f),d=s.selectAll(".tick.minor").data(p,String),m=d.enter().insert("line",".tick").attr("class","tick minor").style("opacity",1e-6),v=va.transition(d.exit()).style("opacity",1e-6).remove(),y=va.transition(d).style("opacity",1),M=s.selectAll(".tick.major").data(h,String),x=M.enter().insert("g",".domain").attr("class","tick major").style("opacity",1e-6),b=va.transition(M.exit()).style("opacity",1e-6).remove(),_=va.transition(M).style("opacity",1),w=Ui(e),S=s.selectAll(".domain").data([0]),E=(S.enter().append("path").attr("class","domain"),va.transition(S)),k=e.copy(),A=this.__chart__||k;this.__chart__=k,x.append("line"),x.append("text"); +var N=x.select("line"),q=_.select("line"),T=M.select("text").text(g),C=x.select("text"),z=_.select("text");switch(r){case"bottom":n=Nu,m.attr("y2",u),y.attr("x2",0).attr("y2",u),N.attr("y2",i),C.attr("y",Math.max(i,0)+o),q.attr("x2",0).attr("y2",i),z.attr("x",0).attr("y",Math.max(i,0)+o),T.attr("dy",".71em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+a+"V0H"+w[1]+"V"+a);break;case"top":n=Nu,m.attr("y2",-u),y.attr("x2",0).attr("y2",-u),N.attr("y2",-i),C.attr("y",-(Math.max(i,0)+o)),q.attr("x2",0).attr("y2",-i),z.attr("x",0).attr("y",-(Math.max(i,0)+o)),T.attr("dy","0em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+-a+"V0H"+w[1]+"V"+-a);break;case"left":n=qu,m.attr("x2",-u),y.attr("x2",-u).attr("y2",0),N.attr("x2",-i),C.attr("x",-(Math.max(i,0)+o)),q.attr("x2",-i).attr("y2",0),z.attr("x",-(Math.max(i,0)+o)).attr("y",0),T.attr("dy",".32em").style("text-anchor","end"),E.attr("d","M"+-a+","+w[0]+"H0V"+w[1]+"H"+-a);break;case"right":n=qu,m.attr("x2",u),y.attr("x2",u).attr("y2",0),N.attr("x2",i),C.attr("x",Math.max(i,0)+o),q.attr("x2",i).attr("y2",0),z.attr("x",Math.max(i,0)+o).attr("y",0),T.attr("dy",".32em").style("text-anchor","start"),E.attr("d","M"+a+","+w[0]+"H0V"+w[1]+"H"+a)}if(e.ticks)x.call(n,A),_.call(n,k),b.call(n,k),m.call(n,A),y.call(n,k),v.call(n,k);else{var D=k.rangeBand()/2,j=function(n){return k(n)+D};x.call(n,j),_.call(n,j)}})}var t,e=va.scale.linear(),r=jc,i=6,u=6,a=6,o=3,c=[10],l=null,f=0;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Lc?t+"":jc,n):r},n.ticks=function(){return arguments.length?(c=arguments,n):c},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t,e){if(!arguments.length)return i;var r=arguments.length-1;return i=+t,u=r>1?+e:i,a=r>0?+arguments[r]:i,n},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(t){return arguments.length?(f=+t,n):f},n};var jc="bottom",Lc={top:1,right:1,bottom:1,left:1};va.svg.brush=function(){function n(u){u.each(function(){var u,a=va.select(this),l=a.selectAll(".background").data([0]),s=a.selectAll(".extent").data([0]),h=a.selectAll(".resize").data(f,String);a.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),l.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),s.enter().append("rect").attr("class","extent").style("cursor","move"),h.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Hc[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),h.style("display",n.empty()?"none":null),h.exit().remove(),o&&(u=Ui(o),l.attr("x",u[0]).attr("width",u[1]-u[0]),e(a)),c&&(u=Ui(c),l.attr("y",u[0]).attr("height",u[1]-u[0]),r(a)),t(a)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)][0]+","+s[+/^s/.test(n)][1]+")"})}function e(n){n.select(".extent").attr("x",s[0][0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1][0]-s[0][0])}function r(n){n.select(".extent").attr("y",s[0][1]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",s[1][1]-s[0][1])}function i(){function i(){var n=va.event.changedTouches;return n?va.touches(M,n)[0]:va.mouse(M)}function f(){va.event.keyCode==32&&(k||(v=null,A[0]-=s[1][0],A[1]-=s[1][1],k=2),l())}function h(){va.event.keyCode==32&&2==k&&(A[0]+=s[1][0],A[1]+=s[1][1],k=0,l())}function p(){var n=i(),u=!1;y&&(n[0]+=y[0],n[1]+=y[1]),k||(va.event.altKey?(v||(v=[(s[0][0]+s[1][0])/2,(s[0][1]+s[1][1])/2]),A[0]=s[+(n[0]l?(i=r,r=l):i=l),s[0][e]!==r||s[1][e]!==i?(u=null,s[0][e]=r,s[1][e]=i,!0):void 0}function m(){p(),_.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),va.select("body").style("cursor",null),N.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),b({type:"brushend"}),l()}var v,y,M=this,x=va.select(va.event.target),b=a.of(M,arguments),_=va.select(M),w=x.datum(),S=!/^(n|s)$/.test(w)&&o,E=!/^(e|w)$/.test(w)&&c,k=x.classed("extent"),A=i(),N=va.select(xa).on("mousemove.brush",p).on("mouseup.brush",m).on("touchmove.brush",p).on("touchend.brush",m).on("keydown.brush",f).on("keyup.brush",h);if(k)A[0]=s[0][0]-A[0],A[1]=s[0][1]-A[1];else if(w){var q=+/w$/.test(w),T=+/^n/.test(w);y=[s[1-q][0]-A[0],s[1-T][1]-A[1]],A[0]=s[q][0],A[1]=s[T][1]}else va.event.altKey&&(v=A.slice());_.style("pointer-events","none").selectAll(".resize").style("display",null),va.select("body").style("cursor",x.style("cursor")),b({type:"brushstart"}),p(),l()}var u,a=h(n,"brushstart","brush","brushend"),o=null,c=null,f=Fc[0],s=[[0,0],[0,0]],g=[!0,!0];return n.x=function(t){return arguments.length?(o=t,f=Fc[!o<<1|!c],n):o},n.y=function(t){return arguments.length?(c=t,f=Fc[!o<<1|!c],n):c},n.clamp=function(t){return arguments.length?(o&&c?g=[!!t[0],!!t[1]]:(o||c)&&(g[+!o]=!!t),n):o&&c?g:o||c?g[+!o]:null},n.extent=function(t){var e,r,i,a,l;return arguments.length?(u=[[0,0],[0,0]],o&&(e=t[0],r=t[1],c&&(e=e[0],r=r[0]),u[0][0]=e,u[1][0]=r,o.invert&&(e=o(e),r=o(r)),e>r&&(l=e,e=r,r=l),s[0][0]=0|e,s[1][0]=0|r),c&&(i=t[0],a=t[1],o&&(i=i[1],a=a[1]),u[0][1]=i,u[1][1]=a,c.invert&&(i=c(i),a=c(a)),i>a&&(l=i,i=a,a=l),s[0][1]=0|i,s[1][1]=0|a),n):(t=u||s,o&&(e=t[0][0],r=t[1][0],u||(e=s[0][0],r=s[1][0],o.invert&&(e=o.invert(e),r=o.invert(r)),e>r&&(l=e,e=r,r=l))),c&&(i=t[0][1],a=t[1][1],u||(i=s[0][1],a=s[1][1],c.invert&&(i=c.invert(i),a=c.invert(a)),i>a&&(l=i,i=a,a=l))),o&&c?[[e,i],[r,a]]:o?[e,r]:c&&[i,a])},n.clear=function(){return u=null,s[0][0]=s[0][1]=s[1][0]=s[1][1]=0,n},n.empty=function(){return o&&s[0][0]===s[1][0]||c&&s[0][1]===s[1][1]},va.rebind(n,a,"on")};var Hc={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Fc=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];va.time={};var Pc=Date,Oc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Cu.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Rc.setUTCDate.apply(this._,arguments)},setDay:function(){Rc.setUTCDay.apply(this._,arguments)},setFullYear:function(){Rc.setUTCFullYear.apply(this._,arguments)},setHours:function(){Rc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Rc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Rc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Rc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Rc.setUTCSeconds.apply(this._,arguments)},setTime:function(){Rc.setTime.apply(this._,arguments)}};var Rc=Date.prototype,Yc="%a %b %e %X %Y",Uc="%m/%d/%Y",Ic="%H:%M:%S",Vc=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Xc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Zc=["January","February","March","April","May","June","July","August","September","October","November","December"],Bc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];va.time.year=zu(function(n){return n=va.time.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),va.time.years=va.time.year.range,va.time.years.utc=va.time.year.utc.range,va.time.day=zu(function(n){var t=new Pc(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),va.time.days=va.time.day.range,va.time.days.utc=va.time.day.utc.range,va.time.dayOfYear=function(n){var t=va.time.year(n);return Math.floor((n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5)},Oc.forEach(function(n,t){n=n.toLowerCase(),t=7-t;var e=va.time[n]=zu(function(n){return(n=va.time.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+Math.floor(t)*7)},function(n){var e=va.time.year(n).getDay();return Math.floor((va.time.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});va.time[n+"s"]=e.range,va.time[n+"s"].utc=e.utc.range,va.time[n+"OfYear"]=function(n){var e=va.time.year(n).getDay();return Math.floor((va.time.dayOfYear(n)+(e+t)%7)/7)}}),va.time.week=va.time.sunday,va.time.weeks=va.time.sunday.range,va.time.weeks.utc=va.time.sunday.utc.range,va.time.weekOfYear=va.time.sundayOfYear,va.time.format=function(n){function t(t){for(var r,i,u,a=[],o=-1,c=0;++o=12?"PM":"AM"},S:function(n,t){return Fu(n.getSeconds(),t,2)},U:function(n,t){return Fu(va.time.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Fu(va.time.mondayOfYear(n),t,2)},x:va.time.format(Uc),X:va.time.format(Ic),y:function(n,t){return Fu(n.getFullYear()%100,t,2)},Y:function(n,t){return Fu(n.getFullYear()%1e4,t,4)},Z:ua,"%":function(){return"%"}},ul={a:Pu,A:Ou,b:Iu,B:Vu,c:Xu,d:Ku,e:Ku,H:na,I:na,j:Qu,L:ra,m:Gu,M:ta,p:ia,S:ea,U:Yu,w:Ru,W:Uu,x:Zu,X:Bu,y:Wu,Y:$u,"%":aa},al=/^\s*\d+/,ol=va.map({am:0,pm:1});va.time.format.utc=function(n){function t(n){try{Pc=Cu;var t=new Pc;return t._=n,e(t)}finally{Pc=Date}}var e=va.time.format(n);return t.parse=function(n){try{Pc=Cu;var t=e.parse(n);return t&&t._}finally{Pc=Date}},t.toString=e.toString,t};var cl=va.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");va.time.format.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?oa:cl,oa.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},oa.toString=cl.toString,va.time.second=zu(function(n){return new Pc(Math.floor(n/1e3)*1e3)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*1e3)},function(n){return n.getSeconds()}),va.time.seconds=va.time.second.range,va.time.seconds.utc=va.time.second.utc.range,va.time.minute=zu(function(n){return new Pc(Math.floor(n/6e4)*6e4)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*6e4)},function(n){return n.getMinutes()}),va.time.minutes=va.time.minute.range,va.time.minutes.utc=va.time.minute.utc.range,va.time.hour=zu(function(n){var t=n.getTimezoneOffset()/60;return new Pc((Math.floor(n/36e5-t)+t)*36e5)},function(n,t){n.setTime(n.getTime()+Math.floor(t)*36e5)},function(n){return n.getHours()}),va.time.hours=va.time.hour.range,va.time.hours.utc=va.time.hour.utc.range,va.time.month=zu(function(n){return n=va.time.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),va.time.months=va.time.month.range,va.time.months.utc=va.time.month.utc.range;var ll=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],fl=[[va.time.second,1],[va.time.second,5],[va.time.second,15],[va.time.second,30],[va.time.minute,1],[va.time.minute,5],[va.time.minute,15],[va.time.minute,30],[va.time.hour,1],[va.time.hour,3],[va.time.hour,6],[va.time.hour,12],[va.time.day,1],[va.time.day,2],[va.time.week,1],[va.time.month,1],[va.time.month,3],[va.time.year,1]],sl=[[va.time.format("%Y"),Rt],[va.time.format("%B"),function(n){return n.getMonth()}],[va.time.format("%b %d"),function(n){return n.getDate()!=1}],[va.time.format("%a %d"),function(n){return n.getDay()&&n.getDate()!=1}],[va.time.format("%I %p"),function(n){return n.getHours()}],[va.time.format("%I:%M"),function(n){return n.getMinutes()}],[va.time.format(":%S"),function(n){return n.getSeconds()}],[va.time.format(".%L"),function(n){return n.getMilliseconds()}]],hl=va.scale.linear(),gl=fa(sl);fl.year=function(n,t){return hl.domain(n.map(ha)).ticks(t).map(sa)},va.time.scale=function(){return ca(va.scale.linear(),fl,gl)};var pl=fl.map(function(n){return[n[0].utc,n[1]]}),dl=[[va.time.format.utc("%Y"),Rt],[va.time.format.utc("%B"),function(n){return n.getUTCMonth()}],[va.time.format.utc("%b %d"),function(n){return n.getUTCDate()!=1}],[va.time.format.utc("%a %d"),function(n){return n.getUTCDay()&&n.getUTCDate()!=1}],[va.time.format.utc("%I %p"),function(n){return n.getUTCHours()}],[va.time.format.utc("%I:%M"),function(n){return n.getUTCMinutes()}],[va.time.format.utc(":%S"),function(n){return n.getUTCSeconds()}],[va.time.format.utc(".%L"),function(n){return n.getUTCMilliseconds()}]],ml=fa(dl);return pl.year=function(n,t){return hl.domain(n.map(pa)).ticks(t).map(ga)},va.time.scale.utc=function(){return ca(va.scale.linear(),pl,ml)},va.text=ht(function(n){return n.responseText}),va.json=function(n,t){return gt(n,"application/json",da,t)},va.html=function(n,t){return gt(n,"text/html",ma,t)},va.xml=ht(function(n){return n.responseXML}),va}(); \ No newline at end of file diff --git a/tworavens/gui.html b/tworavens/gui.html new file mode 100644 index 0000000..b661a31 --- /dev/null +++ b/tworavens/gui.html @@ -0,0 +1,347 @@ + + + + + TwoRavens + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tworavens/install.pl b/tworavens/install.pl new file mode 100644 index 0000000..86dde05 --- /dev/null +++ b/tworavens/install.pl @@ -0,0 +1,267 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Getopt::Long; +use Socket; +use File::Copy; + +my $verbose; +my $yes; + +my ($rez) = GetOptions( + "verbose" => \$verbose +); + +# hostname: + +my $hostname_from_cmdline = `hostname`; +chop $hostname_from_cmdline; + + +my @CONFIG_VARIABLES = ( + 'TWORAVENS_DIRECTORY', + 'APACHE_CONFIG_DIRECTORY', + 'APACHE_WEB_DIRECTORY', + 'HOST_DNS_ADDRESS', + 'HOST_PORT', + 'HOST_HTTPS', + 'DATAVERSE_URL' +); + +my %CONFIG_DEFAULTS = ( + 'TWORAVENS_DIRECTORY', '/var/www/html/dataexplore', + 'APACHE_CONFIG_DIRECTORY', '/etc/httpd', + 'APACHE_WEB_DIRECTORY', '/var/www/html', + 'HOST_DNS_ADDRESS', $hostname_from_cmdline, + 'HOST_PORT', 443, + 'HOST_PROTOCOL', 'https', + 'DATAVERSE_URL', 'https://' . $hostname_from_cmdline + +); + +my %CONFIG_PROMPTS = ( + 'TWORAVENS_DIRECTORY', 'Directory where TwoRavens is installed', + 'APACHE_CONFIG_DIRECTORY', 'Apache config directory', + 'APACHE_WEB_DIRECTORY', 'Apache Web Root directory', + 'HOST_DNS_ADDRESS', 'Internet address of the rApache host', + 'HOST_PORT', 'rApache port number', + 'HOST_PROTOCOL', 'http or https?', + 'DATAVERSE_URL', 'URL address of the Dataverdse application, to access files and metadata' + +); + + +my $user_real = `who am i`; +chop $user_real; +$user_real =~ s/ .*$//; + +if ( $< != 0 ) { + print STDERR "\nERROR: You must be logged in as root to run the installer.\n\n"; + exit 1; +} + +print "\nWelcome to the TwoRavens BETA installer.\n"; + +ENTERCONFIG: + +print "\n"; +print "Please enter the following configuration values:\n"; +print "(hit [RETURN] to accept the default value)\n"; +print "\n"; + +for my $ENTRY (@CONFIG_VARIABLES) { + print $CONFIG_PROMPTS{$ENTRY} . ": "; + print "[" . $CONFIG_DEFAULTS{$ENTRY} . "] "; + + my $user_entry; +# unless ($yes) { + $user_entry = <>; + chop $user_entry; +# } + + if ($ENTRY eq "HOST_PROTOCOL") { + while (($user_entry ne "") && ($user_entry ne "http") && ($user_entry ne "https")) { + print "Please enter 'http' or 'https'!\n"; + print "(or ctrl-C to exit the installer)\n"; + $user_entry = <>; + chop $user_entry; + } + } + + if ( $user_entry ne "" ) { + $CONFIG_DEFAULTS{$ENTRY} = $user_entry; + if ($ENTRY eq "TWORAVENS_DIRECTORY") { + my $tmpwd = $user_entry; + $tmpwd =~s:/dataexplore$::; + unless ($tmpwd eq $user_entry) { + $CONFIG_DEFAULTS{'APACHE_WEB_DIRECTORY'} = $tmpwd; + } + } + } + print "\n"; +} + +# CONFIRM VALUES ENTERED: + +print "\nOK, please confirm what you've entered:\n\n"; + +for my $ENTRY (@CONFIG_VARIABLES) { + print $CONFIG_PROMPTS{$ENTRY} . ": " . $CONFIG_DEFAULTS{$ENTRY} . "\n"; +} + +my $yesno; +#if ($yes) { +# $yesno = "y"; +#} +#else { + print "\nIs this correct? [y/n] "; + $yesno = <>; + chop $yesno; +#} + +while ( $yesno ne "y" && $yesno ne "n" ) { + print "Please enter 'y' or 'n'!\n"; + print "(or ctrl-C to exit the installer)\n"; + $yesno = <>; + chop $yesno; +} + +if ( $yesno eq "n" ) { + goto ENTERCONFIG; +} + + +# 1. Edit R application sources, make necessary changes: + +my $RAPACHEURL = $CONFIG_DEFAULTS{'HOST_PROTOCOL'} . "://" . $CONFIG_DEFAULTS{'HOST_DNS_ADDRESS'}; + +if ($CONFIG_DEFAULTS{'HOST_PROTOCOL'} eq "http" && $CONFIG_DEFAULTS{'HOST_PORT'} != 80) { + $RAPACHEURL .= (":" . $CONFIG_DEFAULTS{'HOST_PORT'}); +} elsif ($CONFIG_DEFAULTS{'HOST_PROTOCOL'} eq "https" && $CONFIG_DEFAULTS{'HOST_PORT'} != 443) { + $RAPACHEURL .= (":" . $CONFIG_DEFAULTS{'HOST_PORT'}); +} + +for my $rFile ( "rooksource.R", "rookdata.R", "rookzelig.R", "rooksubset.R", "rooktransform.R", "rookselector.R" ) { + print "Configuring script " . $rFile . "...\n"; + + unless ( -f $rFile ) { + print "\nWARNING: Can't find " . $rFile . "!\n"; + print "(are you running the installer in the right directory?)\n"; + } + + open RFILEIN, $rFile || die $@; + open RFILEOUT, '>' . $rFile . ".tmp" || die $@; + + while () { + # production toggle: + s/production\<\-FALSE/production\<\-TRUE/g; + # rApache url: + s/https:\/\/dataverse-internal.iq.harvard.edu/$RAPACHEURL/g; + # working directory: + s/\/usr\/local\/glassfish4\/glassfish\/domains\/domain1\/docroot\/dataexplore/$CONFIG_DEFAULTS{'TWORAVENS_DIRECTORY'}/g; + print RFILEOUT $_; + } + + close RFILEIN; + close RFILEOUT; + + system ("mv " . $rFile . ".tmp " . $rFile); +} + + +# 2. Install the rApache config file: + +print "\n\nConfiguring rApache to serve TwoRavens Rook applications...\n"; + +my $RAPACHE_CONFIG_FILE = "tworavens-rapache.conf"; + +unless ( -f $RAPACHE_CONFIG_FILE ) { + print "\nWARNING: Can't find " . $RAPACHE_CONFIG_FILE . "!\n"; + print "(are you running the installer in the right directory?)\n"; + + exit 0; +} + +unless ( -d $CONFIG_DEFAULTS{'APACHE_CONFIG_DIRECTORY'} ) { + print "\nWARNING: Can't find Apache config directory - " . $CONFIG_DEFAULTS{'APACHE_CONFIG_DIRECTORY'} . "!\n"; + print "(is Apache httpd installed on this system?)\n"; + + exit 0; +} + +if ($CONFIG_DEFAULTS{'TWORAVENS_DIRECTORY'} eq "/var/www/html/dataexplore") { + # simply copy the supplied .conf file into the Apache conf.d directory: + + system ("cp " . $RAPACHE_CONFIG_FILE . " " . $CONFIG_DEFAULTS{'APACHE_CONFIG_DIRECTORY'} . "/conf.d"); +} else { + # we have to filter the supplied file and insert the correct directory name: + + open CONFIGFILEIN, $RAPACHE_CONFIG_FILE || die $@; + open CONFIGFILEOUT, '>' . $CONFIG_DEFAULTS{'APACHE_CONFIG_DIRECTORY'} . "/conf.d/" . $RAPACHE_CONFIG_FILE || die $@; + + while () { + s:/var/www/html/dataexplore:$CONFIG_DEFAULTS{'TWORAVENS_DIRECTORY'}:g; + print CONFIGFILEOUT $_; + } + + close CONFIGFILEIN; + close CONFIGFILEOUT; +} + +print "\nRestarting Apache...\n"; + +system ("service httpd restart"); + +# 3. Application directories + +print "\nCreating application directories on the filesystem...\n"; + + +for my $webDir ( "pic_dir", "preprocess_dir" ) { + system ("mkdir --parents " . $CONFIG_DEFAULTS{'APACHE_WEB_DIRECTORY'} . "/" . $webDir); + system ("chown -R apache " . $CONFIG_DEFAULTS{'APACHE_WEB_DIRECTORY'} . "/". $webDir); + + unless ( -d $CONFIG_DEFAULTS{'APACHE_WEB_DIRECTORY'} . "/". $webDir) { + print "\nWARNING: Failed to create directory: " . $CONFIG_DEFAULTS{'APACHE_WEB_DIRECTORY'} . "/". $webDir . "!\n"; + exit 0; + } +} + +print "OK!\n"; + +# 4. Edit the JavaScript application file: + +my $TwoRavensWebApp = "app_ddi.js"; +unless ( -f $TwoRavensWebApp ) { + print "\nWARNING: Can't find " . $TwoRavensWebApp . "!\n"; + print "(are you running the installer in the right directory?)\n"; +} + +open WEBAPPFILEIN, $TwoRavensWebApp || die $@; +open WEBAPPFILEOUT, '>' . $TwoRavensWebApp . ".tmp" || die $@; + +my $dataversehostname=$CONFIG_DEFAULTS{'DATAVERSE_URL'}; +$dataversehostname=~s/^https*:\/\///; # TODO: modify tworavens not to default to either protocol. + +while () { + # production toggle: + $_="var production=true;\n" if /^var production=false/; + # rApache url: + s/http:\/\/0.0.0.0:8000\/custom\//$RAPACHEURL\/custom\//g; + # dataverse url: + s/localhost:8080/$CONFIG_DEFAULTS{'DATAVERSE_URL'}/g; + print WEBAPPFILEOUT $_; +} + +close WEBAPPFILEIN; +close WEBAPPFILEOUT; + +system ("mv " . $TwoRavensWebApp . ".tmp " . $TwoRavensWebApp); + + +# 5. Chown the TwoRavens directory to user Apache: + +system ("chown -R apache " . $CONFIG_DEFAULTS{'TWORAVENS_DIRECTORY'}); + +print "\n\nGreat. You should now have a working TwoRavens installation!\n"; diff --git a/tworavens/plots.js b/tworavens/plots.js new file mode 100644 index 0000000..357db18 --- /dev/null +++ b/tworavens/plots.js @@ -0,0 +1,1319 @@ +// function to use d3 to graph density plots with preprocessed data + +function density(node, div) { + var mydiv; + + if(div=="subset") { + mydiv = "#tab2"; + } + else if(div=="setx") { + mydiv = "#setx"; + } + else if(div=="varSummary") { + mydiv = "#tab3"; + } + else { + return (alert("Error: incorrect div selected for plots")); + } + + var yVals = node.ploty; + var xVals = node.plotx; + + // an array of objects + var data2 = []; + for(var i = 0; i < node.plotx.length; i++) { + data2.push({x:node.plotx[i], y:node.ploty[i]}); + } + + data2.forEach(function(d) { + d.x = +d.x; + d.y = +d.y; + }); + + //stores values for upper bound + var upperError = []; + for(var i = 0; i < node.plotx.length; i++) { + upperError.push({x:node.plotx[i], y:1.1*node.ploty[i]}); + } + + upperError.forEach(function(d) { + d.x = +d.x; + d.y = +d.y; + }); + + // stores values for lower bound + var lowerError = []; + for(var i = 0; i < node.plotx.length; i++) { + lowerError.push({x:node.plotx[i], y:0.9*node.ploty[i]}); + } + + lowerError.forEach(function(d) { + d.x = +d.x; + d.y = +d.y; + }); + + var tempWidth = d3.select(mydiv).style("width") + var width = tempWidth.substring(0,(tempWidth.length-2)); + + var tempHeight = d3.select(mydiv).style("height") + var height = tempHeight.substring(0,(tempHeight.length-2)); + + var margin = {top: 20, right: 20, bottom: 53, left: 30}; + + // Need to fix automatic width and height settings for leftpanel (#tab2, #tab3) + + if(mydiv=="#tab3"){ + width = 0.7 * (width - margin.left - margin.right), + height = 0.3 * (height - margin.top - margin.bottom); + } + else if (mydiv=="#tab2" | mydiv=="#setx"){ + width = 200; + height = 120; + } + else{ + width = 0.35 * (width - margin.left - margin.right), + height = 0.25 * (height - margin.top - margin.bottom); + }; + + + var x = d3.scale.linear() + .domain([d3.min(xVals), d3.max(xVals)]) + .range([0, width]); + + var invx = d3.scale.linear() + .range([d3.min(xVals), d3.max(xVals)]) + .domain([0, width]); + + var y = d3.scale.linear() + .domain([d3.min(yVals), d3.max(yVals)]) + .range([height, 0]); + + + var xAxis = d3.svg.axis() + .scale(x) + .ticks(5) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left"); + + var brush = d3.svg.brush() + .x(x) + .extent(node.subsetrange) + .on("brush", brushed); + + var brush2 = d3.svg.brush() + .x(x) + .on("brush", brushed2); + + var area = d3.svg.area() + .interpolate("monotone") + .x(function(d) { return x(d.x); }) + .y0(height) + .y1(function(d) { return y(d.y); }); + + + // This is cumbersome to treat "tab3" differently, but works for now. + // tab3, has an issue, that unless width height hardcoded, they grow with each additional graph. + if(mydiv=="#tab3"){ + var plotsvg = d3.select(mydiv) + .selectAll("svg") + .remove(); + + var plotsvg = d3.select(mydiv) + .append("svg") + .attr("id", function(){ + return node.name.toString().concat(mydiv.substr(1)); + }) + .style("width", 300) //setting height to the height of #main.left + .style("height", 200) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + }else{ + var plotsvg = d3.select(mydiv) + .append("svg") + .attr("id", function(){ + var myname = node.name.toString(); + myname = myname.replace(/\(|\)/g, ""); + return myname.concat("_",mydiv.substr(1), "_", node.id); + }) + .style("width", width + margin.left + margin.right) //setting height to the height of #main.left + .style("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + }; + + //add upper bound + plotsvg.append("path") + .datum(upperError) + .attr("class", "upperError") + .attr("d", area); + + plotsvg.append("path") + .datum(data2) + .attr("class", "area") + .attr("d", area); + + //add lower bound + plotsvg.append("path") + .datum(lowerError) + .attr("class", "lowerError") + .attr("d", area); + + plotsvg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + plotsvg.append("text") + .attr("x", (width / 2)) + .attr("y", 0-(margin.top / 2)) + .attr("text-anchor", "middle") + .style("font-size", "12px") + .text(node.name); + + // add brush if subset + if(mydiv=="#tab2") { + plotsvg.append("text") + .attr("id", "range") + .attr("x", 25) + .attr("y", height+40) + .text(function() { + return("Range: ".concat(d3.min(xVals).toPrecision(4), " to ", d3.max(xVals).toPrecision(4))); + }); + + plotsvg.append("g") + .attr("class", "x brush") + .call(brush) + .selectAll("rect") + .attr("height", height); + } + + // add z lines and sliders setx + if(mydiv=="#setx") { + plotsvg.append("text") + .attr("id", "range") + .attr("x", 25) + .attr("y", height+40) + .text(function() { + return("x: ".concat((+node.mean).toPrecision(4))); + }); + + plotsvg.append("text") + .attr("id", "range2") + .attr("x", 25) + .attr("y", height+50) + .text(function() { + return("x1: ".concat((+node.mean).toPrecision(4))); + }); + + // create tick marks at all zscores in the bounds of the data + var lineFunction = d3.svg.line() + .x(function(d) { return d.x; }) + .y(function(d) { return d.y; }) + .interpolate("linear"); + + var colSeq = [ "#A2CD5A","orange","red"]; // will cycle through color sequence, and then repeat last color + var lineData = new Array; + + var zLower = -1*(d3.min(xVals)-node.mean)/node.sd; // zscore of lower bound + var zUpper =(d3.max(xVals)-node.mean)/node.sd; // zscore of upper bound + + for (var i = 0; i < zUpper; i++) { + lineData = [{ "x": x(+node.mean + i*node.sd), "y": height*.7}, { "x": x(+node.mean+ i*node.sd), "y": height*.9}]; + plotsvg.append("path") + .attr("d", lineFunction([lineData[0],lineData[1]])) + .attr("stroke", colSeq[d3.min([i,colSeq.length-1])]) + .attr("stroke-width", 1.5) + .attr("fill", "none"); + } + + for (var i = 1; i < zLower; i++) { + lineData = [{ "x": x(+node.mean - i*node.sd), "y": height*.7}, { "x": x(+node.mean- i*node.sd), "y": height*.9}]; + plotsvg.append("path") + .attr("d", lineFunction([lineData[0],lineData[1]])) + .attr("stroke", colSeq[d3.min([i,colSeq.length-1])]) + .attr("stroke-width", 1.5) + .attr("fill", "none"); + } + + // initialize slider components + var slideBox = plotsvg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height*.8 + ")") + .call(d3.svg.axis() + .scale(x) + .ticks(0) + .orient("bottom")) + + var slider = plotsvg.append("g") + .attr("class", "slider") + .call(brush); + + var handle = slider.append("polygon") + .attr("class", "handle") + .attr("transform", "translate(0," + height*.7 + ")") + .attr("points", function(d){ + var s=6; + if(node.setxvals[0]=="") {var xnm=x(node.mean);} + else {var xnm=x(node.setxvals[0])}; + return (xnm-s)+","+(-s)+" "+(xnm+s)+","+(-s)+" "+xnm+","+(s*1.3);}); + + var slider2 = plotsvg.append("g") + .attr("class", "slider") + .call(brush2); + + var handle2 = slider2.append("polygon") + .attr("class", "handle") + .attr("transform", "translate(0," + height*.9 + ")") + .attr("points", function(d){ + var s=6; + if(node.setxvals[1]=="") {var xnm=x(node.mean);} + else {var xnm=x(node.setxvals[1])}; + return (xnm-s)+","+s+" "+(xnm+s)+","+s+" "+xnm+","+(-s*1.3);}); + } + + // brushing functions + function brushed() { + if(mydiv=="#tab2") { + plotsvg.select("text#range") + .text(function() { + if(brush.empty()) {return("Range: ".concat(d3.min(xVals).toPrecision(4), " to ", d3.max(xVals).toPrecision(4)));} + else {return("Range: ".concat((brush.extent()[0]).toPrecision(4), " to ", (brush.extent()[1]).toPrecision(4)));} + }); + + if((brush.extent()[0]).toPrecision(4) != (brush.extent()[1]).toPrecision(4)) { + node.subsetrange=[(brush.extent()[0]).toPrecision(4), (brush.extent()[1]).toPrecision(4)];} + else { + node.subsetrange=["", ""]; + } + } + else if(mydiv=="#setx") { + var value = brush.extent()[0]; + var s = 6; + + if (d3.event.sourceEvent) { + value = x.invert(d3.mouse(this)[0]); + brush.extent([value, value]); + } + + // set x position of slider center + var xpos = x(value); + if(value > d3.max(xVals)) { // dragged past max + xpos = x(d3.max(xVals)); + } + else if(value < d3.min(xVals)) { // dragged past min + xpos = x(d3.min(xVals)); + } + else { + var m = +node.mean; + var sd = +node.sd; + var zScore = (value - m)/sd; // z-score + var zRound = Math.round(zScore); // nearest integer z-score + if( .1 > Math.abs(zRound - zScore)) { // snap to integer z-score + xpos = x(m + (zRound * sd)); + } + } + + // create slider symbol and text + handle.attr("points", function(d){ + return (xpos-s)+","+(-s)+" "+(xpos+s)+","+(-s)+" "+xpos+","+(s*1.3);}); + plotsvg.select("text#range") + .text(function() { + return("x: ".concat((invx(xpos)).toPrecision(4)));}); + node.setxvals[1]=(invx(xpos)).toPrecision(4); + } + } + + function brushed2() { // certainly a more clever way to do this, but for now it's basically copied with brush and handle changes to brush2 and handle2 and #range to #range2 and setxvals[0] to setxvals[1] + var value = brush2.extent()[0]; + var s = 6; // scaling for triangle shape + + if (d3.event.sourceEvent) { + value = x.invert(d3.mouse(this)[0]); + brush2.extent([value, value]); + } + + // set x position of slider center + var xpos = x(value); + if(value > d3.max(xVals)) { // dragged past max + xpos = x(d3.max(xVals)); + } + else if(value < d3.min(xVals)) { // dragged past min + xpos = x(d3.min(xVals)); + } + else { + var m = +node.mean; + var sd = +node.sd; + var zScore = (value - m)/sd; // z-score + var zRound = Math.round(zScore); // nearest integer z-score + if( .1 > Math.abs(zRound - zScore)) { // snap to integer z-score + xpos = x(m + (zRound * sd)); + } + } + + // create slider symbol and text + handle2.attr("points", function(d){ + return (xpos-s)+","+s+" "+(xpos+s)+","+s+" "+xpos+","+(-s*1.3);}); + plotsvg.select("text#range2") + .text(function() { + return("x1: ".concat((invx(xpos)).toPrecision(4)));}); + node.setxvals[1]=(invx(xpos)).toPrecision(4); + } +} //end function density + + +function bars(node, div) { + // Histogram spacing + var barPadding = .015; // Space between bars + var topScale =1.2; // Multiplicative factor to assign space at top within graph - currently removed from implementation + var plotXaxis = true; + + // Data + var keys = Object.keys(node.plotvalues); + var yVals = new Array; + var xVals = new Array; + var yValKey = new Array; + + if(node.nature==="nominal") { + var xi = 0; + for (var i = 0; i < keys.length; i++) { + if(node.plotvalues[keys[i]]==0) {continue;} + yVals[xi] = node.plotvalues[keys[i]]; + xVals[xi] = xi; + yValKey.push({y:yVals[xi], x:keys[i] }); + xi = xi+1; + } + yValKey.sort(function(a,b){return b.y-a.y}); // array of objects, each object has y, the same as yVals, and x, the category + yVals.sort(function(a,b){return b-a}); // array of y values, the height of the bars + } + else { + for (var i = 0; i < keys.length; i++) { + yVals[i] = node.plotvalues[keys[i]]; + xVals[i] = Number(keys[i]); + } + } + + if((yVals.length>15 & node.numchar==="numeric") | (yVals.length>5 & node.numchar==="character")) {plotXaxis=false;} + var maxY = d3.max(yVals); // in the future, set maxY to the value of the maximum confidence limit + var minX = d3.min(xVals); + var maxX = d3.max(xVals); + + var mydiv; + if(div=="setx") { + mydiv = "#setx"; + } + else if(div=="varSummary") { + mydiv = "#tab3"; + } + else { + return (alert("Error: incorrect div selected for plots")); + } + + var tempWidth = d3.select(mydiv).style("width") + var width = tempWidth.substring(0,(tempWidth.length-2)); + + var tempHeight = d3.select(mydiv).style("height") + var height = tempHeight.substring(0,(tempHeight.length-2)); + + var margin = {top: 20, right: 20, bottom: 53, left: 50}; + + // Need to fix automatic width and height settings for leftpanel (#tab2, #tab3) + + if(mydiv=="#tab3"){ + width = 0.7 * (width - margin.left - margin.right), + height = 0.3 * (height - margin.top - margin.bottom); + } + else if (mydiv=="#setx"){ + width = 200; + height = 120; + } + else{ + width = 0.35 * (width - margin.left - margin.right), + height = 0.25 * (height - margin.top - margin.bottom); + }; + + var x = d3.scale.linear() + .domain([ minX-0.5 , maxX+0.5]) + .range([0, width]); + + var invx = d3.scale.linear() + .range([ minX-0.5 , maxX+0.5]) + .domain([0, width]); + + var y = d3.scale.linear() + .domain([0, maxY]) + .range([0, height]); + + var xAxis = d3.svg.axis() + .scale(x) + .ticks(yVals.length) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left"); + + var brush = d3.svg.brush() + .x(x) + .extent(function(){ + if(node.subsetrange.length==1) {return [node.subsetrange[0], node.subsetrange[0]];} + else {return node.subsetrange;} + }) + .on("brush", brushed); + + var brush2 = d3.svg.brush() + .x(x) + .on("brush", brushed2); + + + //Create SVG element + + // This is cumbersome to treat "tab3" differently, but works for now. + // tab3, has an issue, that unless width height hardcoded, they grow with each additional graph. + if(mydiv=="#tab3"){ + var plotsvg = d3.select(mydiv) + .selectAll("svg") + .remove(); + + var plotsvg = d3.select(mydiv) + .append("svg") + .attr("id", function(){ + return node.name.toString().concat(mydiv.substr(1)); + }) + .style("width", 300) //setting height to the height of #main.left + .style("height", 200) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + } + else { + var plotsvg = d3.select(mydiv) + .append("svg") + .attr("id", function(){ + var myname = node.name.toString(); + myname = myname.replace(/\(|\)/g, ""); + return myname.concat("_",mydiv.substr(1), "_", node.id); + }) + .style("width", width + margin.left + margin.right) //setting height to the height of #main.left + .style("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + }; + + var rectWidth = x(minX + 0.5 - 2*barPadding); //the "width" is the coordinate of the end of the first bar + + plotsvg.selectAll("rect") + .data(yVals) + .enter() + .append("rect") + .attr("x", function(d, i) { + return x(xVals[i]-0.5+barPadding); + }) + .attr("y", function(d) { + return y(maxY - d); + }) + .attr("width", rectWidth) + .attr("height", function(d) { + return y(d); + }) + .attr("fill", "#1f77b4"); + + // draw error bars + if (yVals.length <= 20) { //do not display error bars if the number of bins exceeds 20 + plotsvg.selectAll("line") + .data(yVals) + .enter() + .append("line") + .style("stroke", "black") + .attr("x1", function(d, i){ + return x(xVals[i]-0.5+barPadding) + rectWidth/2 + }) + .attr("y1", function(d) { + return y(maxY - d) - .1*y(d); + }) + .attr("x2", function(d, i){ + return x(xVals[i]-0.5+barPadding) + rectWidth/2 + }) + .attr("y2", function(d) { + return y(maxY - d) + .1*y(d); + }) + }; + + //draw top ticks on error bars + //need to fix the height of the graphs - the tops of error bars are getting cut off + plotsvg.selectAll(".topTick") + .data(yVals) + .enter() + .append("line") + .attr("class", "topTick") + .style("stroke", "black") + .attr("x1", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding)//make tick bigger to increase visibility + } else { + return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth + } + }) + .attr("y1", function(d) { + return y(maxY - d) - .1*y(d); + }) + .attr("x2", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding) + rectWidth //make tick bigger to increase visibility + } else { + return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth + } + }) + .attr("y2", function(d) { + return y(maxY - d) - .1*y(d); + }); + + // draw bottom ticks of error bars + plotsvg.selectAll(".bottomTick") + .data(yVals) + .enter() + .append("line") + .attr("class", "bottomTick") + .style("stroke", "black") + .attr("x1", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding)//make tick bigger to increase visibility + } else { + return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth + } + }) + .attr("y1", function(d) { + return y(maxY - d) + .1*y(d); + }) + .attr("x2", function(d, i){ + if (yVals.length > 20) { + return x(xVals[i]-0.5+barPadding) + rectWidth //make tick bigger to increase visibility + } else { + return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth + } + }) + .attr("y2", function(d) { + return y(maxY - d) + .1*y(d); + }) + + //second option for dense histograms + // var num = yVals.length/20 //for every num bins, display an error bar + + // plotsvg.selectAll("line") + // .data(yVals) + // .enter() + // .append("line") + // .style("stroke", "black") + // .attr("x1", function(d, i){ + // if (yVals.length > 20) { + // if (i%num <= 1) { + // return x(xVals[i]-0.5+barPadding) + rectWidth/2 + // } + // } else { + // return x(xVals[i]-0.5+barPadding) + rectWidth/2 + // } + // }) + // .attr("y1", function(d) { + // return y(maxY - d) - .1*y(d); + // }) + // .attr("x2", function(d, i){ + // if (yVals.length > 20) { + // if (i%num <= 1) { + // return x(xVals[i]-0.5+barPadding) + rectWidth/2 + // } + // } else { + // return x(xVals[i]-0.5+barPadding) + rectWidth/2 + // } + // }) + // .attr("y2", function(d) { + // return y(maxY - d) + .1*y(d); + // }) + + + // //draw top ticks on error bars + // //need to fix the height of the graphs - the tops of error bars are getting cut off + // plotsvg.selectAll(".topTick") + // .data(yVals) + // .enter() + // .append("line") + // .attr("class", "topTick") + // .style("stroke", "black") + // .attr("x1", function(d, i){ + // if (yVals.length > 20) { + // if (i%num <= 1) { + // return x(xVals[i]-0.5+barPadding) - 1 + // } + // } else { + // return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth + // } + + // }) + // .attr("y1", function(d) { + // return y(maxY - d) - .1*y(d); + // }) + // .attr("x2", function(d, i){ + // if (yVals.length > 20) { + // if (i%num <= 1) { + // return x(xVals[i]-0.5+barPadding) + rectWidth + 1} + // } else { + // return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth + // } + + // }) + // .attr("y2", function(d) { + // return y(maxY - d) - .1*y(d); + // }); + + // // draw bottom ticks of error bars + // plotsvg.selectAll(".bottomTick") + // .data(yVals) + // .enter() + // .append("line") + // .attr("class", "bottomTick") + // .style("stroke", "black") + // .attr("x1", function(d, i){ + // if (yVals.length > 20) { + // if (i%num <= 1) { + // return x(xVals[i]-0.5+barPadding) - 1 + // } + // } else { + // return x(xVals[i]-0.5+barPadding) + 0.4*rectWidth + // } + // }) + // .attr("y1", function(d) { + // return y(maxY - d) + .1*y(d); + // }) + // .attr("x2", function(d, i){ + // if (yVals.length > 20) { + // if (i%num <= 1) { + // return x(xVals[i]-0.5+barPadding) + rectWidth + 1} + // } else { + // return x(xVals[i]-0.5+barPadding) + 0.6*rectWidth + // } + + // }) + // .attr("y2", function(d) { + // return y(maxY - d) + .1*y(d); + // }) + + + + // draw threshold line + // var threshold = 10; + + // plotsvg.append("line") + // .style("stroke", "black") + // .attr("x1", x(minX)) + // .attr("y1", y(maxY) - threshold) + // .attr("x2", x(maxX)) + // .attr("y2", y(maxY) - threshold) + + + + if(plotXaxis) { + plotsvg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + } + + plotsvg.append("text") + .attr("x", (width / 2)) + .attr("y", 0-(margin.top / 2)) + .attr("text-anchor", "middle") + .style("font-size", "12px") + .text(node.name); + + if(mydiv=="#setx") { + plotsvg.append("text") + .attr("id", "range") + .attr("x", 25) + .attr("y", height+40) + .text(function() { + if (node.numchar==="character") { + return("x: "+yValKey[Math.round(yValKey.length/2)].x); + } + else {return("x: ".concat(Math.round(node.mean)));} + }); + + plotsvg.append("text") + .attr("id", "range2") + .attr("x", 25) + .attr("y", height+50) + .text(function() { + if (node.numchar==="character") { + return("x1: "+yValKey[Math.round(yValKey.length/2)].x); + } + else {return("x1: ".concat(Math.round(node.mean)));} + }); + + // create tick marks at all zscores in the bounds of the data + var lineFunction = d3.svg.line() + .x(function(d) { return d.x; }) + .y(function(d) { return d.y; }) + .interpolate("linear"); + + var colSeq = [ "#A2CD5A","orange","red"]; // will cycle through color sequence, and then repeat last color + var lineData = new Array; + + var zLower = -1*(minX-node.mean)/node.sd; // zscore of lower bound + var zUpper =(maxX-node.mean)/node.sd; // zscore of upper bound + + for (var i = 0; i < zUpper; i++) { + lineData = [{ "x": x(+node.mean + i*node.sd), "y": height*.7}, { "x": x(+node.mean+ i*node.sd), "y": height*.9}]; + plotsvg.append("path") + .attr("d", lineFunction([lineData[0],lineData[1]])) + .attr("stroke", colSeq[d3.min([i,colSeq.length-1])]) + .attr("stroke-width", 1.5) + .attr("fill", "none"); + } + + for (var i = 1; i < zLower; i++) { + lineData = [{ "x": x(+node.mean - i*node.sd), "y": height*.7}, { "x": x(+node.mean- i*node.sd), "y": height*.9}]; + plotsvg.append("path") + .attr("d", lineFunction([lineData[0],lineData[1]])) + .attr("stroke", colSeq[d3.min([i,colSeq.length-1])]) + .attr("stroke-width", 1.5) + .attr("fill", "none"); + } + + for (var i = d3.min(xVals); i <= d3.max(xVals); i++) { + lineData = [{ "x": x(i), "y": height*.75}, { "x": x(i), "y": height*.85}]; + plotsvg.append("path") + .attr("d", lineFunction([lineData[0],lineData[1]])) + .attr("stroke", "black") + .attr("stroke-width", 1) + .attr("fill", "none"); + } + + // initialize slider components + var slideBox = plotsvg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height*.8 + ")") + .call(d3.svg.axis() + .scale(x) + .ticks(0) + .orient("bottom")) + + var slider = plotsvg.append("g") + .attr("class", "slider") + .call(brush); + + var handle = slider.append("polygon") + .attr("class", "handle") + .attr("transform", "translate(0," + height*.7 + ")") + .attr("points", function(d){ + var s=6; + if(node.setxvals[0]=="") { + if(node.nature=="nominal") { // if this variable is a character, use the median frequency as the position for the setx slider + var xnm = x(Math.round(xVals.length/2)); + } + else {var xnm=x(node.mean);} + } + else {var xnm=x(node.setxvals[0])}; + return (xnm-s)+","+(-s)+" "+(xnm+s)+","+(-s)+" "+xnm+","+(s*1.3);}); + + var slider2 = plotsvg.append("g") + .attr("class", "slider") + .call(brush2); + + var handle2 = slider2.append("polygon") + .attr("class", "handle") + .attr("transform", "translate(0," + height*.9 + ")") + .attr("points", function(d){ + var s=6; + if(node.setxvals[1]=="") { + if(node.nature=="nominal") { // if this variable is a character, use the median frequency as the position for the setx slider + var xnm = x(Math.round(xVals.length/2)); + } + else {var xnm=x(node.mean);} + } + else {var xnm=x(node.setxvals[1])}; + return (xnm-s)+","+s+" "+(xnm+s)+","+s+" "+xnm+","+(-s*1.3);}); + } + + + function twoSF(x){ + var tsf = d3.format(".2r"); // format to two significant figures after the decimal place + return tsf(x).replace( /0+$/, "").replace( /\.$/, "") // trim trailing zeros after a period, and any orphaned period + } + + + // brushing functions + function brushed() { + var value = brush.extent()[0]; + var s = 6; + + if (d3.event.sourceEvent) { + value = x.invert(d3.mouse(this)[0]); + brush.extent([value, value]); + } + + // set x position of slider center + var xpos = x(value); + if(value > maxX){ // dragged past max + xpos = x(maxX); + } + else if(value < minX){ // dragged past min + xpos = x(minX); + } + else { + var m = +node.mean; + var sd = +node.sd; + var zScore = (value - m)/sd; // z-score + var zRound = Math.round(zScore); // nearest integer z-score + if (.1 > Math.abs( Math.round(value) - value)){ // snap to integer + xpos = x(Math.round(value)); + } else if( .1 > Math.abs(zRound - zScore)) { // snap to integer z-score + xpos = x(m + (zRound * sd)); + } + } + + // create slider symbol and text + handle.attr("points", function(d){ + return (xpos-s)+","+(-s)+" "+(xpos+s)+","+(-s)+" "+xpos+","+(s*1.3);}); + plotsvg.select("text#range") + .text(function() { + if(node.numchar==="character") { + return("x: "+yValKey[Math.round(invx(xpos))].x); + } + else { + return("x: ".concat(twoSF(invx(xpos)))); + } + }); + node.setxvals[1]=twoSF(invx(xpos)); + } + + function brushed2() { // certainly a more clever way to do this, but for now it's basically copied with brush and handle changes to brush2 and handle2 and #range to #range2 and setxvals[0] to setxvals[1] + var value = brush2.extent()[0]; + var s = 6; // scaling for triangle shape + + if (d3.event.sourceEvent) { + value = x.invert(d3.mouse(this)[0]); + brush2.extent([value, value]); + } + + // set x position of slider center + var xpos = x(value); + if(value > maxX){ // dragged past max + xpos = x(maxX); + } + else if(value < minX){ // dragged past min + xpos = x(minX); + } + else { + var m = +node.mean; + var sd = +node.sd; + var zScore = (value - m)/sd; // z-score + var zRound = Math.round(zScore); // nearest integer z-score + if (.1 > Math.abs( Math.round(value) - value)){ // snap to integer + xpos = x(Math.round(value)); + }else if( .1 > Math.abs(zRound - zScore)) { // snap to integer z-score + xpos = x(m + (zRound * sd)); + } + } + + // create slider symbol and text + handle2.attr("points", function(d){ + return (xpos-s)+","+s+" "+(xpos+s)+","+s+" "+xpos+","+(-s*1.3);}); + plotsvg.select("text#range2") + .text(function() { + if(node.numchar==="character") { + return("x1: "+yValKey[Math.round(invx(xpos))].x); + } + else { + return("x1: ".concat(twoSF(invx(xpos)))); + } + }); + node.setxvals[1]=twoSF(invx(xpos)); + } +} //end function bars + +function barsSubset(node) { + // if untouched, set node.subsetrange to an empty array, meaning all values selected by default + if(node.subsetrange[0]=="" & node.subsetrange[1]=="") { + node.subsetrange=[]; + } + + // Histogram spacing + var barPadding = .015; // Space between bars + var topScale =1.2; // Multiplicative factor to assign space at top within graph - currently removed from implementation + var plotXaxis = true; + + // Variable name + var myname = node.name.toString(); + myname = myname.replace(/\(|\)/g, ""); + + + // Data + var keys = Object.keys(node.plotvalues); + var yVals = new Array; + var xVals = new Array; + var yValKey = new Array; + + if(node.nature==="nominal") { + var xi = 0; + for (var i = 0; i < keys.length; i++) { + if(node.plotvalues[keys[i]]==0) {continue;} + yVals[xi] = node.plotvalues[keys[i]]; + xVals[xi] = xi; + yValKey.push({y:yVals[xi], x:keys[i] }); + xi = xi+1; + } + yValKey.sort(function(a,b){return b.y-a.y}); // array of objects, each object has y, the same as yVals, and x, the category + yVals.sort(function(a,b){return b-a}); // array of y values, the height of the bars + } + else { + for (var i = 0; i < keys.length; i++) { + yVals[i] = node.plotvalues[keys[i]]; + xVals[i] = Number(keys[i]); + } + } + + if((yVals.length>15 & node.numchar==="numeric") | (yVals.length>5 & node.numchar==="character")) {plotXaxis=false;} + + var maxY = d3.max(yVals); + var minX = d3.min(xVals); + var maxX = d3.max(xVals); + var gname = ["subsetyes", "subsetno"]; + + var yVals2 = []; + var yVals1 = []; + for(i=0; i0 & d.col===d3Color & $.inArray(xVals[i].toString(), node.subsetrange)>-1) { + return selVarColor; + } + else { + return d.col; + } + }) + .on("click", function(){ + var selectMe = this; + var selectName = this.getAttribute("name"); + if(this.parentNode.getAttribute("name")==myname.concat("subsetno")) { + selectMe = $('[name="' + myname.concat("subsetyes") + '"]').children('[name="' + selectName + '"]')[0]; + } + d3.select(selectMe) + .style("fill", function(d,i){ + var myCol=""; + if(this.style.fill===selVarColor) { + var myindex = node.subsetrange.indexOf(this.getAttribute("name")); + node.subsetrange.splice(myindex, 1); + myCol=d3Color; + } else { + node.subsetrange.push(this.getAttribute("name")); + myCol=selVarColor; + } + return myCol; + }); + plotsvg.select("text#selectrange") + .text(function() { + if(node.subsetrange.length==0) {return("Selected: all values");} + else { + if(node.numchar==="character") { + var a = node.subsetrange; + var selecteds = new Array; + a.forEach(function(val) { + selecteds.push(yValKey[val].x); + }) + return("Selected: "+selecteds); + } + else { + return("Selected: ".concat(node.subsetrange)); + } + } + }); + }) + .on("mouseover", function(){ + var i = this.getAttribute("name"); + plotsvg.select("text#mymouseover") + .text(function(){ + var out = yValKey[i].x + ": " + yValKey[i].y; + return(out); + }); + }); + + if(plotXaxis) { + plotsvg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + } else { + plotsvg.append("text") + .attr("id", "mymouseover") + .attr("x", 25) + .attr("y", height+20) + .text(function() { + return(""); + }); + } + + plotsvg.append("text") + .attr("x", (width / 2)) + .attr("y", 0-(margin.top / 2)) + .attr("text-anchor", "middle") + .style("font-size", "12px") + .text(myname); + + plotsvg.append("text") + .attr("id", "selectrange") + .attr("x", 25) + .attr("y", height+40) + .text(function() { + if(node.subsetrange.length==0) {return("Selected: all values");} + else { + if(node.numchar==="character") { + var a = node.subsetrange; + var selecteds = new Array; + a.forEach(function(val) { + selecteds.push(yValKey[val].x); + }) + return("Selected: "+selecteds); + } + else { + return("Selected: ".concat(node.subsetrange)); + } + } + }); +} //end function bar subset + + +function densityNode(node, obj) { + + var myname = node.name.toString().concat("nodeplot"); + + if(typeof obj === "undefined") { + var obj = document.getElementById(node.name.toString()+"biggroup"); + + // if obj contains an svg element, remove it. this removes any plot inside the node + if(d3.select(obj).selectAll("svg")[0].length>0) { + d3.select(obj).selectAll("svg").remove(); + } + } + + + var yVals = node.ploty; + var xVals = node.plotx; + + // an array of objects + var data2 = []; + for(var i = 0; i < node.plotx.length; i++) { + data2.push({x:node.plotx[i], y:node.ploty[i]}); + } + + data2.forEach(function(d) { + d.x = +d.x; + d.y = +d.y; + }); + + + var width = 60; // NOTE: hardcoded, should be set automatically + var height = 30; + var margin = {top: 20, right: 10, bottom: 53, left: 10}; + + var x = d3.scale.linear() + .domain([d3.min(xVals), d3.max(xVals)]) + .range([0, width]); + + var y = d3.scale.linear() + .domain([d3.min(yVals), d3.max(yVals)]) + .range([height, 0]); + + var area = d3.svg.area() + .interpolate("monotone") + .x(function(d) { return x(d.x); }) + .y0(height) + .y1(function(d) { return y(d.y); }); + + var plotsvg = d3.select(obj) + .insert("svg", ":first-child") +// .append("svg") + .attr("x", -40) // NOTE: Not sure exactly why these numbers work, but these hardcoded values seem to position the plot inside g correctly. this shouldn't be hardcoded in the future + .attr("y", -45) + .attr("id", function(){ + return myname; + }) + .style("width", width) + .style("height", height) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + plotsvg.append("path") + .datum(data2) + .attr("class", "area") + .attr("d", area); +} //end function densityNode + +function barsNode(node, obj) { + + var myname = node.name.toString().concat("nodeplot"); + + if(typeof obj === "undefined") { + var obj = document.getElementById(node.name.toString()+"biggroup"); + + // if obj contains an svg element, remove it. this removes any plot inside the node + if(d3.select(obj).selectAll("svg")[0].length>0) { + d3.select(obj).selectAll("svg").remove(); + } + } + + + // Histogram spacing + var barPadding = .015; // Space between bars + var topScale =1.2; // Multiplicative factor to assign space at top within graph - currently removed from implementation + + // Data + var keys = Object.keys(node.plotvalues); + var yVals = new Array; + var xVals = new Array; + var yValKey = new Array; + + if(node.nature==="nominal") { + var xi = 0; + for (var i = 0; i < keys.length; i++) { + if(node.plotvalues[keys[i]]==0) {continue;} + yVals[xi] = node.plotvalues[keys[i]]; + xVals[xi] = xi; + yValKey.push({y:yVals[xi], x:keys[i] }); + xi = xi+1; + } + yValKey.sort(function(a,b){return b.y-a.y}); // array of objects, each object has y, the same as yVals, and x, the category + yVals.sort(function(a,b){return b-a}); // array of y values, the height of the bars + } + else { + for (var i = 0; i < keys.length; i++) { + yVals[i] = node.plotvalues[keys[i]]; + xVals[i] = Number(keys[i]); + } + } + + var maxY = d3.max(yVals); + var minX = d3.min(xVals); + var maxX = d3.max(xVals); + + var width = 60; + var height = 30; + var margin = {top: 20, right: 10, bottom: 53, left: 10}; + + var x = d3.scale.linear() + .domain([ minX-0.5 , maxX+0.5]) + .range([0, width]); + + var invx = d3.scale.linear() + .range([ minX-0.5 , maxX+0.5]) + .domain([0, width]); + + var y = d3.scale.linear() + .domain([0, maxY]) + .range([0, height]); + + + + + //Create SVG element + var plotsvg = d3.select(obj) + .insert("svg", ":first-child") +// .append("svg") + .attr("x", -40) + .attr("y", -45) + + .attr("id", function(){ + return myname; + }) + .style("width", width) //setting height to the height of #main.left + .style("height", height) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + plotsvg.selectAll("rect") + .data(yVals) + .enter() + .append("rect") + .attr("x", function(d, i) { + return x(xVals[i]-0.5+barPadding); + }) + .attr("y", function(d) { + return y(maxY - d); + }) + .attr("width", x(minX + 0.5 - 2*barPadding) ) // the "width" is the coordinate of the end of the first bar + .attr("height", function(d) { + return y(d); + }) + .attr("fill", "#1f77b4"); + +} //end function barsNode + + diff --git a/tworavens/tworavens-rapache.conf b/tworavens/tworavens-rapache.conf new file mode 100644 index 0000000..e5fd792 --- /dev/null +++ b/tworavens/tworavens-rapache.conf @@ -0,0 +1,27 @@ +# +# This configures the R applications served by rApache. +# + +RSourceOnStartup "/var/www/html/dataexplore/rook/rooksource.R" + + + SetHandler r-handler + RFileEval /var/www/html/dataexplore/rook/rookzelig.R:Rook::Server$call(zelig.app) + + + + SetHandler r-handler + RFileEval /var/www/html/dataexplore/rook/rooksubset.R:Rook::Server$call(subset.app) + + + + SetHandler r-handler + RFileEval /var/www/html/dataexplore/rook/rooktransform.R:Rook::Server$call(transform.app) + + + + SetHandler r-handler + RFileEval /var/www/html/dataexplore/rook/rookdata.R:Rook::Server$call(data.app) + + +