d3.js 262 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806
  1. (function() {
  2. var d3_format_decimalPoint = ".", d3_format_thousandsSeparator = ",", d3_format_grouping = [ 3, 3 ];
  3. if (!Date.now) Date.now = function() {
  4. return +new Date();
  5. };
  6. try {
  7. document.createElement("div").style.setProperty("opacity", 0, "");
  8. } catch (error) {
  9. var d3_style_prototype = CSSStyleDeclaration.prototype, d3_style_setProperty = d3_style_prototype.setProperty;
  10. d3_style_prototype.setProperty = function(name, value, priority) {
  11. d3_style_setProperty.call(this, name, value + "", priority);
  12. };
  13. }
  14. d3 = {
  15. version: "3.0.4"
  16. };
  17. var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π;
  18. function d3_target(d) {
  19. return d.target;
  20. }
  21. function d3_source(d) {
  22. return d.source;
  23. }
  24. function d3_class(ctor, properties) {
  25. try {
  26. for (var key in properties) {
  27. Object.defineProperty(ctor.prototype, key, {
  28. value: properties[key],
  29. enumerable: false
  30. });
  31. }
  32. } catch (e) {
  33. ctor.prototype = properties;
  34. }
  35. }
  36. var d3_array = d3_arraySlice;
  37. function d3_arrayCopy(pseudoarray) {
  38. var i = -1, n = pseudoarray.length, array = [];
  39. while (++i < n) array.push(pseudoarray[i]);
  40. return array;
  41. }
  42. function d3_arraySlice(pseudoarray) {
  43. return Array.prototype.slice.call(pseudoarray);
  44. }
  45. try {
  46. d3_array(document.documentElement.childNodes)[0].nodeType;
  47. } catch (e) {
  48. d3_array = d3_arrayCopy;
  49. }
  50. var d3_arraySubclass = [].__proto__ ? function(array, prototype) {
  51. array.__proto__ = prototype;
  52. } : function(array, prototype) {
  53. for (var property in prototype) array[property] = prototype[property];
  54. };
  55. d3.map = function(object) {
  56. var map = new d3_Map();
  57. for (var key in object) map.set(key, object[key]);
  58. return map;
  59. };
  60. function d3_Map() {}
  61. d3_class(d3_Map, {
  62. has: function(key) {
  63. return d3_map_prefix + key in this;
  64. },
  65. get: function(key) {
  66. return this[d3_map_prefix + key];
  67. },
  68. set: function(key, value) {
  69. return this[d3_map_prefix + key] = value;
  70. },
  71. remove: function(key) {
  72. key = d3_map_prefix + key;
  73. return key in this && delete this[key];
  74. },
  75. keys: function() {
  76. var keys = [];
  77. this.forEach(function(key) {
  78. keys.push(key);
  79. });
  80. return keys;
  81. },
  82. values: function() {
  83. var values = [];
  84. this.forEach(function(key, value) {
  85. values.push(value);
  86. });
  87. return values;
  88. },
  89. entries: function() {
  90. var entries = [];
  91. this.forEach(function(key, value) {
  92. entries.push({
  93. key: key,
  94. value: value
  95. });
  96. });
  97. return entries;
  98. },
  99. forEach: function(f) {
  100. for (var key in this) {
  101. if (key.charCodeAt(0) === d3_map_prefixCode) {
  102. f.call(this, key.substring(1), this[key]);
  103. }
  104. }
  105. }
  106. });
  107. var d3_map_prefix = "\0", d3_map_prefixCode = d3_map_prefix.charCodeAt(0);
  108. function d3_identity(d) {
  109. return d;
  110. }
  111. function d3_true() {
  112. return true;
  113. }
  114. function d3_functor(v) {
  115. return typeof v === "function" ? v : function() {
  116. return v;
  117. };
  118. }
  119. d3.functor = d3_functor;
  120. d3.rebind = function(target, source) {
  121. var i = 1, n = arguments.length, method;
  122. while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
  123. return target;
  124. };
  125. function d3_rebind(target, source, method) {
  126. return function() {
  127. var value = method.apply(source, arguments);
  128. return arguments.length ? target : value;
  129. };
  130. }
  131. d3.ascending = function(a, b) {
  132. return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
  133. };
  134. d3.descending = function(a, b) {
  135. return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
  136. };
  137. d3.mean = function(array, f) {
  138. var n = array.length, a, m = 0, i = -1, j = 0;
  139. if (arguments.length === 1) {
  140. while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
  141. } else {
  142. while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
  143. }
  144. return j ? m : undefined;
  145. };
  146. d3.median = function(array, f) {
  147. if (arguments.length > 1) array = array.map(f);
  148. array = array.filter(d3_number);
  149. return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined;
  150. };
  151. d3.min = function(array, f) {
  152. var i = -1, n = array.length, a, b;
  153. if (arguments.length === 1) {
  154. while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
  155. while (++i < n) if ((b = array[i]) != null && a > b) a = b;
  156. } else {
  157. while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
  158. while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
  159. }
  160. return a;
  161. };
  162. d3.max = function(array, f) {
  163. var i = -1, n = array.length, a, b;
  164. if (arguments.length === 1) {
  165. while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
  166. while (++i < n) if ((b = array[i]) != null && b > a) a = b;
  167. } else {
  168. while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
  169. while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
  170. }
  171. return a;
  172. };
  173. d3.extent = function(array, f) {
  174. var i = -1, n = array.length, a, b, c;
  175. if (arguments.length === 1) {
  176. while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
  177. while (++i < n) if ((b = array[i]) != null) {
  178. if (a > b) a = b;
  179. if (c < b) c = b;
  180. }
  181. } else {
  182. while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
  183. while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
  184. if (a > b) a = b;
  185. if (c < b) c = b;
  186. }
  187. }
  188. return [ a, c ];
  189. };
  190. d3.random = {
  191. normal: function(µ, σ) {
  192. var n = arguments.length;
  193. if (n < 2) σ = 1;
  194. if (n < 1) µ = 0;
  195. return function() {
  196. var x, y, r;
  197. do {
  198. x = Math.random() * 2 - 1;
  199. y = Math.random() * 2 - 1;
  200. r = x * x + y * y;
  201. } while (!r || r > 1);
  202. return µ + σ * x * Math.sqrt(-2 * Math.log(r) / r);
  203. };
  204. },
  205. logNormal: function(µ, σ) {
  206. var n = arguments.length;
  207. if (n < 2) σ = 1;
  208. if (n < 1) µ = 0;
  209. var random = d3.random.normal();
  210. return function() {
  211. return Math.exp(µ + σ * random());
  212. };
  213. },
  214. irwinHall: function(m) {
  215. return function() {
  216. for (var s = 0, j = 0; j < m; j++) s += Math.random();
  217. return s / m;
  218. };
  219. }
  220. };
  221. function d3_number(x) {
  222. return x != null && !isNaN(x);
  223. }
  224. d3.sum = function(array, f) {
  225. var s = 0, n = array.length, a, i = -1;
  226. if (arguments.length === 1) {
  227. while (++i < n) if (!isNaN(a = +array[i])) s += a;
  228. } else {
  229. while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a;
  230. }
  231. return s;
  232. };
  233. d3.quantile = function(values, p) {
  234. var H = (values.length - 1) * p + 1, h = Math.floor(H), v = +values[h - 1], e = H - h;
  235. return e ? v + e * (values[h] - v) : v;
  236. };
  237. d3.shuffle = function(array) {
  238. var m = array.length, t, i;
  239. while (m) {
  240. i = Math.random() * m-- | 0;
  241. t = array[m], array[m] = array[i], array[i] = t;
  242. }
  243. return array;
  244. };
  245. d3.transpose = function(matrix) {
  246. return d3.zip.apply(d3, matrix);
  247. };
  248. d3.zip = function() {
  249. if (!(n = arguments.length)) return [];
  250. for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) {
  251. for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) {
  252. zip[j] = arguments[j][i];
  253. }
  254. }
  255. return zips;
  256. };
  257. function d3_zipLength(d) {
  258. return d.length;
  259. }
  260. d3.bisector = function(f) {
  261. return {
  262. left: function(a, x, lo, hi) {
  263. if (arguments.length < 3) lo = 0;
  264. if (arguments.length < 4) hi = a.length;
  265. while (lo < hi) {
  266. var mid = lo + hi >>> 1;
  267. if (f.call(a, a[mid], mid) < x) lo = mid + 1; else hi = mid;
  268. }
  269. return lo;
  270. },
  271. right: function(a, x, lo, hi) {
  272. if (arguments.length < 3) lo = 0;
  273. if (arguments.length < 4) hi = a.length;
  274. while (lo < hi) {
  275. var mid = lo + hi >>> 1;
  276. if (x < f.call(a, a[mid], mid)) hi = mid; else lo = mid + 1;
  277. }
  278. return lo;
  279. }
  280. };
  281. };
  282. var d3_bisector = d3.bisector(function(d) {
  283. return d;
  284. });
  285. d3.bisectLeft = d3_bisector.left;
  286. d3.bisect = d3.bisectRight = d3_bisector.right;
  287. d3.nest = function() {
  288. var nest = {}, keys = [], sortKeys = [], sortValues, rollup;
  289. function map(array, depth) {
  290. if (depth >= keys.length) return rollup ? rollup.call(nest, array) : sortValues ? array.sort(sortValues) : array;
  291. var i = -1, n = array.length, key = keys[depth++], keyValue, object, valuesByKey = new d3_Map(), values, o = {};
  292. while (++i < n) {
  293. if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
  294. values.push(object);
  295. } else {
  296. valuesByKey.set(keyValue, [ object ]);
  297. }
  298. }
  299. valuesByKey.forEach(function(keyValue, values) {
  300. o[keyValue] = map(values, depth);
  301. });
  302. return o;
  303. }
  304. function entries(map, depth) {
  305. if (depth >= keys.length) return map;
  306. var a = [], sortKey = sortKeys[depth++], key;
  307. for (key in map) {
  308. a.push({
  309. key: key,
  310. values: entries(map[key], depth)
  311. });
  312. }
  313. if (sortKey) a.sort(function(a, b) {
  314. return sortKey(a.key, b.key);
  315. });
  316. return a;
  317. }
  318. nest.map = function(array) {
  319. return map(array, 0);
  320. };
  321. nest.entries = function(array) {
  322. return entries(map(array, 0), 0);
  323. };
  324. nest.key = function(d) {
  325. keys.push(d);
  326. return nest;
  327. };
  328. nest.sortKeys = function(order) {
  329. sortKeys[keys.length - 1] = order;
  330. return nest;
  331. };
  332. nest.sortValues = function(order) {
  333. sortValues = order;
  334. return nest;
  335. };
  336. nest.rollup = function(f) {
  337. rollup = f;
  338. return nest;
  339. };
  340. return nest;
  341. };
  342. d3.keys = function(map) {
  343. var keys = [];
  344. for (var key in map) keys.push(key);
  345. return keys;
  346. };
  347. d3.values = function(map) {
  348. var values = [];
  349. for (var key in map) values.push(map[key]);
  350. return values;
  351. };
  352. d3.entries = function(map) {
  353. var entries = [];
  354. for (var key in map) entries.push({
  355. key: key,
  356. value: map[key]
  357. });
  358. return entries;
  359. };
  360. d3.permute = function(array, indexes) {
  361. var permutes = [], i = -1, n = indexes.length;
  362. while (++i < n) permutes[i] = array[indexes[i]];
  363. return permutes;
  364. };
  365. d3.merge = function(arrays) {
  366. return Array.prototype.concat.apply([], arrays);
  367. };
  368. function d3_collapse(s) {
  369. return s.trim().replace(/\s+/g, " ");
  370. }
  371. d3.range = function(start, stop, step) {
  372. if (arguments.length < 3) {
  373. step = 1;
  374. if (arguments.length < 2) {
  375. stop = start;
  376. start = 0;
  377. }
  378. }
  379. if ((stop - start) / step === Infinity) throw new Error("infinite range");
  380. var range = [], k = d3_range_integerScale(Math.abs(step)), i = -1, j;
  381. start *= k, stop *= k, step *= k;
  382. if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k); else while ((j = start + step * ++i) < stop) range.push(j / k);
  383. return range;
  384. };
  385. function d3_range_integerScale(x) {
  386. var k = 1;
  387. while (x * k % 1) k *= 10;
  388. return k;
  389. }
  390. d3.requote = function(s) {
  391. return s.replace(d3_requote_re, "\\$&");
  392. };
  393. var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
  394. d3.round = function(x, n) {
  395. return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x);
  396. };
  397. d3.xhr = function(url, mimeType, callback) {
  398. var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, response = d3_identity, request = new (window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)();
  399. "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() {
  400. request.readyState > 3 && respond();
  401. };
  402. function respond() {
  403. var s = request.status;
  404. !s && request.responseText || s >= 200 && s < 300 || s === 304 ? dispatch.load.call(xhr, response.call(xhr, request)) : dispatch.error.call(xhr, request);
  405. }
  406. request.onprogress = function(event) {
  407. var o = d3.event;
  408. d3.event = event;
  409. try {
  410. dispatch.progress.call(xhr, request);
  411. } finally {
  412. d3.event = o;
  413. }
  414. };
  415. xhr.header = function(name, value) {
  416. name = (name + "").toLowerCase();
  417. if (arguments.length < 2) return headers[name];
  418. if (value == null) delete headers[name]; else headers[name] = value + "";
  419. return xhr;
  420. };
  421. xhr.mimeType = function(value) {
  422. if (!arguments.length) return mimeType;
  423. mimeType = value == null ? null : value + "";
  424. return xhr;
  425. };
  426. xhr.response = function(value) {
  427. response = value;
  428. return xhr;
  429. };
  430. [ "get", "post" ].forEach(function(method) {
  431. xhr[method] = function() {
  432. return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments)));
  433. };
  434. });
  435. xhr.send = function(method, data, callback) {
  436. if (arguments.length === 2 && typeof data === "function") callback = data, data = null;
  437. request.open(method, url, true);
  438. if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*";
  439. if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]);
  440. if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType);
  441. if (callback != null) xhr.on("error", callback).on("load", function(request) {
  442. callback(null, request);
  443. });
  444. request.send(data == null ? null : data);
  445. return xhr;
  446. };
  447. xhr.abort = function() {
  448. request.abort();
  449. return xhr;
  450. };
  451. d3.rebind(xhr, dispatch, "on");
  452. if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType,
  453. mimeType = null;
  454. return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback));
  455. };
  456. function d3_xhr_fixCallback(callback) {
  457. return callback.length === 1 ? function(error, request) {
  458. callback(error == null ? request : null);
  459. } : callback;
  460. }
  461. d3.text = function() {
  462. return d3.xhr.apply(d3, arguments).response(d3_text);
  463. };
  464. function d3_text(request) {
  465. return request.responseText;
  466. }
  467. d3.json = function(url, callback) {
  468. return d3.xhr(url, "application/json", callback).response(d3_json);
  469. };
  470. function d3_json(request) {
  471. return JSON.parse(request.responseText);
  472. }
  473. d3.html = function(url, callback) {
  474. return d3.xhr(url, "text/html", callback).response(d3_html);
  475. };
  476. function d3_html(request) {
  477. var range = document.createRange();
  478. range.selectNode(document.body);
  479. return range.createContextualFragment(request.responseText);
  480. }
  481. d3.xml = function() {
  482. return d3.xhr.apply(d3, arguments).response(d3_xml);
  483. };
  484. function d3_xml(request) {
  485. return request.responseXML;
  486. }
  487. var d3_nsPrefix = {
  488. svg: "http://www.w3.org/2000/svg",
  489. xhtml: "http://www.w3.org/1999/xhtml",
  490. xlink: "http://www.w3.org/1999/xlink",
  491. xml: "http://www.w3.org/XML/1998/namespace",
  492. xmlns: "http://www.w3.org/2000/xmlns/"
  493. };
  494. d3.ns = {
  495. prefix: d3_nsPrefix,
  496. qualify: function(name) {
  497. var i = name.indexOf(":"), prefix = name;
  498. if (i >= 0) {
  499. prefix = name.substring(0, i);
  500. name = name.substring(i + 1);
  501. }
  502. return d3_nsPrefix.hasOwnProperty(prefix) ? {
  503. space: d3_nsPrefix[prefix],
  504. local: name
  505. } : name;
  506. }
  507. };
  508. d3.dispatch = function() {
  509. var dispatch = new d3_dispatch(), i = -1, n = arguments.length;
  510. while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
  511. return dispatch;
  512. };
  513. function d3_dispatch() {}
  514. d3_dispatch.prototype.on = function(type, listener) {
  515. var i = type.indexOf("."), name = "";
  516. if (i > 0) {
  517. name = type.substring(i + 1);
  518. type = type.substring(0, i);
  519. }
  520. return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener);
  521. };
  522. function d3_dispatch_event(dispatch) {
  523. var listeners = [], listenerByName = new d3_Map();
  524. function event() {
  525. var z = listeners, i = -1, n = z.length, l;
  526. while (++i < n) if (l = z[i].on) l.apply(this, arguments);
  527. return dispatch;
  528. }
  529. event.on = function(name, listener) {
  530. var l = listenerByName.get(name), i;
  531. if (arguments.length < 2) return l && l.on;
  532. if (l) {
  533. l.on = null;
  534. listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
  535. listenerByName.remove(name);
  536. }
  537. if (listener) listeners.push(listenerByName.set(name, {
  538. on: listener
  539. }));
  540. return dispatch;
  541. };
  542. return event;
  543. }
  544. d3.format = function(specifier) {
  545. 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;
  546. if (precision) precision = +precision.substring(1);
  547. if (zfill || fill === "0" && align === "=") {
  548. zfill = fill = "0";
  549. align = "=";
  550. if (comma) width -= Math.floor((width - 1) / 4);
  551. }
  552. switch (type) {
  553. case "n":
  554. comma = true;
  555. type = "g";
  556. break;
  557. case "%":
  558. scale = 100;
  559. suffix = "%";
  560. type = "f";
  561. break;
  562. case "p":
  563. scale = 100;
  564. suffix = "%";
  565. type = "r";
  566. break;
  567. case "b":
  568. case "o":
  569. case "x":
  570. case "X":
  571. if (basePrefix) basePrefix = "0" + type.toLowerCase();
  572. case "c":
  573. case "d":
  574. integer = true;
  575. precision = 0;
  576. break;
  577. case "s":
  578. scale = -1;
  579. type = "r";
  580. break;
  581. }
  582. if (basePrefix === "#") basePrefix = "";
  583. if (type == "r" && !precision) type = "g";
  584. type = d3_format_types.get(type) || d3_format_typeDefault;
  585. var zcomma = zfill && comma;
  586. return function(value) {
  587. if (integer && value % 1) return "";
  588. var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign;
  589. if (scale < 0) {
  590. var prefix = d3.formatPrefix(value, precision);
  591. value = prefix.scale(value);
  592. suffix = prefix.symbol;
  593. } else {
  594. value *= scale;
  595. }
  596. value = type(value, precision);
  597. if (!zfill && comma) value = d3_format_group(value);
  598. var length = basePrefix.length + value.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : "";
  599. if (zcomma) value = d3_format_group(padding + value);
  600. if (d3_format_decimalPoint) value.replace(".", d3_format_decimalPoint);
  601. negative += basePrefix;
  602. 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;
  603. };
  604. };
  605. var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/;
  606. var d3_format_types = d3.map({
  607. b: function(x) {
  608. return x.toString(2);
  609. },
  610. c: function(x) {
  611. return String.fromCharCode(x);
  612. },
  613. o: function(x) {
  614. return x.toString(8);
  615. },
  616. x: function(x) {
  617. return x.toString(16);
  618. },
  619. X: function(x) {
  620. return x.toString(16).toUpperCase();
  621. },
  622. g: function(x, p) {
  623. return x.toPrecision(p);
  624. },
  625. e: function(x, p) {
  626. return x.toExponential(p);
  627. },
  628. f: function(x, p) {
  629. return x.toFixed(p);
  630. },
  631. r: function(x, p) {
  632. return d3.round(x, p = d3_format_precision(x, p)).toFixed(Math.max(0, Math.min(20, p)));
  633. }
  634. });
  635. function d3_format_precision(x, p) {
  636. return p - (x ? 1 + Math.floor(Math.log(x + Math.pow(10, 1 + Math.floor(Math.log(x) / Math.LN10) - p)) / Math.LN10) : 1);
  637. }
  638. function d3_format_typeDefault(x) {
  639. return x + "";
  640. }
  641. var d3_format_group = d3_identity;
  642. if (d3_format_grouping) {
  643. var d3_format_groupingLength = d3_format_grouping.length;
  644. d3_format_group = function(value) {
  645. var i = value.lastIndexOf("."), f = i >= 0 ? "." + value.substring(i + 1) : (i = value.length,
  646. ""), t = [], j = 0, g = d3_format_grouping[0];
  647. while (i > 0 && g > 0) {
  648. t.push(value.substring(i -= g, i + g));
  649. g = d3_format_grouping[j = (j + 1) % d3_format_groupingLength];
  650. }
  651. return t.reverse().join(d3_format_thousandsSeparator || "") + f;
  652. };
  653. }
  654. var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "μ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix);
  655. d3.formatPrefix = function(value, precision) {
  656. var i = 0;
  657. if (value) {
  658. if (value < 0) value *= -1;
  659. if (precision) value = d3.round(value, d3_format_precision(value, precision));
  660. i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
  661. i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3));
  662. }
  663. return d3_formatPrefixes[8 + i / 3];
  664. };
  665. function d3_formatPrefix(d, i) {
  666. var k = Math.pow(10, Math.abs(8 - i) * 3);
  667. return {
  668. scale: i > 8 ? function(d) {
  669. return d / k;
  670. } : function(d) {
  671. return d * k;
  672. },
  673. symbol: d
  674. };
  675. }
  676. var d3_ease_default = function() {
  677. return d3_identity;
  678. };
  679. var d3_ease = d3.map({
  680. linear: d3_ease_default,
  681. poly: d3_ease_poly,
  682. quad: function() {
  683. return d3_ease_quad;
  684. },
  685. cubic: function() {
  686. return d3_ease_cubic;
  687. },
  688. sin: function() {
  689. return d3_ease_sin;
  690. },
  691. exp: function() {
  692. return d3_ease_exp;
  693. },
  694. circle: function() {
  695. return d3_ease_circle;
  696. },
  697. elastic: d3_ease_elastic,
  698. back: d3_ease_back,
  699. bounce: function() {
  700. return d3_ease_bounce;
  701. }
  702. });
  703. var d3_ease_mode = d3.map({
  704. "in": d3_identity,
  705. out: d3_ease_reverse,
  706. "in-out": d3_ease_reflect,
  707. "out-in": function(f) {
  708. return d3_ease_reflect(d3_ease_reverse(f));
  709. }
  710. });
  711. d3.ease = function(name) {
  712. var i = name.indexOf("-"), t = i >= 0 ? name.substring(0, i) : name, m = i >= 0 ? name.substring(i + 1) : "in";
  713. t = d3_ease.get(t) || d3_ease_default;
  714. m = d3_ease_mode.get(m) || d3_identity;
  715. return d3_ease_clamp(m(t.apply(null, Array.prototype.slice.call(arguments, 1))));
  716. };
  717. function d3_ease_clamp(f) {
  718. return function(t) {
  719. return t <= 0 ? 0 : t >= 1 ? 1 : f(t);
  720. };
  721. }
  722. function d3_ease_reverse(f) {
  723. return function(t) {
  724. return 1 - f(1 - t);
  725. };
  726. }
  727. function d3_ease_reflect(f) {
  728. return function(t) {
  729. return .5 * (t < .5 ? f(2 * t) : 2 - f(2 - 2 * t));
  730. };
  731. }
  732. function d3_ease_quad(t) {
  733. return t * t;
  734. }
  735. function d3_ease_cubic(t) {
  736. return t * t * t;
  737. }
  738. function d3_ease_cubicInOut(t) {
  739. if (t <= 0) return 0;
  740. if (t >= 1) return 1;
  741. var t2 = t * t, t3 = t2 * t;
  742. return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75);
  743. }
  744. function d3_ease_poly(e) {
  745. return function(t) {
  746. return Math.pow(t, e);
  747. };
  748. }
  749. function d3_ease_sin(t) {
  750. return 1 - Math.cos(t * π / 2);
  751. }
  752. function d3_ease_exp(t) {
  753. return Math.pow(2, 10 * (t - 1));
  754. }
  755. function d3_ease_circle(t) {
  756. return 1 - Math.sqrt(1 - t * t);
  757. }
  758. function d3_ease_elastic(a, p) {
  759. var s;
  760. if (arguments.length < 2) p = .45;
  761. if (arguments.length) s = p / (2 * π) * Math.asin(1 / a); else a = 1, s = p / 4;
  762. return function(t) {
  763. return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * π / p);
  764. };
  765. }
  766. function d3_ease_back(s) {
  767. if (!s) s = 1.70158;
  768. return function(t) {
  769. return t * t * ((s + 1) * t - s);
  770. };
  771. }
  772. function d3_ease_bounce(t) {
  773. 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;
  774. }
  775. d3.event = null;
  776. function d3_eventCancel() {
  777. d3.event.stopPropagation();
  778. d3.event.preventDefault();
  779. }
  780. function d3_eventSource() {
  781. var e = d3.event, s;
  782. while (s = e.sourceEvent) e = s;
  783. return e;
  784. }
  785. function d3_eventDispatch(target) {
  786. var dispatch = new d3_dispatch(), i = 0, n = arguments.length;
  787. while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
  788. dispatch.of = function(thiz, argumentz) {
  789. return function(e1) {
  790. try {
  791. var e0 = e1.sourceEvent = d3.event;
  792. e1.target = target;
  793. d3.event = e1;
  794. dispatch[e1.type].apply(thiz, argumentz);
  795. } finally {
  796. d3.event = e0;
  797. }
  798. };
  799. };
  800. return dispatch;
  801. }
  802. d3.transform = function(string) {
  803. var g = document.createElementNS(d3.ns.prefix.svg, "g");
  804. return (d3.transform = function(string) {
  805. g.setAttribute("transform", string);
  806. var t = g.transform.baseVal.consolidate();
  807. return new d3_transform(t ? t.matrix : d3_transformIdentity);
  808. })(string);
  809. };
  810. function d3_transform(m) {
  811. 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;
  812. if (r0[0] * r1[1] < r1[0] * r0[1]) {
  813. r0[0] *= -1;
  814. r0[1] *= -1;
  815. kx *= -1;
  816. kz *= -1;
  817. }
  818. this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_degrees;
  819. this.translate = [ m.e, m.f ];
  820. this.scale = [ kx, ky ];
  821. this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 0;
  822. }
  823. d3_transform.prototype.toString = function() {
  824. return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")";
  825. };
  826. function d3_transformDot(a, b) {
  827. return a[0] * b[0] + a[1] * b[1];
  828. }
  829. function d3_transformNormalize(a) {
  830. var k = Math.sqrt(d3_transformDot(a, a));
  831. if (k) {
  832. a[0] /= k;
  833. a[1] /= k;
  834. }
  835. return k;
  836. }
  837. function d3_transformCombine(a, b, k) {
  838. a[0] += k * b[0];
  839. a[1] += k * b[1];
  840. return a;
  841. }
  842. var d3_transformIdentity = {
  843. a: 1,
  844. b: 0,
  845. c: 0,
  846. d: 1,
  847. e: 0,
  848. f: 0
  849. };
  850. d3.interpolate = function(a, b) {
  851. var i = d3.interpolators.length, f;
  852. while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ;
  853. return f;
  854. };
  855. d3.interpolateNumber = function(a, b) {
  856. b -= a;
  857. return function(t) {
  858. return a + b * t;
  859. };
  860. };
  861. d3.interpolateRound = function(a, b) {
  862. b -= a;
  863. return function(t) {
  864. return Math.round(a + b * t);
  865. };
  866. };
  867. d3.interpolateString = function(a, b) {
  868. var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o;
  869. d3_interpolate_number.lastIndex = 0;
  870. for (i = 0; m = d3_interpolate_number.exec(b); ++i) {
  871. if (m.index) s.push(b.substring(s0, s1 = m.index));
  872. q.push({
  873. i: s.length,
  874. x: m[0]
  875. });
  876. s.push(null);
  877. s0 = d3_interpolate_number.lastIndex;
  878. }
  879. if (s0 < b.length) s.push(b.substring(s0));
  880. for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) {
  881. o = q[i];
  882. if (o.x == m[0]) {
  883. if (o.i) {
  884. if (s[o.i + 1] == null) {
  885. s[o.i - 1] += o.x;
  886. s.splice(o.i, 1);
  887. for (j = i + 1; j < n; ++j) q[j].i--;
  888. } else {
  889. s[o.i - 1] += o.x + s[o.i + 1];
  890. s.splice(o.i, 2);
  891. for (j = i + 1; j < n; ++j) q[j].i -= 2;
  892. }
  893. } else {
  894. if (s[o.i + 1] == null) {
  895. s[o.i] = o.x;
  896. } else {
  897. s[o.i] = o.x + s[o.i + 1];
  898. s.splice(o.i + 1, 1);
  899. for (j = i + 1; j < n; ++j) q[j].i--;
  900. }
  901. }
  902. q.splice(i, 1);
  903. n--;
  904. i--;
  905. } else {
  906. o.x = d3.interpolateNumber(parseFloat(m[0]), parseFloat(o.x));
  907. }
  908. }
  909. while (i < n) {
  910. o = q.pop();
  911. if (s[o.i + 1] == null) {
  912. s[o.i] = o.x;
  913. } else {
  914. s[o.i] = o.x + s[o.i + 1];
  915. s.splice(o.i + 1, 1);
  916. }
  917. n--;
  918. }
  919. if (s.length === 1) {
  920. return s[0] == null ? q[0].x : function() {
  921. return b;
  922. };
  923. }
  924. return function(t) {
  925. for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t);
  926. return s.join("");
  927. };
  928. };
  929. d3.interpolateTransform = function(a, b) {
  930. 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;
  931. if (ta[0] != tb[0] || ta[1] != tb[1]) {
  932. s.push("translate(", null, ",", null, ")");
  933. q.push({
  934. i: 1,
  935. x: d3.interpolateNumber(ta[0], tb[0])
  936. }, {
  937. i: 3,
  938. x: d3.interpolateNumber(ta[1], tb[1])
  939. });
  940. } else if (tb[0] || tb[1]) {
  941. s.push("translate(" + tb + ")");
  942. } else {
  943. s.push("");
  944. }
  945. if (ra != rb) {
  946. if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;
  947. q.push({
  948. i: s.push(s.pop() + "rotate(", null, ")") - 2,
  949. x: d3.interpolateNumber(ra, rb)
  950. });
  951. } else if (rb) {
  952. s.push(s.pop() + "rotate(" + rb + ")");
  953. }
  954. if (wa != wb) {
  955. q.push({
  956. i: s.push(s.pop() + "skewX(", null, ")") - 2,
  957. x: d3.interpolateNumber(wa, wb)
  958. });
  959. } else if (wb) {
  960. s.push(s.pop() + "skewX(" + wb + ")");
  961. }
  962. if (ka[0] != kb[0] || ka[1] != kb[1]) {
  963. n = s.push(s.pop() + "scale(", null, ",", null, ")");
  964. q.push({
  965. i: n - 4,
  966. x: d3.interpolateNumber(ka[0], kb[0])
  967. }, {
  968. i: n - 2,
  969. x: d3.interpolateNumber(ka[1], kb[1])
  970. });
  971. } else if (kb[0] != 1 || kb[1] != 1) {
  972. s.push(s.pop() + "scale(" + kb + ")");
  973. }
  974. n = q.length;
  975. return function(t) {
  976. var i = -1, o;
  977. while (++i < n) s[(o = q[i]).i] = o.x(t);
  978. return s.join("");
  979. };
  980. };
  981. d3.interpolateRgb = function(a, b) {
  982. a = d3.rgb(a);
  983. b = d3.rgb(b);
  984. var ar = a.r, ag = a.g, ab = a.b, br = b.r - ar, bg = b.g - ag, bb = b.b - ab;
  985. return function(t) {
  986. 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));
  987. };
  988. };
  989. d3.interpolateHsl = function(a, b) {
  990. a = d3.hsl(a);
  991. b = d3.hsl(b);
  992. var h0 = a.h, s0 = a.s, l0 = a.l, h1 = b.h - h0, s1 = b.s - s0, l1 = b.l - l0;
  993. if (h1 > 180) h1 -= 360; else if (h1 < -180) h1 += 360;
  994. return function(t) {
  995. return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t) + "";
  996. };
  997. };
  998. d3.interpolateLab = function(a, b) {
  999. a = d3.lab(a);
  1000. b = d3.lab(b);
  1001. var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab;
  1002. return function(t) {
  1003. return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + "";
  1004. };
  1005. };
  1006. d3.interpolateHcl = function(a, b) {
  1007. a = d3.hcl(a);
  1008. b = d3.hcl(b);
  1009. var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;
  1010. if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
  1011. return function(t) {
  1012. return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + "";
  1013. };
  1014. };
  1015. d3.interpolateArray = function(a, b) {
  1016. var x = [], c = [], na = a.length, nb = b.length, n0 = Math.min(a.length, b.length), i;
  1017. for (i = 0; i < n0; ++i) x.push(d3.interpolate(a[i], b[i]));
  1018. for (;i < na; ++i) c[i] = a[i];
  1019. for (;i < nb; ++i) c[i] = b[i];
  1020. return function(t) {
  1021. for (i = 0; i < n0; ++i) c[i] = x[i](t);
  1022. return c;
  1023. };
  1024. };
  1025. d3.interpolateObject = function(a, b) {
  1026. var i = {}, c = {}, k;
  1027. for (k in a) {
  1028. if (k in b) {
  1029. i[k] = d3_interpolateByName(k)(a[k], b[k]);
  1030. } else {
  1031. c[k] = a[k];
  1032. }
  1033. }
  1034. for (k in b) {
  1035. if (!(k in a)) {
  1036. c[k] = b[k];
  1037. }
  1038. }
  1039. return function(t) {
  1040. for (k in i) c[k] = i[k](t);
  1041. return c;
  1042. };
  1043. };
  1044. var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
  1045. function d3_interpolateByName(name) {
  1046. return name == "transform" ? d3.interpolateTransform : d3.interpolate;
  1047. }
  1048. d3.interpolators = [ d3.interpolateObject, function(a, b) {
  1049. return b instanceof Array && d3.interpolateArray(a, b);
  1050. }, function(a, b) {
  1051. return (typeof a === "string" || typeof b === "string") && d3.interpolateString(a + "", b + "");
  1052. }, function(a, b) {
  1053. return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Color) && d3.interpolateRgb(a, b);
  1054. }, function(a, b) {
  1055. return !isNaN(a = +a) && !isNaN(b = +b) && d3.interpolateNumber(a, b);
  1056. } ];
  1057. function d3_uninterpolateNumber(a, b) {
  1058. b = b - (a = +a) ? 1 / (b - a) : 0;
  1059. return function(x) {
  1060. return (x - a) * b;
  1061. };
  1062. }
  1063. function d3_uninterpolateClamp(a, b) {
  1064. b = b - (a = +a) ? 1 / (b - a) : 0;
  1065. return function(x) {
  1066. return Math.max(0, Math.min(1, (x - a) * b));
  1067. };
  1068. }
  1069. function d3_Color() {}
  1070. d3_Color.prototype.toString = function() {
  1071. return this.rgb() + "";
  1072. };
  1073. d3.rgb = function(r, g, b) {
  1074. 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);
  1075. };
  1076. function d3_rgb(r, g, b) {
  1077. return new d3_Rgb(r, g, b);
  1078. }
  1079. function d3_Rgb(r, g, b) {
  1080. this.r = r;
  1081. this.g = g;
  1082. this.b = b;
  1083. }
  1084. var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color();
  1085. d3_rgbPrototype.brighter = function(k) {
  1086. k = Math.pow(.7, arguments.length ? k : 1);
  1087. var r = this.r, g = this.g, b = this.b, i = 30;
  1088. if (!r && !g && !b) return d3_rgb(i, i, i);
  1089. if (r && r < i) r = i;
  1090. if (g && g < i) g = i;
  1091. if (b && b < i) b = i;
  1092. return d3_rgb(Math.min(255, Math.floor(r / k)), Math.min(255, Math.floor(g / k)), Math.min(255, Math.floor(b / k)));
  1093. };
  1094. d3_rgbPrototype.darker = function(k) {
  1095. k = Math.pow(.7, arguments.length ? k : 1);
  1096. return d3_rgb(Math.floor(k * this.r), Math.floor(k * this.g), Math.floor(k * this.b));
  1097. };
  1098. d3_rgbPrototype.hsl = function() {
  1099. return d3_rgb_hsl(this.r, this.g, this.b);
  1100. };
  1101. d3_rgbPrototype.toString = function() {
  1102. return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
  1103. };
  1104. function d3_rgb_hex(v) {
  1105. return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);
  1106. }
  1107. function d3_rgb_parse(format, rgb, hsl) {
  1108. var r = 0, g = 0, b = 0, m1, m2, name;
  1109. m1 = /([a-z]+)\((.*)\)/i.exec(format);
  1110. if (m1) {
  1111. m2 = m1[2].split(",");
  1112. switch (m1[1]) {
  1113. case "hsl":
  1114. {
  1115. return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100);
  1116. }
  1117. case "rgb":
  1118. {
  1119. return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2]));
  1120. }
  1121. }
  1122. }
  1123. if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b);
  1124. if (format != null && format.charAt(0) === "#") {
  1125. if (format.length === 4) {
  1126. r = format.charAt(1);
  1127. r += r;
  1128. g = format.charAt(2);
  1129. g += g;
  1130. b = format.charAt(3);
  1131. b += b;
  1132. } else if (format.length === 7) {
  1133. r = format.substring(1, 3);
  1134. g = format.substring(3, 5);
  1135. b = format.substring(5, 7);
  1136. }
  1137. r = parseInt(r, 16);
  1138. g = parseInt(g, 16);
  1139. b = parseInt(b, 16);
  1140. }
  1141. return rgb(r, g, b);
  1142. }
  1143. function d3_rgb_hsl(r, g, b) {
  1144. 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;
  1145. if (d) {
  1146. s = l < .5 ? d / (max + min) : d / (2 - max - min);
  1147. 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;
  1148. h *= 60;
  1149. } else {
  1150. s = h = 0;
  1151. }
  1152. return d3_hsl(h, s, l);
  1153. }
  1154. function d3_rgb_lab(r, g, b) {
  1155. r = d3_rgb_xyz(r);
  1156. g = d3_rgb_xyz(g);
  1157. b = d3_rgb_xyz(b);
  1158. 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);
  1159. return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z));
  1160. }
  1161. function d3_rgb_xyz(r) {
  1162. return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4);
  1163. }
  1164. function d3_rgb_parseNumber(c) {
  1165. var f = parseFloat(c);
  1166. return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f;
  1167. }
  1168. var d3_rgb_names = d3.map({
  1169. aliceblue: "#f0f8ff",
  1170. antiquewhite: "#faebd7",
  1171. aqua: "#00ffff",
  1172. aquamarine: "#7fffd4",
  1173. azure: "#f0ffff",
  1174. beige: "#f5f5dc",
  1175. bisque: "#ffe4c4",
  1176. black: "#000000",
  1177. blanchedalmond: "#ffebcd",
  1178. blue: "#0000ff",
  1179. blueviolet: "#8a2be2",
  1180. brown: "#a52a2a",
  1181. burlywood: "#deb887",
  1182. cadetblue: "#5f9ea0",
  1183. chartreuse: "#7fff00",
  1184. chocolate: "#d2691e",
  1185. coral: "#ff7f50",
  1186. cornflowerblue: "#6495ed",
  1187. cornsilk: "#fff8dc",
  1188. crimson: "#dc143c",
  1189. cyan: "#00ffff",
  1190. darkblue: "#00008b",
  1191. darkcyan: "#008b8b",
  1192. darkgoldenrod: "#b8860b",
  1193. darkgray: "#a9a9a9",
  1194. darkgreen: "#006400",
  1195. darkgrey: "#a9a9a9",
  1196. darkkhaki: "#bdb76b",
  1197. darkmagenta: "#8b008b",
  1198. darkolivegreen: "#556b2f",
  1199. darkorange: "#ff8c00",
  1200. darkorchid: "#9932cc",
  1201. darkred: "#8b0000",
  1202. darksalmon: "#e9967a",
  1203. darkseagreen: "#8fbc8f",
  1204. darkslateblue: "#483d8b",
  1205. darkslategray: "#2f4f4f",
  1206. darkslategrey: "#2f4f4f",
  1207. darkturquoise: "#00ced1",
  1208. darkviolet: "#9400d3",
  1209. deeppink: "#ff1493",
  1210. deepskyblue: "#00bfff",
  1211. dimgray: "#696969",
  1212. dimgrey: "#696969",
  1213. dodgerblue: "#1e90ff",
  1214. firebrick: "#b22222",
  1215. floralwhite: "#fffaf0",
  1216. forestgreen: "#228b22",
  1217. fuchsia: "#ff00ff",
  1218. gainsboro: "#dcdcdc",
  1219. ghostwhite: "#f8f8ff",
  1220. gold: "#ffd700",
  1221. goldenrod: "#daa520",
  1222. gray: "#808080",
  1223. green: "#008000",
  1224. greenyellow: "#adff2f",
  1225. grey: "#808080",
  1226. honeydew: "#f0fff0",
  1227. hotpink: "#ff69b4",
  1228. indianred: "#cd5c5c",
  1229. indigo: "#4b0082",
  1230. ivory: "#fffff0",
  1231. khaki: "#f0e68c",
  1232. lavender: "#e6e6fa",
  1233. lavenderblush: "#fff0f5",
  1234. lawngreen: "#7cfc00",
  1235. lemonchiffon: "#fffacd",
  1236. lightblue: "#add8e6",
  1237. lightcoral: "#f08080",
  1238. lightcyan: "#e0ffff",
  1239. lightgoldenrodyellow: "#fafad2",
  1240. lightgray: "#d3d3d3",
  1241. lightgreen: "#90ee90",
  1242. lightgrey: "#d3d3d3",
  1243. lightpink: "#ffb6c1",
  1244. lightsalmon: "#ffa07a",
  1245. lightseagreen: "#20b2aa",
  1246. lightskyblue: "#87cefa",
  1247. lightslategray: "#778899",
  1248. lightslategrey: "#778899",
  1249. lightsteelblue: "#b0c4de",
  1250. lightyellow: "#ffffe0",
  1251. lime: "#00ff00",
  1252. limegreen: "#32cd32",
  1253. linen: "#faf0e6",
  1254. magenta: "#ff00ff",
  1255. maroon: "#800000",
  1256. mediumaquamarine: "#66cdaa",
  1257. mediumblue: "#0000cd",
  1258. mediumorchid: "#ba55d3",
  1259. mediumpurple: "#9370db",
  1260. mediumseagreen: "#3cb371",
  1261. mediumslateblue: "#7b68ee",
  1262. mediumspringgreen: "#00fa9a",
  1263. mediumturquoise: "#48d1cc",
  1264. mediumvioletred: "#c71585",
  1265. midnightblue: "#191970",
  1266. mintcream: "#f5fffa",
  1267. mistyrose: "#ffe4e1",
  1268. moccasin: "#ffe4b5",
  1269. navajowhite: "#ffdead",
  1270. navy: "#000080",
  1271. oldlace: "#fdf5e6",
  1272. olive: "#808000",
  1273. olivedrab: "#6b8e23",
  1274. orange: "#ffa500",
  1275. orangered: "#ff4500",
  1276. orchid: "#da70d6",
  1277. palegoldenrod: "#eee8aa",
  1278. palegreen: "#98fb98",
  1279. paleturquoise: "#afeeee",
  1280. palevioletred: "#db7093",
  1281. papayawhip: "#ffefd5",
  1282. peachpuff: "#ffdab9",
  1283. peru: "#cd853f",
  1284. pink: "#ffc0cb",
  1285. plum: "#dda0dd",
  1286. powderblue: "#b0e0e6",
  1287. purple: "#800080",
  1288. red: "#ff0000",
  1289. rosybrown: "#bc8f8f",
  1290. royalblue: "#4169e1",
  1291. saddlebrown: "#8b4513",
  1292. salmon: "#fa8072",
  1293. sandybrown: "#f4a460",
  1294. seagreen: "#2e8b57",
  1295. seashell: "#fff5ee",
  1296. sienna: "#a0522d",
  1297. silver: "#c0c0c0",
  1298. skyblue: "#87ceeb",
  1299. slateblue: "#6a5acd",
  1300. slategray: "#708090",
  1301. slategrey: "#708090",
  1302. snow: "#fffafa",
  1303. springgreen: "#00ff7f",
  1304. steelblue: "#4682b4",
  1305. tan: "#d2b48c",
  1306. teal: "#008080",
  1307. thistle: "#d8bfd8",
  1308. tomato: "#ff6347",
  1309. turquoise: "#40e0d0",
  1310. violet: "#ee82ee",
  1311. wheat: "#f5deb3",
  1312. white: "#ffffff",
  1313. whitesmoke: "#f5f5f5",
  1314. yellow: "#ffff00",
  1315. yellowgreen: "#9acd32"
  1316. });
  1317. d3_rgb_names.forEach(function(key, value) {
  1318. d3_rgb_names.set(key, d3_rgb_parse(value, d3_rgb, d3_hsl_rgb));
  1319. });
  1320. d3.hsl = function(h, s, l) {
  1321. 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);
  1322. };
  1323. function d3_hsl(h, s, l) {
  1324. return new d3_Hsl(h, s, l);
  1325. }
  1326. function d3_Hsl(h, s, l) {
  1327. this.h = h;
  1328. this.s = s;
  1329. this.l = l;
  1330. }
  1331. var d3_hslPrototype = d3_Hsl.prototype = new d3_Color();
  1332. d3_hslPrototype.brighter = function(k) {
  1333. k = Math.pow(.7, arguments.length ? k : 1);
  1334. return d3_hsl(this.h, this.s, this.l / k);
  1335. };
  1336. d3_hslPrototype.darker = function(k) {
  1337. k = Math.pow(.7, arguments.length ? k : 1);
  1338. return d3_hsl(this.h, this.s, k * this.l);
  1339. };
  1340. d3_hslPrototype.rgb = function() {
  1341. return d3_hsl_rgb(this.h, this.s, this.l);
  1342. };
  1343. function d3_hsl_rgb(h, s, l) {
  1344. var m1, m2;
  1345. h = h % 360;
  1346. if (h < 0) h += 360;
  1347. s = s < 0 ? 0 : s > 1 ? 1 : s;
  1348. l = l < 0 ? 0 : l > 1 ? 1 : l;
  1349. m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
  1350. m1 = 2 * l - m2;
  1351. function v(h) {
  1352. if (h > 360) h -= 360; else if (h < 0) h += 360;
  1353. if (h < 60) return m1 + (m2 - m1) * h / 60;
  1354. if (h < 180) return m2;
  1355. if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
  1356. return m1;
  1357. }
  1358. function vv(h) {
  1359. return Math.round(v(h) * 255);
  1360. }
  1361. return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
  1362. }
  1363. d3.hcl = function(h, c, l) {
  1364. 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);
  1365. };
  1366. function d3_hcl(h, c, l) {
  1367. return new d3_Hcl(h, c, l);
  1368. }
  1369. function d3_Hcl(h, c, l) {
  1370. this.h = h;
  1371. this.c = c;
  1372. this.l = l;
  1373. }
  1374. var d3_hclPrototype = d3_Hcl.prototype = new d3_Color();
  1375. d3_hclPrototype.brighter = function(k) {
  1376. return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
  1377. };
  1378. d3_hclPrototype.darker = function(k) {
  1379. return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
  1380. };
  1381. d3_hclPrototype.rgb = function() {
  1382. return d3_hcl_lab(this.h, this.c, this.l).rgb();
  1383. };
  1384. function d3_hcl_lab(h, c, l) {
  1385. return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
  1386. }
  1387. d3.lab = function(l, a, b) {
  1388. 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);
  1389. };
  1390. function d3_lab(l, a, b) {
  1391. return new d3_Lab(l, a, b);
  1392. }
  1393. function d3_Lab(l, a, b) {
  1394. this.l = l;
  1395. this.a = a;
  1396. this.b = b;
  1397. }
  1398. var d3_lab_K = 18;
  1399. var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;
  1400. var d3_labPrototype = d3_Lab.prototype = new d3_Color();
  1401. d3_labPrototype.brighter = function(k) {
  1402. return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
  1403. };
  1404. d3_labPrototype.darker = function(k) {
  1405. return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
  1406. };
  1407. d3_labPrototype.rgb = function() {
  1408. return d3_lab_rgb(this.l, this.a, this.b);
  1409. };
  1410. function d3_lab_rgb(l, a, b) {
  1411. var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;
  1412. x = d3_lab_xyz(x) * d3_lab_X;
  1413. y = d3_lab_xyz(y) * d3_lab_Y;
  1414. z = d3_lab_xyz(z) * d3_lab_Z;
  1415. 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));
  1416. }
  1417. function d3_lab_hcl(l, a, b) {
  1418. return d3_hcl(Math.atan2(b, a) / π * 180, Math.sqrt(a * a + b * b), l);
  1419. }
  1420. function d3_lab_xyz(x) {
  1421. return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
  1422. }
  1423. function d3_xyz_lab(x) {
  1424. return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;
  1425. }
  1426. function d3_xyz_rgb(r) {
  1427. return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055));
  1428. }
  1429. function d3_selection(groups) {
  1430. d3_arraySubclass(groups, d3_selectionPrototype);
  1431. return groups;
  1432. }
  1433. var d3_select = function(s, n) {
  1434. return n.querySelector(s);
  1435. }, d3_selectAll = function(s, n) {
  1436. return n.querySelectorAll(s);
  1437. }, d3_selectRoot = document.documentElement, d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector, d3_selectMatches = function(n, s) {
  1438. return d3_selectMatcher.call(n, s);
  1439. };
  1440. if (typeof Sizzle === "function") {
  1441. d3_select = function(s, n) {
  1442. return Sizzle(s, n)[0] || null;
  1443. };
  1444. d3_selectAll = function(s, n) {
  1445. return Sizzle.uniqueSort(Sizzle(s, n));
  1446. };
  1447. d3_selectMatches = Sizzle.matchesSelector;
  1448. }
  1449. var d3_selectionPrototype = [];
  1450. d3.selection = function() {
  1451. return d3_selectionRoot;
  1452. };
  1453. d3.selection.prototype = d3_selectionPrototype;
  1454. d3_selectionPrototype.select = function(selector) {
  1455. var subgroups = [], subgroup, subnode, group, node;
  1456. if (typeof selector !== "function") selector = d3_selection_selector(selector);
  1457. for (var j = -1, m = this.length; ++j < m; ) {
  1458. subgroups.push(subgroup = []);
  1459. subgroup.parentNode = (group = this[j]).parentNode;
  1460. for (var i = -1, n = group.length; ++i < n; ) {
  1461. if (node = group[i]) {
  1462. subgroup.push(subnode = selector.call(node, node.__data__, i));
  1463. if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
  1464. } else {
  1465. subgroup.push(null);
  1466. }
  1467. }
  1468. }
  1469. return d3_selection(subgroups);
  1470. };
  1471. function d3_selection_selector(selector) {
  1472. return function() {
  1473. return d3_select(selector, this);
  1474. };
  1475. }
  1476. d3_selectionPrototype.selectAll = function(selector) {
  1477. var subgroups = [], subgroup, node;
  1478. if (typeof selector !== "function") selector = d3_selection_selectorAll(selector);
  1479. for (var j = -1, m = this.length; ++j < m; ) {
  1480. for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
  1481. if (node = group[i]) {
  1482. subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i)));
  1483. subgroup.parentNode = node;
  1484. }
  1485. }
  1486. }
  1487. return d3_selection(subgroups);
  1488. };
  1489. function d3_selection_selectorAll(selector) {
  1490. return function() {
  1491. return d3_selectAll(selector, this);
  1492. };
  1493. }
  1494. d3_selectionPrototype.attr = function(name, value) {
  1495. if (arguments.length < 2) {
  1496. if (typeof name === "string") {
  1497. var node = this.node();
  1498. name = d3.ns.qualify(name);
  1499. return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name);
  1500. }
  1501. for (value in name) this.each(d3_selection_attr(value, name[value]));
  1502. return this;
  1503. }
  1504. return this.each(d3_selection_attr(name, value));
  1505. };
  1506. function d3_selection_attr(name, value) {
  1507. name = d3.ns.qualify(name);
  1508. function attrNull() {
  1509. this.removeAttribute(name);
  1510. }
  1511. function attrNullNS() {
  1512. this.removeAttributeNS(name.space, name.local);
  1513. }
  1514. function attrConstant() {
  1515. this.setAttribute(name, value);
  1516. }
  1517. function attrConstantNS() {
  1518. this.setAttributeNS(name.space, name.local, value);
  1519. }
  1520. function attrFunction() {
  1521. var x = value.apply(this, arguments);
  1522. if (x == null) this.removeAttribute(name); else this.setAttribute(name, x);
  1523. }
  1524. function attrFunctionNS() {
  1525. var x = value.apply(this, arguments);
  1526. if (x == null) this.removeAttributeNS(name.space, name.local); else this.setAttributeNS(name.space, name.local, x);
  1527. }
  1528. return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant;
  1529. }
  1530. d3_selectionPrototype.classed = function(name, value) {
  1531. if (arguments.length < 2) {
  1532. if (typeof name === "string") {
  1533. var node = this.node(), n = (name = name.trim().split(/^|\s+/g)).length, i = -1;
  1534. if (value = node.classList) {
  1535. while (++i < n) if (!value.contains(name[i])) return false;
  1536. } else {
  1537. value = node.className;
  1538. if (value.baseVal != null) value = value.baseVal;
  1539. while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false;
  1540. }
  1541. return true;
  1542. }
  1543. for (value in name) this.each(d3_selection_classed(value, name[value]));
  1544. return this;
  1545. }
  1546. return this.each(d3_selection_classed(name, value));
  1547. };
  1548. function d3_selection_classedRe(name) {
  1549. return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g");
  1550. }
  1551. function d3_selection_classed(name, value) {
  1552. name = name.trim().split(/\s+/).map(d3_selection_classedName);
  1553. var n = name.length;
  1554. function classedConstant() {
  1555. var i = -1;
  1556. while (++i < n) name[i](this, value);
  1557. }
  1558. function classedFunction() {
  1559. var i = -1, x = value.apply(this, arguments);
  1560. while (++i < n) name[i](this, x);
  1561. }
  1562. return typeof value === "function" ? classedFunction : classedConstant;
  1563. }
  1564. function d3_selection_classedName(name) {
  1565. var re = d3_selection_classedRe(name);
  1566. return function(node, value) {
  1567. if (c = node.classList) return value ? c.add(name) : c.remove(name);
  1568. var c = node.className, cb = c.baseVal != null, cv = cb ? c.baseVal : c;
  1569. if (value) {
  1570. re.lastIndex = 0;
  1571. if (!re.test(cv)) {
  1572. cv = d3_collapse(cv + " " + name);
  1573. if (cb) c.baseVal = cv; else node.className = cv;
  1574. }
  1575. } else if (cv) {
  1576. cv = d3_collapse(cv.replace(re, " "));
  1577. if (cb) c.baseVal = cv; else node.className = cv;
  1578. }
  1579. };
  1580. }
  1581. d3_selectionPrototype.style = function(name, value, priority) {
  1582. var n = arguments.length;
  1583. if (n < 3) {
  1584. if (typeof name !== "string") {
  1585. if (n < 2) value = "";
  1586. for (priority in name) this.each(d3_selection_style(priority, name[priority], value));
  1587. return this;
  1588. }
  1589. if (n < 2) return getComputedStyle(this.node(), null).getPropertyValue(name);
  1590. priority = "";
  1591. }
  1592. return this.each(d3_selection_style(name, value, priority));
  1593. };
  1594. function d3_selection_style(name, value, priority) {
  1595. function styleNull() {
  1596. this.style.removeProperty(name);
  1597. }
  1598. function styleConstant() {
  1599. this.style.setProperty(name, value, priority);
  1600. }
  1601. function styleFunction() {
  1602. var x = value.apply(this, arguments);
  1603. if (x == null) this.style.removeProperty(name); else this.style.setProperty(name, x, priority);
  1604. }
  1605. return value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant;
  1606. }
  1607. d3_selectionPrototype.property = function(name, value) {
  1608. if (arguments.length < 2) {
  1609. if (typeof name === "string") return this.node()[name];
  1610. for (value in name) this.each(d3_selection_property(value, name[value]));
  1611. return this;
  1612. }
  1613. return this.each(d3_selection_property(name, value));
  1614. };
  1615. function d3_selection_property(name, value) {
  1616. function propertyNull() {
  1617. delete this[name];
  1618. }
  1619. function propertyConstant() {
  1620. this[name] = value;
  1621. }
  1622. function propertyFunction() {
  1623. var x = value.apply(this, arguments);
  1624. if (x == null) delete this[name]; else this[name] = x;
  1625. }
  1626. return value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant;
  1627. }
  1628. d3_selectionPrototype.text = function(value) {
  1629. return arguments.length ? this.each(typeof value === "function" ? function() {
  1630. var v = value.apply(this, arguments);
  1631. this.textContent = v == null ? "" : v;
  1632. } : value == null ? function() {
  1633. this.textContent = "";
  1634. } : function() {
  1635. this.textContent = value;
  1636. }) : this.node().textContent;
  1637. };
  1638. d3_selectionPrototype.html = function(value) {
  1639. return arguments.length ? this.each(typeof value === "function" ? function() {
  1640. var v = value.apply(this, arguments);
  1641. this.innerHTML = v == null ? "" : v;
  1642. } : value == null ? function() {
  1643. this.innerHTML = "";
  1644. } : function() {
  1645. this.innerHTML = value;
  1646. }) : this.node().innerHTML;
  1647. };
  1648. d3_selectionPrototype.append = function(name) {
  1649. name = d3.ns.qualify(name);
  1650. function append() {
  1651. return this.appendChild(document.createElementNS(this.namespaceURI, name));
  1652. }
  1653. function appendNS() {
  1654. return this.appendChild(document.createElementNS(name.space, name.local));
  1655. }
  1656. return this.select(name.local ? appendNS : append);
  1657. };
  1658. d3_selectionPrototype.insert = function(name, before) {
  1659. name = d3.ns.qualify(name);
  1660. function insert() {
  1661. return this.insertBefore(document.createElementNS(this.namespaceURI, name), d3_select(before, this));
  1662. }
  1663. function insertNS() {
  1664. return this.insertBefore(document.createElementNS(name.space, name.local), d3_select(before, this));
  1665. }
  1666. return this.select(name.local ? insertNS : insert);
  1667. };
  1668. d3_selectionPrototype.remove = function() {
  1669. return this.each(function() {
  1670. var parent = this.parentNode;
  1671. if (parent) parent.removeChild(this);
  1672. });
  1673. };
  1674. d3_selectionPrototype.data = function(value, key) {
  1675. var i = -1, n = this.length, group, node;
  1676. if (!arguments.length) {
  1677. value = new Array(n = (group = this[0]).length);
  1678. while (++i < n) {
  1679. if (node = group[i]) {
  1680. value[i] = node.__data__;
  1681. }
  1682. }
  1683. return value;
  1684. }
  1685. function bind(group, groupData) {
  1686. 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;
  1687. if (key) {
  1688. var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue;
  1689. for (i = -1; ++i < n; ) {
  1690. keyValue = key.call(node = group[i], node.__data__, i);
  1691. if (nodeByKeyValue.has(keyValue)) {
  1692. exitNodes[i] = node;
  1693. } else {
  1694. nodeByKeyValue.set(keyValue, node);
  1695. }
  1696. keyValues.push(keyValue);
  1697. }
  1698. for (i = -1; ++i < m; ) {
  1699. keyValue = key.call(groupData, nodeData = groupData[i], i);
  1700. if (node = nodeByKeyValue.get(keyValue)) {
  1701. updateNodes[i] = node;
  1702. node.__data__ = nodeData;
  1703. } else if (!dataByKeyValue.has(keyValue)) {
  1704. enterNodes[i] = d3_selection_dataNode(nodeData);
  1705. }
  1706. dataByKeyValue.set(keyValue, nodeData);
  1707. nodeByKeyValue.remove(keyValue);
  1708. }
  1709. for (i = -1; ++i < n; ) {
  1710. if (nodeByKeyValue.has(keyValues[i])) {
  1711. exitNodes[i] = group[i];
  1712. }
  1713. }
  1714. } else {
  1715. for (i = -1; ++i < n0; ) {
  1716. node = group[i];
  1717. nodeData = groupData[i];
  1718. if (node) {
  1719. node.__data__ = nodeData;
  1720. updateNodes[i] = node;
  1721. } else {
  1722. enterNodes[i] = d3_selection_dataNode(nodeData);
  1723. }
  1724. }
  1725. for (;i < m; ++i) {
  1726. enterNodes[i] = d3_selection_dataNode(groupData[i]);
  1727. }
  1728. for (;i < n; ++i) {
  1729. exitNodes[i] = group[i];
  1730. }
  1731. }
  1732. enterNodes.update = updateNodes;
  1733. enterNodes.parentNode = updateNodes.parentNode = exitNodes.parentNode = group.parentNode;
  1734. enter.push(enterNodes);
  1735. update.push(updateNodes);
  1736. exit.push(exitNodes);
  1737. }
  1738. var enter = d3_selection_enter([]), update = d3_selection([]), exit = d3_selection([]);
  1739. if (typeof value === "function") {
  1740. while (++i < n) {
  1741. bind(group = this[i], value.call(group, group.parentNode.__data__, i));
  1742. }
  1743. } else {
  1744. while (++i < n) {
  1745. bind(group = this[i], value);
  1746. }
  1747. }
  1748. update.enter = function() {
  1749. return enter;
  1750. };
  1751. update.exit = function() {
  1752. return exit;
  1753. };
  1754. return update;
  1755. };
  1756. function d3_selection_dataNode(data) {
  1757. return {
  1758. __data__: data
  1759. };
  1760. }
  1761. d3_selectionPrototype.datum = function(value) {
  1762. return arguments.length ? this.property("__data__", value) : this.property("__data__");
  1763. };
  1764. d3_selectionPrototype.filter = function(filter) {
  1765. var subgroups = [], subgroup, group, node;
  1766. if (typeof filter !== "function") filter = d3_selection_filter(filter);
  1767. for (var j = 0, m = this.length; j < m; j++) {
  1768. subgroups.push(subgroup = []);
  1769. subgroup.parentNode = (group = this[j]).parentNode;
  1770. for (var i = 0, n = group.length; i < n; i++) {
  1771. if ((node = group[i]) && filter.call(node, node.__data__, i)) {
  1772. subgroup.push(node);
  1773. }
  1774. }
  1775. }
  1776. return d3_selection(subgroups);
  1777. };
  1778. function d3_selection_filter(selector) {
  1779. return function() {
  1780. return d3_selectMatches(this, selector);
  1781. };
  1782. }
  1783. d3_selectionPrototype.order = function() {
  1784. for (var j = -1, m = this.length; ++j < m; ) {
  1785. for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0; ) {
  1786. if (node = group[i]) {
  1787. if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
  1788. next = node;
  1789. }
  1790. }
  1791. }
  1792. return this;
  1793. };
  1794. d3_selectionPrototype.sort = function(comparator) {
  1795. comparator = d3_selection_sortComparator.apply(this, arguments);
  1796. for (var j = -1, m = this.length; ++j < m; ) this[j].sort(comparator);
  1797. return this.order();
  1798. };
  1799. function d3_selection_sortComparator(comparator) {
  1800. if (!arguments.length) comparator = d3.ascending;
  1801. return function(a, b) {
  1802. return comparator(a && a.__data__, b && b.__data__);
  1803. };
  1804. }
  1805. d3_selectionPrototype.on = function(type, listener, capture) {
  1806. var n = arguments.length;
  1807. if (n < 3) {
  1808. if (typeof type !== "string") {
  1809. if (n < 2) listener = false;
  1810. for (capture in type) this.each(d3_selection_on(capture, type[capture], listener));
  1811. return this;
  1812. }
  1813. if (n < 2) return (n = this.node()["__on" + type]) && n._;
  1814. capture = false;
  1815. }
  1816. return this.each(d3_selection_on(type, listener, capture));
  1817. };
  1818. function d3_selection_on(type, listener, capture) {
  1819. var name = "__on" + type, i = type.indexOf(".");
  1820. if (i > 0) type = type.substring(0, i);
  1821. function onRemove() {
  1822. var wrapper = this[name];
  1823. if (wrapper) {
  1824. this.removeEventListener(type, wrapper, wrapper.$);
  1825. delete this[name];
  1826. }
  1827. }
  1828. function onAdd() {
  1829. var node = this, args = d3_array(arguments);
  1830. onRemove.call(this);
  1831. this.addEventListener(type, this[name] = wrapper, wrapper.$ = capture);
  1832. wrapper._ = listener;
  1833. function wrapper(e) {
  1834. var o = d3.event;
  1835. d3.event = e;
  1836. args[0] = node.__data__;
  1837. try {
  1838. listener.apply(node, args);
  1839. } finally {
  1840. d3.event = o;
  1841. }
  1842. }
  1843. }
  1844. return listener ? onAdd : onRemove;
  1845. }
  1846. d3_selectionPrototype.each = function(callback) {
  1847. return d3_selection_each(this, function(node, i, j) {
  1848. callback.call(node, node.__data__, i, j);
  1849. });
  1850. };
  1851. function d3_selection_each(groups, callback) {
  1852. for (var j = 0, m = groups.length; j < m; j++) {
  1853. for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {
  1854. if (node = group[i]) callback(node, i, j);
  1855. }
  1856. }
  1857. return groups;
  1858. }
  1859. d3_selectionPrototype.call = function(callback) {
  1860. var args = d3_array(arguments);
  1861. callback.apply(args[0] = this, args);
  1862. return this;
  1863. };
  1864. d3_selectionPrototype.empty = function() {
  1865. return !this.node();
  1866. };
  1867. d3_selectionPrototype.node = function() {
  1868. for (var j = 0, m = this.length; j < m; j++) {
  1869. for (var group = this[j], i = 0, n = group.length; i < n; i++) {
  1870. var node = group[i];
  1871. if (node) return node;
  1872. }
  1873. }
  1874. return null;
  1875. };
  1876. d3_selectionPrototype.transition = function() {
  1877. var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = Object.create(d3_transitionInherit);
  1878. transition.time = Date.now();
  1879. for (var j = -1, m = this.length; ++j < m; ) {
  1880. subgroups.push(subgroup = []);
  1881. for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
  1882. if (node = group[i]) d3_transitionNode(node, i, id, transition);
  1883. subgroup.push(node);
  1884. }
  1885. }
  1886. return d3_transition(subgroups, id);
  1887. };
  1888. var d3_selectionRoot = d3_selection([ [ document ] ]);
  1889. d3_selectionRoot[0].parentNode = d3_selectRoot;
  1890. d3.select = function(selector) {
  1891. return typeof selector === "string" ? d3_selectionRoot.select(selector) : d3_selection([ [ selector ] ]);
  1892. };
  1893. d3.selectAll = function(selector) {
  1894. return typeof selector === "string" ? d3_selectionRoot.selectAll(selector) : d3_selection([ d3_array(selector) ]);
  1895. };
  1896. function d3_selection_enter(selection) {
  1897. d3_arraySubclass(selection, d3_selection_enterPrototype);
  1898. return selection;
  1899. }
  1900. var d3_selection_enterPrototype = [];
  1901. d3.selection.enter = d3_selection_enter;
  1902. d3.selection.enter.prototype = d3_selection_enterPrototype;
  1903. d3_selection_enterPrototype.append = d3_selectionPrototype.append;
  1904. d3_selection_enterPrototype.insert = d3_selectionPrototype.insert;
  1905. d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
  1906. d3_selection_enterPrototype.node = d3_selectionPrototype.node;
  1907. d3_selection_enterPrototype.select = function(selector) {
  1908. var subgroups = [], subgroup, subnode, upgroup, group, node;
  1909. for (var j = -1, m = this.length; ++j < m; ) {
  1910. upgroup = (group = this[j]).update;
  1911. subgroups.push(subgroup = []);
  1912. subgroup.parentNode = group.parentNode;
  1913. for (var i = -1, n = group.length; ++i < n; ) {
  1914. if (node = group[i]) {
  1915. subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i));
  1916. subnode.__data__ = node.__data__;
  1917. } else {
  1918. subgroup.push(null);
  1919. }
  1920. }
  1921. }
  1922. return d3_selection(subgroups);
  1923. };
  1924. function d3_transition(groups, id) {
  1925. d3_arraySubclass(groups, d3_transitionPrototype);
  1926. groups.id = id;
  1927. return groups;
  1928. }
  1929. var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit = {
  1930. ease: d3_ease_cubicInOut,
  1931. delay: 0,
  1932. duration: 250
  1933. };
  1934. d3_transitionPrototype.call = d3_selectionPrototype.call;
  1935. d3_transitionPrototype.empty = d3_selectionPrototype.empty;
  1936. d3_transitionPrototype.node = d3_selectionPrototype.node;
  1937. d3.transition = function(selection) {
  1938. return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition();
  1939. };
  1940. d3.transition.prototype = d3_transitionPrototype;
  1941. function d3_transitionNode(node, i, id, inherit) {
  1942. var lock = node.__transition__ || (node.__transition__ = {
  1943. active: 0,
  1944. count: 0
  1945. }), transition = lock[id];
  1946. if (!transition) {
  1947. var time = inherit.time;
  1948. transition = lock[id] = {
  1949. tween: new d3_Map(),
  1950. event: d3.dispatch("start", "end"),
  1951. time: time,
  1952. ease: inherit.ease,
  1953. delay: inherit.delay,
  1954. duration: inherit.duration
  1955. };
  1956. ++lock.count;
  1957. d3.timer(function(elapsed) {
  1958. var d = node.__data__, ease = transition.ease, event = transition.event, delay = transition.delay, duration = transition.duration, tweened = [];
  1959. return delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time), 1;
  1960. function start(elapsed) {
  1961. if (lock.active > id) return stop();
  1962. lock.active = id;
  1963. event.start.call(node, d, i);
  1964. transition.tween.forEach(function(key, value) {
  1965. if (value = value.call(node, d, i)) {
  1966. tweened.push(value);
  1967. }
  1968. });
  1969. if (!tick(elapsed)) d3.timer(tick, 0, time);
  1970. return 1;
  1971. }
  1972. function tick(elapsed) {
  1973. if (lock.active !== id) return stop();
  1974. var t = (elapsed - delay) / duration, e = ease(t), n = tweened.length;
  1975. while (n > 0) {
  1976. tweened[--n].call(node, e);
  1977. }
  1978. if (t >= 1) {
  1979. stop();
  1980. event.end.call(node, d, i);
  1981. return 1;
  1982. }
  1983. }
  1984. function stop() {
  1985. if (--lock.count) delete lock[id]; else delete node.__transition__;
  1986. return 1;
  1987. }
  1988. }, 0, time);
  1989. return transition;
  1990. }
  1991. }
  1992. d3_transitionPrototype.select = function(selector) {
  1993. var id = this.id, subgroups = [], subgroup, subnode, node;
  1994. if (typeof selector !== "function") selector = d3_selection_selector(selector);
  1995. for (var j = -1, m = this.length; ++j < m; ) {
  1996. subgroups.push(subgroup = []);
  1997. for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
  1998. if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i))) {
  1999. if ("__data__" in node) subnode.__data__ = node.__data__;
  2000. d3_transitionNode(subnode, i, id, node.__transition__[id]);
  2001. subgroup.push(subnode);
  2002. } else {
  2003. subgroup.push(null);
  2004. }
  2005. }
  2006. }
  2007. return d3_transition(subgroups, id);
  2008. };
  2009. d3_transitionPrototype.selectAll = function(selector) {
  2010. var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition;
  2011. if (typeof selector !== "function") selector = d3_selection_selectorAll(selector);
  2012. for (var j = -1, m = this.length; ++j < m; ) {
  2013. for (var group = this[j], i = -1, n = group.length; ++i < n; ) {
  2014. if (node = group[i]) {
  2015. transition = node.__transition__[id];
  2016. subnodes = selector.call(node, node.__data__, i);
  2017. subgroups.push(subgroup = []);
  2018. for (var k = -1, o = subnodes.length; ++k < o; ) {
  2019. d3_transitionNode(subnode = subnodes[k], k, id, transition);
  2020. subgroup.push(subnode);
  2021. }
  2022. }
  2023. }
  2024. }
  2025. return d3_transition(subgroups, id);
  2026. };
  2027. d3_transitionPrototype.filter = function(filter) {
  2028. var subgroups = [], subgroup, group, node;
  2029. if (typeof filter !== "function") filter = d3_selection_filter(filter);
  2030. for (var j = 0, m = this.length; j < m; j++) {
  2031. subgroups.push(subgroup = []);
  2032. for (var group = this[j], i = 0, n = group.length; i < n; i++) {
  2033. if ((node = group[i]) && filter.call(node, node.__data__, i)) {
  2034. subgroup.push(node);
  2035. }
  2036. }
  2037. }
  2038. return d3_transition(subgroups, this.id, this.time).ease(this.ease());
  2039. };
  2040. d3_transitionPrototype.attr = function(nameNS, value) {
  2041. if (arguments.length < 2) {
  2042. for (value in nameNS) this.attr(value, nameNS[value]);
  2043. return this;
  2044. }
  2045. var interpolate = d3_interpolateByName(nameNS), name = d3.ns.qualify(nameNS);
  2046. function attrNull() {
  2047. this.removeAttribute(name);
  2048. }
  2049. function attrNullNS() {
  2050. this.removeAttributeNS(name.space, name.local);
  2051. }
  2052. return d3_transition_tween(this, "attr." + nameNS, value, function(b) {
  2053. function attrString() {
  2054. var a = this.getAttribute(name), i;
  2055. return a !== b && (i = interpolate(a, b), function(t) {
  2056. this.setAttribute(name, i(t));
  2057. });
  2058. }
  2059. function attrStringNS() {
  2060. var a = this.getAttributeNS(name.space, name.local), i;
  2061. return a !== b && (i = interpolate(a, b), function(t) {
  2062. this.setAttributeNS(name.space, name.local, i(t));
  2063. });
  2064. }
  2065. return b == null ? name.local ? attrNullNS : attrNull : (b += "", name.local ? attrStringNS : attrString);
  2066. });
  2067. };
  2068. d3_transitionPrototype.attrTween = function(nameNS, tween) {
  2069. var name = d3.ns.qualify(nameNS);
  2070. function attrTween(d, i) {
  2071. var f = tween.call(this, d, i, this.getAttribute(name));
  2072. return f && function(t) {
  2073. this.setAttribute(name, f(t));
  2074. };
  2075. }
  2076. function attrTweenNS(d, i) {
  2077. var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
  2078. return f && function(t) {
  2079. this.setAttributeNS(name.space, name.local, f(t));
  2080. };
  2081. }
  2082. return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
  2083. };
  2084. d3_transitionPrototype.style = function(name, value, priority) {
  2085. var n = arguments.length;
  2086. if (n < 3) {
  2087. if (typeof name !== "string") {
  2088. if (n < 2) value = "";
  2089. for (priority in name) this.style(priority, name[priority], value);
  2090. return this;
  2091. }
  2092. priority = "";
  2093. }
  2094. var interpolate = d3_interpolateByName(name);
  2095. function styleNull() {
  2096. this.style.removeProperty(name);
  2097. }
  2098. return d3_transition_tween(this, "style." + name, value, function(b) {
  2099. function styleString() {
  2100. var a = getComputedStyle(this, null).getPropertyValue(name), i;
  2101. return a !== b && (i = interpolate(a, b), function(t) {
  2102. this.style.setProperty(name, i(t), priority);
  2103. });
  2104. }
  2105. return b == null ? styleNull : (b += "", styleString);
  2106. });
  2107. };
  2108. d3_transitionPrototype.styleTween = function(name, tween, priority) {
  2109. if (arguments.length < 3) priority = "";
  2110. return this.tween("style." + name, function(d, i) {
  2111. var f = tween.call(this, d, i, getComputedStyle(this, null).getPropertyValue(name));
  2112. return f && function(t) {
  2113. this.style.setProperty(name, f(t), priority);
  2114. };
  2115. });
  2116. };
  2117. d3_transitionPrototype.text = function(value) {
  2118. return d3_transition_tween(this, "text", value, d3_transition_text);
  2119. };
  2120. function d3_transition_text(b) {
  2121. if (b == null) b = "";
  2122. return function() {
  2123. this.textContent = b;
  2124. };
  2125. }
  2126. d3_transitionPrototype.remove = function() {
  2127. return this.each("end.transition", function() {
  2128. var p;
  2129. if (!this.__transition__ && (p = this.parentNode)) p.removeChild(this);
  2130. });
  2131. };
  2132. d3_transitionPrototype.ease = function(value) {
  2133. var id = this.id;
  2134. if (arguments.length < 1) return this.node().__transition__[id].ease;
  2135. if (typeof value !== "function") value = d3.ease.apply(d3, arguments);
  2136. return d3_selection_each(this, function(node) {
  2137. node.__transition__[id].ease = value;
  2138. });
  2139. };
  2140. d3_transitionPrototype.delay = function(value) {
  2141. var id = this.id;
  2142. return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
  2143. node.__transition__[id].delay = value.call(node, node.__data__, i, j) | 0;
  2144. } : (value |= 0, function(node) {
  2145. node.__transition__[id].delay = value;
  2146. }));
  2147. };
  2148. d3_transitionPrototype.duration = function(value) {
  2149. var id = this.id;
  2150. return d3_selection_each(this, typeof value === "function" ? function(node, i, j) {
  2151. node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j) | 0);
  2152. } : (value = Math.max(1, value | 0), function(node) {
  2153. node.__transition__[id].duration = value;
  2154. }));
  2155. };
  2156. d3_transitionPrototype.each = function(type, listener) {
  2157. var id = this.id;
  2158. if (arguments.length < 2) {
  2159. var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId;
  2160. d3_transitionInheritId = id;
  2161. d3_selection_each(this, function(node, i, j) {
  2162. d3_transitionInherit = node.__transition__[id];
  2163. type.call(node, node.__data__, i, j);
  2164. });
  2165. d3_transitionInherit = inherit;
  2166. d3_transitionInheritId = inheritId;
  2167. } else {
  2168. d3_selection_each(this, function(node) {
  2169. node.__transition__[id].event.on(type, listener);
  2170. });
  2171. }
  2172. return this;
  2173. };
  2174. d3_transitionPrototype.transition = function() {
  2175. var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition;
  2176. for (var j = 0, m = this.length; j < m; j++) {
  2177. subgroups.push(subgroup = []);
  2178. for (var group = this[j], i = 0, n = group.length; i < n; i++) {
  2179. if (node = group[i]) {
  2180. transition = Object.create(node.__transition__[id0]);
  2181. transition.delay += transition.duration;
  2182. d3_transitionNode(node, i, id1, transition);
  2183. }
  2184. subgroup.push(node);
  2185. }
  2186. }
  2187. return d3_transition(subgroups, id1);
  2188. };
  2189. d3_transitionPrototype.tween = function(name, tween) {
  2190. var id = this.id;
  2191. if (arguments.length < 2) return this.node().__transition__[id].tween.get(name);
  2192. return d3_selection_each(this, tween == null ? function(node) {
  2193. node.__transition__[id].tween.remove(name);
  2194. } : function(node) {
  2195. node.__transition__[id].tween.set(name, tween);
  2196. });
  2197. };
  2198. function d3_transition_tween(groups, name, value, tween) {
  2199. var id = groups.id;
  2200. return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) {
  2201. node.__transition__[id].tween.set(name, tween(value.call(node, node.__data__, i, j)));
  2202. } : (value = tween(value), function(node) {
  2203. node.__transition__[id].tween.set(name, value);
  2204. }));
  2205. }
  2206. var d3_timer_id = 0, d3_timer_byId = {}, d3_timer_queue = null, d3_timer_interval, d3_timer_timeout;
  2207. d3.timer = function(callback, delay, then) {
  2208. if (arguments.length < 3) {
  2209. if (arguments.length < 2) delay = 0; else if (!isFinite(delay)) return;
  2210. then = Date.now();
  2211. }
  2212. var timer = d3_timer_byId[callback.id];
  2213. if (timer && timer.callback === callback) {
  2214. timer.then = then;
  2215. timer.delay = delay;
  2216. } else d3_timer_byId[callback.id = ++d3_timer_id] = d3_timer_queue = {
  2217. callback: callback,
  2218. then: then,
  2219. delay: delay,
  2220. next: d3_timer_queue
  2221. };
  2222. if (!d3_timer_interval) {
  2223. d3_timer_timeout = clearTimeout(d3_timer_timeout);
  2224. d3_timer_interval = 1;
  2225. d3_timer_frame(d3_timer_step);
  2226. }
  2227. };
  2228. function d3_timer_step() {
  2229. var elapsed, now = Date.now(), t1 = d3_timer_queue;
  2230. while (t1) {
  2231. elapsed = now - t1.then;
  2232. if (elapsed >= t1.delay) t1.flush = t1.callback(elapsed);
  2233. t1 = t1.next;
  2234. }
  2235. var delay = d3_timer_flush() - now;
  2236. if (delay > 24) {
  2237. if (isFinite(delay)) {
  2238. clearTimeout(d3_timer_timeout);
  2239. d3_timer_timeout = setTimeout(d3_timer_step, delay);
  2240. }
  2241. d3_timer_interval = 0;
  2242. } else {
  2243. d3_timer_interval = 1;
  2244. d3_timer_frame(d3_timer_step);
  2245. }
  2246. }
  2247. d3.timer.flush = function() {
  2248. var elapsed, now = Date.now(), t1 = d3_timer_queue;
  2249. while (t1) {
  2250. elapsed = now - t1.then;
  2251. if (!t1.delay) t1.flush = t1.callback(elapsed);
  2252. t1 = t1.next;
  2253. }
  2254. d3_timer_flush();
  2255. };
  2256. function d3_timer_flush() {
  2257. var t0 = null, t1 = d3_timer_queue, then = Infinity;
  2258. while (t1) {
  2259. if (t1.flush) {
  2260. delete d3_timer_byId[t1.callback.id];
  2261. t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
  2262. } else {
  2263. then = Math.min(then, t1.then + t1.delay);
  2264. t1 = (t0 = t1).next;
  2265. }
  2266. }
  2267. return then;
  2268. }
  2269. var d3_timer_frame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
  2270. setTimeout(callback, 17);
  2271. };
  2272. d3.mouse = function(container) {
  2273. return d3_mousePoint(container, d3_eventSource());
  2274. };
  2275. var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0;
  2276. function d3_mousePoint(container, e) {
  2277. var svg = container.ownerSVGElement || container;
  2278. if (svg.createSVGPoint) {
  2279. var point = svg.createSVGPoint();
  2280. if (d3_mouse_bug44083 < 0 && (window.scrollX || window.scrollY)) {
  2281. svg = d3.select(document.body).append("svg").style("position", "absolute").style("top", 0).style("left", 0);
  2282. var ctm = svg[0][0].getScreenCTM();
  2283. d3_mouse_bug44083 = !(ctm.f || ctm.e);
  2284. svg.remove();
  2285. }
  2286. if (d3_mouse_bug44083) {
  2287. point.x = e.pageX;
  2288. point.y = e.pageY;
  2289. } else {
  2290. point.x = e.clientX;
  2291. point.y = e.clientY;
  2292. }
  2293. point = point.matrixTransform(container.getScreenCTM().inverse());
  2294. return [ point.x, point.y ];
  2295. }
  2296. var rect = container.getBoundingClientRect();
  2297. return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ];
  2298. }
  2299. d3.touches = function(container, touches) {
  2300. if (arguments.length < 2) touches = d3_eventSource().touches;
  2301. return touches ? d3_array(touches).map(function(touch) {
  2302. var point = d3_mousePoint(container, touch);
  2303. point.identifier = touch.identifier;
  2304. return point;
  2305. }) : [];
  2306. };
  2307. function d3_noop() {}
  2308. d3.scale = {};
  2309. function d3_scaleExtent(domain) {
  2310. var start = domain[0], stop = domain[domain.length - 1];
  2311. return start < stop ? [ start, stop ] : [ stop, start ];
  2312. }
  2313. function d3_scaleRange(scale) {
  2314. return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
  2315. }
  2316. function d3_scale_nice(domain, nice) {
  2317. var i0 = 0, i1 = domain.length - 1, x0 = domain[i0], x1 = domain[i1], dx;
  2318. if (x1 < x0) {
  2319. dx = i0, i0 = i1, i1 = dx;
  2320. dx = x0, x0 = x1, x1 = dx;
  2321. }
  2322. if (nice = nice(x1 - x0)) {
  2323. domain[i0] = nice.floor(x0);
  2324. domain[i1] = nice.ceil(x1);
  2325. }
  2326. return domain;
  2327. }
  2328. function d3_scale_niceDefault() {
  2329. return Math;
  2330. }
  2331. d3.scale.linear = function() {
  2332. return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3.interpolate, false);
  2333. };
  2334. function d3_scale_linear(domain, range, interpolate, clamp) {
  2335. var output, input;
  2336. function rescale() {
  2337. var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear, uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
  2338. output = linear(domain, range, uninterpolate, interpolate);
  2339. input = linear(range, domain, uninterpolate, d3.interpolate);
  2340. return scale;
  2341. }
  2342. function scale(x) {
  2343. return output(x);
  2344. }
  2345. scale.invert = function(y) {
  2346. return input(y);
  2347. };
  2348. scale.domain = function(x) {
  2349. if (!arguments.length) return domain;
  2350. domain = x.map(Number);
  2351. return rescale();
  2352. };
  2353. scale.range = function(x) {
  2354. if (!arguments.length) return range;
  2355. range = x;
  2356. return rescale();
  2357. };
  2358. scale.rangeRound = function(x) {
  2359. return scale.range(x).interpolate(d3.interpolateRound);
  2360. };
  2361. scale.clamp = function(x) {
  2362. if (!arguments.length) return clamp;
  2363. clamp = x;
  2364. return rescale();
  2365. };
  2366. scale.interpolate = function(x) {
  2367. if (!arguments.length) return interpolate;
  2368. interpolate = x;
  2369. return rescale();
  2370. };
  2371. scale.ticks = function(m) {
  2372. return d3_scale_linearTicks(domain, m);
  2373. };
  2374. scale.tickFormat = function(m) {
  2375. return d3_scale_linearTickFormat(domain, m);
  2376. };
  2377. scale.nice = function() {
  2378. d3_scale_nice(domain, d3_scale_linearNice);
  2379. return rescale();
  2380. };
  2381. scale.copy = function() {
  2382. return d3_scale_linear(domain, range, interpolate, clamp);
  2383. };
  2384. return rescale();
  2385. }
  2386. function d3_scale_linearRebind(scale, linear) {
  2387. return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
  2388. }
  2389. function d3_scale_linearNice(dx) {
  2390. dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
  2391. return dx && {
  2392. floor: function(x) {
  2393. return Math.floor(x / dx) * dx;
  2394. },
  2395. ceil: function(x) {
  2396. return Math.ceil(x / dx) * dx;
  2397. }
  2398. };
  2399. }
  2400. function d3_scale_linearTickRange(domain, m) {
  2401. 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;
  2402. if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2;
  2403. extent[0] = Math.ceil(extent[0] / step) * step;
  2404. extent[1] = Math.floor(extent[1] / step) * step + step * .5;
  2405. extent[2] = step;
  2406. return extent;
  2407. }
  2408. function d3_scale_linearTicks(domain, m) {
  2409. return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));
  2410. }
  2411. function d3_scale_linearTickFormat(domain, m) {
  2412. return d3.format(",." + Math.max(0, -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01)) + "f");
  2413. }
  2414. function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {
  2415. var u = uninterpolate(domain[0], domain[1]), i = interpolate(range[0], range[1]);
  2416. return function(x) {
  2417. return i(u(x));
  2418. };
  2419. }
  2420. function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
  2421. var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1;
  2422. if (domain[k] < domain[0]) {
  2423. domain = domain.slice().reverse();
  2424. range = range.slice().reverse();
  2425. }
  2426. while (++j <= k) {
  2427. u.push(uninterpolate(domain[j - 1], domain[j]));
  2428. i.push(interpolate(range[j - 1], range[j]));
  2429. }
  2430. return function(x) {
  2431. var j = d3.bisect(domain, x, 1, k) - 1;
  2432. return i[j](u[j](x));
  2433. };
  2434. }
  2435. d3.scale.log = function() {
  2436. return d3_scale_log(d3.scale.linear(), d3_scale_logp);
  2437. };
  2438. function d3_scale_log(linear, log) {
  2439. var pow = log.pow;
  2440. function scale(x) {
  2441. return linear(log(x));
  2442. }
  2443. scale.invert = function(x) {
  2444. return pow(linear.invert(x));
  2445. };
  2446. scale.domain = function(x) {
  2447. if (!arguments.length) return linear.domain().map(pow);
  2448. log = x[0] < 0 ? d3_scale_logn : d3_scale_logp;
  2449. pow = log.pow;
  2450. linear.domain(x.map(log));
  2451. return scale;
  2452. };
  2453. scale.nice = function() {
  2454. linear.domain(d3_scale_nice(linear.domain(), d3_scale_niceDefault));
  2455. return scale;
  2456. };
  2457. scale.ticks = function() {
  2458. var extent = d3_scaleExtent(linear.domain()), ticks = [];
  2459. if (extent.every(isFinite)) {
  2460. var i = Math.floor(extent[0]), j = Math.ceil(extent[1]), u = pow(extent[0]), v = pow(extent[1]);
  2461. if (log === d3_scale_logn) {
  2462. ticks.push(pow(i));
  2463. for (;i++ < j; ) for (var k = 9; k > 0; k--) ticks.push(pow(i) * k);
  2464. } else {
  2465. for (;i < j; i++) for (var k = 1; k < 10; k++) ticks.push(pow(i) * k);
  2466. ticks.push(pow(i));
  2467. }
  2468. for (i = 0; ticks[i] < u; i++) {}
  2469. for (j = ticks.length; ticks[j - 1] > v; j--) {}
  2470. ticks = ticks.slice(i, j);
  2471. }
  2472. return ticks;
  2473. };
  2474. scale.tickFormat = function(n, format) {
  2475. if (arguments.length < 2) format = d3_scale_logFormat;
  2476. if (!arguments.length) return format;
  2477. var k = Math.max(.1, n / scale.ticks().length), f = log === d3_scale_logn ? (e = -1e-12,
  2478. Math.floor) : (e = 1e-12, Math.ceil), e;
  2479. return function(d) {
  2480. return d / pow(f(log(d) + e)) <= k ? format(d) : "";
  2481. };
  2482. };
  2483. scale.copy = function() {
  2484. return d3_scale_log(linear.copy(), log);
  2485. };
  2486. return d3_scale_linearRebind(scale, linear);
  2487. }
  2488. var d3_scale_logFormat = d3.format(".0e");
  2489. function d3_scale_logp(x) {
  2490. return Math.log(x < 0 ? 0 : x) / Math.LN10;
  2491. }
  2492. function d3_scale_logn(x) {
  2493. return -Math.log(x > 0 ? 0 : -x) / Math.LN10;
  2494. }
  2495. d3_scale_logp.pow = function(x) {
  2496. return Math.pow(10, x);
  2497. };
  2498. d3_scale_logn.pow = function(x) {
  2499. return -Math.pow(10, -x);
  2500. };
  2501. d3.scale.pow = function() {
  2502. return d3_scale_pow(d3.scale.linear(), 1);
  2503. };
  2504. function d3_scale_pow(linear, exponent) {
  2505. var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent);
  2506. function scale(x) {
  2507. return linear(powp(x));
  2508. }
  2509. scale.invert = function(x) {
  2510. return powb(linear.invert(x));
  2511. };
  2512. scale.domain = function(x) {
  2513. if (!arguments.length) return linear.domain().map(powb);
  2514. linear.domain(x.map(powp));
  2515. return scale;
  2516. };
  2517. scale.ticks = function(m) {
  2518. return d3_scale_linearTicks(scale.domain(), m);
  2519. };
  2520. scale.tickFormat = function(m) {
  2521. return d3_scale_linearTickFormat(scale.domain(), m);
  2522. };
  2523. scale.nice = function() {
  2524. return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
  2525. };
  2526. scale.exponent = function(x) {
  2527. if (!arguments.length) return exponent;
  2528. var domain = scale.domain();
  2529. powp = d3_scale_powPow(exponent = x);
  2530. powb = d3_scale_powPow(1 / exponent);
  2531. return scale.domain(domain);
  2532. };
  2533. scale.copy = function() {
  2534. return d3_scale_pow(linear.copy(), exponent);
  2535. };
  2536. return d3_scale_linearRebind(scale, linear);
  2537. }
  2538. function d3_scale_powPow(e) {
  2539. return function(x) {
  2540. return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
  2541. };
  2542. }
  2543. d3.scale.sqrt = function() {
  2544. return d3.scale.pow().exponent(.5);
  2545. };
  2546. d3.scale.ordinal = function() {
  2547. return d3_scale_ordinal([], {
  2548. t: "range",
  2549. a: [ [] ]
  2550. });
  2551. };
  2552. function d3_scale_ordinal(domain, ranger) {
  2553. var index, range, rangeBand;
  2554. function scale(x) {
  2555. return range[((index.get(x) || index.set(x, domain.push(x))) - 1) % range.length];
  2556. }
  2557. function steps(start, step) {
  2558. return d3.range(domain.length).map(function(i) {
  2559. return start + step * i;
  2560. });
  2561. }
  2562. scale.domain = function(x) {
  2563. if (!arguments.length) return domain;
  2564. domain = [];
  2565. index = new d3_Map();
  2566. var i = -1, n = x.length, xi;
  2567. while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));
  2568. return scale[ranger.t].apply(scale, ranger.a);
  2569. };
  2570. scale.range = function(x) {
  2571. if (!arguments.length) return range;
  2572. range = x;
  2573. rangeBand = 0;
  2574. ranger = {
  2575. t: "range",
  2576. a: arguments
  2577. };
  2578. return scale;
  2579. };
  2580. scale.rangePoints = function(x, padding) {
  2581. if (arguments.length < 2) padding = 0;
  2582. var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding);
  2583. range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
  2584. rangeBand = 0;
  2585. ranger = {
  2586. t: "rangePoints",
  2587. a: arguments
  2588. };
  2589. return scale;
  2590. };
  2591. scale.rangeBands = function(x, padding, outerPadding) {
  2592. if (arguments.length < 2) padding = 0;
  2593. if (arguments.length < 3) outerPadding = padding;
  2594. var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding);
  2595. range = steps(start + step * outerPadding, step);
  2596. if (reverse) range.reverse();
  2597. rangeBand = step * (1 - padding);
  2598. ranger = {
  2599. t: "rangeBands",
  2600. a: arguments
  2601. };
  2602. return scale;
  2603. };
  2604. scale.rangeRoundBands = function(x, padding, outerPadding) {
  2605. if (arguments.length < 2) padding = 0;
  2606. if (arguments.length < 3) outerPadding = padding;
  2607. 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;
  2608. range = steps(start + Math.round(error / 2), step);
  2609. if (reverse) range.reverse();
  2610. rangeBand = Math.round(step * (1 - padding));
  2611. ranger = {
  2612. t: "rangeRoundBands",
  2613. a: arguments
  2614. };
  2615. return scale;
  2616. };
  2617. scale.rangeBand = function() {
  2618. return rangeBand;
  2619. };
  2620. scale.rangeExtent = function() {
  2621. return d3_scaleExtent(ranger.a[0]);
  2622. };
  2623. scale.copy = function() {
  2624. return d3_scale_ordinal(domain, ranger);
  2625. };
  2626. return scale.domain(domain);
  2627. }
  2628. d3.scale.category10 = function() {
  2629. return d3.scale.ordinal().range(d3_category10);
  2630. };
  2631. d3.scale.category20 = function() {
  2632. return d3.scale.ordinal().range(d3_category20);
  2633. };
  2634. d3.scale.category20b = function() {
  2635. return d3.scale.ordinal().range(d3_category20b);
  2636. };
  2637. d3.scale.category20c = function() {
  2638. return d3.scale.ordinal().range(d3_category20c);
  2639. };
  2640. var d3_category10 = [ "#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf" ];
  2641. var d3_category20 = [ "#1f77b4", "#aec7e8", "#ff7f0e", "#ffbb78", "#2ca02c", "#98df8a", "#d62728", "#ff9896", "#9467bd", "#c5b0d5", "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", "#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5" ];
  2642. var d3_category20b = [ "#393b79", "#5254a3", "#6b6ecf", "#9c9ede", "#637939", "#8ca252", "#b5cf6b", "#cedb9c", "#8c6d31", "#bd9e39", "#e7ba52", "#e7cb94", "#843c39", "#ad494a", "#d6616b", "#e7969c", "#7b4173", "#a55194", "#ce6dbd", "#de9ed6" ];
  2643. var d3_category20c = [ "#3182bd", "#6baed6", "#9ecae1", "#c6dbef", "#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2", "#31a354", "#74c476", "#a1d99b", "#c7e9c0", "#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb", "#636363", "#969696", "#bdbdbd", "#d9d9d9" ];
  2644. d3.scale.quantile = function() {
  2645. return d3_scale_quantile([], []);
  2646. };
  2647. function d3_scale_quantile(domain, range) {
  2648. var thresholds;
  2649. function rescale() {
  2650. var k = 0, q = range.length;
  2651. thresholds = [];
  2652. while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
  2653. return scale;
  2654. }
  2655. function scale(x) {
  2656. if (isNaN(x = +x)) return NaN;
  2657. return range[d3.bisect(thresholds, x)];
  2658. }
  2659. scale.domain = function(x) {
  2660. if (!arguments.length) return domain;
  2661. domain = x.filter(function(d) {
  2662. return !isNaN(d);
  2663. }).sort(d3.ascending);
  2664. return rescale();
  2665. };
  2666. scale.range = function(x) {
  2667. if (!arguments.length) return range;
  2668. range = x;
  2669. return rescale();
  2670. };
  2671. scale.quantiles = function() {
  2672. return thresholds;
  2673. };
  2674. scale.copy = function() {
  2675. return d3_scale_quantile(domain, range);
  2676. };
  2677. return rescale();
  2678. }
  2679. d3.scale.quantize = function() {
  2680. return d3_scale_quantize(0, 1, [ 0, 1 ]);
  2681. };
  2682. function d3_scale_quantize(x0, x1, range) {
  2683. var kx, i;
  2684. function scale(x) {
  2685. return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
  2686. }
  2687. function rescale() {
  2688. kx = range.length / (x1 - x0);
  2689. i = range.length - 1;
  2690. return scale;
  2691. }
  2692. scale.domain = function(x) {
  2693. if (!arguments.length) return [ x0, x1 ];
  2694. x0 = +x[0];
  2695. x1 = +x[x.length - 1];
  2696. return rescale();
  2697. };
  2698. scale.range = function(x) {
  2699. if (!arguments.length) return range;
  2700. range = x;
  2701. return rescale();
  2702. };
  2703. scale.copy = function() {
  2704. return d3_scale_quantize(x0, x1, range);
  2705. };
  2706. return rescale();
  2707. }
  2708. d3.scale.threshold = function() {
  2709. return d3_scale_threshold([ .5 ], [ 0, 1 ]);
  2710. };
  2711. function d3_scale_threshold(domain, range) {
  2712. function scale(x) {
  2713. return range[d3.bisect(domain, x)];
  2714. }
  2715. scale.domain = function(_) {
  2716. if (!arguments.length) return domain;
  2717. domain = _;
  2718. return scale;
  2719. };
  2720. scale.range = function(_) {
  2721. if (!arguments.length) return range;
  2722. range = _;
  2723. return scale;
  2724. };
  2725. scale.copy = function() {
  2726. return d3_scale_threshold(domain, range);
  2727. };
  2728. return scale;
  2729. }
  2730. d3.scale.identity = function() {
  2731. return d3_scale_identity([ 0, 1 ]);
  2732. };
  2733. function d3_scale_identity(domain) {
  2734. function identity(x) {
  2735. return +x;
  2736. }
  2737. identity.invert = identity;
  2738. identity.domain = identity.range = function(x) {
  2739. if (!arguments.length) return domain;
  2740. domain = x.map(identity);
  2741. return identity;
  2742. };
  2743. identity.ticks = function(m) {
  2744. return d3_scale_linearTicks(domain, m);
  2745. };
  2746. identity.tickFormat = function(m) {
  2747. return d3_scale_linearTickFormat(domain, m);
  2748. };
  2749. identity.copy = function() {
  2750. return d3_scale_identity(domain);
  2751. };
  2752. return identity;
  2753. }
  2754. d3.svg = {};
  2755. d3.svg.arc = function() {
  2756. var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
  2757. function arc() {
  2758. 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,
  2759. 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);
  2760. 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";
  2761. }
  2762. arc.innerRadius = function(v) {
  2763. if (!arguments.length) return innerRadius;
  2764. innerRadius = d3_functor(v);
  2765. return arc;
  2766. };
  2767. arc.outerRadius = function(v) {
  2768. if (!arguments.length) return outerRadius;
  2769. outerRadius = d3_functor(v);
  2770. return arc;
  2771. };
  2772. arc.startAngle = function(v) {
  2773. if (!arguments.length) return startAngle;
  2774. startAngle = d3_functor(v);
  2775. return arc;
  2776. };
  2777. arc.endAngle = function(v) {
  2778. if (!arguments.length) return endAngle;
  2779. endAngle = d3_functor(v);
  2780. return arc;
  2781. };
  2782. arc.centroid = function() {
  2783. var r = (innerRadius.apply(this, arguments) + outerRadius.apply(this, arguments)) / 2, a = (startAngle.apply(this, arguments) + endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset;
  2784. return [ Math.cos(a) * r, Math.sin(a) * r ];
  2785. };
  2786. return arc;
  2787. };
  2788. var d3_svg_arcOffset = -π / 2, d3_svg_arcMax = 2 * π - 1e-6;
  2789. function d3_svg_arcInnerRadius(d) {
  2790. return d.innerRadius;
  2791. }
  2792. function d3_svg_arcOuterRadius(d) {
  2793. return d.outerRadius;
  2794. }
  2795. function d3_svg_arcStartAngle(d) {
  2796. return d.startAngle;
  2797. }
  2798. function d3_svg_arcEndAngle(d) {
  2799. return d.endAngle;
  2800. }
  2801. function d3_svg_line(projection) {
  2802. var x = d3_svg_lineX, y = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7;
  2803. function line(data) {
  2804. var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y);
  2805. function segment() {
  2806. segments.push("M", interpolate(projection(points), tension));
  2807. }
  2808. while (++i < n) {
  2809. if (defined.call(this, d = data[i], i)) {
  2810. points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]);
  2811. } else if (points.length) {
  2812. segment();
  2813. points = [];
  2814. }
  2815. }
  2816. if (points.length) segment();
  2817. return segments.length ? segments.join("") : null;
  2818. }
  2819. line.x = function(_) {
  2820. if (!arguments.length) return x;
  2821. x = _;
  2822. return line;
  2823. };
  2824. line.y = function(_) {
  2825. if (!arguments.length) return y;
  2826. y = _;
  2827. return line;
  2828. };
  2829. line.defined = function(_) {
  2830. if (!arguments.length) return defined;
  2831. defined = _;
  2832. return line;
  2833. };
  2834. line.interpolate = function(_) {
  2835. if (!arguments.length) return interpolateKey;
  2836. if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
  2837. return line;
  2838. };
  2839. line.tension = function(_) {
  2840. if (!arguments.length) return tension;
  2841. tension = _;
  2842. return line;
  2843. };
  2844. return line;
  2845. }
  2846. d3.svg.line = function() {
  2847. return d3_svg_line(d3_identity);
  2848. };
  2849. function d3_svg_lineX(d) {
  2850. return d[0];
  2851. }
  2852. function d3_svg_lineY(d) {
  2853. return d[1];
  2854. }
  2855. var d3_svg_lineInterpolators = d3.map({
  2856. linear: d3_svg_lineLinear,
  2857. "linear-closed": d3_svg_lineLinearClosed,
  2858. "step-before": d3_svg_lineStepBefore,
  2859. "step-after": d3_svg_lineStepAfter,
  2860. basis: d3_svg_lineBasis,
  2861. "basis-open": d3_svg_lineBasisOpen,
  2862. "basis-closed": d3_svg_lineBasisClosed,
  2863. bundle: d3_svg_lineBundle,
  2864. cardinal: d3_svg_lineCardinal,
  2865. "cardinal-open": d3_svg_lineCardinalOpen,
  2866. "cardinal-closed": d3_svg_lineCardinalClosed,
  2867. monotone: d3_svg_lineMonotone
  2868. });
  2869. d3_svg_lineInterpolators.forEach(function(key, value) {
  2870. value.key = key;
  2871. value.closed = /-closed$/.test(key);
  2872. });
  2873. function d3_svg_lineLinear(points) {
  2874. return points.join("L");
  2875. }
  2876. function d3_svg_lineLinearClosed(points) {
  2877. return d3_svg_lineLinear(points) + "Z";
  2878. }
  2879. function d3_svg_lineStepBefore(points) {
  2880. var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
  2881. while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]);
  2882. return path.join("");
  2883. }
  2884. function d3_svg_lineStepAfter(points) {
  2885. var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
  2886. while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]);
  2887. return path.join("");
  2888. }
  2889. function d3_svg_lineCardinalOpen(points, tension) {
  2890. return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1), d3_svg_lineCardinalTangents(points, tension));
  2891. }
  2892. function d3_svg_lineCardinalClosed(points, tension) {
  2893. return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
  2894. points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));
  2895. }
  2896. function d3_svg_lineCardinal(points, tension) {
  2897. return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension));
  2898. }
  2899. function d3_svg_lineHermite(points, tangents) {
  2900. if (tangents.length < 1 || points.length != tangents.length && points.length != tangents.length + 2) {
  2901. return d3_svg_lineLinear(points);
  2902. }
  2903. var quad = points.length != tangents.length, path = "", p0 = points[0], p = points[1], t0 = tangents[0], t = t0, pi = 1;
  2904. if (quad) {
  2905. path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3) + "," + p[0] + "," + p[1];
  2906. p0 = points[1];
  2907. pi = 2;
  2908. }
  2909. if (tangents.length > 1) {
  2910. t = tangents[1];
  2911. p = points[pi];
  2912. pi++;
  2913. path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1]) + "," + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
  2914. for (var i = 2; i < tangents.length; i++, pi++) {
  2915. p = points[pi];
  2916. t = tangents[i];
  2917. path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1]) + "," + p[0] + "," + p[1];
  2918. }
  2919. }
  2920. if (quad) {
  2921. var lp = points[pi];
  2922. path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3) + "," + lp[0] + "," + lp[1];
  2923. }
  2924. return path;
  2925. }
  2926. function d3_svg_lineCardinalTangents(points, tension) {
  2927. var tangents = [], a = (1 - tension) / 2, p0, p1 = points[0], p2 = points[1], i = 1, n = points.length;
  2928. while (++i < n) {
  2929. p0 = p1;
  2930. p1 = p2;
  2931. p2 = points[i];
  2932. tangents.push([ a * (p2[0] - p0[0]), a * (p2[1] - p0[1]) ]);
  2933. }
  2934. return tangents;
  2935. }
  2936. function d3_svg_lineBasis(points) {
  2937. if (points.length < 3) return d3_svg_lineLinear(points);
  2938. 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 ];
  2939. d3_svg_lineBasisBezier(path, px, py);
  2940. while (++i < n) {
  2941. pi = points[i];
  2942. px.shift();
  2943. px.push(pi[0]);
  2944. py.shift();
  2945. py.push(pi[1]);
  2946. d3_svg_lineBasisBezier(path, px, py);
  2947. }
  2948. i = -1;
  2949. while (++i < 2) {
  2950. px.shift();
  2951. px.push(pi[0]);
  2952. py.shift();
  2953. py.push(pi[1]);
  2954. d3_svg_lineBasisBezier(path, px, py);
  2955. }
  2956. return path.join("");
  2957. }
  2958. function d3_svg_lineBasisOpen(points) {
  2959. if (points.length < 4) return d3_svg_lineLinear(points);
  2960. var path = [], i = -1, n = points.length, pi, px = [ 0 ], py = [ 0 ];
  2961. while (++i < 3) {
  2962. pi = points[i];
  2963. px.push(pi[0]);
  2964. py.push(pi[1]);
  2965. }
  2966. path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px) + "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));
  2967. --i;
  2968. while (++i < n) {
  2969. pi = points[i];
  2970. px.shift();
  2971. px.push(pi[0]);
  2972. py.shift();
  2973. py.push(pi[1]);
  2974. d3_svg_lineBasisBezier(path, px, py);
  2975. }
  2976. return path.join("");
  2977. }
  2978. function d3_svg_lineBasisClosed(points) {
  2979. var path, i = -1, n = points.length, m = n + 4, pi, px = [], py = [];
  2980. while (++i < 4) {
  2981. pi = points[i % n];
  2982. px.push(pi[0]);
  2983. py.push(pi[1]);
  2984. }
  2985. path = [ d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, py) ];
  2986. --i;
  2987. while (++i < m) {
  2988. pi = points[i % n];
  2989. px.shift();
  2990. px.push(pi[0]);
  2991. py.shift();
  2992. py.push(pi[1]);
  2993. d3_svg_lineBasisBezier(path, px, py);
  2994. }
  2995. return path.join("");
  2996. }
  2997. function d3_svg_lineBundle(points, tension) {
  2998. var n = points.length - 1;
  2999. if (n) {
  3000. var x0 = points[0][0], y0 = points[0][1], dx = points[n][0] - x0, dy = points[n][1] - y0, i = -1, p, t;
  3001. while (++i <= n) {
  3002. p = points[i];
  3003. t = i / n;
  3004. p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
  3005. p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
  3006. }
  3007. }
  3008. return d3_svg_lineBasis(points);
  3009. }
  3010. function d3_svg_lineDot4(a, b) {
  3011. return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
  3012. }
  3013. 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 ];
  3014. function d3_svg_lineBasisBezier(path, x, y) {
  3015. 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));
  3016. }
  3017. function d3_svg_lineSlope(p0, p1) {
  3018. return (p1[1] - p0[1]) / (p1[0] - p0[0]);
  3019. }
  3020. function d3_svg_lineFiniteDifferences(points) {
  3021. var i = 0, j = points.length - 1, m = [], p0 = points[0], p1 = points[1], d = m[0] = d3_svg_lineSlope(p0, p1);
  3022. while (++i < j) {
  3023. m[i] = (d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]))) / 2;
  3024. }
  3025. m[i] = d;
  3026. return m;
  3027. }
  3028. function d3_svg_lineMonotoneTangents(points) {
  3029. var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1;
  3030. while (++i < j) {
  3031. d = d3_svg_lineSlope(points[i], points[i + 1]);
  3032. if (Math.abs(d) < 1e-6) {
  3033. m[i] = m[i + 1] = 0;
  3034. } else {
  3035. a = m[i] / d;
  3036. b = m[i + 1] / d;
  3037. s = a * a + b * b;
  3038. if (s > 9) {
  3039. s = d * 3 / Math.sqrt(s);
  3040. m[i] = s * a;
  3041. m[i + 1] = s * b;
  3042. }
  3043. }
  3044. }
  3045. i = -1;
  3046. while (++i <= j) {
  3047. s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0]) / (6 * (1 + m[i] * m[i]));
  3048. tangents.push([ s || 0, m[i] * s || 0 ]);
  3049. }
  3050. return tangents;
  3051. }
  3052. function d3_svg_lineMonotone(points) {
  3053. return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
  3054. }
  3055. d3.svg.line.radial = function() {
  3056. var line = d3_svg_line(d3_svg_lineRadial);
  3057. line.radius = line.x, delete line.x;
  3058. line.angle = line.y, delete line.y;
  3059. return line;
  3060. };
  3061. function d3_svg_lineRadial(points) {
  3062. var point, i = -1, n = points.length, r, a;
  3063. while (++i < n) {
  3064. point = points[i];
  3065. r = point[0];
  3066. a = point[1] + d3_svg_arcOffset;
  3067. point[0] = r * Math.cos(a);
  3068. point[1] = r * Math.sin(a);
  3069. }
  3070. return points;
  3071. }
  3072. function d3_svg_area(projection) {
  3073. 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;
  3074. function area(data) {
  3075. var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() {
  3076. return x;
  3077. } : d3_functor(x1), fy1 = y0 === y1 ? function() {
  3078. return y;
  3079. } : d3_functor(y1), x, y;
  3080. function segment() {
  3081. segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z");
  3082. }
  3083. while (++i < n) {
  3084. if (defined.call(this, d = data[i], i)) {
  3085. points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]);
  3086. points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]);
  3087. } else if (points0.length) {
  3088. segment();
  3089. points0 = [];
  3090. points1 = [];
  3091. }
  3092. }
  3093. if (points0.length) segment();
  3094. return segments.length ? segments.join("") : null;
  3095. }
  3096. area.x = function(_) {
  3097. if (!arguments.length) return x1;
  3098. x0 = x1 = _;
  3099. return area;
  3100. };
  3101. area.x0 = function(_) {
  3102. if (!arguments.length) return x0;
  3103. x0 = _;
  3104. return area;
  3105. };
  3106. area.x1 = function(_) {
  3107. if (!arguments.length) return x1;
  3108. x1 = _;
  3109. return area;
  3110. };
  3111. area.y = function(_) {
  3112. if (!arguments.length) return y1;
  3113. y0 = y1 = _;
  3114. return area;
  3115. };
  3116. area.y0 = function(_) {
  3117. if (!arguments.length) return y0;
  3118. y0 = _;
  3119. return area;
  3120. };
  3121. area.y1 = function(_) {
  3122. if (!arguments.length) return y1;
  3123. y1 = _;
  3124. return area;
  3125. };
  3126. area.defined = function(_) {
  3127. if (!arguments.length) return defined;
  3128. defined = _;
  3129. return area;
  3130. };
  3131. area.interpolate = function(_) {
  3132. if (!arguments.length) return interpolateKey;
  3133. if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key;
  3134. interpolateReverse = interpolate.reverse || interpolate;
  3135. L = interpolate.closed ? "M" : "L";
  3136. return area;
  3137. };
  3138. area.tension = function(_) {
  3139. if (!arguments.length) return tension;
  3140. tension = _;
  3141. return area;
  3142. };
  3143. return area;
  3144. }
  3145. d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
  3146. d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
  3147. d3.svg.area = function() {
  3148. return d3_svg_area(d3_identity);
  3149. };
  3150. d3.svg.area.radial = function() {
  3151. var area = d3_svg_area(d3_svg_lineRadial);
  3152. area.radius = area.x, delete area.x;
  3153. area.innerRadius = area.x0, delete area.x0;
  3154. area.outerRadius = area.x1, delete area.x1;
  3155. area.angle = area.y, delete area.y;
  3156. area.startAngle = area.y0, delete area.y0;
  3157. area.endAngle = area.y1, delete area.y1;
  3158. return area;
  3159. };
  3160. d3.svg.chord = function() {
  3161. var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle;
  3162. function chord(d, i) {
  3163. var s = subgroup(this, source, d, i), t = subgroup(this, target, d, i);
  3164. 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";
  3165. }
  3166. function subgroup(self, f, d, i) {
  3167. 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;
  3168. return {
  3169. r: r,
  3170. a0: a0,
  3171. a1: a1,
  3172. p0: [ r * Math.cos(a0), r * Math.sin(a0) ],
  3173. p1: [ r * Math.cos(a1), r * Math.sin(a1) ]
  3174. };
  3175. }
  3176. function equals(a, b) {
  3177. return a.a0 == b.a0 && a.a1 == b.a1;
  3178. }
  3179. function arc(r, p, a) {
  3180. return "A" + r + "," + r + " 0 " + +(a > π) + ",1 " + p;
  3181. }
  3182. function curve(r0, p0, r1, p1) {
  3183. return "Q 0,0 " + p1;
  3184. }
  3185. chord.radius = function(v) {
  3186. if (!arguments.length) return radius;
  3187. radius = d3_functor(v);
  3188. return chord;
  3189. };
  3190. chord.source = function(v) {
  3191. if (!arguments.length) return source;
  3192. source = d3_functor(v);
  3193. return chord;
  3194. };
  3195. chord.target = function(v) {
  3196. if (!arguments.length) return target;
  3197. target = d3_functor(v);
  3198. return chord;
  3199. };
  3200. chord.startAngle = function(v) {
  3201. if (!arguments.length) return startAngle;
  3202. startAngle = d3_functor(v);
  3203. return chord;
  3204. };
  3205. chord.endAngle = function(v) {
  3206. if (!arguments.length) return endAngle;
  3207. endAngle = d3_functor(v);
  3208. return chord;
  3209. };
  3210. return chord;
  3211. };
  3212. function d3_svg_chordRadius(d) {
  3213. return d.radius;
  3214. }
  3215. d3.svg.diagonal = function() {
  3216. var source = d3_source, target = d3_target, projection = d3_svg_diagonalProjection;
  3217. function diagonal(d, i) {
  3218. var p0 = source.call(this, d, i), p3 = target.call(this, d, i), m = (p0.y + p3.y) / 2, p = [ p0, {
  3219. x: p0.x,
  3220. y: m
  3221. }, {
  3222. x: p3.x,
  3223. y: m
  3224. }, p3 ];
  3225. p = p.map(projection);
  3226. return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3];
  3227. }
  3228. diagonal.source = function(x) {
  3229. if (!arguments.length) return source;
  3230. source = d3_functor(x);
  3231. return diagonal;
  3232. };
  3233. diagonal.target = function(x) {
  3234. if (!arguments.length) return target;
  3235. target = d3_functor(x);
  3236. return diagonal;
  3237. };
  3238. diagonal.projection = function(x) {
  3239. if (!arguments.length) return projection;
  3240. projection = x;
  3241. return diagonal;
  3242. };
  3243. return diagonal;
  3244. };
  3245. function d3_svg_diagonalProjection(d) {
  3246. return [ d.x, d.y ];
  3247. }
  3248. d3.svg.diagonal.radial = function() {
  3249. var diagonal = d3.svg.diagonal(), projection = d3_svg_diagonalProjection, projection_ = diagonal.projection;
  3250. diagonal.projection = function(x) {
  3251. return arguments.length ? projection_(d3_svg_diagonalRadialProjection(projection = x)) : projection;
  3252. };
  3253. return diagonal;
  3254. };
  3255. function d3_svg_diagonalRadialProjection(projection) {
  3256. return function() {
  3257. var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset;
  3258. return [ r * Math.cos(a), r * Math.sin(a) ];
  3259. };
  3260. }
  3261. d3.svg.symbol = function() {
  3262. var type = d3_svg_symbolType, size = d3_svg_symbolSize;
  3263. function symbol(d, i) {
  3264. return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i));
  3265. }
  3266. symbol.type = function(x) {
  3267. if (!arguments.length) return type;
  3268. type = d3_functor(x);
  3269. return symbol;
  3270. };
  3271. symbol.size = function(x) {
  3272. if (!arguments.length) return size;
  3273. size = d3_functor(x);
  3274. return symbol;
  3275. };
  3276. return symbol;
  3277. };
  3278. function d3_svg_symbolSize() {
  3279. return 64;
  3280. }
  3281. function d3_svg_symbolType() {
  3282. return "circle";
  3283. }
  3284. function d3_svg_symbolCircle(size) {
  3285. var r = Math.sqrt(size / π);
  3286. return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z";
  3287. }
  3288. var d3_svg_symbols = d3.map({
  3289. circle: d3_svg_symbolCircle,
  3290. cross: function(size) {
  3291. var r = Math.sqrt(size / 5) / 2;
  3292. 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";
  3293. },
  3294. diamond: function(size) {
  3295. var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)), rx = ry * d3_svg_symbolTan30;
  3296. return "M0," + -ry + "L" + rx + ",0" + " 0," + ry + " " + -rx + ",0" + "Z";
  3297. },
  3298. square: function(size) {
  3299. var r = Math.sqrt(size) / 2;
  3300. return "M" + -r + "," + -r + "L" + r + "," + -r + " " + r + "," + r + " " + -r + "," + r + "Z";
  3301. },
  3302. "triangle-down": function(size) {
  3303. var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
  3304. return "M0," + ry + "L" + rx + "," + -ry + " " + -rx + "," + -ry + "Z";
  3305. },
  3306. "triangle-up": function(size) {
  3307. var rx = Math.sqrt(size / d3_svg_symbolSqrt3), ry = rx * d3_svg_symbolSqrt3 / 2;
  3308. return "M0," + -ry + "L" + rx + "," + ry + " " + -rx + "," + ry + "Z";
  3309. }
  3310. });
  3311. d3.svg.symbolTypes = d3_svg_symbols.keys();
  3312. var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians);
  3313. d3.svg.axis = function() {
  3314. var scale = d3.scale.linear(), orient = "bottom", tickMajorSize = 6, tickMinorSize = 6, tickEndSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_, tickSubdivide = 0;
  3315. function axis(g) {
  3316. g.each(function() {
  3317. var g = d3.select(this);
  3318. 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_;
  3319. var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide), subtick = g.selectAll(".minor").data(subticks, String), subtickEnter = subtick.enter().insert("line", "g").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);
  3320. var tick = g.selectAll("g").data(ticks, String), tickEnter = tick.enter().insert("g", "path").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform;
  3321. var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = d3.transition(path);
  3322. var scale1 = scale.copy(), scale0 = this.__chart__ || scale1;
  3323. this.__chart__ = scale1;
  3324. path.enter().append("path").attr("class", "domain");
  3325. tickEnter.append("line").attr("class", "tick");
  3326. tickEnter.append("text");
  3327. var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text");
  3328. switch (orient) {
  3329. case "bottom":
  3330. {
  3331. tickTransform = d3_svg_axisX;
  3332. subtickEnter.attr("y2", tickMinorSize);
  3333. subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize);
  3334. lineEnter.attr("y2", tickMajorSize);
  3335. textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding);
  3336. lineUpdate.attr("x2", 0).attr("y2", tickMajorSize);
  3337. textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding);
  3338. text.attr("dy", ".71em").style("text-anchor", "middle");
  3339. pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize);
  3340. break;
  3341. }
  3342. case "top":
  3343. {
  3344. tickTransform = d3_svg_axisX;
  3345. subtickEnter.attr("y2", -tickMinorSize);
  3346. subtickUpdate.attr("x2", 0).attr("y2", -tickMinorSize);
  3347. lineEnter.attr("y2", -tickMajorSize);
  3348. textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
  3349. lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize);
  3350. textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
  3351. text.attr("dy", "0em").style("text-anchor", "middle");
  3352. pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize);
  3353. break;
  3354. }
  3355. case "left":
  3356. {
  3357. tickTransform = d3_svg_axisY;
  3358. subtickEnter.attr("x2", -tickMinorSize);
  3359. subtickUpdate.attr("x2", -tickMinorSize).attr("y2", 0);
  3360. lineEnter.attr("x2", -tickMajorSize);
  3361. textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding));
  3362. lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0);
  3363. textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0);
  3364. text.attr("dy", ".32em").style("text-anchor", "end");
  3365. pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize);
  3366. break;
  3367. }
  3368. case "right":
  3369. {
  3370. tickTransform = d3_svg_axisY;
  3371. subtickEnter.attr("x2", tickMinorSize);
  3372. subtickUpdate.attr("x2", tickMinorSize).attr("y2", 0);
  3373. lineEnter.attr("x2", tickMajorSize);
  3374. textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding);
  3375. lineUpdate.attr("x2", tickMajorSize).attr("y2", 0);
  3376. textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0);
  3377. text.attr("dy", ".32em").style("text-anchor", "start");
  3378. pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize);
  3379. break;
  3380. }
  3381. }
  3382. if (scale.ticks) {
  3383. tickEnter.call(tickTransform, scale0);
  3384. tickUpdate.call(tickTransform, scale1);
  3385. tickExit.call(tickTransform, scale1);
  3386. subtickEnter.call(tickTransform, scale0);
  3387. subtickUpdate.call(tickTransform, scale1);
  3388. subtickExit.call(tickTransform, scale1);
  3389. } else {
  3390. var dx = scale1.rangeBand() / 2, x = function(d) {
  3391. return scale1(d) + dx;
  3392. };
  3393. tickEnter.call(tickTransform, x);
  3394. tickUpdate.call(tickTransform, x);
  3395. }
  3396. });
  3397. }
  3398. axis.scale = function(x) {
  3399. if (!arguments.length) return scale;
  3400. scale = x;
  3401. return axis;
  3402. };
  3403. axis.orient = function(x) {
  3404. if (!arguments.length) return orient;
  3405. orient = x;
  3406. return axis;
  3407. };
  3408. axis.ticks = function() {
  3409. if (!arguments.length) return tickArguments_;
  3410. tickArguments_ = arguments;
  3411. return axis;
  3412. };
  3413. axis.tickValues = function(x) {
  3414. if (!arguments.length) return tickValues;
  3415. tickValues = x;
  3416. return axis;
  3417. };
  3418. axis.tickFormat = function(x) {
  3419. if (!arguments.length) return tickFormat_;
  3420. tickFormat_ = x;
  3421. return axis;
  3422. };
  3423. axis.tickSize = function(x, y) {
  3424. if (!arguments.length) return tickMajorSize;
  3425. var n = arguments.length - 1;
  3426. tickMajorSize = +x;
  3427. tickMinorSize = n > 1 ? +y : tickMajorSize;
  3428. tickEndSize = n > 0 ? +arguments[n] : tickMajorSize;
  3429. return axis;
  3430. };
  3431. axis.tickPadding = function(x) {
  3432. if (!arguments.length) return tickPadding;
  3433. tickPadding = +x;
  3434. return axis;
  3435. };
  3436. axis.tickSubdivide = function(x) {
  3437. if (!arguments.length) return tickSubdivide;
  3438. tickSubdivide = +x;
  3439. return axis;
  3440. };
  3441. return axis;
  3442. };
  3443. function d3_svg_axisX(selection, x) {
  3444. selection.attr("transform", function(d) {
  3445. return "translate(" + x(d) + ",0)";
  3446. });
  3447. }
  3448. function d3_svg_axisY(selection, y) {
  3449. selection.attr("transform", function(d) {
  3450. return "translate(0," + y(d) + ")";
  3451. });
  3452. }
  3453. function d3_svg_axisSubdivide(scale, ticks, m) {
  3454. subticks = [];
  3455. if (m && ticks.length > 1) {
  3456. var extent = d3_scaleExtent(scale.domain()), subticks, i = -1, n = ticks.length, d = (ticks[1] - ticks[0]) / ++m, j, v;
  3457. while (++i < n) {
  3458. for (j = m; --j > 0; ) {
  3459. if ((v = +ticks[i] - j * d) >= extent[0]) {
  3460. subticks.push(v);
  3461. }
  3462. }
  3463. }
  3464. for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1]; ) {
  3465. subticks.push(v);
  3466. }
  3467. }
  3468. return subticks;
  3469. }
  3470. d3.svg.brush = function() {
  3471. var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, resizes = d3_svg_brushResizes[0], extent = [ [ 0, 0 ], [ 0, 0 ] ], extentDomain;
  3472. function brush(g) {
  3473. g.each(function() {
  3474. 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;
  3475. g.style("pointer-events", "all").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart);
  3476. bg.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair");
  3477. fg.enter().append("rect").attr("class", "extent").style("cursor", "move");
  3478. tz.enter().append("g").attr("class", function(d) {
  3479. return "resize " + d;
  3480. }).style("cursor", function(d) {
  3481. return d3_svg_brushCursor[d];
  3482. }).append("rect").attr("x", function(d) {
  3483. return /[ew]$/.test(d) ? -3 : null;
  3484. }).attr("y", function(d) {
  3485. return /^[ns]/.test(d) ? -3 : null;
  3486. }).attr("width", 6).attr("height", 6).style("visibility", "hidden");
  3487. tz.style("display", brush.empty() ? "none" : null);
  3488. tz.exit().remove();
  3489. if (x) {
  3490. e = d3_scaleRange(x);
  3491. bg.attr("x", e[0]).attr("width", e[1] - e[0]);
  3492. redrawX(g);
  3493. }
  3494. if (y) {
  3495. e = d3_scaleRange(y);
  3496. bg.attr("y", e[0]).attr("height", e[1] - e[0]);
  3497. redrawY(g);
  3498. }
  3499. redraw(g);
  3500. });
  3501. }
  3502. function redraw(g) {
  3503. g.selectAll(".resize").attr("transform", function(d) {
  3504. return "translate(" + extent[+/e$/.test(d)][0] + "," + extent[+/^s/.test(d)][1] + ")";
  3505. });
  3506. }
  3507. function redrawX(g) {
  3508. g.select(".extent").attr("x", extent[0][0]);
  3509. g.selectAll(".extent,.n>rect,.s>rect").attr("width", extent[1][0] - extent[0][0]);
  3510. }
  3511. function redrawY(g) {
  3512. g.select(".extent").attr("y", extent[0][1]);
  3513. g.selectAll(".extent,.e>rect,.w>rect").attr("height", extent[1][1] - extent[0][1]);
  3514. }
  3515. function brushstart() {
  3516. 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;
  3517. var w = d3.select(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);
  3518. if (dragging) {
  3519. origin[0] = extent[0][0] - origin[0];
  3520. origin[1] = extent[0][1] - origin[1];
  3521. } else if (resizing) {
  3522. var ex = +/w$/.test(resizing), ey = +/^n/.test(resizing);
  3523. offset = [ extent[1 - ex][0] - origin[0], extent[1 - ey][1] - origin[1] ];
  3524. origin[0] = extent[ex][0];
  3525. origin[1] = extent[ey][1];
  3526. } else if (d3.event.altKey) center = origin.slice();
  3527. g.style("pointer-events", "none").selectAll(".resize").style("display", null);
  3528. d3.select("body").style("cursor", eventTarget.style("cursor"));
  3529. event_({
  3530. type: "brushstart"
  3531. });
  3532. brushmove();
  3533. d3_eventCancel();
  3534. function mouse() {
  3535. var touches = d3.event.changedTouches;
  3536. return touches ? d3.touches(target, touches)[0] : d3.mouse(target);
  3537. }
  3538. function keydown() {
  3539. if (d3.event.keyCode == 32) {
  3540. if (!dragging) {
  3541. center = null;
  3542. origin[0] -= extent[1][0];
  3543. origin[1] -= extent[1][1];
  3544. dragging = 2;
  3545. }
  3546. d3_eventCancel();
  3547. }
  3548. }
  3549. function keyup() {
  3550. if (d3.event.keyCode == 32 && dragging == 2) {
  3551. origin[0] += extent[1][0];
  3552. origin[1] += extent[1][1];
  3553. dragging = 0;
  3554. d3_eventCancel();
  3555. }
  3556. }
  3557. function brushmove() {
  3558. var point = mouse(), moved = false;
  3559. if (offset) {
  3560. point[0] += offset[0];
  3561. point[1] += offset[1];
  3562. }
  3563. if (!dragging) {
  3564. if (d3.event.altKey) {
  3565. if (!center) center = [ (extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2 ];
  3566. origin[0] = extent[+(point[0] < center[0])][0];
  3567. origin[1] = extent[+(point[1] < center[1])][1];
  3568. } else center = null;
  3569. }
  3570. if (resizingX && move1(point, x, 0)) {
  3571. redrawX(g);
  3572. moved = true;
  3573. }
  3574. if (resizingY && move1(point, y, 1)) {
  3575. redrawY(g);
  3576. moved = true;
  3577. }
  3578. if (moved) {
  3579. redraw(g);
  3580. event_({
  3581. type: "brush",
  3582. mode: dragging ? "move" : "resize"
  3583. });
  3584. }
  3585. }
  3586. function move1(point, scale, i) {
  3587. var range = d3_scaleRange(scale), r0 = range[0], r1 = range[1], position = origin[i], size = extent[1][i] - extent[0][i], min, max;
  3588. if (dragging) {
  3589. r0 -= position;
  3590. r1 -= size + position;
  3591. }
  3592. min = Math.max(r0, Math.min(r1, point[i]));
  3593. if (dragging) {
  3594. max = (min += position) + size;
  3595. } else {
  3596. if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));
  3597. if (position < min) {
  3598. max = min;
  3599. min = position;
  3600. } else {
  3601. max = position;
  3602. }
  3603. }
  3604. if (extent[0][i] !== min || extent[1][i] !== max) {
  3605. extentDomain = null;
  3606. extent[0][i] = min;
  3607. extent[1][i] = max;
  3608. return true;
  3609. }
  3610. }
  3611. function brushend() {
  3612. brushmove();
  3613. g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null);
  3614. d3.select("body").style("cursor", null);
  3615. 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);
  3616. event_({
  3617. type: "brushend"
  3618. });
  3619. d3_eventCancel();
  3620. }
  3621. }
  3622. brush.x = function(z) {
  3623. if (!arguments.length) return x;
  3624. x = z;
  3625. resizes = d3_svg_brushResizes[!x << 1 | !y];
  3626. return brush;
  3627. };
  3628. brush.y = function(z) {
  3629. if (!arguments.length) return y;
  3630. y = z;
  3631. resizes = d3_svg_brushResizes[!x << 1 | !y];
  3632. return brush;
  3633. };
  3634. brush.extent = function(z) {
  3635. var x0, x1, y0, y1, t;
  3636. if (!arguments.length) {
  3637. z = extentDomain || extent;
  3638. if (x) {
  3639. x0 = z[0][0], x1 = z[1][0];
  3640. if (!extentDomain) {
  3641. x0 = extent[0][0], x1 = extent[1][0];
  3642. if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
  3643. if (x1 < x0) t = x0, x0 = x1, x1 = t;
  3644. }
  3645. }
  3646. if (y) {
  3647. y0 = z[0][1], y1 = z[1][1];
  3648. if (!extentDomain) {
  3649. y0 = extent[0][1], y1 = extent[1][1];
  3650. if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
  3651. if (y1 < y0) t = y0, y0 = y1, y1 = t;
  3652. }
  3653. }
  3654. return x && y ? [ [ x0, y0 ], [ x1, y1 ] ] : x ? [ x0, x1 ] : y && [ y0, y1 ];
  3655. }
  3656. extentDomain = [ [ 0, 0 ], [ 0, 0 ] ];
  3657. if (x) {
  3658. x0 = z[0], x1 = z[1];
  3659. if (y) x0 = x0[0], x1 = x1[0];
  3660. extentDomain[0][0] = x0, extentDomain[1][0] = x1;
  3661. if (x.invert) x0 = x(x0), x1 = x(x1);
  3662. if (x1 < x0) t = x0, x0 = x1, x1 = t;
  3663. extent[0][0] = x0 | 0, extent[1][0] = x1 | 0;
  3664. }
  3665. if (y) {
  3666. y0 = z[0], y1 = z[1];
  3667. if (x) y0 = y0[1], y1 = y1[1];
  3668. extentDomain[0][1] = y0, extentDomain[1][1] = y1;
  3669. if (y.invert) y0 = y(y0), y1 = y(y1);
  3670. if (y1 < y0) t = y0, y0 = y1, y1 = t;
  3671. extent[0][1] = y0 | 0, extent[1][1] = y1 | 0;
  3672. }
  3673. return brush;
  3674. };
  3675. brush.clear = function() {
  3676. extentDomain = null;
  3677. extent[0][0] = extent[0][1] = extent[1][0] = extent[1][1] = 0;
  3678. return brush;
  3679. };
  3680. brush.empty = function() {
  3681. return x && extent[0][0] === extent[1][0] || y && extent[0][1] === extent[1][1];
  3682. };
  3683. return d3.rebind(brush, event, "on");
  3684. };
  3685. var d3_svg_brushCursor = {
  3686. n: "ns-resize",
  3687. e: "ew-resize",
  3688. s: "ns-resize",
  3689. w: "ew-resize",
  3690. nw: "nwse-resize",
  3691. ne: "nesw-resize",
  3692. se: "nwse-resize",
  3693. sw: "nesw-resize"
  3694. };
  3695. var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ];
  3696. d3.behavior = {};
  3697. d3.behavior.drag = function() {
  3698. var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null;
  3699. function drag() {
  3700. this.on("mousedown.drag", mousedown).on("touchstart.drag", mousedown);
  3701. }
  3702. function mousedown() {
  3703. 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;
  3704. var w = d3.select(window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true);
  3705. if (origin) {
  3706. offset = origin.apply(target, arguments);
  3707. offset = [ offset.x - origin_[0], offset.y - origin_[1] ];
  3708. } else {
  3709. offset = [ 0, 0 ];
  3710. }
  3711. if (touchId == null) d3_eventCancel();
  3712. event_({
  3713. type: "dragstart"
  3714. });
  3715. function point() {
  3716. var p = target.parentNode;
  3717. return touchId != null ? d3.touches(p).filter(function(p) {
  3718. return p.identifier === touchId;
  3719. })[0] : d3.mouse(p);
  3720. }
  3721. function dragmove() {
  3722. if (!target.parentNode) return dragend();
  3723. var p = point(), dx = p[0] - origin_[0], dy = p[1] - origin_[1];
  3724. moved |= dx | dy;
  3725. origin_ = p;
  3726. d3_eventCancel();
  3727. event_({
  3728. type: "drag",
  3729. x: p[0] + offset[0],
  3730. y: p[1] + offset[1],
  3731. dx: dx,
  3732. dy: dy
  3733. });
  3734. }
  3735. function dragend() {
  3736. event_({
  3737. type: "dragend"
  3738. });
  3739. if (moved) {
  3740. d3_eventCancel();
  3741. if (d3.event.target === eventTarget) w.on("click.drag", click, true);
  3742. }
  3743. w.on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", null).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", null);
  3744. }
  3745. function click() {
  3746. d3_eventCancel();
  3747. w.on("click.drag", null);
  3748. }
  3749. }
  3750. drag.origin = function(x) {
  3751. if (!arguments.length) return origin;
  3752. origin = x;
  3753. return drag;
  3754. };
  3755. return d3.rebind(drag, event, "on");
  3756. };
  3757. d3.behavior.zoom = function() {
  3758. var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime;
  3759. function zoom() {
  3760. this.on("mousedown.zoom", mousedown).on("mousewheel.zoom", mousewheel).on("mousemove.zoom", mousemove).on("DOMMouseScroll.zoom", mousewheel).on("dblclick.zoom", dblclick).on("touchstart.zoom", touchstart).on("touchmove.zoom", touchmove).on("touchend.zoom", touchstart);
  3761. }
  3762. zoom.translate = function(x) {
  3763. if (!arguments.length) return translate;
  3764. translate = x.map(Number);
  3765. rescale();
  3766. return zoom;
  3767. };
  3768. zoom.scale = function(x) {
  3769. if (!arguments.length) return scale;
  3770. scale = +x;
  3771. rescale();
  3772. return zoom;
  3773. };
  3774. zoom.scaleExtent = function(x) {
  3775. if (!arguments.length) return scaleExtent;
  3776. scaleExtent = x == null ? d3_behavior_zoomInfinity : x.map(Number);
  3777. return zoom;
  3778. };
  3779. zoom.x = function(z) {
  3780. if (!arguments.length) return x1;
  3781. x1 = z;
  3782. x0 = z.copy();
  3783. translate = [ 0, 0 ];
  3784. scale = 1;
  3785. return zoom;
  3786. };
  3787. zoom.y = function(z) {
  3788. if (!arguments.length) return y1;
  3789. y1 = z;
  3790. y0 = z.copy();
  3791. translate = [ 0, 0 ];
  3792. scale = 1;
  3793. return zoom;
  3794. };
  3795. function location(p) {
  3796. return [ (p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale ];
  3797. }
  3798. function point(l) {
  3799. return [ l[0] * scale + translate[0], l[1] * scale + translate[1] ];
  3800. }
  3801. function scaleTo(s) {
  3802. scale = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
  3803. }
  3804. function translateTo(p, l) {
  3805. l = point(l);
  3806. translate[0] += p[0] - l[0];
  3807. translate[1] += p[1] - l[1];
  3808. }
  3809. function rescale() {
  3810. if (x1) x1.domain(x0.range().map(function(x) {
  3811. return (x - translate[0]) / scale;
  3812. }).map(x0.invert));
  3813. if (y1) y1.domain(y0.range().map(function(y) {
  3814. return (y - translate[1]) / scale;
  3815. }).map(y0.invert));
  3816. }
  3817. function dispatch(event) {
  3818. rescale();
  3819. d3.event.preventDefault();
  3820. event({
  3821. type: "zoom",
  3822. scale: scale,
  3823. translate: translate
  3824. });
  3825. }
  3826. function mousedown() {
  3827. var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, moved = 0, w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target));
  3828. window.focus();
  3829. d3_eventCancel();
  3830. function mousemove() {
  3831. moved = 1;
  3832. translateTo(d3.mouse(target), l);
  3833. dispatch(event_);
  3834. }
  3835. function mouseup() {
  3836. if (moved) d3_eventCancel();
  3837. w.on("mousemove.zoom", null).on("mouseup.zoom", null);
  3838. if (moved && d3.event.target === eventTarget) w.on("click.zoom", click, true);
  3839. }
  3840. function click() {
  3841. d3_eventCancel();
  3842. w.on("click.zoom", null);
  3843. }
  3844. }
  3845. function mousewheel() {
  3846. if (!translate0) translate0 = location(d3.mouse(this));
  3847. scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * scale);
  3848. translateTo(d3.mouse(this), translate0);
  3849. dispatch(event.of(this, arguments));
  3850. }
  3851. function mousemove() {
  3852. translate0 = null;
  3853. }
  3854. function dblclick() {
  3855. var p = d3.mouse(this), l = location(p), k = Math.log(scale) / Math.LN2;
  3856. scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1));
  3857. translateTo(p, l);
  3858. dispatch(event.of(this, arguments));
  3859. }
  3860. function touchstart() {
  3861. var touches = d3.touches(this), now = Date.now();
  3862. scale0 = scale;
  3863. translate0 = {};
  3864. touches.forEach(function(t) {
  3865. translate0[t.identifier] = location(t);
  3866. });
  3867. d3_eventCancel();
  3868. if (touches.length === 1) {
  3869. if (now - touchtime < 500) {
  3870. var p = touches[0], l = location(touches[0]);
  3871. scaleTo(scale * 2);
  3872. translateTo(p, l);
  3873. dispatch(event.of(this, arguments));
  3874. }
  3875. touchtime = now;
  3876. }
  3877. }
  3878. function touchmove() {
  3879. var touches = d3.touches(this), p0 = touches[0], l0 = translate0[p0.identifier];
  3880. if (p1 = touches[1]) {
  3881. var p1, l1 = translate0[p1.identifier];
  3882. p0 = [ (p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2 ];
  3883. l0 = [ (l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2 ];
  3884. scaleTo(d3.event.scale * scale0);
  3885. }
  3886. translateTo(p0, l0);
  3887. touchtime = null;
  3888. dispatch(event.of(this, arguments));
  3889. }
  3890. return d3.rebind(zoom, event, "on");
  3891. };
  3892. var d3_behavior_zoomDiv, d3_behavior_zoomInfinity = [ 0, Infinity ];
  3893. function d3_behavior_zoomDelta() {
  3894. if (!d3_behavior_zoomDiv) {
  3895. d3_behavior_zoomDiv = d3.select("body").append("div").style("visibility", "hidden").style("top", 0).style("height", 0).style("width", 0).style("overflow-y", "scroll").append("div").style("height", "2000px").node().parentNode;
  3896. }
  3897. var e = d3.event, delta;
  3898. try {
  3899. d3_behavior_zoomDiv.scrollTop = 1e3;
  3900. d3_behavior_zoomDiv.dispatchEvent(e);
  3901. delta = 1e3 - d3_behavior_zoomDiv.scrollTop;
  3902. } catch (error) {
  3903. delta = e.wheelDelta || -e.detail * 5;
  3904. }
  3905. return delta;
  3906. }
  3907. d3.layout = {};
  3908. d3.layout.bundle = function() {
  3909. return function(links) {
  3910. var paths = [], i = -1, n = links.length;
  3911. while (++i < n) paths.push(d3_layout_bundlePath(links[i]));
  3912. return paths;
  3913. };
  3914. };
  3915. function d3_layout_bundlePath(link) {
  3916. var start = link.source, end = link.target, lca = d3_layout_bundleLeastCommonAncestor(start, end), points = [ start ];
  3917. while (start !== lca) {
  3918. start = start.parent;
  3919. points.push(start);
  3920. }
  3921. var k = points.length;
  3922. while (end !== lca) {
  3923. points.splice(k, 0, end);
  3924. end = end.parent;
  3925. }
  3926. return points;
  3927. }
  3928. function d3_layout_bundleAncestors(node) {
  3929. var ancestors = [], parent = node.parent;
  3930. while (parent != null) {
  3931. ancestors.push(node);
  3932. node = parent;
  3933. parent = parent.parent;
  3934. }
  3935. ancestors.push(node);
  3936. return ancestors;
  3937. }
  3938. function d3_layout_bundleLeastCommonAncestor(a, b) {
  3939. if (a === b) return a;
  3940. var aNodes = d3_layout_bundleAncestors(a), bNodes = d3_layout_bundleAncestors(b), aNode = aNodes.pop(), bNode = bNodes.pop(), sharedNode = null;
  3941. while (aNode === bNode) {
  3942. sharedNode = aNode;
  3943. aNode = aNodes.pop();
  3944. bNode = bNodes.pop();
  3945. }
  3946. return sharedNode;
  3947. }
  3948. d3.layout.chord = function() {
  3949. var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords;
  3950. function relayout() {
  3951. var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j;
  3952. chords = [];
  3953. groups = [];
  3954. k = 0, i = -1;
  3955. while (++i < n) {
  3956. x = 0, j = -1;
  3957. while (++j < n) {
  3958. x += matrix[i][j];
  3959. }
  3960. groupSums.push(x);
  3961. subgroupIndex.push(d3.range(n));
  3962. k += x;
  3963. }
  3964. if (sortGroups) {
  3965. groupIndex.sort(function(a, b) {
  3966. return sortGroups(groupSums[a], groupSums[b]);
  3967. });
  3968. }
  3969. if (sortSubgroups) {
  3970. subgroupIndex.forEach(function(d, i) {
  3971. d.sort(function(a, b) {
  3972. return sortSubgroups(matrix[i][a], matrix[i][b]);
  3973. });
  3974. });
  3975. }
  3976. k = (2 * π - padding * n) / k;
  3977. x = 0, i = -1;
  3978. while (++i < n) {
  3979. x0 = x, j = -1;
  3980. while (++j < n) {
  3981. var di = groupIndex[i], dj = subgroupIndex[di][j], v = matrix[di][dj], a0 = x, a1 = x += v * k;
  3982. subgroups[di + "-" + dj] = {
  3983. index: di,
  3984. subindex: dj,
  3985. startAngle: a0,
  3986. endAngle: a1,
  3987. value: v
  3988. };
  3989. }
  3990. groups[di] = {
  3991. index: di,
  3992. startAngle: x0,
  3993. endAngle: x,
  3994. value: (x - x0) / k
  3995. };
  3996. x += padding;
  3997. }
  3998. i = -1;
  3999. while (++i < n) {
  4000. j = i - 1;
  4001. while (++j < n) {
  4002. var source = subgroups[i + "-" + j], target = subgroups[j + "-" + i];
  4003. if (source.value || target.value) {
  4004. chords.push(source.value < target.value ? {
  4005. source: target,
  4006. target: source
  4007. } : {
  4008. source: source,
  4009. target: target
  4010. });
  4011. }
  4012. }
  4013. }
  4014. if (sortChords) resort();
  4015. }
  4016. function resort() {
  4017. chords.sort(function(a, b) {
  4018. return sortChords((a.source.value + a.target.value) / 2, (b.source.value + b.target.value) / 2);
  4019. });
  4020. }
  4021. chord.matrix = function(x) {
  4022. if (!arguments.length) return matrix;
  4023. n = (matrix = x) && matrix.length;
  4024. chords = groups = null;
  4025. return chord;
  4026. };
  4027. chord.padding = function(x) {
  4028. if (!arguments.length) return padding;
  4029. padding = x;
  4030. chords = groups = null;
  4031. return chord;
  4032. };
  4033. chord.sortGroups = function(x) {
  4034. if (!arguments.length) return sortGroups;
  4035. sortGroups = x;
  4036. chords = groups = null;
  4037. return chord;
  4038. };
  4039. chord.sortSubgroups = function(x) {
  4040. if (!arguments.length) return sortSubgroups;
  4041. sortSubgroups = x;
  4042. chords = null;
  4043. return chord;
  4044. };
  4045. chord.sortChords = function(x) {
  4046. if (!arguments.length) return sortChords;
  4047. sortChords = x;
  4048. if (chords) resort();
  4049. return chord;
  4050. };
  4051. chord.chords = function() {
  4052. if (!chords) relayout();
  4053. return chords;
  4054. };
  4055. chord.groups = function() {
  4056. if (!groups) relayout();
  4057. return groups;
  4058. };
  4059. return chord;
  4060. };
  4061. d3.layout.force = function() {
  4062. 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;
  4063. function repulse(node) {
  4064. return function(quad, x1, _, x2) {
  4065. if (quad.point !== node) {
  4066. var dx = quad.cx - node.x, dy = quad.cy - node.y, dn = 1 / Math.sqrt(dx * dx + dy * dy);
  4067. if ((x2 - x1) * dn < theta) {
  4068. var k = quad.charge * dn * dn;
  4069. node.px -= dx * k;
  4070. node.py -= dy * k;
  4071. return true;
  4072. }
  4073. if (quad.point && isFinite(dn)) {
  4074. var k = quad.pointCharge * dn * dn;
  4075. node.px -= dx * k;
  4076. node.py -= dy * k;
  4077. }
  4078. }
  4079. return !quad.charge;
  4080. };
  4081. }
  4082. force.tick = function() {
  4083. if ((alpha *= .99) < .005) {
  4084. event.end({
  4085. type: "end",
  4086. alpha: alpha = 0
  4087. });
  4088. return true;
  4089. }
  4090. var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y;
  4091. for (i = 0; i < m; ++i) {
  4092. o = links[i];
  4093. s = o.source;
  4094. t = o.target;
  4095. x = t.x - s.x;
  4096. y = t.y - s.y;
  4097. if (l = x * x + y * y) {
  4098. l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
  4099. x *= l;
  4100. y *= l;
  4101. t.x -= x * (k = s.weight / (t.weight + s.weight));
  4102. t.y -= y * k;
  4103. s.x += x * (k = 1 - k);
  4104. s.y += y * k;
  4105. }
  4106. }
  4107. if (k = alpha * gravity) {
  4108. x = size[0] / 2;
  4109. y = size[1] / 2;
  4110. i = -1;
  4111. if (k) while (++i < n) {
  4112. o = nodes[i];
  4113. o.x += (x - o.x) * k;
  4114. o.y += (y - o.y) * k;
  4115. }
  4116. }
  4117. if (charge) {
  4118. d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);
  4119. i = -1;
  4120. while (++i < n) {
  4121. if (!(o = nodes[i]).fixed) {
  4122. q.visit(repulse(o));
  4123. }
  4124. }
  4125. }
  4126. i = -1;
  4127. while (++i < n) {
  4128. o = nodes[i];
  4129. if (o.fixed) {
  4130. o.x = o.px;
  4131. o.y = o.py;
  4132. } else {
  4133. o.x -= (o.px - (o.px = o.x)) * friction;
  4134. o.y -= (o.py - (o.py = o.y)) * friction;
  4135. }
  4136. }
  4137. event.tick({
  4138. type: "tick",
  4139. alpha: alpha
  4140. });
  4141. };
  4142. force.nodes = function(x) {
  4143. if (!arguments.length) return nodes;
  4144. nodes = x;
  4145. return force;
  4146. };
  4147. force.links = function(x) {
  4148. if (!arguments.length) return links;
  4149. links = x;
  4150. return force;
  4151. };
  4152. force.size = function(x) {
  4153. if (!arguments.length) return size;
  4154. size = x;
  4155. return force;
  4156. };
  4157. force.linkDistance = function(x) {
  4158. if (!arguments.length) return linkDistance;
  4159. linkDistance = d3_functor(x);
  4160. return force;
  4161. };
  4162. force.distance = force.linkDistance;
  4163. force.linkStrength = function(x) {
  4164. if (!arguments.length) return linkStrength;
  4165. linkStrength = d3_functor(x);
  4166. return force;
  4167. };
  4168. force.friction = function(x) {
  4169. if (!arguments.length) return friction;
  4170. friction = x;
  4171. return force;
  4172. };
  4173. force.charge = function(x) {
  4174. if (!arguments.length) return charge;
  4175. charge = typeof x === "function" ? x : +x;
  4176. return force;
  4177. };
  4178. force.gravity = function(x) {
  4179. if (!arguments.length) return gravity;
  4180. gravity = x;
  4181. return force;
  4182. };
  4183. force.theta = function(x) {
  4184. if (!arguments.length) return theta;
  4185. theta = x;
  4186. return force;
  4187. };
  4188. force.alpha = function(x) {
  4189. if (!arguments.length) return alpha;
  4190. if (alpha) {
  4191. if (x > 0) alpha = x; else alpha = 0;
  4192. } else if (x > 0) {
  4193. event.start({
  4194. type: "start",
  4195. alpha: alpha = x
  4196. });
  4197. d3.timer(force.tick);
  4198. }
  4199. return force;
  4200. };
  4201. force.start = function() {
  4202. var i, j, n = nodes.length, m = links.length, w = size[0], h = size[1], neighbors, o;
  4203. for (i = 0; i < n; ++i) {
  4204. (o = nodes[i]).index = i;
  4205. o.weight = 0;
  4206. }
  4207. distances = [];
  4208. strengths = [];
  4209. for (i = 0; i < m; ++i) {
  4210. o = links[i];
  4211. if (typeof o.source == "number") o.source = nodes[o.source];
  4212. if (typeof o.target == "number") o.target = nodes[o.target];
  4213. distances[i] = linkDistance.call(this, o, i);
  4214. strengths[i] = linkStrength.call(this, o, i);
  4215. ++o.source.weight;
  4216. ++o.target.weight;
  4217. }
  4218. for (i = 0; i < n; ++i) {
  4219. o = nodes[i];
  4220. if (isNaN(o.x)) o.x = position("x", w);
  4221. if (isNaN(o.y)) o.y = position("y", h);
  4222. if (isNaN(o.px)) o.px = o.x;
  4223. if (isNaN(o.py)) o.py = o.y;
  4224. }
  4225. charges = [];
  4226. if (typeof charge === "function") {
  4227. for (i = 0; i < n; ++i) {
  4228. charges[i] = +charge.call(this, nodes[i], i);
  4229. }
  4230. } else {
  4231. for (i = 0; i < n; ++i) {
  4232. charges[i] = charge;
  4233. }
  4234. }
  4235. function position(dimension, size) {
  4236. var neighbors = neighbor(i), j = -1, m = neighbors.length, x;
  4237. while (++j < m) if (!isNaN(x = neighbors[j][dimension])) return x;
  4238. return Math.random() * size;
  4239. }
  4240. function neighbor() {
  4241. if (!neighbors) {
  4242. neighbors = [];
  4243. for (j = 0; j < n; ++j) {
  4244. neighbors[j] = [];
  4245. }
  4246. for (j = 0; j < m; ++j) {
  4247. var o = links[j];
  4248. neighbors[o.source.index].push(o.target);
  4249. neighbors[o.target.index].push(o.source);
  4250. }
  4251. }
  4252. return neighbors[i];
  4253. }
  4254. return force.resume();
  4255. };
  4256. force.resume = function() {
  4257. return force.alpha(.1);
  4258. };
  4259. force.stop = function() {
  4260. return force.alpha(0);
  4261. };
  4262. force.drag = function() {
  4263. if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart", d3_layout_forceDragstart).on("drag", dragmove).on("dragend", d3_layout_forceDragend);
  4264. this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag);
  4265. };
  4266. function dragmove(d) {
  4267. d.px = d3.event.x, d.py = d3.event.y;
  4268. force.resume();
  4269. }
  4270. return d3.rebind(force, event, "on");
  4271. };
  4272. function d3_layout_forceDragstart(d) {
  4273. d.fixed |= 2;
  4274. }
  4275. function d3_layout_forceDragend(d) {
  4276. d.fixed &= 1;
  4277. }
  4278. function d3_layout_forceMouseover(d) {
  4279. d.fixed |= 4;
  4280. d.px = d.x, d.py = d.y;
  4281. }
  4282. function d3_layout_forceMouseout(d) {
  4283. d.fixed &= 3;
  4284. }
  4285. function d3_layout_forceAccumulate(quad, alpha, charges) {
  4286. var cx = 0, cy = 0;
  4287. quad.charge = 0;
  4288. if (!quad.leaf) {
  4289. var nodes = quad.nodes, n = nodes.length, i = -1, c;
  4290. while (++i < n) {
  4291. c = nodes[i];
  4292. if (c == null) continue;
  4293. d3_layout_forceAccumulate(c, alpha, charges);
  4294. quad.charge += c.charge;
  4295. cx += c.charge * c.cx;
  4296. cy += c.charge * c.cy;
  4297. }
  4298. }
  4299. if (quad.point) {
  4300. if (!quad.leaf) {
  4301. quad.point.x += Math.random() - .5;
  4302. quad.point.y += Math.random() - .5;
  4303. }
  4304. var k = alpha * charges[quad.point.index];
  4305. quad.charge += quad.pointCharge = k;
  4306. cx += k * quad.point.x;
  4307. cy += k * quad.point.y;
  4308. }
  4309. quad.cx = cx / quad.charge;
  4310. quad.cy = cy / quad.charge;
  4311. }
  4312. function d3_layout_forceLinkDistance() {
  4313. return 20;
  4314. }
  4315. function d3_layout_forceLinkStrength() {
  4316. return 1;
  4317. }
  4318. d3.layout.partition = function() {
  4319. var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ];
  4320. function position(node, x, dx, dy) {
  4321. var children = node.children;
  4322. node.x = x;
  4323. node.y = node.depth * dy;
  4324. node.dx = dx;
  4325. node.dy = dy;
  4326. if (children && (n = children.length)) {
  4327. var i = -1, n, c, d;
  4328. dx = node.value ? dx / node.value : 0;
  4329. while (++i < n) {
  4330. position(c = children[i], x, d = c.value * dx, dy);
  4331. x += d;
  4332. }
  4333. }
  4334. }
  4335. function depth(node) {
  4336. var children = node.children, d = 0;
  4337. if (children && (n = children.length)) {
  4338. var i = -1, n;
  4339. while (++i < n) d = Math.max(d, depth(children[i]));
  4340. }
  4341. return 1 + d;
  4342. }
  4343. function partition(d, i) {
  4344. var nodes = hierarchy.call(this, d, i);
  4345. position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));
  4346. return nodes;
  4347. }
  4348. partition.size = function(x) {
  4349. if (!arguments.length) return size;
  4350. size = x;
  4351. return partition;
  4352. };
  4353. return d3_layout_hierarchyRebind(partition, hierarchy);
  4354. };
  4355. d3.layout.pie = function() {
  4356. var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = 2 * π;
  4357. function pie(data) {
  4358. var values = data.map(function(d, i) {
  4359. return +value.call(pie, d, i);
  4360. });
  4361. var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle);
  4362. var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - startAngle) / d3.sum(values);
  4363. var index = d3.range(data.length);
  4364. if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
  4365. return values[j] - values[i];
  4366. } : function(i, j) {
  4367. return sort(data[i], data[j]);
  4368. });
  4369. var arcs = [];
  4370. index.forEach(function(i) {
  4371. var d;
  4372. arcs[i] = {
  4373. data: data[i],
  4374. value: d = values[i],
  4375. startAngle: a,
  4376. endAngle: a += d * k
  4377. };
  4378. });
  4379. return arcs;
  4380. }
  4381. pie.value = function(x) {
  4382. if (!arguments.length) return value;
  4383. value = x;
  4384. return pie;
  4385. };
  4386. pie.sort = function(x) {
  4387. if (!arguments.length) return sort;
  4388. sort = x;
  4389. return pie;
  4390. };
  4391. pie.startAngle = function(x) {
  4392. if (!arguments.length) return startAngle;
  4393. startAngle = x;
  4394. return pie;
  4395. };
  4396. pie.endAngle = function(x) {
  4397. if (!arguments.length) return endAngle;
  4398. endAngle = x;
  4399. return pie;
  4400. };
  4401. return pie;
  4402. };
  4403. var d3_layout_pieSortByValue = {};
  4404. d3.layout.stack = function() {
  4405. var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY;
  4406. function stack(data, index) {
  4407. var series = data.map(function(d, i) {
  4408. return values.call(stack, d, i);
  4409. });
  4410. var points = series.map(function(d) {
  4411. return d.map(function(v, i) {
  4412. return [ x.call(stack, v, i), y.call(stack, v, i) ];
  4413. });
  4414. });
  4415. var orders = order.call(stack, points, index);
  4416. series = d3.permute(series, orders);
  4417. points = d3.permute(points, orders);
  4418. var offsets = offset.call(stack, points, index);
  4419. var n = series.length, m = series[0].length, i, j, o;
  4420. for (j = 0; j < m; ++j) {
  4421. out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);
  4422. for (i = 1; i < n; ++i) {
  4423. out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);
  4424. }
  4425. }
  4426. return data;
  4427. }
  4428. stack.values = function(x) {
  4429. if (!arguments.length) return values;
  4430. values = x;
  4431. return stack;
  4432. };
  4433. stack.order = function(x) {
  4434. if (!arguments.length) return order;
  4435. order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;
  4436. return stack;
  4437. };
  4438. stack.offset = function(x) {
  4439. if (!arguments.length) return offset;
  4440. offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;
  4441. return stack;
  4442. };
  4443. stack.x = function(z) {
  4444. if (!arguments.length) return x;
  4445. x = z;
  4446. return stack;
  4447. };
  4448. stack.y = function(z) {
  4449. if (!arguments.length) return y;
  4450. y = z;
  4451. return stack;
  4452. };
  4453. stack.out = function(z) {
  4454. if (!arguments.length) return out;
  4455. out = z;
  4456. return stack;
  4457. };
  4458. return stack;
  4459. };
  4460. function d3_layout_stackX(d) {
  4461. return d.x;
  4462. }
  4463. function d3_layout_stackY(d) {
  4464. return d.y;
  4465. }
  4466. function d3_layout_stackOut(d, y0, y) {
  4467. d.y0 = y0;
  4468. d.y = y;
  4469. }
  4470. var d3_layout_stackOrders = d3.map({
  4471. "inside-out": function(data) {
  4472. 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) {
  4473. return max[a] - max[b];
  4474. }), top = 0, bottom = 0, tops = [], bottoms = [];
  4475. for (i = 0; i < n; ++i) {
  4476. j = index[i];
  4477. if (top < bottom) {
  4478. top += sums[j];
  4479. tops.push(j);
  4480. } else {
  4481. bottom += sums[j];
  4482. bottoms.push(j);
  4483. }
  4484. }
  4485. return bottoms.reverse().concat(tops);
  4486. },
  4487. reverse: function(data) {
  4488. return d3.range(data.length).reverse();
  4489. },
  4490. "default": d3_layout_stackOrderDefault
  4491. });
  4492. var d3_layout_stackOffsets = d3.map({
  4493. silhouette: function(data) {
  4494. var n = data.length, m = data[0].length, sums = [], max = 0, i, j, o, y0 = [];
  4495. for (j = 0; j < m; ++j) {
  4496. for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
  4497. if (o > max) max = o;
  4498. sums.push(o);
  4499. }
  4500. for (j = 0; j < m; ++j) {
  4501. y0[j] = (max - sums[j]) / 2;
  4502. }
  4503. return y0;
  4504. },
  4505. wiggle: function(data) {
  4506. var n = data.length, x = data[0], m = x.length, i, j, k, s1, s2, s3, dx, o, o0, y0 = [];
  4507. y0[0] = o = o0 = 0;
  4508. for (j = 1; j < m; ++j) {
  4509. for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];
  4510. for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {
  4511. for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {
  4512. s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;
  4513. }
  4514. s2 += s3 * data[i][j][1];
  4515. }
  4516. y0[j] = o -= s1 ? s2 / s1 * dx : 0;
  4517. if (o < o0) o0 = o;
  4518. }
  4519. for (j = 0; j < m; ++j) y0[j] -= o0;
  4520. return y0;
  4521. },
  4522. expand: function(data) {
  4523. var n = data.length, m = data[0].length, k = 1 / n, i, j, o, y0 = [];
  4524. for (j = 0; j < m; ++j) {
  4525. for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
  4526. 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;
  4527. }
  4528. for (j = 0; j < m; ++j) y0[j] = 0;
  4529. return y0;
  4530. },
  4531. zero: d3_layout_stackOffsetZero
  4532. });
  4533. function d3_layout_stackOrderDefault(data) {
  4534. return d3.range(data.length);
  4535. }
  4536. function d3_layout_stackOffsetZero(data) {
  4537. var j = -1, m = data[0].length, y0 = [];
  4538. while (++j < m) y0[j] = 0;
  4539. return y0;
  4540. }
  4541. function d3_layout_stackMaxIndex(array) {
  4542. var i = 1, j = 0, v = array[0][1], k, n = array.length;
  4543. for (;i < n; ++i) {
  4544. if ((k = array[i][1]) > v) {
  4545. j = i;
  4546. v = k;
  4547. }
  4548. }
  4549. return j;
  4550. }
  4551. function d3_layout_stackReduceSum(d) {
  4552. return d.reduce(d3_layout_stackSum, 0);
  4553. }
  4554. function d3_layout_stackSum(p, d) {
  4555. return p + d[1];
  4556. }
  4557. d3.layout.histogram = function() {
  4558. var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges;
  4559. function histogram(data, i) {
  4560. 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;
  4561. while (++i < m) {
  4562. bin = bins[i] = [];
  4563. bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);
  4564. bin.y = 0;
  4565. }
  4566. if (m > 0) {
  4567. i = -1;
  4568. while (++i < n) {
  4569. x = values[i];
  4570. if (x >= range[0] && x <= range[1]) {
  4571. bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
  4572. bin.y += k;
  4573. bin.push(data[i]);
  4574. }
  4575. }
  4576. }
  4577. return bins;
  4578. }
  4579. histogram.value = function(x) {
  4580. if (!arguments.length) return valuer;
  4581. valuer = x;
  4582. return histogram;
  4583. };
  4584. histogram.range = function(x) {
  4585. if (!arguments.length) return ranger;
  4586. ranger = d3_functor(x);
  4587. return histogram;
  4588. };
  4589. histogram.bins = function(x) {
  4590. if (!arguments.length) return binner;
  4591. binner = typeof x === "number" ? function(range) {
  4592. return d3_layout_histogramBinFixed(range, x);
  4593. } : d3_functor(x);
  4594. return histogram;
  4595. };
  4596. histogram.frequency = function(x) {
  4597. if (!arguments.length) return frequency;
  4598. frequency = !!x;
  4599. return histogram;
  4600. };
  4601. return histogram;
  4602. };
  4603. function d3_layout_histogramBinSturges(range, values) {
  4604. return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));
  4605. }
  4606. function d3_layout_histogramBinFixed(range, n) {
  4607. var x = -1, b = +range[0], m = (range[1] - b) / n, f = [];
  4608. while (++x <= n) f[x] = m * x + b;
  4609. return f;
  4610. }
  4611. function d3_layout_histogramRange(values) {
  4612. return [ d3.min(values), d3.max(values) ];
  4613. }
  4614. d3.layout.hierarchy = function() {
  4615. var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue;
  4616. function recurse(node, depth, nodes) {
  4617. var childs = children.call(hierarchy, node, depth);
  4618. node.depth = depth;
  4619. nodes.push(node);
  4620. if (childs && (n = childs.length)) {
  4621. var i = -1, n, c = node.children = [], v = 0, j = depth + 1, d;
  4622. while (++i < n) {
  4623. d = recurse(childs[i], j, nodes);
  4624. d.parent = node;
  4625. c.push(d);
  4626. v += d.value;
  4627. }
  4628. if (sort) c.sort(sort);
  4629. if (value) node.value = v;
  4630. } else if (value) {
  4631. node.value = +value.call(hierarchy, node, depth) || 0;
  4632. }
  4633. return node;
  4634. }
  4635. function revalue(node, depth) {
  4636. var children = node.children, v = 0;
  4637. if (children && (n = children.length)) {
  4638. var i = -1, n, j = depth + 1;
  4639. while (++i < n) v += revalue(children[i], j);
  4640. } else if (value) {
  4641. v = +value.call(hierarchy, node, depth) || 0;
  4642. }
  4643. if (value) node.value = v;
  4644. return v;
  4645. }
  4646. function hierarchy(d) {
  4647. var nodes = [];
  4648. recurse(d, 0, nodes);
  4649. return nodes;
  4650. }
  4651. hierarchy.sort = function(x) {
  4652. if (!arguments.length) return sort;
  4653. sort = x;
  4654. return hierarchy;
  4655. };
  4656. hierarchy.children = function(x) {
  4657. if (!arguments.length) return children;
  4658. children = x;
  4659. return hierarchy;
  4660. };
  4661. hierarchy.value = function(x) {
  4662. if (!arguments.length) return value;
  4663. value = x;
  4664. return hierarchy;
  4665. };
  4666. hierarchy.revalue = function(root) {
  4667. revalue(root, 0);
  4668. return root;
  4669. };
  4670. return hierarchy;
  4671. };
  4672. function d3_layout_hierarchyRebind(object, hierarchy) {
  4673. d3.rebind(object, hierarchy, "sort", "children", "value");
  4674. object.nodes = object;
  4675. object.links = d3_layout_hierarchyLinks;
  4676. return object;
  4677. }
  4678. function d3_layout_hierarchyChildren(d) {
  4679. return d.children;
  4680. }
  4681. function d3_layout_hierarchyValue(d) {
  4682. return d.value;
  4683. }
  4684. function d3_layout_hierarchySort(a, b) {
  4685. return b.value - a.value;
  4686. }
  4687. function d3_layout_hierarchyLinks(nodes) {
  4688. return d3.merge(nodes.map(function(parent) {
  4689. return (parent.children || []).map(function(child) {
  4690. return {
  4691. source: parent,
  4692. target: child
  4693. };
  4694. });
  4695. }));
  4696. }
  4697. d3.layout.pack = function() {
  4698. var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ];
  4699. function pack(d, i) {
  4700. var nodes = hierarchy.call(this, d, i), root = nodes[0];
  4701. root.x = 0;
  4702. root.y = 0;
  4703. d3_layout_treeVisitAfter(root, function(d) {
  4704. d.r = Math.sqrt(d.value);
  4705. });
  4706. d3_layout_treeVisitAfter(root, d3_layout_packSiblings);
  4707. var w = size[0], h = size[1], k = Math.max(2 * root.r / w, 2 * root.r / h);
  4708. if (padding > 0) {
  4709. var dr = padding * k / 2;
  4710. d3_layout_treeVisitAfter(root, function(d) {
  4711. d.r += dr;
  4712. });
  4713. d3_layout_treeVisitAfter(root, d3_layout_packSiblings);
  4714. d3_layout_treeVisitAfter(root, function(d) {
  4715. d.r -= dr;
  4716. });
  4717. k = Math.max(2 * root.r / w, 2 * root.r / h);
  4718. }
  4719. d3_layout_packTransform(root, w / 2, h / 2, 1 / k);
  4720. return nodes;
  4721. }
  4722. pack.size = function(x) {
  4723. if (!arguments.length) return size;
  4724. size = x;
  4725. return pack;
  4726. };
  4727. pack.padding = function(_) {
  4728. if (!arguments.length) return padding;
  4729. padding = +_;
  4730. return pack;
  4731. };
  4732. return d3_layout_hierarchyRebind(pack, hierarchy);
  4733. };
  4734. function d3_layout_packSort(a, b) {
  4735. return a.value - b.value;
  4736. }
  4737. function d3_layout_packInsert(a, b) {
  4738. var c = a._pack_next;
  4739. a._pack_next = b;
  4740. b._pack_prev = a;
  4741. b._pack_next = c;
  4742. c._pack_prev = b;
  4743. }
  4744. function d3_layout_packSplice(a, b) {
  4745. a._pack_next = b;
  4746. b._pack_prev = a;
  4747. }
  4748. function d3_layout_packIntersects(a, b) {
  4749. var dx = b.x - a.x, dy = b.y - a.y, dr = a.r + b.r;
  4750. return dr * dr - dx * dx - dy * dy > .001;
  4751. }
  4752. function d3_layout_packSiblings(node) {
  4753. if (!(nodes = node.children) || !(n = nodes.length)) return;
  4754. var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n;
  4755. function bound(node) {
  4756. xMin = Math.min(node.x - node.r, xMin);
  4757. xMax = Math.max(node.x + node.r, xMax);
  4758. yMin = Math.min(node.y - node.r, yMin);
  4759. yMax = Math.max(node.y + node.r, yMax);
  4760. }
  4761. nodes.forEach(d3_layout_packLink);
  4762. a = nodes[0];
  4763. a.x = -a.r;
  4764. a.y = 0;
  4765. bound(a);
  4766. if (n > 1) {
  4767. b = nodes[1];
  4768. b.x = b.r;
  4769. b.y = 0;
  4770. bound(b);
  4771. if (n > 2) {
  4772. c = nodes[2];
  4773. d3_layout_packPlace(a, b, c);
  4774. bound(c);
  4775. d3_layout_packInsert(a, c);
  4776. a._pack_prev = c;
  4777. d3_layout_packInsert(c, b);
  4778. b = a._pack_next;
  4779. for (i = 3; i < n; i++) {
  4780. d3_layout_packPlace(a, b, c = nodes[i]);
  4781. var isect = 0, s1 = 1, s2 = 1;
  4782. for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {
  4783. if (d3_layout_packIntersects(j, c)) {
  4784. isect = 1;
  4785. break;
  4786. }
  4787. }
  4788. if (isect == 1) {
  4789. for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
  4790. if (d3_layout_packIntersects(k, c)) {
  4791. break;
  4792. }
  4793. }
  4794. }
  4795. if (isect) {
  4796. if (s1 < s2 || s1 == s2 && b.r < a.r) d3_layout_packSplice(a, b = j); else d3_layout_packSplice(a = k, b);
  4797. i--;
  4798. } else {
  4799. d3_layout_packInsert(a, c);
  4800. b = c;
  4801. bound(c);
  4802. }
  4803. }
  4804. }
  4805. }
  4806. var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0;
  4807. for (i = 0; i < n; i++) {
  4808. c = nodes[i];
  4809. c.x -= cx;
  4810. c.y -= cy;
  4811. cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y));
  4812. }
  4813. node.r = cr;
  4814. nodes.forEach(d3_layout_packUnlink);
  4815. }
  4816. function d3_layout_packLink(node) {
  4817. node._pack_next = node._pack_prev = node;
  4818. }
  4819. function d3_layout_packUnlink(node) {
  4820. delete node._pack_next;
  4821. delete node._pack_prev;
  4822. }
  4823. function d3_layout_packTransform(node, x, y, k) {
  4824. var children = node.children;
  4825. node.x = x += k * node.x;
  4826. node.y = y += k * node.y;
  4827. node.r *= k;
  4828. if (children) {
  4829. var i = -1, n = children.length;
  4830. while (++i < n) d3_layout_packTransform(children[i], x, y, k);
  4831. }
  4832. }
  4833. function d3_layout_packPlace(a, b, c) {
  4834. var db = a.r + c.r, dx = b.x - a.x, dy = b.y - a.y;
  4835. if (db && (dx || dy)) {
  4836. var da = b.r + c.r, dc = dx * dx + dy * dy;
  4837. da *= da;
  4838. db *= db;
  4839. var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc);
  4840. c.x = a.x + x * dx + y * dy;
  4841. c.y = a.y + x * dy - y * dx;
  4842. } else {
  4843. c.x = a.x + db;
  4844. c.y = a.y;
  4845. }
  4846. }
  4847. d3.layout.cluster = function() {
  4848. var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ];
  4849. function cluster(d, i) {
  4850. var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0;
  4851. d3_layout_treeVisitAfter(root, function(node) {
  4852. var children = node.children;
  4853. if (children && children.length) {
  4854. node.x = d3_layout_clusterX(children);
  4855. node.y = d3_layout_clusterY(children);
  4856. } else {
  4857. node.x = previousNode ? x += separation(node, previousNode) : 0;
  4858. node.y = 0;
  4859. previousNode = node;
  4860. }
  4861. });
  4862. 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;
  4863. d3_layout_treeVisitAfter(root, function(node) {
  4864. node.x = (node.x - x0) / (x1 - x0) * size[0];
  4865. node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];
  4866. });
  4867. return nodes;
  4868. }
  4869. cluster.separation = function(x) {
  4870. if (!arguments.length) return separation;
  4871. separation = x;
  4872. return cluster;
  4873. };
  4874. cluster.size = function(x) {
  4875. if (!arguments.length) return size;
  4876. size = x;
  4877. return cluster;
  4878. };
  4879. return d3_layout_hierarchyRebind(cluster, hierarchy);
  4880. };
  4881. function d3_layout_clusterY(children) {
  4882. return 1 + d3.max(children, function(child) {
  4883. return child.y;
  4884. });
  4885. }
  4886. function d3_layout_clusterX(children) {
  4887. return children.reduce(function(x, child) {
  4888. return x + child.x;
  4889. }, 0) / children.length;
  4890. }
  4891. function d3_layout_clusterLeft(node) {
  4892. var children = node.children;
  4893. return children && children.length ? d3_layout_clusterLeft(children[0]) : node;
  4894. }
  4895. function d3_layout_clusterRight(node) {
  4896. var children = node.children, n;
  4897. return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;
  4898. }
  4899. d3.layout.tree = function() {
  4900. var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ];
  4901. function tree(d, i) {
  4902. var nodes = hierarchy.call(this, d, i), root = nodes[0];
  4903. function firstWalk(node, previousSibling) {
  4904. var children = node.children, layout = node._tree;
  4905. if (children && (n = children.length)) {
  4906. var n, firstChild = children[0], previousChild, ancestor = firstChild, child, i = -1;
  4907. while (++i < n) {
  4908. child = children[i];
  4909. firstWalk(child, previousChild);
  4910. ancestor = apportion(child, previousChild, ancestor);
  4911. previousChild = child;
  4912. }
  4913. d3_layout_treeShift(node);
  4914. var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim);
  4915. if (previousSibling) {
  4916. layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
  4917. layout.mod = layout.prelim - midpoint;
  4918. } else {
  4919. layout.prelim = midpoint;
  4920. }
  4921. } else {
  4922. if (previousSibling) {
  4923. layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
  4924. }
  4925. }
  4926. }
  4927. function secondWalk(node, x) {
  4928. node.x = node._tree.prelim + x;
  4929. var children = node.children;
  4930. if (children && (n = children.length)) {
  4931. var i = -1, n;
  4932. x += node._tree.mod;
  4933. while (++i < n) {
  4934. secondWalk(children[i], x);
  4935. }
  4936. }
  4937. }
  4938. function apportion(node, previousSibling, ancestor) {
  4939. if (previousSibling) {
  4940. 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;
  4941. while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
  4942. vom = d3_layout_treeLeft(vom);
  4943. vop = d3_layout_treeRight(vop);
  4944. vop._tree.ancestor = node;
  4945. shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip);
  4946. if (shift > 0) {
  4947. d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift);
  4948. sip += shift;
  4949. sop += shift;
  4950. }
  4951. sim += vim._tree.mod;
  4952. sip += vip._tree.mod;
  4953. som += vom._tree.mod;
  4954. sop += vop._tree.mod;
  4955. }
  4956. if (vim && !d3_layout_treeRight(vop)) {
  4957. vop._tree.thread = vim;
  4958. vop._tree.mod += sim - sop;
  4959. }
  4960. if (vip && !d3_layout_treeLeft(vom)) {
  4961. vom._tree.thread = vip;
  4962. vom._tree.mod += sip - som;
  4963. ancestor = node;
  4964. }
  4965. }
  4966. return ancestor;
  4967. }
  4968. d3_layout_treeVisitAfter(root, function(node, previousSibling) {
  4969. node._tree = {
  4970. ancestor: node,
  4971. prelim: 0,
  4972. mod: 0,
  4973. change: 0,
  4974. shift: 0,
  4975. number: previousSibling ? previousSibling._tree.number + 1 : 0
  4976. };
  4977. });
  4978. firstWalk(root);
  4979. secondWalk(root, -root._tree.prelim);
  4980. 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;
  4981. d3_layout_treeVisitAfter(root, function(node) {
  4982. node.x = (node.x - x0) / (x1 - x0) * size[0];
  4983. node.y = node.depth / y1 * size[1];
  4984. delete node._tree;
  4985. });
  4986. return nodes;
  4987. }
  4988. tree.separation = function(x) {
  4989. if (!arguments.length) return separation;
  4990. separation = x;
  4991. return tree;
  4992. };
  4993. tree.size = function(x) {
  4994. if (!arguments.length) return size;
  4995. size = x;
  4996. return tree;
  4997. };
  4998. return d3_layout_hierarchyRebind(tree, hierarchy);
  4999. };
  5000. function d3_layout_treeSeparation(a, b) {
  5001. return a.parent == b.parent ? 1 : 2;
  5002. }
  5003. function d3_layout_treeLeft(node) {
  5004. var children = node.children;
  5005. return children && children.length ? children[0] : node._tree.thread;
  5006. }
  5007. function d3_layout_treeRight(node) {
  5008. var children = node.children, n;
  5009. return children && (n = children.length) ? children[n - 1] : node._tree.thread;
  5010. }
  5011. function d3_layout_treeSearch(node, compare) {
  5012. var children = node.children;
  5013. if (children && (n = children.length)) {
  5014. var child, n, i = -1;
  5015. while (++i < n) {
  5016. if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) {
  5017. node = child;
  5018. }
  5019. }
  5020. }
  5021. return node;
  5022. }
  5023. function d3_layout_treeRightmost(a, b) {
  5024. return a.x - b.x;
  5025. }
  5026. function d3_layout_treeLeftmost(a, b) {
  5027. return b.x - a.x;
  5028. }
  5029. function d3_layout_treeDeepest(a, b) {
  5030. return a.depth - b.depth;
  5031. }
  5032. function d3_layout_treeVisitAfter(node, callback) {
  5033. function visit(node, previousSibling) {
  5034. var children = node.children;
  5035. if (children && (n = children.length)) {
  5036. var child, previousChild = null, i = -1, n;
  5037. while (++i < n) {
  5038. child = children[i];
  5039. visit(child, previousChild);
  5040. previousChild = child;
  5041. }
  5042. }
  5043. callback(node, previousSibling);
  5044. }
  5045. visit(node, null);
  5046. }
  5047. function d3_layout_treeShift(node) {
  5048. var shift = 0, change = 0, children = node.children, i = children.length, child;
  5049. while (--i >= 0) {
  5050. child = children[i]._tree;
  5051. child.prelim += shift;
  5052. child.mod += shift;
  5053. shift += child.shift + (change += child.change);
  5054. }
  5055. }
  5056. function d3_layout_treeMove(ancestor, node, shift) {
  5057. ancestor = ancestor._tree;
  5058. node = node._tree;
  5059. var change = shift / (node.number - ancestor.number);
  5060. ancestor.change += change;
  5061. node.change -= change;
  5062. node.shift += shift;
  5063. node.prelim += shift;
  5064. node.mod += shift;
  5065. }
  5066. function d3_layout_treeAncestor(vim, node, ancestor) {
  5067. return vim._tree.ancestor.parent == node.parent ? vim._tree.ancestor : ancestor;
  5068. }
  5069. d3.layout.treemap = function() {
  5070. 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));
  5071. function scale(children, k) {
  5072. var i = -1, n = children.length, child, area;
  5073. while (++i < n) {
  5074. area = (child = children[i]).value * (k < 0 ? 0 : k);
  5075. child.area = isNaN(area) || area <= 0 ? 0 : area;
  5076. }
  5077. }
  5078. function squarify(node) {
  5079. var children = node.children;
  5080. if (children && children.length) {
  5081. 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;
  5082. scale(remaining, rect.dx * rect.dy / node.value);
  5083. row.area = 0;
  5084. while ((n = remaining.length) > 0) {
  5085. row.push(child = remaining[n - 1]);
  5086. row.area += child.area;
  5087. if (mode !== "squarify" || (score = worst(row, u)) <= best) {
  5088. remaining.pop();
  5089. best = score;
  5090. } else {
  5091. row.area -= row.pop().area;
  5092. position(row, u, rect, false);
  5093. u = Math.min(rect.dx, rect.dy);
  5094. row.length = row.area = 0;
  5095. best = Infinity;
  5096. }
  5097. }
  5098. if (row.length) {
  5099. position(row, u, rect, true);
  5100. row.length = row.area = 0;
  5101. }
  5102. children.forEach(squarify);
  5103. }
  5104. }
  5105. function stickify(node) {
  5106. var children = node.children;
  5107. if (children && children.length) {
  5108. var rect = pad(node), remaining = children.slice(), child, row = [];
  5109. scale(remaining, rect.dx * rect.dy / node.value);
  5110. row.area = 0;
  5111. while (child = remaining.pop()) {
  5112. row.push(child);
  5113. row.area += child.area;
  5114. if (child.z != null) {
  5115. position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);
  5116. row.length = row.area = 0;
  5117. }
  5118. }
  5119. children.forEach(stickify);
  5120. }
  5121. }
  5122. function worst(row, u) {
  5123. var s = row.area, r, rmax = 0, rmin = Infinity, i = -1, n = row.length;
  5124. while (++i < n) {
  5125. if (!(r = row[i].area)) continue;
  5126. if (r < rmin) rmin = r;
  5127. if (r > rmax) rmax = r;
  5128. }
  5129. s *= s;
  5130. u *= u;
  5131. return s ? Math.max(u * rmax * ratio / s, s / (u * rmin * ratio)) : Infinity;
  5132. }
  5133. function position(row, u, rect, flush) {
  5134. var i = -1, n = row.length, x = rect.x, y = rect.y, v = u ? round(row.area / u) : 0, o;
  5135. if (u == rect.dx) {
  5136. if (flush || v > rect.dy) v = rect.dy;
  5137. while (++i < n) {
  5138. o = row[i];
  5139. o.x = x;
  5140. o.y = y;
  5141. o.dy = v;
  5142. x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);
  5143. }
  5144. o.z = true;
  5145. o.dx += rect.x + rect.dx - x;
  5146. rect.y += v;
  5147. rect.dy -= v;
  5148. } else {
  5149. if (flush || v > rect.dx) v = rect.dx;
  5150. while (++i < n) {
  5151. o = row[i];
  5152. o.x = x;
  5153. o.y = y;
  5154. o.dx = v;
  5155. y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);
  5156. }
  5157. o.z = false;
  5158. o.dy += rect.y + rect.dy - y;
  5159. rect.x += v;
  5160. rect.dx -= v;
  5161. }
  5162. }
  5163. function treemap(d) {
  5164. var nodes = stickies || hierarchy(d), root = nodes[0];
  5165. root.x = 0;
  5166. root.y = 0;
  5167. root.dx = size[0];
  5168. root.dy = size[1];
  5169. if (stickies) hierarchy.revalue(root);
  5170. scale([ root ], root.dx * root.dy / root.value);
  5171. (stickies ? stickify : squarify)(root);
  5172. if (sticky) stickies = nodes;
  5173. return nodes;
  5174. }
  5175. treemap.size = function(x) {
  5176. if (!arguments.length) return size;
  5177. size = x;
  5178. return treemap;
  5179. };
  5180. treemap.padding = function(x) {
  5181. if (!arguments.length) return padding;
  5182. function padFunction(node) {
  5183. var p = x.call(treemap, node, node.depth);
  5184. return p == null ? d3_layout_treemapPadNull(node) : d3_layout_treemapPad(node, typeof p === "number" ? [ p, p, p, p ] : p);
  5185. }
  5186. function padConstant(node) {
  5187. return d3_layout_treemapPad(node, x);
  5188. }
  5189. var type;
  5190. pad = (padding = x) == null ? d3_layout_treemapPadNull : (type = typeof x) === "function" ? padFunction : type === "number" ? (x = [ x, x, x, x ],
  5191. padConstant) : padConstant;
  5192. return treemap;
  5193. };
  5194. treemap.round = function(x) {
  5195. if (!arguments.length) return round != Number;
  5196. round = x ? Math.round : Number;
  5197. return treemap;
  5198. };
  5199. treemap.sticky = function(x) {
  5200. if (!arguments.length) return sticky;
  5201. sticky = x;
  5202. stickies = null;
  5203. return treemap;
  5204. };
  5205. treemap.ratio = function(x) {
  5206. if (!arguments.length) return ratio;
  5207. ratio = x;
  5208. return treemap;
  5209. };
  5210. treemap.mode = function(x) {
  5211. if (!arguments.length) return mode;
  5212. mode = x + "";
  5213. return treemap;
  5214. };
  5215. return d3_layout_hierarchyRebind(treemap, hierarchy);
  5216. };
  5217. function d3_layout_treemapPadNull(node) {
  5218. return {
  5219. x: node.x,
  5220. y: node.y,
  5221. dx: node.dx,
  5222. dy: node.dy
  5223. };
  5224. }
  5225. function d3_layout_treemapPad(node, padding) {
  5226. 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];
  5227. if (dx < 0) {
  5228. x += dx / 2;
  5229. dx = 0;
  5230. }
  5231. if (dy < 0) {
  5232. y += dy / 2;
  5233. dy = 0;
  5234. }
  5235. return {
  5236. x: x,
  5237. y: y,
  5238. dx: dx,
  5239. dy: dy
  5240. };
  5241. }
  5242. function d3_dsv(delimiter, mimeType) {
  5243. var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0);
  5244. function dsv(url, callback) {
  5245. return d3.xhr(url, mimeType, callback).response(response);
  5246. }
  5247. function response(request) {
  5248. return dsv.parse(request.responseText);
  5249. }
  5250. dsv.parse = function(text) {
  5251. var o;
  5252. return dsv.parseRows(text, function(row) {
  5253. if (o) return o(row);
  5254. o = new Function("d", "return {" + row.map(function(name, i) {
  5255. return JSON.stringify(name) + ": d[" + i + "]";
  5256. }).join(",") + "}");
  5257. });
  5258. };
  5259. dsv.parseRows = function(text, f) {
  5260. var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol;
  5261. function token() {
  5262. if (I >= N) return EOF;
  5263. if (eol) return eol = false, EOL;
  5264. var j = I;
  5265. if (text.charCodeAt(j) === 34) {
  5266. var i = j;
  5267. while (i++ < N) {
  5268. if (text.charCodeAt(i) === 34) {
  5269. if (text.charCodeAt(i + 1) !== 34) break;
  5270. ++i;
  5271. }
  5272. }
  5273. I = i + 2;
  5274. var c = text.charCodeAt(i + 1);
  5275. if (c === 13) {
  5276. eol = true;
  5277. if (text.charCodeAt(i + 2) === 10) ++I;
  5278. } else if (c === 10) {
  5279. eol = true;
  5280. }
  5281. return text.substring(j + 1, i).replace(/""/g, '"');
  5282. }
  5283. while (I < N) {
  5284. var c = text.charCodeAt(I++), k = 1;
  5285. if (c === 10) eol = true; else if (c === 13) {
  5286. eol = true;
  5287. if (text.charCodeAt(I) === 10) ++I, ++k;
  5288. } else if (c !== delimiterCode) continue;
  5289. return text.substring(j, I - k);
  5290. }
  5291. return text.substring(j);
  5292. }
  5293. while ((t = token()) !== EOF) {
  5294. var a = [];
  5295. while (t !== EOL && t !== EOF) {
  5296. a.push(t);
  5297. t = token();
  5298. }
  5299. if (f && !(a = f(a, n++))) continue;
  5300. rows.push(a);
  5301. }
  5302. return rows;
  5303. };
  5304. dsv.format = function(rows) {
  5305. return rows.map(formatRow).join("\n");
  5306. };
  5307. function formatRow(row) {
  5308. return row.map(formatValue).join(delimiter);
  5309. }
  5310. function formatValue(text) {
  5311. return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text;
  5312. }
  5313. return dsv;
  5314. }
  5315. d3.csv = d3_dsv(",", "text/csv");
  5316. d3.tsv = d3_dsv(" ", "text/tab-separated-values");
  5317. d3.geo = {};
  5318. d3.geo.stream = function(object, listener) {
  5319. if (d3_geo_streamObjectType.hasOwnProperty(object.type)) {
  5320. d3_geo_streamObjectType[object.type](object, listener);
  5321. } else {
  5322. d3_geo_streamGeometry(object, listener);
  5323. }
  5324. };
  5325. function d3_geo_streamGeometry(geometry, listener) {
  5326. if (d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) {
  5327. d3_geo_streamGeometryType[geometry.type](geometry, listener);
  5328. }
  5329. }
  5330. var d3_geo_streamObjectType = {
  5331. Feature: function(feature, listener) {
  5332. d3_geo_streamGeometry(feature.geometry, listener);
  5333. },
  5334. FeatureCollection: function(object, listener) {
  5335. var features = object.features, i = -1, n = features.length;
  5336. while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener);
  5337. }
  5338. };
  5339. var d3_geo_streamGeometryType = {
  5340. Sphere: function(object, listener) {
  5341. listener.sphere();
  5342. },
  5343. Point: function(object, listener) {
  5344. var coordinate = object.coordinates;
  5345. listener.point(coordinate[0], coordinate[1]);
  5346. },
  5347. MultiPoint: function(object, listener) {
  5348. var coordinates = object.coordinates, i = -1, n = coordinates.length, coordinate;
  5349. while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]);
  5350. },
  5351. LineString: function(object, listener) {
  5352. d3_geo_streamLine(object.coordinates, listener, 0);
  5353. },
  5354. MultiLineString: function(object, listener) {
  5355. var coordinates = object.coordinates, i = -1, n = coordinates.length;
  5356. while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0);
  5357. },
  5358. Polygon: function(object, listener) {
  5359. d3_geo_streamPolygon(object.coordinates, listener);
  5360. },
  5361. MultiPolygon: function(object, listener) {
  5362. var coordinates = object.coordinates, i = -1, n = coordinates.length;
  5363. while (++i < n) d3_geo_streamPolygon(coordinates[i], listener);
  5364. },
  5365. GeometryCollection: function(object, listener) {
  5366. var geometries = object.geometries, i = -1, n = geometries.length;
  5367. while (++i < n) d3_geo_streamGeometry(geometries[i], listener);
  5368. }
  5369. };
  5370. function d3_geo_streamLine(coordinates, listener, closed) {
  5371. var i = -1, n = coordinates.length - closed, coordinate;
  5372. listener.lineStart();
  5373. while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]);
  5374. listener.lineEnd();
  5375. }
  5376. function d3_geo_streamPolygon(coordinates, listener) {
  5377. var i = -1, n = coordinates.length;
  5378. listener.polygonStart();
  5379. while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1);
  5380. listener.polygonEnd();
  5381. }
  5382. function d3_geo_spherical(cartesian) {
  5383. return [ Math.atan2(cartesian[1], cartesian[0]), Math.asin(Math.max(-1, Math.min(1, cartesian[2]))) ];
  5384. }
  5385. function d3_geo_sphericalEqual(a, b) {
  5386. return Math.abs(a[0] - b[0]) < ε && Math.abs(a[1] - b[1]) < ε;
  5387. }
  5388. function d3_geo_cartesian(spherical) {
  5389. var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ);
  5390. return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ];
  5391. }
  5392. function d3_geo_cartesianDot(a, b) {
  5393. return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  5394. }
  5395. function d3_geo_cartesianCross(a, b) {
  5396. 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] ];
  5397. }
  5398. function d3_geo_cartesianAdd(a, b) {
  5399. a[0] += b[0];
  5400. a[1] += b[1];
  5401. a[2] += b[2];
  5402. }
  5403. function d3_geo_cartesianScale(vector, k) {
  5404. return [ vector[0] * k, vector[1] * k, vector[2] * k ];
  5405. }
  5406. function d3_geo_cartesianNormalize(d) {
  5407. var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]);
  5408. d[0] /= l;
  5409. d[1] /= l;
  5410. d[2] /= l;
  5411. }
  5412. function d3_geo_resample(project) {
  5413. var δ2 = .5, maxDepth = 16;
  5414. function resample(stream) {
  5415. var λ0, x0, y0, a0, b0, c0;
  5416. var resample = {
  5417. point: point,
  5418. lineStart: lineStart,
  5419. lineEnd: lineEnd,
  5420. polygonStart: function() {
  5421. stream.polygonStart();
  5422. resample.lineStart = polygonLineStart;
  5423. },
  5424. polygonEnd: function() {
  5425. stream.polygonEnd();
  5426. resample.lineStart = lineStart;
  5427. }
  5428. };
  5429. function point(x, y) {
  5430. x = project(x, y);
  5431. stream.point(x[0], x[1]);
  5432. }
  5433. function lineStart() {
  5434. x0 = NaN;
  5435. resample.point = linePoint;
  5436. stream.lineStart();
  5437. }
  5438. function linePoint(λ, φ) {
  5439. var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ);
  5440. resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream);
  5441. stream.point(x0, y0);
  5442. }
  5443. function lineEnd() {
  5444. resample.point = point;
  5445. stream.lineEnd();
  5446. }
  5447. function polygonLineStart() {
  5448. var λ00, φ00, x00, y00, a00, b00, c00;
  5449. lineStart();
  5450. resample.point = function(λ, φ) {
  5451. linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0;
  5452. resample.point = linePoint;
  5453. };
  5454. resample.lineEnd = function() {
  5455. resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream);
  5456. resample.lineEnd = lineEnd;
  5457. lineEnd();
  5458. };
  5459. }
  5460. return resample;
  5461. }
  5462. function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) {
  5463. var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy;
  5464. if (d2 > 4 * δ2 && depth--) {
  5465. 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;
  5466. if (dz * dz / d2 > δ2 || Math.abs((dx * dx2 + dy * dy2) / d2 - .5) > .3) {
  5467. resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream);
  5468. stream.point(x2, y2);
  5469. resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream);
  5470. }
  5471. }
  5472. }
  5473. resample.precision = function(_) {
  5474. if (!arguments.length) return Math.sqrt(δ2);
  5475. maxDepth = (δ2 = _ * _) > 0 && 16;
  5476. return resample;
  5477. };
  5478. return resample;
  5479. }
  5480. d3.geo.albersUsa = function() {
  5481. var lower48 = d3.geo.albers();
  5482. var alaska = d3.geo.albers().rotate([ 160, 0 ]).center([ 0, 60 ]).parallels([ 55, 65 ]);
  5483. var hawaii = d3.geo.albers().rotate([ 160, 0 ]).center([ 0, 20 ]).parallels([ 8, 18 ]);
  5484. var puertoRico = d3.geo.albers().rotate([ 60, 0 ]).center([ 0, 10 ]).parallels([ 8, 18 ]);
  5485. function albersUsa(coordinates) {
  5486. return projection(coordinates)(coordinates);
  5487. }
  5488. function projection(point) {
  5489. var lon = point[0], lat = point[1];
  5490. return lat > 50 ? alaska : lon < -140 ? hawaii : lat < 21 ? puertoRico : lower48;
  5491. }
  5492. albersUsa.scale = function(x) {
  5493. if (!arguments.length) return lower48.scale();
  5494. lower48.scale(x);
  5495. alaska.scale(x * .6);
  5496. hawaii.scale(x);
  5497. puertoRico.scale(x * 1.5);
  5498. return albersUsa.translate(lower48.translate());
  5499. };
  5500. albersUsa.translate = function(x) {
  5501. if (!arguments.length) return lower48.translate();
  5502. var dz = lower48.scale(), dx = x[0], dy = x[1];
  5503. lower48.translate(x);
  5504. alaska.translate([ dx - .4 * dz, dy + .17 * dz ]);
  5505. hawaii.translate([ dx - .19 * dz, dy + .2 * dz ]);
  5506. puertoRico.translate([ dx + .58 * dz, dy + .43 * dz ]);
  5507. return albersUsa;
  5508. };
  5509. return albersUsa.scale(lower48.scale());
  5510. };
  5511. function d3_geo_albers(φ0, φ1) {
  5512. 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;
  5513. function albers(λ, φ) {
  5514. var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n;
  5515. return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ];
  5516. }
  5517. albers.invert = function(x, y) {
  5518. var ρ0_y = ρ0 - y;
  5519. return [ Math.atan2(x, ρ0_y) / n, Math.asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ];
  5520. };
  5521. return albers;
  5522. }
  5523. (d3.geo.albers = function() {
  5524. var φ0 = 29.5 * d3_radians, φ1 = 45.5 * d3_radians, m = d3_geo_projectionMutator(d3_geo_albers), p = m(φ0, φ1);
  5525. p.parallels = function(_) {
  5526. if (!arguments.length) return [ φ0 * d3_degrees, φ1 * d3_degrees ];
  5527. return m(φ0 = _[0] * d3_radians, φ1 = _[1] * d3_radians);
  5528. };
  5529. return p.rotate([ 98, 0 ]).center([ 0, 38 ]).scale(1e3);
  5530. }).raw = d3_geo_albers;
  5531. var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) {
  5532. return Math.sqrt(2 / (1 + cosλcosφ));
  5533. }, function(ρ) {
  5534. return 2 * Math.asin(ρ / 2);
  5535. });
  5536. (d3.geo.azimuthalEqualArea = function() {
  5537. return d3_geo_projection(d3_geo_azimuthalEqualArea);
  5538. }).raw = d3_geo_azimuthalEqualArea;
  5539. var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) {
  5540. var c = Math.acos(cosλcosφ);
  5541. return c && c / Math.sin(c);
  5542. }, d3_identity);
  5543. (d3.geo.azimuthalEquidistant = function() {
  5544. return d3_geo_projection(d3_geo_azimuthalEquidistant);
  5545. }).raw = d3_geo_azimuthalEquidistant;
  5546. d3.geo.bounds = d3_geo_bounds(d3_identity);
  5547. function d3_geo_bounds(projectStream) {
  5548. var x0, y0, x1, y1;
  5549. var bound = {
  5550. point: boundPoint,
  5551. lineStart: d3_noop,
  5552. lineEnd: d3_noop,
  5553. polygonStart: function() {
  5554. bound.lineEnd = boundPolygonLineEnd;
  5555. },
  5556. polygonEnd: function() {
  5557. bound.point = boundPoint;
  5558. }
  5559. };
  5560. function boundPoint(x, y) {
  5561. if (x < x0) x0 = x;
  5562. if (x > x1) x1 = x;
  5563. if (y < y0) y0 = y;
  5564. if (y > y1) y1 = y;
  5565. }
  5566. function boundPolygonLineEnd() {
  5567. bound.point = bound.lineEnd = d3_noop;
  5568. }
  5569. return function(feature) {
  5570. y1 = x1 = -(x0 = y0 = Infinity);
  5571. d3.geo.stream(feature, projectStream(bound));
  5572. return [ [ x0, y0 ], [ x1, y1 ] ];
  5573. };
  5574. }
  5575. d3.geo.centroid = function(object) {
  5576. d3_geo_centroidDimension = d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
  5577. d3.geo.stream(object, d3_geo_centroid);
  5578. var m;
  5579. if (d3_geo_centroidW && Math.abs(m = Math.sqrt(d3_geo_centroidX * d3_geo_centroidX + d3_geo_centroidY * d3_geo_centroidY + d3_geo_centroidZ * d3_geo_centroidZ)) > ε) {
  5580. return [ Math.atan2(d3_geo_centroidY, d3_geo_centroidX) * d3_degrees, Math.asin(Math.max(-1, Math.min(1, d3_geo_centroidZ / m))) * d3_degrees ];
  5581. }
  5582. };
  5583. var d3_geo_centroidDimension, d3_geo_centroidW, d3_geo_centroidX, d3_geo_centroidY, d3_geo_centroidZ;
  5584. var d3_geo_centroid = {
  5585. sphere: function() {
  5586. if (d3_geo_centroidDimension < 2) {
  5587. d3_geo_centroidDimension = 2;
  5588. d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
  5589. }
  5590. },
  5591. point: d3_geo_centroidPoint,
  5592. lineStart: d3_geo_centroidLineStart,
  5593. lineEnd: d3_geo_centroidLineEnd,
  5594. polygonStart: function() {
  5595. if (d3_geo_centroidDimension < 2) {
  5596. d3_geo_centroidDimension = 2;
  5597. d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
  5598. }
  5599. d3_geo_centroid.lineStart = d3_geo_centroidRingStart;
  5600. },
  5601. polygonEnd: function() {
  5602. d3_geo_centroid.lineStart = d3_geo_centroidLineStart;
  5603. }
  5604. };
  5605. function d3_geo_centroidPoint(λ, φ) {
  5606. if (d3_geo_centroidDimension) return;
  5607. ++d3_geo_centroidW;
  5608. λ *= d3_radians;
  5609. var cosφ = Math.cos(φ *= d3_radians);
  5610. d3_geo_centroidX += (cosφ * Math.cos(λ) - d3_geo_centroidX) / d3_geo_centroidW;
  5611. d3_geo_centroidY += (cosφ * Math.sin(λ) - d3_geo_centroidY) / d3_geo_centroidW;
  5612. d3_geo_centroidZ += (Math.sin(φ) - d3_geo_centroidZ) / d3_geo_centroidW;
  5613. }
  5614. function d3_geo_centroidRingStart() {
  5615. var λ00, φ00;
  5616. d3_geo_centroidDimension = 1;
  5617. d3_geo_centroidLineStart();
  5618. d3_geo_centroidDimension = 2;
  5619. var linePoint = d3_geo_centroid.point;
  5620. d3_geo_centroid.point = function(λ, φ) {
  5621. linePoint(λ00 = λ, φ00 = φ);
  5622. };
  5623. d3_geo_centroid.lineEnd = function() {
  5624. d3_geo_centroid.point(λ00, φ00);
  5625. d3_geo_centroidLineEnd();
  5626. d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd;
  5627. };
  5628. }
  5629. function d3_geo_centroidLineStart() {
  5630. var x0, y0, z0;
  5631. if (d3_geo_centroidDimension > 1) return;
  5632. if (d3_geo_centroidDimension < 1) {
  5633. d3_geo_centroidDimension = 1;
  5634. d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
  5635. }
  5636. d3_geo_centroid.point = function(λ, φ) {
  5637. λ *= d3_radians;
  5638. var cosφ = Math.cos(φ *= d3_radians);
  5639. x0 = cosφ * Math.cos(λ);
  5640. y0 = cosφ * Math.sin(λ);
  5641. z0 = Math.sin(φ);
  5642. d3_geo_centroid.point = nextPoint;
  5643. };
  5644. function nextPoint(λ, φ) {
  5645. λ *= d3_radians;
  5646. 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);
  5647. d3_geo_centroidW += w;
  5648. d3_geo_centroidX += w * (x0 + (x0 = x));
  5649. d3_geo_centroidY += w * (y0 + (y0 = y));
  5650. d3_geo_centroidZ += w * (z0 + (z0 = z));
  5651. }
  5652. }
  5653. function d3_geo_centroidLineEnd() {
  5654. d3_geo_centroid.point = d3_geo_centroidPoint;
  5655. }
  5656. d3.geo.circle = function() {
  5657. var origin = [ 0, 0 ], angle, precision = 6, interpolate;
  5658. function circle() {
  5659. 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 = [];
  5660. interpolate(null, null, 1, {
  5661. point: function(x, y) {
  5662. ring.push(x = rotate(x, y));
  5663. x[0] *= d3_degrees, x[1] *= d3_degrees;
  5664. }
  5665. });
  5666. return {
  5667. type: "Polygon",
  5668. coordinates: [ ring ]
  5669. };
  5670. }
  5671. circle.origin = function(x) {
  5672. if (!arguments.length) return origin;
  5673. origin = x;
  5674. return circle;
  5675. };
  5676. circle.angle = function(x) {
  5677. if (!arguments.length) return angle;
  5678. interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians);
  5679. return circle;
  5680. };
  5681. circle.precision = function(_) {
  5682. if (!arguments.length) return precision;
  5683. interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians);
  5684. return circle;
  5685. };
  5686. return circle.angle(90);
  5687. };
  5688. function d3_geo_circleInterpolate(radians, precision) {
  5689. var cr = Math.cos(radians), sr = Math.sin(radians);
  5690. return function(from, to, direction, listener) {
  5691. if (from != null) {
  5692. from = d3_geo_circleAngle(cr, from);
  5693. to = d3_geo_circleAngle(cr, to);
  5694. if (direction > 0 ? from < to : from > to) from += direction * 2 * π;
  5695. } else {
  5696. from = radians + direction * 2 * π;
  5697. to = radians;
  5698. }
  5699. var point;
  5700. for (var step = direction * precision, t = from; direction > 0 ? t > to : t < to; t -= step) {
  5701. listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]);
  5702. }
  5703. };
  5704. }
  5705. function d3_geo_circleAngle(cr, point) {
  5706. var a = d3_geo_cartesian(point);
  5707. a[0] -= cr;
  5708. d3_geo_cartesianNormalize(a);
  5709. var angle = Math.acos(Math.max(-1, Math.min(1, -a[1])));
  5710. return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI);
  5711. }
  5712. function d3_geo_clip(pointVisible, clipLine, interpolate) {
  5713. return function(listener) {
  5714. var line = clipLine(listener);
  5715. var clip = {
  5716. point: point,
  5717. lineStart: lineStart,
  5718. lineEnd: lineEnd,
  5719. polygonStart: function() {
  5720. clip.point = pointRing;
  5721. clip.lineStart = ringStart;
  5722. clip.lineEnd = ringEnd;
  5723. invisible = false;
  5724. invisibleArea = visibleArea = 0;
  5725. segments = [];
  5726. listener.polygonStart();
  5727. },
  5728. polygonEnd: function() {
  5729. clip.point = point;
  5730. clip.lineStart = lineStart;
  5731. clip.lineEnd = lineEnd;
  5732. segments = d3.merge(segments);
  5733. if (segments.length) {
  5734. d3_geo_clipPolygon(segments, interpolate, listener);
  5735. } else if (visibleArea < -ε || invisible && invisibleArea < -ε) {
  5736. listener.lineStart();
  5737. interpolate(null, null, 1, listener);
  5738. listener.lineEnd();
  5739. }
  5740. listener.polygonEnd();
  5741. segments = null;
  5742. },
  5743. sphere: function() {
  5744. listener.polygonStart();
  5745. listener.lineStart();
  5746. interpolate(null, null, 1, listener);
  5747. listener.lineEnd();
  5748. listener.polygonEnd();
  5749. }
  5750. };
  5751. function point(λ, φ) {
  5752. if (pointVisible(λ, φ)) listener.point(λ, φ);
  5753. }
  5754. function pointLine(λ, φ) {
  5755. line.point(λ, φ);
  5756. }
  5757. function lineStart() {
  5758. clip.point = pointLine;
  5759. line.lineStart();
  5760. }
  5761. function lineEnd() {
  5762. clip.point = point;
  5763. line.lineEnd();
  5764. }
  5765. var segments, visibleArea, invisibleArea, invisible;
  5766. var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), ring;
  5767. function pointRing(λ, φ) {
  5768. ringListener.point(λ, φ);
  5769. ring.push([ λ, φ ]);
  5770. }
  5771. function ringStart() {
  5772. ringListener.lineStart();
  5773. ring = [];
  5774. }
  5775. function ringEnd() {
  5776. pointRing(ring[0][0], ring[0][1]);
  5777. ringListener.lineEnd();
  5778. var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length;
  5779. if (!n) {
  5780. invisible = true;
  5781. invisibleArea += d3_geo_clipAreaRing(ring, -1);
  5782. ring = null;
  5783. return;
  5784. }
  5785. ring = null;
  5786. if (clean & 1) {
  5787. segment = ringSegments[0];
  5788. visibleArea += d3_geo_clipAreaRing(segment, 1);
  5789. var n = segment.length - 1, i = -1, point;
  5790. listener.lineStart();
  5791. while (++i < n) listener.point((point = segment[i])[0], point[1]);
  5792. listener.lineEnd();
  5793. return;
  5794. }
  5795. if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
  5796. segments.push(ringSegments.filter(d3_geo_clipSegmentLength1));
  5797. }
  5798. return clip;
  5799. };
  5800. }
  5801. function d3_geo_clipPolygon(segments, interpolate, listener) {
  5802. var subject = [], clip = [];
  5803. segments.forEach(function(segment) {
  5804. var n = segment.length;
  5805. if (n <= 1) return;
  5806. var p0 = segment[0], p1 = segment[n - 1], a = {
  5807. point: p0,
  5808. points: segment,
  5809. other: null,
  5810. visited: false,
  5811. entry: true,
  5812. subject: true
  5813. }, b = {
  5814. point: p0,
  5815. points: [ p0 ],
  5816. other: a,
  5817. visited: false,
  5818. entry: false,
  5819. subject: false
  5820. };
  5821. a.other = b;
  5822. subject.push(a);
  5823. clip.push(b);
  5824. a = {
  5825. point: p1,
  5826. points: [ p1 ],
  5827. other: null,
  5828. visited: false,
  5829. entry: false,
  5830. subject: true
  5831. };
  5832. b = {
  5833. point: p1,
  5834. points: [ p1 ],
  5835. other: a,
  5836. visited: false,
  5837. entry: true,
  5838. subject: false
  5839. };
  5840. a.other = b;
  5841. subject.push(a);
  5842. clip.push(b);
  5843. });
  5844. clip.sort(d3_geo_clipSort);
  5845. d3_geo_clipLinkCircular(subject);
  5846. d3_geo_clipLinkCircular(clip);
  5847. if (!subject.length) return;
  5848. var start = subject[0], current, points, point;
  5849. while (1) {
  5850. current = start;
  5851. while (current.visited) if ((current = current.next) === start) return;
  5852. points = current.points;
  5853. listener.lineStart();
  5854. do {
  5855. current.visited = current.other.visited = true;
  5856. if (current.entry) {
  5857. if (current.subject) {
  5858. for (var i = 0; i < points.length; i++) listener.point((point = points[i])[0], point[1]);
  5859. } else {
  5860. interpolate(current.point, current.next.point, 1, listener);
  5861. }
  5862. current = current.next;
  5863. } else {
  5864. if (current.subject) {
  5865. points = current.prev.points;
  5866. for (var i = points.length; --i >= 0; ) listener.point((point = points[i])[0], point[1]);
  5867. } else {
  5868. interpolate(current.point, current.prev.point, -1, listener);
  5869. }
  5870. current = current.prev;
  5871. }
  5872. current = current.other;
  5873. points = current.points;
  5874. } while (!current.visited);
  5875. listener.lineEnd();
  5876. }
  5877. }
  5878. function d3_geo_clipLinkCircular(array) {
  5879. if (!(n = array.length)) return;
  5880. var n, i = 0, a = array[0], b;
  5881. while (++i < n) {
  5882. a.next = b = array[i];
  5883. b.prev = a;
  5884. a = b;
  5885. }
  5886. a.next = b = array[0];
  5887. b.prev = a;
  5888. }
  5889. function d3_geo_clipSort(a, b) {
  5890. return ((a = a.point)[0] < 0 ? a[1] - π / 2 - ε : π / 2 - a[1]) - ((b = b.point)[0] < 0 ? b[1] - π / 2 - ε : π / 2 - b[1]);
  5891. }
  5892. function d3_geo_clipSegmentLength1(segment) {
  5893. return segment.length > 1;
  5894. }
  5895. function d3_geo_clipBufferListener() {
  5896. var lines = [], line;
  5897. return {
  5898. lineStart: function() {
  5899. lines.push(line = []);
  5900. },
  5901. point: function(λ, φ) {
  5902. line.push([ λ, φ ]);
  5903. },
  5904. lineEnd: d3_noop,
  5905. buffer: function() {
  5906. var buffer = lines;
  5907. lines = [];
  5908. line = null;
  5909. return buffer;
  5910. }
  5911. };
  5912. }
  5913. function d3_geo_clipAreaRing(ring, invisible) {
  5914. if (!(n = ring.length)) return 0;
  5915. var n, i = 0, area = 0, p = ring[0], λ = p[0], φ = p[1], cosφ = Math.cos(φ), x0 = Math.atan2(invisible * Math.sin(λ) * cosφ, Math.sin(φ)), y0 = 1 - invisible * Math.cos(λ) * cosφ, x1 = x0, x, y;
  5916. while (++i < n) {
  5917. p = ring[i];
  5918. cosφ = Math.cos(φ = p[1]);
  5919. x = Math.atan2(invisible * Math.sin(λ = p[0]) * cosφ, Math.sin(φ));
  5920. y = 1 - invisible * Math.cos(λ) * cosφ;
  5921. if (Math.abs(y0 - 2) < ε && Math.abs(y - 2) < ε) continue;
  5922. if (Math.abs(y) < ε || Math.abs(y0) < ε) {} else if (Math.abs(Math.abs(x - x0) - π) < ε) {
  5923. if (y + y0 > 2) area += 4 * (x - x0);
  5924. } else if (Math.abs(y0 - 2) < ε) area += 4 * (x - x1); else area += ((3 * π + x - x0) % (2 * π) - π) * (y0 + y);
  5925. x1 = x0, x0 = x, y0 = y;
  5926. }
  5927. return area;
  5928. }
  5929. var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate);
  5930. function d3_geo_clipAntimeridianLine(listener) {
  5931. var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean;
  5932. return {
  5933. lineStart: function() {
  5934. listener.lineStart();
  5935. clean = 1;
  5936. },
  5937. point: function(λ1, φ1) {
  5938. var sλ1 = λ1 > 0 ? π : -π, dλ = Math.abs(λ1 - λ0);
  5939. if (Math.abs(dλ - π) < ε) {
  5940. listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? π / 2 : -π / 2);
  5941. listener.point(sλ0, φ0);
  5942. listener.lineEnd();
  5943. listener.lineStart();
  5944. listener.point(sλ1, φ0);
  5945. listener.point(λ1, φ0);
  5946. clean = 0;
  5947. } else if (sλ0 !== sλ1 && dλ >= π) {
  5948. if (Math.abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε;
  5949. if (Math.abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε;
  5950. φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1);
  5951. listener.point(sλ0, φ0);
  5952. listener.lineEnd();
  5953. listener.lineStart();
  5954. listener.point(sλ1, φ0);
  5955. clean = 0;
  5956. }
  5957. listener.point(λ0 = λ1, φ0 = φ1);
  5958. sλ0 = sλ1;
  5959. },
  5960. lineEnd: function() {
  5961. listener.lineEnd();
  5962. λ0 = φ0 = NaN;
  5963. },
  5964. clean: function() {
  5965. return 2 - clean;
  5966. }
  5967. };
  5968. }
  5969. function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) {
  5970. var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1);
  5971. 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;
  5972. }
  5973. function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) {
  5974. var φ;
  5975. if (from == null) {
  5976. φ = direction * π / 2;
  5977. listener.point(-π, φ);
  5978. listener.point(0, φ);
  5979. listener.point(π, φ);
  5980. listener.point(π, 0);
  5981. listener.point(π, -φ);
  5982. listener.point(0, -φ);
  5983. listener.point(-π, -φ);
  5984. listener.point(-π, 0);
  5985. listener.point(-π, φ);
  5986. } else if (Math.abs(from[0] - to[0]) > ε) {
  5987. var s = (from[0] < to[0] ? 1 : -1) * π;
  5988. φ = direction * s / 2;
  5989. listener.point(-s, φ);
  5990. listener.point(0, φ);
  5991. listener.point(s, φ);
  5992. } else {
  5993. listener.point(to[0], to[1]);
  5994. }
  5995. }
  5996. function d3_geo_clipCircle(degrees) {
  5997. var radians = degrees * d3_radians, cr = Math.cos(radians), interpolate = d3_geo_circleInterpolate(radians, 6 * d3_radians);
  5998. return d3_geo_clip(visible, clipLine, interpolate);
  5999. function visible(λ, φ) {
  6000. return Math.cos(λ) * Math.cos(φ) > cr;
  6001. }
  6002. function clipLine(listener) {
  6003. var point0, v0, v00, clean;
  6004. return {
  6005. lineStart: function() {
  6006. v00 = v0 = false;
  6007. clean = 1;
  6008. },
  6009. point: function(λ, φ) {
  6010. var point1 = [ λ, φ ], point2, v = visible(λ, φ);
  6011. if (!point0 && (v00 = v0 = v)) listener.lineStart();
  6012. if (v !== v0) {
  6013. point2 = intersect(point0, point1);
  6014. if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) {
  6015. point1[0] += ε;
  6016. point1[1] += ε;
  6017. v = visible(point1[0], point1[1]);
  6018. }
  6019. }
  6020. if (v !== v0) {
  6021. clean = 0;
  6022. if (v0 = v) {
  6023. listener.lineStart();
  6024. point2 = intersect(point1, point0);
  6025. listener.point(point2[0], point2[1]);
  6026. } else {
  6027. point2 = intersect(point0, point1);
  6028. listener.point(point2[0], point2[1]);
  6029. listener.lineEnd();
  6030. }
  6031. point0 = point2;
  6032. }
  6033. if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) listener.point(point1[0], point1[1]);
  6034. point0 = point1;
  6035. },
  6036. lineEnd: function() {
  6037. if (v0) listener.lineEnd();
  6038. point0 = null;
  6039. },
  6040. clean: function() {
  6041. return clean | (v00 && v0) << 1;
  6042. }
  6043. };
  6044. }
  6045. function intersect(a, b) {
  6046. var pa = d3_geo_cartesian(a, 0), pb = d3_geo_cartesian(b, 0);
  6047. var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2;
  6048. if (!determinant) return a;
  6049. 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);
  6050. d3_geo_cartesianAdd(A, B);
  6051. var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t = Math.sqrt(w * w - uu * (d3_geo_cartesianDot(A, A) - 1)), q = d3_geo_cartesianScale(u, (-w - t) / uu);
  6052. d3_geo_cartesianAdd(q, A);
  6053. return d3_geo_spherical(q);
  6054. }
  6055. }
  6056. function d3_geo_compose(a, b) {
  6057. function compose(x, y) {
  6058. return x = a(x, y), b(x[0], x[1]);
  6059. }
  6060. if (a.invert && b.invert) compose.invert = function(x, y) {
  6061. return x = b.invert(x, y), x && a.invert(x[0], x[1]);
  6062. };
  6063. return compose;
  6064. }
  6065. function d3_geo_equirectangular(λ, φ) {
  6066. return [ λ, φ ];
  6067. }
  6068. (d3.geo.equirectangular = function() {
  6069. return d3_geo_projection(d3_geo_equirectangular).scale(250 / π);
  6070. }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular;
  6071. var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) {
  6072. return 1 / cosλcosφ;
  6073. }, Math.atan);
  6074. (d3.geo.gnomonic = function() {
  6075. return d3_geo_projection(d3_geo_gnomonic);
  6076. }).raw = d3_geo_gnomonic;
  6077. d3.geo.graticule = function() {
  6078. var x1, x0, y1, y0, dx = 22.5, dy = dx, x, y, precision = 2.5;
  6079. function graticule() {
  6080. return {
  6081. type: "MultiLineString",
  6082. coordinates: lines()
  6083. };
  6084. }
  6085. function lines() {
  6086. return d3.range(Math.ceil(x0 / dx) * dx, x1, dx).map(x).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).map(y));
  6087. }
  6088. graticule.lines = function() {
  6089. return lines().map(function(coordinates) {
  6090. return {
  6091. type: "LineString",
  6092. coordinates: coordinates
  6093. };
  6094. });
  6095. };
  6096. graticule.outline = function() {
  6097. return {
  6098. type: "Polygon",
  6099. coordinates: [ x(x0).concat(y(y1).slice(1), x(x1).reverse().slice(1), y(y0).reverse().slice(1)) ]
  6100. };
  6101. };
  6102. graticule.extent = function(_) {
  6103. if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ];
  6104. x0 = +_[0][0], x1 = +_[1][0];
  6105. y0 = +_[0][1], y1 = +_[1][1];
  6106. if (x0 > x1) _ = x0, x0 = x1, x1 = _;
  6107. if (y0 > y1) _ = y0, y0 = y1, y1 = _;
  6108. return graticule.precision(precision);
  6109. };
  6110. graticule.step = function(_) {
  6111. if (!arguments.length) return [ dx, dy ];
  6112. dx = +_[0], dy = +_[1];
  6113. return graticule;
  6114. };
  6115. graticule.precision = function(_) {
  6116. if (!arguments.length) return precision;
  6117. precision = +_;
  6118. x = d3_geo_graticuleX(y0, y1, precision);
  6119. y = d3_geo_graticuleY(x0, x1, precision);
  6120. return graticule;
  6121. };
  6122. return graticule.extent([ [ -180 + ε, -90 + ε ], [ 180 - ε, 90 - ε ] ]);
  6123. };
  6124. function d3_geo_graticuleX(y0, y1, dy) {
  6125. var y = d3.range(y0, y1 - ε, dy).concat(y1);
  6126. return function(x) {
  6127. return y.map(function(y) {
  6128. return [ x, y ];
  6129. });
  6130. };
  6131. }
  6132. function d3_geo_graticuleY(x0, x1, dx) {
  6133. var x = d3.range(x0, x1 - ε, dx).concat(x1);
  6134. return function(y) {
  6135. return x.map(function(x) {
  6136. return [ x, y ];
  6137. });
  6138. };
  6139. }
  6140. d3.geo.interpolate = function(source, target) {
  6141. return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians);
  6142. };
  6143. function d3_geo_interpolate(x0, y0, x1, y1) {
  6144. 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 = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0)))), k = 1 / Math.sin(d);
  6145. function interpolate(t) {
  6146. 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;
  6147. return [ Math.atan2(y, x) / d3_radians, Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_radians ];
  6148. }
  6149. interpolate.distance = d;
  6150. return interpolate;
  6151. }
  6152. d3.geo.greatArc = function() {
  6153. var source = d3_source, source_, target = d3_target, target_, precision = 6 * d3_radians, interpolate;
  6154. function greatArc() {
  6155. var p0 = source_ || source.apply(this, arguments), p1 = target_ || target.apply(this, arguments), i = interpolate || d3.geo.interpolate(p0, p1), t = 0, dt = precision / i.distance, coordinates = [ p0 ];
  6156. while ((t += dt) < 1) coordinates.push(i(t));
  6157. coordinates.push(p1);
  6158. return {
  6159. type: "LineString",
  6160. coordinates: coordinates
  6161. };
  6162. }
  6163. greatArc.distance = function() {
  6164. return (interpolate || d3.geo.interpolate(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments))).distance;
  6165. };
  6166. greatArc.source = function(_) {
  6167. if (!arguments.length) return source;
  6168. source = _, source_ = typeof _ === "function" ? null : _;
  6169. interpolate = source_ && target_ ? d3.geo.interpolate(source_, target_) : null;
  6170. return greatArc;
  6171. };
  6172. greatArc.target = function(_) {
  6173. if (!arguments.length) return target;
  6174. target = _, target_ = typeof _ === "function" ? null : _;
  6175. interpolate = source_ && target_ ? d3.geo.interpolate(source_, target_) : null;
  6176. return greatArc;
  6177. };
  6178. greatArc.precision = function(_) {
  6179. if (!arguments.length) return precision / d3_radians;
  6180. precision = _ * d3_radians;
  6181. return greatArc;
  6182. };
  6183. return greatArc;
  6184. };
  6185. function d3_geo_mercator(λ, φ) {
  6186. return [ λ / (2 * π), Math.max(-.5, Math.min(+.5, Math.log(Math.tan(π / 4 + φ / 2)) / (2 * π))) ];
  6187. }
  6188. d3_geo_mercator.invert = function(x, y) {
  6189. return [ 2 * π * x, 2 * Math.atan(Math.exp(2 * π * y)) - π / 2 ];
  6190. };
  6191. (d3.geo.mercator = function() {
  6192. return d3_geo_projection(d3_geo_mercator).scale(500);
  6193. }).raw = d3_geo_mercator;
  6194. var d3_geo_orthographic = d3_geo_azimuthal(function() {
  6195. return 1;
  6196. }, Math.asin);
  6197. (d3.geo.orthographic = function() {
  6198. return d3_geo_projection(d3_geo_orthographic);
  6199. }).raw = d3_geo_orthographic;
  6200. d3.geo.path = function() {
  6201. var pointRadius = 4.5, projection, context, projectStream, contextStream;
  6202. function path(object) {
  6203. if (object) d3.geo.stream(object, projectStream(contextStream.pointRadius(typeof pointRadius === "function" ? +pointRadius.apply(this, arguments) : pointRadius)));
  6204. return contextStream.result();
  6205. }
  6206. path.area = function(object) {
  6207. d3_geo_pathAreaSum = 0;
  6208. d3.geo.stream(object, projectStream(d3_geo_pathArea));
  6209. return d3_geo_pathAreaSum;
  6210. };
  6211. path.centroid = function(object) {
  6212. d3_geo_centroidDimension = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
  6213. d3.geo.stream(object, projectStream(d3_geo_pathCentroid));
  6214. return d3_geo_centroidZ ? [ d3_geo_centroidX / d3_geo_centroidZ, d3_geo_centroidY / d3_geo_centroidZ ] : undefined;
  6215. };
  6216. path.bounds = function(object) {
  6217. return d3_geo_bounds(projectStream)(object);
  6218. };
  6219. path.projection = function(_) {
  6220. if (!arguments.length) return projection;
  6221. projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity;
  6222. return path;
  6223. };
  6224. path.context = function(_) {
  6225. if (!arguments.length) return context;
  6226. contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_);
  6227. return path;
  6228. };
  6229. path.pointRadius = function(_) {
  6230. if (!arguments.length) return pointRadius;
  6231. pointRadius = typeof _ === "function" ? _ : +_;
  6232. return path;
  6233. };
  6234. return path.projection(d3.geo.albersUsa()).context(null);
  6235. };
  6236. function d3_geo_pathCircle(radius) {
  6237. return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + +2 * radius + "z";
  6238. }
  6239. function d3_geo_pathProjectStream(project) {
  6240. var resample = d3_geo_resample(function(λ, φ) {
  6241. return project([ λ * d3_degrees, φ * d3_degrees ]);
  6242. });
  6243. return function(stream) {
  6244. stream = resample(stream);
  6245. return {
  6246. point: function(λ, φ) {
  6247. stream.point(λ * d3_radians, φ * d3_radians);
  6248. },
  6249. sphere: function() {
  6250. stream.sphere();
  6251. },
  6252. lineStart: function() {
  6253. stream.lineStart();
  6254. },
  6255. lineEnd: function() {
  6256. stream.lineEnd();
  6257. },
  6258. polygonStart: function() {
  6259. stream.polygonStart();
  6260. },
  6261. polygonEnd: function() {
  6262. stream.polygonEnd();
  6263. }
  6264. };
  6265. };
  6266. }
  6267. function d3_geo_pathBuffer() {
  6268. var pointCircle = d3_geo_pathCircle(4.5), buffer = [];
  6269. var stream = {
  6270. point: point,
  6271. lineStart: function() {
  6272. stream.point = pointLineStart;
  6273. },
  6274. lineEnd: lineEnd,
  6275. polygonStart: function() {
  6276. stream.lineEnd = lineEndPolygon;
  6277. },
  6278. polygonEnd: function() {
  6279. stream.lineEnd = lineEnd;
  6280. stream.point = point;
  6281. },
  6282. pointRadius: function(_) {
  6283. pointCircle = d3_geo_pathCircle(_);
  6284. return stream;
  6285. },
  6286. result: function() {
  6287. if (buffer.length) {
  6288. var result = buffer.join("");
  6289. buffer = [];
  6290. return result;
  6291. }
  6292. }
  6293. };
  6294. function point(x, y) {
  6295. buffer.push("M", x, ",", y, pointCircle);
  6296. }
  6297. function pointLineStart(x, y) {
  6298. buffer.push("M", x, ",", y);
  6299. stream.point = pointLine;
  6300. }
  6301. function pointLine(x, y) {
  6302. buffer.push("L", x, ",", y);
  6303. }
  6304. function lineEnd() {
  6305. stream.point = point;
  6306. }
  6307. function lineEndPolygon() {
  6308. buffer.push("Z");
  6309. }
  6310. return stream;
  6311. }
  6312. function d3_geo_pathContext(context) {
  6313. var pointRadius = 4.5;
  6314. var stream = {
  6315. point: point,
  6316. lineStart: function() {
  6317. stream.point = pointLineStart;
  6318. },
  6319. lineEnd: lineEnd,
  6320. polygonStart: function() {
  6321. stream.lineEnd = lineEndPolygon;
  6322. },
  6323. polygonEnd: function() {
  6324. stream.lineEnd = lineEnd;
  6325. stream.point = point;
  6326. },
  6327. pointRadius: function(_) {
  6328. pointRadius = _;
  6329. return stream;
  6330. },
  6331. result: d3_noop
  6332. };
  6333. function point(x, y) {
  6334. context.moveTo(x, y);
  6335. context.arc(x, y, pointRadius, 0, 2 * π);
  6336. }
  6337. function pointLineStart(x, y) {
  6338. context.moveTo(x, y);
  6339. stream.point = pointLine;
  6340. }
  6341. function pointLine(x, y) {
  6342. context.lineTo(x, y);
  6343. }
  6344. function lineEnd() {
  6345. stream.point = point;
  6346. }
  6347. function lineEndPolygon() {
  6348. context.closePath();
  6349. }
  6350. return stream;
  6351. }
  6352. var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = {
  6353. point: d3_noop,
  6354. lineStart: d3_noop,
  6355. lineEnd: d3_noop,
  6356. polygonStart: function() {
  6357. d3_geo_pathAreaPolygon = 0;
  6358. d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart;
  6359. },
  6360. polygonEnd: function() {
  6361. d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop;
  6362. d3_geo_pathAreaSum += Math.abs(d3_geo_pathAreaPolygon / 2);
  6363. }
  6364. };
  6365. function d3_geo_pathAreaRingStart() {
  6366. var x00, y00, x0, y0;
  6367. d3_geo_pathArea.point = function(x, y) {
  6368. d3_geo_pathArea.point = nextPoint;
  6369. x00 = x0 = x, y00 = y0 = y;
  6370. };
  6371. function nextPoint(x, y) {
  6372. d3_geo_pathAreaPolygon += y0 * x - x0 * y;
  6373. x0 = x, y0 = y;
  6374. }
  6375. d3_geo_pathArea.lineEnd = function() {
  6376. nextPoint(x00, y00);
  6377. };
  6378. }
  6379. var d3_geo_pathCentroid = {
  6380. point: d3_geo_pathCentroidPoint,
  6381. lineStart: d3_geo_pathCentroidLineStart,
  6382. lineEnd: d3_geo_pathCentroidLineEnd,
  6383. polygonStart: function() {
  6384. d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart;
  6385. },
  6386. polygonEnd: function() {
  6387. d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
  6388. d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart;
  6389. d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd;
  6390. }
  6391. };
  6392. function d3_geo_pathCentroidPoint(x, y) {
  6393. if (d3_geo_centroidDimension) return;
  6394. d3_geo_centroidX += x;
  6395. d3_geo_centroidY += y;
  6396. ++d3_geo_centroidZ;
  6397. }
  6398. function d3_geo_pathCentroidLineStart() {
  6399. var x0, y0;
  6400. if (d3_geo_centroidDimension !== 1) {
  6401. if (d3_geo_centroidDimension < 1) {
  6402. d3_geo_centroidDimension = 1;
  6403. d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
  6404. } else return;
  6405. }
  6406. d3_geo_pathCentroid.point = function(x, y) {
  6407. d3_geo_pathCentroid.point = nextPoint;
  6408. x0 = x, y0 = y;
  6409. };
  6410. function nextPoint(x, y) {
  6411. var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy);
  6412. d3_geo_centroidX += z * (x0 + x) / 2;
  6413. d3_geo_centroidY += z * (y0 + y) / 2;
  6414. d3_geo_centroidZ += z;
  6415. x0 = x, y0 = y;
  6416. }
  6417. }
  6418. function d3_geo_pathCentroidLineEnd() {
  6419. d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint;
  6420. }
  6421. function d3_geo_pathCentroidRingStart() {
  6422. var x00, y00, x0, y0;
  6423. if (d3_geo_centroidDimension < 2) {
  6424. d3_geo_centroidDimension = 2;
  6425. d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0;
  6426. }
  6427. d3_geo_pathCentroid.point = function(x, y) {
  6428. d3_geo_pathCentroid.point = nextPoint;
  6429. x00 = x0 = x, y00 = y0 = y;
  6430. };
  6431. function nextPoint(x, y) {
  6432. var z = y0 * x - x0 * y;
  6433. d3_geo_centroidX += z * (x0 + x);
  6434. d3_geo_centroidY += z * (y0 + y);
  6435. d3_geo_centroidZ += z * 3;
  6436. x0 = x, y0 = y;
  6437. }
  6438. d3_geo_pathCentroid.lineEnd = function() {
  6439. nextPoint(x00, y00);
  6440. };
  6441. }
  6442. d3.geo.area = function(object) {
  6443. d3_geo_areaSum = 0;
  6444. d3.geo.stream(object, d3_geo_area);
  6445. return d3_geo_areaSum;
  6446. };
  6447. var d3_geo_areaSum, d3_geo_areaRing;
  6448. var d3_geo_area = {
  6449. sphere: function() {
  6450. d3_geo_areaSum += 4 * π;
  6451. },
  6452. point: d3_noop,
  6453. lineStart: d3_noop,
  6454. lineEnd: d3_noop,
  6455. polygonStart: function() {
  6456. d3_geo_areaRing = 0;
  6457. d3_geo_area.lineStart = d3_geo_areaRingStart;
  6458. },
  6459. polygonEnd: function() {
  6460. d3_geo_areaSum += d3_geo_areaRing < 0 ? 4 * π + d3_geo_areaRing : d3_geo_areaRing;
  6461. d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop;
  6462. }
  6463. };
  6464. function d3_geo_areaRingStart() {
  6465. var λ00, φ00, λ1, λ0, φ0, cosφ0, sinφ0;
  6466. d3_geo_area.point = function(λ, φ) {
  6467. d3_geo_area.point = nextPoint;
  6468. λ1 = λ0 = (λ00 = λ) * d3_radians, φ0 = (φ00 = φ) * d3_radians, cosφ0 = Math.cos(φ0),
  6469. sinφ0 = Math.sin(φ0);
  6470. };
  6471. function nextPoint(λ, φ) {
  6472. λ *= d3_radians, φ *= d3_radians;
  6473. if (Math.abs(Math.abs(φ0) - π / 2) < ε && Math.abs(Math.abs(φ) - π / 2) < ε) return;
  6474. var cosφ = Math.cos(φ), sinφ = Math.sin(φ);
  6475. if (Math.abs(φ0 - π / 2) < ε) d3_geo_areaRing += (λ - λ1) * 2; else {
  6476. var dλ = λ - λ0, cosdλ = Math.cos(dλ), d = Math.atan2(Math.sqrt((d = cosφ * Math.sin(dλ)) * d + (d = cosφ0 * sinφ - sinφ0 * cosφ * cosdλ) * d), sinφ0 * sinφ + cosφ0 * cosφ * cosdλ), s = (d + π + φ0 + φ) / 4;
  6477. d3_geo_areaRing += (dλ < 0 && dλ > -π || dλ > π ? -4 : 4) * Math.atan(Math.sqrt(Math.abs(Math.tan(s) * Math.tan(s - d / 2) * Math.tan(s - π / 4 - φ0 / 2) * Math.tan(s - π / 4 - φ / 2))));
  6478. }
  6479. λ1 = λ0, λ0 = λ, φ0 = φ, cosφ0 = cosφ, sinφ0 = sinφ;
  6480. }
  6481. d3_geo_area.lineEnd = function() {
  6482. nextPoint(λ00, φ00);
  6483. };
  6484. }
  6485. d3.geo.projection = d3_geo_projection;
  6486. d3.geo.projectionMutator = d3_geo_projectionMutator;
  6487. function d3_geo_projection(project) {
  6488. return d3_geo_projectionMutator(function() {
  6489. return project;
  6490. })();
  6491. }
  6492. function d3_geo_projectionMutator(projectAt) {
  6493. var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) {
  6494. x = project(x, y);
  6495. return [ x[0] * k + δx, δy - x[1] * k ];
  6496. }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, clip = d3_geo_clipAntimeridian, clipAngle = null;
  6497. function projection(point) {
  6498. point = projectRotate(point[0] * d3_radians, point[1] * d3_radians);
  6499. return [ point[0] * k + δx, δy - point[1] * k ];
  6500. }
  6501. function invert(point) {
  6502. point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k);
  6503. return point && [ point[0] * d3_degrees, point[1] * d3_degrees ];
  6504. }
  6505. projection.stream = function(stream) {
  6506. return d3_geo_projectionRadiansRotate(rotate, clip(projectResample(stream)));
  6507. };
  6508. projection.clipAngle = function(_) {
  6509. if (!arguments.length) return clipAngle;
  6510. clip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle(clipAngle = +_);
  6511. return projection;
  6512. };
  6513. projection.scale = function(_) {
  6514. if (!arguments.length) return k;
  6515. k = +_;
  6516. return reset();
  6517. };
  6518. projection.translate = function(_) {
  6519. if (!arguments.length) return [ x, y ];
  6520. x = +_[0];
  6521. y = +_[1];
  6522. return reset();
  6523. };
  6524. projection.center = function(_) {
  6525. if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ];
  6526. λ = _[0] % 360 * d3_radians;
  6527. φ = _[1] % 360 * d3_radians;
  6528. return reset();
  6529. };
  6530. projection.rotate = function(_) {
  6531. if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ];
  6532. δλ = _[0] % 360 * d3_radians;
  6533. δφ = _[1] % 360 * d3_radians;
  6534. δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0;
  6535. return reset();
  6536. };
  6537. d3.rebind(projection, projectResample, "precision");
  6538. function reset() {
  6539. projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project);
  6540. var center = project(λ, φ);
  6541. δx = x - center[0] * k;
  6542. δy = y + center[1] * k;
  6543. return projection;
  6544. }
  6545. return function() {
  6546. project = projectAt.apply(this, arguments);
  6547. projection.invert = project.invert && invert;
  6548. return reset();
  6549. };
  6550. }
  6551. function d3_geo_projectionRadiansRotate(rotate, stream) {
  6552. return {
  6553. point: function(x, y) {
  6554. y = rotate(x * d3_radians, y * d3_radians), x = y[0];
  6555. stream.point(x > π ? x - 2 * π : x < -π ? x + 2 * π : x, y[1]);
  6556. },
  6557. sphere: function() {
  6558. stream.sphere();
  6559. },
  6560. lineStart: function() {
  6561. stream.lineStart();
  6562. },
  6563. lineEnd: function() {
  6564. stream.lineEnd();
  6565. },
  6566. polygonStart: function() {
  6567. stream.polygonStart();
  6568. },
  6569. polygonEnd: function() {
  6570. stream.polygonEnd();
  6571. }
  6572. };
  6573. }
  6574. function d3_geo_rotation(δλ, δφ, δγ) {
  6575. return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_equirectangular;
  6576. }
  6577. function d3_geo_forwardRotationλ(δλ) {
  6578. return function(λ, φ) {
  6579. return λ += δλ, [ λ > π ? λ - 2 * π : λ < -π ? λ + 2 * π : λ, φ ];
  6580. };
  6581. }
  6582. function d3_geo_rotationλ(δλ) {
  6583. var rotation = d3_geo_forwardRotationλ(δλ);
  6584. rotation.invert = d3_geo_forwardRotationλ(-δλ);
  6585. return rotation;
  6586. }
  6587. function d3_geo_rotationφγ(δφ, δγ) {
  6588. var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ);
  6589. function rotation(λ, φ) {
  6590. var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ;
  6591. return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), Math.asin(Math.max(-1, Math.min(1, k * cosδγ + y * sinδγ))) ];
  6592. }
  6593. rotation.invert = function(λ, φ) {
  6594. var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ;
  6595. return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), Math.asin(Math.max(-1, Math.min(1, k * cosδφ - x * sinδφ))) ];
  6596. };
  6597. return rotation;
  6598. }
  6599. var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) {
  6600. return 1 / (1 + cosλcosφ);
  6601. }, function(ρ) {
  6602. return 2 * Math.atan(ρ);
  6603. });
  6604. (d3.geo.stereographic = function() {
  6605. return d3_geo_projection(d3_geo_stereographic);
  6606. }).raw = d3_geo_stereographic;
  6607. function d3_geo_azimuthal(scale, angle) {
  6608. function azimuthal(λ, φ) {
  6609. var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ);
  6610. return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ];
  6611. }
  6612. azimuthal.invert = function(x, y) {
  6613. var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c);
  6614. return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ];
  6615. };
  6616. return azimuthal;
  6617. }
  6618. d3.geom = {};
  6619. d3.geom.hull = function(vertices) {
  6620. if (vertices.length < 3) return [];
  6621. var len = vertices.length, plen = len - 1, points = [], stack = [], i, j, h = 0, x1, y1, x2, y2, u, v, a, sp;
  6622. for (i = 1; i < len; ++i) {
  6623. if (vertices[i][1] < vertices[h][1]) {
  6624. h = i;
  6625. } else if (vertices[i][1] == vertices[h][1]) {
  6626. h = vertices[i][0] < vertices[h][0] ? i : h;
  6627. }
  6628. }
  6629. for (i = 0; i < len; ++i) {
  6630. if (i === h) continue;
  6631. y1 = vertices[i][1] - vertices[h][1];
  6632. x1 = vertices[i][0] - vertices[h][0];
  6633. points.push({
  6634. angle: Math.atan2(y1, x1),
  6635. index: i
  6636. });
  6637. }
  6638. points.sort(function(a, b) {
  6639. return a.angle - b.angle;
  6640. });
  6641. a = points[0].angle;
  6642. v = points[0].index;
  6643. u = 0;
  6644. for (i = 1; i < plen; ++i) {
  6645. j = points[i].index;
  6646. if (a == points[i].angle) {
  6647. x1 = vertices[v][0] - vertices[h][0];
  6648. y1 = vertices[v][1] - vertices[h][1];
  6649. x2 = vertices[j][0] - vertices[h][0];
  6650. y2 = vertices[j][1] - vertices[h][1];
  6651. if (x1 * x1 + y1 * y1 >= x2 * x2 + y2 * y2) {
  6652. points[i].index = -1;
  6653. } else {
  6654. points[u].index = -1;
  6655. a = points[i].angle;
  6656. u = i;
  6657. v = j;
  6658. }
  6659. } else {
  6660. a = points[i].angle;
  6661. u = i;
  6662. v = j;
  6663. }
  6664. }
  6665. stack.push(h);
  6666. for (i = 0, j = 0; i < 2; ++j) {
  6667. if (points[j].index !== -1) {
  6668. stack.push(points[j].index);
  6669. i++;
  6670. }
  6671. }
  6672. sp = stack.length;
  6673. for (;j < plen; ++j) {
  6674. if (points[j].index === -1) continue;
  6675. while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) {
  6676. --sp;
  6677. }
  6678. stack[sp++] = points[j].index;
  6679. }
  6680. var poly = [];
  6681. for (i = 0; i < sp; ++i) {
  6682. poly.push(vertices[stack[i]]);
  6683. }
  6684. return poly;
  6685. };
  6686. function d3_geom_hullCCW(i1, i2, i3, v) {
  6687. var t, a, b, c, d, e, f;
  6688. t = v[i1];
  6689. a = t[0];
  6690. b = t[1];
  6691. t = v[i2];
  6692. c = t[0];
  6693. d = t[1];
  6694. t = v[i3];
  6695. e = t[0];
  6696. f = t[1];
  6697. return (f - b) * (c - a) - (d - b) * (e - a) > 0;
  6698. }
  6699. d3.geom.polygon = function(coordinates) {
  6700. coordinates.area = function() {
  6701. var i = 0, n = coordinates.length, area = coordinates[n - 1][1] * coordinates[0][0] - coordinates[n - 1][0] * coordinates[0][1];
  6702. while (++i < n) {
  6703. area += coordinates[i - 1][1] * coordinates[i][0] - coordinates[i - 1][0] * coordinates[i][1];
  6704. }
  6705. return area * .5;
  6706. };
  6707. coordinates.centroid = function(k) {
  6708. var i = -1, n = coordinates.length, x = 0, y = 0, a, b = coordinates[n - 1], c;
  6709. if (!arguments.length) k = -1 / (6 * coordinates.area());
  6710. while (++i < n) {
  6711. a = b;
  6712. b = coordinates[i];
  6713. c = a[0] * b[1] - b[0] * a[1];
  6714. x += (a[0] + b[0]) * c;
  6715. y += (a[1] + b[1]) * c;
  6716. }
  6717. return [ x * k, y * k ];
  6718. };
  6719. coordinates.clip = function(subject) {
  6720. var input, i = -1, n = coordinates.length, j, m, a = coordinates[n - 1], b, c, d;
  6721. while (++i < n) {
  6722. input = subject.slice();
  6723. subject.length = 0;
  6724. b = coordinates[i];
  6725. c = input[(m = input.length) - 1];
  6726. j = -1;
  6727. while (++j < m) {
  6728. d = input[j];
  6729. if (d3_geom_polygonInside(d, a, b)) {
  6730. if (!d3_geom_polygonInside(c, a, b)) {
  6731. subject.push(d3_geom_polygonIntersect(c, d, a, b));
  6732. }
  6733. subject.push(d);
  6734. } else if (d3_geom_polygonInside(c, a, b)) {
  6735. subject.push(d3_geom_polygonIntersect(c, d, a, b));
  6736. }
  6737. c = d;
  6738. }
  6739. a = b;
  6740. }
  6741. return subject;
  6742. };
  6743. return coordinates;
  6744. };
  6745. function d3_geom_polygonInside(p, a, b) {
  6746. return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);
  6747. }
  6748. function d3_geom_polygonIntersect(c, d, a, b) {
  6749. 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);
  6750. return [ x1 + ua * x21, y1 + ua * y21 ];
  6751. }
  6752. d3.geom.voronoi = function(vertices) {
  6753. var polygons = vertices.map(function() {
  6754. return [];
  6755. }), Z = 1e6;
  6756. d3_voronoi_tessellate(vertices, function(e) {
  6757. var s1, s2, x1, x2, y1, y2;
  6758. if (e.a === 1 && e.b >= 0) {
  6759. s1 = e.ep.r;
  6760. s2 = e.ep.l;
  6761. } else {
  6762. s1 = e.ep.l;
  6763. s2 = e.ep.r;
  6764. }
  6765. if (e.a === 1) {
  6766. y1 = s1 ? s1.y : -Z;
  6767. x1 = e.c - e.b * y1;
  6768. y2 = s2 ? s2.y : Z;
  6769. x2 = e.c - e.b * y2;
  6770. } else {
  6771. x1 = s1 ? s1.x : -Z;
  6772. y1 = e.c - e.a * x1;
  6773. x2 = s2 ? s2.x : Z;
  6774. y2 = e.c - e.a * x2;
  6775. }
  6776. var v1 = [ x1, y1 ], v2 = [ x2, y2 ];
  6777. polygons[e.region.l.index].push(v1, v2);
  6778. polygons[e.region.r.index].push(v1, v2);
  6779. });
  6780. polygons = polygons.map(function(polygon, i) {
  6781. var cx = vertices[i][0], cy = vertices[i][1], angle = polygon.map(function(v) {
  6782. return Math.atan2(v[0] - cx, v[1] - cy);
  6783. });
  6784. return d3.range(polygon.length).sort(function(a, b) {
  6785. return angle[a] - angle[b];
  6786. }).filter(function(d, i, order) {
  6787. return !i || angle[d] - angle[order[i - 1]] > ε;
  6788. }).map(function(d) {
  6789. return polygon[d];
  6790. });
  6791. });
  6792. polygons.forEach(function(polygon, i) {
  6793. var n = polygon.length;
  6794. if (!n) return polygon.push([ -Z, -Z ], [ -Z, Z ], [ Z, Z ], [ Z, -Z ]);
  6795. if (n > 2) return;
  6796. var p0 = vertices[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;
  6797. if (Math.abs(dy) < ε) {
  6798. var y = y0 < y1 ? -Z : Z;
  6799. polygon.push([ -Z, y ], [ Z, y ]);
  6800. } else if (dx < ε) {
  6801. var x = x0 < x1 ? -Z : Z;
  6802. polygon.push([ x, -Z ], [ x, Z ]);
  6803. } else {
  6804. var y = (x2 - x1) * (y1 - y0) < (x1 - x0) * (y2 - y1) ? Z : -Z, z = Math.abs(dy) - dx;
  6805. if (Math.abs(z) < ε) {
  6806. polygon.push([ dy < 0 ? y : -y, y ]);
  6807. } else {
  6808. if (z > 0) y *= -1;
  6809. polygon.push([ -Z, y ], [ Z, y ]);
  6810. }
  6811. }
  6812. });
  6813. return polygons;
  6814. };
  6815. var d3_voronoi_opposite = {
  6816. l: "r",
  6817. r: "l"
  6818. };
  6819. function d3_voronoi_tessellate(vertices, callback) {
  6820. var Sites = {
  6821. list: vertices.map(function(v, i) {
  6822. return {
  6823. index: i,
  6824. x: v[0],
  6825. y: v[1]
  6826. };
  6827. }).sort(function(a, b) {
  6828. return a.y < b.y ? -1 : a.y > b.y ? 1 : a.x < b.x ? -1 : a.x > b.x ? 1 : 0;
  6829. }),
  6830. bottomSite: null
  6831. };
  6832. var EdgeList = {
  6833. list: [],
  6834. leftEnd: null,
  6835. rightEnd: null,
  6836. init: function() {
  6837. EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l");
  6838. EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l");
  6839. EdgeList.leftEnd.r = EdgeList.rightEnd;
  6840. EdgeList.rightEnd.l = EdgeList.leftEnd;
  6841. EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd);
  6842. },
  6843. createHalfEdge: function(edge, side) {
  6844. return {
  6845. edge: edge,
  6846. side: side,
  6847. vertex: null,
  6848. l: null,
  6849. r: null
  6850. };
  6851. },
  6852. insert: function(lb, he) {
  6853. he.l = lb;
  6854. he.r = lb.r;
  6855. lb.r.l = he;
  6856. lb.r = he;
  6857. },
  6858. leftBound: function(p) {
  6859. var he = EdgeList.leftEnd;
  6860. do {
  6861. he = he.r;
  6862. } while (he != EdgeList.rightEnd && Geom.rightOf(he, p));
  6863. he = he.l;
  6864. return he;
  6865. },
  6866. del: function(he) {
  6867. he.l.r = he.r;
  6868. he.r.l = he.l;
  6869. he.edge = null;
  6870. },
  6871. right: function(he) {
  6872. return he.r;
  6873. },
  6874. left: function(he) {
  6875. return he.l;
  6876. },
  6877. leftRegion: function(he) {
  6878. return he.edge == null ? Sites.bottomSite : he.edge.region[he.side];
  6879. },
  6880. rightRegion: function(he) {
  6881. return he.edge == null ? Sites.bottomSite : he.edge.region[d3_voronoi_opposite[he.side]];
  6882. }
  6883. };
  6884. var Geom = {
  6885. bisect: function(s1, s2) {
  6886. var newEdge = {
  6887. region: {
  6888. l: s1,
  6889. r: s2
  6890. },
  6891. ep: {
  6892. l: null,
  6893. r: null
  6894. }
  6895. };
  6896. var dx = s2.x - s1.x, dy = s2.y - s1.y, adx = dx > 0 ? dx : -dx, ady = dy > 0 ? dy : -dy;
  6897. newEdge.c = s1.x * dx + s1.y * dy + (dx * dx + dy * dy) * .5;
  6898. if (adx > ady) {
  6899. newEdge.a = 1;
  6900. newEdge.b = dy / dx;
  6901. newEdge.c /= dx;
  6902. } else {
  6903. newEdge.b = 1;
  6904. newEdge.a = dx / dy;
  6905. newEdge.c /= dy;
  6906. }
  6907. return newEdge;
  6908. },
  6909. intersect: function(el1, el2) {
  6910. var e1 = el1.edge, e2 = el2.edge;
  6911. if (!e1 || !e2 || e1.region.r == e2.region.r) {
  6912. return null;
  6913. }
  6914. var d = e1.a * e2.b - e1.b * e2.a;
  6915. if (Math.abs(d) < 1e-10) {
  6916. return null;
  6917. }
  6918. 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;
  6919. if (e1r.y < e2r.y || e1r.y == e2r.y && e1r.x < e2r.x) {
  6920. el = el1;
  6921. e = e1;
  6922. } else {
  6923. el = el2;
  6924. e = e2;
  6925. }
  6926. var rightOfSite = xint >= e.region.r.x;
  6927. if (rightOfSite && el.side === "l" || !rightOfSite && el.side === "r") {
  6928. return null;
  6929. }
  6930. return {
  6931. x: xint,
  6932. y: yint
  6933. };
  6934. },
  6935. rightOf: function(he, p) {
  6936. var e = he.edge, topsite = e.region.r, rightOfSite = p.x > topsite.x;
  6937. if (rightOfSite && he.side === "l") {
  6938. return 1;
  6939. }
  6940. if (!rightOfSite && he.side === "r") {
  6941. return 0;
  6942. }
  6943. if (e.a === 1) {
  6944. var dyp = p.y - topsite.y, dxp = p.x - topsite.x, fast = 0, above = 0;
  6945. if (!rightOfSite && e.b < 0 || rightOfSite && e.b >= 0) {
  6946. above = fast = dyp >= e.b * dxp;
  6947. } else {
  6948. above = p.x + p.y * e.b > e.c;
  6949. if (e.b < 0) {
  6950. above = !above;
  6951. }
  6952. if (!above) {
  6953. fast = 1;
  6954. }
  6955. }
  6956. if (!fast) {
  6957. var dxs = topsite.x - e.region.l.x;
  6958. above = e.b * (dxp * dxp - dyp * dyp) < dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b);
  6959. if (e.b < 0) {
  6960. above = !above;
  6961. }
  6962. }
  6963. } else {
  6964. var yl = e.c - e.a * p.x, t1 = p.y - yl, t2 = p.x - topsite.x, t3 = yl - topsite.y;
  6965. above = t1 * t1 > t2 * t2 + t3 * t3;
  6966. }
  6967. return he.side === "l" ? above : !above;
  6968. },
  6969. endPoint: function(edge, side, site) {
  6970. edge.ep[side] = site;
  6971. if (!edge.ep[d3_voronoi_opposite[side]]) return;
  6972. callback(edge);
  6973. },
  6974. distance: function(s, t) {
  6975. var dx = s.x - t.x, dy = s.y - t.y;
  6976. return Math.sqrt(dx * dx + dy * dy);
  6977. }
  6978. };
  6979. var EventQueue = {
  6980. list: [],
  6981. insert: function(he, site, offset) {
  6982. he.vertex = site;
  6983. he.ystar = site.y + offset;
  6984. for (var i = 0, list = EventQueue.list, l = list.length; i < l; i++) {
  6985. var next = list[i];
  6986. if (he.ystar > next.ystar || he.ystar == next.ystar && site.x > next.vertex.x) {
  6987. continue;
  6988. } else {
  6989. break;
  6990. }
  6991. }
  6992. list.splice(i, 0, he);
  6993. },
  6994. del: function(he) {
  6995. for (var i = 0, ls = EventQueue.list, l = ls.length; i < l && ls[i] != he; ++i) {}
  6996. ls.splice(i, 1);
  6997. },
  6998. empty: function() {
  6999. return EventQueue.list.length === 0;
  7000. },
  7001. nextEvent: function(he) {
  7002. for (var i = 0, ls = EventQueue.list, l = ls.length; i < l; ++i) {
  7003. if (ls[i] == he) return ls[i + 1];
  7004. }
  7005. return null;
  7006. },
  7007. min: function() {
  7008. var elem = EventQueue.list[0];
  7009. return {
  7010. x: elem.vertex.x,
  7011. y: elem.ystar
  7012. };
  7013. },
  7014. extractMin: function() {
  7015. return EventQueue.list.shift();
  7016. }
  7017. };
  7018. EdgeList.init();
  7019. Sites.bottomSite = Sites.list.shift();
  7020. var newSite = Sites.list.shift(), newIntStar;
  7021. var lbnd, rbnd, llbnd, rrbnd, bisector;
  7022. var bot, top, temp, p, v;
  7023. var e, pm;
  7024. while (true) {
  7025. if (!EventQueue.empty()) {
  7026. newIntStar = EventQueue.min();
  7027. }
  7028. if (newSite && (EventQueue.empty() || newSite.y < newIntStar.y || newSite.y == newIntStar.y && newSite.x < newIntStar.x)) {
  7029. lbnd = EdgeList.leftBound(newSite);
  7030. rbnd = EdgeList.right(lbnd);
  7031. bot = EdgeList.rightRegion(lbnd);
  7032. e = Geom.bisect(bot, newSite);
  7033. bisector = EdgeList.createHalfEdge(e, "l");
  7034. EdgeList.insert(lbnd, bisector);
  7035. p = Geom.intersect(lbnd, bisector);
  7036. if (p) {
  7037. EventQueue.del(lbnd);
  7038. EventQueue.insert(lbnd, p, Geom.distance(p, newSite));
  7039. }
  7040. lbnd = bisector;
  7041. bisector = EdgeList.createHalfEdge(e, "r");
  7042. EdgeList.insert(lbnd, bisector);
  7043. p = Geom.intersect(bisector, rbnd);
  7044. if (p) {
  7045. EventQueue.insert(bisector, p, Geom.distance(p, newSite));
  7046. }
  7047. newSite = Sites.list.shift();
  7048. } else if (!EventQueue.empty()) {
  7049. lbnd = EventQueue.extractMin();
  7050. llbnd = EdgeList.left(lbnd);
  7051. rbnd = EdgeList.right(lbnd);
  7052. rrbnd = EdgeList.right(rbnd);
  7053. bot = EdgeList.leftRegion(lbnd);
  7054. top = EdgeList.rightRegion(rbnd);
  7055. v = lbnd.vertex;
  7056. Geom.endPoint(lbnd.edge, lbnd.side, v);
  7057. Geom.endPoint(rbnd.edge, rbnd.side, v);
  7058. EdgeList.del(lbnd);
  7059. EventQueue.del(rbnd);
  7060. EdgeList.del(rbnd);
  7061. pm = "l";
  7062. if (bot.y > top.y) {
  7063. temp = bot;
  7064. bot = top;
  7065. top = temp;
  7066. pm = "r";
  7067. }
  7068. e = Geom.bisect(bot, top);
  7069. bisector = EdgeList.createHalfEdge(e, pm);
  7070. EdgeList.insert(llbnd, bisector);
  7071. Geom.endPoint(e, d3_voronoi_opposite[pm], v);
  7072. p = Geom.intersect(llbnd, bisector);
  7073. if (p) {
  7074. EventQueue.del(llbnd);
  7075. EventQueue.insert(llbnd, p, Geom.distance(p, bot));
  7076. }
  7077. p = Geom.intersect(bisector, rrbnd);
  7078. if (p) {
  7079. EventQueue.insert(bisector, p, Geom.distance(p, bot));
  7080. }
  7081. } else {
  7082. break;
  7083. }
  7084. }
  7085. for (lbnd = EdgeList.right(EdgeList.leftEnd); lbnd != EdgeList.rightEnd; lbnd = EdgeList.right(lbnd)) {
  7086. callback(lbnd.edge);
  7087. }
  7088. }
  7089. d3.geom.delaunay = function(vertices) {
  7090. var edges = vertices.map(function() {
  7091. return [];
  7092. }), triangles = [];
  7093. d3_voronoi_tessellate(vertices, function(e) {
  7094. edges[e.region.l.index].push(vertices[e.region.r.index]);
  7095. });
  7096. edges.forEach(function(edge, i) {
  7097. var v = vertices[i], cx = v[0], cy = v[1];
  7098. edge.forEach(function(v) {
  7099. v.angle = Math.atan2(v[0] - cx, v[1] - cy);
  7100. });
  7101. edge.sort(function(a, b) {
  7102. return a.angle - b.angle;
  7103. });
  7104. for (var j = 0, m = edge.length - 1; j < m; j++) {
  7105. triangles.push([ v, edge[j], edge[j + 1] ]);
  7106. }
  7107. });
  7108. return triangles;
  7109. };
  7110. d3.geom.quadtree = function(points, x1, y1, x2, y2) {
  7111. var p, i = -1, n = points.length;
  7112. if (arguments.length < 5) {
  7113. if (arguments.length === 3) {
  7114. y2 = y1;
  7115. x2 = x1;
  7116. y1 = x1 = 0;
  7117. } else {
  7118. x1 = y1 = Infinity;
  7119. x2 = y2 = -Infinity;
  7120. while (++i < n) {
  7121. p = points[i];
  7122. if (p.x < x1) x1 = p.x;
  7123. if (p.y < y1) y1 = p.y;
  7124. if (p.x > x2) x2 = p.x;
  7125. if (p.y > y2) y2 = p.y;
  7126. }
  7127. }
  7128. }
  7129. var dx = x2 - x1, dy = y2 - y1;
  7130. if (dx > dy) y2 = y1 + dx; else x2 = x1 + dy;
  7131. function insert(n, p, x1, y1, x2, y2) {
  7132. if (isNaN(p.x) || isNaN(p.y)) return;
  7133. if (n.leaf) {
  7134. var v = n.point;
  7135. if (v) {
  7136. if (Math.abs(v.x - p.x) + Math.abs(v.y - p.y) < .01) {
  7137. insertChild(n, p, x1, y1, x2, y2);
  7138. } else {
  7139. n.point = null;
  7140. insertChild(n, v, x1, y1, x2, y2);
  7141. insertChild(n, p, x1, y1, x2, y2);
  7142. }
  7143. } else {
  7144. n.point = p;
  7145. }
  7146. } else {
  7147. insertChild(n, p, x1, y1, x2, y2);
  7148. }
  7149. }
  7150. function insertChild(n, p, x1, y1, x2, y2) {
  7151. var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = p.x >= sx, bottom = p.y >= sy, i = (bottom << 1) + right;
  7152. n.leaf = false;
  7153. n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
  7154. if (right) x1 = sx; else x2 = sx;
  7155. if (bottom) y1 = sy; else y2 = sy;
  7156. insert(n, p, x1, y1, x2, y2);
  7157. }
  7158. var root = d3_geom_quadtreeNode();
  7159. root.add = function(p) {
  7160. insert(root, p, x1, y1, x2, y2);
  7161. };
  7162. root.visit = function(f) {
  7163. d3_geom_quadtreeVisit(f, root, x1, y1, x2, y2);
  7164. };
  7165. points.forEach(root.add);
  7166. return root;
  7167. };
  7168. function d3_geom_quadtreeNode() {
  7169. return {
  7170. leaf: true,
  7171. nodes: [],
  7172. point: null
  7173. };
  7174. }
  7175. function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {
  7176. if (!f(node, x1, y1, x2, y2)) {
  7177. var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, children = node.nodes;
  7178. if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);
  7179. if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);
  7180. if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);
  7181. if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
  7182. }
  7183. }
  7184. d3.time = {};
  7185. var d3_time = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ];
  7186. function d3_time_utc() {
  7187. this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]);
  7188. }
  7189. d3_time_utc.prototype = {
  7190. getDate: function() {
  7191. return this._.getUTCDate();
  7192. },
  7193. getDay: function() {
  7194. return this._.getUTCDay();
  7195. },
  7196. getFullYear: function() {
  7197. return this._.getUTCFullYear();
  7198. },
  7199. getHours: function() {
  7200. return this._.getUTCHours();
  7201. },
  7202. getMilliseconds: function() {
  7203. return this._.getUTCMilliseconds();
  7204. },
  7205. getMinutes: function() {
  7206. return this._.getUTCMinutes();
  7207. },
  7208. getMonth: function() {
  7209. return this._.getUTCMonth();
  7210. },
  7211. getSeconds: function() {
  7212. return this._.getUTCSeconds();
  7213. },
  7214. getTime: function() {
  7215. return this._.getTime();
  7216. },
  7217. getTimezoneOffset: function() {
  7218. return 0;
  7219. },
  7220. valueOf: function() {
  7221. return this._.valueOf();
  7222. },
  7223. setDate: function() {
  7224. d3_time_prototype.setUTCDate.apply(this._, arguments);
  7225. },
  7226. setDay: function() {
  7227. d3_time_prototype.setUTCDay.apply(this._, arguments);
  7228. },
  7229. setFullYear: function() {
  7230. d3_time_prototype.setUTCFullYear.apply(this._, arguments);
  7231. },
  7232. setHours: function() {
  7233. d3_time_prototype.setUTCHours.apply(this._, arguments);
  7234. },
  7235. setMilliseconds: function() {
  7236. d3_time_prototype.setUTCMilliseconds.apply(this._, arguments);
  7237. },
  7238. setMinutes: function() {
  7239. d3_time_prototype.setUTCMinutes.apply(this._, arguments);
  7240. },
  7241. setMonth: function() {
  7242. d3_time_prototype.setUTCMonth.apply(this._, arguments);
  7243. },
  7244. setSeconds: function() {
  7245. d3_time_prototype.setUTCSeconds.apply(this._, arguments);
  7246. },
  7247. setTime: function() {
  7248. d3_time_prototype.setTime.apply(this._, arguments);
  7249. }
  7250. };
  7251. var d3_time_prototype = Date.prototype;
  7252. var d3_time_formatDateTime = "%a %b %e %X %Y", d3_time_formatDate = "%m/%d/%Y", d3_time_formatTime = "%H:%M:%S";
  7253. 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" ];
  7254. d3.time.format = function(template) {
  7255. var n = template.length;
  7256. function format(date) {
  7257. var string = [], i = -1, j = 0, c, p, f;
  7258. while (++i < n) {
  7259. if (template.charCodeAt(i) === 37) {
  7260. string.push(template.substring(j, i));
  7261. if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i);
  7262. if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p);
  7263. string.push(c);
  7264. j = i + 1;
  7265. }
  7266. }
  7267. string.push(template.substring(j, i));
  7268. return string.join("");
  7269. }
  7270. format.parse = function(string) {
  7271. var d = {
  7272. y: 1900,
  7273. m: 0,
  7274. d: 1,
  7275. H: 0,
  7276. M: 0,
  7277. S: 0,
  7278. L: 0
  7279. }, i = d3_time_parse(d, template, string, 0);
  7280. if (i != string.length) return null;
  7281. if ("p" in d) d.H = d.H % 12 + d.p * 12;
  7282. var date = new d3_time();
  7283. date.setFullYear(d.y, d.m, d.d);
  7284. date.setHours(d.H, d.M, d.S, d.L);
  7285. return date;
  7286. };
  7287. format.toString = function() {
  7288. return template;
  7289. };
  7290. return format;
  7291. };
  7292. function d3_time_parse(date, template, string, j) {
  7293. var c, p, i = 0, n = template.length, m = string.length;
  7294. while (i < n) {
  7295. if (j >= m) return -1;
  7296. c = template.charCodeAt(i++);
  7297. if (c === 37) {
  7298. p = d3_time_parsers[template.charAt(i++)];
  7299. if (!p || (j = p(date, string, j)) < 0) return -1;
  7300. } else if (c != string.charCodeAt(j++)) {
  7301. return -1;
  7302. }
  7303. }
  7304. return j;
  7305. }
  7306. function d3_time_formatRe(names) {
  7307. return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i");
  7308. }
  7309. function d3_time_formatLookup(names) {
  7310. var map = new d3_Map(), i = -1, n = names.length;
  7311. while (++i < n) map.set(names[i].toLowerCase(), i);
  7312. return map;
  7313. }
  7314. function d3_time_formatPad(value, fill, width) {
  7315. value += "";
  7316. var length = value.length;
  7317. return length < width ? new Array(width - length + 1).join(fill) + value : value;
  7318. }
  7319. var d3_time_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(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);
  7320. var d3_time_formatPads = {
  7321. "-": "",
  7322. _: " ",
  7323. "0": "0"
  7324. };
  7325. var d3_time_formats = {
  7326. a: function(d) {
  7327. return d3_time_dayAbbreviations[d.getDay()];
  7328. },
  7329. A: function(d) {
  7330. return d3_time_days[d.getDay()];
  7331. },
  7332. b: function(d) {
  7333. return d3_time_monthAbbreviations[d.getMonth()];
  7334. },
  7335. B: function(d) {
  7336. return d3_time_months[d.getMonth()];
  7337. },
  7338. c: d3.time.format(d3_time_formatDateTime),
  7339. d: function(d, p) {
  7340. return d3_time_formatPad(d.getDate(), p, 2);
  7341. },
  7342. e: function(d, p) {
  7343. return d3_time_formatPad(d.getDate(), p, 2);
  7344. },
  7345. H: function(d, p) {
  7346. return d3_time_formatPad(d.getHours(), p, 2);
  7347. },
  7348. I: function(d, p) {
  7349. return d3_time_formatPad(d.getHours() % 12 || 12, p, 2);
  7350. },
  7351. j: function(d, p) {
  7352. return d3_time_formatPad(1 + d3.time.dayOfYear(d), p, 3);
  7353. },
  7354. L: function(d, p) {
  7355. return d3_time_formatPad(d.getMilliseconds(), p, 3);
  7356. },
  7357. m: function(d, p) {
  7358. return d3_time_formatPad(d.getMonth() + 1, p, 2);
  7359. },
  7360. M: function(d, p) {
  7361. return d3_time_formatPad(d.getMinutes(), p, 2);
  7362. },
  7363. p: function(d) {
  7364. return d.getHours() >= 12 ? "PM" : "AM";
  7365. },
  7366. S: function(d, p) {
  7367. return d3_time_formatPad(d.getSeconds(), p, 2);
  7368. },
  7369. U: function(d, p) {
  7370. return d3_time_formatPad(d3.time.sundayOfYear(d), p, 2);
  7371. },
  7372. w: function(d) {
  7373. return d.getDay();
  7374. },
  7375. W: function(d, p) {
  7376. return d3_time_formatPad(d3.time.mondayOfYear(d), p, 2);
  7377. },
  7378. x: d3.time.format(d3_time_formatDate),
  7379. X: d3.time.format(d3_time_formatTime),
  7380. y: function(d, p) {
  7381. return d3_time_formatPad(d.getFullYear() % 100, p, 2);
  7382. },
  7383. Y: function(d, p) {
  7384. return d3_time_formatPad(d.getFullYear() % 1e4, p, 4);
  7385. },
  7386. Z: d3_time_zone,
  7387. "%": function() {
  7388. return "%";
  7389. }
  7390. };
  7391. var d3_time_parsers = {
  7392. a: d3_time_parseWeekdayAbbrev,
  7393. A: d3_time_parseWeekday,
  7394. b: d3_time_parseMonthAbbrev,
  7395. B: d3_time_parseMonth,
  7396. c: d3_time_parseLocaleFull,
  7397. d: d3_time_parseDay,
  7398. e: d3_time_parseDay,
  7399. H: d3_time_parseHour24,
  7400. I: d3_time_parseHour24,
  7401. L: d3_time_parseMilliseconds,
  7402. m: d3_time_parseMonthNumber,
  7403. M: d3_time_parseMinutes,
  7404. p: d3_time_parseAmPm,
  7405. S: d3_time_parseSeconds,
  7406. x: d3_time_parseLocaleDate,
  7407. X: d3_time_parseLocaleTime,
  7408. y: d3_time_parseYear,
  7409. Y: d3_time_parseFullYear
  7410. };
  7411. function d3_time_parseWeekdayAbbrev(date, string, i) {
  7412. d3_time_dayAbbrevRe.lastIndex = 0;
  7413. var n = d3_time_dayAbbrevRe.exec(string.substring(i));
  7414. return n ? i += n[0].length : -1;
  7415. }
  7416. function d3_time_parseWeekday(date, string, i) {
  7417. d3_time_dayRe.lastIndex = 0;
  7418. var n = d3_time_dayRe.exec(string.substring(i));
  7419. return n ? i += n[0].length : -1;
  7420. }
  7421. function d3_time_parseMonthAbbrev(date, string, i) {
  7422. d3_time_monthAbbrevRe.lastIndex = 0;
  7423. var n = d3_time_monthAbbrevRe.exec(string.substring(i));
  7424. return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i += n[0].length) : -1;
  7425. }
  7426. function d3_time_parseMonth(date, string, i) {
  7427. d3_time_monthRe.lastIndex = 0;
  7428. var n = d3_time_monthRe.exec(string.substring(i));
  7429. return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1;
  7430. }
  7431. function d3_time_parseLocaleFull(date, string, i) {
  7432. return d3_time_parse(date, d3_time_formats.c.toString(), string, i);
  7433. }
  7434. function d3_time_parseLocaleDate(date, string, i) {
  7435. return d3_time_parse(date, d3_time_formats.x.toString(), string, i);
  7436. }
  7437. function d3_time_parseLocaleTime(date, string, i) {
  7438. return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
  7439. }
  7440. function d3_time_parseFullYear(date, string, i) {
  7441. d3_time_numberRe.lastIndex = 0;
  7442. var n = d3_time_numberRe.exec(string.substring(i, i + 4));
  7443. return n ? (date.y = +n[0], i += n[0].length) : -1;
  7444. }
  7445. function d3_time_parseYear(date, string, i) {
  7446. d3_time_numberRe.lastIndex = 0;
  7447. var n = d3_time_numberRe.exec(string.substring(i, i + 2));
  7448. return n ? (date.y = d3_time_expandYear(+n[0]), i += n[0].length) : -1;
  7449. }
  7450. function d3_time_expandYear(d) {
  7451. return d + (d > 68 ? 1900 : 2e3);
  7452. }
  7453. function d3_time_parseMonthNumber(date, string, i) {
  7454. d3_time_numberRe.lastIndex = 0;
  7455. var n = d3_time_numberRe.exec(string.substring(i, i + 2));
  7456. return n ? (date.m = n[0] - 1, i += n[0].length) : -1;
  7457. }
  7458. function d3_time_parseDay(date, string, i) {
  7459. d3_time_numberRe.lastIndex = 0;
  7460. var n = d3_time_numberRe.exec(string.substring(i, i + 2));
  7461. return n ? (date.d = +n[0], i += n[0].length) : -1;
  7462. }
  7463. function d3_time_parseHour24(date, string, i) {
  7464. d3_time_numberRe.lastIndex = 0;
  7465. var n = d3_time_numberRe.exec(string.substring(i, i + 2));
  7466. return n ? (date.H = +n[0], i += n[0].length) : -1;
  7467. }
  7468. function d3_time_parseMinutes(date, string, i) {
  7469. d3_time_numberRe.lastIndex = 0;
  7470. var n = d3_time_numberRe.exec(string.substring(i, i + 2));
  7471. return n ? (date.M = +n[0], i += n[0].length) : -1;
  7472. }
  7473. function d3_time_parseSeconds(date, string, i) {
  7474. d3_time_numberRe.lastIndex = 0;
  7475. var n = d3_time_numberRe.exec(string.substring(i, i + 2));
  7476. return n ? (date.S = +n[0], i += n[0].length) : -1;
  7477. }
  7478. function d3_time_parseMilliseconds(date, string, i) {
  7479. d3_time_numberRe.lastIndex = 0;
  7480. var n = d3_time_numberRe.exec(string.substring(i, i + 3));
  7481. return n ? (date.L = +n[0], i += n[0].length) : -1;
  7482. }
  7483. var d3_time_numberRe = /^\s*\d+/;
  7484. function d3_time_parseAmPm(date, string, i) {
  7485. var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase());
  7486. return n == null ? -1 : (date.p = n, i);
  7487. }
  7488. var d3_time_amPmLookup = d3.map({
  7489. am: 0,
  7490. pm: 1
  7491. });
  7492. function d3_time_zone(d) {
  7493. var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(Math.abs(z) / 60), zm = Math.abs(z) % 60;
  7494. return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2);
  7495. }
  7496. d3.time.format.utc = function(template) {
  7497. var local = d3.time.format(template);
  7498. function format(date) {
  7499. try {
  7500. d3_time = d3_time_utc;
  7501. var utc = new d3_time();
  7502. utc._ = date;
  7503. return local(utc);
  7504. } finally {
  7505. d3_time = Date;
  7506. }
  7507. }
  7508. format.parse = function(string) {
  7509. try {
  7510. d3_time = d3_time_utc;
  7511. var date = local.parse(string);
  7512. return date && date._;
  7513. } finally {
  7514. d3_time = Date;
  7515. }
  7516. };
  7517. format.toString = local.toString;
  7518. return format;
  7519. };
  7520. var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");
  7521. d3.time.format.iso = Date.prototype.toISOString ? d3_time_formatIsoNative : d3_time_formatIso;
  7522. function d3_time_formatIsoNative(date) {
  7523. return date.toISOString();
  7524. }
  7525. d3_time_formatIsoNative.parse = function(string) {
  7526. var date = new Date(string);
  7527. return isNaN(date) ? null : date;
  7528. };
  7529. d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
  7530. function d3_time_interval(local, step, number) {
  7531. function round(date) {
  7532. var d0 = local(date), d1 = offset(d0, 1);
  7533. return date - d0 < d1 - date ? d0 : d1;
  7534. }
  7535. function ceil(date) {
  7536. step(date = local(new d3_time(date - 1)), 1);
  7537. return date;
  7538. }
  7539. function offset(date, k) {
  7540. step(date = new d3_time(+date), k);
  7541. return date;
  7542. }
  7543. function range(t0, t1, dt) {
  7544. var time = ceil(t0), times = [];
  7545. if (dt > 1) {
  7546. while (time < t1) {
  7547. if (!(number(time) % dt)) times.push(new Date(+time));
  7548. step(time, 1);
  7549. }
  7550. } else {
  7551. while (time < t1) times.push(new Date(+time)), step(time, 1);
  7552. }
  7553. return times;
  7554. }
  7555. function range_utc(t0, t1, dt) {
  7556. try {
  7557. d3_time = d3_time_utc;
  7558. var utc = new d3_time_utc();
  7559. utc._ = t0;
  7560. return range(utc, t1, dt);
  7561. } finally {
  7562. d3_time = Date;
  7563. }
  7564. }
  7565. local.floor = local;
  7566. local.round = round;
  7567. local.ceil = ceil;
  7568. local.offset = offset;
  7569. local.range = range;
  7570. var utc = local.utc = d3_time_interval_utc(local);
  7571. utc.floor = utc;
  7572. utc.round = d3_time_interval_utc(round);
  7573. utc.ceil = d3_time_interval_utc(ceil);
  7574. utc.offset = d3_time_interval_utc(offset);
  7575. utc.range = range_utc;
  7576. return local;
  7577. }
  7578. function d3_time_interval_utc(method) {
  7579. return function(date, k) {
  7580. try {
  7581. d3_time = d3_time_utc;
  7582. var utc = new d3_time_utc();
  7583. utc._ = date;
  7584. return method(utc, k)._;
  7585. } finally {
  7586. d3_time = Date;
  7587. }
  7588. };
  7589. }
  7590. d3.time.second = d3_time_interval(function(date) {
  7591. return new d3_time(Math.floor(date / 1e3) * 1e3);
  7592. }, function(date, offset) {
  7593. date.setTime(date.getTime() + Math.floor(offset) * 1e3);
  7594. }, function(date) {
  7595. return date.getSeconds();
  7596. });
  7597. d3.time.seconds = d3.time.second.range;
  7598. d3.time.seconds.utc = d3.time.second.utc.range;
  7599. d3.time.minute = d3_time_interval(function(date) {
  7600. return new d3_time(Math.floor(date / 6e4) * 6e4);
  7601. }, function(date, offset) {
  7602. date.setTime(date.getTime() + Math.floor(offset) * 6e4);
  7603. }, function(date) {
  7604. return date.getMinutes();
  7605. });
  7606. d3.time.minutes = d3.time.minute.range;
  7607. d3.time.minutes.utc = d3.time.minute.utc.range;
  7608. d3.time.hour = d3_time_interval(function(date) {
  7609. var timezone = date.getTimezoneOffset() / 60;
  7610. return new d3_time((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
  7611. }, function(date, offset) {
  7612. date.setTime(date.getTime() + Math.floor(offset) * 36e5);
  7613. }, function(date) {
  7614. return date.getHours();
  7615. });
  7616. d3.time.hours = d3.time.hour.range;
  7617. d3.time.hours.utc = d3.time.hour.utc.range;
  7618. d3.time.day = d3_time_interval(function(date) {
  7619. var day = new d3_time(1970, 0);
  7620. day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
  7621. return day;
  7622. }, function(date, offset) {
  7623. date.setDate(date.getDate() + offset);
  7624. }, function(date) {
  7625. return date.getDate() - 1;
  7626. });
  7627. d3.time.days = d3.time.day.range;
  7628. d3.time.days.utc = d3.time.day.utc.range;
  7629. d3.time.dayOfYear = function(date) {
  7630. var year = d3.time.year(date);
  7631. return Math.floor((date - year - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5);
  7632. };
  7633. d3_time_daySymbols.forEach(function(day, i) {
  7634. day = day.toLowerCase();
  7635. i = 7 - i;
  7636. var interval = d3.time[day] = d3_time_interval(function(date) {
  7637. (date = d3.time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
  7638. return date;
  7639. }, function(date, offset) {
  7640. date.setDate(date.getDate() + Math.floor(offset) * 7);
  7641. }, function(date) {
  7642. var day = d3.time.year(date).getDay();
  7643. return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
  7644. });
  7645. d3.time[day + "s"] = interval.range;
  7646. d3.time[day + "s"].utc = interval.utc.range;
  7647. d3.time[day + "OfYear"] = function(date) {
  7648. var day = d3.time.year(date).getDay();
  7649. return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7);
  7650. };
  7651. });
  7652. d3.time.week = d3.time.sunday;
  7653. d3.time.weeks = d3.time.sunday.range;
  7654. d3.time.weeks.utc = d3.time.sunday.utc.range;
  7655. d3.time.weekOfYear = d3.time.sundayOfYear;
  7656. d3.time.month = d3_time_interval(function(date) {
  7657. date = d3.time.day(date);
  7658. date.setDate(1);
  7659. return date;
  7660. }, function(date, offset) {
  7661. date.setMonth(date.getMonth() + offset);
  7662. }, function(date) {
  7663. return date.getMonth();
  7664. });
  7665. d3.time.months = d3.time.month.range;
  7666. d3.time.months.utc = d3.time.month.utc.range;
  7667. d3.time.year = d3_time_interval(function(date) {
  7668. date = d3.time.day(date);
  7669. date.setMonth(0, 1);
  7670. return date;
  7671. }, function(date, offset) {
  7672. date.setFullYear(date.getFullYear() + offset);
  7673. }, function(date) {
  7674. return date.getFullYear();
  7675. });
  7676. d3.time.years = d3.time.year.range;
  7677. d3.time.years.utc = d3.time.year.utc.range;
  7678. function d3_time_scale(linear, methods, format) {
  7679. function scale(x) {
  7680. return linear(x);
  7681. }
  7682. scale.invert = function(x) {
  7683. return d3_time_scaleDate(linear.invert(x));
  7684. };
  7685. scale.domain = function(x) {
  7686. if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
  7687. linear.domain(x);
  7688. return scale;
  7689. };
  7690. scale.nice = function(m) {
  7691. return scale.domain(d3_scale_nice(scale.domain(), function() {
  7692. return m;
  7693. }));
  7694. };
  7695. scale.ticks = function(m, k) {
  7696. var extent = d3_time_scaleExtent(scale.domain());
  7697. if (typeof m !== "function") {
  7698. var span = extent[1] - extent[0], target = span / m, i = d3.bisect(d3_time_scaleSteps, target);
  7699. if (i == d3_time_scaleSteps.length) return methods.year(extent, m);
  7700. if (!i) return linear.ticks(m).map(d3_time_scaleDate);
  7701. if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i;
  7702. m = methods[i];
  7703. k = m[1];
  7704. m = m[0].range;
  7705. }
  7706. return m(extent[0], new Date(+extent[1] + 1), k);
  7707. };
  7708. scale.tickFormat = function() {
  7709. return format;
  7710. };
  7711. scale.copy = function() {
  7712. return d3_time_scale(linear.copy(), methods, format);
  7713. };
  7714. return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
  7715. }
  7716. function d3_time_scaleExtent(domain) {
  7717. var start = domain[0], stop = domain[domain.length - 1];
  7718. return start < stop ? [ start, stop ] : [ stop, start ];
  7719. }
  7720. function d3_time_scaleDate(t) {
  7721. return new Date(t);
  7722. }
  7723. function d3_time_scaleFormat(formats) {
  7724. return function(date) {
  7725. var i = formats.length - 1, f = formats[i];
  7726. while (!f[1](date)) f = formats[--i];
  7727. return f[0](date);
  7728. };
  7729. }
  7730. function d3_time_scaleSetYear(y) {
  7731. var d = new Date(y, 0, 1);
  7732. d.setFullYear(y);
  7733. return d;
  7734. }
  7735. function d3_time_scaleGetYear(d) {
  7736. var y = d.getFullYear(), d0 = d3_time_scaleSetYear(y), d1 = d3_time_scaleSetYear(y + 1);
  7737. return y + (d - d0) / (d1 - d0);
  7738. }
  7739. var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ];
  7740. 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 ] ];
  7741. var d3_time_scaleLocalFormats = [ [ d3.time.format("%Y"), d3_true ], [ d3.time.format("%B"), function(d) {
  7742. return d.getMonth();
  7743. } ], [ d3.time.format("%b %d"), function(d) {
  7744. return d.getDate() != 1;
  7745. } ], [ d3.time.format("%a %d"), function(d) {
  7746. return d.getDay() && d.getDate() != 1;
  7747. } ], [ d3.time.format("%I %p"), function(d) {
  7748. return d.getHours();
  7749. } ], [ d3.time.format("%I:%M"), function(d) {
  7750. return d.getMinutes();
  7751. } ], [ d3.time.format(":%S"), function(d) {
  7752. return d.getSeconds();
  7753. } ], [ d3.time.format(".%L"), function(d) {
  7754. return d.getMilliseconds();
  7755. } ] ];
  7756. var d3_time_scaleLinear = d3.scale.linear(), d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats);
  7757. d3_time_scaleLocalMethods.year = function(extent, m) {
  7758. return d3_time_scaleLinear.domain(extent.map(d3_time_scaleGetYear)).ticks(m).map(d3_time_scaleSetYear);
  7759. };
  7760. d3.time.scale = function() {
  7761. return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
  7762. };
  7763. var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) {
  7764. return [ m[0].utc, m[1] ];
  7765. });
  7766. var d3_time_scaleUTCFormats = [ [ d3.time.format.utc("%Y"), d3_true ], [ d3.time.format.utc("%B"), function(d) {
  7767. return d.getUTCMonth();
  7768. } ], [ d3.time.format.utc("%b %d"), function(d) {
  7769. return d.getUTCDate() != 1;
  7770. } ], [ d3.time.format.utc("%a %d"), function(d) {
  7771. return d.getUTCDay() && d.getUTCDate() != 1;
  7772. } ], [ d3.time.format.utc("%I %p"), function(d) {
  7773. return d.getUTCHours();
  7774. } ], [ d3.time.format.utc("%I:%M"), function(d) {
  7775. return d.getUTCMinutes();
  7776. } ], [ d3.time.format.utc(":%S"), function(d) {
  7777. return d.getUTCSeconds();
  7778. } ], [ d3.time.format.utc(".%L"), function(d) {
  7779. return d.getUTCMilliseconds();
  7780. } ] ];
  7781. var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats);
  7782. function d3_time_scaleUTCSetYear(y) {
  7783. var d = new Date(Date.UTC(y, 0, 1));
  7784. d.setUTCFullYear(y);
  7785. return d;
  7786. }
  7787. function d3_time_scaleUTCGetYear(d) {
  7788. var y = d.getUTCFullYear(), d0 = d3_time_scaleUTCSetYear(y), d1 = d3_time_scaleUTCSetYear(y + 1);
  7789. return y + (d - d0) / (d1 - d0);
  7790. }
  7791. d3_time_scaleUTCMethods.year = function(extent, m) {
  7792. return d3_time_scaleLinear.domain(extent.map(d3_time_scaleUTCGetYear)).ticks(m).map(d3_time_scaleUTCSetYear);
  7793. };
  7794. d3.time.scale.utc = function() {
  7795. return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat);
  7796. };
  7797. })();