echarts.js 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["echarts"] = factory();
  8. else
  9. root["echarts"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/ // The require function
  15. /******/ function __webpack_require__(moduleId) {
  16. /******/ // Check if module is in cache
  17. /******/ if(installedModules[moduleId])
  18. /******/ return installedModules[moduleId].exports;
  19. /******/ // Create a new module (and put it into the cache)
  20. /******/ var module = installedModules[moduleId] = {
  21. /******/ exports: {},
  22. /******/ id: moduleId,
  23. /******/ loaded: false
  24. /******/ };
  25. /******/ // Execute the module function
  26. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  27. /******/ // Flag the module as loaded
  28. /******/ module.loaded = true;
  29. /******/ // Return the exports of the module
  30. /******/ return module.exports;
  31. /******/ }
  32. /******/ // expose the modules object (__webpack_modules__)
  33. /******/ __webpack_require__.m = modules;
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/ // __webpack_public_path__
  37. /******/ __webpack_require__.p = "";
  38. /******/ // Load entry module and return exports
  39. /******/ return __webpack_require__(0);
  40. /******/ })
  41. /************************************************************************/
  42. /******/ ([
  43. /* 0 */
  44. /***/ function(module, exports, __webpack_require__) {
  45. /**
  46. * Export echarts as CommonJS module
  47. */
  48. module.exports = __webpack_require__(1);
  49. // Import all charts and components
  50. __webpack_require__(100);
  51. __webpack_require__(135);
  52. __webpack_require__(140);
  53. __webpack_require__(149);
  54. __webpack_require__(153);
  55. __webpack_require__(163);
  56. __webpack_require__(184);
  57. __webpack_require__(196);
  58. __webpack_require__(217);
  59. __webpack_require__(221);
  60. __webpack_require__(225);
  61. __webpack_require__(240);
  62. __webpack_require__(246);
  63. __webpack_require__(253);
  64. __webpack_require__(259);
  65. __webpack_require__(263);
  66. __webpack_require__(271);
  67. __webpack_require__(275);
  68. __webpack_require__(113);
  69. __webpack_require__(276);
  70. __webpack_require__(282);
  71. __webpack_require__(286);
  72. __webpack_require__(297);
  73. __webpack_require__(226);
  74. __webpack_require__(300);
  75. __webpack_require__(306);
  76. __webpack_require__(317);
  77. __webpack_require__(318);
  78. __webpack_require__(332);
  79. __webpack_require__(347);
  80. __webpack_require__(353);
  81. __webpack_require__(356);
  82. __webpack_require__(359);
  83. __webpack_require__(368);
  84. __webpack_require__(381);
  85. /***/ },
  86. /* 1 */
  87. /***/ function(module, exports, __webpack_require__) {
  88. // Enable DEV mode when using source code without build. which has no __DEV__ variable
  89. // In build process 'typeof __DEV__' will be replace with 'boolean'
  90. // So this code will be removed or disabled anyway after built.
  91. if (false) {
  92. // In browser
  93. if (typeof window !== 'undefined') {
  94. window.__DEV__ = true;
  95. }
  96. // In node
  97. else if (typeof global !== 'undefined') {
  98. global.__DEV__ = true;
  99. }
  100. }
  101. /*!
  102. * ECharts, a javascript interactive chart library.
  103. *
  104. * Copyright (c) 2015, Baidu Inc.
  105. * All rights reserved.
  106. *
  107. * LICENSE
  108. * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt
  109. */
  110. /**
  111. * @module echarts
  112. */
  113. var env = __webpack_require__(2);
  114. var GlobalModel = __webpack_require__(3);
  115. var ExtensionAPI = __webpack_require__(25);
  116. var CoordinateSystemManager = __webpack_require__(26);
  117. var OptionManager = __webpack_require__(27);
  118. var ComponentModel = __webpack_require__(19);
  119. var SeriesModel = __webpack_require__(28);
  120. var ComponentView = __webpack_require__(29);
  121. var ChartView = __webpack_require__(42);
  122. var graphic = __webpack_require__(43);
  123. var modelUtil = __webpack_require__(5);
  124. var throttle = __webpack_require__(81);
  125. var zrender = __webpack_require__(82);
  126. var zrUtil = __webpack_require__(4);
  127. var colorTool = __webpack_require__(39);
  128. var Eventful = __webpack_require__(33);
  129. var timsort = __webpack_require__(86);
  130. var each = zrUtil.each;
  131. var PRIORITY_PROCESSOR_FILTER = 1000;
  132. var PRIORITY_PROCESSOR_STATISTIC = 5000;
  133. var PRIORITY_VISUAL_LAYOUT = 1000;
  134. var PRIORITY_VISUAL_GLOBAL = 2000;
  135. var PRIORITY_VISUAL_CHART = 3000;
  136. var PRIORITY_VISUAL_COMPONENT = 4000;
  137. var PRIORITY_VISUAL_BRUSH = 5000;
  138. // Main process have three entries: `setOption`, `dispatchAction` and `resize`,
  139. // where they must not be invoked nestedly, except the only case: invoke
  140. // dispatchAction with updateMethod "none" in main process.
  141. // This flag is used to carry out this rule.
  142. // All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]).
  143. var IN_MAIN_PROCESS = '__flagInMainProcess';
  144. var HAS_GRADIENT_OR_PATTERN_BG = '__hasGradientOrPatternBg';
  145. var OPTION_UPDATED = '__optionUpdated';
  146. function createRegisterEventWithLowercaseName(method) {
  147. return function (eventName, handler, context) {
  148. // Event name is all lowercase
  149. eventName = eventName && eventName.toLowerCase();
  150. Eventful.prototype[method].call(this, eventName, handler, context);
  151. };
  152. }
  153. /**
  154. * @module echarts~MessageCenter
  155. */
  156. function MessageCenter() {
  157. Eventful.call(this);
  158. }
  159. MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on');
  160. MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off');
  161. MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one');
  162. zrUtil.mixin(MessageCenter, Eventful);
  163. /**
  164. * @module echarts~ECharts
  165. */
  166. function ECharts (dom, theme, opts) {
  167. opts = opts || {};
  168. // Get theme by name
  169. if (typeof theme === 'string') {
  170. theme = themeStorage[theme];
  171. }
  172. /**
  173. * @type {string}
  174. */
  175. this.id;
  176. /**
  177. * Group id
  178. * @type {string}
  179. */
  180. this.group;
  181. /**
  182. * @type {HTMLDomElement}
  183. * @private
  184. */
  185. this._dom = dom;
  186. /**
  187. * @type {module:zrender/ZRender}
  188. * @private
  189. */
  190. var zr = this._zr = zrender.init(dom, {
  191. renderer: opts.renderer || 'canvas',
  192. devicePixelRatio: opts.devicePixelRatio,
  193. width: opts.width,
  194. height: opts.height
  195. });
  196. /**
  197. * Expect 60 pfs.
  198. * @type {Function}
  199. * @private
  200. */
  201. this._throttledZrFlush = throttle.throttle(zrUtil.bind(zr.flush, zr), 17);
  202. /**
  203. * @type {Object}
  204. * @private
  205. */
  206. this._theme = zrUtil.clone(theme);
  207. /**
  208. * @type {Array.<module:echarts/view/Chart>}
  209. * @private
  210. */
  211. this._chartsViews = [];
  212. /**
  213. * @type {Object.<string, module:echarts/view/Chart>}
  214. * @private
  215. */
  216. this._chartsMap = {};
  217. /**
  218. * @type {Array.<module:echarts/view/Component>}
  219. * @private
  220. */
  221. this._componentsViews = [];
  222. /**
  223. * @type {Object.<string, module:echarts/view/Component>}
  224. * @private
  225. */
  226. this._componentsMap = {};
  227. /**
  228. * @type {module:echarts/ExtensionAPI}
  229. * @private
  230. */
  231. this._api = new ExtensionAPI(this);
  232. /**
  233. * @type {module:echarts/CoordinateSystem}
  234. * @private
  235. */
  236. this._coordSysMgr = new CoordinateSystemManager();
  237. Eventful.call(this);
  238. /**
  239. * @type {module:echarts~MessageCenter}
  240. * @private
  241. */
  242. this._messageCenter = new MessageCenter();
  243. // Init mouse events
  244. this._initEvents();
  245. // In case some people write `window.onresize = chart.resize`
  246. this.resize = zrUtil.bind(this.resize, this);
  247. // Can't dispatch action during rendering procedure
  248. this._pendingActions = [];
  249. // Sort on demand
  250. function prioritySortFunc(a, b) {
  251. return a.prio - b.prio;
  252. }
  253. timsort(visualFuncs, prioritySortFunc);
  254. timsort(dataProcessorFuncs, prioritySortFunc);
  255. zr.animation.on('frame', this._onframe, this);
  256. }
  257. var echartsProto = ECharts.prototype;
  258. echartsProto._onframe = function () {
  259. // Lazy update
  260. if (this[OPTION_UPDATED]) {
  261. this[IN_MAIN_PROCESS] = true;
  262. updateMethods.prepareAndUpdate.call(this);
  263. this[IN_MAIN_PROCESS] = false;
  264. this[OPTION_UPDATED] = false;
  265. }
  266. };
  267. /**
  268. * @return {HTMLDomElement}
  269. */
  270. echartsProto.getDom = function () {
  271. return this._dom;
  272. };
  273. /**
  274. * @return {module:zrender~ZRender}
  275. */
  276. echartsProto.getZr = function () {
  277. return this._zr;
  278. };
  279. /**
  280. * @param {Object} option
  281. * @param {boolean} notMerge
  282. * @param {boolean} [lazyUpdate=false] Useful when setOption frequently.
  283. */
  284. echartsProto.setOption = function (option, notMerge, lazyUpdate) {
  285. if (true) {
  286. zrUtil.assert(!this[IN_MAIN_PROCESS], '`setOption` should not be called during main process.');
  287. }
  288. this[IN_MAIN_PROCESS] = true;
  289. if (!this._model || notMerge) {
  290. var optionManager = new OptionManager(this._api);
  291. var theme = this._theme;
  292. var ecModel = this._model = new GlobalModel(null, null, theme, optionManager);
  293. ecModel.init(null, null, theme, optionManager);
  294. }
  295. // FIXME
  296. // ugly
  297. this.__lastOnlyGraphic = !!(option && option.graphic);
  298. zrUtil.each(option, function (o, mainType) {
  299. mainType !== 'graphic' && (this.__lastOnlyGraphic = false);
  300. }, this);
  301. this._model.setOption(option, optionPreprocessorFuncs);
  302. if (lazyUpdate) {
  303. this[OPTION_UPDATED] = true;
  304. }
  305. else {
  306. updateMethods.prepareAndUpdate.call(this);
  307. // Ensure zr refresh sychronously, and then pixel in canvas can be
  308. // fetched after `setOption`.
  309. this._zr.flush();
  310. this[OPTION_UPDATED] = false;
  311. }
  312. this[IN_MAIN_PROCESS] = false;
  313. flushPendingActions.call(this, false);
  314. };
  315. /**
  316. * @DEPRECATED
  317. */
  318. echartsProto.setTheme = function () {
  319. console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0');
  320. };
  321. /**
  322. * @return {module:echarts/model/Global}
  323. */
  324. echartsProto.getModel = function () {
  325. return this._model;
  326. };
  327. /**
  328. * @return {Object}
  329. */
  330. echartsProto.getOption = function () {
  331. return this._model && this._model.getOption();
  332. };
  333. /**
  334. * @return {number}
  335. */
  336. echartsProto.getWidth = function () {
  337. return this._zr.getWidth();
  338. };
  339. /**
  340. * @return {number}
  341. */
  342. echartsProto.getHeight = function () {
  343. return this._zr.getHeight();
  344. };
  345. /**
  346. * Get canvas which has all thing rendered
  347. * @param {Object} opts
  348. * @param {string} [opts.backgroundColor]
  349. */
  350. echartsProto.getRenderedCanvas = function (opts) {
  351. if (!env.canvasSupported) {
  352. return;
  353. }
  354. opts = opts || {};
  355. opts.pixelRatio = opts.pixelRatio || 1;
  356. opts.backgroundColor = opts.backgroundColor
  357. || this._model.get('backgroundColor');
  358. var zr = this._zr;
  359. var list = zr.storage.getDisplayList();
  360. // Stop animations
  361. zrUtil.each(list, function (el) {
  362. el.stopAnimation(true);
  363. });
  364. return zr.painter.getRenderedCanvas(opts);
  365. };
  366. /**
  367. * @return {string}
  368. * @param {Object} opts
  369. * @param {string} [opts.type='png']
  370. * @param {string} [opts.pixelRatio=1]
  371. * @param {string} [opts.backgroundColor]
  372. * @param {string} [opts.excludeComponents]
  373. */
  374. echartsProto.getDataURL = function (opts) {
  375. opts = opts || {};
  376. var excludeComponents = opts.excludeComponents;
  377. var ecModel = this._model;
  378. var excludesComponentViews = [];
  379. var self = this;
  380. each(excludeComponents, function (componentType) {
  381. ecModel.eachComponent({
  382. mainType: componentType
  383. }, function (component) {
  384. var view = self._componentsMap[component.__viewId];
  385. if (!view.group.ignore) {
  386. excludesComponentViews.push(view);
  387. view.group.ignore = true;
  388. }
  389. });
  390. });
  391. var url = this.getRenderedCanvas(opts).toDataURL(
  392. 'image/' + (opts && opts.type || 'png')
  393. );
  394. each(excludesComponentViews, function (view) {
  395. view.group.ignore = false;
  396. });
  397. return url;
  398. };
  399. /**
  400. * @return {string}
  401. * @param {Object} opts
  402. * @param {string} [opts.type='png']
  403. * @param {string} [opts.pixelRatio=1]
  404. * @param {string} [opts.backgroundColor]
  405. */
  406. echartsProto.getConnectedDataURL = function (opts) {
  407. if (!env.canvasSupported) {
  408. return;
  409. }
  410. var groupId = this.group;
  411. var mathMin = Math.min;
  412. var mathMax = Math.max;
  413. var MAX_NUMBER = Infinity;
  414. if (connectedGroups[groupId]) {
  415. var left = MAX_NUMBER;
  416. var top = MAX_NUMBER;
  417. var right = -MAX_NUMBER;
  418. var bottom = -MAX_NUMBER;
  419. var canvasList = [];
  420. var dpr = (opts && opts.pixelRatio) || 1;
  421. zrUtil.each(instances, function (chart, id) {
  422. if (chart.group === groupId) {
  423. var canvas = chart.getRenderedCanvas(
  424. zrUtil.clone(opts)
  425. );
  426. var boundingRect = chart.getDom().getBoundingClientRect();
  427. left = mathMin(boundingRect.left, left);
  428. top = mathMin(boundingRect.top, top);
  429. right = mathMax(boundingRect.right, right);
  430. bottom = mathMax(boundingRect.bottom, bottom);
  431. canvasList.push({
  432. dom: canvas,
  433. left: boundingRect.left,
  434. top: boundingRect.top
  435. });
  436. }
  437. });
  438. left *= dpr;
  439. top *= dpr;
  440. right *= dpr;
  441. bottom *= dpr;
  442. var width = right - left;
  443. var height = bottom - top;
  444. var targetCanvas = zrUtil.createCanvas();
  445. targetCanvas.width = width;
  446. targetCanvas.height = height;
  447. var zr = zrender.init(targetCanvas);
  448. each(canvasList, function (item) {
  449. var img = new graphic.Image({
  450. style: {
  451. x: item.left * dpr - left,
  452. y: item.top * dpr - top,
  453. image: item.dom
  454. }
  455. });
  456. zr.add(img);
  457. });
  458. zr.refreshImmediately();
  459. return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));
  460. }
  461. else {
  462. return this.getDataURL(opts);
  463. }
  464. };
  465. /**
  466. * Convert from logical coordinate system to pixel coordinate system.
  467. * See CoordinateSystem#convertToPixel.
  468. * @param {string|Object} finder
  469. * If string, e.g., 'geo', means {geoIndex: 0}.
  470. * If Object, could contain some of these properties below:
  471. * {
  472. * seriesIndex / seriesId / seriesName,
  473. * geoIndex / geoId, geoName,
  474. * bmapIndex / bmapId / bmapName,
  475. * xAxisIndex / xAxisId / xAxisName,
  476. * yAxisIndex / yAxisId / yAxisName,
  477. * gridIndex / gridId / gridName,
  478. * ... (can be extended)
  479. * }
  480. * @param {Array|number} value
  481. * @return {Array|number} result
  482. */
  483. echartsProto.convertToPixel = zrUtil.curry(doConvertPixel, 'convertToPixel');
  484. /**
  485. * Convert from pixel coordinate system to logical coordinate system.
  486. * See CoordinateSystem#convertFromPixel.
  487. * @param {string|Object} finder
  488. * If string, e.g., 'geo', means {geoIndex: 0}.
  489. * If Object, could contain some of these properties below:
  490. * {
  491. * seriesIndex / seriesId / seriesName,
  492. * geoIndex / geoId / geoName,
  493. * bmapIndex / bmapId / bmapName,
  494. * xAxisIndex / xAxisId / xAxisName,
  495. * yAxisIndex / yAxisId / yAxisName
  496. * gridIndex / gridId / gridName,
  497. * ... (can be extended)
  498. * }
  499. * @param {Array|number} value
  500. * @return {Array|number} result
  501. */
  502. echartsProto.convertFromPixel = zrUtil.curry(doConvertPixel, 'convertFromPixel');
  503. function doConvertPixel(methodName, finder, value) {
  504. var ecModel = this._model;
  505. var coordSysList = this._coordSysMgr.getCoordinateSystems();
  506. var result;
  507. finder = modelUtil.parseFinder(ecModel, finder);
  508. for (var i = 0; i < coordSysList.length; i++) {
  509. var coordSys = coordSysList[i];
  510. if (coordSys[methodName]
  511. && (result = coordSys[methodName](ecModel, finder, value)) != null
  512. ) {
  513. return result;
  514. }
  515. }
  516. if (true) {
  517. console.warn(
  518. 'No coordinate system that supports ' + methodName + ' found by the given finder.'
  519. );
  520. }
  521. }
  522. /**
  523. * Is the specified coordinate systems or components contain the given pixel point.
  524. * @param {string|Object} finder
  525. * If string, e.g., 'geo', means {geoIndex: 0}.
  526. * If Object, could contain some of these properties below:
  527. * {
  528. * seriesIndex / seriesId / seriesName,
  529. * geoIndex / geoId / geoName,
  530. * bmapIndex / bmapId / bmapName,
  531. * xAxisIndex / xAxisId / xAxisName,
  532. * yAxisIndex / yAxisId / yAxisName
  533. * gridIndex / gridId / gridName,
  534. * ... (can be extended)
  535. * }
  536. * @param {Array|number} value
  537. * @return {boolean} result
  538. */
  539. echartsProto.containPixel = function (finder, value) {
  540. var ecModel = this._model;
  541. var result;
  542. finder = modelUtil.parseFinder(ecModel, finder);
  543. zrUtil.each(finder, function (models, key) {
  544. key.indexOf('Models') >= 0 && zrUtil.each(models, function (model) {
  545. var coordSys = model.coordinateSystem;
  546. if (coordSys && coordSys.containPoint) {
  547. result |= !!coordSys.containPoint(value);
  548. }
  549. else if (key === 'seriesModels') {
  550. var view = this._chartsMap[model.__viewId];
  551. if (view && view.containPoint) {
  552. result |= view.containPoint(value, model);
  553. }
  554. else {
  555. if (true) {
  556. console.warn(key + ': ' + (view
  557. ? 'The found component do not support containPoint.'
  558. : 'No view mapping to the found component.'
  559. ));
  560. }
  561. }
  562. }
  563. else {
  564. if (true) {
  565. console.warn(key + ': containPoint is not supported');
  566. }
  567. }
  568. }, this);
  569. }, this);
  570. return !!result;
  571. };
  572. /**
  573. * Get visual from series or data.
  574. * @param {string|Object} finder
  575. * If string, e.g., 'series', means {seriesIndex: 0}.
  576. * If Object, could contain some of these properties below:
  577. * {
  578. * seriesIndex / seriesId / seriesName,
  579. * dataIndex / dataIndexInside
  580. * }
  581. * If dataIndex is not specified, series visual will be fetched,
  582. * but not data item visual.
  583. * If all of seriesIndex, seriesId, seriesName are not specified,
  584. * visual will be fetched from first series.
  585. * @param {string} visualType 'color', 'symbol', 'symbolSize'
  586. */
  587. echartsProto.getVisual = function (finder, visualType) {
  588. var ecModel = this._model;
  589. finder = modelUtil.parseFinder(ecModel, finder, {defaultMainType: 'series'});
  590. var seriesModel = finder.seriesModel;
  591. if (true) {
  592. if (!seriesModel) {
  593. console.warn('There is no specified seires model');
  594. }
  595. }
  596. var data = seriesModel.getData();
  597. var dataIndexInside = finder.hasOwnProperty('dataIndexInside')
  598. ? finder.dataIndexInside
  599. : finder.hasOwnProperty('dataIndex')
  600. ? data.indexOfRawIndex(finder.dataIndex)
  601. : null;
  602. return dataIndexInside != null
  603. ? data.getItemVisual(dataIndexInside, visualType)
  604. : data.getVisual(visualType);
  605. };
  606. var updateMethods = {
  607. /**
  608. * @param {Object} payload
  609. * @private
  610. */
  611. update: function (payload) {
  612. // console.time && console.time('update');
  613. var ecModel = this._model;
  614. var api = this._api;
  615. var coordSysMgr = this._coordSysMgr;
  616. var zr = this._zr;
  617. // update before setOption
  618. if (!ecModel) {
  619. return;
  620. }
  621. // Fixme First time update ?
  622. ecModel.restoreData();
  623. // TODO
  624. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  625. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  626. // Create new coordinate system each update
  627. // In LineView may save the old coordinate system and use it to get the orignal point
  628. coordSysMgr.create(this._model, this._api);
  629. processData.call(this, ecModel, api);
  630. stackSeriesData.call(this, ecModel);
  631. coordSysMgr.update(ecModel, api);
  632. doVisualEncoding.call(this, ecModel, payload);
  633. doRender.call(this, ecModel, payload);
  634. // Set background
  635. var backgroundColor = ecModel.get('backgroundColor') || 'transparent';
  636. var painter = zr.painter;
  637. // TODO all use clearColor ?
  638. if (painter.isSingleCanvas && painter.isSingleCanvas()) {
  639. zr.configLayer(0, {
  640. clearColor: backgroundColor
  641. });
  642. }
  643. else {
  644. // In IE8
  645. if (!env.canvasSupported) {
  646. var colorArr = colorTool.parse(backgroundColor);
  647. backgroundColor = colorTool.stringify(colorArr, 'rgb');
  648. if (colorArr[3] === 0) {
  649. backgroundColor = 'transparent';
  650. }
  651. }
  652. if (backgroundColor.colorStops || backgroundColor.image) {
  653. // Gradient background
  654. // FIXME Fixed layer?
  655. zr.configLayer(0, {
  656. clearColor: backgroundColor
  657. });
  658. this[HAS_GRADIENT_OR_PATTERN_BG] = true;
  659. this._dom.style.background = 'transparent';
  660. }
  661. else {
  662. if (this[HAS_GRADIENT_OR_PATTERN_BG]) {
  663. zr.configLayer(0, {
  664. clearColor: null
  665. });
  666. }
  667. this[HAS_GRADIENT_OR_PATTERN_BG] = false;
  668. this._dom.style.background = backgroundColor;
  669. }
  670. }
  671. // console.time && console.timeEnd('update');
  672. },
  673. // PENDING
  674. /**
  675. * @param {Object} payload
  676. * @private
  677. */
  678. updateView: function (payload) {
  679. var ecModel = this._model;
  680. // update before setOption
  681. if (!ecModel) {
  682. return;
  683. }
  684. ecModel.eachSeries(function (seriesModel) {
  685. seriesModel.getData().clearAllVisual();
  686. });
  687. doVisualEncoding.call(this, ecModel, payload);
  688. invokeUpdateMethod.call(this, 'updateView', ecModel, payload);
  689. },
  690. /**
  691. * @param {Object} payload
  692. * @private
  693. */
  694. updateVisual: function (payload) {
  695. var ecModel = this._model;
  696. // update before setOption
  697. if (!ecModel) {
  698. return;
  699. }
  700. ecModel.eachSeries(function (seriesModel) {
  701. seriesModel.getData().clearAllVisual();
  702. });
  703. doVisualEncoding.call(this, ecModel, payload);
  704. invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload);
  705. },
  706. /**
  707. * @param {Object} payload
  708. * @private
  709. */
  710. updateLayout: function (payload) {
  711. var ecModel = this._model;
  712. // update before setOption
  713. if (!ecModel) {
  714. return;
  715. }
  716. doLayout.call(this, ecModel, payload);
  717. invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload);
  718. },
  719. /**
  720. * @param {Object} payload
  721. * @private
  722. */
  723. highlight: function (payload) {
  724. toggleHighlight.call(this, 'highlight', payload);
  725. },
  726. /**
  727. * @param {Object} payload
  728. * @private
  729. */
  730. downplay: function (payload) {
  731. toggleHighlight.call(this, 'downplay', payload);
  732. },
  733. /**
  734. * @param {Object} payload
  735. * @private
  736. */
  737. prepareAndUpdate: function (payload) {
  738. var ecModel = this._model;
  739. prepareView.call(this, 'component', ecModel);
  740. prepareView.call(this, 'chart', ecModel);
  741. // FIXME
  742. // ugly
  743. if (this.__lastOnlyGraphic) {
  744. each(this._componentsViews, function (componentView) {
  745. var componentModel = componentView.__model;
  746. if (componentModel && componentModel.mainType === 'graphic') {
  747. componentView.render(componentModel, ecModel, this._api, payload);
  748. updateZ(componentModel, componentView);
  749. }
  750. }, this);
  751. this.__lastOnlyGraphic = false;
  752. }
  753. else {
  754. updateMethods.update.call(this, payload);
  755. }
  756. }
  757. };
  758. /**
  759. * @param {Object} payload
  760. * @private
  761. */
  762. function toggleHighlight(method, payload) {
  763. var ecModel = this._model;
  764. // dispatchAction before setOption
  765. if (!ecModel) {
  766. return;
  767. }
  768. ecModel.eachComponent(
  769. {mainType: 'series', query: payload},
  770. function (seriesModel, index) {
  771. var chartView = this._chartsMap[seriesModel.__viewId];
  772. if (chartView && chartView.__alive) {
  773. chartView[method](
  774. seriesModel, ecModel, this._api, payload
  775. );
  776. }
  777. },
  778. this
  779. );
  780. }
  781. /**
  782. * Resize the chart
  783. * @param {Object} opts
  784. * @param {number} [opts.width] Can be 'auto' (the same as null/undefined)
  785. * @param {number} [opts.height] Can be 'auto' (the same as null/undefined)
  786. */
  787. echartsProto.resize = function (opts) {
  788. if (true) {
  789. zrUtil.assert(!this[IN_MAIN_PROCESS], '`resize` should not be called during main process.');
  790. }
  791. this[IN_MAIN_PROCESS] = true;
  792. this._zr.resize(opts);
  793. var optionChanged = this._model && this._model.resetOption('media');
  794. updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this);
  795. // Resize loading effect
  796. this._loadingFX && this._loadingFX.resize();
  797. this[IN_MAIN_PROCESS] = false;
  798. flushPendingActions.call(this);
  799. };
  800. /**
  801. * Show loading effect
  802. * @param {string} [name='default']
  803. * @param {Object} [cfg]
  804. */
  805. echartsProto.showLoading = function (name, cfg) {
  806. if (zrUtil.isObject(name)) {
  807. cfg = name;
  808. name = '';
  809. }
  810. name = name || 'default';
  811. this.hideLoading();
  812. if (!loadingEffects[name]) {
  813. if (true) {
  814. console.warn('Loading effects ' + name + ' not exists.');
  815. }
  816. return;
  817. }
  818. var el = loadingEffects[name](this._api, cfg);
  819. var zr = this._zr;
  820. this._loadingFX = el;
  821. zr.add(el);
  822. };
  823. /**
  824. * Hide loading effect
  825. */
  826. echartsProto.hideLoading = function () {
  827. this._loadingFX && this._zr.remove(this._loadingFX);
  828. this._loadingFX = null;
  829. };
  830. /**
  831. * @param {Object} eventObj
  832. * @return {Object}
  833. */
  834. echartsProto.makeActionFromEvent = function (eventObj) {
  835. var payload = zrUtil.extend({}, eventObj);
  836. payload.type = eventActionMap[eventObj.type];
  837. return payload;
  838. };
  839. /**
  840. * @pubilc
  841. * @param {Object} payload
  842. * @param {string} [payload.type] Action type
  843. * @param {Object|boolean} [opt] If pass boolean, means opt.silent
  844. * @param {boolean} [opt.silent=false] Whether trigger events.
  845. * @param {boolean} [opt.flush=undefined]
  846. * true: Flush immediately, and then pixel in canvas can be fetched
  847. * immediately. Caution: it might affect performance.
  848. * false: Not not flush.
  849. * undefined: Auto decide whether perform flush.
  850. */
  851. echartsProto.dispatchAction = function (payload, opt) {
  852. if (!zrUtil.isObject(opt)) {
  853. opt = {silent: !!opt};
  854. }
  855. if (!actions[payload.type]) {
  856. return;
  857. }
  858. // if (__DEV__) {
  859. // zrUtil.assert(
  860. // !this[IN_MAIN_PROCESS],
  861. // '`dispatchAction` should not be called during main process.'
  862. // + 'unless updateMathod is "none".'
  863. // );
  864. // }
  865. // May dispatchAction in rendering procedure
  866. if (this[IN_MAIN_PROCESS]) {
  867. this._pendingActions.push(payload);
  868. return;
  869. }
  870. doDispatchAction.call(this, payload, opt.silent);
  871. if (opt.flush) {
  872. this._zr.flush(true);
  873. }
  874. else if (opt.flush !== false && env.browser.weChat) {
  875. // In WeChat embeded browser, `requestAnimationFrame` and `setInterval`
  876. // hang when sliding page (on touch event), which cause that zr does not
  877. // refresh util user interaction finished, which is not expected.
  878. // But `dispatchAction` may be called too frequently when pan on touch
  879. // screen, which impacts performance if do not throttle them.
  880. this._throttledZrFlush();
  881. }
  882. flushPendingActions.call(this, opt.silent);
  883. };
  884. function doDispatchAction(payload, silent) {
  885. var actionWrap = actions[payload.type];
  886. var actionInfo = actionWrap.actionInfo;
  887. var updateMethod = actionInfo.update || 'update';
  888. this[IN_MAIN_PROCESS] = true;
  889. var payloads = [payload];
  890. var batched = false;
  891. // Batch action
  892. if (payload.batch) {
  893. batched = true;
  894. payloads = zrUtil.map(payload.batch, function (item) {
  895. item = zrUtil.defaults(zrUtil.extend({}, item), payload);
  896. item.batch = null;
  897. return item;
  898. });
  899. }
  900. var eventObjBatch = [];
  901. var eventObj;
  902. var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay';
  903. for (var i = 0; i < payloads.length; i++) {
  904. var batchItem = payloads[i];
  905. // Action can specify the event by return it.
  906. eventObj = actionWrap.action(batchItem, this._model);
  907. // Emit event outside
  908. eventObj = eventObj || zrUtil.extend({}, batchItem);
  909. // Convert type to eventType
  910. eventObj.type = actionInfo.event || eventObj.type;
  911. eventObjBatch.push(eventObj);
  912. // Highlight and downplay are special.
  913. isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem);
  914. }
  915. if (updateMethod !== 'none' && !isHighlightOrDownplay) {
  916. // Still dirty
  917. if (this[OPTION_UPDATED]) {
  918. // FIXME Pass payload ?
  919. updateMethods.prepareAndUpdate.call(this, payload);
  920. this[OPTION_UPDATED] = false;
  921. }
  922. else {
  923. updateMethods[updateMethod].call(this, payload);
  924. }
  925. }
  926. // Follow the rule of action batch
  927. if (batched) {
  928. eventObj = {
  929. type: actionInfo.event || payload.type,
  930. batch: eventObjBatch
  931. };
  932. }
  933. else {
  934. eventObj = eventObjBatch[0];
  935. }
  936. this[IN_MAIN_PROCESS] = false;
  937. !silent && this._messageCenter.trigger(eventObj.type, eventObj);
  938. }
  939. function flushPendingActions(silent) {
  940. var pendingActions = this._pendingActions;
  941. while (pendingActions.length) {
  942. var payload = pendingActions.shift();
  943. doDispatchAction.call(this, payload, silent);
  944. }
  945. }
  946. /**
  947. * Register event
  948. * @method
  949. */
  950. echartsProto.on = createRegisterEventWithLowercaseName('on');
  951. echartsProto.off = createRegisterEventWithLowercaseName('off');
  952. echartsProto.one = createRegisterEventWithLowercaseName('one');
  953. /**
  954. * @param {string} methodName
  955. * @private
  956. */
  957. function invokeUpdateMethod(methodName, ecModel, payload) {
  958. var api = this._api;
  959. // Update all components
  960. each(this._componentsViews, function (component) {
  961. var componentModel = component.__model;
  962. component[methodName](componentModel, ecModel, api, payload);
  963. updateZ(componentModel, component);
  964. }, this);
  965. // Upate all charts
  966. ecModel.eachSeries(function (seriesModel, idx) {
  967. var chart = this._chartsMap[seriesModel.__viewId];
  968. chart[methodName](seriesModel, ecModel, api, payload);
  969. updateZ(seriesModel, chart);
  970. updateProgressiveAndBlend(seriesModel, chart);
  971. }, this);
  972. // If use hover layer
  973. updateHoverLayerStatus(this._zr, ecModel);
  974. }
  975. /**
  976. * Prepare view instances of charts and components
  977. * @param {module:echarts/model/Global} ecModel
  978. * @private
  979. */
  980. function prepareView(type, ecModel) {
  981. var isComponent = type === 'component';
  982. var viewList = isComponent ? this._componentsViews : this._chartsViews;
  983. var viewMap = isComponent ? this._componentsMap : this._chartsMap;
  984. var zr = this._zr;
  985. for (var i = 0; i < viewList.length; i++) {
  986. viewList[i].__alive = false;
  987. }
  988. ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) {
  989. if (isComponent) {
  990. if (componentType === 'series') {
  991. return;
  992. }
  993. }
  994. else {
  995. model = componentType;
  996. }
  997. // Consider: id same and type changed.
  998. var viewId = model.id + '_' + model.type;
  999. var view = viewMap[viewId];
  1000. if (!view) {
  1001. var classType = ComponentModel.parseClassType(model.type);
  1002. var Clazz = isComponent
  1003. ? ComponentView.getClass(classType.main, classType.sub)
  1004. : ChartView.getClass(classType.sub);
  1005. if (Clazz) {
  1006. view = new Clazz();
  1007. view.init(ecModel, this._api);
  1008. viewMap[viewId] = view;
  1009. viewList.push(view);
  1010. zr.add(view.group);
  1011. }
  1012. else {
  1013. // Error
  1014. return;
  1015. }
  1016. }
  1017. model.__viewId = viewId;
  1018. view.__alive = true;
  1019. view.__id = viewId;
  1020. view.__model = model;
  1021. }, this);
  1022. for (var i = 0; i < viewList.length;) {
  1023. var view = viewList[i];
  1024. if (!view.__alive) {
  1025. zr.remove(view.group);
  1026. view.dispose(ecModel, this._api);
  1027. viewList.splice(i, 1);
  1028. delete viewMap[view.__id];
  1029. }
  1030. else {
  1031. i++;
  1032. }
  1033. }
  1034. }
  1035. /**
  1036. * Processor data in each series
  1037. *
  1038. * @param {module:echarts/model/Global} ecModel
  1039. * @private
  1040. */
  1041. function processData(ecModel, api) {
  1042. each(dataProcessorFuncs, function (process) {
  1043. process.func(ecModel, api);
  1044. });
  1045. }
  1046. /**
  1047. * @private
  1048. */
  1049. function stackSeriesData(ecModel) {
  1050. var stackedDataMap = {};
  1051. ecModel.eachSeries(function (series) {
  1052. var stack = series.get('stack');
  1053. var data = series.getData();
  1054. if (stack && data.type === 'list') {
  1055. var previousStack = stackedDataMap[stack];
  1056. if (previousStack) {
  1057. data.stackedOn = previousStack;
  1058. }
  1059. stackedDataMap[stack] = data;
  1060. }
  1061. });
  1062. }
  1063. /**
  1064. * Layout before each chart render there series, special visual encoding stage
  1065. *
  1066. * @param {module:echarts/model/Global} ecModel
  1067. * @private
  1068. */
  1069. function doLayout(ecModel, payload) {
  1070. var api = this._api;
  1071. each(visualFuncs, function (visual) {
  1072. if (visual.isLayout) {
  1073. visual.func(ecModel, api, payload);
  1074. }
  1075. });
  1076. }
  1077. /**
  1078. * Encode visual infomation from data after data processing
  1079. *
  1080. * @param {module:echarts/model/Global} ecModel
  1081. * @private
  1082. */
  1083. function doVisualEncoding(ecModel, payload) {
  1084. var api = this._api;
  1085. ecModel.clearColorPalette();
  1086. ecModel.eachSeries(function (seriesModel) {
  1087. seriesModel.clearColorPalette();
  1088. });
  1089. each(visualFuncs, function (visual) {
  1090. visual.func(ecModel, api, payload);
  1091. });
  1092. }
  1093. /**
  1094. * Render each chart and component
  1095. * @private
  1096. */
  1097. function doRender(ecModel, payload) {
  1098. var api = this._api;
  1099. // Render all components
  1100. each(this._componentsViews, function (componentView) {
  1101. var componentModel = componentView.__model;
  1102. componentView.render(componentModel, ecModel, api, payload);
  1103. updateZ(componentModel, componentView);
  1104. }, this);
  1105. each(this._chartsViews, function (chart) {
  1106. chart.__alive = false;
  1107. }, this);
  1108. // Render all charts
  1109. ecModel.eachSeries(function (seriesModel, idx) {
  1110. var chartView = this._chartsMap[seriesModel.__viewId];
  1111. chartView.__alive = true;
  1112. chartView.render(seriesModel, ecModel, api, payload);
  1113. chartView.group.silent = !!seriesModel.get('silent');
  1114. updateZ(seriesModel, chartView);
  1115. updateProgressiveAndBlend(seriesModel, chartView);
  1116. }, this);
  1117. // If use hover layer
  1118. updateHoverLayerStatus(this._zr, ecModel);
  1119. // Remove groups of unrendered charts
  1120. each(this._chartsViews, function (chart) {
  1121. if (!chart.__alive) {
  1122. chart.remove(ecModel, api);
  1123. }
  1124. }, this);
  1125. }
  1126. var MOUSE_EVENT_NAMES = [
  1127. 'click', 'dblclick', 'mouseover', 'mouseout', 'mousemove',
  1128. 'mousedown', 'mouseup', 'globalout', 'contextmenu'
  1129. ];
  1130. /**
  1131. * @private
  1132. */
  1133. echartsProto._initEvents = function () {
  1134. each(MOUSE_EVENT_NAMES, function (eveName) {
  1135. this._zr.on(eveName, function (e) {
  1136. var ecModel = this.getModel();
  1137. var el = e.target;
  1138. var params;
  1139. // no e.target when 'globalout'.
  1140. if (eveName === 'globalout') {
  1141. params = {};
  1142. }
  1143. else if (el && el.dataIndex != null) {
  1144. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  1145. params = dataModel && dataModel.getDataParams(el.dataIndex, el.dataType) || {};
  1146. }
  1147. // If element has custom eventData of components
  1148. else if (el && el.eventData) {
  1149. params = zrUtil.extend({}, el.eventData);
  1150. }
  1151. if (params) {
  1152. params.event = e;
  1153. params.type = eveName;
  1154. this.trigger(eveName, params);
  1155. }
  1156. }, this);
  1157. }, this);
  1158. each(eventActionMap, function (actionType, eventType) {
  1159. this._messageCenter.on(eventType, function (event) {
  1160. this.trigger(eventType, event);
  1161. }, this);
  1162. }, this);
  1163. };
  1164. /**
  1165. * @return {boolean}
  1166. */
  1167. echartsProto.isDisposed = function () {
  1168. return this._disposed;
  1169. };
  1170. /**
  1171. * Clear
  1172. */
  1173. echartsProto.clear = function () {
  1174. this.setOption({ series: [] }, true);
  1175. };
  1176. /**
  1177. * Dispose instance
  1178. */
  1179. echartsProto.dispose = function () {
  1180. if (this._disposed) {
  1181. if (true) {
  1182. console.warn('Instance ' + this.id + ' has been disposed');
  1183. }
  1184. return;
  1185. }
  1186. this._disposed = true;
  1187. var api = this._api;
  1188. var ecModel = this._model;
  1189. each(this._componentsViews, function (component) {
  1190. component.dispose(ecModel, api);
  1191. });
  1192. each(this._chartsViews, function (chart) {
  1193. chart.dispose(ecModel, api);
  1194. });
  1195. // Dispose after all views disposed
  1196. this._zr.dispose();
  1197. delete instances[this.id];
  1198. };
  1199. zrUtil.mixin(ECharts, Eventful);
  1200. function updateHoverLayerStatus(zr, ecModel) {
  1201. var storage = zr.storage;
  1202. var elCount = 0;
  1203. storage.traverse(function (el) {
  1204. if (!el.isGroup) {
  1205. elCount++;
  1206. }
  1207. });
  1208. if (elCount > ecModel.get('hoverLayerThreshold') && !env.node) {
  1209. storage.traverse(function (el) {
  1210. if (!el.isGroup) {
  1211. el.useHoverLayer = true;
  1212. }
  1213. });
  1214. }
  1215. }
  1216. /**
  1217. * Update chart progressive and blend.
  1218. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  1219. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  1220. */
  1221. function updateProgressiveAndBlend(seriesModel, chartView) {
  1222. // Progressive configuration
  1223. var elCount = 0;
  1224. chartView.group.traverse(function (el) {
  1225. if (el.type !== 'group' && !el.ignore) {
  1226. elCount++;
  1227. }
  1228. });
  1229. var frameDrawNum = +seriesModel.get('progressive');
  1230. var needProgressive = elCount > seriesModel.get('progressiveThreshold') && frameDrawNum && !env.node;
  1231. if (needProgressive) {
  1232. chartView.group.traverse(function (el) {
  1233. // FIXME marker and other components
  1234. if (!el.isGroup) {
  1235. el.progressive = needProgressive ?
  1236. Math.floor(elCount++ / frameDrawNum) : -1;
  1237. if (needProgressive) {
  1238. el.stopAnimation(true);
  1239. }
  1240. }
  1241. });
  1242. }
  1243. // Blend configration
  1244. var blendMode = seriesModel.get('blendMode') || null;
  1245. if (true) {
  1246. if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {
  1247. console.warn('Only canvas support blendMode');
  1248. }
  1249. }
  1250. chartView.group.traverse(function (el) {
  1251. // FIXME marker and other components
  1252. if (!el.isGroup) {
  1253. el.setStyle('blend', blendMode);
  1254. }
  1255. });
  1256. }
  1257. /**
  1258. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  1259. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  1260. */
  1261. function updateZ(model, view) {
  1262. var z = model.get('z');
  1263. var zlevel = model.get('zlevel');
  1264. // Set z and zlevel
  1265. view.group.traverse(function (el) {
  1266. if (el.type !== 'group') {
  1267. z != null && (el.z = z);
  1268. zlevel != null && (el.zlevel = zlevel);
  1269. }
  1270. });
  1271. }
  1272. /**
  1273. * @type {Array.<Function>}
  1274. * @inner
  1275. */
  1276. var actions = [];
  1277. /**
  1278. * Map eventType to actionType
  1279. * @type {Object}
  1280. */
  1281. var eventActionMap = {};
  1282. /**
  1283. * Data processor functions of each stage
  1284. * @type {Array.<Object.<string, Function>>}
  1285. * @inner
  1286. */
  1287. var dataProcessorFuncs = [];
  1288. /**
  1289. * @type {Array.<Function>}
  1290. * @inner
  1291. */
  1292. var optionPreprocessorFuncs = [];
  1293. /**
  1294. * Visual encoding functions of each stage
  1295. * @type {Array.<Object.<string, Function>>}
  1296. * @inner
  1297. */
  1298. var visualFuncs = [];
  1299. /**
  1300. * Theme storage
  1301. * @type {Object.<key, Object>}
  1302. */
  1303. var themeStorage = {};
  1304. /**
  1305. * Loading effects
  1306. */
  1307. var loadingEffects = {};
  1308. var instances = {};
  1309. var connectedGroups = {};
  1310. var idBase = new Date() - 0;
  1311. var groupIdBase = new Date() - 0;
  1312. var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
  1313. /**
  1314. * @alias module:echarts
  1315. */
  1316. var echarts = {
  1317. /**
  1318. * @type {number}
  1319. */
  1320. version: '3.3.2',
  1321. dependencies: {
  1322. zrender: '3.2.2'
  1323. }
  1324. };
  1325. function enableConnect(chart) {
  1326. var STATUS_PENDING = 0;
  1327. var STATUS_UPDATING = 1;
  1328. var STATUS_UPDATED = 2;
  1329. var STATUS_KEY = '__connectUpdateStatus';
  1330. function updateConnectedChartsStatus(charts, status) {
  1331. for (var i = 0; i < charts.length; i++) {
  1332. var otherChart = charts[i];
  1333. otherChart[STATUS_KEY] = status;
  1334. }
  1335. }
  1336. zrUtil.each(eventActionMap, function (actionType, eventType) {
  1337. chart._messageCenter.on(eventType, function (event) {
  1338. if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) {
  1339. var action = chart.makeActionFromEvent(event);
  1340. var otherCharts = [];
  1341. zrUtil.each(instances, function (otherChart) {
  1342. if (otherChart !== chart && otherChart.group === chart.group) {
  1343. otherCharts.push(otherChart);
  1344. }
  1345. });
  1346. updateConnectedChartsStatus(otherCharts, STATUS_PENDING);
  1347. each(otherCharts, function (otherChart) {
  1348. if (otherChart[STATUS_KEY] !== STATUS_UPDATING) {
  1349. otherChart.dispatchAction(action);
  1350. }
  1351. });
  1352. updateConnectedChartsStatus(otherCharts, STATUS_UPDATED);
  1353. }
  1354. });
  1355. });
  1356. }
  1357. /**
  1358. * @param {HTMLDomElement} dom
  1359. * @param {Object} [theme]
  1360. * @param {Object} opts
  1361. * @param {number} [opts.devicePixelRatio] Use window.devicePixelRatio by default
  1362. * @param {string} [opts.renderer] Currently only 'canvas' is supported.
  1363. * @param {number} [opts.width] Use clientWidth of the input `dom` by default.
  1364. * Can be 'auto' (the same as null/undefined)
  1365. * @param {number} [opts.height] Use clientHeight of the input `dom` by default.
  1366. * Can be 'auto' (the same as null/undefined)
  1367. */
  1368. echarts.init = function (dom, theme, opts) {
  1369. if (true) {
  1370. // Check version
  1371. if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) {
  1372. throw new Error(
  1373. 'ZRender ' + zrender.version
  1374. + ' is too old for ECharts ' + echarts.version
  1375. + '. Current version need ZRender '
  1376. + echarts.dependencies.zrender + '+'
  1377. );
  1378. }
  1379. if (!dom) {
  1380. throw new Error('Initialize failed: invalid dom.');
  1381. }
  1382. if (zrUtil.isDom(dom) && dom.nodeName.toUpperCase() !== 'CANVAS' && (!dom.clientWidth || !dom.clientHeight)) {
  1383. console.warn('Can\'t get dom width or height');
  1384. }
  1385. }
  1386. var chart = new ECharts(dom, theme, opts);
  1387. chart.id = 'ec_' + idBase++;
  1388. instances[chart.id] = chart;
  1389. dom.setAttribute &&
  1390. dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
  1391. enableConnect(chart);
  1392. return chart;
  1393. };
  1394. /**
  1395. * @return {string|Array.<module:echarts~ECharts>} groupId
  1396. */
  1397. echarts.connect = function (groupId) {
  1398. // Is array of charts
  1399. if (zrUtil.isArray(groupId)) {
  1400. var charts = groupId;
  1401. groupId = null;
  1402. // If any chart has group
  1403. zrUtil.each(charts, function (chart) {
  1404. if (chart.group != null) {
  1405. groupId = chart.group;
  1406. }
  1407. });
  1408. groupId = groupId || ('g_' + groupIdBase++);
  1409. zrUtil.each(charts, function (chart) {
  1410. chart.group = groupId;
  1411. });
  1412. }
  1413. connectedGroups[groupId] = true;
  1414. return groupId;
  1415. };
  1416. /**
  1417. * @return {string} groupId
  1418. */
  1419. echarts.disConnect = function (groupId) {
  1420. connectedGroups[groupId] = false;
  1421. };
  1422. /**
  1423. * Dispose a chart instance
  1424. * @param {module:echarts~ECharts|HTMLDomElement|string} chart
  1425. */
  1426. echarts.dispose = function (chart) {
  1427. if (zrUtil.isDom(chart)) {
  1428. chart = echarts.getInstanceByDom(chart);
  1429. }
  1430. else if (typeof chart === 'string') {
  1431. chart = instances[chart];
  1432. }
  1433. if ((chart instanceof ECharts) && !chart.isDisposed()) {
  1434. chart.dispose();
  1435. }
  1436. };
  1437. /**
  1438. * @param {HTMLDomElement} dom
  1439. * @return {echarts~ECharts}
  1440. */
  1441. echarts.getInstanceByDom = function (dom) {
  1442. var key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
  1443. return instances[key];
  1444. };
  1445. /**
  1446. * @param {string} key
  1447. * @return {echarts~ECharts}
  1448. */
  1449. echarts.getInstanceById = function (key) {
  1450. return instances[key];
  1451. };
  1452. /**
  1453. * Register theme
  1454. */
  1455. echarts.registerTheme = function (name, theme) {
  1456. themeStorage[name] = theme;
  1457. };
  1458. /**
  1459. * Register option preprocessor
  1460. * @param {Function} preprocessorFunc
  1461. */
  1462. echarts.registerPreprocessor = function (preprocessorFunc) {
  1463. optionPreprocessorFuncs.push(preprocessorFunc);
  1464. };
  1465. /**
  1466. * @param {number} [priority=1000]
  1467. * @param {Function} processorFunc
  1468. */
  1469. echarts.registerProcessor = function (priority, processorFunc) {
  1470. if (typeof priority === 'function') {
  1471. processorFunc = priority;
  1472. priority = PRIORITY_PROCESSOR_FILTER;
  1473. }
  1474. if (true) {
  1475. if (isNaN(priority)) {
  1476. throw new Error('Unkown processor priority');
  1477. }
  1478. }
  1479. dataProcessorFuncs.push({
  1480. prio: priority,
  1481. func: processorFunc
  1482. });
  1483. };
  1484. /**
  1485. * Usage:
  1486. * registerAction('someAction', 'someEvent', function () { ... });
  1487. * registerAction('someAction', function () { ... });
  1488. * registerAction(
  1489. * {type: 'someAction', event: 'someEvent', update: 'updateView'},
  1490. * function () { ... }
  1491. * );
  1492. *
  1493. * @param {(string|Object)} actionInfo
  1494. * @param {string} actionInfo.type
  1495. * @param {string} [actionInfo.event]
  1496. * @param {string} [actionInfo.update]
  1497. * @param {string} [eventName]
  1498. * @param {Function} action
  1499. */
  1500. echarts.registerAction = function (actionInfo, eventName, action) {
  1501. if (typeof eventName === 'function') {
  1502. action = eventName;
  1503. eventName = '';
  1504. }
  1505. var actionType = zrUtil.isObject(actionInfo)
  1506. ? actionInfo.type
  1507. : ([actionInfo, actionInfo = {
  1508. event: eventName
  1509. }][0]);
  1510. // Event name is all lowercase
  1511. actionInfo.event = (actionInfo.event || actionType).toLowerCase();
  1512. eventName = actionInfo.event;
  1513. if (!actions[actionType]) {
  1514. actions[actionType] = {action: action, actionInfo: actionInfo};
  1515. }
  1516. eventActionMap[eventName] = actionType;
  1517. };
  1518. /**
  1519. * @param {string} type
  1520. * @param {*} CoordinateSystem
  1521. */
  1522. echarts.registerCoordinateSystem = function (type, CoordinateSystem) {
  1523. CoordinateSystemManager.register(type, CoordinateSystem);
  1524. };
  1525. /**
  1526. * Layout is a special stage of visual encoding
  1527. * Most visual encoding like color are common for different chart
  1528. * But each chart has it's own layout algorithm
  1529. *
  1530. * @param {number} [priority=1000]
  1531. * @param {Function} layoutFunc
  1532. */
  1533. echarts.registerLayout = function (priority, layoutFunc) {
  1534. if (typeof priority === 'function') {
  1535. layoutFunc = priority;
  1536. priority = PRIORITY_VISUAL_LAYOUT;
  1537. }
  1538. if (true) {
  1539. if (isNaN(priority)) {
  1540. throw new Error('Unkown layout priority');
  1541. }
  1542. }
  1543. visualFuncs.push({
  1544. prio: priority,
  1545. func: layoutFunc,
  1546. isLayout: true
  1547. });
  1548. };
  1549. /**
  1550. * @param {number} [priority=3000]
  1551. * @param {Function} visualFunc
  1552. */
  1553. echarts.registerVisual = function (priority, visualFunc) {
  1554. if (typeof priority === 'function') {
  1555. visualFunc = priority;
  1556. priority = PRIORITY_VISUAL_CHART;
  1557. }
  1558. if (true) {
  1559. if (isNaN(priority)) {
  1560. throw new Error('Unkown visual priority');
  1561. }
  1562. }
  1563. visualFuncs.push({
  1564. prio: priority,
  1565. func: visualFunc
  1566. });
  1567. };
  1568. /**
  1569. * @param {string} name
  1570. */
  1571. echarts.registerLoading = function (name, loadingFx) {
  1572. loadingEffects[name] = loadingFx;
  1573. };
  1574. var parseClassType = ComponentModel.parseClassType;
  1575. /**
  1576. * @param {Object} opts
  1577. * @param {string} [superClass]
  1578. */
  1579. echarts.extendComponentModel = function (opts, superClass) {
  1580. var Clazz = ComponentModel;
  1581. if (superClass) {
  1582. var classType = parseClassType(superClass);
  1583. Clazz = ComponentModel.getClass(classType.main, classType.sub, true);
  1584. }
  1585. return Clazz.extend(opts);
  1586. };
  1587. /**
  1588. * @param {Object} opts
  1589. * @param {string} [superClass]
  1590. */
  1591. echarts.extendComponentView = function (opts, superClass) {
  1592. var Clazz = ComponentView;
  1593. if (superClass) {
  1594. var classType = parseClassType(superClass);
  1595. Clazz = ComponentView.getClass(classType.main, classType.sub, true);
  1596. }
  1597. return Clazz.extend(opts);
  1598. };
  1599. /**
  1600. * @param {Object} opts
  1601. * @param {string} [superClass]
  1602. */
  1603. echarts.extendSeriesModel = function (opts, superClass) {
  1604. var Clazz = SeriesModel;
  1605. if (superClass) {
  1606. superClass = 'series.' + superClass.replace('series.', '');
  1607. var classType = parseClassType(superClass);
  1608. Clazz = ComponentModel.getClass(classType.main, classType.sub, true);
  1609. }
  1610. return Clazz.extend(opts);
  1611. };
  1612. /**
  1613. * @param {Object} opts
  1614. * @param {string} [superClass]
  1615. */
  1616. echarts.extendChartView = function (opts, superClass) {
  1617. var Clazz = ChartView;
  1618. if (superClass) {
  1619. superClass.replace('series.', '');
  1620. var classType = parseClassType(superClass);
  1621. Clazz = ChartView.getClass(classType.main, true);
  1622. }
  1623. return Clazz.extend(opts);
  1624. };
  1625. /**
  1626. * ZRender need a canvas context to do measureText.
  1627. * But in node environment canvas may be created by node-canvas.
  1628. * So we need to specify how to create a canvas instead of using document.createElement('canvas')
  1629. *
  1630. * Be careful of using it in the browser.
  1631. *
  1632. * @param {Function} creator
  1633. * @example
  1634. * var Canvas = require('canvas');
  1635. * var echarts = require('echarts');
  1636. * echarts.setCanvasCreator(function () {
  1637. * // Small size is enough.
  1638. * return new Canvas(32, 32);
  1639. * });
  1640. */
  1641. echarts.setCanvasCreator = function (creator) {
  1642. zrUtil.createCanvas = creator;
  1643. };
  1644. echarts.registerVisual(PRIORITY_VISUAL_GLOBAL, __webpack_require__(94));
  1645. echarts.registerPreprocessor(__webpack_require__(95));
  1646. echarts.registerLoading('default', __webpack_require__(97));
  1647. // Default action
  1648. echarts.registerAction({
  1649. type: 'highlight',
  1650. event: 'highlight',
  1651. update: 'highlight'
  1652. }, zrUtil.noop);
  1653. echarts.registerAction({
  1654. type: 'downplay',
  1655. event: 'downplay',
  1656. update: 'downplay'
  1657. }, zrUtil.noop);
  1658. // --------
  1659. // Exports
  1660. // --------
  1661. //
  1662. echarts.List = __webpack_require__(98);
  1663. echarts.Model = __webpack_require__(12);
  1664. echarts.graphic = __webpack_require__(43);
  1665. echarts.number = __webpack_require__(7);
  1666. echarts.format = __webpack_require__(6);
  1667. echarts.matrix = __webpack_require__(11);
  1668. echarts.vector = __webpack_require__(10);
  1669. echarts.color = __webpack_require__(39);
  1670. echarts.util = {};
  1671. each([
  1672. 'map', 'each', 'filter', 'indexOf', 'inherits', 'reduce', 'filter',
  1673. 'bind', 'curry', 'isArray', 'isString', 'isObject', 'isFunction',
  1674. 'extend', 'defaults', 'clone'
  1675. ],
  1676. function (name) {
  1677. echarts.util[name] = zrUtil[name];
  1678. }
  1679. );
  1680. // PRIORITY
  1681. echarts.PRIORITY = {
  1682. PROCESSOR: {
  1683. FILTER: PRIORITY_PROCESSOR_FILTER,
  1684. STATISTIC: PRIORITY_PROCESSOR_STATISTIC
  1685. },
  1686. VISUAL: {
  1687. LAYOUT: PRIORITY_VISUAL_LAYOUT,
  1688. GLOBAL: PRIORITY_VISUAL_GLOBAL,
  1689. CHART: PRIORITY_VISUAL_CHART,
  1690. COMPONENT: PRIORITY_VISUAL_COMPONENT,
  1691. BRUSH: PRIORITY_VISUAL_BRUSH
  1692. }
  1693. };
  1694. module.exports = echarts;
  1695. /***/ },
  1696. /* 2 */
  1697. /***/ function(module, exports) {
  1698. /**
  1699. * echarts设备环境识别
  1700. *
  1701. * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
  1702. * @author firede[firede@firede.us]
  1703. * @desc thanks zepto.
  1704. */
  1705. var env = {};
  1706. if (typeof navigator === 'undefined') {
  1707. // In node
  1708. env = {
  1709. browser: {},
  1710. os: {},
  1711. node: true,
  1712. // Assume canvas is supported
  1713. canvasSupported: true
  1714. };
  1715. }
  1716. else {
  1717. env = detect(navigator.userAgent);
  1718. }
  1719. module.exports = env;
  1720. // Zepto.js
  1721. // (c) 2010-2013 Thomas Fuchs
  1722. // Zepto.js may be freely distributed under the MIT license.
  1723. function detect(ua) {
  1724. var os = {};
  1725. var browser = {};
  1726. // var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
  1727. // var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  1728. // var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  1729. // var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  1730. // var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  1731. // var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
  1732. // var touchpad = webos && ua.match(/TouchPad/);
  1733. // var kindle = ua.match(/Kindle\/([\d.]+)/);
  1734. // var silk = ua.match(/Silk\/([\d._]+)/);
  1735. // var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  1736. // var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  1737. // var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  1738. // var playbook = ua.match(/PlayBook/);
  1739. // var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  1740. var firefox = ua.match(/Firefox\/([\d.]+)/);
  1741. // var safari = webkit && ua.match(/Mobile\//) && !chrome;
  1742. // var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
  1743. var ie = ua.match(/MSIE\s([\d.]+)/)
  1744. // IE 11 Trident/7.0; rv:11.0
  1745. || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  1746. var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
  1747. var weChat = (/micromessenger/i).test(ua);
  1748. // Todo: clean this up with a better OS/browser seperation:
  1749. // - discern (more) between multiple browsers on android
  1750. // - decide if kindle fire in silk mode is android or not
  1751. // - Firefox on Android doesn't specify the Android version
  1752. // - possibly devide in os, device and browser hashes
  1753. // if (browser.webkit = !!webkit) browser.version = webkit[1];
  1754. // if (android) os.android = true, os.version = android[2];
  1755. // if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
  1756. // if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
  1757. // if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  1758. // if (webos) os.webos = true, os.version = webos[2];
  1759. // if (touchpad) os.touchpad = true;
  1760. // if (blackberry) os.blackberry = true, os.version = blackberry[2];
  1761. // if (bb10) os.bb10 = true, os.version = bb10[2];
  1762. // if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
  1763. // if (playbook) browser.playbook = true;
  1764. // if (kindle) os.kindle = true, os.version = kindle[1];
  1765. // if (silk) browser.silk = true, browser.version = silk[1];
  1766. // if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
  1767. // if (chrome) browser.chrome = true, browser.version = chrome[1];
  1768. if (firefox) {
  1769. browser.firefox = true;
  1770. browser.version = firefox[1];
  1771. }
  1772. // if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
  1773. // if (webview) browser.webview = true;
  1774. if (ie) {
  1775. browser.ie = true;
  1776. browser.version = ie[1];
  1777. }
  1778. if (edge) {
  1779. browser.edge = true;
  1780. browser.version = edge[1];
  1781. }
  1782. // It is difficult to detect WeChat in Win Phone precisely, because ua can
  1783. // not be set on win phone. So we do not consider Win Phone.
  1784. if (weChat) {
  1785. browser.weChat = true;
  1786. }
  1787. // os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
  1788. // (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
  1789. // os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos ||
  1790. // (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
  1791. // (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
  1792. return {
  1793. browser: browser,
  1794. os: os,
  1795. node: false,
  1796. // 原生canvas支持,改极端点了
  1797. // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
  1798. canvasSupported : document.createElement('canvas').getContext ? true : false,
  1799. // @see <http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript>
  1800. // works on most browsers
  1801. // IE10/11 does not support touch event, and MS Edge supports them but not by
  1802. // default, so we dont check navigator.maxTouchPoints for them here.
  1803. touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
  1804. // <http://caniuse.com/#search=pointer%20event>.
  1805. pointerEventsSupported: 'onpointerdown' in window
  1806. // Firefox supports pointer but not by default,
  1807. // only MS browsers are reliable on pointer events currently.
  1808. && (browser.edge || (browser.ie && browser.version >= 10))
  1809. };
  1810. }
  1811. /***/ },
  1812. /* 3 */
  1813. /***/ function(module, exports, __webpack_require__) {
  1814. /**
  1815. * ECharts global model
  1816. *
  1817. * @module {echarts/model/Global}
  1818. */
  1819. /**
  1820. * Caution: If the mechanism should be changed some day, these cases
  1821. * should be considered:
  1822. *
  1823. * (1) In `merge option` mode, if using the same option to call `setOption`
  1824. * many times, the result should be the same (try our best to ensure that).
  1825. * (2) In `merge option` mode, if a component has no id/name specified, it
  1826. * will be merged by index, and the result sequence of the components is
  1827. * consistent to the original sequence.
  1828. * (3) `reset` feature (in toolbox). Find detailed info in comments about
  1829. * `mergeOption` in module:echarts/model/OptionManager.
  1830. */
  1831. var zrUtil = __webpack_require__(4);
  1832. var modelUtil = __webpack_require__(5);
  1833. var Model = __webpack_require__(12);
  1834. var each = zrUtil.each;
  1835. var filter = zrUtil.filter;
  1836. var map = zrUtil.map;
  1837. var isArray = zrUtil.isArray;
  1838. var indexOf = zrUtil.indexOf;
  1839. var isObject = zrUtil.isObject;
  1840. var ComponentModel = __webpack_require__(19);
  1841. var globalDefault = __webpack_require__(23);
  1842. var OPTION_INNER_KEY = '\0_ec_inner';
  1843. /**
  1844. * @alias module:echarts/model/Global
  1845. *
  1846. * @param {Object} option
  1847. * @param {module:echarts/model/Model} parentModel
  1848. * @param {Object} theme
  1849. */
  1850. var GlobalModel = Model.extend({
  1851. constructor: GlobalModel,
  1852. init: function (option, parentModel, theme, optionManager) {
  1853. theme = theme || {};
  1854. this.option = null; // Mark as not initialized.
  1855. /**
  1856. * @type {module:echarts/model/Model}
  1857. * @private
  1858. */
  1859. this._theme = new Model(theme);
  1860. /**
  1861. * @type {module:echarts/model/OptionManager}
  1862. */
  1863. this._optionManager = optionManager;
  1864. },
  1865. setOption: function (option, optionPreprocessorFuncs) {
  1866. zrUtil.assert(
  1867. !(OPTION_INNER_KEY in option),
  1868. 'please use chart.getOption()'
  1869. );
  1870. this._optionManager.setOption(option, optionPreprocessorFuncs);
  1871. this.resetOption();
  1872. },
  1873. /**
  1874. * @param {string} type null/undefined: reset all.
  1875. * 'recreate': force recreate all.
  1876. * 'timeline': only reset timeline option
  1877. * 'media': only reset media query option
  1878. * @return {boolean} Whether option changed.
  1879. */
  1880. resetOption: function (type) {
  1881. var optionChanged = false;
  1882. var optionManager = this._optionManager;
  1883. if (!type || type === 'recreate') {
  1884. var baseOption = optionManager.mountOption(type === 'recreate');
  1885. if (!this.option || type === 'recreate') {
  1886. initBase.call(this, baseOption);
  1887. }
  1888. else {
  1889. this.restoreData();
  1890. this.mergeOption(baseOption);
  1891. }
  1892. optionChanged = true;
  1893. }
  1894. if (type === 'timeline' || type === 'media') {
  1895. this.restoreData();
  1896. }
  1897. if (!type || type === 'recreate' || type === 'timeline') {
  1898. var timelineOption = optionManager.getTimelineOption(this);
  1899. timelineOption && (this.mergeOption(timelineOption), optionChanged = true);
  1900. }
  1901. if (!type || type === 'recreate' || type === 'media') {
  1902. var mediaOptions = optionManager.getMediaOption(this, this._api);
  1903. if (mediaOptions.length) {
  1904. each(mediaOptions, function (mediaOption) {
  1905. this.mergeOption(mediaOption, optionChanged = true);
  1906. }, this);
  1907. }
  1908. }
  1909. return optionChanged;
  1910. },
  1911. /**
  1912. * @protected
  1913. */
  1914. mergeOption: function (newOption) {
  1915. var option = this.option;
  1916. var componentsMap = this._componentsMap;
  1917. var newCptTypes = [];
  1918. // 如果不存在对应的 component model 则直接 merge
  1919. each(newOption, function (componentOption, mainType) {
  1920. if (componentOption == null) {
  1921. return;
  1922. }
  1923. if (!ComponentModel.hasClass(mainType)) {
  1924. option[mainType] = option[mainType] == null
  1925. ? zrUtil.clone(componentOption)
  1926. : zrUtil.merge(option[mainType], componentOption, true);
  1927. }
  1928. else {
  1929. newCptTypes.push(mainType);
  1930. }
  1931. });
  1932. // FIXME OPTION 同步是否要改回原来的
  1933. ComponentModel.topologicalTravel(
  1934. newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this
  1935. );
  1936. this._seriesIndices = this._seriesIndices || [];
  1937. function visitComponent(mainType, dependencies) {
  1938. var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
  1939. var mapResult = modelUtil.mappingToExists(
  1940. componentsMap[mainType], newCptOptionList
  1941. );
  1942. modelUtil.makeIdAndName(mapResult);
  1943. // Set mainType and complete subType.
  1944. each(mapResult, function (item, index) {
  1945. var opt = item.option;
  1946. if (isObject(opt)) {
  1947. item.keyInfo.mainType = mainType;
  1948. item.keyInfo.subType = determineSubType(mainType, opt, item.exist);
  1949. }
  1950. });
  1951. var dependentModels = getComponentsByTypes(
  1952. componentsMap, dependencies
  1953. );
  1954. option[mainType] = [];
  1955. componentsMap[mainType] = [];
  1956. each(mapResult, function (resultItem, index) {
  1957. var componentModel = resultItem.exist;
  1958. var newCptOption = resultItem.option;
  1959. zrUtil.assert(
  1960. isObject(newCptOption) || componentModel,
  1961. 'Empty component definition'
  1962. );
  1963. // Consider where is no new option and should be merged using {},
  1964. // see removeEdgeAndAdd in topologicalTravel and
  1965. // ComponentModel.getAllClassMainTypes.
  1966. if (!newCptOption) {
  1967. componentModel.mergeOption({}, this);
  1968. componentModel.optionUpdated({}, false);
  1969. }
  1970. else {
  1971. var ComponentModelClass = ComponentModel.getClass(
  1972. mainType, resultItem.keyInfo.subType, true
  1973. );
  1974. if (componentModel && componentModel instanceof ComponentModelClass) {
  1975. componentModel.name = resultItem.keyInfo.name;
  1976. componentModel.mergeOption(newCptOption, this);
  1977. componentModel.optionUpdated(newCptOption, false);
  1978. }
  1979. else {
  1980. // PENDING Global as parent ?
  1981. var extraOpt = zrUtil.extend(
  1982. {
  1983. dependentModels: dependentModels,
  1984. componentIndex: index
  1985. },
  1986. resultItem.keyInfo
  1987. );
  1988. componentModel = new ComponentModelClass(
  1989. newCptOption, this, this, extraOpt
  1990. );
  1991. zrUtil.extend(componentModel, extraOpt);
  1992. componentModel.init(newCptOption, this, this, extraOpt);
  1993. // Call optionUpdated after init.
  1994. // newCptOption has been used as componentModel.option
  1995. // and may be merged with theme and default, so pass null
  1996. // to avoid confusion.
  1997. componentModel.optionUpdated(null, true);
  1998. }
  1999. }
  2000. componentsMap[mainType][index] = componentModel;
  2001. option[mainType][index] = componentModel.option;
  2002. }, this);
  2003. // Backup series for filtering.
  2004. if (mainType === 'series') {
  2005. this._seriesIndices = createSeriesIndices(componentsMap.series);
  2006. }
  2007. }
  2008. },
  2009. /**
  2010. * Get option for output (cloned option and inner info removed)
  2011. * @public
  2012. * @return {Object}
  2013. */
  2014. getOption: function () {
  2015. var option = zrUtil.clone(this.option);
  2016. each(option, function (opts, mainType) {
  2017. if (ComponentModel.hasClass(mainType)) {
  2018. var opts = modelUtil.normalizeToArray(opts);
  2019. for (var i = opts.length - 1; i >= 0; i--) {
  2020. // Remove options with inner id.
  2021. if (modelUtil.isIdInner(opts[i])) {
  2022. opts.splice(i, 1);
  2023. }
  2024. }
  2025. option[mainType] = opts;
  2026. }
  2027. });
  2028. delete option[OPTION_INNER_KEY];
  2029. return option;
  2030. },
  2031. /**
  2032. * @return {module:echarts/model/Model}
  2033. */
  2034. getTheme: function () {
  2035. return this._theme;
  2036. },
  2037. /**
  2038. * @param {string} mainType
  2039. * @param {number} [idx=0]
  2040. * @return {module:echarts/model/Component}
  2041. */
  2042. getComponent: function (mainType, idx) {
  2043. var list = this._componentsMap[mainType];
  2044. if (list) {
  2045. return list[idx || 0];
  2046. }
  2047. },
  2048. /**
  2049. * @param {Object} condition
  2050. * @param {string} condition.mainType
  2051. * @param {string} [condition.subType] If ignore, only query by mainType
  2052. * @param {number|Array.<number>} [condition.index] Either input index or id or name.
  2053. * @param {string|Array.<string>} [condition.id] Either input index or id or name.
  2054. * @param {string|Array.<string>} [condition.name] Either input index or id or name.
  2055. * @return {Array.<module:echarts/model/Component>}
  2056. */
  2057. queryComponents: function (condition) {
  2058. var mainType = condition.mainType;
  2059. if (!mainType) {
  2060. return [];
  2061. }
  2062. var index = condition.index;
  2063. var id = condition.id;
  2064. var name = condition.name;
  2065. var cpts = this._componentsMap[mainType];
  2066. if (!cpts || !cpts.length) {
  2067. return [];
  2068. }
  2069. var result;
  2070. if (index != null) {
  2071. if (!isArray(index)) {
  2072. index = [index];
  2073. }
  2074. result = filter(map(index, function (idx) {
  2075. return cpts[idx];
  2076. }), function (val) {
  2077. return !!val;
  2078. });
  2079. }
  2080. else if (id != null) {
  2081. var isIdArray = isArray(id);
  2082. result = filter(cpts, function (cpt) {
  2083. return (isIdArray && indexOf(id, cpt.id) >= 0)
  2084. || (!isIdArray && cpt.id === id);
  2085. });
  2086. }
  2087. else if (name != null) {
  2088. var isNameArray = isArray(name);
  2089. result = filter(cpts, function (cpt) {
  2090. return (isNameArray && indexOf(name, cpt.name) >= 0)
  2091. || (!isNameArray && cpt.name === name);
  2092. });
  2093. }
  2094. else {
  2095. // Return all components with mainType
  2096. result = cpts;
  2097. }
  2098. return filterBySubType(result, condition);
  2099. },
  2100. /**
  2101. * The interface is different from queryComponents,
  2102. * which is convenient for inner usage.
  2103. *
  2104. * @usage
  2105. * var result = findComponents(
  2106. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  2107. * );
  2108. * var result = findComponents(
  2109. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  2110. * );
  2111. * var result = findComponents(
  2112. * {mainType: 'series'},
  2113. * function (model, index) {...}
  2114. * );
  2115. * // result like [component0, componnet1, ...]
  2116. *
  2117. * @param {Object} condition
  2118. * @param {string} condition.mainType Mandatory.
  2119. * @param {string} [condition.subType] Optional.
  2120. * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName},
  2121. * where xxx is mainType.
  2122. * If query attribute is null/undefined or has no index/id/name,
  2123. * do not filtering by query conditions, which is convenient for
  2124. * no-payload situations or when target of action is global.
  2125. * @param {Function} [condition.filter] parameter: component, return boolean.
  2126. * @return {Array.<module:echarts/model/Component>}
  2127. */
  2128. findComponents: function (condition) {
  2129. var query = condition.query;
  2130. var mainType = condition.mainType;
  2131. var queryCond = getQueryCond(query);
  2132. var result = queryCond
  2133. ? this.queryComponents(queryCond)
  2134. : this._componentsMap[mainType];
  2135. return doFilter(filterBySubType(result, condition));
  2136. function getQueryCond(q) {
  2137. var indexAttr = mainType + 'Index';
  2138. var idAttr = mainType + 'Id';
  2139. var nameAttr = mainType + 'Name';
  2140. return q && (
  2141. q.hasOwnProperty(indexAttr)
  2142. || q.hasOwnProperty(idAttr)
  2143. || q.hasOwnProperty(nameAttr)
  2144. )
  2145. ? {
  2146. mainType: mainType,
  2147. // subType will be filtered finally.
  2148. index: q[indexAttr],
  2149. id: q[idAttr],
  2150. name: q[nameAttr]
  2151. }
  2152. : null;
  2153. }
  2154. function doFilter(res) {
  2155. return condition.filter
  2156. ? filter(res, condition.filter)
  2157. : res;
  2158. }
  2159. },
  2160. /**
  2161. * @usage
  2162. * eachComponent('legend', function (legendModel, index) {
  2163. * ...
  2164. * });
  2165. * eachComponent(function (componentType, model, index) {
  2166. * // componentType does not include subType
  2167. * // (componentType is 'xxx' but not 'xxx.aa')
  2168. * });
  2169. * eachComponent(
  2170. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
  2171. * function (model, index) {...}
  2172. * );
  2173. * eachComponent(
  2174. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
  2175. * function (model, index) {...}
  2176. * );
  2177. *
  2178. * @param {string|Object=} mainType When mainType is object, the definition
  2179. * is the same as the method 'findComponents'.
  2180. * @param {Function} cb
  2181. * @param {*} context
  2182. */
  2183. eachComponent: function (mainType, cb, context) {
  2184. var componentsMap = this._componentsMap;
  2185. if (typeof mainType === 'function') {
  2186. context = cb;
  2187. cb = mainType;
  2188. each(componentsMap, function (components, componentType) {
  2189. each(components, function (component, index) {
  2190. cb.call(context, componentType, component, index);
  2191. });
  2192. });
  2193. }
  2194. else if (zrUtil.isString(mainType)) {
  2195. each(componentsMap[mainType], cb, context);
  2196. }
  2197. else if (isObject(mainType)) {
  2198. var queryResult = this.findComponents(mainType);
  2199. each(queryResult, cb, context);
  2200. }
  2201. },
  2202. /**
  2203. * @param {string} name
  2204. * @return {Array.<module:echarts/model/Series>}
  2205. */
  2206. getSeriesByName: function (name) {
  2207. var series = this._componentsMap.series;
  2208. return filter(series, function (oneSeries) {
  2209. return oneSeries.name === name;
  2210. });
  2211. },
  2212. /**
  2213. * @param {number} seriesIndex
  2214. * @return {module:echarts/model/Series}
  2215. */
  2216. getSeriesByIndex: function (seriesIndex) {
  2217. return this._componentsMap.series[seriesIndex];
  2218. },
  2219. /**
  2220. * @param {string} subType
  2221. * @return {Array.<module:echarts/model/Series>}
  2222. */
  2223. getSeriesByType: function (subType) {
  2224. var series = this._componentsMap.series;
  2225. return filter(series, function (oneSeries) {
  2226. return oneSeries.subType === subType;
  2227. });
  2228. },
  2229. /**
  2230. * @return {Array.<module:echarts/model/Series>}
  2231. */
  2232. getSeries: function () {
  2233. return this._componentsMap.series.slice();
  2234. },
  2235. /**
  2236. * After filtering, series may be different
  2237. * frome raw series.
  2238. *
  2239. * @param {Function} cb
  2240. * @param {*} context
  2241. */
  2242. eachSeries: function (cb, context) {
  2243. assertSeriesInitialized(this);
  2244. each(this._seriesIndices, function (rawSeriesIndex) {
  2245. var series = this._componentsMap.series[rawSeriesIndex];
  2246. cb.call(context, series, rawSeriesIndex);
  2247. }, this);
  2248. },
  2249. /**
  2250. * Iterate raw series before filtered.
  2251. *
  2252. * @param {Function} cb
  2253. * @param {*} context
  2254. */
  2255. eachRawSeries: function (cb, context) {
  2256. each(this._componentsMap.series, cb, context);
  2257. },
  2258. /**
  2259. * After filtering, series may be different.
  2260. * frome raw series.
  2261. *
  2262. * @parma {string} subType
  2263. * @param {Function} cb
  2264. * @param {*} context
  2265. */
  2266. eachSeriesByType: function (subType, cb, context) {
  2267. assertSeriesInitialized(this);
  2268. each(this._seriesIndices, function (rawSeriesIndex) {
  2269. var series = this._componentsMap.series[rawSeriesIndex];
  2270. if (series.subType === subType) {
  2271. cb.call(context, series, rawSeriesIndex);
  2272. }
  2273. }, this);
  2274. },
  2275. /**
  2276. * Iterate raw series before filtered of given type.
  2277. *
  2278. * @parma {string} subType
  2279. * @param {Function} cb
  2280. * @param {*} context
  2281. */
  2282. eachRawSeriesByType: function (subType, cb, context) {
  2283. return each(this.getSeriesByType(subType), cb, context);
  2284. },
  2285. /**
  2286. * @param {module:echarts/model/Series} seriesModel
  2287. */
  2288. isSeriesFiltered: function (seriesModel) {
  2289. assertSeriesInitialized(this);
  2290. return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
  2291. },
  2292. /**
  2293. * @param {Function} cb
  2294. * @param {*} context
  2295. */
  2296. filterSeries: function (cb, context) {
  2297. assertSeriesInitialized(this);
  2298. var filteredSeries = filter(
  2299. this._componentsMap.series, cb, context
  2300. );
  2301. this._seriesIndices = createSeriesIndices(filteredSeries);
  2302. },
  2303. restoreData: function () {
  2304. var componentsMap = this._componentsMap;
  2305. this._seriesIndices = createSeriesIndices(componentsMap.series);
  2306. var componentTypes = [];
  2307. each(componentsMap, function (components, componentType) {
  2308. componentTypes.push(componentType);
  2309. });
  2310. ComponentModel.topologicalTravel(
  2311. componentTypes,
  2312. ComponentModel.getAllClassMainTypes(),
  2313. function (componentType, dependencies) {
  2314. each(componentsMap[componentType], function (component) {
  2315. component.restoreData();
  2316. });
  2317. }
  2318. );
  2319. }
  2320. });
  2321. /**
  2322. * @inner
  2323. */
  2324. function mergeTheme(option, theme) {
  2325. zrUtil.each(theme, function (themeItem, name) {
  2326. // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理
  2327. if (!ComponentModel.hasClass(name)) {
  2328. if (typeof themeItem === 'object') {
  2329. option[name] = !option[name]
  2330. ? zrUtil.clone(themeItem)
  2331. : zrUtil.merge(option[name], themeItem, false);
  2332. }
  2333. else {
  2334. if (option[name] == null) {
  2335. option[name] = themeItem;
  2336. }
  2337. }
  2338. }
  2339. });
  2340. }
  2341. function initBase(baseOption) {
  2342. baseOption = baseOption;
  2343. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  2344. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  2345. this.option = {};
  2346. this.option[OPTION_INNER_KEY] = 1;
  2347. /**
  2348. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  2349. * @private
  2350. */
  2351. this._componentsMap = {};
  2352. /**
  2353. * Mapping between filtered series list and raw series list.
  2354. * key: filtered series indices, value: raw series indices.
  2355. * @type {Array.<nubmer>}
  2356. * @private
  2357. */
  2358. this._seriesIndices = null;
  2359. mergeTheme(baseOption, this._theme.option);
  2360. // TODO Needs clone when merging to the unexisted property
  2361. zrUtil.merge(baseOption, globalDefault, false);
  2362. this.mergeOption(baseOption);
  2363. }
  2364. /**
  2365. * @inner
  2366. * @param {Array.<string>|string} types model types
  2367. * @return {Object} key: {string} type, value: {Array.<Object>} models
  2368. */
  2369. function getComponentsByTypes(componentsMap, types) {
  2370. if (!zrUtil.isArray(types)) {
  2371. types = types ? [types] : [];
  2372. }
  2373. var ret = {};
  2374. each(types, function (type) {
  2375. ret[type] = (componentsMap[type] || []).slice();
  2376. });
  2377. return ret;
  2378. }
  2379. /**
  2380. * @inner
  2381. */
  2382. function determineSubType(mainType, newCptOption, existComponent) {
  2383. var subType = newCptOption.type
  2384. ? newCptOption.type
  2385. : existComponent
  2386. ? existComponent.subType
  2387. // Use determineSubType only when there is no existComponent.
  2388. : ComponentModel.determineSubType(mainType, newCptOption);
  2389. // tooltip, markline, markpoint may always has no subType
  2390. return subType;
  2391. }
  2392. /**
  2393. * @inner
  2394. */
  2395. function createSeriesIndices(seriesModels) {
  2396. return map(seriesModels, function (series) {
  2397. return series.componentIndex;
  2398. }) || [];
  2399. }
  2400. /**
  2401. * @inner
  2402. */
  2403. function filterBySubType(components, condition) {
  2404. // Using hasOwnProperty for restrict. Consider
  2405. // subType is undefined in user payload.
  2406. return condition.hasOwnProperty('subType')
  2407. ? filter(components, function (cpt) {
  2408. return cpt.subType === condition.subType;
  2409. })
  2410. : components;
  2411. }
  2412. /**
  2413. * @inner
  2414. */
  2415. function assertSeriesInitialized(ecModel) {
  2416. // Components that use _seriesIndices should depends on series component,
  2417. // which make sure that their initialization is after series.
  2418. if (true) {
  2419. if (!ecModel._seriesIndices) {
  2420. throw new Error('Series has not been initialized yet.');
  2421. }
  2422. }
  2423. }
  2424. zrUtil.mixin(GlobalModel, __webpack_require__(24));
  2425. module.exports = GlobalModel;
  2426. /***/ },
  2427. /* 4 */
  2428. /***/ function(module, exports) {
  2429. /**
  2430. * @module zrender/core/util
  2431. */
  2432. // 用于处理merge时无法遍历Date等对象的问题
  2433. var BUILTIN_OBJECT = {
  2434. '[object Function]': 1,
  2435. '[object RegExp]': 1,
  2436. '[object Date]': 1,
  2437. '[object Error]': 1,
  2438. '[object CanvasGradient]': 1,
  2439. '[object CanvasPattern]': 1,
  2440. // For node-canvas
  2441. '[object Image]': 1,
  2442. '[object Canvas]': 1
  2443. };
  2444. var TYPED_ARRAY = {
  2445. '[object Int8Array]': 1,
  2446. '[object Uint8Array]': 1,
  2447. '[object Uint8ClampedArray]': 1,
  2448. '[object Int16Array]': 1,
  2449. '[object Uint16Array]': 1,
  2450. '[object Int32Array]': 1,
  2451. '[object Uint32Array]': 1,
  2452. '[object Float32Array]': 1,
  2453. '[object Float64Array]': 1
  2454. };
  2455. var objToString = Object.prototype.toString;
  2456. var arrayProto = Array.prototype;
  2457. var nativeForEach = arrayProto.forEach;
  2458. var nativeFilter = arrayProto.filter;
  2459. var nativeSlice = arrayProto.slice;
  2460. var nativeMap = arrayProto.map;
  2461. var nativeReduce = arrayProto.reduce;
  2462. /**
  2463. * Those data types can be cloned:
  2464. * Plain object, Array, TypedArray, number, string, null, undefined.
  2465. * Those data types will be assgined using the orginal data:
  2466. * BUILTIN_OBJECT
  2467. * Instance of user defined class will be cloned to a plain object, without
  2468. * properties in prototype.
  2469. * Other data types is not supported (not sure what will happen).
  2470. *
  2471. * Caution: do not support clone Date, for performance consideration.
  2472. * (There might be a large number of date in `series.data`).
  2473. * So date should not be modified in and out of echarts.
  2474. *
  2475. * @param {*} source
  2476. * @return {*} new
  2477. */
  2478. function clone(source) {
  2479. if (source == null || typeof source != 'object') {
  2480. return source;
  2481. }
  2482. var result = source;
  2483. var typeStr = objToString.call(source);
  2484. if (typeStr === '[object Array]') {
  2485. result = [];
  2486. for (var i = 0, len = source.length; i < len; i++) {
  2487. result[i] = clone(source[i]);
  2488. }
  2489. }
  2490. else if (TYPED_ARRAY[typeStr]) {
  2491. result = source.constructor.from(source);
  2492. }
  2493. else if (!BUILTIN_OBJECT[typeStr] && !isDom(source)) {
  2494. result = {};
  2495. for (var key in source) {
  2496. if (source.hasOwnProperty(key)) {
  2497. result[key] = clone(source[key]);
  2498. }
  2499. }
  2500. }
  2501. return result;
  2502. }
  2503. /**
  2504. * @memberOf module:zrender/core/util
  2505. * @param {*} target
  2506. * @param {*} source
  2507. * @param {boolean} [overwrite=false]
  2508. */
  2509. function merge(target, source, overwrite) {
  2510. // We should escapse that source is string
  2511. // and enter for ... in ...
  2512. if (!isObject(source) || !isObject(target)) {
  2513. return overwrite ? clone(source) : target;
  2514. }
  2515. for (var key in source) {
  2516. if (source.hasOwnProperty(key)) {
  2517. var targetProp = target[key];
  2518. var sourceProp = source[key];
  2519. if (isObject(sourceProp)
  2520. && isObject(targetProp)
  2521. && !isArray(sourceProp)
  2522. && !isArray(targetProp)
  2523. && !isDom(sourceProp)
  2524. && !isDom(targetProp)
  2525. && !isBuildInObject(sourceProp)
  2526. && !isBuildInObject(targetProp)
  2527. ) {
  2528. // 如果需要递归覆盖,就递归调用merge
  2529. merge(targetProp, sourceProp, overwrite);
  2530. }
  2531. else if (overwrite || !(key in target)) {
  2532. // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
  2533. // NOTE,在 target[key] 不存在的时候也是直接覆盖
  2534. target[key] = clone(source[key], true);
  2535. }
  2536. }
  2537. }
  2538. return target;
  2539. }
  2540. /**
  2541. * @param {Array} targetAndSources The first item is target, and the rests are source.
  2542. * @param {boolean} [overwrite=false]
  2543. * @return {*} target
  2544. */
  2545. function mergeAll(targetAndSources, overwrite) {
  2546. var result = targetAndSources[0];
  2547. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  2548. result = merge(result, targetAndSources[i], overwrite);
  2549. }
  2550. return result;
  2551. }
  2552. /**
  2553. * @param {*} target
  2554. * @param {*} source
  2555. * @memberOf module:zrender/core/util
  2556. */
  2557. function extend(target, source) {
  2558. for (var key in source) {
  2559. if (source.hasOwnProperty(key)) {
  2560. target[key] = source[key];
  2561. }
  2562. }
  2563. return target;
  2564. }
  2565. /**
  2566. * @param {*} target
  2567. * @param {*} source
  2568. * @param {boolen} [overlay=false]
  2569. * @memberOf module:zrender/core/util
  2570. */
  2571. function defaults(target, source, overlay) {
  2572. for (var key in source) {
  2573. if (source.hasOwnProperty(key)
  2574. && (overlay ? source[key] != null : target[key] == null)
  2575. ) {
  2576. target[key] = source[key];
  2577. }
  2578. }
  2579. return target;
  2580. }
  2581. function createCanvas() {
  2582. return document.createElement('canvas');
  2583. }
  2584. // FIXME
  2585. var _ctx;
  2586. function getContext() {
  2587. if (!_ctx) {
  2588. // Use util.createCanvas instead of createCanvas
  2589. // because createCanvas may be overwritten in different environment
  2590. _ctx = util.createCanvas().getContext('2d');
  2591. }
  2592. return _ctx;
  2593. }
  2594. /**
  2595. * 查询数组中元素的index
  2596. * @memberOf module:zrender/core/util
  2597. */
  2598. function indexOf(array, value) {
  2599. if (array) {
  2600. if (array.indexOf) {
  2601. return array.indexOf(value);
  2602. }
  2603. for (var i = 0, len = array.length; i < len; i++) {
  2604. if (array[i] === value) {
  2605. return i;
  2606. }
  2607. }
  2608. }
  2609. return -1;
  2610. }
  2611. /**
  2612. * 构造类继承关系
  2613. *
  2614. * @memberOf module:zrender/core/util
  2615. * @param {Function} clazz 源类
  2616. * @param {Function} baseClazz 基类
  2617. */
  2618. function inherits(clazz, baseClazz) {
  2619. var clazzPrototype = clazz.prototype;
  2620. function F() {}
  2621. F.prototype = baseClazz.prototype;
  2622. clazz.prototype = new F();
  2623. for (var prop in clazzPrototype) {
  2624. clazz.prototype[prop] = clazzPrototype[prop];
  2625. }
  2626. clazz.prototype.constructor = clazz;
  2627. clazz.superClass = baseClazz;
  2628. }
  2629. /**
  2630. * @memberOf module:zrender/core/util
  2631. * @param {Object|Function} target
  2632. * @param {Object|Function} sorce
  2633. * @param {boolean} overlay
  2634. */
  2635. function mixin(target, source, overlay) {
  2636. target = 'prototype' in target ? target.prototype : target;
  2637. source = 'prototype' in source ? source.prototype : source;
  2638. defaults(target, source, overlay);
  2639. }
  2640. /**
  2641. * @param {Array|TypedArray} data
  2642. */
  2643. function isArrayLike(data) {
  2644. if (! data) {
  2645. return;
  2646. }
  2647. if (typeof data == 'string') {
  2648. return false;
  2649. }
  2650. return typeof data.length == 'number';
  2651. }
  2652. /**
  2653. * 数组或对象遍历
  2654. * @memberOf module:zrender/core/util
  2655. * @param {Object|Array} obj
  2656. * @param {Function} cb
  2657. * @param {*} [context]
  2658. */
  2659. function each(obj, cb, context) {
  2660. if (!(obj && cb)) {
  2661. return;
  2662. }
  2663. if (obj.forEach && obj.forEach === nativeForEach) {
  2664. obj.forEach(cb, context);
  2665. }
  2666. else if (obj.length === +obj.length) {
  2667. for (var i = 0, len = obj.length; i < len; i++) {
  2668. cb.call(context, obj[i], i, obj);
  2669. }
  2670. }
  2671. else {
  2672. for (var key in obj) {
  2673. if (obj.hasOwnProperty(key)) {
  2674. cb.call(context, obj[key], key, obj);
  2675. }
  2676. }
  2677. }
  2678. }
  2679. /**
  2680. * 数组映射
  2681. * @memberOf module:zrender/core/util
  2682. * @param {Array} obj
  2683. * @param {Function} cb
  2684. * @param {*} [context]
  2685. * @return {Array}
  2686. */
  2687. function map(obj, cb, context) {
  2688. if (!(obj && cb)) {
  2689. return;
  2690. }
  2691. if (obj.map && obj.map === nativeMap) {
  2692. return obj.map(cb, context);
  2693. }
  2694. else {
  2695. var result = [];
  2696. for (var i = 0, len = obj.length; i < len; i++) {
  2697. result.push(cb.call(context, obj[i], i, obj));
  2698. }
  2699. return result;
  2700. }
  2701. }
  2702. /**
  2703. * @memberOf module:zrender/core/util
  2704. * @param {Array} obj
  2705. * @param {Function} cb
  2706. * @param {Object} [memo]
  2707. * @param {*} [context]
  2708. * @return {Array}
  2709. */
  2710. function reduce(obj, cb, memo, context) {
  2711. if (!(obj && cb)) {
  2712. return;
  2713. }
  2714. if (obj.reduce && obj.reduce === nativeReduce) {
  2715. return obj.reduce(cb, memo, context);
  2716. }
  2717. else {
  2718. for (var i = 0, len = obj.length; i < len; i++) {
  2719. memo = cb.call(context, memo, obj[i], i, obj);
  2720. }
  2721. return memo;
  2722. }
  2723. }
  2724. /**
  2725. * 数组过滤
  2726. * @memberOf module:zrender/core/util
  2727. * @param {Array} obj
  2728. * @param {Function} cb
  2729. * @param {*} [context]
  2730. * @return {Array}
  2731. */
  2732. function filter(obj, cb, context) {
  2733. if (!(obj && cb)) {
  2734. return;
  2735. }
  2736. if (obj.filter && obj.filter === nativeFilter) {
  2737. return obj.filter(cb, context);
  2738. }
  2739. else {
  2740. var result = [];
  2741. for (var i = 0, len = obj.length; i < len; i++) {
  2742. if (cb.call(context, obj[i], i, obj)) {
  2743. result.push(obj[i]);
  2744. }
  2745. }
  2746. return result;
  2747. }
  2748. }
  2749. /**
  2750. * 数组项查找
  2751. * @memberOf module:zrender/core/util
  2752. * @param {Array} obj
  2753. * @param {Function} cb
  2754. * @param {*} [context]
  2755. * @return {Array}
  2756. */
  2757. function find(obj, cb, context) {
  2758. if (!(obj && cb)) {
  2759. return;
  2760. }
  2761. for (var i = 0, len = obj.length; i < len; i++) {
  2762. if (cb.call(context, obj[i], i, obj)) {
  2763. return obj[i];
  2764. }
  2765. }
  2766. }
  2767. /**
  2768. * @memberOf module:zrender/core/util
  2769. * @param {Function} func
  2770. * @param {*} context
  2771. * @return {Function}
  2772. */
  2773. function bind(func, context) {
  2774. var args = nativeSlice.call(arguments, 2);
  2775. return function () {
  2776. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  2777. };
  2778. }
  2779. /**
  2780. * @memberOf module:zrender/core/util
  2781. * @param {Function} func
  2782. * @return {Function}
  2783. */
  2784. function curry(func) {
  2785. var args = nativeSlice.call(arguments, 1);
  2786. return function () {
  2787. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  2788. };
  2789. }
  2790. /**
  2791. * @memberOf module:zrender/core/util
  2792. * @param {*} value
  2793. * @return {boolean}
  2794. */
  2795. function isArray(value) {
  2796. return objToString.call(value) === '[object Array]';
  2797. }
  2798. /**
  2799. * @memberOf module:zrender/core/util
  2800. * @param {*} value
  2801. * @return {boolean}
  2802. */
  2803. function isFunction(value) {
  2804. return typeof value === 'function';
  2805. }
  2806. /**
  2807. * @memberOf module:zrender/core/util
  2808. * @param {*} value
  2809. * @return {boolean}
  2810. */
  2811. function isString(value) {
  2812. return objToString.call(value) === '[object String]';
  2813. }
  2814. /**
  2815. * @memberOf module:zrender/core/util
  2816. * @param {*} value
  2817. * @return {boolean}
  2818. */
  2819. function isObject(value) {
  2820. // Avoid a V8 JIT bug in Chrome 19-20.
  2821. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  2822. var type = typeof value;
  2823. return type === 'function' || (!!value && type == 'object');
  2824. }
  2825. /**
  2826. * @memberOf module:zrender/core/util
  2827. * @param {*} value
  2828. * @return {boolean}
  2829. */
  2830. function isBuildInObject(value) {
  2831. return !!BUILTIN_OBJECT[objToString.call(value)];
  2832. }
  2833. /**
  2834. * @memberOf module:zrender/core/util
  2835. * @param {*} value
  2836. * @return {boolean}
  2837. */
  2838. function isDom(value) {
  2839. return typeof value === 'object'
  2840. && typeof value.nodeType === 'number'
  2841. && typeof value.ownerDocument === 'object';
  2842. }
  2843. /**
  2844. * If value1 is not null, then return value1, otherwise judget rest of values.
  2845. * @memberOf module:zrender/core/util
  2846. * @return {*} Final value
  2847. */
  2848. function retrieve(values) {
  2849. for (var i = 0, len = arguments.length; i < len; i++) {
  2850. if (arguments[i] != null) {
  2851. return arguments[i];
  2852. }
  2853. }
  2854. }
  2855. /**
  2856. * @memberOf module:zrender/core/util
  2857. * @param {Array} arr
  2858. * @param {number} startIndex
  2859. * @param {number} endIndex
  2860. * @return {Array}
  2861. */
  2862. function slice() {
  2863. return Function.call.apply(nativeSlice, arguments);
  2864. }
  2865. /**
  2866. * @memberOf module:zrender/core/util
  2867. * @param {boolean} condition
  2868. * @param {string} message
  2869. */
  2870. function assert(condition, message) {
  2871. if (!condition) {
  2872. throw new Error(message);
  2873. }
  2874. }
  2875. var util = {
  2876. inherits: inherits,
  2877. mixin: mixin,
  2878. clone: clone,
  2879. merge: merge,
  2880. mergeAll: mergeAll,
  2881. extend: extend,
  2882. defaults: defaults,
  2883. getContext: getContext,
  2884. createCanvas: createCanvas,
  2885. indexOf: indexOf,
  2886. slice: slice,
  2887. find: find,
  2888. isArrayLike: isArrayLike,
  2889. each: each,
  2890. map: map,
  2891. reduce: reduce,
  2892. filter: filter,
  2893. bind: bind,
  2894. curry: curry,
  2895. isArray: isArray,
  2896. isString: isString,
  2897. isObject: isObject,
  2898. isFunction: isFunction,
  2899. isBuildInObject: isBuildInObject,
  2900. isDom: isDom,
  2901. retrieve: retrieve,
  2902. assert: assert,
  2903. noop: function () {}
  2904. };
  2905. module.exports = util;
  2906. /***/ },
  2907. /* 5 */
  2908. /***/ function(module, exports, __webpack_require__) {
  2909. var formatUtil = __webpack_require__(6);
  2910. var nubmerUtil = __webpack_require__(7);
  2911. var Model = __webpack_require__(12);
  2912. var zrUtil = __webpack_require__(4);
  2913. var each = zrUtil.each;
  2914. var isObject = zrUtil.isObject;
  2915. var modelUtil = {};
  2916. /**
  2917. * If value is not array, then translate it to array.
  2918. * @param {*} value
  2919. * @return {Array} [value] or value
  2920. */
  2921. modelUtil.normalizeToArray = function (value) {
  2922. return value instanceof Array
  2923. ? value
  2924. : value == null
  2925. ? []
  2926. : [value];
  2927. };
  2928. /**
  2929. * Sync default option between normal and emphasis like `position` and `show`
  2930. * In case some one will write code like
  2931. * label: {
  2932. * normal: {
  2933. * show: false,
  2934. * position: 'outside',
  2935. * textStyle: {
  2936. * fontSize: 18
  2937. * }
  2938. * },
  2939. * emphasis: {
  2940. * show: true
  2941. * }
  2942. * }
  2943. * @param {Object} opt
  2944. * @param {Array.<string>} subOpts
  2945. */
  2946. modelUtil.defaultEmphasis = function (opt, subOpts) {
  2947. if (opt) {
  2948. var emphasisOpt = opt.emphasis = opt.emphasis || {};
  2949. var normalOpt = opt.normal = opt.normal || {};
  2950. // Default emphasis option from normal
  2951. each(subOpts, function (subOptName) {
  2952. var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]);
  2953. if (val != null) {
  2954. emphasisOpt[subOptName] = val;
  2955. }
  2956. });
  2957. }
  2958. };
  2959. modelUtil.LABEL_OPTIONS = ['position', 'show', 'textStyle', 'distance', 'formatter'];
  2960. /**
  2961. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  2962. * This helper method retieves value from data.
  2963. * @param {string|number|Date|Array|Object} dataItem
  2964. * @return {number|string|Date|Array.<number|string|Date>}
  2965. */
  2966. modelUtil.getDataItemValue = function (dataItem) {
  2967. // Performance sensitive.
  2968. return dataItem && (dataItem.value == null ? dataItem : dataItem.value);
  2969. };
  2970. /**
  2971. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  2972. * This helper method determine if dataItem has extra option besides value
  2973. * @param {string|number|Date|Array|Object} dataItem
  2974. */
  2975. modelUtil.isDataItemOption = function (dataItem) {
  2976. return isObject(dataItem)
  2977. && !(dataItem instanceof Array);
  2978. // // markLine data can be array
  2979. // && !(dataItem[0] && isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
  2980. };
  2981. /**
  2982. * This helper method convert value in data.
  2983. * @param {string|number|Date} value
  2984. * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'.
  2985. */
  2986. modelUtil.converDataValue = function (value, dimInfo) {
  2987. // Performance sensitive.
  2988. var dimType = dimInfo && dimInfo.type;
  2989. if (dimType === 'ordinal') {
  2990. return value;
  2991. }
  2992. if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') {
  2993. value = +nubmerUtil.parseDate(value);
  2994. }
  2995. // dimType defaults 'number'.
  2996. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  2997. // parse to NaN.
  2998. return (value == null || value === '')
  2999. ? NaN : +value; // If string (like '-'), using '+' parse to NaN
  3000. };
  3001. /**
  3002. * Create a model proxy to be used in tooltip for edge data, markLine data, markPoint data.
  3003. * @param {module:echarts/data/List} data
  3004. * @param {Object} opt
  3005. * @param {string} [opt.seriesIndex]
  3006. * @param {Object} [opt.name]
  3007. * @param {Object} [opt.mainType]
  3008. * @param {Object} [opt.subType]
  3009. */
  3010. modelUtil.createDataFormatModel = function (data, opt) {
  3011. var model = new Model();
  3012. zrUtil.mixin(model, modelUtil.dataFormatMixin);
  3013. model.seriesIndex = opt.seriesIndex;
  3014. model.name = opt.name || '';
  3015. model.mainType = opt.mainType;
  3016. model.subType = opt.subType;
  3017. model.getData = function () {
  3018. return data;
  3019. };
  3020. return model;
  3021. };
  3022. // PENDING A little ugly
  3023. modelUtil.dataFormatMixin = {
  3024. /**
  3025. * Get params for formatter
  3026. * @param {number} dataIndex
  3027. * @param {string} [dataType]
  3028. * @return {Object}
  3029. */
  3030. getDataParams: function (dataIndex, dataType) {
  3031. var data = this.getData(dataType);
  3032. var seriesIndex = this.seriesIndex;
  3033. var seriesName = this.name;
  3034. var rawValue = this.getRawValue(dataIndex, dataType);
  3035. var rawDataIndex = data.getRawIndex(dataIndex);
  3036. var name = data.getName(dataIndex, true);
  3037. var itemOpt = data.getRawDataItem(dataIndex);
  3038. return {
  3039. componentType: this.mainType,
  3040. componentSubType: this.subType,
  3041. seriesType: this.mainType === 'series' ? this.subType : null,
  3042. seriesIndex: seriesIndex,
  3043. seriesName: seriesName,
  3044. name: name,
  3045. dataIndex: rawDataIndex,
  3046. data: itemOpt,
  3047. dataType: dataType,
  3048. value: rawValue,
  3049. color: data.getItemVisual(dataIndex, 'color'),
  3050. // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  3051. $vars: ['seriesName', 'name', 'value']
  3052. };
  3053. },
  3054. /**
  3055. * Format label
  3056. * @param {number} dataIndex
  3057. * @param {string} [status='normal'] 'normal' or 'emphasis'
  3058. * @param {string} [dataType]
  3059. * @param {number} [dimIndex]
  3060. * @return {string}
  3061. */
  3062. getFormattedLabel: function (dataIndex, status, dataType, dimIndex) {
  3063. status = status || 'normal';
  3064. var data = this.getData(dataType);
  3065. var itemModel = data.getItemModel(dataIndex);
  3066. var params = this.getDataParams(dataIndex, dataType);
  3067. if (dimIndex != null && (params.value instanceof Array)) {
  3068. params.value = params.value[dimIndex];
  3069. }
  3070. var formatter = itemModel.get(['label', status, 'formatter']);
  3071. if (typeof formatter === 'function') {
  3072. params.status = status;
  3073. return formatter(params);
  3074. }
  3075. else if (typeof formatter === 'string') {
  3076. return formatUtil.formatTpl(formatter, params);
  3077. }
  3078. },
  3079. /**
  3080. * Get raw value in option
  3081. * @param {number} idx
  3082. * @param {string} [dataType]
  3083. * @return {Object}
  3084. */
  3085. getRawValue: function (idx, dataType) {
  3086. var data = this.getData(dataType);
  3087. var dataItem = data.getRawDataItem(idx);
  3088. if (dataItem != null) {
  3089. return (isObject(dataItem) && !(dataItem instanceof Array))
  3090. ? dataItem.value : dataItem;
  3091. }
  3092. },
  3093. /**
  3094. * Should be implemented.
  3095. * @param {number} dataIndex
  3096. * @param {boolean} [multipleSeries=false]
  3097. * @param {number} [dataType]
  3098. * @return {string} tooltip string
  3099. */
  3100. formatTooltip: zrUtil.noop
  3101. };
  3102. /**
  3103. * Mapping to exists for merge.
  3104. *
  3105. * @public
  3106. * @param {Array.<Object>|Array.<module:echarts/model/Component>} exists
  3107. * @param {Object|Array.<Object>} newCptOptions
  3108. * @return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3109. * index of which is the same as exists.
  3110. */
  3111. modelUtil.mappingToExists = function (exists, newCptOptions) {
  3112. // Mapping by the order by original option (but not order of
  3113. // new option) in merge mode. Because we should ensure
  3114. // some specified index (like xAxisIndex) is consistent with
  3115. // original option, which is easy to understand, espatially in
  3116. // media query. And in most case, merge option is used to
  3117. // update partial option but not be expected to change order.
  3118. newCptOptions = (newCptOptions || []).slice();
  3119. var result = zrUtil.map(exists || [], function (obj, index) {
  3120. return {exist: obj};
  3121. });
  3122. // Mapping by id or name if specified.
  3123. each(newCptOptions, function (cptOption, index) {
  3124. if (!isObject(cptOption)) {
  3125. return;
  3126. }
  3127. // id has highest priority.
  3128. for (var i = 0; i < result.length; i++) {
  3129. if (!result[i].option // Consider name: two map to one.
  3130. && cptOption.id != null
  3131. && result[i].exist.id === cptOption.id + ''
  3132. ) {
  3133. result[i].option = cptOption;
  3134. newCptOptions[index] = null;
  3135. return;
  3136. }
  3137. }
  3138. for (var i = 0; i < result.length; i++) {
  3139. var exist = result[i].exist;
  3140. if (!result[i].option // Consider name: two map to one.
  3141. // Can not match when both ids exist but different.
  3142. && (exist.id == null || cptOption.id == null)
  3143. && cptOption.name != null
  3144. && !modelUtil.isIdInner(cptOption)
  3145. && !modelUtil.isIdInner(exist)
  3146. && exist.name === cptOption.name + ''
  3147. ) {
  3148. result[i].option = cptOption;
  3149. newCptOptions[index] = null;
  3150. return;
  3151. }
  3152. }
  3153. });
  3154. // Otherwise mapping by index.
  3155. each(newCptOptions, function (cptOption, index) {
  3156. if (!isObject(cptOption)) {
  3157. return;
  3158. }
  3159. var i = 0;
  3160. for (; i < result.length; i++) {
  3161. var exist = result[i].exist;
  3162. if (!result[i].option
  3163. // Existing model that already has id should be able to
  3164. // mapped to (because after mapping performed model may
  3165. // be assigned with a id, whish should not affect next
  3166. // mapping), except those has inner id.
  3167. && !modelUtil.isIdInner(exist)
  3168. // Caution:
  3169. // Do not overwrite id. But name can be overwritten,
  3170. // because axis use name as 'show label text'.
  3171. // 'exist' always has id and name and we dont
  3172. // need to check it.
  3173. && cptOption.id == null
  3174. ) {
  3175. result[i].option = cptOption;
  3176. break;
  3177. }
  3178. }
  3179. if (i >= result.length) {
  3180. result.push({option: cptOption});
  3181. }
  3182. });
  3183. return result;
  3184. };
  3185. /**
  3186. * Make id and name for mapping result (result of mappingToExists)
  3187. * into `keyInfo` field.
  3188. *
  3189. * @public
  3190. * @param {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3191. * which order is the same as exists.
  3192. * @return {Array.<Object>} The input.
  3193. */
  3194. modelUtil.makeIdAndName = function (mapResult) {
  3195. // We use this id to hash component models and view instances
  3196. // in echarts. id can be specified by user, or auto generated.
  3197. // The id generation rule ensures new view instance are able
  3198. // to mapped to old instance when setOption are called in
  3199. // no-merge mode. So we generate model id by name and plus
  3200. // type in view id.
  3201. // name can be duplicated among components, which is convenient
  3202. // to specify multi components (like series) by one name.
  3203. // Ensure that each id is distinct.
  3204. var idMap = {};
  3205. each(mapResult, function (item, index) {
  3206. var existCpt = item.exist;
  3207. existCpt && (idMap[existCpt.id] = item);
  3208. });
  3209. each(mapResult, function (item, index) {
  3210. var opt = item.option;
  3211. zrUtil.assert(
  3212. !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item,
  3213. 'id duplicates: ' + (opt && opt.id)
  3214. );
  3215. opt && opt.id != null && (idMap[opt.id] = item);
  3216. !item.keyInfo && (item.keyInfo = {});
  3217. });
  3218. // Make name and id.
  3219. each(mapResult, function (item, index) {
  3220. var existCpt = item.exist;
  3221. var opt = item.option;
  3222. var keyInfo = item.keyInfo;
  3223. if (!isObject(opt)) {
  3224. return;
  3225. }
  3226. // name can be overwitten. Consider case: axis.name = '20km'.
  3227. // But id generated by name will not be changed, which affect
  3228. // only in that case: setOption with 'not merge mode' and view
  3229. // instance will be recreated, which can be accepted.
  3230. keyInfo.name = opt.name != null
  3231. ? opt.name + ''
  3232. : existCpt
  3233. ? existCpt.name
  3234. : '\0-';
  3235. if (existCpt) {
  3236. keyInfo.id = existCpt.id;
  3237. }
  3238. else if (opt.id != null) {
  3239. keyInfo.id = opt.id + '';
  3240. }
  3241. else {
  3242. // Consider this situatoin:
  3243. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  3244. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  3245. // Series with the same name between optionA and optionB
  3246. // should be mapped.
  3247. var idNum = 0;
  3248. do {
  3249. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  3250. }
  3251. while (idMap[keyInfo.id]);
  3252. }
  3253. idMap[keyInfo.id] = item;
  3254. });
  3255. };
  3256. /**
  3257. * @public
  3258. * @param {Object} cptOption
  3259. * @return {boolean}
  3260. */
  3261. modelUtil.isIdInner = function (cptOption) {
  3262. return isObject(cptOption)
  3263. && cptOption.id
  3264. && (cptOption.id + '').indexOf('\0_ec_\0') === 0;
  3265. };
  3266. /**
  3267. * A helper for removing duplicate items between batchA and batchB,
  3268. * and in themselves, and categorize by series.
  3269. *
  3270. * @param {Array.<Object>} batchA Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3271. * @param {Array.<Object>} batchB Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3272. * @return {Array.<Array.<Object>, Array.<Object>>} result: [resultBatchA, resultBatchB]
  3273. */
  3274. modelUtil.compressBatches = function (batchA, batchB) {
  3275. var mapA = {};
  3276. var mapB = {};
  3277. makeMap(batchA || [], mapA);
  3278. makeMap(batchB || [], mapB, mapA);
  3279. return [mapToArray(mapA), mapToArray(mapB)];
  3280. function makeMap(sourceBatch, map, otherMap) {
  3281. for (var i = 0, len = sourceBatch.length; i < len; i++) {
  3282. var seriesId = sourceBatch[i].seriesId;
  3283. var dataIndices = modelUtil.normalizeToArray(sourceBatch[i].dataIndex);
  3284. var otherDataIndices = otherMap && otherMap[seriesId];
  3285. for (var j = 0, lenj = dataIndices.length; j < lenj; j++) {
  3286. var dataIndex = dataIndices[j];
  3287. if (otherDataIndices && otherDataIndices[dataIndex]) {
  3288. otherDataIndices[dataIndex] = null;
  3289. }
  3290. else {
  3291. (map[seriesId] || (map[seriesId] = {}))[dataIndex] = 1;
  3292. }
  3293. }
  3294. }
  3295. }
  3296. function mapToArray(map, isData) {
  3297. var result = [];
  3298. for (var i in map) {
  3299. if (map.hasOwnProperty(i) && map[i] != null) {
  3300. if (isData) {
  3301. result.push(+i);
  3302. }
  3303. else {
  3304. var dataIndices = mapToArray(map[i], true);
  3305. dataIndices.length && result.push({seriesId: i, dataIndex: dataIndices});
  3306. }
  3307. }
  3308. }
  3309. return result;
  3310. }
  3311. };
  3312. /**
  3313. * @param {module:echarts/data/List} data
  3314. * @param {Object} payload Contains dataIndex (means rawIndex) / dataIndexInside / name
  3315. * each of which can be Array or primary type.
  3316. * @return {number|Array.<number>} dataIndex If not found, return undefined/null.
  3317. */
  3318. modelUtil.queryDataIndex = function (data, payload) {
  3319. if (payload.dataIndexInside != null) {
  3320. return payload.dataIndexInside;
  3321. }
  3322. else if (payload.dataIndex != null) {
  3323. return zrUtil.isArray(payload.dataIndex)
  3324. ? zrUtil.map(payload.dataIndex, function (value) {
  3325. return data.indexOfRawIndex(value);
  3326. })
  3327. : data.indexOfRawIndex(payload.dataIndex);
  3328. }
  3329. else if (payload.name != null) {
  3330. return zrUtil.isArray(payload.name)
  3331. ? zrUtil.map(payload.name, function (value) {
  3332. return data.indexOfName(value);
  3333. })
  3334. : data.indexOfName(payload.name);
  3335. }
  3336. };
  3337. /**
  3338. * @param {module:echarts/model/Global} ecModel
  3339. * @param {string|Object} finder
  3340. * If string, e.g., 'geo', means {geoIndex: 0}.
  3341. * If Object, could contain some of these properties below:
  3342. * {
  3343. * seriesIndex, seriesId, seriesName,
  3344. * geoIndex, geoId, goeName,
  3345. * bmapIndex, bmapId, bmapName,
  3346. * xAxisIndex, xAxisId, xAxisName,
  3347. * yAxisIndex, yAxisId, yAxisName,
  3348. * gridIndex, gridId, gridName,
  3349. * ... (can be extended)
  3350. * }
  3351. * Each properties can be number|string|Array.<number>|Array.<string>
  3352. * For example, a finder could be
  3353. * {
  3354. * seriesIndex: 3,
  3355. * geoId: ['aa', 'cc'],
  3356. * gridName: ['xx', 'rr']
  3357. * }
  3358. * @param {Object} [opt]
  3359. * @param {string} [opt.defaultMainType]
  3360. * @return {Object} result like:
  3361. * {
  3362. * seriesModels: [seriesModel1, seriesModel2],
  3363. * seriesModel: seriesModel1, // The first model
  3364. * geoModels: [geoModel1, geoModel2],
  3365. * geoModel: geoModel1, // The first model
  3366. * ...
  3367. * }
  3368. */
  3369. modelUtil.parseFinder = function (ecModel, finder, opt) {
  3370. if (zrUtil.isString(finder)) {
  3371. var obj = {};
  3372. obj[finder + 'Index'] = 0;
  3373. finder = obj;
  3374. }
  3375. var defaultMainType = opt && opt.defaultMainType;
  3376. if (defaultMainType
  3377. && !has(finder, defaultMainType + 'Index')
  3378. && !has(finder, defaultMainType + 'Id')
  3379. && !has(finder, defaultMainType + 'Name')
  3380. ) {
  3381. finder[defaultMainType + 'Index'] = 0;
  3382. }
  3383. var result = {};
  3384. each(finder, function (value, key) {
  3385. var value = finder[key];
  3386. // Exclude 'dataIndex' and other illgal keys.
  3387. if (key === 'dataIndex' || key === 'dataIndexInside') {
  3388. result[key] = value;
  3389. return;
  3390. }
  3391. var parsedKey = key.match(/^(\w+)(Index|Id|Name)$/) || [];
  3392. var mainType = parsedKey[1];
  3393. var queryType = parsedKey[2];
  3394. if (!mainType || !queryType) {
  3395. return;
  3396. }
  3397. var queryParam = {mainType: mainType};
  3398. queryParam[queryType.toLowerCase()] = value;
  3399. var models = ecModel.queryComponents(queryParam);
  3400. result[mainType + 'Models'] = models;
  3401. result[mainType + 'Model'] = models[0];
  3402. });
  3403. return result;
  3404. };
  3405. function has(obj, prop) {
  3406. return obj && obj.hasOwnProperty(prop);
  3407. }
  3408. module.exports = modelUtil;
  3409. /***/ },
  3410. /* 6 */
  3411. /***/ function(module, exports, __webpack_require__) {
  3412. var zrUtil = __webpack_require__(4);
  3413. var numberUtil = __webpack_require__(7);
  3414. var textContain = __webpack_require__(8);
  3415. var formatUtil = {};
  3416. /**
  3417. * 每三位默认加,格式化
  3418. * @type {string|number} x
  3419. */
  3420. formatUtil.addCommas = function (x) {
  3421. if (isNaN(x)) {
  3422. return '-';
  3423. }
  3424. x = (x + '').split('.');
  3425. return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,')
  3426. + (x.length > 1 ? ('.' + x[1]) : '');
  3427. };
  3428. /**
  3429. * @param {string} str
  3430. * @param {boolean} [upperCaseFirst=false]
  3431. * @return {string} str
  3432. */
  3433. formatUtil.toCamelCase = function (str, upperCaseFirst) {
  3434. str = (str || '').toLowerCase().replace(/-(.)/g, function(match, group1) {
  3435. return group1.toUpperCase();
  3436. });
  3437. if (upperCaseFirst && str) {
  3438. str = str.charAt(0).toUpperCase() + str.slice(1);
  3439. }
  3440. return str;
  3441. };
  3442. /**
  3443. * Normalize css liked array configuration
  3444. * e.g.
  3445. * 3 => [3, 3, 3, 3]
  3446. * [4, 2] => [4, 2, 4, 2]
  3447. * [4, 3, 2] => [4, 3, 2, 3]
  3448. * @param {number|Array.<number>} val
  3449. */
  3450. formatUtil.normalizeCssArray = function (val) {
  3451. var len = val.length;
  3452. if (typeof (val) === 'number') {
  3453. return [val, val, val, val];
  3454. }
  3455. else if (len === 2) {
  3456. // vertical | horizontal
  3457. return [val[0], val[1], val[0], val[1]];
  3458. }
  3459. else if (len === 3) {
  3460. // top | horizontal | bottom
  3461. return [val[0], val[1], val[2], val[1]];
  3462. }
  3463. return val;
  3464. };
  3465. formatUtil.encodeHTML = function (source) {
  3466. return String(source)
  3467. .replace(/&/g, '&amp;')
  3468. .replace(/</g, '&lt;')
  3469. .replace(/>/g, '&gt;')
  3470. .replace(/"/g, '&quot;')
  3471. .replace(/'/g, '&#39;');
  3472. };
  3473. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
  3474. var wrapVar = function (varName, seriesIdx) {
  3475. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
  3476. };
  3477. /**
  3478. * Template formatter
  3479. * @param {string} tpl
  3480. * @param {Array.<Object>|Object} paramsList
  3481. * @return {string}
  3482. */
  3483. formatUtil.formatTpl = function (tpl, paramsList) {
  3484. if (!zrUtil.isArray(paramsList)) {
  3485. paramsList = [paramsList];
  3486. }
  3487. var seriesLen = paramsList.length;
  3488. if (!seriesLen) {
  3489. return '';
  3490. }
  3491. var $vars = paramsList[0].$vars || [];
  3492. for (var i = 0; i < $vars.length; i++) {
  3493. var alias = TPL_VAR_ALIAS[i];
  3494. tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
  3495. }
  3496. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  3497. for (var k = 0; k < $vars.length; k++) {
  3498. tpl = tpl.replace(
  3499. wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
  3500. paramsList[seriesIdx][$vars[k]]
  3501. );
  3502. }
  3503. }
  3504. return tpl;
  3505. };
  3506. /**
  3507. * @param {string} str
  3508. * @return {string}
  3509. * @inner
  3510. */
  3511. var s2d = function (str) {
  3512. return str < 10 ? ('0' + str) : str;
  3513. };
  3514. /**
  3515. * ISO Date format
  3516. * @param {string} tpl
  3517. * @param {number} value
  3518. * @inner
  3519. */
  3520. formatUtil.formatTime = function (tpl, value) {
  3521. if (tpl === 'week'
  3522. || tpl === 'month'
  3523. || tpl === 'quarter'
  3524. || tpl === 'half-year'
  3525. || tpl === 'year'
  3526. ) {
  3527. tpl = 'MM-dd\nyyyy';
  3528. }
  3529. var date = numberUtil.parseDate(value);
  3530. var y = date.getFullYear();
  3531. var M = date.getMonth() + 1;
  3532. var d = date.getDate();
  3533. var h = date.getHours();
  3534. var m = date.getMinutes();
  3535. var s = date.getSeconds();
  3536. tpl = tpl.replace('MM', s2d(M))
  3537. .toLowerCase()
  3538. .replace('yyyy', y)
  3539. .replace('yy', y % 100)
  3540. .replace('dd', s2d(d))
  3541. .replace('d', d)
  3542. .replace('hh', s2d(h))
  3543. .replace('h', h)
  3544. .replace('mm', s2d(m))
  3545. .replace('m', m)
  3546. .replace('ss', s2d(s))
  3547. .replace('s', s);
  3548. return tpl;
  3549. };
  3550. /**
  3551. * Capital first
  3552. * @param {string} str
  3553. * @return {string}
  3554. */
  3555. formatUtil.capitalFirst = function (str) {
  3556. return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
  3557. };
  3558. formatUtil.truncateText = textContain.truncateText;
  3559. module.exports = formatUtil;
  3560. /***/ },
  3561. /* 7 */
  3562. /***/ function(module, exports) {
  3563. /**
  3564. * 数值处理模块
  3565. * @module echarts/util/number
  3566. */
  3567. var number = {};
  3568. var RADIAN_EPSILON = 1e-4;
  3569. function _trim(str) {
  3570. return str.replace(/^\s+/, '').replace(/\s+$/, '');
  3571. }
  3572. /**
  3573. * Linear mapping a value from domain to range
  3574. * @memberOf module:echarts/util/number
  3575. * @param {(number|Array.<number>)} val
  3576. * @param {Array.<number>} domain Domain extent domain[0] can be bigger than domain[1]
  3577. * @param {Array.<number>} range Range extent range[0] can be bigger than range[1]
  3578. * @param {boolean} clamp
  3579. * @return {(number|Array.<number>}
  3580. */
  3581. number.linearMap = function (val, domain, range, clamp) {
  3582. var subDomain = domain[1] - domain[0];
  3583. var subRange = range[1] - range[0];
  3584. if (subDomain === 0) {
  3585. return subRange === 0
  3586. ? range[0]
  3587. : (range[0] + range[1]) / 2;
  3588. }
  3589. // Avoid accuracy problem in edge, such as
  3590. // 146.39 - 62.83 === 83.55999999999999.
  3591. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  3592. // It is a little verbose for efficiency considering this method
  3593. // is a hotspot.
  3594. if (clamp) {
  3595. if (subDomain > 0) {
  3596. if (val <= domain[0]) {
  3597. return range[0];
  3598. }
  3599. else if (val >= domain[1]) {
  3600. return range[1];
  3601. }
  3602. }
  3603. else {
  3604. if (val >= domain[0]) {
  3605. return range[0];
  3606. }
  3607. else if (val <= domain[1]) {
  3608. return range[1];
  3609. }
  3610. }
  3611. }
  3612. else {
  3613. if (val === domain[0]) {
  3614. return range[0];
  3615. }
  3616. if (val === domain[1]) {
  3617. return range[1];
  3618. }
  3619. }
  3620. return (val - domain[0]) / subDomain * subRange + range[0];
  3621. };
  3622. /**
  3623. * Convert a percent string to absolute number.
  3624. * Returns NaN if percent is not a valid string or number
  3625. * @memberOf module:echarts/util/number
  3626. * @param {string|number} percent
  3627. * @param {number} all
  3628. * @return {number}
  3629. */
  3630. number.parsePercent = function(percent, all) {
  3631. switch (percent) {
  3632. case 'center':
  3633. case 'middle':
  3634. percent = '50%';
  3635. break;
  3636. case 'left':
  3637. case 'top':
  3638. percent = '0%';
  3639. break;
  3640. case 'right':
  3641. case 'bottom':
  3642. percent = '100%';
  3643. break;
  3644. }
  3645. if (typeof percent === 'string') {
  3646. if (_trim(percent).match(/%$/)) {
  3647. return parseFloat(percent) / 100 * all;
  3648. }
  3649. return parseFloat(percent);
  3650. }
  3651. return percent == null ? NaN : +percent;
  3652. };
  3653. /**
  3654. * Fix rounding error of float numbers
  3655. * @param {number} x
  3656. * @return {number}
  3657. */
  3658. number.round = function (x, precision) {
  3659. if (precision == null) {
  3660. precision = 10;
  3661. }
  3662. // Avoid range error
  3663. precision = Math.min(Math.max(0, precision), 20);
  3664. return +(+x).toFixed(precision);
  3665. };
  3666. number.asc = function (arr) {
  3667. arr.sort(function (a, b) {
  3668. return a - b;
  3669. });
  3670. return arr;
  3671. };
  3672. /**
  3673. * Get precision
  3674. * @param {number} val
  3675. */
  3676. number.getPrecision = function (val) {
  3677. val = +val;
  3678. if (isNaN(val)) {
  3679. return 0;
  3680. }
  3681. // It is much faster than methods converting number to string as follows
  3682. // var tmp = val.toString();
  3683. // return tmp.length - 1 - tmp.indexOf('.');
  3684. // especially when precision is low
  3685. var e = 1;
  3686. var count = 0;
  3687. while (Math.round(val * e) / e !== val) {
  3688. e *= 10;
  3689. count++;
  3690. }
  3691. return count;
  3692. };
  3693. number.getPrecisionSafe = function (val) {
  3694. var str = val.toString();
  3695. var dotIndex = str.indexOf('.');
  3696. if (dotIndex < 0) {
  3697. return 0;
  3698. }
  3699. return str.length - 1 - dotIndex;
  3700. };
  3701. /**
  3702. * @param {Array.<number>} dataExtent
  3703. * @param {Array.<number>} pixelExtent
  3704. * @return {number} precision
  3705. */
  3706. number.getPixelPrecision = function (dataExtent, pixelExtent) {
  3707. var log = Math.log;
  3708. var LN10 = Math.LN10;
  3709. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  3710. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
  3711. return Math.max(
  3712. -dataQuantity + sizeQuantity,
  3713. 0
  3714. );
  3715. };
  3716. // Number.MAX_SAFE_INTEGER, ie do not support.
  3717. number.MAX_SAFE_INTEGER = 9007199254740991;
  3718. /**
  3719. * To 0 - 2 * PI, considering negative radian.
  3720. * @param {number} radian
  3721. * @return {number}
  3722. */
  3723. number.remRadian = function (radian) {
  3724. var pi2 = Math.PI * 2;
  3725. return (radian % pi2 + pi2) % pi2;
  3726. };
  3727. /**
  3728. * @param {type} radian
  3729. * @return {boolean}
  3730. */
  3731. number.isRadianAroundZero = function (val) {
  3732. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  3733. };
  3734. /**
  3735. * @param {string|Date|number} value
  3736. * @return {Date} date
  3737. */
  3738. number.parseDate = function (value) {
  3739. if (value instanceof Date) {
  3740. return value;
  3741. }
  3742. else if (typeof value === 'string') {
  3743. // Treat as ISO format. See issue #3623
  3744. var ret = new Date(value);
  3745. if (isNaN(+ret)) {
  3746. // FIXME new Date('1970-01-01') is UTC, new Date('1970/01/01') is local
  3747. ret = new Date(new Date(value.replace(/-/g, '/')) - new Date('1970/01/01'));
  3748. }
  3749. return ret;
  3750. }
  3751. return new Date(Math.round(value));
  3752. };
  3753. /**
  3754. * Quantity of a number. e.g. 0.1, 1, 10, 100
  3755. * @param {number} val
  3756. * @return {number}
  3757. */
  3758. number.quantity = function (val) {
  3759. return Math.pow(10, Math.floor(Math.log(val) / Math.LN10));
  3760. };
  3761. // "Nice Numbers for Graph Labels" of Graphic Gems
  3762. /**
  3763. * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false
  3764. * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  3765. * @param {number} val
  3766. * @param {boolean} round
  3767. * @return {number}
  3768. */
  3769. number.nice = function (val, round) {
  3770. var exp10 = number.quantity(val);
  3771. var f = val / exp10; // between 1 and 10
  3772. var nf;
  3773. if (round) {
  3774. if (f < 1.5) { nf = 1; }
  3775. else if (f < 2.5) { nf = 2; }
  3776. else if (f < 4) { nf = 3; }
  3777. else if (f < 7) { nf = 5; }
  3778. else { nf = 10; }
  3779. }
  3780. else {
  3781. if (f < 1) { nf = 1; }
  3782. else if (f < 2) { nf = 2; }
  3783. else if (f < 3) { nf = 3; }
  3784. else if (f < 5) { nf = 5; }
  3785. else { nf = 10; }
  3786. }
  3787. return nf * exp10;
  3788. };
  3789. /**
  3790. * Order intervals asc, and split them when overlap.
  3791. * expect(numberUtil.reformIntervals([
  3792. * {interval: [18, 62], close: [1, 1]},
  3793. * {interval: [-Infinity, -70], close: [0, 0]},
  3794. * {interval: [-70, -26], close: [1, 1]},
  3795. * {interval: [-26, 18], close: [1, 1]},
  3796. * {interval: [62, 150], close: [1, 1]},
  3797. * {interval: [106, 150], close: [1, 1]},
  3798. * {interval: [150, Infinity], close: [0, 0]}
  3799. * ])).toEqual([
  3800. * {interval: [-Infinity, -70], close: [0, 0]},
  3801. * {interval: [-70, -26], close: [1, 1]},
  3802. * {interval: [-26, 18], close: [0, 1]},
  3803. * {interval: [18, 62], close: [0, 1]},
  3804. * {interval: [62, 150], close: [0, 1]},
  3805. * {interval: [150, Infinity], close: [0, 0]}
  3806. * ]);
  3807. * @param {Array.<Object>} list, where `close` mean open or close
  3808. * of the interval, and Infinity can be used.
  3809. * @return {Array.<Object>} The origin list, which has been reformed.
  3810. */
  3811. number.reformIntervals = function (list) {
  3812. list.sort(function (a, b) {
  3813. return littleThan(a, b, 0) ? -1 : 1;
  3814. });
  3815. var curr = -Infinity;
  3816. var currClose = 1;
  3817. for (var i = 0; i < list.length;) {
  3818. var interval = list[i].interval;
  3819. var close = list[i].close;
  3820. for (var lg = 0; lg < 2; lg++) {
  3821. if (interval[lg] <= curr) {
  3822. interval[lg] = curr;
  3823. close[lg] = !lg ? 1 - currClose : 1;
  3824. }
  3825. curr = interval[lg];
  3826. currClose = close[lg];
  3827. }
  3828. if (interval[0] === interval[1] && close[0] * close[1] !== 1) {
  3829. list.splice(i, 1);
  3830. }
  3831. else {
  3832. i++;
  3833. }
  3834. }
  3835. return list;
  3836. function littleThan(a, b, lg) {
  3837. return a.interval[lg] < b.interval[lg]
  3838. || (
  3839. a.interval[lg] === b.interval[lg]
  3840. && (
  3841. (a.close[lg] - b.close[lg] === (!lg ? 1 : -1))
  3842. || (!lg && littleThan(a, b, 1))
  3843. )
  3844. );
  3845. }
  3846. };
  3847. module.exports = number;
  3848. /***/ },
  3849. /* 8 */
  3850. /***/ function(module, exports, __webpack_require__) {
  3851. var textWidthCache = {};
  3852. var textWidthCacheCounter = 0;
  3853. var TEXT_CACHE_MAX = 5000;
  3854. var util = __webpack_require__(4);
  3855. var BoundingRect = __webpack_require__(9);
  3856. var retrieve = util.retrieve;
  3857. function getTextWidth(text, textFont) {
  3858. var key = text + ':' + textFont;
  3859. if (textWidthCache[key]) {
  3860. return textWidthCache[key];
  3861. }
  3862. var textLines = (text + '').split('\n');
  3863. var width = 0;
  3864. for (var i = 0, l = textLines.length; i < l; i++) {
  3865. // measureText 可以被覆盖以兼容不支持 Canvas 的环境
  3866. width = Math.max(textContain.measureText(textLines[i], textFont).width, width);
  3867. }
  3868. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  3869. textWidthCacheCounter = 0;
  3870. textWidthCache = {};
  3871. }
  3872. textWidthCacheCounter++;
  3873. textWidthCache[key] = width;
  3874. return width;
  3875. }
  3876. function getTextRect(text, textFont, textAlign, textBaseline) {
  3877. var textLineLen = ((text || '') + '').split('\n').length;
  3878. var width = getTextWidth(text, textFont);
  3879. // FIXME 高度计算比较粗暴
  3880. var lineHeight = getTextWidth('国', textFont);
  3881. var height = textLineLen * lineHeight;
  3882. var rect = new BoundingRect(0, 0, width, height);
  3883. // Text has a special line height property
  3884. rect.lineHeight = lineHeight;
  3885. switch (textBaseline) {
  3886. case 'bottom':
  3887. case 'alphabetic':
  3888. rect.y -= lineHeight;
  3889. break;
  3890. case 'middle':
  3891. rect.y -= lineHeight / 2;
  3892. break;
  3893. // case 'hanging':
  3894. // case 'top':
  3895. }
  3896. // FIXME Right to left language
  3897. switch (textAlign) {
  3898. case 'end':
  3899. case 'right':
  3900. rect.x -= rect.width;
  3901. break;
  3902. case 'center':
  3903. rect.x -= rect.width / 2;
  3904. break;
  3905. // case 'start':
  3906. // case 'left':
  3907. }
  3908. return rect;
  3909. }
  3910. function adjustTextPositionOnRect(textPosition, rect, textRect, distance) {
  3911. var x = rect.x;
  3912. var y = rect.y;
  3913. var height = rect.height;
  3914. var width = rect.width;
  3915. var textHeight = textRect.height;
  3916. var halfHeight = height / 2 - textHeight / 2;
  3917. var textAlign = 'left';
  3918. switch (textPosition) {
  3919. case 'left':
  3920. x -= distance;
  3921. y += halfHeight;
  3922. textAlign = 'right';
  3923. break;
  3924. case 'right':
  3925. x += distance + width;
  3926. y += halfHeight;
  3927. textAlign = 'left';
  3928. break;
  3929. case 'top':
  3930. x += width / 2;
  3931. y -= distance + textHeight;
  3932. textAlign = 'center';
  3933. break;
  3934. case 'bottom':
  3935. x += width / 2;
  3936. y += height + distance;
  3937. textAlign = 'center';
  3938. break;
  3939. case 'inside':
  3940. x += width / 2;
  3941. y += halfHeight;
  3942. textAlign = 'center';
  3943. break;
  3944. case 'insideLeft':
  3945. x += distance;
  3946. y += halfHeight;
  3947. textAlign = 'left';
  3948. break;
  3949. case 'insideRight':
  3950. x += width - distance;
  3951. y += halfHeight;
  3952. textAlign = 'right';
  3953. break;
  3954. case 'insideTop':
  3955. x += width / 2;
  3956. y += distance;
  3957. textAlign = 'center';
  3958. break;
  3959. case 'insideBottom':
  3960. x += width / 2;
  3961. y += height - textHeight - distance;
  3962. textAlign = 'center';
  3963. break;
  3964. case 'insideTopLeft':
  3965. x += distance;
  3966. y += distance;
  3967. textAlign = 'left';
  3968. break;
  3969. case 'insideTopRight':
  3970. x += width - distance;
  3971. y += distance;
  3972. textAlign = 'right';
  3973. break;
  3974. case 'insideBottomLeft':
  3975. x += distance;
  3976. y += height - textHeight - distance;
  3977. break;
  3978. case 'insideBottomRight':
  3979. x += width - distance;
  3980. y += height - textHeight - distance;
  3981. textAlign = 'right';
  3982. break;
  3983. }
  3984. return {
  3985. x: x,
  3986. y: y,
  3987. textAlign: textAlign,
  3988. textBaseline: 'top'
  3989. };
  3990. }
  3991. /**
  3992. * Show ellipsis if overflow.
  3993. *
  3994. * @param {string} text
  3995. * @param {string} containerWidth
  3996. * @param {string} textFont
  3997. * @param {number} [ellipsis='...']
  3998. * @param {Object} [options]
  3999. * @param {number} [options.maxIterations=3]
  4000. * @param {number} [options.minChar=0] If truncate result are less
  4001. * then minChar, ellipsis will not show, which is
  4002. * better for user hint in some cases.
  4003. * @param {number} [options.placeholder=''] When all truncated, use the placeholder.
  4004. * @return {string}
  4005. */
  4006. function truncateText(text, containerWidth, textFont, ellipsis, options) {
  4007. if (!containerWidth) {
  4008. return '';
  4009. }
  4010. options = options || {};
  4011. ellipsis = retrieve(ellipsis, '...');
  4012. var maxIterations = retrieve(options.maxIterations, 2);
  4013. var minChar = retrieve(options.minChar, 0);
  4014. // FIXME
  4015. // Other languages?
  4016. var cnCharWidth = getTextWidth('国', textFont);
  4017. // FIXME
  4018. // Consider proportional font?
  4019. var ascCharWidth = getTextWidth('a', textFont);
  4020. var placeholder = retrieve(options.placeholder, '');
  4021. // Example 1: minChar: 3, text: 'asdfzxcv', truncate result: 'asdf', but not: 'a...'.
  4022. // Example 2: minChar: 3, text: '维度', truncate result: '维', but not: '...'.
  4023. var contentWidth = containerWidth = Math.max(0, containerWidth - 1); // Reserve some gap.
  4024. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  4025. contentWidth -= ascCharWidth;
  4026. }
  4027. var ellipsisWidth = getTextWidth(ellipsis);
  4028. if (ellipsisWidth > contentWidth) {
  4029. ellipsis = '';
  4030. ellipsisWidth = 0;
  4031. }
  4032. contentWidth = containerWidth - ellipsisWidth;
  4033. var textLines = (text + '').split('\n');
  4034. for (var i = 0, len = textLines.length; i < len; i++) {
  4035. var textLine = textLines[i];
  4036. var lineWidth = getTextWidth(textLine, textFont);
  4037. if (lineWidth <= containerWidth) {
  4038. continue;
  4039. }
  4040. for (var j = 0;; j++) {
  4041. if (lineWidth <= contentWidth || j >= maxIterations) {
  4042. textLine += ellipsis;
  4043. break;
  4044. }
  4045. var subLength = j === 0
  4046. ? estimateLength(textLine, contentWidth, ascCharWidth, cnCharWidth)
  4047. : lineWidth > 0
  4048. ? Math.floor(textLine.length * contentWidth / lineWidth)
  4049. : 0;
  4050. textLine = textLine.substr(0, subLength);
  4051. lineWidth = getTextWidth(textLine, textFont);
  4052. }
  4053. if (textLine === '') {
  4054. textLine = placeholder;
  4055. }
  4056. textLines[i] = textLine;
  4057. }
  4058. return textLines.join('\n');
  4059. }
  4060. function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
  4061. var width = 0;
  4062. var i = 0;
  4063. for (var len = text.length; i < len && width < contentWidth; i++) {
  4064. var charCode = text.charCodeAt(i);
  4065. width += (0 <= charCode && charCode <= 127) ? ascCharWidth : cnCharWidth;
  4066. }
  4067. return i;
  4068. }
  4069. var textContain = {
  4070. getWidth: getTextWidth,
  4071. getBoundingRect: getTextRect,
  4072. adjustTextPositionOnRect: adjustTextPositionOnRect,
  4073. truncateText: truncateText,
  4074. measureText: function (text, textFont) {
  4075. var ctx = util.getContext();
  4076. ctx.font = textFont || '12px sans-serif';
  4077. return ctx.measureText(text);
  4078. }
  4079. };
  4080. module.exports = textContain;
  4081. /***/ },
  4082. /* 9 */
  4083. /***/ function(module, exports, __webpack_require__) {
  4084. 'use strict';
  4085. /**
  4086. * @module echarts/core/BoundingRect
  4087. */
  4088. var vec2 = __webpack_require__(10);
  4089. var matrix = __webpack_require__(11);
  4090. var v2ApplyTransform = vec2.applyTransform;
  4091. var mathMin = Math.min;
  4092. var mathMax = Math.max;
  4093. /**
  4094. * @alias module:echarts/core/BoundingRect
  4095. */
  4096. function BoundingRect(x, y, width, height) {
  4097. if (width < 0) {
  4098. x = x + width;
  4099. width = -width;
  4100. }
  4101. if (height < 0) {
  4102. y = y + height;
  4103. height = -height;
  4104. }
  4105. /**
  4106. * @type {number}
  4107. */
  4108. this.x = x;
  4109. /**
  4110. * @type {number}
  4111. */
  4112. this.y = y;
  4113. /**
  4114. * @type {number}
  4115. */
  4116. this.width = width;
  4117. /**
  4118. * @type {number}
  4119. */
  4120. this.height = height;
  4121. }
  4122. BoundingRect.prototype = {
  4123. constructor: BoundingRect,
  4124. /**
  4125. * @param {module:echarts/core/BoundingRect} other
  4126. */
  4127. union: function (other) {
  4128. var x = mathMin(other.x, this.x);
  4129. var y = mathMin(other.y, this.y);
  4130. this.width = mathMax(
  4131. other.x + other.width,
  4132. this.x + this.width
  4133. ) - x;
  4134. this.height = mathMax(
  4135. other.y + other.height,
  4136. this.y + this.height
  4137. ) - y;
  4138. this.x = x;
  4139. this.y = y;
  4140. },
  4141. /**
  4142. * @param {Array.<number>} m
  4143. * @methods
  4144. */
  4145. applyTransform: (function () {
  4146. var lt = [];
  4147. var rb = [];
  4148. var lb = [];
  4149. var rt = [];
  4150. return function (m) {
  4151. // In case usage like this
  4152. // el.getBoundingRect().applyTransform(el.transform)
  4153. // And element has no transform
  4154. if (!m) {
  4155. return;
  4156. }
  4157. lt[0] = lb[0] = this.x;
  4158. lt[1] = rt[1] = this.y;
  4159. rb[0] = rt[0] = this.x + this.width;
  4160. rb[1] = lb[1] = this.y + this.height;
  4161. v2ApplyTransform(lt, lt, m);
  4162. v2ApplyTransform(rb, rb, m);
  4163. v2ApplyTransform(lb, lb, m);
  4164. v2ApplyTransform(rt, rt, m);
  4165. this.x = mathMin(lt[0], rb[0], lb[0], rt[0]);
  4166. this.y = mathMin(lt[1], rb[1], lb[1], rt[1]);
  4167. var maxX = mathMax(lt[0], rb[0], lb[0], rt[0]);
  4168. var maxY = mathMax(lt[1], rb[1], lb[1], rt[1]);
  4169. this.width = maxX - this.x;
  4170. this.height = maxY - this.y;
  4171. };
  4172. })(),
  4173. /**
  4174. * Calculate matrix of transforming from self to target rect
  4175. * @param {module:zrender/core/BoundingRect} b
  4176. * @return {Array.<number>}
  4177. */
  4178. calculateTransform: function (b) {
  4179. var a = this;
  4180. var sx = b.width / a.width;
  4181. var sy = b.height / a.height;
  4182. var m = matrix.create();
  4183. // 矩阵右乘
  4184. matrix.translate(m, m, [-a.x, -a.y]);
  4185. matrix.scale(m, m, [sx, sy]);
  4186. matrix.translate(m, m, [b.x, b.y]);
  4187. return m;
  4188. },
  4189. /**
  4190. * @param {(module:echarts/core/BoundingRect|Object)} b
  4191. * @return {boolean}
  4192. */
  4193. intersect: function (b) {
  4194. if (!b) {
  4195. return false;
  4196. }
  4197. if (!(b instanceof BoundingRect)) {
  4198. // Normalize negative width/height.
  4199. b = BoundingRect.create(b);
  4200. }
  4201. var a = this;
  4202. var ax0 = a.x;
  4203. var ax1 = a.x + a.width;
  4204. var ay0 = a.y;
  4205. var ay1 = a.y + a.height;
  4206. var bx0 = b.x;
  4207. var bx1 = b.x + b.width;
  4208. var by0 = b.y;
  4209. var by1 = b.y + b.height;
  4210. return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  4211. },
  4212. contain: function (x, y) {
  4213. var rect = this;
  4214. return x >= rect.x
  4215. && x <= (rect.x + rect.width)
  4216. && y >= rect.y
  4217. && y <= (rect.y + rect.height);
  4218. },
  4219. /**
  4220. * @return {module:echarts/core/BoundingRect}
  4221. */
  4222. clone: function () {
  4223. return new BoundingRect(this.x, this.y, this.width, this.height);
  4224. },
  4225. /**
  4226. * Copy from another rect
  4227. */
  4228. copy: function (other) {
  4229. this.x = other.x;
  4230. this.y = other.y;
  4231. this.width = other.width;
  4232. this.height = other.height;
  4233. },
  4234. plain: function () {
  4235. return {
  4236. x: this.x,
  4237. y: this.y,
  4238. width: this.width,
  4239. height: this.height
  4240. };
  4241. }
  4242. };
  4243. /**
  4244. * @param {Object|module:zrender/core/BoundingRect} rect
  4245. * @param {number} rect.x
  4246. * @param {number} rect.y
  4247. * @param {number} rect.width
  4248. * @param {number} rect.height
  4249. * @return {module:zrender/core/BoundingRect}
  4250. */
  4251. BoundingRect.create = function (rect) {
  4252. return new BoundingRect(rect.x, rect.y, rect.width, rect.height);
  4253. };
  4254. module.exports = BoundingRect;
  4255. /***/ },
  4256. /* 10 */
  4257. /***/ function(module, exports) {
  4258. var ArrayCtor = typeof Float32Array === 'undefined'
  4259. ? Array
  4260. : Float32Array;
  4261. /**
  4262. * @typedef {Float32Array|Array.<number>} Vector2
  4263. */
  4264. /**
  4265. * 二维向量类
  4266. * @exports zrender/tool/vector
  4267. */
  4268. var vector = {
  4269. /**
  4270. * 创建一个向量
  4271. * @param {number} [x=0]
  4272. * @param {number} [y=0]
  4273. * @return {Vector2}
  4274. */
  4275. create: function (x, y) {
  4276. var out = new ArrayCtor(2);
  4277. if (x == null) {
  4278. x = 0;
  4279. }
  4280. if (y == null) {
  4281. y = 0;
  4282. }
  4283. out[0] = x;
  4284. out[1] = y;
  4285. return out;
  4286. },
  4287. /**
  4288. * 复制向量数据
  4289. * @param {Vector2} out
  4290. * @param {Vector2} v
  4291. * @return {Vector2}
  4292. */
  4293. copy: function (out, v) {
  4294. out[0] = v[0];
  4295. out[1] = v[1];
  4296. return out;
  4297. },
  4298. /**
  4299. * 克隆一个向量
  4300. * @param {Vector2} v
  4301. * @return {Vector2}
  4302. */
  4303. clone: function (v) {
  4304. var out = new ArrayCtor(2);
  4305. out[0] = v[0];
  4306. out[1] = v[1];
  4307. return out;
  4308. },
  4309. /**
  4310. * 设置向量的两个项
  4311. * @param {Vector2} out
  4312. * @param {number} a
  4313. * @param {number} b
  4314. * @return {Vector2} 结果
  4315. */
  4316. set: function (out, a, b) {
  4317. out[0] = a;
  4318. out[1] = b;
  4319. return out;
  4320. },
  4321. /**
  4322. * 向量相加
  4323. * @param {Vector2} out
  4324. * @param {Vector2} v1
  4325. * @param {Vector2} v2
  4326. */
  4327. add: function (out, v1, v2) {
  4328. out[0] = v1[0] + v2[0];
  4329. out[1] = v1[1] + v2[1];
  4330. return out;
  4331. },
  4332. /**
  4333. * 向量缩放后相加
  4334. * @param {Vector2} out
  4335. * @param {Vector2} v1
  4336. * @param {Vector2} v2
  4337. * @param {number} a
  4338. */
  4339. scaleAndAdd: function (out, v1, v2, a) {
  4340. out[0] = v1[0] + v2[0] * a;
  4341. out[1] = v1[1] + v2[1] * a;
  4342. return out;
  4343. },
  4344. /**
  4345. * 向量相减
  4346. * @param {Vector2} out
  4347. * @param {Vector2} v1
  4348. * @param {Vector2} v2
  4349. */
  4350. sub: function (out, v1, v2) {
  4351. out[0] = v1[0] - v2[0];
  4352. out[1] = v1[1] - v2[1];
  4353. return out;
  4354. },
  4355. /**
  4356. * 向量长度
  4357. * @param {Vector2} v
  4358. * @return {number}
  4359. */
  4360. len: function (v) {
  4361. return Math.sqrt(this.lenSquare(v));
  4362. },
  4363. /**
  4364. * 向量长度平方
  4365. * @param {Vector2} v
  4366. * @return {number}
  4367. */
  4368. lenSquare: function (v) {
  4369. return v[0] * v[0] + v[1] * v[1];
  4370. },
  4371. /**
  4372. * 向量乘法
  4373. * @param {Vector2} out
  4374. * @param {Vector2} v1
  4375. * @param {Vector2} v2
  4376. */
  4377. mul: function (out, v1, v2) {
  4378. out[0] = v1[0] * v2[0];
  4379. out[1] = v1[1] * v2[1];
  4380. return out;
  4381. },
  4382. /**
  4383. * 向量除法
  4384. * @param {Vector2} out
  4385. * @param {Vector2} v1
  4386. * @param {Vector2} v2
  4387. */
  4388. div: function (out, v1, v2) {
  4389. out[0] = v1[0] / v2[0];
  4390. out[1] = v1[1] / v2[1];
  4391. return out;
  4392. },
  4393. /**
  4394. * 向量点乘
  4395. * @param {Vector2} v1
  4396. * @param {Vector2} v2
  4397. * @return {number}
  4398. */
  4399. dot: function (v1, v2) {
  4400. return v1[0] * v2[0] + v1[1] * v2[1];
  4401. },
  4402. /**
  4403. * 向量缩放
  4404. * @param {Vector2} out
  4405. * @param {Vector2} v
  4406. * @param {number} s
  4407. */
  4408. scale: function (out, v, s) {
  4409. out[0] = v[0] * s;
  4410. out[1] = v[1] * s;
  4411. return out;
  4412. },
  4413. /**
  4414. * 向量归一化
  4415. * @param {Vector2} out
  4416. * @param {Vector2} v
  4417. */
  4418. normalize: function (out, v) {
  4419. var d = vector.len(v);
  4420. if (d === 0) {
  4421. out[0] = 0;
  4422. out[1] = 0;
  4423. }
  4424. else {
  4425. out[0] = v[0] / d;
  4426. out[1] = v[1] / d;
  4427. }
  4428. return out;
  4429. },
  4430. /**
  4431. * 计算向量间距离
  4432. * @param {Vector2} v1
  4433. * @param {Vector2} v2
  4434. * @return {number}
  4435. */
  4436. distance: function (v1, v2) {
  4437. return Math.sqrt(
  4438. (v1[0] - v2[0]) * (v1[0] - v2[0])
  4439. + (v1[1] - v2[1]) * (v1[1] - v2[1])
  4440. );
  4441. },
  4442. /**
  4443. * 向量距离平方
  4444. * @param {Vector2} v1
  4445. * @param {Vector2} v2
  4446. * @return {number}
  4447. */
  4448. distanceSquare: function (v1, v2) {
  4449. return (v1[0] - v2[0]) * (v1[0] - v2[0])
  4450. + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  4451. },
  4452. /**
  4453. * 求负向量
  4454. * @param {Vector2} out
  4455. * @param {Vector2} v
  4456. */
  4457. negate: function (out, v) {
  4458. out[0] = -v[0];
  4459. out[1] = -v[1];
  4460. return out;
  4461. },
  4462. /**
  4463. * 插值两个点
  4464. * @param {Vector2} out
  4465. * @param {Vector2} v1
  4466. * @param {Vector2} v2
  4467. * @param {number} t
  4468. */
  4469. lerp: function (out, v1, v2, t) {
  4470. out[0] = v1[0] + t * (v2[0] - v1[0]);
  4471. out[1] = v1[1] + t * (v2[1] - v1[1]);
  4472. return out;
  4473. },
  4474. /**
  4475. * 矩阵左乘向量
  4476. * @param {Vector2} out
  4477. * @param {Vector2} v
  4478. * @param {Vector2} m
  4479. */
  4480. applyTransform: function (out, v, m) {
  4481. var x = v[0];
  4482. var y = v[1];
  4483. out[0] = m[0] * x + m[2] * y + m[4];
  4484. out[1] = m[1] * x + m[3] * y + m[5];
  4485. return out;
  4486. },
  4487. /**
  4488. * 求两个向量最小值
  4489. * @param {Vector2} out
  4490. * @param {Vector2} v1
  4491. * @param {Vector2} v2
  4492. */
  4493. min: function (out, v1, v2) {
  4494. out[0] = Math.min(v1[0], v2[0]);
  4495. out[1] = Math.min(v1[1], v2[1]);
  4496. return out;
  4497. },
  4498. /**
  4499. * 求两个向量最大值
  4500. * @param {Vector2} out
  4501. * @param {Vector2} v1
  4502. * @param {Vector2} v2
  4503. */
  4504. max: function (out, v1, v2) {
  4505. out[0] = Math.max(v1[0], v2[0]);
  4506. out[1] = Math.max(v1[1], v2[1]);
  4507. return out;
  4508. }
  4509. };
  4510. vector.length = vector.len;
  4511. vector.lengthSquare = vector.lenSquare;
  4512. vector.dist = vector.distance;
  4513. vector.distSquare = vector.distanceSquare;
  4514. module.exports = vector;
  4515. /***/ },
  4516. /* 11 */
  4517. /***/ function(module, exports) {
  4518. var ArrayCtor = typeof Float32Array === 'undefined'
  4519. ? Array
  4520. : Float32Array;
  4521. /**
  4522. * 3x2矩阵操作类
  4523. * @exports zrender/tool/matrix
  4524. */
  4525. var matrix = {
  4526. /**
  4527. * 创建一个单位矩阵
  4528. * @return {Float32Array|Array.<number>}
  4529. */
  4530. create : function() {
  4531. var out = new ArrayCtor(6);
  4532. matrix.identity(out);
  4533. return out;
  4534. },
  4535. /**
  4536. * 设置矩阵为单位矩阵
  4537. * @param {Float32Array|Array.<number>} out
  4538. */
  4539. identity : function(out) {
  4540. out[0] = 1;
  4541. out[1] = 0;
  4542. out[2] = 0;
  4543. out[3] = 1;
  4544. out[4] = 0;
  4545. out[5] = 0;
  4546. return out;
  4547. },
  4548. /**
  4549. * 复制矩阵
  4550. * @param {Float32Array|Array.<number>} out
  4551. * @param {Float32Array|Array.<number>} m
  4552. */
  4553. copy: function(out, m) {
  4554. out[0] = m[0];
  4555. out[1] = m[1];
  4556. out[2] = m[2];
  4557. out[3] = m[3];
  4558. out[4] = m[4];
  4559. out[5] = m[5];
  4560. return out;
  4561. },
  4562. /**
  4563. * 矩阵相乘
  4564. * @param {Float32Array|Array.<number>} out
  4565. * @param {Float32Array|Array.<number>} m1
  4566. * @param {Float32Array|Array.<number>} m2
  4567. */
  4568. mul : function (out, m1, m2) {
  4569. // Consider matrix.mul(m, m2, m);
  4570. // where out is the same as m2.
  4571. // So use temp variable to escape error.
  4572. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  4573. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  4574. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  4575. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  4576. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  4577. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  4578. out[0] = out0;
  4579. out[1] = out1;
  4580. out[2] = out2;
  4581. out[3] = out3;
  4582. out[4] = out4;
  4583. out[5] = out5;
  4584. return out;
  4585. },
  4586. /**
  4587. * 平移变换
  4588. * @param {Float32Array|Array.<number>} out
  4589. * @param {Float32Array|Array.<number>} a
  4590. * @param {Float32Array|Array.<number>} v
  4591. */
  4592. translate : function(out, a, v) {
  4593. out[0] = a[0];
  4594. out[1] = a[1];
  4595. out[2] = a[2];
  4596. out[3] = a[3];
  4597. out[4] = a[4] + v[0];
  4598. out[5] = a[5] + v[1];
  4599. return out;
  4600. },
  4601. /**
  4602. * 旋转变换
  4603. * @param {Float32Array|Array.<number>} out
  4604. * @param {Float32Array|Array.<number>} a
  4605. * @param {number} rad
  4606. */
  4607. rotate : function(out, a, rad) {
  4608. var aa = a[0];
  4609. var ac = a[2];
  4610. var atx = a[4];
  4611. var ab = a[1];
  4612. var ad = a[3];
  4613. var aty = a[5];
  4614. var st = Math.sin(rad);
  4615. var ct = Math.cos(rad);
  4616. out[0] = aa * ct + ab * st;
  4617. out[1] = -aa * st + ab * ct;
  4618. out[2] = ac * ct + ad * st;
  4619. out[3] = -ac * st + ct * ad;
  4620. out[4] = ct * atx + st * aty;
  4621. out[5] = ct * aty - st * atx;
  4622. return out;
  4623. },
  4624. /**
  4625. * 缩放变换
  4626. * @param {Float32Array|Array.<number>} out
  4627. * @param {Float32Array|Array.<number>} a
  4628. * @param {Float32Array|Array.<number>} v
  4629. */
  4630. scale : function(out, a, v) {
  4631. var vx = v[0];
  4632. var vy = v[1];
  4633. out[0] = a[0] * vx;
  4634. out[1] = a[1] * vy;
  4635. out[2] = a[2] * vx;
  4636. out[3] = a[3] * vy;
  4637. out[4] = a[4] * vx;
  4638. out[5] = a[5] * vy;
  4639. return out;
  4640. },
  4641. /**
  4642. * 求逆矩阵
  4643. * @param {Float32Array|Array.<number>} out
  4644. * @param {Float32Array|Array.<number>} a
  4645. */
  4646. invert : function(out, a) {
  4647. var aa = a[0];
  4648. var ac = a[2];
  4649. var atx = a[4];
  4650. var ab = a[1];
  4651. var ad = a[3];
  4652. var aty = a[5];
  4653. var det = aa * ad - ab * ac;
  4654. if (!det) {
  4655. return null;
  4656. }
  4657. det = 1.0 / det;
  4658. out[0] = ad * det;
  4659. out[1] = -ab * det;
  4660. out[2] = -ac * det;
  4661. out[3] = aa * det;
  4662. out[4] = (ac * aty - ad * atx) * det;
  4663. out[5] = (ab * atx - aa * aty) * det;
  4664. return out;
  4665. }
  4666. };
  4667. module.exports = matrix;
  4668. /***/ },
  4669. /* 12 */
  4670. /***/ function(module, exports, __webpack_require__) {
  4671. /**
  4672. * @module echarts/model/Model
  4673. */
  4674. var zrUtil = __webpack_require__(4);
  4675. var clazzUtil = __webpack_require__(13);
  4676. /**
  4677. * @alias module:echarts/model/Model
  4678. * @constructor
  4679. * @param {Object} option
  4680. * @param {module:echarts/model/Model} [parentModel]
  4681. * @param {module:echarts/model/Global} [ecModel]
  4682. */
  4683. function Model(option, parentModel, ecModel) {
  4684. /**
  4685. * @type {module:echarts/model/Model}
  4686. * @readOnly
  4687. */
  4688. this.parentModel = parentModel;
  4689. /**
  4690. * @type {module:echarts/model/Global}
  4691. * @readOnly
  4692. */
  4693. this.ecModel = ecModel;
  4694. /**
  4695. * @type {Object}
  4696. * @protected
  4697. */
  4698. this.option = option;
  4699. // Simple optimization
  4700. // if (this.init) {
  4701. // if (arguments.length <= 4) {
  4702. // this.init(option, parentModel, ecModel, extraOpt);
  4703. // }
  4704. // else {
  4705. // this.init.apply(this, arguments);
  4706. // }
  4707. // }
  4708. }
  4709. Model.prototype = {
  4710. constructor: Model,
  4711. /**
  4712. * Model 的初始化函数
  4713. * @param {Object} option
  4714. */
  4715. init: null,
  4716. /**
  4717. * 从新的 Option merge
  4718. */
  4719. mergeOption: function (option) {
  4720. zrUtil.merge(this.option, option, true);
  4721. },
  4722. /**
  4723. * @param {string} path
  4724. * @param {boolean} [ignoreParent=false]
  4725. * @return {*}
  4726. */
  4727. get: function (path, ignoreParent) {
  4728. if (!path) {
  4729. return this.option;
  4730. }
  4731. if (typeof path === 'string') {
  4732. path = path.split('.');
  4733. }
  4734. var obj = this.option;
  4735. var parentModel = this.parentModel;
  4736. for (var i = 0; i < path.length; i++) {
  4737. // Ignore empty
  4738. if (!path[i]) {
  4739. continue;
  4740. }
  4741. // obj could be number/string/... (like 0)
  4742. obj = (obj && typeof obj === 'object') ? obj[path[i]] : null;
  4743. if (obj == null) {
  4744. break;
  4745. }
  4746. }
  4747. if (obj == null && parentModel && !ignoreParent) {
  4748. obj = parentModel.get(path);
  4749. }
  4750. return obj;
  4751. },
  4752. /**
  4753. * @param {string} key
  4754. * @param {boolean} [ignoreParent=false]
  4755. * @return {*}
  4756. */
  4757. getShallow: function (key, ignoreParent) {
  4758. var option = this.option;
  4759. var val = option == null ? option : option[key];
  4760. var parentModel = this.parentModel;
  4761. if (val == null && parentModel && !ignoreParent) {
  4762. val = parentModel.getShallow(key);
  4763. }
  4764. return val;
  4765. },
  4766. /**
  4767. * @param {string} path
  4768. * @param {module:echarts/model/Model} [parentModel]
  4769. * @return {module:echarts/model/Model}
  4770. */
  4771. getModel: function (path, parentModel) {
  4772. var obj = this.get(path, true);
  4773. var thisParentModel = this.parentModel;
  4774. var model = new Model(
  4775. obj, parentModel || (thisParentModel && thisParentModel.getModel(path)),
  4776. this.ecModel
  4777. );
  4778. return model;
  4779. },
  4780. /**
  4781. * If model has option
  4782. */
  4783. isEmpty: function () {
  4784. return this.option == null;
  4785. },
  4786. restoreData: function () {},
  4787. // Pending
  4788. clone: function () {
  4789. var Ctor = this.constructor;
  4790. return new Ctor(zrUtil.clone(this.option));
  4791. },
  4792. setReadOnly: function (properties) {
  4793. clazzUtil.setReadOnly(this, properties);
  4794. }
  4795. };
  4796. // Enable Model.extend.
  4797. clazzUtil.enableClassExtend(Model);
  4798. var mixin = zrUtil.mixin;
  4799. mixin(Model, __webpack_require__(14));
  4800. mixin(Model, __webpack_require__(16));
  4801. mixin(Model, __webpack_require__(17));
  4802. mixin(Model, __webpack_require__(18));
  4803. module.exports = Model;
  4804. /***/ },
  4805. /* 13 */
  4806. /***/ function(module, exports, __webpack_require__) {
  4807. var zrUtil = __webpack_require__(4);
  4808. var clazz = {};
  4809. var TYPE_DELIMITER = '.';
  4810. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  4811. /**
  4812. * @public
  4813. */
  4814. var parseClassType = clazz.parseClassType = function (componentType) {
  4815. var ret = {main: '', sub: ''};
  4816. if (componentType) {
  4817. componentType = componentType.split(TYPE_DELIMITER);
  4818. ret.main = componentType[0] || '';
  4819. ret.sub = componentType[1] || '';
  4820. }
  4821. return ret;
  4822. };
  4823. /**
  4824. * @public
  4825. */
  4826. clazz.enableClassExtend = function (RootClass, mandatoryMethods) {
  4827. RootClass.$constructor = RootClass;
  4828. RootClass.extend = function (proto) {
  4829. if (true) {
  4830. zrUtil.each(mandatoryMethods, function (method) {
  4831. if (!proto[method]) {
  4832. console.warn(
  4833. 'Method `' + method + '` should be implemented'
  4834. + (proto.type ? ' in ' + proto.type : '') + '.'
  4835. );
  4836. }
  4837. });
  4838. }
  4839. var superClass = this;
  4840. var ExtendedClass = function () {
  4841. if (!proto.$constructor) {
  4842. superClass.apply(this, arguments);
  4843. }
  4844. else {
  4845. proto.$constructor.apply(this, arguments);
  4846. }
  4847. };
  4848. zrUtil.extend(ExtendedClass.prototype, proto);
  4849. ExtendedClass.extend = this.extend;
  4850. ExtendedClass.superCall = superCall;
  4851. ExtendedClass.superApply = superApply;
  4852. zrUtil.inherits(ExtendedClass, this);
  4853. ExtendedClass.superClass = superClass;
  4854. return ExtendedClass;
  4855. };
  4856. };
  4857. // superCall should have class info, which can not be fetch from 'this'.
  4858. // Consider this case:
  4859. // class A has method f,
  4860. // class B inherits class A, overrides method f, f call superApply('f'),
  4861. // class C inherits class B, do not overrides method f,
  4862. // then when method of class C is called, dead loop occured.
  4863. function superCall(context, methodName) {
  4864. var args = zrUtil.slice(arguments, 2);
  4865. return this.superClass.prototype[methodName].apply(context, args);
  4866. }
  4867. function superApply(context, methodName, args) {
  4868. return this.superClass.prototype[methodName].apply(context, args);
  4869. }
  4870. /**
  4871. * @param {Object} entity
  4872. * @param {Object} options
  4873. * @param {boolean} [options.registerWhenExtend]
  4874. * @public
  4875. */
  4876. clazz.enableClassManagement = function (entity, options) {
  4877. options = options || {};
  4878. /**
  4879. * Component model classes
  4880. * key: componentType,
  4881. * value:
  4882. * componentClass, when componentType is 'xxx'
  4883. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  4884. * @type {Object}
  4885. */
  4886. var storage = {};
  4887. entity.registerClass = function (Clazz, componentType) {
  4888. if (componentType) {
  4889. componentType = parseClassType(componentType);
  4890. if (!componentType.sub) {
  4891. if (true) {
  4892. if (storage[componentType.main]) {
  4893. console.warn(componentType.main + ' exists.');
  4894. }
  4895. }
  4896. storage[componentType.main] = Clazz;
  4897. }
  4898. else if (componentType.sub !== IS_CONTAINER) {
  4899. var container = makeContainer(componentType);
  4900. container[componentType.sub] = Clazz;
  4901. }
  4902. }
  4903. return Clazz;
  4904. };
  4905. entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) {
  4906. var Clazz = storage[componentTypeMain];
  4907. if (Clazz && Clazz[IS_CONTAINER]) {
  4908. Clazz = subType ? Clazz[subType] : null;
  4909. }
  4910. if (throwWhenNotFound && !Clazz) {
  4911. throw new Error(
  4912. 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists. Load it first.'
  4913. );
  4914. }
  4915. return Clazz;
  4916. };
  4917. entity.getClassesByMainType = function (componentType) {
  4918. componentType = parseClassType(componentType);
  4919. var result = [];
  4920. var obj = storage[componentType.main];
  4921. if (obj && obj[IS_CONTAINER]) {
  4922. zrUtil.each(obj, function (o, type) {
  4923. type !== IS_CONTAINER && result.push(o);
  4924. });
  4925. }
  4926. else {
  4927. result.push(obj);
  4928. }
  4929. return result;
  4930. };
  4931. entity.hasClass = function (componentType) {
  4932. // Just consider componentType.main.
  4933. componentType = parseClassType(componentType);
  4934. return !!storage[componentType.main];
  4935. };
  4936. /**
  4937. * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
  4938. */
  4939. entity.getAllClassMainTypes = function () {
  4940. var types = [];
  4941. zrUtil.each(storage, function (obj, type) {
  4942. types.push(type);
  4943. });
  4944. return types;
  4945. };
  4946. /**
  4947. * If a main type is container and has sub types
  4948. * @param {string} mainType
  4949. * @return {boolean}
  4950. */
  4951. entity.hasSubTypes = function (componentType) {
  4952. componentType = parseClassType(componentType);
  4953. var obj = storage[componentType.main];
  4954. return obj && obj[IS_CONTAINER];
  4955. };
  4956. entity.parseClassType = parseClassType;
  4957. function makeContainer(componentType) {
  4958. var container = storage[componentType.main];
  4959. if (!container || !container[IS_CONTAINER]) {
  4960. container = storage[componentType.main] = {};
  4961. container[IS_CONTAINER] = true;
  4962. }
  4963. return container;
  4964. }
  4965. if (options.registerWhenExtend) {
  4966. var originalExtend = entity.extend;
  4967. if (originalExtend) {
  4968. entity.extend = function (proto) {
  4969. var ExtendedClass = originalExtend.call(this, proto);
  4970. return entity.registerClass(ExtendedClass, proto.type);
  4971. };
  4972. }
  4973. }
  4974. return entity;
  4975. };
  4976. /**
  4977. * @param {string|Array.<string>} properties
  4978. */
  4979. clazz.setReadOnly = function (obj, properties) {
  4980. // FIXME It seems broken in IE8 simulation of IE11
  4981. // if (!zrUtil.isArray(properties)) {
  4982. // properties = properties != null ? [properties] : [];
  4983. // }
  4984. // zrUtil.each(properties, function (prop) {
  4985. // var value = obj[prop];
  4986. // Object.defineProperty
  4987. // && Object.defineProperty(obj, prop, {
  4988. // value: value, writable: false
  4989. // });
  4990. // zrUtil.isArray(obj[prop])
  4991. // && Object.freeze
  4992. // && Object.freeze(obj[prop]);
  4993. // });
  4994. };
  4995. module.exports = clazz;
  4996. /***/ },
  4997. /* 14 */
  4998. /***/ function(module, exports, __webpack_require__) {
  4999. var getLineStyle = __webpack_require__(15)(
  5000. [
  5001. ['lineWidth', 'width'],
  5002. ['stroke', 'color'],
  5003. ['opacity'],
  5004. ['shadowBlur'],
  5005. ['shadowOffsetX'],
  5006. ['shadowOffsetY'],
  5007. ['shadowColor']
  5008. ]
  5009. );
  5010. module.exports = {
  5011. getLineStyle: function (excludes) {
  5012. var style = getLineStyle.call(this, excludes);
  5013. var lineDash = this.getLineDash(style.lineWidth);
  5014. lineDash && (style.lineDash = lineDash);
  5015. return style;
  5016. },
  5017. getLineDash: function (lineWidth) {
  5018. if (lineWidth == null) {
  5019. lineWidth = 1;
  5020. }
  5021. var lineType = this.get('type');
  5022. var dotSize = Math.max(lineWidth, 2);
  5023. var dashSize = lineWidth * 4;
  5024. return (lineType === 'solid' || lineType == null) ? null
  5025. : (lineType === 'dashed' ? [dashSize, dashSize] : [dotSize, dotSize]);
  5026. }
  5027. };
  5028. /***/ },
  5029. /* 15 */
  5030. /***/ function(module, exports, __webpack_require__) {
  5031. // TODO Parse shadow style
  5032. // TODO Only shallow path support
  5033. var zrUtil = __webpack_require__(4);
  5034. module.exports = function (properties) {
  5035. // Normalize
  5036. for (var i = 0; i < properties.length; i++) {
  5037. if (!properties[i][1]) {
  5038. properties[i][1] = properties[i][0];
  5039. }
  5040. }
  5041. return function (excludes) {
  5042. var style = {};
  5043. for (var i = 0; i < properties.length; i++) {
  5044. var propName = properties[i][1];
  5045. if (excludes && zrUtil.indexOf(excludes, propName) >= 0) {
  5046. continue;
  5047. }
  5048. var val = this.getShallow(propName);
  5049. if (val != null) {
  5050. style[properties[i][0]] = val;
  5051. }
  5052. }
  5053. return style;
  5054. };
  5055. };
  5056. /***/ },
  5057. /* 16 */
  5058. /***/ function(module, exports, __webpack_require__) {
  5059. module.exports = {
  5060. getAreaStyle: __webpack_require__(15)(
  5061. [
  5062. ['fill', 'color'],
  5063. ['shadowBlur'],
  5064. ['shadowOffsetX'],
  5065. ['shadowOffsetY'],
  5066. ['opacity'],
  5067. ['shadowColor']
  5068. ]
  5069. )
  5070. };
  5071. /***/ },
  5072. /* 17 */
  5073. /***/ function(module, exports, __webpack_require__) {
  5074. var textContain = __webpack_require__(8);
  5075. function getShallow(model, path) {
  5076. return model && model.getShallow(path);
  5077. }
  5078. module.exports = {
  5079. /**
  5080. * Get color property or get color from option.textStyle.color
  5081. * @return {string}
  5082. */
  5083. getTextColor: function () {
  5084. var ecModel = this.ecModel;
  5085. return this.getShallow('color')
  5086. || (ecModel && ecModel.get('textStyle.color'));
  5087. },
  5088. /**
  5089. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  5090. * @return {string}
  5091. */
  5092. getFont: function () {
  5093. var ecModel = this.ecModel;
  5094. var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
  5095. return [
  5096. // FIXME in node-canvas fontWeight is before fontStyle
  5097. this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'),
  5098. this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'),
  5099. (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px',
  5100. this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif'
  5101. ].join(' ');
  5102. },
  5103. getTextRect: function (text) {
  5104. return textContain.getBoundingRect(
  5105. text,
  5106. this.getFont(),
  5107. this.getShallow('align'),
  5108. this.getShallow('baseline')
  5109. );
  5110. },
  5111. truncateText: function (text, containerWidth, ellipsis, options) {
  5112. return textContain.truncateText(
  5113. text, containerWidth, this.getFont(), ellipsis, options
  5114. );
  5115. }
  5116. };
  5117. /***/ },
  5118. /* 18 */
  5119. /***/ function(module, exports, __webpack_require__) {
  5120. var getItemStyle = __webpack_require__(15)(
  5121. [
  5122. ['fill', 'color'],
  5123. ['stroke', 'borderColor'],
  5124. ['lineWidth', 'borderWidth'],
  5125. ['opacity'],
  5126. ['shadowBlur'],
  5127. ['shadowOffsetX'],
  5128. ['shadowOffsetY'],
  5129. ['shadowColor'],
  5130. ['textPosition'],
  5131. ['textAlign']
  5132. ]
  5133. );
  5134. module.exports = {
  5135. getItemStyle: function (excludes) {
  5136. var style = getItemStyle.call(this, excludes);
  5137. var lineDash = this.getBorderLineDash();
  5138. lineDash && (style.lineDash = lineDash);
  5139. return style;
  5140. },
  5141. getBorderLineDash: function () {
  5142. var lineType = this.get('borderType');
  5143. return (lineType === 'solid' || lineType == null) ? null
  5144. : (lineType === 'dashed' ? [5, 5] : [1, 1]);
  5145. }
  5146. };
  5147. /***/ },
  5148. /* 19 */
  5149. /***/ function(module, exports, __webpack_require__) {
  5150. /**
  5151. * Component model
  5152. *
  5153. * @module echarts/model/Component
  5154. */
  5155. var Model = __webpack_require__(12);
  5156. var zrUtil = __webpack_require__(4);
  5157. var arrayPush = Array.prototype.push;
  5158. var componentUtil = __webpack_require__(20);
  5159. var clazzUtil = __webpack_require__(13);
  5160. var layout = __webpack_require__(21);
  5161. /**
  5162. * @alias module:echarts/model/Component
  5163. * @constructor
  5164. * @param {Object} option
  5165. * @param {module:echarts/model/Model} parentModel
  5166. * @param {module:echarts/model/Model} ecModel
  5167. */
  5168. var ComponentModel = Model.extend({
  5169. type: 'component',
  5170. /**
  5171. * @readOnly
  5172. * @type {string}
  5173. */
  5174. id: '',
  5175. /**
  5176. * @readOnly
  5177. */
  5178. name: '',
  5179. /**
  5180. * @readOnly
  5181. * @type {string}
  5182. */
  5183. mainType: '',
  5184. /**
  5185. * @readOnly
  5186. * @type {string}
  5187. */
  5188. subType: '',
  5189. /**
  5190. * @readOnly
  5191. * @type {number}
  5192. */
  5193. componentIndex: 0,
  5194. /**
  5195. * @type {Object}
  5196. * @protected
  5197. */
  5198. defaultOption: null,
  5199. /**
  5200. * @type {module:echarts/model/Global}
  5201. * @readOnly
  5202. */
  5203. ecModel: null,
  5204. /**
  5205. * key: componentType
  5206. * value: Component model list, can not be null.
  5207. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  5208. * @readOnly
  5209. */
  5210. dependentModels: [],
  5211. /**
  5212. * @type {string}
  5213. * @readOnly
  5214. */
  5215. uid: null,
  5216. /**
  5217. * Support merge layout params.
  5218. * Only support 'box' now (left/right/top/bottom/width/height).
  5219. * @type {string|Object} Object can be {ignoreSize: true}
  5220. * @readOnly
  5221. */
  5222. layoutMode: null,
  5223. $constructor: function (option, parentModel, ecModel, extraOpt) {
  5224. Model.call(this, option, parentModel, ecModel, extraOpt);
  5225. this.uid = componentUtil.getUID('componentModel');
  5226. },
  5227. init: function (option, parentModel, ecModel, extraOpt) {
  5228. this.mergeDefaultAndTheme(option, ecModel);
  5229. },
  5230. mergeDefaultAndTheme: function (option, ecModel) {
  5231. var layoutMode = this.layoutMode;
  5232. var inputPositionParams = layoutMode
  5233. ? layout.getLayoutParams(option) : {};
  5234. var themeModel = ecModel.getTheme();
  5235. zrUtil.merge(option, themeModel.get(this.mainType));
  5236. zrUtil.merge(option, this.getDefaultOption());
  5237. if (layoutMode) {
  5238. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  5239. }
  5240. },
  5241. mergeOption: function (option, extraOpt) {
  5242. zrUtil.merge(this.option, option, true);
  5243. var layoutMode = this.layoutMode;
  5244. if (layoutMode) {
  5245. layout.mergeLayoutParam(this.option, option, layoutMode);
  5246. }
  5247. },
  5248. // Hooker after init or mergeOption
  5249. optionUpdated: function (newCptOption, isInit) {},
  5250. getDefaultOption: function () {
  5251. if (!this.hasOwnProperty('__defaultOption')) {
  5252. var optList = [];
  5253. var Class = this.constructor;
  5254. while (Class) {
  5255. var opt = Class.prototype.defaultOption;
  5256. opt && optList.push(opt);
  5257. Class = Class.superClass;
  5258. }
  5259. var defaultOption = {};
  5260. for (var i = optList.length - 1; i >= 0; i--) {
  5261. defaultOption = zrUtil.merge(defaultOption, optList[i], true);
  5262. }
  5263. this.__defaultOption = defaultOption;
  5264. }
  5265. return this.__defaultOption;
  5266. },
  5267. getReferringComponents: function (mainType) {
  5268. return this.ecModel.queryComponents({
  5269. mainType: mainType,
  5270. index: this.get(mainType + 'Index', true),
  5271. id: this.get(mainType + 'Id', true)
  5272. });
  5273. }
  5274. });
  5275. // Reset ComponentModel.extend, add preConstruct.
  5276. // clazzUtil.enableClassExtend(
  5277. // ComponentModel,
  5278. // function (option, parentModel, ecModel, extraOpt) {
  5279. // // Set dependentModels, componentIndex, name, id, mainType, subType.
  5280. // zrUtil.extend(this, extraOpt);
  5281. // this.uid = componentUtil.getUID('componentModel');
  5282. // // this.setReadOnly([
  5283. // // 'type', 'id', 'uid', 'name', 'mainType', 'subType',
  5284. // // 'dependentModels', 'componentIndex'
  5285. // // ]);
  5286. // }
  5287. // );
  5288. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  5289. clazzUtil.enableClassManagement(
  5290. ComponentModel, {registerWhenExtend: true}
  5291. );
  5292. componentUtil.enableSubTypeDefaulter(ComponentModel);
  5293. // Add capability of ComponentModel.topologicalTravel.
  5294. componentUtil.enableTopologicalTravel(ComponentModel, getDependencies);
  5295. function getDependencies(componentType) {
  5296. var deps = [];
  5297. zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) {
  5298. arrayPush.apply(deps, Clazz.prototype.dependencies || []);
  5299. });
  5300. // Ensure main type
  5301. return zrUtil.map(deps, function (type) {
  5302. return clazzUtil.parseClassType(type).main;
  5303. });
  5304. }
  5305. zrUtil.mixin(ComponentModel, __webpack_require__(22));
  5306. module.exports = ComponentModel;
  5307. /***/ },
  5308. /* 20 */
  5309. /***/ function(module, exports, __webpack_require__) {
  5310. var zrUtil = __webpack_require__(4);
  5311. var clazz = __webpack_require__(13);
  5312. var parseClassType = clazz.parseClassType;
  5313. var base = 0;
  5314. var componentUtil = {};
  5315. var DELIMITER = '_';
  5316. /**
  5317. * @public
  5318. * @param {string} type
  5319. * @return {string}
  5320. */
  5321. componentUtil.getUID = function (type) {
  5322. // Considering the case of crossing js context,
  5323. // use Math.random to make id as unique as possible.
  5324. return [(type || ''), base++, Math.random()].join(DELIMITER);
  5325. };
  5326. /**
  5327. * @inner
  5328. */
  5329. componentUtil.enableSubTypeDefaulter = function (entity) {
  5330. var subTypeDefaulters = {};
  5331. entity.registerSubTypeDefaulter = function (componentType, defaulter) {
  5332. componentType = parseClassType(componentType);
  5333. subTypeDefaulters[componentType.main] = defaulter;
  5334. };
  5335. entity.determineSubType = function (componentType, option) {
  5336. var type = option.type;
  5337. if (!type) {
  5338. var componentTypeMain = parseClassType(componentType).main;
  5339. if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) {
  5340. type = subTypeDefaulters[componentTypeMain](option);
  5341. }
  5342. }
  5343. return type;
  5344. };
  5345. return entity;
  5346. };
  5347. /**
  5348. * Topological travel on Activity Network (Activity On Vertices).
  5349. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  5350. *
  5351. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  5352. *
  5353. * If there is circle dependencey, Error will be thrown.
  5354. *
  5355. */
  5356. componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) {
  5357. /**
  5358. * @public
  5359. * @param {Array.<string>} targetNameList Target Component type list.
  5360. * Can be ['aa', 'bb', 'aa.xx']
  5361. * @param {Array.<string>} fullNameList By which we can build dependency graph.
  5362. * @param {Function} callback Params: componentType, dependencies.
  5363. * @param {Object} context Scope of callback.
  5364. */
  5365. entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) {
  5366. if (!targetNameList.length) {
  5367. return;
  5368. }
  5369. var result = makeDepndencyGraph(fullNameList);
  5370. var graph = result.graph;
  5371. var stack = result.noEntryList;
  5372. var targetNameSet = {};
  5373. zrUtil.each(targetNameList, function (name) {
  5374. targetNameSet[name] = true;
  5375. });
  5376. while (stack.length) {
  5377. var currComponentType = stack.pop();
  5378. var currVertex = graph[currComponentType];
  5379. var isInTargetNameSet = !!targetNameSet[currComponentType];
  5380. if (isInTargetNameSet) {
  5381. callback.call(context, currComponentType, currVertex.originalDeps.slice());
  5382. delete targetNameSet[currComponentType];
  5383. }
  5384. zrUtil.each(
  5385. currVertex.successor,
  5386. isInTargetNameSet ? removeEdgeAndAdd : removeEdge
  5387. );
  5388. }
  5389. zrUtil.each(targetNameSet, function () {
  5390. throw new Error('Circle dependency may exists');
  5391. });
  5392. function removeEdge(succComponentType) {
  5393. graph[succComponentType].entryCount--;
  5394. if (graph[succComponentType].entryCount === 0) {
  5395. stack.push(succComponentType);
  5396. }
  5397. }
  5398. // Consider this case: legend depends on series, and we call
  5399. // chart.setOption({series: [...]}), where only series is in option.
  5400. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  5401. // not be called, but only sereis.mergeOption is called. Thus legend
  5402. // have no chance to update its local record about series (like which
  5403. // name of series is available in legend).
  5404. function removeEdgeAndAdd(succComponentType) {
  5405. targetNameSet[succComponentType] = true;
  5406. removeEdge(succComponentType);
  5407. }
  5408. };
  5409. /**
  5410. * DepndencyGraph: {Object}
  5411. * key: conponentType,
  5412. * value: {
  5413. * successor: [conponentTypes...],
  5414. * originalDeps: [conponentTypes...],
  5415. * entryCount: {number}
  5416. * }
  5417. */
  5418. function makeDepndencyGraph(fullNameList) {
  5419. var graph = {};
  5420. var noEntryList = [];
  5421. zrUtil.each(fullNameList, function (name) {
  5422. var thisItem = createDependencyGraphItem(graph, name);
  5423. var originalDeps = thisItem.originalDeps = dependencyGetter(name);
  5424. var availableDeps = getAvailableDependencies(originalDeps, fullNameList);
  5425. thisItem.entryCount = availableDeps.length;
  5426. if (thisItem.entryCount === 0) {
  5427. noEntryList.push(name);
  5428. }
  5429. zrUtil.each(availableDeps, function (dependentName) {
  5430. if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) {
  5431. thisItem.predecessor.push(dependentName);
  5432. }
  5433. var thatItem = createDependencyGraphItem(graph, dependentName);
  5434. if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) {
  5435. thatItem.successor.push(name);
  5436. }
  5437. });
  5438. });
  5439. return {graph: graph, noEntryList: noEntryList};
  5440. }
  5441. function createDependencyGraphItem(graph, name) {
  5442. if (!graph[name]) {
  5443. graph[name] = {predecessor: [], successor: []};
  5444. }
  5445. return graph[name];
  5446. }
  5447. function getAvailableDependencies(originalDeps, fullNameList) {
  5448. var availableDeps = [];
  5449. zrUtil.each(originalDeps, function (dep) {
  5450. zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep);
  5451. });
  5452. return availableDeps;
  5453. }
  5454. };
  5455. module.exports = componentUtil;
  5456. /***/ },
  5457. /* 21 */
  5458. /***/ function(module, exports, __webpack_require__) {
  5459. 'use strict';
  5460. // Layout helpers for each component positioning
  5461. var zrUtil = __webpack_require__(4);
  5462. var BoundingRect = __webpack_require__(9);
  5463. var numberUtil = __webpack_require__(7);
  5464. var formatUtil = __webpack_require__(6);
  5465. var parsePercent = numberUtil.parsePercent;
  5466. var each = zrUtil.each;
  5467. var layout = {};
  5468. var LOCATION_PARAMS = layout.LOCATION_PARAMS = [
  5469. 'left', 'right', 'top', 'bottom', 'width', 'height'
  5470. ];
  5471. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  5472. var x = 0;
  5473. var y = 0;
  5474. if (maxWidth == null) {
  5475. maxWidth = Infinity;
  5476. }
  5477. if (maxHeight == null) {
  5478. maxHeight = Infinity;
  5479. }
  5480. var currentLineMaxSize = 0;
  5481. group.eachChild(function (child, idx) {
  5482. var position = child.position;
  5483. var rect = child.getBoundingRect();
  5484. var nextChild = group.childAt(idx + 1);
  5485. var nextChildRect = nextChild && nextChild.getBoundingRect();
  5486. var nextX;
  5487. var nextY;
  5488. if (orient === 'horizontal') {
  5489. var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
  5490. nextX = x + moveX;
  5491. // Wrap when width exceeds maxWidth or meet a `newline` group
  5492. if (nextX > maxWidth || child.newline) {
  5493. x = 0;
  5494. nextX = moveX;
  5495. y += currentLineMaxSize + gap;
  5496. currentLineMaxSize = rect.height;
  5497. }
  5498. else {
  5499. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
  5500. }
  5501. }
  5502. else {
  5503. var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
  5504. nextY = y + moveY;
  5505. // Wrap when width exceeds maxHeight or meet a `newline` group
  5506. if (nextY > maxHeight || child.newline) {
  5507. x += currentLineMaxSize + gap;
  5508. y = 0;
  5509. nextY = moveY;
  5510. currentLineMaxSize = rect.width;
  5511. }
  5512. else {
  5513. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
  5514. }
  5515. }
  5516. if (child.newline) {
  5517. return;
  5518. }
  5519. position[0] = x;
  5520. position[1] = y;
  5521. orient === 'horizontal'
  5522. ? (x = nextX + gap)
  5523. : (y = nextY + gap);
  5524. });
  5525. }
  5526. /**
  5527. * VBox or HBox layouting
  5528. * @param {string} orient
  5529. * @param {module:zrender/container/Group} group
  5530. * @param {number} gap
  5531. * @param {number} [width=Infinity]
  5532. * @param {number} [height=Infinity]
  5533. */
  5534. layout.box = boxLayout;
  5535. /**
  5536. * VBox layouting
  5537. * @param {module:zrender/container/Group} group
  5538. * @param {number} gap
  5539. * @param {number} [width=Infinity]
  5540. * @param {number} [height=Infinity]
  5541. */
  5542. layout.vbox = zrUtil.curry(boxLayout, 'vertical');
  5543. /**
  5544. * HBox layouting
  5545. * @param {module:zrender/container/Group} group
  5546. * @param {number} gap
  5547. * @param {number} [width=Infinity]
  5548. * @param {number} [height=Infinity]
  5549. */
  5550. layout.hbox = zrUtil.curry(boxLayout, 'horizontal');
  5551. /**
  5552. * If x or x2 is not specified or 'center' 'left' 'right',
  5553. * the width would be as long as possible.
  5554. * If y or y2 is not specified or 'middle' 'top' 'bottom',
  5555. * the height would be as long as possible.
  5556. *
  5557. * @param {Object} positionInfo
  5558. * @param {number|string} [positionInfo.x]
  5559. * @param {number|string} [positionInfo.y]
  5560. * @param {number|string} [positionInfo.x2]
  5561. * @param {number|string} [positionInfo.y2]
  5562. * @param {Object} containerRect
  5563. * @param {string|number} margin
  5564. * @return {Object} {width, height}
  5565. */
  5566. layout.getAvailableSize = function (positionInfo, containerRect, margin) {
  5567. var containerWidth = containerRect.width;
  5568. var containerHeight = containerRect.height;
  5569. var x = parsePercent(positionInfo.x, containerWidth);
  5570. var y = parsePercent(positionInfo.y, containerHeight);
  5571. var x2 = parsePercent(positionInfo.x2, containerWidth);
  5572. var y2 = parsePercent(positionInfo.y2, containerHeight);
  5573. (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0);
  5574. (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth);
  5575. (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0);
  5576. (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight);
  5577. margin = formatUtil.normalizeCssArray(margin || 0);
  5578. return {
  5579. width: Math.max(x2 - x - margin[1] - margin[3], 0),
  5580. height: Math.max(y2 - y - margin[0] - margin[2], 0)
  5581. };
  5582. };
  5583. /**
  5584. * Parse position info.
  5585. *
  5586. * @param {Object} positionInfo
  5587. * @param {number|string} [positionInfo.left]
  5588. * @param {number|string} [positionInfo.top]
  5589. * @param {number|string} [positionInfo.right]
  5590. * @param {number|string} [positionInfo.bottom]
  5591. * @param {number|string} [positionInfo.width]
  5592. * @param {number|string} [positionInfo.height]
  5593. * @param {number|string} [positionInfo.aspect] Aspect is width / height
  5594. * @param {Object} containerRect
  5595. * @param {string|number} [margin]
  5596. *
  5597. * @return {module:zrender/core/BoundingRect}
  5598. */
  5599. layout.getLayoutRect = function (
  5600. positionInfo, containerRect, margin
  5601. ) {
  5602. margin = formatUtil.normalizeCssArray(margin || 0);
  5603. var containerWidth = containerRect.width;
  5604. var containerHeight = containerRect.height;
  5605. var left = parsePercent(positionInfo.left, containerWidth);
  5606. var top = parsePercent(positionInfo.top, containerHeight);
  5607. var right = parsePercent(positionInfo.right, containerWidth);
  5608. var bottom = parsePercent(positionInfo.bottom, containerHeight);
  5609. var width = parsePercent(positionInfo.width, containerWidth);
  5610. var height = parsePercent(positionInfo.height, containerHeight);
  5611. var verticalMargin = margin[2] + margin[0];
  5612. var horizontalMargin = margin[1] + margin[3];
  5613. var aspect = positionInfo.aspect;
  5614. // If width is not specified, calculate width from left and right
  5615. if (isNaN(width)) {
  5616. width = containerWidth - right - horizontalMargin - left;
  5617. }
  5618. if (isNaN(height)) {
  5619. height = containerHeight - bottom - verticalMargin - top;
  5620. }
  5621. // If width and height are not given
  5622. // 1. Graph should not exceeds the container
  5623. // 2. Aspect must be keeped
  5624. // 3. Graph should take the space as more as possible
  5625. if (isNaN(width) && isNaN(height)) {
  5626. if (aspect > containerWidth / containerHeight) {
  5627. width = containerWidth * 0.8;
  5628. }
  5629. else {
  5630. height = containerHeight * 0.8;
  5631. }
  5632. }
  5633. if (aspect != null) {
  5634. // Calculate width or height with given aspect
  5635. if (isNaN(width)) {
  5636. width = aspect * height;
  5637. }
  5638. if (isNaN(height)) {
  5639. height = width / aspect;
  5640. }
  5641. }
  5642. // If left is not specified, calculate left from right and width
  5643. if (isNaN(left)) {
  5644. left = containerWidth - right - width - horizontalMargin;
  5645. }
  5646. if (isNaN(top)) {
  5647. top = containerHeight - bottom - height - verticalMargin;
  5648. }
  5649. // Align left and top
  5650. switch (positionInfo.left || positionInfo.right) {
  5651. case 'center':
  5652. left = containerWidth / 2 - width / 2 - margin[3];
  5653. break;
  5654. case 'right':
  5655. left = containerWidth - width - horizontalMargin;
  5656. break;
  5657. }
  5658. switch (positionInfo.top || positionInfo.bottom) {
  5659. case 'middle':
  5660. case 'center':
  5661. top = containerHeight / 2 - height / 2 - margin[0];
  5662. break;
  5663. case 'bottom':
  5664. top = containerHeight - height - verticalMargin;
  5665. break;
  5666. }
  5667. // If something is wrong and left, top, width, height are calculated as NaN
  5668. left = left || 0;
  5669. top = top || 0;
  5670. if (isNaN(width)) {
  5671. // Width may be NaN if only one value is given except width
  5672. width = containerWidth - left - (right || 0);
  5673. }
  5674. if (isNaN(height)) {
  5675. // Height may be NaN if only one value is given except height
  5676. height = containerHeight - top - (bottom || 0);
  5677. }
  5678. var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
  5679. rect.margin = margin;
  5680. return rect;
  5681. };
  5682. /**
  5683. * Position a zr element in viewport
  5684. * Group position is specified by either
  5685. * {left, top}, {right, bottom}
  5686. * If all properties exists, right and bottom will be igonred.
  5687. *
  5688. * Logic:
  5689. * 1. Scale (against origin point in parent coord)
  5690. * 2. Rotate (against origin point in parent coord)
  5691. * 3. Traslate (with el.position by this method)
  5692. * So this method only fixes the last step 'Traslate', which does not affect
  5693. * scaling and rotating.
  5694. *
  5695. * If be called repeatly with the same input el, the same result will be gotten.
  5696. *
  5697. * @param {module:zrender/Element} el Should have `getBoundingRect` method.
  5698. * @param {Object} positionInfo
  5699. * @param {number|string} [positionInfo.left]
  5700. * @param {number|string} [positionInfo.top]
  5701. * @param {number|string} [positionInfo.right]
  5702. * @param {number|string} [positionInfo.bottom]
  5703. * @param {Object} containerRect
  5704. * @param {string|number} margin
  5705. * @param {Object} [opt]
  5706. * @param {Array.<number>} [opt.hv=[1,1]] Only horizontal or only vertical.
  5707. * @param {Array.<number>} [opt.boundingMode='all']
  5708. * Specify how to calculate boundingRect when locating.
  5709. * 'all': Position the boundingRect that is transformed and uioned
  5710. * both itself and its descendants.
  5711. * This mode simplies confine the elements in the bounding
  5712. * of their container (e.g., using 'right: 0').
  5713. * 'raw': Position the boundingRect that is not transformed and only itself.
  5714. * This mode is useful when you want a element can overflow its
  5715. * container. (Consider a rotated circle needs to be located in a corner.)
  5716. * In this mode positionInfo.width/height can only be number.
  5717. */
  5718. layout.positionElement = function (el, positionInfo, containerRect, margin, opt) {
  5719. var h = !opt || !opt.hv || opt.hv[0];
  5720. var v = !opt || !opt.hv || opt.hv[1];
  5721. var boundingMode = opt && opt.boundingMode || 'all';
  5722. if (!h && !v) {
  5723. return;
  5724. }
  5725. var rect;
  5726. if (boundingMode === 'raw') {
  5727. rect = el.type === 'group'
  5728. ? new BoundingRect(0, 0, +positionInfo.width || 0, +positionInfo.height || 0)
  5729. : el.getBoundingRect();
  5730. }
  5731. else {
  5732. rect = el.getBoundingRect();
  5733. if (el.needLocalTransform()) {
  5734. var transform = el.getLocalTransform();
  5735. // Notice: raw rect may be inner object of el,
  5736. // which should not be modified.
  5737. rect = rect.clone();
  5738. rect.applyTransform(transform);
  5739. }
  5740. }
  5741. positionInfo = layout.getLayoutRect(
  5742. zrUtil.defaults(
  5743. {width: rect.width, height: rect.height},
  5744. positionInfo
  5745. ),
  5746. containerRect,
  5747. margin
  5748. );
  5749. // Because 'tranlate' is the last step in transform
  5750. // (see zrender/core/Transformable#getLocalTransfrom),
  5751. // we can just only modify el.position to get final result.
  5752. var elPos = el.position;
  5753. var dx = h ? positionInfo.x - rect.x : 0;
  5754. var dy = v ? positionInfo.y - rect.y : 0;
  5755. el.attr('position', boundingMode === 'raw' ? [dx, dy] : [elPos[0] + dx, elPos[1] + dy]);
  5756. };
  5757. /**
  5758. * Consider Case:
  5759. * When defulat option has {left: 0, width: 100}, and we set {right: 0}
  5760. * through setOption or media query, using normal zrUtil.merge will cause
  5761. * {right: 0} does not take effect.
  5762. *
  5763. * @example
  5764. * ComponentModel.extend({
  5765. * init: function () {
  5766. * ...
  5767. * var inputPositionParams = layout.getLayoutParams(option);
  5768. * this.mergeOption(inputPositionParams);
  5769. * },
  5770. * mergeOption: function (newOption) {
  5771. * newOption && zrUtil.merge(thisOption, newOption, true);
  5772. * layout.mergeLayoutParam(thisOption, newOption);
  5773. * }
  5774. * });
  5775. *
  5776. * @param {Object} targetOption
  5777. * @param {Object} newOption
  5778. * @param {Object|string} [opt]
  5779. * @param {boolean} [opt.ignoreSize=false] Some component must has width and height.
  5780. */
  5781. layout.mergeLayoutParam = function (targetOption, newOption, opt) {
  5782. !zrUtil.isObject(opt) && (opt = {});
  5783. var hNames = ['width', 'left', 'right']; // Order by priority.
  5784. var vNames = ['height', 'top', 'bottom']; // Order by priority.
  5785. var hResult = merge(hNames);
  5786. var vResult = merge(vNames);
  5787. copy(hNames, targetOption, hResult);
  5788. copy(vNames, targetOption, vResult);
  5789. function merge(names) {
  5790. var newParams = {};
  5791. var newValueCount = 0;
  5792. var merged = {};
  5793. var mergedValueCount = 0;
  5794. var enoughParamNumber = opt.ignoreSize ? 1 : 2;
  5795. each(names, function (name) {
  5796. merged[name] = targetOption[name];
  5797. });
  5798. each(names, function (name) {
  5799. // Consider case: newOption.width is null, which is
  5800. // set by user for removing width setting.
  5801. hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
  5802. hasValue(newParams, name) && newValueCount++;
  5803. hasValue(merged, name) && mergedValueCount++;
  5804. });
  5805. // Case: newOption: {width: ..., right: ...},
  5806. // or targetOption: {right: ...} and newOption: {width: ...},
  5807. // There is no conflict when merged only has params count
  5808. // little than enoughParamNumber.
  5809. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  5810. return merged;
  5811. }
  5812. // Case: newOption: {width: ..., right: ...},
  5813. // Than we can make sure user only want those two, and ignore
  5814. // all origin params in targetOption.
  5815. else if (newValueCount >= enoughParamNumber) {
  5816. return newParams;
  5817. }
  5818. else {
  5819. // Chose another param from targetOption by priority.
  5820. // When 'ignoreSize', enoughParamNumber is 1 and those will not happen.
  5821. for (var i = 0; i < names.length; i++) {
  5822. var name = names[i];
  5823. if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
  5824. newParams[name] = targetOption[name];
  5825. break;
  5826. }
  5827. }
  5828. return newParams;
  5829. }
  5830. }
  5831. function hasProp(obj, name) {
  5832. return obj.hasOwnProperty(name);
  5833. }
  5834. function hasValue(obj, name) {
  5835. return obj[name] != null && obj[name] !== 'auto';
  5836. }
  5837. function copy(names, target, source) {
  5838. each(names, function (name) {
  5839. target[name] = source[name];
  5840. });
  5841. }
  5842. };
  5843. /**
  5844. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  5845. * @param {Object} source
  5846. * @return {Object} Result contains those props.
  5847. */
  5848. layout.getLayoutParams = function (source) {
  5849. return layout.copyLayoutParams({}, source);
  5850. };
  5851. /**
  5852. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  5853. * @param {Object} source
  5854. * @return {Object} Result contains those props.
  5855. */
  5856. layout.copyLayoutParams = function (target, source) {
  5857. source && target && each(LOCATION_PARAMS, function (name) {
  5858. source.hasOwnProperty(name) && (target[name] = source[name]);
  5859. });
  5860. return target;
  5861. };
  5862. module.exports = layout;
  5863. /***/ },
  5864. /* 22 */
  5865. /***/ function(module, exports) {
  5866. module.exports = {
  5867. getBoxLayoutParams: function () {
  5868. return {
  5869. left: this.get('left'),
  5870. top: this.get('top'),
  5871. right: this.get('right'),
  5872. bottom: this.get('bottom'),
  5873. width: this.get('width'),
  5874. height: this.get('height')
  5875. };
  5876. }
  5877. };
  5878. /***/ },
  5879. /* 23 */
  5880. /***/ function(module, exports) {
  5881. var platform = '';
  5882. // Navigator not exists in node
  5883. if (typeof navigator !== 'undefined') {
  5884. platform = navigator.platform || '';
  5885. }
  5886. module.exports = {
  5887. // 全图默认背景
  5888. // backgroundColor: 'rgba(0,0,0,0)',
  5889. // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization
  5890. // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'],
  5891. // 浅色
  5892. // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
  5893. // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'],
  5894. // 深色
  5895. color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
  5896. // 默认需要 Grid 配置项
  5897. // grid: {},
  5898. // 主题,主题
  5899. textStyle: {
  5900. // color: '#000',
  5901. // decoration: 'none',
  5902. // PENDING
  5903. fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
  5904. // fontFamily: 'Arial, Verdana, sans-serif',
  5905. fontSize: 12,
  5906. fontStyle: 'normal',
  5907. fontWeight: 'normal'
  5908. },
  5909. // http://blogs.adobe.com/webplatform/2014/02/24/using-blend-modes-in-html-canvas/
  5910. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  5911. // Default is source-over
  5912. blendMode: null,
  5913. animation: true,
  5914. animationDuration: 1000,
  5915. animationDurationUpdate: 300,
  5916. animationEasing: 'exponentialOut',
  5917. animationEasingUpdate: 'cubicOut',
  5918. animationThreshold: 2000,
  5919. // Configuration for progressive/incremental rendering
  5920. progressiveThreshold: 3000,
  5921. progressive: 400,
  5922. // Threshold of if use single hover layer to optimize.
  5923. // It is recommended that `hoverLayerThreshold` is equivalent to or less than
  5924. // `progressiveThreshold`, otherwise hover will cause restart of progressive,
  5925. // which is unexpected.
  5926. // see example <echarts/test/heatmap-large.html>.
  5927. hoverLayerThreshold: 3000
  5928. };
  5929. /***/ },
  5930. /* 24 */
  5931. /***/ function(module, exports) {
  5932. module.exports = {
  5933. clearColorPalette: function () {
  5934. this._colorIdx = 0;
  5935. this._colorNameMap = {};
  5936. },
  5937. getColorFromPalette: function (name, scope) {
  5938. scope = scope || this;
  5939. var colorIdx = scope._colorIdx || 0;
  5940. var colorNameMap = scope._colorNameMap || (scope._colorNameMap = {});
  5941. if (colorNameMap[name]) {
  5942. return colorNameMap[name];
  5943. }
  5944. var colorPalette = this.get('color', true) || [];
  5945. if (!colorPalette.length) {
  5946. return;
  5947. }
  5948. var color = colorPalette[colorIdx];
  5949. if (name) {
  5950. colorNameMap[name] = color;
  5951. }
  5952. scope._colorIdx = (colorIdx + 1) % colorPalette.length;
  5953. return color;
  5954. }
  5955. };
  5956. /***/ },
  5957. /* 25 */
  5958. /***/ function(module, exports, __webpack_require__) {
  5959. 'use strict';
  5960. var zrUtil = __webpack_require__(4);
  5961. var echartsAPIList = [
  5962. 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction', 'isDisposed',
  5963. 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption'
  5964. ];
  5965. function ExtensionAPI(chartInstance) {
  5966. zrUtil.each(echartsAPIList, function (name) {
  5967. this[name] = zrUtil.bind(chartInstance[name], chartInstance);
  5968. }, this);
  5969. }
  5970. module.exports = ExtensionAPI;
  5971. /***/ },
  5972. /* 26 */
  5973. /***/ function(module, exports, __webpack_require__) {
  5974. 'use strict';
  5975. var zrUtil = __webpack_require__(4);
  5976. /**
  5977. * Interface of Coordinate System Class
  5978. *
  5979. * create:
  5980. * @param {module:echarts/model/Global} ecModel
  5981. * @param {module:echarts/ExtensionAPI} api
  5982. * @return {Object} coordinate system instance
  5983. *
  5984. * update:
  5985. * @param {module:echarts/model/Global} ecModel
  5986. * @param {module:echarts/ExtensionAPI} api
  5987. *
  5988. * convertToPixel:
  5989. * convertFromPixel:
  5990. * These two methods is also responsible for determine whether this
  5991. * coodinate system is applicable to the given `finder`.
  5992. * Each coordinate system will be tried, util one returns none
  5993. * null/undefined value.
  5994. * @param {module:echarts/model/Global} ecModel
  5995. * @param {Object} finder
  5996. * @param {Array|number} value
  5997. * @return {Array|number} convert result.
  5998. *
  5999. * containPoint:
  6000. * @param {Array.<number>} point In pixel coordinate system.
  6001. * @return {boolean}
  6002. */
  6003. var coordinateSystemCreators = {};
  6004. function CoordinateSystemManager() {
  6005. this._coordinateSystems = [];
  6006. }
  6007. CoordinateSystemManager.prototype = {
  6008. constructor: CoordinateSystemManager,
  6009. create: function (ecModel, api) {
  6010. var coordinateSystems = [];
  6011. zrUtil.each(coordinateSystemCreators, function (creater, type) {
  6012. var list = creater.create(ecModel, api);
  6013. coordinateSystems = coordinateSystems.concat(list || []);
  6014. });
  6015. this._coordinateSystems = coordinateSystems;
  6016. },
  6017. update: function (ecModel, api) {
  6018. zrUtil.each(this._coordinateSystems, function (coordSys) {
  6019. // FIXME MUST have
  6020. coordSys.update && coordSys.update(ecModel, api);
  6021. });
  6022. },
  6023. getCoordinateSystems: function () {
  6024. return this._coordinateSystems.slice();
  6025. }
  6026. };
  6027. CoordinateSystemManager.register = function (type, coordinateSystemCreator) {
  6028. coordinateSystemCreators[type] = coordinateSystemCreator;
  6029. };
  6030. CoordinateSystemManager.get = function (type) {
  6031. return coordinateSystemCreators[type];
  6032. };
  6033. module.exports = CoordinateSystemManager;
  6034. /***/ },
  6035. /* 27 */
  6036. /***/ function(module, exports, __webpack_require__) {
  6037. /**
  6038. * ECharts option manager
  6039. *
  6040. * @module {echarts/model/OptionManager}
  6041. */
  6042. var zrUtil = __webpack_require__(4);
  6043. var modelUtil = __webpack_require__(5);
  6044. var ComponentModel = __webpack_require__(19);
  6045. var each = zrUtil.each;
  6046. var clone = zrUtil.clone;
  6047. var map = zrUtil.map;
  6048. var merge = zrUtil.merge;
  6049. var QUERY_REG = /^(min|max)?(.+)$/;
  6050. /**
  6051. * TERM EXPLANATIONS:
  6052. *
  6053. * [option]:
  6054. *
  6055. * An object that contains definitions of components. For example:
  6056. * var option = {
  6057. * title: {...},
  6058. * legend: {...},
  6059. * visualMap: {...},
  6060. * series: [
  6061. * {data: [...]},
  6062. * {data: [...]},
  6063. * ...
  6064. * ]
  6065. * };
  6066. *
  6067. * [rawOption]:
  6068. *
  6069. * An object input to echarts.setOption. 'rawOption' may be an
  6070. * 'option', or may be an object contains multi-options. For example:
  6071. * var option = {
  6072. * baseOption: {
  6073. * title: {...},
  6074. * legend: {...},
  6075. * series: [
  6076. * {data: [...]},
  6077. * {data: [...]},
  6078. * ...
  6079. * ]
  6080. * },
  6081. * timeline: {...},
  6082. * options: [
  6083. * {title: {...}, series: {data: [...]}},
  6084. * {title: {...}, series: {data: [...]}},
  6085. * ...
  6086. * ],
  6087. * media: [
  6088. * {
  6089. * query: {maxWidth: 320},
  6090. * option: {series: {x: 20}, visualMap: {show: false}}
  6091. * },
  6092. * {
  6093. * query: {minWidth: 320, maxWidth: 720},
  6094. * option: {series: {x: 500}, visualMap: {show: true}}
  6095. * },
  6096. * {
  6097. * option: {series: {x: 1200}, visualMap: {show: true}}
  6098. * }
  6099. * ]
  6100. * };
  6101. *
  6102. * @alias module:echarts/model/OptionManager
  6103. * @param {module:echarts/ExtensionAPI} api
  6104. */
  6105. function OptionManager(api) {
  6106. /**
  6107. * @private
  6108. * @type {module:echarts/ExtensionAPI}
  6109. */
  6110. this._api = api;
  6111. /**
  6112. * @private
  6113. * @type {Array.<number>}
  6114. */
  6115. this._timelineOptions = [];
  6116. /**
  6117. * @private
  6118. * @type {Array.<Object>}
  6119. */
  6120. this._mediaList = [];
  6121. /**
  6122. * @private
  6123. * @type {Object}
  6124. */
  6125. this._mediaDefault;
  6126. /**
  6127. * -1, means default.
  6128. * empty means no media.
  6129. * @private
  6130. * @type {Array.<number>}
  6131. */
  6132. this._currentMediaIndices = [];
  6133. /**
  6134. * @private
  6135. * @type {Object}
  6136. */
  6137. this._optionBackup;
  6138. /**
  6139. * @private
  6140. * @type {Object}
  6141. */
  6142. this._newBaseOption;
  6143. }
  6144. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  6145. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  6146. // rawOption cloned and backuped when timeline changed, which does no
  6147. // good to performance. What's more, that both timeline and setOption
  6148. // method supply 'notMerge' brings complex and some problems.
  6149. // Consider this case:
  6150. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  6151. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  6152. OptionManager.prototype = {
  6153. constructor: OptionManager,
  6154. /**
  6155. * @public
  6156. * @param {Object} rawOption Raw option.
  6157. * @param {module:echarts/model/Global} ecModel
  6158. * @param {Array.<Function>} optionPreprocessorFuncs
  6159. * @return {Object} Init option
  6160. */
  6161. setOption: function (rawOption, optionPreprocessorFuncs) {
  6162. rawOption = clone(rawOption, true);
  6163. // FIXME
  6164. // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。
  6165. var oldOptionBackup = this._optionBackup;
  6166. var newParsedOption = parseRawOption.call(
  6167. this, rawOption, optionPreprocessorFuncs, !oldOptionBackup
  6168. );
  6169. this._newBaseOption = newParsedOption.baseOption;
  6170. // For setOption at second time (using merge mode);
  6171. if (oldOptionBackup) {
  6172. // Only baseOption can be merged.
  6173. mergeOption(oldOptionBackup.baseOption, newParsedOption.baseOption);
  6174. // For simplicity, timeline options and media options do not support merge,
  6175. // that is, if you `setOption` twice and both has timeline options, the latter
  6176. // timeline opitons will not be merged to the formers, but just substitude them.
  6177. if (newParsedOption.timelineOptions.length) {
  6178. oldOptionBackup.timelineOptions = newParsedOption.timelineOptions;
  6179. }
  6180. if (newParsedOption.mediaList.length) {
  6181. oldOptionBackup.mediaList = newParsedOption.mediaList;
  6182. }
  6183. if (newParsedOption.mediaDefault) {
  6184. oldOptionBackup.mediaDefault = newParsedOption.mediaDefault;
  6185. }
  6186. }
  6187. else {
  6188. this._optionBackup = newParsedOption;
  6189. }
  6190. },
  6191. /**
  6192. * @param {boolean} isRecreate
  6193. * @return {Object}
  6194. */
  6195. mountOption: function (isRecreate) {
  6196. var optionBackup = this._optionBackup;
  6197. // TODO
  6198. // 如果没有reset功能则不clone。
  6199. this._timelineOptions = map(optionBackup.timelineOptions, clone);
  6200. this._mediaList = map(optionBackup.mediaList, clone);
  6201. this._mediaDefault = clone(optionBackup.mediaDefault);
  6202. this._currentMediaIndices = [];
  6203. return clone(isRecreate
  6204. // this._optionBackup.baseOption, which is created at the first `setOption`
  6205. // called, and is merged into every new option by inner method `mergeOption`
  6206. // each time `setOption` called, can be only used in `isRecreate`, because
  6207. // its reliability is under suspicion. In other cases option merge is
  6208. // performed by `model.mergeOption`.
  6209. ? optionBackup.baseOption : this._newBaseOption
  6210. );
  6211. },
  6212. /**
  6213. * @param {module:echarts/model/Global} ecModel
  6214. * @return {Object}
  6215. */
  6216. getTimelineOption: function (ecModel) {
  6217. var option;
  6218. var timelineOptions = this._timelineOptions;
  6219. if (timelineOptions.length) {
  6220. // getTimelineOption can only be called after ecModel inited,
  6221. // so we can get currentIndex from timelineModel.
  6222. var timelineModel = ecModel.getComponent('timeline');
  6223. if (timelineModel) {
  6224. option = clone(
  6225. timelineOptions[timelineModel.getCurrentIndex()],
  6226. true
  6227. );
  6228. }
  6229. }
  6230. return option;
  6231. },
  6232. /**
  6233. * @param {module:echarts/model/Global} ecModel
  6234. * @return {Array.<Object>}
  6235. */
  6236. getMediaOption: function (ecModel) {
  6237. var ecWidth = this._api.getWidth();
  6238. var ecHeight = this._api.getHeight();
  6239. var mediaList = this._mediaList;
  6240. var mediaDefault = this._mediaDefault;
  6241. var indices = [];
  6242. var result = [];
  6243. // No media defined.
  6244. if (!mediaList.length && !mediaDefault) {
  6245. return result;
  6246. }
  6247. // Multi media may be applied, the latter defined media has higher priority.
  6248. for (var i = 0, len = mediaList.length; i < len; i++) {
  6249. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  6250. indices.push(i);
  6251. }
  6252. }
  6253. // FIXME
  6254. // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。
  6255. if (!indices.length && mediaDefault) {
  6256. indices = [-1];
  6257. }
  6258. if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) {
  6259. result = map(indices, function (index) {
  6260. return clone(
  6261. index === -1 ? mediaDefault.option : mediaList[index].option
  6262. );
  6263. });
  6264. }
  6265. // Otherwise return nothing.
  6266. this._currentMediaIndices = indices;
  6267. return result;
  6268. }
  6269. };
  6270. function parseRawOption(rawOption, optionPreprocessorFuncs, isNew) {
  6271. var timelineOptions = [];
  6272. var mediaList = [];
  6273. var mediaDefault;
  6274. var baseOption;
  6275. // Compatible with ec2.
  6276. var timelineOpt = rawOption.timeline;
  6277. if (rawOption.baseOption) {
  6278. baseOption = rawOption.baseOption;
  6279. }
  6280. // For timeline
  6281. if (timelineOpt || rawOption.options) {
  6282. baseOption = baseOption || {};
  6283. timelineOptions = (rawOption.options || []).slice();
  6284. }
  6285. // For media query
  6286. if (rawOption.media) {
  6287. baseOption = baseOption || {};
  6288. var media = rawOption.media;
  6289. each(media, function (singleMedia) {
  6290. if (singleMedia && singleMedia.option) {
  6291. if (singleMedia.query) {
  6292. mediaList.push(singleMedia);
  6293. }
  6294. else if (!mediaDefault) {
  6295. // Use the first media default.
  6296. mediaDefault = singleMedia;
  6297. }
  6298. }
  6299. });
  6300. }
  6301. // For normal option
  6302. if (!baseOption) {
  6303. baseOption = rawOption;
  6304. }
  6305. // Set timelineOpt to baseOption in ec3,
  6306. // which is convenient for merge option.
  6307. if (!baseOption.timeline) {
  6308. baseOption.timeline = timelineOpt;
  6309. }
  6310. // Preprocess.
  6311. each([baseOption].concat(timelineOptions)
  6312. .concat(zrUtil.map(mediaList, function (media) {
  6313. return media.option;
  6314. })),
  6315. function (option) {
  6316. each(optionPreprocessorFuncs, function (preProcess) {
  6317. preProcess(option, isNew);
  6318. });
  6319. }
  6320. );
  6321. return {
  6322. baseOption: baseOption,
  6323. timelineOptions: timelineOptions,
  6324. mediaDefault: mediaDefault,
  6325. mediaList: mediaList
  6326. };
  6327. }
  6328. /**
  6329. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  6330. * Support: width, height, aspectRatio
  6331. * Can use max or min as prefix.
  6332. */
  6333. function applyMediaQuery(query, ecWidth, ecHeight) {
  6334. var realMap = {
  6335. width: ecWidth,
  6336. height: ecHeight,
  6337. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  6338. };
  6339. var applicatable = true;
  6340. zrUtil.each(query, function (value, attr) {
  6341. var matched = attr.match(QUERY_REG);
  6342. if (!matched || !matched[1] || !matched[2]) {
  6343. return;
  6344. }
  6345. var operator = matched[1];
  6346. var realAttr = matched[2].toLowerCase();
  6347. if (!compare(realMap[realAttr], value, operator)) {
  6348. applicatable = false;
  6349. }
  6350. });
  6351. return applicatable;
  6352. }
  6353. function compare(real, expect, operator) {
  6354. if (operator === 'min') {
  6355. return real >= expect;
  6356. }
  6357. else if (operator === 'max') {
  6358. return real <= expect;
  6359. }
  6360. else { // Equals
  6361. return real === expect;
  6362. }
  6363. }
  6364. function indicesEquals(indices1, indices2) {
  6365. // indices is always order by asc and has only finite number.
  6366. return indices1.join(',') === indices2.join(',');
  6367. }
  6368. /**
  6369. * Consider case:
  6370. * `chart.setOption(opt1);`
  6371. * Then user do some interaction like dataZoom, dataView changing.
  6372. * `chart.setOption(opt2);`
  6373. * Then user press 'reset button' in toolbox.
  6374. *
  6375. * After doing that all of the interaction effects should be reset, the
  6376. * chart should be the same as the result of invoke
  6377. * `chart.setOption(opt1); chart.setOption(opt2);`.
  6378. *
  6379. * Although it is not able ensure that
  6380. * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to
  6381. * `chart.setOption(merge(opt1, opt2));` exactly,
  6382. * this might be the only simple way to implement that feature.
  6383. *
  6384. * MEMO: We've considered some other approaches:
  6385. * 1. Each model handle its self restoration but not uniform treatment.
  6386. * (Too complex in logic and error-prone)
  6387. * 2. Use a shadow ecModel. (Performace expensive)
  6388. */
  6389. function mergeOption(oldOption, newOption) {
  6390. newOption = newOption || {};
  6391. each(newOption, function (newCptOpt, mainType) {
  6392. if (newCptOpt == null) {
  6393. return;
  6394. }
  6395. var oldCptOpt = oldOption[mainType];
  6396. if (!ComponentModel.hasClass(mainType)) {
  6397. oldOption[mainType] = merge(oldCptOpt, newCptOpt, true);
  6398. }
  6399. else {
  6400. newCptOpt = modelUtil.normalizeToArray(newCptOpt);
  6401. oldCptOpt = modelUtil.normalizeToArray(oldCptOpt);
  6402. var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt);
  6403. oldOption[mainType] = map(mapResult, function (item) {
  6404. return (item.option && item.exist)
  6405. ? merge(item.exist, item.option, true)
  6406. : (item.exist || item.option);
  6407. });
  6408. }
  6409. });
  6410. }
  6411. module.exports = OptionManager;
  6412. /***/ },
  6413. /* 28 */
  6414. /***/ function(module, exports, __webpack_require__) {
  6415. 'use strict';
  6416. var zrUtil = __webpack_require__(4);
  6417. var formatUtil = __webpack_require__(6);
  6418. var modelUtil = __webpack_require__(5);
  6419. var ComponentModel = __webpack_require__(19);
  6420. var colorPaletteMixin = __webpack_require__(24);
  6421. var env = __webpack_require__(2);
  6422. var layout = __webpack_require__(21);
  6423. var encodeHTML = formatUtil.encodeHTML;
  6424. var addCommas = formatUtil.addCommas;
  6425. var SeriesModel = ComponentModel.extend({
  6426. type: 'series.__base__',
  6427. /**
  6428. * @readOnly
  6429. */
  6430. seriesIndex: 0,
  6431. // coodinateSystem will be injected in the echarts/CoordinateSystem
  6432. coordinateSystem: null,
  6433. /**
  6434. * @type {Object}
  6435. * @protected
  6436. */
  6437. defaultOption: null,
  6438. /**
  6439. * Data provided for legend
  6440. * @type {Function}
  6441. */
  6442. // PENDING
  6443. legendDataProvider: null,
  6444. /**
  6445. * Access path of color for visual
  6446. */
  6447. visualColorAccessPath: 'itemStyle.normal.color',
  6448. /**
  6449. * Support merge layout params.
  6450. * Only support 'box' now (left/right/top/bottom/width/height).
  6451. * @type {string|Object} Object can be {ignoreSize: true}
  6452. * @readOnly
  6453. */
  6454. layoutMode: null,
  6455. init: function (option, parentModel, ecModel, extraOpt) {
  6456. /**
  6457. * @type {number}
  6458. * @readOnly
  6459. */
  6460. this.seriesIndex = this.componentIndex;
  6461. this.mergeDefaultAndTheme(option, ecModel);
  6462. /**
  6463. * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph}
  6464. * @private
  6465. */
  6466. this._dataBeforeProcessed = this.getInitialData(option, ecModel);
  6467. // If we reverse the order (make this._data firstly, and then make
  6468. // this._dataBeforeProcessed by cloneShallow), cloneShallow will
  6469. // cause this._data.graph.data !== this._data when using
  6470. // module:echarts/data/Graph or module:echarts/data/Tree.
  6471. // See module:echarts/data/helper/linkList
  6472. this._data = this._dataBeforeProcessed.cloneShallow();
  6473. },
  6474. /**
  6475. * Util for merge default and theme to option
  6476. * @param {Object} option
  6477. * @param {module:echarts/model/Global} ecModel
  6478. */
  6479. mergeDefaultAndTheme: function (option, ecModel) {
  6480. var layoutMode = this.layoutMode;
  6481. var inputPositionParams = layoutMode
  6482. ? layout.getLayoutParams(option) : {};
  6483. zrUtil.merge(
  6484. option,
  6485. ecModel.getTheme().get(this.subType)
  6486. );
  6487. zrUtil.merge(option, this.getDefaultOption());
  6488. // Default label emphasis `position` and `show`
  6489. // FIXME Set label in mergeOption
  6490. modelUtil.defaultEmphasis(option.label, modelUtil.LABEL_OPTIONS);
  6491. this.fillDataTextStyle(option.data);
  6492. if (layoutMode) {
  6493. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  6494. }
  6495. },
  6496. mergeOption: function (newSeriesOption, ecModel) {
  6497. newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true);
  6498. this.fillDataTextStyle(newSeriesOption.data);
  6499. var layoutMode = this.layoutMode;
  6500. if (layoutMode) {
  6501. layout.mergeLayoutParam(this.option, newSeriesOption, layoutMode);
  6502. }
  6503. var data = this.getInitialData(newSeriesOption, ecModel);
  6504. // TODO Merge data?
  6505. if (data) {
  6506. this._data = data;
  6507. this._dataBeforeProcessed = data.cloneShallow();
  6508. }
  6509. },
  6510. fillDataTextStyle: function (data) {
  6511. // Default data label emphasis `position` and `show`
  6512. // FIXME Tree structure data ?
  6513. // FIXME Performance ?
  6514. if (data) {
  6515. for (var i = 0; i < data.length; i++) {
  6516. if (data[i] && data[i].label) {
  6517. modelUtil.defaultEmphasis(data[i].label, modelUtil.LABEL_OPTIONS);
  6518. }
  6519. }
  6520. }
  6521. },
  6522. /**
  6523. * Init a data structure from data related option in series
  6524. * Must be overwritten
  6525. */
  6526. getInitialData: function () {},
  6527. /**
  6528. * @param {string} [dataType]
  6529. * @return {module:echarts/data/List}
  6530. */
  6531. getData: function (dataType) {
  6532. return dataType == null ? this._data : this._data.getLinkedData(dataType);
  6533. },
  6534. /**
  6535. * @param {module:echarts/data/List} data
  6536. */
  6537. setData: function (data) {
  6538. this._data = data;
  6539. },
  6540. /**
  6541. * Get data before processed
  6542. * @return {module:echarts/data/List}
  6543. */
  6544. getRawData: function () {
  6545. return this._dataBeforeProcessed;
  6546. },
  6547. /**
  6548. * Coord dimension to data dimension.
  6549. *
  6550. * By default the result is the same as dimensions of series data.
  6551. * But in some series data dimensions are different from coord dimensions (i.e.
  6552. * candlestick and boxplot). Override this method to handle those cases.
  6553. *
  6554. * Coord dimension to data dimension can be one-to-many
  6555. *
  6556. * @param {string} coordDim
  6557. * @return {Array.<string>} dimensions on the axis.
  6558. */
  6559. coordDimToDataDim: function (coordDim) {
  6560. return [coordDim];
  6561. },
  6562. /**
  6563. * Convert data dimension to coord dimension.
  6564. *
  6565. * @param {string|number} dataDim
  6566. * @return {string}
  6567. */
  6568. dataDimToCoordDim: function (dataDim) {
  6569. return dataDim;
  6570. },
  6571. /**
  6572. * Get base axis if has coordinate system and has axis.
  6573. * By default use coordSys.getBaseAxis();
  6574. * Can be overrided for some chart.
  6575. * @return {type} description
  6576. */
  6577. getBaseAxis: function () {
  6578. var coordSys = this.coordinateSystem;
  6579. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
  6580. },
  6581. // FIXME
  6582. /**
  6583. * Default tooltip formatter
  6584. *
  6585. * @param {number} dataIndex
  6586. * @param {boolean} [multipleSeries=false]
  6587. * @param {number} [dataType]
  6588. */
  6589. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  6590. function formatArrayValue(value) {
  6591. var result = [];
  6592. zrUtil.each(value, function (val, idx) {
  6593. var dimInfo = data.getDimensionInfo(idx);
  6594. var dimType = dimInfo && dimInfo.type;
  6595. var valStr;
  6596. if (dimType === 'ordinal') {
  6597. valStr = val + '';
  6598. }
  6599. else if (dimType === 'time') {
  6600. valStr = multipleSeries ? '' : formatUtil.formatTime('yyyy/MM/dd hh:mm:ss', val);
  6601. }
  6602. else {
  6603. valStr = addCommas(val);
  6604. }
  6605. valStr && result.push(valStr);
  6606. });
  6607. return result.join(', ');
  6608. }
  6609. var data = this._data;
  6610. var value = this.getRawValue(dataIndex);
  6611. var formattedValue = zrUtil.isArray(value)
  6612. ? formatArrayValue(value) : addCommas(value);
  6613. var name = data.getName(dataIndex);
  6614. var color = data.getItemVisual(dataIndex, 'color');
  6615. if (zrUtil.isObject(color) && color.colorStops) {
  6616. color = (color.colorStops[0] || {}).color;
  6617. }
  6618. color = color || 'transparent';
  6619. var colorEl = '<span style="display:inline-block;margin-right:5px;'
  6620. + 'border-radius:10px;width:9px;height:9px;background-color:' + color + '"></span>';
  6621. var seriesName = this.name;
  6622. // FIXME
  6623. if (seriesName === '\0-') {
  6624. // Not show '-'
  6625. seriesName = '';
  6626. }
  6627. return !multipleSeries
  6628. ? ((seriesName && encodeHTML(seriesName) + '<br />') + colorEl
  6629. + (name
  6630. ? encodeHTML(name) + ' : ' + formattedValue
  6631. : formattedValue)
  6632. )
  6633. : (colorEl + encodeHTML(this.name) + ' : ' + formattedValue);
  6634. },
  6635. /**
  6636. * @return {boolean}
  6637. */
  6638. ifEnableAnimation: function () {
  6639. if (env.node) {
  6640. return false;
  6641. }
  6642. var animationEnabled = this.getShallow('animation');
  6643. if (animationEnabled) {
  6644. if (this.getData().count() > this.getShallow('animationThreshold')) {
  6645. animationEnabled = false;
  6646. }
  6647. }
  6648. return animationEnabled;
  6649. },
  6650. restoreData: function () {
  6651. this._data = this._dataBeforeProcessed.cloneShallow();
  6652. },
  6653. getColorFromPalette: function (name, scope) {
  6654. var ecModel = this.ecModel;
  6655. // PENDING
  6656. var color = colorPaletteMixin.getColorFromPalette.call(this, name, scope);
  6657. if (!color) {
  6658. color = ecModel.getColorFromPalette(name, scope);
  6659. }
  6660. return color;
  6661. },
  6662. /**
  6663. * Get data indices for show tooltip content. See tooltip.
  6664. * @abstract
  6665. * @param {Array.<string>|string} dim
  6666. * @param {Array.<number>} value
  6667. * @param {module:echarts/coord/single/SingleAxis} baseAxis
  6668. * @return {Array.<number>} data indices.
  6669. */
  6670. getAxisTooltipDataIndex: null,
  6671. /**
  6672. * See tooltip.
  6673. * @abstract
  6674. * @param {number} dataIndex
  6675. * @return {Array.<number>} Point of tooltip. null/undefined can be returned.
  6676. */
  6677. getTooltipPosition: null
  6678. });
  6679. zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin);
  6680. zrUtil.mixin(SeriesModel, colorPaletteMixin);
  6681. module.exports = SeriesModel;
  6682. /***/ },
  6683. /* 29 */
  6684. /***/ function(module, exports, __webpack_require__) {
  6685. var Group = __webpack_require__(30);
  6686. var componentUtil = __webpack_require__(20);
  6687. var clazzUtil = __webpack_require__(13);
  6688. var Component = function () {
  6689. /**
  6690. * @type {module:zrender/container/Group}
  6691. * @readOnly
  6692. */
  6693. this.group = new Group();
  6694. /**
  6695. * @type {string}
  6696. * @readOnly
  6697. */
  6698. this.uid = componentUtil.getUID('viewComponent');
  6699. };
  6700. Component.prototype = {
  6701. constructor: Component,
  6702. init: function (ecModel, api) {},
  6703. render: function (componentModel, ecModel, api, payload) {},
  6704. dispose: function () {}
  6705. };
  6706. var componentProto = Component.prototype;
  6707. componentProto.updateView
  6708. = componentProto.updateLayout
  6709. = componentProto.updateVisual
  6710. = function (seriesModel, ecModel, api, payload) {
  6711. // Do nothing;
  6712. };
  6713. // Enable Component.extend.
  6714. clazzUtil.enableClassExtend(Component);
  6715. // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  6716. clazzUtil.enableClassManagement(Component, {registerWhenExtend: true});
  6717. module.exports = Component;
  6718. /***/ },
  6719. /* 30 */
  6720. /***/ function(module, exports, __webpack_require__) {
  6721. /**
  6722. * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
  6723. * @module zrender/graphic/Group
  6724. * @example
  6725. * var Group = require('zrender/lib/container/Group');
  6726. * var Circle = require('zrender/lib/graphic/shape/Circle');
  6727. * var g = new Group();
  6728. * g.position[0] = 100;
  6729. * g.position[1] = 100;
  6730. * g.add(new Circle({
  6731. * style: {
  6732. * x: 100,
  6733. * y: 100,
  6734. * r: 20,
  6735. * }
  6736. * }));
  6737. * zr.add(g);
  6738. */
  6739. var zrUtil = __webpack_require__(4);
  6740. var Element = __webpack_require__(31);
  6741. var BoundingRect = __webpack_require__(9);
  6742. /**
  6743. * @alias module:zrender/graphic/Group
  6744. * @constructor
  6745. * @extends module:zrender/mixin/Transformable
  6746. * @extends module:zrender/mixin/Eventful
  6747. */
  6748. var Group = function (opts) {
  6749. opts = opts || {};
  6750. Element.call(this, opts);
  6751. for (var key in opts) {
  6752. if (opts.hasOwnProperty(key)) {
  6753. this[key] = opts[key];
  6754. }
  6755. }
  6756. this._children = [];
  6757. this.__storage = null;
  6758. this.__dirty = true;
  6759. };
  6760. Group.prototype = {
  6761. constructor: Group,
  6762. isGroup: true,
  6763. /**
  6764. * @type {string}
  6765. */
  6766. type: 'group',
  6767. /**
  6768. * 所有子孙元素是否响应鼠标事件
  6769. * @name module:/zrender/container/Group#silent
  6770. * @type {boolean}
  6771. * @default false
  6772. */
  6773. silent: false,
  6774. /**
  6775. * @return {Array.<module:zrender/Element>}
  6776. */
  6777. children: function () {
  6778. return this._children.slice();
  6779. },
  6780. /**
  6781. * 获取指定 index 的儿子节点
  6782. * @param {number} idx
  6783. * @return {module:zrender/Element}
  6784. */
  6785. childAt: function (idx) {
  6786. return this._children[idx];
  6787. },
  6788. /**
  6789. * 获取指定名字的儿子节点
  6790. * @param {string} name
  6791. * @return {module:zrender/Element}
  6792. */
  6793. childOfName: function (name) {
  6794. var children = this._children;
  6795. for (var i = 0; i < children.length; i++) {
  6796. if (children[i].name === name) {
  6797. return children[i];
  6798. }
  6799. }
  6800. },
  6801. /**
  6802. * @return {number}
  6803. */
  6804. childCount: function () {
  6805. return this._children.length;
  6806. },
  6807. /**
  6808. * 添加子节点到最后
  6809. * @param {module:zrender/Element} child
  6810. */
  6811. add: function (child) {
  6812. if (child && child !== this && child.parent !== this) {
  6813. this._children.push(child);
  6814. this._doAdd(child);
  6815. }
  6816. return this;
  6817. },
  6818. /**
  6819. * 添加子节点在 nextSibling 之前
  6820. * @param {module:zrender/Element} child
  6821. * @param {module:zrender/Element} nextSibling
  6822. */
  6823. addBefore: function (child, nextSibling) {
  6824. if (child && child !== this && child.parent !== this
  6825. && nextSibling && nextSibling.parent === this) {
  6826. var children = this._children;
  6827. var idx = children.indexOf(nextSibling);
  6828. if (idx >= 0) {
  6829. children.splice(idx, 0, child);
  6830. this._doAdd(child);
  6831. }
  6832. }
  6833. return this;
  6834. },
  6835. _doAdd: function (child) {
  6836. if (child.parent) {
  6837. child.parent.remove(child);
  6838. }
  6839. child.parent = this;
  6840. var storage = this.__storage;
  6841. var zr = this.__zr;
  6842. if (storage && storage !== child.__storage) {
  6843. storage.addToMap(child);
  6844. if (child instanceof Group) {
  6845. child.addChildrenToStorage(storage);
  6846. }
  6847. }
  6848. zr && zr.refresh();
  6849. },
  6850. /**
  6851. * 移除子节点
  6852. * @param {module:zrender/Element} child
  6853. */
  6854. remove: function (child) {
  6855. var zr = this.__zr;
  6856. var storage = this.__storage;
  6857. var children = this._children;
  6858. var idx = zrUtil.indexOf(children, child);
  6859. if (idx < 0) {
  6860. return this;
  6861. }
  6862. children.splice(idx, 1);
  6863. child.parent = null;
  6864. if (storage) {
  6865. storage.delFromMap(child.id);
  6866. if (child instanceof Group) {
  6867. child.delChildrenFromStorage(storage);
  6868. }
  6869. }
  6870. zr && zr.refresh();
  6871. return this;
  6872. },
  6873. /**
  6874. * 移除所有子节点
  6875. */
  6876. removeAll: function () {
  6877. var children = this._children;
  6878. var storage = this.__storage;
  6879. var child;
  6880. var i;
  6881. for (i = 0; i < children.length; i++) {
  6882. child = children[i];
  6883. if (storage) {
  6884. storage.delFromMap(child.id);
  6885. if (child instanceof Group) {
  6886. child.delChildrenFromStorage(storage);
  6887. }
  6888. }
  6889. child.parent = null;
  6890. }
  6891. children.length = 0;
  6892. return this;
  6893. },
  6894. /**
  6895. * 遍历所有子节点
  6896. * @param {Function} cb
  6897. * @param {} context
  6898. */
  6899. eachChild: function (cb, context) {
  6900. var children = this._children;
  6901. for (var i = 0; i < children.length; i++) {
  6902. var child = children[i];
  6903. cb.call(context, child, i);
  6904. }
  6905. return this;
  6906. },
  6907. /**
  6908. * 深度优先遍历所有子孙节点
  6909. * @param {Function} cb
  6910. * @param {} context
  6911. */
  6912. traverse: function (cb, context) {
  6913. for (var i = 0; i < this._children.length; i++) {
  6914. var child = this._children[i];
  6915. cb.call(context, child);
  6916. if (child.type === 'group') {
  6917. child.traverse(cb, context);
  6918. }
  6919. }
  6920. return this;
  6921. },
  6922. addChildrenToStorage: function (storage) {
  6923. for (var i = 0; i < this._children.length; i++) {
  6924. var child = this._children[i];
  6925. storage.addToMap(child);
  6926. if (child instanceof Group) {
  6927. child.addChildrenToStorage(storage);
  6928. }
  6929. }
  6930. },
  6931. delChildrenFromStorage: function (storage) {
  6932. for (var i = 0; i < this._children.length; i++) {
  6933. var child = this._children[i];
  6934. storage.delFromMap(child.id);
  6935. if (child instanceof Group) {
  6936. child.delChildrenFromStorage(storage);
  6937. }
  6938. }
  6939. },
  6940. dirty: function () {
  6941. this.__dirty = true;
  6942. this.__zr && this.__zr.refresh();
  6943. return this;
  6944. },
  6945. /**
  6946. * @return {module:zrender/core/BoundingRect}
  6947. */
  6948. getBoundingRect: function (includeChildren) {
  6949. // TODO Caching
  6950. var rect = null;
  6951. var tmpRect = new BoundingRect(0, 0, 0, 0);
  6952. var children = includeChildren || this._children;
  6953. var tmpMat = [];
  6954. for (var i = 0; i < children.length; i++) {
  6955. var child = children[i];
  6956. if (child.ignore || child.invisible) {
  6957. continue;
  6958. }
  6959. var childRect = child.getBoundingRect();
  6960. var transform = child.getLocalTransform(tmpMat);
  6961. // TODO
  6962. // The boundingRect cacluated by transforming original
  6963. // rect may be bigger than the actual bundingRect when rotation
  6964. // is used. (Consider a circle rotated aginst its center, where
  6965. // the actual boundingRect should be the same as that not be
  6966. // rotated.) But we can not find better approach to calculate
  6967. // actual boundingRect yet, considering performance.
  6968. if (transform) {
  6969. tmpRect.copy(childRect);
  6970. tmpRect.applyTransform(transform);
  6971. rect = rect || tmpRect.clone();
  6972. rect.union(tmpRect);
  6973. }
  6974. else {
  6975. rect = rect || childRect.clone();
  6976. rect.union(childRect);
  6977. }
  6978. }
  6979. return rect || tmpRect;
  6980. }
  6981. };
  6982. zrUtil.inherits(Group, Element);
  6983. module.exports = Group;
  6984. /***/ },
  6985. /* 31 */
  6986. /***/ function(module, exports, __webpack_require__) {
  6987. 'use strict';
  6988. /**
  6989. * @module zrender/Element
  6990. */
  6991. var guid = __webpack_require__(32);
  6992. var Eventful = __webpack_require__(33);
  6993. var Transformable = __webpack_require__(34);
  6994. var Animatable = __webpack_require__(35);
  6995. var zrUtil = __webpack_require__(4);
  6996. /**
  6997. * @alias module:zrender/Element
  6998. * @constructor
  6999. * @extends {module:zrender/mixin/Animatable}
  7000. * @extends {module:zrender/mixin/Transformable}
  7001. * @extends {module:zrender/mixin/Eventful}
  7002. */
  7003. var Element = function (opts) {
  7004. Transformable.call(this, opts);
  7005. Eventful.call(this, opts);
  7006. Animatable.call(this, opts);
  7007. /**
  7008. * 画布元素ID
  7009. * @type {string}
  7010. */
  7011. this.id = opts.id || guid();
  7012. };
  7013. Element.prototype = {
  7014. /**
  7015. * 元素类型
  7016. * Element type
  7017. * @type {string}
  7018. */
  7019. type: 'element',
  7020. /**
  7021. * 元素名字
  7022. * Element name
  7023. * @type {string}
  7024. */
  7025. name: '',
  7026. /**
  7027. * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值
  7028. * ZRender instance will be assigned when element is associated with zrender
  7029. * @name module:/zrender/Element#__zr
  7030. * @type {module:zrender/ZRender}
  7031. */
  7032. __zr: null,
  7033. /**
  7034. * 图形是否忽略,为true时忽略图形的绘制以及事件触发
  7035. * If ignore drawing and events of the element object
  7036. * @name module:/zrender/Element#ignore
  7037. * @type {boolean}
  7038. * @default false
  7039. */
  7040. ignore: false,
  7041. /**
  7042. * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪
  7043. * 该路径会继承被裁减对象的变换
  7044. * @type {module:zrender/graphic/Path}
  7045. * @see http://www.w3.org/TR/2dcontext/#clipping-region
  7046. * @readOnly
  7047. */
  7048. clipPath: null,
  7049. /**
  7050. * Drift element
  7051. * @param {number} dx dx on the global space
  7052. * @param {number} dy dy on the global space
  7053. */
  7054. drift: function (dx, dy) {
  7055. switch (this.draggable) {
  7056. case 'horizontal':
  7057. dy = 0;
  7058. break;
  7059. case 'vertical':
  7060. dx = 0;
  7061. break;
  7062. }
  7063. var m = this.transform;
  7064. if (!m) {
  7065. m = this.transform = [1, 0, 0, 1, 0, 0];
  7066. }
  7067. m[4] += dx;
  7068. m[5] += dy;
  7069. this.decomposeTransform();
  7070. this.dirty(false);
  7071. },
  7072. /**
  7073. * Hook before update
  7074. */
  7075. beforeUpdate: function () {},
  7076. /**
  7077. * Hook after update
  7078. */
  7079. afterUpdate: function () {},
  7080. /**
  7081. * Update each frame
  7082. */
  7083. update: function () {
  7084. this.updateTransform();
  7085. },
  7086. /**
  7087. * @param {Function} cb
  7088. * @param {} context
  7089. */
  7090. traverse: function (cb, context) {},
  7091. /**
  7092. * @protected
  7093. */
  7094. attrKV: function (key, value) {
  7095. if (key === 'position' || key === 'scale' || key === 'origin') {
  7096. // Copy the array
  7097. if (value) {
  7098. var target = this[key];
  7099. if (!target) {
  7100. target = this[key] = [];
  7101. }
  7102. target[0] = value[0];
  7103. target[1] = value[1];
  7104. }
  7105. }
  7106. else {
  7107. this[key] = value;
  7108. }
  7109. },
  7110. /**
  7111. * Hide the element
  7112. */
  7113. hide: function () {
  7114. this.ignore = true;
  7115. this.__zr && this.__zr.refresh();
  7116. },
  7117. /**
  7118. * Show the element
  7119. */
  7120. show: function () {
  7121. this.ignore = false;
  7122. this.__zr && this.__zr.refresh();
  7123. },
  7124. /**
  7125. * @param {string|Object} key
  7126. * @param {*} value
  7127. */
  7128. attr: function (key, value) {
  7129. if (typeof key === 'string') {
  7130. this.attrKV(key, value);
  7131. }
  7132. else if (zrUtil.isObject(key)) {
  7133. for (var name in key) {
  7134. if (key.hasOwnProperty(name)) {
  7135. this.attrKV(name, key[name]);
  7136. }
  7137. }
  7138. }
  7139. this.dirty(false);
  7140. return this;
  7141. },
  7142. /**
  7143. * @param {module:zrender/graphic/Path} clipPath
  7144. */
  7145. setClipPath: function (clipPath) {
  7146. var zr = this.__zr;
  7147. if (zr) {
  7148. clipPath.addSelfToZr(zr);
  7149. }
  7150. // Remove previous clip path
  7151. if (this.clipPath && this.clipPath !== clipPath) {
  7152. this.removeClipPath();
  7153. }
  7154. this.clipPath = clipPath;
  7155. clipPath.__zr = zr;
  7156. clipPath.__clipTarget = this;
  7157. this.dirty(false);
  7158. },
  7159. /**
  7160. */
  7161. removeClipPath: function () {
  7162. var clipPath = this.clipPath;
  7163. if (clipPath) {
  7164. if (clipPath.__zr) {
  7165. clipPath.removeSelfFromZr(clipPath.__zr);
  7166. }
  7167. clipPath.__zr = null;
  7168. clipPath.__clipTarget = null;
  7169. this.clipPath = null;
  7170. this.dirty(false);
  7171. }
  7172. },
  7173. /**
  7174. * Add self from zrender instance.
  7175. * Not recursively because it will be invoked when element added to storage.
  7176. * @param {module:zrender/ZRender} zr
  7177. */
  7178. addSelfToZr: function (zr) {
  7179. this.__zr = zr;
  7180. // 添加动画
  7181. var animators = this.animators;
  7182. if (animators) {
  7183. for (var i = 0; i < animators.length; i++) {
  7184. zr.animation.addAnimator(animators[i]);
  7185. }
  7186. }
  7187. if (this.clipPath) {
  7188. this.clipPath.addSelfToZr(zr);
  7189. }
  7190. },
  7191. /**
  7192. * Remove self from zrender instance.
  7193. * Not recursively because it will be invoked when element added to storage.
  7194. * @param {module:zrender/ZRender} zr
  7195. */
  7196. removeSelfFromZr: function (zr) {
  7197. this.__zr = null;
  7198. // 移除动画
  7199. var animators = this.animators;
  7200. if (animators) {
  7201. for (var i = 0; i < animators.length; i++) {
  7202. zr.animation.removeAnimator(animators[i]);
  7203. }
  7204. }
  7205. if (this.clipPath) {
  7206. this.clipPath.removeSelfFromZr(zr);
  7207. }
  7208. }
  7209. };
  7210. zrUtil.mixin(Element, Animatable);
  7211. zrUtil.mixin(Element, Transformable);
  7212. zrUtil.mixin(Element, Eventful);
  7213. module.exports = Element;
  7214. /***/ },
  7215. /* 32 */
  7216. /***/ function(module, exports) {
  7217. /**
  7218. * zrender: 生成唯一id
  7219. *
  7220. * @author errorrik (errorrik@gmail.com)
  7221. */
  7222. var idStart = 0x0907;
  7223. module.exports = function () {
  7224. return idStart++;
  7225. };
  7226. /***/ },
  7227. /* 33 */
  7228. /***/ function(module, exports) {
  7229. /**
  7230. * 事件扩展
  7231. * @module zrender/mixin/Eventful
  7232. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  7233. * pissang (https://www.github.com/pissang)
  7234. */
  7235. var arrySlice = Array.prototype.slice;
  7236. /**
  7237. * 事件分发器
  7238. * @alias module:zrender/mixin/Eventful
  7239. * @constructor
  7240. */
  7241. var Eventful = function () {
  7242. this._$handlers = {};
  7243. };
  7244. Eventful.prototype = {
  7245. constructor: Eventful,
  7246. /**
  7247. * 单次触发绑定,trigger后销毁
  7248. *
  7249. * @param {string} event 事件名
  7250. * @param {Function} handler 响应函数
  7251. * @param {Object} context
  7252. */
  7253. one: function (event, handler, context) {
  7254. var _h = this._$handlers;
  7255. if (!handler || !event) {
  7256. return this;
  7257. }
  7258. if (!_h[event]) {
  7259. _h[event] = [];
  7260. }
  7261. for (var i = 0; i < _h[event].length; i++) {
  7262. if (_h[event][i].h === handler) {
  7263. return this;
  7264. }
  7265. }
  7266. _h[event].push({
  7267. h: handler,
  7268. one: true,
  7269. ctx: context || this
  7270. });
  7271. return this;
  7272. },
  7273. /**
  7274. * 绑定事件
  7275. * @param {string} event 事件名
  7276. * @param {Function} handler 事件处理函数
  7277. * @param {Object} [context]
  7278. */
  7279. on: function (event, handler, context) {
  7280. var _h = this._$handlers;
  7281. if (!handler || !event) {
  7282. return this;
  7283. }
  7284. if (!_h[event]) {
  7285. _h[event] = [];
  7286. }
  7287. for (var i = 0; i < _h[event].length; i++) {
  7288. if (_h[event][i].h === handler) {
  7289. return this;
  7290. }
  7291. }
  7292. _h[event].push({
  7293. h: handler,
  7294. one: false,
  7295. ctx: context || this
  7296. });
  7297. return this;
  7298. },
  7299. /**
  7300. * 是否绑定了事件
  7301. * @param {string} event
  7302. * @return {boolean}
  7303. */
  7304. isSilent: function (event) {
  7305. var _h = this._$handlers;
  7306. return _h[event] && _h[event].length;
  7307. },
  7308. /**
  7309. * 解绑事件
  7310. * @param {string} event 事件名
  7311. * @param {Function} [handler] 事件处理函数
  7312. */
  7313. off: function (event, handler) {
  7314. var _h = this._$handlers;
  7315. if (!event) {
  7316. this._$handlers = {};
  7317. return this;
  7318. }
  7319. if (handler) {
  7320. if (_h[event]) {
  7321. var newList = [];
  7322. for (var i = 0, l = _h[event].length; i < l; i++) {
  7323. if (_h[event][i]['h'] != handler) {
  7324. newList.push(_h[event][i]);
  7325. }
  7326. }
  7327. _h[event] = newList;
  7328. }
  7329. if (_h[event] && _h[event].length === 0) {
  7330. delete _h[event];
  7331. }
  7332. }
  7333. else {
  7334. delete _h[event];
  7335. }
  7336. return this;
  7337. },
  7338. /**
  7339. * 事件分发
  7340. *
  7341. * @param {string} type 事件类型
  7342. */
  7343. trigger: function (type) {
  7344. if (this._$handlers[type]) {
  7345. var args = arguments;
  7346. var argLen = args.length;
  7347. if (argLen > 3) {
  7348. args = arrySlice.call(args, 1);
  7349. }
  7350. var _h = this._$handlers[type];
  7351. var len = _h.length;
  7352. for (var i = 0; i < len;) {
  7353. // Optimize advise from backbone
  7354. switch (argLen) {
  7355. case 1:
  7356. _h[i]['h'].call(_h[i]['ctx']);
  7357. break;
  7358. case 2:
  7359. _h[i]['h'].call(_h[i]['ctx'], args[1]);
  7360. break;
  7361. case 3:
  7362. _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]);
  7363. break;
  7364. default:
  7365. // have more than 2 given arguments
  7366. _h[i]['h'].apply(_h[i]['ctx'], args);
  7367. break;
  7368. }
  7369. if (_h[i]['one']) {
  7370. _h.splice(i, 1);
  7371. len--;
  7372. }
  7373. else {
  7374. i++;
  7375. }
  7376. }
  7377. }
  7378. return this;
  7379. },
  7380. /**
  7381. * 带有context的事件分发, 最后一个参数是事件回调的context
  7382. * @param {string} type 事件类型
  7383. */
  7384. triggerWithContext: function (type) {
  7385. if (this._$handlers[type]) {
  7386. var args = arguments;
  7387. var argLen = args.length;
  7388. if (argLen > 4) {
  7389. args = arrySlice.call(args, 1, args.length - 1);
  7390. }
  7391. var ctx = args[args.length - 1];
  7392. var _h = this._$handlers[type];
  7393. var len = _h.length;
  7394. for (var i = 0; i < len;) {
  7395. // Optimize advise from backbone
  7396. switch (argLen) {
  7397. case 1:
  7398. _h[i]['h'].call(ctx);
  7399. break;
  7400. case 2:
  7401. _h[i]['h'].call(ctx, args[1]);
  7402. break;
  7403. case 3:
  7404. _h[i]['h'].call(ctx, args[1], args[2]);
  7405. break;
  7406. default:
  7407. // have more than 2 given arguments
  7408. _h[i]['h'].apply(ctx, args);
  7409. break;
  7410. }
  7411. if (_h[i]['one']) {
  7412. _h.splice(i, 1);
  7413. len--;
  7414. }
  7415. else {
  7416. i++;
  7417. }
  7418. }
  7419. }
  7420. return this;
  7421. }
  7422. };
  7423. // 对象可以通过 onxxxx 绑定事件
  7424. /**
  7425. * @event module:zrender/mixin/Eventful#onclick
  7426. * @type {Function}
  7427. * @default null
  7428. */
  7429. /**
  7430. * @event module:zrender/mixin/Eventful#onmouseover
  7431. * @type {Function}
  7432. * @default null
  7433. */
  7434. /**
  7435. * @event module:zrender/mixin/Eventful#onmouseout
  7436. * @type {Function}
  7437. * @default null
  7438. */
  7439. /**
  7440. * @event module:zrender/mixin/Eventful#onmousemove
  7441. * @type {Function}
  7442. * @default null
  7443. */
  7444. /**
  7445. * @event module:zrender/mixin/Eventful#onmousewheel
  7446. * @type {Function}
  7447. * @default null
  7448. */
  7449. /**
  7450. * @event module:zrender/mixin/Eventful#onmousedown
  7451. * @type {Function}
  7452. * @default null
  7453. */
  7454. /**
  7455. * @event module:zrender/mixin/Eventful#onmouseup
  7456. * @type {Function}
  7457. * @default null
  7458. */
  7459. /**
  7460. * @event module:zrender/mixin/Eventful#ondrag
  7461. * @type {Function}
  7462. * @default null
  7463. */
  7464. /**
  7465. * @event module:zrender/mixin/Eventful#ondragstart
  7466. * @type {Function}
  7467. * @default null
  7468. */
  7469. /**
  7470. * @event module:zrender/mixin/Eventful#ondragend
  7471. * @type {Function}
  7472. * @default null
  7473. */
  7474. /**
  7475. * @event module:zrender/mixin/Eventful#ondragenter
  7476. * @type {Function}
  7477. * @default null
  7478. */
  7479. /**
  7480. * @event module:zrender/mixin/Eventful#ondragleave
  7481. * @type {Function}
  7482. * @default null
  7483. */
  7484. /**
  7485. * @event module:zrender/mixin/Eventful#ondragover
  7486. * @type {Function}
  7487. * @default null
  7488. */
  7489. /**
  7490. * @event module:zrender/mixin/Eventful#ondrop
  7491. * @type {Function}
  7492. * @default null
  7493. */
  7494. module.exports = Eventful;
  7495. /***/ },
  7496. /* 34 */
  7497. /***/ function(module, exports, __webpack_require__) {
  7498. 'use strict';
  7499. /**
  7500. * 提供变换扩展
  7501. * @module zrender/mixin/Transformable
  7502. * @author pissang (https://www.github.com/pissang)
  7503. */
  7504. var matrix = __webpack_require__(11);
  7505. var vector = __webpack_require__(10);
  7506. var mIdentity = matrix.identity;
  7507. var EPSILON = 5e-5;
  7508. function isNotAroundZero(val) {
  7509. return val > EPSILON || val < -EPSILON;
  7510. }
  7511. /**
  7512. * @alias module:zrender/mixin/Transformable
  7513. * @constructor
  7514. */
  7515. var Transformable = function (opts) {
  7516. opts = opts || {};
  7517. // If there are no given position, rotation, scale
  7518. if (!opts.position) {
  7519. /**
  7520. * 平移
  7521. * @type {Array.<number>}
  7522. * @default [0, 0]
  7523. */
  7524. this.position = [0, 0];
  7525. }
  7526. if (opts.rotation == null) {
  7527. /**
  7528. * 旋转
  7529. * @type {Array.<number>}
  7530. * @default 0
  7531. */
  7532. this.rotation = 0;
  7533. }
  7534. if (!opts.scale) {
  7535. /**
  7536. * 缩放
  7537. * @type {Array.<number>}
  7538. * @default [1, 1]
  7539. */
  7540. this.scale = [1, 1];
  7541. }
  7542. /**
  7543. * 旋转和缩放的原点
  7544. * @type {Array.<number>}
  7545. * @default null
  7546. */
  7547. this.origin = this.origin || null;
  7548. };
  7549. var transformableProto = Transformable.prototype;
  7550. transformableProto.transform = null;
  7551. /**
  7552. * 判断是否需要有坐标变换
  7553. * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
  7554. */
  7555. transformableProto.needLocalTransform = function () {
  7556. return isNotAroundZero(this.rotation)
  7557. || isNotAroundZero(this.position[0])
  7558. || isNotAroundZero(this.position[1])
  7559. || isNotAroundZero(this.scale[0] - 1)
  7560. || isNotAroundZero(this.scale[1] - 1);
  7561. };
  7562. transformableProto.updateTransform = function () {
  7563. var parent = this.parent;
  7564. var parentHasTransform = parent && parent.transform;
  7565. var needLocalTransform = this.needLocalTransform();
  7566. var m = this.transform;
  7567. if (!(needLocalTransform || parentHasTransform)) {
  7568. m && mIdentity(m);
  7569. return;
  7570. }
  7571. m = m || matrix.create();
  7572. if (needLocalTransform) {
  7573. this.getLocalTransform(m);
  7574. }
  7575. else {
  7576. mIdentity(m);
  7577. }
  7578. // 应用父节点变换
  7579. if (parentHasTransform) {
  7580. if (needLocalTransform) {
  7581. matrix.mul(m, parent.transform, m);
  7582. }
  7583. else {
  7584. matrix.copy(m, parent.transform);
  7585. }
  7586. }
  7587. // 保存这个变换矩阵
  7588. this.transform = m;
  7589. this.invTransform = this.invTransform || matrix.create();
  7590. matrix.invert(this.invTransform, m);
  7591. };
  7592. transformableProto.getLocalTransform = function (m) {
  7593. m = m || [];
  7594. mIdentity(m);
  7595. var origin = this.origin;
  7596. var scale = this.scale;
  7597. var rotation = this.rotation;
  7598. var position = this.position;
  7599. if (origin) {
  7600. // Translate to origin
  7601. m[4] -= origin[0];
  7602. m[5] -= origin[1];
  7603. }
  7604. matrix.scale(m, m, scale);
  7605. if (rotation) {
  7606. matrix.rotate(m, m, rotation);
  7607. }
  7608. if (origin) {
  7609. // Translate back from origin
  7610. m[4] += origin[0];
  7611. m[5] += origin[1];
  7612. }
  7613. m[4] += position[0];
  7614. m[5] += position[1];
  7615. return m;
  7616. };
  7617. /**
  7618. * 将自己的transform应用到context上
  7619. * @param {Context2D} ctx
  7620. */
  7621. transformableProto.setTransform = function (ctx) {
  7622. var m = this.transform;
  7623. var dpr = ctx.dpr || 1;
  7624. if (m) {
  7625. ctx.setTransform(dpr * m[0], dpr * m[1], dpr * m[2], dpr * m[3], dpr * m[4], dpr * m[5]);
  7626. }
  7627. else {
  7628. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  7629. }
  7630. };
  7631. transformableProto.restoreTransform = function (ctx) {
  7632. var m = this.transform;
  7633. var dpr = ctx.dpr || 1;
  7634. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  7635. }
  7636. var tmpTransform = [];
  7637. /**
  7638. * 分解`transform`矩阵到`position`, `rotation`, `scale`
  7639. */
  7640. transformableProto.decomposeTransform = function () {
  7641. if (!this.transform) {
  7642. return;
  7643. }
  7644. var parent = this.parent;
  7645. var m = this.transform;
  7646. if (parent && parent.transform) {
  7647. // Get local transform and decompose them to position, scale, rotation
  7648. matrix.mul(tmpTransform, parent.invTransform, m);
  7649. m = tmpTransform;
  7650. }
  7651. var sx = m[0] * m[0] + m[1] * m[1];
  7652. var sy = m[2] * m[2] + m[3] * m[3];
  7653. var position = this.position;
  7654. var scale = this.scale;
  7655. if (isNotAroundZero(sx - 1)) {
  7656. sx = Math.sqrt(sx);
  7657. }
  7658. if (isNotAroundZero(sy - 1)) {
  7659. sy = Math.sqrt(sy);
  7660. }
  7661. if (m[0] < 0) {
  7662. sx = -sx;
  7663. }
  7664. if (m[3] < 0) {
  7665. sy = -sy;
  7666. }
  7667. position[0] = m[4];
  7668. position[1] = m[5];
  7669. scale[0] = sx;
  7670. scale[1] = sy;
  7671. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  7672. };
  7673. /**
  7674. * Get global scale
  7675. * @return {Array.<number>}
  7676. */
  7677. transformableProto.getGlobalScale = function () {
  7678. var m = this.transform;
  7679. if (!m) {
  7680. return [1, 1];
  7681. }
  7682. var sx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  7683. var sy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  7684. if (m[0] < 0) {
  7685. sx = -sx;
  7686. }
  7687. if (m[3] < 0) {
  7688. sy = -sy;
  7689. }
  7690. return [sx, sy];
  7691. };
  7692. /**
  7693. * 变换坐标位置到 shape 的局部坐标空间
  7694. * @method
  7695. * @param {number} x
  7696. * @param {number} y
  7697. * @return {Array.<number>}
  7698. */
  7699. transformableProto.transformCoordToLocal = function (x, y) {
  7700. var v2 = [x, y];
  7701. var invTransform = this.invTransform;
  7702. if (invTransform) {
  7703. vector.applyTransform(v2, v2, invTransform);
  7704. }
  7705. return v2;
  7706. };
  7707. /**
  7708. * 变换局部坐标位置到全局坐标空间
  7709. * @method
  7710. * @param {number} x
  7711. * @param {number} y
  7712. * @return {Array.<number>}
  7713. */
  7714. transformableProto.transformCoordToGlobal = function (x, y) {
  7715. var v2 = [x, y];
  7716. var transform = this.transform;
  7717. if (transform) {
  7718. vector.applyTransform(v2, v2, transform);
  7719. }
  7720. return v2;
  7721. };
  7722. module.exports = Transformable;
  7723. /***/ },
  7724. /* 35 */
  7725. /***/ function(module, exports, __webpack_require__) {
  7726. 'use strict';
  7727. /**
  7728. * @module zrender/mixin/Animatable
  7729. */
  7730. var Animator = __webpack_require__(36);
  7731. var util = __webpack_require__(4);
  7732. var isString = util.isString;
  7733. var isFunction = util.isFunction;
  7734. var isObject = util.isObject;
  7735. var log = __webpack_require__(40);
  7736. /**
  7737. * @alias modue:zrender/mixin/Animatable
  7738. * @constructor
  7739. */
  7740. var Animatable = function () {
  7741. /**
  7742. * @type {Array.<module:zrender/animation/Animator>}
  7743. * @readOnly
  7744. */
  7745. this.animators = [];
  7746. };
  7747. Animatable.prototype = {
  7748. constructor: Animatable,
  7749. /**
  7750. * 动画
  7751. *
  7752. * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性
  7753. * @param {boolean} [loop] 动画是否循环
  7754. * @return {module:zrender/animation/Animator}
  7755. * @example:
  7756. * el.animate('style', false)
  7757. * .when(1000, {x: 10} )
  7758. * .done(function(){ // Animation done })
  7759. * .start()
  7760. */
  7761. animate: function (path, loop) {
  7762. var target;
  7763. var animatingShape = false;
  7764. var el = this;
  7765. var zr = this.__zr;
  7766. if (path) {
  7767. var pathSplitted = path.split('.');
  7768. var prop = el;
  7769. // If animating shape
  7770. animatingShape = pathSplitted[0] === 'shape';
  7771. for (var i = 0, l = pathSplitted.length; i < l; i++) {
  7772. if (!prop) {
  7773. continue;
  7774. }
  7775. prop = prop[pathSplitted[i]];
  7776. }
  7777. if (prop) {
  7778. target = prop;
  7779. }
  7780. }
  7781. else {
  7782. target = el;
  7783. }
  7784. if (!target) {
  7785. log(
  7786. 'Property "'
  7787. + path
  7788. + '" is not existed in element '
  7789. + el.id
  7790. );
  7791. return;
  7792. }
  7793. var animators = el.animators;
  7794. var animator = new Animator(target, loop);
  7795. animator.during(function (target) {
  7796. el.dirty(animatingShape);
  7797. })
  7798. .done(function () {
  7799. // FIXME Animator will not be removed if use `Animator#stop` to stop animation
  7800. animators.splice(util.indexOf(animators, animator), 1);
  7801. });
  7802. animators.push(animator);
  7803. // If animate after added to the zrender
  7804. if (zr) {
  7805. zr.animation.addAnimator(animator);
  7806. }
  7807. return animator;
  7808. },
  7809. /**
  7810. * 停止动画
  7811. * @param {boolean} forwardToLast If move to last frame before stop
  7812. */
  7813. stopAnimation: function (forwardToLast) {
  7814. var animators = this.animators;
  7815. var len = animators.length;
  7816. for (var i = 0; i < len; i++) {
  7817. animators[i].stop(forwardToLast);
  7818. }
  7819. animators.length = 0;
  7820. return this;
  7821. },
  7822. /**
  7823. * @param {Object} target
  7824. * @param {number} [time=500] Time in ms
  7825. * @param {string} [easing='linear']
  7826. * @param {number} [delay=0]
  7827. * @param {Function} [callback]
  7828. *
  7829. * @example
  7830. * // Animate position
  7831. * el.animateTo({
  7832. * position: [10, 10]
  7833. * }, function () { // done })
  7834. *
  7835. * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing
  7836. * el.animateTo({
  7837. * shape: {
  7838. * width: 500
  7839. * },
  7840. * style: {
  7841. * fill: 'red'
  7842. * }
  7843. * position: [10, 10]
  7844. * }, 100, 100, 'cubicOut', function () { // done })
  7845. */
  7846. // TODO Return animation key
  7847. animateTo: function (target, time, delay, easing, callback) {
  7848. // animateTo(target, time, easing, callback);
  7849. if (isString(delay)) {
  7850. callback = easing;
  7851. easing = delay;
  7852. delay = 0;
  7853. }
  7854. // animateTo(target, time, delay, callback);
  7855. else if (isFunction(easing)) {
  7856. callback = easing;
  7857. easing = 'linear';
  7858. delay = 0;
  7859. }
  7860. // animateTo(target, time, callback);
  7861. else if (isFunction(delay)) {
  7862. callback = delay;
  7863. delay = 0;
  7864. }
  7865. // animateTo(target, callback)
  7866. else if (isFunction(time)) {
  7867. callback = time;
  7868. time = 500;
  7869. }
  7870. // animateTo(target)
  7871. else if (!time) {
  7872. time = 500;
  7873. }
  7874. // Stop all previous animations
  7875. this.stopAnimation();
  7876. this._animateToShallow('', this, target, time, delay, easing, callback);
  7877. // Animators may be removed immediately after start
  7878. // if there is nothing to animate
  7879. var animators = this.animators.slice();
  7880. var count = animators.length;
  7881. function done() {
  7882. count--;
  7883. if (!count) {
  7884. callback && callback();
  7885. }
  7886. }
  7887. // No animators. This should be checked before animators[i].start(),
  7888. // because 'done' may be executed immediately if no need to animate.
  7889. if (!count) {
  7890. callback && callback();
  7891. }
  7892. // Start after all animators created
  7893. // Incase any animator is done immediately when all animation properties are not changed
  7894. for (var i = 0; i < animators.length; i++) {
  7895. animators[i]
  7896. .done(done)
  7897. .start(easing);
  7898. }
  7899. },
  7900. /**
  7901. * @private
  7902. * @param {string} path=''
  7903. * @param {Object} source=this
  7904. * @param {Object} target
  7905. * @param {number} [time=500]
  7906. * @param {number} [delay=0]
  7907. *
  7908. * @example
  7909. * // Animate position
  7910. * el._animateToShallow({
  7911. * position: [10, 10]
  7912. * })
  7913. *
  7914. * // Animate shape, style and position in 100ms, delayed 100ms
  7915. * el._animateToShallow({
  7916. * shape: {
  7917. * width: 500
  7918. * },
  7919. * style: {
  7920. * fill: 'red'
  7921. * }
  7922. * position: [10, 10]
  7923. * }, 100, 100)
  7924. */
  7925. _animateToShallow: function (path, source, target, time, delay) {
  7926. var objShallow = {};
  7927. var propertyCount = 0;
  7928. for (var name in target) {
  7929. if (!target.hasOwnProperty(name)) {
  7930. continue;
  7931. }
  7932. if (source[name] != null) {
  7933. if (isObject(target[name]) && !util.isArrayLike(target[name])) {
  7934. this._animateToShallow(
  7935. path ? path + '.' + name : name,
  7936. source[name],
  7937. target[name],
  7938. time,
  7939. delay
  7940. );
  7941. }
  7942. else {
  7943. objShallow[name] = target[name];
  7944. propertyCount++;
  7945. }
  7946. }
  7947. else if (target[name] != null) {
  7948. // Attr directly if not has property
  7949. // FIXME, if some property not needed for element ?
  7950. if (!path) {
  7951. this.attr(name, target[name]);
  7952. }
  7953. else { // Shape or style
  7954. var props = {};
  7955. props[path] = {};
  7956. props[path][name] = target[name];
  7957. this.attr(props);
  7958. }
  7959. }
  7960. }
  7961. if (propertyCount > 0) {
  7962. this.animate(path, false)
  7963. .when(time == null ? 500 : time, objShallow)
  7964. .delay(delay || 0);
  7965. }
  7966. return this;
  7967. }
  7968. };
  7969. module.exports = Animatable;
  7970. /***/ },
  7971. /* 36 */
  7972. /***/ function(module, exports, __webpack_require__) {
  7973. /**
  7974. * @module echarts/animation/Animator
  7975. */
  7976. var Clip = __webpack_require__(37);
  7977. var color = __webpack_require__(39);
  7978. var util = __webpack_require__(4);
  7979. var isArrayLike = util.isArrayLike;
  7980. var arraySlice = Array.prototype.slice;
  7981. function defaultGetter(target, key) {
  7982. return target[key];
  7983. }
  7984. function defaultSetter(target, key, value) {
  7985. target[key] = value;
  7986. }
  7987. /**
  7988. * @param {number} p0
  7989. * @param {number} p1
  7990. * @param {number} percent
  7991. * @return {number}
  7992. */
  7993. function interpolateNumber(p0, p1, percent) {
  7994. return (p1 - p0) * percent + p0;
  7995. }
  7996. /**
  7997. * @param {string} p0
  7998. * @param {string} p1
  7999. * @param {number} percent
  8000. * @return {string}
  8001. */
  8002. function interpolateString(p0, p1, percent) {
  8003. return percent > 0.5 ? p1 : p0;
  8004. }
  8005. /**
  8006. * @param {Array} p0
  8007. * @param {Array} p1
  8008. * @param {number} percent
  8009. * @param {Array} out
  8010. * @param {number} arrDim
  8011. */
  8012. function interpolateArray(p0, p1, percent, out, arrDim) {
  8013. var len = p0.length;
  8014. if (arrDim == 1) {
  8015. for (var i = 0; i < len; i++) {
  8016. out[i] = interpolateNumber(p0[i], p1[i], percent);
  8017. }
  8018. }
  8019. else {
  8020. var len2 = p0[0].length;
  8021. for (var i = 0; i < len; i++) {
  8022. for (var j = 0; j < len2; j++) {
  8023. out[i][j] = interpolateNumber(
  8024. p0[i][j], p1[i][j], percent
  8025. );
  8026. }
  8027. }
  8028. }
  8029. }
  8030. // arr0 is source array, arr1 is target array.
  8031. // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
  8032. function fillArr(arr0, arr1, arrDim) {
  8033. var arr0Len = arr0.length;
  8034. var arr1Len = arr1.length;
  8035. if (arr0Len !== arr1Len) {
  8036. // FIXME Not work for TypedArray
  8037. var isPreviousLarger = arr0Len > arr1Len;
  8038. if (isPreviousLarger) {
  8039. // Cut the previous
  8040. arr0.length = arr1Len;
  8041. }
  8042. else {
  8043. // Fill the previous
  8044. for (var i = arr0Len; i < arr1Len; i++) {
  8045. arr0.push(
  8046. arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i])
  8047. );
  8048. }
  8049. }
  8050. }
  8051. // Handling NaN value
  8052. var len2 = arr0[0] && arr0[0].length;
  8053. for (var i = 0; i < arr0.length; i++) {
  8054. if (arrDim === 1) {
  8055. if (isNaN(arr0[i])) {
  8056. arr0[i] = arr1[i];
  8057. }
  8058. }
  8059. else {
  8060. for (var j = 0; j < len2; j++) {
  8061. if (isNaN(arr0[i][j])) {
  8062. arr0[i][j] = arr1[i][j];
  8063. }
  8064. }
  8065. }
  8066. }
  8067. }
  8068. /**
  8069. * @param {Array} arr0
  8070. * @param {Array} arr1
  8071. * @param {number} arrDim
  8072. * @return {boolean}
  8073. */
  8074. function isArraySame(arr0, arr1, arrDim) {
  8075. if (arr0 === arr1) {
  8076. return true;
  8077. }
  8078. var len = arr0.length;
  8079. if (len !== arr1.length) {
  8080. return false;
  8081. }
  8082. if (arrDim === 1) {
  8083. for (var i = 0; i < len; i++) {
  8084. if (arr0[i] !== arr1[i]) {
  8085. return false;
  8086. }
  8087. }
  8088. }
  8089. else {
  8090. var len2 = arr0[0].length;
  8091. for (var i = 0; i < len; i++) {
  8092. for (var j = 0; j < len2; j++) {
  8093. if (arr0[i][j] !== arr1[i][j]) {
  8094. return false;
  8095. }
  8096. }
  8097. }
  8098. }
  8099. return true;
  8100. }
  8101. /**
  8102. * Catmull Rom interpolate array
  8103. * @param {Array} p0
  8104. * @param {Array} p1
  8105. * @param {Array} p2
  8106. * @param {Array} p3
  8107. * @param {number} t
  8108. * @param {number} t2
  8109. * @param {number} t3
  8110. * @param {Array} out
  8111. * @param {number} arrDim
  8112. */
  8113. function catmullRomInterpolateArray(
  8114. p0, p1, p2, p3, t, t2, t3, out, arrDim
  8115. ) {
  8116. var len = p0.length;
  8117. if (arrDim == 1) {
  8118. for (var i = 0; i < len; i++) {
  8119. out[i] = catmullRomInterpolate(
  8120. p0[i], p1[i], p2[i], p3[i], t, t2, t3
  8121. );
  8122. }
  8123. }
  8124. else {
  8125. var len2 = p0[0].length;
  8126. for (var i = 0; i < len; i++) {
  8127. for (var j = 0; j < len2; j++) {
  8128. out[i][j] = catmullRomInterpolate(
  8129. p0[i][j], p1[i][j], p2[i][j], p3[i][j],
  8130. t, t2, t3
  8131. );
  8132. }
  8133. }
  8134. }
  8135. }
  8136. /**
  8137. * Catmull Rom interpolate number
  8138. * @param {number} p0
  8139. * @param {number} p1
  8140. * @param {number} p2
  8141. * @param {number} p3
  8142. * @param {number} t
  8143. * @param {number} t2
  8144. * @param {number} t3
  8145. * @return {number}
  8146. */
  8147. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  8148. var v0 = (p2 - p0) * 0.5;
  8149. var v1 = (p3 - p1) * 0.5;
  8150. return (2 * (p1 - p2) + v0 + v1) * t3
  8151. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  8152. + v0 * t + p1;
  8153. }
  8154. function cloneValue(value) {
  8155. if (isArrayLike(value)) {
  8156. var len = value.length;
  8157. if (isArrayLike(value[0])) {
  8158. var ret = [];
  8159. for (var i = 0; i < len; i++) {
  8160. ret.push(arraySlice.call(value[i]));
  8161. }
  8162. return ret;
  8163. }
  8164. return arraySlice.call(value);
  8165. }
  8166. return value;
  8167. }
  8168. function rgba2String(rgba) {
  8169. rgba[0] = Math.floor(rgba[0]);
  8170. rgba[1] = Math.floor(rgba[1]);
  8171. rgba[2] = Math.floor(rgba[2]);
  8172. return 'rgba(' + rgba.join(',') + ')';
  8173. }
  8174. function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) {
  8175. var getter = animator._getter;
  8176. var setter = animator._setter;
  8177. var useSpline = easing === 'spline';
  8178. var trackLen = keyframes.length;
  8179. if (!trackLen) {
  8180. return;
  8181. }
  8182. // Guess data type
  8183. var firstVal = keyframes[0].value;
  8184. var isValueArray = isArrayLike(firstVal);
  8185. var isValueColor = false;
  8186. var isValueString = false;
  8187. // For vertices morphing
  8188. var arrDim = (
  8189. isValueArray
  8190. && isArrayLike(firstVal[0])
  8191. )
  8192. ? 2 : 1;
  8193. var trackMaxTime;
  8194. // Sort keyframe as ascending
  8195. keyframes.sort(function(a, b) {
  8196. return a.time - b.time;
  8197. });
  8198. trackMaxTime = keyframes[trackLen - 1].time;
  8199. // Percents of each keyframe
  8200. var kfPercents = [];
  8201. // Value of each keyframe
  8202. var kfValues = [];
  8203. var prevValue = keyframes[0].value;
  8204. var isAllValueEqual = true;
  8205. for (var i = 0; i < trackLen; i++) {
  8206. kfPercents.push(keyframes[i].time / trackMaxTime);
  8207. // Assume value is a color when it is a string
  8208. var value = keyframes[i].value;
  8209. // Check if value is equal, deep check if value is array
  8210. if (!((isValueArray && isArraySame(value, prevValue, arrDim))
  8211. || (!isValueArray && value === prevValue))) {
  8212. isAllValueEqual = false;
  8213. }
  8214. prevValue = value;
  8215. // Try converting a string to a color array
  8216. if (typeof value == 'string') {
  8217. var colorArray = color.parse(value);
  8218. if (colorArray) {
  8219. value = colorArray;
  8220. isValueColor = true;
  8221. }
  8222. else {
  8223. isValueString = true;
  8224. }
  8225. }
  8226. kfValues.push(value);
  8227. }
  8228. if (isAllValueEqual) {
  8229. return;
  8230. }
  8231. var lastValue = kfValues[trackLen - 1];
  8232. // Polyfill array and NaN value
  8233. for (var i = 0; i < trackLen - 1; i++) {
  8234. if (isValueArray) {
  8235. fillArr(kfValues[i], lastValue, arrDim);
  8236. }
  8237. else {
  8238. if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
  8239. kfValues[i] = lastValue;
  8240. }
  8241. }
  8242. }
  8243. isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim);
  8244. // Cache the key of last frame to speed up when
  8245. // animation playback is sequency
  8246. var lastFrame = 0;
  8247. var lastFramePercent = 0;
  8248. var start;
  8249. var w;
  8250. var p0;
  8251. var p1;
  8252. var p2;
  8253. var p3;
  8254. if (isValueColor) {
  8255. var rgba = [0, 0, 0, 0];
  8256. }
  8257. var onframe = function (target, percent) {
  8258. // Find the range keyframes
  8259. // kf1-----kf2---------current--------kf3
  8260. // find kf2 and kf3 and do interpolation
  8261. var frame;
  8262. // In the easing function like elasticOut, percent may less than 0
  8263. if (percent < 0) {
  8264. frame = 0;
  8265. }
  8266. else if (percent < lastFramePercent) {
  8267. // Start from next key
  8268. // PENDING start from lastFrame ?
  8269. start = Math.min(lastFrame + 1, trackLen - 1);
  8270. for (frame = start; frame >= 0; frame--) {
  8271. if (kfPercents[frame] <= percent) {
  8272. break;
  8273. }
  8274. }
  8275. // PENDING really need to do this ?
  8276. frame = Math.min(frame, trackLen - 2);
  8277. }
  8278. else {
  8279. for (frame = lastFrame; frame < trackLen; frame++) {
  8280. if (kfPercents[frame] > percent) {
  8281. break;
  8282. }
  8283. }
  8284. frame = Math.min(frame - 1, trackLen - 2);
  8285. }
  8286. lastFrame = frame;
  8287. lastFramePercent = percent;
  8288. var range = (kfPercents[frame + 1] - kfPercents[frame]);
  8289. if (range === 0) {
  8290. return;
  8291. }
  8292. else {
  8293. w = (percent - kfPercents[frame]) / range;
  8294. }
  8295. if (useSpline) {
  8296. p1 = kfValues[frame];
  8297. p0 = kfValues[frame === 0 ? frame : frame - 1];
  8298. p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
  8299. p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
  8300. if (isValueArray) {
  8301. catmullRomInterpolateArray(
  8302. p0, p1, p2, p3, w, w * w, w * w * w,
  8303. getter(target, propName),
  8304. arrDim
  8305. );
  8306. }
  8307. else {
  8308. var value;
  8309. if (isValueColor) {
  8310. value = catmullRomInterpolateArray(
  8311. p0, p1, p2, p3, w, w * w, w * w * w,
  8312. rgba, 1
  8313. );
  8314. value = rgba2String(rgba);
  8315. }
  8316. else if (isValueString) {
  8317. // String is step(0.5)
  8318. return interpolateString(p1, p2, w);
  8319. }
  8320. else {
  8321. value = catmullRomInterpolate(
  8322. p0, p1, p2, p3, w, w * w, w * w * w
  8323. );
  8324. }
  8325. setter(
  8326. target,
  8327. propName,
  8328. value
  8329. );
  8330. }
  8331. }
  8332. else {
  8333. if (isValueArray) {
  8334. interpolateArray(
  8335. kfValues[frame], kfValues[frame + 1], w,
  8336. getter(target, propName),
  8337. arrDim
  8338. );
  8339. }
  8340. else {
  8341. var value;
  8342. if (isValueColor) {
  8343. interpolateArray(
  8344. kfValues[frame], kfValues[frame + 1], w,
  8345. rgba, 1
  8346. );
  8347. value = rgba2String(rgba);
  8348. }
  8349. else if (isValueString) {
  8350. // String is step(0.5)
  8351. return interpolateString(kfValues[frame], kfValues[frame + 1], w);
  8352. }
  8353. else {
  8354. value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
  8355. }
  8356. setter(
  8357. target,
  8358. propName,
  8359. value
  8360. );
  8361. }
  8362. }
  8363. };
  8364. var clip = new Clip({
  8365. target: animator._target,
  8366. life: trackMaxTime,
  8367. loop: animator._loop,
  8368. delay: animator._delay,
  8369. onframe: onframe,
  8370. ondestroy: oneTrackDone
  8371. });
  8372. if (easing && easing !== 'spline') {
  8373. clip.easing = easing;
  8374. }
  8375. return clip;
  8376. }
  8377. /**
  8378. * @alias module:zrender/animation/Animator
  8379. * @constructor
  8380. * @param {Object} target
  8381. * @param {boolean} loop
  8382. * @param {Function} getter
  8383. * @param {Function} setter
  8384. */
  8385. var Animator = function(target, loop, getter, setter) {
  8386. this._tracks = {};
  8387. this._target = target;
  8388. this._loop = loop || false;
  8389. this._getter = getter || defaultGetter;
  8390. this._setter = setter || defaultSetter;
  8391. this._clipCount = 0;
  8392. this._delay = 0;
  8393. this._doneList = [];
  8394. this._onframeList = [];
  8395. this._clipList = [];
  8396. };
  8397. Animator.prototype = {
  8398. /**
  8399. * 设置动画关键帧
  8400. * @param {number} time 关键帧时间,单位是ms
  8401. * @param {Object} props 关键帧的属性值,key-value表示
  8402. * @return {module:zrender/animation/Animator}
  8403. */
  8404. when: function(time /* ms */, props) {
  8405. var tracks = this._tracks;
  8406. for (var propName in props) {
  8407. if (!props.hasOwnProperty(propName)) {
  8408. continue;
  8409. }
  8410. if (!tracks[propName]) {
  8411. tracks[propName] = [];
  8412. // Invalid value
  8413. var value = this._getter(this._target, propName);
  8414. if (value == null) {
  8415. // zrLog('Invalid property ' + propName);
  8416. continue;
  8417. }
  8418. // If time is 0
  8419. // Then props is given initialize value
  8420. // Else
  8421. // Initialize value from current prop value
  8422. if (time !== 0) {
  8423. tracks[propName].push({
  8424. time: 0,
  8425. value: cloneValue(value)
  8426. });
  8427. }
  8428. }
  8429. tracks[propName].push({
  8430. time: time,
  8431. value: props[propName]
  8432. });
  8433. }
  8434. return this;
  8435. },
  8436. /**
  8437. * 添加动画每一帧的回调函数
  8438. * @param {Function} callback
  8439. * @return {module:zrender/animation/Animator}
  8440. */
  8441. during: function (callback) {
  8442. this._onframeList.push(callback);
  8443. return this;
  8444. },
  8445. _doneCallback: function () {
  8446. // Clear all tracks
  8447. this._tracks = {};
  8448. // Clear all clips
  8449. this._clipList.length = 0;
  8450. var doneList = this._doneList;
  8451. var len = doneList.length;
  8452. for (var i = 0; i < len; i++) {
  8453. doneList[i].call(this);
  8454. }
  8455. },
  8456. /**
  8457. * 开始执行动画
  8458. * @param {string|Function} easing
  8459. * 动画缓动函数,详见{@link module:zrender/animation/easing}
  8460. * @return {module:zrender/animation/Animator}
  8461. */
  8462. start: function (easing) {
  8463. var self = this;
  8464. var clipCount = 0;
  8465. var oneTrackDone = function() {
  8466. clipCount--;
  8467. if (!clipCount) {
  8468. self._doneCallback();
  8469. }
  8470. };
  8471. var lastClip;
  8472. for (var propName in this._tracks) {
  8473. if (!this._tracks.hasOwnProperty(propName)) {
  8474. continue;
  8475. }
  8476. var clip = createTrackClip(
  8477. this, easing, oneTrackDone,
  8478. this._tracks[propName], propName
  8479. );
  8480. if (clip) {
  8481. this._clipList.push(clip);
  8482. clipCount++;
  8483. // If start after added to animation
  8484. if (this.animation) {
  8485. this.animation.addClip(clip);
  8486. }
  8487. lastClip = clip;
  8488. }
  8489. }
  8490. // Add during callback on the last clip
  8491. if (lastClip) {
  8492. var oldOnFrame = lastClip.onframe;
  8493. lastClip.onframe = function (target, percent) {
  8494. oldOnFrame(target, percent);
  8495. for (var i = 0; i < self._onframeList.length; i++) {
  8496. self._onframeList[i](target, percent);
  8497. }
  8498. };
  8499. }
  8500. if (!clipCount) {
  8501. this._doneCallback();
  8502. }
  8503. return this;
  8504. },
  8505. /**
  8506. * 停止动画
  8507. * @param {boolean} forwardToLast If move to last frame before stop
  8508. */
  8509. stop: function (forwardToLast) {
  8510. var clipList = this._clipList;
  8511. var animation = this.animation;
  8512. for (var i = 0; i < clipList.length; i++) {
  8513. var clip = clipList[i];
  8514. if (forwardToLast) {
  8515. // Move to last frame before stop
  8516. clip.onframe(this._target, 1);
  8517. }
  8518. animation && animation.removeClip(clip);
  8519. }
  8520. clipList.length = 0;
  8521. },
  8522. /**
  8523. * 设置动画延迟开始的时间
  8524. * @param {number} time 单位ms
  8525. * @return {module:zrender/animation/Animator}
  8526. */
  8527. delay: function (time) {
  8528. this._delay = time;
  8529. return this;
  8530. },
  8531. /**
  8532. * 添加动画结束的回调
  8533. * @param {Function} cb
  8534. * @return {module:zrender/animation/Animator}
  8535. */
  8536. done: function(cb) {
  8537. if (cb) {
  8538. this._doneList.push(cb);
  8539. }
  8540. return this;
  8541. },
  8542. /**
  8543. * @return {Array.<module:zrender/animation/Clip>}
  8544. */
  8545. getClips: function () {
  8546. return this._clipList;
  8547. }
  8548. };
  8549. module.exports = Animator;
  8550. /***/ },
  8551. /* 37 */
  8552. /***/ function(module, exports, __webpack_require__) {
  8553. /**
  8554. * 动画主控制器
  8555. * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件
  8556. * @config life(1000) 动画时长
  8557. * @config delay(0) 动画延迟时间
  8558. * @config loop(true)
  8559. * @config gap(0) 循环的间隔时间
  8560. * @config onframe
  8561. * @config easing(optional)
  8562. * @config ondestroy(optional)
  8563. * @config onrestart(optional)
  8564. *
  8565. * TODO pause
  8566. */
  8567. var easingFuncs = __webpack_require__(38);
  8568. function Clip(options) {
  8569. this._target = options.target;
  8570. // 生命周期
  8571. this._life = options.life || 1000;
  8572. // 延时
  8573. this._delay = options.delay || 0;
  8574. // 开始时间
  8575. // this._startTime = new Date().getTime() + this._delay;// 单位毫秒
  8576. this._initialized = false;
  8577. // 是否循环
  8578. this.loop = options.loop == null ? false : options.loop;
  8579. this.gap = options.gap || 0;
  8580. this.easing = options.easing || 'Linear';
  8581. this.onframe = options.onframe;
  8582. this.ondestroy = options.ondestroy;
  8583. this.onrestart = options.onrestart;
  8584. }
  8585. Clip.prototype = {
  8586. constructor: Clip,
  8587. step: function (globalTime) {
  8588. // Set startTime on first step, or _startTime may has milleseconds different between clips
  8589. // PENDING
  8590. if (!this._initialized) {
  8591. this._startTime = globalTime + this._delay;
  8592. this._initialized = true;
  8593. }
  8594. var percent = (globalTime - this._startTime) / this._life;
  8595. // 还没开始
  8596. if (percent < 0) {
  8597. return;
  8598. }
  8599. percent = Math.min(percent, 1);
  8600. var easing = this.easing;
  8601. var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing;
  8602. var schedule = typeof easingFunc === 'function'
  8603. ? easingFunc(percent)
  8604. : percent;
  8605. this.fire('frame', schedule);
  8606. // 结束
  8607. if (percent == 1) {
  8608. if (this.loop) {
  8609. this.restart (globalTime);
  8610. // 重新开始周期
  8611. // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件
  8612. return 'restart';
  8613. }
  8614. // 动画完成将这个控制器标识为待删除
  8615. // 在Animation.update中进行批量删除
  8616. this._needsRemove = true;
  8617. return 'destroy';
  8618. }
  8619. return null;
  8620. },
  8621. restart: function (globalTime) {
  8622. var remainder = (globalTime - this._startTime) % this._life;
  8623. this._startTime = globalTime - remainder + this.gap;
  8624. this._needsRemove = false;
  8625. },
  8626. fire: function(eventType, arg) {
  8627. eventType = 'on' + eventType;
  8628. if (this[eventType]) {
  8629. this[eventType](this._target, arg);
  8630. }
  8631. }
  8632. };
  8633. module.exports = Clip;
  8634. /***/ },
  8635. /* 38 */
  8636. /***/ function(module, exports) {
  8637. /**
  8638. * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js
  8639. * @see http://sole.github.io/tween.js/examples/03_graphs.html
  8640. * @exports zrender/animation/easing
  8641. */
  8642. var easing = {
  8643. /**
  8644. * @param {number} k
  8645. * @return {number}
  8646. */
  8647. linear: function (k) {
  8648. return k;
  8649. },
  8650. /**
  8651. * @param {number} k
  8652. * @return {number}
  8653. */
  8654. quadraticIn: function (k) {
  8655. return k * k;
  8656. },
  8657. /**
  8658. * @param {number} k
  8659. * @return {number}
  8660. */
  8661. quadraticOut: function (k) {
  8662. return k * (2 - k);
  8663. },
  8664. /**
  8665. * @param {number} k
  8666. * @return {number}
  8667. */
  8668. quadraticInOut: function (k) {
  8669. if ((k *= 2) < 1) {
  8670. return 0.5 * k * k;
  8671. }
  8672. return -0.5 * (--k * (k - 2) - 1);
  8673. },
  8674. // 三次方的缓动(t^3)
  8675. /**
  8676. * @param {number} k
  8677. * @return {number}
  8678. */
  8679. cubicIn: function (k) {
  8680. return k * k * k;
  8681. },
  8682. /**
  8683. * @param {number} k
  8684. * @return {number}
  8685. */
  8686. cubicOut: function (k) {
  8687. return --k * k * k + 1;
  8688. },
  8689. /**
  8690. * @param {number} k
  8691. * @return {number}
  8692. */
  8693. cubicInOut: function (k) {
  8694. if ((k *= 2) < 1) {
  8695. return 0.5 * k * k * k;
  8696. }
  8697. return 0.5 * ((k -= 2) * k * k + 2);
  8698. },
  8699. // 四次方的缓动(t^4)
  8700. /**
  8701. * @param {number} k
  8702. * @return {number}
  8703. */
  8704. quarticIn: function (k) {
  8705. return k * k * k * k;
  8706. },
  8707. /**
  8708. * @param {number} k
  8709. * @return {number}
  8710. */
  8711. quarticOut: function (k) {
  8712. return 1 - (--k * k * k * k);
  8713. },
  8714. /**
  8715. * @param {number} k
  8716. * @return {number}
  8717. */
  8718. quarticInOut: function (k) {
  8719. if ((k *= 2) < 1) {
  8720. return 0.5 * k * k * k * k;
  8721. }
  8722. return -0.5 * ((k -= 2) * k * k * k - 2);
  8723. },
  8724. // 五次方的缓动(t^5)
  8725. /**
  8726. * @param {number} k
  8727. * @return {number}
  8728. */
  8729. quinticIn: function (k) {
  8730. return k * k * k * k * k;
  8731. },
  8732. /**
  8733. * @param {number} k
  8734. * @return {number}
  8735. */
  8736. quinticOut: function (k) {
  8737. return --k * k * k * k * k + 1;
  8738. },
  8739. /**
  8740. * @param {number} k
  8741. * @return {number}
  8742. */
  8743. quinticInOut: function (k) {
  8744. if ((k *= 2) < 1) {
  8745. return 0.5 * k * k * k * k * k;
  8746. }
  8747. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  8748. },
  8749. // 正弦曲线的缓动(sin(t))
  8750. /**
  8751. * @param {number} k
  8752. * @return {number}
  8753. */
  8754. sinusoidalIn: function (k) {
  8755. return 1 - Math.cos(k * Math.PI / 2);
  8756. },
  8757. /**
  8758. * @param {number} k
  8759. * @return {number}
  8760. */
  8761. sinusoidalOut: function (k) {
  8762. return Math.sin(k * Math.PI / 2);
  8763. },
  8764. /**
  8765. * @param {number} k
  8766. * @return {number}
  8767. */
  8768. sinusoidalInOut: function (k) {
  8769. return 0.5 * (1 - Math.cos(Math.PI * k));
  8770. },
  8771. // 指数曲线的缓动(2^t)
  8772. /**
  8773. * @param {number} k
  8774. * @return {number}
  8775. */
  8776. exponentialIn: function (k) {
  8777. return k === 0 ? 0 : Math.pow(1024, k - 1);
  8778. },
  8779. /**
  8780. * @param {number} k
  8781. * @return {number}
  8782. */
  8783. exponentialOut: function (k) {
  8784. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  8785. },
  8786. /**
  8787. * @param {number} k
  8788. * @return {number}
  8789. */
  8790. exponentialInOut: function (k) {
  8791. if (k === 0) {
  8792. return 0;
  8793. }
  8794. if (k === 1) {
  8795. return 1;
  8796. }
  8797. if ((k *= 2) < 1) {
  8798. return 0.5 * Math.pow(1024, k - 1);
  8799. }
  8800. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  8801. },
  8802. // 圆形曲线的缓动(sqrt(1-t^2))
  8803. /**
  8804. * @param {number} k
  8805. * @return {number}
  8806. */
  8807. circularIn: function (k) {
  8808. return 1 - Math.sqrt(1 - k * k);
  8809. },
  8810. /**
  8811. * @param {number} k
  8812. * @return {number}
  8813. */
  8814. circularOut: function (k) {
  8815. return Math.sqrt(1 - (--k * k));
  8816. },
  8817. /**
  8818. * @param {number} k
  8819. * @return {number}
  8820. */
  8821. circularInOut: function (k) {
  8822. if ((k *= 2) < 1) {
  8823. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  8824. }
  8825. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  8826. },
  8827. // 创建类似于弹簧在停止前来回振荡的动画
  8828. /**
  8829. * @param {number} k
  8830. * @return {number}
  8831. */
  8832. elasticIn: function (k) {
  8833. var s;
  8834. var a = 0.1;
  8835. var p = 0.4;
  8836. if (k === 0) {
  8837. return 0;
  8838. }
  8839. if (k === 1) {
  8840. return 1;
  8841. }
  8842. if (!a || a < 1) {
  8843. a = 1; s = p / 4;
  8844. }
  8845. else {
  8846. s = p * Math.asin(1 / a) / (2 * Math.PI);
  8847. }
  8848. return -(a * Math.pow(2, 10 * (k -= 1)) *
  8849. Math.sin((k - s) * (2 * Math.PI) / p));
  8850. },
  8851. /**
  8852. * @param {number} k
  8853. * @return {number}
  8854. */
  8855. elasticOut: function (k) {
  8856. var s;
  8857. var a = 0.1;
  8858. var p = 0.4;
  8859. if (k === 0) {
  8860. return 0;
  8861. }
  8862. if (k === 1) {
  8863. return 1;
  8864. }
  8865. if (!a || a < 1) {
  8866. a = 1; s = p / 4;
  8867. }
  8868. else {
  8869. s = p * Math.asin(1 / a) / (2 * Math.PI);
  8870. }
  8871. return (a * Math.pow(2, -10 * k) *
  8872. Math.sin((k - s) * (2 * Math.PI) / p) + 1);
  8873. },
  8874. /**
  8875. * @param {number} k
  8876. * @return {number}
  8877. */
  8878. elasticInOut: function (k) {
  8879. var s;
  8880. var a = 0.1;
  8881. var p = 0.4;
  8882. if (k === 0) {
  8883. return 0;
  8884. }
  8885. if (k === 1) {
  8886. return 1;
  8887. }
  8888. if (!a || a < 1) {
  8889. a = 1; s = p / 4;
  8890. }
  8891. else {
  8892. s = p * Math.asin(1 / a) / (2 * Math.PI);
  8893. }
  8894. if ((k *= 2) < 1) {
  8895. return -0.5 * (a * Math.pow(2, 10 * (k -= 1))
  8896. * Math.sin((k - s) * (2 * Math.PI) / p));
  8897. }
  8898. return a * Math.pow(2, -10 * (k -= 1))
  8899. * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  8900. },
  8901. // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动
  8902. /**
  8903. * @param {number} k
  8904. * @return {number}
  8905. */
  8906. backIn: function (k) {
  8907. var s = 1.70158;
  8908. return k * k * ((s + 1) * k - s);
  8909. },
  8910. /**
  8911. * @param {number} k
  8912. * @return {number}
  8913. */
  8914. backOut: function (k) {
  8915. var s = 1.70158;
  8916. return --k * k * ((s + 1) * k + s) + 1;
  8917. },
  8918. /**
  8919. * @param {number} k
  8920. * @return {number}
  8921. */
  8922. backInOut: function (k) {
  8923. var s = 1.70158 * 1.525;
  8924. if ((k *= 2) < 1) {
  8925. return 0.5 * (k * k * ((s + 1) * k - s));
  8926. }
  8927. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  8928. },
  8929. // 创建弹跳效果
  8930. /**
  8931. * @param {number} k
  8932. * @return {number}
  8933. */
  8934. bounceIn: function (k) {
  8935. return 1 - easing.bounceOut(1 - k);
  8936. },
  8937. /**
  8938. * @param {number} k
  8939. * @return {number}
  8940. */
  8941. bounceOut: function (k) {
  8942. if (k < (1 / 2.75)) {
  8943. return 7.5625 * k * k;
  8944. }
  8945. else if (k < (2 / 2.75)) {
  8946. return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
  8947. }
  8948. else if (k < (2.5 / 2.75)) {
  8949. return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
  8950. }
  8951. else {
  8952. return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
  8953. }
  8954. },
  8955. /**
  8956. * @param {number} k
  8957. * @return {number}
  8958. */
  8959. bounceInOut: function (k) {
  8960. if (k < 0.5) {
  8961. return easing.bounceIn(k * 2) * 0.5;
  8962. }
  8963. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  8964. }
  8965. };
  8966. module.exports = easing;
  8967. /***/ },
  8968. /* 39 */
  8969. /***/ function(module, exports) {
  8970. /**
  8971. * @module zrender/tool/color
  8972. */
  8973. var kCSSColorTable = {
  8974. 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1],
  8975. 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1],
  8976. 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1],
  8977. 'beige': [245,245,220,1], 'bisque': [255,228,196,1],
  8978. 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1],
  8979. 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1],
  8980. 'brown': [165,42,42,1], 'burlywood': [222,184,135,1],
  8981. 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1],
  8982. 'chocolate': [210,105,30,1], 'coral': [255,127,80,1],
  8983. 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1],
  8984. 'crimson': [220,20,60,1], 'cyan': [0,255,255,1],
  8985. 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1],
  8986. 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1],
  8987. 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1],
  8988. 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1],
  8989. 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1],
  8990. 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1],
  8991. 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1],
  8992. 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1],
  8993. 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1],
  8994. 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1],
  8995. 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1],
  8996. 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1],
  8997. 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1],
  8998. 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1],
  8999. 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1],
  9000. 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1],
  9001. 'gray': [128,128,128,1], 'green': [0,128,0,1],
  9002. 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1],
  9003. 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1],
  9004. 'indianred': [205,92,92,1], 'indigo': [75,0,130,1],
  9005. 'ivory': [255,255,240,1], 'khaki': [240,230,140,1],
  9006. 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1],
  9007. 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1],
  9008. 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1],
  9009. 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1],
  9010. 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1],
  9011. 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1],
  9012. 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1],
  9013. 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1],
  9014. 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1],
  9015. 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1],
  9016. 'limegreen': [50,205,50,1], 'linen': [250,240,230,1],
  9017. 'magenta': [255,0,255,1], 'maroon': [128,0,0,1],
  9018. 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1],
  9019. 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1],
  9020. 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1],
  9021. 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1],
  9022. 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1],
  9023. 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1],
  9024. 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1],
  9025. 'navy': [0,0,128,1], 'oldlace': [253,245,230,1],
  9026. 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1],
  9027. 'orange': [255,165,0,1], 'orangered': [255,69,0,1],
  9028. 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1],
  9029. 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1],
  9030. 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1],
  9031. 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1],
  9032. 'pink': [255,192,203,1], 'plum': [221,160,221,1],
  9033. 'powderblue': [176,224,230,1], 'purple': [128,0,128,1],
  9034. 'red': [255,0,0,1], 'rosybrown': [188,143,143,1],
  9035. 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1],
  9036. 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1],
  9037. 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1],
  9038. 'sienna': [160,82,45,1], 'silver': [192,192,192,1],
  9039. 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1],
  9040. 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1],
  9041. 'snow': [255,250,250,1], 'springgreen': [0,255,127,1],
  9042. 'steelblue': [70,130,180,1], 'tan': [210,180,140,1],
  9043. 'teal': [0,128,128,1], 'thistle': [216,191,216,1],
  9044. 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1],
  9045. 'violet': [238,130,238,1], 'wheat': [245,222,179,1],
  9046. 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1],
  9047. 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1]
  9048. };
  9049. function clampCssByte(i) { // Clamp to integer 0 .. 255.
  9050. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  9051. return i < 0 ? 0 : i > 255 ? 255 : i;
  9052. }
  9053. function clampCssAngle(i) { // Clamp to integer 0 .. 360.
  9054. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  9055. return i < 0 ? 0 : i > 360 ? 360 : i;
  9056. }
  9057. function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0.
  9058. return f < 0 ? 0 : f > 1 ? 1 : f;
  9059. }
  9060. function parseCssInt(str) { // int or percentage.
  9061. if (str.length && str.charAt(str.length - 1) === '%') {
  9062. return clampCssByte(parseFloat(str) / 100 * 255);
  9063. }
  9064. return clampCssByte(parseInt(str, 10));
  9065. }
  9066. function parseCssFloat(str) { // float or percentage.
  9067. if (str.length && str.charAt(str.length - 1) === '%') {
  9068. return clampCssFloat(parseFloat(str) / 100);
  9069. }
  9070. return clampCssFloat(parseFloat(str));
  9071. }
  9072. function cssHueToRgb(m1, m2, h) {
  9073. if (h < 0) {
  9074. h += 1;
  9075. }
  9076. else if (h > 1) {
  9077. h -= 1;
  9078. }
  9079. if (h * 6 < 1) {
  9080. return m1 + (m2 - m1) * h * 6;
  9081. }
  9082. if (h * 2 < 1) {
  9083. return m2;
  9084. }
  9085. if (h * 3 < 2) {
  9086. return m1 + (m2 - m1) * (2/3 - h) * 6;
  9087. }
  9088. return m1;
  9089. }
  9090. function lerp(a, b, p) {
  9091. return a + (b - a) * p;
  9092. }
  9093. /**
  9094. * @param {string} colorStr
  9095. * @return {Array.<number>}
  9096. * @memberOf module:zrender/util/color
  9097. */
  9098. function parse(colorStr) {
  9099. if (!colorStr) {
  9100. return;
  9101. }
  9102. // colorStr may be not string
  9103. colorStr = colorStr + '';
  9104. // Remove all whitespace, not compliant, but should just be more accepting.
  9105. var str = colorStr.replace(/ /g, '').toLowerCase();
  9106. // Color keywords (and transparent) lookup.
  9107. if (str in kCSSColorTable) {
  9108. return kCSSColorTable[str].slice(); // dup.
  9109. }
  9110. // #abc and #abc123 syntax.
  9111. if (str.charAt(0) === '#') {
  9112. if (str.length === 4) {
  9113. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  9114. if (!(iv >= 0 && iv <= 0xfff)) {
  9115. return; // Covers NaN.
  9116. }
  9117. return [
  9118. ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
  9119. (iv & 0xf0) | ((iv & 0xf0) >> 4),
  9120. (iv & 0xf) | ((iv & 0xf) << 4),
  9121. 1
  9122. ];
  9123. }
  9124. else if (str.length === 7) {
  9125. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  9126. if (!(iv >= 0 && iv <= 0xffffff)) {
  9127. return; // Covers NaN.
  9128. }
  9129. return [
  9130. (iv & 0xff0000) >> 16,
  9131. (iv & 0xff00) >> 8,
  9132. iv & 0xff,
  9133. 1
  9134. ];
  9135. }
  9136. return;
  9137. }
  9138. var op = str.indexOf('('), ep = str.indexOf(')');
  9139. if (op !== -1 && ep + 1 === str.length) {
  9140. var fname = str.substr(0, op);
  9141. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  9142. var alpha = 1; // To allow case fallthrough.
  9143. switch (fname) {
  9144. case 'rgba':
  9145. if (params.length !== 4) {
  9146. return;
  9147. }
  9148. alpha = parseCssFloat(params.pop()); // jshint ignore:line
  9149. // Fall through.
  9150. case 'rgb':
  9151. if (params.length !== 3) {
  9152. return;
  9153. }
  9154. return [
  9155. parseCssInt(params[0]),
  9156. parseCssInt(params[1]),
  9157. parseCssInt(params[2]),
  9158. alpha
  9159. ];
  9160. case 'hsla':
  9161. if (params.length !== 4) {
  9162. return;
  9163. }
  9164. params[3] = parseCssFloat(params[3]);
  9165. return hsla2rgba(params);
  9166. case 'hsl':
  9167. if (params.length !== 3) {
  9168. return;
  9169. }
  9170. return hsla2rgba(params);
  9171. default:
  9172. return;
  9173. }
  9174. }
  9175. return;
  9176. }
  9177. /**
  9178. * @param {Array.<number>} hsla
  9179. * @return {Array.<number>} rgba
  9180. */
  9181. function hsla2rgba(hsla) {
  9182. var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1
  9183. // NOTE(deanm): According to the CSS spec s/l should only be
  9184. // percentages, but we don't bother and let float or percentage.
  9185. var s = parseCssFloat(hsla[1]);
  9186. var l = parseCssFloat(hsla[2]);
  9187. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  9188. var m1 = l * 2 - m2;
  9189. var rgba = [
  9190. clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
  9191. clampCssByte(cssHueToRgb(m1, m2, h) * 255),
  9192. clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255)
  9193. ];
  9194. if (hsla.length === 4) {
  9195. rgba[3] = hsla[3];
  9196. }
  9197. return rgba;
  9198. }
  9199. /**
  9200. * @param {Array.<number>} rgba
  9201. * @return {Array.<number>} hsla
  9202. */
  9203. function rgba2hsla(rgba) {
  9204. if (!rgba) {
  9205. return;
  9206. }
  9207. // RGB from 0 to 255
  9208. var R = rgba[0] / 255;
  9209. var G = rgba[1] / 255;
  9210. var B = rgba[2] / 255;
  9211. var vMin = Math.min(R, G, B); // Min. value of RGB
  9212. var vMax = Math.max(R, G, B); // Max. value of RGB
  9213. var delta = vMax - vMin; // Delta RGB value
  9214. var L = (vMax + vMin) / 2;
  9215. var H;
  9216. var S;
  9217. // HSL results from 0 to 1
  9218. if (delta === 0) {
  9219. H = 0;
  9220. S = 0;
  9221. }
  9222. else {
  9223. if (L < 0.5) {
  9224. S = delta / (vMax + vMin);
  9225. }
  9226. else {
  9227. S = delta / (2 - vMax - vMin);
  9228. }
  9229. var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
  9230. var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
  9231. var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
  9232. if (R === vMax) {
  9233. H = deltaB - deltaG;
  9234. }
  9235. else if (G === vMax) {
  9236. H = (1 / 3) + deltaR - deltaB;
  9237. }
  9238. else if (B === vMax) {
  9239. H = (2 / 3) + deltaG - deltaR;
  9240. }
  9241. if (H < 0) {
  9242. H += 1;
  9243. }
  9244. if (H > 1) {
  9245. H -= 1;
  9246. }
  9247. }
  9248. var hsla = [H * 360, S, L];
  9249. if (rgba[3] != null) {
  9250. hsla.push(rgba[3]);
  9251. }
  9252. return hsla;
  9253. }
  9254. /**
  9255. * @param {string} color
  9256. * @param {number} level
  9257. * @return {string}
  9258. * @memberOf module:zrender/util/color
  9259. */
  9260. function lift(color, level) {
  9261. var colorArr = parse(color);
  9262. if (colorArr) {
  9263. for (var i = 0; i < 3; i++) {
  9264. if (level < 0) {
  9265. colorArr[i] = colorArr[i] * (1 - level) | 0;
  9266. }
  9267. else {
  9268. colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
  9269. }
  9270. }
  9271. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  9272. }
  9273. }
  9274. /**
  9275. * @param {string} color
  9276. * @return {string}
  9277. * @memberOf module:zrender/util/color
  9278. */
  9279. function toHex(color, level) {
  9280. var colorArr = parse(color);
  9281. if (colorArr) {
  9282. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
  9283. }
  9284. }
  9285. /**
  9286. * Map value to color. Faster than mapToColor methods because color is represented by rgba array
  9287. * @param {number} normalizedValue A float between 0 and 1.
  9288. * @param {Array.<Array.<number>>} colors List of rgba color array
  9289. * @param {Array.<number>} [out] Mapped gba color array
  9290. * @return {Array.<number>}
  9291. */
  9292. function fastMapToColor(normalizedValue, colors, out) {
  9293. if (!(colors && colors.length)
  9294. || !(normalizedValue >= 0 && normalizedValue <= 1)
  9295. ) {
  9296. return;
  9297. }
  9298. out = out || [0, 0, 0, 0];
  9299. var value = normalizedValue * (colors.length - 1);
  9300. var leftIndex = Math.floor(value);
  9301. var rightIndex = Math.ceil(value);
  9302. var leftColor = colors[leftIndex];
  9303. var rightColor = colors[rightIndex];
  9304. var dv = value - leftIndex;
  9305. out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv));
  9306. out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv));
  9307. out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv));
  9308. out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv));
  9309. return out;
  9310. }
  9311. /**
  9312. * @param {number} normalizedValue A float between 0 and 1.
  9313. * @param {Array.<string>} colors Color list.
  9314. * @param {boolean=} fullOutput Default false.
  9315. * @return {(string|Object)} Result color. If fullOutput,
  9316. * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
  9317. * @memberOf module:zrender/util/color
  9318. */
  9319. function mapToColor(normalizedValue, colors, fullOutput) {
  9320. if (!(colors && colors.length)
  9321. || !(normalizedValue >= 0 && normalizedValue <= 1)
  9322. ) {
  9323. return;
  9324. }
  9325. var value = normalizedValue * (colors.length - 1);
  9326. var leftIndex = Math.floor(value);
  9327. var rightIndex = Math.ceil(value);
  9328. var leftColor = parse(colors[leftIndex]);
  9329. var rightColor = parse(colors[rightIndex]);
  9330. var dv = value - leftIndex;
  9331. var color = stringify(
  9332. [
  9333. clampCssByte(lerp(leftColor[0], rightColor[0], dv)),
  9334. clampCssByte(lerp(leftColor[1], rightColor[1], dv)),
  9335. clampCssByte(lerp(leftColor[2], rightColor[2], dv)),
  9336. clampCssFloat(lerp(leftColor[3], rightColor[3], dv))
  9337. ],
  9338. 'rgba'
  9339. );
  9340. return fullOutput
  9341. ? {
  9342. color: color,
  9343. leftIndex: leftIndex,
  9344. rightIndex: rightIndex,
  9345. value: value
  9346. }
  9347. : color;
  9348. }
  9349. /**
  9350. * @param {string} color
  9351. * @param {number=} h 0 ~ 360, ignore when null.
  9352. * @param {number=} s 0 ~ 1, ignore when null.
  9353. * @param {number=} l 0 ~ 1, ignore when null.
  9354. * @return {string} Color string in rgba format.
  9355. * @memberOf module:zrender/util/color
  9356. */
  9357. function modifyHSL(color, h, s, l) {
  9358. color = parse(color);
  9359. if (color) {
  9360. color = rgba2hsla(color);
  9361. h != null && (color[0] = clampCssAngle(h));
  9362. s != null && (color[1] = parseCssFloat(s));
  9363. l != null && (color[2] = parseCssFloat(l));
  9364. return stringify(hsla2rgba(color), 'rgba');
  9365. }
  9366. }
  9367. /**
  9368. * @param {string} color
  9369. * @param {number=} alpha 0 ~ 1
  9370. * @return {string} Color string in rgba format.
  9371. * @memberOf module:zrender/util/color
  9372. */
  9373. function modifyAlpha(color, alpha) {
  9374. color = parse(color);
  9375. if (color && alpha != null) {
  9376. color[3] = clampCssFloat(alpha);
  9377. return stringify(color, 'rgba');
  9378. }
  9379. }
  9380. /**
  9381. * @param {Array.<string>} colors Color list.
  9382. * @param {string} type 'rgba', 'hsva', ...
  9383. * @return {string} Result color.
  9384. */
  9385. function stringify(arrColor, type) {
  9386. var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
  9387. if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
  9388. colorStr += ',' + arrColor[3];
  9389. }
  9390. return type + '(' + colorStr + ')';
  9391. }
  9392. module.exports = {
  9393. parse: parse,
  9394. lift: lift,
  9395. toHex: toHex,
  9396. fastMapToColor: fastMapToColor,
  9397. mapToColor: mapToColor,
  9398. modifyHSL: modifyHSL,
  9399. modifyAlpha: modifyAlpha,
  9400. stringify: stringify
  9401. };
  9402. /***/ },
  9403. /* 40 */
  9404. /***/ function(module, exports, __webpack_require__) {
  9405. var config = __webpack_require__(41);
  9406. /**
  9407. * @exports zrender/tool/log
  9408. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  9409. */
  9410. module.exports = function() {
  9411. if (config.debugMode === 0) {
  9412. return;
  9413. }
  9414. else if (config.debugMode == 1) {
  9415. for (var k in arguments) {
  9416. throw new Error(arguments[k]);
  9417. }
  9418. }
  9419. else if (config.debugMode > 1) {
  9420. for (var k in arguments) {
  9421. console.log(arguments[k]);
  9422. }
  9423. }
  9424. };
  9425. /* for debug
  9426. return function(mes) {
  9427. document.getElementById('wrong-message').innerHTML =
  9428. mes + ' ' + (new Date() - 0)
  9429. + '<br/>'
  9430. + document.getElementById('wrong-message').innerHTML;
  9431. };
  9432. */
  9433. /***/ },
  9434. /* 41 */
  9435. /***/ function(module, exports) {
  9436. var dpr = 1;
  9437. // If in browser environment
  9438. if (typeof window !== 'undefined') {
  9439. dpr = Math.max(window.devicePixelRatio || 1, 1);
  9440. }
  9441. /**
  9442. * config默认配置项
  9443. * @exports zrender/config
  9444. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  9445. */
  9446. var config = {
  9447. /**
  9448. * debug日志选项:catchBrushException为true下有效
  9449. * 0 : 不生成debug数据,发布用
  9450. * 1 : 异常抛出,调试用
  9451. * 2 : 控制台输出,调试用
  9452. */
  9453. debugMode: 0,
  9454. // retina 屏幕优化
  9455. devicePixelRatio: dpr
  9456. };
  9457. module.exports = config;
  9458. /***/ },
  9459. /* 42 */
  9460. /***/ function(module, exports, __webpack_require__) {
  9461. var Group = __webpack_require__(30);
  9462. var componentUtil = __webpack_require__(20);
  9463. var clazzUtil = __webpack_require__(13);
  9464. var modelUtil = __webpack_require__(5);
  9465. var zrUtil = __webpack_require__(4);
  9466. function Chart() {
  9467. /**
  9468. * @type {module:zrender/container/Group}
  9469. * @readOnly
  9470. */
  9471. this.group = new Group();
  9472. /**
  9473. * @type {string}
  9474. * @readOnly
  9475. */
  9476. this.uid = componentUtil.getUID('viewChart');
  9477. }
  9478. Chart.prototype = {
  9479. type: 'chart',
  9480. /**
  9481. * Init the chart
  9482. * @param {module:echarts/model/Global} ecModel
  9483. * @param {module:echarts/ExtensionAPI} api
  9484. */
  9485. init: function (ecModel, api) {},
  9486. /**
  9487. * Render the chart
  9488. * @param {module:echarts/model/Series} seriesModel
  9489. * @param {module:echarts/model/Global} ecModel
  9490. * @param {module:echarts/ExtensionAPI} api
  9491. * @param {Object} payload
  9492. */
  9493. render: function (seriesModel, ecModel, api, payload) {},
  9494. /**
  9495. * Highlight series or specified data item
  9496. * @param {module:echarts/model/Series} seriesModel
  9497. * @param {module:echarts/model/Global} ecModel
  9498. * @param {module:echarts/ExtensionAPI} api
  9499. * @param {Object} payload
  9500. */
  9501. highlight: function (seriesModel, ecModel, api, payload) {
  9502. toggleHighlight(seriesModel.getData(), payload, 'emphasis');
  9503. },
  9504. /**
  9505. * Downplay series or specified data item
  9506. * @param {module:echarts/model/Series} seriesModel
  9507. * @param {module:echarts/model/Global} ecModel
  9508. * @param {module:echarts/ExtensionAPI} api
  9509. * @param {Object} payload
  9510. */
  9511. downplay: function (seriesModel, ecModel, api, payload) {
  9512. toggleHighlight(seriesModel.getData(), payload, 'normal');
  9513. },
  9514. /**
  9515. * Remove self
  9516. * @param {module:echarts/model/Global} ecModel
  9517. * @param {module:echarts/ExtensionAPI} api
  9518. */
  9519. remove: function (ecModel, api) {
  9520. this.group.removeAll();
  9521. },
  9522. /**
  9523. * Dispose self
  9524. * @param {module:echarts/model/Global} ecModel
  9525. * @param {module:echarts/ExtensionAPI} api
  9526. */
  9527. dispose: function () {}
  9528. /**
  9529. * The view contains the given point.
  9530. * @interface
  9531. * @param {Array.<number>} point
  9532. * @return {boolean}
  9533. */
  9534. // containPoint: function () {}
  9535. };
  9536. var chartProto = Chart.prototype;
  9537. chartProto.updateView
  9538. = chartProto.updateLayout
  9539. = chartProto.updateVisual
  9540. = function (seriesModel, ecModel, api, payload) {
  9541. this.render(seriesModel, ecModel, api, payload);
  9542. };
  9543. /**
  9544. * Set state of single element
  9545. * @param {module:zrender/Element} el
  9546. * @param {string} state
  9547. */
  9548. function elSetState(el, state) {
  9549. if (el) {
  9550. el.trigger(state);
  9551. if (el.type === 'group') {
  9552. for (var i = 0; i < el.childCount(); i++) {
  9553. elSetState(el.childAt(i), state);
  9554. }
  9555. }
  9556. }
  9557. }
  9558. /**
  9559. * @param {module:echarts/data/List} data
  9560. * @param {Object} payload
  9561. * @param {string} state 'normal'|'emphasis'
  9562. * @inner
  9563. */
  9564. function toggleHighlight(data, payload, state) {
  9565. var dataIndex = modelUtil.queryDataIndex(data, payload);
  9566. if (dataIndex != null) {
  9567. zrUtil.each(modelUtil.normalizeToArray(dataIndex), function (dataIdx) {
  9568. elSetState(data.getItemGraphicEl(dataIdx), state);
  9569. });
  9570. }
  9571. else {
  9572. data.eachItemGraphicEl(function (el) {
  9573. elSetState(el, state);
  9574. });
  9575. }
  9576. }
  9577. // Enable Chart.extend.
  9578. clazzUtil.enableClassExtend(Chart, ['dispose']);
  9579. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  9580. clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true});
  9581. module.exports = Chart;
  9582. /***/ },
  9583. /* 43 */
  9584. /***/ function(module, exports, __webpack_require__) {
  9585. 'use strict';
  9586. var zrUtil = __webpack_require__(4);
  9587. var pathTool = __webpack_require__(44);
  9588. var round = Math.round;
  9589. var Path = __webpack_require__(45);
  9590. var colorTool = __webpack_require__(39);
  9591. var matrix = __webpack_require__(11);
  9592. var vector = __webpack_require__(10);
  9593. var graphic = {};
  9594. graphic.Group = __webpack_require__(30);
  9595. graphic.Image = __webpack_require__(61);
  9596. graphic.Text = __webpack_require__(63);
  9597. graphic.Circle = __webpack_require__(64);
  9598. graphic.Sector = __webpack_require__(65);
  9599. graphic.Ring = __webpack_require__(66);
  9600. graphic.Polygon = __webpack_require__(67);
  9601. graphic.Polyline = __webpack_require__(71);
  9602. graphic.Rect = __webpack_require__(72);
  9603. graphic.Line = __webpack_require__(74);
  9604. graphic.BezierCurve = __webpack_require__(75);
  9605. graphic.Arc = __webpack_require__(76);
  9606. graphic.CompoundPath = __webpack_require__(77);
  9607. graphic.LinearGradient = __webpack_require__(78);
  9608. graphic.RadialGradient = __webpack_require__(80);
  9609. graphic.BoundingRect = __webpack_require__(9);
  9610. /**
  9611. * Extend shape with parameters
  9612. */
  9613. graphic.extendShape = function (opts) {
  9614. return Path.extend(opts);
  9615. };
  9616. /**
  9617. * Extend path
  9618. */
  9619. graphic.extendPath = function (pathData, opts) {
  9620. return pathTool.extendFromString(pathData, opts);
  9621. };
  9622. /**
  9623. * Create a path element from path data string
  9624. * @param {string} pathData
  9625. * @param {Object} opts
  9626. * @param {module:zrender/core/BoundingRect} rect
  9627. * @param {string} [layout=cover] 'center' or 'cover'
  9628. */
  9629. graphic.makePath = function (pathData, opts, rect, layout) {
  9630. var path = pathTool.createFromString(pathData, opts);
  9631. var boundingRect = path.getBoundingRect();
  9632. if (rect) {
  9633. var aspect = boundingRect.width / boundingRect.height;
  9634. if (layout === 'center') {
  9635. // Set rect to center, keep width / height ratio.
  9636. var width = rect.height * aspect;
  9637. var height;
  9638. if (width <= rect.width) {
  9639. height = rect.height;
  9640. }
  9641. else {
  9642. width = rect.width;
  9643. height = width / aspect;
  9644. }
  9645. var cx = rect.x + rect.width / 2;
  9646. var cy = rect.y + rect.height / 2;
  9647. rect.x = cx - width / 2;
  9648. rect.y = cy - height / 2;
  9649. rect.width = width;
  9650. rect.height = height;
  9651. }
  9652. this.resizePath(path, rect);
  9653. }
  9654. return path;
  9655. };
  9656. graphic.mergePath = pathTool.mergePath,
  9657. /**
  9658. * Resize a path to fit the rect
  9659. * @param {module:zrender/graphic/Path} path
  9660. * @param {Object} rect
  9661. */
  9662. graphic.resizePath = function (path, rect) {
  9663. if (!path.applyTransform) {
  9664. return;
  9665. }
  9666. var pathRect = path.getBoundingRect();
  9667. var m = pathRect.calculateTransform(rect);
  9668. path.applyTransform(m);
  9669. };
  9670. /**
  9671. * Sub pixel optimize line for canvas
  9672. *
  9673. * @param {Object} param
  9674. * @param {Object} [param.shape]
  9675. * @param {number} [param.shape.x1]
  9676. * @param {number} [param.shape.y1]
  9677. * @param {number} [param.shape.x2]
  9678. * @param {number} [param.shape.y2]
  9679. * @param {Object} [param.style]
  9680. * @param {number} [param.style.lineWidth]
  9681. * @return {Object} Modified param
  9682. */
  9683. graphic.subPixelOptimizeLine = function (param) {
  9684. var subPixelOptimize = graphic.subPixelOptimize;
  9685. var shape = param.shape;
  9686. var lineWidth = param.style.lineWidth;
  9687. if (round(shape.x1 * 2) === round(shape.x2 * 2)) {
  9688. shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true);
  9689. }
  9690. if (round(shape.y1 * 2) === round(shape.y2 * 2)) {
  9691. shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true);
  9692. }
  9693. return param;
  9694. };
  9695. /**
  9696. * Sub pixel optimize rect for canvas
  9697. *
  9698. * @param {Object} param
  9699. * @param {Object} [param.shape]
  9700. * @param {number} [param.shape.x]
  9701. * @param {number} [param.shape.y]
  9702. * @param {number} [param.shape.width]
  9703. * @param {number} [param.shape.height]
  9704. * @param {Object} [param.style]
  9705. * @param {number} [param.style.lineWidth]
  9706. * @return {Object} Modified param
  9707. */
  9708. graphic.subPixelOptimizeRect = function (param) {
  9709. var subPixelOptimize = graphic.subPixelOptimize;
  9710. var shape = param.shape;
  9711. var lineWidth = param.style.lineWidth;
  9712. var originX = shape.x;
  9713. var originY = shape.y;
  9714. var originWidth = shape.width;
  9715. var originHeight = shape.height;
  9716. shape.x = subPixelOptimize(shape.x, lineWidth, true);
  9717. shape.y = subPixelOptimize(shape.y, lineWidth, true);
  9718. shape.width = Math.max(
  9719. subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x,
  9720. originWidth === 0 ? 0 : 1
  9721. );
  9722. shape.height = Math.max(
  9723. subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y,
  9724. originHeight === 0 ? 0 : 1
  9725. );
  9726. return param;
  9727. };
  9728. /**
  9729. * Sub pixel optimize for canvas
  9730. *
  9731. * @param {number} position Coordinate, such as x, y
  9732. * @param {number} lineWidth Should be nonnegative integer.
  9733. * @param {boolean=} positiveOrNegative Default false (negative).
  9734. * @return {number} Optimized position.
  9735. */
  9736. graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
  9737. // Assure that (position + lineWidth / 2) is near integer edge,
  9738. // otherwise line will be fuzzy in canvas.
  9739. var doubledPosition = round(position * 2);
  9740. return (doubledPosition + round(lineWidth)) % 2 === 0
  9741. ? doubledPosition / 2
  9742. : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  9743. };
  9744. function hasFillOrStroke(fillOrStroke) {
  9745. return fillOrStroke != null && fillOrStroke != 'none';
  9746. }
  9747. function liftColor(color) {
  9748. return typeof color === 'string' ? colorTool.lift(color, -0.1) : color;
  9749. }
  9750. /**
  9751. * @private
  9752. */
  9753. function cacheElementStl(el) {
  9754. if (el.__hoverStlDirty) {
  9755. var stroke = el.style.stroke;
  9756. var fill = el.style.fill;
  9757. // Create hoverStyle on mouseover
  9758. var hoverStyle = el.__hoverStl;
  9759. hoverStyle.fill = hoverStyle.fill
  9760. || (hasFillOrStroke(fill) ? liftColor(fill) : null);
  9761. hoverStyle.stroke = hoverStyle.stroke
  9762. || (hasFillOrStroke(stroke) ? liftColor(stroke) : null);
  9763. var normalStyle = {};
  9764. for (var name in hoverStyle) {
  9765. if (hoverStyle.hasOwnProperty(name)) {
  9766. normalStyle[name] = el.style[name];
  9767. }
  9768. }
  9769. el.__normalStl = normalStyle;
  9770. el.__hoverStlDirty = false;
  9771. }
  9772. }
  9773. /**
  9774. * @private
  9775. */
  9776. function doSingleEnterHover(el) {
  9777. if (el.__isHover) {
  9778. return;
  9779. }
  9780. cacheElementStl(el);
  9781. if (el.useHoverLayer) {
  9782. el.__zr && el.__zr.addHover(el, el.__hoverStl);
  9783. }
  9784. else {
  9785. el.setStyle(el.__hoverStl);
  9786. el.z2 += 1;
  9787. }
  9788. el.__isHover = true;
  9789. }
  9790. /**
  9791. * @inner
  9792. */
  9793. function doSingleLeaveHover(el) {
  9794. if (!el.__isHover) {
  9795. return;
  9796. }
  9797. var normalStl = el.__normalStl;
  9798. if (el.useHoverLayer) {
  9799. el.__zr && el.__zr.removeHover(el);
  9800. }
  9801. else {
  9802. normalStl && el.setStyle(normalStl);
  9803. el.z2 -= 1;
  9804. }
  9805. el.__isHover = false;
  9806. }
  9807. /**
  9808. * @inner
  9809. */
  9810. function doEnterHover(el) {
  9811. el.type === 'group'
  9812. ? el.traverse(function (child) {
  9813. if (child.type !== 'group') {
  9814. doSingleEnterHover(child);
  9815. }
  9816. })
  9817. : doSingleEnterHover(el);
  9818. }
  9819. function doLeaveHover(el) {
  9820. el.type === 'group'
  9821. ? el.traverse(function (child) {
  9822. if (child.type !== 'group') {
  9823. doSingleLeaveHover(child);
  9824. }
  9825. })
  9826. : doSingleLeaveHover(el);
  9827. }
  9828. /**
  9829. * @inner
  9830. */
  9831. function setElementHoverStl(el, hoverStl) {
  9832. // If element has sepcified hoverStyle, then use it instead of given hoverStyle
  9833. // Often used when item group has a label element and it's hoverStyle is different
  9834. el.__hoverStl = el.hoverStyle || hoverStl || {};
  9835. el.__hoverStlDirty = true;
  9836. if (el.__isHover) {
  9837. cacheElementStl(el);
  9838. }
  9839. }
  9840. /**
  9841. * @inner
  9842. */
  9843. function onElementMouseOver(e) {
  9844. if (this.__hoverSilentOnTouch && e.zrByTouch) {
  9845. return;
  9846. }
  9847. // Only if element is not in emphasis status
  9848. !this.__isEmphasis && doEnterHover(this);
  9849. }
  9850. /**
  9851. * @inner
  9852. */
  9853. function onElementMouseOut(e) {
  9854. if (this.__hoverSilentOnTouch && e.zrByTouch) {
  9855. return;
  9856. }
  9857. // Only if element is not in emphasis status
  9858. !this.__isEmphasis && doLeaveHover(this);
  9859. }
  9860. /**
  9861. * @inner
  9862. */
  9863. function enterEmphasis() {
  9864. this.__isEmphasis = true;
  9865. doEnterHover(this);
  9866. }
  9867. /**
  9868. * @inner
  9869. */
  9870. function leaveEmphasis() {
  9871. this.__isEmphasis = false;
  9872. doLeaveHover(this);
  9873. }
  9874. /**
  9875. * Set hover style of element
  9876. * @param {module:zrender/Element} el
  9877. * @param {Object} [hoverStyle]
  9878. * @param {Object} [opt]
  9879. * @param {boolean} [opt.hoverSilentOnTouch=false]
  9880. * In touch device, mouseover event will be trigger on touchstart event
  9881. * (see module:zrender/dom/HandlerProxy). By this mechanism, we can
  9882. * conviniently use hoverStyle when tap on touch screen without additional
  9883. * code for compatibility.
  9884. * But if the chart/component has select feature, which usually also use
  9885. * hoverStyle, there might be conflict between 'select-highlight' and
  9886. * 'hover-highlight' especially when roam is enabled (see geo for example).
  9887. * In this case, hoverSilentOnTouch should be used to disable hover-highlight
  9888. * on touch device.
  9889. */
  9890. graphic.setHoverStyle = function (el, hoverStyle, opt) {
  9891. el.__hoverSilentOnTouch = opt && opt.hoverSilentOnTouch;
  9892. el.type === 'group'
  9893. ? el.traverse(function (child) {
  9894. if (child.type !== 'group') {
  9895. setElementHoverStl(child, hoverStyle);
  9896. }
  9897. })
  9898. : setElementHoverStl(el, hoverStyle);
  9899. // Duplicated function will be auto-ignored, see Eventful.js.
  9900. el.on('mouseover', onElementMouseOver)
  9901. .on('mouseout', onElementMouseOut);
  9902. // Emphasis, normal can be triggered manually
  9903. el.on('emphasis', enterEmphasis)
  9904. .on('normal', leaveEmphasis);
  9905. };
  9906. /**
  9907. * Set text option in the style
  9908. * @param {Object} textStyle
  9909. * @param {module:echarts/model/Model} labelModel
  9910. * @param {string} color
  9911. */
  9912. graphic.setText = function (textStyle, labelModel, color) {
  9913. var labelPosition = labelModel.getShallow('position') || 'inside';
  9914. var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
  9915. var textStyleModel = labelModel.getModel('textStyle');
  9916. zrUtil.extend(textStyle, {
  9917. textDistance: labelModel.getShallow('distance') || 5,
  9918. textFont: textStyleModel.getFont(),
  9919. textPosition: labelPosition,
  9920. textFill: textStyleModel.getTextColor() || labelColor
  9921. });
  9922. };
  9923. function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
  9924. if (typeof dataIndex === 'function') {
  9925. cb = dataIndex;
  9926. dataIndex = null;
  9927. }
  9928. var animationEnabled = animatableModel
  9929. && (
  9930. animatableModel.ifEnableAnimation
  9931. ? animatableModel.ifEnableAnimation()
  9932. // Directly use animation property
  9933. : animatableModel.getShallow('animation')
  9934. );
  9935. if (animationEnabled) {
  9936. var postfix = isUpdate ? 'Update' : '';
  9937. var duration = animatableModel
  9938. && animatableModel.getShallow('animationDuration' + postfix);
  9939. var animationEasing = animatableModel
  9940. && animatableModel.getShallow('animationEasing' + postfix);
  9941. var animationDelay = animatableModel
  9942. && animatableModel.getShallow('animationDelay' + postfix);
  9943. if (typeof animationDelay === 'function') {
  9944. animationDelay = animationDelay(dataIndex);
  9945. }
  9946. duration > 0
  9947. ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
  9948. : (el.attr(props), cb && cb());
  9949. }
  9950. else {
  9951. el.attr(props);
  9952. cb && cb();
  9953. }
  9954. }
  9955. /**
  9956. * Update graphic element properties with or without animation according to the configuration in series
  9957. * @param {module:zrender/Element} el
  9958. * @param {Object} props
  9959. * @param {module:echarts/model/Model} [animatableModel]
  9960. * @param {number} [dataIndex]
  9961. * @param {Function} [cb]
  9962. * @example
  9963. * graphic.updateProps(el, {
  9964. * position: [100, 100]
  9965. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  9966. * // Or
  9967. * graphic.updateProps(el, {
  9968. * position: [100, 100]
  9969. * }, seriesModel, function () { console.log('Animation done!'); });
  9970. */
  9971. graphic.updateProps = function (el, props, animatableModel, dataIndex, cb) {
  9972. animateOrSetProps(true, el, props, animatableModel, dataIndex, cb);
  9973. };
  9974. /**
  9975. * Init graphic element properties with or without animation according to the configuration in series
  9976. * @param {module:zrender/Element} el
  9977. * @param {Object} props
  9978. * @param {module:echarts/model/Model} [animatableModel]
  9979. * @param {number} [dataIndex]
  9980. * @param {Function} cb
  9981. */
  9982. graphic.initProps = function (el, props, animatableModel, dataIndex, cb) {
  9983. animateOrSetProps(false, el, props, animatableModel, dataIndex, cb);
  9984. };
  9985. /**
  9986. * Get transform matrix of target (param target),
  9987. * in coordinate of its ancestor (param ancestor)
  9988. *
  9989. * @param {module:zrender/mixin/Transformable} target
  9990. * @param {module:zrender/mixin/Transformable} [ancestor]
  9991. */
  9992. graphic.getTransform = function (target, ancestor) {
  9993. var mat = matrix.identity([]);
  9994. while (target && target !== ancestor) {
  9995. matrix.mul(mat, target.getLocalTransform(), mat);
  9996. target = target.parent;
  9997. }
  9998. return mat;
  9999. };
  10000. /**
  10001. * Apply transform to an vertex.
  10002. * @param {Array.<number>} vertex [x, y]
  10003. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  10004. * @param {boolean=} invert Whether use invert matrix.
  10005. * @return {Array.<number>} [x, y]
  10006. */
  10007. graphic.applyTransform = function (vertex, transform, invert) {
  10008. if (invert) {
  10009. transform = matrix.invert([], transform);
  10010. }
  10011. return vector.applyTransform([], vertex, transform);
  10012. };
  10013. /**
  10014. * @param {string} direction 'left' 'right' 'top' 'bottom'
  10015. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  10016. * @param {boolean=} invert Whether use invert matrix.
  10017. * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom'
  10018. */
  10019. graphic.transformDirection = function (direction, transform, invert) {
  10020. // Pick a base, ensure that transform result will not be (0, 0).
  10021. var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0)
  10022. ? 1 : Math.abs(2 * transform[4] / transform[0]);
  10023. var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0)
  10024. ? 1 : Math.abs(2 * transform[4] / transform[2]);
  10025. var vertex = [
  10026. direction === 'left' ? -hBase : direction === 'right' ? hBase : 0,
  10027. direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0
  10028. ];
  10029. vertex = graphic.applyTransform(vertex, transform, invert);
  10030. return Math.abs(vertex[0]) > Math.abs(vertex[1])
  10031. ? (vertex[0] > 0 ? 'right' : 'left')
  10032. : (vertex[1] > 0 ? 'bottom' : 'top');
  10033. };
  10034. /**
  10035. * Apply group transition animation from g1 to g2
  10036. */
  10037. graphic.groupTransition = function (g1, g2, animatableModel, cb) {
  10038. if (!g1 || !g2) {
  10039. return;
  10040. }
  10041. function getElMap(g) {
  10042. var elMap = {};
  10043. g.traverse(function (el) {
  10044. if (!el.isGroup && el.anid) {
  10045. elMap[el.anid] = el;
  10046. }
  10047. });
  10048. return elMap;
  10049. }
  10050. function getAnimatableProps(el) {
  10051. var obj = {
  10052. position: vector.clone(el.position),
  10053. rotation: el.rotation
  10054. };
  10055. if (el.shape) {
  10056. obj.shape = zrUtil.extend({}, el.shape);
  10057. }
  10058. return obj;
  10059. }
  10060. var elMap1 = getElMap(g1);
  10061. g2.traverse(function (el) {
  10062. if (!el.isGroup && el.anid) {
  10063. var oldEl = elMap1[el.anid];
  10064. if (oldEl) {
  10065. var newProp = getAnimatableProps(el);
  10066. el.attr(getAnimatableProps(oldEl));
  10067. graphic.updateProps(el, newProp, animatableModel, el.dataIndex);
  10068. }
  10069. // else {
  10070. // if (el.previousProps) {
  10071. // graphic.updateProps
  10072. // }
  10073. // }
  10074. }
  10075. });
  10076. };
  10077. module.exports = graphic;
  10078. /***/ },
  10079. /* 44 */
  10080. /***/ function(module, exports, __webpack_require__) {
  10081. var Path = __webpack_require__(45);
  10082. var PathProxy = __webpack_require__(49);
  10083. var transformPath = __webpack_require__(60);
  10084. var matrix = __webpack_require__(11);
  10085. // command chars
  10086. var cc = [
  10087. 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',
  10088. 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'
  10089. ];
  10090. var mathSqrt = Math.sqrt;
  10091. var mathSin = Math.sin;
  10092. var mathCos = Math.cos;
  10093. var PI = Math.PI;
  10094. var vMag = function(v) {
  10095. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  10096. };
  10097. var vRatio = function(u, v) {
  10098. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  10099. };
  10100. var vAngle = function(u, v) {
  10101. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)
  10102. * Math.acos(vRatio(u, v));
  10103. };
  10104. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  10105. var psi = psiDeg * (PI / 180.0);
  10106. var xp = mathCos(psi) * (x1 - x2) / 2.0
  10107. + mathSin(psi) * (y1 - y2) / 2.0;
  10108. var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
  10109. + mathCos(psi) * (y1 - y2) / 2.0;
  10110. var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
  10111. if (lambda > 1) {
  10112. rx *= mathSqrt(lambda);
  10113. ry *= mathSqrt(lambda);
  10114. }
  10115. var f = (fa === fs ? -1 : 1)
  10116. * mathSqrt((((rx * rx) * (ry * ry))
  10117. - ((rx * rx) * (yp * yp))
  10118. - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
  10119. + (ry * ry) * (xp * xp))
  10120. ) || 0;
  10121. var cxp = f * rx * yp / ry;
  10122. var cyp = f * -ry * xp / rx;
  10123. var cx = (x1 + x2) / 2.0
  10124. + mathCos(psi) * cxp
  10125. - mathSin(psi) * cyp;
  10126. var cy = (y1 + y2) / 2.0
  10127. + mathSin(psi) * cxp
  10128. + mathCos(psi) * cyp;
  10129. var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);
  10130. var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];
  10131. var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];
  10132. var dTheta = vAngle(u, v);
  10133. if (vRatio(u, v) <= -1) {
  10134. dTheta = PI;
  10135. }
  10136. if (vRatio(u, v) >= 1) {
  10137. dTheta = 0;
  10138. }
  10139. if (fs === 0 && dTheta > 0) {
  10140. dTheta = dTheta - 2 * PI;
  10141. }
  10142. if (fs === 1 && dTheta < 0) {
  10143. dTheta = dTheta + 2 * PI;
  10144. }
  10145. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  10146. }
  10147. function createPathProxyFromString(data) {
  10148. if (!data) {
  10149. return [];
  10150. }
  10151. // command string
  10152. var cs = data.replace(/-/g, ' -')
  10153. .replace(/ /g, ' ')
  10154. .replace(/ /g, ',')
  10155. .replace(/,,/g, ',');
  10156. var n;
  10157. // create pipes so that we can split the data
  10158. for (n = 0; n < cc.length; n++) {
  10159. cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
  10160. }
  10161. // create array
  10162. var arr = cs.split('|');
  10163. // init context point
  10164. var cpx = 0;
  10165. var cpy = 0;
  10166. var path = new PathProxy();
  10167. var CMD = PathProxy.CMD;
  10168. var prevCmd;
  10169. for (n = 1; n < arr.length; n++) {
  10170. var str = arr[n];
  10171. var c = str.charAt(0);
  10172. var off = 0;
  10173. var p = str.slice(1).replace(/e,-/g, 'e-').split(',');
  10174. var cmd;
  10175. if (p.length > 0 && p[0] === '') {
  10176. p.shift();
  10177. }
  10178. for (var i = 0; i < p.length; i++) {
  10179. p[i] = parseFloat(p[i]);
  10180. }
  10181. while (off < p.length && !isNaN(p[off])) {
  10182. if (isNaN(p[0])) {
  10183. break;
  10184. }
  10185. var ctlPtx;
  10186. var ctlPty;
  10187. var rx;
  10188. var ry;
  10189. var psi;
  10190. var fa;
  10191. var fs;
  10192. var x1 = cpx;
  10193. var y1 = cpy;
  10194. // convert l, H, h, V, and v to L
  10195. switch (c) {
  10196. case 'l':
  10197. cpx += p[off++];
  10198. cpy += p[off++];
  10199. cmd = CMD.L;
  10200. path.addData(cmd, cpx, cpy);
  10201. break;
  10202. case 'L':
  10203. cpx = p[off++];
  10204. cpy = p[off++];
  10205. cmd = CMD.L;
  10206. path.addData(cmd, cpx, cpy);
  10207. break;
  10208. case 'm':
  10209. cpx += p[off++];
  10210. cpy += p[off++];
  10211. cmd = CMD.M;
  10212. path.addData(cmd, cpx, cpy);
  10213. c = 'l';
  10214. break;
  10215. case 'M':
  10216. cpx = p[off++];
  10217. cpy = p[off++];
  10218. cmd = CMD.M;
  10219. path.addData(cmd, cpx, cpy);
  10220. c = 'L';
  10221. break;
  10222. case 'h':
  10223. cpx += p[off++];
  10224. cmd = CMD.L;
  10225. path.addData(cmd, cpx, cpy);
  10226. break;
  10227. case 'H':
  10228. cpx = p[off++];
  10229. cmd = CMD.L;
  10230. path.addData(cmd, cpx, cpy);
  10231. break;
  10232. case 'v':
  10233. cpy += p[off++];
  10234. cmd = CMD.L;
  10235. path.addData(cmd, cpx, cpy);
  10236. break;
  10237. case 'V':
  10238. cpy = p[off++];
  10239. cmd = CMD.L;
  10240. path.addData(cmd, cpx, cpy);
  10241. break;
  10242. case 'C':
  10243. cmd = CMD.C;
  10244. path.addData(
  10245. cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
  10246. );
  10247. cpx = p[off - 2];
  10248. cpy = p[off - 1];
  10249. break;
  10250. case 'c':
  10251. cmd = CMD.C;
  10252. path.addData(
  10253. cmd,
  10254. p[off++] + cpx, p[off++] + cpy,
  10255. p[off++] + cpx, p[off++] + cpy,
  10256. p[off++] + cpx, p[off++] + cpy
  10257. );
  10258. cpx += p[off - 2];
  10259. cpy += p[off - 1];
  10260. break;
  10261. case 'S':
  10262. ctlPtx = cpx;
  10263. ctlPty = cpy;
  10264. var len = path.len();
  10265. var pathData = path.data;
  10266. if (prevCmd === CMD.C) {
  10267. ctlPtx += cpx - pathData[len - 4];
  10268. ctlPty += cpy - pathData[len - 3];
  10269. }
  10270. cmd = CMD.C;
  10271. x1 = p[off++];
  10272. y1 = p[off++];
  10273. cpx = p[off++];
  10274. cpy = p[off++];
  10275. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  10276. break;
  10277. case 's':
  10278. ctlPtx = cpx;
  10279. ctlPty = cpy;
  10280. var len = path.len();
  10281. var pathData = path.data;
  10282. if (prevCmd === CMD.C) {
  10283. ctlPtx += cpx - pathData[len - 4];
  10284. ctlPty += cpy - pathData[len - 3];
  10285. }
  10286. cmd = CMD.C;
  10287. x1 = cpx + p[off++];
  10288. y1 = cpy + p[off++];
  10289. cpx += p[off++];
  10290. cpy += p[off++];
  10291. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  10292. break;
  10293. case 'Q':
  10294. x1 = p[off++];
  10295. y1 = p[off++];
  10296. cpx = p[off++];
  10297. cpy = p[off++];
  10298. cmd = CMD.Q;
  10299. path.addData(cmd, x1, y1, cpx, cpy);
  10300. break;
  10301. case 'q':
  10302. x1 = p[off++] + cpx;
  10303. y1 = p[off++] + cpy;
  10304. cpx += p[off++];
  10305. cpy += p[off++];
  10306. cmd = CMD.Q;
  10307. path.addData(cmd, x1, y1, cpx, cpy);
  10308. break;
  10309. case 'T':
  10310. ctlPtx = cpx;
  10311. ctlPty = cpy;
  10312. var len = path.len();
  10313. var pathData = path.data;
  10314. if (prevCmd === CMD.Q) {
  10315. ctlPtx += cpx - pathData[len - 4];
  10316. ctlPty += cpy - pathData[len - 3];
  10317. }
  10318. cpx = p[off++];
  10319. cpy = p[off++];
  10320. cmd = CMD.Q;
  10321. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  10322. break;
  10323. case 't':
  10324. ctlPtx = cpx;
  10325. ctlPty = cpy;
  10326. var len = path.len();
  10327. var pathData = path.data;
  10328. if (prevCmd === CMD.Q) {
  10329. ctlPtx += cpx - pathData[len - 4];
  10330. ctlPty += cpy - pathData[len - 3];
  10331. }
  10332. cpx += p[off++];
  10333. cpy += p[off++];
  10334. cmd = CMD.Q;
  10335. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  10336. break;
  10337. case 'A':
  10338. rx = p[off++];
  10339. ry = p[off++];
  10340. psi = p[off++];
  10341. fa = p[off++];
  10342. fs = p[off++];
  10343. x1 = cpx, y1 = cpy;
  10344. cpx = p[off++];
  10345. cpy = p[off++];
  10346. cmd = CMD.A;
  10347. processArc(
  10348. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  10349. );
  10350. break;
  10351. case 'a':
  10352. rx = p[off++];
  10353. ry = p[off++];
  10354. psi = p[off++];
  10355. fa = p[off++];
  10356. fs = p[off++];
  10357. x1 = cpx, y1 = cpy;
  10358. cpx += p[off++];
  10359. cpy += p[off++];
  10360. cmd = CMD.A;
  10361. processArc(
  10362. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  10363. );
  10364. break;
  10365. }
  10366. }
  10367. if (c === 'z' || c === 'Z') {
  10368. cmd = CMD.Z;
  10369. path.addData(cmd);
  10370. }
  10371. prevCmd = cmd;
  10372. }
  10373. path.toStatic();
  10374. return path;
  10375. }
  10376. // TODO Optimize double memory cost problem
  10377. function createPathOptions(str, opts) {
  10378. var pathProxy = createPathProxyFromString(str);
  10379. var transform;
  10380. opts = opts || {};
  10381. opts.buildPath = function (path) {
  10382. path.setData(pathProxy.data);
  10383. transform && transformPath(path, transform);
  10384. // Svg and vml renderer don't have context
  10385. var ctx = path.getContext();
  10386. if (ctx) {
  10387. path.rebuildPath(ctx);
  10388. }
  10389. };
  10390. opts.applyTransform = function (m) {
  10391. if (!transform) {
  10392. transform = matrix.create();
  10393. }
  10394. matrix.mul(transform, m, transform);
  10395. this.dirty(true);
  10396. };
  10397. return opts;
  10398. }
  10399. module.exports = {
  10400. /**
  10401. * Create a Path object from path string data
  10402. * http://www.w3.org/TR/SVG/paths.html#PathData
  10403. * @param {Object} opts Other options
  10404. */
  10405. createFromString: function (str, opts) {
  10406. return new Path(createPathOptions(str, opts));
  10407. },
  10408. /**
  10409. * Create a Path class from path string data
  10410. * @param {string} str
  10411. * @param {Object} opts Other options
  10412. */
  10413. extendFromString: function (str, opts) {
  10414. return Path.extend(createPathOptions(str, opts));
  10415. },
  10416. /**
  10417. * Merge multiple paths
  10418. */
  10419. // TODO Apply transform
  10420. // TODO stroke dash
  10421. // TODO Optimize double memory cost problem
  10422. mergePath: function (pathEls, opts) {
  10423. var pathList = [];
  10424. var len = pathEls.length;
  10425. for (var i = 0; i < len; i++) {
  10426. var pathEl = pathEls[i];
  10427. if (pathEl.__dirty) {
  10428. pathEl.buildPath(pathEl.path, pathEl.shape, true);
  10429. }
  10430. pathList.push(pathEl.path);
  10431. }
  10432. var pathBundle = new Path(opts);
  10433. pathBundle.buildPath = function (path) {
  10434. path.appendPath(pathList);
  10435. // Svg and vml renderer don't have context
  10436. var ctx = path.getContext();
  10437. if (ctx) {
  10438. path.rebuildPath(ctx);
  10439. }
  10440. };
  10441. return pathBundle;
  10442. }
  10443. };
  10444. /***/ },
  10445. /* 45 */
  10446. /***/ function(module, exports, __webpack_require__) {
  10447. /**
  10448. * Path element
  10449. * @module zrender/graphic/Path
  10450. */
  10451. var Displayable = __webpack_require__(46);
  10452. var zrUtil = __webpack_require__(4);
  10453. var PathProxy = __webpack_require__(49);
  10454. var pathContain = __webpack_require__(52);
  10455. var Pattern = __webpack_require__(59);
  10456. var getCanvasPattern = Pattern.prototype.getCanvasPattern;
  10457. var abs = Math.abs;
  10458. /**
  10459. * @alias module:zrender/graphic/Path
  10460. * @extends module:zrender/graphic/Displayable
  10461. * @constructor
  10462. * @param {Object} opts
  10463. */
  10464. function Path(opts) {
  10465. Displayable.call(this, opts);
  10466. /**
  10467. * @type {module:zrender/core/PathProxy}
  10468. * @readOnly
  10469. */
  10470. this.path = new PathProxy();
  10471. }
  10472. Path.prototype = {
  10473. constructor: Path,
  10474. type: 'path',
  10475. __dirtyPath: true,
  10476. strokeContainThreshold: 5,
  10477. brush: function (ctx, prevEl) {
  10478. var style = this.style;
  10479. var path = this.path;
  10480. var hasStroke = style.hasStroke();
  10481. var hasFill = style.hasFill();
  10482. var fill = style.fill;
  10483. var stroke = style.stroke;
  10484. var hasFillGradient = hasFill && !!(fill.colorStops);
  10485. var hasStrokeGradient = hasStroke && !!(stroke.colorStops);
  10486. var hasFillPattern = hasFill && !!(fill.image);
  10487. var hasStrokePattern = hasStroke && !!(stroke.image);
  10488. style.bind(ctx, this, prevEl);
  10489. this.setTransform(ctx);
  10490. if (this.__dirty) {
  10491. var rect = this.getBoundingRect();
  10492. // Update gradient because bounding rect may changed
  10493. if (hasFillGradient) {
  10494. this._fillGradient = style.getGradient(ctx, fill, rect);
  10495. }
  10496. if (hasStrokeGradient) {
  10497. this._strokeGradient = style.getGradient(ctx, stroke, rect);
  10498. }
  10499. }
  10500. // Use the gradient or pattern
  10501. if (hasFillGradient) {
  10502. // PENDING If may have affect the state
  10503. ctx.fillStyle = this._fillGradient;
  10504. }
  10505. else if (hasFillPattern) {
  10506. ctx.fillStyle = getCanvasPattern.call(fill, ctx);
  10507. }
  10508. if (hasStrokeGradient) {
  10509. ctx.strokeStyle = this._strokeGradient;
  10510. }
  10511. else if (hasStrokePattern) {
  10512. ctx.strokeStyle = getCanvasPattern.call(stroke, ctx);
  10513. }
  10514. var lineDash = style.lineDash;
  10515. var lineDashOffset = style.lineDashOffset;
  10516. var ctxLineDash = !!ctx.setLineDash;
  10517. // Update path sx, sy
  10518. var scale = this.getGlobalScale();
  10519. path.setScale(scale[0], scale[1]);
  10520. // Proxy context
  10521. // Rebuild path in following 2 cases
  10522. // 1. Path is dirty
  10523. // 2. Path needs javascript implemented lineDash stroking.
  10524. // In this case, lineDash information will not be saved in PathProxy
  10525. if (this.__dirtyPath || (
  10526. lineDash && !ctxLineDash && hasStroke
  10527. )) {
  10528. path = this.path.beginPath(ctx);
  10529. // Setting line dash before build path
  10530. if (lineDash && !ctxLineDash) {
  10531. path.setLineDash(lineDash);
  10532. path.setLineDashOffset(lineDashOffset);
  10533. }
  10534. this.buildPath(path, this.shape, false);
  10535. // Clear path dirty flag
  10536. this.__dirtyPath = false;
  10537. }
  10538. else {
  10539. // Replay path building
  10540. ctx.beginPath();
  10541. this.path.rebuildPath(ctx);
  10542. }
  10543. hasFill && path.fill(ctx);
  10544. if (lineDash && ctxLineDash) {
  10545. ctx.setLineDash(lineDash);
  10546. ctx.lineDashOffset = lineDashOffset;
  10547. }
  10548. hasStroke && path.stroke(ctx);
  10549. if (lineDash && ctxLineDash) {
  10550. // PENDING
  10551. // Remove lineDash
  10552. ctx.setLineDash([]);
  10553. }
  10554. this.restoreTransform(ctx);
  10555. // Draw rect text
  10556. if (style.text != null) {
  10557. // var rect = this.getBoundingRect();
  10558. this.drawRectText(ctx, this.getBoundingRect());
  10559. }
  10560. },
  10561. // When bundling path, some shape may decide if use moveTo to begin a new subpath or closePath
  10562. // Like in circle
  10563. buildPath: function (ctx, shapeCfg, inBundle) {},
  10564. getBoundingRect: function () {
  10565. var rect = this._rect;
  10566. var style = this.style;
  10567. var needsUpdateRect = !rect;
  10568. if (needsUpdateRect) {
  10569. var path = this.path;
  10570. if (this.__dirtyPath) {
  10571. path.beginPath();
  10572. this.buildPath(path, this.shape, false);
  10573. }
  10574. rect = path.getBoundingRect();
  10575. }
  10576. this._rect = rect;
  10577. if (style.hasStroke()) {
  10578. // Needs update rect with stroke lineWidth when
  10579. // 1. Element changes scale or lineWidth
  10580. // 2. Shape is changed
  10581. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  10582. if (this.__dirty || needsUpdateRect) {
  10583. rectWithStroke.copy(rect);
  10584. // FIXME Must after updateTransform
  10585. var w = style.lineWidth;
  10586. // PENDING, Min line width is needed when line is horizontal or vertical
  10587. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  10588. // Only add extra hover lineWidth when there are no fill
  10589. if (!style.hasFill()) {
  10590. w = Math.max(w, this.strokeContainThreshold || 4);
  10591. }
  10592. // Consider line width
  10593. // Line scale can't be 0;
  10594. if (lineScale > 1e-10) {
  10595. rectWithStroke.width += w / lineScale;
  10596. rectWithStroke.height += w / lineScale;
  10597. rectWithStroke.x -= w / lineScale / 2;
  10598. rectWithStroke.y -= w / lineScale / 2;
  10599. }
  10600. }
  10601. // Return rect with stroke
  10602. return rectWithStroke;
  10603. }
  10604. return rect;
  10605. },
  10606. contain: function (x, y) {
  10607. var localPos = this.transformCoordToLocal(x, y);
  10608. var rect = this.getBoundingRect();
  10609. var style = this.style;
  10610. x = localPos[0];
  10611. y = localPos[1];
  10612. if (rect.contain(x, y)) {
  10613. var pathData = this.path.data;
  10614. if (style.hasStroke()) {
  10615. var lineWidth = style.lineWidth;
  10616. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  10617. // Line scale can't be 0;
  10618. if (lineScale > 1e-10) {
  10619. // Only add extra hover lineWidth when there are no fill
  10620. if (!style.hasFill()) {
  10621. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  10622. }
  10623. if (pathContain.containStroke(
  10624. pathData, lineWidth / lineScale, x, y
  10625. )) {
  10626. return true;
  10627. }
  10628. }
  10629. }
  10630. if (style.hasFill()) {
  10631. return pathContain.contain(pathData, x, y);
  10632. }
  10633. }
  10634. return false;
  10635. },
  10636. /**
  10637. * @param {boolean} dirtyPath
  10638. */
  10639. dirty: function (dirtyPath) {
  10640. if (dirtyPath == null) {
  10641. dirtyPath = true;
  10642. }
  10643. // Only mark dirty, not mark clean
  10644. if (dirtyPath) {
  10645. this.__dirtyPath = dirtyPath;
  10646. this._rect = null;
  10647. }
  10648. this.__dirty = true;
  10649. this.__zr && this.__zr.refresh();
  10650. // Used as a clipping path
  10651. if (this.__clipTarget) {
  10652. this.__clipTarget.dirty();
  10653. }
  10654. },
  10655. /**
  10656. * Alias for animate('shape')
  10657. * @param {boolean} loop
  10658. */
  10659. animateShape: function (loop) {
  10660. return this.animate('shape', loop);
  10661. },
  10662. // Overwrite attrKV
  10663. attrKV: function (key, value) {
  10664. // FIXME
  10665. if (key === 'shape') {
  10666. this.setShape(value);
  10667. this.__dirtyPath = true;
  10668. this._rect = null;
  10669. }
  10670. else {
  10671. Displayable.prototype.attrKV.call(this, key, value);
  10672. }
  10673. },
  10674. /**
  10675. * @param {Object|string} key
  10676. * @param {*} value
  10677. */
  10678. setShape: function (key, value) {
  10679. var shape = this.shape;
  10680. // Path from string may not have shape
  10681. if (shape) {
  10682. if (zrUtil.isObject(key)) {
  10683. for (var name in key) {
  10684. if (key.hasOwnProperty(name)) {
  10685. shape[name] = key[name];
  10686. }
  10687. }
  10688. }
  10689. else {
  10690. shape[key] = value;
  10691. }
  10692. this.dirty(true);
  10693. }
  10694. return this;
  10695. },
  10696. getLineScale: function () {
  10697. var m = this.transform;
  10698. // Get the line scale.
  10699. // Determinant of `m` means how much the area is enlarged by the
  10700. // transformation. So its square root can be used as a scale factor
  10701. // for width.
  10702. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10
  10703. ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1]))
  10704. : 1;
  10705. }
  10706. };
  10707. /**
  10708. * 扩展一个 Path element, 比如星形,圆等。
  10709. * Extend a path element
  10710. * @param {Object} props
  10711. * @param {string} props.type Path type
  10712. * @param {Function} props.init Initialize
  10713. * @param {Function} props.buildPath Overwrite buildPath method
  10714. * @param {Object} [props.style] Extended default style config
  10715. * @param {Object} [props.shape] Extended default shape config
  10716. */
  10717. Path.extend = function (defaults) {
  10718. var Sub = function (opts) {
  10719. Path.call(this, opts);
  10720. if (defaults.style) {
  10721. // Extend default style
  10722. this.style.extendFrom(defaults.style, false);
  10723. }
  10724. // Extend default shape
  10725. var defaultShape = defaults.shape;
  10726. if (defaultShape) {
  10727. this.shape = this.shape || {};
  10728. var thisShape = this.shape;
  10729. for (var name in defaultShape) {
  10730. if (
  10731. ! thisShape.hasOwnProperty(name)
  10732. && defaultShape.hasOwnProperty(name)
  10733. ) {
  10734. thisShape[name] = defaultShape[name];
  10735. }
  10736. }
  10737. }
  10738. defaults.init && defaults.init.call(this, opts);
  10739. };
  10740. zrUtil.inherits(Sub, Path);
  10741. // FIXME 不能 extend position, rotation 等引用对象
  10742. for (var name in defaults) {
  10743. // Extending prototype values and methods
  10744. if (name !== 'style' && name !== 'shape') {
  10745. Sub.prototype[name] = defaults[name];
  10746. }
  10747. }
  10748. return Sub;
  10749. };
  10750. zrUtil.inherits(Path, Displayable);
  10751. module.exports = Path;
  10752. /***/ },
  10753. /* 46 */
  10754. /***/ function(module, exports, __webpack_require__) {
  10755. /**
  10756. * 可绘制的图形基类
  10757. * Base class of all displayable graphic objects
  10758. * @module zrender/graphic/Displayable
  10759. */
  10760. var zrUtil = __webpack_require__(4);
  10761. var Style = __webpack_require__(47);
  10762. var Element = __webpack_require__(31);
  10763. var RectText = __webpack_require__(48);
  10764. // var Stateful = require('./mixin/Stateful');
  10765. /**
  10766. * @alias module:zrender/graphic/Displayable
  10767. * @extends module:zrender/Element
  10768. * @extends module:zrender/graphic/mixin/RectText
  10769. */
  10770. function Displayable(opts) {
  10771. opts = opts || {};
  10772. Element.call(this, opts);
  10773. // Extend properties
  10774. for (var name in opts) {
  10775. if (
  10776. opts.hasOwnProperty(name) &&
  10777. name !== 'style'
  10778. ) {
  10779. this[name] = opts[name];
  10780. }
  10781. }
  10782. /**
  10783. * @type {module:zrender/graphic/Style}
  10784. */
  10785. this.style = new Style(opts.style);
  10786. this._rect = null;
  10787. // Shapes for cascade clipping.
  10788. this.__clipPaths = [];
  10789. // FIXME Stateful must be mixined after style is setted
  10790. // Stateful.call(this, opts);
  10791. }
  10792. Displayable.prototype = {
  10793. constructor: Displayable,
  10794. type: 'displayable',
  10795. /**
  10796. * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制
  10797. * Dirty flag. From which painter will determine if this displayable object needs brush
  10798. * @name module:zrender/graphic/Displayable#__dirty
  10799. * @type {boolean}
  10800. */
  10801. __dirty: true,
  10802. /**
  10803. * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件
  10804. * If ignore drawing of the displayable object. Mouse event will still be triggered
  10805. * @name module:/zrender/graphic/Displayable#invisible
  10806. * @type {boolean}
  10807. * @default false
  10808. */
  10809. invisible: false,
  10810. /**
  10811. * @name module:/zrender/graphic/Displayable#z
  10812. * @type {number}
  10813. * @default 0
  10814. */
  10815. z: 0,
  10816. /**
  10817. * @name module:/zrender/graphic/Displayable#z
  10818. * @type {number}
  10819. * @default 0
  10820. */
  10821. z2: 0,
  10822. /**
  10823. * z层level,决定绘画在哪层canvas中
  10824. * @name module:/zrender/graphic/Displayable#zlevel
  10825. * @type {number}
  10826. * @default 0
  10827. */
  10828. zlevel: 0,
  10829. /**
  10830. * 是否可拖拽
  10831. * @name module:/zrender/graphic/Displayable#draggable
  10832. * @type {boolean}
  10833. * @default false
  10834. */
  10835. draggable: false,
  10836. /**
  10837. * 是否正在拖拽
  10838. * @name module:/zrender/graphic/Displayable#draggable
  10839. * @type {boolean}
  10840. * @default false
  10841. */
  10842. dragging: false,
  10843. /**
  10844. * 是否相应鼠标事件
  10845. * @name module:/zrender/graphic/Displayable#silent
  10846. * @type {boolean}
  10847. * @default false
  10848. */
  10849. silent: false,
  10850. /**
  10851. * If enable culling
  10852. * @type {boolean}
  10853. * @default false
  10854. */
  10855. culling: false,
  10856. /**
  10857. * Mouse cursor when hovered
  10858. * @name module:/zrender/graphic/Displayable#cursor
  10859. * @type {string}
  10860. */
  10861. cursor: 'pointer',
  10862. /**
  10863. * If hover area is bounding rect
  10864. * @name module:/zrender/graphic/Displayable#rectHover
  10865. * @type {string}
  10866. */
  10867. rectHover: false,
  10868. /**
  10869. * Render the element progressively when the value >= 0,
  10870. * usefull for large data.
  10871. * @type {number}
  10872. */
  10873. progressive: -1,
  10874. beforeBrush: function (ctx) {},
  10875. afterBrush: function (ctx) {},
  10876. /**
  10877. * 图形绘制方法
  10878. * @param {Canvas2DRenderingContext} ctx
  10879. */
  10880. // Interface
  10881. brush: function (ctx, prevEl) {},
  10882. /**
  10883. * 获取最小包围盒
  10884. * @return {module:zrender/core/BoundingRect}
  10885. */
  10886. // Interface
  10887. getBoundingRect: function () {},
  10888. /**
  10889. * 判断坐标 x, y 是否在图形上
  10890. * If displayable element contain coord x, y
  10891. * @param {number} x
  10892. * @param {number} y
  10893. * @return {boolean}
  10894. */
  10895. contain: function (x, y) {
  10896. return this.rectContain(x, y);
  10897. },
  10898. /**
  10899. * @param {Function} cb
  10900. * @param {} context
  10901. */
  10902. traverse: function (cb, context) {
  10903. cb.call(context, this);
  10904. },
  10905. /**
  10906. * 判断坐标 x, y 是否在图形的包围盒上
  10907. * If bounding rect of element contain coord x, y
  10908. * @param {number} x
  10909. * @param {number} y
  10910. * @return {boolean}
  10911. */
  10912. rectContain: function (x, y) {
  10913. var coord = this.transformCoordToLocal(x, y);
  10914. var rect = this.getBoundingRect();
  10915. return rect.contain(coord[0], coord[1]);
  10916. },
  10917. /**
  10918. * 标记图形元素为脏,并且在下一帧重绘
  10919. * Mark displayable element dirty and refresh next frame
  10920. */
  10921. dirty: function () {
  10922. this.__dirty = true;
  10923. this._rect = null;
  10924. this.__zr && this.__zr.refresh();
  10925. },
  10926. /**
  10927. * 图形是否会触发事件
  10928. * If displayable object binded any event
  10929. * @return {boolean}
  10930. */
  10931. // TODO, 通过 bind 绑定的事件
  10932. // isSilent: function () {
  10933. // return !(
  10934. // this.hoverable || this.draggable
  10935. // || this.onmousemove || this.onmouseover || this.onmouseout
  10936. // || this.onmousedown || this.onmouseup || this.onclick
  10937. // || this.ondragenter || this.ondragover || this.ondragleave
  10938. // || this.ondrop
  10939. // );
  10940. // },
  10941. /**
  10942. * Alias for animate('style')
  10943. * @param {boolean} loop
  10944. */
  10945. animateStyle: function (loop) {
  10946. return this.animate('style', loop);
  10947. },
  10948. attrKV: function (key, value) {
  10949. if (key !== 'style') {
  10950. Element.prototype.attrKV.call(this, key, value);
  10951. }
  10952. else {
  10953. this.style.set(value);
  10954. }
  10955. },
  10956. /**
  10957. * @param {Object|string} key
  10958. * @param {*} value
  10959. */
  10960. setStyle: function (key, value) {
  10961. this.style.set(key, value);
  10962. this.dirty(false);
  10963. return this;
  10964. },
  10965. /**
  10966. * Use given style object
  10967. * @param {Object} obj
  10968. */
  10969. useStyle: function (obj) {
  10970. this.style = new Style(obj);
  10971. this.dirty(false);
  10972. return this;
  10973. }
  10974. };
  10975. zrUtil.inherits(Displayable, Element);
  10976. zrUtil.mixin(Displayable, RectText);
  10977. // zrUtil.mixin(Displayable, Stateful);
  10978. module.exports = Displayable;
  10979. /***/ },
  10980. /* 47 */
  10981. /***/ function(module, exports) {
  10982. /**
  10983. * @module zrender/graphic/Style
  10984. */
  10985. var STYLE_COMMON_PROPS = [
  10986. ['shadowBlur', 0], ['shadowOffsetX', 0], ['shadowOffsetY', 0], ['shadowColor', '#000'],
  10987. ['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]
  10988. ];
  10989. // var SHADOW_PROPS = STYLE_COMMON_PROPS.slice(0, 4);
  10990. // var LINE_PROPS = STYLE_COMMON_PROPS.slice(4);
  10991. var Style = function (opts) {
  10992. this.extendFrom(opts);
  10993. };
  10994. function createLinearGradient(ctx, obj, rect) {
  10995. // var size =
  10996. var x = obj.x;
  10997. var x2 = obj.x2;
  10998. var y = obj.y;
  10999. var y2 = obj.y2;
  11000. if (!obj.global) {
  11001. x = x * rect.width + rect.x;
  11002. x2 = x2 * rect.width + rect.x;
  11003. y = y * rect.height + rect.y;
  11004. y2 = y2 * rect.height + rect.y;
  11005. }
  11006. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  11007. return canvasGradient;
  11008. }
  11009. function createRadialGradient(ctx, obj, rect) {
  11010. var width = rect.width;
  11011. var height = rect.height;
  11012. var min = Math.min(width, height);
  11013. var x = obj.x;
  11014. var y = obj.y;
  11015. var r = obj.r;
  11016. if (!obj.global) {
  11017. x = x * width + rect.x;
  11018. y = y * height + rect.y;
  11019. r = r * min;
  11020. }
  11021. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  11022. return canvasGradient;
  11023. }
  11024. Style.prototype = {
  11025. constructor: Style,
  11026. /**
  11027. * @type {string}
  11028. */
  11029. fill: '#000000',
  11030. /**
  11031. * @type {string}
  11032. */
  11033. stroke: null,
  11034. /**
  11035. * @type {number}
  11036. */
  11037. opacity: 1,
  11038. /**
  11039. * @type {Array.<number>}
  11040. */
  11041. lineDash: null,
  11042. /**
  11043. * @type {number}
  11044. */
  11045. lineDashOffset: 0,
  11046. /**
  11047. * @type {number}
  11048. */
  11049. shadowBlur: 0,
  11050. /**
  11051. * @type {number}
  11052. */
  11053. shadowOffsetX: 0,
  11054. /**
  11055. * @type {number}
  11056. */
  11057. shadowOffsetY: 0,
  11058. /**
  11059. * @type {number}
  11060. */
  11061. lineWidth: 1,
  11062. /**
  11063. * If stroke ignore scale
  11064. * @type {Boolean}
  11065. */
  11066. strokeNoScale: false,
  11067. // Bounding rect text configuration
  11068. // Not affected by element transform
  11069. /**
  11070. * @type {string}
  11071. */
  11072. text: null,
  11073. /**
  11074. * @type {string}
  11075. */
  11076. textFill: '#000',
  11077. /**
  11078. * @type {string}
  11079. */
  11080. textStroke: null,
  11081. /**
  11082. * 'inside', 'left', 'right', 'top', 'bottom'
  11083. * [x, y]
  11084. * @type {string|Array.<number>}
  11085. * @default 'inside'
  11086. */
  11087. textPosition: 'inside',
  11088. /**
  11089. * @type {string}
  11090. */
  11091. textBaseline: null,
  11092. /**
  11093. * @type {string}
  11094. */
  11095. textAlign: null,
  11096. /**
  11097. * @type {string}
  11098. */
  11099. textVerticalAlign: null,
  11100. /**
  11101. * Only useful in Path and Image element
  11102. * @type {number}
  11103. */
  11104. textDistance: 5,
  11105. /**
  11106. * Only useful in Path and Image element
  11107. * @type {number}
  11108. */
  11109. textShadowBlur: 0,
  11110. /**
  11111. * Only useful in Path and Image element
  11112. * @type {number}
  11113. */
  11114. textShadowOffsetX: 0,
  11115. /**
  11116. * Only useful in Path and Image element
  11117. * @type {number}
  11118. */
  11119. textShadowOffsetY: 0,
  11120. /**
  11121. * If transform text
  11122. * Only useful in Path and Image element
  11123. * @type {boolean}
  11124. */
  11125. textTransform: false,
  11126. /**
  11127. * Text rotate around position of Path or Image
  11128. * Only useful in Path and Image element and textTransform is false.
  11129. */
  11130. textRotation: 0,
  11131. /**
  11132. * @type {string}
  11133. * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  11134. */
  11135. blend: null,
  11136. /**
  11137. * @param {CanvasRenderingContext2D} ctx
  11138. */
  11139. bind: function (ctx, el, prevEl) {
  11140. var style = this;
  11141. var prevStyle = prevEl && prevEl.style;
  11142. var firstDraw = !prevStyle;
  11143. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  11144. var prop = STYLE_COMMON_PROPS[i];
  11145. var styleName = prop[0];
  11146. if (firstDraw || style[styleName] !== prevStyle[styleName]) {
  11147. // FIXME Invalid property value will cause style leak from previous element.
  11148. ctx[styleName] = style[styleName] || prop[1];
  11149. }
  11150. }
  11151. if ((firstDraw || style.fill !== prevStyle.fill)) {
  11152. ctx.fillStyle = style.fill;
  11153. }
  11154. if ((firstDraw || style.stroke !== prevStyle.stroke)) {
  11155. ctx.strokeStyle = style.stroke;
  11156. }
  11157. if ((firstDraw || style.opacity !== prevStyle.opacity)) {
  11158. ctx.globalAlpha = style.opacity == null ? 1 : style.opacity;
  11159. }
  11160. if ((firstDraw || style.blend !== prevStyle.blend)) {
  11161. ctx.globalCompositeOperation = style.blend || 'source-over';
  11162. }
  11163. if (this.hasStroke()) {
  11164. var lineWidth = style.lineWidth;
  11165. ctx.lineWidth = lineWidth / (
  11166. (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1
  11167. );
  11168. }
  11169. },
  11170. hasFill: function () {
  11171. var fill = this.fill;
  11172. return fill != null && fill !== 'none';
  11173. },
  11174. hasStroke: function () {
  11175. var stroke = this.stroke;
  11176. return stroke != null && stroke !== 'none' && this.lineWidth > 0;
  11177. },
  11178. /**
  11179. * Extend from other style
  11180. * @param {zrender/graphic/Style} otherStyle
  11181. * @param {boolean} overwrite
  11182. */
  11183. extendFrom: function (otherStyle, overwrite) {
  11184. if (otherStyle) {
  11185. var target = this;
  11186. for (var name in otherStyle) {
  11187. if (otherStyle.hasOwnProperty(name)
  11188. && (overwrite || ! target.hasOwnProperty(name))
  11189. ) {
  11190. target[name] = otherStyle[name];
  11191. }
  11192. }
  11193. }
  11194. },
  11195. /**
  11196. * Batch setting style with a given object
  11197. * @param {Object|string} obj
  11198. * @param {*} [obj]
  11199. */
  11200. set: function (obj, value) {
  11201. if (typeof obj === 'string') {
  11202. this[obj] = value;
  11203. }
  11204. else {
  11205. this.extendFrom(obj, true);
  11206. }
  11207. },
  11208. /**
  11209. * Clone
  11210. * @return {zrender/graphic/Style} [description]
  11211. */
  11212. clone: function () {
  11213. var newStyle = new this.constructor();
  11214. newStyle.extendFrom(this, true);
  11215. return newStyle;
  11216. },
  11217. getGradient: function (ctx, obj, rect) {
  11218. var method = obj.type === 'radial' ? createRadialGradient : createLinearGradient;
  11219. var canvasGradient = method(ctx, obj, rect);
  11220. var colorStops = obj.colorStops;
  11221. for (var i = 0; i < colorStops.length; i++) {
  11222. canvasGradient.addColorStop(
  11223. colorStops[i].offset, colorStops[i].color
  11224. );
  11225. }
  11226. return canvasGradient;
  11227. }
  11228. };
  11229. var styleProto = Style.prototype;
  11230. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  11231. var prop = STYLE_COMMON_PROPS[i];
  11232. if (!(prop[0] in styleProto)) {
  11233. styleProto[prop[0]] = prop[1];
  11234. }
  11235. }
  11236. // Provide for others
  11237. Style.getGradient = styleProto.getGradient;
  11238. module.exports = Style;
  11239. /***/ },
  11240. /* 48 */
  11241. /***/ function(module, exports, __webpack_require__) {
  11242. /**
  11243. * Mixin for drawing text in a element bounding rect
  11244. * @module zrender/mixin/RectText
  11245. */
  11246. var textContain = __webpack_require__(8);
  11247. var BoundingRect = __webpack_require__(9);
  11248. var tmpRect = new BoundingRect();
  11249. var RectText = function () {};
  11250. function parsePercent(value, maxValue) {
  11251. if (typeof value === 'string') {
  11252. if (value.lastIndexOf('%') >= 0) {
  11253. return parseFloat(value) / 100 * maxValue;
  11254. }
  11255. return parseFloat(value);
  11256. }
  11257. return value;
  11258. }
  11259. RectText.prototype = {
  11260. constructor: RectText,
  11261. /**
  11262. * Draw text in a rect with specified position.
  11263. * @param {CanvasRenderingContext} ctx
  11264. * @param {Object} rect Displayable rect
  11265. * @return {Object} textRect Alternative precalculated text bounding rect
  11266. */
  11267. drawRectText: function (ctx, rect, textRect) {
  11268. var style = this.style;
  11269. var text = style.text;
  11270. // Convert to string
  11271. text != null && (text += '');
  11272. if (!text) {
  11273. return;
  11274. }
  11275. // FIXME
  11276. ctx.save();
  11277. var x;
  11278. var y;
  11279. var textPosition = style.textPosition;
  11280. var distance = style.textDistance;
  11281. var align = style.textAlign;
  11282. var font = style.textFont || style.font;
  11283. var baseline = style.textBaseline;
  11284. var verticalAlign = style.textVerticalAlign;
  11285. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  11286. // Transform rect to view space
  11287. var transform = this.transform;
  11288. if (!style.textTransform) {
  11289. if (transform) {
  11290. tmpRect.copy(rect);
  11291. tmpRect.applyTransform(transform);
  11292. rect = tmpRect;
  11293. }
  11294. }
  11295. else {
  11296. this.setTransform(ctx);
  11297. }
  11298. // Text position represented by coord
  11299. if (textPosition instanceof Array) {
  11300. // Percent
  11301. x = rect.x + parsePercent(textPosition[0], rect.width);
  11302. y = rect.y + parsePercent(textPosition[1], rect.height);
  11303. align = align || 'left';
  11304. baseline = baseline || 'top';
  11305. if (verticalAlign) {
  11306. switch (verticalAlign) {
  11307. case 'middle':
  11308. y -= textRect.height / 2 - textRect.lineHeight / 2;
  11309. break;
  11310. case 'bottom':
  11311. y -= textRect.height - textRect.lineHeight / 2;
  11312. break;
  11313. default:
  11314. y += textRect.lineHeight / 2;
  11315. }
  11316. // Force bseline to be middle
  11317. baseline = 'middle';
  11318. }
  11319. }
  11320. else {
  11321. var res = textContain.adjustTextPositionOnRect(
  11322. textPosition, rect, textRect, distance
  11323. );
  11324. x = res.x;
  11325. y = res.y;
  11326. // Default align and baseline when has textPosition
  11327. align = align || res.textAlign;
  11328. baseline = baseline || res.textBaseline;
  11329. }
  11330. // Use canvas default left textAlign. Giving invalid value will cause state not change
  11331. ctx.textAlign = align || 'left';
  11332. // Use canvas default alphabetic baseline
  11333. ctx.textBaseline = baseline || 'alphabetic';
  11334. var textFill = style.textFill;
  11335. var textStroke = style.textStroke;
  11336. textFill && (ctx.fillStyle = textFill);
  11337. textStroke && (ctx.strokeStyle = textStroke);
  11338. // TODO Invalid font
  11339. ctx.font = font || '12px sans-serif';
  11340. // Text shadow
  11341. // Always set shadowBlur and shadowOffset to avoid leak from displayable
  11342. ctx.shadowBlur = style.textShadowBlur;
  11343. ctx.shadowColor = style.textShadowColor || 'transparent';
  11344. ctx.shadowOffsetX = style.textShadowOffsetX;
  11345. ctx.shadowOffsetY = style.textShadowOffsetY;
  11346. var textLines = text.split('\n');
  11347. if (style.textRotation) {
  11348. transform && ctx.translate(transform[4], transform[5]);
  11349. ctx.rotate(style.textRotation);
  11350. transform && ctx.translate(-transform[4], -transform[5]);
  11351. }
  11352. for (var i = 0; i < textLines.length; i++) {
  11353. textFill && ctx.fillText(textLines[i], x, y);
  11354. textStroke && ctx.strokeText(textLines[i], x, y);
  11355. y += textRect.lineHeight;
  11356. }
  11357. ctx.restore();
  11358. }
  11359. };
  11360. module.exports = RectText;
  11361. /***/ },
  11362. /* 49 */
  11363. /***/ function(module, exports, __webpack_require__) {
  11364. 'use strict';
  11365. /**
  11366. * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中
  11367. * 可以用于 isInsidePath 判断以及获取boundingRect
  11368. *
  11369. * @module zrender/core/PathProxy
  11370. * @author Yi Shen (http://www.github.com/pissang)
  11371. */
  11372. // TODO getTotalLength, getPointAtLength
  11373. var curve = __webpack_require__(50);
  11374. var vec2 = __webpack_require__(10);
  11375. var bbox = __webpack_require__(51);
  11376. var BoundingRect = __webpack_require__(9);
  11377. var dpr = __webpack_require__(41).devicePixelRatio;
  11378. var CMD = {
  11379. M: 1,
  11380. L: 2,
  11381. C: 3,
  11382. Q: 4,
  11383. A: 5,
  11384. Z: 6,
  11385. // Rect
  11386. R: 7
  11387. };
  11388. var min = [];
  11389. var max = [];
  11390. var min2 = [];
  11391. var max2 = [];
  11392. var mathMin = Math.min;
  11393. var mathMax = Math.max;
  11394. var mathCos = Math.cos;
  11395. var mathSin = Math.sin;
  11396. var mathSqrt = Math.sqrt;
  11397. var mathAbs = Math.abs;
  11398. var hasTypedArray = typeof Float32Array != 'undefined';
  11399. /**
  11400. * @alias module:zrender/core/PathProxy
  11401. * @constructor
  11402. */
  11403. var PathProxy = function () {
  11404. /**
  11405. * Path data. Stored as flat array
  11406. * @type {Array.<Object>}
  11407. */
  11408. this.data = [];
  11409. this._len = 0;
  11410. this._ctx = null;
  11411. this._xi = 0;
  11412. this._yi = 0;
  11413. this._x0 = 0;
  11414. this._y0 = 0;
  11415. // Unit x, Unit y. Provide for avoiding drawing that too short line segment
  11416. this._ux = 0;
  11417. this._uy = 0;
  11418. };
  11419. /**
  11420. * 快速计算Path包围盒(并不是最小包围盒)
  11421. * @return {Object}
  11422. */
  11423. PathProxy.prototype = {
  11424. constructor: PathProxy,
  11425. _lineDash: null,
  11426. _dashOffset: 0,
  11427. _dashIdx: 0,
  11428. _dashSum: 0,
  11429. /**
  11430. * @readOnly
  11431. */
  11432. setScale: function (sx, sy) {
  11433. this._ux = mathAbs(1 / dpr / sx) || 0;
  11434. this._uy = mathAbs(1 / dpr / sy) || 0;
  11435. },
  11436. getContext: function () {
  11437. return this._ctx;
  11438. },
  11439. /**
  11440. * @param {CanvasRenderingContext2D} ctx
  11441. * @return {module:zrender/core/PathProxy}
  11442. */
  11443. beginPath: function (ctx) {
  11444. this._ctx = ctx;
  11445. ctx && ctx.beginPath();
  11446. ctx && (this.dpr = ctx.dpr);
  11447. // Reset
  11448. this._len = 0;
  11449. if (this._lineDash) {
  11450. this._lineDash = null;
  11451. this._dashOffset = 0;
  11452. }
  11453. return this;
  11454. },
  11455. /**
  11456. * @param {number} x
  11457. * @param {number} y
  11458. * @return {module:zrender/core/PathProxy}
  11459. */
  11460. moveTo: function (x, y) {
  11461. this.addData(CMD.M, x, y);
  11462. this._ctx && this._ctx.moveTo(x, y);
  11463. // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用
  11464. // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。
  11465. // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要
  11466. // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持
  11467. this._x0 = x;
  11468. this._y0 = y;
  11469. this._xi = x;
  11470. this._yi = y;
  11471. return this;
  11472. },
  11473. /**
  11474. * @param {number} x
  11475. * @param {number} y
  11476. * @return {module:zrender/core/PathProxy}
  11477. */
  11478. lineTo: function (x, y) {
  11479. var exceedUnit = mathAbs(x - this._xi) > this._ux
  11480. || mathAbs(y - this._yi) > this._uy
  11481. // Force draw the first segment
  11482. || this._len < 5;
  11483. this.addData(CMD.L, x, y);
  11484. if (this._ctx && exceedUnit) {
  11485. this._needsDash() ? this._dashedLineTo(x, y)
  11486. : this._ctx.lineTo(x, y);
  11487. }
  11488. if (exceedUnit) {
  11489. this._xi = x;
  11490. this._yi = y;
  11491. }
  11492. return this;
  11493. },
  11494. /**
  11495. * @param {number} x1
  11496. * @param {number} y1
  11497. * @param {number} x2
  11498. * @param {number} y2
  11499. * @param {number} x3
  11500. * @param {number} y3
  11501. * @return {module:zrender/core/PathProxy}
  11502. */
  11503. bezierCurveTo: function (x1, y1, x2, y2, x3, y3) {
  11504. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  11505. if (this._ctx) {
  11506. this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3)
  11507. : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  11508. }
  11509. this._xi = x3;
  11510. this._yi = y3;
  11511. return this;
  11512. },
  11513. /**
  11514. * @param {number} x1
  11515. * @param {number} y1
  11516. * @param {number} x2
  11517. * @param {number} y2
  11518. * @return {module:zrender/core/PathProxy}
  11519. */
  11520. quadraticCurveTo: function (x1, y1, x2, y2) {
  11521. this.addData(CMD.Q, x1, y1, x2, y2);
  11522. if (this._ctx) {
  11523. this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2)
  11524. : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  11525. }
  11526. this._xi = x2;
  11527. this._yi = y2;
  11528. return this;
  11529. },
  11530. /**
  11531. * @param {number} cx
  11532. * @param {number} cy
  11533. * @param {number} r
  11534. * @param {number} startAngle
  11535. * @param {number} endAngle
  11536. * @param {boolean} anticlockwise
  11537. * @return {module:zrender/core/PathProxy}
  11538. */
  11539. arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  11540. this.addData(
  11541. CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1
  11542. );
  11543. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  11544. this._xi = mathCos(endAngle) * r + cx;
  11545. this._xi = mathSin(endAngle) * r + cx;
  11546. return this;
  11547. },
  11548. // TODO
  11549. arcTo: function (x1, y1, x2, y2, radius) {
  11550. if (this._ctx) {
  11551. this._ctx.arcTo(x1, y1, x2, y2, radius);
  11552. }
  11553. return this;
  11554. },
  11555. // TODO
  11556. rect: function (x, y, w, h) {
  11557. this._ctx && this._ctx.rect(x, y, w, h);
  11558. this.addData(CMD.R, x, y, w, h);
  11559. return this;
  11560. },
  11561. /**
  11562. * @return {module:zrender/core/PathProxy}
  11563. */
  11564. closePath: function () {
  11565. this.addData(CMD.Z);
  11566. var ctx = this._ctx;
  11567. var x0 = this._x0;
  11568. var y0 = this._y0;
  11569. if (ctx) {
  11570. this._needsDash() && this._dashedLineTo(x0, y0);
  11571. ctx.closePath();
  11572. }
  11573. this._xi = x0;
  11574. this._yi = y0;
  11575. return this;
  11576. },
  11577. /**
  11578. * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。
  11579. * stroke 同样
  11580. * @param {CanvasRenderingContext2D} ctx
  11581. * @return {module:zrender/core/PathProxy}
  11582. */
  11583. fill: function (ctx) {
  11584. ctx && ctx.fill();
  11585. this.toStatic();
  11586. },
  11587. /**
  11588. * @param {CanvasRenderingContext2D} ctx
  11589. * @return {module:zrender/core/PathProxy}
  11590. */
  11591. stroke: function (ctx) {
  11592. ctx && ctx.stroke();
  11593. this.toStatic();
  11594. },
  11595. /**
  11596. * 必须在其它绘制命令前调用
  11597. * Must be invoked before all other path drawing methods
  11598. * @return {module:zrender/core/PathProxy}
  11599. */
  11600. setLineDash: function (lineDash) {
  11601. if (lineDash instanceof Array) {
  11602. this._lineDash = lineDash;
  11603. this._dashIdx = 0;
  11604. var lineDashSum = 0;
  11605. for (var i = 0; i < lineDash.length; i++) {
  11606. lineDashSum += lineDash[i];
  11607. }
  11608. this._dashSum = lineDashSum;
  11609. }
  11610. return this;
  11611. },
  11612. /**
  11613. * 必须在其它绘制命令前调用
  11614. * Must be invoked before all other path drawing methods
  11615. * @return {module:zrender/core/PathProxy}
  11616. */
  11617. setLineDashOffset: function (offset) {
  11618. this._dashOffset = offset;
  11619. return this;
  11620. },
  11621. /**
  11622. *
  11623. * @return {boolean}
  11624. */
  11625. len: function () {
  11626. return this._len;
  11627. },
  11628. /**
  11629. * 直接设置 Path 数据
  11630. */
  11631. setData: function (data) {
  11632. var len = data.length;
  11633. if (! (this.data && this.data.length == len) && hasTypedArray) {
  11634. this.data = new Float32Array(len);
  11635. }
  11636. for (var i = 0; i < len; i++) {
  11637. this.data[i] = data[i];
  11638. }
  11639. this._len = len;
  11640. },
  11641. /**
  11642. * 添加子路径
  11643. * @param {module:zrender/core/PathProxy|Array.<module:zrender/core/PathProxy>} path
  11644. */
  11645. appendPath: function (path) {
  11646. if (!(path instanceof Array)) {
  11647. path = [path];
  11648. }
  11649. var len = path.length;
  11650. var appendSize = 0;
  11651. var offset = this._len;
  11652. for (var i = 0; i < len; i++) {
  11653. appendSize += path[i].len();
  11654. }
  11655. if (hasTypedArray && (this.data instanceof Float32Array)) {
  11656. this.data = new Float32Array(offset + appendSize);
  11657. }
  11658. for (var i = 0; i < len; i++) {
  11659. var appendPathData = path[i].data;
  11660. for (var k = 0; k < appendPathData.length; k++) {
  11661. this.data[offset++] = appendPathData[k];
  11662. }
  11663. }
  11664. this._len = offset;
  11665. },
  11666. /**
  11667. * 填充 Path 数据。
  11668. * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。
  11669. */
  11670. addData: function (cmd) {
  11671. var data = this.data;
  11672. if (this._len + arguments.length > data.length) {
  11673. // 因为之前的数组已经转换成静态的 Float32Array
  11674. // 所以不够用时需要扩展一个新的动态数组
  11675. this._expandData();
  11676. data = this.data;
  11677. }
  11678. for (var i = 0; i < arguments.length; i++) {
  11679. data[this._len++] = arguments[i];
  11680. }
  11681. this._prevCmd = cmd;
  11682. },
  11683. _expandData: function () {
  11684. // Only if data is Float32Array
  11685. if (!(this.data instanceof Array)) {
  11686. var newData = [];
  11687. for (var i = 0; i < this._len; i++) {
  11688. newData[i] = this.data[i];
  11689. }
  11690. this.data = newData;
  11691. }
  11692. },
  11693. /**
  11694. * If needs js implemented dashed line
  11695. * @return {boolean}
  11696. * @private
  11697. */
  11698. _needsDash: function () {
  11699. return this._lineDash;
  11700. },
  11701. _dashedLineTo: function (x1, y1) {
  11702. var dashSum = this._dashSum;
  11703. var offset = this._dashOffset;
  11704. var lineDash = this._lineDash;
  11705. var ctx = this._ctx;
  11706. var x0 = this._xi;
  11707. var y0 = this._yi;
  11708. var dx = x1 - x0;
  11709. var dy = y1 - y0;
  11710. var dist = mathSqrt(dx * dx + dy * dy);
  11711. var x = x0;
  11712. var y = y0;
  11713. var dash;
  11714. var nDash = lineDash.length;
  11715. var idx;
  11716. dx /= dist;
  11717. dy /= dist;
  11718. if (offset < 0) {
  11719. // Convert to positive offset
  11720. offset = dashSum + offset;
  11721. }
  11722. offset %= dashSum;
  11723. x -= offset * dx;
  11724. y -= offset * dy;
  11725. while ((dx > 0 && x <= x1) || (dx < 0 && x >= x1)
  11726. || (dx == 0 && ((dy > 0 && y <= y1) || (dy < 0 && y >= y1)))) {
  11727. idx = this._dashIdx;
  11728. dash = lineDash[idx];
  11729. x += dx * dash;
  11730. y += dy * dash;
  11731. this._dashIdx = (idx + 1) % nDash;
  11732. // Skip positive offset
  11733. if ((dx > 0 && x < x0) || (dx < 0 && x > x0) || (dy > 0 && y < y0) || (dy < 0 && y > y0)) {
  11734. continue;
  11735. }
  11736. ctx[idx % 2 ? 'moveTo' : 'lineTo'](
  11737. dx >= 0 ? mathMin(x, x1) : mathMax(x, x1),
  11738. dy >= 0 ? mathMin(y, y1) : mathMax(y, y1)
  11739. );
  11740. }
  11741. // Offset for next lineTo
  11742. dx = x - x1;
  11743. dy = y - y1;
  11744. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  11745. },
  11746. // Not accurate dashed line to
  11747. _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) {
  11748. var dashSum = this._dashSum;
  11749. var offset = this._dashOffset;
  11750. var lineDash = this._lineDash;
  11751. var ctx = this._ctx;
  11752. var x0 = this._xi;
  11753. var y0 = this._yi;
  11754. var t;
  11755. var dx;
  11756. var dy;
  11757. var cubicAt = curve.cubicAt;
  11758. var bezierLen = 0;
  11759. var idx = this._dashIdx;
  11760. var nDash = lineDash.length;
  11761. var x;
  11762. var y;
  11763. var tmpLen = 0;
  11764. if (offset < 0) {
  11765. // Convert to positive offset
  11766. offset = dashSum + offset;
  11767. }
  11768. offset %= dashSum;
  11769. // Bezier approx length
  11770. for (t = 0; t < 1; t += 0.1) {
  11771. dx = cubicAt(x0, x1, x2, x3, t + 0.1)
  11772. - cubicAt(x0, x1, x2, x3, t);
  11773. dy = cubicAt(y0, y1, y2, y3, t + 0.1)
  11774. - cubicAt(y0, y1, y2, y3, t);
  11775. bezierLen += mathSqrt(dx * dx + dy * dy);
  11776. }
  11777. // Find idx after add offset
  11778. for (; idx < nDash; idx++) {
  11779. tmpLen += lineDash[idx];
  11780. if (tmpLen > offset) {
  11781. break;
  11782. }
  11783. }
  11784. t = (tmpLen - offset) / bezierLen;
  11785. while (t <= 1) {
  11786. x = cubicAt(x0, x1, x2, x3, t);
  11787. y = cubicAt(y0, y1, y2, y3, t);
  11788. // Use line to approximate dashed bezier
  11789. // Bad result if dash is long
  11790. idx % 2 ? ctx.moveTo(x, y)
  11791. : ctx.lineTo(x, y);
  11792. t += lineDash[idx] / bezierLen;
  11793. idx = (idx + 1) % nDash;
  11794. }
  11795. // Finish the last segment and calculate the new offset
  11796. (idx % 2 !== 0) && ctx.lineTo(x3, y3);
  11797. dx = x3 - x;
  11798. dy = y3 - y;
  11799. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  11800. },
  11801. _dashedQuadraticTo: function (x1, y1, x2, y2) {
  11802. // Convert quadratic to cubic using degree elevation
  11803. var x3 = x2;
  11804. var y3 = y2;
  11805. x2 = (x2 + 2 * x1) / 3;
  11806. y2 = (y2 + 2 * y1) / 3;
  11807. x1 = (this._xi + 2 * x1) / 3;
  11808. y1 = (this._yi + 2 * y1) / 3;
  11809. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  11810. },
  11811. /**
  11812. * 转成静态的 Float32Array 减少堆内存占用
  11813. * Convert dynamic array to static Float32Array
  11814. */
  11815. toStatic: function () {
  11816. var data = this.data;
  11817. if (data instanceof Array) {
  11818. data.length = this._len;
  11819. if (hasTypedArray) {
  11820. this.data = new Float32Array(data);
  11821. }
  11822. }
  11823. },
  11824. /**
  11825. * @return {module:zrender/core/BoundingRect}
  11826. */
  11827. getBoundingRect: function () {
  11828. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  11829. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  11830. var data = this.data;
  11831. var xi = 0;
  11832. var yi = 0;
  11833. var x0 = 0;
  11834. var y0 = 0;
  11835. for (var i = 0; i < data.length;) {
  11836. var cmd = data[i++];
  11837. if (i == 1) {
  11838. // 如果第一个命令是 L, C, Q
  11839. // 则 previous point 同绘制命令的第一个 point
  11840. //
  11841. // 第一个命令为 Arc 的情况下会在后面特殊处理
  11842. xi = data[i];
  11843. yi = data[i + 1];
  11844. x0 = xi;
  11845. y0 = yi;
  11846. }
  11847. switch (cmd) {
  11848. case CMD.M:
  11849. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  11850. // 在 closePath 的时候使用
  11851. x0 = data[i++];
  11852. y0 = data[i++];
  11853. xi = x0;
  11854. yi = y0;
  11855. min2[0] = x0;
  11856. min2[1] = y0;
  11857. max2[0] = x0;
  11858. max2[1] = y0;
  11859. break;
  11860. case CMD.L:
  11861. bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  11862. xi = data[i++];
  11863. yi = data[i++];
  11864. break;
  11865. case CMD.C:
  11866. bbox.fromCubic(
  11867. xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11868. min2, max2
  11869. );
  11870. xi = data[i++];
  11871. yi = data[i++];
  11872. break;
  11873. case CMD.Q:
  11874. bbox.fromQuadratic(
  11875. xi, yi, data[i++], data[i++], data[i], data[i + 1],
  11876. min2, max2
  11877. );
  11878. xi = data[i++];
  11879. yi = data[i++];
  11880. break;
  11881. case CMD.A:
  11882. // TODO Arc 判断的开销比较大
  11883. var cx = data[i++];
  11884. var cy = data[i++];
  11885. var rx = data[i++];
  11886. var ry = data[i++];
  11887. var startAngle = data[i++];
  11888. var endAngle = data[i++] + startAngle;
  11889. // TODO Arc 旋转
  11890. var psi = data[i++];
  11891. var anticlockwise = 1 - data[i++];
  11892. if (i == 1) {
  11893. // 直接使用 arc 命令
  11894. // 第一个命令起点还未定义
  11895. x0 = mathCos(startAngle) * rx + cx;
  11896. y0 = mathSin(startAngle) * ry + cy;
  11897. }
  11898. bbox.fromArc(
  11899. cx, cy, rx, ry, startAngle, endAngle,
  11900. anticlockwise, min2, max2
  11901. );
  11902. xi = mathCos(endAngle) * rx + cx;
  11903. yi = mathSin(endAngle) * ry + cy;
  11904. break;
  11905. case CMD.R:
  11906. x0 = xi = data[i++];
  11907. y0 = yi = data[i++];
  11908. var width = data[i++];
  11909. var height = data[i++];
  11910. // Use fromLine
  11911. bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  11912. break;
  11913. case CMD.Z:
  11914. xi = x0;
  11915. yi = y0;
  11916. break;
  11917. }
  11918. // Union
  11919. vec2.min(min, min, min2);
  11920. vec2.max(max, max, max2);
  11921. }
  11922. // No data
  11923. if (i === 0) {
  11924. min[0] = min[1] = max[0] = max[1] = 0;
  11925. }
  11926. return new BoundingRect(
  11927. min[0], min[1], max[0] - min[0], max[1] - min[1]
  11928. );
  11929. },
  11930. /**
  11931. * Rebuild path from current data
  11932. * Rebuild path will not consider javascript implemented line dash.
  11933. * @param {CanvasRenderingContext} ctx
  11934. */
  11935. rebuildPath: function (ctx) {
  11936. var d = this.data;
  11937. var x0, y0;
  11938. var xi, yi;
  11939. var x, y;
  11940. var ux = this._ux;
  11941. var uy = this._uy;
  11942. var len = this._len;
  11943. for (var i = 0; i < len;) {
  11944. var cmd = d[i++];
  11945. if (i == 1) {
  11946. // 如果第一个命令是 L, C, Q
  11947. // 则 previous point 同绘制命令的第一个 point
  11948. //
  11949. // 第一个命令为 Arc 的情况下会在后面特殊处理
  11950. xi = d[i];
  11951. yi = d[i + 1];
  11952. x0 = xi;
  11953. y0 = yi;
  11954. }
  11955. switch (cmd) {
  11956. case CMD.M:
  11957. x0 = xi = d[i++];
  11958. y0 = yi = d[i++];
  11959. ctx.moveTo(xi, yi);
  11960. break;
  11961. case CMD.L:
  11962. x = d[i++];
  11963. y = d[i++];
  11964. // Not draw too small seg between
  11965. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
  11966. ctx.lineTo(x, y);
  11967. xi = x;
  11968. yi = y;
  11969. }
  11970. break;
  11971. case CMD.C:
  11972. ctx.bezierCurveTo(
  11973. d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]
  11974. );
  11975. xi = d[i - 2];
  11976. yi = d[i - 1];
  11977. break;
  11978. case CMD.Q:
  11979. ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
  11980. xi = d[i - 2];
  11981. yi = d[i - 1];
  11982. break;
  11983. case CMD.A:
  11984. var cx = d[i++];
  11985. var cy = d[i++];
  11986. var rx = d[i++];
  11987. var ry = d[i++];
  11988. var theta = d[i++];
  11989. var dTheta = d[i++];
  11990. var psi = d[i++];
  11991. var fs = d[i++];
  11992. var r = (rx > ry) ? rx : ry;
  11993. var scaleX = (rx > ry) ? 1 : rx / ry;
  11994. var scaleY = (rx > ry) ? ry / rx : 1;
  11995. var isEllipse = Math.abs(rx - ry) > 1e-3;
  11996. var endAngle = theta + dTheta;
  11997. if (isEllipse) {
  11998. ctx.translate(cx, cy);
  11999. ctx.rotate(psi);
  12000. ctx.scale(scaleX, scaleY);
  12001. ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
  12002. ctx.scale(1 / scaleX, 1 / scaleY);
  12003. ctx.rotate(-psi);
  12004. ctx.translate(-cx, -cy);
  12005. }
  12006. else {
  12007. ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
  12008. }
  12009. if (i == 1) {
  12010. // 直接使用 arc 命令
  12011. // 第一个命令起点还未定义
  12012. x0 = mathCos(theta) * rx + cx;
  12013. y0 = mathSin(theta) * ry + cy;
  12014. }
  12015. xi = mathCos(endAngle) * rx + cx;
  12016. yi = mathSin(endAngle) * ry + cy;
  12017. break;
  12018. case CMD.R:
  12019. x0 = xi = d[i];
  12020. y0 = yi = d[i + 1];
  12021. ctx.rect(d[i++], d[i++], d[i++], d[i++]);
  12022. break;
  12023. case CMD.Z:
  12024. ctx.closePath();
  12025. xi = x0;
  12026. yi = y0;
  12027. }
  12028. }
  12029. }
  12030. };
  12031. PathProxy.CMD = CMD;
  12032. module.exports = PathProxy;
  12033. /***/ },
  12034. /* 50 */
  12035. /***/ function(module, exports, __webpack_require__) {
  12036. 'use strict';
  12037. /**
  12038. * 曲线辅助模块
  12039. * @module zrender/core/curve
  12040. * @author pissang(https://www.github.com/pissang)
  12041. */
  12042. var vec2 = __webpack_require__(10);
  12043. var v2Create = vec2.create;
  12044. var v2DistSquare = vec2.distSquare;
  12045. var mathPow = Math.pow;
  12046. var mathSqrt = Math.sqrt;
  12047. var EPSILON = 1e-8;
  12048. var EPSILON_NUMERIC = 1e-4;
  12049. var THREE_SQRT = mathSqrt(3);
  12050. var ONE_THIRD = 1 / 3;
  12051. // 临时变量
  12052. var _v0 = v2Create();
  12053. var _v1 = v2Create();
  12054. var _v2 = v2Create();
  12055. // var _v3 = vec2.create();
  12056. function isAroundZero(val) {
  12057. return val > -EPSILON && val < EPSILON;
  12058. }
  12059. function isNotAroundZero(val) {
  12060. return val > EPSILON || val < -EPSILON;
  12061. }
  12062. /**
  12063. * 计算三次贝塞尔值
  12064. * @memberOf module:zrender/core/curve
  12065. * @param {number} p0
  12066. * @param {number} p1
  12067. * @param {number} p2
  12068. * @param {number} p3
  12069. * @param {number} t
  12070. * @return {number}
  12071. */
  12072. function cubicAt(p0, p1, p2, p3, t) {
  12073. var onet = 1 - t;
  12074. return onet * onet * (onet * p0 + 3 * t * p1)
  12075. + t * t * (t * p3 + 3 * onet * p2);
  12076. }
  12077. /**
  12078. * 计算三次贝塞尔导数值
  12079. * @memberOf module:zrender/core/curve
  12080. * @param {number} p0
  12081. * @param {number} p1
  12082. * @param {number} p2
  12083. * @param {number} p3
  12084. * @param {number} t
  12085. * @return {number}
  12086. */
  12087. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  12088. var onet = 1 - t;
  12089. return 3 * (
  12090. ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet
  12091. + (p3 - p2) * t * t
  12092. );
  12093. }
  12094. /**
  12095. * 计算三次贝塞尔方程根,使用盛金公式
  12096. * @memberOf module:zrender/core/curve
  12097. * @param {number} p0
  12098. * @param {number} p1
  12099. * @param {number} p2
  12100. * @param {number} p3
  12101. * @param {number} val
  12102. * @param {Array.<number>} roots
  12103. * @return {number} 有效根数目
  12104. */
  12105. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  12106. // Evaluate roots of cubic functions
  12107. var a = p3 + 3 * (p1 - p2) - p0;
  12108. var b = 3 * (p2 - p1 * 2 + p0);
  12109. var c = 3 * (p1 - p0);
  12110. var d = p0 - val;
  12111. var A = b * b - 3 * a * c;
  12112. var B = b * c - 9 * a * d;
  12113. var C = c * c - 3 * b * d;
  12114. var n = 0;
  12115. if (isAroundZero(A) && isAroundZero(B)) {
  12116. if (isAroundZero(b)) {
  12117. roots[0] = 0;
  12118. }
  12119. else {
  12120. var t1 = -c / b; //t1, t2, t3, b is not zero
  12121. if (t1 >= 0 && t1 <= 1) {
  12122. roots[n++] = t1;
  12123. }
  12124. }
  12125. }
  12126. else {
  12127. var disc = B * B - 4 * A * C;
  12128. if (isAroundZero(disc)) {
  12129. var K = B / A;
  12130. var t1 = -b / a + K; // t1, a is not zero
  12131. var t2 = -K / 2; // t2, t3
  12132. if (t1 >= 0 && t1 <= 1) {
  12133. roots[n++] = t1;
  12134. }
  12135. if (t2 >= 0 && t2 <= 1) {
  12136. roots[n++] = t2;
  12137. }
  12138. }
  12139. else if (disc > 0) {
  12140. var discSqrt = mathSqrt(disc);
  12141. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  12142. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  12143. if (Y1 < 0) {
  12144. Y1 = -mathPow(-Y1, ONE_THIRD);
  12145. }
  12146. else {
  12147. Y1 = mathPow(Y1, ONE_THIRD);
  12148. }
  12149. if (Y2 < 0) {
  12150. Y2 = -mathPow(-Y2, ONE_THIRD);
  12151. }
  12152. else {
  12153. Y2 = mathPow(Y2, ONE_THIRD);
  12154. }
  12155. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  12156. if (t1 >= 0 && t1 <= 1) {
  12157. roots[n++] = t1;
  12158. }
  12159. }
  12160. else {
  12161. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A));
  12162. var theta = Math.acos(T) / 3;
  12163. var ASqrt = mathSqrt(A);
  12164. var tmp = Math.cos(theta);
  12165. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  12166. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  12167. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  12168. if (t1 >= 0 && t1 <= 1) {
  12169. roots[n++] = t1;
  12170. }
  12171. if (t2 >= 0 && t2 <= 1) {
  12172. roots[n++] = t2;
  12173. }
  12174. if (t3 >= 0 && t3 <= 1) {
  12175. roots[n++] = t3;
  12176. }
  12177. }
  12178. }
  12179. return n;
  12180. }
  12181. /**
  12182. * 计算三次贝塞尔方程极限值的位置
  12183. * @memberOf module:zrender/core/curve
  12184. * @param {number} p0
  12185. * @param {number} p1
  12186. * @param {number} p2
  12187. * @param {number} p3
  12188. * @param {Array.<number>} extrema
  12189. * @return {number} 有效数目
  12190. */
  12191. function cubicExtrema(p0, p1, p2, p3, extrema) {
  12192. var b = 6 * p2 - 12 * p1 + 6 * p0;
  12193. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  12194. var c = 3 * p1 - 3 * p0;
  12195. var n = 0;
  12196. if (isAroundZero(a)) {
  12197. if (isNotAroundZero(b)) {
  12198. var t1 = -c / b;
  12199. if (t1 >= 0 && t1 <=1) {
  12200. extrema[n++] = t1;
  12201. }
  12202. }
  12203. }
  12204. else {
  12205. var disc = b * b - 4 * a * c;
  12206. if (isAroundZero(disc)) {
  12207. extrema[0] = -b / (2 * a);
  12208. }
  12209. else if (disc > 0) {
  12210. var discSqrt = mathSqrt(disc);
  12211. var t1 = (-b + discSqrt) / (2 * a);
  12212. var t2 = (-b - discSqrt) / (2 * a);
  12213. if (t1 >= 0 && t1 <= 1) {
  12214. extrema[n++] = t1;
  12215. }
  12216. if (t2 >= 0 && t2 <= 1) {
  12217. extrema[n++] = t2;
  12218. }
  12219. }
  12220. }
  12221. return n;
  12222. }
  12223. /**
  12224. * 细分三次贝塞尔曲线
  12225. * @memberOf module:zrender/core/curve
  12226. * @param {number} p0
  12227. * @param {number} p1
  12228. * @param {number} p2
  12229. * @param {number} p3
  12230. * @param {number} t
  12231. * @param {Array.<number>} out
  12232. */
  12233. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  12234. var p01 = (p1 - p0) * t + p0;
  12235. var p12 = (p2 - p1) * t + p1;
  12236. var p23 = (p3 - p2) * t + p2;
  12237. var p012 = (p12 - p01) * t + p01;
  12238. var p123 = (p23 - p12) * t + p12;
  12239. var p0123 = (p123 - p012) * t + p012;
  12240. // Seg0
  12241. out[0] = p0;
  12242. out[1] = p01;
  12243. out[2] = p012;
  12244. out[3] = p0123;
  12245. // Seg1
  12246. out[4] = p0123;
  12247. out[5] = p123;
  12248. out[6] = p23;
  12249. out[7] = p3;
  12250. }
  12251. /**
  12252. * 投射点到三次贝塞尔曲线上,返回投射距离。
  12253. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  12254. * @param {number} x0
  12255. * @param {number} y0
  12256. * @param {number} x1
  12257. * @param {number} y1
  12258. * @param {number} x2
  12259. * @param {number} y2
  12260. * @param {number} x3
  12261. * @param {number} y3
  12262. * @param {number} x
  12263. * @param {number} y
  12264. * @param {Array.<number>} [out] 投射点
  12265. * @return {number}
  12266. */
  12267. function cubicProjectPoint(
  12268. x0, y0, x1, y1, x2, y2, x3, y3,
  12269. x, y, out
  12270. ) {
  12271. // http://pomax.github.io/bezierinfo/#projections
  12272. var t;
  12273. var interval = 0.005;
  12274. var d = Infinity;
  12275. var prev;
  12276. var next;
  12277. var d1;
  12278. var d2;
  12279. _v0[0] = x;
  12280. _v0[1] = y;
  12281. // 先粗略估计一下可能的最小距离的 t 值
  12282. // PENDING
  12283. for (var _t = 0; _t < 1; _t += 0.05) {
  12284. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  12285. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  12286. d1 = v2DistSquare(_v0, _v1);
  12287. if (d1 < d) {
  12288. t = _t;
  12289. d = d1;
  12290. }
  12291. }
  12292. d = Infinity;
  12293. // At most 32 iteration
  12294. for (var i = 0; i < 32; i++) {
  12295. if (interval < EPSILON_NUMERIC) {
  12296. break;
  12297. }
  12298. prev = t - interval;
  12299. next = t + interval;
  12300. // t - interval
  12301. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  12302. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  12303. d1 = v2DistSquare(_v1, _v0);
  12304. if (prev >= 0 && d1 < d) {
  12305. t = prev;
  12306. d = d1;
  12307. }
  12308. else {
  12309. // t + interval
  12310. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  12311. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  12312. d2 = v2DistSquare(_v2, _v0);
  12313. if (next <= 1 && d2 < d) {
  12314. t = next;
  12315. d = d2;
  12316. }
  12317. else {
  12318. interval *= 0.5;
  12319. }
  12320. }
  12321. }
  12322. // t
  12323. if (out) {
  12324. out[0] = cubicAt(x0, x1, x2, x3, t);
  12325. out[1] = cubicAt(y0, y1, y2, y3, t);
  12326. }
  12327. // console.log(interval, i);
  12328. return mathSqrt(d);
  12329. }
  12330. /**
  12331. * 计算二次方贝塞尔值
  12332. * @param {number} p0
  12333. * @param {number} p1
  12334. * @param {number} p2
  12335. * @param {number} t
  12336. * @return {number}
  12337. */
  12338. function quadraticAt(p0, p1, p2, t) {
  12339. var onet = 1 - t;
  12340. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  12341. }
  12342. /**
  12343. * 计算二次方贝塞尔导数值
  12344. * @param {number} p0
  12345. * @param {number} p1
  12346. * @param {number} p2
  12347. * @param {number} t
  12348. * @return {number}
  12349. */
  12350. function quadraticDerivativeAt(p0, p1, p2, t) {
  12351. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  12352. }
  12353. /**
  12354. * 计算二次方贝塞尔方程根
  12355. * @param {number} p0
  12356. * @param {number} p1
  12357. * @param {number} p2
  12358. * @param {number} t
  12359. * @param {Array.<number>} roots
  12360. * @return {number} 有效根数目
  12361. */
  12362. function quadraticRootAt(p0, p1, p2, val, roots) {
  12363. var a = p0 - 2 * p1 + p2;
  12364. var b = 2 * (p1 - p0);
  12365. var c = p0 - val;
  12366. var n = 0;
  12367. if (isAroundZero(a)) {
  12368. if (isNotAroundZero(b)) {
  12369. var t1 = -c / b;
  12370. if (t1 >= 0 && t1 <= 1) {
  12371. roots[n++] = t1;
  12372. }
  12373. }
  12374. }
  12375. else {
  12376. var disc = b * b - 4 * a * c;
  12377. if (isAroundZero(disc)) {
  12378. var t1 = -b / (2 * a);
  12379. if (t1 >= 0 && t1 <= 1) {
  12380. roots[n++] = t1;
  12381. }
  12382. }
  12383. else if (disc > 0) {
  12384. var discSqrt = mathSqrt(disc);
  12385. var t1 = (-b + discSqrt) / (2 * a);
  12386. var t2 = (-b - discSqrt) / (2 * a);
  12387. if (t1 >= 0 && t1 <= 1) {
  12388. roots[n++] = t1;
  12389. }
  12390. if (t2 >= 0 && t2 <= 1) {
  12391. roots[n++] = t2;
  12392. }
  12393. }
  12394. }
  12395. return n;
  12396. }
  12397. /**
  12398. * 计算二次贝塞尔方程极限值
  12399. * @memberOf module:zrender/core/curve
  12400. * @param {number} p0
  12401. * @param {number} p1
  12402. * @param {number} p2
  12403. * @return {number}
  12404. */
  12405. function quadraticExtremum(p0, p1, p2) {
  12406. var divider = p0 + p2 - 2 * p1;
  12407. if (divider === 0) {
  12408. // p1 is center of p0 and p2
  12409. return 0.5;
  12410. }
  12411. else {
  12412. return (p0 - p1) / divider;
  12413. }
  12414. }
  12415. /**
  12416. * 细分二次贝塞尔曲线
  12417. * @memberOf module:zrender/core/curve
  12418. * @param {number} p0
  12419. * @param {number} p1
  12420. * @param {number} p2
  12421. * @param {number} t
  12422. * @param {Array.<number>} out
  12423. */
  12424. function quadraticSubdivide(p0, p1, p2, t, out) {
  12425. var p01 = (p1 - p0) * t + p0;
  12426. var p12 = (p2 - p1) * t + p1;
  12427. var p012 = (p12 - p01) * t + p01;
  12428. // Seg0
  12429. out[0] = p0;
  12430. out[1] = p01;
  12431. out[2] = p012;
  12432. // Seg1
  12433. out[3] = p012;
  12434. out[4] = p12;
  12435. out[5] = p2;
  12436. }
  12437. /**
  12438. * 投射点到二次贝塞尔曲线上,返回投射距离。
  12439. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  12440. * @param {number} x0
  12441. * @param {number} y0
  12442. * @param {number} x1
  12443. * @param {number} y1
  12444. * @param {number} x2
  12445. * @param {number} y2
  12446. * @param {number} x
  12447. * @param {number} y
  12448. * @param {Array.<number>} out 投射点
  12449. * @return {number}
  12450. */
  12451. function quadraticProjectPoint(
  12452. x0, y0, x1, y1, x2, y2,
  12453. x, y, out
  12454. ) {
  12455. // http://pomax.github.io/bezierinfo/#projections
  12456. var t;
  12457. var interval = 0.005;
  12458. var d = Infinity;
  12459. _v0[0] = x;
  12460. _v0[1] = y;
  12461. // 先粗略估计一下可能的最小距离的 t 值
  12462. // PENDING
  12463. for (var _t = 0; _t < 1; _t += 0.05) {
  12464. _v1[0] = quadraticAt(x0, x1, x2, _t);
  12465. _v1[1] = quadraticAt(y0, y1, y2, _t);
  12466. var d1 = v2DistSquare(_v0, _v1);
  12467. if (d1 < d) {
  12468. t = _t;
  12469. d = d1;
  12470. }
  12471. }
  12472. d = Infinity;
  12473. // At most 32 iteration
  12474. for (var i = 0; i < 32; i++) {
  12475. if (interval < EPSILON_NUMERIC) {
  12476. break;
  12477. }
  12478. var prev = t - interval;
  12479. var next = t + interval;
  12480. // t - interval
  12481. _v1[0] = quadraticAt(x0, x1, x2, prev);
  12482. _v1[1] = quadraticAt(y0, y1, y2, prev);
  12483. var d1 = v2DistSquare(_v1, _v0);
  12484. if (prev >= 0 && d1 < d) {
  12485. t = prev;
  12486. d = d1;
  12487. }
  12488. else {
  12489. // t + interval
  12490. _v2[0] = quadraticAt(x0, x1, x2, next);
  12491. _v2[1] = quadraticAt(y0, y1, y2, next);
  12492. var d2 = v2DistSquare(_v2, _v0);
  12493. if (next <= 1 && d2 < d) {
  12494. t = next;
  12495. d = d2;
  12496. }
  12497. else {
  12498. interval *= 0.5;
  12499. }
  12500. }
  12501. }
  12502. // t
  12503. if (out) {
  12504. out[0] = quadraticAt(x0, x1, x2, t);
  12505. out[1] = quadraticAt(y0, y1, y2, t);
  12506. }
  12507. // console.log(interval, i);
  12508. return mathSqrt(d);
  12509. }
  12510. module.exports = {
  12511. cubicAt: cubicAt,
  12512. cubicDerivativeAt: cubicDerivativeAt,
  12513. cubicRootAt: cubicRootAt,
  12514. cubicExtrema: cubicExtrema,
  12515. cubicSubdivide: cubicSubdivide,
  12516. cubicProjectPoint: cubicProjectPoint,
  12517. quadraticAt: quadraticAt,
  12518. quadraticDerivativeAt: quadraticDerivativeAt,
  12519. quadraticRootAt: quadraticRootAt,
  12520. quadraticExtremum: quadraticExtremum,
  12521. quadraticSubdivide: quadraticSubdivide,
  12522. quadraticProjectPoint: quadraticProjectPoint
  12523. };
  12524. /***/ },
  12525. /* 51 */
  12526. /***/ function(module, exports, __webpack_require__) {
  12527. /**
  12528. * @author Yi Shen(https://github.com/pissang)
  12529. */
  12530. var vec2 = __webpack_require__(10);
  12531. var curve = __webpack_require__(50);
  12532. var bbox = {};
  12533. var mathMin = Math.min;
  12534. var mathMax = Math.max;
  12535. var mathSin = Math.sin;
  12536. var mathCos = Math.cos;
  12537. var start = vec2.create();
  12538. var end = vec2.create();
  12539. var extremity = vec2.create();
  12540. var PI2 = Math.PI * 2;
  12541. /**
  12542. * 从顶点数组中计算出最小包围盒,写入`min`和`max`中
  12543. * @module zrender/core/bbox
  12544. * @param {Array<Object>} points 顶点数组
  12545. * @param {number} min
  12546. * @param {number} max
  12547. */
  12548. bbox.fromPoints = function(points, min, max) {
  12549. if (points.length === 0) {
  12550. return;
  12551. }
  12552. var p = points[0];
  12553. var left = p[0];
  12554. var right = p[0];
  12555. var top = p[1];
  12556. var bottom = p[1];
  12557. var i;
  12558. for (i = 1; i < points.length; i++) {
  12559. p = points[i];
  12560. left = mathMin(left, p[0]);
  12561. right = mathMax(right, p[0]);
  12562. top = mathMin(top, p[1]);
  12563. bottom = mathMax(bottom, p[1]);
  12564. }
  12565. min[0] = left;
  12566. min[1] = top;
  12567. max[0] = right;
  12568. max[1] = bottom;
  12569. };
  12570. /**
  12571. * @memberOf module:zrender/core/bbox
  12572. * @param {number} x0
  12573. * @param {number} y0
  12574. * @param {number} x1
  12575. * @param {number} y1
  12576. * @param {Array.<number>} min
  12577. * @param {Array.<number>} max
  12578. */
  12579. bbox.fromLine = function (x0, y0, x1, y1, min, max) {
  12580. min[0] = mathMin(x0, x1);
  12581. min[1] = mathMin(y0, y1);
  12582. max[0] = mathMax(x0, x1);
  12583. max[1] = mathMax(y0, y1);
  12584. };
  12585. var xDim = [];
  12586. var yDim = [];
  12587. /**
  12588. * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中
  12589. * @memberOf module:zrender/core/bbox
  12590. * @param {number} x0
  12591. * @param {number} y0
  12592. * @param {number} x1
  12593. * @param {number} y1
  12594. * @param {number} x2
  12595. * @param {number} y2
  12596. * @param {number} x3
  12597. * @param {number} y3
  12598. * @param {Array.<number>} min
  12599. * @param {Array.<number>} max
  12600. */
  12601. bbox.fromCubic = function(
  12602. x0, y0, x1, y1, x2, y2, x3, y3, min, max
  12603. ) {
  12604. var cubicExtrema = curve.cubicExtrema;
  12605. var cubicAt = curve.cubicAt;
  12606. var i;
  12607. var n = cubicExtrema(x0, x1, x2, x3, xDim);
  12608. min[0] = Infinity;
  12609. min[1] = Infinity;
  12610. max[0] = -Infinity;
  12611. max[1] = -Infinity;
  12612. for (i = 0; i < n; i++) {
  12613. var x = cubicAt(x0, x1, x2, x3, xDim[i]);
  12614. min[0] = mathMin(x, min[0]);
  12615. max[0] = mathMax(x, max[0]);
  12616. }
  12617. n = cubicExtrema(y0, y1, y2, y3, yDim);
  12618. for (i = 0; i < n; i++) {
  12619. var y = cubicAt(y0, y1, y2, y3, yDim[i]);
  12620. min[1] = mathMin(y, min[1]);
  12621. max[1] = mathMax(y, max[1]);
  12622. }
  12623. min[0] = mathMin(x0, min[0]);
  12624. max[0] = mathMax(x0, max[0]);
  12625. min[0] = mathMin(x3, min[0]);
  12626. max[0] = mathMax(x3, max[0]);
  12627. min[1] = mathMin(y0, min[1]);
  12628. max[1] = mathMax(y0, max[1]);
  12629. min[1] = mathMin(y3, min[1]);
  12630. max[1] = mathMax(y3, max[1]);
  12631. };
  12632. /**
  12633. * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中
  12634. * @memberOf module:zrender/core/bbox
  12635. * @param {number} x0
  12636. * @param {number} y0
  12637. * @param {number} x1
  12638. * @param {number} y1
  12639. * @param {number} x2
  12640. * @param {number} y2
  12641. * @param {Array.<number>} min
  12642. * @param {Array.<number>} max
  12643. */
  12644. bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) {
  12645. var quadraticExtremum = curve.quadraticExtremum;
  12646. var quadraticAt = curve.quadraticAt;
  12647. // Find extremities, where derivative in x dim or y dim is zero
  12648. var tx =
  12649. mathMax(
  12650. mathMin(quadraticExtremum(x0, x1, x2), 1), 0
  12651. );
  12652. var ty =
  12653. mathMax(
  12654. mathMin(quadraticExtremum(y0, y1, y2), 1), 0
  12655. );
  12656. var x = quadraticAt(x0, x1, x2, tx);
  12657. var y = quadraticAt(y0, y1, y2, ty);
  12658. min[0] = mathMin(x0, x2, x);
  12659. min[1] = mathMin(y0, y2, y);
  12660. max[0] = mathMax(x0, x2, x);
  12661. max[1] = mathMax(y0, y2, y);
  12662. };
  12663. /**
  12664. * 从圆弧中计算出最小包围盒,写入`min`和`max`中
  12665. * @method
  12666. * @memberOf module:zrender/core/bbox
  12667. * @param {number} x
  12668. * @param {number} y
  12669. * @param {number} rx
  12670. * @param {number} ry
  12671. * @param {number} startAngle
  12672. * @param {number} endAngle
  12673. * @param {number} anticlockwise
  12674. * @param {Array.<number>} min
  12675. * @param {Array.<number>} max
  12676. */
  12677. bbox.fromArc = function (
  12678. x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max
  12679. ) {
  12680. var vec2Min = vec2.min;
  12681. var vec2Max = vec2.max;
  12682. var diff = Math.abs(startAngle - endAngle);
  12683. if (diff % PI2 < 1e-4 && diff > 1e-4) {
  12684. // Is a circle
  12685. min[0] = x - rx;
  12686. min[1] = y - ry;
  12687. max[0] = x + rx;
  12688. max[1] = y + ry;
  12689. return;
  12690. }
  12691. start[0] = mathCos(startAngle) * rx + x;
  12692. start[1] = mathSin(startAngle) * ry + y;
  12693. end[0] = mathCos(endAngle) * rx + x;
  12694. end[1] = mathSin(endAngle) * ry + y;
  12695. vec2Min(min, start, end);
  12696. vec2Max(max, start, end);
  12697. // Thresh to [0, Math.PI * 2]
  12698. startAngle = startAngle % (PI2);
  12699. if (startAngle < 0) {
  12700. startAngle = startAngle + PI2;
  12701. }
  12702. endAngle = endAngle % (PI2);
  12703. if (endAngle < 0) {
  12704. endAngle = endAngle + PI2;
  12705. }
  12706. if (startAngle > endAngle && !anticlockwise) {
  12707. endAngle += PI2;
  12708. }
  12709. else if (startAngle < endAngle && anticlockwise) {
  12710. startAngle += PI2;
  12711. }
  12712. if (anticlockwise) {
  12713. var tmp = endAngle;
  12714. endAngle = startAngle;
  12715. startAngle = tmp;
  12716. }
  12717. // var number = 0;
  12718. // var step = (anticlockwise ? -Math.PI : Math.PI) / 2;
  12719. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  12720. if (angle > startAngle) {
  12721. extremity[0] = mathCos(angle) * rx + x;
  12722. extremity[1] = mathSin(angle) * ry + y;
  12723. vec2Min(min, extremity, min);
  12724. vec2Max(max, extremity, max);
  12725. }
  12726. }
  12727. };
  12728. module.exports = bbox;
  12729. /***/ },
  12730. /* 52 */
  12731. /***/ function(module, exports, __webpack_require__) {
  12732. 'use strict';
  12733. var CMD = __webpack_require__(49).CMD;
  12734. var line = __webpack_require__(53);
  12735. var cubic = __webpack_require__(54);
  12736. var quadratic = __webpack_require__(55);
  12737. var arc = __webpack_require__(56);
  12738. var normalizeRadian = __webpack_require__(57).normalizeRadian;
  12739. var curve = __webpack_require__(50);
  12740. var windingLine = __webpack_require__(58);
  12741. var containStroke = line.containStroke;
  12742. var PI2 = Math.PI * 2;
  12743. var EPSILON = 1e-4;
  12744. function isAroundEqual(a, b) {
  12745. return Math.abs(a - b) < EPSILON;
  12746. }
  12747. // 临时数组
  12748. var roots = [-1, -1, -1];
  12749. var extrema = [-1, -1];
  12750. function swapExtrema() {
  12751. var tmp = extrema[0];
  12752. extrema[0] = extrema[1];
  12753. extrema[1] = tmp;
  12754. }
  12755. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  12756. // Quick reject
  12757. if (
  12758. (y > y0 && y > y1 && y > y2 && y > y3)
  12759. || (y < y0 && y < y1 && y < y2 && y < y3)
  12760. ) {
  12761. return 0;
  12762. }
  12763. var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
  12764. if (nRoots === 0) {
  12765. return 0;
  12766. }
  12767. else {
  12768. var w = 0;
  12769. var nExtrema = -1;
  12770. var y0_, y1_;
  12771. for (var i = 0; i < nRoots; i++) {
  12772. var t = roots[i];
  12773. // Avoid winding error when intersection point is the connect point of two line of polygon
  12774. var unit = (t === 0 || t === 1) ? 0.5 : 1;
  12775. var x_ = curve.cubicAt(x0, x1, x2, x3, t);
  12776. if (x_ < x) { // Quick reject
  12777. continue;
  12778. }
  12779. if (nExtrema < 0) {
  12780. nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
  12781. if (extrema[1] < extrema[0] && nExtrema > 1) {
  12782. swapExtrema();
  12783. }
  12784. y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
  12785. if (nExtrema > 1) {
  12786. y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
  12787. }
  12788. }
  12789. if (nExtrema == 2) {
  12790. // 分成三段单调函数
  12791. if (t < extrema[0]) {
  12792. w += y0_ < y0 ? unit : -unit;
  12793. }
  12794. else if (t < extrema[1]) {
  12795. w += y1_ < y0_ ? unit : -unit;
  12796. }
  12797. else {
  12798. w += y3 < y1_ ? unit : -unit;
  12799. }
  12800. }
  12801. else {
  12802. // 分成两段单调函数
  12803. if (t < extrema[0]) {
  12804. w += y0_ < y0 ? unit : -unit;
  12805. }
  12806. else {
  12807. w += y3 < y0_ ? unit : -unit;
  12808. }
  12809. }
  12810. }
  12811. return w;
  12812. }
  12813. }
  12814. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  12815. // Quick reject
  12816. if (
  12817. (y > y0 && y > y1 && y > y2)
  12818. || (y < y0 && y < y1 && y < y2)
  12819. ) {
  12820. return 0;
  12821. }
  12822. var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
  12823. if (nRoots === 0) {
  12824. return 0;
  12825. }
  12826. else {
  12827. var t = curve.quadraticExtremum(y0, y1, y2);
  12828. if (t >= 0 && t <= 1) {
  12829. var w = 0;
  12830. var y_ = curve.quadraticAt(y0, y1, y2, t);
  12831. for (var i = 0; i < nRoots; i++) {
  12832. // Remove one endpoint.
  12833. var unit = (roots[i] === 0 || roots[i] === 1) ? 0.5 : 1;
  12834. var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
  12835. if (x_ < x) { // Quick reject
  12836. continue;
  12837. }
  12838. if (roots[i] < t) {
  12839. w += y_ < y0 ? unit : -unit;
  12840. }
  12841. else {
  12842. w += y2 < y_ ? unit : -unit;
  12843. }
  12844. }
  12845. return w;
  12846. }
  12847. else {
  12848. // Remove one endpoint.
  12849. var unit = (roots[0] === 0 || roots[0] === 1) ? 0.5 : 1;
  12850. var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
  12851. if (x_ < x) { // Quick reject
  12852. return 0;
  12853. }
  12854. return y2 < y0 ? unit : -unit;
  12855. }
  12856. }
  12857. }
  12858. // TODO
  12859. // Arc 旋转
  12860. function windingArc(
  12861. cx, cy, r, startAngle, endAngle, anticlockwise, x, y
  12862. ) {
  12863. y -= cy;
  12864. if (y > r || y < -r) {
  12865. return 0;
  12866. }
  12867. var tmp = Math.sqrt(r * r - y * y);
  12868. roots[0] = -tmp;
  12869. roots[1] = tmp;
  12870. var diff = Math.abs(startAngle - endAngle);
  12871. if (diff < 1e-4) {
  12872. return 0;
  12873. }
  12874. if (diff % PI2 < 1e-4) {
  12875. // Is a circle
  12876. startAngle = 0;
  12877. endAngle = PI2;
  12878. var dir = anticlockwise ? 1 : -1;
  12879. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  12880. return dir;
  12881. } else {
  12882. return 0;
  12883. }
  12884. }
  12885. if (anticlockwise) {
  12886. var tmp = startAngle;
  12887. startAngle = normalizeRadian(endAngle);
  12888. endAngle = normalizeRadian(tmp);
  12889. }
  12890. else {
  12891. startAngle = normalizeRadian(startAngle);
  12892. endAngle = normalizeRadian(endAngle);
  12893. }
  12894. if (startAngle > endAngle) {
  12895. endAngle += PI2;
  12896. }
  12897. var w = 0;
  12898. for (var i = 0; i < 2; i++) {
  12899. var x_ = roots[i];
  12900. if (x_ + cx > x) {
  12901. var angle = Math.atan2(y, x_);
  12902. var dir = anticlockwise ? 1 : -1;
  12903. if (angle < 0) {
  12904. angle = PI2 + angle;
  12905. }
  12906. if (
  12907. (angle >= startAngle && angle <= endAngle)
  12908. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle)
  12909. ) {
  12910. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  12911. dir = -dir;
  12912. }
  12913. w += dir;
  12914. }
  12915. }
  12916. }
  12917. return w;
  12918. }
  12919. function containPath(data, lineWidth, isStroke, x, y) {
  12920. var w = 0;
  12921. var xi = 0;
  12922. var yi = 0;
  12923. var x0 = 0;
  12924. var y0 = 0;
  12925. for (var i = 0; i < data.length;) {
  12926. var cmd = data[i++];
  12927. // Begin a new subpath
  12928. if (cmd === CMD.M && i > 1) {
  12929. // Close previous subpath
  12930. if (!isStroke) {
  12931. w += windingLine(xi, yi, x0, y0, x, y);
  12932. }
  12933. // 如果被任何一个 subpath 包含
  12934. // if (w !== 0) {
  12935. // return true;
  12936. // }
  12937. }
  12938. if (i == 1) {
  12939. // 如果第一个命令是 L, C, Q
  12940. // 则 previous point 同绘制命令的第一个 point
  12941. //
  12942. // 第一个命令为 Arc 的情况下会在后面特殊处理
  12943. xi = data[i];
  12944. yi = data[i + 1];
  12945. x0 = xi;
  12946. y0 = yi;
  12947. }
  12948. switch (cmd) {
  12949. case CMD.M:
  12950. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  12951. // 在 closePath 的时候使用
  12952. x0 = data[i++];
  12953. y0 = data[i++];
  12954. xi = x0;
  12955. yi = y0;
  12956. break;
  12957. case CMD.L:
  12958. if (isStroke) {
  12959. if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  12960. return true;
  12961. }
  12962. }
  12963. else {
  12964. // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN
  12965. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  12966. }
  12967. xi = data[i++];
  12968. yi = data[i++];
  12969. break;
  12970. case CMD.C:
  12971. if (isStroke) {
  12972. if (cubic.containStroke(xi, yi,
  12973. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  12974. lineWidth, x, y
  12975. )) {
  12976. return true;
  12977. }
  12978. }
  12979. else {
  12980. w += windingCubic(
  12981. xi, yi,
  12982. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  12983. x, y
  12984. ) || 0;
  12985. }
  12986. xi = data[i++];
  12987. yi = data[i++];
  12988. break;
  12989. case CMD.Q:
  12990. if (isStroke) {
  12991. if (quadratic.containStroke(xi, yi,
  12992. data[i++], data[i++], data[i], data[i + 1],
  12993. lineWidth, x, y
  12994. )) {
  12995. return true;
  12996. }
  12997. }
  12998. else {
  12999. w += windingQuadratic(
  13000. xi, yi,
  13001. data[i++], data[i++], data[i], data[i + 1],
  13002. x, y
  13003. ) || 0;
  13004. }
  13005. xi = data[i++];
  13006. yi = data[i++];
  13007. break;
  13008. case CMD.A:
  13009. // TODO Arc 判断的开销比较大
  13010. var cx = data[i++];
  13011. var cy = data[i++];
  13012. var rx = data[i++];
  13013. var ry = data[i++];
  13014. var theta = data[i++];
  13015. var dTheta = data[i++];
  13016. // TODO Arc 旋转
  13017. var psi = data[i++];
  13018. var anticlockwise = 1 - data[i++];
  13019. var x1 = Math.cos(theta) * rx + cx;
  13020. var y1 = Math.sin(theta) * ry + cy;
  13021. // 不是直接使用 arc 命令
  13022. if (i > 1) {
  13023. w += windingLine(xi, yi, x1, y1, x, y);
  13024. }
  13025. else {
  13026. // 第一个命令起点还未定义
  13027. x0 = x1;
  13028. y0 = y1;
  13029. }
  13030. // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  13031. var _x = (x - cx) * ry / rx + cx;
  13032. if (isStroke) {
  13033. if (arc.containStroke(
  13034. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  13035. lineWidth, _x, y
  13036. )) {
  13037. return true;
  13038. }
  13039. }
  13040. else {
  13041. w += windingArc(
  13042. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  13043. _x, y
  13044. );
  13045. }
  13046. xi = Math.cos(theta + dTheta) * rx + cx;
  13047. yi = Math.sin(theta + dTheta) * ry + cy;
  13048. break;
  13049. case CMD.R:
  13050. x0 = xi = data[i++];
  13051. y0 = yi = data[i++];
  13052. var width = data[i++];
  13053. var height = data[i++];
  13054. var x1 = x0 + width;
  13055. var y1 = y0 + height;
  13056. if (isStroke) {
  13057. if (containStroke(x0, y0, x1, y0, lineWidth, x, y)
  13058. || containStroke(x1, y0, x1, y1, lineWidth, x, y)
  13059. || containStroke(x1, y1, x0, y1, lineWidth, x, y)
  13060. || containStroke(x0, y1, x0, y0, lineWidth, x, y)
  13061. ) {
  13062. return true;
  13063. }
  13064. }
  13065. else {
  13066. // FIXME Clockwise ?
  13067. w += windingLine(x1, y0, x1, y1, x, y);
  13068. w += windingLine(x0, y1, x0, y0, x, y);
  13069. }
  13070. break;
  13071. case CMD.Z:
  13072. if (isStroke) {
  13073. if (containStroke(
  13074. xi, yi, x0, y0, lineWidth, x, y
  13075. )) {
  13076. return true;
  13077. }
  13078. }
  13079. else {
  13080. // Close a subpath
  13081. w += windingLine(xi, yi, x0, y0, x, y);
  13082. // 如果被任何一个 subpath 包含
  13083. // FIXME subpaths may overlap
  13084. // if (w !== 0) {
  13085. // return true;
  13086. // }
  13087. }
  13088. xi = x0;
  13089. yi = y0;
  13090. break;
  13091. }
  13092. }
  13093. if (!isStroke && !isAroundEqual(yi, y0)) {
  13094. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  13095. }
  13096. return w !== 0;
  13097. }
  13098. module.exports = {
  13099. contain: function (pathData, x, y) {
  13100. return containPath(pathData, 0, false, x, y);
  13101. },
  13102. containStroke: function (pathData, lineWidth, x, y) {
  13103. return containPath(pathData, lineWidth, true, x, y);
  13104. }
  13105. };
  13106. /***/ },
  13107. /* 53 */
  13108. /***/ function(module, exports) {
  13109. module.exports = {
  13110. /**
  13111. * 线段包含判断
  13112. * @param {number} x0
  13113. * @param {number} y0
  13114. * @param {number} x1
  13115. * @param {number} y1
  13116. * @param {number} lineWidth
  13117. * @param {number} x
  13118. * @param {number} y
  13119. * @return {boolean}
  13120. */
  13121. containStroke: function (x0, y0, x1, y1, lineWidth, x, y) {
  13122. if (lineWidth === 0) {
  13123. return false;
  13124. }
  13125. var _l = lineWidth;
  13126. var _a = 0;
  13127. var _b = x0;
  13128. // Quick reject
  13129. if (
  13130. (y > y0 + _l && y > y1 + _l)
  13131. || (y < y0 - _l && y < y1 - _l)
  13132. || (x > x0 + _l && x > x1 + _l)
  13133. || (x < x0 - _l && x < x1 - _l)
  13134. ) {
  13135. return false;
  13136. }
  13137. if (x0 !== x1) {
  13138. _a = (y0 - y1) / (x0 - x1);
  13139. _b = (x0 * y1 - x1 * y0) / (x0 - x1) ;
  13140. }
  13141. else {
  13142. return Math.abs(x - x0) <= _l / 2;
  13143. }
  13144. var tmp = _a * x - y + _b;
  13145. var _s = tmp * tmp / (_a * _a + 1);
  13146. return _s <= _l / 2 * _l / 2;
  13147. }
  13148. };
  13149. /***/ },
  13150. /* 54 */
  13151. /***/ function(module, exports, __webpack_require__) {
  13152. var curve = __webpack_require__(50);
  13153. module.exports = {
  13154. /**
  13155. * 三次贝塞尔曲线描边包含判断
  13156. * @param {number} x0
  13157. * @param {number} y0
  13158. * @param {number} x1
  13159. * @param {number} y1
  13160. * @param {number} x2
  13161. * @param {number} y2
  13162. * @param {number} x3
  13163. * @param {number} y3
  13164. * @param {number} lineWidth
  13165. * @param {number} x
  13166. * @param {number} y
  13167. * @return {boolean}
  13168. */
  13169. containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  13170. if (lineWidth === 0) {
  13171. return false;
  13172. }
  13173. var _l = lineWidth;
  13174. // Quick reject
  13175. if (
  13176. (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
  13177. || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
  13178. || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
  13179. || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
  13180. ) {
  13181. return false;
  13182. }
  13183. var d = curve.cubicProjectPoint(
  13184. x0, y0, x1, y1, x2, y2, x3, y3,
  13185. x, y, null
  13186. );
  13187. return d <= _l / 2;
  13188. }
  13189. };
  13190. /***/ },
  13191. /* 55 */
  13192. /***/ function(module, exports, __webpack_require__) {
  13193. var curve = __webpack_require__(50);
  13194. module.exports = {
  13195. /**
  13196. * 二次贝塞尔曲线描边包含判断
  13197. * @param {number} x0
  13198. * @param {number} y0
  13199. * @param {number} x1
  13200. * @param {number} y1
  13201. * @param {number} x2
  13202. * @param {number} y2
  13203. * @param {number} lineWidth
  13204. * @param {number} x
  13205. * @param {number} y
  13206. * @return {boolean}
  13207. */
  13208. containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  13209. if (lineWidth === 0) {
  13210. return false;
  13211. }
  13212. var _l = lineWidth;
  13213. // Quick reject
  13214. if (
  13215. (y > y0 + _l && y > y1 + _l && y > y2 + _l)
  13216. || (y < y0 - _l && y < y1 - _l && y < y2 - _l)
  13217. || (x > x0 + _l && x > x1 + _l && x > x2 + _l)
  13218. || (x < x0 - _l && x < x1 - _l && x < x2 - _l)
  13219. ) {
  13220. return false;
  13221. }
  13222. var d = curve.quadraticProjectPoint(
  13223. x0, y0, x1, y1, x2, y2,
  13224. x, y, null
  13225. );
  13226. return d <= _l / 2;
  13227. }
  13228. };
  13229. /***/ },
  13230. /* 56 */
  13231. /***/ function(module, exports, __webpack_require__) {
  13232. var normalizeRadian = __webpack_require__(57).normalizeRadian;
  13233. var PI2 = Math.PI * 2;
  13234. module.exports = {
  13235. /**
  13236. * 圆弧描边包含判断
  13237. * @param {number} cx
  13238. * @param {number} cy
  13239. * @param {number} r
  13240. * @param {number} startAngle
  13241. * @param {number} endAngle
  13242. * @param {boolean} anticlockwise
  13243. * @param {number} lineWidth
  13244. * @param {number} x
  13245. * @param {number} y
  13246. * @return {Boolean}
  13247. */
  13248. containStroke: function (
  13249. cx, cy, r, startAngle, endAngle, anticlockwise,
  13250. lineWidth, x, y
  13251. ) {
  13252. if (lineWidth === 0) {
  13253. return false;
  13254. }
  13255. var _l = lineWidth;
  13256. x -= cx;
  13257. y -= cy;
  13258. var d = Math.sqrt(x * x + y * y);
  13259. if ((d - _l > r) || (d + _l < r)) {
  13260. return false;
  13261. }
  13262. if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
  13263. // Is a circle
  13264. return true;
  13265. }
  13266. if (anticlockwise) {
  13267. var tmp = startAngle;
  13268. startAngle = normalizeRadian(endAngle);
  13269. endAngle = normalizeRadian(tmp);
  13270. } else {
  13271. startAngle = normalizeRadian(startAngle);
  13272. endAngle = normalizeRadian(endAngle);
  13273. }
  13274. if (startAngle > endAngle) {
  13275. endAngle += PI2;
  13276. }
  13277. var angle = Math.atan2(y, x);
  13278. if (angle < 0) {
  13279. angle += PI2;
  13280. }
  13281. return (angle >= startAngle && angle <= endAngle)
  13282. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle);
  13283. }
  13284. };
  13285. /***/ },
  13286. /* 57 */
  13287. /***/ function(module, exports) {
  13288. var PI2 = Math.PI * 2;
  13289. module.exports = {
  13290. normalizeRadian: function(angle) {
  13291. angle %= PI2;
  13292. if (angle < 0) {
  13293. angle += PI2;
  13294. }
  13295. return angle;
  13296. }
  13297. };
  13298. /***/ },
  13299. /* 58 */
  13300. /***/ function(module, exports) {
  13301. module.exports = function windingLine(x0, y0, x1, y1, x, y) {
  13302. if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
  13303. return 0;
  13304. }
  13305. // Ignore horizontal line
  13306. if (y1 === y0) {
  13307. return 0;
  13308. }
  13309. var dir = y1 < y0 ? 1 : -1;
  13310. var t = (y - y0) / (y1 - y0);
  13311. // Avoid winding error when intersection point is the connect point of two line of polygon
  13312. if (t === 1 || t === 0) {
  13313. dir = y1 < y0 ? 0.5 : -0.5;
  13314. }
  13315. var x_ = t * (x1 - x0) + x0;
  13316. return x_ > x ? dir : 0;
  13317. };
  13318. /***/ },
  13319. /* 59 */
  13320. /***/ function(module, exports) {
  13321. var Pattern = function (image, repeat) {
  13322. this.image = image;
  13323. this.repeat = repeat;
  13324. // Can be cloned
  13325. this.type = 'pattern';
  13326. };
  13327. Pattern.prototype.getCanvasPattern = function (ctx) {
  13328. return this._canvasPattern
  13329. || (this._canvasPattern = ctx.createPattern(this.image, this.repeat));
  13330. };
  13331. module.exports = Pattern;
  13332. /***/ },
  13333. /* 60 */
  13334. /***/ function(module, exports, __webpack_require__) {
  13335. var CMD = __webpack_require__(49).CMD;
  13336. var vec2 = __webpack_require__(10);
  13337. var v2ApplyTransform = vec2.applyTransform;
  13338. var points = [[], [], []];
  13339. var mathSqrt = Math.sqrt;
  13340. var mathAtan2 = Math.atan2;
  13341. function transformPath(path, m) {
  13342. var data = path.data;
  13343. var cmd;
  13344. var nPoint;
  13345. var i;
  13346. var j;
  13347. var k;
  13348. var p;
  13349. var M = CMD.M;
  13350. var C = CMD.C;
  13351. var L = CMD.L;
  13352. var R = CMD.R;
  13353. var A = CMD.A;
  13354. var Q = CMD.Q;
  13355. for (i = 0, j = 0; i < data.length;) {
  13356. cmd = data[i++];
  13357. j = i;
  13358. nPoint = 0;
  13359. switch (cmd) {
  13360. case M:
  13361. nPoint = 1;
  13362. break;
  13363. case L:
  13364. nPoint = 1;
  13365. break;
  13366. case C:
  13367. nPoint = 3;
  13368. break;
  13369. case Q:
  13370. nPoint = 2;
  13371. break;
  13372. case A:
  13373. var x = m[4];
  13374. var y = m[5];
  13375. var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
  13376. var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
  13377. var angle = mathAtan2(-m[1] / sy, m[0] / sx);
  13378. // cx
  13379. data[i++] += x;
  13380. // cy
  13381. data[i++] += y;
  13382. // Scale rx and ry
  13383. // FIXME Assume psi is 0 here
  13384. data[i++] *= sx;
  13385. data[i++] *= sy;
  13386. // Start angle
  13387. data[i++] += angle;
  13388. // end angle
  13389. data[i++] += angle;
  13390. // FIXME psi
  13391. i += 2;
  13392. j = i;
  13393. break;
  13394. case R:
  13395. // x0, y0
  13396. p[0] = data[i++];
  13397. p[1] = data[i++];
  13398. v2ApplyTransform(p, p, m);
  13399. data[j++] = p[0];
  13400. data[j++] = p[1];
  13401. // x1, y1
  13402. p[0] += data[i++];
  13403. p[1] += data[i++];
  13404. v2ApplyTransform(p, p, m);
  13405. data[j++] = p[0];
  13406. data[j++] = p[1];
  13407. }
  13408. for (k = 0; k < nPoint; k++) {
  13409. var p = points[k];
  13410. p[0] = data[i++];
  13411. p[1] = data[i++];
  13412. v2ApplyTransform(p, p, m);
  13413. // Write back
  13414. data[j++] = p[0];
  13415. data[j++] = p[1];
  13416. }
  13417. }
  13418. }
  13419. module.exports = transformPath;
  13420. /***/ },
  13421. /* 61 */
  13422. /***/ function(module, exports, __webpack_require__) {
  13423. /**
  13424. * Image element
  13425. * @module zrender/graphic/Image
  13426. */
  13427. var Displayable = __webpack_require__(46);
  13428. var BoundingRect = __webpack_require__(9);
  13429. var zrUtil = __webpack_require__(4);
  13430. var LRU = __webpack_require__(62);
  13431. var globalImageCache = new LRU(50);
  13432. /**
  13433. * @alias zrender/graphic/Image
  13434. * @extends module:zrender/graphic/Displayable
  13435. * @constructor
  13436. * @param {Object} opts
  13437. */
  13438. function ZImage(opts) {
  13439. Displayable.call(this, opts);
  13440. }
  13441. ZImage.prototype = {
  13442. constructor: ZImage,
  13443. type: 'image',
  13444. brush: function (ctx, prevEl) {
  13445. var style = this.style;
  13446. var src = style.image;
  13447. var image;
  13448. // Must bind each time
  13449. style.bind(ctx, this, prevEl);
  13450. // style.image is a url string
  13451. if (typeof src === 'string') {
  13452. image = this._image;
  13453. }
  13454. // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas
  13455. else {
  13456. image = src;
  13457. }
  13458. // FIXME Case create many images with src
  13459. if (!image && src) {
  13460. // Try get from global image cache
  13461. var cachedImgObj = globalImageCache.get(src);
  13462. if (!cachedImgObj) {
  13463. // Create a new image
  13464. image = new Image();
  13465. image.onload = function () {
  13466. image.onload = null;
  13467. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  13468. cachedImgObj.pending[i].dirty();
  13469. }
  13470. };
  13471. cachedImgObj = {
  13472. image: image,
  13473. pending: [this]
  13474. };
  13475. image.src = src;
  13476. globalImageCache.put(src, cachedImgObj);
  13477. this._image = image;
  13478. return;
  13479. }
  13480. else {
  13481. image = cachedImgObj.image;
  13482. this._image = image;
  13483. // Image is not complete finish, add to pending list
  13484. if (!image.width || !image.height) {
  13485. cachedImgObj.pending.push(this);
  13486. return;
  13487. }
  13488. }
  13489. }
  13490. if (image) {
  13491. // 图片已经加载完成
  13492. // if (image.nodeName.toUpperCase() == 'IMG') {
  13493. // if (!image.complete) {
  13494. // return;
  13495. // }
  13496. // }
  13497. // Else is canvas
  13498. var width = style.width || image.width;
  13499. var height = style.height || image.height;
  13500. var x = style.x || 0;
  13501. var y = style.y || 0;
  13502. // 图片加载失败
  13503. if (!image.width || !image.height) {
  13504. return;
  13505. }
  13506. // 设置transform
  13507. this.setTransform(ctx);
  13508. if (style.sWidth && style.sHeight) {
  13509. var sx = style.sx || 0;
  13510. var sy = style.sy || 0;
  13511. ctx.drawImage(
  13512. image,
  13513. sx, sy, style.sWidth, style.sHeight,
  13514. x, y, width, height
  13515. );
  13516. }
  13517. else if (style.sx && style.sy) {
  13518. var sx = style.sx;
  13519. var sy = style.sy;
  13520. var sWidth = width - sx;
  13521. var sHeight = height - sy;
  13522. ctx.drawImage(
  13523. image,
  13524. sx, sy, sWidth, sHeight,
  13525. x, y, width, height
  13526. );
  13527. }
  13528. else {
  13529. ctx.drawImage(image, x, y, width, height);
  13530. }
  13531. // 如果没设置宽和高的话自动根据图片宽高设置
  13532. if (style.width == null) {
  13533. style.width = width;
  13534. }
  13535. if (style.height == null) {
  13536. style.height = height;
  13537. }
  13538. this.restoreTransform(ctx);
  13539. // Draw rect text
  13540. if (style.text != null) {
  13541. this.drawRectText(ctx, this.getBoundingRect());
  13542. }
  13543. }
  13544. },
  13545. getBoundingRect: function () {
  13546. var style = this.style;
  13547. if (! this._rect) {
  13548. this._rect = new BoundingRect(
  13549. style.x || 0, style.y || 0, style.width || 0, style.height || 0
  13550. );
  13551. }
  13552. return this._rect;
  13553. }
  13554. };
  13555. zrUtil.inherits(ZImage, Displayable);
  13556. module.exports = ZImage;
  13557. /***/ },
  13558. /* 62 */
  13559. /***/ function(module, exports) {
  13560. // Simple LRU cache use doubly linked list
  13561. // @module zrender/core/LRU
  13562. /**
  13563. * Simple double linked list. Compared with array, it has O(1) remove operation.
  13564. * @constructor
  13565. */
  13566. var LinkedList = function() {
  13567. /**
  13568. * @type {module:zrender/core/LRU~Entry}
  13569. */
  13570. this.head = null;
  13571. /**
  13572. * @type {module:zrender/core/LRU~Entry}
  13573. */
  13574. this.tail = null;
  13575. this._len = 0;
  13576. };
  13577. var linkedListProto = LinkedList.prototype;
  13578. /**
  13579. * Insert a new value at the tail
  13580. * @param {} val
  13581. * @return {module:zrender/core/LRU~Entry}
  13582. */
  13583. linkedListProto.insert = function(val) {
  13584. var entry = new Entry(val);
  13585. this.insertEntry(entry);
  13586. return entry;
  13587. };
  13588. /**
  13589. * Insert an entry at the tail
  13590. * @param {module:zrender/core/LRU~Entry} entry
  13591. */
  13592. linkedListProto.insertEntry = function(entry) {
  13593. if (!this.head) {
  13594. this.head = this.tail = entry;
  13595. }
  13596. else {
  13597. this.tail.next = entry;
  13598. entry.prev = this.tail;
  13599. this.tail = entry;
  13600. }
  13601. this._len++;
  13602. };
  13603. /**
  13604. * Remove entry.
  13605. * @param {module:zrender/core/LRU~Entry} entry
  13606. */
  13607. linkedListProto.remove = function(entry) {
  13608. var prev = entry.prev;
  13609. var next = entry.next;
  13610. if (prev) {
  13611. prev.next = next;
  13612. }
  13613. else {
  13614. // Is head
  13615. this.head = next;
  13616. }
  13617. if (next) {
  13618. next.prev = prev;
  13619. }
  13620. else {
  13621. // Is tail
  13622. this.tail = prev;
  13623. }
  13624. entry.next = entry.prev = null;
  13625. this._len--;
  13626. };
  13627. /**
  13628. * @return {number}
  13629. */
  13630. linkedListProto.len = function() {
  13631. return this._len;
  13632. };
  13633. /**
  13634. * @constructor
  13635. * @param {} val
  13636. */
  13637. var Entry = function(val) {
  13638. /**
  13639. * @type {}
  13640. */
  13641. this.value = val;
  13642. /**
  13643. * @type {module:zrender/core/LRU~Entry}
  13644. */
  13645. this.next;
  13646. /**
  13647. * @type {module:zrender/core/LRU~Entry}
  13648. */
  13649. this.prev;
  13650. };
  13651. /**
  13652. * LRU Cache
  13653. * @constructor
  13654. * @alias module:zrender/core/LRU
  13655. */
  13656. var LRU = function(maxSize) {
  13657. this._list = new LinkedList();
  13658. this._map = {};
  13659. this._maxSize = maxSize || 10;
  13660. };
  13661. var LRUProto = LRU.prototype;
  13662. /**
  13663. * @param {string} key
  13664. * @param {} value
  13665. */
  13666. LRUProto.put = function(key, value) {
  13667. var list = this._list;
  13668. var map = this._map;
  13669. if (map[key] == null) {
  13670. var len = list.len();
  13671. if (len >= this._maxSize && len > 0) {
  13672. // Remove the least recently used
  13673. var leastUsedEntry = list.head;
  13674. list.remove(leastUsedEntry);
  13675. delete map[leastUsedEntry.key];
  13676. }
  13677. var entry = list.insert(value);
  13678. entry.key = key;
  13679. map[key] = entry;
  13680. }
  13681. };
  13682. /**
  13683. * @param {string} key
  13684. * @return {}
  13685. */
  13686. LRUProto.get = function(key) {
  13687. var entry = this._map[key];
  13688. var list = this._list;
  13689. if (entry != null) {
  13690. // Put the latest used entry in the tail
  13691. if (entry !== list.tail) {
  13692. list.remove(entry);
  13693. list.insertEntry(entry);
  13694. }
  13695. return entry.value;
  13696. }
  13697. };
  13698. /**
  13699. * Clear the cache
  13700. */
  13701. LRUProto.clear = function() {
  13702. this._list.clear();
  13703. this._map = {};
  13704. };
  13705. module.exports = LRU;
  13706. /***/ },
  13707. /* 63 */
  13708. /***/ function(module, exports, __webpack_require__) {
  13709. /**
  13710. * Text element
  13711. * @module zrender/graphic/Text
  13712. *
  13713. * TODO Wrapping
  13714. *
  13715. * Text not support gradient
  13716. */
  13717. var Displayable = __webpack_require__(46);
  13718. var zrUtil = __webpack_require__(4);
  13719. var textContain = __webpack_require__(8);
  13720. /**
  13721. * @alias zrender/graphic/Text
  13722. * @extends module:zrender/graphic/Displayable
  13723. * @constructor
  13724. * @param {Object} opts
  13725. */
  13726. var Text = function (opts) {
  13727. Displayable.call(this, opts);
  13728. };
  13729. Text.prototype = {
  13730. constructor: Text,
  13731. type: 'text',
  13732. brush: function (ctx, prevEl) {
  13733. var style = this.style;
  13734. var x = style.x || 0;
  13735. var y = style.y || 0;
  13736. // Convert to string
  13737. var text = style.text;
  13738. // Convert to string
  13739. text != null && (text += '');
  13740. // Always bind style
  13741. style.bind(ctx, this, prevEl);
  13742. if (text) {
  13743. this.setTransform(ctx);
  13744. var textBaseline;
  13745. var textAlign = style.textAlign;
  13746. var font = style.textFont || style.font;
  13747. if (style.textVerticalAlign) {
  13748. var rect = textContain.getBoundingRect(
  13749. text, font, style.textAlign, 'top'
  13750. );
  13751. // Ignore textBaseline
  13752. textBaseline = 'middle';
  13753. switch (style.textVerticalAlign) {
  13754. case 'middle':
  13755. y -= rect.height / 2 - rect.lineHeight / 2;
  13756. break;
  13757. case 'bottom':
  13758. y -= rect.height - rect.lineHeight / 2;
  13759. break;
  13760. default:
  13761. y += rect.lineHeight / 2;
  13762. }
  13763. }
  13764. else {
  13765. textBaseline = style.textBaseline;
  13766. }
  13767. // TODO Invalid font
  13768. ctx.font = font || '12px sans-serif';
  13769. ctx.textAlign = textAlign || 'left';
  13770. // Use canvas default left textAlign. Giving invalid value will cause state not change
  13771. if (ctx.textAlign !== textAlign) {
  13772. ctx.textAlign = 'left';
  13773. }
  13774. ctx.textBaseline = textBaseline || 'alphabetic';
  13775. // Use canvas default alphabetic baseline
  13776. if (ctx.textBaseline !== textBaseline) {
  13777. ctx.textBaseline = 'alphabetic';
  13778. }
  13779. var lineHeight = textContain.measureText('国', ctx.font).width;
  13780. var textLines = text.split('\n');
  13781. for (var i = 0; i < textLines.length; i++) {
  13782. style.hasFill() && ctx.fillText(textLines[i], x, y);
  13783. style.hasStroke() && ctx.strokeText(textLines[i], x, y);
  13784. y += lineHeight;
  13785. }
  13786. this.restoreTransform(ctx);
  13787. }
  13788. },
  13789. getBoundingRect: function () {
  13790. if (!this._rect) {
  13791. var style = this.style;
  13792. var textVerticalAlign = style.textVerticalAlign;
  13793. var rect = textContain.getBoundingRect(
  13794. style.text + '', style.textFont || style.font, style.textAlign,
  13795. textVerticalAlign ? 'top' : style.textBaseline
  13796. );
  13797. switch (textVerticalAlign) {
  13798. case 'middle':
  13799. rect.y -= rect.height / 2;
  13800. break;
  13801. case 'bottom':
  13802. rect.y -= rect.height;
  13803. break;
  13804. }
  13805. rect.x += style.x || 0;
  13806. rect.y += style.y || 0;
  13807. this._rect = rect;
  13808. }
  13809. return this._rect;
  13810. }
  13811. };
  13812. zrUtil.inherits(Text, Displayable);
  13813. module.exports = Text;
  13814. /***/ },
  13815. /* 64 */
  13816. /***/ function(module, exports, __webpack_require__) {
  13817. 'use strict';
  13818. /**
  13819. * 圆形
  13820. * @module zrender/shape/Circle
  13821. */
  13822. module.exports = __webpack_require__(45).extend({
  13823. type: 'circle',
  13824. shape: {
  13825. cx: 0,
  13826. cy: 0,
  13827. r: 0
  13828. },
  13829. buildPath : function (ctx, shape, inBundle) {
  13830. // Better stroking in ShapeBundle
  13831. // Always do it may have performence issue ( fill may be 2x more cost)
  13832. if (inBundle) {
  13833. ctx.moveTo(shape.cx + shape.r, shape.cy);
  13834. }
  13835. // Better stroking in ShapeBundle
  13836. // ctx.moveTo(shape.cx + shape.r, shape.cy);
  13837. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true);
  13838. }
  13839. });
  13840. /***/ },
  13841. /* 65 */
  13842. /***/ function(module, exports, __webpack_require__) {
  13843. /**
  13844. * 扇形
  13845. * @module zrender/graphic/shape/Sector
  13846. */
  13847. module.exports = __webpack_require__(45).extend({
  13848. type: 'sector',
  13849. shape: {
  13850. cx: 0,
  13851. cy: 0,
  13852. r0: 0,
  13853. r: 0,
  13854. startAngle: 0,
  13855. endAngle: Math.PI * 2,
  13856. clockwise: true
  13857. },
  13858. buildPath: function (ctx, shape) {
  13859. var x = shape.cx;
  13860. var y = shape.cy;
  13861. var r0 = Math.max(shape.r0 || 0, 0);
  13862. var r = Math.max(shape.r, 0);
  13863. var startAngle = shape.startAngle;
  13864. var endAngle = shape.endAngle;
  13865. var clockwise = shape.clockwise;
  13866. var unitX = Math.cos(startAngle);
  13867. var unitY = Math.sin(startAngle);
  13868. ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  13869. ctx.lineTo(unitX * r + x, unitY * r + y);
  13870. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  13871. ctx.lineTo(
  13872. Math.cos(endAngle) * r0 + x,
  13873. Math.sin(endAngle) * r0 + y
  13874. );
  13875. if (r0 !== 0) {
  13876. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  13877. }
  13878. ctx.closePath();
  13879. }
  13880. });
  13881. /***/ },
  13882. /* 66 */
  13883. /***/ function(module, exports, __webpack_require__) {
  13884. /**
  13885. * 圆环
  13886. * @module zrender/graphic/shape/Ring
  13887. */
  13888. module.exports = __webpack_require__(45).extend({
  13889. type: 'ring',
  13890. shape: {
  13891. cx: 0,
  13892. cy: 0,
  13893. r: 0,
  13894. r0: 0
  13895. },
  13896. buildPath: function (ctx, shape) {
  13897. var x = shape.cx;
  13898. var y = shape.cy;
  13899. var PI2 = Math.PI * 2;
  13900. ctx.moveTo(x + shape.r, y);
  13901. ctx.arc(x, y, shape.r, 0, PI2, false);
  13902. ctx.moveTo(x + shape.r0, y);
  13903. ctx.arc(x, y, shape.r0, 0, PI2, true);
  13904. }
  13905. });
  13906. /***/ },
  13907. /* 67 */
  13908. /***/ function(module, exports, __webpack_require__) {
  13909. /**
  13910. * 多边形
  13911. * @module zrender/shape/Polygon
  13912. */
  13913. var polyHelper = __webpack_require__(68);
  13914. module.exports = __webpack_require__(45).extend({
  13915. type: 'polygon',
  13916. shape: {
  13917. points: null,
  13918. smooth: false,
  13919. smoothConstraint: null
  13920. },
  13921. buildPath: function (ctx, shape) {
  13922. polyHelper.buildPath(ctx, shape, true);
  13923. }
  13924. });
  13925. /***/ },
  13926. /* 68 */
  13927. /***/ function(module, exports, __webpack_require__) {
  13928. var smoothSpline = __webpack_require__(69);
  13929. var smoothBezier = __webpack_require__(70);
  13930. module.exports = {
  13931. buildPath: function (ctx, shape, closePath) {
  13932. var points = shape.points;
  13933. var smooth = shape.smooth;
  13934. if (points && points.length >= 2) {
  13935. if (smooth && smooth !== 'spline') {
  13936. var controlPoints = smoothBezier(
  13937. points, smooth, closePath, shape.smoothConstraint
  13938. );
  13939. ctx.moveTo(points[0][0], points[0][1]);
  13940. var len = points.length;
  13941. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  13942. var cp1 = controlPoints[i * 2];
  13943. var cp2 = controlPoints[i * 2 + 1];
  13944. var p = points[(i + 1) % len];
  13945. ctx.bezierCurveTo(
  13946. cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]
  13947. );
  13948. }
  13949. }
  13950. else {
  13951. if (smooth === 'spline') {
  13952. points = smoothSpline(points, closePath);
  13953. }
  13954. ctx.moveTo(points[0][0], points[0][1]);
  13955. for (var i = 1, l = points.length; i < l; i++) {
  13956. ctx.lineTo(points[i][0], points[i][1]);
  13957. }
  13958. }
  13959. closePath && ctx.closePath();
  13960. }
  13961. }
  13962. };
  13963. /***/ },
  13964. /* 69 */
  13965. /***/ function(module, exports, __webpack_require__) {
  13966. /**
  13967. * Catmull-Rom spline 插值折线
  13968. * @module zrender/shape/util/smoothSpline
  13969. * @author pissang (https://www.github.com/pissang)
  13970. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  13971. * errorrik (errorrik@gmail.com)
  13972. */
  13973. var vec2 = __webpack_require__(10);
  13974. /**
  13975. * @inner
  13976. */
  13977. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  13978. var v0 = (p2 - p0) * 0.5;
  13979. var v1 = (p3 - p1) * 0.5;
  13980. return (2 * (p1 - p2) + v0 + v1) * t3
  13981. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  13982. + v0 * t + p1;
  13983. }
  13984. /**
  13985. * @alias module:zrender/shape/util/smoothSpline
  13986. * @param {Array} points 线段顶点数组
  13987. * @param {boolean} isLoop
  13988. * @return {Array}
  13989. */
  13990. module.exports = function (points, isLoop) {
  13991. var len = points.length;
  13992. var ret = [];
  13993. var distance = 0;
  13994. for (var i = 1; i < len; i++) {
  13995. distance += vec2.distance(points[i - 1], points[i]);
  13996. }
  13997. var segs = distance / 2;
  13998. segs = segs < len ? len : segs;
  13999. for (var i = 0; i < segs; i++) {
  14000. var pos = i / (segs - 1) * (isLoop ? len : len - 1);
  14001. var idx = Math.floor(pos);
  14002. var w = pos - idx;
  14003. var p0;
  14004. var p1 = points[idx % len];
  14005. var p2;
  14006. var p3;
  14007. if (!isLoop) {
  14008. p0 = points[idx === 0 ? idx : idx - 1];
  14009. p2 = points[idx > len - 2 ? len - 1 : idx + 1];
  14010. p3 = points[idx > len - 3 ? len - 1 : idx + 2];
  14011. }
  14012. else {
  14013. p0 = points[(idx - 1 + len) % len];
  14014. p2 = points[(idx + 1) % len];
  14015. p3 = points[(idx + 2) % len];
  14016. }
  14017. var w2 = w * w;
  14018. var w3 = w * w2;
  14019. ret.push([
  14020. interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
  14021. interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
  14022. ]);
  14023. }
  14024. return ret;
  14025. };
  14026. /***/ },
  14027. /* 70 */
  14028. /***/ function(module, exports, __webpack_require__) {
  14029. /**
  14030. * 贝塞尔平滑曲线
  14031. * @module zrender/shape/util/smoothBezier
  14032. * @author pissang (https://www.github.com/pissang)
  14033. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14034. * errorrik (errorrik@gmail.com)
  14035. */
  14036. var vec2 = __webpack_require__(10);
  14037. var v2Min = vec2.min;
  14038. var v2Max = vec2.max;
  14039. var v2Scale = vec2.scale;
  14040. var v2Distance = vec2.distance;
  14041. var v2Add = vec2.add;
  14042. /**
  14043. * 贝塞尔平滑曲线
  14044. * @alias module:zrender/shape/util/smoothBezier
  14045. * @param {Array} points 线段顶点数组
  14046. * @param {number} smooth 平滑等级, 0-1
  14047. * @param {boolean} isLoop
  14048. * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内
  14049. * 比如 [[0, 0], [100, 100]], 这个包围盒会与
  14050. * 整个折线的包围盒做一个并集用来约束控制点。
  14051. * @param {Array} 计算出来的控制点数组
  14052. */
  14053. module.exports = function (points, smooth, isLoop, constraint) {
  14054. var cps = [];
  14055. var v = [];
  14056. var v1 = [];
  14057. var v2 = [];
  14058. var prevPoint;
  14059. var nextPoint;
  14060. var min, max;
  14061. if (constraint) {
  14062. min = [Infinity, Infinity];
  14063. max = [-Infinity, -Infinity];
  14064. for (var i = 0, len = points.length; i < len; i++) {
  14065. v2Min(min, min, points[i]);
  14066. v2Max(max, max, points[i]);
  14067. }
  14068. // 与指定的包围盒做并集
  14069. v2Min(min, min, constraint[0]);
  14070. v2Max(max, max, constraint[1]);
  14071. }
  14072. for (var i = 0, len = points.length; i < len; i++) {
  14073. var point = points[i];
  14074. if (isLoop) {
  14075. prevPoint = points[i ? i - 1 : len - 1];
  14076. nextPoint = points[(i + 1) % len];
  14077. }
  14078. else {
  14079. if (i === 0 || i === len - 1) {
  14080. cps.push(vec2.clone(points[i]));
  14081. continue;
  14082. }
  14083. else {
  14084. prevPoint = points[i - 1];
  14085. nextPoint = points[i + 1];
  14086. }
  14087. }
  14088. vec2.sub(v, nextPoint, prevPoint);
  14089. // use degree to scale the handle length
  14090. v2Scale(v, v, smooth);
  14091. var d0 = v2Distance(point, prevPoint);
  14092. var d1 = v2Distance(point, nextPoint);
  14093. var sum = d0 + d1;
  14094. if (sum !== 0) {
  14095. d0 /= sum;
  14096. d1 /= sum;
  14097. }
  14098. v2Scale(v1, v, -d0);
  14099. v2Scale(v2, v, d1);
  14100. var cp0 = v2Add([], point, v1);
  14101. var cp1 = v2Add([], point, v2);
  14102. if (constraint) {
  14103. v2Max(cp0, cp0, min);
  14104. v2Min(cp0, cp0, max);
  14105. v2Max(cp1, cp1, min);
  14106. v2Min(cp1, cp1, max);
  14107. }
  14108. cps.push(cp0);
  14109. cps.push(cp1);
  14110. }
  14111. if (isLoop) {
  14112. cps.push(cps.shift());
  14113. }
  14114. return cps;
  14115. };
  14116. /***/ },
  14117. /* 71 */
  14118. /***/ function(module, exports, __webpack_require__) {
  14119. /**
  14120. * @module zrender/graphic/shape/Polyline
  14121. */
  14122. var polyHelper = __webpack_require__(68);
  14123. module.exports = __webpack_require__(45).extend({
  14124. type: 'polyline',
  14125. shape: {
  14126. points: null,
  14127. smooth: false,
  14128. smoothConstraint: null
  14129. },
  14130. style: {
  14131. stroke: '#000',
  14132. fill: null
  14133. },
  14134. buildPath: function (ctx, shape) {
  14135. polyHelper.buildPath(ctx, shape, false);
  14136. }
  14137. });
  14138. /***/ },
  14139. /* 72 */
  14140. /***/ function(module, exports, __webpack_require__) {
  14141. /**
  14142. * 矩形
  14143. * @module zrender/graphic/shape/Rect
  14144. */
  14145. var roundRectHelper = __webpack_require__(73);
  14146. module.exports = __webpack_require__(45).extend({
  14147. type: 'rect',
  14148. shape: {
  14149. // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
  14150. // r缩写为1 相当于 [1, 1, 1, 1]
  14151. // r缩写为[1] 相当于 [1, 1, 1, 1]
  14152. // r缩写为[1, 2] 相当于 [1, 2, 1, 2]
  14153. // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2]
  14154. r: 0,
  14155. x: 0,
  14156. y: 0,
  14157. width: 0,
  14158. height: 0
  14159. },
  14160. buildPath: function (ctx, shape) {
  14161. var x = shape.x;
  14162. var y = shape.y;
  14163. var width = shape.width;
  14164. var height = shape.height;
  14165. if (!shape.r) {
  14166. ctx.rect(x, y, width, height);
  14167. }
  14168. else {
  14169. roundRectHelper.buildPath(ctx, shape);
  14170. }
  14171. ctx.closePath();
  14172. return;
  14173. }
  14174. });
  14175. /***/ },
  14176. /* 73 */
  14177. /***/ function(module, exports) {
  14178. module.exports = {
  14179. buildPath: function (ctx, shape) {
  14180. var x = shape.x;
  14181. var y = shape.y;
  14182. var width = shape.width;
  14183. var height = shape.height;
  14184. var r = shape.r;
  14185. var r1;
  14186. var r2;
  14187. var r3;
  14188. var r4;
  14189. // Convert width and height to positive for better borderRadius
  14190. if (width < 0) {
  14191. x = x + width;
  14192. width = -width;
  14193. }
  14194. if (height < 0) {
  14195. y = y + height;
  14196. height = -height;
  14197. }
  14198. if (typeof r === 'number') {
  14199. r1 = r2 = r3 = r4 = r;
  14200. }
  14201. else if (r instanceof Array) {
  14202. if (r.length === 1) {
  14203. r1 = r2 = r3 = r4 = r[0];
  14204. }
  14205. else if (r.length === 2) {
  14206. r1 = r3 = r[0];
  14207. r2 = r4 = r[1];
  14208. }
  14209. else if (r.length === 3) {
  14210. r1 = r[0];
  14211. r2 = r4 = r[1];
  14212. r3 = r[2];
  14213. }
  14214. else {
  14215. r1 = r[0];
  14216. r2 = r[1];
  14217. r3 = r[2];
  14218. r4 = r[3];
  14219. }
  14220. }
  14221. else {
  14222. r1 = r2 = r3 = r4 = 0;
  14223. }
  14224. var total;
  14225. if (r1 + r2 > width) {
  14226. total = r1 + r2;
  14227. r1 *= width / total;
  14228. r2 *= width / total;
  14229. }
  14230. if (r3 + r4 > width) {
  14231. total = r3 + r4;
  14232. r3 *= width / total;
  14233. r4 *= width / total;
  14234. }
  14235. if (r2 + r3 > height) {
  14236. total = r2 + r3;
  14237. r2 *= height / total;
  14238. r3 *= height / total;
  14239. }
  14240. if (r1 + r4 > height) {
  14241. total = r1 + r4;
  14242. r1 *= height / total;
  14243. r4 *= height / total;
  14244. }
  14245. ctx.moveTo(x + r1, y);
  14246. ctx.lineTo(x + width - r2, y);
  14247. r2 !== 0 && ctx.quadraticCurveTo(
  14248. x + width, y, x + width, y + r2
  14249. );
  14250. ctx.lineTo(x + width, y + height - r3);
  14251. r3 !== 0 && ctx.quadraticCurveTo(
  14252. x + width, y + height, x + width - r3, y + height
  14253. );
  14254. ctx.lineTo(x + r4, y + height);
  14255. r4 !== 0 && ctx.quadraticCurveTo(
  14256. x, y + height, x, y + height - r4
  14257. );
  14258. ctx.lineTo(x, y + r1);
  14259. r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
  14260. }
  14261. };
  14262. /***/ },
  14263. /* 74 */
  14264. /***/ function(module, exports, __webpack_require__) {
  14265. /**
  14266. * 直线
  14267. * @module zrender/graphic/shape/Line
  14268. */
  14269. module.exports = __webpack_require__(45).extend({
  14270. type: 'line',
  14271. shape: {
  14272. // Start point
  14273. x1: 0,
  14274. y1: 0,
  14275. // End point
  14276. x2: 0,
  14277. y2: 0,
  14278. percent: 1
  14279. },
  14280. style: {
  14281. stroke: '#000',
  14282. fill: null
  14283. },
  14284. buildPath: function (ctx, shape) {
  14285. var x1 = shape.x1;
  14286. var y1 = shape.y1;
  14287. var x2 = shape.x2;
  14288. var y2 = shape.y2;
  14289. var percent = shape.percent;
  14290. if (percent === 0) {
  14291. return;
  14292. }
  14293. ctx.moveTo(x1, y1);
  14294. if (percent < 1) {
  14295. x2 = x1 * (1 - percent) + x2 * percent;
  14296. y2 = y1 * (1 - percent) + y2 * percent;
  14297. }
  14298. ctx.lineTo(x2, y2);
  14299. },
  14300. /**
  14301. * Get point at percent
  14302. * @param {number} percent
  14303. * @return {Array.<number>}
  14304. */
  14305. pointAt: function (p) {
  14306. var shape = this.shape;
  14307. return [
  14308. shape.x1 * (1 - p) + shape.x2 * p,
  14309. shape.y1 * (1 - p) + shape.y2 * p
  14310. ];
  14311. }
  14312. });
  14313. /***/ },
  14314. /* 75 */
  14315. /***/ function(module, exports, __webpack_require__) {
  14316. 'use strict';
  14317. /**
  14318. * 贝塞尔曲线
  14319. * @module zrender/shape/BezierCurve
  14320. */
  14321. var curveTool = __webpack_require__(50);
  14322. var vec2 = __webpack_require__(10);
  14323. var quadraticSubdivide = curveTool.quadraticSubdivide;
  14324. var cubicSubdivide = curveTool.cubicSubdivide;
  14325. var quadraticAt = curveTool.quadraticAt;
  14326. var cubicAt = curveTool.cubicAt;
  14327. var quadraticDerivativeAt = curveTool.quadraticDerivativeAt;
  14328. var cubicDerivativeAt = curveTool.cubicDerivativeAt;
  14329. var out = [];
  14330. function someVectorAt(shape, t, isTangent) {
  14331. var cpx2 = shape.cpx2;
  14332. var cpy2 = shape.cpy2;
  14333. if (cpx2 === null || cpy2 === null) {
  14334. return [
  14335. (isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t),
  14336. (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)
  14337. ];
  14338. }
  14339. else {
  14340. return [
  14341. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t),
  14342. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)
  14343. ];
  14344. }
  14345. }
  14346. module.exports = __webpack_require__(45).extend({
  14347. type: 'bezier-curve',
  14348. shape: {
  14349. x1: 0,
  14350. y1: 0,
  14351. x2: 0,
  14352. y2: 0,
  14353. cpx1: 0,
  14354. cpy1: 0,
  14355. // cpx2: 0,
  14356. // cpy2: 0
  14357. // Curve show percent, for animating
  14358. percent: 1
  14359. },
  14360. style: {
  14361. stroke: '#000',
  14362. fill: null
  14363. },
  14364. buildPath: function (ctx, shape) {
  14365. var x1 = shape.x1;
  14366. var y1 = shape.y1;
  14367. var x2 = shape.x2;
  14368. var y2 = shape.y2;
  14369. var cpx1 = shape.cpx1;
  14370. var cpy1 = shape.cpy1;
  14371. var cpx2 = shape.cpx2;
  14372. var cpy2 = shape.cpy2;
  14373. var percent = shape.percent;
  14374. if (percent === 0) {
  14375. return;
  14376. }
  14377. ctx.moveTo(x1, y1);
  14378. if (cpx2 == null || cpy2 == null) {
  14379. if (percent < 1) {
  14380. quadraticSubdivide(
  14381. x1, cpx1, x2, percent, out
  14382. );
  14383. cpx1 = out[1];
  14384. x2 = out[2];
  14385. quadraticSubdivide(
  14386. y1, cpy1, y2, percent, out
  14387. );
  14388. cpy1 = out[1];
  14389. y2 = out[2];
  14390. }
  14391. ctx.quadraticCurveTo(
  14392. cpx1, cpy1,
  14393. x2, y2
  14394. );
  14395. }
  14396. else {
  14397. if (percent < 1) {
  14398. cubicSubdivide(
  14399. x1, cpx1, cpx2, x2, percent, out
  14400. );
  14401. cpx1 = out[1];
  14402. cpx2 = out[2];
  14403. x2 = out[3];
  14404. cubicSubdivide(
  14405. y1, cpy1, cpy2, y2, percent, out
  14406. );
  14407. cpy1 = out[1];
  14408. cpy2 = out[2];
  14409. y2 = out[3];
  14410. }
  14411. ctx.bezierCurveTo(
  14412. cpx1, cpy1,
  14413. cpx2, cpy2,
  14414. x2, y2
  14415. );
  14416. }
  14417. },
  14418. /**
  14419. * Get point at percent
  14420. * @param {number} t
  14421. * @return {Array.<number>}
  14422. */
  14423. pointAt: function (t) {
  14424. return someVectorAt(this.shape, t, false);
  14425. },
  14426. /**
  14427. * Get tangent at percent
  14428. * @param {number} t
  14429. * @return {Array.<number>}
  14430. */
  14431. tangentAt: function (t) {
  14432. var p = someVectorAt(this.shape, t, true);
  14433. return vec2.normalize(p, p);
  14434. }
  14435. });
  14436. /***/ },
  14437. /* 76 */
  14438. /***/ function(module, exports, __webpack_require__) {
  14439. /**
  14440. * 圆弧
  14441. * @module zrender/graphic/shape/Arc
  14442. */
  14443. module.exports = __webpack_require__(45).extend({
  14444. type: 'arc',
  14445. shape: {
  14446. cx: 0,
  14447. cy: 0,
  14448. r: 0,
  14449. startAngle: 0,
  14450. endAngle: Math.PI * 2,
  14451. clockwise: true
  14452. },
  14453. style: {
  14454. stroke: '#000',
  14455. fill: null
  14456. },
  14457. buildPath: function (ctx, shape) {
  14458. var x = shape.cx;
  14459. var y = shape.cy;
  14460. var r = Math.max(shape.r, 0);
  14461. var startAngle = shape.startAngle;
  14462. var endAngle = shape.endAngle;
  14463. var clockwise = shape.clockwise;
  14464. var unitX = Math.cos(startAngle);
  14465. var unitY = Math.sin(startAngle);
  14466. ctx.moveTo(unitX * r + x, unitY * r + y);
  14467. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  14468. }
  14469. });
  14470. /***/ },
  14471. /* 77 */
  14472. /***/ function(module, exports, __webpack_require__) {
  14473. // CompoundPath to improve performance
  14474. var Path = __webpack_require__(45);
  14475. module.exports = Path.extend({
  14476. type: 'compound',
  14477. shape: {
  14478. paths: null
  14479. },
  14480. _updatePathDirty: function () {
  14481. var dirtyPath = this.__dirtyPath;
  14482. var paths = this.shape.paths;
  14483. for (var i = 0; i < paths.length; i++) {
  14484. // Mark as dirty if any subpath is dirty
  14485. dirtyPath = dirtyPath || paths[i].__dirtyPath;
  14486. }
  14487. this.__dirtyPath = dirtyPath;
  14488. this.__dirty = this.__dirty || dirtyPath;
  14489. },
  14490. beforeBrush: function () {
  14491. this._updatePathDirty();
  14492. var paths = this.shape.paths || [];
  14493. var scale = this.getGlobalScale();
  14494. // Update path scale
  14495. for (var i = 0; i < paths.length; i++) {
  14496. paths[i].path.setScale(scale[0], scale[1]);
  14497. }
  14498. },
  14499. buildPath: function (ctx, shape) {
  14500. var paths = shape.paths || [];
  14501. for (var i = 0; i < paths.length; i++) {
  14502. paths[i].buildPath(ctx, paths[i].shape, true);
  14503. }
  14504. },
  14505. afterBrush: function () {
  14506. var paths = this.shape.paths;
  14507. for (var i = 0; i < paths.length; i++) {
  14508. paths[i].__dirtyPath = false;
  14509. }
  14510. },
  14511. getBoundingRect: function () {
  14512. this._updatePathDirty();
  14513. return Path.prototype.getBoundingRect.call(this);
  14514. }
  14515. });
  14516. /***/ },
  14517. /* 78 */
  14518. /***/ function(module, exports, __webpack_require__) {
  14519. 'use strict';
  14520. var zrUtil = __webpack_require__(4);
  14521. var Gradient = __webpack_require__(79);
  14522. /**
  14523. * x, y, x2, y2 are all percent from 0 to 1
  14524. * @param {number} [x=0]
  14525. * @param {number} [y=0]
  14526. * @param {number} [x2=1]
  14527. * @param {number} [y2=0]
  14528. * @param {Array.<Object>} colorStops
  14529. * @param {boolean} [globalCoord=false]
  14530. */
  14531. var LinearGradient = function (x, y, x2, y2, colorStops, globalCoord) {
  14532. this.x = x == null ? 0 : x;
  14533. this.y = y == null ? 0 : y;
  14534. this.x2 = x2 == null ? 1 : x2;
  14535. this.y2 = y2 == null ? 0 : y2;
  14536. // Can be cloned
  14537. this.type = 'linear';
  14538. // If use global coord
  14539. this.global = globalCoord || false;
  14540. Gradient.call(this, colorStops);
  14541. };
  14542. LinearGradient.prototype = {
  14543. constructor: LinearGradient
  14544. };
  14545. zrUtil.inherits(LinearGradient, Gradient);
  14546. module.exports = LinearGradient;
  14547. /***/ },
  14548. /* 79 */
  14549. /***/ function(module, exports) {
  14550. /**
  14551. * @param {Array.<Object>} colorStops
  14552. */
  14553. var Gradient = function (colorStops) {
  14554. this.colorStops = colorStops || [];
  14555. };
  14556. Gradient.prototype = {
  14557. constructor: Gradient,
  14558. addColorStop: function (offset, color) {
  14559. this.colorStops.push({
  14560. offset: offset,
  14561. color: color
  14562. });
  14563. }
  14564. };
  14565. module.exports = Gradient;
  14566. /***/ },
  14567. /* 80 */
  14568. /***/ function(module, exports, __webpack_require__) {
  14569. 'use strict';
  14570. var zrUtil = __webpack_require__(4);
  14571. var Gradient = __webpack_require__(79);
  14572. /**
  14573. * x, y, r are all percent from 0 to 1
  14574. * @param {number} [x=0.5]
  14575. * @param {number} [y=0.5]
  14576. * @param {number} [r=0.5]
  14577. * @param {Array.<Object>} [colorStops]
  14578. * @param {boolean} [globalCoord=false]
  14579. */
  14580. var RadialGradient = function (x, y, r, colorStops, globalCoord) {
  14581. this.x = x == null ? 0.5 : x;
  14582. this.y = y == null ? 0.5 : y;
  14583. this.r = r == null ? 0.5 : r;
  14584. // Can be cloned
  14585. this.type = 'radial';
  14586. // If use global coord
  14587. this.global = globalCoord || false;
  14588. Gradient.call(this, colorStops);
  14589. };
  14590. RadialGradient.prototype = {
  14591. constructor: RadialGradient
  14592. };
  14593. zrUtil.inherits(RadialGradient, Gradient);
  14594. module.exports = RadialGradient;
  14595. /***/ },
  14596. /* 81 */
  14597. /***/ function(module, exports) {
  14598. var lib = {};
  14599. var ORIGIN_METHOD = '\0__throttleOriginMethod';
  14600. var RATE = '\0__throttleRate';
  14601. var THROTTLE_TYPE = '\0__throttleType';
  14602. /**
  14603. * @public
  14604. * @param {(Function)} fn
  14605. * @param {number} [delay=0] Unit: ms.
  14606. * @param {boolean} [debounce=false]
  14607. * true: If call interval less than `delay`, only the last call works.
  14608. * false: If call interval less than `delay, call works on fixed rate.
  14609. * @return {(Function)} throttled fn.
  14610. */
  14611. lib.throttle = function (fn, delay, debounce) {
  14612. var currCall;
  14613. var lastCall = 0;
  14614. var lastExec = 0;
  14615. var timer = null;
  14616. var diff;
  14617. var scope;
  14618. var args;
  14619. delay = delay || 0;
  14620. function exec() {
  14621. lastExec = (new Date()).getTime();
  14622. timer = null;
  14623. fn.apply(scope, args || []);
  14624. }
  14625. var cb = function () {
  14626. currCall = (new Date()).getTime();
  14627. scope = this;
  14628. args = arguments;
  14629. diff = currCall - (debounce ? lastCall : lastExec) - delay;
  14630. clearTimeout(timer);
  14631. if (debounce) {
  14632. timer = setTimeout(exec, delay);
  14633. }
  14634. else {
  14635. if (diff >= 0) {
  14636. exec();
  14637. }
  14638. else {
  14639. timer = setTimeout(exec, -diff);
  14640. }
  14641. }
  14642. lastCall = currCall;
  14643. };
  14644. /**
  14645. * Clear throttle.
  14646. * @public
  14647. */
  14648. cb.clear = function () {
  14649. if (timer) {
  14650. clearTimeout(timer);
  14651. timer = null;
  14652. }
  14653. };
  14654. return cb;
  14655. };
  14656. /**
  14657. * Create throttle method or update throttle rate.
  14658. *
  14659. * @example
  14660. * ComponentView.prototype.render = function () {
  14661. * ...
  14662. * throttle.createOrUpdate(
  14663. * this,
  14664. * '_dispatchAction',
  14665. * this.model.get('throttle'),
  14666. * 'fixRate'
  14667. * );
  14668. * };
  14669. * ComponentView.prototype.remove = function () {
  14670. * throttle.clear(this, '_dispatchAction');
  14671. * };
  14672. * ComponentView.prototype.dispose = function () {
  14673. * throttle.clear(this, '_dispatchAction');
  14674. * };
  14675. *
  14676. * @public
  14677. * @param {Object} obj
  14678. * @param {string} fnAttr
  14679. * @param {number} [rate]
  14680. * @param {string} [throttleType='fixRate'] 'fixRate' or 'debounce'
  14681. * @return {Function} throttled function.
  14682. */
  14683. lib.createOrUpdate = function (obj, fnAttr, rate, throttleType) {
  14684. var fn = obj[fnAttr];
  14685. if (!fn) {
  14686. return;
  14687. }
  14688. var originFn = fn[ORIGIN_METHOD] || fn;
  14689. var lastThrottleType = fn[THROTTLE_TYPE];
  14690. var lastRate = fn[RATE];
  14691. if (lastRate !== rate || lastThrottleType !== throttleType) {
  14692. if (rate == null || !throttleType) {
  14693. return (obj[fnAttr] = originFn);
  14694. }
  14695. fn = obj[fnAttr] = lib.throttle(
  14696. originFn, rate, throttleType === 'debounce'
  14697. );
  14698. fn[ORIGIN_METHOD] = originFn;
  14699. fn[THROTTLE_TYPE] = throttleType;
  14700. fn[RATE] = rate;
  14701. }
  14702. return fn;
  14703. };
  14704. /**
  14705. * Clear throttle. Example see throttle.createOrUpdate.
  14706. *
  14707. * @public
  14708. * @param {Object} obj
  14709. * @param {string} fnAttr
  14710. */
  14711. lib.clear = function (obj, fnAttr) {
  14712. var fn = obj[fnAttr];
  14713. if (fn && fn[ORIGIN_METHOD]) {
  14714. obj[fnAttr] = fn[ORIGIN_METHOD];
  14715. }
  14716. };
  14717. module.exports = lib;
  14718. /***/ },
  14719. /* 82 */
  14720. /***/ function(module, exports, __webpack_require__) {
  14721. /*!
  14722. * ZRender, a high performance 2d drawing library.
  14723. *
  14724. * Copyright (c) 2013, Baidu Inc.
  14725. * All rights reserved.
  14726. *
  14727. * LICENSE
  14728. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  14729. */
  14730. // Global defines
  14731. var guid = __webpack_require__(32);
  14732. var env = __webpack_require__(2);
  14733. var zrUtil = __webpack_require__(4);
  14734. var Handler = __webpack_require__(83);
  14735. var Storage = __webpack_require__(85);
  14736. var Animation = __webpack_require__(87);
  14737. var HandlerProxy = __webpack_require__(90);
  14738. var useVML = !env.canvasSupported;
  14739. var painterCtors = {
  14740. canvas: __webpack_require__(92)
  14741. };
  14742. var instances = {}; // ZRender实例map索引
  14743. var zrender = {};
  14744. /**
  14745. * @type {string}
  14746. */
  14747. zrender.version = '3.2.2';
  14748. /**
  14749. * Initializing a zrender instance
  14750. * @param {HTMLElement} dom
  14751. * @param {Object} opts
  14752. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  14753. * @param {number} [opts.devicePixelRatio]
  14754. * @param {number|string} [opts.width] Can be 'auto' (the same as null/undefined)
  14755. * @param {number|string} [opts.height] Can be 'auto' (the same as null/undefined)
  14756. * @return {module:zrender/ZRender}
  14757. */
  14758. zrender.init = function(dom, opts) {
  14759. var zr = new ZRender(guid(), dom, opts);
  14760. instances[zr.id] = zr;
  14761. return zr;
  14762. };
  14763. /**
  14764. * Dispose zrender instance
  14765. * @param {module:zrender/ZRender} zr
  14766. */
  14767. zrender.dispose = function (zr) {
  14768. if (zr) {
  14769. zr.dispose();
  14770. }
  14771. else {
  14772. for (var key in instances) {
  14773. if (instances.hasOwnProperty(key)) {
  14774. instances[key].dispose();
  14775. }
  14776. }
  14777. instances = {};
  14778. }
  14779. return zrender;
  14780. };
  14781. /**
  14782. * Get zrender instance by id
  14783. * @param {string} id zrender instance id
  14784. * @return {module:zrender/ZRender}
  14785. */
  14786. zrender.getInstance = function (id) {
  14787. return instances[id];
  14788. };
  14789. zrender.registerPainter = function (name, Ctor) {
  14790. painterCtors[name] = Ctor;
  14791. };
  14792. function delInstance(id) {
  14793. delete instances[id];
  14794. }
  14795. /**
  14796. * @module zrender/ZRender
  14797. */
  14798. /**
  14799. * @constructor
  14800. * @alias module:zrender/ZRender
  14801. * @param {string} id
  14802. * @param {HTMLDomElement} dom
  14803. * @param {Object} opts
  14804. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  14805. * @param {number} [opts.devicePixelRatio]
  14806. * @param {number} [opts.width] Can be 'auto' (the same as null/undefined)
  14807. * @param {number} [opts.height] Can be 'auto' (the same as null/undefined)
  14808. */
  14809. var ZRender = function(id, dom, opts) {
  14810. opts = opts || {};
  14811. /**
  14812. * @type {HTMLDomElement}
  14813. */
  14814. this.dom = dom;
  14815. /**
  14816. * @type {string}
  14817. */
  14818. this.id = id;
  14819. var self = this;
  14820. var storage = new Storage();
  14821. var rendererType = opts.renderer;
  14822. if (useVML) {
  14823. if (!painterCtors.vml) {
  14824. throw new Error('You need to require \'zrender/vml/vml\' to support IE8');
  14825. }
  14826. rendererType = 'vml';
  14827. }
  14828. else if (!rendererType || !painterCtors[rendererType]) {
  14829. rendererType = 'canvas';
  14830. }
  14831. var painter = new painterCtors[rendererType](dom, storage, opts);
  14832. this.storage = storage;
  14833. this.painter = painter;
  14834. var handerProxy = !env.node ? new HandlerProxy(painter.getViewportRoot()) : null;
  14835. this.handler = new Handler(storage, painter, handerProxy, painter.root);
  14836. /**
  14837. * @type {module:zrender/animation/Animation}
  14838. */
  14839. this.animation = new Animation({
  14840. stage: {
  14841. update: zrUtil.bind(this.flush, this)
  14842. }
  14843. });
  14844. this.animation.start();
  14845. /**
  14846. * @type {boolean}
  14847. * @private
  14848. */
  14849. this._needsRefresh;
  14850. // 修改 storage.delFromMap, 每次删除元素之前删除动画
  14851. // FIXME 有点ugly
  14852. var oldDelFromMap = storage.delFromMap;
  14853. var oldAddToMap = storage.addToMap;
  14854. storage.delFromMap = function (elId) {
  14855. var el = storage.get(elId);
  14856. oldDelFromMap.call(storage, elId);
  14857. el && el.removeSelfFromZr(self);
  14858. };
  14859. storage.addToMap = function (el) {
  14860. oldAddToMap.call(storage, el);
  14861. el.addSelfToZr(self);
  14862. };
  14863. };
  14864. ZRender.prototype = {
  14865. constructor: ZRender,
  14866. /**
  14867. * 获取实例唯一标识
  14868. * @return {string}
  14869. */
  14870. getId: function () {
  14871. return this.id;
  14872. },
  14873. /**
  14874. * 添加元素
  14875. * @param {module:zrender/Element} el
  14876. */
  14877. add: function (el) {
  14878. this.storage.addRoot(el);
  14879. this._needsRefresh = true;
  14880. },
  14881. /**
  14882. * 删除元素
  14883. * @param {module:zrender/Element} el
  14884. */
  14885. remove: function (el) {
  14886. this.storage.delRoot(el);
  14887. this._needsRefresh = true;
  14888. },
  14889. /**
  14890. * Change configuration of layer
  14891. * @param {string} zLevel
  14892. * @param {Object} config
  14893. * @param {string} [config.clearColor=0] Clear color
  14894. * @param {string} [config.motionBlur=false] If enable motion blur
  14895. * @param {number} [config.lastFrameAlpha=0.7] Motion blur factor. Larger value cause longer trailer
  14896. */
  14897. configLayer: function (zLevel, config) {
  14898. this.painter.configLayer(zLevel, config);
  14899. this._needsRefresh = true;
  14900. },
  14901. /**
  14902. * Repaint the canvas immediately
  14903. */
  14904. refreshImmediately: function () {
  14905. // Clear needsRefresh ahead to avoid something wrong happens in refresh
  14906. // Or it will cause zrender refreshes again and again.
  14907. this._needsRefresh = false;
  14908. this.painter.refresh();
  14909. /**
  14910. * Avoid trigger zr.refresh in Element#beforeUpdate hook
  14911. */
  14912. this._needsRefresh = false;
  14913. },
  14914. /**
  14915. * Mark and repaint the canvas in the next frame of browser
  14916. */
  14917. refresh: function() {
  14918. this._needsRefresh = true;
  14919. },
  14920. /**
  14921. * Perform all refresh
  14922. */
  14923. flush: function () {
  14924. if (this._needsRefresh) {
  14925. this.refreshImmediately();
  14926. }
  14927. if (this._needsRefreshHover) {
  14928. this.refreshHoverImmediately();
  14929. }
  14930. },
  14931. /**
  14932. * Add element to hover layer
  14933. * @param {module:zrender/Element} el
  14934. * @param {Object} style
  14935. */
  14936. addHover: function (el, style) {
  14937. if (this.painter.addHover) {
  14938. this.painter.addHover(el, style);
  14939. this.refreshHover();
  14940. }
  14941. },
  14942. /**
  14943. * Add element from hover layer
  14944. * @param {module:zrender/Element} el
  14945. */
  14946. removeHover: function (el) {
  14947. if (this.painter.removeHover) {
  14948. this.painter.removeHover(el);
  14949. this.refreshHover();
  14950. }
  14951. },
  14952. /**
  14953. * Clear all hover elements in hover layer
  14954. * @param {module:zrender/Element} el
  14955. */
  14956. clearHover: function () {
  14957. if (this.painter.clearHover) {
  14958. this.painter.clearHover();
  14959. this.refreshHover();
  14960. }
  14961. },
  14962. /**
  14963. * Refresh hover in next frame
  14964. */
  14965. refreshHover: function () {
  14966. this._needsRefreshHover = true;
  14967. },
  14968. /**
  14969. * Refresh hover immediately
  14970. */
  14971. refreshHoverImmediately: function () {
  14972. this._needsRefreshHover = false;
  14973. this.painter.refreshHover && this.painter.refreshHover();
  14974. },
  14975. /**
  14976. * Resize the canvas.
  14977. * Should be invoked when container size is changed
  14978. * @param {Object} [opts]
  14979. * @param {number|string} [opts.width] Can be 'auto' (the same as null/undefined)
  14980. * @param {number|string} [opts.height] Can be 'auto' (the same as null/undefined)
  14981. */
  14982. resize: function(opts) {
  14983. opts = opts || {};
  14984. this.painter.resize(opts.width, opts.height);
  14985. this.handler.resize();
  14986. },
  14987. /**
  14988. * Stop and clear all animation immediately
  14989. */
  14990. clearAnimation: function () {
  14991. this.animation.clear();
  14992. },
  14993. /**
  14994. * Get container width
  14995. */
  14996. getWidth: function() {
  14997. return this.painter.getWidth();
  14998. },
  14999. /**
  15000. * Get container height
  15001. */
  15002. getHeight: function() {
  15003. return this.painter.getHeight();
  15004. },
  15005. /**
  15006. * Export the canvas as Base64 URL
  15007. * @param {string} type
  15008. * @param {string} [backgroundColor='#fff']
  15009. * @return {string} Base64 URL
  15010. */
  15011. // toDataURL: function(type, backgroundColor) {
  15012. // return this.painter.getRenderedCanvas({
  15013. // backgroundColor: backgroundColor
  15014. // }).toDataURL(type);
  15015. // },
  15016. /**
  15017. * Converting a path to image.
  15018. * It has much better performance of drawing image rather than drawing a vector path.
  15019. * @param {module:zrender/graphic/Path} e
  15020. * @param {number} width
  15021. * @param {number} height
  15022. */
  15023. pathToImage: function(e, width, height) {
  15024. var id = guid();
  15025. return this.painter.pathToImage(id, e, width, height);
  15026. },
  15027. /**
  15028. * Set default cursor
  15029. * @param {string} [cursorStyle='default'] 例如 crosshair
  15030. */
  15031. setCursorStyle: function (cursorStyle) {
  15032. this.handler.setCursorStyle(cursorStyle);
  15033. },
  15034. /**
  15035. * Bind event
  15036. *
  15037. * @param {string} eventName Event name
  15038. * @param {Function} eventHandler Handler function
  15039. * @param {Object} [context] Context object
  15040. */
  15041. on: function(eventName, eventHandler, context) {
  15042. this.handler.on(eventName, eventHandler, context);
  15043. },
  15044. /**
  15045. * Unbind event
  15046. * @param {string} eventName Event name
  15047. * @param {Function} [eventHandler] Handler function
  15048. */
  15049. off: function(eventName, eventHandler) {
  15050. this.handler.off(eventName, eventHandler);
  15051. },
  15052. /**
  15053. * Trigger event manually
  15054. *
  15055. * @param {string} eventName Event name
  15056. * @param {event=} event Event object
  15057. */
  15058. trigger: function (eventName, event) {
  15059. this.handler.trigger(eventName, event);
  15060. },
  15061. /**
  15062. * Clear all objects and the canvas.
  15063. */
  15064. clear: function () {
  15065. this.storage.delRoot();
  15066. this.painter.clear();
  15067. },
  15068. /**
  15069. * Dispose self.
  15070. */
  15071. dispose: function () {
  15072. this.animation.stop();
  15073. this.clear();
  15074. this.storage.dispose();
  15075. this.painter.dispose();
  15076. this.handler.dispose();
  15077. this.animation =
  15078. this.storage =
  15079. this.painter =
  15080. this.handler = null;
  15081. delInstance(this.id);
  15082. }
  15083. };
  15084. module.exports = zrender;
  15085. /***/ },
  15086. /* 83 */
  15087. /***/ function(module, exports, __webpack_require__) {
  15088. 'use strict';
  15089. /**
  15090. * Handler
  15091. * @module zrender/Handler
  15092. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  15093. * errorrik (errorrik@gmail.com)
  15094. * pissang (shenyi.914@gmail.com)
  15095. */
  15096. var util = __webpack_require__(4);
  15097. var Draggable = __webpack_require__(84);
  15098. var Eventful = __webpack_require__(33);
  15099. function makeEventPacket(eveType, target, event) {
  15100. return {
  15101. type: eveType,
  15102. event: event,
  15103. target: target,
  15104. cancelBubble: false,
  15105. offsetX: event.zrX,
  15106. offsetY: event.zrY,
  15107. gestureEvent: event.gestureEvent,
  15108. pinchX: event.pinchX,
  15109. pinchY: event.pinchY,
  15110. pinchScale: event.pinchScale,
  15111. wheelDelta: event.zrDelta,
  15112. zrByTouch: event.zrByTouch
  15113. };
  15114. }
  15115. function EmptyProxy () {}
  15116. EmptyProxy.prototype.dispose = function () {};
  15117. var handlerNames = [
  15118. 'click', 'dblclick', 'mousewheel', 'mouseout',
  15119. 'mouseup', 'mousedown', 'mousemove', 'contextmenu'
  15120. ];
  15121. /**
  15122. * @alias module:zrender/Handler
  15123. * @constructor
  15124. * @extends module:zrender/mixin/Eventful
  15125. * @param {module:zrender/Storage} storage Storage instance.
  15126. * @param {module:zrender/Painter} painter Painter instance.
  15127. * @param {module:zrender/dom/HandlerProxy} proxy HandlerProxy instance.
  15128. * @param {HTMLElement} painterRoot painter.root (not painter.getViewportRoot()).
  15129. */
  15130. var Handler = function(storage, painter, proxy, painterRoot) {
  15131. Eventful.call(this);
  15132. this.storage = storage;
  15133. this.painter = painter;
  15134. this.painterRoot = painterRoot;
  15135. proxy = proxy || new EmptyProxy();
  15136. /**
  15137. * Proxy of event. can be Dom, WebGLSurface, etc.
  15138. */
  15139. this.proxy = proxy;
  15140. // Attach handler
  15141. proxy.handler = this;
  15142. /**
  15143. * @private
  15144. * @type {boolean}
  15145. */
  15146. this._hovered;
  15147. /**
  15148. * @private
  15149. * @type {Date}
  15150. */
  15151. this._lastTouchMoment;
  15152. /**
  15153. * @private
  15154. * @type {number}
  15155. */
  15156. this._lastX;
  15157. /**
  15158. * @private
  15159. * @type {number}
  15160. */
  15161. this._lastY;
  15162. Draggable.call(this);
  15163. util.each(handlerNames, function (name) {
  15164. proxy.on && proxy.on(name, this[name], this);
  15165. }, this);
  15166. };
  15167. Handler.prototype = {
  15168. constructor: Handler,
  15169. mousemove: function (event) {
  15170. var x = event.zrX;
  15171. var y = event.zrY;
  15172. var hovered = this.findHover(x, y, null);
  15173. var lastHovered = this._hovered;
  15174. var proxy = this.proxy;
  15175. this._hovered = hovered;
  15176. proxy.setCursor && proxy.setCursor(hovered ? hovered.cursor : 'default');
  15177. // Mouse out on previous hovered element
  15178. if (lastHovered && hovered !== lastHovered && lastHovered.__zr) {
  15179. this.dispatchToElement(lastHovered, 'mouseout', event);
  15180. }
  15181. // Mouse moving on one element
  15182. this.dispatchToElement(hovered, 'mousemove', event);
  15183. // Mouse over on a new element
  15184. if (hovered && hovered !== lastHovered) {
  15185. this.dispatchToElement(hovered, 'mouseover', event);
  15186. }
  15187. },
  15188. mouseout: function (event) {
  15189. this.dispatchToElement(this._hovered, 'mouseout', event);
  15190. // There might be some doms created by upper layer application
  15191. // at the same level of painter.getViewportRoot() (e.g., tooltip
  15192. // dom created by echarts), where 'globalout' event should not
  15193. // be triggered when mouse enters these doms. (But 'mouseout'
  15194. // should be triggered at the original hovered element as usual).
  15195. var element = event.toElement || event.relatedTarget;
  15196. var innerDom;
  15197. do {
  15198. element = element && element.parentNode;
  15199. }
  15200. while (element && element.nodeType != 9 && !(
  15201. innerDom = element === this.painterRoot
  15202. ));
  15203. !innerDom && this.trigger('globalout', {event: event});
  15204. },
  15205. /**
  15206. * Resize
  15207. */
  15208. resize: function (event) {
  15209. this._hovered = null;
  15210. },
  15211. /**
  15212. * Dispatch event
  15213. * @param {string} eventName
  15214. * @param {event=} eventArgs
  15215. */
  15216. dispatch: function (eventName, eventArgs) {
  15217. var handler = this[eventName];
  15218. handler && handler.call(this, eventArgs);
  15219. },
  15220. /**
  15221. * Dispose
  15222. */
  15223. dispose: function () {
  15224. this.proxy.dispose();
  15225. this.storage =
  15226. this.proxy =
  15227. this.painter = null;
  15228. },
  15229. /**
  15230. * 设置默认的cursor style
  15231. * @param {string} [cursorStyle='default'] 例如 crosshair
  15232. */
  15233. setCursorStyle: function (cursorStyle) {
  15234. var proxy = this.proxy;
  15235. proxy.setCursor && proxy.setCursor(cursorStyle);
  15236. },
  15237. /**
  15238. * 事件分发代理
  15239. *
  15240. * @private
  15241. * @param {Object} targetEl 目标图形元素
  15242. * @param {string} eventName 事件名称
  15243. * @param {Object} event 事件对象
  15244. */
  15245. dispatchToElement: function (targetEl, eventName, event) {
  15246. var eventHandler = 'on' + eventName;
  15247. var eventPacket = makeEventPacket(eventName, targetEl, event);
  15248. var el = targetEl;
  15249. while (el) {
  15250. el[eventHandler]
  15251. && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket));
  15252. el.trigger(eventName, eventPacket);
  15253. el = el.parent;
  15254. if (eventPacket.cancelBubble) {
  15255. break;
  15256. }
  15257. }
  15258. if (!eventPacket.cancelBubble) {
  15259. // 冒泡到顶级 zrender 对象
  15260. this.trigger(eventName, eventPacket);
  15261. // 分发事件到用户自定义层
  15262. // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在
  15263. this.painter && this.painter.eachOtherLayer(function (layer) {
  15264. if (typeof(layer[eventHandler]) == 'function') {
  15265. layer[eventHandler].call(layer, eventPacket);
  15266. }
  15267. if (layer.trigger) {
  15268. layer.trigger(eventName, eventPacket);
  15269. }
  15270. });
  15271. }
  15272. },
  15273. /**
  15274. * @private
  15275. * @param {number} x
  15276. * @param {number} y
  15277. * @param {module:zrender/graphic/Displayable} exclude
  15278. * @method
  15279. */
  15280. findHover: function(x, y, exclude) {
  15281. var list = this.storage.getDisplayList();
  15282. for (var i = list.length - 1; i >= 0 ; i--) {
  15283. if (!list[i].silent
  15284. && list[i] !== exclude
  15285. // getDisplayList may include ignored item in VML mode
  15286. && !list[i].ignore
  15287. && isHover(list[i], x, y)) {
  15288. return list[i];
  15289. }
  15290. }
  15291. }
  15292. };
  15293. // Common handlers
  15294. util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
  15295. Handler.prototype[name] = function (event) {
  15296. // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover
  15297. var hovered = this.findHover(event.zrX, event.zrY, null);
  15298. if (name === 'mousedown') {
  15299. this._downel = hovered;
  15300. // In case click triggered before mouseup
  15301. this._upel = hovered;
  15302. }
  15303. else if (name === 'mosueup') {
  15304. this._upel = hovered;
  15305. }
  15306. else if (name === 'click') {
  15307. if (this._downel !== this._upel) {
  15308. return;
  15309. }
  15310. }
  15311. this.dispatchToElement(hovered, name, event);
  15312. };
  15313. });
  15314. function isHover(displayable, x, y) {
  15315. if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) {
  15316. var el = displayable;
  15317. while (el) {
  15318. // If ancestor is silent or clipped by ancestor
  15319. if (el.silent || (el.clipPath && !el.clipPath.contain(x, y))) {
  15320. return false;
  15321. }
  15322. el = el.parent;
  15323. }
  15324. return true;
  15325. }
  15326. return false;
  15327. }
  15328. util.mixin(Handler, Eventful);
  15329. util.mixin(Handler, Draggable);
  15330. module.exports = Handler;
  15331. /***/ },
  15332. /* 84 */
  15333. /***/ function(module, exports) {
  15334. // TODO Draggable for group
  15335. // FIXME Draggable on element which has parent rotation or scale
  15336. function Draggable() {
  15337. this.on('mousedown', this._dragStart, this);
  15338. this.on('mousemove', this._drag, this);
  15339. this.on('mouseup', this._dragEnd, this);
  15340. this.on('globalout', this._dragEnd, this);
  15341. // this._dropTarget = null;
  15342. // this._draggingTarget = null;
  15343. // this._x = 0;
  15344. // this._y = 0;
  15345. }
  15346. Draggable.prototype = {
  15347. constructor: Draggable,
  15348. _dragStart: function (e) {
  15349. var draggingTarget = e.target;
  15350. if (draggingTarget && draggingTarget.draggable) {
  15351. this._draggingTarget = draggingTarget;
  15352. draggingTarget.dragging = true;
  15353. this._x = e.offsetX;
  15354. this._y = e.offsetY;
  15355. this.dispatchToElement(draggingTarget, 'dragstart', e.event);
  15356. }
  15357. },
  15358. _drag: function (e) {
  15359. var draggingTarget = this._draggingTarget;
  15360. if (draggingTarget) {
  15361. var x = e.offsetX;
  15362. var y = e.offsetY;
  15363. var dx = x - this._x;
  15364. var dy = y - this._y;
  15365. this._x = x;
  15366. this._y = y;
  15367. draggingTarget.drift(dx, dy, e);
  15368. this.dispatchToElement(draggingTarget, 'drag', e.event);
  15369. var dropTarget = this.findHover(x, y, draggingTarget);
  15370. var lastDropTarget = this._dropTarget;
  15371. this._dropTarget = dropTarget;
  15372. if (draggingTarget !== dropTarget) {
  15373. if (lastDropTarget && dropTarget !== lastDropTarget) {
  15374. this.dispatchToElement(lastDropTarget, 'dragleave', e.event);
  15375. }
  15376. if (dropTarget && dropTarget !== lastDropTarget) {
  15377. this.dispatchToElement(dropTarget, 'dragenter', e.event);
  15378. }
  15379. }
  15380. }
  15381. },
  15382. _dragEnd: function (e) {
  15383. var draggingTarget = this._draggingTarget;
  15384. if (draggingTarget) {
  15385. draggingTarget.dragging = false;
  15386. }
  15387. this.dispatchToElement(draggingTarget, 'dragend', e.event);
  15388. if (this._dropTarget) {
  15389. this.dispatchToElement(this._dropTarget, 'drop', e.event);
  15390. }
  15391. this._draggingTarget = null;
  15392. this._dropTarget = null;
  15393. }
  15394. };
  15395. module.exports = Draggable;
  15396. /***/ },
  15397. /* 85 */
  15398. /***/ function(module, exports, __webpack_require__) {
  15399. 'use strict';
  15400. /**
  15401. * Storage内容仓库模块
  15402. * @module zrender/Storage
  15403. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  15404. * @author errorrik (errorrik@gmail.com)
  15405. * @author pissang (https://github.com/pissang/)
  15406. */
  15407. var util = __webpack_require__(4);
  15408. var env = __webpack_require__(2);
  15409. var Group = __webpack_require__(30);
  15410. // Use timsort because in most case elements are partially sorted
  15411. // https://jsfiddle.net/pissang/jr4x7mdm/8/
  15412. var timsort = __webpack_require__(86);
  15413. function shapeCompareFunc(a, b) {
  15414. if (a.zlevel === b.zlevel) {
  15415. if (a.z === b.z) {
  15416. // if (a.z2 === b.z2) {
  15417. // // FIXME Slow has renderidx compare
  15418. // // http://stackoverflow.com/questions/20883421/sorting-in-javascript-should-every-compare-function-have-a-return-0-statement
  15419. // // https://github.com/v8/v8/blob/47cce544a31ed5577ffe2963f67acb4144ee0232/src/js/array.js#L1012
  15420. // return a.__renderidx - b.__renderidx;
  15421. // }
  15422. return a.z2 - b.z2;
  15423. }
  15424. return a.z - b.z;
  15425. }
  15426. return a.zlevel - b.zlevel;
  15427. }
  15428. /**
  15429. * 内容仓库 (M)
  15430. * @alias module:zrender/Storage
  15431. * @constructor
  15432. */
  15433. var Storage = function () {
  15434. // 所有常规形状,id索引的map
  15435. this._elements = {};
  15436. this._roots = [];
  15437. this._displayList = [];
  15438. this._displayListLen = 0;
  15439. };
  15440. Storage.prototype = {
  15441. constructor: Storage,
  15442. /**
  15443. * @param {Function} cb
  15444. *
  15445. */
  15446. traverse: function (cb, context) {
  15447. for (var i = 0; i < this._roots.length; i++) {
  15448. this._roots[i].traverse(cb, context);
  15449. }
  15450. },
  15451. /**
  15452. * 返回所有图形的绘制队列
  15453. * @param {boolean} [update=false] 是否在返回前更新该数组
  15454. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效
  15455. *
  15456. * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList}
  15457. * @return {Array.<module:zrender/graphic/Displayable>}
  15458. */
  15459. getDisplayList: function (update, includeIgnore) {
  15460. includeIgnore = includeIgnore || false;
  15461. if (update) {
  15462. this.updateDisplayList(includeIgnore);
  15463. }
  15464. return this._displayList;
  15465. },
  15466. /**
  15467. * 更新图形的绘制队列。
  15468. * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中,
  15469. * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列
  15470. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组
  15471. */
  15472. updateDisplayList: function (includeIgnore) {
  15473. this._displayListLen = 0;
  15474. var roots = this._roots;
  15475. var displayList = this._displayList;
  15476. for (var i = 0, len = roots.length; i < len; i++) {
  15477. this._updateAndAddDisplayable(roots[i], null, includeIgnore);
  15478. }
  15479. displayList.length = this._displayListLen;
  15480. // for (var i = 0, len = displayList.length; i < len; i++) {
  15481. // displayList[i].__renderidx = i;
  15482. // }
  15483. // displayList.sort(shapeCompareFunc);
  15484. env.canvasSupported && timsort(displayList, shapeCompareFunc);
  15485. },
  15486. _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) {
  15487. if (el.ignore && !includeIgnore) {
  15488. return;
  15489. }
  15490. el.beforeUpdate();
  15491. if (el.__dirty) {
  15492. el.update();
  15493. }
  15494. el.afterUpdate();
  15495. var clipPath = el.clipPath;
  15496. if (clipPath) {
  15497. // clipPath 的变换是基于 group 的变换
  15498. clipPath.parent = el;
  15499. clipPath.updateTransform();
  15500. // FIXME 效率影响
  15501. if (clipPaths) {
  15502. clipPaths = clipPaths.slice();
  15503. clipPaths.push(clipPath);
  15504. }
  15505. else {
  15506. clipPaths = [clipPath];
  15507. }
  15508. }
  15509. if (el.isGroup) {
  15510. var children = el._children;
  15511. for (var i = 0; i < children.length; i++) {
  15512. var child = children[i];
  15513. // Force to mark as dirty if group is dirty
  15514. // FIXME __dirtyPath ?
  15515. if (el.__dirty) {
  15516. child.__dirty = true;
  15517. }
  15518. this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
  15519. }
  15520. // Mark group clean here
  15521. el.__dirty = false;
  15522. }
  15523. else {
  15524. el.__clipPaths = clipPaths;
  15525. this._displayList[this._displayListLen++] = el;
  15526. }
  15527. },
  15528. /**
  15529. * 添加图形(Shape)或者组(Group)到根节点
  15530. * @param {module:zrender/Element} el
  15531. */
  15532. addRoot: function (el) {
  15533. // Element has been added
  15534. if (this._elements[el.id]) {
  15535. return;
  15536. }
  15537. if (el instanceof Group) {
  15538. el.addChildrenToStorage(this);
  15539. }
  15540. this.addToMap(el);
  15541. this._roots.push(el);
  15542. },
  15543. /**
  15544. * 删除指定的图形(Shape)或者组(Group)
  15545. * @param {string|Array.<string>} [elId] 如果为空清空整个Storage
  15546. */
  15547. delRoot: function (elId) {
  15548. if (elId == null) {
  15549. // 不指定elId清空
  15550. for (var i = 0; i < this._roots.length; i++) {
  15551. var root = this._roots[i];
  15552. if (root instanceof Group) {
  15553. root.delChildrenFromStorage(this);
  15554. }
  15555. }
  15556. this._elements = {};
  15557. this._roots = [];
  15558. this._displayList = [];
  15559. this._displayListLen = 0;
  15560. return;
  15561. }
  15562. if (elId instanceof Array) {
  15563. for (var i = 0, l = elId.length; i < l; i++) {
  15564. this.delRoot(elId[i]);
  15565. }
  15566. return;
  15567. }
  15568. var el;
  15569. if (typeof(elId) == 'string') {
  15570. el = this._elements[elId];
  15571. }
  15572. else {
  15573. el = elId;
  15574. }
  15575. var idx = util.indexOf(this._roots, el);
  15576. if (idx >= 0) {
  15577. this.delFromMap(el.id);
  15578. this._roots.splice(idx, 1);
  15579. if (el instanceof Group) {
  15580. el.delChildrenFromStorage(this);
  15581. }
  15582. }
  15583. },
  15584. addToMap: function (el) {
  15585. if (el instanceof Group) {
  15586. el.__storage = this;
  15587. }
  15588. el.dirty(false);
  15589. this._elements[el.id] = el;
  15590. return this;
  15591. },
  15592. get: function (elId) {
  15593. return this._elements[elId];
  15594. },
  15595. delFromMap: function (elId) {
  15596. var elements = this._elements;
  15597. var el = elements[elId];
  15598. if (el) {
  15599. delete elements[elId];
  15600. if (el instanceof Group) {
  15601. el.__storage = null;
  15602. }
  15603. }
  15604. return this;
  15605. },
  15606. /**
  15607. * 清空并且释放Storage
  15608. */
  15609. dispose: function () {
  15610. this._elements =
  15611. this._renderList =
  15612. this._roots = null;
  15613. },
  15614. displayableSortFunc: shapeCompareFunc
  15615. };
  15616. module.exports = Storage;
  15617. /***/ },
  15618. /* 86 */
  15619. /***/ function(module, exports) {
  15620. // https://github.com/mziccard/node-timsort
  15621. var DEFAULT_MIN_MERGE = 32;
  15622. var DEFAULT_MIN_GALLOPING = 7;
  15623. var DEFAULT_TMP_STORAGE_LENGTH = 256;
  15624. function minRunLength(n) {
  15625. var r = 0;
  15626. while (n >= DEFAULT_MIN_MERGE) {
  15627. r |= n & 1;
  15628. n >>= 1;
  15629. }
  15630. return n + r;
  15631. }
  15632. function makeAscendingRun(array, lo, hi, compare) {
  15633. var runHi = lo + 1;
  15634. if (runHi === hi) {
  15635. return 1;
  15636. }
  15637. if (compare(array[runHi++], array[lo]) < 0) {
  15638. while (runHi < hi && compare(array[runHi], array[runHi - 1]) < 0) {
  15639. runHi++;
  15640. }
  15641. reverseRun(array, lo, runHi);
  15642. }
  15643. else {
  15644. while (runHi < hi && compare(array[runHi], array[runHi - 1]) >= 0) {
  15645. runHi++;
  15646. }
  15647. }
  15648. return runHi - lo;
  15649. }
  15650. function reverseRun(array, lo, hi) {
  15651. hi--;
  15652. while (lo < hi) {
  15653. var t = array[lo];
  15654. array[lo++] = array[hi];
  15655. array[hi--] = t;
  15656. }
  15657. }
  15658. function binaryInsertionSort(array, lo, hi, start, compare) {
  15659. if (start === lo) {
  15660. start++;
  15661. }
  15662. for (; start < hi; start++) {
  15663. var pivot = array[start];
  15664. var left = lo;
  15665. var right = start;
  15666. var mid;
  15667. while (left < right) {
  15668. mid = left + right >>> 1;
  15669. if (compare(pivot, array[mid]) < 0) {
  15670. right = mid;
  15671. }
  15672. else {
  15673. left = mid + 1;
  15674. }
  15675. }
  15676. var n = start - left;
  15677. switch (n) {
  15678. case 3:
  15679. array[left + 3] = array[left + 2];
  15680. case 2:
  15681. array[left + 2] = array[left + 1];
  15682. case 1:
  15683. array[left + 1] = array[left];
  15684. break;
  15685. default:
  15686. while (n > 0) {
  15687. array[left + n] = array[left + n - 1];
  15688. n--;
  15689. }
  15690. }
  15691. array[left] = pivot;
  15692. }
  15693. }
  15694. function gallopLeft(value, array, start, length, hint, compare) {
  15695. var lastOffset = 0;
  15696. var maxOffset = 0;
  15697. var offset = 1;
  15698. if (compare(value, array[start + hint]) > 0) {
  15699. maxOffset = length - hint;
  15700. while (offset < maxOffset && compare(value, array[start + hint + offset]) > 0) {
  15701. lastOffset = offset;
  15702. offset = (offset << 1) + 1;
  15703. if (offset <= 0) {
  15704. offset = maxOffset;
  15705. }
  15706. }
  15707. if (offset > maxOffset) {
  15708. offset = maxOffset;
  15709. }
  15710. lastOffset += hint;
  15711. offset += hint;
  15712. }
  15713. else {
  15714. maxOffset = hint + 1;
  15715. while (offset < maxOffset && compare(value, array[start + hint - offset]) <= 0) {
  15716. lastOffset = offset;
  15717. offset = (offset << 1) + 1;
  15718. if (offset <= 0) {
  15719. offset = maxOffset;
  15720. }
  15721. }
  15722. if (offset > maxOffset) {
  15723. offset = maxOffset;
  15724. }
  15725. var tmp = lastOffset;
  15726. lastOffset = hint - offset;
  15727. offset = hint - tmp;
  15728. }
  15729. lastOffset++;
  15730. while (lastOffset < offset) {
  15731. var m = lastOffset + (offset - lastOffset >>> 1);
  15732. if (compare(value, array[start + m]) > 0) {
  15733. lastOffset = m + 1;
  15734. }
  15735. else {
  15736. offset = m;
  15737. }
  15738. }
  15739. return offset;
  15740. }
  15741. function gallopRight(value, array, start, length, hint, compare) {
  15742. var lastOffset = 0;
  15743. var maxOffset = 0;
  15744. var offset = 1;
  15745. if (compare(value, array[start + hint]) < 0) {
  15746. maxOffset = hint + 1;
  15747. while (offset < maxOffset && compare(value, array[start + hint - offset]) < 0) {
  15748. lastOffset = offset;
  15749. offset = (offset << 1) + 1;
  15750. if (offset <= 0) {
  15751. offset = maxOffset;
  15752. }
  15753. }
  15754. if (offset > maxOffset) {
  15755. offset = maxOffset;
  15756. }
  15757. var tmp = lastOffset;
  15758. lastOffset = hint - offset;
  15759. offset = hint - tmp;
  15760. }
  15761. else {
  15762. maxOffset = length - hint;
  15763. while (offset < maxOffset && compare(value, array[start + hint + offset]) >= 0) {
  15764. lastOffset = offset;
  15765. offset = (offset << 1) + 1;
  15766. if (offset <= 0) {
  15767. offset = maxOffset;
  15768. }
  15769. }
  15770. if (offset > maxOffset) {
  15771. offset = maxOffset;
  15772. }
  15773. lastOffset += hint;
  15774. offset += hint;
  15775. }
  15776. lastOffset++;
  15777. while (lastOffset < offset) {
  15778. var m = lastOffset + (offset - lastOffset >>> 1);
  15779. if (compare(value, array[start + m]) < 0) {
  15780. offset = m;
  15781. }
  15782. else {
  15783. lastOffset = m + 1;
  15784. }
  15785. }
  15786. return offset;
  15787. }
  15788. function TimSort(array, compare) {
  15789. var minGallop = DEFAULT_MIN_GALLOPING;
  15790. var length = 0;
  15791. var tmpStorageLength = DEFAULT_TMP_STORAGE_LENGTH;
  15792. var stackLength = 0;
  15793. var runStart;
  15794. var runLength;
  15795. var stackSize = 0;
  15796. length = array.length;
  15797. if (length < 2 * DEFAULT_TMP_STORAGE_LENGTH) {
  15798. tmpStorageLength = length >>> 1;
  15799. }
  15800. var tmp = [];
  15801. stackLength = length < 120 ? 5 : length < 1542 ? 10 : length < 119151 ? 19 : 40;
  15802. runStart = [];
  15803. runLength = [];
  15804. function pushRun(_runStart, _runLength) {
  15805. runStart[stackSize] = _runStart;
  15806. runLength[stackSize] = _runLength;
  15807. stackSize += 1;
  15808. }
  15809. function mergeRuns() {
  15810. while (stackSize > 1) {
  15811. var n = stackSize - 2;
  15812. if (n >= 1 && runLength[n - 1] <= runLength[n] + runLength[n + 1] || n >= 2 && runLength[n - 2] <= runLength[n] + runLength[n - 1]) {
  15813. if (runLength[n - 1] < runLength[n + 1]) {
  15814. n--;
  15815. }
  15816. }
  15817. else if (runLength[n] > runLength[n + 1]) {
  15818. break;
  15819. }
  15820. mergeAt(n);
  15821. }
  15822. }
  15823. function forceMergeRuns() {
  15824. while (stackSize > 1) {
  15825. var n = stackSize - 2;
  15826. if (n > 0 && runLength[n - 1] < runLength[n + 1]) {
  15827. n--;
  15828. }
  15829. mergeAt(n);
  15830. }
  15831. }
  15832. function mergeAt(i) {
  15833. var start1 = runStart[i];
  15834. var length1 = runLength[i];
  15835. var start2 = runStart[i + 1];
  15836. var length2 = runLength[i + 1];
  15837. runLength[i] = length1 + length2;
  15838. if (i === stackSize - 3) {
  15839. runStart[i + 1] = runStart[i + 2];
  15840. runLength[i + 1] = runLength[i + 2];
  15841. }
  15842. stackSize--;
  15843. var k = gallopRight(array[start2], array, start1, length1, 0, compare);
  15844. start1 += k;
  15845. length1 -= k;
  15846. if (length1 === 0) {
  15847. return;
  15848. }
  15849. length2 = gallopLeft(array[start1 + length1 - 1], array, start2, length2, length2 - 1, compare);
  15850. if (length2 === 0) {
  15851. return;
  15852. }
  15853. if (length1 <= length2) {
  15854. mergeLow(start1, length1, start2, length2);
  15855. }
  15856. else {
  15857. mergeHigh(start1, length1, start2, length2);
  15858. }
  15859. }
  15860. function mergeLow(start1, length1, start2, length2) {
  15861. var i = 0;
  15862. for (i = 0; i < length1; i++) {
  15863. tmp[i] = array[start1 + i];
  15864. }
  15865. var cursor1 = 0;
  15866. var cursor2 = start2;
  15867. var dest = start1;
  15868. array[dest++] = array[cursor2++];
  15869. if (--length2 === 0) {
  15870. for (i = 0; i < length1; i++) {
  15871. array[dest + i] = tmp[cursor1 + i];
  15872. }
  15873. return;
  15874. }
  15875. if (length1 === 1) {
  15876. for (i = 0; i < length2; i++) {
  15877. array[dest + i] = array[cursor2 + i];
  15878. }
  15879. array[dest + length2] = tmp[cursor1];
  15880. return;
  15881. }
  15882. var _minGallop = minGallop;
  15883. var count1, count2, exit;
  15884. while (1) {
  15885. count1 = 0;
  15886. count2 = 0;
  15887. exit = false;
  15888. do {
  15889. if (compare(array[cursor2], tmp[cursor1]) < 0) {
  15890. array[dest++] = array[cursor2++];
  15891. count2++;
  15892. count1 = 0;
  15893. if (--length2 === 0) {
  15894. exit = true;
  15895. break;
  15896. }
  15897. }
  15898. else {
  15899. array[dest++] = tmp[cursor1++];
  15900. count1++;
  15901. count2 = 0;
  15902. if (--length1 === 1) {
  15903. exit = true;
  15904. break;
  15905. }
  15906. }
  15907. } while ((count1 | count2) < _minGallop);
  15908. if (exit) {
  15909. break;
  15910. }
  15911. do {
  15912. count1 = gallopRight(array[cursor2], tmp, cursor1, length1, 0, compare);
  15913. if (count1 !== 0) {
  15914. for (i = 0; i < count1; i++) {
  15915. array[dest + i] = tmp[cursor1 + i];
  15916. }
  15917. dest += count1;
  15918. cursor1 += count1;
  15919. length1 -= count1;
  15920. if (length1 <= 1) {
  15921. exit = true;
  15922. break;
  15923. }
  15924. }
  15925. array[dest++] = array[cursor2++];
  15926. if (--length2 === 0) {
  15927. exit = true;
  15928. break;
  15929. }
  15930. count2 = gallopLeft(tmp[cursor1], array, cursor2, length2, 0, compare);
  15931. if (count2 !== 0) {
  15932. for (i = 0; i < count2; i++) {
  15933. array[dest + i] = array[cursor2 + i];
  15934. }
  15935. dest += count2;
  15936. cursor2 += count2;
  15937. length2 -= count2;
  15938. if (length2 === 0) {
  15939. exit = true;
  15940. break;
  15941. }
  15942. }
  15943. array[dest++] = tmp[cursor1++];
  15944. if (--length1 === 1) {
  15945. exit = true;
  15946. break;
  15947. }
  15948. _minGallop--;
  15949. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  15950. if (exit) {
  15951. break;
  15952. }
  15953. if (_minGallop < 0) {
  15954. _minGallop = 0;
  15955. }
  15956. _minGallop += 2;
  15957. }
  15958. minGallop = _minGallop;
  15959. minGallop < 1 && (minGallop = 1);
  15960. if (length1 === 1) {
  15961. for (i = 0; i < length2; i++) {
  15962. array[dest + i] = array[cursor2 + i];
  15963. }
  15964. array[dest + length2] = tmp[cursor1];
  15965. }
  15966. else if (length1 === 0) {
  15967. throw new Error();
  15968. // throw new Error('mergeLow preconditions were not respected');
  15969. }
  15970. else {
  15971. for (i = 0; i < length1; i++) {
  15972. array[dest + i] = tmp[cursor1 + i];
  15973. }
  15974. }
  15975. }
  15976. function mergeHigh (start1, length1, start2, length2) {
  15977. var i = 0;
  15978. for (i = 0; i < length2; i++) {
  15979. tmp[i] = array[start2 + i];
  15980. }
  15981. var cursor1 = start1 + length1 - 1;
  15982. var cursor2 = length2 - 1;
  15983. var dest = start2 + length2 - 1;
  15984. var customCursor = 0;
  15985. var customDest = 0;
  15986. array[dest--] = array[cursor1--];
  15987. if (--length1 === 0) {
  15988. customCursor = dest - (length2 - 1);
  15989. for (i = 0; i < length2; i++) {
  15990. array[customCursor + i] = tmp[i];
  15991. }
  15992. return;
  15993. }
  15994. if (length2 === 1) {
  15995. dest -= length1;
  15996. cursor1 -= length1;
  15997. customDest = dest + 1;
  15998. customCursor = cursor1 + 1;
  15999. for (i = length1 - 1; i >= 0; i--) {
  16000. array[customDest + i] = array[customCursor + i];
  16001. }
  16002. array[dest] = tmp[cursor2];
  16003. return;
  16004. }
  16005. var _minGallop = minGallop;
  16006. while (true) {
  16007. var count1 = 0;
  16008. var count2 = 0;
  16009. var exit = false;
  16010. do {
  16011. if (compare(tmp[cursor2], array[cursor1]) < 0) {
  16012. array[dest--] = array[cursor1--];
  16013. count1++;
  16014. count2 = 0;
  16015. if (--length1 === 0) {
  16016. exit = true;
  16017. break;
  16018. }
  16019. }
  16020. else {
  16021. array[dest--] = tmp[cursor2--];
  16022. count2++;
  16023. count1 = 0;
  16024. if (--length2 === 1) {
  16025. exit = true;
  16026. break;
  16027. }
  16028. }
  16029. } while ((count1 | count2) < _minGallop);
  16030. if (exit) {
  16031. break;
  16032. }
  16033. do {
  16034. count1 = length1 - gallopRight(tmp[cursor2], array, start1, length1, length1 - 1, compare);
  16035. if (count1 !== 0) {
  16036. dest -= count1;
  16037. cursor1 -= count1;
  16038. length1 -= count1;
  16039. customDest = dest + 1;
  16040. customCursor = cursor1 + 1;
  16041. for (i = count1 - 1; i >= 0; i--) {
  16042. array[customDest + i] = array[customCursor + i];
  16043. }
  16044. if (length1 === 0) {
  16045. exit = true;
  16046. break;
  16047. }
  16048. }
  16049. array[dest--] = tmp[cursor2--];
  16050. if (--length2 === 1) {
  16051. exit = true;
  16052. break;
  16053. }
  16054. count2 = length2 - gallopLeft(array[cursor1], tmp, 0, length2, length2 - 1, compare);
  16055. if (count2 !== 0) {
  16056. dest -= count2;
  16057. cursor2 -= count2;
  16058. length2 -= count2;
  16059. customDest = dest + 1;
  16060. customCursor = cursor2 + 1;
  16061. for (i = 0; i < count2; i++) {
  16062. array[customDest + i] = tmp[customCursor + i];
  16063. }
  16064. if (length2 <= 1) {
  16065. exit = true;
  16066. break;
  16067. }
  16068. }
  16069. array[dest--] = array[cursor1--];
  16070. if (--length1 === 0) {
  16071. exit = true;
  16072. break;
  16073. }
  16074. _minGallop--;
  16075. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  16076. if (exit) {
  16077. break;
  16078. }
  16079. if (_minGallop < 0) {
  16080. _minGallop = 0;
  16081. }
  16082. _minGallop += 2;
  16083. }
  16084. minGallop = _minGallop;
  16085. if (minGallop < 1) {
  16086. minGallop = 1;
  16087. }
  16088. if (length2 === 1) {
  16089. dest -= length1;
  16090. cursor1 -= length1;
  16091. customDest = dest + 1;
  16092. customCursor = cursor1 + 1;
  16093. for (i = length1 - 1; i >= 0; i--) {
  16094. array[customDest + i] = array[customCursor + i];
  16095. }
  16096. array[dest] = tmp[cursor2];
  16097. }
  16098. else if (length2 === 0) {
  16099. throw new Error();
  16100. // throw new Error('mergeHigh preconditions were not respected');
  16101. }
  16102. else {
  16103. customCursor = dest - (length2 - 1);
  16104. for (i = 0; i < length2; i++) {
  16105. array[customCursor + i] = tmp[i];
  16106. }
  16107. }
  16108. }
  16109. this.mergeRuns = mergeRuns;
  16110. this.forceMergeRuns = forceMergeRuns;
  16111. this.pushRun = pushRun;
  16112. }
  16113. function sort(array, compare, lo, hi) {
  16114. if (!lo) {
  16115. lo = 0;
  16116. }
  16117. if (!hi) {
  16118. hi = array.length;
  16119. }
  16120. var remaining = hi - lo;
  16121. if (remaining < 2) {
  16122. return;
  16123. }
  16124. var runLength = 0;
  16125. if (remaining < DEFAULT_MIN_MERGE) {
  16126. runLength = makeAscendingRun(array, lo, hi, compare);
  16127. binaryInsertionSort(array, lo, hi, lo + runLength, compare);
  16128. return;
  16129. }
  16130. var ts = new TimSort(array, compare);
  16131. var minRun = minRunLength(remaining);
  16132. do {
  16133. runLength = makeAscendingRun(array, lo, hi, compare);
  16134. if (runLength < minRun) {
  16135. var force = remaining;
  16136. if (force > minRun) {
  16137. force = minRun;
  16138. }
  16139. binaryInsertionSort(array, lo, lo + force, lo + runLength, compare);
  16140. runLength = force;
  16141. }
  16142. ts.pushRun(lo, runLength);
  16143. ts.mergeRuns();
  16144. remaining -= runLength;
  16145. lo += runLength;
  16146. } while (remaining !== 0);
  16147. ts.forceMergeRuns();
  16148. }
  16149. module.exports = sort;
  16150. /***/ },
  16151. /* 87 */
  16152. /***/ function(module, exports, __webpack_require__) {
  16153. 'use strict';
  16154. /**
  16155. * 动画主类, 调度和管理所有动画控制器
  16156. *
  16157. * @module zrender/animation/Animation
  16158. * @author pissang(https://github.com/pissang)
  16159. */
  16160. // TODO Additive animation
  16161. // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/
  16162. // https://developer.apple.com/videos/wwdc2014/#236
  16163. var util = __webpack_require__(4);
  16164. var Dispatcher = __webpack_require__(88).Dispatcher;
  16165. var requestAnimationFrame = __webpack_require__(89);
  16166. var Animator = __webpack_require__(36);
  16167. /**
  16168. * @typedef {Object} IZRenderStage
  16169. * @property {Function} update
  16170. */
  16171. /**
  16172. * @alias module:zrender/animation/Animation
  16173. * @constructor
  16174. * @param {Object} [options]
  16175. * @param {Function} [options.onframe]
  16176. * @param {IZRenderStage} [options.stage]
  16177. * @example
  16178. * var animation = new Animation();
  16179. * var obj = {
  16180. * x: 100,
  16181. * y: 100
  16182. * };
  16183. * animation.animate(node.position)
  16184. * .when(1000, {
  16185. * x: 500,
  16186. * y: 500
  16187. * })
  16188. * .when(2000, {
  16189. * x: 100,
  16190. * y: 100
  16191. * })
  16192. * .start('spline');
  16193. */
  16194. var Animation = function (options) {
  16195. options = options || {};
  16196. this.stage = options.stage || {};
  16197. this.onframe = options.onframe || function() {};
  16198. // private properties
  16199. this._clips = [];
  16200. this._running = false;
  16201. this._time;
  16202. this._pausedTime;
  16203. this._pauseStart;
  16204. this._paused = false;
  16205. Dispatcher.call(this);
  16206. };
  16207. Animation.prototype = {
  16208. constructor: Animation,
  16209. /**
  16210. * 添加 clip
  16211. * @param {module:zrender/animation/Clip} clip
  16212. */
  16213. addClip: function (clip) {
  16214. this._clips.push(clip);
  16215. },
  16216. /**
  16217. * 添加 animator
  16218. * @param {module:zrender/animation/Animator} animator
  16219. */
  16220. addAnimator: function (animator) {
  16221. animator.animation = this;
  16222. var clips = animator.getClips();
  16223. for (var i = 0; i < clips.length; i++) {
  16224. this.addClip(clips[i]);
  16225. }
  16226. },
  16227. /**
  16228. * 删除动画片段
  16229. * @param {module:zrender/animation/Clip} clip
  16230. */
  16231. removeClip: function(clip) {
  16232. var idx = util.indexOf(this._clips, clip);
  16233. if (idx >= 0) {
  16234. this._clips.splice(idx, 1);
  16235. }
  16236. },
  16237. /**
  16238. * 删除动画片段
  16239. * @param {module:zrender/animation/Animator} animator
  16240. */
  16241. removeAnimator: function (animator) {
  16242. var clips = animator.getClips();
  16243. for (var i = 0; i < clips.length; i++) {
  16244. this.removeClip(clips[i]);
  16245. }
  16246. animator.animation = null;
  16247. },
  16248. _update: function() {
  16249. var time = new Date().getTime() - this._pausedTime;
  16250. var delta = time - this._time;
  16251. var clips = this._clips;
  16252. var len = clips.length;
  16253. var deferredEvents = [];
  16254. var deferredClips = [];
  16255. for (var i = 0; i < len; i++) {
  16256. var clip = clips[i];
  16257. var e = clip.step(time);
  16258. // Throw out the events need to be called after
  16259. // stage.update, like destroy
  16260. if (e) {
  16261. deferredEvents.push(e);
  16262. deferredClips.push(clip);
  16263. }
  16264. }
  16265. // Remove the finished clip
  16266. for (var i = 0; i < len;) {
  16267. if (clips[i]._needsRemove) {
  16268. clips[i] = clips[len - 1];
  16269. clips.pop();
  16270. len--;
  16271. }
  16272. else {
  16273. i++;
  16274. }
  16275. }
  16276. len = deferredEvents.length;
  16277. for (var i = 0; i < len; i++) {
  16278. deferredClips[i].fire(deferredEvents[i]);
  16279. }
  16280. this._time = time;
  16281. this.onframe(delta);
  16282. this.trigger('frame', delta);
  16283. if (this.stage.update) {
  16284. this.stage.update();
  16285. }
  16286. },
  16287. _startLoop: function () {
  16288. var self = this;
  16289. this._running = true;
  16290. function step() {
  16291. if (self._running) {
  16292. requestAnimationFrame(step);
  16293. !self._paused && self._update();
  16294. }
  16295. }
  16296. requestAnimationFrame(step);
  16297. },
  16298. /**
  16299. * 开始运行动画
  16300. */
  16301. start: function () {
  16302. this._time = new Date().getTime();
  16303. this._pausedTime = 0;
  16304. this._startLoop();
  16305. },
  16306. /**
  16307. * 停止运行动画
  16308. */
  16309. stop: function () {
  16310. this._running = false;
  16311. },
  16312. /**
  16313. * Pause
  16314. */
  16315. pause: function () {
  16316. if (!this._paused) {
  16317. this._pauseStart = new Date().getTime();
  16318. this._paused = true;
  16319. }
  16320. },
  16321. /**
  16322. * Resume
  16323. */
  16324. resume: function () {
  16325. if (this._paused) {
  16326. this._pausedTime += (new Date().getTime()) - this._pauseStart;
  16327. this._paused = false;
  16328. }
  16329. },
  16330. /**
  16331. * 清除所有动画片段
  16332. */
  16333. clear: function () {
  16334. this._clips = [];
  16335. },
  16336. /**
  16337. * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画
  16338. * @param {Object} target
  16339. * @param {Object} options
  16340. * @param {boolean} [options.loop=false] 是否循环播放动画
  16341. * @param {Function} [options.getter=null]
  16342. * 如果指定getter函数,会通过getter函数取属性值
  16343. * @param {Function} [options.setter=null]
  16344. * 如果指定setter函数,会通过setter函数设置属性值
  16345. * @return {module:zrender/animation/Animation~Animator}
  16346. */
  16347. // TODO Gap
  16348. animate: function (target, options) {
  16349. options = options || {};
  16350. var animator = new Animator(
  16351. target,
  16352. options.loop,
  16353. options.getter,
  16354. options.setter
  16355. );
  16356. return animator;
  16357. }
  16358. };
  16359. util.mixin(Animation, Dispatcher);
  16360. module.exports = Animation;
  16361. /***/ },
  16362. /* 88 */
  16363. /***/ function(module, exports, __webpack_require__) {
  16364. 'use strict';
  16365. /**
  16366. * 事件辅助类
  16367. * @module zrender/core/event
  16368. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  16369. */
  16370. var Eventful = __webpack_require__(33);
  16371. var env = __webpack_require__(2);
  16372. var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
  16373. function getBoundingClientRect(el) {
  16374. // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect
  16375. return el.getBoundingClientRect ? el.getBoundingClientRect() : {left: 0, top: 0};
  16376. }
  16377. // `calculate` is optional, default false
  16378. function clientToLocal(el, e, out, calculate) {
  16379. out = out || {};
  16380. // According to the W3C Working Draft, offsetX and offsetY should be relative
  16381. // to the padding edge of the target element. The only browser using this convention
  16382. // is IE. Webkit uses the border edge, Opera uses the content edge, and FireFox does
  16383. // not support the properties.
  16384. // (see http://www.jacklmoore.com/notes/mouse-position/)
  16385. // In zr painter.dom, padding edge equals to border edge.
  16386. // FIXME
  16387. // When mousemove event triggered on ec tooltip, target is not zr painter.dom, and
  16388. // offsetX/Y is relative to e.target, where the calculation of zrX/Y via offsetX/Y
  16389. // is too complex. So css-transfrom dont support in this case temporarily.
  16390. if (calculate || !env.canvasSupported) {
  16391. defaultGetZrXY(el, e, out);
  16392. }
  16393. // Caution: In FireFox, layerX/layerY Mouse position relative to the closest positioned
  16394. // ancestor element, so we should make sure el is positioned (e.g., not position:static).
  16395. // BTW1, Webkit don't return the same results as FF in non-simple cases (like add
  16396. // zoom-factor, overflow / opacity layers, transforms ...)
  16397. // BTW2, (ev.offsetY || ev.pageY - $(ev.target).offset().top) is not correct in preserve-3d.
  16398. // <https://bugs.jquery.com/ticket/8523#comment:14>
  16399. // BTW3, In ff, offsetX/offsetY is always 0.
  16400. else if (env.browser.firefox && e.layerX != null && e.layerX !== e.offsetX) {
  16401. out.zrX = e.layerX;
  16402. out.zrY = e.layerY;
  16403. }
  16404. // For IE6+, chrome, safari, opera. (When will ff support offsetX?)
  16405. else if (e.offsetX != null) {
  16406. out.zrX = e.offsetX;
  16407. out.zrY = e.offsetY;
  16408. }
  16409. // For some other device, e.g., IOS safari.
  16410. else {
  16411. defaultGetZrXY(el, e, out);
  16412. }
  16413. return out;
  16414. }
  16415. function defaultGetZrXY(el, e, out) {
  16416. // This well-known method below does not support css transform.
  16417. var box = getBoundingClientRect(el);
  16418. out.zrX = e.clientX - box.left;
  16419. out.zrY = e.clientY - box.top;
  16420. }
  16421. /**
  16422. * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标.
  16423. * `calculate` is optional, default false.
  16424. */
  16425. function normalizeEvent(el, e, calculate) {
  16426. e = e || window.event;
  16427. if (e.zrX != null) {
  16428. return e;
  16429. }
  16430. var eventType = e.type;
  16431. var isTouch = eventType && eventType.indexOf('touch') >= 0;
  16432. if (!isTouch) {
  16433. clientToLocal(el, e, e, calculate);
  16434. e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3;
  16435. }
  16436. else {
  16437. var touch = eventType != 'touchend'
  16438. ? e.targetTouches[0]
  16439. : e.changedTouches[0];
  16440. touch && clientToLocal(el, touch, e, calculate);
  16441. }
  16442. return e;
  16443. }
  16444. function addEventListener(el, name, handler) {
  16445. if (isDomLevel2) {
  16446. el.addEventListener(name, handler);
  16447. }
  16448. else {
  16449. el.attachEvent('on' + name, handler);
  16450. }
  16451. }
  16452. function removeEventListener(el, name, handler) {
  16453. if (isDomLevel2) {
  16454. el.removeEventListener(name, handler);
  16455. }
  16456. else {
  16457. el.detachEvent('on' + name, handler);
  16458. }
  16459. }
  16460. /**
  16461. * 停止冒泡和阻止默认行为
  16462. * @memberOf module:zrender/core/event
  16463. * @method
  16464. * @param {Event} e : event对象
  16465. */
  16466. var stop = isDomLevel2
  16467. ? function (e) {
  16468. e.preventDefault();
  16469. e.stopPropagation();
  16470. e.cancelBubble = true;
  16471. }
  16472. : function (e) {
  16473. e.returnValue = false;
  16474. e.cancelBubble = true;
  16475. };
  16476. module.exports = {
  16477. clientToLocal: clientToLocal,
  16478. normalizeEvent: normalizeEvent,
  16479. addEventListener: addEventListener,
  16480. removeEventListener: removeEventListener,
  16481. stop: stop,
  16482. // 做向上兼容
  16483. Dispatcher: Eventful
  16484. };
  16485. /***/ },
  16486. /* 89 */
  16487. /***/ function(module, exports) {
  16488. module.exports = (typeof window !== 'undefined' &&
  16489. (window.requestAnimationFrame
  16490. || window.msRequestAnimationFrame
  16491. || window.mozRequestAnimationFrame
  16492. || window.webkitRequestAnimationFrame))
  16493. || function (func) {
  16494. setTimeout(func, 16);
  16495. };
  16496. /***/ },
  16497. /* 90 */
  16498. /***/ function(module, exports, __webpack_require__) {
  16499. var eventTool = __webpack_require__(88);
  16500. var zrUtil = __webpack_require__(4);
  16501. var Eventful = __webpack_require__(33);
  16502. var env = __webpack_require__(2);
  16503. var GestureMgr = __webpack_require__(91);
  16504. var addEventListener = eventTool.addEventListener;
  16505. var removeEventListener = eventTool.removeEventListener;
  16506. var normalizeEvent = eventTool.normalizeEvent;
  16507. var TOUCH_CLICK_DELAY = 300;
  16508. var mouseHandlerNames = [
  16509. 'click', 'dblclick', 'mousewheel', 'mouseout',
  16510. 'mouseup', 'mousedown', 'mousemove', 'contextmenu'
  16511. ];
  16512. var touchHandlerNames = [
  16513. 'touchstart', 'touchend', 'touchmove'
  16514. ];
  16515. function eventNameFix(name) {
  16516. return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name;
  16517. }
  16518. function processGesture(proxy, event, stage) {
  16519. var gestureMgr = proxy._gestureMgr;
  16520. stage === 'start' && gestureMgr.clear();
  16521. var gestureInfo = gestureMgr.recognize(
  16522. event,
  16523. proxy.handler.findHover(event.zrX, event.zrY, null),
  16524. proxy.dom
  16525. );
  16526. stage === 'end' && gestureMgr.clear();
  16527. if (gestureInfo) {
  16528. // eventTool.stop(event);
  16529. var type = gestureInfo.type;
  16530. event.gestureEvent = type;
  16531. proxy.handler.dispatchToElement(gestureInfo.target, type, gestureInfo.event);
  16532. }
  16533. }
  16534. /**
  16535. * Prevent mouse event from being dispatched after Touch Events action
  16536. * @see <https://github.com/deltakosh/handjs/blob/master/src/hand.base.js>
  16537. * 1. Mobile browsers dispatch mouse events 300ms after touchend.
  16538. * 2. Chrome for Android dispatch mousedown for long-touch about 650ms
  16539. * Result: Blocking Mouse Events for 700ms.
  16540. */
  16541. function setTouchTimer(instance) {
  16542. instance._touching = true;
  16543. clearTimeout(instance._touchTimer);
  16544. instance._touchTimer = setTimeout(function () {
  16545. instance._touching = false;
  16546. }, 700);
  16547. }
  16548. function useTouchEvent() {
  16549. return env.touchEventsSupported;
  16550. }
  16551. var domHandlers = {
  16552. /**
  16553. * Mouse move handler
  16554. * @inner
  16555. * @param {Event} event
  16556. */
  16557. mousemove: function (event) {
  16558. event = normalizeEvent(this.dom, event);
  16559. this.trigger('mousemove', event);
  16560. },
  16561. /**
  16562. * Mouse out handler
  16563. * @inner
  16564. * @param {Event} event
  16565. */
  16566. mouseout: function (event) {
  16567. event = normalizeEvent(this.dom, event);
  16568. var element = event.toElement || event.relatedTarget;
  16569. if (element != this.dom) {
  16570. while (element && element.nodeType != 9) {
  16571. // 忽略包含在root中的dom引起的mouseOut
  16572. if (element === this.dom) {
  16573. return;
  16574. }
  16575. element = element.parentNode;
  16576. }
  16577. }
  16578. this.trigger('mouseout', event);
  16579. },
  16580. /**
  16581. * Touch开始响应函数
  16582. * @inner
  16583. * @param {Event} event
  16584. */
  16585. touchstart: function (event) {
  16586. // Default mouse behaviour should not be disabled here.
  16587. // For example, page may needs to be slided.
  16588. event = normalizeEvent(this.dom, event);
  16589. // Mark touch, which is useful in distinguish touch and
  16590. // mouse event in upper applicatoin.
  16591. event.zrByTouch = true;
  16592. this._lastTouchMoment = new Date();
  16593. processGesture(this, event, 'start');
  16594. // In touch device, trigger `mousemove`(`mouseover`) should
  16595. // be triggered.
  16596. domHandlers.mousemove.call(this, event);
  16597. domHandlers.mousedown.call(this, event);
  16598. setTouchTimer(this);
  16599. },
  16600. /**
  16601. * Touch移动响应函数
  16602. * @inner
  16603. * @param {Event} event
  16604. */
  16605. touchmove: function (event) {
  16606. event = normalizeEvent(this.dom, event);
  16607. // Mark touch, which is useful in distinguish touch and
  16608. // mouse event in upper applicatoin.
  16609. event.zrByTouch = true;
  16610. processGesture(this, event, 'change');
  16611. // Mouse move should always be triggered no matter whether
  16612. // there is gestrue event, because mouse move and pinch may
  16613. // be used at the same time.
  16614. domHandlers.mousemove.call(this, event);
  16615. setTouchTimer(this);
  16616. },
  16617. /**
  16618. * Touch结束响应函数
  16619. * @inner
  16620. * @param {Event} event
  16621. */
  16622. touchend: function (event) {
  16623. event = normalizeEvent(this.dom, event);
  16624. // Mark touch, which is useful in distinguish touch and
  16625. // mouse event in upper applicatoin.
  16626. event.zrByTouch = true;
  16627. processGesture(this, event, 'end');
  16628. domHandlers.mouseup.call(this, event);
  16629. // Do not trigger `mouseout` here, in spite of `mousemove`(`mouseover`) is
  16630. // triggered in `touchstart`. This seems to be illogical, but by this mechanism,
  16631. // we can conveniently implement "hover style" in both PC and touch device just
  16632. // by listening to `mouseover` to add "hover style" and listening to `mouseout`
  16633. // to remove "hover style" on an element, without any additional code for
  16634. // compatibility. (`mouseout` will not be triggered in `touchend`, so "hover
  16635. // style" will remain for user view)
  16636. // click event should always be triggered no matter whether
  16637. // there is gestrue event. System click can not be prevented.
  16638. if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
  16639. domHandlers.click.call(this, event);
  16640. }
  16641. setTouchTimer(this);
  16642. }
  16643. };
  16644. // Common handlers
  16645. zrUtil.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
  16646. domHandlers[name] = function (event) {
  16647. event = normalizeEvent(this.dom, event);
  16648. this.trigger(name, event);
  16649. };
  16650. });
  16651. /**
  16652. * 为控制类实例初始化dom 事件处理函数
  16653. *
  16654. * @inner
  16655. * @param {module:zrender/Handler} instance 控制类实例
  16656. */
  16657. function initDomHandler(instance) {
  16658. for (var i = 0; i < touchHandlerNames.length; i++) {
  16659. var name = touchHandlerNames[i];
  16660. instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
  16661. }
  16662. for (var i = 0; i < mouseHandlerNames.length; i++) {
  16663. var name = mouseHandlerNames[i];
  16664. instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
  16665. }
  16666. function makeMouseHandler(fn, instance) {
  16667. return function () {
  16668. if (instance._touching) {
  16669. return;
  16670. }
  16671. return fn.apply(instance, arguments);
  16672. };
  16673. }
  16674. }
  16675. function HandlerDomProxy(dom) {
  16676. Eventful.call(this);
  16677. this.dom = dom;
  16678. /**
  16679. * @private
  16680. * @type {boolean}
  16681. */
  16682. this._touching = false;
  16683. /**
  16684. * @private
  16685. * @type {number}
  16686. */
  16687. this._touchTimer;
  16688. /**
  16689. * @private
  16690. * @type {module:zrender/core/GestureMgr}
  16691. */
  16692. this._gestureMgr = new GestureMgr();
  16693. this._handlers = {};
  16694. initDomHandler(this);
  16695. if (useTouchEvent()) {
  16696. mountHandlers(touchHandlerNames, this);
  16697. // Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
  16698. // addEventListener(root, 'mouseout', this._mouseoutHandler);
  16699. }
  16700. // Considering some devices that both enable touch and mouse event (like MS Surface
  16701. // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise
  16702. // mouse event can not be handle in those devices.
  16703. mountHandlers(mouseHandlerNames, this);
  16704. function mountHandlers(handlerNames, instance) {
  16705. zrUtil.each(handlerNames, function (name) {
  16706. addEventListener(dom, eventNameFix(name), instance._handlers[name]);
  16707. }, instance);
  16708. }
  16709. }
  16710. var handlerDomProxyProto = HandlerDomProxy.prototype;
  16711. handlerDomProxyProto.dispose = function () {
  16712. var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
  16713. for (var i = 0; i < handlerNames.length; i++) {
  16714. var name = handlerNames[i];
  16715. removeEventListener(this.dom, eventNameFix(name), this._handlers[name]);
  16716. }
  16717. };
  16718. handlerDomProxyProto.setCursor = function (cursorStyle) {
  16719. this.dom.style.cursor = cursorStyle || 'default';
  16720. };
  16721. zrUtil.mixin(HandlerDomProxy, Eventful);
  16722. module.exports = HandlerDomProxy;
  16723. /***/ },
  16724. /* 91 */
  16725. /***/ function(module, exports, __webpack_require__) {
  16726. 'use strict';
  16727. /**
  16728. * Only implements needed gestures for mobile.
  16729. */
  16730. var eventUtil = __webpack_require__(88);
  16731. var GestureMgr = function () {
  16732. /**
  16733. * @private
  16734. * @type {Array.<Object>}
  16735. */
  16736. this._track = [];
  16737. };
  16738. GestureMgr.prototype = {
  16739. constructor: GestureMgr,
  16740. recognize: function (event, target, root) {
  16741. this._doTrack(event, target, root);
  16742. return this._recognize(event);
  16743. },
  16744. clear: function () {
  16745. this._track.length = 0;
  16746. return this;
  16747. },
  16748. _doTrack: function (event, target, root) {
  16749. var touches = event.touches;
  16750. if (!touches) {
  16751. return;
  16752. }
  16753. var trackItem = {
  16754. points: [],
  16755. touches: [],
  16756. target: target,
  16757. event: event
  16758. };
  16759. for (var i = 0, len = touches.length; i < len; i++) {
  16760. var touch = touches[i];
  16761. var pos = eventUtil.clientToLocal(root, touch, {});
  16762. trackItem.points.push([pos.zrX, pos.zrY]);
  16763. trackItem.touches.push(touch);
  16764. }
  16765. this._track.push(trackItem);
  16766. },
  16767. _recognize: function (event) {
  16768. for (var eventName in recognizers) {
  16769. if (recognizers.hasOwnProperty(eventName)) {
  16770. var gestureInfo = recognizers[eventName](this._track, event);
  16771. if (gestureInfo) {
  16772. return gestureInfo;
  16773. }
  16774. }
  16775. }
  16776. }
  16777. };
  16778. function dist(pointPair) {
  16779. var dx = pointPair[1][0] - pointPair[0][0];
  16780. var dy = pointPair[1][1] - pointPair[0][1];
  16781. return Math.sqrt(dx * dx + dy * dy);
  16782. }
  16783. function center(pointPair) {
  16784. return [
  16785. (pointPair[0][0] + pointPair[1][0]) / 2,
  16786. (pointPair[0][1] + pointPair[1][1]) / 2
  16787. ];
  16788. }
  16789. var recognizers = {
  16790. pinch: function (track, event) {
  16791. var trackLen = track.length;
  16792. if (!trackLen) {
  16793. return;
  16794. }
  16795. var pinchEnd = (track[trackLen - 1] || {}).points;
  16796. var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd;
  16797. if (pinchPre
  16798. && pinchPre.length > 1
  16799. && pinchEnd
  16800. && pinchEnd.length > 1
  16801. ) {
  16802. var pinchScale = dist(pinchEnd) / dist(pinchPre);
  16803. !isFinite(pinchScale) && (pinchScale = 1);
  16804. event.pinchScale = pinchScale;
  16805. var pinchCenter = center(pinchEnd);
  16806. event.pinchX = pinchCenter[0];
  16807. event.pinchY = pinchCenter[1];
  16808. return {
  16809. type: 'pinch',
  16810. target: track[0].target,
  16811. event: event
  16812. };
  16813. }
  16814. }
  16815. // Only pinch currently.
  16816. };
  16817. module.exports = GestureMgr;
  16818. /***/ },
  16819. /* 92 */
  16820. /***/ function(module, exports, __webpack_require__) {
  16821. 'use strict';
  16822. /**
  16823. * Default canvas painter
  16824. * @module zrender/Painter
  16825. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  16826. * errorrik (errorrik@gmail.com)
  16827. * pissang (https://www.github.com/pissang)
  16828. */
  16829. var config = __webpack_require__(41);
  16830. var util = __webpack_require__(4);
  16831. var log = __webpack_require__(40);
  16832. var BoundingRect = __webpack_require__(9);
  16833. var timsort = __webpack_require__(86);
  16834. var Layer = __webpack_require__(93);
  16835. var requestAnimationFrame = __webpack_require__(89);
  16836. // PENDIGN
  16837. // Layer exceeds MAX_PROGRESSIVE_LAYER_NUMBER may have some problem when flush directly second time.
  16838. //
  16839. // Maximum progressive layer. When exceeding this number. All elements will be drawed in the last layer.
  16840. var MAX_PROGRESSIVE_LAYER_NUMBER = 5;
  16841. function parseInt10(val) {
  16842. return parseInt(val, 10);
  16843. }
  16844. function isLayerValid(layer) {
  16845. if (!layer) {
  16846. return false;
  16847. }
  16848. if (layer.isBuildin) {
  16849. return true;
  16850. }
  16851. if (typeof(layer.resize) !== 'function'
  16852. || typeof(layer.refresh) !== 'function'
  16853. ) {
  16854. return false;
  16855. }
  16856. return true;
  16857. }
  16858. function preProcessLayer(layer) {
  16859. layer.__unusedCount++;
  16860. }
  16861. function postProcessLayer(layer) {
  16862. if (layer.__unusedCount == 1) {
  16863. layer.clear();
  16864. }
  16865. }
  16866. var tmpRect = new BoundingRect(0, 0, 0, 0);
  16867. var viewRect = new BoundingRect(0, 0, 0, 0);
  16868. function isDisplayableCulled(el, width, height) {
  16869. tmpRect.copy(el.getBoundingRect());
  16870. if (el.transform) {
  16871. tmpRect.applyTransform(el.transform);
  16872. }
  16873. viewRect.width = width;
  16874. viewRect.height = height;
  16875. return !tmpRect.intersect(viewRect);
  16876. }
  16877. function isClipPathChanged(clipPaths, prevClipPaths) {
  16878. if (clipPaths == prevClipPaths) { // Can both be null or undefined
  16879. return false;
  16880. }
  16881. if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) {
  16882. return true;
  16883. }
  16884. for (var i = 0; i < clipPaths.length; i++) {
  16885. if (clipPaths[i] !== prevClipPaths[i]) {
  16886. return true;
  16887. }
  16888. }
  16889. }
  16890. function doClip(clipPaths, ctx) {
  16891. for (var i = 0; i < clipPaths.length; i++) {
  16892. var clipPath = clipPaths[i];
  16893. var path = clipPath.path;
  16894. clipPath.setTransform(ctx);
  16895. path.beginPath(ctx);
  16896. clipPath.buildPath(path, clipPath.shape);
  16897. ctx.clip();
  16898. // Transform back
  16899. clipPath.restoreTransform(ctx);
  16900. }
  16901. }
  16902. function createRoot(width, height) {
  16903. var domRoot = document.createElement('div');
  16904. // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬
  16905. domRoot.style.cssText = [
  16906. 'position:relative',
  16907. 'overflow:hidden',
  16908. 'width:' + width + 'px',
  16909. 'height:' + height + 'px',
  16910. 'padding:0',
  16911. 'margin:0',
  16912. 'border-width:0'
  16913. ].join(';') + ';';
  16914. return domRoot;
  16915. }
  16916. /**
  16917. * @alias module:zrender/Painter
  16918. * @constructor
  16919. * @param {HTMLElement} root 绘图容器
  16920. * @param {module:zrender/Storage} storage
  16921. * @param {Ojbect} opts
  16922. */
  16923. var Painter = function (root, storage, opts) {
  16924. // In node environment using node-canvas
  16925. var singleCanvas = !root.nodeName // In node ?
  16926. || root.nodeName.toUpperCase() === 'CANVAS';
  16927. this._opts = opts = util.extend({}, opts || {});
  16928. /**
  16929. * @type {number}
  16930. */
  16931. this.dpr = opts.devicePixelRatio || config.devicePixelRatio;
  16932. /**
  16933. * @type {boolean}
  16934. * @private
  16935. */
  16936. this._singleCanvas = singleCanvas;
  16937. /**
  16938. * 绘图容器
  16939. * @type {HTMLElement}
  16940. */
  16941. this.root = root;
  16942. var rootStyle = root.style;
  16943. if (rootStyle) {
  16944. rootStyle['-webkit-tap-highlight-color'] = 'transparent';
  16945. rootStyle['-webkit-user-select'] =
  16946. rootStyle['user-select'] =
  16947. rootStyle['-webkit-touch-callout'] = 'none';
  16948. root.innerHTML = '';
  16949. }
  16950. /**
  16951. * @type {module:zrender/Storage}
  16952. */
  16953. this.storage = storage;
  16954. /**
  16955. * @type {Array.<number>}
  16956. * @private
  16957. */
  16958. var zlevelList = this._zlevelList = [];
  16959. /**
  16960. * @type {Object.<string, module:zrender/Layer>}
  16961. * @private
  16962. */
  16963. var layers = this._layers = {};
  16964. /**
  16965. * @type {Object.<string, Object>}
  16966. * @type {private}
  16967. */
  16968. this._layerConfig = {};
  16969. if (!singleCanvas) {
  16970. this._width = this._getSize(0);
  16971. this._height = this._getSize(1);
  16972. var domRoot = this._domRoot = createRoot(
  16973. this._width, this._height
  16974. );
  16975. root.appendChild(domRoot);
  16976. }
  16977. else {
  16978. // Use canvas width and height directly
  16979. var width = root.width;
  16980. var height = root.height;
  16981. this._width = width;
  16982. this._height = height;
  16983. // Create layer if only one given canvas
  16984. // Device pixel ratio is fixed to 1 because given canvas has its specified width and height
  16985. var mainLayer = new Layer(root, this, 1);
  16986. mainLayer.initContext();
  16987. // FIXME Use canvas width and height
  16988. // mainLayer.resize(width, height);
  16989. layers[0] = mainLayer;
  16990. zlevelList.push(0);
  16991. }
  16992. this.pathToImage = this._createPathToImage();
  16993. // Layers for progressive rendering
  16994. this._progressiveLayers = [];
  16995. /**
  16996. * @type {module:zrender/Layer}
  16997. * @private
  16998. */
  16999. this._hoverlayer;
  17000. this._hoverElements = [];
  17001. };
  17002. Painter.prototype = {
  17003. constructor: Painter,
  17004. /**
  17005. * If painter use a single canvas
  17006. * @return {boolean}
  17007. */
  17008. isSingleCanvas: function () {
  17009. return this._singleCanvas;
  17010. },
  17011. /**
  17012. * @return {HTMLDivElement}
  17013. */
  17014. getViewportRoot: function () {
  17015. return this._singleCanvas ? this._layers[0].dom : this._domRoot;
  17016. },
  17017. /**
  17018. * 刷新
  17019. * @param {boolean} [paintAll=false] 强制绘制所有displayable
  17020. */
  17021. refresh: function (paintAll) {
  17022. var list = this.storage.getDisplayList(true);
  17023. var zlevelList = this._zlevelList;
  17024. this._paintList(list, paintAll);
  17025. // Paint custum layers
  17026. for (var i = 0; i < zlevelList.length; i++) {
  17027. var z = zlevelList[i];
  17028. var layer = this._layers[z];
  17029. if (!layer.isBuildin && layer.refresh) {
  17030. layer.refresh();
  17031. }
  17032. }
  17033. this.refreshHover();
  17034. if (this._progressiveLayers.length) {
  17035. this._startProgessive();
  17036. }
  17037. return this;
  17038. },
  17039. addHover: function (el, hoverStyle) {
  17040. if (el.__hoverMir) {
  17041. return;
  17042. }
  17043. var elMirror = new el.constructor({
  17044. style: el.style,
  17045. shape: el.shape
  17046. });
  17047. elMirror.__from = el;
  17048. el.__hoverMir = elMirror;
  17049. elMirror.setStyle(hoverStyle);
  17050. this._hoverElements.push(elMirror);
  17051. },
  17052. removeHover: function (el) {
  17053. var elMirror = el.__hoverMir;
  17054. var hoverElements = this._hoverElements;
  17055. var idx = util.indexOf(hoverElements, elMirror);
  17056. if (idx >= 0) {
  17057. hoverElements.splice(idx, 1);
  17058. }
  17059. el.__hoverMir = null;
  17060. },
  17061. clearHover: function (el) {
  17062. var hoverElements = this._hoverElements;
  17063. for (var i = 0; i < hoverElements.length; i++) {
  17064. var from = hoverElements[i].__from;
  17065. if (from) {
  17066. from.__hoverMir = null;
  17067. }
  17068. }
  17069. hoverElements.length = 0;
  17070. },
  17071. refreshHover: function () {
  17072. var hoverElements = this._hoverElements;
  17073. var len = hoverElements.length;
  17074. var hoverLayer = this._hoverlayer;
  17075. hoverLayer && hoverLayer.clear();
  17076. if (!len) {
  17077. return;
  17078. }
  17079. timsort(hoverElements, this.storage.displayableSortFunc);
  17080. // Use a extream large zlevel
  17081. // FIXME?
  17082. if (!hoverLayer) {
  17083. hoverLayer = this._hoverlayer = this.getLayer(1e5);
  17084. }
  17085. var scope = {};
  17086. hoverLayer.ctx.save();
  17087. for (var i = 0; i < len;) {
  17088. var el = hoverElements[i];
  17089. var originalEl = el.__from;
  17090. // Original el is removed
  17091. // PENDING
  17092. if (!(originalEl && originalEl.__zr)) {
  17093. hoverElements.splice(i, 1);
  17094. originalEl.__hoverMir = null;
  17095. len--;
  17096. continue;
  17097. }
  17098. i++;
  17099. // Use transform
  17100. // FIXME style and shape ?
  17101. if (!originalEl.invisible) {
  17102. el.transform = originalEl.transform;
  17103. el.invTransform = originalEl.invTransform;
  17104. el.__clipPaths = originalEl.__clipPaths;
  17105. // el.
  17106. this._doPaintEl(el, hoverLayer, true, scope);
  17107. }
  17108. }
  17109. hoverLayer.ctx.restore();
  17110. },
  17111. _startProgessive: function () {
  17112. var self = this;
  17113. if (!self._furtherProgressive) {
  17114. return;
  17115. }
  17116. // Use a token to stop progress steps triggered by
  17117. // previous zr.refresh calling.
  17118. var token = self._progressiveToken = +new Date();
  17119. self._progress++;
  17120. requestAnimationFrame(step);
  17121. function step() {
  17122. // In case refreshed or disposed
  17123. if (token === self._progressiveToken && self.storage) {
  17124. self._doPaintList(self.storage.getDisplayList());
  17125. if (self._furtherProgressive) {
  17126. self._progress++;
  17127. requestAnimationFrame(step);
  17128. }
  17129. else {
  17130. self._progressiveToken = -1;
  17131. }
  17132. }
  17133. }
  17134. },
  17135. _clearProgressive: function () {
  17136. this._progressiveToken = -1;
  17137. this._progress = 0;
  17138. util.each(this._progressiveLayers, function (layer) {
  17139. layer.__dirty && layer.clear();
  17140. });
  17141. },
  17142. _paintList: function (list, paintAll) {
  17143. if (paintAll == null) {
  17144. paintAll = false;
  17145. }
  17146. this._updateLayerStatus(list);
  17147. this._clearProgressive();
  17148. this.eachBuildinLayer(preProcessLayer);
  17149. this._doPaintList(list, paintAll);
  17150. this.eachBuildinLayer(postProcessLayer);
  17151. },
  17152. _doPaintList: function (list, paintAll) {
  17153. var currentLayer;
  17154. var currentZLevel;
  17155. var ctx;
  17156. // var invTransform = [];
  17157. var scope;
  17158. var progressiveLayerIdx = 0;
  17159. var currentProgressiveLayer;
  17160. var width = this._width;
  17161. var height = this._height;
  17162. var layerProgress;
  17163. var frame = this._progress;
  17164. function flushProgressiveLayer(layer) {
  17165. var dpr = ctx.dpr || 1;
  17166. ctx.save();
  17167. ctx.globalAlpha = 1;
  17168. ctx.shadowBlur = 0;
  17169. // Avoid layer don't clear in next progressive frame
  17170. currentLayer.__dirty = true;
  17171. ctx.setTransform(1, 0, 0, 1, 0, 0);
  17172. ctx.drawImage(layer.dom, 0, 0, width * dpr, height * dpr);
  17173. ctx.restore();
  17174. }
  17175. for (var i = 0, l = list.length; i < l; i++) {
  17176. var el = list[i];
  17177. var elZLevel = this._singleCanvas ? 0 : el.zlevel;
  17178. var elFrame = el.__frame;
  17179. // Flush at current context
  17180. // PENDING
  17181. if (elFrame < 0 && currentProgressiveLayer) {
  17182. flushProgressiveLayer(currentProgressiveLayer);
  17183. currentProgressiveLayer = null;
  17184. }
  17185. // Change draw layer
  17186. if (currentZLevel !== elZLevel) {
  17187. if (ctx) {
  17188. ctx.restore();
  17189. }
  17190. // Reset scope
  17191. scope = {};
  17192. // Only 0 zlevel if only has one canvas
  17193. currentZLevel = elZLevel;
  17194. currentLayer = this.getLayer(currentZLevel);
  17195. if (!currentLayer.isBuildin) {
  17196. log(
  17197. 'ZLevel ' + currentZLevel
  17198. + ' has been used by unkown layer ' + currentLayer.id
  17199. );
  17200. }
  17201. ctx = currentLayer.ctx;
  17202. ctx.save();
  17203. // Reset the count
  17204. currentLayer.__unusedCount = 0;
  17205. if (currentLayer.__dirty || paintAll) {
  17206. currentLayer.clear();
  17207. }
  17208. }
  17209. if (!(currentLayer.__dirty || paintAll)) {
  17210. continue;
  17211. }
  17212. if (elFrame >= 0) {
  17213. // Progressive layer changed
  17214. if (!currentProgressiveLayer) {
  17215. currentProgressiveLayer = this._progressiveLayers[
  17216. Math.min(progressiveLayerIdx++, MAX_PROGRESSIVE_LAYER_NUMBER - 1)
  17217. ];
  17218. currentProgressiveLayer.ctx.save();
  17219. currentProgressiveLayer.renderScope = {};
  17220. if (currentProgressiveLayer
  17221. && (currentProgressiveLayer.__progress > currentProgressiveLayer.__maxProgress)
  17222. ) {
  17223. // flushProgressiveLayer(currentProgressiveLayer);
  17224. // Quick jump all progressive elements
  17225. // All progressive element are not dirty, jump over and flush directly
  17226. i = currentProgressiveLayer.__nextIdxNotProg - 1;
  17227. // currentProgressiveLayer = null;
  17228. continue;
  17229. }
  17230. layerProgress = currentProgressiveLayer.__progress;
  17231. if (!currentProgressiveLayer.__dirty) {
  17232. // Keep rendering
  17233. frame = layerProgress;
  17234. }
  17235. currentProgressiveLayer.__progress = frame + 1;
  17236. }
  17237. if (elFrame === frame) {
  17238. this._doPaintEl(el, currentProgressiveLayer, true, currentProgressiveLayer.renderScope);
  17239. }
  17240. }
  17241. else {
  17242. this._doPaintEl(el, currentLayer, paintAll, scope);
  17243. }
  17244. el.__dirty = false;
  17245. }
  17246. if (currentProgressiveLayer) {
  17247. flushProgressiveLayer(currentProgressiveLayer);
  17248. }
  17249. // Restore the lastLayer ctx
  17250. ctx && ctx.restore();
  17251. // If still has clipping state
  17252. // if (scope.prevElClipPaths) {
  17253. // ctx.restore();
  17254. // }
  17255. this._furtherProgressive = false;
  17256. util.each(this._progressiveLayers, function (layer) {
  17257. if (layer.__maxProgress >= layer.__progress) {
  17258. this._furtherProgressive = true;
  17259. }
  17260. }, this);
  17261. },
  17262. _doPaintEl: function (el, currentLayer, forcePaint, scope) {
  17263. var ctx = currentLayer.ctx;
  17264. var m = el.transform;
  17265. if (
  17266. (currentLayer.__dirty || forcePaint)
  17267. // Ignore invisible element
  17268. && !el.invisible
  17269. // Ignore transparent element
  17270. && el.style.opacity !== 0
  17271. // Ignore scale 0 element, in some environment like node-canvas
  17272. // Draw a scale 0 element can cause all following draw wrong
  17273. // And setTransform with scale 0 will cause set back transform failed.
  17274. && !(m && !m[0] && !m[3])
  17275. // Ignore culled element
  17276. && !(el.culling && isDisplayableCulled(el, this._width, this._height))
  17277. ) {
  17278. var clipPaths = el.__clipPaths;
  17279. // Optimize when clipping on group with several elements
  17280. if (scope.prevClipLayer !== currentLayer
  17281. || isClipPathChanged(clipPaths, scope.prevElClipPaths)
  17282. ) {
  17283. // If has previous clipping state, restore from it
  17284. if (scope.prevElClipPaths) {
  17285. scope.prevClipLayer.ctx.restore();
  17286. scope.prevClipLayer = scope.prevElClipPaths = null;
  17287. // Reset prevEl since context has been restored
  17288. scope.prevEl = null;
  17289. }
  17290. // New clipping state
  17291. if (clipPaths) {
  17292. ctx.save();
  17293. doClip(clipPaths, ctx);
  17294. scope.prevClipLayer = currentLayer;
  17295. scope.prevElClipPaths = clipPaths;
  17296. }
  17297. }
  17298. el.beforeBrush && el.beforeBrush(ctx);
  17299. el.brush(ctx, scope.prevEl || null);
  17300. scope.prevEl = el;
  17301. el.afterBrush && el.afterBrush(ctx);
  17302. }
  17303. },
  17304. /**
  17305. * 获取 zlevel 所在层,如果不存在则会创建一个新的层
  17306. * @param {number} zlevel
  17307. * @return {module:zrender/Layer}
  17308. */
  17309. getLayer: function (zlevel) {
  17310. if (this._singleCanvas) {
  17311. return this._layers[0];
  17312. }
  17313. var layer = this._layers[zlevel];
  17314. if (!layer) {
  17315. // Create a new layer
  17316. layer = new Layer('zr_' + zlevel, this, this.dpr);
  17317. layer.isBuildin = true;
  17318. if (this._layerConfig[zlevel]) {
  17319. util.merge(layer, this._layerConfig[zlevel], true);
  17320. }
  17321. this.insertLayer(zlevel, layer);
  17322. // Context is created after dom inserted to document
  17323. // Or excanvas will get 0px clientWidth and clientHeight
  17324. layer.initContext();
  17325. }
  17326. return layer;
  17327. },
  17328. insertLayer: function (zlevel, layer) {
  17329. var layersMap = this._layers;
  17330. var zlevelList = this._zlevelList;
  17331. var len = zlevelList.length;
  17332. var prevLayer = null;
  17333. var i = -1;
  17334. var domRoot = this._domRoot;
  17335. if (layersMap[zlevel]) {
  17336. log('ZLevel ' + zlevel + ' has been used already');
  17337. return;
  17338. }
  17339. // Check if is a valid layer
  17340. if (!isLayerValid(layer)) {
  17341. log('Layer of zlevel ' + zlevel + ' is not valid');
  17342. return;
  17343. }
  17344. if (len > 0 && zlevel > zlevelList[0]) {
  17345. for (i = 0; i < len - 1; i++) {
  17346. if (
  17347. zlevelList[i] < zlevel
  17348. && zlevelList[i + 1] > zlevel
  17349. ) {
  17350. break;
  17351. }
  17352. }
  17353. prevLayer = layersMap[zlevelList[i]];
  17354. }
  17355. zlevelList.splice(i + 1, 0, zlevel);
  17356. if (prevLayer) {
  17357. var prevDom = prevLayer.dom;
  17358. if (prevDom.nextSibling) {
  17359. domRoot.insertBefore(
  17360. layer.dom,
  17361. prevDom.nextSibling
  17362. );
  17363. }
  17364. else {
  17365. domRoot.appendChild(layer.dom);
  17366. }
  17367. }
  17368. else {
  17369. if (domRoot.firstChild) {
  17370. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  17371. }
  17372. else {
  17373. domRoot.appendChild(layer.dom);
  17374. }
  17375. }
  17376. layersMap[zlevel] = layer;
  17377. },
  17378. // Iterate each layer
  17379. eachLayer: function (cb, context) {
  17380. var zlevelList = this._zlevelList;
  17381. var z;
  17382. var i;
  17383. for (i = 0; i < zlevelList.length; i++) {
  17384. z = zlevelList[i];
  17385. cb.call(context, this._layers[z], z);
  17386. }
  17387. },
  17388. // Iterate each buildin layer
  17389. eachBuildinLayer: function (cb, context) {
  17390. var zlevelList = this._zlevelList;
  17391. var layer;
  17392. var z;
  17393. var i;
  17394. for (i = 0; i < zlevelList.length; i++) {
  17395. z = zlevelList[i];
  17396. layer = this._layers[z];
  17397. if (layer.isBuildin) {
  17398. cb.call(context, layer, z);
  17399. }
  17400. }
  17401. },
  17402. // Iterate each other layer except buildin layer
  17403. eachOtherLayer: function (cb, context) {
  17404. var zlevelList = this._zlevelList;
  17405. var layer;
  17406. var z;
  17407. var i;
  17408. for (i = 0; i < zlevelList.length; i++) {
  17409. z = zlevelList[i];
  17410. layer = this._layers[z];
  17411. if (! layer.isBuildin) {
  17412. cb.call(context, layer, z);
  17413. }
  17414. }
  17415. },
  17416. /**
  17417. * 获取所有已创建的层
  17418. * @param {Array.<module:zrender/Layer>} [prevLayer]
  17419. */
  17420. getLayers: function () {
  17421. return this._layers;
  17422. },
  17423. _updateLayerStatus: function (list) {
  17424. var layers = this._layers;
  17425. var progressiveLayers = this._progressiveLayers;
  17426. var elCountsLastFrame = {};
  17427. var progressiveElCountsLastFrame = {};
  17428. this.eachBuildinLayer(function (layer, z) {
  17429. elCountsLastFrame[z] = layer.elCount;
  17430. layer.elCount = 0;
  17431. layer.__dirty = false;
  17432. });
  17433. util.each(progressiveLayers, function (layer, idx) {
  17434. progressiveElCountsLastFrame[idx] = layer.elCount;
  17435. layer.elCount = 0;
  17436. layer.__dirty = false;
  17437. });
  17438. var progressiveLayerCount = 0;
  17439. var currentProgressiveLayer;
  17440. var lastProgressiveKey;
  17441. var frameCount = 0;
  17442. for (var i = 0, l = list.length; i < l; i++) {
  17443. var el = list[i];
  17444. var zlevel = this._singleCanvas ? 0 : el.zlevel;
  17445. var layer = layers[zlevel];
  17446. var elProgress = el.progressive;
  17447. if (layer) {
  17448. layer.elCount++;
  17449. layer.__dirty = layer.__dirty || el.__dirty;
  17450. }
  17451. /////// Update progressive
  17452. if (elProgress >= 0) {
  17453. // Fix wrong progressive sequence problem.
  17454. if (lastProgressiveKey !== elProgress) {
  17455. lastProgressiveKey = elProgress;
  17456. frameCount++;
  17457. }
  17458. var elFrame = el.__frame = frameCount - 1;
  17459. if (!currentProgressiveLayer) {
  17460. var idx = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER - 1);
  17461. currentProgressiveLayer = progressiveLayers[idx];
  17462. if (!currentProgressiveLayer) {
  17463. currentProgressiveLayer = progressiveLayers[idx] = new Layer(
  17464. 'progressive', this, this.dpr
  17465. );
  17466. currentProgressiveLayer.initContext();
  17467. }
  17468. currentProgressiveLayer.__maxProgress = 0;
  17469. }
  17470. currentProgressiveLayer.__dirty = currentProgressiveLayer.__dirty || el.__dirty;
  17471. currentProgressiveLayer.elCount++;
  17472. currentProgressiveLayer.__maxProgress = Math.max(
  17473. currentProgressiveLayer.__maxProgress, elFrame
  17474. );
  17475. if (currentProgressiveLayer.__maxProgress >= currentProgressiveLayer.__progress) {
  17476. // Should keep rendering this layer because progressive rendering is not finished yet
  17477. layer.__dirty = true;
  17478. }
  17479. }
  17480. else {
  17481. el.__frame = -1;
  17482. if (currentProgressiveLayer) {
  17483. currentProgressiveLayer.__nextIdxNotProg = i;
  17484. progressiveLayerCount++;
  17485. currentProgressiveLayer = null;
  17486. }
  17487. }
  17488. }
  17489. if (currentProgressiveLayer) {
  17490. progressiveLayerCount++;
  17491. currentProgressiveLayer.__nextIdxNotProg = i;
  17492. }
  17493. // 层中的元素数量有发生变化
  17494. this.eachBuildinLayer(function (layer, z) {
  17495. if (elCountsLastFrame[z] !== layer.elCount) {
  17496. layer.__dirty = true;
  17497. }
  17498. });
  17499. progressiveLayers.length = Math.min(progressiveLayerCount, MAX_PROGRESSIVE_LAYER_NUMBER);
  17500. util.each(progressiveLayers, function (layer, idx) {
  17501. if (progressiveElCountsLastFrame[idx] !== layer.elCount) {
  17502. el.__dirty = true;
  17503. }
  17504. if (layer.__dirty) {
  17505. layer.__progress = 0;
  17506. }
  17507. });
  17508. },
  17509. /**
  17510. * 清除hover层外所有内容
  17511. */
  17512. clear: function () {
  17513. this.eachBuildinLayer(this._clearLayer);
  17514. return this;
  17515. },
  17516. _clearLayer: function (layer) {
  17517. layer.clear();
  17518. },
  17519. /**
  17520. * 修改指定zlevel的绘制参数
  17521. *
  17522. * @param {string} zlevel
  17523. * @param {Object} config 配置对象
  17524. * @param {string} [config.clearColor=0] 每次清空画布的颜色
  17525. * @param {string} [config.motionBlur=false] 是否开启动态模糊
  17526. * @param {number} [config.lastFrameAlpha=0.7]
  17527. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  17528. */
  17529. configLayer: function (zlevel, config) {
  17530. if (config) {
  17531. var layerConfig = this._layerConfig;
  17532. if (!layerConfig[zlevel]) {
  17533. layerConfig[zlevel] = config;
  17534. }
  17535. else {
  17536. util.merge(layerConfig[zlevel], config, true);
  17537. }
  17538. var layer = this._layers[zlevel];
  17539. if (layer) {
  17540. util.merge(layer, layerConfig[zlevel], true);
  17541. }
  17542. }
  17543. },
  17544. /**
  17545. * 删除指定层
  17546. * @param {number} zlevel 层所在的zlevel
  17547. */
  17548. delLayer: function (zlevel) {
  17549. var layers = this._layers;
  17550. var zlevelList = this._zlevelList;
  17551. var layer = layers[zlevel];
  17552. if (!layer) {
  17553. return;
  17554. }
  17555. layer.dom.parentNode.removeChild(layer.dom);
  17556. delete layers[zlevel];
  17557. zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
  17558. },
  17559. /**
  17560. * 区域大小变化后重绘
  17561. */
  17562. resize: function (width, height) {
  17563. var domRoot = this._domRoot;
  17564. // FIXME Why ?
  17565. domRoot.style.display = 'none';
  17566. // Save input w/h
  17567. var opts = this._opts;
  17568. width != null && (opts.width = width);
  17569. height != null && (opts.height = height);
  17570. width = this._getSize(0);
  17571. height = this._getSize(1);
  17572. domRoot.style.display = '';
  17573. // 优化没有实际改变的resize
  17574. if (this._width != width || height != this._height) {
  17575. domRoot.style.width = width + 'px';
  17576. domRoot.style.height = height + 'px';
  17577. for (var id in this._layers) {
  17578. if (this._layers.hasOwnProperty(id)) {
  17579. this._layers[id].resize(width, height);
  17580. }
  17581. }
  17582. util.each(this._progressiveLayers, function (layer) {
  17583. layer.resize(width, height);
  17584. });
  17585. this.refresh(true);
  17586. }
  17587. this._width = width;
  17588. this._height = height;
  17589. return this;
  17590. },
  17591. /**
  17592. * 清除单独的一个层
  17593. * @param {number} zlevel
  17594. */
  17595. clearLayer: function (zlevel) {
  17596. var layer = this._layers[zlevel];
  17597. if (layer) {
  17598. layer.clear();
  17599. }
  17600. },
  17601. /**
  17602. * 释放
  17603. */
  17604. dispose: function () {
  17605. this.root.innerHTML = '';
  17606. this.root =
  17607. this.storage =
  17608. this._domRoot =
  17609. this._layers = null;
  17610. },
  17611. /**
  17612. * Get canvas which has all thing rendered
  17613. * @param {Object} opts
  17614. * @param {string} [opts.backgroundColor]
  17615. */
  17616. getRenderedCanvas: function (opts) {
  17617. opts = opts || {};
  17618. if (this._singleCanvas) {
  17619. return this._layers[0].dom;
  17620. }
  17621. var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
  17622. imageLayer.initContext();
  17623. imageLayer.clearColor = opts.backgroundColor;
  17624. imageLayer.clear();
  17625. var displayList = this.storage.getDisplayList(true);
  17626. var scope = {};
  17627. for (var i = 0; i < displayList.length; i++) {
  17628. var el = displayList[i];
  17629. this._doPaintEl(el, imageLayer, true, scope);
  17630. }
  17631. return imageLayer.dom;
  17632. },
  17633. /**
  17634. * 获取绘图区域宽度
  17635. */
  17636. getWidth: function () {
  17637. return this._width;
  17638. },
  17639. /**
  17640. * 获取绘图区域高度
  17641. */
  17642. getHeight: function () {
  17643. return this._height;
  17644. },
  17645. _getSize: function (whIdx) {
  17646. var opts = this._opts;
  17647. var wh = ['width', 'height'][whIdx];
  17648. var cwh = ['clientWidth', 'clientHeight'][whIdx];
  17649. var plt = ['paddingLeft', 'paddingTop'][whIdx];
  17650. var prb = ['paddingRight', 'paddingBottom'][whIdx];
  17651. if (opts[wh] != null && opts[wh] !== 'auto') {
  17652. return parseFloat(opts[wh]);
  17653. }
  17654. var root = this.root;
  17655. var stl = document.defaultView.getComputedStyle(root);
  17656. return (
  17657. (root[cwh] || parseInt10(stl[wh]) || parseInt10(root.style[wh]))
  17658. - (parseInt10(stl[plt]) || 0)
  17659. - (parseInt10(stl[prb]) || 0)
  17660. ) | 0;
  17661. },
  17662. _pathToImage: function (id, path, width, height, dpr) {
  17663. var canvas = document.createElement('canvas');
  17664. var ctx = canvas.getContext('2d');
  17665. canvas.width = width * dpr;
  17666. canvas.height = height * dpr;
  17667. ctx.clearRect(0, 0, width * dpr, height * dpr);
  17668. var pathTransform = {
  17669. position: path.position,
  17670. rotation: path.rotation,
  17671. scale: path.scale
  17672. };
  17673. path.position = [0, 0, 0];
  17674. path.rotation = 0;
  17675. path.scale = [1, 1];
  17676. if (path) {
  17677. path.brush(ctx);
  17678. }
  17679. var ImageShape = __webpack_require__(61);
  17680. var imgShape = new ImageShape({
  17681. id: id,
  17682. style: {
  17683. x: 0,
  17684. y: 0,
  17685. image: canvas
  17686. }
  17687. });
  17688. if (pathTransform.position != null) {
  17689. imgShape.position = path.position = pathTransform.position;
  17690. }
  17691. if (pathTransform.rotation != null) {
  17692. imgShape.rotation = path.rotation = pathTransform.rotation;
  17693. }
  17694. if (pathTransform.scale != null) {
  17695. imgShape.scale = path.scale = pathTransform.scale;
  17696. }
  17697. return imgShape;
  17698. },
  17699. _createPathToImage: function () {
  17700. var me = this;
  17701. return function (id, e, width, height) {
  17702. return me._pathToImage(
  17703. id, e, width, height, me.dpr
  17704. );
  17705. };
  17706. }
  17707. };
  17708. module.exports = Painter;
  17709. /***/ },
  17710. /* 93 */
  17711. /***/ function(module, exports, __webpack_require__) {
  17712. /**
  17713. * @module zrender/Layer
  17714. * @author pissang(https://www.github.com/pissang)
  17715. */
  17716. var util = __webpack_require__(4);
  17717. var config = __webpack_require__(41);
  17718. var Style = __webpack_require__(47);
  17719. var Pattern = __webpack_require__(59);
  17720. function returnFalse() {
  17721. return false;
  17722. }
  17723. /**
  17724. * 创建dom
  17725. *
  17726. * @inner
  17727. * @param {string} id dom id 待用
  17728. * @param {string} type dom type,such as canvas, div etc.
  17729. * @param {Painter} painter painter instance
  17730. * @param {number} number
  17731. */
  17732. function createDom(id, type, painter, dpr) {
  17733. var newDom = document.createElement(type);
  17734. var width = painter.getWidth();
  17735. var height = painter.getHeight();
  17736. var newDomStyle = newDom.style;
  17737. // 没append呢,请原谅我这样写,清晰~
  17738. newDomStyle.position = 'absolute';
  17739. newDomStyle.left = 0;
  17740. newDomStyle.top = 0;
  17741. newDomStyle.width = width + 'px';
  17742. newDomStyle.height = height + 'px';
  17743. newDom.width = width * dpr;
  17744. newDom.height = height * dpr;
  17745. // id不作为索引用,避免可能造成的重名,定义为私有属性
  17746. newDom.setAttribute('data-zr-dom-id', id);
  17747. return newDom;
  17748. }
  17749. /**
  17750. * @alias module:zrender/Layer
  17751. * @constructor
  17752. * @extends module:zrender/mixin/Transformable
  17753. * @param {string} id
  17754. * @param {module:zrender/Painter} painter
  17755. * @param {number} [dpr]
  17756. */
  17757. var Layer = function(id, painter, dpr) {
  17758. var dom;
  17759. dpr = dpr || config.devicePixelRatio;
  17760. if (typeof id === 'string') {
  17761. dom = createDom(id, 'canvas', painter, dpr);
  17762. }
  17763. // Not using isDom because in node it will return false
  17764. else if (util.isObject(id)) {
  17765. dom = id;
  17766. id = dom.id;
  17767. }
  17768. this.id = id;
  17769. this.dom = dom;
  17770. var domStyle = dom.style;
  17771. if (domStyle) { // Not in node
  17772. dom.onselectstart = returnFalse; // 避免页面选中的尴尬
  17773. domStyle['-webkit-user-select'] = 'none';
  17774. domStyle['user-select'] = 'none';
  17775. domStyle['-webkit-touch-callout'] = 'none';
  17776. domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)';
  17777. domStyle['padding'] = 0;
  17778. domStyle['margin'] = 0;
  17779. domStyle['border-width'] = 0;
  17780. }
  17781. this.domBack = null;
  17782. this.ctxBack = null;
  17783. this.painter = painter;
  17784. this.config = null;
  17785. // Configs
  17786. /**
  17787. * 每次清空画布的颜色
  17788. * @type {string}
  17789. * @default 0
  17790. */
  17791. this.clearColor = 0;
  17792. /**
  17793. * 是否开启动态模糊
  17794. * @type {boolean}
  17795. * @default false
  17796. */
  17797. this.motionBlur = false;
  17798. /**
  17799. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  17800. * @type {number}
  17801. * @default 0.7
  17802. */
  17803. this.lastFrameAlpha = 0.7;
  17804. /**
  17805. * Layer dpr
  17806. * @type {number}
  17807. */
  17808. this.dpr = dpr;
  17809. };
  17810. Layer.prototype = {
  17811. constructor: Layer,
  17812. elCount: 0,
  17813. __dirty: true,
  17814. initContext: function () {
  17815. this.ctx = this.dom.getContext('2d');
  17816. this.ctx.dpr = this.dpr;
  17817. },
  17818. createBackBuffer: function () {
  17819. var dpr = this.dpr;
  17820. this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr);
  17821. this.ctxBack = this.domBack.getContext('2d');
  17822. if (dpr != 1) {
  17823. this.ctxBack.scale(dpr, dpr);
  17824. }
  17825. },
  17826. /**
  17827. * @param {number} width
  17828. * @param {number} height
  17829. */
  17830. resize: function (width, height) {
  17831. var dpr = this.dpr;
  17832. var dom = this.dom;
  17833. var domStyle = dom.style;
  17834. var domBack = this.domBack;
  17835. domStyle.width = width + 'px';
  17836. domStyle.height = height + 'px';
  17837. dom.width = width * dpr;
  17838. dom.height = height * dpr;
  17839. if (domBack) {
  17840. domBack.width = width * dpr;
  17841. domBack.height = height * dpr;
  17842. if (dpr != 1) {
  17843. this.ctxBack.scale(dpr, dpr);
  17844. }
  17845. }
  17846. },
  17847. /**
  17848. * 清空该层画布
  17849. * @param {boolean} clearAll Clear all with out motion blur
  17850. */
  17851. clear: function (clearAll) {
  17852. var dom = this.dom;
  17853. var ctx = this.ctx;
  17854. var width = dom.width;
  17855. var height = dom.height;
  17856. var clearColor = this.clearColor;
  17857. var haveMotionBLur = this.motionBlur && !clearAll;
  17858. var lastFrameAlpha = this.lastFrameAlpha;
  17859. var dpr = this.dpr;
  17860. if (haveMotionBLur) {
  17861. if (!this.domBack) {
  17862. this.createBackBuffer();
  17863. }
  17864. this.ctxBack.globalCompositeOperation = 'copy';
  17865. this.ctxBack.drawImage(
  17866. dom, 0, 0,
  17867. width / dpr,
  17868. height / dpr
  17869. );
  17870. }
  17871. ctx.clearRect(0, 0, width, height);
  17872. if (clearColor) {
  17873. var clearColorGradientOrPattern;
  17874. // Gradient
  17875. if (clearColor.colorStops) {
  17876. // Cache canvas gradient
  17877. clearColorGradientOrPattern = clearColor.__canvasGradient || Style.getGradient(ctx, clearColor, {
  17878. x: 0,
  17879. y: 0,
  17880. width: width,
  17881. height: height
  17882. });
  17883. clearColor.__canvasGradient = clearColorGradientOrPattern;
  17884. }
  17885. // Pattern
  17886. else if (clearColor.image) {
  17887. clearColorGradientOrPattern = Pattern.prototype.getCanvasPattern.call(clearColor, ctx);
  17888. }
  17889. ctx.save();
  17890. ctx.fillStyle = clearColorGradientOrPattern || clearColor;
  17891. ctx.fillRect(0, 0, width, height);
  17892. ctx.restore();
  17893. }
  17894. if (haveMotionBLur) {
  17895. var domBack = this.domBack;
  17896. ctx.save();
  17897. ctx.globalAlpha = lastFrameAlpha;
  17898. ctx.drawImage(domBack, 0, 0, width, height);
  17899. ctx.restore();
  17900. }
  17901. }
  17902. };
  17903. module.exports = Layer;
  17904. /***/ },
  17905. /* 94 */
  17906. /***/ function(module, exports, __webpack_require__) {
  17907. var Gradient = __webpack_require__(79);
  17908. module.exports = function (ecModel) {
  17909. function encodeColor(seriesModel) {
  17910. var colorAccessPath = (seriesModel.visualColorAccessPath || 'itemStyle.normal.color').split('.');
  17911. var data = seriesModel.getData();
  17912. var color = seriesModel.get(colorAccessPath) // Set in itemStyle
  17913. || seriesModel.getColorFromPalette(seriesModel.get('name')); // Default color
  17914. // FIXME Set color function or use the platte color
  17915. data.setVisual('color', color);
  17916. // Only visible series has each data be visual encoded
  17917. if (!ecModel.isSeriesFiltered(seriesModel)) {
  17918. if (typeof color === 'function' && !(color instanceof Gradient)) {
  17919. data.each(function (idx) {
  17920. data.setItemVisual(
  17921. idx, 'color', color(seriesModel.getDataParams(idx))
  17922. );
  17923. });
  17924. }
  17925. // itemStyle in each data item
  17926. data.each(function (idx) {
  17927. var itemModel = data.getItemModel(idx);
  17928. var color = itemModel.get(colorAccessPath, true);
  17929. if (color != null) {
  17930. data.setItemVisual(idx, 'color', color);
  17931. }
  17932. });
  17933. }
  17934. }
  17935. ecModel.eachRawSeries(encodeColor);
  17936. };
  17937. /***/ },
  17938. /* 95 */
  17939. /***/ function(module, exports, __webpack_require__) {
  17940. // Compatitable with 2.0
  17941. var zrUtil = __webpack_require__(4);
  17942. var compatStyle = __webpack_require__(96);
  17943. function get(opt, path) {
  17944. path = path.split(',');
  17945. var obj = opt;
  17946. for (var i = 0; i < path.length; i++) {
  17947. obj = obj && obj[path[i]];
  17948. if (obj == null) {
  17949. break;
  17950. }
  17951. }
  17952. return obj;
  17953. }
  17954. function set(opt, path, val, overwrite) {
  17955. path = path.split(',');
  17956. var obj = opt;
  17957. var key;
  17958. for (var i = 0; i < path.length - 1; i++) {
  17959. key = path[i];
  17960. if (obj[key] == null) {
  17961. obj[key] = {};
  17962. }
  17963. obj = obj[key];
  17964. }
  17965. if (overwrite || obj[path[i]] == null) {
  17966. obj[path[i]] = val;
  17967. }
  17968. }
  17969. function compatLayoutProperties(option) {
  17970. each(LAYOUT_PROPERTIES, function (prop) {
  17971. if (prop[0] in option && !(prop[1] in option)) {
  17972. option[prop[1]] = option[prop[0]];
  17973. }
  17974. });
  17975. }
  17976. var LAYOUT_PROPERTIES = [
  17977. ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom']
  17978. ];
  17979. var COMPATITABLE_COMPONENTS = [
  17980. 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline'
  17981. ];
  17982. var COMPATITABLE_SERIES = [
  17983. 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter',
  17984. 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel',
  17985. 'pie', 'radar', 'sankey', 'scatter', 'treemap'
  17986. ];
  17987. var each = zrUtil.each;
  17988. module.exports = function (option) {
  17989. each(option.series, function (seriesOpt) {
  17990. if (!zrUtil.isObject(seriesOpt)) {
  17991. return;
  17992. }
  17993. var seriesType = seriesOpt.type;
  17994. compatStyle(seriesOpt);
  17995. if (seriesType === 'pie' || seriesType === 'gauge') {
  17996. if (seriesOpt.clockWise != null) {
  17997. seriesOpt.clockwise = seriesOpt.clockWise;
  17998. }
  17999. }
  18000. if (seriesType === 'gauge') {
  18001. var pointerColor = get(seriesOpt, 'pointer.color');
  18002. pointerColor != null
  18003. && set(seriesOpt, 'itemStyle.normal.color', pointerColor);
  18004. }
  18005. for (var i = 0; i < COMPATITABLE_SERIES.length; i++) {
  18006. if (COMPATITABLE_SERIES[i] === seriesOpt.type) {
  18007. compatLayoutProperties(seriesOpt);
  18008. break;
  18009. }
  18010. }
  18011. });
  18012. // dataRange has changed to visualMap
  18013. if (option.dataRange) {
  18014. option.visualMap = option.dataRange;
  18015. }
  18016. each(COMPATITABLE_COMPONENTS, function (componentName) {
  18017. var options = option[componentName];
  18018. if (options) {
  18019. if (!zrUtil.isArray(options)) {
  18020. options = [options];
  18021. }
  18022. each(options, function (option) {
  18023. compatLayoutProperties(option);
  18024. });
  18025. }
  18026. });
  18027. };
  18028. /***/ },
  18029. /* 96 */
  18030. /***/ function(module, exports, __webpack_require__) {
  18031. var zrUtil = __webpack_require__(4);
  18032. var POSSIBLE_STYLES = [
  18033. 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
  18034. 'chordStyle', 'label', 'labelLine'
  18035. ];
  18036. function compatItemStyle(opt) {
  18037. var itemStyleOpt = opt && opt.itemStyle;
  18038. if (itemStyleOpt) {
  18039. zrUtil.each(POSSIBLE_STYLES, function (styleName) {
  18040. var normalItemStyleOpt = itemStyleOpt.normal;
  18041. var emphasisItemStyleOpt = itemStyleOpt.emphasis;
  18042. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  18043. opt[styleName] = opt[styleName] || {};
  18044. if (!opt[styleName].normal) {
  18045. opt[styleName].normal = normalItemStyleOpt[styleName];
  18046. }
  18047. else {
  18048. zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
  18049. }
  18050. normalItemStyleOpt[styleName] = null;
  18051. }
  18052. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  18053. opt[styleName] = opt[styleName] || {};
  18054. if (!opt[styleName].emphasis) {
  18055. opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
  18056. }
  18057. else {
  18058. zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
  18059. }
  18060. emphasisItemStyleOpt[styleName] = null;
  18061. }
  18062. });
  18063. }
  18064. }
  18065. module.exports = function (seriesOpt) {
  18066. if (!seriesOpt) {
  18067. return;
  18068. }
  18069. compatItemStyle(seriesOpt);
  18070. compatItemStyle(seriesOpt.markPoint);
  18071. compatItemStyle(seriesOpt.markLine);
  18072. var data = seriesOpt.data;
  18073. if (data) {
  18074. for (var i = 0; i < data.length; i++) {
  18075. compatItemStyle(data[i]);
  18076. }
  18077. // mark point data
  18078. var markPoint = seriesOpt.markPoint;
  18079. if (markPoint && markPoint.data) {
  18080. var mpData = markPoint.data;
  18081. for (var i = 0; i < mpData.length; i++) {
  18082. compatItemStyle(mpData[i]);
  18083. }
  18084. }
  18085. // mark line data
  18086. var markLine = seriesOpt.markLine;
  18087. if (markLine && markLine.data) {
  18088. var mlData = markLine.data;
  18089. for (var i = 0; i < mlData.length; i++) {
  18090. if (zrUtil.isArray(mlData[i])) {
  18091. compatItemStyle(mlData[i][0]);
  18092. compatItemStyle(mlData[i][1]);
  18093. }
  18094. else {
  18095. compatItemStyle(mlData[i]);
  18096. }
  18097. }
  18098. }
  18099. }
  18100. };
  18101. /***/ },
  18102. /* 97 */
  18103. /***/ function(module, exports, __webpack_require__) {
  18104. var graphic = __webpack_require__(43);
  18105. var zrUtil = __webpack_require__(4);
  18106. var PI = Math.PI;
  18107. /**
  18108. * @param {module:echarts/ExtensionAPI} api
  18109. * @param {Object} [opts]
  18110. * @param {string} [opts.text]
  18111. * @param {string} [opts.color]
  18112. * @param {string} [opts.textColor]
  18113. * @return {module:zrender/Element}
  18114. */
  18115. module.exports = function (api, opts) {
  18116. opts = opts || {};
  18117. zrUtil.defaults(opts, {
  18118. text: 'loading',
  18119. color: '#c23531',
  18120. textColor: '#000',
  18121. maskColor: 'rgba(255, 255, 255, 0.8)',
  18122. zlevel: 0
  18123. });
  18124. var mask = new graphic.Rect({
  18125. style: {
  18126. fill: opts.maskColor
  18127. },
  18128. zlevel: opts.zlevel,
  18129. z: 10000
  18130. });
  18131. var arc = new graphic.Arc({
  18132. shape: {
  18133. startAngle: -PI / 2,
  18134. endAngle: -PI / 2 + 0.1,
  18135. r: 10
  18136. },
  18137. style: {
  18138. stroke: opts.color,
  18139. lineCap: 'round',
  18140. lineWidth: 5
  18141. },
  18142. zlevel: opts.zlevel,
  18143. z: 10001
  18144. });
  18145. var labelRect = new graphic.Rect({
  18146. style: {
  18147. fill: 'none',
  18148. text: opts.text,
  18149. textPosition: 'right',
  18150. textDistance: 10,
  18151. textFill: opts.textColor
  18152. },
  18153. zlevel: opts.zlevel,
  18154. z: 10001
  18155. });
  18156. arc.animateShape(true)
  18157. .when(1000, {
  18158. endAngle: PI * 3 / 2
  18159. })
  18160. .start('circularInOut');
  18161. arc.animateShape(true)
  18162. .when(1000, {
  18163. startAngle: PI * 3 / 2
  18164. })
  18165. .delay(300)
  18166. .start('circularInOut');
  18167. var group = new graphic.Group();
  18168. group.add(arc);
  18169. group.add(labelRect);
  18170. group.add(mask);
  18171. // Inject resize
  18172. group.resize = function () {
  18173. var cx = api.getWidth() / 2;
  18174. var cy = api.getHeight() / 2;
  18175. arc.setShape({
  18176. cx: cx,
  18177. cy: cy
  18178. });
  18179. var r = arc.shape.r;
  18180. labelRect.setShape({
  18181. x: cx - r,
  18182. y: cy - r,
  18183. width: r * 2,
  18184. height: r * 2
  18185. });
  18186. mask.setShape({
  18187. x: 0,
  18188. y: 0,
  18189. width: api.getWidth(),
  18190. height: api.getHeight()
  18191. });
  18192. };
  18193. group.resize();
  18194. return group;
  18195. };
  18196. /***/ },
  18197. /* 98 */
  18198. /***/ function(module, exports, __webpack_require__) {
  18199. /* WEBPACK VAR INJECTION */(function(global) {/**
  18200. * List for data storage
  18201. * @module echarts/data/List
  18202. */
  18203. var UNDEFINED = 'undefined';
  18204. var globalObj = typeof window === 'undefined' ? global : window;
  18205. var Float64Array = typeof globalObj.Float64Array === UNDEFINED
  18206. ? Array : globalObj.Float64Array;
  18207. var Int32Array = typeof globalObj.Int32Array === UNDEFINED
  18208. ? Array : globalObj.Int32Array;
  18209. var dataCtors = {
  18210. 'float': Float64Array,
  18211. 'int': Int32Array,
  18212. // Ordinal data type can be string or int
  18213. 'ordinal': Array,
  18214. 'number': Array,
  18215. 'time': Array
  18216. };
  18217. var Model = __webpack_require__(12);
  18218. var DataDiffer = __webpack_require__(99);
  18219. var zrUtil = __webpack_require__(4);
  18220. var modelUtil = __webpack_require__(5);
  18221. var isObject = zrUtil.isObject;
  18222. var TRANSFERABLE_PROPERTIES = [
  18223. 'stackedOn', 'hasItemOption', '_nameList', '_idList', '_rawData'
  18224. ];
  18225. var transferProperties = function (a, b) {
  18226. zrUtil.each(TRANSFERABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
  18227. if (b.hasOwnProperty(propName)) {
  18228. a[propName] = b[propName];
  18229. }
  18230. });
  18231. a.__wrappedMethods = b.__wrappedMethods;
  18232. };
  18233. /**
  18234. * @constructor
  18235. * @alias module:echarts/data/List
  18236. *
  18237. * @param {Array.<string>} dimensions
  18238. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  18239. * @param {module:echarts/model/Model} hostModel
  18240. */
  18241. var List = function (dimensions, hostModel) {
  18242. dimensions = dimensions || ['x', 'y'];
  18243. var dimensionInfos = {};
  18244. var dimensionNames = [];
  18245. for (var i = 0; i < dimensions.length; i++) {
  18246. var dimensionName;
  18247. var dimensionInfo = {};
  18248. if (typeof dimensions[i] === 'string') {
  18249. dimensionName = dimensions[i];
  18250. dimensionInfo = {
  18251. name: dimensionName,
  18252. stackable: false,
  18253. // Type can be 'float', 'int', 'number'
  18254. // Default is number, Precision of float may not enough
  18255. type: 'number'
  18256. };
  18257. }
  18258. else {
  18259. dimensionInfo = dimensions[i];
  18260. dimensionName = dimensionInfo.name;
  18261. dimensionInfo.type = dimensionInfo.type || 'number';
  18262. }
  18263. dimensionNames.push(dimensionName);
  18264. dimensionInfos[dimensionName] = dimensionInfo;
  18265. }
  18266. /**
  18267. * @readOnly
  18268. * @type {Array.<string>}
  18269. */
  18270. this.dimensions = dimensionNames;
  18271. /**
  18272. * Infomation of each data dimension, like data type.
  18273. * @type {Object}
  18274. */
  18275. this._dimensionInfos = dimensionInfos;
  18276. /**
  18277. * @type {module:echarts/model/Model}
  18278. */
  18279. this.hostModel = hostModel;
  18280. /**
  18281. * @type {module:echarts/model/Model}
  18282. */
  18283. this.dataType;
  18284. /**
  18285. * Indices stores the indices of data subset after filtered.
  18286. * This data subset will be used in chart.
  18287. * @type {Array.<number>}
  18288. * @readOnly
  18289. */
  18290. this.indices = [];
  18291. /**
  18292. * Data storage
  18293. * @type {Object.<key, TypedArray|Array>}
  18294. * @private
  18295. */
  18296. this._storage = {};
  18297. /**
  18298. * @type {Array.<string>}
  18299. */
  18300. this._nameList = [];
  18301. /**
  18302. * @type {Array.<string>}
  18303. */
  18304. this._idList = [];
  18305. /**
  18306. * Models of data option is stored sparse for optimizing memory cost
  18307. * @type {Array.<module:echarts/model/Model>}
  18308. * @private
  18309. */
  18310. this._optionModels = [];
  18311. /**
  18312. * @param {module:echarts/data/List}
  18313. */
  18314. this.stackedOn = null;
  18315. /**
  18316. * Global visual properties after visual coding
  18317. * @type {Object}
  18318. * @private
  18319. */
  18320. this._visual = {};
  18321. /**
  18322. * Globel layout properties.
  18323. * @type {Object}
  18324. * @private
  18325. */
  18326. this._layout = {};
  18327. /**
  18328. * Item visual properties after visual coding
  18329. * @type {Array.<Object>}
  18330. * @private
  18331. */
  18332. this._itemVisuals = [];
  18333. /**
  18334. * Item layout properties after layout
  18335. * @type {Array.<Object>}
  18336. * @private
  18337. */
  18338. this._itemLayouts = [];
  18339. /**
  18340. * Graphic elemnents
  18341. * @type {Array.<module:zrender/Element>}
  18342. * @private
  18343. */
  18344. this._graphicEls = [];
  18345. /**
  18346. * @type {Array.<Array|Object>}
  18347. * @private
  18348. */
  18349. this._rawData;
  18350. /**
  18351. * @type {Object}
  18352. * @private
  18353. */
  18354. this._extent;
  18355. };
  18356. var listProto = List.prototype;
  18357. listProto.type = 'list';
  18358. /**
  18359. * If each data item has it's own option
  18360. * @type {boolean}
  18361. */
  18362. listProto.hasItemOption = true;
  18363. /**
  18364. * Get dimension name
  18365. * @param {string|number} dim
  18366. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  18367. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  18368. * @return {string} Concrete dim name.
  18369. */
  18370. listProto.getDimension = function (dim) {
  18371. if (!isNaN(dim)) {
  18372. dim = this.dimensions[dim] || dim;
  18373. }
  18374. return dim;
  18375. };
  18376. /**
  18377. * Get type and stackable info of particular dimension
  18378. * @param {string|number} dim
  18379. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  18380. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  18381. */
  18382. listProto.getDimensionInfo = function (dim) {
  18383. return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]);
  18384. };
  18385. /**
  18386. * Initialize from data
  18387. * @param {Array.<Object|number|Array>} data
  18388. * @param {Array.<string>} [nameList]
  18389. * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number
  18390. */
  18391. listProto.initData = function (data, nameList, dimValueGetter) {
  18392. data = data || [];
  18393. if (true) {
  18394. if (!zrUtil.isArray(data)) {
  18395. throw new Error('Invalid data.');
  18396. }
  18397. }
  18398. this._rawData = data;
  18399. // Clear
  18400. var storage = this._storage = {};
  18401. var indices = this.indices = [];
  18402. var dimensions = this.dimensions;
  18403. var size = data.length;
  18404. var dimensionInfoMap = this._dimensionInfos;
  18405. var idList = [];
  18406. var nameRepeatCount = {};
  18407. nameList = nameList || [];
  18408. // Init storage
  18409. for (var i = 0; i < dimensions.length; i++) {
  18410. var dimInfo = dimensionInfoMap[dimensions[i]];
  18411. var DataCtor = dataCtors[dimInfo.type];
  18412. storage[dimensions[i]] = new DataCtor(size);
  18413. }
  18414. var self = this;
  18415. if (!dimValueGetter) {
  18416. self.hasItemOption = false;
  18417. }
  18418. // Default dim value getter
  18419. dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) {
  18420. var value = modelUtil.getDataItemValue(dataItem);
  18421. // If any dataItem is like { value: 10 }
  18422. if (modelUtil.isDataItemOption(dataItem)) {
  18423. self.hasItemOption = true;
  18424. }
  18425. return modelUtil.converDataValue(
  18426. (value instanceof Array)
  18427. ? value[dimIndex]
  18428. // If value is a single number or something else not array.
  18429. : value,
  18430. dimensionInfoMap[dimName]
  18431. );
  18432. };
  18433. for (var idx = 0; idx < data.length; idx++) {
  18434. var dataItem = data[idx];
  18435. // Each data item is value
  18436. // [1, 2]
  18437. // 2
  18438. // Bar chart, line chart which uses category axis
  18439. // only gives the 'y' value. 'x' value is the indices of cateogry
  18440. // Use a tempValue to normalize the value to be a (x, y) value
  18441. // Store the data by dimensions
  18442. for (var k = 0; k < dimensions.length; k++) {
  18443. var dim = dimensions[k];
  18444. var dimStorage = storage[dim];
  18445. // PENDING NULL is empty or zero
  18446. dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k);
  18447. }
  18448. indices.push(idx);
  18449. }
  18450. // Use the name in option and create id
  18451. for (var i = 0; i < data.length; i++) {
  18452. if (!nameList[i]) {
  18453. if (data[i] && data[i].name != null) {
  18454. nameList[i] = data[i].name;
  18455. }
  18456. }
  18457. var name = nameList[i] || '';
  18458. // Try using the id in option
  18459. var id = data[i] && data[i].id;
  18460. if (!id && name) {
  18461. // Use name as id and add counter to avoid same name
  18462. nameRepeatCount[name] = nameRepeatCount[name] || 0;
  18463. id = name;
  18464. if (nameRepeatCount[name] > 0) {
  18465. id += '__ec__' + nameRepeatCount[name];
  18466. }
  18467. nameRepeatCount[name]++;
  18468. }
  18469. id && (idList[i] = id);
  18470. }
  18471. this._nameList = nameList;
  18472. this._idList = idList;
  18473. };
  18474. /**
  18475. * @return {number}
  18476. */
  18477. listProto.count = function () {
  18478. return this.indices.length;
  18479. };
  18480. /**
  18481. * Get value. Return NaN if idx is out of range.
  18482. * @param {string} dim Dim must be concrete name.
  18483. * @param {number} idx
  18484. * @param {boolean} stack
  18485. * @return {number}
  18486. */
  18487. listProto.get = function (dim, idx, stack) {
  18488. var storage = this._storage;
  18489. var dataIndex = this.indices[idx];
  18490. // If value not exists
  18491. if (dataIndex == null) {
  18492. return NaN;
  18493. }
  18494. var value = storage[dim] && storage[dim][dataIndex];
  18495. // FIXME ordinal data type is not stackable
  18496. if (stack) {
  18497. var dimensionInfo = this._dimensionInfos[dim];
  18498. if (dimensionInfo && dimensionInfo.stackable) {
  18499. var stackedOn = this.stackedOn;
  18500. while (stackedOn) {
  18501. // Get no stacked data of stacked on
  18502. var stackedValue = stackedOn.get(dim, idx);
  18503. // Considering positive stack, negative stack and empty data
  18504. if ((value >= 0 && stackedValue > 0) // Positive stack
  18505. || (value <= 0 && stackedValue < 0) // Negative stack
  18506. ) {
  18507. value += stackedValue;
  18508. }
  18509. stackedOn = stackedOn.stackedOn;
  18510. }
  18511. }
  18512. }
  18513. return value;
  18514. };
  18515. /**
  18516. * Get value for multi dimensions.
  18517. * @param {Array.<string>} [dimensions] If ignored, using all dimensions.
  18518. * @param {number} idx
  18519. * @param {boolean} stack
  18520. * @return {number}
  18521. */
  18522. listProto.getValues = function (dimensions, idx, stack) {
  18523. var values = [];
  18524. if (!zrUtil.isArray(dimensions)) {
  18525. stack = idx;
  18526. idx = dimensions;
  18527. dimensions = this.dimensions;
  18528. }
  18529. for (var i = 0, len = dimensions.length; i < len; i++) {
  18530. values.push(this.get(dimensions[i], idx, stack));
  18531. }
  18532. return values;
  18533. };
  18534. /**
  18535. * If value is NaN. Inlcuding '-'
  18536. * @param {string} dim
  18537. * @param {number} idx
  18538. * @return {number}
  18539. */
  18540. listProto.hasValue = function (idx) {
  18541. var dimensions = this.dimensions;
  18542. var dimensionInfos = this._dimensionInfos;
  18543. for (var i = 0, len = dimensions.length; i < len; i++) {
  18544. if (
  18545. // Ordinal type can be string or number
  18546. dimensionInfos[dimensions[i]].type !== 'ordinal'
  18547. && isNaN(this.get(dimensions[i], idx))
  18548. ) {
  18549. return false;
  18550. }
  18551. }
  18552. return true;
  18553. };
  18554. /**
  18555. * Get extent of data in one dimension
  18556. * @param {string} dim
  18557. * @param {boolean} stack
  18558. */
  18559. listProto.getDataExtent = function (dim, stack) {
  18560. dim = this.getDimension(dim);
  18561. var dimData = this._storage[dim];
  18562. var dimInfo = this.getDimensionInfo(dim);
  18563. stack = (dimInfo && dimInfo.stackable) && stack;
  18564. var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)];
  18565. var value;
  18566. if (dimExtent) {
  18567. return dimExtent;
  18568. }
  18569. // var dimInfo = this._dimensionInfos[dim];
  18570. if (dimData) {
  18571. var min = Infinity;
  18572. var max = -Infinity;
  18573. // var isOrdinal = dimInfo.type === 'ordinal';
  18574. for (var i = 0, len = this.count(); i < len; i++) {
  18575. value = this.get(dim, i, stack);
  18576. // FIXME
  18577. // if (isOrdinal && typeof value === 'string') {
  18578. // value = zrUtil.indexOf(dimData, value);
  18579. // }
  18580. value < min && (min = value);
  18581. value > max && (max = value);
  18582. }
  18583. return (this._extent[dim + !!stack] = [min, max]);
  18584. }
  18585. else {
  18586. return [Infinity, -Infinity];
  18587. }
  18588. };
  18589. /**
  18590. * Get sum of data in one dimension
  18591. * @param {string} dim
  18592. * @param {boolean} stack
  18593. */
  18594. listProto.getSum = function (dim, stack) {
  18595. var dimData = this._storage[dim];
  18596. var sum = 0;
  18597. if (dimData) {
  18598. for (var i = 0, len = this.count(); i < len; i++) {
  18599. var value = this.get(dim, i, stack);
  18600. if (!isNaN(value)) {
  18601. sum += value;
  18602. }
  18603. }
  18604. }
  18605. return sum;
  18606. };
  18607. /**
  18608. * Retreive the index with given value
  18609. * @param {number} idx
  18610. * @param {number} value
  18611. * @return {number}
  18612. */
  18613. // FIXME Precision of float value
  18614. listProto.indexOf = function (dim, value) {
  18615. var storage = this._storage;
  18616. var dimData = storage[dim];
  18617. var indices = this.indices;
  18618. if (dimData) {
  18619. for (var i = 0, len = indices.length; i < len; i++) {
  18620. var rawIndex = indices[i];
  18621. if (dimData[rawIndex] === value) {
  18622. return i;
  18623. }
  18624. }
  18625. }
  18626. return -1;
  18627. };
  18628. /**
  18629. * Retreive the index with given name
  18630. * @param {number} idx
  18631. * @param {number} name
  18632. * @return {number}
  18633. */
  18634. listProto.indexOfName = function (name) {
  18635. var indices = this.indices;
  18636. var nameList = this._nameList;
  18637. for (var i = 0, len = indices.length; i < len; i++) {
  18638. var rawIndex = indices[i];
  18639. if (nameList[rawIndex] === name) {
  18640. return i;
  18641. }
  18642. }
  18643. return -1;
  18644. };
  18645. /**
  18646. * Retreive the index with given raw data index
  18647. * @param {number} idx
  18648. * @param {number} name
  18649. * @return {number}
  18650. */
  18651. listProto.indexOfRawIndex = function (rawIndex) {
  18652. // Indices are ascending
  18653. var indices = this.indices;
  18654. // If rawIndex === dataIndex
  18655. var rawDataIndex = indices[rawIndex];
  18656. if (rawDataIndex != null && rawDataIndex === rawIndex) {
  18657. return rawIndex;
  18658. }
  18659. var left = 0;
  18660. var right = indices.length - 1;
  18661. while (left <= right) {
  18662. var mid = (left + right) / 2 | 0;
  18663. if (indices[mid] < rawIndex) {
  18664. left = mid + 1;
  18665. }
  18666. else if (indices[mid] > rawIndex) {
  18667. right = mid - 1;
  18668. }
  18669. else {
  18670. return mid;
  18671. }
  18672. }
  18673. return -1;
  18674. };
  18675. /**
  18676. * Retreive the index of nearest value
  18677. * @param {string} dim
  18678. * @param {number} value
  18679. * @param {boolean} stack If given value is after stacked
  18680. * @param {number} [maxDistance=Infinity]
  18681. * @return {number}
  18682. */
  18683. listProto.indexOfNearest = function (dim, value, stack, maxDistance) {
  18684. var storage = this._storage;
  18685. var dimData = storage[dim];
  18686. if (maxDistance == null) {
  18687. maxDistance = Infinity;
  18688. }
  18689. var nearestIdx = -1;
  18690. if (dimData) {
  18691. var minDist = Number.MAX_VALUE;
  18692. for (var i = 0, len = this.count(); i < len; i++) {
  18693. var diff = value - this.get(dim, i, stack);
  18694. var dist = Math.abs(diff);
  18695. if (
  18696. diff <= maxDistance
  18697. && (dist < minDist
  18698. // For the case of two data are same on xAxis, which has sequence data.
  18699. // Show the nearest index
  18700. // https://github.com/ecomfe/echarts/issues/2869
  18701. || (dist === minDist && diff > 0)
  18702. )
  18703. ) {
  18704. minDist = dist;
  18705. nearestIdx = i;
  18706. }
  18707. }
  18708. }
  18709. return nearestIdx;
  18710. };
  18711. /**
  18712. * Get raw data index
  18713. * @param {number} idx
  18714. * @return {number}
  18715. */
  18716. listProto.getRawIndex = function (idx) {
  18717. var rawIdx = this.indices[idx];
  18718. return rawIdx == null ? -1 : rawIdx;
  18719. };
  18720. /**
  18721. * Get raw data item
  18722. * @param {number} idx
  18723. * @return {number}
  18724. */
  18725. listProto.getRawDataItem = function (idx) {
  18726. return this._rawData[this.getRawIndex(idx)];
  18727. };
  18728. /**
  18729. * @param {number} idx
  18730. * @param {boolean} [notDefaultIdx=false]
  18731. * @return {string}
  18732. */
  18733. listProto.getName = function (idx) {
  18734. return this._nameList[this.indices[idx]] || '';
  18735. };
  18736. /**
  18737. * @param {number} idx
  18738. * @param {boolean} [notDefaultIdx=false]
  18739. * @return {string}
  18740. */
  18741. listProto.getId = function (idx) {
  18742. return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + '');
  18743. };
  18744. function normalizeDimensions(dimensions) {
  18745. if (!zrUtil.isArray(dimensions)) {
  18746. dimensions = [dimensions];
  18747. }
  18748. return dimensions;
  18749. }
  18750. /**
  18751. * Data iteration
  18752. * @param {string|Array.<string>}
  18753. * @param {Function} cb
  18754. * @param {boolean} [stack=false]
  18755. * @param {*} [context=this]
  18756. *
  18757. * @example
  18758. * list.each('x', function (x, idx) {});
  18759. * list.each(['x', 'y'], function (x, y, idx) {});
  18760. * list.each(function (idx) {})
  18761. */
  18762. listProto.each = function (dims, cb, stack, context) {
  18763. if (typeof dims === 'function') {
  18764. context = stack;
  18765. stack = cb;
  18766. cb = dims;
  18767. dims = [];
  18768. }
  18769. dims = zrUtil.map(normalizeDimensions(dims), this.getDimension, this);
  18770. var value = [];
  18771. var dimSize = dims.length;
  18772. var indices = this.indices;
  18773. context = context || this;
  18774. for (var i = 0; i < indices.length; i++) {
  18775. // Simple optimization
  18776. switch (dimSize) {
  18777. case 0:
  18778. cb.call(context, i);
  18779. break;
  18780. case 1:
  18781. cb.call(context, this.get(dims[0], i, stack), i);
  18782. break;
  18783. case 2:
  18784. cb.call(context, this.get(dims[0], i, stack), this.get(dims[1], i, stack), i);
  18785. break;
  18786. default:
  18787. for (var k = 0; k < dimSize; k++) {
  18788. value[k] = this.get(dims[k], i, stack);
  18789. }
  18790. // Index
  18791. value[k] = i;
  18792. cb.apply(context, value);
  18793. }
  18794. }
  18795. };
  18796. /**
  18797. * Data filter
  18798. * @param {string|Array.<string>}
  18799. * @param {Function} cb
  18800. * @param {boolean} [stack=false]
  18801. * @param {*} [context=this]
  18802. */
  18803. listProto.filterSelf = function (dimensions, cb, stack, context) {
  18804. if (typeof dimensions === 'function') {
  18805. context = stack;
  18806. stack = cb;
  18807. cb = dimensions;
  18808. dimensions = [];
  18809. }
  18810. dimensions = zrUtil.map(
  18811. normalizeDimensions(dimensions), this.getDimension, this
  18812. );
  18813. var newIndices = [];
  18814. var value = [];
  18815. var dimSize = dimensions.length;
  18816. var indices = this.indices;
  18817. context = context || this;
  18818. for (var i = 0; i < indices.length; i++) {
  18819. var keep;
  18820. // Simple optimization
  18821. if (dimSize === 1) {
  18822. keep = cb.call(
  18823. context, this.get(dimensions[0], i, stack), i
  18824. );
  18825. }
  18826. else {
  18827. for (var k = 0; k < dimSize; k++) {
  18828. value[k] = this.get(dimensions[k], i, stack);
  18829. }
  18830. value[k] = i;
  18831. keep = cb.apply(context, value);
  18832. }
  18833. if (keep) {
  18834. newIndices.push(indices[i]);
  18835. }
  18836. }
  18837. this.indices = newIndices;
  18838. // Reset data extent
  18839. this._extent = {};
  18840. return this;
  18841. };
  18842. /**
  18843. * Data mapping to a plain array
  18844. * @param {string|Array.<string>} [dimensions]
  18845. * @param {Function} cb
  18846. * @param {boolean} [stack=false]
  18847. * @param {*} [context=this]
  18848. * @return {Array}
  18849. */
  18850. listProto.mapArray = function (dimensions, cb, stack, context) {
  18851. if (typeof dimensions === 'function') {
  18852. context = stack;
  18853. stack = cb;
  18854. cb = dimensions;
  18855. dimensions = [];
  18856. }
  18857. var result = [];
  18858. this.each(dimensions, function () {
  18859. result.push(cb && cb.apply(this, arguments));
  18860. }, stack, context);
  18861. return result;
  18862. };
  18863. function cloneListForMapAndSample(original, excludeDimensions) {
  18864. var allDimensions = original.dimensions;
  18865. var list = new List(
  18866. zrUtil.map(allDimensions, original.getDimensionInfo, original),
  18867. original.hostModel
  18868. );
  18869. // FIXME If needs stackedOn, value may already been stacked
  18870. transferProperties(list, original);
  18871. var storage = list._storage = {};
  18872. var originalStorage = original._storage;
  18873. // Init storage
  18874. for (var i = 0; i < allDimensions.length; i++) {
  18875. var dim = allDimensions[i];
  18876. var dimStore = originalStorage[dim];
  18877. if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {
  18878. storage[dim] = new dimStore.constructor(
  18879. originalStorage[dim].length
  18880. );
  18881. }
  18882. else {
  18883. // Direct reference for other dimensions
  18884. storage[dim] = originalStorage[dim];
  18885. }
  18886. }
  18887. return list;
  18888. }
  18889. /**
  18890. * Data mapping to a new List with given dimensions
  18891. * @param {string|Array.<string>} dimensions
  18892. * @param {Function} cb
  18893. * @param {boolean} [stack=false]
  18894. * @param {*} [context=this]
  18895. * @return {Array}
  18896. */
  18897. listProto.map = function (dimensions, cb, stack, context) {
  18898. dimensions = zrUtil.map(
  18899. normalizeDimensions(dimensions), this.getDimension, this
  18900. );
  18901. var list = cloneListForMapAndSample(this, dimensions);
  18902. // Following properties are all immutable.
  18903. // So we can reference to the same value
  18904. var indices = list.indices = this.indices;
  18905. var storage = list._storage;
  18906. var tmpRetValue = [];
  18907. this.each(dimensions, function () {
  18908. var idx = arguments[arguments.length - 1];
  18909. var retValue = cb && cb.apply(this, arguments);
  18910. if (retValue != null) {
  18911. // a number
  18912. if (typeof retValue === 'number') {
  18913. tmpRetValue[0] = retValue;
  18914. retValue = tmpRetValue;
  18915. }
  18916. for (var i = 0; i < retValue.length; i++) {
  18917. var dim = dimensions[i];
  18918. var dimStore = storage[dim];
  18919. var rawIdx = indices[idx];
  18920. if (dimStore) {
  18921. dimStore[rawIdx] = retValue[i];
  18922. }
  18923. }
  18924. }
  18925. }, stack, context);
  18926. return list;
  18927. };
  18928. /**
  18929. * Large data down sampling on given dimension
  18930. * @param {string} dimension
  18931. * @param {number} rate
  18932. * @param {Function} sampleValue
  18933. * @param {Function} sampleIndex Sample index for name and id
  18934. */
  18935. listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) {
  18936. var list = cloneListForMapAndSample(this, [dimension]);
  18937. var storage = this._storage;
  18938. var targetStorage = list._storage;
  18939. var originalIndices = this.indices;
  18940. var indices = list.indices = [];
  18941. var frameValues = [];
  18942. var frameIndices = [];
  18943. var frameSize = Math.floor(1 / rate);
  18944. var dimStore = targetStorage[dimension];
  18945. var len = this.count();
  18946. // Copy data from original data
  18947. for (var i = 0; i < storage[dimension].length; i++) {
  18948. targetStorage[dimension][i] = storage[dimension][i];
  18949. }
  18950. for (var i = 0; i < len; i += frameSize) {
  18951. // Last frame
  18952. if (frameSize > len - i) {
  18953. frameSize = len - i;
  18954. frameValues.length = frameSize;
  18955. }
  18956. for (var k = 0; k < frameSize; k++) {
  18957. var idx = originalIndices[i + k];
  18958. frameValues[k] = dimStore[idx];
  18959. frameIndices[k] = idx;
  18960. }
  18961. var value = sampleValue(frameValues);
  18962. var idx = frameIndices[sampleIndex(frameValues, value) || 0];
  18963. // Only write value on the filtered data
  18964. dimStore[idx] = value;
  18965. indices.push(idx);
  18966. }
  18967. return list;
  18968. };
  18969. /**
  18970. * Get model of one data item.
  18971. *
  18972. * @param {number} idx
  18973. */
  18974. // FIXME Model proxy ?
  18975. listProto.getItemModel = function (idx) {
  18976. var hostModel = this.hostModel;
  18977. idx = this.indices[idx];
  18978. return new Model(this._rawData[idx], hostModel, hostModel && hostModel.ecModel);
  18979. };
  18980. /**
  18981. * Create a data differ
  18982. * @param {module:echarts/data/List} otherList
  18983. * @return {module:echarts/data/DataDiffer}
  18984. */
  18985. listProto.diff = function (otherList) {
  18986. var idList = this._idList;
  18987. var otherIdList = otherList && otherList._idList;
  18988. var val;
  18989. // Use prefix to avoid index to be the same as otherIdList[idx],
  18990. // which will cause weird udpate animation.
  18991. var prefix = 'e\0\0';
  18992. return new DataDiffer(
  18993. otherList ? otherList.indices : [],
  18994. this.indices,
  18995. function (idx) {
  18996. return (val = otherIdList[idx]) != null ? val : prefix + idx;
  18997. },
  18998. function (idx) {
  18999. return (val = idList[idx]) != null ? val : prefix + idx;
  19000. }
  19001. );
  19002. };
  19003. /**
  19004. * Get visual property.
  19005. * @param {string} key
  19006. */
  19007. listProto.getVisual = function (key) {
  19008. var visual = this._visual;
  19009. return visual && visual[key];
  19010. };
  19011. /**
  19012. * Set visual property
  19013. * @param {string|Object} key
  19014. * @param {*} [value]
  19015. *
  19016. * @example
  19017. * setVisual('color', color);
  19018. * setVisual({
  19019. * 'color': color
  19020. * });
  19021. */
  19022. listProto.setVisual = function (key, val) {
  19023. if (isObject(key)) {
  19024. for (var name in key) {
  19025. if (key.hasOwnProperty(name)) {
  19026. this.setVisual(name, key[name]);
  19027. }
  19028. }
  19029. return;
  19030. }
  19031. this._visual = this._visual || {};
  19032. this._visual[key] = val;
  19033. };
  19034. /**
  19035. * Set layout property.
  19036. * @param {string} key
  19037. * @param {*} [val]
  19038. */
  19039. listProto.setLayout = function (key, val) {
  19040. if (isObject(key)) {
  19041. for (var name in key) {
  19042. if (key.hasOwnProperty(name)) {
  19043. this.setLayout(name, key[name]);
  19044. }
  19045. }
  19046. return;
  19047. }
  19048. this._layout[key] = val;
  19049. };
  19050. /**
  19051. * Get layout property.
  19052. * @param {string} key.
  19053. * @return {*}
  19054. */
  19055. listProto.getLayout = function (key) {
  19056. return this._layout[key];
  19057. };
  19058. /**
  19059. * Get layout of single data item
  19060. * @param {number} idx
  19061. */
  19062. listProto.getItemLayout = function (idx) {
  19063. return this._itemLayouts[idx];
  19064. };
  19065. /**
  19066. * Set layout of single data item
  19067. * @param {number} idx
  19068. * @param {Object} layout
  19069. * @param {boolean=} [merge=false]
  19070. */
  19071. listProto.setItemLayout = function (idx, layout, merge) {
  19072. this._itemLayouts[idx] = merge
  19073. ? zrUtil.extend(this._itemLayouts[idx] || {}, layout)
  19074. : layout;
  19075. };
  19076. /**
  19077. * Clear all layout of single data item
  19078. */
  19079. listProto.clearItemLayouts = function () {
  19080. this._itemLayouts.length = 0;
  19081. };
  19082. /**
  19083. * Get visual property of single data item
  19084. * @param {number} idx
  19085. * @param {string} key
  19086. * @param {boolean} ignoreParent
  19087. */
  19088. listProto.getItemVisual = function (idx, key, ignoreParent) {
  19089. var itemVisual = this._itemVisuals[idx];
  19090. var val = itemVisual && itemVisual[key];
  19091. if (val == null && !ignoreParent) {
  19092. // Use global visual property
  19093. return this.getVisual(key);
  19094. }
  19095. return val;
  19096. };
  19097. /**
  19098. * Set visual property of single data item
  19099. *
  19100. * @param {number} idx
  19101. * @param {string|Object} key
  19102. * @param {*} [value]
  19103. *
  19104. * @example
  19105. * setItemVisual(0, 'color', color);
  19106. * setItemVisual(0, {
  19107. * 'color': color
  19108. * });
  19109. */
  19110. listProto.setItemVisual = function (idx, key, value) {
  19111. var itemVisual = this._itemVisuals[idx] || {};
  19112. this._itemVisuals[idx] = itemVisual;
  19113. if (isObject(key)) {
  19114. for (var name in key) {
  19115. if (key.hasOwnProperty(name)) {
  19116. itemVisual[name] = key[name];
  19117. }
  19118. }
  19119. return;
  19120. }
  19121. itemVisual[key] = value;
  19122. };
  19123. /**
  19124. * Clear itemVisuals and list visual.
  19125. */
  19126. listProto.clearAllVisual = function () {
  19127. this._visual = {};
  19128. this._itemVisuals = [];
  19129. };
  19130. var setItemDataAndSeriesIndex = function (child) {
  19131. child.seriesIndex = this.seriesIndex;
  19132. child.dataIndex = this.dataIndex;
  19133. child.dataType = this.dataType;
  19134. };
  19135. /**
  19136. * Set graphic element relative to data. It can be set as null
  19137. * @param {number} idx
  19138. * @param {module:zrender/Element} [el]
  19139. */
  19140. listProto.setItemGraphicEl = function (idx, el) {
  19141. var hostModel = this.hostModel;
  19142. if (el) {
  19143. // Add data index and series index for indexing the data by element
  19144. // Useful in tooltip
  19145. el.dataIndex = idx;
  19146. el.dataType = this.dataType;
  19147. el.seriesIndex = hostModel && hostModel.seriesIndex;
  19148. if (el.type === 'group') {
  19149. el.traverse(setItemDataAndSeriesIndex, el);
  19150. }
  19151. }
  19152. this._graphicEls[idx] = el;
  19153. };
  19154. /**
  19155. * @param {number} idx
  19156. * @return {module:zrender/Element}
  19157. */
  19158. listProto.getItemGraphicEl = function (idx) {
  19159. return this._graphicEls[idx];
  19160. };
  19161. /**
  19162. * @param {Function} cb
  19163. * @param {*} context
  19164. */
  19165. listProto.eachItemGraphicEl = function (cb, context) {
  19166. zrUtil.each(this._graphicEls, function (el, idx) {
  19167. if (el) {
  19168. cb && cb.call(context, el, idx);
  19169. }
  19170. });
  19171. };
  19172. /**
  19173. * Shallow clone a new list except visual and layout properties, and graph elements.
  19174. * New list only change the indices.
  19175. */
  19176. listProto.cloneShallow = function () {
  19177. var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this);
  19178. var list = new List(dimensionInfoList, this.hostModel);
  19179. // FIXME
  19180. list._storage = this._storage;
  19181. transferProperties(list, this);
  19182. // Clone will not change the data extent and indices
  19183. list.indices = this.indices.slice();
  19184. if (this._extent) {
  19185. list._extent = zrUtil.extend({}, this._extent);
  19186. }
  19187. return list;
  19188. };
  19189. /**
  19190. * Wrap some method to add more feature
  19191. * @param {string} methodName
  19192. * @param {Function} injectFunction
  19193. */
  19194. listProto.wrapMethod = function (methodName, injectFunction) {
  19195. var originalMethod = this[methodName];
  19196. if (typeof originalMethod !== 'function') {
  19197. return;
  19198. }
  19199. this.__wrappedMethods = this.__wrappedMethods || [];
  19200. this.__wrappedMethods.push(methodName);
  19201. this[methodName] = function () {
  19202. var res = originalMethod.apply(this, arguments);
  19203. return injectFunction.apply(this, [res].concat(zrUtil.slice(arguments)));
  19204. };
  19205. };
  19206. // Methods that create a new list based on this list should be listed here.
  19207. // Notice that those method should `RETURN` the new list.
  19208. listProto.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'map'];
  19209. // Methods that change indices of this list should be listed here.
  19210. listProto.CHANGABLE_METHODS = ['filterSelf'];
  19211. module.exports = List;
  19212. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  19213. /***/ },
  19214. /* 99 */
  19215. /***/ function(module, exports) {
  19216. 'use strict';
  19217. function defaultKeyGetter(item) {
  19218. return item;
  19219. }
  19220. function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) {
  19221. this._old = oldArr;
  19222. this._new = newArr;
  19223. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
  19224. this._newKeyGetter = newKeyGetter || defaultKeyGetter;
  19225. }
  19226. DataDiffer.prototype = {
  19227. constructor: DataDiffer,
  19228. /**
  19229. * Callback function when add a data
  19230. */
  19231. add: function (func) {
  19232. this._add = func;
  19233. return this;
  19234. },
  19235. /**
  19236. * Callback function when update a data
  19237. */
  19238. update: function (func) {
  19239. this._update = func;
  19240. return this;
  19241. },
  19242. /**
  19243. * Callback function when remove a data
  19244. */
  19245. remove: function (func) {
  19246. this._remove = func;
  19247. return this;
  19248. },
  19249. execute: function () {
  19250. var oldArr = this._old;
  19251. var newArr = this._new;
  19252. var oldKeyGetter = this._oldKeyGetter;
  19253. var newKeyGetter = this._newKeyGetter;
  19254. var oldDataIndexMap = {};
  19255. var newDataIndexMap = {};
  19256. var oldDataKeyArr = [];
  19257. var newDataKeyArr = [];
  19258. var i;
  19259. initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, oldKeyGetter);
  19260. initIndexMap(newArr, newDataIndexMap, newDataKeyArr, newKeyGetter);
  19261. // Travel by inverted order to make sure order consistency
  19262. // when duplicate keys exists (consider newDataIndex.pop() below).
  19263. // For performance consideration, these code below do not look neat.
  19264. for (i = 0; i < oldArr.length; i++) {
  19265. var key = oldDataKeyArr[i];
  19266. var idx = newDataIndexMap[key];
  19267. // idx can never be empty array here. see 'set null' logic below.
  19268. if (idx != null) {
  19269. // Consider there is duplicate key (for example, use dataItem.name as key).
  19270. // We should make sure every item in newArr and oldArr can be visited.
  19271. var len = idx.length;
  19272. if (len) {
  19273. len === 1 && (newDataIndexMap[key] = null);
  19274. idx = idx.unshift();
  19275. }
  19276. else {
  19277. newDataIndexMap[key] = null;
  19278. }
  19279. this._update && this._update(idx, i);
  19280. }
  19281. else {
  19282. this._remove && this._remove(i);
  19283. }
  19284. }
  19285. for (var i = 0; i < newDataKeyArr.length; i++) {
  19286. var key = newDataKeyArr[i];
  19287. if (newDataIndexMap.hasOwnProperty(key)) {
  19288. var idx = newDataIndexMap[key];
  19289. if (idx == null) {
  19290. continue;
  19291. }
  19292. // idx can never be empty array here. see 'set null' logic above.
  19293. if (!idx.length) {
  19294. this._add && this._add(idx);
  19295. }
  19296. else {
  19297. for (var j = 0, len = idx.length; j < len; j++) {
  19298. this._add && this._add(idx[j]);
  19299. }
  19300. }
  19301. }
  19302. }
  19303. }
  19304. };
  19305. function initIndexMap(arr, map, keyArr, keyGetter) {
  19306. for (var i = 0; i < arr.length; i++) {
  19307. var key = keyGetter(arr[i], i);
  19308. var existence = map[key];
  19309. if (existence == null) {
  19310. keyArr.push(key);
  19311. map[key] = i;
  19312. }
  19313. else {
  19314. if (!existence.length) {
  19315. map[key] = existence = [existence];
  19316. }
  19317. existence.push(i);
  19318. }
  19319. }
  19320. }
  19321. module.exports = DataDiffer;
  19322. /***/ },
  19323. /* 100 */
  19324. /***/ function(module, exports, __webpack_require__) {
  19325. var zrUtil = __webpack_require__(4);
  19326. var echarts = __webpack_require__(1);
  19327. var PRIORITY = echarts.PRIORITY;
  19328. __webpack_require__(101);
  19329. __webpack_require__(104);
  19330. echarts.registerVisual(zrUtil.curry(
  19331. __webpack_require__(110), 'line', 'circle', 'line'
  19332. ));
  19333. echarts.registerLayout(zrUtil.curry(
  19334. __webpack_require__(111), 'line'
  19335. ));
  19336. // Down sample after filter
  19337. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, zrUtil.curry(
  19338. __webpack_require__(112), 'line'
  19339. ));
  19340. // In case developer forget to include grid component
  19341. __webpack_require__(113);
  19342. /***/ },
  19343. /* 101 */
  19344. /***/ function(module, exports, __webpack_require__) {
  19345. 'use strict';
  19346. var createListFromArray = __webpack_require__(102);
  19347. var SeriesModel = __webpack_require__(28);
  19348. module.exports = SeriesModel.extend({
  19349. type: 'series.line',
  19350. dependencies: ['grid', 'polar'],
  19351. getInitialData: function (option, ecModel) {
  19352. if (true) {
  19353. var coordSys = option.coordinateSystem;
  19354. if (coordSys !== 'polar' && coordSys !== 'cartesian2d') {
  19355. throw new Error('Line not support coordinateSystem besides cartesian and polar');
  19356. }
  19357. }
  19358. return createListFromArray(option.data, this, ecModel);
  19359. },
  19360. defaultOption: {
  19361. zlevel: 0, // 一级层叠
  19362. z: 2, // 二级层叠
  19363. coordinateSystem: 'cartesian2d',
  19364. legendHoverLink: true,
  19365. hoverAnimation: true,
  19366. // stack: null
  19367. // xAxisIndex: 0,
  19368. // yAxisIndex: 0,
  19369. // polarIndex: 0,
  19370. // If clip the overflow value
  19371. clipOverflow: true,
  19372. label: {
  19373. normal: {
  19374. position: 'top'
  19375. }
  19376. },
  19377. // itemStyle: {
  19378. // normal: {},
  19379. // emphasis: {}
  19380. // },
  19381. lineStyle: {
  19382. normal: {
  19383. width: 2,
  19384. type: 'solid'
  19385. }
  19386. },
  19387. // areaStyle: {},
  19388. // false, 'start', 'end', 'middle'
  19389. step: false,
  19390. // Disabled if step is true
  19391. smooth: false,
  19392. smoothMonotone: null,
  19393. // 拐点图形类型
  19394. symbol: 'emptyCircle',
  19395. // 拐点图形大小
  19396. symbolSize: 4,
  19397. // 拐点图形旋转控制
  19398. symbolRotate: null,
  19399. // 是否显示 symbol, 只有在 tooltip hover 的时候显示
  19400. showSymbol: true,
  19401. // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略)
  19402. showAllSymbol: false,
  19403. // 是否连接断点
  19404. connectNulls: false,
  19405. // 数据过滤,'average', 'max', 'min', 'sum'
  19406. sampling: 'none',
  19407. animationEasing: 'linear',
  19408. // Disable progressive
  19409. progressive: 0,
  19410. hoverLayerThreshold: Infinity
  19411. }
  19412. });
  19413. /***/ },
  19414. /* 102 */
  19415. /***/ function(module, exports, __webpack_require__) {
  19416. 'use strict';
  19417. var List = __webpack_require__(98);
  19418. var completeDimensions = __webpack_require__(103);
  19419. var zrUtil = __webpack_require__(4);
  19420. var modelUtil = __webpack_require__(5);
  19421. var CoordinateSystem = __webpack_require__(26);
  19422. var getDataItemValue = modelUtil.getDataItemValue;
  19423. var converDataValue = modelUtil.converDataValue;
  19424. function firstDataNotNull(data) {
  19425. var i = 0;
  19426. while (i < data.length && data[i] == null) {
  19427. i++;
  19428. }
  19429. return data[i];
  19430. }
  19431. function ifNeedCompleteOrdinalData(data) {
  19432. var sampleItem = firstDataNotNull(data);
  19433. return sampleItem != null
  19434. && !zrUtil.isArray(getDataItemValue(sampleItem));
  19435. }
  19436. /**
  19437. * Helper function to create a list from option data
  19438. */
  19439. function createListFromArray(data, seriesModel, ecModel) {
  19440. // If data is undefined
  19441. data = data || [];
  19442. if (true) {
  19443. if (!zrUtil.isArray(data)) {
  19444. throw new Error('Invalid data.');
  19445. }
  19446. }
  19447. var coordSysName = seriesModel.get('coordinateSystem');
  19448. var creator = creators[coordSysName];
  19449. var registeredCoordSys = CoordinateSystem.get(coordSysName);
  19450. // FIXME
  19451. var axesInfo = creator && creator(data, seriesModel, ecModel);
  19452. var dimensions = axesInfo && axesInfo.dimensions;
  19453. if (!dimensions) {
  19454. // Get dimensions from registered coordinate system
  19455. dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y'];
  19456. dimensions = completeDimensions(dimensions, data, dimensions.concat(['value']));
  19457. }
  19458. var categoryIndex = axesInfo ? axesInfo.categoryIndex : -1;
  19459. var list = new List(dimensions, seriesModel);
  19460. var nameList = createNameList(axesInfo, data);
  19461. var categories = {};
  19462. var dimValueGetter = (categoryIndex >= 0 && ifNeedCompleteOrdinalData(data))
  19463. ? function (itemOpt, dimName, dataIndex, dimIndex) {
  19464. // If any dataItem is like { value: 10 }
  19465. if (modelUtil.isDataItemOption(itemOpt)) {
  19466. list.hasItemOption = true;
  19467. }
  19468. // Use dataIndex as ordinal value in categoryAxis
  19469. return dimIndex === categoryIndex
  19470. ? dataIndex
  19471. : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]);
  19472. }
  19473. : function (itemOpt, dimName, dataIndex, dimIndex) {
  19474. var value = getDataItemValue(itemOpt);
  19475. var val = converDataValue(value && value[dimIndex], dimensions[dimIndex]);
  19476. // If any dataItem is like { value: 10 }
  19477. if (modelUtil.isDataItemOption(itemOpt)) {
  19478. list.hasItemOption = true;
  19479. }
  19480. var categoryAxesModels = axesInfo && axesInfo.categoryAxesModels;
  19481. if (categoryAxesModels && categoryAxesModels[dimName]) {
  19482. // If given value is a category string
  19483. if (typeof val === 'string') {
  19484. // Lazy get categories
  19485. categories[dimName] = categories[dimName]
  19486. || categoryAxesModels[dimName].getCategories();
  19487. val = zrUtil.indexOf(categories[dimName], val);
  19488. if (val < 0 && !isNaN(val)) {
  19489. // In case some one write '1', '2' istead of 1, 2
  19490. val = +val;
  19491. }
  19492. }
  19493. }
  19494. return val;
  19495. };
  19496. list.hasItemOption = false;
  19497. list.initData(data, nameList, dimValueGetter);
  19498. return list;
  19499. }
  19500. function isStackable(axisType) {
  19501. return axisType !== 'category' && axisType !== 'time';
  19502. }
  19503. function getDimTypeByAxis(axisType) {
  19504. return axisType === 'category'
  19505. ? 'ordinal'
  19506. : axisType === 'time'
  19507. ? 'time'
  19508. : 'float';
  19509. }
  19510. /**
  19511. * Creaters for each coord system.
  19512. */
  19513. var creators = {
  19514. cartesian2d: function (data, seriesModel, ecModel) {
  19515. var axesModels = zrUtil.map(['xAxis', 'yAxis'], function (name) {
  19516. return ecModel.queryComponents({
  19517. mainType: name,
  19518. index: seriesModel.get(name + 'Index'),
  19519. id: seriesModel.get(name + 'Id')
  19520. })[0];
  19521. });
  19522. var xAxisModel = axesModels[0];
  19523. var yAxisModel = axesModels[1];
  19524. if (true) {
  19525. if (!xAxisModel) {
  19526. throw new Error('xAxis "' + zrUtil.retrieve(
  19527. seriesModel.get('xAxisIndex'),
  19528. seriesModel.get('xAxisId'),
  19529. 0
  19530. ) + '" not found');
  19531. }
  19532. if (!yAxisModel) {
  19533. throw new Error('yAxis "' + zrUtil.retrieve(
  19534. seriesModel.get('xAxisIndex'),
  19535. seriesModel.get('yAxisId'),
  19536. 0
  19537. ) + '" not found');
  19538. }
  19539. }
  19540. var xAxisType = xAxisModel.get('type');
  19541. var yAxisType = yAxisModel.get('type');
  19542. var dimensions = [
  19543. {
  19544. name: 'x',
  19545. type: getDimTypeByAxis(xAxisType),
  19546. stackable: isStackable(xAxisType)
  19547. },
  19548. {
  19549. name: 'y',
  19550. // If two category axes
  19551. type: getDimTypeByAxis(yAxisType),
  19552. stackable: isStackable(yAxisType)
  19553. }
  19554. ];
  19555. var isXAxisCateogry = xAxisType === 'category';
  19556. var isYAxisCategory = yAxisType === 'category';
  19557. completeDimensions(dimensions, data, ['x', 'y', 'z']);
  19558. var categoryAxesModels = {};
  19559. if (isXAxisCateogry) {
  19560. categoryAxesModels.x = xAxisModel;
  19561. }
  19562. if (isYAxisCategory) {
  19563. categoryAxesModels.y = yAxisModel;
  19564. }
  19565. return {
  19566. dimensions: dimensions,
  19567. categoryIndex: isXAxisCateogry ? 0 : (isYAxisCategory ? 1 : -1),
  19568. categoryAxesModels: categoryAxesModels
  19569. };
  19570. },
  19571. polar: function (data, seriesModel, ecModel) {
  19572. var polarModel = ecModel.queryComponents({
  19573. mainType: 'polar',
  19574. index: seriesModel.get('polarIndex'),
  19575. id: seriesModel.get('polarId')
  19576. })[0];
  19577. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  19578. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  19579. if (true) {
  19580. if (!angleAxisModel) {
  19581. throw new Error('angleAxis option not found');
  19582. }
  19583. if (!radiusAxisModel) {
  19584. throw new Error('radiusAxis option not found');
  19585. }
  19586. }
  19587. var radiusAxisType = radiusAxisModel.get('type');
  19588. var angleAxisType = angleAxisModel.get('type');
  19589. var dimensions = [
  19590. {
  19591. name: 'radius',
  19592. type: getDimTypeByAxis(radiusAxisType),
  19593. stackable: isStackable(radiusAxisType)
  19594. },
  19595. {
  19596. name: 'angle',
  19597. type: getDimTypeByAxis(angleAxisType),
  19598. stackable: isStackable(angleAxisType)
  19599. }
  19600. ];
  19601. var isAngleAxisCateogry = angleAxisType === 'category';
  19602. var isRadiusAxisCateogry = radiusAxisType === 'category';
  19603. completeDimensions(dimensions, data, ['radius', 'angle', 'value']);
  19604. var categoryAxesModels = {};
  19605. if (isRadiusAxisCateogry) {
  19606. categoryAxesModels.radius = radiusAxisModel;
  19607. }
  19608. if (isAngleAxisCateogry) {
  19609. categoryAxesModels.angle = angleAxisModel;
  19610. }
  19611. return {
  19612. dimensions: dimensions,
  19613. categoryIndex: isAngleAxisCateogry ? 1 : (isRadiusAxisCateogry ? 0 : -1),
  19614. categoryAxesModels: categoryAxesModels
  19615. };
  19616. },
  19617. geo: function (data, seriesModel, ecModel) {
  19618. // TODO Region
  19619. // 多个散点图系列在同一个地区的时候
  19620. return {
  19621. dimensions: completeDimensions([
  19622. {name: 'lng'},
  19623. {name: 'lat'}
  19624. ], data, ['lng', 'lat', 'value'])
  19625. };
  19626. }
  19627. };
  19628. function createNameList(result, data) {
  19629. var nameList = [];
  19630. var categoryDim = result && result.dimensions[result.categoryIndex];
  19631. var categoryAxisModel;
  19632. if (categoryDim) {
  19633. categoryAxisModel = result.categoryAxesModels[categoryDim.name];
  19634. }
  19635. if (categoryAxisModel) {
  19636. // FIXME Two category axis
  19637. var categories = categoryAxisModel.getCategories();
  19638. if (categories) {
  19639. var dataLen = data.length;
  19640. // Ordered data is given explicitly like
  19641. // [[3, 0.2], [1, 0.3], [2, 0.15]]
  19642. // or given scatter data,
  19643. // pick the category
  19644. if (zrUtil.isArray(data[0]) && data[0].length > 1) {
  19645. nameList = [];
  19646. for (var i = 0; i < dataLen; i++) {
  19647. nameList[i] = categories[data[i][result.categoryIndex || 0]];
  19648. }
  19649. }
  19650. else {
  19651. nameList = categories.slice(0);
  19652. }
  19653. }
  19654. }
  19655. return nameList;
  19656. }
  19657. module.exports = createListFromArray;
  19658. /***/ },
  19659. /* 103 */
  19660. /***/ function(module, exports, __webpack_require__) {
  19661. /**
  19662. * Complete dimensions by data (guess dimension).
  19663. */
  19664. var zrUtil = __webpack_require__(4);
  19665. /**
  19666. * Complete the dimensions array guessed from the data structure.
  19667. * @param {Array.<string>} dimensions Necessary dimensions, like ['x', 'y']
  19668. * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]]
  19669. * @param {Array.<string>} defaultNames Default names to fill not necessary dimensions, like ['value']
  19670. * @param {string} extraPrefix Prefix of name when filling the left dimensions.
  19671. * @return {Array.<string>}
  19672. */
  19673. function completeDimensions(dimensions, data, defaultNames, extraPrefix) {
  19674. if (!data) {
  19675. return dimensions;
  19676. }
  19677. var value0 = retrieveValue(data[0]);
  19678. var dimSize = zrUtil.isArray(value0) && value0.length || 1;
  19679. defaultNames = defaultNames || [];
  19680. extraPrefix = extraPrefix || 'extra';
  19681. for (var i = 0; i < dimSize; i++) {
  19682. if (!dimensions[i]) {
  19683. var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length));
  19684. dimensions[i] = guessOrdinal(data, i)
  19685. ? {type: 'ordinal', name: name}
  19686. : name;
  19687. }
  19688. }
  19689. return dimensions;
  19690. }
  19691. // The rule should not be complex, otherwise user might not
  19692. // be able to known where the data is wrong.
  19693. var guessOrdinal = completeDimensions.guessOrdinal = function (data, dimIndex) {
  19694. for (var i = 0, len = data.length; i < len; i++) {
  19695. var value = retrieveValue(data[i]);
  19696. if (!zrUtil.isArray(value)) {
  19697. return false;
  19698. }
  19699. var value = value[dimIndex];
  19700. if (value != null && isFinite(value)) {
  19701. return false;
  19702. }
  19703. else if (zrUtil.isString(value) && value !== '-') {
  19704. return true;
  19705. }
  19706. }
  19707. return false;
  19708. };
  19709. function retrieveValue(o) {
  19710. return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o;
  19711. }
  19712. module.exports = completeDimensions;
  19713. /***/ },
  19714. /* 104 */
  19715. /***/ function(module, exports, __webpack_require__) {
  19716. 'use strict';
  19717. // FIXME step not support polar
  19718. var zrUtil = __webpack_require__(4);
  19719. var SymbolDraw = __webpack_require__(105);
  19720. var Symbol = __webpack_require__(106);
  19721. var lineAnimationDiff = __webpack_require__(108);
  19722. var graphic = __webpack_require__(43);
  19723. var modelUtil = __webpack_require__(5);
  19724. var polyHelper = __webpack_require__(109);
  19725. var ChartView = __webpack_require__(42);
  19726. function isPointsSame(points1, points2) {
  19727. if (points1.length !== points2.length) {
  19728. return;
  19729. }
  19730. for (var i = 0; i < points1.length; i++) {
  19731. var p1 = points1[i];
  19732. var p2 = points2[i];
  19733. if (p1[0] !== p2[0] || p1[1] !== p2[1]) {
  19734. return;
  19735. }
  19736. }
  19737. return true;
  19738. }
  19739. function getSmooth(smooth) {
  19740. return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0);
  19741. }
  19742. function getAxisExtentWithGap(axis) {
  19743. var extent = axis.getGlobalExtent();
  19744. if (axis.onBand) {
  19745. // Remove extra 1px to avoid line miter in clipped edge
  19746. var halfBandWidth = axis.getBandWidth() / 2 - 1;
  19747. var dir = extent[1] > extent[0] ? 1 : -1;
  19748. extent[0] += dir * halfBandWidth;
  19749. extent[1] -= dir * halfBandWidth;
  19750. }
  19751. return extent;
  19752. }
  19753. function sign(val) {
  19754. return val >= 0 ? 1 : -1;
  19755. }
  19756. /**
  19757. * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
  19758. * @param {module:echarts/data/List} data
  19759. * @param {Array.<Array.<number>>} points
  19760. * @private
  19761. */
  19762. function getStackedOnPoints(coordSys, data) {
  19763. var baseAxis = coordSys.getBaseAxis();
  19764. var valueAxis = coordSys.getOtherAxis(baseAxis);
  19765. var valueStart = baseAxis.onZero
  19766. ? 0 : valueAxis.scale.getExtent()[0];
  19767. var valueDim = valueAxis.dim;
  19768. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  19769. return data.mapArray([valueDim], function (val, idx) {
  19770. var stackedOnSameSign;
  19771. var stackedOn = data.stackedOn;
  19772. // Find first stacked value with same sign
  19773. while (stackedOn &&
  19774. sign(stackedOn.get(valueDim, idx)) === sign(val)
  19775. ) {
  19776. stackedOnSameSign = stackedOn;
  19777. break;
  19778. }
  19779. var stackedData = [];
  19780. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  19781. stackedData[1 - baseDataOffset] = stackedOnSameSign
  19782. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  19783. return coordSys.dataToPoint(stackedData);
  19784. }, true);
  19785. }
  19786. function createGridClipShape(cartesian, hasAnimation, seriesModel) {
  19787. var xExtent = getAxisExtentWithGap(cartesian.getAxis('x'));
  19788. var yExtent = getAxisExtentWithGap(cartesian.getAxis('y'));
  19789. var isHorizontal = cartesian.getBaseAxis().isHorizontal();
  19790. var x = Math.min(xExtent[0], xExtent[1]);
  19791. var y = Math.min(yExtent[0], yExtent[1]);
  19792. var width = Math.max(xExtent[0], xExtent[1]) - x;
  19793. var height = Math.max(yExtent[0], yExtent[1]) - y;
  19794. var lineWidth = seriesModel.get('lineStyle.normal.width') || 2;
  19795. // Expand clip shape to avoid clipping when line value exceeds axis
  19796. var expandSize = seriesModel.get('clipOverflow') ? lineWidth / 2 : Math.max(width, height);
  19797. if (isHorizontal) {
  19798. y -= expandSize;
  19799. height += expandSize * 2;
  19800. }
  19801. else {
  19802. x -= expandSize;
  19803. width += expandSize * 2;
  19804. }
  19805. var clipPath = new graphic.Rect({
  19806. shape: {
  19807. x: x,
  19808. y: y,
  19809. width: width,
  19810. height: height
  19811. }
  19812. });
  19813. if (hasAnimation) {
  19814. clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
  19815. graphic.initProps(clipPath, {
  19816. shape: {
  19817. width: width,
  19818. height: height
  19819. }
  19820. }, seriesModel);
  19821. }
  19822. return clipPath;
  19823. }
  19824. function createPolarClipShape(polar, hasAnimation, seriesModel) {
  19825. var angleAxis = polar.getAngleAxis();
  19826. var radiusAxis = polar.getRadiusAxis();
  19827. var radiusExtent = radiusAxis.getExtent();
  19828. var angleExtent = angleAxis.getExtent();
  19829. var RADIAN = Math.PI / 180;
  19830. var clipPath = new graphic.Sector({
  19831. shape: {
  19832. cx: polar.cx,
  19833. cy: polar.cy,
  19834. r0: radiusExtent[0],
  19835. r: radiusExtent[1],
  19836. startAngle: -angleExtent[0] * RADIAN,
  19837. endAngle: -angleExtent[1] * RADIAN,
  19838. clockwise: angleAxis.inverse
  19839. }
  19840. });
  19841. if (hasAnimation) {
  19842. clipPath.shape.endAngle = -angleExtent[0] * RADIAN;
  19843. graphic.initProps(clipPath, {
  19844. shape: {
  19845. endAngle: -angleExtent[1] * RADIAN
  19846. }
  19847. }, seriesModel);
  19848. }
  19849. return clipPath;
  19850. }
  19851. function createClipShape(coordSys, hasAnimation, seriesModel) {
  19852. return coordSys.type === 'polar'
  19853. ? createPolarClipShape(coordSys, hasAnimation, seriesModel)
  19854. : createGridClipShape(coordSys, hasAnimation, seriesModel);
  19855. }
  19856. function turnPointsIntoStep(points, coordSys, stepTurnAt) {
  19857. var baseAxis = coordSys.getBaseAxis();
  19858. var baseIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
  19859. var stepPoints = [];
  19860. for (var i = 0; i < points.length - 1; i++) {
  19861. var nextPt = points[i + 1];
  19862. var pt = points[i];
  19863. stepPoints.push(pt);
  19864. var stepPt = [];
  19865. switch (stepTurnAt) {
  19866. case 'end':
  19867. stepPt[baseIndex] = nextPt[baseIndex];
  19868. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  19869. // default is start
  19870. stepPoints.push(stepPt);
  19871. break;
  19872. case 'middle':
  19873. // default is start
  19874. var middle = (pt[baseIndex] + nextPt[baseIndex]) / 2;
  19875. var stepPt2 = [];
  19876. stepPt[baseIndex] = stepPt2[baseIndex] = middle;
  19877. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  19878. stepPt2[1 - baseIndex] = nextPt[1 - baseIndex];
  19879. stepPoints.push(stepPt);
  19880. stepPoints.push(stepPt2);
  19881. break;
  19882. default:
  19883. stepPt[baseIndex] = pt[baseIndex];
  19884. stepPt[1 - baseIndex] = nextPt[1 - baseIndex];
  19885. // default is start
  19886. stepPoints.push(stepPt);
  19887. }
  19888. }
  19889. // Last points
  19890. points[i] && stepPoints.push(points[i]);
  19891. return stepPoints;
  19892. }
  19893. function getVisualGradient(data, coordSys) {
  19894. var visualMetaList = data.getVisual('visualMeta');
  19895. if (!visualMetaList || !visualMetaList.length || !data.count()) {
  19896. // When data.count() is 0, gradient range can not be calculated.
  19897. return;
  19898. }
  19899. var visualMeta;
  19900. for (var i = visualMetaList.length - 1; i >= 0; i--) {
  19901. // Can only be x or y
  19902. if (visualMetaList[i].dimension < 2) {
  19903. visualMeta = visualMetaList[i];
  19904. break;
  19905. }
  19906. }
  19907. if (!visualMeta || coordSys.type !== 'cartesian2d') {
  19908. if (true) {
  19909. console.warn('Visual map on line style only support x or y dimension.');
  19910. }
  19911. return;
  19912. }
  19913. // If the area to be rendered is bigger than area defined by LinearGradient,
  19914. // the canvas spec prescribes that the color of the first stop and the last
  19915. // stop should be used. But if two stops are added at offset 0, in effect
  19916. // browsers use the color of the second stop to render area outside
  19917. // LinearGradient. So we can only infinitesimally extend area defined in
  19918. // LinearGradient to render `outerColors`.
  19919. var dimension = visualMeta.dimension;
  19920. var dimName = data.dimensions[dimension];
  19921. var axis = coordSys.getAxis(dimName);
  19922. // dataToCoor mapping may not be linear, but must be monotonic.
  19923. var colorStops = zrUtil.map(visualMeta.stops, function (stop) {
  19924. return {
  19925. coord: axis.toGlobalCoord(axis.dataToCoord(stop.value)),
  19926. color: stop.color
  19927. };
  19928. });
  19929. var stopLen = colorStops.length;
  19930. var outerColors = visualMeta.outerColors.slice();
  19931. if (stopLen && colorStops[0].coord > colorStops[stopLen - 1].coord) {
  19932. colorStops.reverse();
  19933. outerColors.reverse();
  19934. }
  19935. var tinyExtent = 10; // Arbitrary value: 10px
  19936. var minCoord = colorStops[0].coord - tinyExtent;
  19937. var maxCoord = colorStops[stopLen - 1].coord + tinyExtent;
  19938. var coordSpan = maxCoord - minCoord;
  19939. if (coordSpan < 1e-3) {
  19940. return 'transparent';
  19941. }
  19942. zrUtil.each(colorStops, function (stop) {
  19943. stop.offset = (stop.coord - minCoord) / coordSpan;
  19944. });
  19945. colorStops.push({
  19946. offset: stopLen ? colorStops[stopLen - 1].offset : 0.5,
  19947. color: outerColors[1] || 'transparent'
  19948. });
  19949. colorStops.unshift({ // notice colorStops.length have been changed.
  19950. offset: stopLen ? colorStops[0].offset : 0.5,
  19951. color: outerColors[0] || 'transparent'
  19952. });
  19953. // zrUtil.each(colorStops, function (colorStop) {
  19954. // // Make sure each offset has rounded px to avoid not sharp edge
  19955. // colorStop.offset = (Math.round(colorStop.offset * (end - start) + start) - start) / (end - start);
  19956. // });
  19957. var gradient = new graphic.LinearGradient(0, 0, 0, 0, colorStops, true);
  19958. gradient[dimName] = minCoord;
  19959. gradient[dimName + '2'] = maxCoord;
  19960. return gradient;
  19961. }
  19962. module.exports = ChartView.extend({
  19963. type: 'line',
  19964. init: function () {
  19965. var lineGroup = new graphic.Group();
  19966. var symbolDraw = new SymbolDraw();
  19967. this.group.add(symbolDraw.group);
  19968. this._symbolDraw = symbolDraw;
  19969. this._lineGroup = lineGroup;
  19970. },
  19971. render: function (seriesModel, ecModel, api) {
  19972. var coordSys = seriesModel.coordinateSystem;
  19973. var group = this.group;
  19974. var data = seriesModel.getData();
  19975. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  19976. var areaStyleModel = seriesModel.getModel('areaStyle.normal');
  19977. var points = data.mapArray(data.getItemLayout, true);
  19978. var isCoordSysPolar = coordSys.type === 'polar';
  19979. var prevCoordSys = this._coordSys;
  19980. var symbolDraw = this._symbolDraw;
  19981. var polyline = this._polyline;
  19982. var polygon = this._polygon;
  19983. var lineGroup = this._lineGroup;
  19984. var hasAnimation = seriesModel.get('animation');
  19985. var isAreaChart = !areaStyleModel.isEmpty();
  19986. var stackedOnPoints = getStackedOnPoints(coordSys, data);
  19987. var showSymbol = seriesModel.get('showSymbol');
  19988. var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol')
  19989. && this._getSymbolIgnoreFunc(data, coordSys);
  19990. // Remove temporary symbols
  19991. var oldData = this._data;
  19992. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  19993. if (el.__temp) {
  19994. group.remove(el);
  19995. oldData.setItemGraphicEl(idx, null);
  19996. }
  19997. });
  19998. // Remove previous created symbols if showSymbol changed to false
  19999. if (!showSymbol) {
  20000. symbolDraw.remove();
  20001. }
  20002. group.add(lineGroup);
  20003. // FIXME step not support polar
  20004. var step = !isCoordSysPolar && seriesModel.get('step');
  20005. // Initialization animation or coordinate system changed
  20006. if (
  20007. !(polyline && prevCoordSys.type === coordSys.type && step === this._step)
  20008. ) {
  20009. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  20010. if (step) {
  20011. // TODO If stacked series is not step
  20012. points = turnPointsIntoStep(points, coordSys, step);
  20013. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  20014. }
  20015. polyline = this._newPolyline(points, coordSys, hasAnimation);
  20016. if (isAreaChart) {
  20017. polygon = this._newPolygon(
  20018. points, stackedOnPoints,
  20019. coordSys, hasAnimation
  20020. );
  20021. }
  20022. lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel));
  20023. }
  20024. else {
  20025. if (isAreaChart && !polygon) {
  20026. // If areaStyle is added
  20027. polygon = this._newPolygon(
  20028. points, stackedOnPoints,
  20029. coordSys, hasAnimation
  20030. );
  20031. }
  20032. else if (polygon && !isAreaChart) {
  20033. // If areaStyle is removed
  20034. lineGroup.remove(polygon);
  20035. polygon = this._polygon = null;
  20036. }
  20037. // Update clipPath
  20038. lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel));
  20039. // Always update, or it is wrong in the case turning on legend
  20040. // because points are not changed
  20041. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  20042. // Stop symbol animation and sync with line points
  20043. // FIXME performance?
  20044. data.eachItemGraphicEl(function (el) {
  20045. el.stopAnimation(true);
  20046. });
  20047. // In the case data zoom triggerred refreshing frequently
  20048. // Data may not change if line has a category axis. So it should animate nothing
  20049. if (!isPointsSame(this._stackedOnPoints, stackedOnPoints)
  20050. || !isPointsSame(this._points, points)
  20051. ) {
  20052. if (hasAnimation) {
  20053. this._updateAnimation(
  20054. data, stackedOnPoints, coordSys, api, step
  20055. );
  20056. }
  20057. else {
  20058. // Not do it in update with animation
  20059. if (step) {
  20060. // TODO If stacked series is not step
  20061. points = turnPointsIntoStep(points, coordSys, step);
  20062. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  20063. }
  20064. polyline.setShape({
  20065. points: points
  20066. });
  20067. polygon && polygon.setShape({
  20068. points: points,
  20069. stackedOnPoints: stackedOnPoints
  20070. });
  20071. }
  20072. }
  20073. }
  20074. var visualColor = getVisualGradient(data, coordSys) || data.getVisual('color');
  20075. polyline.useStyle(zrUtil.defaults(
  20076. // Use color in lineStyle first
  20077. lineStyleModel.getLineStyle(),
  20078. {
  20079. fill: 'none',
  20080. stroke: visualColor,
  20081. lineJoin: 'bevel'
  20082. }
  20083. ));
  20084. var smooth = seriesModel.get('smooth');
  20085. smooth = getSmooth(seriesModel.get('smooth'));
  20086. polyline.setShape({
  20087. smooth: smooth,
  20088. smoothMonotone: seriesModel.get('smoothMonotone'),
  20089. connectNulls: seriesModel.get('connectNulls')
  20090. });
  20091. if (polygon) {
  20092. var stackedOn = data.stackedOn;
  20093. var stackedOnSmooth = 0;
  20094. polygon.useStyle(zrUtil.defaults(
  20095. areaStyleModel.getAreaStyle(),
  20096. {
  20097. fill: visualColor,
  20098. opacity: 0.7,
  20099. lineJoin: 'bevel'
  20100. }
  20101. ));
  20102. if (stackedOn) {
  20103. var stackedOnSeries = stackedOn.hostModel;
  20104. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'));
  20105. }
  20106. polygon.setShape({
  20107. smooth: smooth,
  20108. stackedOnSmooth: stackedOnSmooth,
  20109. smoothMonotone: seriesModel.get('smoothMonotone'),
  20110. connectNulls: seriesModel.get('connectNulls')
  20111. });
  20112. }
  20113. this._data = data;
  20114. // Save the coordinate system for transition animation when data changed
  20115. this._coordSys = coordSys;
  20116. this._stackedOnPoints = stackedOnPoints;
  20117. this._points = points;
  20118. this._step = step;
  20119. },
  20120. dispose: function () {},
  20121. highlight: function (seriesModel, ecModel, api, payload) {
  20122. var data = seriesModel.getData();
  20123. var dataIndex = modelUtil.queryDataIndex(data, payload);
  20124. if (!(dataIndex instanceof Array) && dataIndex != null && dataIndex >= 0) {
  20125. var symbol = data.getItemGraphicEl(dataIndex);
  20126. if (!symbol) {
  20127. // Create a temporary symbol if it is not exists
  20128. var pt = data.getItemLayout(dataIndex);
  20129. if (!pt) {
  20130. // Null data
  20131. return;
  20132. }
  20133. symbol = new Symbol(data, dataIndex);
  20134. symbol.position = pt;
  20135. symbol.setZ(
  20136. seriesModel.get('zlevel'),
  20137. seriesModel.get('z')
  20138. );
  20139. symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]);
  20140. symbol.__temp = true;
  20141. data.setItemGraphicEl(dataIndex, symbol);
  20142. // Stop scale animation
  20143. symbol.stopSymbolAnimation(true);
  20144. this.group.add(symbol);
  20145. }
  20146. symbol.highlight();
  20147. }
  20148. else {
  20149. // Highlight whole series
  20150. ChartView.prototype.highlight.call(
  20151. this, seriesModel, ecModel, api, payload
  20152. );
  20153. }
  20154. },
  20155. downplay: function (seriesModel, ecModel, api, payload) {
  20156. var data = seriesModel.getData();
  20157. var dataIndex = modelUtil.queryDataIndex(data, payload);
  20158. if (dataIndex != null && dataIndex >= 0) {
  20159. var symbol = data.getItemGraphicEl(dataIndex);
  20160. if (symbol) {
  20161. if (symbol.__temp) {
  20162. data.setItemGraphicEl(dataIndex, null);
  20163. this.group.remove(symbol);
  20164. }
  20165. else {
  20166. symbol.downplay();
  20167. }
  20168. }
  20169. }
  20170. else {
  20171. // Downplay whole series
  20172. ChartView.prototype.downplay.call(
  20173. this, seriesModel, ecModel, api, payload
  20174. );
  20175. }
  20176. },
  20177. /**
  20178. * @param {module:zrender/container/Group} group
  20179. * @param {Array.<Array.<number>>} points
  20180. * @private
  20181. */
  20182. _newPolyline: function (points) {
  20183. var polyline = this._polyline;
  20184. // Remove previous created polyline
  20185. if (polyline) {
  20186. this._lineGroup.remove(polyline);
  20187. }
  20188. polyline = new polyHelper.Polyline({
  20189. shape: {
  20190. points: points
  20191. },
  20192. silent: true,
  20193. z2: 10
  20194. });
  20195. this._lineGroup.add(polyline);
  20196. this._polyline = polyline;
  20197. return polyline;
  20198. },
  20199. /**
  20200. * @param {module:zrender/container/Group} group
  20201. * @param {Array.<Array.<number>>} stackedOnPoints
  20202. * @param {Array.<Array.<number>>} points
  20203. * @private
  20204. */
  20205. _newPolygon: function (points, stackedOnPoints) {
  20206. var polygon = this._polygon;
  20207. // Remove previous created polygon
  20208. if (polygon) {
  20209. this._lineGroup.remove(polygon);
  20210. }
  20211. polygon = new polyHelper.Polygon({
  20212. shape: {
  20213. points: points,
  20214. stackedOnPoints: stackedOnPoints
  20215. },
  20216. silent: true
  20217. });
  20218. this._lineGroup.add(polygon);
  20219. this._polygon = polygon;
  20220. return polygon;
  20221. },
  20222. /**
  20223. * @private
  20224. */
  20225. _getSymbolIgnoreFunc: function (data, coordSys) {
  20226. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  20227. // `getLabelInterval` is provided by echarts/component/axis
  20228. if (categoryAxis && categoryAxis.isLabelIgnored) {
  20229. return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis);
  20230. }
  20231. },
  20232. /**
  20233. * @private
  20234. */
  20235. // FIXME Two value axis
  20236. _updateAnimation: function (data, stackedOnPoints, coordSys, api, step) {
  20237. var polyline = this._polyline;
  20238. var polygon = this._polygon;
  20239. var seriesModel = data.hostModel;
  20240. var diff = lineAnimationDiff(
  20241. this._data, data,
  20242. this._stackedOnPoints, stackedOnPoints,
  20243. this._coordSys, coordSys
  20244. );
  20245. var current = diff.current;
  20246. var stackedOnCurrent = diff.stackedOnCurrent;
  20247. var next = diff.next;
  20248. var stackedOnNext = diff.stackedOnNext;
  20249. if (step) {
  20250. // TODO If stacked series is not step
  20251. current = turnPointsIntoStep(diff.current, coordSys, step);
  20252. stackedOnCurrent = turnPointsIntoStep(diff.stackedOnCurrent, coordSys, step);
  20253. next = turnPointsIntoStep(diff.next, coordSys, step);
  20254. stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step);
  20255. }
  20256. // `diff.current` is subset of `current` (which should be ensured by
  20257. // turnPointsIntoStep), so points in `__points` can be updated when
  20258. // points in `current` are update during animation.
  20259. polyline.shape.__points = diff.current;
  20260. polyline.shape.points = current;
  20261. graphic.updateProps(polyline, {
  20262. shape: {
  20263. points: next
  20264. }
  20265. }, seriesModel);
  20266. if (polygon) {
  20267. polygon.setShape({
  20268. points: current,
  20269. stackedOnPoints: stackedOnCurrent
  20270. });
  20271. graphic.updateProps(polygon, {
  20272. shape: {
  20273. points: next,
  20274. stackedOnPoints: stackedOnNext
  20275. }
  20276. }, seriesModel);
  20277. }
  20278. var updatedDataInfo = [];
  20279. var diffStatus = diff.status;
  20280. for (var i = 0; i < diffStatus.length; i++) {
  20281. var cmd = diffStatus[i].cmd;
  20282. if (cmd === '=') {
  20283. var el = data.getItemGraphicEl(diffStatus[i].idx1);
  20284. if (el) {
  20285. updatedDataInfo.push({
  20286. el: el,
  20287. ptIdx: i // Index of points
  20288. });
  20289. }
  20290. }
  20291. }
  20292. if (polyline.animators && polyline.animators.length) {
  20293. polyline.animators[0].during(function () {
  20294. for (var i = 0; i < updatedDataInfo.length; i++) {
  20295. var el = updatedDataInfo[i].el;
  20296. el.attr('position', polyline.shape.__points[updatedDataInfo[i].ptIdx]);
  20297. }
  20298. });
  20299. }
  20300. },
  20301. remove: function (ecModel) {
  20302. var group = this.group;
  20303. var oldData = this._data;
  20304. this._lineGroup.removeAll();
  20305. this._symbolDraw.remove(true);
  20306. // Remove temporary created elements when highlighting
  20307. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  20308. if (el.__temp) {
  20309. group.remove(el);
  20310. oldData.setItemGraphicEl(idx, null);
  20311. }
  20312. });
  20313. this._polyline =
  20314. this._polygon =
  20315. this._coordSys =
  20316. this._points =
  20317. this._stackedOnPoints =
  20318. this._data = null;
  20319. }
  20320. });
  20321. /***/ },
  20322. /* 105 */
  20323. /***/ function(module, exports, __webpack_require__) {
  20324. /**
  20325. * @module echarts/chart/helper/SymbolDraw
  20326. */
  20327. var graphic = __webpack_require__(43);
  20328. var Symbol = __webpack_require__(106);
  20329. /**
  20330. * @constructor
  20331. * @alias module:echarts/chart/helper/SymbolDraw
  20332. * @param {module:zrender/graphic/Group} [symbolCtor]
  20333. */
  20334. function SymbolDraw(symbolCtor) {
  20335. this.group = new graphic.Group();
  20336. this._symbolCtor = symbolCtor || Symbol;
  20337. }
  20338. var symbolDrawProto = SymbolDraw.prototype;
  20339. function symbolNeedsDraw(data, idx, isIgnore) {
  20340. var point = data.getItemLayout(idx);
  20341. // Is an object
  20342. // if (point && point.hasOwnProperty('point')) {
  20343. // point = point.point;
  20344. // }
  20345. return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx))
  20346. && data.getItemVisual(idx, 'symbol') !== 'none';
  20347. }
  20348. /**
  20349. * Update symbols draw by new data
  20350. * @param {module:echarts/data/List} data
  20351. * @param {Array.<boolean>} [isIgnore]
  20352. */
  20353. symbolDrawProto.updateData = function (data, isIgnore) {
  20354. var group = this.group;
  20355. var seriesModel = data.hostModel;
  20356. var oldData = this._data;
  20357. var SymbolCtor = this._symbolCtor;
  20358. var seriesScope = {
  20359. itemStyle: seriesModel.getModel('itemStyle.normal').getItemStyle(['color']),
  20360. hoverItemStyle: seriesModel.getModel('itemStyle.emphasis').getItemStyle(),
  20361. symbolRotate: seriesModel.get('symbolRotate'),
  20362. symbolOffset: seriesModel.get('symbolOffset'),
  20363. hoverAnimation: seriesModel.get('hoverAnimation'),
  20364. labelModel: seriesModel.getModel('label.normal'),
  20365. hoverLabelModel: seriesModel.getModel('label.emphasis')
  20366. };
  20367. data.diff(oldData)
  20368. .add(function (newIdx) {
  20369. var point = data.getItemLayout(newIdx);
  20370. if (symbolNeedsDraw(data, newIdx, isIgnore)) {
  20371. var symbolEl = new SymbolCtor(data, newIdx, seriesScope);
  20372. symbolEl.attr('position', point);
  20373. data.setItemGraphicEl(newIdx, symbolEl);
  20374. group.add(symbolEl);
  20375. }
  20376. })
  20377. .update(function (newIdx, oldIdx) {
  20378. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  20379. var point = data.getItemLayout(newIdx);
  20380. if (!symbolNeedsDraw(data, newIdx, isIgnore)) {
  20381. group.remove(symbolEl);
  20382. return;
  20383. }
  20384. if (!symbolEl) {
  20385. symbolEl = new SymbolCtor(data, newIdx);
  20386. symbolEl.attr('position', point);
  20387. }
  20388. else {
  20389. symbolEl.updateData(data, newIdx, seriesScope);
  20390. graphic.updateProps(symbolEl, {
  20391. position: point
  20392. }, seriesModel);
  20393. }
  20394. // Add back
  20395. group.add(symbolEl);
  20396. data.setItemGraphicEl(newIdx, symbolEl);
  20397. })
  20398. .remove(function (oldIdx) {
  20399. var el = oldData.getItemGraphicEl(oldIdx);
  20400. el && el.fadeOut(function () {
  20401. group.remove(el);
  20402. });
  20403. })
  20404. .execute();
  20405. this._data = data;
  20406. };
  20407. symbolDrawProto.updateLayout = function () {
  20408. var data = this._data;
  20409. if (data) {
  20410. // Not use animation
  20411. data.eachItemGraphicEl(function (el, idx) {
  20412. var point = data.getItemLayout(idx);
  20413. el.attr('position', point);
  20414. });
  20415. }
  20416. };
  20417. symbolDrawProto.remove = function (enableAnimation) {
  20418. var group = this.group;
  20419. var data = this._data;
  20420. if (data) {
  20421. if (enableAnimation) {
  20422. data.eachItemGraphicEl(function (el) {
  20423. el.fadeOut(function () {
  20424. group.remove(el);
  20425. });
  20426. });
  20427. }
  20428. else {
  20429. group.removeAll();
  20430. }
  20431. }
  20432. };
  20433. module.exports = SymbolDraw;
  20434. /***/ },
  20435. /* 106 */
  20436. /***/ function(module, exports, __webpack_require__) {
  20437. /**
  20438. * @module echarts/chart/helper/Symbol
  20439. */
  20440. var zrUtil = __webpack_require__(4);
  20441. var symbolUtil = __webpack_require__(107);
  20442. var graphic = __webpack_require__(43);
  20443. var numberUtil = __webpack_require__(7);
  20444. function normalizeSymbolSize(symbolSize) {
  20445. symbolSize = symbolSize instanceof Array
  20446. ? symbolSize.slice()
  20447. : [+symbolSize, +symbolSize];
  20448. symbolSize[0] /= 2;
  20449. symbolSize[1] /= 2;
  20450. return symbolSize;
  20451. }
  20452. /**
  20453. * @constructor
  20454. * @alias {module:echarts/chart/helper/Symbol}
  20455. * @param {module:echarts/data/List} data
  20456. * @param {number} idx
  20457. * @extends {module:zrender/graphic/Group}
  20458. */
  20459. function Symbol(data, idx, seriesScope) {
  20460. graphic.Group.call(this);
  20461. this.updateData(data, idx, seriesScope);
  20462. }
  20463. var symbolProto = Symbol.prototype;
  20464. function driftSymbol(dx, dy) {
  20465. this.parent.drift(dx, dy);
  20466. }
  20467. symbolProto._createSymbol = function (symbolType, data, idx) {
  20468. // Remove paths created before
  20469. this.removeAll();
  20470. var seriesModel = data.hostModel;
  20471. var color = data.getItemVisual(idx, 'color');
  20472. // var symbolPath = symbolUtil.createSymbol(
  20473. // symbolType, -0.5, -0.5, 1, 1, color
  20474. // );
  20475. // If width/height are set too small (e.g., set to 1) on ios10
  20476. // and macOS Sierra, a circle stroke become a rect, no matter what
  20477. // the scale is set. So we set width/height as 2. See #4150.
  20478. var symbolPath = symbolUtil.createSymbol(
  20479. symbolType, -1, -1, 2, 2, color
  20480. );
  20481. symbolPath.attr({
  20482. z2: 100,
  20483. culling: true,
  20484. scale: [0, 0]
  20485. });
  20486. // Rewrite drift method
  20487. symbolPath.drift = driftSymbol;
  20488. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  20489. graphic.initProps(symbolPath, {
  20490. scale: size
  20491. }, seriesModel, idx);
  20492. this._symbolType = symbolType;
  20493. this.add(symbolPath);
  20494. };
  20495. /**
  20496. * Stop animation
  20497. * @param {boolean} toLastFrame
  20498. */
  20499. symbolProto.stopSymbolAnimation = function (toLastFrame) {
  20500. this.childAt(0).stopAnimation(toLastFrame);
  20501. };
  20502. /**
  20503. * Get symbol path element
  20504. */
  20505. symbolProto.getSymbolPath = function () {
  20506. return this.childAt(0);
  20507. };
  20508. /**
  20509. * Get scale(aka, current symbol size).
  20510. * Including the change caused by animation
  20511. */
  20512. symbolProto.getScale = function () {
  20513. return this.childAt(0).scale;
  20514. };
  20515. /**
  20516. * Highlight symbol
  20517. */
  20518. symbolProto.highlight = function () {
  20519. this.childAt(0).trigger('emphasis');
  20520. };
  20521. /**
  20522. * Downplay symbol
  20523. */
  20524. symbolProto.downplay = function () {
  20525. this.childAt(0).trigger('normal');
  20526. };
  20527. /**
  20528. * @param {number} zlevel
  20529. * @param {number} z
  20530. */
  20531. symbolProto.setZ = function (zlevel, z) {
  20532. var symbolPath = this.childAt(0);
  20533. symbolPath.zlevel = zlevel;
  20534. symbolPath.z = z;
  20535. };
  20536. symbolProto.setDraggable = function (draggable) {
  20537. var symbolPath = this.childAt(0);
  20538. symbolPath.draggable = draggable;
  20539. symbolPath.cursor = draggable ? 'move' : 'pointer';
  20540. };
  20541. /**
  20542. * Update symbol properties
  20543. * @param {module:echarts/data/List} data
  20544. * @param {number} idx
  20545. */
  20546. symbolProto.updateData = function (data, idx, seriesScope) {
  20547. this.silent = false;
  20548. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  20549. var seriesModel = data.hostModel;
  20550. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  20551. if (symbolType !== this._symbolType) {
  20552. this._createSymbol(symbolType, data, idx);
  20553. }
  20554. else {
  20555. var symbolPath = this.childAt(0);
  20556. graphic.updateProps(symbolPath, {
  20557. scale: symbolSize
  20558. }, seriesModel, idx);
  20559. }
  20560. this._updateCommon(data, idx, symbolSize, seriesScope);
  20561. this._seriesModel = seriesModel;
  20562. };
  20563. // Update common properties
  20564. var normalStyleAccessPath = ['itemStyle', 'normal'];
  20565. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  20566. var normalLabelAccessPath = ['label', 'normal'];
  20567. var emphasisLabelAccessPath = ['label', 'emphasis'];
  20568. symbolProto._updateCommon = function (data, idx, symbolSize, seriesScope) {
  20569. var symbolPath = this.childAt(0);
  20570. var seriesModel = data.hostModel;
  20571. var color = data.getItemVisual(idx, 'color');
  20572. // Reset style
  20573. if (symbolPath.type !== 'image') {
  20574. symbolPath.useStyle({
  20575. strokeNoScale: true
  20576. });
  20577. }
  20578. seriesScope = seriesScope || null;
  20579. var itemStyle = seriesScope && seriesScope.itemStyle;
  20580. var hoverItemStyle = seriesScope && seriesScope.hoverItemStyle;
  20581. var symbolRotate = seriesScope && seriesScope.symbolRotate;
  20582. var symbolOffset = seriesScope && seriesScope.symbolOffset;
  20583. var labelModel = seriesScope && seriesScope.labelModel;
  20584. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  20585. var hoverAnimation = seriesScope && seriesScope.hoverAnimation;
  20586. if (!seriesScope || data.hasItemOption) {
  20587. var itemModel = data.getItemModel(idx);
  20588. // Color must be excluded.
  20589. // Because symbol provide setColor individually to set fill and stroke
  20590. itemStyle = itemModel.getModel(normalStyleAccessPath).getItemStyle(['color']);
  20591. hoverItemStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  20592. symbolRotate = itemModel.getShallow('symbolRotate');
  20593. symbolOffset = itemModel.getShallow('symbolOffset');
  20594. labelModel = itemModel.getModel(normalLabelAccessPath);
  20595. hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath);
  20596. hoverAnimation = itemModel.getShallow('hoverAnimation');
  20597. }
  20598. else {
  20599. hoverItemStyle = zrUtil.extend({}, hoverItemStyle);
  20600. }
  20601. var elStyle = symbolPath.style;
  20602. symbolPath.attr('rotation', (symbolRotate || 0) * Math.PI / 180 || 0);
  20603. if (symbolOffset) {
  20604. symbolPath.attr('position', [
  20605. numberUtil.parsePercent(symbolOffset[0], symbolSize[0]),
  20606. numberUtil.parsePercent(symbolOffset[1], symbolSize[1])
  20607. ]);
  20608. }
  20609. // PENDING setColor before setStyle!!!
  20610. symbolPath.setColor(color);
  20611. symbolPath.setStyle(itemStyle);
  20612. var opacity = data.getItemVisual(idx, 'opacity');
  20613. if (opacity != null) {
  20614. elStyle.opacity = opacity;
  20615. }
  20616. // Get last value dim
  20617. var dimensions = data.dimensions.slice();
  20618. var valueDim;
  20619. var dataType;
  20620. while (dimensions.length && (
  20621. valueDim = dimensions.pop(),
  20622. dataType = data.getDimensionInfo(valueDim).type,
  20623. dataType === 'ordinal' || dataType === 'time'
  20624. )) {} // jshint ignore:line
  20625. if (valueDim != null && labelModel.getShallow('show')) {
  20626. graphic.setText(elStyle, labelModel, color);
  20627. elStyle.text = zrUtil.retrieve(
  20628. seriesModel.getFormattedLabel(idx, 'normal'),
  20629. data.get(valueDim, idx)
  20630. );
  20631. }
  20632. else {
  20633. elStyle.text = '';
  20634. }
  20635. if (valueDim != null && hoverLabelModel.getShallow('show')) {
  20636. graphic.setText(hoverItemStyle, hoverLabelModel, color);
  20637. hoverItemStyle.text = zrUtil.retrieve(
  20638. seriesModel.getFormattedLabel(idx, 'emphasis'),
  20639. data.get(valueDim, idx)
  20640. );
  20641. }
  20642. else {
  20643. hoverItemStyle.text = '';
  20644. }
  20645. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  20646. symbolPath.off('mouseover')
  20647. .off('mouseout')
  20648. .off('emphasis')
  20649. .off('normal');
  20650. symbolPath.hoverStyle = hoverItemStyle;
  20651. graphic.setHoverStyle(symbolPath);
  20652. if (hoverAnimation && seriesModel.ifEnableAnimation()) {
  20653. var onEmphasis = function() {
  20654. var ratio = size[1] / size[0];
  20655. this.animateTo({
  20656. scale: [
  20657. Math.max(size[0] * 1.1, size[0] + 3),
  20658. Math.max(size[1] * 1.1, size[1] + 3 * ratio)
  20659. ]
  20660. }, 400, 'elasticOut');
  20661. };
  20662. var onNormal = function() {
  20663. this.animateTo({
  20664. scale: size
  20665. }, 400, 'elasticOut');
  20666. };
  20667. symbolPath.on('mouseover', onEmphasis)
  20668. .on('mouseout', onNormal)
  20669. .on('emphasis', onEmphasis)
  20670. .on('normal', onNormal);
  20671. }
  20672. };
  20673. symbolProto.fadeOut = function (cb) {
  20674. var symbolPath = this.childAt(0);
  20675. // Avoid mistaken hover when fading out
  20676. this.silent = true;
  20677. // Not show text when animating
  20678. symbolPath.style.text = '';
  20679. graphic.updateProps(symbolPath, {
  20680. scale: [0, 0]
  20681. }, this._seriesModel, this.dataIndex, cb);
  20682. };
  20683. zrUtil.inherits(Symbol, graphic.Group);
  20684. module.exports = Symbol;
  20685. /***/ },
  20686. /* 107 */
  20687. /***/ function(module, exports, __webpack_require__) {
  20688. 'use strict';
  20689. // Symbol factory
  20690. var graphic = __webpack_require__(43);
  20691. var BoundingRect = __webpack_require__(9);
  20692. /**
  20693. * Triangle shape
  20694. * @inner
  20695. */
  20696. var Triangle = graphic.extendShape({
  20697. type: 'triangle',
  20698. shape: {
  20699. cx: 0,
  20700. cy: 0,
  20701. width: 0,
  20702. height: 0
  20703. },
  20704. buildPath: function (path, shape) {
  20705. var cx = shape.cx;
  20706. var cy = shape.cy;
  20707. var width = shape.width / 2;
  20708. var height = shape.height / 2;
  20709. path.moveTo(cx, cy - height);
  20710. path.lineTo(cx + width, cy + height);
  20711. path.lineTo(cx - width, cy + height);
  20712. path.closePath();
  20713. }
  20714. });
  20715. /**
  20716. * Diamond shape
  20717. * @inner
  20718. */
  20719. var Diamond = graphic.extendShape({
  20720. type: 'diamond',
  20721. shape: {
  20722. cx: 0,
  20723. cy: 0,
  20724. width: 0,
  20725. height: 0
  20726. },
  20727. buildPath: function (path, shape) {
  20728. var cx = shape.cx;
  20729. var cy = shape.cy;
  20730. var width = shape.width / 2;
  20731. var height = shape.height / 2;
  20732. path.moveTo(cx, cy - height);
  20733. path.lineTo(cx + width, cy);
  20734. path.lineTo(cx, cy + height);
  20735. path.lineTo(cx - width, cy);
  20736. path.closePath();
  20737. }
  20738. });
  20739. /**
  20740. * Pin shape
  20741. * @inner
  20742. */
  20743. var Pin = graphic.extendShape({
  20744. type: 'pin',
  20745. shape: {
  20746. // x, y on the cusp
  20747. x: 0,
  20748. y: 0,
  20749. width: 0,
  20750. height: 0
  20751. },
  20752. buildPath: function (path, shape) {
  20753. var x = shape.x;
  20754. var y = shape.y;
  20755. var w = shape.width / 5 * 3;
  20756. // Height must be larger than width
  20757. var h = Math.max(w, shape.height);
  20758. var r = w / 2;
  20759. // Dist on y with tangent point and circle center
  20760. var dy = r * r / (h - r);
  20761. var cy = y - h + r + dy;
  20762. var angle = Math.asin(dy / r);
  20763. // Dist on x with tangent point and circle center
  20764. var dx = Math.cos(angle) * r;
  20765. var tanX = Math.sin(angle);
  20766. var tanY = Math.cos(angle);
  20767. path.arc(
  20768. x, cy, r,
  20769. Math.PI - angle,
  20770. Math.PI * 2 + angle
  20771. );
  20772. var cpLen = r * 0.6;
  20773. var cpLen2 = r * 0.7;
  20774. path.bezierCurveTo(
  20775. x + dx - tanX * cpLen, cy + dy + tanY * cpLen,
  20776. x, y - cpLen2,
  20777. x, y
  20778. );
  20779. path.bezierCurveTo(
  20780. x, y - cpLen2,
  20781. x - dx + tanX * cpLen, cy + dy + tanY * cpLen,
  20782. x - dx, cy + dy
  20783. );
  20784. path.closePath();
  20785. }
  20786. });
  20787. /**
  20788. * Arrow shape
  20789. * @inner
  20790. */
  20791. var Arrow = graphic.extendShape({
  20792. type: 'arrow',
  20793. shape: {
  20794. x: 0,
  20795. y: 0,
  20796. width: 0,
  20797. height: 0
  20798. },
  20799. buildPath: function (ctx, shape) {
  20800. var height = shape.height;
  20801. var width = shape.width;
  20802. var x = shape.x;
  20803. var y = shape.y;
  20804. var dx = width / 3 * 2;
  20805. ctx.moveTo(x, y);
  20806. ctx.lineTo(x + dx, y + height);
  20807. ctx.lineTo(x, y + height / 4 * 3);
  20808. ctx.lineTo(x - dx, y + height);
  20809. ctx.lineTo(x, y);
  20810. ctx.closePath();
  20811. }
  20812. });
  20813. /**
  20814. * Map of path contructors
  20815. * @type {Object.<string, module:zrender/graphic/Path>}
  20816. */
  20817. var symbolCtors = {
  20818. line: graphic.Line,
  20819. rect: graphic.Rect,
  20820. roundRect: graphic.Rect,
  20821. square: graphic.Rect,
  20822. circle: graphic.Circle,
  20823. diamond: Diamond,
  20824. pin: Pin,
  20825. arrow: Arrow,
  20826. triangle: Triangle
  20827. };
  20828. var symbolShapeMakers = {
  20829. line: function (x, y, w, h, shape) {
  20830. // FIXME
  20831. shape.x1 = x;
  20832. shape.y1 = y + h / 2;
  20833. shape.x2 = x + w;
  20834. shape.y2 = y + h / 2;
  20835. },
  20836. rect: function (x, y, w, h, shape) {
  20837. shape.x = x;
  20838. shape.y = y;
  20839. shape.width = w;
  20840. shape.height = h;
  20841. },
  20842. roundRect: function (x, y, w, h, shape) {
  20843. shape.x = x;
  20844. shape.y = y;
  20845. shape.width = w;
  20846. shape.height = h;
  20847. shape.r = Math.min(w, h) / 4;
  20848. },
  20849. square: function (x, y, w, h, shape) {
  20850. var size = Math.min(w, h);
  20851. shape.x = x;
  20852. shape.y = y;
  20853. shape.width = size;
  20854. shape.height = size;
  20855. },
  20856. circle: function (x, y, w, h, shape) {
  20857. // Put circle in the center of square
  20858. shape.cx = x + w / 2;
  20859. shape.cy = y + h / 2;
  20860. shape.r = Math.min(w, h) / 2;
  20861. },
  20862. diamond: function (x, y, w, h, shape) {
  20863. shape.cx = x + w / 2;
  20864. shape.cy = y + h / 2;
  20865. shape.width = w;
  20866. shape.height = h;
  20867. },
  20868. pin: function (x, y, w, h, shape) {
  20869. shape.x = x + w / 2;
  20870. shape.y = y + h / 2;
  20871. shape.width = w;
  20872. shape.height = h;
  20873. },
  20874. arrow: function (x, y, w, h, shape) {
  20875. shape.x = x + w / 2;
  20876. shape.y = y + h / 2;
  20877. shape.width = w;
  20878. shape.height = h;
  20879. },
  20880. triangle: function (x, y, w, h, shape) {
  20881. shape.cx = x + w / 2;
  20882. shape.cy = y + h / 2;
  20883. shape.width = w;
  20884. shape.height = h;
  20885. }
  20886. };
  20887. var symbolBuildProxies = {};
  20888. for (var name in symbolCtors) {
  20889. if (symbolCtors.hasOwnProperty(name)) {
  20890. symbolBuildProxies[name] = new symbolCtors[name]();
  20891. }
  20892. }
  20893. var Symbol = graphic.extendShape({
  20894. type: 'symbol',
  20895. shape: {
  20896. symbolType: '',
  20897. x: 0,
  20898. y: 0,
  20899. width: 0,
  20900. height: 0
  20901. },
  20902. beforeBrush: function () {
  20903. var style = this.style;
  20904. var shape = this.shape;
  20905. // FIXME
  20906. if (shape.symbolType === 'pin' && style.textPosition === 'inside') {
  20907. style.textPosition = ['50%', '40%'];
  20908. style.textAlign = 'center';
  20909. style.textVerticalAlign = 'middle';
  20910. }
  20911. },
  20912. buildPath: function (ctx, shape, inBundle) {
  20913. var symbolType = shape.symbolType;
  20914. var proxySymbol = symbolBuildProxies[symbolType];
  20915. if (shape.symbolType !== 'none') {
  20916. if (!proxySymbol) {
  20917. // Default rect
  20918. symbolType = 'rect';
  20919. proxySymbol = symbolBuildProxies[symbolType];
  20920. }
  20921. symbolShapeMakers[symbolType](
  20922. shape.x, shape.y, shape.width, shape.height, proxySymbol.shape
  20923. );
  20924. proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle);
  20925. }
  20926. }
  20927. });
  20928. // Provide setColor helper method to avoid determine if set the fill or stroke outside
  20929. var symbolPathSetColor = function (color) {
  20930. if (this.type !== 'image') {
  20931. var symbolStyle = this.style;
  20932. var symbolShape = this.shape;
  20933. if (symbolShape && symbolShape.symbolType === 'line') {
  20934. symbolStyle.stroke = color;
  20935. }
  20936. else if (this.__isEmptyBrush) {
  20937. symbolStyle.stroke = color;
  20938. symbolStyle.fill = '#fff';
  20939. }
  20940. else {
  20941. // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
  20942. symbolStyle.fill && (symbolStyle.fill = color);
  20943. symbolStyle.stroke && (symbolStyle.stroke = color);
  20944. }
  20945. this.dirty(false);
  20946. }
  20947. };
  20948. var symbolUtil = {
  20949. /**
  20950. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  20951. * @param {string} symbolType
  20952. * @param {number} x
  20953. * @param {number} y
  20954. * @param {number} w
  20955. * @param {number} h
  20956. * @param {string} color
  20957. */
  20958. createSymbol: function (symbolType, x, y, w, h, color) {
  20959. var isEmpty = symbolType.indexOf('empty') === 0;
  20960. if (isEmpty) {
  20961. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  20962. }
  20963. var symbolPath;
  20964. if (symbolType.indexOf('image://') === 0) {
  20965. symbolPath = new graphic.Image({
  20966. style: {
  20967. image: symbolType.slice(8),
  20968. x: x,
  20969. y: y,
  20970. width: w,
  20971. height: h
  20972. }
  20973. });
  20974. }
  20975. else if (symbolType.indexOf('path://') === 0) {
  20976. symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
  20977. }
  20978. else {
  20979. symbolPath = new Symbol({
  20980. shape: {
  20981. symbolType: symbolType,
  20982. x: x,
  20983. y: y,
  20984. width: w,
  20985. height: h
  20986. }
  20987. });
  20988. }
  20989. symbolPath.__isEmptyBrush = isEmpty;
  20990. symbolPath.setColor = symbolPathSetColor;
  20991. symbolPath.setColor(color);
  20992. return symbolPath;
  20993. }
  20994. };
  20995. module.exports = symbolUtil;
  20996. /***/ },
  20997. /* 108 */
  20998. /***/ function(module, exports) {
  20999. // var arrayDiff = require('zrender/lib/core/arrayDiff');
  21000. // 'zrender/core/arrayDiff' has been used before, but it did
  21001. // not do well in performance when roam with fixed dataZoom window.
  21002. function sign(val) {
  21003. return val >= 0 ? 1 : -1;
  21004. }
  21005. function getStackedOnPoint(coordSys, data, idx) {
  21006. var baseAxis = coordSys.getBaseAxis();
  21007. var valueAxis = coordSys.getOtherAxis(baseAxis);
  21008. var valueStart = baseAxis.onZero
  21009. ? 0 : valueAxis.scale.getExtent()[0];
  21010. var valueDim = valueAxis.dim;
  21011. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  21012. var stackedOnSameSign;
  21013. var stackedOn = data.stackedOn;
  21014. var val = data.get(valueDim, idx);
  21015. // Find first stacked value with same sign
  21016. while (stackedOn &&
  21017. sign(stackedOn.get(valueDim, idx)) === sign(val)
  21018. ) {
  21019. stackedOnSameSign = stackedOn;
  21020. break;
  21021. }
  21022. var stackedData = [];
  21023. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  21024. stackedData[1 - baseDataOffset] = stackedOnSameSign
  21025. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  21026. return coordSys.dataToPoint(stackedData);
  21027. }
  21028. // function convertToIntId(newIdList, oldIdList) {
  21029. // // Generate int id instead of string id.
  21030. // // Compare string maybe slow in score function of arrDiff
  21031. // // Assume id in idList are all unique
  21032. // var idIndicesMap = {};
  21033. // var idx = 0;
  21034. // for (var i = 0; i < newIdList.length; i++) {
  21035. // idIndicesMap[newIdList[i]] = idx;
  21036. // newIdList[i] = idx++;
  21037. // }
  21038. // for (var i = 0; i < oldIdList.length; i++) {
  21039. // var oldId = oldIdList[i];
  21040. // // Same with newIdList
  21041. // if (idIndicesMap[oldId]) {
  21042. // oldIdList[i] = idIndicesMap[oldId];
  21043. // }
  21044. // else {
  21045. // oldIdList[i] = idx++;
  21046. // }
  21047. // }
  21048. // }
  21049. function diffData(oldData, newData) {
  21050. var diffResult = [];
  21051. newData.diff(oldData)
  21052. .add(function (idx) {
  21053. diffResult.push({cmd: '+', idx: idx});
  21054. })
  21055. .update(function (newIdx, oldIdx) {
  21056. diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx});
  21057. })
  21058. .remove(function (idx) {
  21059. diffResult.push({cmd: '-', idx: idx});
  21060. })
  21061. .execute();
  21062. return diffResult;
  21063. }
  21064. module.exports = function (
  21065. oldData, newData,
  21066. oldStackedOnPoints, newStackedOnPoints,
  21067. oldCoordSys, newCoordSys
  21068. ) {
  21069. var diff = diffData(oldData, newData);
  21070. // var newIdList = newData.mapArray(newData.getId);
  21071. // var oldIdList = oldData.mapArray(oldData.getId);
  21072. // convertToIntId(newIdList, oldIdList);
  21073. // // FIXME One data ?
  21074. // diff = arrayDiff(oldIdList, newIdList);
  21075. var currPoints = [];
  21076. var nextPoints = [];
  21077. // Points for stacking base line
  21078. var currStackedPoints = [];
  21079. var nextStackedPoints = [];
  21080. var status = [];
  21081. var sortedIndices = [];
  21082. var rawIndices = [];
  21083. var dims = newCoordSys.dimensions;
  21084. for (var i = 0; i < diff.length; i++) {
  21085. var diffItem = diff[i];
  21086. var pointAdded = true;
  21087. // FIXME, animation is not so perfect when dataZoom window moves fast
  21088. // Which is in case remvoing or add more than one data in the tail or head
  21089. switch (diffItem.cmd) {
  21090. case '=':
  21091. var currentPt = oldData.getItemLayout(diffItem.idx);
  21092. var nextPt = newData.getItemLayout(diffItem.idx1);
  21093. // If previous data is NaN, use next point directly
  21094. if (isNaN(currentPt[0]) || isNaN(currentPt[1])) {
  21095. currentPt = nextPt.slice();
  21096. }
  21097. currPoints.push(currentPt);
  21098. nextPoints.push(nextPt);
  21099. currStackedPoints.push(oldStackedOnPoints[diffItem.idx]);
  21100. nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]);
  21101. rawIndices.push(newData.getRawIndex(diffItem.idx1));
  21102. break;
  21103. case '+':
  21104. var idx = diffItem.idx;
  21105. currPoints.push(
  21106. oldCoordSys.dataToPoint([
  21107. newData.get(dims[0], idx, true), newData.get(dims[1], idx, true)
  21108. ])
  21109. );
  21110. nextPoints.push(newData.getItemLayout(idx).slice());
  21111. currStackedPoints.push(
  21112. getStackedOnPoint(oldCoordSys, newData, idx)
  21113. );
  21114. nextStackedPoints.push(newStackedOnPoints[idx]);
  21115. rawIndices.push(newData.getRawIndex(idx));
  21116. break;
  21117. case '-':
  21118. var idx = diffItem.idx;
  21119. var rawIndex = oldData.getRawIndex(idx);
  21120. // Data is replaced. In the case of dynamic data queue
  21121. // FIXME FIXME FIXME
  21122. if (rawIndex !== idx) {
  21123. currPoints.push(oldData.getItemLayout(idx));
  21124. nextPoints.push(newCoordSys.dataToPoint([
  21125. oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true)
  21126. ]));
  21127. currStackedPoints.push(oldStackedOnPoints[idx]);
  21128. nextStackedPoints.push(
  21129. getStackedOnPoint(
  21130. newCoordSys, oldData, idx
  21131. )
  21132. );
  21133. rawIndices.push(rawIndex);
  21134. }
  21135. else {
  21136. pointAdded = false;
  21137. }
  21138. }
  21139. // Original indices
  21140. if (pointAdded) {
  21141. status.push(diffItem);
  21142. sortedIndices.push(sortedIndices.length);
  21143. }
  21144. }
  21145. // Diff result may be crossed if all items are changed
  21146. // Sort by data index
  21147. sortedIndices.sort(function (a, b) {
  21148. return rawIndices[a] - rawIndices[b];
  21149. });
  21150. var sortedCurrPoints = [];
  21151. var sortedNextPoints = [];
  21152. var sortedCurrStackedPoints = [];
  21153. var sortedNextStackedPoints = [];
  21154. var sortedStatus = [];
  21155. for (var i = 0; i < sortedIndices.length; i++) {
  21156. var idx = sortedIndices[i];
  21157. sortedCurrPoints[i] = currPoints[idx];
  21158. sortedNextPoints[i] = nextPoints[idx];
  21159. sortedCurrStackedPoints[i] = currStackedPoints[idx];
  21160. sortedNextStackedPoints[i] = nextStackedPoints[idx];
  21161. sortedStatus[i] = status[idx];
  21162. }
  21163. return {
  21164. current: sortedCurrPoints,
  21165. next: sortedNextPoints,
  21166. stackedOnCurrent: sortedCurrStackedPoints,
  21167. stackedOnNext: sortedNextStackedPoints,
  21168. status: sortedStatus
  21169. };
  21170. };
  21171. /***/ },
  21172. /* 109 */
  21173. /***/ function(module, exports, __webpack_require__) {
  21174. // Poly path support NaN point
  21175. var Path = __webpack_require__(45);
  21176. var vec2 = __webpack_require__(10);
  21177. var vec2Min = vec2.min;
  21178. var vec2Max = vec2.max;
  21179. var scaleAndAdd = vec2.scaleAndAdd;
  21180. var v2Copy = vec2.copy;
  21181. // Temporary variable
  21182. var v = [];
  21183. var cp0 = [];
  21184. var cp1 = [];
  21185. function isPointNull(p) {
  21186. return isNaN(p[0]) || isNaN(p[1]);
  21187. }
  21188. function drawSegment(
  21189. ctx, points, start, segLen, allLen,
  21190. dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
  21191. ) {
  21192. var prevIdx = 0;
  21193. var idx = start;
  21194. for (var k = 0; k < segLen; k++) {
  21195. var p = points[idx];
  21196. if (idx >= allLen || idx < 0) {
  21197. break;
  21198. }
  21199. if (isPointNull(p)) {
  21200. if (connectNulls) {
  21201. idx += dir;
  21202. continue;
  21203. }
  21204. break;
  21205. }
  21206. if (idx === start) {
  21207. ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
  21208. v2Copy(cp0, p);
  21209. }
  21210. else {
  21211. if (smooth > 0) {
  21212. var nextIdx = idx + dir;
  21213. var nextP = points[nextIdx];
  21214. if (connectNulls) {
  21215. // Find next point not null
  21216. while (nextP && isPointNull(points[nextIdx])) {
  21217. nextIdx += dir;
  21218. nextP = points[nextIdx];
  21219. }
  21220. }
  21221. var ratioNextSeg = 0.5;
  21222. var prevP = points[prevIdx];
  21223. var nextP = points[nextIdx];
  21224. // Last point
  21225. if (!nextP || isPointNull(nextP)) {
  21226. v2Copy(cp1, p);
  21227. }
  21228. else {
  21229. // If next data is null in not connect case
  21230. if (isPointNull(nextP) && !connectNulls) {
  21231. nextP = p;
  21232. }
  21233. vec2.sub(v, nextP, prevP);
  21234. var lenPrevSeg;
  21235. var lenNextSeg;
  21236. if (smoothMonotone === 'x' || smoothMonotone === 'y') {
  21237. var dim = smoothMonotone === 'x' ? 0 : 1;
  21238. lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
  21239. lenNextSeg = Math.abs(p[dim] - nextP[dim]);
  21240. }
  21241. else {
  21242. lenPrevSeg = vec2.dist(p, prevP);
  21243. lenNextSeg = vec2.dist(p, nextP);
  21244. }
  21245. // Use ratio of seg length
  21246. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
  21247. scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg));
  21248. }
  21249. // Smooth constraint
  21250. vec2Min(cp0, cp0, smoothMax);
  21251. vec2Max(cp0, cp0, smoothMin);
  21252. vec2Min(cp1, cp1, smoothMax);
  21253. vec2Max(cp1, cp1, smoothMin);
  21254. ctx.bezierCurveTo(
  21255. cp0[0], cp0[1],
  21256. cp1[0], cp1[1],
  21257. p[0], p[1]
  21258. );
  21259. // cp0 of next segment
  21260. scaleAndAdd(cp0, p, v, smooth * ratioNextSeg);
  21261. }
  21262. else {
  21263. ctx.lineTo(p[0], p[1]);
  21264. }
  21265. }
  21266. prevIdx = idx;
  21267. idx += dir;
  21268. }
  21269. return k;
  21270. }
  21271. function getBoundingBox(points, smoothConstraint) {
  21272. var ptMin = [Infinity, Infinity];
  21273. var ptMax = [-Infinity, -Infinity];
  21274. if (smoothConstraint) {
  21275. for (var i = 0; i < points.length; i++) {
  21276. var pt = points[i];
  21277. if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; }
  21278. if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; }
  21279. if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; }
  21280. if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; }
  21281. }
  21282. }
  21283. return {
  21284. min: smoothConstraint ? ptMin : ptMax,
  21285. max: smoothConstraint ? ptMax : ptMin
  21286. };
  21287. }
  21288. module.exports = {
  21289. Polyline: Path.extend({
  21290. type: 'ec-polyline',
  21291. shape: {
  21292. points: [],
  21293. smooth: 0,
  21294. smoothConstraint: true,
  21295. smoothMonotone: null,
  21296. connectNulls: false
  21297. },
  21298. style: {
  21299. fill: null,
  21300. stroke: '#000'
  21301. },
  21302. buildPath: function (ctx, shape) {
  21303. var points = shape.points;
  21304. var i = 0;
  21305. var len = points.length;
  21306. var result = getBoundingBox(points, shape.smoothConstraint);
  21307. if (shape.connectNulls) {
  21308. // Must remove first and last null values avoid draw error in polygon
  21309. for (; len > 0; len--) {
  21310. if (!isPointNull(points[len - 1])) {
  21311. break;
  21312. }
  21313. }
  21314. for (; i < len; i++) {
  21315. if (!isPointNull(points[i])) {
  21316. break;
  21317. }
  21318. }
  21319. }
  21320. while (i < len) {
  21321. i += drawSegment(
  21322. ctx, points, i, len, len,
  21323. 1, result.min, result.max, shape.smooth,
  21324. shape.smoothMonotone, shape.connectNulls
  21325. ) + 1;
  21326. }
  21327. }
  21328. }),
  21329. Polygon: Path.extend({
  21330. type: 'ec-polygon',
  21331. shape: {
  21332. points: [],
  21333. // Offset between stacked base points and points
  21334. stackedOnPoints: [],
  21335. smooth: 0,
  21336. stackedOnSmooth: 0,
  21337. smoothConstraint: true,
  21338. smoothMonotone: null,
  21339. connectNulls: false
  21340. },
  21341. buildPath: function (ctx, shape) {
  21342. var points = shape.points;
  21343. var stackedOnPoints = shape.stackedOnPoints;
  21344. var i = 0;
  21345. var len = points.length;
  21346. var smoothMonotone = shape.smoothMonotone;
  21347. var bbox = getBoundingBox(points, shape.smoothConstraint);
  21348. var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint);
  21349. if (shape.connectNulls) {
  21350. // Must remove first and last null values avoid draw error in polygon
  21351. for (; len > 0; len--) {
  21352. if (!isPointNull(points[len - 1])) {
  21353. break;
  21354. }
  21355. }
  21356. for (; i < len; i++) {
  21357. if (!isPointNull(points[i])) {
  21358. break;
  21359. }
  21360. }
  21361. }
  21362. while (i < len) {
  21363. var k = drawSegment(
  21364. ctx, points, i, len, len,
  21365. 1, bbox.min, bbox.max, shape.smooth,
  21366. smoothMonotone, shape.connectNulls
  21367. );
  21368. drawSegment(
  21369. ctx, stackedOnPoints, i + k - 1, k, len,
  21370. -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth,
  21371. smoothMonotone, shape.connectNulls
  21372. );
  21373. i += k + 1;
  21374. ctx.closePath();
  21375. }
  21376. }
  21377. })
  21378. };
  21379. /***/ },
  21380. /* 110 */
  21381. /***/ function(module, exports) {
  21382. module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) {
  21383. // Encoding visual for all series include which is filtered for legend drawing
  21384. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  21385. var data = seriesModel.getData();
  21386. var symbolType = seriesModel.get('symbol') || defaultSymbolType;
  21387. var symbolSize = seriesModel.get('symbolSize');
  21388. data.setVisual({
  21389. legendSymbol: legendSymbol || symbolType,
  21390. symbol: symbolType,
  21391. symbolSize: symbolSize
  21392. });
  21393. // Only visible series has each data be visual encoded
  21394. if (!ecModel.isSeriesFiltered(seriesModel)) {
  21395. if (typeof symbolSize === 'function') {
  21396. data.each(function (idx) {
  21397. var rawValue = seriesModel.getRawValue(idx);
  21398. // FIXME
  21399. var params = seriesModel.getDataParams(idx);
  21400. data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
  21401. });
  21402. }
  21403. data.each(function (idx) {
  21404. var itemModel = data.getItemModel(idx);
  21405. var itemSymbolType = itemModel.getShallow('symbol', true);
  21406. var itemSymbolSize = itemModel.getShallow('symbolSize', true);
  21407. // If has item symbol
  21408. if (itemSymbolType != null) {
  21409. data.setItemVisual(idx, 'symbol', itemSymbolType);
  21410. }
  21411. if (itemSymbolSize != null) {
  21412. // PENDING Transform symbolSize ?
  21413. data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
  21414. }
  21415. });
  21416. }
  21417. });
  21418. };
  21419. /***/ },
  21420. /* 111 */
  21421. /***/ function(module, exports) {
  21422. module.exports = function (seriesType, ecModel) {
  21423. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  21424. var data = seriesModel.getData();
  21425. var coordSys = seriesModel.coordinateSystem;
  21426. if (coordSys) {
  21427. var dims = coordSys.dimensions;
  21428. if (coordSys.type === 'singleAxis') {
  21429. data.each(dims[0], function (x, idx) {
  21430. // Also {Array.<number>}, not undefined to avoid if...else... statement
  21431. data.setItemLayout(idx, isNaN(x) ? [NaN, NaN] : coordSys.dataToPoint(x));
  21432. });
  21433. }
  21434. else {
  21435. data.each(dims, function (x, y, idx) {
  21436. // Also {Array.<number>}, not undefined to avoid if...else... statement
  21437. data.setItemLayout(
  21438. idx, (isNaN(x) || isNaN(y)) ? [NaN, NaN] : coordSys.dataToPoint([x, y])
  21439. );
  21440. }, true);
  21441. }
  21442. }
  21443. });
  21444. };
  21445. /***/ },
  21446. /* 112 */
  21447. /***/ function(module, exports) {
  21448. var samplers = {
  21449. average: function (frame) {
  21450. var sum = 0;
  21451. var count = 0;
  21452. for (var i = 0; i < frame.length; i++) {
  21453. if (!isNaN(frame[i])) {
  21454. sum += frame[i];
  21455. count++;
  21456. }
  21457. }
  21458. // Return NaN if count is 0
  21459. return count === 0 ? NaN : sum / count;
  21460. },
  21461. sum: function (frame) {
  21462. var sum = 0;
  21463. for (var i = 0; i < frame.length; i++) {
  21464. // Ignore NaN
  21465. sum += frame[i] || 0;
  21466. }
  21467. return sum;
  21468. },
  21469. max: function (frame) {
  21470. var max = -Infinity;
  21471. for (var i = 0; i < frame.length; i++) {
  21472. frame[i] > max && (max = frame[i]);
  21473. }
  21474. return max;
  21475. },
  21476. min: function (frame) {
  21477. var min = Infinity;
  21478. for (var i = 0; i < frame.length; i++) {
  21479. frame[i] < min && (min = frame[i]);
  21480. }
  21481. return min;
  21482. },
  21483. // TODO
  21484. // Median
  21485. nearest: function (frame) {
  21486. return frame[0];
  21487. }
  21488. };
  21489. var indexSampler = function (frame, value) {
  21490. return Math.round(frame.length / 2);
  21491. };
  21492. module.exports = function (seriesType, ecModel, api) {
  21493. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  21494. var data = seriesModel.getData();
  21495. var sampling = seriesModel.get('sampling');
  21496. var coordSys = seriesModel.coordinateSystem;
  21497. // Only cartesian2d support down sampling
  21498. if (coordSys.type === 'cartesian2d' && sampling) {
  21499. var baseAxis = coordSys.getBaseAxis();
  21500. var valueAxis = coordSys.getOtherAxis(baseAxis);
  21501. var extent = baseAxis.getExtent();
  21502. // Coordinste system has been resized
  21503. var size = extent[1] - extent[0];
  21504. var rate = Math.round(data.count() / size);
  21505. if (rate > 1) {
  21506. var sampler;
  21507. if (typeof sampling === 'string') {
  21508. sampler = samplers[sampling];
  21509. }
  21510. else if (typeof sampling === 'function') {
  21511. sampler = sampling;
  21512. }
  21513. if (sampler) {
  21514. data = data.downSample(
  21515. valueAxis.dim, 1 / rate, sampler, indexSampler
  21516. );
  21517. seriesModel.setData(data);
  21518. }
  21519. }
  21520. }
  21521. }, this);
  21522. };
  21523. /***/ },
  21524. /* 113 */
  21525. /***/ function(module, exports, __webpack_require__) {
  21526. 'use strict';
  21527. var graphic = __webpack_require__(43);
  21528. var zrUtil = __webpack_require__(4);
  21529. var echarts = __webpack_require__(1);
  21530. __webpack_require__(114);
  21531. __webpack_require__(132);
  21532. // Grid view
  21533. echarts.extendComponentView({
  21534. type: 'grid',
  21535. render: function (gridModel, ecModel) {
  21536. this.group.removeAll();
  21537. if (gridModel.get('show')) {
  21538. this.group.add(new graphic.Rect({
  21539. shape: gridModel.coordinateSystem.getRect(),
  21540. style: zrUtil.defaults({
  21541. fill: gridModel.get('backgroundColor')
  21542. }, gridModel.getItemStyle()),
  21543. silent: true,
  21544. z2: -1
  21545. }));
  21546. }
  21547. }
  21548. });
  21549. echarts.registerPreprocessor(function (option) {
  21550. // Only create grid when need
  21551. if (option.xAxis && option.yAxis && !option.grid) {
  21552. option.grid = {};
  21553. }
  21554. });
  21555. /***/ },
  21556. /* 114 */
  21557. /***/ function(module, exports, __webpack_require__) {
  21558. /**
  21559. * Grid is a region which contains at most 4 cartesian systems
  21560. *
  21561. * TODO Default cartesian
  21562. */
  21563. var factory = exports;
  21564. var layout = __webpack_require__(21);
  21565. var axisHelper = __webpack_require__(115);
  21566. var zrUtil = __webpack_require__(4);
  21567. var Cartesian2D = __webpack_require__(121);
  21568. var Axis2D = __webpack_require__(123);
  21569. var each = zrUtil.each;
  21570. var ifAxisCrossZero = axisHelper.ifAxisCrossZero;
  21571. var niceScaleExtent = axisHelper.niceScaleExtent;
  21572. // 依赖 GridModel, AxisModel 做预处理
  21573. __webpack_require__(126);
  21574. /**
  21575. * Check if the axis is used in the specified grid
  21576. * @inner
  21577. */
  21578. function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) {
  21579. return axisModel.findGridModel() === gridModel;
  21580. }
  21581. function getLabelUnionRect(axis) {
  21582. var axisModel = axis.model;
  21583. var labels = axisModel.getFormattedLabels();
  21584. var textStyleModel = axisModel.getModel('axisLabel.textStyle');
  21585. var rect;
  21586. var step = 1;
  21587. var labelCount = labels.length;
  21588. if (labelCount > 40) {
  21589. // Simple optimization for large amount of labels
  21590. step = Math.ceil(labelCount / 40);
  21591. }
  21592. for (var i = 0; i < labelCount; i += step) {
  21593. if (!axis.isLabelIgnored(i)) {
  21594. var singleRect = textStyleModel.getTextRect(labels[i]);
  21595. // FIXME consider label rotate
  21596. rect ? rect.union(singleRect) : (rect = singleRect);
  21597. }
  21598. }
  21599. return rect;
  21600. }
  21601. function Grid(gridModel, ecModel, api) {
  21602. /**
  21603. * @type {Object.<string, module:echarts/coord/cartesian/Cartesian2D>}
  21604. * @private
  21605. */
  21606. this._coordsMap = {};
  21607. /**
  21608. * @type {Array.<module:echarts/coord/cartesian/Cartesian>}
  21609. * @private
  21610. */
  21611. this._coordsList = [];
  21612. /**
  21613. * @type {Object.<string, module:echarts/coord/cartesian/Axis2D>}
  21614. * @private
  21615. */
  21616. this._axesMap = {};
  21617. /**
  21618. * @type {Array.<module:echarts/coord/cartesian/Axis2D>}
  21619. * @private
  21620. */
  21621. this._axesList = [];
  21622. this._initCartesian(gridModel, ecModel, api);
  21623. this._model = gridModel;
  21624. }
  21625. var gridProto = Grid.prototype;
  21626. gridProto.type = 'grid';
  21627. gridProto.getRect = function () {
  21628. return this._rect;
  21629. };
  21630. gridProto.update = function (ecModel, api) {
  21631. var axesMap = this._axesMap;
  21632. this._updateScale(ecModel, this._model);
  21633. function ifAxisCanNotOnZero(otherAxisDim) {
  21634. var axes = axesMap[otherAxisDim];
  21635. for (var idx in axes) {
  21636. if (axes.hasOwnProperty(idx)) {
  21637. var axis = axes[idx];
  21638. if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) {
  21639. return true;
  21640. }
  21641. }
  21642. }
  21643. return false;
  21644. }
  21645. each(axesMap.x, function (xAxis) {
  21646. niceScaleExtent(xAxis, xAxis.model);
  21647. });
  21648. each(axesMap.y, function (yAxis) {
  21649. niceScaleExtent(yAxis, yAxis.model);
  21650. });
  21651. // Fix configuration
  21652. each(axesMap.x, function (xAxis) {
  21653. // onZero can not be enabled in these two situations
  21654. // 1. When any other axis is a category axis
  21655. // 2. When any other axis not across 0 point
  21656. if (ifAxisCanNotOnZero('y')) {
  21657. xAxis.onZero = false;
  21658. }
  21659. });
  21660. each(axesMap.y, function (yAxis) {
  21661. if (ifAxisCanNotOnZero('x')) {
  21662. yAxis.onZero = false;
  21663. }
  21664. });
  21665. // Resize again if containLabel is enabled
  21666. // FIXME It may cause getting wrong grid size in data processing stage
  21667. this.resize(this._model, api);
  21668. };
  21669. /**
  21670. * Resize the grid
  21671. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  21672. * @param {module:echarts/ExtensionAPI} api
  21673. */
  21674. gridProto.resize = function (gridModel, api) {
  21675. var gridRect = layout.getLayoutRect(
  21676. gridModel.getBoxLayoutParams(), {
  21677. width: api.getWidth(),
  21678. height: api.getHeight()
  21679. });
  21680. this._rect = gridRect;
  21681. var axesList = this._axesList;
  21682. adjustAxes();
  21683. // Minus label size
  21684. if (gridModel.get('containLabel')) {
  21685. each(axesList, function (axis) {
  21686. if (!axis.model.get('axisLabel.inside')) {
  21687. var labelUnionRect = getLabelUnionRect(axis);
  21688. if (labelUnionRect) {
  21689. var dim = axis.isHorizontal() ? 'height' : 'width';
  21690. var margin = axis.model.get('axisLabel.margin');
  21691. gridRect[dim] -= labelUnionRect[dim] + margin;
  21692. if (axis.position === 'top') {
  21693. gridRect.y += labelUnionRect.height + margin;
  21694. }
  21695. else if (axis.position === 'left') {
  21696. gridRect.x += labelUnionRect.width + margin;
  21697. }
  21698. }
  21699. }
  21700. });
  21701. adjustAxes();
  21702. }
  21703. function adjustAxes() {
  21704. each(axesList, function (axis) {
  21705. var isHorizontal = axis.isHorizontal();
  21706. var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
  21707. var idx = axis.inverse ? 1 : 0;
  21708. axis.setExtent(extent[idx], extent[1 - idx]);
  21709. updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y);
  21710. });
  21711. }
  21712. };
  21713. /**
  21714. * @param {string} axisType
  21715. * @param {ndumber} [axisIndex]
  21716. */
  21717. gridProto.getAxis = function (axisType, axisIndex) {
  21718. var axesMapOnDim = this._axesMap[axisType];
  21719. if (axesMapOnDim != null) {
  21720. if (axisIndex == null) {
  21721. // Find first axis
  21722. for (var name in axesMapOnDim) {
  21723. if (axesMapOnDim.hasOwnProperty(name)) {
  21724. return axesMapOnDim[name];
  21725. }
  21726. }
  21727. }
  21728. return axesMapOnDim[axisIndex];
  21729. }
  21730. };
  21731. gridProto.getCartesian = function (xAxisIndex, yAxisIndex) {
  21732. if (xAxisIndex != null && yAxisIndex != null) {
  21733. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  21734. return this._coordsMap[key];
  21735. }
  21736. else {
  21737. // When only xAxisIndex or yAxisIndex given, find its first cartesian.
  21738. for (var i = 0, coordList = this._coordsList; i < coordList.length; i++) {
  21739. if (coordList[i].getAxis('x').index === xAxisIndex
  21740. || coordList[i].getAxis('y').index === yAxisIndex
  21741. ) {
  21742. return coordList[i];
  21743. }
  21744. }
  21745. }
  21746. };
  21747. /**
  21748. * @implements
  21749. * see {module:echarts/CoodinateSystem}
  21750. */
  21751. gridProto.convertToPixel = function (ecModel, finder, value) {
  21752. var target = this._findConvertTarget(ecModel, finder);
  21753. return target.cartesian
  21754. ? target.cartesian.dataToPoint(value)
  21755. : target.axis
  21756. ? target.axis.toGlobalCoord(target.axis.dataToCoord(value))
  21757. : null;
  21758. };
  21759. /**
  21760. * @implements
  21761. * see {module:echarts/CoodinateSystem}
  21762. */
  21763. gridProto.convertFromPixel = function (ecModel, finder, value) {
  21764. var target = this._findConvertTarget(ecModel, finder);
  21765. return target.cartesian
  21766. ? target.cartesian.pointToData(value)
  21767. : target.axis
  21768. ? target.axis.coordToData(target.axis.toLocalCoord(value))
  21769. : null;
  21770. };
  21771. /**
  21772. * @inner
  21773. */
  21774. gridProto._findConvertTarget = function (ecModel, finder) {
  21775. var seriesModel = finder.seriesModel;
  21776. var xAxisModel = finder.xAxisModel
  21777. || (seriesModel && seriesModel.getReferringComponents('xAxis')[0]);
  21778. var yAxisModel = finder.yAxisModel
  21779. || (seriesModel && seriesModel.getReferringComponents('yAxis')[0]);
  21780. var gridModel = finder.gridModel;
  21781. var coordsList = this._coordsList;
  21782. var cartesian;
  21783. var axis;
  21784. if (seriesModel) {
  21785. cartesian = seriesModel.coordinateSystem;
  21786. zrUtil.indexOf(coordsList, cartesian) < 0 && (cartesian = null);
  21787. }
  21788. else if (xAxisModel && yAxisModel) {
  21789. cartesian = this.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
  21790. }
  21791. else if (xAxisModel) {
  21792. axis = this.getAxis('x', xAxisModel.componentIndex);
  21793. }
  21794. else if (yAxisModel) {
  21795. axis = this.getAxis('y', yAxisModel.componentIndex);
  21796. }
  21797. // Lowest priority.
  21798. else if (gridModel) {
  21799. var grid = gridModel.coordinateSystem;
  21800. if (grid === this) {
  21801. cartesian = this._coordsList[0];
  21802. }
  21803. }
  21804. return {cartesian: cartesian, axis: axis};
  21805. };
  21806. /**
  21807. * @implements
  21808. * see {module:echarts/CoodinateSystem}
  21809. */
  21810. gridProto.containPoint = function (point) {
  21811. var coord = this._coordsList[0];
  21812. if (coord) {
  21813. return coord.containPoint(point);
  21814. }
  21815. };
  21816. /**
  21817. * Initialize cartesian coordinate systems
  21818. * @private
  21819. */
  21820. gridProto._initCartesian = function (gridModel, ecModel, api) {
  21821. var axisPositionUsed = {
  21822. left: false,
  21823. right: false,
  21824. top: false,
  21825. bottom: false
  21826. };
  21827. var axesMap = {
  21828. x: {},
  21829. y: {}
  21830. };
  21831. var axesCount = {
  21832. x: 0,
  21833. y: 0
  21834. };
  21835. /// Create axis
  21836. ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
  21837. ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
  21838. if (!axesCount.x || !axesCount.y) {
  21839. // Roll back when there no either x or y axis
  21840. this._axesMap = {};
  21841. this._axesList = [];
  21842. return;
  21843. }
  21844. this._axesMap = axesMap;
  21845. /// Create cartesian2d
  21846. each(axesMap.x, function (xAxis, xAxisIndex) {
  21847. each(axesMap.y, function (yAxis, yAxisIndex) {
  21848. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  21849. var cartesian = new Cartesian2D(key);
  21850. cartesian.grid = this;
  21851. this._coordsMap[key] = cartesian;
  21852. this._coordsList.push(cartesian);
  21853. cartesian.addAxis(xAxis);
  21854. cartesian.addAxis(yAxis);
  21855. }, this);
  21856. }, this);
  21857. function createAxisCreator(axisType) {
  21858. return function (axisModel, idx) {
  21859. if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) {
  21860. return;
  21861. }
  21862. var axisPosition = axisModel.get('position');
  21863. if (axisType === 'x') {
  21864. // Fix position
  21865. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  21866. // Default bottom of X
  21867. axisPosition = 'bottom';
  21868. if (axisPositionUsed[axisPosition]) {
  21869. axisPosition = axisPosition === 'top' ? 'bottom' : 'top';
  21870. }
  21871. }
  21872. }
  21873. else {
  21874. // Fix position
  21875. if (axisPosition !== 'left' && axisPosition !== 'right') {
  21876. // Default left of Y
  21877. axisPosition = 'left';
  21878. if (axisPositionUsed[axisPosition]) {
  21879. axisPosition = axisPosition === 'left' ? 'right' : 'left';
  21880. }
  21881. }
  21882. }
  21883. axisPositionUsed[axisPosition] = true;
  21884. var axis = new Axis2D(
  21885. axisType, axisHelper.createScaleByModel(axisModel),
  21886. [0, 0],
  21887. axisModel.get('type'),
  21888. axisPosition
  21889. );
  21890. var isCategory = axis.type === 'category';
  21891. axis.onBand = isCategory && axisModel.get('boundaryGap');
  21892. axis.inverse = axisModel.get('inverse');
  21893. axis.onZero = axisModel.get('axisLine.onZero');
  21894. // Inject axis into axisModel
  21895. axisModel.axis = axis;
  21896. // Inject axisModel into axis
  21897. axis.model = axisModel;
  21898. // Inject grid info axis
  21899. axis.grid = this;
  21900. // Index of axis, can be used as key
  21901. axis.index = idx;
  21902. this._axesList.push(axis);
  21903. axesMap[axisType][idx] = axis;
  21904. axesCount[axisType]++;
  21905. };
  21906. }
  21907. };
  21908. /**
  21909. * Update cartesian properties from series
  21910. * @param {module:echarts/model/Option} option
  21911. * @private
  21912. */
  21913. gridProto._updateScale = function (ecModel, gridModel) {
  21914. // Reset scale
  21915. zrUtil.each(this._axesList, function (axis) {
  21916. axis.scale.setExtent(Infinity, -Infinity);
  21917. });
  21918. ecModel.eachSeries(function (seriesModel) {
  21919. if (isCartesian2D(seriesModel)) {
  21920. var axesModels = findAxesModels(seriesModel, ecModel);
  21921. var xAxisModel = axesModels[0];
  21922. var yAxisModel = axesModels[1];
  21923. if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel)
  21924. || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel)
  21925. ) {
  21926. return;
  21927. }
  21928. var cartesian = this.getCartesian(
  21929. xAxisModel.componentIndex, yAxisModel.componentIndex
  21930. );
  21931. var data = seriesModel.getData();
  21932. var xAxis = cartesian.getAxis('x');
  21933. var yAxis = cartesian.getAxis('y');
  21934. if (data.type === 'list') {
  21935. unionExtent(data, xAxis, seriesModel);
  21936. unionExtent(data, yAxis, seriesModel);
  21937. }
  21938. }
  21939. }, this);
  21940. function unionExtent(data, axis, seriesModel) {
  21941. each(seriesModel.coordDimToDataDim(axis.dim), function (dim) {
  21942. axis.scale.unionExtent(data.getDataExtent(
  21943. dim, axis.scale.type !== 'ordinal'
  21944. ));
  21945. });
  21946. }
  21947. };
  21948. /**
  21949. * @inner
  21950. */
  21951. function updateAxisTransfrom(axis, coordBase) {
  21952. var axisExtent = axis.getExtent();
  21953. var axisExtentSum = axisExtent[0] + axisExtent[1];
  21954. // Fast transform
  21955. axis.toGlobalCoord = axis.dim === 'x'
  21956. ? function (coord) {
  21957. return coord + coordBase;
  21958. }
  21959. : function (coord) {
  21960. return axisExtentSum - coord + coordBase;
  21961. };
  21962. axis.toLocalCoord = axis.dim === 'x'
  21963. ? function (coord) {
  21964. return coord - coordBase;
  21965. }
  21966. : function (coord) {
  21967. return axisExtentSum - coord + coordBase;
  21968. };
  21969. }
  21970. var axesTypes = ['xAxis', 'yAxis'];
  21971. /**
  21972. * @inner
  21973. */
  21974. function findAxesModels(seriesModel, ecModel) {
  21975. return zrUtil.map(axesTypes, function (axisType) {
  21976. var axisModel = seriesModel.getReferringComponents(axisType)[0];
  21977. if (true) {
  21978. if (!axisModel) {
  21979. throw new Error(axisType + ' "' + zrUtil.retrieve(
  21980. seriesModel.get(axisType + 'Index'),
  21981. seriesModel.get(axisType + 'Id'),
  21982. 0
  21983. ) + '" not found');
  21984. }
  21985. }
  21986. return axisModel;
  21987. });
  21988. }
  21989. /**
  21990. * @inner
  21991. */
  21992. function isCartesian2D(seriesModel) {
  21993. return seriesModel.get('coordinateSystem') === 'cartesian2d';
  21994. }
  21995. Grid.create = function (ecModel, api) {
  21996. var grids = [];
  21997. ecModel.eachComponent('grid', function (gridModel, idx) {
  21998. var grid = new Grid(gridModel, ecModel, api);
  21999. grid.name = 'grid_' + idx;
  22000. grid.resize(gridModel, api);
  22001. gridModel.coordinateSystem = grid;
  22002. grids.push(grid);
  22003. });
  22004. // Inject the coordinateSystems into seriesModel
  22005. ecModel.eachSeries(function (seriesModel) {
  22006. if (!isCartesian2D(seriesModel)) {
  22007. return;
  22008. }
  22009. var axesModels = findAxesModels(seriesModel, ecModel);
  22010. var xAxisModel = axesModels[0];
  22011. var yAxisModel = axesModels[1];
  22012. var gridModel = xAxisModel.findGridModel();
  22013. if (true) {
  22014. if (!gridModel) {
  22015. throw new Error(
  22016. 'Grid "' + zrUtil.retrieve(
  22017. xAxisModel.get('gridIndex'),
  22018. xAxisModel.get('gridId'),
  22019. 0
  22020. ) + '" not found'
  22021. );
  22022. }
  22023. if (xAxisModel.findGridModel() !== yAxisModel.findGridModel()) {
  22024. throw new Error('xAxis and yAxis must use the same grid');
  22025. }
  22026. }
  22027. var grid = gridModel.coordinateSystem;
  22028. seriesModel.coordinateSystem = grid.getCartesian(
  22029. xAxisModel.componentIndex, yAxisModel.componentIndex
  22030. );
  22031. });
  22032. return grids;
  22033. };
  22034. // For deciding which dimensions to use when creating list data
  22035. Grid.dimensions = Cartesian2D.prototype.dimensions;
  22036. __webpack_require__(26).register('cartesian2d', Grid);
  22037. module.exports = Grid;
  22038. /***/ },
  22039. /* 115 */
  22040. /***/ function(module, exports, __webpack_require__) {
  22041. var OrdinalScale = __webpack_require__(116);
  22042. var IntervalScale = __webpack_require__(118);
  22043. __webpack_require__(119);
  22044. __webpack_require__(120);
  22045. var Scale = __webpack_require__(117);
  22046. var numberUtil = __webpack_require__(7);
  22047. var zrUtil = __webpack_require__(4);
  22048. var textContain = __webpack_require__(8);
  22049. var axisHelper = {};
  22050. /**
  22051. * Get axis scale extent before niced.
  22052. */
  22053. axisHelper.getScaleExtent = function (axis, model) {
  22054. var scale = axis.scale;
  22055. var originalExtent = scale.getExtent();
  22056. var span = originalExtent[1] - originalExtent[0];
  22057. if (scale.type === 'ordinal') {
  22058. // If series has no data, scale extent may be wrong
  22059. if (!isFinite(span)) {
  22060. return [0, 0];
  22061. }
  22062. else {
  22063. return originalExtent;
  22064. }
  22065. }
  22066. var min = model.getMin ? model.getMin() : model.get('min');
  22067. var max = model.getMax ? model.getMax() : model.get('max');
  22068. var crossZero = model.getNeedCrossZero
  22069. ? model.getNeedCrossZero() : !model.get('scale');
  22070. var boundaryGap = model.get('boundaryGap');
  22071. if (!zrUtil.isArray(boundaryGap)) {
  22072. boundaryGap = [boundaryGap || 0, boundaryGap || 0];
  22073. }
  22074. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1);
  22075. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1);
  22076. var fixMin = true;
  22077. var fixMax = true;
  22078. // Add boundary gap
  22079. if (min == null) {
  22080. min = originalExtent[0] - boundaryGap[0] * span;
  22081. fixMin = false;
  22082. }
  22083. if (max == null) {
  22084. max = originalExtent[1] + boundaryGap[1] * span;
  22085. fixMax = false;
  22086. }
  22087. if (min === 'dataMin') {
  22088. min = originalExtent[0];
  22089. }
  22090. if (max === 'dataMax') {
  22091. max = originalExtent[1];
  22092. }
  22093. // Evaluate if axis needs cross zero
  22094. if (crossZero) {
  22095. // Axis is over zero and min is not set
  22096. if (min > 0 && max > 0 && !fixMin) {
  22097. min = 0;
  22098. }
  22099. // Axis is under zero and max is not set
  22100. if (min < 0 && max < 0 && !fixMax) {
  22101. max = 0;
  22102. }
  22103. }
  22104. return [min, max];
  22105. };
  22106. axisHelper.niceScaleExtent = function (axis, model) {
  22107. var scale = axis.scale;
  22108. var extent = axisHelper.getScaleExtent(axis, model);
  22109. var fixMin = (model.getMin ? model.getMin() : model.get('min')) != null;
  22110. var fixMax = (model.getMax ? model.getMax() : model.get('max')) != null;
  22111. var splitNumber = model.get('splitNumber');
  22112. if (scale.type === 'log') {
  22113. scale.base = model.get('logBase');
  22114. }
  22115. scale.setExtent(extent[0], extent[1]);
  22116. scale.niceExtent(splitNumber, fixMin, fixMax);
  22117. // Use minInterval to constraint the calculated interval.
  22118. // If calculated interval is less than minInterval. increase the interval quantity until
  22119. // it is larger than minInterval.
  22120. // For example:
  22121. // minInterval is 1, calculated interval is 0.2, so increase it to be 1. In this way we can get
  22122. // an integer axis.
  22123. var minInterval = model.get('minInterval');
  22124. if (isFinite(minInterval) && !fixMin && !fixMax && scale.type === 'interval') {
  22125. var interval = scale.getInterval();
  22126. var intervalScale = Math.max(Math.abs(interval), minInterval) / interval;
  22127. // while (interval < minInterval) {
  22128. // var quantity = numberUtil.quantity(interval);
  22129. // interval = quantity * 10;
  22130. // scaleQuantity *= 10;
  22131. // }
  22132. extent = scale.getExtent();
  22133. var origin = (extent[1] + extent[0]) / 2;
  22134. scale.setExtent(
  22135. intervalScale * (extent[0] - origin) + origin,
  22136. intervalScale * (extent[1] - origin) + origin
  22137. );
  22138. scale.niceExtent(splitNumber);
  22139. }
  22140. // If some one specified the min, max. And the default calculated interval
  22141. // is not good enough. He can specify the interval. It is often appeared
  22142. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  22143. // to be 60.
  22144. // FIXME
  22145. var interval = model.get('interval');
  22146. if (interval != null) {
  22147. scale.setInterval && scale.setInterval(interval);
  22148. }
  22149. };
  22150. /**
  22151. * @param {module:echarts/model/Model} model
  22152. * @param {string} [axisType] Default retrieve from model.type
  22153. * @return {module:echarts/scale/*}
  22154. */
  22155. axisHelper.createScaleByModel = function(model, axisType) {
  22156. axisType = axisType || model.get('type');
  22157. if (axisType) {
  22158. switch (axisType) {
  22159. // Buildin scale
  22160. case 'category':
  22161. return new OrdinalScale(
  22162. model.getCategories(), [Infinity, -Infinity]
  22163. );
  22164. case 'value':
  22165. return new IntervalScale();
  22166. // Extended scale, like time and log
  22167. default:
  22168. return (Scale.getClass(axisType) || IntervalScale).create(model);
  22169. }
  22170. }
  22171. };
  22172. /**
  22173. * Check if the axis corss 0
  22174. */
  22175. axisHelper.ifAxisCrossZero = function (axis) {
  22176. var dataExtent = axis.scale.getExtent();
  22177. var min = dataExtent[0];
  22178. var max = dataExtent[1];
  22179. return !((min > 0 && max > 0) || (min < 0 && max < 0));
  22180. };
  22181. /**
  22182. * @param {Array.<number>} tickCoords In axis self coordinate.
  22183. * @param {Array.<string>} labels
  22184. * @param {string} font
  22185. * @param {boolean} isAxisHorizontal
  22186. * @return {number}
  22187. */
  22188. axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) {
  22189. // FIXME
  22190. // 不同角的axis和label,不只是horizontal和vertical.
  22191. var textSpaceTakenRect;
  22192. var autoLabelInterval = 0;
  22193. var accumulatedLabelInterval = 0;
  22194. var step = 1;
  22195. if (labels.length > 40) {
  22196. // Simple optimization for large amount of labels
  22197. step = Math.floor(labels.length / 40);
  22198. }
  22199. for (var i = 0; i < tickCoords.length; i += step) {
  22200. var tickCoord = tickCoords[i];
  22201. var rect = textContain.getBoundingRect(
  22202. labels[i], font, 'center', 'top'
  22203. );
  22204. rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord;
  22205. // FIXME Magic number 1.5
  22206. rect[isAxisHorizontal ? 'width' : 'height'] *= 1.3;
  22207. if (!textSpaceTakenRect) {
  22208. textSpaceTakenRect = rect.clone();
  22209. }
  22210. // There is no space for current label;
  22211. else if (textSpaceTakenRect.intersect(rect)) {
  22212. accumulatedLabelInterval++;
  22213. autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval);
  22214. }
  22215. else {
  22216. textSpaceTakenRect.union(rect);
  22217. // Reset
  22218. accumulatedLabelInterval = 0;
  22219. }
  22220. }
  22221. if (autoLabelInterval === 0 && step > 1) {
  22222. return step;
  22223. }
  22224. return (autoLabelInterval + 1) * step - 1;
  22225. };
  22226. /**
  22227. * @param {Object} axis
  22228. * @param {Function} labelFormatter
  22229. * @return {Array.<string>}
  22230. */
  22231. axisHelper.getFormattedLabels = function (axis, labelFormatter) {
  22232. var scale = axis.scale;
  22233. var labels = scale.getTicksLabels();
  22234. var ticks = scale.getTicks();
  22235. if (typeof labelFormatter === 'string') {
  22236. labelFormatter = (function (tpl) {
  22237. return function (val) {
  22238. return tpl.replace('{value}', val != null ? val : '');
  22239. };
  22240. })(labelFormatter);
  22241. // Consider empty array
  22242. return zrUtil.map(labels, labelFormatter);
  22243. }
  22244. else if (typeof labelFormatter === 'function') {
  22245. return zrUtil.map(ticks, function (tick, idx) {
  22246. return labelFormatter(
  22247. axis.type === 'category' ? scale.getLabel(tick) : tick,
  22248. idx
  22249. );
  22250. }, this);
  22251. }
  22252. else {
  22253. return labels;
  22254. }
  22255. };
  22256. module.exports = axisHelper;
  22257. /***/ },
  22258. /* 116 */
  22259. /***/ function(module, exports, __webpack_require__) {
  22260. /**
  22261. * Linear continuous scale
  22262. * @module echarts/coord/scale/Ordinal
  22263. *
  22264. * http://en.wikipedia.org/wiki/Level_of_measurement
  22265. */
  22266. // FIXME only one data
  22267. var zrUtil = __webpack_require__(4);
  22268. var Scale = __webpack_require__(117);
  22269. var scaleProto = Scale.prototype;
  22270. var OrdinalScale = Scale.extend({
  22271. type: 'ordinal',
  22272. init: function (data, extent) {
  22273. this._data = data;
  22274. this._extent = extent || [0, data.length - 1];
  22275. },
  22276. parse: function (val) {
  22277. return typeof val === 'string'
  22278. ? zrUtil.indexOf(this._data, val)
  22279. // val might be float.
  22280. : Math.round(val);
  22281. },
  22282. contain: function (rank) {
  22283. rank = this.parse(rank);
  22284. return scaleProto.contain.call(this, rank)
  22285. && this._data[rank] != null;
  22286. },
  22287. /**
  22288. * Normalize given rank or name to linear [0, 1]
  22289. * @param {number|string} [val]
  22290. * @return {number}
  22291. */
  22292. normalize: function (val) {
  22293. return scaleProto.normalize.call(this, this.parse(val));
  22294. },
  22295. scale: function (val) {
  22296. return Math.round(scaleProto.scale.call(this, val));
  22297. },
  22298. /**
  22299. * @return {Array}
  22300. */
  22301. getTicks: function () {
  22302. var ticks = [];
  22303. var extent = this._extent;
  22304. var rank = extent[0];
  22305. while (rank <= extent[1]) {
  22306. ticks.push(rank);
  22307. rank++;
  22308. }
  22309. return ticks;
  22310. },
  22311. /**
  22312. * Get item on rank n
  22313. * @param {number} n
  22314. * @return {string}
  22315. */
  22316. getLabel: function (n) {
  22317. return this._data[n];
  22318. },
  22319. /**
  22320. * @return {number}
  22321. */
  22322. count: function () {
  22323. return this._extent[1] - this._extent[0] + 1;
  22324. },
  22325. niceTicks: zrUtil.noop,
  22326. niceExtent: zrUtil.noop
  22327. });
  22328. /**
  22329. * @return {module:echarts/scale/Time}
  22330. */
  22331. OrdinalScale.create = function () {
  22332. return new OrdinalScale();
  22333. };
  22334. module.exports = OrdinalScale;
  22335. /***/ },
  22336. /* 117 */
  22337. /***/ function(module, exports, __webpack_require__) {
  22338. /**
  22339. * // Scale class management
  22340. * @module echarts/scale/Scale
  22341. */
  22342. var clazzUtil = __webpack_require__(13);
  22343. function Scale() {
  22344. /**
  22345. * Extent
  22346. * @type {Array.<number>}
  22347. * @protected
  22348. */
  22349. this._extent = [Infinity, -Infinity];
  22350. /**
  22351. * Step is calculated in adjustExtent
  22352. * @type {Array.<number>}
  22353. * @protected
  22354. */
  22355. this._interval = 0;
  22356. this.init && this.init.apply(this, arguments);
  22357. }
  22358. var scaleProto = Scale.prototype;
  22359. /**
  22360. * Parse input val to valid inner number.
  22361. * @param {*} val
  22362. * @return {number}
  22363. */
  22364. scaleProto.parse = function (val) {
  22365. // Notice: This would be a trap here, If the implementation
  22366. // of this method depends on extent, and this method is used
  22367. // before extent set (like in dataZoom), it would be wrong.
  22368. // Nevertheless, parse does not depend on extent generally.
  22369. return val;
  22370. };
  22371. scaleProto.contain = function (val) {
  22372. var extent = this._extent;
  22373. return val >= extent[0] && val <= extent[1];
  22374. };
  22375. /**
  22376. * Normalize value to linear [0, 1], return 0.5 if extent span is 0
  22377. * @param {number} val
  22378. * @return {number}
  22379. */
  22380. scaleProto.normalize = function (val) {
  22381. var extent = this._extent;
  22382. if (extent[1] === extent[0]) {
  22383. return 0.5;
  22384. }
  22385. return (val - extent[0]) / (extent[1] - extent[0]);
  22386. };
  22387. /**
  22388. * Scale normalized value
  22389. * @param {number} val
  22390. * @return {number}
  22391. */
  22392. scaleProto.scale = function (val) {
  22393. var extent = this._extent;
  22394. return val * (extent[1] - extent[0]) + extent[0];
  22395. };
  22396. /**
  22397. * Set extent from data
  22398. * @param {Array.<number>} other
  22399. */
  22400. scaleProto.unionExtent = function (other) {
  22401. var extent = this._extent;
  22402. other[0] < extent[0] && (extent[0] = other[0]);
  22403. other[1] > extent[1] && (extent[1] = other[1]);
  22404. // not setExtent because in log axis it may transformed to power
  22405. // this.setExtent(extent[0], extent[1]);
  22406. };
  22407. /**
  22408. * Get extent
  22409. * @return {Array.<number>}
  22410. */
  22411. scaleProto.getExtent = function () {
  22412. return this._extent.slice();
  22413. };
  22414. /**
  22415. * Set extent
  22416. * @param {number} start
  22417. * @param {number} end
  22418. */
  22419. scaleProto.setExtent = function (start, end) {
  22420. var thisExtent = this._extent;
  22421. if (!isNaN(start)) {
  22422. thisExtent[0] = start;
  22423. }
  22424. if (!isNaN(end)) {
  22425. thisExtent[1] = end;
  22426. }
  22427. };
  22428. /**
  22429. * @return {Array.<string>}
  22430. */
  22431. scaleProto.getTicksLabels = function () {
  22432. var labels = [];
  22433. var ticks = this.getTicks();
  22434. for (var i = 0; i < ticks.length; i++) {
  22435. labels.push(this.getLabel(ticks[i]));
  22436. }
  22437. return labels;
  22438. };
  22439. clazzUtil.enableClassExtend(Scale);
  22440. clazzUtil.enableClassManagement(Scale, {
  22441. registerWhenExtend: true
  22442. });
  22443. module.exports = Scale;
  22444. /***/ },
  22445. /* 118 */
  22446. /***/ function(module, exports, __webpack_require__) {
  22447. /**
  22448. * Interval scale
  22449. * @module echarts/scale/Interval
  22450. */
  22451. var numberUtil = __webpack_require__(7);
  22452. var formatUtil = __webpack_require__(6);
  22453. var Scale = __webpack_require__(117);
  22454. var mathFloor = Math.floor;
  22455. var mathCeil = Math.ceil;
  22456. var getPrecisionSafe = numberUtil.getPrecisionSafe;
  22457. var roundingErrorFix = numberUtil.round;
  22458. /**
  22459. * @alias module:echarts/coord/scale/Interval
  22460. * @constructor
  22461. */
  22462. var IntervalScale = Scale.extend({
  22463. type: 'interval',
  22464. _interval: 0,
  22465. setExtent: function (start, end) {
  22466. var thisExtent = this._extent;
  22467. //start,end may be a Number like '25',so...
  22468. if (!isNaN(start)) {
  22469. thisExtent[0] = parseFloat(start);
  22470. }
  22471. if (!isNaN(end)) {
  22472. thisExtent[1] = parseFloat(end);
  22473. }
  22474. },
  22475. unionExtent: function (other) {
  22476. var extent = this._extent;
  22477. other[0] < extent[0] && (extent[0] = other[0]);
  22478. other[1] > extent[1] && (extent[1] = other[1]);
  22479. // unionExtent may called by it's sub classes
  22480. IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]);
  22481. },
  22482. /**
  22483. * Get interval
  22484. */
  22485. getInterval: function () {
  22486. if (!this._interval) {
  22487. this.niceTicks();
  22488. }
  22489. return this._interval;
  22490. },
  22491. /**
  22492. * Set interval
  22493. */
  22494. setInterval: function (interval) {
  22495. this._interval = interval;
  22496. // Dropped auto calculated niceExtent and use user setted extent
  22497. // We assume user wan't to set both interval, min, max to get a better result
  22498. this._niceExtent = this._extent.slice();
  22499. },
  22500. /**
  22501. * @return {Array.<number>}
  22502. */
  22503. getTicks: function () {
  22504. if (!this._interval) {
  22505. this.niceTicks();
  22506. }
  22507. var interval = this._interval;
  22508. var extent = this._extent;
  22509. var ticks = [];
  22510. // Consider this case: using dataZoom toolbox, zoom and zoom.
  22511. var safeLimit = 10000;
  22512. if (interval) {
  22513. var niceExtent = this._niceExtent;
  22514. var precision = getPrecisionSafe(interval) + 2;
  22515. if (extent[0] < niceExtent[0]) {
  22516. ticks.push(extent[0]);
  22517. }
  22518. var tick = niceExtent[0];
  22519. while (tick <= niceExtent[1]) {
  22520. ticks.push(tick);
  22521. // Avoid rounding error
  22522. tick = roundingErrorFix(tick + interval, precision);
  22523. if (ticks.length > safeLimit) {
  22524. return [];
  22525. }
  22526. }
  22527. // Consider this case: the last item of ticks is smaller
  22528. // than niceExtent[1] and niceExtent[1] === extent[1].
  22529. if (extent[1] > (ticks.length ? ticks[ticks.length - 1] : niceExtent[1])) {
  22530. ticks.push(extent[1]);
  22531. }
  22532. }
  22533. return ticks;
  22534. },
  22535. /**
  22536. * @return {Array.<string>}
  22537. */
  22538. getTicksLabels: function () {
  22539. var labels = [];
  22540. var ticks = this.getTicks();
  22541. for (var i = 0; i < ticks.length; i++) {
  22542. labels.push(this.getLabel(ticks[i]));
  22543. }
  22544. return labels;
  22545. },
  22546. /**
  22547. * @param {number} n
  22548. * @return {number}
  22549. */
  22550. getLabel: function (data) {
  22551. return formatUtil.addCommas(data);
  22552. },
  22553. /**
  22554. * Update interval and extent of intervals for nice ticks
  22555. *
  22556. * @param {number} [splitNumber = 5] Desired number of ticks
  22557. */
  22558. niceTicks: function (splitNumber) {
  22559. splitNumber = splitNumber || 5;
  22560. var extent = this._extent;
  22561. var span = extent[1] - extent[0];
  22562. if (!isFinite(span)) {
  22563. return;
  22564. }
  22565. // User may set axis min 0 and data are all negative
  22566. // FIXME If it needs to reverse ?
  22567. if (span < 0) {
  22568. span = -span;
  22569. extent.reverse();
  22570. }
  22571. // From "Nice Numbers for Graph Labels" of Graphic Gems
  22572. // var niceSpan = numberUtil.nice(span, false);
  22573. var step = roundingErrorFix(
  22574. numberUtil.nice(span / splitNumber, true),
  22575. Math.max(
  22576. getPrecisionSafe(extent[0]),
  22577. getPrecisionSafe(extent[1])
  22578. // extent may be [0, 1], and step should have 1 more digits.
  22579. // To make it safe we add 2 more digits
  22580. ) + 2
  22581. );
  22582. var precision = getPrecisionSafe(step) + 2;
  22583. // Niced extent inside original extent
  22584. var niceExtent = [
  22585. roundingErrorFix(mathCeil(extent[0] / step) * step, precision),
  22586. roundingErrorFix(mathFloor(extent[1] / step) * step, precision)
  22587. ];
  22588. this._interval = step;
  22589. this._niceExtent = niceExtent;
  22590. },
  22591. /**
  22592. * Nice extent.
  22593. * @param {number} [splitNumber = 5] Given approx tick number
  22594. * @param {boolean} [fixMin=false]
  22595. * @param {boolean} [fixMax=false]
  22596. */
  22597. niceExtent: function (splitNumber, fixMin, fixMax) {
  22598. var extent = this._extent;
  22599. // If extent start and end are same, expand them
  22600. if (extent[0] === extent[1]) {
  22601. if (extent[0] !== 0) {
  22602. // Expand extent
  22603. var expandSize = extent[0];
  22604. // In the fowllowing case
  22605. // Axis has been fixed max 100
  22606. // Plus data are all 100 and axis extent are [100, 100].
  22607. // Extend to the both side will cause expanded max is larger than fixed max.
  22608. // So only expand to the smaller side.
  22609. if (!fixMax) {
  22610. extent[1] += expandSize / 2;
  22611. extent[0] -= expandSize / 2;
  22612. }
  22613. else {
  22614. extent[0] -= expandSize / 2;
  22615. }
  22616. }
  22617. else {
  22618. extent[1] = 1;
  22619. }
  22620. }
  22621. var span = extent[1] - extent[0];
  22622. // If there are no data and extent are [Infinity, -Infinity]
  22623. if (!isFinite(span)) {
  22624. extent[0] = 0;
  22625. extent[1] = 1;
  22626. }
  22627. this.niceTicks(splitNumber);
  22628. // var extent = this._extent;
  22629. var interval = this._interval;
  22630. if (!fixMin) {
  22631. extent[0] = roundingErrorFix(mathFloor(extent[0] / interval) * interval);
  22632. }
  22633. if (!fixMax) {
  22634. extent[1] = roundingErrorFix(mathCeil(extent[1] / interval) * interval);
  22635. }
  22636. }
  22637. });
  22638. /**
  22639. * @return {module:echarts/scale/Time}
  22640. */
  22641. IntervalScale.create = function () {
  22642. return new IntervalScale();
  22643. };
  22644. module.exports = IntervalScale;
  22645. /***/ },
  22646. /* 119 */
  22647. /***/ function(module, exports, __webpack_require__) {
  22648. /**
  22649. * Interval scale
  22650. * @module echarts/coord/scale/Time
  22651. */
  22652. var zrUtil = __webpack_require__(4);
  22653. var numberUtil = __webpack_require__(7);
  22654. var formatUtil = __webpack_require__(6);
  22655. var IntervalScale = __webpack_require__(118);
  22656. var intervalScaleProto = IntervalScale.prototype;
  22657. var mathCeil = Math.ceil;
  22658. var mathFloor = Math.floor;
  22659. var ONE_SECOND = 1000;
  22660. var ONE_MINUTE = ONE_SECOND * 60;
  22661. var ONE_HOUR = ONE_MINUTE * 60;
  22662. var ONE_DAY = ONE_HOUR * 24;
  22663. // FIXME 公用?
  22664. var bisect = function (a, x, lo, hi) {
  22665. while (lo < hi) {
  22666. var mid = lo + hi >>> 1;
  22667. if (a[mid][2] < x) {
  22668. lo = mid + 1;
  22669. }
  22670. else {
  22671. hi = mid;
  22672. }
  22673. }
  22674. return lo;
  22675. };
  22676. /**
  22677. * @alias module:echarts/coord/scale/Time
  22678. * @constructor
  22679. */
  22680. var TimeScale = IntervalScale.extend({
  22681. type: 'time',
  22682. // Overwrite
  22683. getLabel: function (val) {
  22684. var stepLvl = this._stepLvl;
  22685. var date = new Date(val);
  22686. return formatUtil.formatTime(stepLvl[0], date);
  22687. },
  22688. // Overwrite
  22689. niceExtent: function (approxTickNum, fixMin, fixMax) {
  22690. var extent = this._extent;
  22691. // If extent start and end are same, expand them
  22692. if (extent[0] === extent[1]) {
  22693. // Expand extent
  22694. extent[0] -= ONE_DAY;
  22695. extent[1] += ONE_DAY;
  22696. }
  22697. // If there are no data and extent are [Infinity, -Infinity]
  22698. if (extent[1] === -Infinity && extent[0] === Infinity) {
  22699. var d = new Date();
  22700. extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
  22701. extent[0] = extent[1] - ONE_DAY;
  22702. }
  22703. this.niceTicks(approxTickNum);
  22704. // var extent = this._extent;
  22705. var interval = this._interval;
  22706. if (!fixMin) {
  22707. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  22708. }
  22709. if (!fixMax) {
  22710. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  22711. }
  22712. },
  22713. // Overwrite
  22714. niceTicks: function (approxTickNum) {
  22715. approxTickNum = approxTickNum || 10;
  22716. var extent = this._extent;
  22717. var span = extent[1] - extent[0];
  22718. var approxInterval = span / approxTickNum;
  22719. var scaleLevelsLen = scaleLevels.length;
  22720. var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen);
  22721. var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)];
  22722. var interval = level[2];
  22723. // Same with interval scale if span is much larger than 1 year
  22724. if (level[0] === 'year') {
  22725. var yearSpan = span / interval;
  22726. // From "Nice Numbers for Graph Labels" of Graphic Gems
  22727. // var niceYearSpan = numberUtil.nice(yearSpan, false);
  22728. var yearStep = numberUtil.nice(yearSpan / approxTickNum, true);
  22729. interval *= yearStep;
  22730. }
  22731. var niceExtent = [
  22732. mathCeil(extent[0] / interval) * interval,
  22733. mathFloor(extent[1] / interval) * interval
  22734. ];
  22735. this._stepLvl = level;
  22736. // Interval will be used in getTicks
  22737. this._interval = interval;
  22738. this._niceExtent = niceExtent;
  22739. },
  22740. parse: function (val) {
  22741. // val might be float.
  22742. return +numberUtil.parseDate(val);
  22743. }
  22744. });
  22745. zrUtil.each(['contain', 'normalize'], function (methodName) {
  22746. TimeScale.prototype[methodName] = function (val) {
  22747. return intervalScaleProto[methodName].call(this, this.parse(val));
  22748. };
  22749. });
  22750. // Steps from d3
  22751. var scaleLevels = [
  22752. // Format step interval
  22753. ['hh:mm:ss', 1, ONE_SECOND], // 1s
  22754. ['hh:mm:ss', 5, ONE_SECOND * 5], // 5s
  22755. ['hh:mm:ss', 10, ONE_SECOND * 10], // 10s
  22756. ['hh:mm:ss', 15, ONE_SECOND * 15], // 15s
  22757. ['hh:mm:ss', 30, ONE_SECOND * 30], // 30s
  22758. ['hh:mm\nMM-dd',1, ONE_MINUTE], // 1m
  22759. ['hh:mm\nMM-dd',5, ONE_MINUTE * 5], // 5m
  22760. ['hh:mm\nMM-dd',10, ONE_MINUTE * 10], // 10m
  22761. ['hh:mm\nMM-dd',15, ONE_MINUTE * 15], // 15m
  22762. ['hh:mm\nMM-dd',30, ONE_MINUTE * 30], // 30m
  22763. ['hh:mm\nMM-dd',1, ONE_HOUR], // 1h
  22764. ['hh:mm\nMM-dd',2, ONE_HOUR * 2], // 2h
  22765. ['hh:mm\nMM-dd',6, ONE_HOUR * 6], // 6h
  22766. ['hh:mm\nMM-dd',12, ONE_HOUR * 12], // 12h
  22767. ['MM-dd\nyyyy', 1, ONE_DAY], // 1d
  22768. ['week', 7, ONE_DAY * 7], // 7d
  22769. ['month', 1, ONE_DAY * 31], // 1M
  22770. ['quarter', 3, ONE_DAY * 380 / 4], // 3M
  22771. ['half-year', 6, ONE_DAY * 380 / 2], // 6M
  22772. ['year', 1, ONE_DAY * 380] // 1Y
  22773. ];
  22774. /**
  22775. * @return {module:echarts/scale/Time}
  22776. */
  22777. TimeScale.create = function () {
  22778. return new TimeScale();
  22779. };
  22780. module.exports = TimeScale;
  22781. /***/ },
  22782. /* 120 */
  22783. /***/ function(module, exports, __webpack_require__) {
  22784. /**
  22785. * Log scale
  22786. * @module echarts/scale/Log
  22787. */
  22788. var zrUtil = __webpack_require__(4);
  22789. var Scale = __webpack_require__(117);
  22790. var numberUtil = __webpack_require__(7);
  22791. // Use some method of IntervalScale
  22792. var IntervalScale = __webpack_require__(118);
  22793. var scaleProto = Scale.prototype;
  22794. var intervalScaleProto = IntervalScale.prototype;
  22795. var getPrecisionSafe = numberUtil.getPrecisionSafe;
  22796. var roundingErrorFix = numberUtil.round;
  22797. var mathFloor = Math.floor;
  22798. var mathCeil = Math.ceil;
  22799. var mathPow = Math.pow;
  22800. var mathLog = Math.log;
  22801. var LogScale = Scale.extend({
  22802. type: 'log',
  22803. base: 10,
  22804. $constructor: function () {
  22805. Scale.apply(this, arguments);
  22806. this._originalScale = new IntervalScale();
  22807. },
  22808. /**
  22809. * @return {Array.<number>}
  22810. */
  22811. getTicks: function () {
  22812. var originalScale = this._originalScale;
  22813. var extent = this._extent;
  22814. var originalExtent = originalScale.getExtent();
  22815. return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
  22816. var powVal = numberUtil.round(mathPow(this.base, val));
  22817. // Fix #4158
  22818. powVal = (val === extent[0] && originalScale.__fixMin)
  22819. ? fixRoundingError(powVal, originalExtent[0])
  22820. : powVal;
  22821. powVal = (val === extent[1] && originalScale.__fixMax)
  22822. ? fixRoundingError(powVal, originalExtent[1])
  22823. : powVal;
  22824. return powVal;
  22825. }, this);
  22826. },
  22827. /**
  22828. * @param {number} val
  22829. * @return {string}
  22830. */
  22831. getLabel: intervalScaleProto.getLabel,
  22832. /**
  22833. * @param {number} val
  22834. * @return {number}
  22835. */
  22836. scale: function (val) {
  22837. val = scaleProto.scale.call(this, val);
  22838. return mathPow(this.base, val);
  22839. },
  22840. /**
  22841. * @param {number} start
  22842. * @param {number} end
  22843. */
  22844. setExtent: function (start, end) {
  22845. var base = this.base;
  22846. start = mathLog(start) / mathLog(base);
  22847. end = mathLog(end) / mathLog(base);
  22848. intervalScaleProto.setExtent.call(this, start, end);
  22849. },
  22850. /**
  22851. * @return {number} end
  22852. */
  22853. getExtent: function () {
  22854. var base = this.base;
  22855. var extent = scaleProto.getExtent.call(this);
  22856. extent[0] = mathPow(base, extent[0]);
  22857. extent[1] = mathPow(base, extent[1]);
  22858. // Fix #4158
  22859. var originalScale = this._originalScale;
  22860. var originalExtent = originalScale.getExtent();
  22861. originalScale.__fixMin && (extent[0] = fixRoundingError(extent[0], originalExtent[0]));
  22862. originalScale.__fixMax && (extent[1] = fixRoundingError(extent[1], originalExtent[1]));
  22863. return extent;
  22864. },
  22865. /**
  22866. * @param {Array.<number>} extent
  22867. */
  22868. unionExtent: function (extent) {
  22869. this._originalScale.unionExtent(extent);
  22870. var base = this.base;
  22871. extent[0] = mathLog(extent[0]) / mathLog(base);
  22872. extent[1] = mathLog(extent[1]) / mathLog(base);
  22873. scaleProto.unionExtent.call(this, extent);
  22874. },
  22875. /**
  22876. * Update interval and extent of intervals for nice ticks
  22877. * @param {number} [approxTickNum = 10] Given approx tick number
  22878. */
  22879. niceTicks: function (approxTickNum) {
  22880. approxTickNum = approxTickNum || 10;
  22881. var extent = this._extent;
  22882. var span = extent[1] - extent[0];
  22883. if (span === Infinity || span <= 0) {
  22884. return;
  22885. }
  22886. var interval = numberUtil.quantity(span);
  22887. var err = approxTickNum / span * interval;
  22888. // Filter ticks to get closer to the desired count.
  22889. if (err <= 0.5) {
  22890. interval *= 10;
  22891. }
  22892. // Interval should be integer
  22893. while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
  22894. interval *= 10;
  22895. }
  22896. var niceExtent = [
  22897. numberUtil.round(mathCeil(extent[0] / interval) * interval),
  22898. numberUtil.round(mathFloor(extent[1] / interval) * interval)
  22899. ];
  22900. this._interval = interval;
  22901. this._niceExtent = niceExtent;
  22902. },
  22903. /**
  22904. * Nice extent.
  22905. * @param {number} [approxTickNum = 10] Given approx tick number
  22906. * @param {boolean} [fixMin=false]
  22907. * @param {boolean} [fixMax=false]
  22908. */
  22909. niceExtent: function (splitNumber, fixMin, fixMax) {
  22910. intervalScaleProto.niceExtent.call(this, splitNumber, fixMin, fixMax);
  22911. var originalScale = this._originalScale;
  22912. originalScale.__fixMin = fixMin;
  22913. originalScale.__fixMax = fixMax;
  22914. }
  22915. });
  22916. zrUtil.each(['contain', 'normalize'], function (methodName) {
  22917. LogScale.prototype[methodName] = function (val) {
  22918. val = mathLog(val) / mathLog(this.base);
  22919. return scaleProto[methodName].call(this, val);
  22920. };
  22921. });
  22922. LogScale.create = function () {
  22923. return new LogScale();
  22924. };
  22925. function fixRoundingError(val, originalVal) {
  22926. return roundingErrorFix(val, getPrecisionSafe(originalVal));
  22927. }
  22928. module.exports = LogScale;
  22929. /***/ },
  22930. /* 121 */
  22931. /***/ function(module, exports, __webpack_require__) {
  22932. 'use strict';
  22933. var zrUtil = __webpack_require__(4);
  22934. var Cartesian = __webpack_require__(122);
  22935. function Cartesian2D(name) {
  22936. Cartesian.call(this, name);
  22937. }
  22938. Cartesian2D.prototype = {
  22939. constructor: Cartesian2D,
  22940. type: 'cartesian2d',
  22941. /**
  22942. * @type {Array.<string>}
  22943. * @readOnly
  22944. */
  22945. dimensions: ['x', 'y'],
  22946. /**
  22947. * Base axis will be used on stacking.
  22948. *
  22949. * @return {module:echarts/coord/cartesian/Axis2D}
  22950. */
  22951. getBaseAxis: function () {
  22952. return this.getAxesByScale('ordinal')[0]
  22953. || this.getAxesByScale('time')[0]
  22954. || this.getAxis('x');
  22955. },
  22956. /**
  22957. * If contain point
  22958. * @param {Array.<number>} point
  22959. * @return {boolean}
  22960. */
  22961. containPoint: function (point) {
  22962. var axisX = this.getAxis('x');
  22963. var axisY = this.getAxis('y');
  22964. return axisX.contain(axisX.toLocalCoord(point[0]))
  22965. && axisY.contain(axisY.toLocalCoord(point[1]));
  22966. },
  22967. /**
  22968. * If contain data
  22969. * @param {Array.<number>} data
  22970. * @return {boolean}
  22971. */
  22972. containData: function (data) {
  22973. return this.getAxis('x').containData(data[0])
  22974. && this.getAxis('y').containData(data[1]);
  22975. },
  22976. /**
  22977. * Convert series data to an array of points
  22978. * @param {module:echarts/data/List} data
  22979. * @param {boolean} stack
  22980. * @return {Array}
  22981. * Return array of points. For example:
  22982. * `[[10, 10], [20, 20], [30, 30]]`
  22983. */
  22984. dataToPoints: function (data, stack) {
  22985. return data.mapArray(['x', 'y'], function (x, y) {
  22986. return this.dataToPoint([x, y]);
  22987. }, stack, this);
  22988. },
  22989. /**
  22990. * @param {Array.<number>} data
  22991. * @param {boolean} [clamp=false]
  22992. * @return {Array.<number>}
  22993. */
  22994. dataToPoint: function (data, clamp) {
  22995. var xAxis = this.getAxis('x');
  22996. var yAxis = this.getAxis('y');
  22997. return [
  22998. xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)),
  22999. yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp))
  23000. ];
  23001. },
  23002. /**
  23003. * @param {Array.<number>} point
  23004. * @param {boolean} [clamp=false]
  23005. * @return {Array.<number>}
  23006. */
  23007. pointToData: function (point, clamp) {
  23008. var xAxis = this.getAxis('x');
  23009. var yAxis = this.getAxis('y');
  23010. return [
  23011. xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp),
  23012. yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp)
  23013. ];
  23014. },
  23015. /**
  23016. * Get other axis
  23017. * @param {module:echarts/coord/cartesian/Axis2D} axis
  23018. */
  23019. getOtherAxis: function (axis) {
  23020. return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
  23021. }
  23022. };
  23023. zrUtil.inherits(Cartesian2D, Cartesian);
  23024. module.exports = Cartesian2D;
  23025. /***/ },
  23026. /* 122 */
  23027. /***/ function(module, exports, __webpack_require__) {
  23028. 'use strict';
  23029. /**
  23030. * Cartesian coordinate system
  23031. * @module echarts/coord/Cartesian
  23032. *
  23033. */
  23034. var zrUtil = __webpack_require__(4);
  23035. function dimAxisMapper(dim) {
  23036. return this._axes[dim];
  23037. }
  23038. /**
  23039. * @alias module:echarts/coord/Cartesian
  23040. * @constructor
  23041. */
  23042. var Cartesian = function (name) {
  23043. this._axes = {};
  23044. this._dimList = [];
  23045. /**
  23046. * @type {string}
  23047. */
  23048. this.name = name || '';
  23049. };
  23050. Cartesian.prototype = {
  23051. constructor: Cartesian,
  23052. type: 'cartesian',
  23053. /**
  23054. * Get axis
  23055. * @param {number|string} dim
  23056. * @return {module:echarts/coord/Cartesian~Axis}
  23057. */
  23058. getAxis: function (dim) {
  23059. return this._axes[dim];
  23060. },
  23061. /**
  23062. * Get axes list
  23063. * @return {Array.<module:echarts/coord/Cartesian~Axis>}
  23064. */
  23065. getAxes: function () {
  23066. return zrUtil.map(this._dimList, dimAxisMapper, this);
  23067. },
  23068. /**
  23069. * Get axes list by given scale type
  23070. */
  23071. getAxesByScale: function (scaleType) {
  23072. scaleType = scaleType.toLowerCase();
  23073. return zrUtil.filter(
  23074. this.getAxes(),
  23075. function (axis) {
  23076. return axis.scale.type === scaleType;
  23077. }
  23078. );
  23079. },
  23080. /**
  23081. * Add axis
  23082. * @param {module:echarts/coord/Cartesian.Axis}
  23083. */
  23084. addAxis: function (axis) {
  23085. var dim = axis.dim;
  23086. this._axes[dim] = axis;
  23087. this._dimList.push(dim);
  23088. },
  23089. /**
  23090. * Convert data to coord in nd space
  23091. * @param {Array.<number>|Object.<string, number>} val
  23092. * @return {Array.<number>|Object.<string, number>}
  23093. */
  23094. dataToCoord: function (val) {
  23095. return this._dataCoordConvert(val, 'dataToCoord');
  23096. },
  23097. /**
  23098. * Convert coord in nd space to data
  23099. * @param {Array.<number>|Object.<string, number>} val
  23100. * @return {Array.<number>|Object.<string, number>}
  23101. */
  23102. coordToData: function (val) {
  23103. return this._dataCoordConvert(val, 'coordToData');
  23104. },
  23105. _dataCoordConvert: function (input, method) {
  23106. var dimList = this._dimList;
  23107. var output = input instanceof Array ? [] : {};
  23108. for (var i = 0; i < dimList.length; i++) {
  23109. var dim = dimList[i];
  23110. var axis = this._axes[dim];
  23111. output[dim] = axis[method](input[dim]);
  23112. }
  23113. return output;
  23114. }
  23115. };
  23116. module.exports = Cartesian;
  23117. /***/ },
  23118. /* 123 */
  23119. /***/ function(module, exports, __webpack_require__) {
  23120. var zrUtil = __webpack_require__(4);
  23121. var Axis = __webpack_require__(124);
  23122. var axisLabelInterval = __webpack_require__(125);
  23123. /**
  23124. * Extend axis 2d
  23125. * @constructor module:echarts/coord/cartesian/Axis2D
  23126. * @extends {module:echarts/coord/cartesian/Axis}
  23127. * @param {string} dim
  23128. * @param {*} scale
  23129. * @param {Array.<number>} coordExtent
  23130. * @param {string} axisType
  23131. * @param {string} position
  23132. */
  23133. var Axis2D = function (dim, scale, coordExtent, axisType, position) {
  23134. Axis.call(this, dim, scale, coordExtent);
  23135. /**
  23136. * Axis type
  23137. * - 'category'
  23138. * - 'value'
  23139. * - 'time'
  23140. * - 'log'
  23141. * @type {string}
  23142. */
  23143. this.type = axisType || 'value';
  23144. /**
  23145. * Axis position
  23146. * - 'top'
  23147. * - 'bottom'
  23148. * - 'left'
  23149. * - 'right'
  23150. */
  23151. this.position = position || 'bottom';
  23152. };
  23153. Axis2D.prototype = {
  23154. constructor: Axis2D,
  23155. /**
  23156. * Index of axis, can be used as key
  23157. */
  23158. index: 0,
  23159. /**
  23160. * If axis is on the zero position of the other axis
  23161. * @type {boolean}
  23162. */
  23163. onZero: false,
  23164. /**
  23165. * Axis model
  23166. * @param {module:echarts/coord/cartesian/AxisModel}
  23167. */
  23168. model: null,
  23169. isHorizontal: function () {
  23170. var position = this.position;
  23171. return position === 'top' || position === 'bottom';
  23172. },
  23173. getGlobalExtent: function () {
  23174. var ret = this.getExtent();
  23175. ret[0] = this.toGlobalCoord(ret[0]);
  23176. ret[1] = this.toGlobalCoord(ret[1]);
  23177. return ret;
  23178. },
  23179. /**
  23180. * @return {number}
  23181. */
  23182. getLabelInterval: function () {
  23183. var labelInterval = this._labelInterval;
  23184. if (!labelInterval) {
  23185. labelInterval = this._labelInterval = axisLabelInterval(this);
  23186. }
  23187. return labelInterval;
  23188. },
  23189. /**
  23190. * If label is ignored.
  23191. * Automatically used when axis is category and label can not be all shown
  23192. * @param {number} idx
  23193. * @return {boolean}
  23194. */
  23195. isLabelIgnored: function (idx) {
  23196. if (this.type === 'category') {
  23197. var labelInterval = this.getLabelInterval();
  23198. return ((typeof labelInterval === 'function')
  23199. && !labelInterval(idx, this.scale.getLabel(idx)))
  23200. || idx % (labelInterval + 1);
  23201. }
  23202. },
  23203. /**
  23204. * Transform global coord to local coord,
  23205. * i.e. var localCoord = axis.toLocalCoord(80);
  23206. * designate by module:echarts/coord/cartesian/Grid.
  23207. * @type {Function}
  23208. */
  23209. toLocalCoord: null,
  23210. /**
  23211. * Transform global coord to local coord,
  23212. * i.e. var globalCoord = axis.toLocalCoord(40);
  23213. * designate by module:echarts/coord/cartesian/Grid.
  23214. * @type {Function}
  23215. */
  23216. toGlobalCoord: null
  23217. };
  23218. zrUtil.inherits(Axis2D, Axis);
  23219. module.exports = Axis2D;
  23220. /***/ },
  23221. /* 124 */
  23222. /***/ function(module, exports, __webpack_require__) {
  23223. var numberUtil = __webpack_require__(7);
  23224. var linearMap = numberUtil.linearMap;
  23225. var zrUtil = __webpack_require__(4);
  23226. function fixExtentWithBands(extent, nTick) {
  23227. var size = extent[1] - extent[0];
  23228. var len = nTick;
  23229. var margin = size / len / 2;
  23230. extent[0] += margin;
  23231. extent[1] -= margin;
  23232. }
  23233. var normalizedExtent = [0, 1];
  23234. /**
  23235. * @name module:echarts/coord/CartesianAxis
  23236. * @constructor
  23237. */
  23238. var Axis = function (dim, scale, extent) {
  23239. /**
  23240. * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'
  23241. * @type {string}
  23242. */
  23243. this.dim = dim;
  23244. /**
  23245. * Axis scale
  23246. * @type {module:echarts/coord/scale/*}
  23247. */
  23248. this.scale = scale;
  23249. /**
  23250. * @type {Array.<number>}
  23251. * @private
  23252. */
  23253. this._extent = extent || [0, 0];
  23254. /**
  23255. * @type {boolean}
  23256. */
  23257. this.inverse = false;
  23258. /**
  23259. * Usually true when axis has a ordinal scale
  23260. * @type {boolean}
  23261. */
  23262. this.onBand = false;
  23263. };
  23264. Axis.prototype = {
  23265. constructor: Axis,
  23266. /**
  23267. * If axis extent contain given coord
  23268. * @param {number} coord
  23269. * @return {boolean}
  23270. */
  23271. contain: function (coord) {
  23272. var extent = this._extent;
  23273. var min = Math.min(extent[0], extent[1]);
  23274. var max = Math.max(extent[0], extent[1]);
  23275. return coord >= min && coord <= max;
  23276. },
  23277. /**
  23278. * If axis extent contain given data
  23279. * @param {number} data
  23280. * @return {boolean}
  23281. */
  23282. containData: function (data) {
  23283. return this.contain(this.dataToCoord(data));
  23284. },
  23285. /**
  23286. * Get coord extent.
  23287. * @return {Array.<number>}
  23288. */
  23289. getExtent: function () {
  23290. var ret = this._extent.slice();
  23291. return ret;
  23292. },
  23293. /**
  23294. * Get precision used for formatting
  23295. * @param {Array.<number>} [dataExtent]
  23296. * @return {number}
  23297. */
  23298. getPixelPrecision: function (dataExtent) {
  23299. return numberUtil.getPixelPrecision(
  23300. dataExtent || this.scale.getExtent(),
  23301. this._extent
  23302. );
  23303. },
  23304. /**
  23305. * Set coord extent
  23306. * @param {number} start
  23307. * @param {number} end
  23308. */
  23309. setExtent: function (start, end) {
  23310. var extent = this._extent;
  23311. extent[0] = start;
  23312. extent[1] = end;
  23313. },
  23314. /**
  23315. * Convert data to coord. Data is the rank if it has a ordinal scale
  23316. * @param {number} data
  23317. * @param {boolean} clamp
  23318. * @return {number}
  23319. */
  23320. dataToCoord: function (data, clamp) {
  23321. var extent = this._extent;
  23322. var scale = this.scale;
  23323. data = scale.normalize(data);
  23324. if (this.onBand && scale.type === 'ordinal') {
  23325. extent = extent.slice();
  23326. fixExtentWithBands(extent, scale.count());
  23327. }
  23328. return linearMap(data, normalizedExtent, extent, clamp);
  23329. },
  23330. /**
  23331. * Convert coord to data. Data is the rank if it has a ordinal scale
  23332. * @param {number} coord
  23333. * @param {boolean} clamp
  23334. * @return {number}
  23335. */
  23336. coordToData: function (coord, clamp) {
  23337. var extent = this._extent;
  23338. var scale = this.scale;
  23339. if (this.onBand && scale.type === 'ordinal') {
  23340. extent = extent.slice();
  23341. fixExtentWithBands(extent, scale.count());
  23342. }
  23343. var t = linearMap(coord, extent, normalizedExtent, clamp);
  23344. return this.scale.scale(t);
  23345. },
  23346. /**
  23347. * @return {Array.<number>}
  23348. */
  23349. getTicksCoords: function (alignWithLabel) {
  23350. if (this.onBand && !alignWithLabel) {
  23351. var bands = this.getBands();
  23352. var coords = [];
  23353. for (var i = 0; i < bands.length; i++) {
  23354. coords.push(bands[i][0]);
  23355. }
  23356. if (bands[i - 1]) {
  23357. coords.push(bands[i - 1][1]);
  23358. }
  23359. return coords;
  23360. }
  23361. else {
  23362. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  23363. }
  23364. },
  23365. /**
  23366. * Coords of labels are on the ticks or on the middle of bands
  23367. * @return {Array.<number>}
  23368. */
  23369. getLabelsCoords: function () {
  23370. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  23371. },
  23372. /**
  23373. * Get bands.
  23374. *
  23375. * If axis has labels [1, 2, 3, 4]. Bands on the axis are
  23376. * |---1---|---2---|---3---|---4---|.
  23377. *
  23378. * @return {Array}
  23379. */
  23380. // FIXME Situation when labels is on ticks
  23381. getBands: function () {
  23382. var extent = this.getExtent();
  23383. var bands = [];
  23384. var len = this.scale.count();
  23385. var start = extent[0];
  23386. var end = extent[1];
  23387. var span = end - start;
  23388. for (var i = 0; i < len; i++) {
  23389. bands.push([
  23390. span * i / len + start,
  23391. span * (i + 1) / len + start
  23392. ]);
  23393. }
  23394. return bands;
  23395. },
  23396. /**
  23397. * Get width of band
  23398. * @return {number}
  23399. */
  23400. getBandWidth: function () {
  23401. var axisExtent = this._extent;
  23402. var dataExtent = this.scale.getExtent();
  23403. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
  23404. // Fix #2728, avoid NaN when only one data.
  23405. len === 0 && (len = 1);
  23406. var size = Math.abs(axisExtent[1] - axisExtent[0]);
  23407. return Math.abs(size) / len;
  23408. }
  23409. };
  23410. module.exports = Axis;
  23411. /***/ },
  23412. /* 125 */
  23413. /***/ function(module, exports, __webpack_require__) {
  23414. 'use strict';
  23415. /**
  23416. * Helper function for axisLabelInterval calculation
  23417. */
  23418. var zrUtil = __webpack_require__(4);
  23419. var axisHelper = __webpack_require__(115);
  23420. module.exports = function (axis) {
  23421. var axisModel = axis.model;
  23422. var labelModel = axisModel.getModel('axisLabel');
  23423. var labelInterval = labelModel.get('interval');
  23424. if (!(axis.type === 'category' && labelInterval === 'auto')) {
  23425. return labelInterval === 'auto' ? 0 : labelInterval;
  23426. }
  23427. return axisHelper.getAxisLabelInterval(
  23428. zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis),
  23429. axisModel.getFormattedLabels(),
  23430. labelModel.getModel('textStyle').getFont(),
  23431. axis.isHorizontal()
  23432. );
  23433. };
  23434. /***/ },
  23435. /* 126 */
  23436. /***/ function(module, exports, __webpack_require__) {
  23437. 'use strict';
  23438. // Grid 是在有直角坐标系的时候必须要存在的
  23439. // 所以这里也要被 Cartesian2D 依赖
  23440. __webpack_require__(127);
  23441. var ComponentModel = __webpack_require__(19);
  23442. module.exports = ComponentModel.extend({
  23443. type: 'grid',
  23444. dependencies: ['xAxis', 'yAxis'],
  23445. layoutMode: 'box',
  23446. /**
  23447. * @type {module:echarts/coord/cartesian/Grid}
  23448. */
  23449. coordinateSystem: null,
  23450. defaultOption: {
  23451. show: false,
  23452. zlevel: 0,
  23453. z: 0,
  23454. left: '10%',
  23455. top: 60,
  23456. right: '10%',
  23457. bottom: 60,
  23458. // If grid size contain label
  23459. containLabel: false,
  23460. // width: {totalWidth} - left - right,
  23461. // height: {totalHeight} - top - bottom,
  23462. backgroundColor: 'rgba(0,0,0,0)',
  23463. borderWidth: 1,
  23464. borderColor: '#ccc'
  23465. }
  23466. });
  23467. /***/ },
  23468. /* 127 */
  23469. /***/ function(module, exports, __webpack_require__) {
  23470. 'use strict';
  23471. var ComponentModel = __webpack_require__(19);
  23472. var zrUtil = __webpack_require__(4);
  23473. var axisModelCreator = __webpack_require__(128);
  23474. var AxisModel = ComponentModel.extend({
  23475. type: 'cartesian2dAxis',
  23476. /**
  23477. * @type {module:echarts/coord/cartesian/Axis2D}
  23478. */
  23479. axis: null,
  23480. /**
  23481. * @override
  23482. */
  23483. init: function () {
  23484. AxisModel.superApply(this, 'init', arguments);
  23485. this.resetRange();
  23486. },
  23487. /**
  23488. * @override
  23489. */
  23490. mergeOption: function () {
  23491. AxisModel.superApply(this, 'mergeOption', arguments);
  23492. this.resetRange();
  23493. },
  23494. /**
  23495. * @override
  23496. */
  23497. restoreData: function () {
  23498. AxisModel.superApply(this, 'restoreData', arguments);
  23499. this.resetRange();
  23500. },
  23501. /**
  23502. * @return {module:echarts/model/Model}
  23503. */
  23504. findGridModel: function () {
  23505. return this.ecModel.queryComponents({
  23506. mainType: 'grid',
  23507. index: this.get('gridIndex'),
  23508. id: this.get('gridId')
  23509. })[0];
  23510. }
  23511. });
  23512. function getAxisType(axisDim, option) {
  23513. // Default axis with data is category axis
  23514. return option.type || (option.data ? 'category' : 'value');
  23515. }
  23516. zrUtil.merge(AxisModel.prototype, __webpack_require__(130));
  23517. zrUtil.merge(AxisModel.prototype, __webpack_require__(131));
  23518. var extraOption = {
  23519. // gridIndex: 0,
  23520. // gridId: '',
  23521. // Offset is for multiple axis on the same position
  23522. offset: 0
  23523. };
  23524. axisModelCreator('x', AxisModel, getAxisType, extraOption);
  23525. axisModelCreator('y', AxisModel, getAxisType, extraOption);
  23526. module.exports = AxisModel;
  23527. /***/ },
  23528. /* 128 */
  23529. /***/ function(module, exports, __webpack_require__) {
  23530. var axisDefault = __webpack_require__(129);
  23531. var zrUtil = __webpack_require__(4);
  23532. var ComponentModel = __webpack_require__(19);
  23533. var layout = __webpack_require__(21);
  23534. // FIXME axisType is fixed ?
  23535. var AXIS_TYPES = ['value', 'category', 'time', 'log'];
  23536. /**
  23537. * Generate sub axis model class
  23538. * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel'
  23539. * @param {module:echarts/model/Component} BaseAxisModelClass
  23540. * @param {Function} axisTypeDefaulter
  23541. * @param {Object} [extraDefaultOption]
  23542. */
  23543. module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
  23544. zrUtil.each(AXIS_TYPES, function (axisType) {
  23545. BaseAxisModelClass.extend({
  23546. type: axisName + 'Axis.' + axisType,
  23547. mergeDefaultAndTheme: function (option, ecModel) {
  23548. var layoutMode = this.layoutMode;
  23549. var inputPositionParams = layoutMode
  23550. ? layout.getLayoutParams(option) : {};
  23551. var themeModel = ecModel.getTheme();
  23552. zrUtil.merge(option, themeModel.get(axisType + 'Axis'));
  23553. zrUtil.merge(option, this.getDefaultOption());
  23554. option.type = axisTypeDefaulter(axisName, option);
  23555. if (layoutMode) {
  23556. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  23557. }
  23558. },
  23559. defaultOption: zrUtil.mergeAll(
  23560. [
  23561. {},
  23562. axisDefault[axisType + 'Axis'],
  23563. extraDefaultOption
  23564. ],
  23565. true
  23566. )
  23567. });
  23568. });
  23569. ComponentModel.registerSubTypeDefaulter(
  23570. axisName + 'Axis',
  23571. zrUtil.curry(axisTypeDefaulter, axisName)
  23572. );
  23573. };
  23574. /***/ },
  23575. /* 129 */
  23576. /***/ function(module, exports, __webpack_require__) {
  23577. var zrUtil = __webpack_require__(4);
  23578. var defaultOption = {
  23579. show: true,
  23580. zlevel: 0, // 一级层叠
  23581. z: 0, // 二级层叠
  23582. // 反向坐标轴
  23583. inverse: false,
  23584. // 坐标轴名字,默认为空
  23585. name: '',
  23586. // 坐标轴名字位置,支持'start' | 'middle' | 'end'
  23587. nameLocation: 'end',
  23588. // 坐标轴名字旋转,degree。
  23589. nameRotate: null, // Adapt to axis rotate, when nameLocation is 'middle'.
  23590. nameTruncate: {
  23591. maxWidth: null,
  23592. ellipsis: '...',
  23593. placeholder: '.'
  23594. },
  23595. // 坐标轴文字样式,默认取全局样式
  23596. nameTextStyle: {},
  23597. // 文字与轴线距离
  23598. nameGap: 15,
  23599. silent: false, // Default false to support tooltip.
  23600. triggerEvent: false, // Default false to avoid legacy user event listener fail.
  23601. tooltip: {
  23602. show: false
  23603. },
  23604. // 坐标轴线
  23605. axisLine: {
  23606. // 默认显示,属性show控制显示与否
  23607. show: true,
  23608. onZero: true,
  23609. // 属性lineStyle控制线条样式
  23610. lineStyle: {
  23611. color: '#333',
  23612. width: 1,
  23613. type: 'solid'
  23614. }
  23615. },
  23616. // 坐标轴小标记
  23617. axisTick: {
  23618. // 属性show控制显示与否,默认显示
  23619. show: true,
  23620. // 控制小标记是否在grid里
  23621. inside: false,
  23622. // 属性length控制线长
  23623. length: 5,
  23624. // 属性lineStyle控制线条样式
  23625. lineStyle: {
  23626. width: 1
  23627. }
  23628. },
  23629. // 坐标轴文本标签,详见axis.axisLabel
  23630. axisLabel: {
  23631. show: true,
  23632. // 控制文本标签是否在grid里
  23633. inside: false,
  23634. rotate: 0,
  23635. margin: 8,
  23636. // formatter: null,
  23637. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  23638. textStyle: {
  23639. fontSize: 12
  23640. }
  23641. },
  23642. // 分隔线
  23643. splitLine: {
  23644. // 默认显示,属性show控制显示与否
  23645. show: true,
  23646. // 属性lineStyle(详见lineStyle)控制线条样式
  23647. lineStyle: {
  23648. color: ['#ccc'],
  23649. width: 1,
  23650. type: 'solid'
  23651. }
  23652. },
  23653. // 分隔区域
  23654. splitArea: {
  23655. // 默认不显示,属性show控制显示与否
  23656. show: false,
  23657. // 属性areaStyle(详见areaStyle)控制区域样式
  23658. areaStyle: {
  23659. color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)']
  23660. }
  23661. }
  23662. };
  23663. var categoryAxis = zrUtil.merge({
  23664. // 类目起始和结束两端空白策略
  23665. boundaryGap: true,
  23666. // splitArea: {
  23667. // show: false
  23668. // },
  23669. splitLine: {
  23670. show: false
  23671. },
  23672. // 坐标轴小标记
  23673. axisTick: {
  23674. // If tick is align with label when boundaryGap is true
  23675. // Default with axisTick
  23676. alignWithLabel: false,
  23677. interval: 'auto'
  23678. },
  23679. // 坐标轴文本标签,详见axis.axisLabel
  23680. axisLabel: {
  23681. interval: 'auto'
  23682. }
  23683. }, defaultOption);
  23684. var valueAxis = zrUtil.merge({
  23685. // 数值起始和结束两端空白策略
  23686. boundaryGap: [0, 0],
  23687. // 最小值, 设置成 'dataMin' 则从数据中计算最小值
  23688. // min: null,
  23689. // 最大值,设置成 'dataMax' 则从数据中计算最大值
  23690. // max: null,
  23691. // Readonly prop, specifies start value of the range when using data zoom.
  23692. // rangeStart: null
  23693. // Readonly prop, specifies end value of the range when using data zoom.
  23694. // rangeEnd: null
  23695. // 脱离0值比例,放大聚焦到最终_min,_max区间
  23696. // scale: false,
  23697. // 分割段数,默认为5
  23698. splitNumber: 5
  23699. // Minimum interval
  23700. // minInterval: null
  23701. }, defaultOption);
  23702. // FIXME
  23703. var timeAxis = zrUtil.defaults({
  23704. scale: true,
  23705. min: 'dataMin',
  23706. max: 'dataMax'
  23707. }, valueAxis);
  23708. var logAxis = zrUtil.defaults({
  23709. logBase: 10
  23710. }, valueAxis);
  23711. logAxis.scale = true;
  23712. module.exports = {
  23713. categoryAxis: categoryAxis,
  23714. valueAxis: valueAxis,
  23715. timeAxis: timeAxis,
  23716. logAxis: logAxis
  23717. };
  23718. /***/ },
  23719. /* 130 */
  23720. /***/ function(module, exports, __webpack_require__) {
  23721. var zrUtil = __webpack_require__(4);
  23722. var axisHelper = __webpack_require__(115);
  23723. function getName(obj) {
  23724. if (zrUtil.isObject(obj) && obj.value != null) {
  23725. return obj.value;
  23726. }
  23727. else {
  23728. return obj;
  23729. }
  23730. }
  23731. /**
  23732. * Get categories
  23733. */
  23734. function getCategories() {
  23735. return this.get('type') === 'category'
  23736. && zrUtil.map(this.get('data'), getName);
  23737. }
  23738. /**
  23739. * Format labels
  23740. * @return {Array.<string>}
  23741. */
  23742. function getFormattedLabels() {
  23743. return axisHelper.getFormattedLabels(
  23744. this.axis,
  23745. this.get('axisLabel.formatter')
  23746. );
  23747. }
  23748. module.exports = {
  23749. getFormattedLabels: getFormattedLabels,
  23750. getCategories: getCategories
  23751. };
  23752. /***/ },
  23753. /* 131 */
  23754. /***/ function(module, exports) {
  23755. module.exports = {
  23756. /**
  23757. * @public
  23758. * @return {Array.<number|string|Date>}
  23759. */
  23760. getMin: function () {
  23761. var option = this.option;
  23762. var min = option.rangeStart != null ? option.rangeStart : option.min;
  23763. // In case of axis.type === 'time', Date should be converted to timestamp.
  23764. // In other cases, min/max should be a number or null/undefined or 'dataMin/Max'.
  23765. if (min instanceof Date) {
  23766. min = +min;
  23767. }
  23768. return min;
  23769. },
  23770. /**
  23771. * @public
  23772. * @return {Array.<number|string|Date>}
  23773. */
  23774. getMax: function () {
  23775. var option = this.option;
  23776. var max = option.rangeEnd != null ? option.rangeEnd : option.max;
  23777. // In case of axis.type === 'time', Date should be converted to timestamp.
  23778. // In other cases, min/max should be a number or null/undefined or 'dataMin/Max'.
  23779. if (max instanceof Date) {
  23780. max = +max;
  23781. }
  23782. return max;
  23783. },
  23784. /**
  23785. * @public
  23786. * @return {boolean}
  23787. */
  23788. getNeedCrossZero: function () {
  23789. var option = this.option;
  23790. return (option.rangeStart != null || option.rangeEnd != null)
  23791. ? false : !option.scale;
  23792. },
  23793. /**
  23794. * @public
  23795. * @param {number} rangeStart
  23796. * @param {number} rangeEnd
  23797. */
  23798. setRange: function (rangeStart, rangeEnd) {
  23799. this.option.rangeStart = rangeStart;
  23800. this.option.rangeEnd = rangeEnd;
  23801. },
  23802. /**
  23803. * @public
  23804. */
  23805. resetRange: function () {
  23806. // rangeStart and rangeEnd is readonly.
  23807. this.option.rangeStart = this.option.rangeEnd = null;
  23808. }
  23809. };
  23810. /***/ },
  23811. /* 132 */
  23812. /***/ function(module, exports, __webpack_require__) {
  23813. 'use strict';
  23814. // TODO boundaryGap
  23815. __webpack_require__(127);
  23816. __webpack_require__(133);
  23817. /***/ },
  23818. /* 133 */
  23819. /***/ function(module, exports, __webpack_require__) {
  23820. var zrUtil = __webpack_require__(4);
  23821. var graphic = __webpack_require__(43);
  23822. var AxisBuilder = __webpack_require__(134);
  23823. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  23824. var getInterval = AxisBuilder.getInterval;
  23825. var axisBuilderAttrs = [
  23826. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  23827. ];
  23828. var selfBuilderAttrs = [
  23829. 'splitArea', 'splitLine'
  23830. ];
  23831. // function getAlignWithLabel(model, axisModel) {
  23832. // var alignWithLabel = model.get('alignWithLabel');
  23833. // if (alignWithLabel === 'auto') {
  23834. // alignWithLabel = axisModel.get('axisTick.alignWithLabel');
  23835. // }
  23836. // return alignWithLabel;
  23837. // }
  23838. var AxisView = __webpack_require__(1).extendComponentView({
  23839. type: 'axis',
  23840. render: function (axisModel, ecModel) {
  23841. this.group.removeAll();
  23842. var oldAxisGroup = this._axisGroup;
  23843. this._axisGroup = new graphic.Group();
  23844. this.group.add(this._axisGroup);
  23845. if (!axisModel.get('show')) {
  23846. return;
  23847. }
  23848. var gridModel = axisModel.findGridModel();
  23849. var layout = layoutAxis(gridModel, axisModel);
  23850. var axisBuilder = new AxisBuilder(axisModel, layout);
  23851. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  23852. this._axisGroup.add(axisBuilder.getGroup());
  23853. zrUtil.each(selfBuilderAttrs, function (name) {
  23854. if (axisModel.get(name + '.show')) {
  23855. this['_' + name](axisModel, gridModel, layout.labelInterval);
  23856. }
  23857. }, this);
  23858. graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  23859. },
  23860. /**
  23861. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  23862. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  23863. * @param {number|Function} labelInterval
  23864. * @private
  23865. */
  23866. _splitLine: function (axisModel, gridModel, labelInterval) {
  23867. var axis = axisModel.axis;
  23868. var splitLineModel = axisModel.getModel('splitLine');
  23869. var lineStyleModel = splitLineModel.getModel('lineStyle');
  23870. var lineColors = lineStyleModel.get('color');
  23871. var lineInterval = getInterval(splitLineModel, labelInterval);
  23872. lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];
  23873. var gridRect = gridModel.coordinateSystem.getRect();
  23874. var isHorizontal = axis.isHorizontal();
  23875. var lineCount = 0;
  23876. var ticksCoords = axis.getTicksCoords(
  23877. // splitLineModel.get('alignWithLabel')
  23878. );
  23879. var ticks = axis.scale.getTicks();
  23880. var p1 = [];
  23881. var p2 = [];
  23882. // Simple optimization
  23883. // Batching the lines if color are the same
  23884. var lineStyle = lineStyleModel.getLineStyle();
  23885. for (var i = 0; i < ticksCoords.length; i++) {
  23886. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  23887. continue;
  23888. }
  23889. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  23890. if (isHorizontal) {
  23891. p1[0] = tickCoord;
  23892. p1[1] = gridRect.y;
  23893. p2[0] = tickCoord;
  23894. p2[1] = gridRect.y + gridRect.height;
  23895. }
  23896. else {
  23897. p1[0] = gridRect.x;
  23898. p1[1] = tickCoord;
  23899. p2[0] = gridRect.x + gridRect.width;
  23900. p2[1] = tickCoord;
  23901. }
  23902. var colorIndex = (lineCount++) % lineColors.length;
  23903. this._axisGroup.add(new graphic.Line(graphic.subPixelOptimizeLine({
  23904. anid: 'line_' + ticks[i],
  23905. shape: {
  23906. x1: p1[0],
  23907. y1: p1[1],
  23908. x2: p2[0],
  23909. y2: p2[1]
  23910. },
  23911. style: zrUtil.defaults({
  23912. stroke: lineColors[colorIndex]
  23913. }, lineStyle),
  23914. silent: true
  23915. })));
  23916. }
  23917. },
  23918. /**
  23919. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  23920. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  23921. * @param {number|Function} labelInterval
  23922. * @private
  23923. */
  23924. _splitArea: function (axisModel, gridModel, labelInterval) {
  23925. var axis = axisModel.axis;
  23926. var splitAreaModel = axisModel.getModel('splitArea');
  23927. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  23928. var areaColors = areaStyleModel.get('color');
  23929. var gridRect = gridModel.coordinateSystem.getRect();
  23930. var ticksCoords = axis.getTicksCoords(
  23931. // splitAreaModel.get('alignWithLabel')
  23932. );
  23933. var ticks = axis.scale.getTicks();
  23934. var prevX = axis.toGlobalCoord(ticksCoords[0]);
  23935. var prevY = axis.toGlobalCoord(ticksCoords[0]);
  23936. var count = 0;
  23937. var areaInterval = getInterval(splitAreaModel, labelInterval);
  23938. var areaStyle = areaStyleModel.getAreaStyle();
  23939. areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
  23940. for (var i = 1; i < ticksCoords.length; i++) {
  23941. if (ifIgnoreOnTick(axis, i, areaInterval)) {
  23942. continue;
  23943. }
  23944. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  23945. var x;
  23946. var y;
  23947. var width;
  23948. var height;
  23949. if (axis.isHorizontal()) {
  23950. x = prevX;
  23951. y = gridRect.y;
  23952. width = tickCoord - x;
  23953. height = gridRect.height;
  23954. }
  23955. else {
  23956. x = gridRect.x;
  23957. y = prevY;
  23958. width = gridRect.width;
  23959. height = tickCoord - y;
  23960. }
  23961. var colorIndex = (count++) % areaColors.length;
  23962. this._axisGroup.add(new graphic.Rect({
  23963. anid: 'area_' + ticks[i],
  23964. shape: {
  23965. x: x,
  23966. y: y,
  23967. width: width,
  23968. height: height
  23969. },
  23970. style: zrUtil.defaults({
  23971. fill: areaColors[colorIndex]
  23972. }, areaStyle),
  23973. silent: true
  23974. }));
  23975. prevX = x + width;
  23976. prevY = y + height;
  23977. }
  23978. }
  23979. });
  23980. AxisView.extend({
  23981. type: 'xAxis'
  23982. });
  23983. AxisView.extend({
  23984. type: 'yAxis'
  23985. });
  23986. /**
  23987. * @inner
  23988. */
  23989. function layoutAxis(gridModel, axisModel) {
  23990. var grid = gridModel.coordinateSystem;
  23991. var axis = axisModel.axis;
  23992. var layout = {};
  23993. var rawAxisPosition = axis.position;
  23994. var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition;
  23995. var axisDim = axis.dim;
  23996. // [left, right, top, bottom]
  23997. var rect = grid.getRect();
  23998. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  23999. var axisOffset = axisModel.get('offset') || 0;
  24000. var posMap = {
  24001. x: { top: rectBound[2] - axisOffset, bottom: rectBound[3] + axisOffset },
  24002. y: { left: rectBound[0] - axisOffset, right: rectBound[1] + axisOffset }
  24003. };
  24004. posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top);
  24005. posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left);
  24006. function getZero(dim, val) {
  24007. var theAxis = grid.getAxis(dim);
  24008. return theAxis.toGlobalCoord(theAxis.dataToCoord(0));
  24009. }
  24010. // Axis position
  24011. layout.position = [
  24012. axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0],
  24013. axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3]
  24014. ];
  24015. // Axis rotation
  24016. layout.rotation = Math.PI / 2 * (axisDim === 'x' ? 0 : 1);
  24017. // Tick and label direction, x y is axisDim
  24018. var dirMap = {top: -1, bottom: 1, left: -1, right: 1};
  24019. layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition];
  24020. if (axis.onZero) {
  24021. layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero;
  24022. }
  24023. if (axisModel.getModel('axisTick').get('inside')) {
  24024. layout.tickDirection = -layout.tickDirection;
  24025. }
  24026. if (axisModel.getModel('axisLabel').get('inside')) {
  24027. layout.labelDirection = -layout.labelDirection;
  24028. }
  24029. // Special label rotation
  24030. var labelRotation = axisModel.getModel('axisLabel').get('rotate');
  24031. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  24032. // label interval when auto mode.
  24033. layout.labelInterval = axis.getLabelInterval();
  24034. // Over splitLine and splitArea
  24035. layout.z2 = 1;
  24036. return layout;
  24037. }
  24038. /***/ },
  24039. /* 134 */
  24040. /***/ function(module, exports, __webpack_require__) {
  24041. var zrUtil = __webpack_require__(4);
  24042. var formatUtil = __webpack_require__(6);
  24043. var graphic = __webpack_require__(43);
  24044. var Model = __webpack_require__(12);
  24045. var numberUtil = __webpack_require__(7);
  24046. var remRadian = numberUtil.remRadian;
  24047. var isRadianAroundZero = numberUtil.isRadianAroundZero;
  24048. var vec2 = __webpack_require__(10);
  24049. var v2ApplyTransform = vec2.applyTransform;
  24050. var retrieve = zrUtil.retrieve;
  24051. var PI = Math.PI;
  24052. function makeAxisEventDataBase(axisModel) {
  24053. var eventData = {
  24054. componentType: axisModel.mainType
  24055. };
  24056. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex;
  24057. return eventData;
  24058. }
  24059. /**
  24060. * A final axis is translated and rotated from a "standard axis".
  24061. * So opt.position and opt.rotation is required.
  24062. *
  24063. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  24064. * for example: (0, 0) ------------> (0, 50)
  24065. *
  24066. * nameDirection or tickDirection or labelDirection is 1 means tick
  24067. * or label is below the standard axis, whereas is -1 means above
  24068. * the standard axis. labelOffset means offset between label and axis,
  24069. * which is useful when 'onZero', where axisLabel is in the grid and
  24070. * label in outside grid.
  24071. *
  24072. * Tips: like always,
  24073. * positive rotation represents anticlockwise, and negative rotation
  24074. * represents clockwise.
  24075. * The direction of position coordinate is the same as the direction
  24076. * of screen coordinate.
  24077. *
  24078. * Do not need to consider axis 'inverse', which is auto processed by
  24079. * axis extent.
  24080. *
  24081. * @param {module:zrender/container/Group} group
  24082. * @param {Object} axisModel
  24083. * @param {Object} opt Standard axis parameters.
  24084. * @param {Array.<number>} opt.position [x, y]
  24085. * @param {number} opt.rotation by radian
  24086. * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
  24087. * @param {number} [opt.tickDirection=1] 1 or -1
  24088. * @param {number} [opt.labelDirection=1] 1 or -1
  24089. * @param {number} [opt.labelOffset=0] Usefull when onZero.
  24090. * @param {string} [opt.axisLabelShow] default get from axisModel.
  24091. * @param {string} [opt.axisName] default get from axisModel.
  24092. * @param {number} [opt.axisNameAvailableWidth]
  24093. * @param {number} [opt.labelRotation] by degree, default get from axisModel.
  24094. * @param {number} [opt.labelInterval] Default label interval when label
  24095. * interval from model is null or 'auto'.
  24096. * @param {number} [opt.strokeContainThreshold] Default label interval when label
  24097. */
  24098. var AxisBuilder = function (axisModel, opt) {
  24099. /**
  24100. * @readOnly
  24101. */
  24102. this.opt = opt;
  24103. /**
  24104. * @readOnly
  24105. */
  24106. this.axisModel = axisModel;
  24107. // Default value
  24108. zrUtil.defaults(
  24109. opt,
  24110. {
  24111. labelOffset: 0,
  24112. nameDirection: 1,
  24113. tickDirection: 1,
  24114. labelDirection: 1,
  24115. silent: true
  24116. }
  24117. );
  24118. /**
  24119. * @readOnly
  24120. */
  24121. this.group = new graphic.Group();
  24122. // FIXME Not use a seperate text group?
  24123. var dumbGroup = new graphic.Group({
  24124. position: opt.position.slice(),
  24125. rotation: opt.rotation
  24126. });
  24127. // this.group.add(dumbGroup);
  24128. // this._dumbGroup = dumbGroup;
  24129. dumbGroup.updateTransform();
  24130. this._transform = dumbGroup.transform;
  24131. this._dumbGroup = dumbGroup;
  24132. };
  24133. AxisBuilder.prototype = {
  24134. constructor: AxisBuilder,
  24135. hasBuilder: function (name) {
  24136. return !!builders[name];
  24137. },
  24138. add: function (name) {
  24139. builders[name].call(this);
  24140. },
  24141. getGroup: function () {
  24142. return this.group;
  24143. }
  24144. };
  24145. var builders = {
  24146. /**
  24147. * @private
  24148. */
  24149. axisLine: function () {
  24150. var opt = this.opt;
  24151. var axisModel = this.axisModel;
  24152. if (!axisModel.get('axisLine.show')) {
  24153. return;
  24154. }
  24155. var extent = this.axisModel.axis.getExtent();
  24156. var matrix = this._transform;
  24157. var pt1 = [extent[0], 0];
  24158. var pt2 = [extent[1], 0];
  24159. if (matrix) {
  24160. v2ApplyTransform(pt1, pt1, matrix);
  24161. v2ApplyTransform(pt2, pt2, matrix);
  24162. }
  24163. this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
  24164. // Id for animation
  24165. anid: 'line',
  24166. shape: {
  24167. x1: pt1[0],
  24168. y1: pt1[1],
  24169. x2: pt2[0],
  24170. y2: pt2[1]
  24171. },
  24172. style: zrUtil.extend(
  24173. {lineCap: 'round'},
  24174. axisModel.getModel('axisLine.lineStyle').getLineStyle()
  24175. ),
  24176. strokeContainThreshold: opt.strokeContainThreshold || 5,
  24177. silent: true,
  24178. z2: 1
  24179. })));
  24180. },
  24181. /**
  24182. * @private
  24183. */
  24184. axisTick: function () {
  24185. var axisModel = this.axisModel;
  24186. if (!axisModel.get('axisTick.show')) {
  24187. return;
  24188. }
  24189. var axis = axisModel.axis;
  24190. var tickModel = axisModel.getModel('axisTick');
  24191. var opt = this.opt;
  24192. var lineStyleModel = tickModel.getModel('lineStyle');
  24193. var tickLen = tickModel.get('length');
  24194. var tickInterval = getInterval(tickModel, opt.labelInterval);
  24195. var ticksCoords = axis.getTicksCoords(tickModel.get('alignWithLabel'));
  24196. var ticks = axis.scale.getTicks();
  24197. var pt1 = [];
  24198. var pt2 = [];
  24199. var matrix = this._transform;
  24200. for (var i = 0; i < ticksCoords.length; i++) {
  24201. // Only ordinal scale support tick interval
  24202. if (ifIgnoreOnTick(axis, i, tickInterval)) {
  24203. continue;
  24204. }
  24205. var tickCoord = ticksCoords[i];
  24206. pt1[0] = tickCoord;
  24207. pt1[1] = 0;
  24208. pt2[0] = tickCoord;
  24209. pt2[1] = opt.tickDirection * tickLen;
  24210. if (matrix) {
  24211. v2ApplyTransform(pt1, pt1, matrix);
  24212. v2ApplyTransform(pt2, pt2, matrix);
  24213. }
  24214. // Tick line, Not use group transform to have better line draw
  24215. this.group.add(new graphic.Line(graphic.subPixelOptimizeLine({
  24216. // Id for animation
  24217. anid: 'tick_' + ticks[i],
  24218. shape: {
  24219. x1: pt1[0],
  24220. y1: pt1[1],
  24221. x2: pt2[0],
  24222. y2: pt2[1]
  24223. },
  24224. style: zrUtil.defaults(
  24225. lineStyleModel.getLineStyle(),
  24226. {
  24227. stroke: axisModel.get('axisLine.lineStyle.color')
  24228. }
  24229. ),
  24230. z2: 2,
  24231. silent: true
  24232. })));
  24233. }
  24234. },
  24235. /**
  24236. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  24237. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  24238. * @private
  24239. */
  24240. axisLabel: function () {
  24241. var opt = this.opt;
  24242. var axisModel = this.axisModel;
  24243. var show = retrieve(opt.axisLabelShow, axisModel.get('axisLabel.show'));
  24244. if (!show) {
  24245. return;
  24246. }
  24247. var axis = axisModel.axis;
  24248. var labelModel = axisModel.getModel('axisLabel');
  24249. var textStyleModel = labelModel.getModel('textStyle');
  24250. var labelMargin = labelModel.get('margin');
  24251. var ticks = axis.scale.getTicks();
  24252. var labels = axisModel.getFormattedLabels();
  24253. // Special label rotate.
  24254. var labelRotation = retrieve(opt.labelRotation, labelModel.get('rotate')) || 0;
  24255. // To radian.
  24256. labelRotation = labelRotation * PI / 180;
  24257. var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection);
  24258. var categoryData = axisModel.get('data');
  24259. var textEls = [];
  24260. var silent = isSilent(axisModel);
  24261. var triggerEvent = axisModel.get('triggerEvent');
  24262. zrUtil.each(ticks, function (tickVal, index) {
  24263. if (ifIgnoreOnTick(axis, index, opt.labelInterval)) {
  24264. return;
  24265. }
  24266. var itemTextStyleModel = textStyleModel;
  24267. if (categoryData && categoryData[tickVal] && categoryData[tickVal].textStyle) {
  24268. itemTextStyleModel = new Model(
  24269. categoryData[tickVal].textStyle, textStyleModel, axisModel.ecModel
  24270. );
  24271. }
  24272. var textColor = itemTextStyleModel.getTextColor()
  24273. || axisModel.get('axisLine.lineStyle.color');
  24274. var tickCoord = axis.dataToCoord(tickVal);
  24275. var pos = [
  24276. tickCoord,
  24277. opt.labelOffset + opt.labelDirection * labelMargin
  24278. ];
  24279. var labelBeforeFormat = axis.scale.getLabel(tickVal);
  24280. var textEl = new graphic.Text({
  24281. // Id for animation
  24282. anid: 'label_' + tickVal,
  24283. style: {
  24284. text: labels[index],
  24285. textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign,
  24286. textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.verticalAlign,
  24287. textFont: itemTextStyleModel.getFont(),
  24288. fill: typeof textColor === 'function' ? textColor(labelBeforeFormat) : textColor
  24289. },
  24290. position: pos,
  24291. rotation: labelLayout.rotation,
  24292. silent: silent,
  24293. z2: 10
  24294. });
  24295. // Pack data for mouse event
  24296. if (triggerEvent) {
  24297. textEl.eventData = makeAxisEventDataBase(axisModel);
  24298. textEl.eventData.targetType = 'axisLabel';
  24299. textEl.eventData.value = labelBeforeFormat;
  24300. }
  24301. // FIXME
  24302. this._dumbGroup.add(textEl);
  24303. textEl.updateTransform();
  24304. textEls.push(textEl);
  24305. this.group.add(textEl);
  24306. textEl.decomposeTransform();
  24307. }, this);
  24308. function isTwoLabelOverlapped(current, next) {
  24309. var firstRect = current && current.getBoundingRect().clone();
  24310. var nextRect = next && next.getBoundingRect().clone();
  24311. if (firstRect && nextRect) {
  24312. firstRect.applyTransform(current.getLocalTransform());
  24313. nextRect.applyTransform(next.getLocalTransform());
  24314. return firstRect.intersect(nextRect);
  24315. }
  24316. }
  24317. if (axis.type !== 'category') {
  24318. // If min or max are user set, we need to check
  24319. // If the tick on min(max) are overlap on their neighbour tick
  24320. // If they are overlapped, we need to hide the min(max) tick label
  24321. if (axisModel.getMin ? axisModel.getMin() : axisModel.get('min')) {
  24322. var firstLabel = textEls[0];
  24323. var nextLabel = textEls[1];
  24324. if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
  24325. firstLabel.ignore = true;
  24326. }
  24327. }
  24328. if (axisModel.getMax ? axisModel.getMax() : axisModel.get('max')) {
  24329. var lastLabel = textEls[textEls.length - 1];
  24330. var prevLabel = textEls[textEls.length - 2];
  24331. if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
  24332. lastLabel.ignore = true;
  24333. }
  24334. }
  24335. }
  24336. },
  24337. /**
  24338. * @private
  24339. */
  24340. axisName: function () {
  24341. var opt = this.opt;
  24342. var axisModel = this.axisModel;
  24343. var name = retrieve(opt.axisName, axisModel.get('name'));
  24344. if (!name) {
  24345. return;
  24346. }
  24347. var nameLocation = axisModel.get('nameLocation');
  24348. var nameDirection = opt.nameDirection;
  24349. var textStyleModel = axisModel.getModel('nameTextStyle');
  24350. var gap = axisModel.get('nameGap') || 0;
  24351. var extent = this.axisModel.axis.getExtent();
  24352. var gapSignal = extent[0] > extent[1] ? -1 : 1;
  24353. var pos = [
  24354. nameLocation === 'start'
  24355. ? extent[0] - gapSignal * gap
  24356. : nameLocation === 'end'
  24357. ? extent[1] + gapSignal * gap
  24358. : (extent[0] + extent[1]) / 2, // 'middle'
  24359. // Reuse labelOffset.
  24360. nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0
  24361. ];
  24362. var labelLayout;
  24363. var nameRotation = axisModel.get('nameRotate');
  24364. if (nameRotation != null) {
  24365. nameRotation = nameRotation * PI / 180; // To radian.
  24366. }
  24367. var axisNameAvailableWidth;
  24368. if (nameLocation === 'middle') {
  24369. labelLayout = innerTextLayout(
  24370. opt,
  24371. nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
  24372. nameDirection
  24373. );
  24374. }
  24375. else {
  24376. labelLayout = endTextLayout(
  24377. opt, nameLocation, nameRotation || 0, extent
  24378. );
  24379. axisNameAvailableWidth = opt.axisNameAvailableWidth;
  24380. if (axisNameAvailableWidth != null) {
  24381. axisNameAvailableWidth = Math.abs(
  24382. axisNameAvailableWidth / Math.sin(labelLayout.rotation)
  24383. );
  24384. !isFinite(axisNameAvailableWidth) && (axisNameAvailableWidth = null);
  24385. }
  24386. }
  24387. var textFont = textStyleModel.getFont();
  24388. var truncateOpt = axisModel.get('nameTruncate', true) || {};
  24389. var ellipsis = truncateOpt.ellipsis;
  24390. var maxWidth = retrieve(truncateOpt.maxWidth, axisNameAvailableWidth);
  24391. var truncatedText = (ellipsis != null && maxWidth != null)
  24392. ? formatUtil.truncateText(
  24393. name, maxWidth, textFont, ellipsis,
  24394. {minChar: 2, placeholder: truncateOpt.placeholder}
  24395. )
  24396. : name;
  24397. var tooltipOpt = axisModel.get('tooltip', true);
  24398. var mainType = axisModel.mainType;
  24399. var formatterParams = {
  24400. componentType: mainType,
  24401. name: name,
  24402. $vars: ['name']
  24403. };
  24404. formatterParams[mainType + 'Index'] = axisModel.componentIndex;
  24405. var textEl = new graphic.Text({
  24406. // Id for animation
  24407. anid: 'name',
  24408. __fullText: name,
  24409. __truncatedText: truncatedText,
  24410. style: {
  24411. text: truncatedText,
  24412. textFont: textFont,
  24413. fill: textStyleModel.getTextColor()
  24414. || axisModel.get('axisLine.lineStyle.color'),
  24415. textAlign: labelLayout.textAlign,
  24416. textVerticalAlign: labelLayout.verticalAlign
  24417. },
  24418. position: pos,
  24419. rotation: labelLayout.rotation,
  24420. silent: isSilent(axisModel),
  24421. z2: 1,
  24422. tooltip: (tooltipOpt && tooltipOpt.show)
  24423. ? zrUtil.extend({
  24424. content: name,
  24425. formatter: function () {
  24426. return name;
  24427. },
  24428. formatterParams: formatterParams
  24429. }, tooltipOpt)
  24430. : null
  24431. });
  24432. if (axisModel.get('triggerEvent')) {
  24433. textEl.eventData = makeAxisEventDataBase(axisModel);
  24434. textEl.eventData.targetType = 'axisName';
  24435. textEl.eventData.name = name;
  24436. }
  24437. // FIXME
  24438. this._dumbGroup.add(textEl);
  24439. textEl.updateTransform();
  24440. this.group.add(textEl);
  24441. textEl.decomposeTransform();
  24442. }
  24443. };
  24444. /**
  24445. * @inner
  24446. */
  24447. function innerTextLayout(opt, textRotation, direction) {
  24448. var rotationDiff = remRadian(textRotation - opt.rotation);
  24449. var textAlign;
  24450. var verticalAlign;
  24451. if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line.
  24452. verticalAlign = direction > 0 ? 'top' : 'bottom';
  24453. textAlign = 'center';
  24454. }
  24455. else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line.
  24456. verticalAlign = direction > 0 ? 'bottom' : 'top';
  24457. textAlign = 'center';
  24458. }
  24459. else {
  24460. verticalAlign = 'middle';
  24461. if (rotationDiff > 0 && rotationDiff < PI) {
  24462. textAlign = direction > 0 ? 'right' : 'left';
  24463. }
  24464. else {
  24465. textAlign = direction > 0 ? 'left' : 'right';
  24466. }
  24467. }
  24468. return {
  24469. rotation: rotationDiff,
  24470. textAlign: textAlign,
  24471. verticalAlign: verticalAlign
  24472. };
  24473. }
  24474. /**
  24475. * @inner
  24476. */
  24477. function endTextLayout(opt, textPosition, textRotate, extent) {
  24478. var rotationDiff = remRadian(textRotate - opt.rotation);
  24479. var textAlign;
  24480. var verticalAlign;
  24481. var inverse = extent[0] > extent[1];
  24482. var onLeft = (textPosition === 'start' && !inverse)
  24483. || (textPosition !== 'start' && inverse);
  24484. if (isRadianAroundZero(rotationDiff - PI / 2)) {
  24485. verticalAlign = onLeft ? 'bottom' : 'top';
  24486. textAlign = 'center';
  24487. }
  24488. else if (isRadianAroundZero(rotationDiff - PI * 1.5)) {
  24489. verticalAlign = onLeft ? 'top' : 'bottom';
  24490. textAlign = 'center';
  24491. }
  24492. else {
  24493. verticalAlign = 'middle';
  24494. if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) {
  24495. textAlign = onLeft ? 'left' : 'right';
  24496. }
  24497. else {
  24498. textAlign = onLeft ? 'right' : 'left';
  24499. }
  24500. }
  24501. return {
  24502. rotation: rotationDiff,
  24503. textAlign: textAlign,
  24504. verticalAlign: verticalAlign
  24505. };
  24506. }
  24507. /**
  24508. * @inner
  24509. */
  24510. function isSilent(axisModel) {
  24511. var tooltipOpt = axisModel.get('tooltip');
  24512. return axisModel.get('silent')
  24513. // Consider mouse cursor, add these restrictions.
  24514. || !(
  24515. axisModel.get('triggerEvent') || (tooltipOpt && tooltipOpt.show)
  24516. );
  24517. }
  24518. /**
  24519. * @static
  24520. */
  24521. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) {
  24522. var rawTick;
  24523. var scale = axis.scale;
  24524. return scale.type === 'ordinal'
  24525. && (
  24526. typeof interval === 'function'
  24527. ? (
  24528. rawTick = scale.getTicks()[i],
  24529. !interval(rawTick, scale.getLabel(rawTick))
  24530. )
  24531. : i % (interval + 1)
  24532. );
  24533. };
  24534. /**
  24535. * @static
  24536. */
  24537. var getInterval = AxisBuilder.getInterval = function (model, labelInterval) {
  24538. var interval = model.get('interval');
  24539. if (interval == null || interval == 'auto') {
  24540. interval = labelInterval;
  24541. }
  24542. return interval;
  24543. };
  24544. module.exports = AxisBuilder;
  24545. /***/ },
  24546. /* 135 */
  24547. /***/ function(module, exports, __webpack_require__) {
  24548. var zrUtil = __webpack_require__(4);
  24549. __webpack_require__(114);
  24550. __webpack_require__(136);
  24551. __webpack_require__(137);
  24552. var barLayoutGrid = __webpack_require__(139);
  24553. var echarts = __webpack_require__(1);
  24554. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
  24555. // Visual coding for legend
  24556. echarts.registerVisual(function (ecModel) {
  24557. ecModel.eachSeriesByType('bar', function (seriesModel) {
  24558. var data = seriesModel.getData();
  24559. data.setVisual('legendSymbol', 'roundRect');
  24560. });
  24561. });
  24562. // In case developer forget to include grid component
  24563. __webpack_require__(113);
  24564. /***/ },
  24565. /* 136 */
  24566. /***/ function(module, exports, __webpack_require__) {
  24567. 'use strict';
  24568. var SeriesModel = __webpack_require__(28);
  24569. var createListFromArray = __webpack_require__(102);
  24570. module.exports = SeriesModel.extend({
  24571. type: 'series.bar',
  24572. dependencies: ['grid', 'polar'],
  24573. getInitialData: function (option, ecModel) {
  24574. if (true) {
  24575. var coordSys = option.coordinateSystem;
  24576. if (coordSys !== 'cartesian2d') {
  24577. throw new Error('Bar only support cartesian2d coordinateSystem');
  24578. }
  24579. }
  24580. return createListFromArray(option.data, this, ecModel);
  24581. },
  24582. getMarkerPosition: function (value) {
  24583. var coordSys = this.coordinateSystem;
  24584. if (coordSys) {
  24585. // PENDING if clamp ?
  24586. var pt = coordSys.dataToPoint(value, true);
  24587. var data = this.getData();
  24588. var offset = data.getLayout('offset');
  24589. var size = data.getLayout('size');
  24590. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
  24591. pt[offsetIndex] += offset + size / 2;
  24592. return pt;
  24593. }
  24594. return [NaN, NaN];
  24595. },
  24596. brushSelector: 'rect',
  24597. defaultOption: {
  24598. zlevel: 0, // 一级层叠
  24599. z: 2, // 二级层叠
  24600. coordinateSystem: 'cartesian2d',
  24601. legendHoverLink: true,
  24602. // stack: null
  24603. // Cartesian coordinate system
  24604. // xAxisIndex: 0,
  24605. // yAxisIndex: 0,
  24606. // 最小高度改为0
  24607. barMinHeight: 0,
  24608. // barMaxWidth: null,
  24609. // 默认自适应
  24610. // barWidth: null,
  24611. // 柱间距离,默认为柱形宽度的30%,可设固定值
  24612. // barGap: '30%',
  24613. // 类目间柱形距离,默认为类目间距的20%,可设固定值
  24614. // barCategoryGap: '20%',
  24615. // label: {
  24616. // normal: {
  24617. // show: false
  24618. // }
  24619. // },
  24620. itemStyle: {
  24621. normal: {
  24622. // color: '各异'
  24623. },
  24624. emphasis: {}
  24625. }
  24626. }
  24627. });
  24628. /***/ },
  24629. /* 137 */
  24630. /***/ function(module, exports, __webpack_require__) {
  24631. 'use strict';
  24632. var zrUtil = __webpack_require__(4);
  24633. var graphic = __webpack_require__(43);
  24634. zrUtil.extend(__webpack_require__(12).prototype, __webpack_require__(138));
  24635. function fixLayoutWithLineWidth(layout, lineWidth) {
  24636. var signX = layout.width > 0 ? 1 : -1;
  24637. var signY = layout.height > 0 ? 1 : -1;
  24638. // In case width or height are too small.
  24639. lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height));
  24640. layout.x += signX * lineWidth / 2;
  24641. layout.y += signY * lineWidth / 2;
  24642. layout.width -= signX * lineWidth;
  24643. layout.height -= signY * lineWidth;
  24644. }
  24645. module.exports = __webpack_require__(1).extendChartView({
  24646. type: 'bar',
  24647. render: function (seriesModel, ecModel, api) {
  24648. var coordinateSystemType = seriesModel.get('coordinateSystem');
  24649. if (coordinateSystemType === 'cartesian2d') {
  24650. this._renderOnCartesian(seriesModel, ecModel, api);
  24651. }
  24652. return this.group;
  24653. },
  24654. dispose: zrUtil.noop,
  24655. _renderOnCartesian: function (seriesModel, ecModel, api) {
  24656. var group = this.group;
  24657. var data = seriesModel.getData();
  24658. var oldData = this._data;
  24659. var cartesian = seriesModel.coordinateSystem;
  24660. var baseAxis = cartesian.getBaseAxis();
  24661. var isHorizontal = baseAxis.isHorizontal();
  24662. var enableAnimation = seriesModel.get('animation');
  24663. var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth'];
  24664. function createRect(dataIndex, isUpdate) {
  24665. var layout = data.getItemLayout(dataIndex);
  24666. var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0;
  24667. fixLayoutWithLineWidth(layout, lineWidth);
  24668. var rect = new graphic.Rect({
  24669. shape: zrUtil.extend({}, layout)
  24670. });
  24671. // Animation
  24672. if (enableAnimation) {
  24673. var rectShape = rect.shape;
  24674. var animateProperty = isHorizontal ? 'height' : 'width';
  24675. var animateTarget = {};
  24676. rectShape[animateProperty] = 0;
  24677. animateTarget[animateProperty] = layout[animateProperty];
  24678. graphic[isUpdate? 'updateProps' : 'initProps'](rect, {
  24679. shape: animateTarget
  24680. }, seriesModel, dataIndex);
  24681. }
  24682. return rect;
  24683. }
  24684. data.diff(oldData)
  24685. .add(function (dataIndex) {
  24686. // 空数据
  24687. if (!data.hasValue(dataIndex)) {
  24688. return;
  24689. }
  24690. var rect = createRect(dataIndex);
  24691. data.setItemGraphicEl(dataIndex, rect);
  24692. group.add(rect);
  24693. })
  24694. .update(function (newIndex, oldIndex) {
  24695. var rect = oldData.getItemGraphicEl(oldIndex);
  24696. // 空数据
  24697. if (!data.hasValue(newIndex)) {
  24698. group.remove(rect);
  24699. return;
  24700. }
  24701. if (!rect) {
  24702. rect = createRect(newIndex, true);
  24703. }
  24704. var layout = data.getItemLayout(newIndex);
  24705. var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0;
  24706. fixLayoutWithLineWidth(layout, lineWidth);
  24707. graphic.updateProps(rect, {
  24708. shape: layout
  24709. }, seriesModel, newIndex);
  24710. data.setItemGraphicEl(newIndex, rect);
  24711. // Add back
  24712. group.add(rect);
  24713. })
  24714. .remove(function (idx) {
  24715. var rect = oldData.getItemGraphicEl(idx);
  24716. if (rect) {
  24717. // Not show text when animating
  24718. rect.style.text = '';
  24719. graphic.updateProps(rect, {
  24720. shape: {
  24721. width: 0
  24722. }
  24723. }, seriesModel, idx, function () {
  24724. group.remove(rect);
  24725. });
  24726. }
  24727. })
  24728. .execute();
  24729. this._updateStyle(seriesModel, data, isHorizontal);
  24730. this._data = data;
  24731. },
  24732. _updateStyle: function (seriesModel, data, isHorizontal) {
  24733. function setLabel(style, model, color, labelText, labelPositionOutside) {
  24734. graphic.setText(style, model, color);
  24735. style.text = labelText;
  24736. if (style.textPosition === 'outside') {
  24737. style.textPosition = labelPositionOutside;
  24738. }
  24739. }
  24740. data.eachItemGraphicEl(function (rect, idx) {
  24741. var itemModel = data.getItemModel(idx);
  24742. var color = data.getItemVisual(idx, 'color');
  24743. var opacity = data.getItemVisual(idx, 'opacity');
  24744. var layout = data.getItemLayout(idx);
  24745. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  24746. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
  24747. rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
  24748. rect.useStyle(zrUtil.defaults(
  24749. {
  24750. fill: color,
  24751. opacity: opacity
  24752. },
  24753. itemStyleModel.getBarItemStyle()
  24754. ));
  24755. var labelPositionOutside = isHorizontal
  24756. ? (layout.height > 0 ? 'bottom' : 'top')
  24757. : (layout.width > 0 ? 'left' : 'right');
  24758. var labelModel = itemModel.getModel('label.normal');
  24759. var hoverLabelModel = itemModel.getModel('label.emphasis');
  24760. var rectStyle = rect.style;
  24761. if (labelModel.get('show')) {
  24762. setLabel(
  24763. rectStyle, labelModel, color,
  24764. zrUtil.retrieve(
  24765. seriesModel.getFormattedLabel(idx, 'normal'),
  24766. seriesModel.getRawValue(idx)
  24767. ),
  24768. labelPositionOutside
  24769. );
  24770. }
  24771. else {
  24772. rectStyle.text = '';
  24773. }
  24774. if (hoverLabelModel.get('show')) {
  24775. setLabel(
  24776. hoverStyle, hoverLabelModel, color,
  24777. zrUtil.retrieve(
  24778. seriesModel.getFormattedLabel(idx, 'emphasis'),
  24779. seriesModel.getRawValue(idx)
  24780. ),
  24781. labelPositionOutside
  24782. );
  24783. }
  24784. else {
  24785. hoverStyle.text = '';
  24786. }
  24787. graphic.setHoverStyle(rect, hoverStyle);
  24788. });
  24789. },
  24790. remove: function (ecModel, api) {
  24791. var group = this.group;
  24792. if (ecModel.get('animation')) {
  24793. if (this._data) {
  24794. this._data.eachItemGraphicEl(function (el) {
  24795. // Not show text when animating
  24796. el.style.text = '';
  24797. graphic.updateProps(el, {
  24798. shape: {
  24799. width: 0
  24800. }
  24801. }, ecModel, el.dataIndex, function () {
  24802. group.remove(el);
  24803. });
  24804. });
  24805. }
  24806. }
  24807. else {
  24808. group.removeAll();
  24809. }
  24810. }
  24811. });
  24812. /***/ },
  24813. /* 138 */
  24814. /***/ function(module, exports, __webpack_require__) {
  24815. var getBarItemStyle = __webpack_require__(15)(
  24816. [
  24817. ['fill', 'color'],
  24818. ['stroke', 'borderColor'],
  24819. ['lineWidth', 'borderWidth'],
  24820. // Compatitable with 2
  24821. ['stroke', 'barBorderColor'],
  24822. ['lineWidth', 'barBorderWidth'],
  24823. ['opacity'],
  24824. ['shadowBlur'],
  24825. ['shadowOffsetX'],
  24826. ['shadowOffsetY'],
  24827. ['shadowColor']
  24828. ]
  24829. );
  24830. module.exports = {
  24831. getBarItemStyle: function (excludes) {
  24832. var style = getBarItemStyle.call(this, excludes);
  24833. if (this.getBorderLineDash) {
  24834. var lineDash = this.getBorderLineDash();
  24835. lineDash && (style.lineDash = lineDash);
  24836. }
  24837. return style;
  24838. }
  24839. };
  24840. /***/ },
  24841. /* 139 */
  24842. /***/ function(module, exports, __webpack_require__) {
  24843. 'use strict';
  24844. var zrUtil = __webpack_require__(4);
  24845. var numberUtil = __webpack_require__(7);
  24846. var parsePercent = numberUtil.parsePercent;
  24847. function getSeriesStackId(seriesModel) {
  24848. return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex;
  24849. }
  24850. function getAxisKey(axis) {
  24851. return axis.dim + axis.index;
  24852. }
  24853. function calBarWidthAndOffset(barSeries, api) {
  24854. // Columns info on each category axis. Key is cartesian name
  24855. var columnsMap = {};
  24856. zrUtil.each(barSeries, function (seriesModel, idx) {
  24857. var data = seriesModel.getData();
  24858. var cartesian = seriesModel.coordinateSystem;
  24859. var baseAxis = cartesian.getBaseAxis();
  24860. var axisExtent = baseAxis.getExtent();
  24861. var bandWidth = baseAxis.type === 'category'
  24862. ? baseAxis.getBandWidth()
  24863. : (Math.abs(axisExtent[1] - axisExtent[0]) / data.count());
  24864. var columnsOnAxis = columnsMap[getAxisKey(baseAxis)] || {
  24865. bandWidth: bandWidth,
  24866. remainedWidth: bandWidth,
  24867. autoWidthCount: 0,
  24868. categoryGap: '20%',
  24869. gap: '30%',
  24870. stacks: {}
  24871. };
  24872. var stacks = columnsOnAxis.stacks;
  24873. columnsMap[getAxisKey(baseAxis)] = columnsOnAxis;
  24874. var stackId = getSeriesStackId(seriesModel);
  24875. if (!stacks[stackId]) {
  24876. columnsOnAxis.autoWidthCount++;
  24877. }
  24878. stacks[stackId] = stacks[stackId] || {
  24879. width: 0,
  24880. maxWidth: 0
  24881. };
  24882. var barWidth = parsePercent(
  24883. seriesModel.get('barWidth'), bandWidth
  24884. );
  24885. var barMaxWidth = parsePercent(
  24886. seriesModel.get('barMaxWidth'), bandWidth
  24887. );
  24888. var barGap = seriesModel.get('barGap');
  24889. var barCategoryGap = seriesModel.get('barCategoryGap');
  24890. // TODO
  24891. if (barWidth && !stacks[stackId].width) {
  24892. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  24893. stacks[stackId].width = barWidth;
  24894. columnsOnAxis.remainedWidth -= barWidth;
  24895. }
  24896. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  24897. (barGap != null) && (columnsOnAxis.gap = barGap);
  24898. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  24899. });
  24900. var result = {};
  24901. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  24902. result[coordSysName] = {};
  24903. var stacks = columnsOnAxis.stacks;
  24904. var bandWidth = columnsOnAxis.bandWidth;
  24905. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  24906. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  24907. var remainedWidth = columnsOnAxis.remainedWidth;
  24908. var autoWidthCount = columnsOnAxis.autoWidthCount;
  24909. var autoWidth = (remainedWidth - categoryGap)
  24910. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  24911. autoWidth = Math.max(autoWidth, 0);
  24912. // Find if any auto calculated bar exceeded maxBarWidth
  24913. zrUtil.each(stacks, function (column, stack) {
  24914. var maxWidth = column.maxWidth;
  24915. if (!column.width && maxWidth && maxWidth < autoWidth) {
  24916. maxWidth = Math.min(maxWidth, remainedWidth);
  24917. remainedWidth -= maxWidth;
  24918. column.width = maxWidth;
  24919. autoWidthCount--;
  24920. }
  24921. });
  24922. // Recalculate width again
  24923. autoWidth = (remainedWidth - categoryGap)
  24924. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  24925. autoWidth = Math.max(autoWidth, 0);
  24926. var widthSum = 0;
  24927. var lastColumn;
  24928. zrUtil.each(stacks, function (column, idx) {
  24929. if (!column.width) {
  24930. column.width = autoWidth;
  24931. }
  24932. lastColumn = column;
  24933. widthSum += column.width * (1 + barGapPercent);
  24934. });
  24935. if (lastColumn) {
  24936. widthSum -= lastColumn.width * barGapPercent;
  24937. }
  24938. var offset = -widthSum / 2;
  24939. zrUtil.each(stacks, function (column, stackId) {
  24940. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  24941. offset: offset,
  24942. width: column.width
  24943. };
  24944. offset += column.width * (1 + barGapPercent);
  24945. });
  24946. });
  24947. return result;
  24948. }
  24949. /**
  24950. * @param {string} seriesType
  24951. * @param {module:echarts/model/Global} ecModel
  24952. * @param {module:echarts/ExtensionAPI} api
  24953. */
  24954. function barLayoutGrid(seriesType, ecModel, api) {
  24955. var barWidthAndOffset = calBarWidthAndOffset(
  24956. zrUtil.filter(
  24957. ecModel.getSeriesByType(seriesType),
  24958. function (seriesModel) {
  24959. return !ecModel.isSeriesFiltered(seriesModel)
  24960. && seriesModel.coordinateSystem
  24961. && seriesModel.coordinateSystem.type === 'cartesian2d';
  24962. }
  24963. )
  24964. );
  24965. var lastStackCoords = {};
  24966. var lastStackCoordsOrigin = {};
  24967. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  24968. var data = seriesModel.getData();
  24969. var cartesian = seriesModel.coordinateSystem;
  24970. var baseAxis = cartesian.getBaseAxis();
  24971. var stackId = getSeriesStackId(seriesModel);
  24972. var columnLayoutInfo = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
  24973. var columnOffset = columnLayoutInfo.offset;
  24974. var columnWidth = columnLayoutInfo.width;
  24975. var valueAxis = cartesian.getOtherAxis(baseAxis);
  24976. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  24977. var valueAxisStart = baseAxis.onZero
  24978. ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0))
  24979. : valueAxis.getGlobalExtent()[0];
  24980. var coords = cartesian.dataToPoints(data, true);
  24981. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  24982. lastStackCoordsOrigin[stackId] = lastStackCoordsOrigin[stackId] || []; // Fix #4243
  24983. data.setLayout({
  24984. offset: columnOffset,
  24985. size: columnWidth
  24986. });
  24987. data.each(valueAxis.dim, function (value, idx) {
  24988. // 空数据
  24989. if (isNaN(value)) {
  24990. return;
  24991. }
  24992. if (!lastStackCoords[stackId][idx]) {
  24993. lastStackCoords[stackId][idx] = {
  24994. p: valueAxisStart, // Positive stack
  24995. n: valueAxisStart // Negative stack
  24996. };
  24997. lastStackCoordsOrigin[stackId][idx] = {
  24998. p: valueAxisStart, // Positive stack
  24999. n: valueAxisStart // Negative stack
  25000. };
  25001. }
  25002. var sign = value >= 0 ? 'p' : 'n';
  25003. var coord = coords[idx];
  25004. var lastCoord = lastStackCoords[stackId][idx][sign];
  25005. var lastCoordOrigin = lastStackCoordsOrigin[stackId][idx][sign];
  25006. var x;
  25007. var y;
  25008. var width;
  25009. var height;
  25010. if (valueAxis.isHorizontal()) {
  25011. x = lastCoord;
  25012. y = coord[1] + columnOffset;
  25013. width = coord[0] - lastCoordOrigin;
  25014. height = columnWidth;
  25015. lastStackCoordsOrigin[stackId][idx][sign] += width;
  25016. if (Math.abs(width) < barMinHeight) {
  25017. width = (width < 0 ? -1 : 1) * barMinHeight;
  25018. }
  25019. lastStackCoords[stackId][idx][sign] += width;
  25020. }
  25021. else {
  25022. x = coord[0] + columnOffset;
  25023. y = lastCoord;
  25024. width = columnWidth;
  25025. height = coord[1] - lastCoordOrigin;
  25026. lastStackCoordsOrigin[stackId][idx][sign] += height;
  25027. if (Math.abs(height) < barMinHeight) {
  25028. // Include zero to has a positive bar
  25029. height = (height <= 0 ? -1 : 1) * barMinHeight;
  25030. }
  25031. lastStackCoords[stackId][idx][sign] += height;
  25032. }
  25033. data.setItemLayout(idx, {
  25034. x: x,
  25035. y: y,
  25036. width: width,
  25037. height: height
  25038. });
  25039. }, true);
  25040. }, this);
  25041. }
  25042. module.exports = barLayoutGrid;
  25043. /***/ },
  25044. /* 140 */
  25045. /***/ function(module, exports, __webpack_require__) {
  25046. var zrUtil = __webpack_require__(4);
  25047. var echarts = __webpack_require__(1);
  25048. __webpack_require__(141);
  25049. __webpack_require__(143);
  25050. __webpack_require__(144)('pie', [{
  25051. type: 'pieToggleSelect',
  25052. event: 'pieselectchanged',
  25053. method: 'toggleSelected'
  25054. }, {
  25055. type: 'pieSelect',
  25056. event: 'pieselected',
  25057. method: 'select'
  25058. }, {
  25059. type: 'pieUnSelect',
  25060. event: 'pieunselected',
  25061. method: 'unSelect'
  25062. }]);
  25063. echarts.registerVisual(zrUtil.curry(__webpack_require__(145), 'pie'));
  25064. echarts.registerLayout(zrUtil.curry(
  25065. __webpack_require__(146), 'pie'
  25066. ));
  25067. echarts.registerProcessor(zrUtil.curry(__webpack_require__(148), 'pie'));
  25068. /***/ },
  25069. /* 141 */
  25070. /***/ function(module, exports, __webpack_require__) {
  25071. 'use strict';
  25072. var List = __webpack_require__(98);
  25073. var zrUtil = __webpack_require__(4);
  25074. var modelUtil = __webpack_require__(5);
  25075. var completeDimensions = __webpack_require__(103);
  25076. var dataSelectableMixin = __webpack_require__(142);
  25077. var PieSeries = __webpack_require__(1).extendSeriesModel({
  25078. type: 'series.pie',
  25079. // Overwrite
  25080. init: function (option) {
  25081. PieSeries.superApply(this, 'init', arguments);
  25082. // Enable legend selection for each data item
  25083. // Use a function instead of direct access because data reference may changed
  25084. this.legendDataProvider = function () {
  25085. return this._dataBeforeProcessed;
  25086. };
  25087. this.updateSelectedMap(option.data);
  25088. this._defaultLabelLine(option);
  25089. },
  25090. // Overwrite
  25091. mergeOption: function (newOption) {
  25092. PieSeries.superCall(this, 'mergeOption', newOption);
  25093. this.updateSelectedMap(this.option.data);
  25094. },
  25095. getInitialData: function (option, ecModel) {
  25096. var dimensions = completeDimensions(['value'], option.data);
  25097. var list = new List(dimensions, this);
  25098. list.initData(option.data);
  25099. return list;
  25100. },
  25101. // Overwrite
  25102. getDataParams: function (dataIndex) {
  25103. var data = this._data;
  25104. var params = PieSeries.superCall(this, 'getDataParams', dataIndex);
  25105. var sum = data.getSum('value');
  25106. // FIXME toFixed?
  25107. //
  25108. // Percent is 0 if sum is 0
  25109. params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2);
  25110. params.$vars.push('percent');
  25111. return params;
  25112. },
  25113. _defaultLabelLine: function (option) {
  25114. // Extend labelLine emphasis
  25115. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  25116. var labelLineNormalOpt = option.labelLine.normal;
  25117. var labelLineEmphasisOpt = option.labelLine.emphasis;
  25118. // Not show label line if `label.normal.show = false`
  25119. labelLineNormalOpt.show = labelLineNormalOpt.show
  25120. && option.label.normal.show;
  25121. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  25122. && option.label.emphasis.show;
  25123. },
  25124. defaultOption: {
  25125. zlevel: 0,
  25126. z: 2,
  25127. legendHoverLink: true,
  25128. hoverAnimation: true,
  25129. // 默认全局居中
  25130. center: ['50%', '50%'],
  25131. radius: [0, '75%'],
  25132. // 默认顺时针
  25133. clockwise: true,
  25134. startAngle: 90,
  25135. // 最小角度改为0
  25136. minAngle: 0,
  25137. // 选中是扇区偏移量
  25138. selectedOffset: 10,
  25139. // If use strategy to avoid label overlapping
  25140. avoidLabelOverlap: true,
  25141. // 选择模式,默认关闭,可选single,multiple
  25142. // selectedMode: false,
  25143. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  25144. // roseType: null,
  25145. label: {
  25146. normal: {
  25147. // If rotate around circle
  25148. rotate: false,
  25149. show: true,
  25150. // 'outer', 'inside', 'center'
  25151. position: 'outer'
  25152. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  25153. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  25154. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  25155. },
  25156. emphasis: {}
  25157. },
  25158. // Enabled when label.normal.position is 'outer'
  25159. labelLine: {
  25160. normal: {
  25161. show: true,
  25162. // 引导线两段中的第一段长度
  25163. length: 15,
  25164. // 引导线两段中的第二段长度
  25165. length2: 15,
  25166. smooth: false,
  25167. lineStyle: {
  25168. // color: 各异,
  25169. width: 1,
  25170. type: 'solid'
  25171. }
  25172. }
  25173. },
  25174. itemStyle: {
  25175. normal: {
  25176. borderWidth: 1
  25177. },
  25178. emphasis: {}
  25179. },
  25180. animationEasing: 'cubicOut',
  25181. data: []
  25182. }
  25183. });
  25184. zrUtil.mixin(PieSeries, dataSelectableMixin);
  25185. module.exports = PieSeries;
  25186. /***/ },
  25187. /* 142 */
  25188. /***/ function(module, exports, __webpack_require__) {
  25189. /**
  25190. * Data selectable mixin for chart series.
  25191. * To eanble data select, option of series must have `selectedMode`.
  25192. * And each data item will use `selected` to toggle itself selected status
  25193. *
  25194. * @module echarts/chart/helper/DataSelectable
  25195. */
  25196. var zrUtil = __webpack_require__(4);
  25197. module.exports = {
  25198. updateSelectedMap: function (targetList) {
  25199. this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
  25200. targetMap[target.name] = target;
  25201. return targetMap;
  25202. }, {});
  25203. },
  25204. /**
  25205. * @param {string} name
  25206. */
  25207. // PENGING If selectedMode is null ?
  25208. select: function (name) {
  25209. var targetMap = this._selectTargetMap;
  25210. var target = targetMap[name];
  25211. var selectedMode = this.get('selectedMode');
  25212. if (selectedMode === 'single') {
  25213. zrUtil.each(targetMap, function (target) {
  25214. target.selected = false;
  25215. });
  25216. }
  25217. target && (target.selected = true);
  25218. },
  25219. /**
  25220. * @param {string} name
  25221. */
  25222. unSelect: function (name) {
  25223. var target = this._selectTargetMap[name];
  25224. // var selectedMode = this.get('selectedMode');
  25225. // selectedMode !== 'single' && target && (target.selected = false);
  25226. target && (target.selected = false);
  25227. },
  25228. /**
  25229. * @param {string} name
  25230. */
  25231. toggleSelected: function (name) {
  25232. var target = this._selectTargetMap[name];
  25233. if (target != null) {
  25234. this[target.selected ? 'unSelect' : 'select'](name);
  25235. return target.selected;
  25236. }
  25237. },
  25238. /**
  25239. * @param {string} name
  25240. */
  25241. isSelected: function (name) {
  25242. var target = this._selectTargetMap[name];
  25243. return target && target.selected;
  25244. }
  25245. };
  25246. /***/ },
  25247. /* 143 */
  25248. /***/ function(module, exports, __webpack_require__) {
  25249. var graphic = __webpack_require__(43);
  25250. var zrUtil = __webpack_require__(4);
  25251. /**
  25252. * @param {module:echarts/model/Series} seriesModel
  25253. * @param {boolean} hasAnimation
  25254. * @inner
  25255. */
  25256. function updateDataSelected(uid, seriesModel, hasAnimation, api) {
  25257. var data = seriesModel.getData();
  25258. var dataIndex = this.dataIndex;
  25259. var name = data.getName(dataIndex);
  25260. var selectedOffset = seriesModel.get('selectedOffset');
  25261. api.dispatchAction({
  25262. type: 'pieToggleSelect',
  25263. from: uid,
  25264. name: name,
  25265. seriesId: seriesModel.id
  25266. });
  25267. data.each(function (idx) {
  25268. toggleItemSelected(
  25269. data.getItemGraphicEl(idx),
  25270. data.getItemLayout(idx),
  25271. seriesModel.isSelected(data.getName(idx)),
  25272. selectedOffset,
  25273. hasAnimation
  25274. );
  25275. });
  25276. }
  25277. /**
  25278. * @param {module:zrender/graphic/Sector} el
  25279. * @param {Object} layout
  25280. * @param {boolean} isSelected
  25281. * @param {number} selectedOffset
  25282. * @param {boolean} hasAnimation
  25283. * @inner
  25284. */
  25285. function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) {
  25286. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  25287. var dx = Math.cos(midAngle);
  25288. var dy = Math.sin(midAngle);
  25289. var offset = isSelected ? selectedOffset : 0;
  25290. var position = [dx * offset, dy * offset];
  25291. hasAnimation
  25292. // animateTo will stop revious animation like update transition
  25293. ? el.animate()
  25294. .when(200, {
  25295. position: position
  25296. })
  25297. .start('bounceOut')
  25298. : el.attr('position', position);
  25299. }
  25300. /**
  25301. * Piece of pie including Sector, Label, LabelLine
  25302. * @constructor
  25303. * @extends {module:zrender/graphic/Group}
  25304. */
  25305. function PiePiece(data, idx) {
  25306. graphic.Group.call(this);
  25307. var sector = new graphic.Sector({
  25308. z2: 2
  25309. });
  25310. var polyline = new graphic.Polyline();
  25311. var text = new graphic.Text();
  25312. this.add(sector);
  25313. this.add(polyline);
  25314. this.add(text);
  25315. this.updateData(data, idx, true);
  25316. // Hover to change label and labelLine
  25317. function onEmphasis() {
  25318. polyline.ignore = polyline.hoverIgnore;
  25319. text.ignore = text.hoverIgnore;
  25320. }
  25321. function onNormal() {
  25322. polyline.ignore = polyline.normalIgnore;
  25323. text.ignore = text.normalIgnore;
  25324. }
  25325. this.on('emphasis', onEmphasis)
  25326. .on('normal', onNormal)
  25327. .on('mouseover', onEmphasis)
  25328. .on('mouseout', onNormal);
  25329. }
  25330. var piePieceProto = PiePiece.prototype;
  25331. function getLabelStyle(data, idx, state, labelModel, labelPosition) {
  25332. var textStyleModel = labelModel.getModel('textStyle');
  25333. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  25334. return {
  25335. fill: textStyleModel.getTextColor()
  25336. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  25337. opacity: data.getItemVisual(idx, 'opacity'),
  25338. textFont: textStyleModel.getFont(),
  25339. text: zrUtil.retrieve(
  25340. data.hostModel.getFormattedLabel(idx, state), data.getName(idx)
  25341. )
  25342. };
  25343. }
  25344. piePieceProto.updateData = function (data, idx, firstCreate) {
  25345. var sector = this.childAt(0);
  25346. var seriesModel = data.hostModel;
  25347. var itemModel = data.getItemModel(idx);
  25348. var layout = data.getItemLayout(idx);
  25349. var sectorShape = zrUtil.extend({}, layout);
  25350. sectorShape.label = null;
  25351. if (firstCreate) {
  25352. sector.setShape(sectorShape);
  25353. sector.shape.endAngle = layout.startAngle;
  25354. graphic.updateProps(sector, {
  25355. shape: {
  25356. endAngle: layout.endAngle
  25357. }
  25358. }, seriesModel, idx);
  25359. }
  25360. else {
  25361. graphic.updateProps(sector, {
  25362. shape: sectorShape
  25363. }, seriesModel, idx);
  25364. }
  25365. // Update common style
  25366. var itemStyleModel = itemModel.getModel('itemStyle');
  25367. var visualColor = data.getItemVisual(idx, 'color');
  25368. sector.useStyle(
  25369. zrUtil.defaults(
  25370. {
  25371. lineJoin: 'bevel',
  25372. fill: visualColor
  25373. },
  25374. itemStyleModel.getModel('normal').getItemStyle()
  25375. )
  25376. );
  25377. sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  25378. // Toggle selected
  25379. toggleItemSelected(
  25380. this,
  25381. data.getItemLayout(idx),
  25382. itemModel.get('selected'),
  25383. seriesModel.get('selectedOffset'),
  25384. seriesModel.get('animation')
  25385. );
  25386. function onEmphasis() {
  25387. // Sector may has animation of updating data. Force to move to the last frame
  25388. // Or it may stopped on the wrong shape
  25389. sector.stopAnimation(true);
  25390. sector.animateTo({
  25391. shape: {
  25392. r: layout.r + 10
  25393. }
  25394. }, 300, 'elasticOut');
  25395. }
  25396. function onNormal() {
  25397. sector.stopAnimation(true);
  25398. sector.animateTo({
  25399. shape: {
  25400. r: layout.r
  25401. }
  25402. }, 300, 'elasticOut');
  25403. }
  25404. sector.off('mouseover').off('mouseout').off('emphasis').off('normal');
  25405. if (itemModel.get('hoverAnimation') && seriesModel.ifEnableAnimation()) {
  25406. sector
  25407. .on('mouseover', onEmphasis)
  25408. .on('mouseout', onNormal)
  25409. .on('emphasis', onEmphasis)
  25410. .on('normal', onNormal);
  25411. }
  25412. this._updateLabel(data, idx);
  25413. graphic.setHoverStyle(this);
  25414. };
  25415. piePieceProto._updateLabel = function (data, idx) {
  25416. var labelLine = this.childAt(1);
  25417. var labelText = this.childAt(2);
  25418. var seriesModel = data.hostModel;
  25419. var itemModel = data.getItemModel(idx);
  25420. var layout = data.getItemLayout(idx);
  25421. var labelLayout = layout.label;
  25422. var visualColor = data.getItemVisual(idx, 'color');
  25423. graphic.updateProps(labelLine, {
  25424. shape: {
  25425. points: labelLayout.linePoints || [
  25426. [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y]
  25427. ]
  25428. }
  25429. }, seriesModel, idx);
  25430. graphic.updateProps(labelText, {
  25431. style: {
  25432. x: labelLayout.x,
  25433. y: labelLayout.y
  25434. }
  25435. }, seriesModel, idx);
  25436. labelText.attr({
  25437. style: {
  25438. textVerticalAlign: labelLayout.verticalAlign,
  25439. textAlign: labelLayout.textAlign,
  25440. textFont: labelLayout.font
  25441. },
  25442. rotation: labelLayout.rotation,
  25443. origin: [labelLayout.x, labelLayout.y],
  25444. z2: 10
  25445. });
  25446. var labelModel = itemModel.getModel('label.normal');
  25447. var labelHoverModel = itemModel.getModel('label.emphasis');
  25448. var labelLineModel = itemModel.getModel('labelLine.normal');
  25449. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  25450. var labelPosition = labelModel.get('position') || labelHoverModel.get('position');
  25451. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition));
  25452. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  25453. labelText.hoverIgnore = !labelHoverModel.get('show');
  25454. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  25455. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  25456. // Default use item visual color
  25457. labelLine.setStyle({
  25458. stroke: visualColor,
  25459. opacity: data.getItemVisual(idx, 'opacity')
  25460. });
  25461. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  25462. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition);
  25463. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  25464. var smooth = labelLineModel.get('smooth');
  25465. if (smooth && smooth === true) {
  25466. smooth = 0.4;
  25467. }
  25468. labelLine.setShape({
  25469. smooth: smooth
  25470. });
  25471. };
  25472. zrUtil.inherits(PiePiece, graphic.Group);
  25473. // Pie view
  25474. var Pie = __webpack_require__(42).extend({
  25475. type: 'pie',
  25476. init: function () {
  25477. var sectorGroup = new graphic.Group();
  25478. this._sectorGroup = sectorGroup;
  25479. },
  25480. render: function (seriesModel, ecModel, api, payload) {
  25481. if (payload && (payload.from === this.uid)) {
  25482. return;
  25483. }
  25484. var data = seriesModel.getData();
  25485. var oldData = this._data;
  25486. var group = this.group;
  25487. var hasAnimation = ecModel.get('animation');
  25488. var isFirstRender = !oldData;
  25489. var onSectorClick = zrUtil.curry(
  25490. updateDataSelected, this.uid, seriesModel, hasAnimation, api
  25491. );
  25492. var selectedMode = seriesModel.get('selectedMode');
  25493. data.diff(oldData)
  25494. .add(function (idx) {
  25495. var piePiece = new PiePiece(data, idx);
  25496. if (isFirstRender) {
  25497. piePiece.eachChild(function (child) {
  25498. child.stopAnimation(true);
  25499. });
  25500. }
  25501. selectedMode && piePiece.on('click', onSectorClick);
  25502. data.setItemGraphicEl(idx, piePiece);
  25503. group.add(piePiece);
  25504. })
  25505. .update(function (newIdx, oldIdx) {
  25506. var piePiece = oldData.getItemGraphicEl(oldIdx);
  25507. piePiece.updateData(data, newIdx);
  25508. piePiece.off('click');
  25509. selectedMode && piePiece.on('click', onSectorClick);
  25510. group.add(piePiece);
  25511. data.setItemGraphicEl(newIdx, piePiece);
  25512. })
  25513. .remove(function (idx) {
  25514. var piePiece = oldData.getItemGraphicEl(idx);
  25515. group.remove(piePiece);
  25516. })
  25517. .execute();
  25518. if (hasAnimation && isFirstRender && data.count() > 0) {
  25519. var shape = data.getItemLayout(0);
  25520. var r = Math.max(api.getWidth(), api.getHeight()) / 2;
  25521. var removeClipPath = zrUtil.bind(group.removeClipPath, group);
  25522. group.setClipPath(this._createClipPath(
  25523. shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel
  25524. ));
  25525. }
  25526. this._data = data;
  25527. },
  25528. dispose: function () {},
  25529. _createClipPath: function (
  25530. cx, cy, r, startAngle, clockwise, cb, seriesModel
  25531. ) {
  25532. var clipPath = new graphic.Sector({
  25533. shape: {
  25534. cx: cx,
  25535. cy: cy,
  25536. r0: 0,
  25537. r: r,
  25538. startAngle: startAngle,
  25539. endAngle: startAngle,
  25540. clockwise: clockwise
  25541. }
  25542. });
  25543. graphic.initProps(clipPath, {
  25544. shape: {
  25545. endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2
  25546. }
  25547. }, seriesModel, cb);
  25548. return clipPath;
  25549. },
  25550. /**
  25551. * @implement
  25552. */
  25553. containPoint: function (point, seriesModel) {
  25554. var data = seriesModel.getData();
  25555. var itemLayout = data.getItemLayout(0);
  25556. if (itemLayout) {
  25557. var dx = point[0] - itemLayout.cx;
  25558. var dy = point[1] - itemLayout.cy;
  25559. var radius = Math.sqrt(dx * dx + dy * dy);
  25560. return radius <= itemLayout.r && radius >= itemLayout.r0;
  25561. }
  25562. }
  25563. });
  25564. module.exports = Pie;
  25565. /***/ },
  25566. /* 144 */
  25567. /***/ function(module, exports, __webpack_require__) {
  25568. var echarts = __webpack_require__(1);
  25569. var zrUtil = __webpack_require__(4);
  25570. module.exports = function (seriesType, actionInfos) {
  25571. zrUtil.each(actionInfos, function (actionInfo) {
  25572. actionInfo.update = 'updateView';
  25573. /**
  25574. * @payload
  25575. * @property {string} seriesName
  25576. * @property {string} name
  25577. */
  25578. echarts.registerAction(actionInfo, function (payload, ecModel) {
  25579. var selected = {};
  25580. ecModel.eachComponent(
  25581. {mainType: 'series', subType: seriesType, query: payload},
  25582. function (seriesModel) {
  25583. if (seriesModel[actionInfo.method]) {
  25584. seriesModel[actionInfo.method](payload.name);
  25585. }
  25586. var data = seriesModel.getData();
  25587. // Create selected map
  25588. data.each(function (idx) {
  25589. var name = data.getName(idx);
  25590. selected[name] = seriesModel.isSelected(name) || false;
  25591. });
  25592. }
  25593. );
  25594. return {
  25595. name: payload.name,
  25596. selected: selected
  25597. };
  25598. });
  25599. });
  25600. };
  25601. /***/ },
  25602. /* 145 */
  25603. /***/ function(module, exports) {
  25604. // Pick color from palette for each data item
  25605. module.exports = function (seriesType, ecModel) {
  25606. // Pie and funnel may use diferrent scope
  25607. var paletteScope = {};
  25608. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  25609. var dataAll = seriesModel.getRawData();
  25610. var idxMap = {};
  25611. if (!ecModel.isSeriesFiltered(seriesModel)) {
  25612. var data = seriesModel.getData();
  25613. data.each(function (idx) {
  25614. var rawIdx = data.getRawIndex(idx);
  25615. idxMap[rawIdx] = idx;
  25616. });
  25617. dataAll.each(function (rawIdx) {
  25618. // FIXME Performance
  25619. var itemModel = dataAll.getItemModel(rawIdx);
  25620. var filteredIdx = idxMap[rawIdx];
  25621. // If series.itemStyle.normal.color is a function. itemVisual may be encoded
  25622. var singleDataColor = filteredIdx != null
  25623. && data.getItemVisual(filteredIdx, 'color', true);
  25624. if (!singleDataColor) {
  25625. var color = itemModel.get('itemStyle.normal.color')
  25626. || seriesModel.getColorFromPalette(dataAll.getName(rawIdx), paletteScope);
  25627. // Legend may use the visual info in data before processed
  25628. dataAll.setItemVisual(rawIdx, 'color', color);
  25629. // Data is not filtered
  25630. if (filteredIdx != null) {
  25631. data.setItemVisual(filteredIdx, 'color', color);
  25632. }
  25633. }
  25634. else {
  25635. // Set data all color for legend
  25636. dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
  25637. }
  25638. });
  25639. }
  25640. });
  25641. };
  25642. /***/ },
  25643. /* 146 */
  25644. /***/ function(module, exports, __webpack_require__) {
  25645. // TODO minAngle
  25646. var numberUtil = __webpack_require__(7);
  25647. var parsePercent = numberUtil.parsePercent;
  25648. var labelLayout = __webpack_require__(147);
  25649. var zrUtil = __webpack_require__(4);
  25650. var PI2 = Math.PI * 2;
  25651. var RADIAN = Math.PI / 180;
  25652. module.exports = function (seriesType, ecModel, api, payload) {
  25653. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  25654. var center = seriesModel.get('center');
  25655. var radius = seriesModel.get('radius');
  25656. if (!zrUtil.isArray(radius)) {
  25657. radius = [0, radius];
  25658. }
  25659. if (!zrUtil.isArray(center)) {
  25660. center = [center, center];
  25661. }
  25662. var width = api.getWidth();
  25663. var height = api.getHeight();
  25664. var size = Math.min(width, height);
  25665. var cx = parsePercent(center[0], width);
  25666. var cy = parsePercent(center[1], height);
  25667. var r0 = parsePercent(radius[0], size / 2);
  25668. var r = parsePercent(radius[1], size / 2);
  25669. var data = seriesModel.getData();
  25670. var startAngle = -seriesModel.get('startAngle') * RADIAN;
  25671. var minAngle = seriesModel.get('minAngle') * RADIAN;
  25672. var sum = data.getSum('value');
  25673. // Sum may be 0
  25674. var unitRadian = Math.PI / (sum || data.count()) * 2;
  25675. var clockwise = seriesModel.get('clockwise');
  25676. var roseType = seriesModel.get('roseType');
  25677. // [0...max]
  25678. var extent = data.getDataExtent('value');
  25679. extent[0] = 0;
  25680. // In the case some sector angle is smaller than minAngle
  25681. var restAngle = PI2;
  25682. var valueSumLargerThanMinAngle = 0;
  25683. var currentAngle = startAngle;
  25684. var dir = clockwise ? 1 : -1;
  25685. data.each('value', function (value, idx) {
  25686. var angle;
  25687. // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  25688. if (roseType !== 'area') {
  25689. angle = sum === 0 ? unitRadian : (value * unitRadian);
  25690. }
  25691. else {
  25692. angle = PI2 / (data.count() || 1);
  25693. }
  25694. if (angle < minAngle) {
  25695. angle = minAngle;
  25696. restAngle -= minAngle;
  25697. }
  25698. else {
  25699. valueSumLargerThanMinAngle += value;
  25700. }
  25701. var endAngle = currentAngle + dir * angle;
  25702. data.setItemLayout(idx, {
  25703. angle: angle,
  25704. startAngle: currentAngle,
  25705. endAngle: endAngle,
  25706. clockwise: clockwise,
  25707. cx: cx,
  25708. cy: cy,
  25709. r0: r0,
  25710. r: roseType
  25711. ? numberUtil.linearMap(value, extent, [r0, r])
  25712. : r
  25713. });
  25714. currentAngle = endAngle;
  25715. }, true);
  25716. // Some sector is constrained by minAngle
  25717. // Rest sectors needs recalculate angle
  25718. if (restAngle < PI2) {
  25719. // Average the angle if rest angle is not enough after all angles is
  25720. // Constrained by minAngle
  25721. if (restAngle <= 1e-3) {
  25722. var angle = PI2 / data.count();
  25723. data.each(function (idx) {
  25724. var layout = data.getItemLayout(idx);
  25725. layout.startAngle = startAngle + dir * idx * angle;
  25726. layout.endAngle = startAngle + dir * (idx + 1) * angle;
  25727. });
  25728. }
  25729. else {
  25730. unitRadian = restAngle / valueSumLargerThanMinAngle;
  25731. currentAngle = startAngle;
  25732. data.each('value', function (value, idx) {
  25733. var layout = data.getItemLayout(idx);
  25734. var angle = layout.angle === minAngle
  25735. ? minAngle : value * unitRadian;
  25736. layout.startAngle = currentAngle;
  25737. layout.endAngle = currentAngle + dir * angle;
  25738. currentAngle += dir * angle;
  25739. });
  25740. }
  25741. }
  25742. labelLayout(seriesModel, r, width, height);
  25743. });
  25744. };
  25745. /***/ },
  25746. /* 147 */
  25747. /***/ function(module, exports, __webpack_require__) {
  25748. 'use strict';
  25749. // FIXME emphasis label position is not same with normal label position
  25750. var textContain = __webpack_require__(8);
  25751. function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
  25752. list.sort(function (a, b) {
  25753. return a.y - b.y;
  25754. });
  25755. // 压
  25756. function shiftDown(start, end, delta, dir) {
  25757. for (var j = start; j < end; j++) {
  25758. list[j].y += delta;
  25759. if (j > start
  25760. && j + 1 < end
  25761. && list[j + 1].y > list[j].y + list[j].height
  25762. ) {
  25763. shiftUp(j, delta / 2);
  25764. return;
  25765. }
  25766. }
  25767. shiftUp(end - 1, delta / 2);
  25768. }
  25769. // 弹
  25770. function shiftUp(end, delta) {
  25771. for (var j = end; j >= 0; j--) {
  25772. list[j].y -= delta;
  25773. if (j > 0
  25774. && list[j].y > list[j - 1].y + list[j - 1].height
  25775. ) {
  25776. break;
  25777. }
  25778. }
  25779. }
  25780. function changeX(list, isDownList, cx, cy, r, dir) {
  25781. var lastDeltaX = dir > 0
  25782. ? isDownList // 右侧
  25783. ? Number.MAX_VALUE // 下
  25784. : 0 // 上
  25785. : isDownList // 左侧
  25786. ? Number.MAX_VALUE // 下
  25787. : 0; // 上
  25788. for (var i = 0, l = list.length; i < l; i++) {
  25789. // Not change x for center label
  25790. if (list[i].position === 'center') {
  25791. continue;
  25792. }
  25793. var deltaY = Math.abs(list[i].y - cy);
  25794. var length = list[i].len;
  25795. var length2 = list[i].len2;
  25796. var deltaX = (deltaY < r + length)
  25797. ? Math.sqrt(
  25798. (r + length + length2) * (r + length + length2)
  25799. - deltaY * deltaY
  25800. )
  25801. : Math.abs(list[i].x - cx);
  25802. if (isDownList && deltaX >= lastDeltaX) {
  25803. // 右下,左下
  25804. deltaX = lastDeltaX - 10;
  25805. }
  25806. if (!isDownList && deltaX <= lastDeltaX) {
  25807. // 右上,左上
  25808. deltaX = lastDeltaX + 10;
  25809. }
  25810. list[i].x = cx + deltaX * dir;
  25811. lastDeltaX = deltaX;
  25812. }
  25813. }
  25814. var lastY = 0;
  25815. var delta;
  25816. var len = list.length;
  25817. var upList = [];
  25818. var downList = [];
  25819. for (var i = 0; i < len; i++) {
  25820. delta = list[i].y - lastY;
  25821. if (delta < 0) {
  25822. shiftDown(i, len, -delta, dir);
  25823. }
  25824. lastY = list[i].y + list[i].height;
  25825. }
  25826. if (viewHeight - lastY < 0) {
  25827. shiftUp(len - 1, lastY - viewHeight);
  25828. }
  25829. for (var i = 0; i < len; i++) {
  25830. if (list[i].y >= cy) {
  25831. downList.push(list[i]);
  25832. }
  25833. else {
  25834. upList.push(list[i]);
  25835. }
  25836. }
  25837. changeX(upList, false, cx, cy, r, dir);
  25838. changeX(downList, true, cx, cy, r, dir);
  25839. }
  25840. function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
  25841. var leftList = [];
  25842. var rightList = [];
  25843. for (var i = 0; i < labelLayoutList.length; i++) {
  25844. if (labelLayoutList[i].x < cx) {
  25845. leftList.push(labelLayoutList[i]);
  25846. }
  25847. else {
  25848. rightList.push(labelLayoutList[i]);
  25849. }
  25850. }
  25851. adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
  25852. adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
  25853. for (var i = 0; i < labelLayoutList.length; i++) {
  25854. var linePoints = labelLayoutList[i].linePoints;
  25855. if (linePoints) {
  25856. var dist = linePoints[1][0] - linePoints[2][0];
  25857. if (labelLayoutList[i].x < cx) {
  25858. linePoints[2][0] = labelLayoutList[i].x + 3;
  25859. }
  25860. else {
  25861. linePoints[2][0] = labelLayoutList[i].x - 3;
  25862. }
  25863. linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
  25864. linePoints[1][0] = linePoints[2][0] + dist;
  25865. }
  25866. }
  25867. }
  25868. module.exports = function (seriesModel, r, viewWidth, viewHeight) {
  25869. var data = seriesModel.getData();
  25870. var labelLayoutList = [];
  25871. var cx;
  25872. var cy;
  25873. var hasLabelRotate = false;
  25874. data.each(function (idx) {
  25875. var layout = data.getItemLayout(idx);
  25876. var itemModel = data.getItemModel(idx);
  25877. var labelModel = itemModel.getModel('label.normal');
  25878. // Use position in normal or emphasis
  25879. var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position');
  25880. var labelLineModel = itemModel.getModel('labelLine.normal');
  25881. var labelLineLen = labelLineModel.get('length');
  25882. var labelLineLen2 = labelLineModel.get('length2');
  25883. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  25884. var dx = Math.cos(midAngle);
  25885. var dy = Math.sin(midAngle);
  25886. var textX;
  25887. var textY;
  25888. var linePoints;
  25889. var textAlign;
  25890. cx = layout.cx;
  25891. cy = layout.cy;
  25892. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  25893. if (labelPosition === 'center') {
  25894. textX = layout.cx;
  25895. textY = layout.cy;
  25896. textAlign = 'center';
  25897. }
  25898. else {
  25899. var x1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dx : layout.r * dx) + cx;
  25900. var y1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dy : layout.r * dy) + cy;
  25901. textX = x1 + dx * 3;
  25902. textY = y1 + dy * 3;
  25903. if (!isLabelInside) {
  25904. // For roseType
  25905. var x2 = x1 + dx * (labelLineLen + r - layout.r);
  25906. var y2 = y1 + dy * (labelLineLen + r - layout.r);
  25907. var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
  25908. var y3 = y2;
  25909. textX = x3 + (dx < 0 ? -5 : 5);
  25910. textY = y3;
  25911. linePoints = [[x1, y1], [x2, y2], [x3, y3]];
  25912. }
  25913. textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
  25914. }
  25915. var font = labelModel.getModel('textStyle').getFont();
  25916. var labelRotate = labelModel.get('rotate')
  25917. ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0;
  25918. var text = seriesModel.getFormattedLabel(idx, 'normal')
  25919. || data.getName(idx);
  25920. var textRect = textContain.getBoundingRect(
  25921. text, font, textAlign, 'top'
  25922. );
  25923. hasLabelRotate = !!labelRotate;
  25924. layout.label = {
  25925. x: textX,
  25926. y: textY,
  25927. position: labelPosition,
  25928. height: textRect.height,
  25929. len: labelLineLen,
  25930. len2: labelLineLen2,
  25931. linePoints: linePoints,
  25932. textAlign: textAlign,
  25933. verticalAlign: 'middle',
  25934. font: font,
  25935. rotation: labelRotate
  25936. };
  25937. // Not layout the inside label
  25938. if (!isLabelInside) {
  25939. labelLayoutList.push(layout.label);
  25940. }
  25941. });
  25942. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  25943. avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
  25944. }
  25945. };
  25946. /***/ },
  25947. /* 148 */
  25948. /***/ function(module, exports) {
  25949. module.exports = function (seriesType, ecModel) {
  25950. var legendModels = ecModel.findComponents({
  25951. mainType: 'legend'
  25952. });
  25953. if (!legendModels || !legendModels.length) {
  25954. return;
  25955. }
  25956. ecModel.eachSeriesByType(seriesType, function (series) {
  25957. var data = series.getData();
  25958. data.filterSelf(function (idx) {
  25959. var name = data.getName(idx);
  25960. // If in any legend component the status is not selected.
  25961. for (var i = 0; i < legendModels.length; i++) {
  25962. if (!legendModels[i].isSelected(name)) {
  25963. return false;
  25964. }
  25965. }
  25966. return true;
  25967. }, this);
  25968. }, this);
  25969. };
  25970. /***/ },
  25971. /* 149 */
  25972. /***/ function(module, exports, __webpack_require__) {
  25973. var zrUtil = __webpack_require__(4);
  25974. var echarts = __webpack_require__(1);
  25975. __webpack_require__(150);
  25976. __webpack_require__(151);
  25977. echarts.registerVisual(zrUtil.curry(
  25978. __webpack_require__(110), 'scatter', 'circle', null
  25979. ));
  25980. echarts.registerLayout(zrUtil.curry(
  25981. __webpack_require__(111), 'scatter'
  25982. ));
  25983. // In case developer forget to include grid component
  25984. __webpack_require__(113);
  25985. /***/ },
  25986. /* 150 */
  25987. /***/ function(module, exports, __webpack_require__) {
  25988. 'use strict';
  25989. var createListFromArray = __webpack_require__(102);
  25990. var SeriesModel = __webpack_require__(28);
  25991. module.exports = SeriesModel.extend({
  25992. type: 'series.scatter',
  25993. dependencies: ['grid', 'polar'],
  25994. getInitialData: function (option, ecModel) {
  25995. var list = createListFromArray(option.data, this, ecModel);
  25996. return list;
  25997. },
  25998. brushSelector: 'point',
  25999. defaultOption: {
  26000. coordinateSystem: 'cartesian2d',
  26001. zlevel: 0,
  26002. z: 2,
  26003. legendHoverLink: true,
  26004. hoverAnimation: true,
  26005. // Cartesian coordinate system
  26006. // xAxisIndex: 0,
  26007. // yAxisIndex: 0,
  26008. // Polar coordinate system
  26009. // polarIndex: 0,
  26010. // Geo coordinate system
  26011. // geoIndex: 0,
  26012. // symbol: null, // 图形类型
  26013. symbolSize: 10, // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  26014. // symbolRotate: null, // 图形旋转控制
  26015. large: false,
  26016. // Available when large is true
  26017. largeThreshold: 2000,
  26018. // label: {
  26019. // normal: {
  26020. // show: false
  26021. // distance: 5,
  26022. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  26023. // position: 默认自适应,水平布局为'top',垂直布局为'right',可选为
  26024. // 'inside'|'left'|'right'|'top'|'bottom'
  26025. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  26026. // }
  26027. // },
  26028. itemStyle: {
  26029. normal: {
  26030. opacity: 0.8
  26031. // color: 各异
  26032. }
  26033. }
  26034. }
  26035. });
  26036. /***/ },
  26037. /* 151 */
  26038. /***/ function(module, exports, __webpack_require__) {
  26039. var SymbolDraw = __webpack_require__(105);
  26040. var LargeSymbolDraw = __webpack_require__(152);
  26041. __webpack_require__(1).extendChartView({
  26042. type: 'scatter',
  26043. init: function () {
  26044. this._normalSymbolDraw = new SymbolDraw();
  26045. this._largeSymbolDraw = new LargeSymbolDraw();
  26046. },
  26047. render: function (seriesModel, ecModel, api) {
  26048. var data = seriesModel.getData();
  26049. var largeSymbolDraw = this._largeSymbolDraw;
  26050. var normalSymbolDraw = this._normalSymbolDraw;
  26051. var group = this.group;
  26052. var symbolDraw = seriesModel.get('large') && data.count() > seriesModel.get('largeThreshold')
  26053. ? largeSymbolDraw : normalSymbolDraw;
  26054. this._symbolDraw = symbolDraw;
  26055. symbolDraw.updateData(data);
  26056. group.add(symbolDraw.group);
  26057. group.remove(
  26058. symbolDraw === largeSymbolDraw
  26059. ? normalSymbolDraw.group : largeSymbolDraw.group
  26060. );
  26061. },
  26062. updateLayout: function (seriesModel) {
  26063. this._symbolDraw.updateLayout(seriesModel);
  26064. },
  26065. remove: function (ecModel, api) {
  26066. this._symbolDraw && this._symbolDraw.remove(api, true);
  26067. },
  26068. dispose: function () {}
  26069. });
  26070. /***/ },
  26071. /* 152 */
  26072. /***/ function(module, exports, __webpack_require__) {
  26073. // TODO Batch by color
  26074. var graphic = __webpack_require__(43);
  26075. var symbolUtil = __webpack_require__(107);
  26076. var LargeSymbolPath = graphic.extendShape({
  26077. shape: {
  26078. points: null,
  26079. sizes: null
  26080. },
  26081. symbolProxy: null,
  26082. buildPath: function (path, shape) {
  26083. var points = shape.points;
  26084. var sizes = shape.sizes;
  26085. var symbolProxy = this.symbolProxy;
  26086. var symbolProxyShape = symbolProxy.shape;
  26087. for (var i = 0; i < points.length; i++) {
  26088. var pt = points[i];
  26089. var size = sizes[i];
  26090. if (size[0] < 4) {
  26091. // Optimize for small symbol
  26092. path.rect(
  26093. pt[0] - size[0] / 2, pt[1] - size[1] / 2,
  26094. size[0], size[1]
  26095. );
  26096. }
  26097. else {
  26098. symbolProxyShape.x = pt[0] - size[0] / 2;
  26099. symbolProxyShape.y = pt[1] - size[1] / 2;
  26100. symbolProxyShape.width = size[0];
  26101. symbolProxyShape.height = size[1];
  26102. symbolProxy.buildPath(path, symbolProxyShape, true);
  26103. }
  26104. }
  26105. },
  26106. findDataIndex: function (x, y) {
  26107. var shape = this.shape;
  26108. var points = shape.points;
  26109. var sizes = shape.sizes;
  26110. // Not consider transform
  26111. // Treat each element as a rect
  26112. // top down traverse
  26113. for (var i = points.length - 1; i >= 0; i--) {
  26114. var pt = points[i];
  26115. var size = sizes[i];
  26116. var x0 = pt[0] - size[0] / 2;
  26117. var y0 = pt[1] - size[1] / 2;
  26118. if (x >= x0 && y >= y0 && x <= x0 + size[0] && y <= y0 + size[1]) {
  26119. // i is dataIndex
  26120. return i;
  26121. }
  26122. }
  26123. return -1;
  26124. }
  26125. });
  26126. function LargeSymbolDraw() {
  26127. this.group = new graphic.Group();
  26128. this._symbolEl = new LargeSymbolPath({
  26129. // rectHover: true,
  26130. // cursor: 'default'
  26131. });
  26132. }
  26133. var largeSymbolProto = LargeSymbolDraw.prototype;
  26134. /**
  26135. * Update symbols draw by new data
  26136. * @param {module:echarts/data/List} data
  26137. */
  26138. largeSymbolProto.updateData = function (data) {
  26139. this.group.removeAll();
  26140. var symbolEl = this._symbolEl;
  26141. var seriesModel = data.hostModel;
  26142. symbolEl.setShape({
  26143. points: data.mapArray(data.getItemLayout),
  26144. sizes: data.mapArray(
  26145. function (idx) {
  26146. var size = data.getItemVisual(idx, 'symbolSize');
  26147. if (!(size instanceof Array)) {
  26148. size = [size, size];
  26149. }
  26150. return size;
  26151. }
  26152. )
  26153. });
  26154. // Create symbolProxy to build path for each data
  26155. symbolEl.symbolProxy = symbolUtil.createSymbol(
  26156. data.getVisual('symbol'), 0, 0, 0, 0
  26157. );
  26158. // Use symbolProxy setColor method
  26159. symbolEl.setColor = symbolEl.symbolProxy.setColor;
  26160. symbolEl.useStyle(
  26161. seriesModel.getModel('itemStyle.normal').getItemStyle(['color'])
  26162. );
  26163. var visualColor = data.getVisual('color');
  26164. if (visualColor) {
  26165. symbolEl.setColor(visualColor);
  26166. }
  26167. // Enable tooltip
  26168. // PENDING May have performance issue when path is extremely large
  26169. symbolEl.seriesIndex = seriesModel.seriesIndex;
  26170. symbolEl.on('mousemove', function (e) {
  26171. symbolEl.dataIndex = null;
  26172. var dataIndex = symbolEl.findDataIndex(e.offsetX, e.offsetY);
  26173. if (dataIndex > 0) {
  26174. // Provide dataIndex for tooltip
  26175. symbolEl.dataIndex = dataIndex;
  26176. }
  26177. });
  26178. // Add back
  26179. this.group.add(symbolEl);
  26180. };
  26181. largeSymbolProto.updateLayout = function (seriesModel) {
  26182. var data = seriesModel.getData();
  26183. this._symbolEl.setShape({
  26184. points: data.mapArray(data.getItemLayout)
  26185. });
  26186. };
  26187. largeSymbolProto.remove = function () {
  26188. this.group.removeAll();
  26189. };
  26190. module.exports = LargeSymbolDraw;
  26191. /***/ },
  26192. /* 153 */
  26193. /***/ function(module, exports, __webpack_require__) {
  26194. var zrUtil = __webpack_require__(4);
  26195. var echarts = __webpack_require__(1);
  26196. // Must use radar component
  26197. __webpack_require__(154);
  26198. __webpack_require__(159);
  26199. __webpack_require__(160);
  26200. echarts.registerVisual(zrUtil.curry(__webpack_require__(145), 'radar'));
  26201. echarts.registerVisual(zrUtil.curry(
  26202. __webpack_require__(110), 'radar', 'circle', null
  26203. ));
  26204. echarts.registerLayout(__webpack_require__(161));
  26205. echarts.registerProcessor(
  26206. zrUtil.curry(__webpack_require__(148), 'radar')
  26207. );
  26208. echarts.registerPreprocessor(__webpack_require__(162));
  26209. /***/ },
  26210. /* 154 */
  26211. /***/ function(module, exports, __webpack_require__) {
  26212. __webpack_require__(155);
  26213. __webpack_require__(157);
  26214. __webpack_require__(158);
  26215. /***/ },
  26216. /* 155 */
  26217. /***/ function(module, exports, __webpack_require__) {
  26218. // TODO clockwise
  26219. var zrUtil = __webpack_require__(4);
  26220. var IndicatorAxis = __webpack_require__(156);
  26221. var IntervalScale = __webpack_require__(118);
  26222. var numberUtil = __webpack_require__(7);
  26223. var axisHelper = __webpack_require__(115);
  26224. function Radar(radarModel, ecModel, api) {
  26225. this._model = radarModel;
  26226. /**
  26227. * Radar dimensions
  26228. * @type {Array.<string>}
  26229. */
  26230. this.dimensions = [];
  26231. this._indicatorAxes = zrUtil.map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
  26232. var dim = 'indicator_' + idx;
  26233. var indicatorAxis = new IndicatorAxis(dim, new IntervalScale());
  26234. indicatorAxis.name = indicatorModel.get('name');
  26235. // Inject model and axis
  26236. indicatorAxis.model = indicatorModel;
  26237. indicatorModel.axis = indicatorAxis;
  26238. this.dimensions.push(dim);
  26239. return indicatorAxis;
  26240. }, this);
  26241. this.resize(radarModel, api);
  26242. /**
  26243. * @type {number}
  26244. * @readOnly
  26245. */
  26246. this.cx;
  26247. /**
  26248. * @type {number}
  26249. * @readOnly
  26250. */
  26251. this.cy;
  26252. /**
  26253. * @type {number}
  26254. * @readOnly
  26255. */
  26256. this.r;
  26257. /**
  26258. * @type {number}
  26259. * @readOnly
  26260. */
  26261. this.startAngle;
  26262. }
  26263. Radar.prototype.getIndicatorAxes = function () {
  26264. return this._indicatorAxes;
  26265. };
  26266. Radar.prototype.dataToPoint = function (value, indicatorIndex) {
  26267. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  26268. return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
  26269. };
  26270. Radar.prototype.coordToPoint = function (coord, indicatorIndex) {
  26271. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  26272. var angle = indicatorAxis.angle;
  26273. var x = this.cx + coord * Math.cos(angle);
  26274. var y = this.cy - coord * Math.sin(angle);
  26275. return [x, y];
  26276. };
  26277. Radar.prototype.pointToData = function (pt) {
  26278. var dx = pt[0] - this.cx;
  26279. var dy = pt[1] - this.cy;
  26280. var radius = Math.sqrt(dx * dx + dy * dy);
  26281. dx /= radius;
  26282. dy /= radius;
  26283. var radian = Math.atan2(-dy, dx);
  26284. // Find the closest angle
  26285. // FIXME index can calculated directly
  26286. var minRadianDiff = Infinity;
  26287. var closestAxis;
  26288. var closestAxisIdx = -1;
  26289. for (var i = 0; i < this._indicatorAxes.length; i++) {
  26290. var indicatorAxis = this._indicatorAxes[i];
  26291. var diff = Math.abs(radian - indicatorAxis.angle);
  26292. if (diff < minRadianDiff) {
  26293. closestAxis = indicatorAxis;
  26294. closestAxisIdx = i;
  26295. minRadianDiff = diff;
  26296. }
  26297. }
  26298. return [closestAxisIdx, +(closestAxis && closestAxis.coodToData(radius))];
  26299. };
  26300. Radar.prototype.resize = function (radarModel, api) {
  26301. var center = radarModel.get('center');
  26302. var viewWidth = api.getWidth();
  26303. var viewHeight = api.getHeight();
  26304. var viewSize = Math.min(viewWidth, viewHeight) / 2;
  26305. this.cx = numberUtil.parsePercent(center[0], viewWidth);
  26306. this.cy = numberUtil.parsePercent(center[1], viewHeight);
  26307. this.startAngle = radarModel.get('startAngle') * Math.PI / 180;
  26308. this.r = numberUtil.parsePercent(radarModel.get('radius'), viewSize);
  26309. zrUtil.each(this._indicatorAxes, function (indicatorAxis, idx) {
  26310. indicatorAxis.setExtent(0, this.r);
  26311. var angle = (this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length);
  26312. // Normalize to [-PI, PI]
  26313. angle = Math.atan2(Math.sin(angle), Math.cos(angle));
  26314. indicatorAxis.angle = angle;
  26315. }, this);
  26316. };
  26317. Radar.prototype.update = function (ecModel, api) {
  26318. var indicatorAxes = this._indicatorAxes;
  26319. var radarModel = this._model;
  26320. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  26321. indicatorAxis.scale.setExtent(Infinity, -Infinity);
  26322. });
  26323. ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
  26324. if (radarSeries.get('coordinateSystem') !== 'radar'
  26325. || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel
  26326. ) {
  26327. return;
  26328. }
  26329. var data = radarSeries.getData();
  26330. zrUtil.each(indicatorAxes, function (indicatorAxis) {
  26331. indicatorAxis.scale.unionExtent(data.getDataExtent(indicatorAxis.dim));
  26332. });
  26333. }, this);
  26334. var splitNumber = radarModel.get('splitNumber');
  26335. function increaseInterval(interval) {
  26336. var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10));
  26337. // Increase interval
  26338. var f = interval / exp10;
  26339. if (f === 2) {
  26340. f = 5;
  26341. }
  26342. else { // f is 2 or 5
  26343. f *= 2;
  26344. }
  26345. return f * exp10;
  26346. }
  26347. // Force all the axis fixing the maxSplitNumber.
  26348. zrUtil.each(indicatorAxes, function (indicatorAxis, idx) {
  26349. var rawExtent = axisHelper.getScaleExtent(indicatorAxis, indicatorAxis.model);
  26350. axisHelper.niceScaleExtent(indicatorAxis, indicatorAxis.model);
  26351. var axisModel = indicatorAxis.model;
  26352. var scale = indicatorAxis.scale;
  26353. var fixedMin = axisModel.get('min');
  26354. var fixedMax = axisModel.get('max');
  26355. var interval = scale.getInterval();
  26356. if (fixedMin != null && fixedMax != null) {
  26357. // User set min, max, divide to get new interval
  26358. // FIXME precision
  26359. scale.setInterval(
  26360. (fixedMax - fixedMin) / splitNumber
  26361. );
  26362. }
  26363. else if (fixedMin != null) {
  26364. var max;
  26365. // User set min, expand extent on the other side
  26366. do {
  26367. max = fixedMin + interval * splitNumber;
  26368. scale.setExtent(+fixedMin, max);
  26369. // Interval must been set after extent
  26370. // FIXME
  26371. scale.setInterval(interval);
  26372. interval = increaseInterval(interval);
  26373. } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
  26374. }
  26375. else if (fixedMax != null) {
  26376. var min;
  26377. // User set min, expand extent on the other side
  26378. do {
  26379. min = fixedMax - interval * splitNumber;
  26380. scale.setExtent(min, +fixedMax);
  26381. scale.setInterval(interval);
  26382. interval = increaseInterval(interval);
  26383. } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
  26384. }
  26385. else {
  26386. var nicedSplitNumber = scale.getTicks().length - 1;
  26387. if (nicedSplitNumber > splitNumber) {
  26388. interval = increaseInterval(interval);
  26389. }
  26390. // PENDING
  26391. var center = Math.round((rawExtent[0] + rawExtent[1]) / 2 / interval) * interval;
  26392. var halfSplitNumber = Math.round(splitNumber / 2);
  26393. scale.setExtent(
  26394. numberUtil.round(center - halfSplitNumber * interval),
  26395. numberUtil.round(center + (splitNumber - halfSplitNumber) * interval)
  26396. );
  26397. scale.setInterval(interval);
  26398. }
  26399. });
  26400. };
  26401. /**
  26402. * Radar dimensions is based on the data
  26403. * @type {Array}
  26404. */
  26405. Radar.dimensions = [];
  26406. Radar.create = function (ecModel, api) {
  26407. var radarList = [];
  26408. ecModel.eachComponent('radar', function (radarModel) {
  26409. var radar = new Radar(radarModel, ecModel, api);
  26410. radarList.push(radar);
  26411. radarModel.coordinateSystem = radar;
  26412. });
  26413. ecModel.eachSeriesByType('radar', function (radarSeries) {
  26414. if (radarSeries.get('coordinateSystem') === 'radar') {
  26415. // Inject coordinate system
  26416. radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
  26417. }
  26418. });
  26419. return radarList;
  26420. };
  26421. __webpack_require__(26).register('radar', Radar);
  26422. module.exports = Radar;
  26423. /***/ },
  26424. /* 156 */
  26425. /***/ function(module, exports, __webpack_require__) {
  26426. var zrUtil = __webpack_require__(4);
  26427. var Axis = __webpack_require__(124);
  26428. function IndicatorAxis(dim, scale, radiusExtent) {
  26429. Axis.call(this, dim, scale, radiusExtent);
  26430. /**
  26431. * Axis type
  26432. * - 'category'
  26433. * - 'value'
  26434. * - 'time'
  26435. * - 'log'
  26436. * @type {string}
  26437. */
  26438. this.type = 'value';
  26439. this.angle = 0;
  26440. /**
  26441. * Indicator name
  26442. * @type {string}
  26443. */
  26444. this.name = '';
  26445. /**
  26446. * @type {module:echarts/model/Model}
  26447. */
  26448. this.model;
  26449. }
  26450. zrUtil.inherits(IndicatorAxis, Axis);
  26451. module.exports = IndicatorAxis;
  26452. /***/ },
  26453. /* 157 */
  26454. /***/ function(module, exports, __webpack_require__) {
  26455. var axisDefault = __webpack_require__(129);
  26456. var valueAxisDefault = axisDefault.valueAxis;
  26457. var Model = __webpack_require__(12);
  26458. var zrUtil = __webpack_require__(4);
  26459. var axisModelCommonMixin = __webpack_require__(130);
  26460. function defaultsShow(opt, show) {
  26461. return zrUtil.defaults({
  26462. show: show
  26463. }, opt);
  26464. }
  26465. var RadarModel = __webpack_require__(1).extendComponentModel({
  26466. type: 'radar',
  26467. optionUpdated: function () {
  26468. var boundaryGap = this.get('boundaryGap');
  26469. var splitNumber = this.get('splitNumber');
  26470. var scale = this.get('scale');
  26471. var axisLine = this.get('axisLine');
  26472. var axisTick = this.get('axisTick');
  26473. var axisLabel = this.get('axisLabel');
  26474. var nameTextStyle = this.get('name.textStyle');
  26475. var showName = this.get('name.show');
  26476. var nameFormatter = this.get('name.formatter');
  26477. var nameGap = this.get('nameGap');
  26478. var triggerEvent = this.get('triggerEvent');
  26479. var indicatorModels = zrUtil.map(this.get('indicator') || [], function (indicatorOpt) {
  26480. // PENDING
  26481. if (indicatorOpt.max != null && indicatorOpt.max > 0 && !indicatorOpt.min) {
  26482. indicatorOpt.min = 0;
  26483. }
  26484. else if (indicatorOpt.min != null && indicatorOpt.min < 0 && !indicatorOpt.max) {
  26485. indicatorOpt.max = 0;
  26486. }
  26487. // Use same configuration
  26488. indicatorOpt = zrUtil.merge(zrUtil.clone(indicatorOpt), {
  26489. boundaryGap: boundaryGap,
  26490. splitNumber: splitNumber,
  26491. scale: scale,
  26492. axisLine: axisLine,
  26493. axisTick: axisTick,
  26494. axisLabel: axisLabel,
  26495. // Competitable with 2 and use text
  26496. name: indicatorOpt.text,
  26497. nameLocation: 'end',
  26498. nameGap: nameGap,
  26499. // min: 0,
  26500. nameTextStyle: nameTextStyle,
  26501. triggerEvent: triggerEvent
  26502. }, false);
  26503. if (!showName) {
  26504. indicatorOpt.name = '';
  26505. }
  26506. if (typeof nameFormatter === 'string') {
  26507. var indName = indicatorOpt.name;
  26508. indicatorOpt.name = nameFormatter.replace('{value}', indName != null ? indName : '');
  26509. }
  26510. else if (typeof nameFormatter === 'function') {
  26511. indicatorOpt.name = nameFormatter(
  26512. indicatorOpt.name, indicatorOpt
  26513. );
  26514. }
  26515. var model = zrUtil.extend(
  26516. new Model(indicatorOpt, null, this.ecModel),
  26517. axisModelCommonMixin
  26518. );
  26519. // For triggerEvent.
  26520. model.mainType = 'radar';
  26521. model.componentIndex = this.componentIndex;
  26522. return model;
  26523. }, this);
  26524. this.getIndicatorModels = function () {
  26525. return indicatorModels;
  26526. };
  26527. },
  26528. defaultOption: {
  26529. zlevel: 0,
  26530. z: 0,
  26531. center: ['50%', '50%'],
  26532. radius: '75%',
  26533. startAngle: 90,
  26534. name: {
  26535. show: true
  26536. // formatter: null
  26537. // textStyle: {}
  26538. },
  26539. boundaryGap: [0, 0],
  26540. splitNumber: 5,
  26541. nameGap: 15,
  26542. scale: false,
  26543. // Polygon or circle
  26544. shape: 'polygon',
  26545. axisLine: zrUtil.merge(
  26546. {
  26547. lineStyle: {
  26548. color: '#bbb'
  26549. }
  26550. },
  26551. valueAxisDefault.axisLine
  26552. ),
  26553. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  26554. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  26555. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  26556. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  26557. // {text, min, max}
  26558. indicator: []
  26559. }
  26560. });
  26561. module.exports = RadarModel;
  26562. /***/ },
  26563. /* 158 */
  26564. /***/ function(module, exports, __webpack_require__) {
  26565. var AxisBuilder = __webpack_require__(134);
  26566. var zrUtil = __webpack_require__(4);
  26567. var graphic = __webpack_require__(43);
  26568. var axisBuilderAttrs = [
  26569. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  26570. ];
  26571. module.exports = __webpack_require__(1).extendComponentView({
  26572. type: 'radar',
  26573. render: function (radarModel, ecModel, api) {
  26574. var group = this.group;
  26575. group.removeAll();
  26576. this._buildAxes(radarModel);
  26577. this._buildSplitLineAndArea(radarModel);
  26578. },
  26579. _buildAxes: function (radarModel) {
  26580. var radar = radarModel.coordinateSystem;
  26581. var indicatorAxes = radar.getIndicatorAxes();
  26582. var axisBuilders = zrUtil.map(indicatorAxes, function (indicatorAxis) {
  26583. var axisBuilder = new AxisBuilder(indicatorAxis.model, {
  26584. position: [radar.cx, radar.cy],
  26585. rotation: indicatorAxis.angle,
  26586. labelDirection: -1,
  26587. tickDirection: -1,
  26588. nameDirection: 1
  26589. });
  26590. return axisBuilder;
  26591. });
  26592. zrUtil.each(axisBuilders, function (axisBuilder) {
  26593. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  26594. this.group.add(axisBuilder.getGroup());
  26595. }, this);
  26596. },
  26597. _buildSplitLineAndArea: function (radarModel) {
  26598. var radar = radarModel.coordinateSystem;
  26599. var splitNumber = radarModel.get('splitNumber');
  26600. var indicatorAxes = radar.getIndicatorAxes();
  26601. if (!indicatorAxes.length) {
  26602. return;
  26603. }
  26604. var shape = radarModel.get('shape');
  26605. var splitLineModel = radarModel.getModel('splitLine');
  26606. var splitAreaModel = radarModel.getModel('splitArea');
  26607. var lineStyleModel = splitLineModel.getModel('lineStyle');
  26608. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  26609. var showSplitLine = splitLineModel.get('show');
  26610. var showSplitArea = splitAreaModel.get('show');
  26611. var splitLineColors = lineStyleModel.get('color');
  26612. var splitAreaColors = areaStyleModel.get('color');
  26613. splitLineColors = zrUtil.isArray(splitLineColors) ? splitLineColors : [splitLineColors];
  26614. splitAreaColors = zrUtil.isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors];
  26615. var splitLines = [];
  26616. var splitAreas = [];
  26617. function getColorIndex(areaOrLine, areaOrLineColorList, idx) {
  26618. var colorIndex = idx % areaOrLineColorList.length;
  26619. areaOrLine[colorIndex] = areaOrLine[colorIndex] || [];
  26620. return colorIndex;
  26621. }
  26622. if (shape === 'circle') {
  26623. var ticksRadius = indicatorAxes[0].getTicksCoords();
  26624. var cx = radar.cx;
  26625. var cy = radar.cy;
  26626. for (var i = 0; i < ticksRadius.length; i++) {
  26627. if (showSplitLine) {
  26628. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  26629. splitLines[colorIndex].push(new graphic.Circle({
  26630. shape: {
  26631. cx: cx,
  26632. cy: cy,
  26633. r: ticksRadius[i]
  26634. }
  26635. }));
  26636. }
  26637. if (showSplitArea && i < ticksRadius.length - 1) {
  26638. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i);
  26639. splitAreas[colorIndex].push(new graphic.Ring({
  26640. shape: {
  26641. cx: cx,
  26642. cy: cy,
  26643. r0: ticksRadius[i],
  26644. r: ticksRadius[i + 1]
  26645. }
  26646. }));
  26647. }
  26648. }
  26649. }
  26650. // Polyyon
  26651. else {
  26652. var axesTicksPoints = zrUtil.map(indicatorAxes, function (indicatorAxis, idx) {
  26653. var ticksCoords = indicatorAxis.getTicksCoords();
  26654. return zrUtil.map(ticksCoords, function (tickCoord) {
  26655. return radar.coordToPoint(tickCoord, idx);
  26656. });
  26657. });
  26658. var prevPoints = [];
  26659. for (var i = 0; i <= splitNumber; i++) {
  26660. var points = [];
  26661. for (var j = 0; j < indicatorAxes.length; j++) {
  26662. points.push(axesTicksPoints[j][i]);
  26663. }
  26664. // Close
  26665. if (points[0]) {
  26666. points.push(points[0].slice());
  26667. }
  26668. else {
  26669. if (true) {
  26670. console.error('Can\'t draw value axis ' + i);
  26671. }
  26672. }
  26673. if (showSplitLine) {
  26674. var colorIndex = getColorIndex(splitLines, splitLineColors, i);
  26675. splitLines[colorIndex].push(new graphic.Polyline({
  26676. shape: {
  26677. points: points
  26678. }
  26679. }));
  26680. }
  26681. if (showSplitArea && prevPoints) {
  26682. var colorIndex = getColorIndex(splitAreas, splitAreaColors, i - 1);
  26683. splitAreas[colorIndex].push(new graphic.Polygon({
  26684. shape: {
  26685. points: points.concat(prevPoints)
  26686. }
  26687. }));
  26688. }
  26689. prevPoints = points.slice().reverse();
  26690. }
  26691. }
  26692. var lineStyle = lineStyleModel.getLineStyle();
  26693. var areaStyle = areaStyleModel.getAreaStyle();
  26694. // Add splitArea before splitLine
  26695. zrUtil.each(splitAreas, function (splitAreas, idx) {
  26696. this.group.add(graphic.mergePath(
  26697. splitAreas, {
  26698. style: zrUtil.defaults({
  26699. stroke: 'none',
  26700. fill: splitAreaColors[idx % splitAreaColors.length]
  26701. }, areaStyle),
  26702. silent: true
  26703. }
  26704. ));
  26705. }, this);
  26706. zrUtil.each(splitLines, function (splitLines, idx) {
  26707. this.group.add(graphic.mergePath(
  26708. splitLines, {
  26709. style: zrUtil.defaults({
  26710. fill: 'none',
  26711. stroke: splitLineColors[idx % splitLineColors.length]
  26712. }, lineStyle),
  26713. silent: true
  26714. }
  26715. ));
  26716. }, this);
  26717. }
  26718. });
  26719. /***/ },
  26720. /* 159 */
  26721. /***/ function(module, exports, __webpack_require__) {
  26722. 'use strict';
  26723. var SeriesModel = __webpack_require__(28);
  26724. var List = __webpack_require__(98);
  26725. var completeDimensions = __webpack_require__(103);
  26726. var zrUtil = __webpack_require__(4);
  26727. var RadarSeries = SeriesModel.extend({
  26728. type: 'series.radar',
  26729. dependencies: ['radar'],
  26730. // Overwrite
  26731. init: function (option) {
  26732. RadarSeries.superApply(this, 'init', arguments);
  26733. // Enable legend selection for each data item
  26734. // Use a function instead of direct access because data reference may changed
  26735. this.legendDataProvider = function () {
  26736. return this._dataBeforeProcessed;
  26737. };
  26738. },
  26739. getInitialData: function (option, ecModel) {
  26740. var data = option.data || [];
  26741. var dimensions = completeDimensions(
  26742. [], data, [], 'indicator_'
  26743. );
  26744. var list = new List(dimensions, this);
  26745. list.initData(data);
  26746. return list;
  26747. },
  26748. formatTooltip: function (dataIndex) {
  26749. var value = this.getRawValue(dataIndex);
  26750. var coordSys = this.coordinateSystem;
  26751. var indicatorAxes = coordSys.getIndicatorAxes();
  26752. return (this._data.getName(dataIndex) == '' ? this.name : this._data.getName(dataIndex)) + '<br/>'
  26753. + zrUtil.map(indicatorAxes, function (axis, idx) {
  26754. return axis.name + ' : ' + value[idx];
  26755. }).join('<br />');
  26756. },
  26757. defaultOption: {
  26758. zlevel: 0,
  26759. z: 2,
  26760. coordinateSystem: 'radar',
  26761. legendHoverLink: true,
  26762. radarIndex: 0,
  26763. lineStyle: {
  26764. normal: {
  26765. width: 2,
  26766. type: 'solid'
  26767. }
  26768. },
  26769. label: {
  26770. normal: {
  26771. position: 'top'
  26772. }
  26773. },
  26774. // areaStyle: {
  26775. // },
  26776. // itemStyle: {}
  26777. symbol: 'emptyCircle',
  26778. symbolSize: 4
  26779. // symbolRotate: null
  26780. }
  26781. });
  26782. module.exports = RadarSeries;
  26783. /***/ },
  26784. /* 160 */
  26785. /***/ function(module, exports, __webpack_require__) {
  26786. var graphic = __webpack_require__(43);
  26787. var zrUtil = __webpack_require__(4);
  26788. var symbolUtil = __webpack_require__(107);
  26789. function normalizeSymbolSize(symbolSize) {
  26790. if (!zrUtil.isArray(symbolSize)) {
  26791. symbolSize = [+symbolSize, +symbolSize];
  26792. }
  26793. return symbolSize;
  26794. }
  26795. module.exports = __webpack_require__(1).extendChartView({
  26796. type: 'radar',
  26797. render: function (seriesModel, ecModel, api) {
  26798. var polar = seriesModel.coordinateSystem;
  26799. var group = this.group;
  26800. var data = seriesModel.getData();
  26801. var oldData = this._data;
  26802. function createSymbol(data, idx) {
  26803. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  26804. var color = data.getItemVisual(idx, 'color');
  26805. if (symbolType === 'none') {
  26806. return;
  26807. }
  26808. var symbolPath = symbolUtil.createSymbol(
  26809. symbolType, -0.5, -0.5, 1, 1, color
  26810. );
  26811. symbolPath.attr({
  26812. style: {
  26813. strokeNoScale: true
  26814. },
  26815. z2: 100,
  26816. scale: normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'))
  26817. });
  26818. return symbolPath;
  26819. }
  26820. function updateSymbols(oldPoints, newPoints, symbolGroup, data, idx, isInit) {
  26821. // Simply rerender all
  26822. symbolGroup.removeAll();
  26823. for (var i = 0; i < newPoints.length - 1; i++) {
  26824. var symbolPath = createSymbol(data, idx);
  26825. if (symbolPath) {
  26826. symbolPath.__dimIdx = i;
  26827. if (oldPoints[i]) {
  26828. symbolPath.attr('position', oldPoints[i]);
  26829. graphic[isInit ? 'initProps' : 'updateProps'](
  26830. symbolPath, {
  26831. position: newPoints[i]
  26832. }, seriesModel, idx
  26833. );
  26834. }
  26835. else {
  26836. symbolPath.attr('position', newPoints[i]);
  26837. }
  26838. symbolGroup.add(symbolPath);
  26839. }
  26840. }
  26841. }
  26842. function getInitialPoints(points) {
  26843. return zrUtil.map(points, function (pt) {
  26844. return [polar.cx, polar.cy];
  26845. });
  26846. }
  26847. data.diff(oldData)
  26848. .add(function (idx) {
  26849. var points = data.getItemLayout(idx);
  26850. if (!points) {
  26851. return;
  26852. }
  26853. var polygon = new graphic.Polygon();
  26854. var polyline = new graphic.Polyline();
  26855. var target = {
  26856. shape: {
  26857. points: points
  26858. }
  26859. };
  26860. polygon.shape.points = getInitialPoints(points);
  26861. polyline.shape.points = getInitialPoints(points);
  26862. graphic.initProps(polygon, target, seriesModel, idx);
  26863. graphic.initProps(polyline, target, seriesModel, idx);
  26864. var itemGroup = new graphic.Group();
  26865. var symbolGroup = new graphic.Group();
  26866. itemGroup.add(polyline);
  26867. itemGroup.add(polygon);
  26868. itemGroup.add(symbolGroup);
  26869. updateSymbols(
  26870. polyline.shape.points, points, symbolGroup, data, idx, true
  26871. );
  26872. data.setItemGraphicEl(idx, itemGroup);
  26873. })
  26874. .update(function (newIdx, oldIdx) {
  26875. var itemGroup = oldData.getItemGraphicEl(oldIdx);
  26876. var polyline = itemGroup.childAt(0);
  26877. var polygon = itemGroup.childAt(1);
  26878. var symbolGroup = itemGroup.childAt(2);
  26879. var target = {
  26880. shape: {
  26881. points: data.getItemLayout(newIdx)
  26882. }
  26883. };
  26884. if (!target.shape.points) {
  26885. return;
  26886. }
  26887. updateSymbols(
  26888. polyline.shape.points, target.shape.points, symbolGroup, data, newIdx, false
  26889. );
  26890. graphic.updateProps(polyline, target, seriesModel);
  26891. graphic.updateProps(polygon, target, seriesModel);
  26892. data.setItemGraphicEl(newIdx, itemGroup);
  26893. })
  26894. .remove(function (idx) {
  26895. group.remove(oldData.getItemGraphicEl(idx));
  26896. })
  26897. .execute();
  26898. data.eachItemGraphicEl(function (itemGroup, idx) {
  26899. var itemModel = data.getItemModel(idx);
  26900. var polyline = itemGroup.childAt(0);
  26901. var polygon = itemGroup.childAt(1);
  26902. var symbolGroup = itemGroup.childAt(2);
  26903. var color = data.getItemVisual(idx, 'color');
  26904. group.add(itemGroup);
  26905. polyline.useStyle(
  26906. zrUtil.defaults(
  26907. itemModel.getModel('lineStyle.normal').getLineStyle(),
  26908. {
  26909. fill: 'none',
  26910. stroke: color
  26911. }
  26912. )
  26913. );
  26914. polyline.hoverStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  26915. var areaStyleModel = itemModel.getModel('areaStyle.normal');
  26916. var hoverAreaStyleModel = itemModel.getModel('areaStyle.emphasis');
  26917. var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty();
  26918. var hoverPolygonIgnore = hoverAreaStyleModel.isEmpty() && hoverAreaStyleModel.parentModel.isEmpty();
  26919. hoverPolygonIgnore = hoverPolygonIgnore && polygonIgnore;
  26920. polygon.ignore = polygonIgnore;
  26921. polygon.useStyle(
  26922. zrUtil.defaults(
  26923. areaStyleModel.getAreaStyle(),
  26924. {
  26925. fill: color,
  26926. opacity: 0.7
  26927. }
  26928. )
  26929. );
  26930. polygon.hoverStyle = hoverAreaStyleModel.getAreaStyle();
  26931. var itemStyle = itemModel.getModel('itemStyle.normal').getItemStyle(['color']);
  26932. var itemHoverStyle = itemModel.getModel('itemStyle.emphasis').getItemStyle();
  26933. var labelModel = itemModel.getModel('label.normal');
  26934. var labelHoverModel = itemModel.getModel('label.emphasis');
  26935. symbolGroup.eachChild(function (symbolPath) {
  26936. symbolPath.setStyle(itemStyle);
  26937. symbolPath.hoverStyle = zrUtil.clone(itemHoverStyle);
  26938. var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
  26939. graphic.setText(symbolPath.style, labelModel, color);
  26940. symbolPath.setStyle({
  26941. text: labelModel.get('show') ? zrUtil.retrieve(
  26942. seriesModel.getFormattedLabel(
  26943. idx, 'normal', null, symbolPath.__dimIdx
  26944. ),
  26945. defaultText
  26946. ) : ''
  26947. });
  26948. graphic.setText(symbolPath.hoverStyle, labelHoverModel, color);
  26949. symbolPath.hoverStyle.text = labelHoverModel.get('show') ? zrUtil.retrieve(
  26950. seriesModel.getFormattedLabel(
  26951. idx, 'emphasis', null, symbolPath.__dimIdx
  26952. ),
  26953. defaultText
  26954. ) : '';
  26955. });
  26956. function onEmphasis() {
  26957. polygon.attr('ignore', hoverPolygonIgnore);
  26958. }
  26959. function onNormal() {
  26960. polygon.attr('ignore', polygonIgnore);
  26961. }
  26962. itemGroup.off('mouseover').off('mouseout').off('normal').off('emphasis');
  26963. itemGroup.on('emphasis', onEmphasis)
  26964. .on('mouseover', onEmphasis)
  26965. .on('normal', onNormal)
  26966. .on('mouseout', onNormal);
  26967. graphic.setHoverStyle(itemGroup);
  26968. });
  26969. this._data = data;
  26970. },
  26971. remove: function () {
  26972. this.group.removeAll();
  26973. this._data = null;
  26974. },
  26975. dispose: function () {}
  26976. });
  26977. /***/ },
  26978. /* 161 */
  26979. /***/ function(module, exports) {
  26980. module.exports = function (ecModel) {
  26981. ecModel.eachSeriesByType('radar', function (seriesModel) {
  26982. var data = seriesModel.getData();
  26983. var points = [];
  26984. var coordSys = seriesModel.coordinateSystem;
  26985. if (!coordSys) {
  26986. return;
  26987. }
  26988. function pointsConverter(val, idx) {
  26989. points[idx] = points[idx] || [];
  26990. points[idx][i] = coordSys.dataToPoint(val, i);
  26991. }
  26992. for (var i = 0; i < coordSys.getIndicatorAxes().length; i++) {
  26993. var dim = data.dimensions[i];
  26994. data.each(dim, pointsConverter);
  26995. }
  26996. data.each(function (idx) {
  26997. // Close polygon
  26998. points[idx][0] && points[idx].push(points[idx][0].slice());
  26999. data.setItemLayout(idx, points[idx]);
  27000. });
  27001. });
  27002. };
  27003. /***/ },
  27004. /* 162 */
  27005. /***/ function(module, exports, __webpack_require__) {
  27006. // Backward compat for radar chart in 2
  27007. var zrUtil = __webpack_require__(4);
  27008. module.exports = function (option) {
  27009. var polarOptArr = option.polar;
  27010. if (polarOptArr) {
  27011. if (!zrUtil.isArray(polarOptArr)) {
  27012. polarOptArr = [polarOptArr];
  27013. }
  27014. var polarNotRadar = [];
  27015. zrUtil.each(polarOptArr, function (polarOpt, idx) {
  27016. if (polarOpt.indicator) {
  27017. if (polarOpt.type && !polarOpt.shape) {
  27018. polarOpt.shape = polarOpt.type;
  27019. }
  27020. option.radar = option.radar || [];
  27021. if (!zrUtil.isArray(option.radar)) {
  27022. option.radar = [option.radar];
  27023. }
  27024. option.radar.push(polarOpt);
  27025. }
  27026. else {
  27027. polarNotRadar.push(polarOpt);
  27028. }
  27029. });
  27030. option.polar = polarNotRadar;
  27031. }
  27032. zrUtil.each(option.series, function (seriesOpt) {
  27033. if (seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
  27034. seriesOpt.radarIndex = seriesOpt.polarIndex;
  27035. }
  27036. });
  27037. };
  27038. /***/ },
  27039. /* 163 */
  27040. /***/ function(module, exports, __webpack_require__) {
  27041. var echarts = __webpack_require__(1);
  27042. var PRIORITY = echarts.PRIORITY;
  27043. __webpack_require__(164);
  27044. __webpack_require__(174);
  27045. __webpack_require__(178);
  27046. __webpack_require__(165);
  27047. echarts.registerLayout(__webpack_require__(180));
  27048. echarts.registerVisual(__webpack_require__(181));
  27049. echarts.registerProcessor(PRIORITY.PROCESSOR.STATISTIC, __webpack_require__(182));
  27050. echarts.registerPreprocessor(__webpack_require__(183));
  27051. __webpack_require__(144)('map', [{
  27052. type: 'mapToggleSelect',
  27053. event: 'mapselectchanged',
  27054. method: 'toggleSelected'
  27055. }, {
  27056. type: 'mapSelect',
  27057. event: 'mapselected',
  27058. method: 'select'
  27059. }, {
  27060. type: 'mapUnSelect',
  27061. event: 'mapunselected',
  27062. method: 'unSelect'
  27063. }]);
  27064. /***/ },
  27065. /* 164 */
  27066. /***/ function(module, exports, __webpack_require__) {
  27067. var List = __webpack_require__(98);
  27068. var SeriesModel = __webpack_require__(28);
  27069. var zrUtil = __webpack_require__(4);
  27070. var completeDimensions = __webpack_require__(103);
  27071. var formatUtil = __webpack_require__(6);
  27072. var encodeHTML = formatUtil.encodeHTML;
  27073. var addCommas = formatUtil.addCommas;
  27074. var dataSelectableMixin = __webpack_require__(142);
  27075. var geoCreator = __webpack_require__(165);
  27076. var MapSeries = SeriesModel.extend({
  27077. type: 'series.map',
  27078. layoutMode: 'box',
  27079. /**
  27080. * Only first map series of same mapType will drawMap
  27081. * @type {boolean}
  27082. */
  27083. needsDrawMap: false,
  27084. /**
  27085. * Group of all map series with same mapType
  27086. * @type {boolean}
  27087. */
  27088. seriesGroup: [],
  27089. init: function (option) {
  27090. option = this._fillOption(option, option.map);
  27091. this.option = option;
  27092. MapSeries.superApply(this, 'init', arguments);
  27093. this.updateSelectedMap(option.data);
  27094. },
  27095. getInitialData: function (option) {
  27096. var dimensions = completeDimensions(['value'], option.data || []);
  27097. var list = new List(dimensions, this);
  27098. list.initData(option.data);
  27099. return list;
  27100. },
  27101. mergeOption: function (newOption) {
  27102. if (newOption.data) {
  27103. newOption = this._fillOption(newOption, this.option.map);
  27104. }
  27105. MapSeries.superCall(this, 'mergeOption', newOption);
  27106. this.updateSelectedMap(this.option.data);
  27107. },
  27108. _fillOption: function (option, mapName) {
  27109. // Shallow clone
  27110. option = zrUtil.extend({}, option);
  27111. option.data = geoCreator.getFilledRegions(option.data, mapName);
  27112. return option;
  27113. },
  27114. getRawValue: function (dataIndex) {
  27115. // Use value stored in data instead because it is calculated from multiple series
  27116. // FIXME Provide all value of multiple series ?
  27117. return this._data.get('value', dataIndex);
  27118. },
  27119. /**
  27120. * Get model of region
  27121. * @param {string} name
  27122. * @return {module:echarts/model/Model}
  27123. */
  27124. getRegionModel: function (regionName) {
  27125. var data = this.getData();
  27126. return data.getItemModel(data.indexOfName(regionName));
  27127. },
  27128. /**
  27129. * Map tooltip formatter
  27130. *
  27131. * @param {number} dataIndex
  27132. */
  27133. formatTooltip: function (dataIndex) {
  27134. // FIXME orignalData and data is a bit confusing
  27135. var data = this.getData();
  27136. var formattedValue = addCommas(this.getRawValue(dataIndex));
  27137. var name = data.getName(dataIndex);
  27138. var seriesGroup = this.seriesGroup;
  27139. var seriesNames = [];
  27140. for (var i = 0; i < seriesGroup.length; i++) {
  27141. var otherIndex = seriesGroup[i].originalData.indexOfName(name);
  27142. if (!isNaN(seriesGroup[i].originalData.get('value', otherIndex))) {
  27143. seriesNames.push(
  27144. encodeHTML(seriesGroup[i].name)
  27145. );
  27146. }
  27147. }
  27148. return seriesNames.join(', ') + '<br />'
  27149. + name + ' : ' + formattedValue;
  27150. },
  27151. /**
  27152. * @implement
  27153. */
  27154. getTooltipPosition: function (dataIndex) {
  27155. if (dataIndex != null) {
  27156. var name = this.getData().getName(dataIndex);
  27157. var geo = this.coordinateSystem;
  27158. var region = geo.getRegion(name);
  27159. return region && geo.dataToPoint(region.center);
  27160. }
  27161. },
  27162. setZoom: function (zoom) {
  27163. this.option.zoom = zoom;
  27164. },
  27165. setCenter: function (center) {
  27166. this.option.center = center;
  27167. },
  27168. defaultOption: {
  27169. // 一级层叠
  27170. zlevel: 0,
  27171. // 二级层叠
  27172. z: 2,
  27173. coordinateSystem: 'geo',
  27174. // 各省的 map 暂时都用中文
  27175. map: 'china',
  27176. // 'center' | 'left' | 'right' | 'x%' | {number}
  27177. left: 'center',
  27178. // 'center' | 'top' | 'bottom' | 'x%' | {number}
  27179. top: 'center',
  27180. // right
  27181. // bottom
  27182. // width:
  27183. // height
  27184. // Aspect is width / height. Inited to be geoJson bbox aspect
  27185. // This parameter is used for scale this aspect
  27186. aspectScale: 0.75,
  27187. ///// Layout with center and size
  27188. // If you wan't to put map in a fixed size box with right aspect ratio
  27189. // This two properties may more conveninet
  27190. // layoutCenter: [50%, 50%]
  27191. // layoutSize: 100
  27192. // 数值合并方式,默认加和,可选为:
  27193. // 'sum' | 'average' | 'max' | 'min'
  27194. // mapValueCalculation: 'sum',
  27195. // 地图数值计算结果小数精度
  27196. // mapValuePrecision: 0,
  27197. // 显示图例颜色标识(系列标识的小圆点),图例开启时有效
  27198. showLegendSymbol: true,
  27199. // 选择模式,默认关闭,可选single,multiple
  27200. // selectedMode: false,
  27201. dataRangeHoverLink: true,
  27202. // 是否开启缩放及漫游模式
  27203. // roam: false,
  27204. // Default on center of map
  27205. center: null,
  27206. zoom: 1,
  27207. scaleLimit: null,
  27208. label: {
  27209. normal: {
  27210. show: false,
  27211. textStyle: {
  27212. color: '#000'
  27213. }
  27214. },
  27215. emphasis: {
  27216. show: true,
  27217. textStyle: {
  27218. color: 'rgb(100,0,0)'
  27219. }
  27220. }
  27221. },
  27222. // scaleLimit: null,
  27223. itemStyle: {
  27224. normal: {
  27225. // color: 各异,
  27226. borderWidth: 0.5,
  27227. borderColor: '#444',
  27228. areaColor: '#eee'
  27229. },
  27230. // 也是选中样式
  27231. emphasis: {
  27232. areaColor: 'rgba(255,215,0,0.8)'
  27233. }
  27234. }
  27235. }
  27236. });
  27237. zrUtil.mixin(MapSeries, dataSelectableMixin);
  27238. module.exports = MapSeries;
  27239. /***/ },
  27240. /* 165 */
  27241. /***/ function(module, exports, __webpack_require__) {
  27242. var Geo = __webpack_require__(166);
  27243. var layout = __webpack_require__(21);
  27244. var zrUtil = __webpack_require__(4);
  27245. var numberUtil = __webpack_require__(7);
  27246. var mapDataStores = {};
  27247. /**
  27248. * Resize method bound to the geo
  27249. * @param {module:echarts/coord/geo/GeoModel|module:echarts/chart/map/MapModel} geoModel
  27250. * @param {module:echarts/ExtensionAPI} api
  27251. */
  27252. function resizeGeo (geoModel, api) {
  27253. var rect = this.getBoundingRect();
  27254. var boxLayoutOption;
  27255. var center = geoModel.get('layoutCenter');
  27256. var size = geoModel.get('layoutSize');
  27257. var viewWidth = api.getWidth();
  27258. var viewHeight = api.getHeight();
  27259. var aspectScale = geoModel.get('aspectScale') || 0.75;
  27260. var aspect = rect.width / rect.height * aspectScale;
  27261. var useCenterAndSize = false;
  27262. if (center && size) {
  27263. center = [
  27264. numberUtil.parsePercent(center[0], viewWidth),
  27265. numberUtil.parsePercent(center[1], viewHeight)
  27266. ];
  27267. size = numberUtil.parsePercent(size, Math.min(viewWidth, viewHeight));
  27268. if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
  27269. useCenterAndSize = true;
  27270. }
  27271. else {
  27272. if (true) {
  27273. console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
  27274. }
  27275. }
  27276. }
  27277. var viewRect;
  27278. if (useCenterAndSize) {
  27279. var viewRect = {};
  27280. if (aspect > 1) {
  27281. // Width is same with size
  27282. viewRect.width = size;
  27283. viewRect.height = size / aspect;
  27284. }
  27285. else {
  27286. viewRect.height = size;
  27287. viewRect.width = size * aspect;
  27288. }
  27289. viewRect.y = center[1] - viewRect.height / 2;
  27290. viewRect.x = center[0] - viewRect.width / 2;
  27291. }
  27292. else {
  27293. // Use left/top/width/height
  27294. boxLayoutOption = geoModel.getBoxLayoutParams();
  27295. // 0.75 rate
  27296. boxLayoutOption.aspect = aspect;
  27297. viewRect = layout.getLayoutRect(boxLayoutOption, {
  27298. width: viewWidth,
  27299. height: viewHeight
  27300. });
  27301. }
  27302. this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
  27303. this.setCenter(geoModel.get('center'));
  27304. this.setZoom(geoModel.get('zoom'));
  27305. }
  27306. /**
  27307. * @param {module:echarts/coord/Geo} geo
  27308. * @param {module:echarts/model/Model} model
  27309. * @inner
  27310. */
  27311. function setGeoCoords(geo, model) {
  27312. zrUtil.each(model.get('geoCoord'), function (geoCoord, name) {
  27313. geo.addGeoCoord(name, geoCoord);
  27314. });
  27315. }
  27316. if (true) {
  27317. var mapNotExistsError = function (name) {
  27318. console.error('Map ' + name + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html');
  27319. };
  27320. }
  27321. var geoCreator = {
  27322. // For deciding which dimensions to use when creating list data
  27323. dimensions: Geo.prototype.dimensions,
  27324. create: function (ecModel, api) {
  27325. var geoList = [];
  27326. // FIXME Create each time may be slow
  27327. ecModel.eachComponent('geo', function (geoModel, idx) {
  27328. var name = geoModel.get('map');
  27329. var mapData = mapDataStores[name];
  27330. if (true) {
  27331. if (!mapData) {
  27332. mapNotExistsError(name);
  27333. }
  27334. }
  27335. var geo = new Geo(
  27336. name + idx, name,
  27337. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  27338. geoModel.get('nameMap')
  27339. );
  27340. geo.zoomLimit = geoModel.get('scaleLimit');
  27341. geoList.push(geo);
  27342. setGeoCoords(geo, geoModel);
  27343. geoModel.coordinateSystem = geo;
  27344. geo.model = geoModel;
  27345. // Inject resize method
  27346. geo.resize = resizeGeo;
  27347. geo.resize(geoModel, api);
  27348. });
  27349. ecModel.eachSeries(function (seriesModel) {
  27350. var coordSys = seriesModel.get('coordinateSystem');
  27351. if (coordSys === 'geo') {
  27352. var geoIndex = seriesModel.get('geoIndex') || 0;
  27353. seriesModel.coordinateSystem = geoList[geoIndex];
  27354. }
  27355. });
  27356. // If has map series
  27357. var mapModelGroupBySeries = {};
  27358. ecModel.eachSeriesByType('map', function (seriesModel) {
  27359. var mapType = seriesModel.get('map');
  27360. mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || [];
  27361. mapModelGroupBySeries[mapType].push(seriesModel);
  27362. });
  27363. zrUtil.each(mapModelGroupBySeries, function (mapSeries, mapType) {
  27364. var mapData = mapDataStores[mapType];
  27365. if (true) {
  27366. if (!mapData) {
  27367. mapNotExistsError(mapSeries[0].get('map'));
  27368. }
  27369. }
  27370. var nameMapList = zrUtil.map(mapSeries, function (singleMapSeries) {
  27371. return singleMapSeries.get('nameMap');
  27372. });
  27373. var geo = new Geo(
  27374. mapType, mapType,
  27375. mapData && mapData.geoJson, mapData && mapData.specialAreas,
  27376. zrUtil.mergeAll(nameMapList)
  27377. );
  27378. geo.zoomLimit = zrUtil.retrieve.apply(null, zrUtil.map(mapSeries, function (singleMapSeries) {
  27379. return singleMapSeries.get('scaleLimit');
  27380. }));
  27381. geoList.push(geo);
  27382. // Inject resize method
  27383. geo.resize = resizeGeo;
  27384. geo.resize(mapSeries[0], api);
  27385. zrUtil.each(mapSeries, function (singleMapSeries) {
  27386. singleMapSeries.coordinateSystem = geo;
  27387. setGeoCoords(geo, singleMapSeries);
  27388. });
  27389. });
  27390. return geoList;
  27391. },
  27392. /**
  27393. * @param {string} mapName
  27394. * @param {Object|string} geoJson
  27395. * @param {Object} [specialAreas]
  27396. *
  27397. * @example
  27398. * $.get('USA.json', function (geoJson) {
  27399. * echarts.registerMap('USA', geoJson);
  27400. * // Or
  27401. * echarts.registerMap('USA', {
  27402. * geoJson: geoJson,
  27403. * specialAreas: {}
  27404. * })
  27405. * });
  27406. */
  27407. registerMap: function (mapName, geoJson, specialAreas) {
  27408. if (geoJson.geoJson && !geoJson.features) {
  27409. specialAreas = geoJson.specialAreas;
  27410. geoJson = geoJson.geoJson;
  27411. }
  27412. if (typeof geoJson === 'string') {
  27413. geoJson = (typeof JSON !== 'undefined' && JSON.parse)
  27414. ? JSON.parse(geoJson) : (new Function('return (' + geoJson + ');'))();
  27415. }
  27416. mapDataStores[mapName] = {
  27417. geoJson: geoJson,
  27418. specialAreas: specialAreas
  27419. };
  27420. },
  27421. /**
  27422. * @param {string} mapName
  27423. * @return {Object}
  27424. */
  27425. getMap: function (mapName) {
  27426. return mapDataStores[mapName];
  27427. },
  27428. /**
  27429. * Fill given regions array
  27430. * @param {Array.<Object>} originRegionArr
  27431. * @param {string} mapName
  27432. * @return {Array}
  27433. */
  27434. getFilledRegions: function (originRegionArr, mapName) {
  27435. // Not use the original
  27436. var regionsArr = (originRegionArr || []).slice();
  27437. var map = geoCreator.getMap(mapName);
  27438. var geoJson = map && map.geoJson;
  27439. if (!geoJson) {
  27440. if (true) {
  27441. mapNotExistsError(mapName);
  27442. }
  27443. return originRegionArr;
  27444. }
  27445. var dataNameMap = {};
  27446. var features = geoJson.features;
  27447. for (var i = 0; i < regionsArr.length; i++) {
  27448. dataNameMap[regionsArr[i].name] = regionsArr[i];
  27449. }
  27450. for (var i = 0; i < features.length; i++) {
  27451. var name = features[i].properties.name;
  27452. if (!dataNameMap[name]) {
  27453. regionsArr.push({
  27454. name: name
  27455. });
  27456. }
  27457. }
  27458. return regionsArr;
  27459. }
  27460. };
  27461. // Inject methods into echarts
  27462. var echarts = __webpack_require__(1);
  27463. echarts.registerMap = geoCreator.registerMap;
  27464. echarts.getMap = geoCreator.getMap;
  27465. // TODO
  27466. echarts.loadMap = function () {};
  27467. echarts.registerCoordinateSystem('geo', geoCreator);
  27468. module.exports = geoCreator;
  27469. /***/ },
  27470. /* 166 */
  27471. /***/ function(module, exports, __webpack_require__) {
  27472. var parseGeoJson = __webpack_require__(167);
  27473. var zrUtil = __webpack_require__(4);
  27474. var BoundingRect = __webpack_require__(9);
  27475. var View = __webpack_require__(170);
  27476. // Geo fix functions
  27477. var geoFixFuncs = [
  27478. __webpack_require__(171),
  27479. __webpack_require__(172),
  27480. __webpack_require__(173)
  27481. ];
  27482. /**
  27483. * [Geo description]
  27484. * @param {string} name Geo name
  27485. * @param {string} map Map type
  27486. * @param {Object} geoJson
  27487. * @param {Object} [specialAreas]
  27488. * Specify the positioned areas by left, top, width, height
  27489. * @param {Object.<string, string>} [nameMap]
  27490. * Specify name alias
  27491. */
  27492. function Geo(name, map, geoJson, specialAreas, nameMap) {
  27493. View.call(this, name);
  27494. /**
  27495. * Map type
  27496. * @type {string}
  27497. */
  27498. this.map = map;
  27499. this._nameCoordMap = {};
  27500. this.loadGeoJson(geoJson, specialAreas, nameMap);
  27501. }
  27502. Geo.prototype = {
  27503. constructor: Geo,
  27504. type: 'geo',
  27505. /**
  27506. * @param {Array.<string>}
  27507. * @readOnly
  27508. */
  27509. dimensions: ['lng', 'lat'],
  27510. /**
  27511. * If contain given lng,lat coord
  27512. * @param {Array.<number>}
  27513. * @readOnly
  27514. */
  27515. containCoord: function (coord) {
  27516. var regions = this.regions;
  27517. for (var i = 0; i < regions.length; i++) {
  27518. if (regions[i].contain(coord)) {
  27519. return true;
  27520. }
  27521. }
  27522. return false;
  27523. },
  27524. /**
  27525. * @param {Object} geoJson
  27526. * @param {Object} [specialAreas]
  27527. * Specify the positioned areas by left, top, width, height
  27528. * @param {Object.<string, string>} [nameMap]
  27529. * Specify name alias
  27530. */
  27531. loadGeoJson: function (geoJson, specialAreas, nameMap) {
  27532. // https://jsperf.com/try-catch-performance-overhead
  27533. try {
  27534. this.regions = geoJson ? parseGeoJson(geoJson) : [];
  27535. }
  27536. catch (e) {
  27537. throw 'Invalid geoJson format\n' + e;
  27538. }
  27539. specialAreas = specialAreas || {};
  27540. nameMap = nameMap || {};
  27541. var regions = this.regions;
  27542. var regionsMap = {};
  27543. for (var i = 0; i < regions.length; i++) {
  27544. var regionName = regions[i].name;
  27545. // Try use the alias in nameMap
  27546. regionName = nameMap[regionName] || regionName;
  27547. regions[i].name = regionName;
  27548. regionsMap[regionName] = regions[i];
  27549. // Add geoJson
  27550. this.addGeoCoord(regionName, regions[i].center);
  27551. // Some area like Alaska in USA map needs to be tansformed
  27552. // to look better
  27553. var specialArea = specialAreas[regionName];
  27554. if (specialArea) {
  27555. regions[i].transformTo(
  27556. specialArea.left, specialArea.top, specialArea.width, specialArea.height
  27557. );
  27558. }
  27559. }
  27560. this._regionsMap = regionsMap;
  27561. this._rect = null;
  27562. zrUtil.each(geoFixFuncs, function (fixFunc) {
  27563. fixFunc(this);
  27564. }, this);
  27565. },
  27566. // Overwrite
  27567. transformTo: function (x, y, width, height) {
  27568. var rect = this.getBoundingRect();
  27569. rect = rect.clone();
  27570. // Longitute is inverted
  27571. rect.y = -rect.y - rect.height;
  27572. var viewTransform = this._viewTransform;
  27573. viewTransform.transform = rect.calculateTransform(
  27574. new BoundingRect(x, y, width, height)
  27575. );
  27576. viewTransform.decomposeTransform();
  27577. var scale = viewTransform.scale;
  27578. scale[1] = -scale[1];
  27579. viewTransform.updateTransform();
  27580. this._updateTransform();
  27581. },
  27582. /**
  27583. * @param {string} name
  27584. * @return {module:echarts/coord/geo/Region}
  27585. */
  27586. getRegion: function (name) {
  27587. return this._regionsMap[name];
  27588. },
  27589. getRegionByCoord: function (coord) {
  27590. var regions = this.regions;
  27591. for (var i = 0; i < regions.length; i++) {
  27592. if (regions[i].contain(coord)) {
  27593. return regions[i];
  27594. }
  27595. }
  27596. },
  27597. /**
  27598. * Add geoCoord for indexing by name
  27599. * @param {string} name
  27600. * @param {Array.<number>} geoCoord
  27601. */
  27602. addGeoCoord: function (name, geoCoord) {
  27603. this._nameCoordMap[name] = geoCoord;
  27604. },
  27605. /**
  27606. * Get geoCoord by name
  27607. * @param {string} name
  27608. * @return {Array.<number>}
  27609. */
  27610. getGeoCoord: function (name) {
  27611. return this._nameCoordMap[name];
  27612. },
  27613. // Overwrite
  27614. getBoundingRect: function () {
  27615. if (this._rect) {
  27616. return this._rect;
  27617. }
  27618. var rect;
  27619. var regions = this.regions;
  27620. for (var i = 0; i < regions.length; i++) {
  27621. var regionRect = regions[i].getBoundingRect();
  27622. rect = rect || regionRect.clone();
  27623. rect.union(regionRect);
  27624. }
  27625. // FIXME Always return new ?
  27626. return (this._rect = rect || new BoundingRect(0, 0, 0, 0));
  27627. },
  27628. /**
  27629. * Convert series data to a list of points
  27630. * @param {module:echarts/data/List} data
  27631. * @param {boolean} stack
  27632. * @return {Array}
  27633. * Return list of points. For example:
  27634. * `[[10, 10], [20, 20], [30, 30]]`
  27635. */
  27636. dataToPoints: function (data) {
  27637. var item = [];
  27638. return data.mapArray(['lng', 'lat'], function (lon, lat) {
  27639. item[0] = lon;
  27640. item[1] = lat;
  27641. return this.dataToPoint(item);
  27642. }, this);
  27643. },
  27644. // Overwrite
  27645. /**
  27646. * @param {string|Array.<number>} data
  27647. * @return {Array.<number>}
  27648. */
  27649. dataToPoint: function (data) {
  27650. if (typeof data === 'string') {
  27651. // Map area name to geoCoord
  27652. data = this.getGeoCoord(data);
  27653. }
  27654. if (data) {
  27655. return View.prototype.dataToPoint.call(this, data);
  27656. }
  27657. },
  27658. /**
  27659. * @override
  27660. * @implements
  27661. * see {module:echarts/CoodinateSystem}
  27662. */
  27663. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  27664. /**
  27665. * @override
  27666. * @implements
  27667. * see {module:echarts/CoodinateSystem}
  27668. */
  27669. convertFromPixel: zrUtil.curry(doConvert, 'pointToData')
  27670. };
  27671. zrUtil.mixin(Geo, View);
  27672. function doConvert(methodName, ecModel, finder, value) {
  27673. var geoModel = finder.geoModel;
  27674. var seriesModel = finder.seriesModel;
  27675. var coordSys = geoModel
  27676. ? geoModel.coordinateSystem
  27677. : seriesModel
  27678. ? (
  27679. seriesModel.coordinateSystem // For map.
  27680. || (seriesModel.getReferringComponents('geo')[0] || {}).coordinateSystem
  27681. )
  27682. : null;
  27683. return coordSys === this ? coordSys[methodName](value) : null;
  27684. }
  27685. module.exports = Geo;
  27686. /***/ },
  27687. /* 167 */
  27688. /***/ function(module, exports, __webpack_require__) {
  27689. /**
  27690. * Parse and decode geo json
  27691. * @module echarts/coord/geo/parseGeoJson
  27692. */
  27693. var zrUtil = __webpack_require__(4);
  27694. var Region = __webpack_require__(168);
  27695. function decode(json) {
  27696. if (!json.UTF8Encoding) {
  27697. return json;
  27698. }
  27699. var features = json.features;
  27700. for (var f = 0; f < features.length; f++) {
  27701. var feature = features[f];
  27702. var geometry = feature.geometry;
  27703. var coordinates = geometry.coordinates;
  27704. var encodeOffsets = geometry.encodeOffsets;
  27705. for (var c = 0; c < coordinates.length; c++) {
  27706. var coordinate = coordinates[c];
  27707. if (geometry.type === 'Polygon') {
  27708. coordinates[c] = decodePolygon(
  27709. coordinate,
  27710. encodeOffsets[c]
  27711. );
  27712. }
  27713. else if (geometry.type === 'MultiPolygon') {
  27714. for (var c2 = 0; c2 < coordinate.length; c2++) {
  27715. var polygon = coordinate[c2];
  27716. coordinate[c2] = decodePolygon(
  27717. polygon,
  27718. encodeOffsets[c][c2]
  27719. );
  27720. }
  27721. }
  27722. }
  27723. }
  27724. // Has been decoded
  27725. json.UTF8Encoding = false;
  27726. return json;
  27727. }
  27728. function decodePolygon(coordinate, encodeOffsets) {
  27729. var result = [];
  27730. var prevX = encodeOffsets[0];
  27731. var prevY = encodeOffsets[1];
  27732. for (var i = 0; i < coordinate.length; i += 2) {
  27733. var x = coordinate.charCodeAt(i) - 64;
  27734. var y = coordinate.charCodeAt(i + 1) - 64;
  27735. // ZigZag decoding
  27736. x = (x >> 1) ^ (-(x & 1));
  27737. y = (y >> 1) ^ (-(y & 1));
  27738. // Delta deocding
  27739. x += prevX;
  27740. y += prevY;
  27741. prevX = x;
  27742. prevY = y;
  27743. // Dequantize
  27744. result.push([x / 1024, y / 1024]);
  27745. }
  27746. return result;
  27747. }
  27748. /**
  27749. * @inner
  27750. */
  27751. function flattern2D(array) {
  27752. var ret = [];
  27753. for (var i = 0; i < array.length; i++) {
  27754. for (var k = 0; k < array[i].length; k++) {
  27755. ret.push(array[i][k]);
  27756. }
  27757. }
  27758. return ret;
  27759. }
  27760. /**
  27761. * @alias module:echarts/coord/geo/parseGeoJson
  27762. * @param {Object} geoJson
  27763. * @return {module:zrender/container/Group}
  27764. */
  27765. module.exports = function (geoJson) {
  27766. decode(geoJson);
  27767. return zrUtil.map(zrUtil.filter(geoJson.features, function (featureObj) {
  27768. // Output of mapshaper may have geometry null
  27769. return featureObj.geometry && featureObj.properties;
  27770. }), function (featureObj) {
  27771. var properties = featureObj.properties;
  27772. var geometry = featureObj.geometry;
  27773. var coordinates = geometry.coordinates;
  27774. if (geometry.type === 'MultiPolygon') {
  27775. coordinates = flattern2D(coordinates);
  27776. }
  27777. return new Region(
  27778. properties.name,
  27779. coordinates,
  27780. properties.cp
  27781. );
  27782. });
  27783. };
  27784. /***/ },
  27785. /* 168 */
  27786. /***/ function(module, exports, __webpack_require__) {
  27787. /**
  27788. * @module echarts/coord/geo/Region
  27789. */
  27790. var polygonContain = __webpack_require__(169);
  27791. var BoundingRect = __webpack_require__(9);
  27792. var bbox = __webpack_require__(51);
  27793. var vec2 = __webpack_require__(10);
  27794. /**
  27795. * @param {string} name
  27796. * @param {Array} contours
  27797. * @param {Array.<number>} cp
  27798. */
  27799. function Region(name, contours, cp) {
  27800. /**
  27801. * @type {string}
  27802. * @readOnly
  27803. */
  27804. this.name = name;
  27805. /**
  27806. * @type {Array.<Array>}
  27807. * @readOnly
  27808. */
  27809. this.contours = contours;
  27810. if (!cp) {
  27811. var rect = this.getBoundingRect();
  27812. cp = [
  27813. rect.x + rect.width / 2,
  27814. rect.y + rect.height / 2
  27815. ];
  27816. }
  27817. else {
  27818. cp = [cp[0], cp[1]];
  27819. }
  27820. /**
  27821. * @type {Array.<number>}
  27822. */
  27823. this.center = cp;
  27824. }
  27825. Region.prototype = {
  27826. constructor: Region,
  27827. /**
  27828. * @return {module:zrender/core/BoundingRect}
  27829. */
  27830. getBoundingRect: function () {
  27831. var rect = this._rect;
  27832. if (rect) {
  27833. return rect;
  27834. }
  27835. var MAX_NUMBER = Number.MAX_VALUE;
  27836. var min = [MAX_NUMBER, MAX_NUMBER];
  27837. var max = [-MAX_NUMBER, -MAX_NUMBER];
  27838. var min2 = [];
  27839. var max2 = [];
  27840. var contours = this.contours;
  27841. for (var i = 0; i < contours.length; i++) {
  27842. bbox.fromPoints(contours[i], min2, max2);
  27843. vec2.min(min, min, min2);
  27844. vec2.max(max, max, max2);
  27845. }
  27846. // No data
  27847. if (i === 0) {
  27848. min[0] = min[1] = max[0] = max[1] = 0;
  27849. }
  27850. return (this._rect = new BoundingRect(
  27851. min[0], min[1], max[0] - min[0], max[1] - min[1]
  27852. ));
  27853. },
  27854. /**
  27855. * @param {<Array.<number>} coord
  27856. * @return {boolean}
  27857. */
  27858. contain: function (coord) {
  27859. var rect = this.getBoundingRect();
  27860. var contours = this.contours;
  27861. if (rect.contain(coord[0], coord[1])) {
  27862. for (var i = 0, len = contours.length; i < len; i++) {
  27863. if (polygonContain.contain(contours[i], coord[0], coord[1])) {
  27864. return true;
  27865. }
  27866. }
  27867. }
  27868. return false;
  27869. },
  27870. transformTo: function (x, y, width, height) {
  27871. var rect = this.getBoundingRect();
  27872. var aspect = rect.width / rect.height;
  27873. if (!width) {
  27874. width = aspect * height;
  27875. }
  27876. else if (!height) {
  27877. height = width / aspect ;
  27878. }
  27879. var target = new BoundingRect(x, y, width, height);
  27880. var transform = rect.calculateTransform(target);
  27881. var contours = this.contours;
  27882. for (var i = 0; i < contours.length; i++) {
  27883. for (var p = 0; p < contours[i].length; p++) {
  27884. vec2.applyTransform(contours[i][p], contours[i][p], transform);
  27885. }
  27886. }
  27887. rect = this._rect;
  27888. rect.copy(target);
  27889. // Update center
  27890. this.center = [
  27891. rect.x + rect.width / 2,
  27892. rect.y + rect.height / 2
  27893. ];
  27894. }
  27895. };
  27896. module.exports = Region;
  27897. /***/ },
  27898. /* 169 */
  27899. /***/ function(module, exports, __webpack_require__) {
  27900. var windingLine = __webpack_require__(58);
  27901. var EPSILON = 1e-8;
  27902. function isAroundEqual(a, b) {
  27903. return Math.abs(a - b) < EPSILON;
  27904. }
  27905. function contain(points, x, y) {
  27906. var w = 0;
  27907. var p = points[0];
  27908. if (!p) {
  27909. return false;
  27910. }
  27911. for (var i = 1; i < points.length; i++) {
  27912. var p2 = points[i];
  27913. w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
  27914. p = p2;
  27915. }
  27916. // Close polygon
  27917. var p0 = points[0];
  27918. if (!isAroundEqual(p[0], p0[0]) || !isAroundEqual(p[1], p0[1])) {
  27919. w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
  27920. }
  27921. return w !== 0;
  27922. }
  27923. module.exports = {
  27924. contain: contain
  27925. };
  27926. /***/ },
  27927. /* 170 */
  27928. /***/ function(module, exports, __webpack_require__) {
  27929. /**
  27930. * Simple view coordinate system
  27931. * Mapping given x, y to transformd view x, y
  27932. */
  27933. var vector = __webpack_require__(10);
  27934. var matrix = __webpack_require__(11);
  27935. var Transformable = __webpack_require__(34);
  27936. var zrUtil = __webpack_require__(4);
  27937. var BoundingRect = __webpack_require__(9);
  27938. var v2ApplyTransform = vector.applyTransform;
  27939. // Dummy transform node
  27940. function TransformDummy() {
  27941. Transformable.call(this);
  27942. }
  27943. zrUtil.mixin(TransformDummy, Transformable);
  27944. function View(name) {
  27945. /**
  27946. * @type {string}
  27947. */
  27948. this.name = name;
  27949. /**
  27950. * @type {Object}
  27951. */
  27952. this.zoomLimit;
  27953. Transformable.call(this);
  27954. this._roamTransform = new TransformDummy();
  27955. this._viewTransform = new TransformDummy();
  27956. this._center;
  27957. this._zoom;
  27958. }
  27959. View.prototype = {
  27960. constructor: View,
  27961. type: 'view',
  27962. /**
  27963. * @param {Array.<string>}
  27964. * @readOnly
  27965. */
  27966. dimensions: ['x', 'y'],
  27967. /**
  27968. * Set bounding rect
  27969. * @param {number} x
  27970. * @param {number} y
  27971. * @param {number} width
  27972. * @param {number} height
  27973. */
  27974. // PENDING to getRect
  27975. setBoundingRect: function (x, y, width, height) {
  27976. this._rect = new BoundingRect(x, y, width, height);
  27977. return this._rect;
  27978. },
  27979. /**
  27980. * @return {module:zrender/core/BoundingRect}
  27981. */
  27982. // PENDING to getRect
  27983. getBoundingRect: function () {
  27984. return this._rect;
  27985. },
  27986. /**
  27987. * @param {number} x
  27988. * @param {number} y
  27989. * @param {number} width
  27990. * @param {number} height
  27991. */
  27992. setViewRect: function (x, y, width, height) {
  27993. this.transformTo(x, y, width, height);
  27994. this._viewRect = new BoundingRect(x, y, width, height);
  27995. },
  27996. /**
  27997. * Transformed to particular position and size
  27998. * @param {number} x
  27999. * @param {number} y
  28000. * @param {number} width
  28001. * @param {number} height
  28002. */
  28003. transformTo: function (x, y, width, height) {
  28004. var rect = this.getBoundingRect();
  28005. var viewTransform = this._viewTransform;
  28006. viewTransform.transform = rect.calculateTransform(
  28007. new BoundingRect(x, y, width, height)
  28008. );
  28009. viewTransform.decomposeTransform();
  28010. this._updateTransform();
  28011. },
  28012. /**
  28013. * Set center of view
  28014. * @param {Array.<number>} [centerCoord]
  28015. */
  28016. setCenter: function (centerCoord) {
  28017. if (!centerCoord) {
  28018. return;
  28019. }
  28020. this._center = centerCoord;
  28021. this._updateCenterAndZoom();
  28022. },
  28023. /**
  28024. * @param {number} zoom
  28025. */
  28026. setZoom: function (zoom) {
  28027. zoom = zoom || 1;
  28028. var zoomLimit = this.zoomLimit;
  28029. if (zoomLimit) {
  28030. if (zoomLimit.max != null) {
  28031. zoom = Math.min(zoomLimit.max, zoom);
  28032. }
  28033. if (zoomLimit.min != null) {
  28034. zoom = Math.max(zoomLimit.min, zoom);
  28035. }
  28036. }
  28037. this._zoom = zoom;
  28038. this._updateCenterAndZoom();
  28039. },
  28040. /**
  28041. * Get default center without roam
  28042. */
  28043. getDefaultCenter: function () {
  28044. // Rect before any transform
  28045. var rawRect = this.getBoundingRect();
  28046. var cx = rawRect.x + rawRect.width / 2;
  28047. var cy = rawRect.y + rawRect.height / 2;
  28048. return [cx, cy];
  28049. },
  28050. getCenter: function () {
  28051. return this._center || this.getDefaultCenter();
  28052. },
  28053. getZoom: function () {
  28054. return this._zoom || 1;
  28055. },
  28056. /**
  28057. * @return {Array.<number}
  28058. */
  28059. getRoamTransform: function () {
  28060. return this._roamTransform;
  28061. },
  28062. _updateCenterAndZoom: function () {
  28063. // Must update after view transform updated
  28064. var viewTransformMatrix = this._viewTransform.getLocalTransform();
  28065. var roamTransform = this._roamTransform;
  28066. var defaultCenter = this.getDefaultCenter();
  28067. var center = this.getCenter();
  28068. var zoom = this.getZoom();
  28069. center = vector.applyTransform([], center, viewTransformMatrix);
  28070. defaultCenter = vector.applyTransform([], defaultCenter, viewTransformMatrix);
  28071. roamTransform.origin = center;
  28072. roamTransform.position = [
  28073. defaultCenter[0] - center[0],
  28074. defaultCenter[1] - center[1]
  28075. ];
  28076. roamTransform.scale = [zoom, zoom];
  28077. this._updateTransform();
  28078. },
  28079. /**
  28080. * Update transform from roam and mapLocation
  28081. * @private
  28082. */
  28083. _updateTransform: function () {
  28084. var roamTransform = this._roamTransform;
  28085. var viewTransform = this._viewTransform;
  28086. viewTransform.parent = roamTransform;
  28087. roamTransform.updateTransform();
  28088. viewTransform.updateTransform();
  28089. viewTransform.transform
  28090. && matrix.copy(this.transform || (this.transform = []), viewTransform.transform);
  28091. if (this.transform) {
  28092. this.invTransform = this.invTransform || [];
  28093. matrix.invert(this.invTransform, this.transform);
  28094. }
  28095. else {
  28096. this.invTransform = null;
  28097. }
  28098. this.decomposeTransform();
  28099. },
  28100. /**
  28101. * @return {module:zrender/core/BoundingRect}
  28102. */
  28103. getViewRect: function () {
  28104. return this._viewRect;
  28105. },
  28106. /**
  28107. * Get view rect after roam transform
  28108. * @return {module:zrender/core/BoundingRect}
  28109. */
  28110. getViewRectAfterRoam: function () {
  28111. var rect = this.getBoundingRect().clone();
  28112. rect.applyTransform(this.transform);
  28113. return rect;
  28114. },
  28115. /**
  28116. * Convert a single (lon, lat) data item to (x, y) point.
  28117. * @param {Array.<number>} data
  28118. * @return {Array.<number>}
  28119. */
  28120. dataToPoint: function (data) {
  28121. var transform = this.transform;
  28122. return transform
  28123. ? v2ApplyTransform([], data, transform)
  28124. : [data[0], data[1]];
  28125. },
  28126. /**
  28127. * Convert a (x, y) point to (lon, lat) data
  28128. * @param {Array.<number>} point
  28129. * @return {Array.<number>}
  28130. */
  28131. pointToData: function (point) {
  28132. var invTransform = this.invTransform;
  28133. return invTransform
  28134. ? v2ApplyTransform([], point, invTransform)
  28135. : [point[0], point[1]];
  28136. },
  28137. /**
  28138. * @implements
  28139. * see {module:echarts/CoodinateSystem}
  28140. */
  28141. convertToPixel: zrUtil.curry(doConvert, 'dataToPoint'),
  28142. /**
  28143. * @implements
  28144. * see {module:echarts/CoodinateSystem}
  28145. */
  28146. convertFromPixel: zrUtil.curry(doConvert, 'pointToData'),
  28147. /**
  28148. * @implements
  28149. * see {module:echarts/CoodinateSystem}
  28150. */
  28151. containPoint: function (point) {
  28152. return this.getViewRectAfterRoam().contain(point[0], point[1]);
  28153. }
  28154. /**
  28155. * @return {number}
  28156. */
  28157. // getScalarScale: function () {
  28158. // // Use determinant square root of transform to mutiply scalar
  28159. // var m = this.transform;
  28160. // var det = Math.sqrt(Math.abs(m[0] * m[3] - m[2] * m[1]));
  28161. // return det;
  28162. // }
  28163. };
  28164. zrUtil.mixin(View, Transformable);
  28165. function doConvert(methodName, ecModel, finder, value) {
  28166. var seriesModel = finder.seriesModel;
  28167. var coordSys = seriesModel ? seriesModel.coordinateSystem : null; // e.g., graph.
  28168. return coordSys === this ? coordSys[methodName](value) : null;
  28169. }
  28170. module.exports = View;
  28171. /***/ },
  28172. /* 171 */
  28173. /***/ function(module, exports, __webpack_require__) {
  28174. // Fix for 南海诸岛
  28175. var Region = __webpack_require__(168);
  28176. var geoCoord = [126, 25];
  28177. var points = [
  28178. [[0,3.5],[7,11.2],[15,11.9],[30,7],[42,0.7],[52,0.7],
  28179. [56,7.7],[59,0.7],[64,0.7],[64,0],[5,0],[0,3.5]],
  28180. [[13,16.1],[19,14.7],[16,21.7],[11,23.1],[13,16.1]],
  28181. [[12,32.2],[14,38.5],[15,38.5],[13,32.2],[12,32.2]],
  28182. [[16,47.6],[12,53.2],[13,53.2],[18,47.6],[16,47.6]],
  28183. [[6,64.4],[8,70],[9,70],[8,64.4],[6,64.4]],
  28184. [[23,82.6],[29,79.8],[30,79.8],[25,82.6],[23,82.6]],
  28185. [[37,70.7],[43,62.3],[44,62.3],[39,70.7],[37,70.7]],
  28186. [[48,51.1],[51,45.5],[53,45.5],[50,51.1],[48,51.1]],
  28187. [[51,35],[51,28.7],[53,28.7],[53,35],[51,35]],
  28188. [[52,22.4],[55,17.5],[56,17.5],[53,22.4],[52,22.4]],
  28189. [[58,12.6],[62,7],[63,7],[60,12.6],[58,12.6]],
  28190. [[0,3.5],[0,93.1],[64,93.1],[64,0],[63,0],[63,92.4],
  28191. [1,92.4],[1,3.5],[0,3.5]]
  28192. ];
  28193. for (var i = 0; i < points.length; i++) {
  28194. for (var k = 0; k < points[i].length; k++) {
  28195. points[i][k][0] /= 10.5;
  28196. points[i][k][1] /= -10.5 / 0.75;
  28197. points[i][k][0] += geoCoord[0];
  28198. points[i][k][1] += geoCoord[1];
  28199. }
  28200. }
  28201. module.exports = function (geo) {
  28202. if (geo.map === 'china') {
  28203. geo.regions.push(new Region(
  28204. '南海诸岛', points, geoCoord
  28205. ));
  28206. }
  28207. };
  28208. /***/ },
  28209. /* 172 */
  28210. /***/ function(module, exports, __webpack_require__) {
  28211. var zrUtil = __webpack_require__(4);
  28212. var coordsOffsetMap = {
  28213. '南海诸岛' : [32, 80],
  28214. // 全国
  28215. '广东': [0, -10],
  28216. '香港': [10, 5],
  28217. '澳门': [-10, 10],
  28218. //'北京': [-10, 0],
  28219. '天津': [5, 5]
  28220. };
  28221. module.exports = function (geo) {
  28222. zrUtil.each(geo.regions, function (region) {
  28223. var coordFix = coordsOffsetMap[region.name];
  28224. if (coordFix) {
  28225. var cp = region.center;
  28226. cp[0] += coordFix[0] / 10.5;
  28227. cp[1] += -coordFix[1] / (10.5 / 0.75);
  28228. }
  28229. });
  28230. };
  28231. /***/ },
  28232. /* 173 */
  28233. /***/ function(module, exports, __webpack_require__) {
  28234. var zrUtil = __webpack_require__(4);
  28235. var geoCoordMap = {
  28236. 'Russia': [100, 60],
  28237. 'United States of America': [-99, 38]
  28238. };
  28239. module.exports = function (geo) {
  28240. zrUtil.each(geo.regions, function (region) {
  28241. var geoCoord = geoCoordMap[region.name];
  28242. if (geoCoord) {
  28243. var cp = region.center;
  28244. cp[0] = geoCoord[0];
  28245. cp[1] = geoCoord[1];
  28246. }
  28247. });
  28248. };
  28249. /***/ },
  28250. /* 174 */
  28251. /***/ function(module, exports, __webpack_require__) {
  28252. // var zrUtil = require('zrender/lib/core/util');
  28253. var graphic = __webpack_require__(43);
  28254. var MapDraw = __webpack_require__(175);
  28255. __webpack_require__(1).extendChartView({
  28256. type: 'map',
  28257. render: function (mapModel, ecModel, api, payload) {
  28258. // Not render if it is an toggleSelect action from self
  28259. if (payload && payload.type === 'mapToggleSelect'
  28260. && payload.from === this.uid
  28261. ) {
  28262. return;
  28263. }
  28264. var group = this.group;
  28265. group.removeAll();
  28266. // Not update map if it is an roam action from self
  28267. if (!(payload && payload.type === 'geoRoam'
  28268. && payload.componentType === 'series'
  28269. && payload.seriesId === mapModel.id)) {
  28270. if (mapModel.needsDrawMap) {
  28271. var mapDraw = this._mapDraw || new MapDraw(api, true);
  28272. group.add(mapDraw.group);
  28273. mapDraw.draw(mapModel, ecModel, api, this, payload);
  28274. this._mapDraw = mapDraw;
  28275. }
  28276. else {
  28277. // Remove drawed map
  28278. this._mapDraw && this._mapDraw.remove();
  28279. this._mapDraw = null;
  28280. }
  28281. }
  28282. else {
  28283. var mapDraw = this._mapDraw;
  28284. mapDraw && group.add(mapDraw.group);
  28285. }
  28286. mapModel.get('showLegendSymbol') && ecModel.getComponent('legend')
  28287. && this._renderSymbols(mapModel, ecModel, api);
  28288. },
  28289. remove: function () {
  28290. this._mapDraw && this._mapDraw.remove();
  28291. this._mapDraw = null;
  28292. this.group.removeAll();
  28293. },
  28294. dispose: function () {
  28295. this._mapDraw && this._mapDraw.remove();
  28296. this._mapDraw = null;
  28297. },
  28298. _renderSymbols: function (mapModel, ecModel, api) {
  28299. var originalData = mapModel.originalData;
  28300. var group = this.group;
  28301. originalData.each('value', function (value, idx) {
  28302. if (isNaN(value)) {
  28303. return;
  28304. }
  28305. var layout = originalData.getItemLayout(idx);
  28306. if (!layout || !layout.point) {
  28307. // Not exists in map
  28308. return;
  28309. }
  28310. var point = layout.point;
  28311. var offset = layout.offset;
  28312. var circle = new graphic.Circle({
  28313. style: {
  28314. // Because the special of map draw.
  28315. // Which needs statistic of multiple series and draw on one map.
  28316. // And each series also need a symbol with legend color
  28317. //
  28318. // Layout and visual are put one the different data
  28319. fill: mapModel.getData().getVisual('color')
  28320. },
  28321. shape: {
  28322. cx: point[0] + offset * 9,
  28323. cy: point[1],
  28324. r: 3
  28325. },
  28326. silent: true,
  28327. z2: 10
  28328. });
  28329. // First data on the same region
  28330. if (!offset) {
  28331. var fullData = mapModel.mainSeries.getData();
  28332. var name = originalData.getName(idx);
  28333. var labelText = name;
  28334. var fullIndex = fullData.indexOfName(name);
  28335. var itemModel = originalData.getItemModel(idx);
  28336. var labelModel = itemModel.getModel('label.normal');
  28337. var hoverLabelModel = itemModel.getModel('label.emphasis');
  28338. var textStyleModel = labelModel.getModel('textStyle');
  28339. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  28340. var polygonGroups = fullData.getItemGraphicEl(fullIndex);
  28341. circle.setStyle({
  28342. textPosition: 'bottom'
  28343. });
  28344. var onEmphasis = function () {
  28345. circle.setStyle({
  28346. text: hoverLabelModel.get('show') ? labelText : '',
  28347. textFill: hoverTextStyleModel.getTextColor(),
  28348. textFont: hoverTextStyleModel.getFont()
  28349. });
  28350. };
  28351. var onNormal = function () {
  28352. circle.setStyle({
  28353. text: labelModel.get('show') ? labelText : '',
  28354. textFill: textStyleModel.getTextColor(),
  28355. textFont: textStyleModel.getFont()
  28356. });
  28357. };
  28358. polygonGroups.on('mouseover', onEmphasis)
  28359. .on('mouseout', onNormal)
  28360. .on('emphasis', onEmphasis)
  28361. .on('normal', onNormal);
  28362. onNormal();
  28363. }
  28364. group.add(circle);
  28365. });
  28366. }
  28367. });
  28368. /***/ },
  28369. /* 175 */
  28370. /***/ function(module, exports, __webpack_require__) {
  28371. /**
  28372. * @module echarts/component/helper/MapDraw
  28373. */
  28374. var RoamController = __webpack_require__(176);
  28375. var graphic = __webpack_require__(43);
  28376. var zrUtil = __webpack_require__(4);
  28377. function getFixedItemStyle(model, scale) {
  28378. var itemStyle = model.getItemStyle();
  28379. var areaColor = model.get('areaColor');
  28380. if (areaColor) {
  28381. itemStyle.fill = areaColor;
  28382. }
  28383. return itemStyle;
  28384. }
  28385. function updateMapSelectHandler(mapDraw, mapOrGeoModel, group, api, fromView) {
  28386. group.off('click');
  28387. group.off('mousedown');
  28388. if (mapOrGeoModel.get('selectedMode')) {
  28389. group.on('mousedown', function () {
  28390. mapDraw._mouseDownFlag = true;
  28391. });
  28392. group.on('click', function (e) {
  28393. if (!mapDraw._mouseDownFlag) {
  28394. return;
  28395. }
  28396. mapDraw._mouseDownFlag = false;
  28397. var el = e.target;
  28398. while (!el.__region) {
  28399. el = el.parent;
  28400. }
  28401. if (!el) {
  28402. return;
  28403. }
  28404. var region = el.__region;
  28405. var action = {
  28406. type: (mapOrGeoModel.mainType === 'geo' ? 'geo' : 'map') + 'ToggleSelect',
  28407. name: region.name,
  28408. from: fromView.uid
  28409. };
  28410. action[mapOrGeoModel.mainType + 'Id'] = mapOrGeoModel.id;
  28411. api.dispatchAction(action);
  28412. updateMapSelected(mapOrGeoModel, group);
  28413. });
  28414. }
  28415. }
  28416. function updateMapSelected(mapOrGeoModel, group) {
  28417. // FIXME
  28418. group.eachChild(function (otherRegionEl) {
  28419. if (otherRegionEl.__region) {
  28420. otherRegionEl.trigger(mapOrGeoModel.isSelected(otherRegionEl.__region.name) ? 'emphasis' : 'normal');
  28421. }
  28422. });
  28423. }
  28424. /**
  28425. * @alias module:echarts/component/helper/MapDraw
  28426. * @param {module:echarts/ExtensionAPI} api
  28427. * @param {boolean} updateGroup
  28428. */
  28429. function MapDraw(api, updateGroup) {
  28430. var group = new graphic.Group();
  28431. /**
  28432. * @type {module:echarts/component/helper/RoamController}
  28433. * @private
  28434. */
  28435. this._controller = new RoamController(
  28436. api.getZr(), updateGroup ? group : null, null
  28437. );
  28438. /**
  28439. * @type {module:zrender/container/Group}
  28440. * @readOnly
  28441. */
  28442. this.group = group;
  28443. /**
  28444. * @type {boolean}
  28445. * @private
  28446. */
  28447. this._updateGroup = updateGroup;
  28448. /**
  28449. * This flag is used to make sure that only one among
  28450. * `pan`, `zoom`, `click` can occurs, otherwise 'selected'
  28451. * action may be triggered when `pan`, which is unexpected.
  28452. * @type {booelan}
  28453. */
  28454. this._mouseDownFlag;
  28455. }
  28456. MapDraw.prototype = {
  28457. constructor: MapDraw,
  28458. draw: function (mapOrGeoModel, ecModel, api, fromView, payload) {
  28459. // geoModel has no data
  28460. var data = mapOrGeoModel.getData && mapOrGeoModel.getData();
  28461. var geo = mapOrGeoModel.coordinateSystem;
  28462. var group = this.group;
  28463. var scale = geo.scale;
  28464. var groupNewProp = {
  28465. position: geo.position,
  28466. scale: scale
  28467. };
  28468. // No animation when first draw or in action
  28469. if (!group.childAt(0) || payload) {
  28470. group.attr(groupNewProp);
  28471. }
  28472. else {
  28473. graphic.updateProps(group, groupNewProp, mapOrGeoModel);
  28474. }
  28475. group.removeAll();
  28476. var itemStyleAccessPath = ['itemStyle', 'normal'];
  28477. var hoverItemStyleAccessPath = ['itemStyle', 'emphasis'];
  28478. var labelAccessPath = ['label', 'normal'];
  28479. var hoverLabelAccessPath = ['label', 'emphasis'];
  28480. zrUtil.each(geo.regions, function (region) {
  28481. var regionGroup = new graphic.Group();
  28482. var compoundPath = new graphic.CompoundPath({
  28483. shape: {
  28484. paths: []
  28485. }
  28486. });
  28487. regionGroup.add(compoundPath);
  28488. var regionModel = mapOrGeoModel.getRegionModel(region.name) || mapOrGeoModel;
  28489. var itemStyleModel = regionModel.getModel(itemStyleAccessPath);
  28490. var hoverItemStyleModel = regionModel.getModel(hoverItemStyleAccessPath);
  28491. var itemStyle = getFixedItemStyle(itemStyleModel, scale);
  28492. var hoverItemStyle = getFixedItemStyle(hoverItemStyleModel, scale);
  28493. var labelModel = regionModel.getModel(labelAccessPath);
  28494. var hoverLabelModel = regionModel.getModel(hoverLabelAccessPath);
  28495. var dataIdx;
  28496. // Use the itemStyle in data if has data
  28497. if (data) {
  28498. dataIdx = data.indexOfName(region.name);
  28499. // Only visual color of each item will be used. It can be encoded by dataRange
  28500. // But visual color of series is used in symbol drawing
  28501. //
  28502. // Visual color for each series is for the symbol draw
  28503. var visualColor = data.getItemVisual(dataIdx, 'color', true);
  28504. if (visualColor) {
  28505. itemStyle.fill = visualColor;
  28506. }
  28507. }
  28508. var textStyleModel = labelModel.getModel('textStyle');
  28509. var hoverTextStyleModel = hoverLabelModel.getModel('textStyle');
  28510. zrUtil.each(region.contours, function (contour) {
  28511. var polygon = new graphic.Polygon({
  28512. shape: {
  28513. points: contour
  28514. }
  28515. });
  28516. compoundPath.shape.paths.push(polygon);
  28517. });
  28518. compoundPath.setStyle(itemStyle);
  28519. compoundPath.style.strokeNoScale = true;
  28520. compoundPath.culling = true;
  28521. // Label
  28522. var showLabel = labelModel.get('show');
  28523. var hoverShowLabel = hoverLabelModel.get('show');
  28524. var isDataNaN = data && isNaN(data.get('value', dataIdx));
  28525. var itemLayout = data && data.getItemLayout(dataIdx);
  28526. // In the following cases label will be drawn
  28527. // 1. In map series and data value is NaN
  28528. // 2. In geo component
  28529. // 4. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout
  28530. if (
  28531. (!data || isDataNaN && (showLabel || hoverShowLabel))
  28532. || (itemLayout && itemLayout.showLabel)
  28533. ) {
  28534. var query = data ? dataIdx : region.name;
  28535. var formattedStr = mapOrGeoModel.getFormattedLabel(query, 'normal');
  28536. var hoverFormattedStr = mapOrGeoModel.getFormattedLabel(query, 'emphasis');
  28537. var text = new graphic.Text({
  28538. style: {
  28539. text: showLabel ? (formattedStr || region.name) : '',
  28540. fill: textStyleModel.getTextColor(),
  28541. textFont: textStyleModel.getFont(),
  28542. textAlign: 'center',
  28543. textVerticalAlign: 'middle'
  28544. },
  28545. hoverStyle: {
  28546. text: hoverShowLabel ? (hoverFormattedStr || region.name) : '',
  28547. fill: hoverTextStyleModel.getTextColor(),
  28548. textFont: hoverTextStyleModel.getFont()
  28549. },
  28550. position: region.center.slice(),
  28551. scale: [1 / scale[0], 1 / scale[1]],
  28552. z2: 10,
  28553. silent: true
  28554. });
  28555. regionGroup.add(text);
  28556. }
  28557. // setItemGraphicEl, setHoverStyle after all polygons and labels
  28558. // are added to the rigionGroup
  28559. if (data) {
  28560. data.setItemGraphicEl(dataIdx, regionGroup);
  28561. }
  28562. else {
  28563. var regionModel = mapOrGeoModel.getRegionModel(region.name);
  28564. // Package custom mouse event for geo component
  28565. compoundPath.eventData = {
  28566. componentType: 'geo',
  28567. geoIndex: mapOrGeoModel.componentIndex,
  28568. name: region.name,
  28569. region: (regionModel && regionModel.option) || {}
  28570. };
  28571. }
  28572. regionGroup.__region = region;
  28573. graphic.setHoverStyle(
  28574. regionGroup,
  28575. hoverItemStyle,
  28576. {hoverSilentOnTouch: !!mapOrGeoModel.get('selectedMode')}
  28577. );
  28578. group.add(regionGroup);
  28579. });
  28580. this._updateController(mapOrGeoModel, ecModel, api);
  28581. updateMapSelectHandler(this, mapOrGeoModel, group, api, fromView);
  28582. updateMapSelected(mapOrGeoModel, group);
  28583. },
  28584. remove: function () {
  28585. this.group.removeAll();
  28586. this._controller.dispose();
  28587. },
  28588. _updateController: function (mapOrGeoModel, ecModel, api) {
  28589. var geo = mapOrGeoModel.coordinateSystem;
  28590. var controller = this._controller;
  28591. controller.zoomLimit = mapOrGeoModel.get('scaleLimit');
  28592. // Update zoom from model
  28593. controller.zoom = geo.getZoom();
  28594. // roamType is will be set default true if it is null
  28595. controller.enable(mapOrGeoModel.get('roam') || false);
  28596. var mainType = mapOrGeoModel.mainType;
  28597. function makeActionBase() {
  28598. var action = {
  28599. type: 'geoRoam',
  28600. componentType: mainType
  28601. };
  28602. action[mainType + 'Id'] = mapOrGeoModel.id;
  28603. return action;
  28604. }
  28605. controller.off('pan').on('pan', function (dx, dy) {
  28606. this._mouseDownFlag = false;
  28607. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  28608. dx: dx,
  28609. dy: dy
  28610. }));
  28611. }, this);
  28612. controller.off('zoom').on('zoom', function (zoom, mouseX, mouseY) {
  28613. this._mouseDownFlag = false;
  28614. api.dispatchAction(zrUtil.extend(makeActionBase(), {
  28615. zoom: zoom,
  28616. originX: mouseX,
  28617. originY: mouseY
  28618. }));
  28619. if (this._updateGroup) {
  28620. var group = this.group;
  28621. var scale = group.scale;
  28622. group.traverse(function (el) {
  28623. if (el.type === 'text') {
  28624. el.attr('scale', [1 / scale[0], 1 / scale[1]]);
  28625. }
  28626. });
  28627. }
  28628. }, this);
  28629. controller.setContainsPoint(function (x, y) {
  28630. return geo.getViewRectAfterRoam().contain(x, y);
  28631. });
  28632. }
  28633. };
  28634. module.exports = MapDraw;
  28635. /***/ },
  28636. /* 176 */
  28637. /***/ function(module, exports, __webpack_require__) {
  28638. /**
  28639. * @module echarts/component/helper/RoamController
  28640. */
  28641. var Eventful = __webpack_require__(33);
  28642. var zrUtil = __webpack_require__(4);
  28643. var eventTool = __webpack_require__(88);
  28644. var interactionMutex = __webpack_require__(177);
  28645. function mousedown(e) {
  28646. if (e.target && e.target.draggable) {
  28647. return;
  28648. }
  28649. var x = e.offsetX;
  28650. var y = e.offsetY;
  28651. if (this.containsPoint && this.containsPoint(x, y)) {
  28652. this._x = x;
  28653. this._y = y;
  28654. this._dragging = true;
  28655. }
  28656. }
  28657. function mousemove(e) {
  28658. if (!this._dragging) {
  28659. return;
  28660. }
  28661. eventTool.stop(e.event);
  28662. if (e.gestureEvent !== 'pinch') {
  28663. if (interactionMutex.isTaken(this._zr, 'globalPan')) {
  28664. return;
  28665. }
  28666. var x = e.offsetX;
  28667. var y = e.offsetY;
  28668. var oldX = this._x;
  28669. var oldY = this._y;
  28670. var dx = x - oldX;
  28671. var dy = y - oldY;
  28672. this._x = x;
  28673. this._y = y;
  28674. var target = this.target;
  28675. if (target) {
  28676. var pos = target.position;
  28677. pos[0] += dx;
  28678. pos[1] += dy;
  28679. target.dirty();
  28680. }
  28681. eventTool.stop(e.event);
  28682. this.trigger('pan', dx, dy, oldX, oldY, x, y);
  28683. }
  28684. }
  28685. function mouseup(e) {
  28686. this._dragging = false;
  28687. }
  28688. function mousewheel(e) {
  28689. // Convenience:
  28690. // Mac and VM Windows on Mac: scroll up: zoom out.
  28691. // Windows: scroll up: zoom in.
  28692. var zoomDelta = e.wheelDelta > 0 ? 1.1 : 1 / 1.1;
  28693. zoom.call(this, e, zoomDelta, e.offsetX, e.offsetY);
  28694. }
  28695. function pinch(e) {
  28696. if (interactionMutex.isTaken(this._zr, 'globalPan')) {
  28697. return;
  28698. }
  28699. var zoomDelta = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
  28700. zoom.call(this, e, zoomDelta, e.pinchX, e.pinchY);
  28701. }
  28702. function zoom(e, zoomDelta, zoomX, zoomY) {
  28703. if (this.containsPoint && this.containsPoint(zoomX, zoomY)) {
  28704. // When mouse is out of roamController rect,
  28705. // default befavoius should be be disabled, otherwise
  28706. // page sliding is disabled, contrary to expectation.
  28707. eventTool.stop(e.event);
  28708. var target = this.target;
  28709. var zoomLimit = this.zoomLimit;
  28710. if (target) {
  28711. var pos = target.position;
  28712. var scale = target.scale;
  28713. var newZoom = this.zoom = this.zoom || 1;
  28714. newZoom *= zoomDelta;
  28715. if (zoomLimit) {
  28716. var zoomMin = zoomLimit.min || 0;
  28717. var zoomMax = zoomLimit.max || Infinity;
  28718. newZoom = Math.max(
  28719. Math.min(zoomMax, newZoom),
  28720. zoomMin
  28721. );
  28722. }
  28723. var zoomScale = newZoom / this.zoom;
  28724. this.zoom = newZoom;
  28725. // Keep the mouse center when scaling
  28726. pos[0] -= (zoomX - pos[0]) * (zoomScale - 1);
  28727. pos[1] -= (zoomY - pos[1]) * (zoomScale - 1);
  28728. scale[0] *= zoomScale;
  28729. scale[1] *= zoomScale;
  28730. target.dirty();
  28731. }
  28732. this.trigger('zoom', zoomDelta, zoomX, zoomY);
  28733. }
  28734. }
  28735. /**
  28736. * @alias module:echarts/component/helper/RoamController
  28737. * @constructor
  28738. * @mixin {module:zrender/mixin/Eventful}
  28739. *
  28740. * @param {module:zrender/zrender~ZRender} zr
  28741. * @param {module:zrender/Element} target
  28742. */
  28743. function RoamController(zr, target) {
  28744. /**
  28745. * @type {module:zrender/Element}
  28746. */
  28747. this.target = target;
  28748. /**
  28749. * @type {Function}
  28750. */
  28751. this.containsPoint;
  28752. /**
  28753. * { min: 1, max: 2 }
  28754. * @type {Object}
  28755. */
  28756. this.zoomLimit;
  28757. /**
  28758. * @type {number}
  28759. */
  28760. this.zoom;
  28761. /**
  28762. * @type {module:zrender}
  28763. */
  28764. this._zr = zr;
  28765. // Avoid two roamController bind the same handler
  28766. var bind = zrUtil.bind;
  28767. var mousedownHandler = bind(mousedown, this);
  28768. var mousemoveHandler = bind(mousemove, this);
  28769. var mouseupHandler = bind(mouseup, this);
  28770. var mousewheelHandler = bind(mousewheel, this);
  28771. var pinchHandler = bind(pinch, this);
  28772. Eventful.call(this);
  28773. /**
  28774. * @param {Function} containsPoint
  28775. * input: x, y
  28776. * output: boolean
  28777. */
  28778. this.setContainsPoint = function (containsPoint) {
  28779. this.containsPoint = containsPoint;
  28780. };
  28781. /**
  28782. * Notice: only enable needed types. For example, if 'zoom'
  28783. * is not needed, 'zoom' should not be enabled, otherwise
  28784. * default mousewheel behaviour (scroll page) will be disabled.
  28785. *
  28786. * @param {boolean|string} [controlType=true] Specify the control type,
  28787. * which can be null/undefined or true/false
  28788. * or 'pan/move' or 'zoom'/'scale'
  28789. */
  28790. this.enable = function (controlType) {
  28791. // Disable previous first
  28792. this.disable();
  28793. if (controlType == null) {
  28794. controlType = true;
  28795. }
  28796. if (controlType === true || (controlType === 'move' || controlType === 'pan')) {
  28797. zr.on('mousedown', mousedownHandler);
  28798. zr.on('mousemove', mousemoveHandler);
  28799. zr.on('mouseup', mouseupHandler);
  28800. }
  28801. if (controlType === true || (controlType === 'scale' || controlType === 'zoom')) {
  28802. zr.on('mousewheel', mousewheelHandler);
  28803. zr.on('pinch', pinchHandler);
  28804. }
  28805. };
  28806. this.disable = function () {
  28807. zr.off('mousedown', mousedownHandler);
  28808. zr.off('mousemove', mousemoveHandler);
  28809. zr.off('mouseup', mouseupHandler);
  28810. zr.off('mousewheel', mousewheelHandler);
  28811. zr.off('pinch', pinchHandler);
  28812. };
  28813. this.dispose = this.disable;
  28814. this.isDragging = function () {
  28815. return this._dragging;
  28816. };
  28817. this.isPinching = function () {
  28818. return this._pinching;
  28819. };
  28820. }
  28821. zrUtil.mixin(RoamController, Eventful);
  28822. module.exports = RoamController;
  28823. /***/ },
  28824. /* 177 */
  28825. /***/ function(module, exports, __webpack_require__) {
  28826. var ATTR = '\0_ec_interaction_mutex';
  28827. var interactionMutex = {
  28828. take: function (zr, resourceKey, userKey) {
  28829. var store = getStore(zr);
  28830. store[resourceKey] = userKey;
  28831. },
  28832. release: function (zr, resourceKey, userKey) {
  28833. var store = getStore(zr);
  28834. var uKey = store[resourceKey];
  28835. if (uKey === userKey) {
  28836. store[resourceKey] = null;
  28837. }
  28838. },
  28839. isTaken: function (zr, resourceKey) {
  28840. return !!getStore(zr)[resourceKey];
  28841. }
  28842. };
  28843. function getStore(zr) {
  28844. return zr[ATTR] || (zr[ATTR] = {});
  28845. }
  28846. /**
  28847. * payload: {
  28848. * type: 'takeGlobalCursor',
  28849. * key: 'dataZoomSelect', or 'brush', or ...,
  28850. * If no userKey, release global cursor.
  28851. * }
  28852. */
  28853. __webpack_require__(1).registerAction(
  28854. {type: 'takeGlobalCursor', event: 'globalCursorTaken', update: 'update'},
  28855. function () {}
  28856. );
  28857. module.exports = interactionMutex;
  28858. /***/ },
  28859. /* 178 */
  28860. /***/ function(module, exports, __webpack_require__) {
  28861. var zrUtil = __webpack_require__(4);
  28862. var roamHelper = __webpack_require__(179);
  28863. var echarts = __webpack_require__(1);
  28864. /**
  28865. * @payload
  28866. * @property {string} [componentType=series]
  28867. * @property {number} [dx]
  28868. * @property {number} [dy]
  28869. * @property {number} [zoom]
  28870. * @property {number} [originX]
  28871. * @property {number} [originY]
  28872. */
  28873. echarts.registerAction({
  28874. type: 'geoRoam',
  28875. event: 'geoRoam',
  28876. update: 'updateLayout'
  28877. }, function (payload, ecModel) {
  28878. var componentType = payload.componentType || 'series';
  28879. ecModel.eachComponent(
  28880. { mainType: componentType, query: payload },
  28881. function (componentModel) {
  28882. var geo = componentModel.coordinateSystem;
  28883. if (geo.type !== 'geo') {
  28884. return;
  28885. }
  28886. var res = roamHelper.updateCenterAndZoom(
  28887. geo, payload, componentModel.get('scaleLimit')
  28888. );
  28889. componentModel.setCenter
  28890. && componentModel.setCenter(res.center);
  28891. componentModel.setZoom
  28892. && componentModel.setZoom(res.zoom);
  28893. // All map series with same `map` use the same geo coordinate system
  28894. // So the center and zoom must be in sync. Include the series not selected by legend
  28895. if (componentType === 'series') {
  28896. zrUtil.each(componentModel.seriesGroup, function (seriesModel) {
  28897. seriesModel.setCenter(res.center);
  28898. seriesModel.setZoom(res.zoom);
  28899. });
  28900. }
  28901. }
  28902. );
  28903. });
  28904. /***/ },
  28905. /* 179 */
  28906. /***/ function(module, exports) {
  28907. var roamHelper = {};
  28908. /**
  28909. * @param {module:echarts/coord/View} view
  28910. * @param {Object} payload
  28911. * @param {Object} [zoomLimit]
  28912. */
  28913. roamHelper.updateCenterAndZoom = function (
  28914. view, payload, zoomLimit
  28915. ) {
  28916. var previousZoom = view.getZoom();
  28917. var center = view.getCenter();
  28918. var zoom = payload.zoom;
  28919. var point = view.dataToPoint(center);
  28920. if (payload.dx != null && payload.dy != null) {
  28921. point[0] -= payload.dx;
  28922. point[1] -= payload.dy;
  28923. var center = view.pointToData(point);
  28924. view.setCenter(center);
  28925. }
  28926. if (zoom != null) {
  28927. if (zoomLimit) {
  28928. var zoomMin = zoomLimit.min || 0;
  28929. var zoomMax = zoomLimit.max || Infinity;
  28930. zoom = Math.max(
  28931. Math.min(previousZoom * zoom, zoomMax),
  28932. zoomMin
  28933. ) / previousZoom;
  28934. }
  28935. // Zoom on given point(originX, originY)
  28936. view.scale[0] *= zoom;
  28937. view.scale[1] *= zoom;
  28938. var position = view.position;
  28939. var fixX = (payload.originX - position[0]) * (zoom - 1);
  28940. var fixY = (payload.originY - position[1]) * (zoom - 1);
  28941. position[0] -= fixX;
  28942. position[1] -= fixY;
  28943. view.updateTransform();
  28944. // Get the new center
  28945. var center = view.pointToData(point);
  28946. view.setCenter(center);
  28947. view.setZoom(zoom * previousZoom);
  28948. }
  28949. return {
  28950. center: view.getCenter(),
  28951. zoom: view.getZoom()
  28952. };
  28953. };
  28954. module.exports = roamHelper;
  28955. /***/ },
  28956. /* 180 */
  28957. /***/ function(module, exports, __webpack_require__) {
  28958. var zrUtil = __webpack_require__(4);
  28959. module.exports = function (ecModel) {
  28960. var processedMapType = {};
  28961. ecModel.eachSeriesByType('map', function (mapSeries) {
  28962. var mapType = mapSeries.get('map');
  28963. if (processedMapType[mapType]) {
  28964. return;
  28965. }
  28966. var mapSymbolOffsets = {};
  28967. zrUtil.each(mapSeries.seriesGroup, function (subMapSeries) {
  28968. var geo = subMapSeries.coordinateSystem;
  28969. var data = subMapSeries.originalData;
  28970. if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) {
  28971. data.each('value', function (value, idx) {
  28972. var name = data.getName(idx);
  28973. var region = geo.getRegion(name);
  28974. // If input series.data is [11, 22, '-'/null/undefined, 44],
  28975. // it will be filled with NaN: [11, 22, NaN, 44] and NaN will
  28976. // not be drawn. So here must validate if value is NaN.
  28977. if (!region || isNaN(value)) {
  28978. return;
  28979. }
  28980. var offset = mapSymbolOffsets[name] || 0;
  28981. var point = geo.dataToPoint(region.center);
  28982. mapSymbolOffsets[name] = offset + 1;
  28983. data.setItemLayout(idx, {
  28984. point: point,
  28985. offset: offset
  28986. });
  28987. });
  28988. }
  28989. });
  28990. // Show label of those region not has legendSymbol(which is offset 0)
  28991. var data = mapSeries.getData();
  28992. data.each(function (idx) {
  28993. var name = data.getName(idx);
  28994. var layout = data.getItemLayout(idx) || {};
  28995. layout.showLabel = !mapSymbolOffsets[name];
  28996. data.setItemLayout(idx, layout);
  28997. });
  28998. processedMapType[mapType] = true;
  28999. });
  29000. };
  29001. /***/ },
  29002. /* 181 */
  29003. /***/ function(module, exports) {
  29004. module.exports = function (ecModel) {
  29005. ecModel.eachSeriesByType('map', function (seriesModel) {
  29006. var colorList = seriesModel.get('color');
  29007. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  29008. var areaColor = itemStyleModel.get('areaColor');
  29009. var color = itemStyleModel.get('color')
  29010. || colorList[seriesModel.seriesIndex % colorList.length];
  29011. seriesModel.getData().setVisual({
  29012. 'areaColor': areaColor,
  29013. 'color': color
  29014. });
  29015. });
  29016. };
  29017. /***/ },
  29018. /* 182 */
  29019. /***/ function(module, exports, __webpack_require__) {
  29020. var zrUtil = __webpack_require__(4);
  29021. // FIXME 公用?
  29022. /**
  29023. * @param {Array.<module:echarts/data/List>} datas
  29024. * @param {string} statisticType 'average' 'sum'
  29025. * @inner
  29026. */
  29027. function dataStatistics(datas, statisticType) {
  29028. var dataNameMap = {};
  29029. var dims = ['value'];
  29030. for (var i = 0; i < datas.length; i++) {
  29031. datas[i].each(dims, function (value, idx) {
  29032. var name = datas[i].getName(idx);
  29033. dataNameMap[name] = dataNameMap[name] || [];
  29034. if (!isNaN(value)) {
  29035. dataNameMap[name].push(value);
  29036. }
  29037. });
  29038. }
  29039. return datas[0].map(dims, function (value, idx) {
  29040. var name = datas[0].getName(idx);
  29041. var sum = 0;
  29042. var min = Infinity;
  29043. var max = -Infinity;
  29044. var len = dataNameMap[name].length;
  29045. for (var i = 0; i < len; i++) {
  29046. min = Math.min(min, dataNameMap[name][i]);
  29047. max = Math.max(max, dataNameMap[name][i]);
  29048. sum += dataNameMap[name][i];
  29049. }
  29050. var result;
  29051. if (statisticType === 'min') {
  29052. result = min;
  29053. }
  29054. else if (statisticType === 'max') {
  29055. result = max;
  29056. }
  29057. else if (statisticType === 'average') {
  29058. result = sum / len;
  29059. }
  29060. else {
  29061. result = sum;
  29062. }
  29063. return len === 0 ? NaN : result;
  29064. });
  29065. }
  29066. module.exports = function (ecModel) {
  29067. var seriesGroupByMapType = {};
  29068. ecModel.eachSeriesByType('map', function (seriesModel) {
  29069. var mapType = seriesModel.get('map');
  29070. seriesGroupByMapType[mapType] = seriesGroupByMapType[mapType] || [];
  29071. seriesGroupByMapType[mapType].push(seriesModel);
  29072. });
  29073. zrUtil.each(seriesGroupByMapType, function (seriesList, mapType) {
  29074. var data = dataStatistics(
  29075. zrUtil.map(seriesList, function (seriesModel) {
  29076. return seriesModel.getData();
  29077. }),
  29078. seriesList[0].get('mapValueCalculation')
  29079. );
  29080. for (var i = 0; i < seriesList.length; i++) {
  29081. seriesList[i].originalData = seriesList[i].getData();
  29082. }
  29083. // FIXME Put where?
  29084. for (var i = 0; i < seriesList.length; i++) {
  29085. seriesList[i].seriesGroup = seriesList;
  29086. seriesList[i].needsDrawMap = i === 0;
  29087. seriesList[i].setData(data.cloneShallow());
  29088. seriesList[i].mainSeries = seriesList[0];
  29089. }
  29090. });
  29091. };
  29092. /***/ },
  29093. /* 183 */
  29094. /***/ function(module, exports, __webpack_require__) {
  29095. var zrUtil = __webpack_require__(4);
  29096. module.exports = function (option) {
  29097. // Save geoCoord
  29098. var mapSeries = [];
  29099. zrUtil.each(option.series, function (seriesOpt) {
  29100. if (seriesOpt.type === 'map') {
  29101. mapSeries.push(seriesOpt);
  29102. }
  29103. });
  29104. zrUtil.each(mapSeries, function (seriesOpt) {
  29105. seriesOpt.map = seriesOpt.map || seriesOpt.mapType;
  29106. // Put x, y, width, height, x2, y2 in the top level
  29107. zrUtil.defaults(seriesOpt, seriesOpt.mapLocation);
  29108. });
  29109. };
  29110. /***/ },
  29111. /* 184 */
  29112. /***/ function(module, exports, __webpack_require__) {
  29113. var echarts = __webpack_require__(1);
  29114. __webpack_require__(185);
  29115. __webpack_require__(189);
  29116. __webpack_require__(192);
  29117. echarts.registerVisual(__webpack_require__(193));
  29118. echarts.registerLayout(__webpack_require__(195));
  29119. /***/ },
  29120. /* 185 */
  29121. /***/ function(module, exports, __webpack_require__) {
  29122. var SeriesModel = __webpack_require__(28);
  29123. var Tree = __webpack_require__(186);
  29124. var zrUtil = __webpack_require__(4);
  29125. var Model = __webpack_require__(12);
  29126. var formatUtil = __webpack_require__(6);
  29127. var helper = __webpack_require__(188);
  29128. var encodeHTML = formatUtil.encodeHTML;
  29129. var addCommas = formatUtil.addCommas;
  29130. module.exports = SeriesModel.extend({
  29131. type: 'series.treemap',
  29132. layoutMode: 'box',
  29133. dependencies: ['grid', 'polar'],
  29134. /**
  29135. * @type {module:echarts/data/Tree~Node}
  29136. */
  29137. _viewRoot: null,
  29138. defaultOption: {
  29139. // Disable progressive rendering
  29140. progressive: 0,
  29141. hoverLayerThreshold: Infinity,
  29142. // center: ['50%', '50%'], // not supported in ec3.
  29143. // size: ['80%', '80%'], // deprecated, compatible with ec2.
  29144. left: 'center',
  29145. top: 'middle',
  29146. right: null,
  29147. bottom: null,
  29148. width: '80%',
  29149. height: '80%',
  29150. sort: true, // Can be null or false or true
  29151. // (order by desc default, asc not supported yet (strange effect))
  29152. clipWindow: 'origin', // Size of clipped window when zooming. 'origin' or 'fullscreen'
  29153. squareRatio: 0.5 * (1 + Math.sqrt(5)), // golden ratio
  29154. leafDepth: null, // Nodes on depth from root are regarded as leaves.
  29155. // Count from zero (zero represents only view root).
  29156. drillDownIcon: '▶', // Use html character temporarily because it is complicated
  29157. // to align specialized icon. ▷▶❒❐▼✚
  29158. zoomToNodeRatio: 0.32 * 0.32, // Be effective when using zoomToNode. Specify the proportion of the
  29159. // target node area in the view area.
  29160. roam: true, // true, false, 'scale' or 'zoom', 'move'.
  29161. nodeClick: 'zoomToNode', // Leaf node click behaviour: 'zoomToNode', 'link', false.
  29162. // If leafDepth is set and clicking a node which has children but
  29163. // be on left depth, the behaviour would be changing root. Otherwise
  29164. // use behavious defined above.
  29165. animation: true,
  29166. animationDurationUpdate: 900,
  29167. animationEasing: 'quinticInOut',
  29168. breadcrumb: {
  29169. show: true,
  29170. height: 22,
  29171. left: 'center',
  29172. top: 'bottom',
  29173. // right
  29174. // bottom
  29175. emptyItemWidth: 25, // Width of empty node.
  29176. itemStyle: {
  29177. normal: {
  29178. color: 'rgba(0,0,0,0.7)', //'#5793f3',
  29179. borderColor: 'rgba(255,255,255,0.7)',
  29180. borderWidth: 1,
  29181. shadowColor: 'rgba(150,150,150,1)',
  29182. shadowBlur: 3,
  29183. shadowOffsetX: 0,
  29184. shadowOffsetY: 0,
  29185. textStyle: {
  29186. color: '#fff'
  29187. }
  29188. },
  29189. emphasis: {
  29190. textStyle: {}
  29191. }
  29192. }
  29193. },
  29194. label: {
  29195. normal: {
  29196. show: true,
  29197. position: 'inside', // Can be [5, '5%'] or position stirng like 'insideTopLeft', ...
  29198. textStyle: {
  29199. color: '#fff',
  29200. ellipsis: true
  29201. }
  29202. }
  29203. },
  29204. itemStyle: {
  29205. normal: {
  29206. color: null, // Can be 'none' if not necessary.
  29207. colorAlpha: null, // Can be 'none' if not necessary.
  29208. colorSaturation: null, // Can be 'none' if not necessary.
  29209. borderWidth: 0,
  29210. gapWidth: 0,
  29211. borderColor: '#fff',
  29212. borderColorSaturation: null // If specified, borderColor will be ineffective, and the
  29213. // border color is evaluated by color of current node and
  29214. // borderColorSaturation.
  29215. },
  29216. emphasis: {
  29217. }
  29218. },
  29219. visualDimension: 0, // Can be 0, 1, 2, 3.
  29220. visualMin: null,
  29221. visualMax: null,
  29222. color: [], // + treemapSeries.color should not be modified. Please only modified
  29223. // level[n].color (if necessary).
  29224. // + Specify color list of each level. level[0].color would be global
  29225. // color list if not specified. (see method `setDefault`).
  29226. // + But set as a empty array to forbid fetch color from global palette
  29227. // when using nodeModel.get('color'), otherwise nodes on deep level
  29228. // will always has color palette set and are not able to inherit color
  29229. // from parent node.
  29230. // + TreemapSeries.color can not be set as 'none', otherwise effect
  29231. // legend color fetching (see seriesColor.js).
  29232. colorAlpha: null, // Array. Specify color alpha range of each level, like [0.2, 0.8]
  29233. colorSaturation: null, // Array. Specify color saturation of each level, like [0.2, 0.5]
  29234. colorMappingBy: 'index', // 'value' or 'index' or 'id'.
  29235. visibleMin: 10, // If area less than this threshold (unit: pixel^2), node will not
  29236. // be rendered. Only works when sort is 'asc' or 'desc'.
  29237. childrenVisibleMin: null, // If area of a node less than this threshold (unit: pixel^2),
  29238. // grandchildren will not show.
  29239. // Why grandchildren? If not grandchildren but children,
  29240. // some siblings show children and some not,
  29241. // the appearance may be mess and not consistent,
  29242. levels: [] // Each item: {
  29243. // visibleMin, itemStyle, visualDimension, label
  29244. // }
  29245. // data: {
  29246. // value: [],
  29247. // children: [],
  29248. // link: 'http://xxx.xxx.xxx',
  29249. // target: 'blank' or 'self'
  29250. // }
  29251. },
  29252. /**
  29253. * @override
  29254. */
  29255. getInitialData: function (option, ecModel) {
  29256. var data = option.data || [];
  29257. var rootName = option.name;
  29258. rootName == null && (rootName = option.name);
  29259. // Create a virtual root.
  29260. var root = {name: rootName, children: option.data};
  29261. var value0 = (data[0] || {}).value;
  29262. completeTreeValue(root, zrUtil.isArray(value0) ? value0.length : -1);
  29263. // FIXME
  29264. // sereis.mergeOption 的 getInitData是否放在merge后,从而能直接获取merege后的结果而非手动判断。
  29265. var levels = option.levels || [];
  29266. levels = option.levels = setDefault(levels, ecModel);
  29267. // Make sure always a new tree is created when setOption,
  29268. // in TreemapView, we check whether oldTree === newTree
  29269. // to choose mappings approach among old shapes and new shapes.
  29270. return Tree.createTree(root, this, levels).data;
  29271. },
  29272. optionUpdated: function () {
  29273. this.resetViewRoot();
  29274. },
  29275. /**
  29276. * @override
  29277. * @param {number} dataIndex
  29278. * @param {boolean} [mutipleSeries=false]
  29279. */
  29280. formatTooltip: function (dataIndex) {
  29281. var data = this.getData();
  29282. var value = this.getRawValue(dataIndex);
  29283. var formattedValue = zrUtil.isArray(value)
  29284. ? addCommas(value[0]) : addCommas(value);
  29285. var name = data.getName(dataIndex);
  29286. return encodeHTML(name) + ': ' + formattedValue;
  29287. },
  29288. /**
  29289. * Add tree path to tooltip param
  29290. *
  29291. * @override
  29292. * @param {number} dataIndex
  29293. * @return {Object}
  29294. */
  29295. getDataParams: function (dataIndex) {
  29296. var params = SeriesModel.prototype.getDataParams.apply(this, arguments);
  29297. var node = this.getData().tree.getNodeByDataIndex(dataIndex);
  29298. params.treePathInfo = helper.wrapTreePathInfo(node, this);
  29299. return params;
  29300. },
  29301. /**
  29302. * @public
  29303. * @param {Object} layoutInfo {
  29304. * x: containerGroup x
  29305. * y: containerGroup y
  29306. * width: containerGroup width
  29307. * height: containerGroup height
  29308. * }
  29309. */
  29310. setLayoutInfo: function (layoutInfo) {
  29311. /**
  29312. * @readOnly
  29313. * @type {Object}
  29314. */
  29315. this.layoutInfo = this.layoutInfo || {};
  29316. zrUtil.extend(this.layoutInfo, layoutInfo);
  29317. },
  29318. /**
  29319. * @param {string} id
  29320. * @return {number} index
  29321. */
  29322. mapIdToIndex: function (id) {
  29323. // A feature is implemented:
  29324. // index is monotone increasing with the sequence of
  29325. // input id at the first time.
  29326. // This feature can make sure that each data item and its
  29327. // mapped color have the same index between data list and
  29328. // color list at the beginning, which is useful for user
  29329. // to adjust data-color mapping.
  29330. /**
  29331. * @private
  29332. * @type {Object}
  29333. */
  29334. var idIndexMap = this._idIndexMap;
  29335. if (!idIndexMap) {
  29336. idIndexMap = this._idIndexMap = {};
  29337. /**
  29338. * @private
  29339. * @type {number}
  29340. */
  29341. this._idIndexMapCount = 0;
  29342. }
  29343. var index = idIndexMap[id];
  29344. if (index == null) {
  29345. idIndexMap[id] = index = this._idIndexMapCount++;
  29346. }
  29347. return index;
  29348. },
  29349. getViewRoot: function () {
  29350. return this._viewRoot;
  29351. },
  29352. /**
  29353. * @param {module:echarts/data/Tree~Node} [viewRoot]
  29354. */
  29355. resetViewRoot: function (viewRoot) {
  29356. viewRoot
  29357. ? (this._viewRoot = viewRoot)
  29358. : (viewRoot = this._viewRoot);
  29359. var root = this.getData().tree.root;
  29360. if (!viewRoot
  29361. || (viewRoot !== root && !root.contains(viewRoot))
  29362. ) {
  29363. this._viewRoot = root;
  29364. }
  29365. }
  29366. });
  29367. /**
  29368. * @param {Object} dataNode
  29369. */
  29370. function completeTreeValue(dataNode, arrValueLength) {
  29371. // Postorder travel tree.
  29372. // If value of none-leaf node is not set,
  29373. // calculate it by suming up the value of all children.
  29374. var sum = 0;
  29375. zrUtil.each(dataNode.children, function (child) {
  29376. completeTreeValue(child, arrValueLength);
  29377. var childValue = child.value;
  29378. zrUtil.isArray(childValue) && (childValue = childValue[0]);
  29379. sum += childValue;
  29380. });
  29381. var thisValue = dataNode.value;
  29382. if (arrValueLength >= 0) {
  29383. if (!zrUtil.isArray(thisValue)) {
  29384. dataNode.value = new Array(arrValueLength);
  29385. }
  29386. else {
  29387. thisValue = thisValue[0];
  29388. }
  29389. }
  29390. if (thisValue == null || isNaN(thisValue)) {
  29391. thisValue = sum;
  29392. }
  29393. // Value should not less than 0.
  29394. if (thisValue < 0) {
  29395. thisValue = 0;
  29396. }
  29397. arrValueLength >= 0
  29398. ? (dataNode.value[0] = thisValue)
  29399. : (dataNode.value = thisValue);
  29400. }
  29401. /**
  29402. * set default to level configuration
  29403. */
  29404. function setDefault(levels, ecModel) {
  29405. var globalColorList = ecModel.get('color');
  29406. if (!globalColorList) {
  29407. return;
  29408. }
  29409. levels = levels || [];
  29410. var hasColorDefine;
  29411. zrUtil.each(levels, function (levelDefine) {
  29412. var model = new Model(levelDefine);
  29413. var modelColor = model.get('color');
  29414. if (model.get('itemStyle.normal.color')
  29415. || (modelColor && modelColor !== 'none')
  29416. ) {
  29417. hasColorDefine = true;
  29418. }
  29419. });
  29420. if (!hasColorDefine) {
  29421. var level0 = levels[0] || (levels[0] = {});
  29422. level0.color = globalColorList.slice();
  29423. }
  29424. return levels;
  29425. }
  29426. /***/ },
  29427. /* 186 */
  29428. /***/ function(module, exports, __webpack_require__) {
  29429. /**
  29430. * Tree data structure
  29431. *
  29432. * @module echarts/data/Tree
  29433. */
  29434. var zrUtil = __webpack_require__(4);
  29435. var Model = __webpack_require__(12);
  29436. var List = __webpack_require__(98);
  29437. var linkList = __webpack_require__(187);
  29438. var completeDimensions = __webpack_require__(103);
  29439. /**
  29440. * @constructor module:echarts/data/Tree~TreeNode
  29441. * @param {string} name
  29442. * @param {module:echarts/data/Tree} hostTree
  29443. */
  29444. var TreeNode = function (name, hostTree) {
  29445. /**
  29446. * @type {string}
  29447. */
  29448. this.name = name || '';
  29449. /**
  29450. * Depth of node
  29451. *
  29452. * @type {number}
  29453. * @readOnly
  29454. */
  29455. this.depth = 0;
  29456. /**
  29457. * Height of the subtree rooted at this node.
  29458. * @type {number}
  29459. * @readOnly
  29460. */
  29461. this.height = 0;
  29462. /**
  29463. * @type {module:echarts/data/Tree~TreeNode}
  29464. * @readOnly
  29465. */
  29466. this.parentNode = null;
  29467. /**
  29468. * Reference to list item.
  29469. * Do not persistent dataIndex outside,
  29470. * besause it may be changed by list.
  29471. * If dataIndex -1,
  29472. * this node is logical deleted (filtered) in list.
  29473. *
  29474. * @type {Object}
  29475. * @readOnly
  29476. */
  29477. this.dataIndex = -1;
  29478. /**
  29479. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  29480. * @readOnly
  29481. */
  29482. this.children = [];
  29483. /**
  29484. * @type {Array.<module:echarts/data/Tree~TreeNode>}
  29485. * @pubilc
  29486. */
  29487. this.viewChildren = [];
  29488. /**
  29489. * @type {moduel:echarts/data/Tree}
  29490. * @readOnly
  29491. */
  29492. this.hostTree = hostTree;
  29493. };
  29494. TreeNode.prototype = {
  29495. constructor: TreeNode,
  29496. /**
  29497. * The node is removed.
  29498. * @return {boolean} is removed.
  29499. */
  29500. isRemoved: function () {
  29501. return this.dataIndex < 0;
  29502. },
  29503. /**
  29504. * Travel this subtree (include this node).
  29505. * Usage:
  29506. * node.eachNode(function () { ... }); // preorder
  29507. * node.eachNode('preorder', function () { ... }); // preorder
  29508. * node.eachNode('postorder', function () { ... }); // postorder
  29509. * node.eachNode(
  29510. * {order: 'postorder', attr: 'viewChildren'},
  29511. * function () { ... }
  29512. * ); // postorder
  29513. *
  29514. * @param {(Object|string)} options If string, means order.
  29515. * @param {string=} options.order 'preorder' or 'postorder'
  29516. * @param {string=} options.attr 'children' or 'viewChildren'
  29517. * @param {Function} cb If in preorder and return false,
  29518. * its subtree will not be visited.
  29519. * @param {Object} [context]
  29520. */
  29521. eachNode: function (options, cb, context) {
  29522. if (typeof options === 'function') {
  29523. context = cb;
  29524. cb = options;
  29525. options = null;
  29526. }
  29527. options = options || {};
  29528. if (zrUtil.isString(options)) {
  29529. options = {order: options};
  29530. }
  29531. var order = options.order || 'preorder';
  29532. var children = this[options.attr || 'children'];
  29533. var suppressVisitSub;
  29534. order === 'preorder' && (suppressVisitSub = cb.call(context, this));
  29535. for (var i = 0; !suppressVisitSub && i < children.length; i++) {
  29536. children[i].eachNode(options, cb, context);
  29537. }
  29538. order === 'postorder' && cb.call(context, this);
  29539. },
  29540. /**
  29541. * Update depth and height of this subtree.
  29542. *
  29543. * @param {number} depth
  29544. */
  29545. updateDepthAndHeight: function (depth) {
  29546. var height = 0;
  29547. this.depth = depth;
  29548. for (var i = 0; i < this.children.length; i++) {
  29549. var child = this.children[i];
  29550. child.updateDepthAndHeight(depth + 1);
  29551. if (child.height > height) {
  29552. height = child.height;
  29553. }
  29554. }
  29555. this.height = height + 1;
  29556. },
  29557. /**
  29558. * @param {string} id
  29559. * @return {module:echarts/data/Tree~TreeNode}
  29560. */
  29561. getNodeById: function (id) {
  29562. if (this.getId() === id) {
  29563. return this;
  29564. }
  29565. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  29566. var res = children[i].getNodeById(id);
  29567. if (res) {
  29568. return res;
  29569. }
  29570. }
  29571. },
  29572. /**
  29573. * @param {module:echarts/data/Tree~TreeNode} node
  29574. * @return {boolean}
  29575. */
  29576. contains: function (node) {
  29577. if (node === this) {
  29578. return true;
  29579. }
  29580. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  29581. var res = children[i].contains(node);
  29582. if (res) {
  29583. return res;
  29584. }
  29585. }
  29586. },
  29587. /**
  29588. * @param {boolean} includeSelf Default false.
  29589. * @return {Array.<module:echarts/data/Tree~TreeNode>} order: [root, child, grandchild, ...]
  29590. */
  29591. getAncestors: function (includeSelf) {
  29592. var ancestors = [];
  29593. var node = includeSelf ? this : this.parentNode;
  29594. while (node) {
  29595. ancestors.push(node);
  29596. node = node.parentNode;
  29597. }
  29598. ancestors.reverse();
  29599. return ancestors;
  29600. },
  29601. /**
  29602. * @param {string|Array=} [dimension='value'] Default 'value'. can be 0, 1, 2, 3
  29603. * @return {number} Value.
  29604. */
  29605. getValue: function (dimension) {
  29606. var data = this.hostTree.data;
  29607. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  29608. },
  29609. /**
  29610. * @param {Object} layout
  29611. * @param {boolean=} [merge=false]
  29612. */
  29613. setLayout: function (layout, merge) {
  29614. this.dataIndex >= 0
  29615. && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge);
  29616. },
  29617. /**
  29618. * @return {Object} layout
  29619. */
  29620. getLayout: function () {
  29621. return this.hostTree.data.getItemLayout(this.dataIndex);
  29622. },
  29623. /**
  29624. * @param {string} path
  29625. * @return {module:echarts/model/Model}
  29626. */
  29627. getModel: function (path) {
  29628. if (this.dataIndex < 0) {
  29629. return;
  29630. }
  29631. var hostTree = this.hostTree;
  29632. var itemModel = hostTree.data.getItemModel(this.dataIndex);
  29633. var levelModel = this.getLevelModel();
  29634. return itemModel.getModel(path, (levelModel || hostTree.hostModel).getModel(path));
  29635. },
  29636. /**
  29637. * @return {module:echarts/model/Model}
  29638. */
  29639. getLevelModel: function () {
  29640. return (this.hostTree.levelModels || [])[this.depth];
  29641. },
  29642. /**
  29643. * @example
  29644. * setItemVisual('color', color);
  29645. * setItemVisual({
  29646. * 'color': color
  29647. * });
  29648. */
  29649. setVisual: function (key, value) {
  29650. this.dataIndex >= 0
  29651. && this.hostTree.data.setItemVisual(this.dataIndex, key, value);
  29652. },
  29653. /**
  29654. * Get item visual
  29655. */
  29656. getVisual: function (key, ignoreParent) {
  29657. return this.hostTree.data.getItemVisual(this.dataIndex, key, ignoreParent);
  29658. },
  29659. /**
  29660. * @public
  29661. * @return {number}
  29662. */
  29663. getRawIndex: function () {
  29664. return this.hostTree.data.getRawIndex(this.dataIndex);
  29665. },
  29666. /**
  29667. * @public
  29668. * @return {string}
  29669. */
  29670. getId: function () {
  29671. return this.hostTree.data.getId(this.dataIndex);
  29672. }
  29673. };
  29674. /**
  29675. * @constructor
  29676. * @alias module:echarts/data/Tree
  29677. * @param {module:echarts/model/Model} hostModel
  29678. * @param {Array.<Object>} levelOptions
  29679. */
  29680. function Tree(hostModel, levelOptions) {
  29681. /**
  29682. * @type {module:echarts/data/Tree~TreeNode}
  29683. * @readOnly
  29684. */
  29685. this.root;
  29686. /**
  29687. * @type {module:echarts/data/List}
  29688. * @readOnly
  29689. */
  29690. this.data;
  29691. /**
  29692. * Index of each item is the same as the raw index of coresponding list item.
  29693. * @private
  29694. * @type {Array.<module:echarts/data/Tree~TreeNode}
  29695. */
  29696. this._nodes = [];
  29697. /**
  29698. * @private
  29699. * @readOnly
  29700. * @type {module:echarts/model/Model}
  29701. */
  29702. this.hostModel = hostModel;
  29703. /**
  29704. * @private
  29705. * @readOnly
  29706. * @type {Array.<module:echarts/model/Model}
  29707. */
  29708. this.levelModels = zrUtil.map(levelOptions || [], function (levelDefine) {
  29709. return new Model(levelDefine, hostModel, hostModel.ecModel);
  29710. });
  29711. }
  29712. Tree.prototype = {
  29713. constructor: Tree,
  29714. type: 'tree',
  29715. /**
  29716. * Travel this subtree (include this node).
  29717. * Usage:
  29718. * node.eachNode(function () { ... }); // preorder
  29719. * node.eachNode('preorder', function () { ... }); // preorder
  29720. * node.eachNode('postorder', function () { ... }); // postorder
  29721. * node.eachNode(
  29722. * {order: 'postorder', attr: 'viewChildren'},
  29723. * function () { ... }
  29724. * ); // postorder
  29725. *
  29726. * @param {(Object|string)} options If string, means order.
  29727. * @param {string=} options.order 'preorder' or 'postorder'
  29728. * @param {string=} options.attr 'children' or 'viewChildren'
  29729. * @param {Function} cb
  29730. * @param {Object} [context]
  29731. */
  29732. eachNode: function(options, cb, context) {
  29733. this.root.eachNode(options, cb, context);
  29734. },
  29735. /**
  29736. * @param {number} dataIndex
  29737. * @return {module:echarts/data/Tree~TreeNode}
  29738. */
  29739. getNodeByDataIndex: function (dataIndex) {
  29740. var rawIndex = this.data.getRawIndex(dataIndex);
  29741. return this._nodes[rawIndex];
  29742. },
  29743. /**
  29744. * @param {string} name
  29745. * @return {module:echarts/data/Tree~TreeNode}
  29746. */
  29747. getNodeByName: function (name) {
  29748. return this.root.getNodeByName(name);
  29749. },
  29750. /**
  29751. * Update item available by list,
  29752. * when list has been performed options like 'filterSelf' or 'map'.
  29753. */
  29754. update: function () {
  29755. var data = this.data;
  29756. var nodes = this._nodes;
  29757. for (var i = 0, len = nodes.length; i < len; i++) {
  29758. nodes[i].dataIndex = -1;
  29759. }
  29760. for (var i = 0, len = data.count(); i < len; i++) {
  29761. nodes[data.getRawIndex(i)].dataIndex = i;
  29762. }
  29763. },
  29764. /**
  29765. * Clear all layouts
  29766. */
  29767. clearLayouts: function () {
  29768. this.data.clearItemLayouts();
  29769. }
  29770. };
  29771. /**
  29772. * data node format:
  29773. * {
  29774. * name: ...
  29775. * value: ...
  29776. * children: [
  29777. * {
  29778. * name: ...
  29779. * value: ...
  29780. * children: ...
  29781. * },
  29782. * ...
  29783. * ]
  29784. * }
  29785. *
  29786. * @static
  29787. * @param {Objec} dataRoot Root node.
  29788. * @param {module:echarts/model/Model} hostModel
  29789. * @param {Array.<Object>} levelOptions
  29790. * @return module:echarts/data/Tree
  29791. */
  29792. Tree.createTree = function (dataRoot, hostModel, levelOptions) {
  29793. var tree = new Tree(hostModel, levelOptions);
  29794. var listData = [];
  29795. buildHierarchy(dataRoot);
  29796. function buildHierarchy(dataNode, parentNode) {
  29797. listData.push(dataNode);
  29798. var node = new TreeNode(dataNode.name, tree);
  29799. parentNode
  29800. ? addChild(node, parentNode)
  29801. : (tree.root = node);
  29802. tree._nodes.push(node);
  29803. var children = dataNode.children;
  29804. if (children) {
  29805. for (var i = 0; i < children.length; i++) {
  29806. buildHierarchy(children[i], node);
  29807. }
  29808. }
  29809. }
  29810. tree.root.updateDepthAndHeight(0);
  29811. var dimensions = completeDimensions([{name: 'value'}], listData);
  29812. var list = new List(dimensions, hostModel);
  29813. list.initData(listData);
  29814. linkList({
  29815. mainData: list,
  29816. struct: tree,
  29817. structAttr: 'tree'
  29818. });
  29819. tree.update();
  29820. return tree;
  29821. };
  29822. /**
  29823. * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote,
  29824. * so this function is not ready and not necessary to be public.
  29825. *
  29826. * @param {(module:echarts/data/Tree~TreeNode|Object)} child
  29827. */
  29828. function addChild(child, node) {
  29829. var children = node.children;
  29830. if (child.parentNode === node) {
  29831. return;
  29832. }
  29833. children.push(child);
  29834. child.parentNode = node;
  29835. }
  29836. module.exports = Tree;
  29837. /***/ },
  29838. /* 187 */
  29839. /***/ function(module, exports, __webpack_require__) {
  29840. /**
  29841. * Link lists and struct (graph or tree)
  29842. */
  29843. var zrUtil = __webpack_require__(4);
  29844. var each = zrUtil.each;
  29845. var DATAS = '\0__link_datas';
  29846. var MAIN_DATA = '\0__link_mainData';
  29847. // Caution:
  29848. // In most case, either list or its shallow clones (see list.cloneShallow)
  29849. // is active in echarts process. So considering heap memory consumption,
  29850. // we do not clone tree or graph, but share them among list and its shallow clones.
  29851. // But in some rare case, we have to keep old list (like do animation in chart). So
  29852. // please take care that both the old list and the new list share the same tree/graph.
  29853. /**
  29854. * @param {Object} opt
  29855. * @param {module:echarts/data/List} opt.mainData
  29856. * @param {Object} [opt.struct] For example, instance of Graph or Tree.
  29857. * @param {string} [opt.structAttr] designation: list[structAttr] = struct;
  29858. * @param {Object} [opt.datas] {dataType: data},
  29859. * like: {node: nodeList, edge: edgeList}.
  29860. * Should contain mainData.
  29861. * @param {Object} [opt.datasAttr] {dataType: attr},
  29862. * designation: struct[datasAttr[dataType]] = list;
  29863. */
  29864. function linkList(opt) {
  29865. var mainData = opt.mainData;
  29866. var datas = opt.datas;
  29867. if (!datas) {
  29868. datas = {main: mainData};
  29869. opt.datasAttr = {main: 'data'};
  29870. }
  29871. opt.datas = opt.mainData = null;
  29872. linkAll(mainData, datas, opt);
  29873. // Porxy data original methods.
  29874. each(datas, function (data) {
  29875. each(mainData.TRANSFERABLE_METHODS, function (methodName) {
  29876. data.wrapMethod(methodName, zrUtil.curry(transferInjection, opt));
  29877. });
  29878. });
  29879. // Beyond transfer, additional features should be added to `cloneShallow`.
  29880. mainData.wrapMethod('cloneShallow', zrUtil.curry(cloneShallowInjection, opt));
  29881. // Only mainData trigger change, because struct.update may trigger
  29882. // another changable methods, which may bring about dead lock.
  29883. each(mainData.CHANGABLE_METHODS, function (methodName) {
  29884. mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
  29885. });
  29886. // Make sure datas contains mainData.
  29887. zrUtil.assert(datas[mainData.dataType] === mainData);
  29888. }
  29889. function transferInjection(opt, res) {
  29890. if (isMainData(this)) {
  29891. // Transfer datas to new main data.
  29892. var datas = zrUtil.extend({}, this[DATAS]);
  29893. datas[this.dataType] = res;
  29894. linkAll(res, datas, opt);
  29895. }
  29896. else {
  29897. // Modify the reference in main data to point newData.
  29898. linkSingle(res, this.dataType, this[MAIN_DATA], opt);
  29899. }
  29900. return res;
  29901. }
  29902. function changeInjection(opt, res) {
  29903. opt.struct && opt.struct.update(this);
  29904. return res;
  29905. }
  29906. function cloneShallowInjection(opt, res) {
  29907. // cloneShallow, which brings about some fragilities, may be inappropriate
  29908. // to be exposed as an API. So for implementation simplicity we can make
  29909. // the restriction that cloneShallow of not-mainData should not be invoked
  29910. // outside, but only be invoked here.
  29911. each(res[DATAS], function (data, dataType) {
  29912. data !== res && linkSingle(data.cloneShallow(), dataType, res, opt);
  29913. });
  29914. return res;
  29915. }
  29916. /**
  29917. * Supplement method to List.
  29918. *
  29919. * @public
  29920. * @param {string} [dataType] If not specified, return mainData.
  29921. * @return {module:echarts/data/List}
  29922. */
  29923. function getLinkedData(dataType) {
  29924. var mainData = this[MAIN_DATA];
  29925. return (dataType == null || mainData == null)
  29926. ? mainData
  29927. : mainData[DATAS][dataType];
  29928. }
  29929. function isMainData(data) {
  29930. return data[MAIN_DATA] === data;
  29931. }
  29932. function linkAll(mainData, datas, opt) {
  29933. mainData[DATAS] = {};
  29934. each(datas, function (data, dataType) {
  29935. linkSingle(data, dataType, mainData, opt);
  29936. });
  29937. }
  29938. function linkSingle(data, dataType, mainData, opt) {
  29939. mainData[DATAS][dataType] = data;
  29940. data[MAIN_DATA] = mainData;
  29941. data.dataType = dataType;
  29942. if (opt.struct) {
  29943. data[opt.structAttr] = opt.struct;
  29944. opt.struct[opt.datasAttr[dataType]] = data;
  29945. }
  29946. // Supplement method.
  29947. data.getLinkedData = getLinkedData;
  29948. }
  29949. module.exports = linkList;
  29950. /***/ },
  29951. /* 188 */
  29952. /***/ function(module, exports, __webpack_require__) {
  29953. var zrUtil = __webpack_require__(4);
  29954. var helper = {
  29955. retrieveTargetInfo: function (payload, seriesModel) {
  29956. if (payload
  29957. && (
  29958. payload.type === 'treemapZoomToNode'
  29959. || payload.type === 'treemapRootToNode'
  29960. )
  29961. ) {
  29962. var root = seriesModel.getData().tree.root;
  29963. var targetNode = payload.targetNode;
  29964. if (targetNode && root.contains(targetNode)) {
  29965. return {node: targetNode};
  29966. }
  29967. var targetNodeId = payload.targetNodeId;
  29968. if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
  29969. return {node: targetNode};
  29970. }
  29971. }
  29972. },
  29973. // Not includes the given node at the last item.
  29974. getPathToRoot: function (node) {
  29975. var path = [];
  29976. while (node) {
  29977. node = node.parentNode;
  29978. node && path.push(node);
  29979. }
  29980. return path.reverse();
  29981. },
  29982. aboveViewRoot: function (viewRoot, node) {
  29983. var viewPath = helper.getPathToRoot(viewRoot);
  29984. return zrUtil.indexOf(viewPath, node) >= 0;
  29985. },
  29986. // From root to the input node (the input node will be included).
  29987. wrapTreePathInfo: function (node, seriesModel) {
  29988. var treePathInfo = [];
  29989. while (node) {
  29990. var nodeDataIndex = node.dataIndex;
  29991. treePathInfo.push({
  29992. name: node.name,
  29993. dataIndex: nodeDataIndex,
  29994. value: seriesModel.getRawValue(nodeDataIndex)
  29995. });
  29996. node = node.parentNode;
  29997. }
  29998. treePathInfo.reverse();
  29999. return treePathInfo;
  30000. }
  30001. };
  30002. module.exports = helper;
  30003. /***/ },
  30004. /* 189 */
  30005. /***/ function(module, exports, __webpack_require__) {
  30006. var zrUtil = __webpack_require__(4);
  30007. var graphic = __webpack_require__(43);
  30008. var DataDiffer = __webpack_require__(99);
  30009. var helper = __webpack_require__(188);
  30010. var Breadcrumb = __webpack_require__(190);
  30011. var RoamController = __webpack_require__(176);
  30012. var BoundingRect = __webpack_require__(9);
  30013. var matrix = __webpack_require__(11);
  30014. var animationUtil = __webpack_require__(191);
  30015. var bind = zrUtil.bind;
  30016. var Group = graphic.Group;
  30017. var Rect = graphic.Rect;
  30018. var each = zrUtil.each;
  30019. var DRAG_THRESHOLD = 3;
  30020. var PATH_LABEL_NORMAL = ['label', 'normal'];
  30021. var PATH_LABEL_EMPHASIS = ['label', 'emphasis'];
  30022. var Z_BASE = 10; // Should bigger than every z.
  30023. var Z_BG = 1;
  30024. var Z_CONTENT = 2;
  30025. module.exports = __webpack_require__(1).extendChartView({
  30026. type: 'treemap',
  30027. /**
  30028. * @override
  30029. */
  30030. init: function (o, api) {
  30031. /**
  30032. * @private
  30033. * @type {module:zrender/container/Group}
  30034. */
  30035. this._containerGroup;
  30036. /**
  30037. * @private
  30038. * @type {Object.<string, Array.<module:zrender/container/Group>>}
  30039. */
  30040. this._storage = createStorage();
  30041. /**
  30042. * @private
  30043. * @type {module:echarts/data/Tree}
  30044. */
  30045. this._oldTree;
  30046. /**
  30047. * @private
  30048. * @type {module:echarts/chart/treemap/Breadcrumb}
  30049. */
  30050. this._breadcrumb;
  30051. /**
  30052. * @private
  30053. * @type {module:echarts/component/helper/RoamController}
  30054. */
  30055. this._controller;
  30056. /**
  30057. * 'ready', 'animating'
  30058. * @private
  30059. */
  30060. this._state = 'ready';
  30061. /**
  30062. * @private
  30063. * @type {boolean}
  30064. */
  30065. this._mayClick;
  30066. },
  30067. /**
  30068. * @override
  30069. */
  30070. render: function (seriesModel, ecModel, api, payload) {
  30071. var models = ecModel.findComponents({
  30072. mainType: 'series', subType: 'treemap', query: payload
  30073. });
  30074. if (zrUtil.indexOf(models, seriesModel) < 0) {
  30075. return;
  30076. }
  30077. this.seriesModel = seriesModel;
  30078. this.api = api;
  30079. this.ecModel = ecModel;
  30080. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  30081. var payloadType = payload && payload.type;
  30082. var layoutInfo = seriesModel.layoutInfo;
  30083. var isInit = !this._oldTree;
  30084. var thisStorage = this._storage;
  30085. // Mark new root when action is treemapRootToNode.
  30086. var reRoot = (payloadType === 'treemapRootToNode' && targetInfo && thisStorage)
  30087. ? {
  30088. rootNodeGroup: thisStorage.nodeGroup[targetInfo.node.getRawIndex()],
  30089. direction: payload.direction
  30090. }
  30091. : null;
  30092. var containerGroup = this._giveContainerGroup(layoutInfo);
  30093. var renderResult = this._doRender(containerGroup, seriesModel, reRoot);
  30094. (
  30095. !isInit && (
  30096. !payloadType
  30097. || payloadType === 'treemapZoomToNode'
  30098. || payloadType === 'treemapRootToNode'
  30099. )
  30100. )
  30101. ? this._doAnimation(containerGroup, renderResult, seriesModel, reRoot)
  30102. : renderResult.renderFinally();
  30103. this._resetController(api);
  30104. this._renderBreadcrumb(seriesModel, api, targetInfo);
  30105. },
  30106. /**
  30107. * @private
  30108. */
  30109. _giveContainerGroup: function (layoutInfo) {
  30110. var containerGroup = this._containerGroup;
  30111. if (!containerGroup) {
  30112. // FIXME
  30113. // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。
  30114. containerGroup = this._containerGroup = new Group();
  30115. this._initEvents(containerGroup);
  30116. this.group.add(containerGroup);
  30117. }
  30118. containerGroup.attr('position', [layoutInfo.x, layoutInfo.y]);
  30119. return containerGroup;
  30120. },
  30121. /**
  30122. * @private
  30123. */
  30124. _doRender: function (containerGroup, seriesModel, reRoot) {
  30125. var thisTree = seriesModel.getData().tree;
  30126. var oldTree = this._oldTree;
  30127. // Clear last shape records.
  30128. var lastsForAnimation = createStorage();
  30129. var thisStorage = createStorage();
  30130. var oldStorage = this._storage;
  30131. var willInvisibleEls = [];
  30132. var doRenderNode = zrUtil.curry(
  30133. renderNode, seriesModel,
  30134. thisStorage, oldStorage, reRoot,
  30135. lastsForAnimation, willInvisibleEls
  30136. );
  30137. // Notice: when thisTree and oldTree are the same tree (see list.cloneShadow),
  30138. // the oldTree is actually losted, so we can not find all of the old graphic
  30139. // elements from tree. So we use this stragegy: make element storage, move
  30140. // from old storage to new storage, clear old storage.
  30141. dualTravel(
  30142. thisTree.root ? [thisTree.root] : [],
  30143. (oldTree && oldTree.root) ? [oldTree.root] : [],
  30144. containerGroup,
  30145. thisTree === oldTree || !oldTree,
  30146. 0
  30147. );
  30148. // Process all removing.
  30149. var willDeleteEls = clearStorage(oldStorage);
  30150. this._oldTree = thisTree;
  30151. this._storage = thisStorage;
  30152. return {
  30153. lastsForAnimation: lastsForAnimation,
  30154. willDeleteEls: willDeleteEls,
  30155. renderFinally: renderFinally
  30156. };
  30157. function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, depth) {
  30158. // When 'render' is triggered by action,
  30159. // 'this' and 'old' may be the same tree,
  30160. // we use rawIndex in that case.
  30161. if (sameTree) {
  30162. oldViewChildren = thisViewChildren;
  30163. each(thisViewChildren, function (child, index) {
  30164. !child.isRemoved() && processNode(index, index);
  30165. });
  30166. }
  30167. // Diff hierarchically (diff only in each subtree, but not whole).
  30168. // because, consistency of view is important.
  30169. else {
  30170. (new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey))
  30171. .add(processNode)
  30172. .update(processNode)
  30173. .remove(zrUtil.curry(processNode, null))
  30174. .execute();
  30175. }
  30176. function getKey(node) {
  30177. // Identify by name or raw index.
  30178. return node.getId();
  30179. }
  30180. function processNode(newIndex, oldIndex) {
  30181. var thisNode = newIndex != null ? thisViewChildren[newIndex] : null;
  30182. var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null;
  30183. var group = doRenderNode(thisNode, oldNode, parentGroup, depth);
  30184. group && dualTravel(
  30185. thisNode && thisNode.viewChildren || [],
  30186. oldNode && oldNode.viewChildren || [],
  30187. group,
  30188. sameTree,
  30189. depth + 1
  30190. );
  30191. }
  30192. }
  30193. function clearStorage(storage) {
  30194. var willDeleteEls = createStorage();
  30195. storage && each(storage, function (store, storageName) {
  30196. var delEls = willDeleteEls[storageName];
  30197. each(store, function (el) {
  30198. el && (delEls.push(el), el.__tmWillDelete = 1);
  30199. });
  30200. });
  30201. return willDeleteEls;
  30202. }
  30203. function renderFinally() {
  30204. each(willDeleteEls, function (els) {
  30205. each(els, function (el) {
  30206. el.parent && el.parent.remove(el);
  30207. });
  30208. });
  30209. each(willInvisibleEls, function (el) {
  30210. el.invisible = true;
  30211. // Setting invisible is for optimizing, so no need to set dirty,
  30212. // just mark as invisible.
  30213. el.dirty();
  30214. });
  30215. }
  30216. },
  30217. /**
  30218. * @private
  30219. */
  30220. _doAnimation: function (containerGroup, renderResult, seriesModel, reRoot) {
  30221. if (!seriesModel.get('animation')) {
  30222. return;
  30223. }
  30224. var duration = seriesModel.get('animationDurationUpdate');
  30225. var easing = seriesModel.get('animationEasing');
  30226. var animationWrap = animationUtil.createWrap();
  30227. // Make delete animations.
  30228. each(renderResult.willDeleteEls, function (store, storageName) {
  30229. each(store, function (el, rawIndex) {
  30230. if (el.invisible) {
  30231. return;
  30232. }
  30233. var parent = el.parent; // Always has parent, and parent is nodeGroup.
  30234. var target;
  30235. if (reRoot && reRoot.direction === 'drillDown') {
  30236. target = parent === reRoot.rootNodeGroup
  30237. // This is the content element of view root.
  30238. // Only `content` will enter this branch, because
  30239. // `background` and `nodeGroup` will not be deleted.
  30240. ? {
  30241. shape: {
  30242. x: 0,
  30243. y: 0,
  30244. width: parent.__tmNodeWidth,
  30245. height: parent.__tmNodeHeight
  30246. },
  30247. style: {
  30248. opacity: 0
  30249. }
  30250. }
  30251. // Others.
  30252. : {style: {opacity: 0}};
  30253. }
  30254. else {
  30255. var targetX = 0;
  30256. var targetY = 0;
  30257. if (!parent.__tmWillDelete) {
  30258. // Let node animate to right-bottom corner, cooperating with fadeout,
  30259. // which is appropriate for user understanding.
  30260. // Divided by 2 for reRoot rolling up effect.
  30261. targetX = parent.__tmNodeWidth / 2;
  30262. targetY = parent.__tmNodeHeight / 2;
  30263. }
  30264. target = storageName === 'nodeGroup'
  30265. ? {position: [targetX, targetY], style: {opacity: 0}}
  30266. : {
  30267. shape: {x: targetX, y: targetY, width: 0, height: 0},
  30268. style: {opacity: 0}
  30269. };
  30270. }
  30271. target && animationWrap.add(el, target, duration, easing);
  30272. });
  30273. });
  30274. // Make other animations
  30275. each(this._storage, function (store, storageName) {
  30276. each(store, function (el, rawIndex) {
  30277. var last = renderResult.lastsForAnimation[storageName][rawIndex];
  30278. var target = {};
  30279. if (!last) {
  30280. return;
  30281. }
  30282. if (storageName === 'nodeGroup') {
  30283. if (last.old) {
  30284. target.position = el.position.slice();
  30285. el.attr('position', last.old);
  30286. }
  30287. }
  30288. else {
  30289. if (last.old) {
  30290. target.shape = zrUtil.extend({}, el.shape);
  30291. el.setShape(last.old);
  30292. }
  30293. if (last.fadein) {
  30294. el.setStyle('opacity', 0);
  30295. target.style = {opacity: 1};
  30296. }
  30297. // When animation is stopped for succedent animation starting,
  30298. // el.style.opacity might not be 1
  30299. else if (el.style.opacity !== 1) {
  30300. target.style = {opacity: 1};
  30301. }
  30302. }
  30303. animationWrap.add(el, target, duration, easing);
  30304. });
  30305. }, this);
  30306. this._state = 'animating';
  30307. animationWrap
  30308. .done(bind(function () {
  30309. this._state = 'ready';
  30310. renderResult.renderFinally();
  30311. }, this))
  30312. .start();
  30313. },
  30314. /**
  30315. * @private
  30316. */
  30317. _resetController: function (api) {
  30318. var controller = this._controller;
  30319. // Init controller.
  30320. if (!controller) {
  30321. controller = this._controller = new RoamController(api.getZr());
  30322. controller.enable(this.seriesModel.get('roam'));
  30323. controller.on('pan', bind(this._onPan, this));
  30324. controller.on('zoom', bind(this._onZoom, this));
  30325. }
  30326. var rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight());
  30327. controller.setContainsPoint(function (x, y) {
  30328. return rect.contain(x, y);
  30329. });
  30330. },
  30331. /**
  30332. * @private
  30333. */
  30334. _clearController: function () {
  30335. var controller = this._controller;
  30336. if (controller) {
  30337. controller.dispose();
  30338. controller = null;
  30339. }
  30340. },
  30341. /**
  30342. * @private
  30343. */
  30344. _onPan: function (dx, dy) {
  30345. this._mayClick = false;
  30346. if (this._state !== 'animating'
  30347. && (Math.abs(dx) > DRAG_THRESHOLD || Math.abs(dy) > DRAG_THRESHOLD)
  30348. ) {
  30349. // These param must not be cached.
  30350. var root = this.seriesModel.getData().tree.root;
  30351. if (!root) {
  30352. return;
  30353. }
  30354. var rootLayout = root.getLayout();
  30355. if (!rootLayout) {
  30356. return;
  30357. }
  30358. this.api.dispatchAction({
  30359. type: 'treemapMove',
  30360. from: this.uid,
  30361. seriesId: this.seriesModel.id,
  30362. rootRect: {
  30363. x: rootLayout.x + dx, y: rootLayout.y + dy,
  30364. width: rootLayout.width, height: rootLayout.height
  30365. }
  30366. });
  30367. }
  30368. },
  30369. /**
  30370. * @private
  30371. */
  30372. _onZoom: function (scale, mouseX, mouseY) {
  30373. this._mayClick = false;
  30374. if (this._state !== 'animating') {
  30375. // These param must not be cached.
  30376. var root = this.seriesModel.getData().tree.root;
  30377. if (!root) {
  30378. return;
  30379. }
  30380. var rootLayout = root.getLayout();
  30381. if (!rootLayout) {
  30382. return;
  30383. }
  30384. var rect = new BoundingRect(
  30385. rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height
  30386. );
  30387. var layoutInfo = this.seriesModel.layoutInfo;
  30388. // Transform mouse coord from global to containerGroup.
  30389. mouseX -= layoutInfo.x;
  30390. mouseY -= layoutInfo.y;
  30391. // Scale root bounding rect.
  30392. var m = matrix.create();
  30393. matrix.translate(m, m, [-mouseX, -mouseY]);
  30394. matrix.scale(m, m, [scale, scale]);
  30395. matrix.translate(m, m, [mouseX, mouseY]);
  30396. rect.applyTransform(m);
  30397. this.api.dispatchAction({
  30398. type: 'treemapRender',
  30399. from: this.uid,
  30400. seriesId: this.seriesModel.id,
  30401. rootRect: {
  30402. x: rect.x, y: rect.y,
  30403. width: rect.width, height: rect.height
  30404. }
  30405. });
  30406. }
  30407. },
  30408. /**
  30409. * @private
  30410. */
  30411. _initEvents: function (containerGroup) {
  30412. // FIXME
  30413. // 不用click以及silent的原因是,animate时视图设置silent true来避免click生效,
  30414. // 但是animate中,按下鼠标,animate结束后(silent设回为false)松开鼠标,
  30415. // 还是会触发click,期望是不触发。
  30416. // Mousedown occurs when drag start, and mouseup occurs when drag end,
  30417. // click event should not be triggered in that case.
  30418. containerGroup.on('mousedown', function (e) {
  30419. this._state === 'ready' && (this._mayClick = true);
  30420. }, this);
  30421. containerGroup.on('mouseup', function (e) {
  30422. if (this._mayClick) {
  30423. this._mayClick = false;
  30424. this._state === 'ready' && onClick.call(this, e);
  30425. }
  30426. }, this);
  30427. function onClick(e) {
  30428. var nodeClick = this.seriesModel.get('nodeClick', true);
  30429. if (!nodeClick) {
  30430. return;
  30431. }
  30432. var targetInfo = this.findTarget(e.offsetX, e.offsetY);
  30433. if (!targetInfo) {
  30434. return;
  30435. }
  30436. var node = targetInfo.node;
  30437. if (node.getLayout().isLeafRoot) {
  30438. this._rootToNode(targetInfo);
  30439. }
  30440. else {
  30441. if (nodeClick === 'zoomToNode') {
  30442. this._zoomToNode(targetInfo);
  30443. }
  30444. else if (nodeClick === 'link') {
  30445. var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
  30446. var link = itemModel.get('link', true);
  30447. var linkTarget = itemModel.get('target', true) || 'blank';
  30448. link && window.open(link, linkTarget);
  30449. }
  30450. }
  30451. }
  30452. },
  30453. /**
  30454. * @private
  30455. */
  30456. _renderBreadcrumb: function (seriesModel, api, targetInfo) {
  30457. if (!targetInfo) {
  30458. targetInfo = seriesModel.get('leafDepth', true) != null
  30459. ? {node: seriesModel.getViewRoot()}
  30460. // FIXME
  30461. // better way?
  30462. // Find breadcrumb tail on center of containerGroup.
  30463. : this.findTarget(api.getWidth() / 2, api.getHeight() / 2);
  30464. if (!targetInfo) {
  30465. targetInfo = {node: seriesModel.getData().tree.root};
  30466. }
  30467. }
  30468. (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group)))
  30469. .render(seriesModel, api, targetInfo.node, bind(onSelect, this));
  30470. function onSelect(node) {
  30471. if (this._state !== 'animating') {
  30472. helper.aboveViewRoot(seriesModel.getViewRoot(), node)
  30473. ? this._rootToNode({node: node})
  30474. : this._zoomToNode({node: node});
  30475. }
  30476. }
  30477. },
  30478. /**
  30479. * @override
  30480. */
  30481. remove: function () {
  30482. this._clearController();
  30483. this._containerGroup && this._containerGroup.removeAll();
  30484. this._storage = createStorage();
  30485. this._state = 'ready';
  30486. this._breadcrumb && this._breadcrumb.remove();
  30487. },
  30488. dispose: function () {
  30489. this._clearController();
  30490. },
  30491. /**
  30492. * @private
  30493. */
  30494. _zoomToNode: function (targetInfo) {
  30495. this.api.dispatchAction({
  30496. type: 'treemapZoomToNode',
  30497. from: this.uid,
  30498. seriesId: this.seriesModel.id,
  30499. targetNode: targetInfo.node
  30500. });
  30501. },
  30502. /**
  30503. * @private
  30504. */
  30505. _rootToNode: function (targetInfo) {
  30506. this.api.dispatchAction({
  30507. type: 'treemapRootToNode',
  30508. from: this.uid,
  30509. seriesId: this.seriesModel.id,
  30510. targetNode: targetInfo.node
  30511. });
  30512. },
  30513. /**
  30514. * @public
  30515. * @param {number} x Global coord x.
  30516. * @param {number} y Global coord y.
  30517. * @return {Object} info If not found, return undefined;
  30518. * @return {number} info.node Target node.
  30519. * @return {number} info.offsetX x refer to target node.
  30520. * @return {number} info.offsetY y refer to target node.
  30521. */
  30522. findTarget: function (x, y) {
  30523. var targetInfo;
  30524. var viewRoot = this.seriesModel.getViewRoot();
  30525. viewRoot.eachNode({attr: 'viewChildren', order: 'preorder'}, function (node) {
  30526. var bgEl = this._storage.background[node.getRawIndex()];
  30527. // If invisible, there might be no element.
  30528. if (bgEl) {
  30529. var point = bgEl.transformCoordToLocal(x, y);
  30530. var shape = bgEl.shape;
  30531. // For performance consideration, dont use 'getBoundingRect'.
  30532. if (shape.x <= point[0]
  30533. && point[0] <= shape.x + shape.width
  30534. && shape.y <= point[1]
  30535. && point[1] <= shape.y + shape.height
  30536. ) {
  30537. targetInfo = {node: node, offsetX: point[0], offsetY: point[1]};
  30538. }
  30539. else {
  30540. return false; // Suppress visit subtree.
  30541. }
  30542. }
  30543. }, this);
  30544. return targetInfo;
  30545. }
  30546. });
  30547. /**
  30548. * @inner
  30549. */
  30550. function createStorage() {
  30551. return {nodeGroup: [], background: [], content: []};
  30552. }
  30553. /**
  30554. * @inner
  30555. * @return Return undefined means do not travel further.
  30556. */
  30557. function renderNode(
  30558. seriesModel, thisStorage, oldStorage, reRoot,
  30559. lastsForAnimation, willInvisibleEls,
  30560. thisNode, oldNode, parentGroup, depth
  30561. ) {
  30562. // Whether under viewRoot.
  30563. if (!thisNode) {
  30564. // Deleting nodes will be performed finally. This method just find
  30565. // element from old storage, or create new element, set them to new
  30566. // storage, and set styles.
  30567. return;
  30568. }
  30569. var thisLayout = thisNode.getLayout();
  30570. if (!thisLayout || !thisLayout.isInView) {
  30571. return;
  30572. }
  30573. var thisWidth = thisLayout.width;
  30574. var thisHeight = thisLayout.height;
  30575. var thisInvisible = thisLayout.invisible;
  30576. var thisRawIndex = thisNode.getRawIndex();
  30577. var oldRawIndex = oldNode && oldNode.getRawIndex();
  30578. // Node group
  30579. var group = giveGraphic('nodeGroup', Group);
  30580. if (!group) {
  30581. return;
  30582. }
  30583. parentGroup.add(group);
  30584. // x,y are not set when el is above view root.
  30585. group.attr('position', [thisLayout.x || 0, thisLayout.y || 0]);
  30586. group.__tmNodeWidth = thisWidth;
  30587. group.__tmNodeHeight = thisHeight;
  30588. if (thisLayout.isAboveViewRoot) {
  30589. return group;
  30590. }
  30591. // Background
  30592. var bg = giveGraphic('background', Rect, depth, Z_BG);
  30593. if (bg) {
  30594. bg.setShape({x: 0, y: 0, width: thisWidth, height: thisHeight});
  30595. updateStyle(bg, function () {
  30596. bg.setStyle('fill', thisNode.getVisual('borderColor', true));
  30597. });
  30598. group.add(bg);
  30599. }
  30600. var thisViewChildren = thisNode.viewChildren;
  30601. // No children, render content.
  30602. if (!thisViewChildren || !thisViewChildren.length) {
  30603. var content = giveGraphic('content', Rect, depth, Z_CONTENT);
  30604. content && renderContent(group);
  30605. }
  30606. return group;
  30607. // ----------------------------
  30608. // | Procedures in renderNode |
  30609. // ----------------------------
  30610. function renderContent(group) {
  30611. // For tooltip.
  30612. content.dataIndex = thisNode.dataIndex;
  30613. content.seriesIndex = seriesModel.seriesIndex;
  30614. var borderWidth = thisLayout.borderWidth;
  30615. var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0);
  30616. var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0);
  30617. content.culling = true;
  30618. content.setShape({
  30619. x: borderWidth,
  30620. y: borderWidth,
  30621. width: contentWidth,
  30622. height: contentHeight
  30623. });
  30624. var visualColor = thisNode.getVisual('color', true);
  30625. updateStyle(content, function () {
  30626. var normalStyle = {fill: visualColor};
  30627. var emphasisStyle = thisNode.getModel('itemStyle.emphasis').getItemStyle();
  30628. prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight);
  30629. content.setStyle(normalStyle);
  30630. graphic.setHoverStyle(content, emphasisStyle);
  30631. });
  30632. group.add(content);
  30633. }
  30634. function updateStyle(element, cb) {
  30635. if (!thisInvisible) {
  30636. // If invisible, do not set visual, otherwise the element will
  30637. // change immediately before animation. We think it is OK to
  30638. // remain its origin color when moving out of the view window.
  30639. cb();
  30640. if (!element.__tmWillVisible) {
  30641. element.invisible = false;
  30642. }
  30643. }
  30644. else {
  30645. // Delay invisible setting utill animation finished,
  30646. // avoid element vanish suddenly before animation.
  30647. !element.invisible && willInvisibleEls.push(element);
  30648. }
  30649. }
  30650. function prepareText(normalStyle, emphasisStyle, visualColor, contentWidth, contentHeight) {
  30651. var nodeModel = thisNode.getModel();
  30652. var text = nodeModel.get('name');
  30653. if (thisLayout.isLeafRoot) {
  30654. var iconChar = seriesModel.get('drillDownIcon', true);
  30655. text = iconChar ? iconChar + ' ' + text : text;
  30656. }
  30657. setText(
  30658. text, normalStyle, nodeModel, PATH_LABEL_NORMAL,
  30659. visualColor, contentWidth, contentHeight
  30660. );
  30661. setText(
  30662. text, emphasisStyle, nodeModel, PATH_LABEL_EMPHASIS,
  30663. visualColor, contentWidth, contentHeight
  30664. );
  30665. }
  30666. function setText(text, style, nodeModel, labelPath, visualColor, contentWidth, contentHeight) {
  30667. var labelModel = nodeModel.getModel(labelPath);
  30668. var labelTextStyleModel = labelModel.getModel('textStyle');
  30669. graphic.setText(style, labelModel, visualColor);
  30670. // text.align and text.baseline is not included by graphic.setText,
  30671. // because in most cases the two attributes are not exposed to user,
  30672. // except in treemap.
  30673. style.textAlign = labelTextStyleModel.get('align');
  30674. style.textVerticalAlign = labelTextStyleModel.get('baseline');
  30675. var textRect = labelTextStyleModel.getTextRect(text);
  30676. if (!labelModel.getShallow('show') || textRect.height > contentHeight) {
  30677. style.text = '';
  30678. }
  30679. else if (textRect.width > contentWidth) {
  30680. style.text = labelTextStyleModel.get('ellipsis')
  30681. ? labelTextStyleModel.truncateText(
  30682. text, contentWidth, null, {minChar: 2}
  30683. )
  30684. : '';
  30685. }
  30686. else {
  30687. style.text = text;
  30688. }
  30689. }
  30690. function giveGraphic(storageName, Ctor, depth, z) {
  30691. var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
  30692. var lasts = lastsForAnimation[storageName];
  30693. if (element) {
  30694. // Remove from oldStorage
  30695. oldStorage[storageName][oldRawIndex] = null;
  30696. prepareAnimationWhenHasOld(lasts, element, storageName);
  30697. }
  30698. // If invisible and no old element, do not create new element (for optimizing).
  30699. else if (!thisInvisible) {
  30700. element = new Ctor({z: calculateZ(depth, z)});
  30701. element.__tmDepth = depth;
  30702. element.__tmStorageName = storageName;
  30703. prepareAnimationWhenNoOld(lasts, element, storageName);
  30704. }
  30705. // Set to thisStorage
  30706. return (thisStorage[storageName][thisRawIndex] = element);
  30707. }
  30708. function prepareAnimationWhenHasOld(lasts, element, storageName) {
  30709. var lastCfg = lasts[thisRawIndex] = {};
  30710. lastCfg.old = storageName === 'nodeGroup'
  30711. ? element.position.slice()
  30712. : zrUtil.extend({}, element.shape);
  30713. }
  30714. // If a element is new, we need to find the animation start point carefully,
  30715. // otherwise it will looks strange when 'zoomToNode'.
  30716. function prepareAnimationWhenNoOld(lasts, element, storageName) {
  30717. var lastCfg = lasts[thisRawIndex] = {};
  30718. var parentNode = thisNode.parentNode;
  30719. if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
  30720. var parentOldX = 0;
  30721. var parentOldY = 0;
  30722. // New nodes appear from right-bottom corner in 'zoomToNode' animation.
  30723. // For convenience, get old bounding rect from background.
  30724. var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
  30725. if (!reRoot && parentOldBg && parentOldBg.old) {
  30726. parentOldX = parentOldBg.old.width;
  30727. parentOldY = parentOldBg.old.height;
  30728. }
  30729. // When no parent old shape found, its parent is new too,
  30730. // so we can just use {x:0, y:0}.
  30731. lastCfg.old = storageName === 'nodeGroup'
  30732. ? [0, parentOldY]
  30733. : {x: parentOldX, y: parentOldY, width: 0, height: 0};
  30734. }
  30735. // Fade in, user can be aware that these nodes are new.
  30736. lastCfg.fadein = storageName !== 'nodeGroup';
  30737. }
  30738. }
  30739. // We can not set all backgroud with the same z, Because the behaviour of
  30740. // drill down and roll up differ background creation sequence from tree
  30741. // hierarchy sequence, which cause that lowser background element overlap
  30742. // upper ones. So we calculate z based on depth.
  30743. // Moreover, we try to shrink down z interval to [0, 1] to avoid that
  30744. // treemap with large z overlaps other components.
  30745. function calculateZ(depth, zInLevel) {
  30746. var zb = depth * Z_BASE + zInLevel;
  30747. return (zb - 1) / zb;
  30748. }
  30749. /***/ },
  30750. /* 190 */
  30751. /***/ function(module, exports, __webpack_require__) {
  30752. var graphic = __webpack_require__(43);
  30753. var layout = __webpack_require__(21);
  30754. var zrUtil = __webpack_require__(4);
  30755. var helper = __webpack_require__(188);
  30756. var TEXT_PADDING = 8;
  30757. var ITEM_GAP = 8;
  30758. var ARRAY_LENGTH = 5;
  30759. function Breadcrumb(containerGroup) {
  30760. /**
  30761. * @private
  30762. * @type {module:zrender/container/Group}
  30763. */
  30764. this.group = new graphic.Group();
  30765. containerGroup.add(this.group);
  30766. }
  30767. Breadcrumb.prototype = {
  30768. constructor: Breadcrumb,
  30769. render: function (seriesModel, api, targetNode, onSelect) {
  30770. var model = seriesModel.getModel('breadcrumb');
  30771. var thisGroup = this.group;
  30772. thisGroup.removeAll();
  30773. if (!model.get('show') || !targetNode) {
  30774. return;
  30775. }
  30776. var normalStyleModel = model.getModel('itemStyle.normal');
  30777. // var emphasisStyleModel = model.getModel('itemStyle.emphasis');
  30778. var textStyleModel = normalStyleModel.getModel('textStyle');
  30779. var layoutParam = {
  30780. pos: {
  30781. left: model.get('left'),
  30782. right: model.get('right'),
  30783. top: model.get('top'),
  30784. bottom: model.get('bottom')
  30785. },
  30786. box: {
  30787. width: api.getWidth(),
  30788. height: api.getHeight()
  30789. },
  30790. emptyItemWidth: model.get('emptyItemWidth'),
  30791. totalWidth: 0,
  30792. renderList: []
  30793. };
  30794. this._prepare(targetNode, layoutParam, textStyleModel);
  30795. this._renderContent(seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect);
  30796. layout.positionElement(thisGroup, layoutParam.pos, layoutParam.box);
  30797. },
  30798. /**
  30799. * Prepare render list and total width
  30800. * @private
  30801. */
  30802. _prepare: function (targetNode, layoutParam, textStyleModel) {
  30803. for (var node = targetNode; node; node = node.parentNode) {
  30804. var text = node.getModel().get('name');
  30805. var textRect = textStyleModel.getTextRect(text);
  30806. var itemWidth = Math.max(
  30807. textRect.width + TEXT_PADDING * 2,
  30808. layoutParam.emptyItemWidth
  30809. );
  30810. layoutParam.totalWidth += itemWidth + ITEM_GAP;
  30811. layoutParam.renderList.push({node: node, text: text, width: itemWidth});
  30812. }
  30813. },
  30814. /**
  30815. * @private
  30816. */
  30817. _renderContent: function (
  30818. seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect
  30819. ) {
  30820. // Start rendering.
  30821. var lastX = 0;
  30822. var emptyItemWidth = layoutParam.emptyItemWidth;
  30823. var height = seriesModel.get('breadcrumb.height');
  30824. var availableSize = layout.getAvailableSize(layoutParam.pos, layoutParam.box);
  30825. var totalWidth = layoutParam.totalWidth;
  30826. var renderList = layoutParam.renderList;
  30827. for (var i = renderList.length - 1; i >= 0; i--) {
  30828. var item = renderList[i];
  30829. var itemNode = item.node;
  30830. var itemWidth = item.width;
  30831. var text = item.text;
  30832. // Hdie text and shorten width if necessary.
  30833. if (totalWidth > availableSize.width) {
  30834. totalWidth -= itemWidth - emptyItemWidth;
  30835. itemWidth = emptyItemWidth;
  30836. text = '';
  30837. }
  30838. var el = new graphic.Polygon({
  30839. shape: {
  30840. points: makeItemPoints(
  30841. lastX, 0, itemWidth, height,
  30842. i === renderList.length - 1, i === 0
  30843. )
  30844. },
  30845. style: zrUtil.defaults(
  30846. normalStyleModel.getItemStyle(),
  30847. {
  30848. lineJoin: 'bevel',
  30849. text: text,
  30850. textFill: textStyleModel.getTextColor(),
  30851. textFont: textStyleModel.getFont()
  30852. }
  30853. ),
  30854. z: 10,
  30855. onclick: zrUtil.curry(onSelect, itemNode)
  30856. });
  30857. this.group.add(el);
  30858. packEventData(el, seriesModel, itemNode);
  30859. lastX += itemWidth + ITEM_GAP;
  30860. }
  30861. },
  30862. /**
  30863. * @override
  30864. */
  30865. remove: function () {
  30866. this.group.removeAll();
  30867. }
  30868. };
  30869. function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) {
  30870. var points = [
  30871. [head ? x : x - ARRAY_LENGTH, y],
  30872. [x + itemWidth, y],
  30873. [x + itemWidth, y + itemHeight],
  30874. [head ? x : x - ARRAY_LENGTH, y + itemHeight]
  30875. ];
  30876. !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]);
  30877. !head && points.push([x, y + itemHeight / 2]);
  30878. return points;
  30879. }
  30880. // Package custom mouse event.
  30881. function packEventData(el, seriesModel, itemNode) {
  30882. el.eventData = {
  30883. componentType: 'series',
  30884. componentSubType: 'treemap',
  30885. seriesIndex: seriesModel.componentIndex,
  30886. seriesName: seriesModel.name,
  30887. seriesType: 'treemap',
  30888. selfType: 'breadcrumb', // Distinguish with click event on treemap node.
  30889. nodeData: {
  30890. dataIndex: itemNode && itemNode.dataIndex,
  30891. name: itemNode && itemNode.name
  30892. },
  30893. treePathInfo: itemNode && helper.wrapTreePathInfo(itemNode, seriesModel)
  30894. };
  30895. }
  30896. module.exports = Breadcrumb;
  30897. /***/ },
  30898. /* 191 */
  30899. /***/ function(module, exports, __webpack_require__) {
  30900. var zrUtil = __webpack_require__(4);
  30901. /**
  30902. * @param {number} [time=500] Time in ms
  30903. * @param {string} [easing='linear']
  30904. * @param {number} [delay=0]
  30905. * @param {Function} [callback]
  30906. *
  30907. * @example
  30908. * // Animate position
  30909. * animation
  30910. * .createWrap()
  30911. * .add(el1, {position: [10, 10]})
  30912. * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400)
  30913. * .done(function () { // done })
  30914. * .start('cubicOut');
  30915. */
  30916. function createWrap() {
  30917. var storage = [];
  30918. var elExistsMap = {};
  30919. var doneCallback;
  30920. return {
  30921. /**
  30922. * Caution: a el can only be added once, otherwise 'done'
  30923. * might not be called. This method checks this (by el.id),
  30924. * suppresses adding and returns false when existing el found.
  30925. *
  30926. * @param {modele:zrender/Element} el
  30927. * @param {Object} target
  30928. * @param {number} [time=500]
  30929. * @param {number} [delay=0]
  30930. * @param {string} [easing='linear']
  30931. * @return {boolean} Whether adding succeeded.
  30932. *
  30933. * @example
  30934. * add(el, target, time, delay, easing);
  30935. * add(el, target, time, easing);
  30936. * add(el, target, time);
  30937. * add(el, target);
  30938. */
  30939. add: function (el, target, time, delay, easing) {
  30940. if (zrUtil.isString(delay)) {
  30941. easing = delay;
  30942. delay = 0;
  30943. }
  30944. if (elExistsMap[el.id]) {
  30945. return false;
  30946. }
  30947. elExistsMap[el.id] = 1;
  30948. storage.push(
  30949. {el: el, target: target, time: time, delay: delay, easing: easing}
  30950. );
  30951. return true;
  30952. },
  30953. /**
  30954. * Only execute when animation finished. Will not execute when any
  30955. * of 'stop' or 'stopAnimation' called.
  30956. *
  30957. * @param {Function} callback
  30958. */
  30959. done: function (callback) {
  30960. doneCallback = callback;
  30961. return this;
  30962. },
  30963. /**
  30964. * Will stop exist animation firstly.
  30965. */
  30966. start: function () {
  30967. var count = storage.length;
  30968. for (var i = 0, len = storage.length; i < len; i++) {
  30969. var item = storage[i];
  30970. item.el.animateTo(item.target, item.time, item.delay, item.easing, done);
  30971. }
  30972. return this;
  30973. function done() {
  30974. count--;
  30975. if (!count) {
  30976. storage.length = 0;
  30977. elExistsMap = {};
  30978. doneCallback && doneCallback();
  30979. }
  30980. }
  30981. }
  30982. };
  30983. }
  30984. module.exports = {createWrap: createWrap};
  30985. /***/ },
  30986. /* 192 */
  30987. /***/ function(module, exports, __webpack_require__) {
  30988. /**
  30989. * @file Treemap action
  30990. */
  30991. var echarts = __webpack_require__(1);
  30992. var helper = __webpack_require__(188);
  30993. var noop = function () {};
  30994. var actionTypes = [
  30995. 'treemapZoomToNode',
  30996. 'treemapRender',
  30997. 'treemapMove'
  30998. ];
  30999. for (var i = 0; i < actionTypes.length; i++) {
  31000. echarts.registerAction({type: actionTypes[i], update: 'updateView'}, noop);
  31001. }
  31002. echarts.registerAction(
  31003. {type: 'treemapRootToNode', update: 'updateView'},
  31004. function (payload, ecModel) {
  31005. ecModel.eachComponent(
  31006. {mainType: 'series', subType: 'treemap', query: payload},
  31007. handleRootToNode
  31008. );
  31009. function handleRootToNode(model, index) {
  31010. var targetInfo = helper.retrieveTargetInfo(payload, model);
  31011. if (targetInfo) {
  31012. var originViewRoot = model.getViewRoot();
  31013. if (originViewRoot) {
  31014. payload.direction = helper.aboveViewRoot(originViewRoot, targetInfo.node)
  31015. ? 'rollUp' : 'drillDown';
  31016. }
  31017. model.resetViewRoot(targetInfo.node);
  31018. }
  31019. }
  31020. }
  31021. );
  31022. /***/ },
  31023. /* 193 */
  31024. /***/ function(module, exports, __webpack_require__) {
  31025. var VisualMapping = __webpack_require__(194);
  31026. var zrColor = __webpack_require__(39);
  31027. var zrUtil = __webpack_require__(4);
  31028. var isArray = zrUtil.isArray;
  31029. var ITEM_STYLE_NORMAL = 'itemStyle.normal';
  31030. module.exports = function (ecModel, api, payload) {
  31031. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  31032. ecModel.eachComponent(condition, function (seriesModel) {
  31033. var tree = seriesModel.getData().tree;
  31034. var root = tree.root;
  31035. var seriesItemStyleModel = seriesModel.getModel(ITEM_STYLE_NORMAL);
  31036. if (root.isRemoved()) {
  31037. return;
  31038. }
  31039. var levelItemStyles = zrUtil.map(tree.levelModels, function (levelModel) {
  31040. return levelModel ? levelModel.get(ITEM_STYLE_NORMAL) : null;
  31041. });
  31042. travelTree(
  31043. root, // Visual should calculate from tree root but not view root.
  31044. {},
  31045. levelItemStyles,
  31046. seriesItemStyleModel,
  31047. seriesModel.getViewRoot().getAncestors(),
  31048. seriesModel
  31049. );
  31050. });
  31051. };
  31052. function travelTree(
  31053. node, designatedVisual, levelItemStyles, seriesItemStyleModel,
  31054. viewRootAncestors, seriesModel
  31055. ) {
  31056. var nodeModel = node.getModel();
  31057. var nodeLayout = node.getLayout();
  31058. // Optimize
  31059. if (!nodeLayout || nodeLayout.invisible || !nodeLayout.isInView) {
  31060. return;
  31061. }
  31062. var nodeItemStyleModel = node.getModel(ITEM_STYLE_NORMAL);
  31063. var levelItemStyle = levelItemStyles[node.depth];
  31064. var visuals = buildVisuals(
  31065. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  31066. );
  31067. // calculate border color
  31068. var borderColor = nodeItemStyleModel.get('borderColor');
  31069. var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation');
  31070. var thisNodeColor;
  31071. if (borderColorSaturation != null) {
  31072. // For performance, do not always execute 'calculateColor'.
  31073. thisNodeColor = calculateColor(visuals, node);
  31074. borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor);
  31075. }
  31076. node.setVisual('borderColor', borderColor);
  31077. var viewChildren = node.viewChildren;
  31078. if (!viewChildren || !viewChildren.length) {
  31079. thisNodeColor = calculateColor(visuals, node);
  31080. // Apply visual to this node.
  31081. node.setVisual('color', thisNodeColor);
  31082. }
  31083. else {
  31084. var mapping = buildVisualMapping(
  31085. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  31086. );
  31087. // Designate visual to children.
  31088. zrUtil.each(viewChildren, function (child, index) {
  31089. // If higher than viewRoot, only ancestors of viewRoot is needed to visit.
  31090. if (child.depth >= viewRootAncestors.length
  31091. || child === viewRootAncestors[child.depth]
  31092. ) {
  31093. var childVisual = mapVisual(
  31094. nodeModel, visuals, child, index, mapping, seriesModel
  31095. );
  31096. travelTree(
  31097. child, childVisual, levelItemStyles, seriesItemStyleModel,
  31098. viewRootAncestors, seriesModel
  31099. );
  31100. }
  31101. });
  31102. }
  31103. }
  31104. function buildVisuals(
  31105. nodeItemStyleModel, designatedVisual, levelItemStyle, seriesItemStyleModel
  31106. ) {
  31107. var visuals = zrUtil.extend({}, designatedVisual);
  31108. zrUtil.each(['color', 'colorAlpha', 'colorSaturation'], function (visualName) {
  31109. // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel
  31110. var val = nodeItemStyleModel.get(visualName, true); // Ignore parent
  31111. val == null && levelItemStyle && (val = levelItemStyle[visualName]);
  31112. val == null && (val = designatedVisual[visualName]);
  31113. val == null && (val = seriesItemStyleModel.get(visualName));
  31114. val != null && (visuals[visualName] = val);
  31115. });
  31116. return visuals;
  31117. }
  31118. function calculateColor(visuals) {
  31119. var color = getValueVisualDefine(visuals, 'color');
  31120. if (color) {
  31121. var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha');
  31122. var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation');
  31123. if (colorSaturation) {
  31124. color = zrColor.modifyHSL(color, null, null, colorSaturation);
  31125. }
  31126. if (colorAlpha) {
  31127. color = zrColor.modifyAlpha(color, colorAlpha);
  31128. }
  31129. return color;
  31130. }
  31131. }
  31132. function calculateBorderColor(borderColorSaturation, thisNodeColor) {
  31133. return thisNodeColor != null
  31134. ? zrColor.modifyHSL(thisNodeColor, null, null, borderColorSaturation)
  31135. : null;
  31136. }
  31137. function getValueVisualDefine(visuals, name) {
  31138. var value = visuals[name];
  31139. if (value != null && value !== 'none') {
  31140. return value;
  31141. }
  31142. }
  31143. function buildVisualMapping(
  31144. node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren
  31145. ) {
  31146. if (!viewChildren || !viewChildren.length) {
  31147. return;
  31148. }
  31149. var rangeVisual = getRangeVisual(nodeModel, 'color')
  31150. || (
  31151. visuals.color != null
  31152. && visuals.color !== 'none'
  31153. && (
  31154. getRangeVisual(nodeModel, 'colorAlpha')
  31155. || getRangeVisual(nodeModel, 'colorSaturation')
  31156. )
  31157. );
  31158. if (!rangeVisual) {
  31159. return;
  31160. }
  31161. var visualMin = nodeModel.get('visualMin');
  31162. var visualMax = nodeModel.get('visualMax');
  31163. var dataExtent = nodeLayout.dataExtent.slice();
  31164. visualMin != null && visualMin < dataExtent[0] && (dataExtent[0] = visualMin);
  31165. visualMax != null && visualMax > dataExtent[1] && (dataExtent[1] = visualMax);
  31166. var colorMappingBy = nodeModel.get('colorMappingBy');
  31167. var opt = {
  31168. type: rangeVisual.name,
  31169. dataExtent: dataExtent,
  31170. visual: rangeVisual.range
  31171. };
  31172. if (opt.type === 'color'
  31173. && (colorMappingBy === 'index' || colorMappingBy === 'id')
  31174. ) {
  31175. opt.mappingMethod = 'category';
  31176. opt.loop = true;
  31177. // categories is ordinal, so do not set opt.categories.
  31178. }
  31179. else {
  31180. opt.mappingMethod = 'linear';
  31181. }
  31182. var mapping = new VisualMapping(opt);
  31183. mapping.__drColorMappingBy = colorMappingBy;
  31184. return mapping;
  31185. }
  31186. // Notice: If we dont have the attribute 'colorRange', but only use
  31187. // attribute 'color' to represent both concepts of 'colorRange' and 'color',
  31188. // (It means 'colorRange' when 'color' is Array, means 'color' when not array),
  31189. // this problem will be encountered:
  31190. // If a level-1 node dont have children, and its siblings has children,
  31191. // and colorRange is set on level-1, then the node can not be colored.
  31192. // So we separate 'colorRange' and 'color' to different attributes.
  31193. function getRangeVisual(nodeModel, name) {
  31194. // 'colorRange', 'colorARange', 'colorSRange'.
  31195. // If not exsits on this node, fetch from levels and series.
  31196. var range = nodeModel.get(name);
  31197. return (isArray(range) && range.length) ? {name: name, range: range} : null;
  31198. }
  31199. function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) {
  31200. var childVisuals = zrUtil.extend({}, visuals);
  31201. if (mapping) {
  31202. var mappingType = mapping.type;
  31203. var colorMappingBy = mappingType === 'color' && mapping.__drColorMappingBy;
  31204. var value =
  31205. colorMappingBy === 'index'
  31206. ? index
  31207. : colorMappingBy === 'id'
  31208. ? seriesModel.mapIdToIndex(child.getId())
  31209. : child.getValue(nodeModel.get('visualDimension'));
  31210. childVisuals[mappingType] = mapping.mapValueToVisual(value);
  31211. }
  31212. return childVisuals;
  31213. }
  31214. /***/ },
  31215. /* 194 */
  31216. /***/ function(module, exports, __webpack_require__) {
  31217. /**
  31218. * @file Visual mapping.
  31219. */
  31220. var zrUtil = __webpack_require__(4);
  31221. var zrColor = __webpack_require__(39);
  31222. var linearMap = __webpack_require__(7).linearMap;
  31223. var each = zrUtil.each;
  31224. var isObject = zrUtil.isObject;
  31225. var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
  31226. /**
  31227. * @param {Object} option
  31228. * @param {string} [option.type] See visualHandlers.
  31229. * @param {string} [option.mappingMethod] 'linear' or 'piecewise' or 'category' or 'fixed'
  31230. * @param {Array.<number>=} [option.dataExtent] [minExtent, maxExtent],
  31231. * required when mappingMethod is 'linear'
  31232. * @param {Array.<Object>=} [option.pieceList] [
  31233. * {value: someValue},
  31234. * {interval: [min1, max1], visual: {...}},
  31235. * {interval: [min2, max2]}
  31236. * ],
  31237. * required when mappingMethod is 'piecewise'.
  31238. * Visual for only each piece can be specified.
  31239. * @param {Array.<string|Object>=} [option.categories] ['cate1', 'cate2']
  31240. * required when mappingMethod is 'category'.
  31241. * If no option.categories, categories is set
  31242. * as [0, 1, 2, ...].
  31243. * @param {boolean} [option.loop=false] Whether loop mapping when mappingMethod is 'category'.
  31244. * @param {(Array|Object|*)} [option.visual] Visual data.
  31245. * when mappingMethod is 'category',
  31246. * visual data can be array or object
  31247. * (like: {cate1: '#222', none: '#fff'})
  31248. * or primary types (which represents
  31249. * defualt category visual), otherwise visual
  31250. * can be array or primary (which will be
  31251. * normalized to array).
  31252. *
  31253. */
  31254. var VisualMapping = function (option) {
  31255. var mappingMethod = option.mappingMethod;
  31256. var visualType = option.type;
  31257. /**
  31258. * @readOnly
  31259. * @type {Object}
  31260. */
  31261. var thisOption = this.option = zrUtil.clone(option);
  31262. /**
  31263. * @readOnly
  31264. * @type {string}
  31265. */
  31266. this.type = visualType;
  31267. /**
  31268. * @readOnly
  31269. * @type {string}
  31270. */
  31271. this.mappingMethod = mappingMethod;
  31272. /**
  31273. * @private
  31274. * @type {Function}
  31275. */
  31276. this._normalizeData = normalizers[mappingMethod];
  31277. var visualHandler = visualHandlers[visualType];
  31278. /**
  31279. * @public
  31280. * @type {Function}
  31281. */
  31282. this.applyVisual = visualHandler.applyVisual;
  31283. /**
  31284. * @public
  31285. * @type {Function}
  31286. */
  31287. this.getColorMapper = visualHandler.getColorMapper;
  31288. /**
  31289. * @private
  31290. * @type {Function}
  31291. */
  31292. this._doMap = visualHandler._doMap[mappingMethod];
  31293. if (mappingMethod === 'piecewise') {
  31294. normalizeVisualRange(thisOption);
  31295. preprocessForPiecewise(thisOption);
  31296. }
  31297. else if (mappingMethod === 'category') {
  31298. thisOption.categories
  31299. ? preprocessForSpecifiedCategory(thisOption)
  31300. // categories is ordinal when thisOption.categories not specified,
  31301. // which need no more preprocess except normalize visual.
  31302. : normalizeVisualRange(thisOption, true);
  31303. }
  31304. else { // mappingMethod === 'linear' or 'fixed'
  31305. zrUtil.assert(mappingMethod !== 'linear' || thisOption.dataExtent);
  31306. normalizeVisualRange(thisOption);
  31307. }
  31308. };
  31309. VisualMapping.prototype = {
  31310. constructor: VisualMapping,
  31311. mapValueToVisual: function (value) {
  31312. var normalized = this._normalizeData(value);
  31313. return this._doMap(normalized, value);
  31314. },
  31315. getNormalizer: function () {
  31316. return zrUtil.bind(this._normalizeData, this);
  31317. }
  31318. };
  31319. var visualHandlers = VisualMapping.visualHandlers = {
  31320. color: {
  31321. applyVisual: makeApplyVisual('color'),
  31322. /**
  31323. * Create a mapper function
  31324. * @return {Function}
  31325. */
  31326. getColorMapper: function () {
  31327. var thisOption = this.option;
  31328. var parsedVisual = zrUtil.map(thisOption.visual, zrColor.parse);
  31329. return zrUtil.bind(
  31330. thisOption.mappingMethod === 'category'
  31331. ? function (value, isNormalized) {
  31332. !isNormalized && (value = this._normalizeData(value));
  31333. return doMapCategory.call(this, value);
  31334. }
  31335. : function (value, isNormalized, out) {
  31336. // If output rgb array
  31337. // which will be much faster and useful in pixel manipulation
  31338. var returnRGBArray = !!out;
  31339. !isNormalized && (value = this._normalizeData(value));
  31340. out = zrColor.fastMapToColor(value, parsedVisual, out);
  31341. return returnRGBArray ? out : zrUtil.stringify(out, 'rgba');
  31342. },
  31343. this
  31344. );
  31345. },
  31346. _doMap: {
  31347. linear: function (normalized) {
  31348. return zrColor.mapToColor(normalized, this.option.visual);
  31349. },
  31350. category: doMapCategory,
  31351. piecewise: function (normalized, value) {
  31352. var result = getSpecifiedVisual.call(this, value);
  31353. if (result == null) {
  31354. result = zrColor.mapToColor(normalized, this.option.visual);
  31355. }
  31356. return result;
  31357. },
  31358. fixed: doMapFixed
  31359. }
  31360. },
  31361. colorHue: makePartialColorVisualHandler(function (color, value) {
  31362. return zrColor.modifyHSL(color, value);
  31363. }),
  31364. colorSaturation: makePartialColorVisualHandler(function (color, value) {
  31365. return zrColor.modifyHSL(color, null, value);
  31366. }),
  31367. colorLightness: makePartialColorVisualHandler(function (color, value) {
  31368. return zrColor.modifyHSL(color, null, null, value);
  31369. }),
  31370. colorAlpha: makePartialColorVisualHandler(function (color, value) {
  31371. return zrColor.modifyAlpha(color, value);
  31372. }),
  31373. opacity: {
  31374. applyVisual: makeApplyVisual('opacity'),
  31375. _doMap: makeDoMap([0, 1])
  31376. },
  31377. symbol: {
  31378. applyVisual: function (value, getter, setter) {
  31379. var symbolCfg = this.mapValueToVisual(value);
  31380. if (zrUtil.isString(symbolCfg)) {
  31381. setter('symbol', symbolCfg);
  31382. }
  31383. else if (isObject(symbolCfg)) {
  31384. for (var name in symbolCfg) {
  31385. if (symbolCfg.hasOwnProperty(name)) {
  31386. setter(name, symbolCfg[name]);
  31387. }
  31388. }
  31389. }
  31390. },
  31391. _doMap: {
  31392. linear: doMapToArray,
  31393. category: doMapCategory,
  31394. piecewise: function (normalized, value) {
  31395. var result = getSpecifiedVisual.call(this, value);
  31396. if (result == null) {
  31397. result = doMapToArray.call(this, normalized);
  31398. }
  31399. return result;
  31400. },
  31401. fixed: doMapFixed
  31402. }
  31403. },
  31404. symbolSize: {
  31405. applyVisual: makeApplyVisual('symbolSize'),
  31406. _doMap: makeDoMap([0, 1])
  31407. }
  31408. };
  31409. function preprocessForPiecewise(thisOption) {
  31410. var pieceList = thisOption.pieceList;
  31411. thisOption.hasSpecialVisual = false;
  31412. zrUtil.each(pieceList, function (piece, index) {
  31413. piece.originIndex = index;
  31414. // piece.visual is "result visual value" but not
  31415. // a visual range, so it does not need to be normalized.
  31416. if (piece.visual != null) {
  31417. thisOption.hasSpecialVisual = true;
  31418. }
  31419. });
  31420. }
  31421. function preprocessForSpecifiedCategory(thisOption) {
  31422. // Hash categories.
  31423. var categories = thisOption.categories;
  31424. var visual = thisOption.visual;
  31425. var categoryMap = thisOption.categoryMap = {};
  31426. each(categories, function (cate, index) {
  31427. categoryMap[cate] = index;
  31428. });
  31429. // Process visual map input.
  31430. if (!zrUtil.isArray(visual)) {
  31431. var visualArr = [];
  31432. if (zrUtil.isObject(visual)) {
  31433. each(visual, function (v, cate) {
  31434. var index = categoryMap[cate];
  31435. visualArr[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v;
  31436. });
  31437. }
  31438. else { // Is primary type, represents default visual.
  31439. visualArr[CATEGORY_DEFAULT_VISUAL_INDEX] = visual;
  31440. }
  31441. visual = thisOption.visual = visualArr;
  31442. }
  31443. // Remove categories that has no visual,
  31444. // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX.
  31445. for (var i = categories.length - 1; i >= 0; i--) {
  31446. if (visual[i] == null) {
  31447. delete categoryMap[categories[i]];
  31448. categories.pop();
  31449. }
  31450. }
  31451. }
  31452. function normalizeVisualRange(thisOption, isCategory) {
  31453. var visual = thisOption.visual;
  31454. var visualArr = [];
  31455. if (zrUtil.isObject(visual)) {
  31456. each(visual, function (v) {
  31457. visualArr.push(v);
  31458. });
  31459. }
  31460. else if (visual != null) {
  31461. visualArr.push(visual);
  31462. }
  31463. var doNotNeedPair = {color: 1, symbol: 1};
  31464. if (!isCategory
  31465. && visualArr.length === 1
  31466. && !doNotNeedPair.hasOwnProperty(thisOption.type)
  31467. ) {
  31468. // Do not care visualArr.length === 0, which is illegal.
  31469. visualArr[1] = visualArr[0];
  31470. }
  31471. thisOption.visual = visualArr;
  31472. }
  31473. function makePartialColorVisualHandler(applyValue) {
  31474. return {
  31475. applyVisual: function (value, getter, setter) {
  31476. value = this.mapValueToVisual(value);
  31477. // Must not be array value
  31478. setter('color', applyValue(getter('color'), value));
  31479. },
  31480. _doMap: makeDoMap([0, 1])
  31481. };
  31482. }
  31483. function doMapToArray(normalized) {
  31484. var visual = this.option.visual;
  31485. return visual[
  31486. Math.round(linearMap(normalized, [0, 1], [0, visual.length - 1], true))
  31487. ] || {};
  31488. }
  31489. function makeApplyVisual(visualType) {
  31490. return function (value, getter, setter) {
  31491. setter(visualType, this.mapValueToVisual(value));
  31492. };
  31493. }
  31494. function doMapCategory(normalized) {
  31495. var visual = this.option.visual;
  31496. return visual[
  31497. (this.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX)
  31498. ? normalized % visual.length
  31499. : normalized
  31500. ];
  31501. }
  31502. function doMapFixed() {
  31503. return this.option.visual[0];
  31504. }
  31505. function makeDoMap(sourceExtent) {
  31506. return {
  31507. linear: function (normalized) {
  31508. return linearMap(normalized, sourceExtent, this.option.visual, true);
  31509. },
  31510. category: doMapCategory,
  31511. piecewise: function (normalized, value) {
  31512. var result = getSpecifiedVisual.call(this, value);
  31513. if (result == null) {
  31514. result = linearMap(normalized, sourceExtent, this.option.visual, true);
  31515. }
  31516. return result;
  31517. },
  31518. fixed: doMapFixed
  31519. };
  31520. }
  31521. function getSpecifiedVisual(value) {
  31522. var thisOption = this.option;
  31523. var pieceList = thisOption.pieceList;
  31524. if (thisOption.hasSpecialVisual) {
  31525. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList);
  31526. var piece = pieceList[pieceIndex];
  31527. if (piece && piece.visual) {
  31528. return piece.visual[this.type];
  31529. }
  31530. }
  31531. }
  31532. /**
  31533. * Normalizers by mapping methods.
  31534. */
  31535. var normalizers = {
  31536. linear: function (value) {
  31537. return linearMap(value, this.option.dataExtent, [0, 1], true);
  31538. },
  31539. piecewise: function (value) {
  31540. var pieceList = this.option.pieceList;
  31541. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList, true);
  31542. if (pieceIndex != null) {
  31543. return linearMap(pieceIndex, [0, pieceList.length - 1], [0, 1], true);
  31544. }
  31545. },
  31546. category: function (value) {
  31547. var index = this.option.categories
  31548. ? this.option.categoryMap[value]
  31549. : value; // ordinal
  31550. return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index;
  31551. },
  31552. fixed: zrUtil.noop
  31553. };
  31554. /**
  31555. * List available visual types.
  31556. *
  31557. * @public
  31558. * @return {Array.<string>}
  31559. */
  31560. VisualMapping.listVisualTypes = function () {
  31561. var visualTypes = [];
  31562. zrUtil.each(visualHandlers, function (handler, key) {
  31563. visualTypes.push(key);
  31564. });
  31565. return visualTypes;
  31566. };
  31567. /**
  31568. * @public
  31569. */
  31570. VisualMapping.addVisualHandler = function (name, handler) {
  31571. visualHandlers[name] = handler;
  31572. };
  31573. /**
  31574. * @public
  31575. */
  31576. VisualMapping.isValidType = function (visualType) {
  31577. return visualHandlers.hasOwnProperty(visualType);
  31578. };
  31579. /**
  31580. * Convinent method.
  31581. * Visual can be Object or Array or primary type.
  31582. *
  31583. * @public
  31584. */
  31585. VisualMapping.eachVisual = function (visual, callback, context) {
  31586. if (zrUtil.isObject(visual)) {
  31587. zrUtil.each(visual, callback, context);
  31588. }
  31589. else {
  31590. callback.call(context, visual);
  31591. }
  31592. };
  31593. VisualMapping.mapVisual = function (visual, callback, context) {
  31594. var isPrimary;
  31595. var newVisual = zrUtil.isArray(visual)
  31596. ? []
  31597. : zrUtil.isObject(visual)
  31598. ? {}
  31599. : (isPrimary = true, null);
  31600. VisualMapping.eachVisual(visual, function (v, key) {
  31601. var newVal = callback.call(context, v, key);
  31602. isPrimary ? (newVisual = newVal) : (newVisual[key] = newVal);
  31603. });
  31604. return newVisual;
  31605. };
  31606. /**
  31607. * @public
  31608. * @param {Object} obj
  31609. * @return {Oject} new object containers visual values.
  31610. * If no visuals, return null.
  31611. */
  31612. VisualMapping.retrieveVisuals = function (obj) {
  31613. var ret = {};
  31614. var hasVisual;
  31615. obj && each(visualHandlers, function (h, visualType) {
  31616. if (obj.hasOwnProperty(visualType)) {
  31617. ret[visualType] = obj[visualType];
  31618. hasVisual = true;
  31619. }
  31620. });
  31621. return hasVisual ? ret : null;
  31622. };
  31623. /**
  31624. * Give order to visual types, considering colorSaturation, colorAlpha depends on color.
  31625. *
  31626. * @public
  31627. * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...}
  31628. * IF Array, like: ['color', 'symbol', 'colorSaturation']
  31629. * @return {Array.<string>} Sorted visual types.
  31630. */
  31631. VisualMapping.prepareVisualTypes = function (visualTypes) {
  31632. if (isObject(visualTypes)) {
  31633. var types = [];
  31634. each(visualTypes, function (item, type) {
  31635. types.push(type);
  31636. });
  31637. visualTypes = types;
  31638. }
  31639. else if (zrUtil.isArray(visualTypes)) {
  31640. visualTypes = visualTypes.slice();
  31641. }
  31642. else {
  31643. return [];
  31644. }
  31645. visualTypes.sort(function (type1, type2) {
  31646. // color should be front of colorSaturation, colorAlpha, ...
  31647. // symbol and symbolSize do not matter.
  31648. return (type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0)
  31649. ? 1 : -1;
  31650. });
  31651. return visualTypes;
  31652. };
  31653. /**
  31654. * 'color', 'colorSaturation', 'colorAlpha', ... are depends on 'color'.
  31655. * Other visuals are only depends on themself.
  31656. *
  31657. * @public
  31658. * @param {string} visualType1
  31659. * @param {string} visualType2
  31660. * @return {boolean}
  31661. */
  31662. VisualMapping.dependsOn = function (visualType1, visualType2) {
  31663. return visualType2 === 'color'
  31664. ? !!(visualType1 && visualType1.indexOf(visualType2) === 0)
  31665. : visualType1 === visualType2;
  31666. };
  31667. /**
  31668. * @param {number} value
  31669. * @param {Array.<Object>} pieceList [{value: ..., interval: [min, max]}, ...]
  31670. * Always from small to big.
  31671. * @param {boolean} [findClosestWhenOutside=false]
  31672. * @return {number} index
  31673. */
  31674. VisualMapping.findPieceIndex = function (value, pieceList, findClosestWhenOutside) {
  31675. var possibleI;
  31676. var abs = Infinity;
  31677. // value has the higher priority.
  31678. for (var i = 0, len = pieceList.length; i < len; i++) {
  31679. var pieceValue = pieceList[i].value;
  31680. if (pieceValue != null) {
  31681. if (pieceValue === value) {
  31682. return i;
  31683. }
  31684. findClosestWhenOutside && updatePossible(pieceValue, i);
  31685. }
  31686. }
  31687. for (var i = 0, len = pieceList.length; i < len; i++) {
  31688. var piece = pieceList[i];
  31689. var interval = piece.interval;
  31690. var close = piece.close;
  31691. if (interval) {
  31692. if (interval[0] === -Infinity) {
  31693. if (littleThan(close[1], value, interval[1])) {
  31694. return i;
  31695. }
  31696. }
  31697. else if (interval[1] === Infinity) {
  31698. if (littleThan(close[0], interval[0], value)) {
  31699. return i;
  31700. }
  31701. }
  31702. else if (
  31703. littleThan(close[0], interval[0], value)
  31704. && littleThan(close[1], value, interval[1])
  31705. ) {
  31706. return i;
  31707. }
  31708. findClosestWhenOutside && updatePossible(interval[0], i);
  31709. findClosestWhenOutside && updatePossible(interval[1], i);
  31710. }
  31711. }
  31712. if (findClosestWhenOutside) {
  31713. return value === Infinity
  31714. ? pieceList.length - 1
  31715. : value === -Infinity
  31716. ? 0
  31717. : possibleI;
  31718. }
  31719. function updatePossible(val, index) {
  31720. var newAbs = Math.abs(val - value);
  31721. if (newAbs < abs) {
  31722. abs = newAbs;
  31723. possibleI = index;
  31724. }
  31725. }
  31726. };
  31727. function littleThan(close, a, b) {
  31728. return close ? a <= b : a < b;
  31729. }
  31730. module.exports = VisualMapping;
  31731. /***/ },
  31732. /* 195 */
  31733. /***/ function(module, exports, __webpack_require__) {
  31734. var zrUtil = __webpack_require__(4);
  31735. var numberUtil = __webpack_require__(7);
  31736. var layout = __webpack_require__(21);
  31737. var helper = __webpack_require__(188);
  31738. var BoundingRect = __webpack_require__(9);
  31739. var helper = __webpack_require__(188);
  31740. var mathMax = Math.max;
  31741. var mathMin = Math.min;
  31742. var parsePercent = numberUtil.parsePercent;
  31743. var retrieveValue = zrUtil.retrieve;
  31744. var each = zrUtil.each;
  31745. /**
  31746. * @public
  31747. */
  31748. function update(ecModel, api, payload) {
  31749. // Layout result in each node:
  31750. // {x, y, width, height, area, borderWidth}
  31751. var condition = {mainType: 'series', subType: 'treemap', query: payload};
  31752. ecModel.eachComponent(condition, function (seriesModel) {
  31753. var ecWidth = api.getWidth();
  31754. var ecHeight = api.getHeight();
  31755. var seriesOption = seriesModel.option;
  31756. var size = seriesOption.size || []; // Compatible with ec2.
  31757. var containerWidth = parsePercent(
  31758. retrieveValue(seriesOption.width, size[0]),
  31759. ecWidth
  31760. );
  31761. var containerHeight = parsePercent(
  31762. retrieveValue(seriesOption.height, size[1]),
  31763. ecHeight
  31764. );
  31765. var layoutInfo = layout.getLayoutRect(
  31766. seriesModel.getBoxLayoutParams(),
  31767. {
  31768. width: api.getWidth(),
  31769. height: api.getHeight()
  31770. }
  31771. );
  31772. // Fetch payload info.
  31773. var payloadType = payload && payload.type;
  31774. var targetInfo = helper.retrieveTargetInfo(payload, seriesModel);
  31775. var rootRect = (payloadType === 'treemapRender' || payloadType === 'treemapMove')
  31776. ? payload.rootRect : null;
  31777. var viewRoot = seriesModel.getViewRoot();
  31778. var viewAbovePath = helper.getPathToRoot(viewRoot);
  31779. if (payloadType !== 'treemapMove') {
  31780. var rootSize = payloadType === 'treemapZoomToNode'
  31781. ? estimateRootSize(
  31782. seriesModel, targetInfo, viewRoot, containerWidth, containerHeight
  31783. )
  31784. : rootRect
  31785. ? [rootRect.width, rootRect.height]
  31786. : [containerWidth, containerHeight];
  31787. var sort = seriesOption.sort;
  31788. if (sort && sort !== 'asc' && sort !== 'desc') {
  31789. sort = 'desc';
  31790. }
  31791. var options = {
  31792. squareRatio: seriesOption.squareRatio,
  31793. sort: sort,
  31794. leafDepth: seriesOption.leafDepth
  31795. };
  31796. // layout should be cleared because using updateView but not update.
  31797. viewRoot.hostTree.clearLayouts();
  31798. // TODO
  31799. // optimize: if out of view clip, do not layout.
  31800. // But take care that if do not render node out of view clip,
  31801. // how to calculate start po
  31802. var viewRootLayout = {
  31803. x: 0, y: 0,
  31804. width: rootSize[0], height: rootSize[1],
  31805. area: rootSize[0] * rootSize[1]
  31806. };
  31807. viewRoot.setLayout(viewRootLayout);
  31808. squarify(viewRoot, options, false, 0);
  31809. // Supplement layout.
  31810. var viewRootLayout = viewRoot.getLayout();
  31811. each(viewAbovePath, function (node, index) {
  31812. var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
  31813. node.setLayout(zrUtil.extend(
  31814. {dataExtent: [childValue, childValue], borderWidth: 0},
  31815. viewRootLayout
  31816. ));
  31817. });
  31818. }
  31819. var treeRoot = seriesModel.getData().tree.root;
  31820. treeRoot.setLayout(
  31821. calculateRootPosition(layoutInfo, rootRect, targetInfo),
  31822. true
  31823. );
  31824. seriesModel.setLayoutInfo(layoutInfo);
  31825. // FIXME
  31826. // 现在没有clip功能,暂时取ec高宽。
  31827. prunning(
  31828. treeRoot,
  31829. // Transform to base element coordinate system.
  31830. new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight),
  31831. viewAbovePath,
  31832. viewRoot,
  31833. 0
  31834. );
  31835. });
  31836. }
  31837. /**
  31838. * Layout treemap with squarify algorithm.
  31839. * @see https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf
  31840. * @see https://github.com/mbostock/d3/blob/master/src/layout/treemap.js
  31841. *
  31842. * @protected
  31843. * @param {module:echarts/data/Tree~TreeNode} node
  31844. * @param {Object} options
  31845. * @param {string} options.sort 'asc' or 'desc'
  31846. * @param {number} options.squareRatio
  31847. * @param {boolean} hideChildren
  31848. * @param {number} depth
  31849. */
  31850. function squarify(node, options, hideChildren, depth) {
  31851. var width;
  31852. var height;
  31853. if (node.isRemoved()) {
  31854. return;
  31855. }
  31856. var thisLayout = node.getLayout();
  31857. width = thisLayout.width;
  31858. height = thisLayout.height;
  31859. // Considering border and gap
  31860. var itemStyleModel = node.getModel('itemStyle.normal');
  31861. var borderWidth = itemStyleModel.get('borderWidth');
  31862. var halfGapWidth = itemStyleModel.get('gapWidth') / 2;
  31863. var layoutOffset = borderWidth - halfGapWidth;
  31864. var nodeModel = node.getModel();
  31865. node.setLayout({borderWidth: borderWidth}, true);
  31866. width = mathMax(width - 2 * layoutOffset, 0);
  31867. height = mathMax(height - 2 * layoutOffset, 0);
  31868. var totalArea = width * height;
  31869. var viewChildren = initChildren(
  31870. node, nodeModel, totalArea, options, hideChildren, depth
  31871. );
  31872. if (!viewChildren.length) {
  31873. return;
  31874. }
  31875. var rect = {x: layoutOffset, y: layoutOffset, width: width, height: height};
  31876. var rowFixedLength = mathMin(width, height);
  31877. var best = Infinity; // the best row score so far
  31878. var row = [];
  31879. row.area = 0;
  31880. for (var i = 0, len = viewChildren.length; i < len;) {
  31881. var child = viewChildren[i];
  31882. row.push(child);
  31883. row.area += child.getLayout().area;
  31884. var score = worst(row, rowFixedLength, options.squareRatio);
  31885. // continue with this orientation
  31886. if (score <= best) {
  31887. i++;
  31888. best = score;
  31889. }
  31890. // abort, and try a different orientation
  31891. else {
  31892. row.area -= row.pop().getLayout().area;
  31893. position(row, rowFixedLength, rect, halfGapWidth, false);
  31894. rowFixedLength = mathMin(rect.width, rect.height);
  31895. row.length = row.area = 0;
  31896. best = Infinity;
  31897. }
  31898. }
  31899. if (row.length) {
  31900. position(row, rowFixedLength, rect, halfGapWidth, true);
  31901. }
  31902. if (!hideChildren) {
  31903. var childrenVisibleMin = nodeModel.get('childrenVisibleMin');
  31904. if (childrenVisibleMin != null && totalArea < childrenVisibleMin) {
  31905. hideChildren = true;
  31906. }
  31907. }
  31908. for (var i = 0, len = viewChildren.length; i < len; i++) {
  31909. squarify(viewChildren[i], options, hideChildren, depth + 1);
  31910. }
  31911. }
  31912. /**
  31913. * Set area to each child, and calculate data extent for visual coding.
  31914. */
  31915. function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
  31916. var viewChildren = node.children || [];
  31917. var orderBy = options.sort;
  31918. orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
  31919. var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth;
  31920. // leafDepth has higher priority.
  31921. if (hideChildren && !overLeafDepth) {
  31922. return (node.viewChildren = []);
  31923. }
  31924. // Sort children, order by desc.
  31925. viewChildren = zrUtil.filter(viewChildren, function (child) {
  31926. return !child.isRemoved();
  31927. });
  31928. sort(viewChildren, orderBy);
  31929. var info = statistic(nodeModel, viewChildren, orderBy);
  31930. if (info.sum === 0) {
  31931. return (node.viewChildren = []);
  31932. }
  31933. info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
  31934. if (info.sum === 0) {
  31935. return (node.viewChildren = []);
  31936. }
  31937. // Set area to each child.
  31938. for (var i = 0, len = viewChildren.length; i < len; i++) {
  31939. var area = viewChildren[i].getValue() / info.sum * totalArea;
  31940. // Do not use setLayout({...}, true), because it is needed to clear last layout.
  31941. viewChildren[i].setLayout({area: area});
  31942. }
  31943. if (overLeafDepth) {
  31944. viewChildren.length && node.setLayout({isLeafRoot: true}, true);
  31945. viewChildren.length = 0;
  31946. }
  31947. node.viewChildren = viewChildren;
  31948. node.setLayout({dataExtent: info.dataExtent}, true);
  31949. return viewChildren;
  31950. }
  31951. /**
  31952. * Consider 'visibleMin'. Modify viewChildren and get new sum.
  31953. */
  31954. function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
  31955. // visibleMin is not supported yet when no option.sort.
  31956. if (!orderBy) {
  31957. return sum;
  31958. }
  31959. var visibleMin = nodeModel.get('visibleMin');
  31960. var len = orderedChildren.length;
  31961. var deletePoint = len;
  31962. // Always travel from little value to big value.
  31963. for (var i = len - 1; i >= 0; i--) {
  31964. var value = orderedChildren[
  31965. orderBy === 'asc' ? len - i - 1 : i
  31966. ].getValue();
  31967. if (value / sum * totalArea < visibleMin) {
  31968. deletePoint = i;
  31969. sum -= value;
  31970. }
  31971. }
  31972. orderBy === 'asc'
  31973. ? orderedChildren.splice(0, len - deletePoint)
  31974. : orderedChildren.splice(deletePoint, len - deletePoint);
  31975. return sum;
  31976. }
  31977. /**
  31978. * Sort
  31979. */
  31980. function sort(viewChildren, orderBy) {
  31981. if (orderBy) {
  31982. viewChildren.sort(function (a, b) {
  31983. return orderBy === 'asc'
  31984. ? a.getValue() - b.getValue() : b.getValue() - a.getValue();
  31985. });
  31986. }
  31987. return viewChildren;
  31988. }
  31989. /**
  31990. * Statistic
  31991. */
  31992. function statistic(nodeModel, children, orderBy) {
  31993. // Calculate sum.
  31994. var sum = 0;
  31995. for (var i = 0, len = children.length; i < len; i++) {
  31996. sum += children[i].getValue();
  31997. }
  31998. // Statistic data extent for latter visual coding.
  31999. // Notice: data extent should be calculate based on raw children
  32000. // but not filtered view children, otherwise visual mapping will not
  32001. // be stable when zoom (where children is filtered by visibleMin).
  32002. var dimension = nodeModel.get('visualDimension');
  32003. var dataExtent;
  32004. // The same as area dimension.
  32005. if (!children || !children.length) {
  32006. dataExtent = [NaN, NaN];
  32007. }
  32008. else if (dimension === 'value' && orderBy) {
  32009. dataExtent = [
  32010. children[children.length - 1].getValue(),
  32011. children[0].getValue()
  32012. ];
  32013. orderBy === 'asc' && dataExtent.reverse();
  32014. }
  32015. // Other dimension.
  32016. else {
  32017. var dataExtent = [Infinity, -Infinity];
  32018. each(children, function (child) {
  32019. var value = child.getValue(dimension);
  32020. value < dataExtent[0] && (dataExtent[0] = value);
  32021. value > dataExtent[1] && (dataExtent[1] = value);
  32022. });
  32023. }
  32024. return {sum: sum, dataExtent: dataExtent};
  32025. }
  32026. /**
  32027. * Computes the score for the specified row,
  32028. * as the worst aspect ratio.
  32029. */
  32030. function worst(row, rowFixedLength, ratio) {
  32031. var areaMax = 0;
  32032. var areaMin = Infinity;
  32033. for (var i = 0, area, len = row.length; i < len; i++) {
  32034. area = row[i].getLayout().area;
  32035. if (area) {
  32036. area < areaMin && (areaMin = area);
  32037. area > areaMax && (areaMax = area);
  32038. }
  32039. }
  32040. var squareArea = row.area * row.area;
  32041. var f = rowFixedLength * rowFixedLength * ratio;
  32042. return squareArea
  32043. ? mathMax(
  32044. (f * areaMax) / squareArea,
  32045. squareArea / (f * areaMin)
  32046. )
  32047. : Infinity;
  32048. }
  32049. /**
  32050. * Positions the specified row of nodes. Modifies `rect`.
  32051. */
  32052. function position(row, rowFixedLength, rect, halfGapWidth, flush) {
  32053. // When rowFixedLength === rect.width,
  32054. // it is horizontal subdivision,
  32055. // rowFixedLength is the width of the subdivision,
  32056. // rowOtherLength is the height of the subdivision,
  32057. // and nodes will be positioned from left to right.
  32058. // wh[idx0WhenH] means: when horizontal,
  32059. // wh[idx0WhenH] => wh[0] => 'width'.
  32060. // xy[idx1WhenH] => xy[1] => 'y'.
  32061. var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
  32062. var idx1WhenH = 1 - idx0WhenH;
  32063. var xy = ['x', 'y'];
  32064. var wh = ['width', 'height'];
  32065. var last = rect[xy[idx0WhenH]];
  32066. var rowOtherLength = rowFixedLength
  32067. ? row.area / rowFixedLength : 0;
  32068. if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
  32069. rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
  32070. }
  32071. for (var i = 0, rowLen = row.length; i < rowLen; i++) {
  32072. var node = row[i];
  32073. var nodeLayout = {};
  32074. var step = rowOtherLength
  32075. ? node.getLayout().area / rowOtherLength : 0;
  32076. var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax(rowOtherLength - 2 * halfGapWidth, 0);
  32077. // We use Math.max/min to avoid negative width/height when considering gap width.
  32078. var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
  32079. var modWH = (i === rowLen - 1 || remain < step) ? remain : step;
  32080. var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax(modWH - 2 * halfGapWidth, 0);
  32081. nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin(halfGapWidth, wh1 / 2);
  32082. nodeLayout[xy[idx0WhenH]] = last + mathMin(halfGapWidth, wh0 / 2);
  32083. last += modWH;
  32084. node.setLayout(nodeLayout, true);
  32085. }
  32086. rect[xy[idx1WhenH]] += rowOtherLength;
  32087. rect[wh[idx1WhenH]] -= rowOtherLength;
  32088. }
  32089. // Return [containerWidth, containerHeight] as defualt.
  32090. function estimateRootSize(seriesModel, targetInfo, viewRoot, containerWidth, containerHeight) {
  32091. // If targetInfo.node exists, we zoom to the node,
  32092. // so estimate whold width and heigth by target node.
  32093. var currNode = (targetInfo || {}).node;
  32094. var defaultSize = [containerWidth, containerHeight];
  32095. if (!currNode || currNode === viewRoot) {
  32096. return defaultSize;
  32097. }
  32098. var parent;
  32099. var viewArea = containerWidth * containerHeight;
  32100. var area = viewArea * seriesModel.option.zoomToNodeRatio;
  32101. while (parent = currNode.parentNode) { // jshint ignore:line
  32102. var sum = 0;
  32103. var siblings = parent.children;
  32104. for (var i = 0, len = siblings.length; i < len; i++) {
  32105. sum += siblings[i].getValue();
  32106. }
  32107. var currNodeValue = currNode.getValue();
  32108. if (currNodeValue === 0) {
  32109. return defaultSize;
  32110. }
  32111. area *= sum / currNodeValue;
  32112. var borderWidth = parent.getModel('itemStyle.normal').get('borderWidth');
  32113. if (isFinite(borderWidth)) {
  32114. // Considering border, suppose aspect ratio is 1.
  32115. area += 4 * borderWidth * borderWidth + 4 * borderWidth * Math.pow(area, 0.5);
  32116. }
  32117. area > numberUtil.MAX_SAFE_INTEGER && (area = numberUtil.MAX_SAFE_INTEGER);
  32118. currNode = parent;
  32119. }
  32120. area < viewArea && (area = viewArea);
  32121. var scale = Math.pow(area / viewArea, 0.5);
  32122. return [containerWidth * scale, containerHeight * scale];
  32123. }
  32124. // Root postion base on coord of containerGroup
  32125. function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
  32126. if (rootRect) {
  32127. return {x: rootRect.x, y: rootRect.y};
  32128. }
  32129. var defaultPosition = {x: 0, y: 0};
  32130. if (!targetInfo) {
  32131. return defaultPosition;
  32132. }
  32133. // If targetInfo is fetched by 'retrieveTargetInfo',
  32134. // old tree and new tree are the same tree,
  32135. // so the node still exists and we can visit it.
  32136. var targetNode = targetInfo.node;
  32137. var layout = targetNode.getLayout();
  32138. if (!layout) {
  32139. return defaultPosition;
  32140. }
  32141. // Transform coord from local to container.
  32142. var targetCenter = [layout.width / 2, layout.height / 2];
  32143. var node = targetNode;
  32144. while (node) {
  32145. var nodeLayout = node.getLayout();
  32146. targetCenter[0] += nodeLayout.x;
  32147. targetCenter[1] += nodeLayout.y;
  32148. node = node.parentNode;
  32149. }
  32150. return {
  32151. x: layoutInfo.width / 2 - targetCenter[0],
  32152. y: layoutInfo.height / 2 - targetCenter[1]
  32153. };
  32154. }
  32155. // Mark nodes visible for prunning when visual coding and rendering.
  32156. // Prunning depends on layout and root position, so we have to do it after layout.
  32157. function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
  32158. var nodeLayout = node.getLayout();
  32159. var nodeInViewAbovePath = viewAbovePath[depth];
  32160. var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
  32161. if (
  32162. (nodeInViewAbovePath && !isAboveViewRoot)
  32163. || (depth === viewAbovePath.length && node !== viewRoot)
  32164. ) {
  32165. return;
  32166. }
  32167. node.setLayout({
  32168. // isInView means: viewRoot sub tree + viewAbovePath
  32169. isInView: true,
  32170. // invisible only means: outside view clip so that the node can not
  32171. // see but still layout for animation preparation but not render.
  32172. invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
  32173. isAboveViewRoot: isAboveViewRoot
  32174. }, true);
  32175. // Transform to child coordinate.
  32176. var childClipRect = new BoundingRect(
  32177. clipRect.x - nodeLayout.x,
  32178. clipRect.y - nodeLayout.y,
  32179. clipRect.width,
  32180. clipRect.height
  32181. );
  32182. each(node.viewChildren || [], function (child) {
  32183. prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
  32184. });
  32185. }
  32186. module.exports = update;
  32187. /***/ },
  32188. /* 196 */
  32189. /***/ function(module, exports, __webpack_require__) {
  32190. var echarts = __webpack_require__(1);
  32191. var zrUtil = __webpack_require__(4);
  32192. __webpack_require__(197);
  32193. __webpack_require__(200);
  32194. __webpack_require__(205);
  32195. echarts.registerProcessor(__webpack_require__(206));
  32196. echarts.registerVisual(zrUtil.curry(
  32197. __webpack_require__(110), 'graph', 'circle', null
  32198. ));
  32199. echarts.registerVisual(__webpack_require__(207));
  32200. echarts.registerVisual(__webpack_require__(208));
  32201. echarts.registerLayout(__webpack_require__(209));
  32202. echarts.registerLayout(__webpack_require__(212));
  32203. echarts.registerLayout(__webpack_require__(214));
  32204. // Graph view coordinate system
  32205. echarts.registerCoordinateSystem('graphView', {
  32206. create: __webpack_require__(216)
  32207. });
  32208. /***/ },
  32209. /* 197 */
  32210. /***/ function(module, exports, __webpack_require__) {
  32211. 'use strict';
  32212. var List = __webpack_require__(98);
  32213. var zrUtil = __webpack_require__(4);
  32214. var modelUtil = __webpack_require__(5);
  32215. var Model = __webpack_require__(12);
  32216. var createGraphFromNodeEdge = __webpack_require__(198);
  32217. var GraphSeries = __webpack_require__(1).extendSeriesModel({
  32218. type: 'series.graph',
  32219. init: function (option) {
  32220. GraphSeries.superApply(this, 'init', arguments);
  32221. // Provide data for legend select
  32222. this.legendDataProvider = function () {
  32223. return this._categoriesData;
  32224. };
  32225. this.fillDataTextStyle(option.edges || option.links);
  32226. this._updateCategoriesData();
  32227. },
  32228. mergeOption: function (option) {
  32229. GraphSeries.superApply(this, 'mergeOption', arguments);
  32230. this.fillDataTextStyle(option.edges || option.links);
  32231. this._updateCategoriesData();
  32232. },
  32233. mergeDefaultAndTheme: function (option) {
  32234. GraphSeries.superApply(this, 'mergeDefaultAndTheme', arguments);
  32235. modelUtil.defaultEmphasis(option.edgeLabel, modelUtil.LABEL_OPTIONS);
  32236. },
  32237. getInitialData: function (option, ecModel) {
  32238. var edges = option.edges || option.links || [];
  32239. var nodes = option.data || option.nodes || [];
  32240. var self = this;
  32241. if (nodes && edges) {
  32242. return createGraphFromNodeEdge(nodes, edges, this, true, beforeLink).data;
  32243. }
  32244. function beforeLink(nodeData, edgeData) {
  32245. // Overwrite nodeData.getItemModel to
  32246. nodeData.wrapMethod('getItemModel', function (model) {
  32247. var categoriesModels = self._categoriesModels;
  32248. var categoryIdx = model.getShallow('category');
  32249. var categoryModel = categoriesModels[categoryIdx];
  32250. if (categoryModel) {
  32251. categoryModel.parentModel = model.parentModel;
  32252. model.parentModel = categoryModel;
  32253. }
  32254. return model;
  32255. });
  32256. var edgeLabelModel = self.getModel('edgeLabel');
  32257. var wrappedGetEdgeModel = function (path, parentModel) {
  32258. var pathArr = (path || '').split('.');
  32259. if (pathArr[0] === 'label') {
  32260. parentModel = parentModel
  32261. || edgeLabelModel.getModel(pathArr.slice(1));
  32262. }
  32263. var model = Model.prototype.getModel.call(this, pathArr, parentModel);
  32264. model.getModel = wrappedGetEdgeModel;
  32265. return model;
  32266. };
  32267. edgeData.wrapMethod('getItemModel', function (model) {
  32268. // FIXME Wrap get method ?
  32269. model.getModel = wrappedGetEdgeModel;
  32270. return model;
  32271. });
  32272. }
  32273. },
  32274. /**
  32275. * @return {module:echarts/data/Graph}
  32276. */
  32277. getGraph: function () {
  32278. return this.getData().graph;
  32279. },
  32280. /**
  32281. * @return {module:echarts/data/List}
  32282. */
  32283. getEdgeData: function () {
  32284. return this.getGraph().edgeData;
  32285. },
  32286. /**
  32287. * @return {module:echarts/data/List}
  32288. */
  32289. getCategoriesData: function () {
  32290. return this._categoriesData;
  32291. },
  32292. /**
  32293. * @override
  32294. */
  32295. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  32296. if (dataType === 'edge') {
  32297. var nodeData = this.getData();
  32298. var params = this.getDataParams(dataIndex, dataType);
  32299. var edge = nodeData.graph.getEdgeByIndex(dataIndex);
  32300. var sourceName = nodeData.getName(edge.node1.dataIndex);
  32301. var targetName = nodeData.getName(edge.node2.dataIndex);
  32302. var html = sourceName + ' > ' + targetName;
  32303. if (params.value) {
  32304. html += ' : ' + params.value;
  32305. }
  32306. return html;
  32307. }
  32308. else { // dataType === 'node' or empty
  32309. return GraphSeries.superApply(this, 'formatTooltip', arguments);
  32310. }
  32311. },
  32312. _updateCategoriesData: function () {
  32313. var categories = zrUtil.map(this.option.categories || [], function (category) {
  32314. // Data must has value
  32315. return category.value != null ? category : zrUtil.extend({
  32316. value: 0
  32317. }, category);
  32318. });
  32319. var categoriesData = new List(['value'], this);
  32320. categoriesData.initData(categories);
  32321. this._categoriesData = categoriesData;
  32322. this._categoriesModels = categoriesData.mapArray(function (idx) {
  32323. return categoriesData.getItemModel(idx, true);
  32324. });
  32325. },
  32326. setZoom: function (zoom) {
  32327. this.option.zoom = zoom;
  32328. },
  32329. setCenter: function (center) {
  32330. this.option.center = center;
  32331. },
  32332. ifEnableAnimation: function () {
  32333. return GraphSeries.superCall(this, 'ifEnableAnimation')
  32334. // Not enable animation when do force layout
  32335. && !(this.get('layout') === 'force' && this.get('force.layoutAnimation'));
  32336. },
  32337. defaultOption: {
  32338. zlevel: 0,
  32339. z: 2,
  32340. coordinateSystem: 'view',
  32341. // Default option for all coordinate systems
  32342. // xAxisIndex: 0,
  32343. // yAxisIndex: 0,
  32344. // polarIndex: 0,
  32345. // geoIndex: 0,
  32346. legendHoverLink: true,
  32347. hoverAnimation: true,
  32348. layout: null,
  32349. focusNodeAdjacency: false,
  32350. // Configuration of circular layout
  32351. circular: {
  32352. rotateLabel: false
  32353. },
  32354. // Configuration of force directed layout
  32355. force: {
  32356. initLayout: null,
  32357. // Node repulsion. Can be an array to represent range.
  32358. repulsion: [0, 50],
  32359. gravity: 0.1,
  32360. // Edge length. Can be an array to represent range.
  32361. edgeLength: 30,
  32362. layoutAnimation: true
  32363. },
  32364. left: 'center',
  32365. top: 'center',
  32366. // right: null,
  32367. // bottom: null,
  32368. // width: '80%',
  32369. // height: '80%',
  32370. symbol: 'circle',
  32371. symbolSize: 10,
  32372. edgeSymbol: ['none', 'none'],
  32373. edgeSymbolSize: 10,
  32374. edgeLabel: {
  32375. normal: {
  32376. position: 'middle'
  32377. },
  32378. emphasis: {}
  32379. },
  32380. draggable: false,
  32381. roam: false,
  32382. // Default on center of graph
  32383. center: null,
  32384. zoom: 1,
  32385. // Symbol size scale ratio in roam
  32386. nodeScaleRatio: 0.6,
  32387. // categories: [],
  32388. // data: []
  32389. // Or
  32390. // nodes: []
  32391. //
  32392. // links: []
  32393. // Or
  32394. // edges: []
  32395. label: {
  32396. normal: {
  32397. show: false,
  32398. formatter: '{b}'
  32399. },
  32400. emphasis: {
  32401. show: true
  32402. }
  32403. },
  32404. itemStyle: {
  32405. normal: {},
  32406. emphasis: {}
  32407. },
  32408. lineStyle: {
  32409. normal: {
  32410. color: '#aaa',
  32411. width: 1,
  32412. curveness: 0,
  32413. opacity: 0.5
  32414. },
  32415. emphasis: {}
  32416. }
  32417. }
  32418. });
  32419. module.exports = GraphSeries;
  32420. /***/ },
  32421. /* 198 */
  32422. /***/ function(module, exports, __webpack_require__) {
  32423. var List = __webpack_require__(98);
  32424. var Graph = __webpack_require__(199);
  32425. var linkList = __webpack_require__(187);
  32426. var completeDimensions = __webpack_require__(103);
  32427. var CoordinateSystem = __webpack_require__(26);
  32428. var zrUtil = __webpack_require__(4);
  32429. var createListFromArray = __webpack_require__(102);
  32430. module.exports = function (nodes, edges, hostModel, directed, beforeLink) {
  32431. var graph = new Graph(directed);
  32432. for (var i = 0; i < nodes.length; i++) {
  32433. graph.addNode(zrUtil.retrieve(
  32434. // Id, name, dataIndex
  32435. nodes[i].id, nodes[i].name, i
  32436. ), i);
  32437. }
  32438. var linkNameList = [];
  32439. var validEdges = [];
  32440. var linkCount = 0;
  32441. for (var i = 0; i < edges.length; i++) {
  32442. var link = edges[i];
  32443. var source = link.source;
  32444. var target = link.target;
  32445. // addEdge may fail when source or target not exists
  32446. if (graph.addEdge(source, target, linkCount)) {
  32447. validEdges.push(link);
  32448. linkNameList.push(zrUtil.retrieve(link.id, source + ' > ' + target));
  32449. linkCount++;
  32450. }
  32451. }
  32452. var coordSys = hostModel.get('coordinateSystem');
  32453. var nodeData;
  32454. if (coordSys === 'cartesian2d' || coordSys === 'polar') {
  32455. nodeData = createListFromArray(nodes, hostModel, hostModel.ecModel);
  32456. }
  32457. else {
  32458. // FIXME
  32459. var coordSysCtor = CoordinateSystem.get(coordSys);
  32460. // FIXME
  32461. var dimensionNames = completeDimensions(
  32462. ((coordSysCtor && coordSysCtor.type !== 'view') ? (coordSysCtor.dimensions || []) : []).concat(['value']),
  32463. nodes
  32464. );
  32465. nodeData = new List(dimensionNames, hostModel);
  32466. nodeData.initData(nodes);
  32467. }
  32468. var edgeData = new List(['value'], hostModel);
  32469. edgeData.initData(validEdges, linkNameList);
  32470. beforeLink && beforeLink(nodeData, edgeData);
  32471. linkList({
  32472. mainData: nodeData,
  32473. struct: graph,
  32474. structAttr: 'graph',
  32475. datas: {node: nodeData, edge: edgeData},
  32476. datasAttr: {node: 'data', edge: 'edgeData'}
  32477. });
  32478. // Update dataIndex of nodes and edges because invalid edge may be removed
  32479. graph.update();
  32480. return graph;
  32481. };
  32482. /***/ },
  32483. /* 199 */
  32484. /***/ function(module, exports, __webpack_require__) {
  32485. 'use strict';
  32486. /**
  32487. * Graph data structure
  32488. *
  32489. * @module echarts/data/Graph
  32490. * @author Yi Shen(https://www.github.com/pissang)
  32491. */
  32492. var zrUtil = __webpack_require__(4);
  32493. /**
  32494. * @alias module:echarts/data/Graph
  32495. * @constructor
  32496. * @param {boolean} directed
  32497. */
  32498. var Graph = function(directed) {
  32499. /**
  32500. * 是否是有向图
  32501. * @type {boolean}
  32502. * @private
  32503. */
  32504. this._directed = directed || false;
  32505. /**
  32506. * @type {Array.<module:echarts/data/Graph.Node>}
  32507. * @readOnly
  32508. */
  32509. this.nodes = [];
  32510. /**
  32511. * @type {Array.<module:echarts/data/Graph.Edge>}
  32512. * @readOnly
  32513. */
  32514. this.edges = [];
  32515. /**
  32516. * @type {Object.<string, module:echarts/data/Graph.Node>}
  32517. * @private
  32518. */
  32519. this._nodesMap = {};
  32520. /**
  32521. * @type {Object.<string, module:echarts/data/Graph.Edge>}
  32522. * @private
  32523. */
  32524. this._edgesMap = {};
  32525. /**
  32526. * @type {module:echarts/data/List}
  32527. * @readOnly
  32528. */
  32529. this.data;
  32530. /**
  32531. * @type {module:echarts/data/List}
  32532. * @readOnly
  32533. */
  32534. this.edgeData;
  32535. };
  32536. var graphProto = Graph.prototype;
  32537. /**
  32538. * @type {string}
  32539. */
  32540. graphProto.type = 'graph';
  32541. /**
  32542. * If is directed graph
  32543. * @return {boolean}
  32544. */
  32545. graphProto.isDirected = function () {
  32546. return this._directed;
  32547. };
  32548. /**
  32549. * Add a new node
  32550. * @param {string} id
  32551. * @param {number} [dataIndex]
  32552. */
  32553. graphProto.addNode = function (id, dataIndex) {
  32554. id = id || ('' + dataIndex);
  32555. var nodesMap = this._nodesMap;
  32556. if (nodesMap[id]) {
  32557. return;
  32558. }
  32559. var node = new Node(id, dataIndex);
  32560. node.hostGraph = this;
  32561. this.nodes.push(node);
  32562. nodesMap[id] = node;
  32563. return node;
  32564. };
  32565. /**
  32566. * Get node by data index
  32567. * @param {number} dataIndex
  32568. * @return {module:echarts/data/Graph~Node}
  32569. */
  32570. graphProto.getNodeByIndex = function (dataIndex) {
  32571. var rawIdx = this.data.getRawIndex(dataIndex);
  32572. return this.nodes[rawIdx];
  32573. };
  32574. /**
  32575. * Get node by id
  32576. * @param {string} id
  32577. * @return {module:echarts/data/Graph.Node}
  32578. */
  32579. graphProto.getNodeById = function (id) {
  32580. return this._nodesMap[id];
  32581. };
  32582. /**
  32583. * Add a new edge
  32584. * @param {number|string|module:echarts/data/Graph.Node} n1
  32585. * @param {number|string|module:echarts/data/Graph.Node} n2
  32586. * @param {number} [dataIndex=-1]
  32587. * @return {module:echarts/data/Graph.Edge}
  32588. */
  32589. graphProto.addEdge = function (n1, n2, dataIndex) {
  32590. var nodesMap = this._nodesMap;
  32591. var edgesMap = this._edgesMap;
  32592. // PNEDING
  32593. if (typeof n1 === 'number') {
  32594. n1 = this.nodes[n1];
  32595. }
  32596. if (typeof n2 === 'number') {
  32597. n2 = this.nodes[n2];
  32598. }
  32599. if (!(n1 instanceof Node)) {
  32600. n1 = nodesMap[n1];
  32601. }
  32602. if (!(n2 instanceof Node)) {
  32603. n2 = nodesMap[n2];
  32604. }
  32605. if (!n1 || !n2) {
  32606. return;
  32607. }
  32608. var key = n1.id + '-' + n2.id;
  32609. // PENDING
  32610. if (edgesMap[key]) {
  32611. return;
  32612. }
  32613. var edge = new Edge(n1, n2, dataIndex);
  32614. edge.hostGraph = this;
  32615. if (this._directed) {
  32616. n1.outEdges.push(edge);
  32617. n2.inEdges.push(edge);
  32618. }
  32619. n1.edges.push(edge);
  32620. if (n1 !== n2) {
  32621. n2.edges.push(edge);
  32622. }
  32623. this.edges.push(edge);
  32624. edgesMap[key] = edge;
  32625. return edge;
  32626. };
  32627. /**
  32628. * Get edge by data index
  32629. * @param {number} dataIndex
  32630. * @return {module:echarts/data/Graph~Node}
  32631. */
  32632. graphProto.getEdgeByIndex = function (dataIndex) {
  32633. var rawIdx = this.edgeData.getRawIndex(dataIndex);
  32634. return this.edges[rawIdx];
  32635. };
  32636. /**
  32637. * Get edge by two linked nodes
  32638. * @param {module:echarts/data/Graph.Node|string} n1
  32639. * @param {module:echarts/data/Graph.Node|string} n2
  32640. * @return {module:echarts/data/Graph.Edge}
  32641. */
  32642. graphProto.getEdge = function (n1, n2) {
  32643. if (n1 instanceof Node) {
  32644. n1 = n1.id;
  32645. }
  32646. if (n2 instanceof Node) {
  32647. n2 = n2.id;
  32648. }
  32649. var edgesMap = this._edgesMap;
  32650. if (this._directed) {
  32651. return edgesMap[n1 + '-' + n2];
  32652. } else {
  32653. return edgesMap[n1 + '-' + n2]
  32654. || edgesMap[n2 + '-' + n1];
  32655. }
  32656. };
  32657. /**
  32658. * Iterate all nodes
  32659. * @param {Function} cb
  32660. * @param {*} [context]
  32661. */
  32662. graphProto.eachNode = function (cb, context) {
  32663. var nodes = this.nodes;
  32664. var len = nodes.length;
  32665. for (var i = 0; i < len; i++) {
  32666. if (nodes[i].dataIndex >= 0) {
  32667. cb.call(context, nodes[i], i);
  32668. }
  32669. }
  32670. };
  32671. /**
  32672. * Iterate all edges
  32673. * @param {Function} cb
  32674. * @param {*} [context]
  32675. */
  32676. graphProto.eachEdge = function (cb, context) {
  32677. var edges = this.edges;
  32678. var len = edges.length;
  32679. for (var i = 0; i < len; i++) {
  32680. if (edges[i].dataIndex >= 0
  32681. && edges[i].node1.dataIndex >= 0
  32682. && edges[i].node2.dataIndex >= 0
  32683. ) {
  32684. cb.call(context, edges[i], i);
  32685. }
  32686. }
  32687. };
  32688. /**
  32689. * Breadth first traverse
  32690. * @param {Function} cb
  32691. * @param {module:echarts/data/Graph.Node} startNode
  32692. * @param {string} [direction='none'] 'none'|'in'|'out'
  32693. * @param {*} [context]
  32694. */
  32695. graphProto.breadthFirstTraverse = function (
  32696. cb, startNode, direction, context
  32697. ) {
  32698. if (!(startNode instanceof Node)) {
  32699. startNode = this._nodesMap[startNode];
  32700. }
  32701. if (!startNode) {
  32702. return;
  32703. }
  32704. var edgeType = direction === 'out'
  32705. ? 'outEdges' : (direction === 'in' ? 'inEdges' : 'edges');
  32706. for (var i = 0; i < this.nodes.length; i++) {
  32707. this.nodes[i].__visited = false;
  32708. }
  32709. if (cb.call(context, startNode, null)) {
  32710. return;
  32711. }
  32712. var queue = [startNode];
  32713. while (queue.length) {
  32714. var currentNode = queue.shift();
  32715. var edges = currentNode[edgeType];
  32716. for (var i = 0; i < edges.length; i++) {
  32717. var e = edges[i];
  32718. var otherNode = e.node1 === currentNode
  32719. ? e.node2 : e.node1;
  32720. if (!otherNode.__visited) {
  32721. if (cb.call(otherNode, otherNode, currentNode)) {
  32722. // Stop traversing
  32723. return;
  32724. }
  32725. queue.push(otherNode);
  32726. otherNode.__visited = true;
  32727. }
  32728. }
  32729. }
  32730. };
  32731. // TODO
  32732. // graphProto.depthFirstTraverse = function (
  32733. // cb, startNode, direction, context
  32734. // ) {
  32735. // };
  32736. // Filter update
  32737. graphProto.update = function () {
  32738. var data = this.data;
  32739. var edgeData = this.edgeData;
  32740. var nodes = this.nodes;
  32741. var edges = this.edges;
  32742. for (var i = 0, len = nodes.length; i < len; i++) {
  32743. nodes[i].dataIndex = -1;
  32744. }
  32745. for (var i = 0, len = data.count(); i < len; i++) {
  32746. nodes[data.getRawIndex(i)].dataIndex = i;
  32747. }
  32748. edgeData.filterSelf(function (idx) {
  32749. var edge = edges[edgeData.getRawIndex(idx)];
  32750. return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0;
  32751. });
  32752. // Update edge
  32753. for (var i = 0, len = edges.length; i < len; i++) {
  32754. edges[i].dataIndex = -1;
  32755. }
  32756. for (var i = 0, len = edgeData.count(); i < len; i++) {
  32757. edges[edgeData.getRawIndex(i)].dataIndex = i;
  32758. }
  32759. };
  32760. /**
  32761. * @return {module:echarts/data/Graph}
  32762. */
  32763. graphProto.clone = function () {
  32764. var graph = new Graph(this._directed);
  32765. var nodes = this.nodes;
  32766. var edges = this.edges;
  32767. for (var i = 0; i < nodes.length; i++) {
  32768. graph.addNode(nodes[i].id, nodes[i].dataIndex);
  32769. }
  32770. for (var i = 0; i < edges.length; i++) {
  32771. var e = edges[i];
  32772. graph.addEdge(e.node1.id, e.node2.id, e.dataIndex);
  32773. }
  32774. return graph;
  32775. };
  32776. /**
  32777. * @alias module:echarts/data/Graph.Node
  32778. */
  32779. function Node(id, dataIndex) {
  32780. /**
  32781. * @type {string}
  32782. */
  32783. this.id = id == null ? '' : id;
  32784. /**
  32785. * @type {Array.<module:echarts/data/Graph.Edge>}
  32786. */
  32787. this.inEdges = [];
  32788. /**
  32789. * @type {Array.<module:echarts/data/Graph.Edge>}
  32790. */
  32791. this.outEdges = [];
  32792. /**
  32793. * @type {Array.<module:echarts/data/Graph.Edge>}
  32794. */
  32795. this.edges = [];
  32796. /**
  32797. * @type {module:echarts/data/Graph}
  32798. */
  32799. this.hostGraph;
  32800. /**
  32801. * @type {number}
  32802. */
  32803. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  32804. }
  32805. Node.prototype = {
  32806. constructor: Node,
  32807. /**
  32808. * @return {number}
  32809. */
  32810. degree: function () {
  32811. return this.edges.length;
  32812. },
  32813. /**
  32814. * @return {number}
  32815. */
  32816. inDegree: function () {
  32817. return this.inEdges.length;
  32818. },
  32819. /**
  32820. * @return {number}
  32821. */
  32822. outDegree: function () {
  32823. return this.outEdges.length;
  32824. },
  32825. /**
  32826. * @param {string} [path]
  32827. * @return {module:echarts/model/Model}
  32828. */
  32829. getModel: function (path) {
  32830. if (this.dataIndex < 0) {
  32831. return;
  32832. }
  32833. var graph = this.hostGraph;
  32834. var itemModel = graph.data.getItemModel(this.dataIndex);
  32835. return itemModel.getModel(path);
  32836. }
  32837. };
  32838. /**
  32839. * 图边
  32840. * @alias module:echarts/data/Graph.Edge
  32841. * @param {module:echarts/data/Graph.Node} n1
  32842. * @param {module:echarts/data/Graph.Node} n2
  32843. * @param {number} [dataIndex=-1]
  32844. */
  32845. function Edge(n1, n2, dataIndex) {
  32846. /**
  32847. * 节点1,如果是有向图则为源节点
  32848. * @type {module:echarts/data/Graph.Node}
  32849. */
  32850. this.node1 = n1;
  32851. /**
  32852. * 节点2,如果是有向图则为目标节点
  32853. * @type {module:echarts/data/Graph.Node}
  32854. */
  32855. this.node2 = n2;
  32856. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  32857. }
  32858. /**
  32859. * @param {string} [path]
  32860. * @return {module:echarts/model/Model}
  32861. */
  32862. Edge.prototype.getModel = function (path) {
  32863. if (this.dataIndex < 0) {
  32864. return;
  32865. }
  32866. var graph = this.hostGraph;
  32867. var itemModel = graph.edgeData.getItemModel(this.dataIndex);
  32868. return itemModel.getModel(path);
  32869. };
  32870. var createGraphDataProxyMixin = function (hostName, dataName) {
  32871. return {
  32872. /**
  32873. * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
  32874. * @return {number}
  32875. */
  32876. getValue: function (dimension) {
  32877. var data = this[hostName][dataName];
  32878. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  32879. },
  32880. /**
  32881. * @param {Object|string} key
  32882. * @param {*} [value]
  32883. */
  32884. setVisual: function (key, value) {
  32885. this.dataIndex >= 0
  32886. && this[hostName][dataName].setItemVisual(this.dataIndex, key, value);
  32887. },
  32888. /**
  32889. * @param {string} key
  32890. * @return {boolean}
  32891. */
  32892. getVisual: function (key, ignoreParent) {
  32893. return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent);
  32894. },
  32895. /**
  32896. * @param {Object} layout
  32897. * @return {boolean} [merge=false]
  32898. */
  32899. setLayout: function (layout, merge) {
  32900. this.dataIndex >= 0
  32901. && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge);
  32902. },
  32903. /**
  32904. * @return {Object}
  32905. */
  32906. getLayout: function () {
  32907. return this[hostName][dataName].getItemLayout(this.dataIndex);
  32908. },
  32909. /**
  32910. * @return {module:zrender/Element}
  32911. */
  32912. getGraphicEl: function () {
  32913. return this[hostName][dataName].getItemGraphicEl(this.dataIndex);
  32914. },
  32915. /**
  32916. * @return {number}
  32917. */
  32918. getRawIndex: function () {
  32919. return this[hostName][dataName].getRawIndex(this.dataIndex);
  32920. }
  32921. };
  32922. };
  32923. zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data'));
  32924. zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
  32925. Graph.Node = Node;
  32926. Graph.Edge = Edge;
  32927. module.exports = Graph;
  32928. /***/ },
  32929. /* 200 */
  32930. /***/ function(module, exports, __webpack_require__) {
  32931. var SymbolDraw = __webpack_require__(105);
  32932. var LineDraw = __webpack_require__(201);
  32933. var RoamController = __webpack_require__(176);
  32934. var graphic = __webpack_require__(43);
  32935. var adjustEdge = __webpack_require__(204);
  32936. var zrUtil = __webpack_require__(4);
  32937. var nodeOpacityPath = ['itemStyle', 'normal', 'opacity'];
  32938. var lineOpacityPath = ['lineStyle', 'normal', 'opacity'];
  32939. function getItemOpacity(item, opacityPath) {
  32940. return item.getVisual('opacity') || item.getModel().get(opacityPath);
  32941. }
  32942. __webpack_require__(1).extendChartView({
  32943. type: 'graph',
  32944. init: function (ecModel, api) {
  32945. var symbolDraw = new SymbolDraw();
  32946. var lineDraw = new LineDraw();
  32947. var group = this.group;
  32948. var controller = new RoamController(api.getZr(), group);
  32949. group.add(symbolDraw.group);
  32950. group.add(lineDraw.group);
  32951. this._symbolDraw = symbolDraw;
  32952. this._lineDraw = lineDraw;
  32953. this._controller = controller;
  32954. this._firstRender = true;
  32955. },
  32956. render: function (seriesModel, ecModel, api) {
  32957. var coordSys = seriesModel.coordinateSystem;
  32958. this._model = seriesModel;
  32959. this._nodeScaleRatio = seriesModel.get('nodeScaleRatio');
  32960. var symbolDraw = this._symbolDraw;
  32961. var lineDraw = this._lineDraw;
  32962. var group = this.group;
  32963. if (coordSys.type === 'view') {
  32964. var groupNewProp = {
  32965. position: coordSys.position,
  32966. scale: coordSys.scale
  32967. };
  32968. if (this._firstRender) {
  32969. group.attr(groupNewProp);
  32970. }
  32971. else {
  32972. graphic.updateProps(group, groupNewProp, seriesModel);
  32973. }
  32974. }
  32975. // Fix edge contact point with node
  32976. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  32977. var data = seriesModel.getData();
  32978. symbolDraw.updateData(data);
  32979. var edgeData = seriesModel.getEdgeData();
  32980. lineDraw.updateData(edgeData);
  32981. this._updateNodeAndLinkScale();
  32982. this._updateController(seriesModel, api);
  32983. clearTimeout(this._layoutTimeout);
  32984. var forceLayout = seriesModel.forceLayout;
  32985. var layoutAnimation = seriesModel.get('force.layoutAnimation');
  32986. if (forceLayout) {
  32987. this._startForceLayoutIteration(forceLayout, layoutAnimation);
  32988. }
  32989. data.eachItemGraphicEl(function (el, idx) {
  32990. var itemModel = data.getItemModel(idx);
  32991. // Update draggable
  32992. el.off('drag').off('dragend');
  32993. var draggable = data.getItemModel(idx).get('draggable');
  32994. if (draggable) {
  32995. el.on('drag', function () {
  32996. if (forceLayout) {
  32997. forceLayout.warmUp();
  32998. !this._layouting
  32999. && this._startForceLayoutIteration(forceLayout, layoutAnimation);
  33000. forceLayout.setFixed(idx);
  33001. // Write position back to layout
  33002. data.setItemLayout(idx, el.position);
  33003. }
  33004. }, this).on('dragend', function () {
  33005. if (forceLayout) {
  33006. forceLayout.setUnfixed(idx);
  33007. }
  33008. }, this);
  33009. }
  33010. el.setDraggable(draggable && forceLayout);
  33011. el.off('mouseover', this._focusNodeAdjacency);
  33012. el.off('mouseout', this._unfocusAll);
  33013. if (itemModel.get('focusNodeAdjacency')) {
  33014. el.on('mouseover', this._focusNodeAdjacency, this);
  33015. el.on('mouseout', this._unfocusAll, this);
  33016. }
  33017. }, this);
  33018. var circularRotateLabel = seriesModel.get('layout') === 'circular' && seriesModel.get('circular.rotateLabel');
  33019. var cx = data.getLayout('cx');
  33020. var cy = data.getLayout('cy');
  33021. data.eachItemGraphicEl(function (el, idx) {
  33022. var symbolPath = el.getSymbolPath();
  33023. if (circularRotateLabel) {
  33024. var pos = data.getItemLayout(idx);
  33025. var rad = Math.atan2(pos[1] - cy, pos[0] - cx);
  33026. if (rad < 0) {
  33027. rad = Math.PI * 2 + rad;
  33028. }
  33029. var isLeft = pos[0] < cx;
  33030. if (isLeft) {
  33031. rad = rad - Math.PI;
  33032. }
  33033. var textPosition = isLeft ? 'left' : 'right';
  33034. symbolPath.setStyle({
  33035. textRotation: rad,
  33036. textPosition: textPosition
  33037. });
  33038. symbolPath.hoverStyle && (symbolPath.hoverStyle.textPosition = textPosition);
  33039. }
  33040. else {
  33041. symbolPath.setStyle({
  33042. textRotation: 0
  33043. });
  33044. }
  33045. });
  33046. this._firstRender = false;
  33047. },
  33048. dispose: function () {
  33049. this._controller && this._controller.dispose();
  33050. },
  33051. _focusNodeAdjacency: function (e) {
  33052. var data = this._model.getData();
  33053. var graph = data.graph;
  33054. var el = e.target;
  33055. var dataIndex = el.dataIndex;
  33056. var dataType = el.dataType;
  33057. function fadeOutItem(item, opacityPath) {
  33058. var opacity = getItemOpacity(item, opacityPath);
  33059. var el = item.getGraphicEl();
  33060. if (opacity == null) {
  33061. opacity = 1;
  33062. }
  33063. el.traverse(function (child) {
  33064. child.trigger('normal');
  33065. if (child.type !== 'group') {
  33066. child.setStyle('opacity', opacity * 0.1);
  33067. }
  33068. });
  33069. }
  33070. function fadeInItem(item, opacityPath) {
  33071. var opacity = getItemOpacity(item, opacityPath);
  33072. var el = item.getGraphicEl();
  33073. el.traverse(function (child) {
  33074. child.trigger('emphasis');
  33075. if (child.type !== 'group') {
  33076. child.setStyle('opacity', opacity);
  33077. }
  33078. });
  33079. }
  33080. if (dataIndex !== null && dataType !== 'edge') {
  33081. graph.eachNode(function (node) {
  33082. fadeOutItem(node, nodeOpacityPath);
  33083. });
  33084. graph.eachEdge(function (edge) {
  33085. fadeOutItem(edge, lineOpacityPath);
  33086. });
  33087. var node = graph.getNodeByIndex(dataIndex);
  33088. fadeInItem(node, nodeOpacityPath);
  33089. zrUtil.each(node.edges, function (edge) {
  33090. if (edge.dataIndex < 0) {
  33091. return;
  33092. }
  33093. fadeInItem(edge, lineOpacityPath);
  33094. fadeInItem(edge.node1, nodeOpacityPath);
  33095. fadeInItem(edge.node2, nodeOpacityPath);
  33096. });
  33097. }
  33098. },
  33099. _unfocusAll: function () {
  33100. var data = this._model.getData();
  33101. var graph = data.graph;
  33102. graph.eachNode(function (node) {
  33103. var opacity = getItemOpacity(node, nodeOpacityPath);
  33104. node.getGraphicEl().traverse(function (child) {
  33105. child.trigger('normal');
  33106. if (child.type !== 'group') {
  33107. child.setStyle('opacity', opacity);
  33108. }
  33109. });
  33110. });
  33111. graph.eachEdge(function (edge) {
  33112. var opacity = getItemOpacity(edge, lineOpacityPath);
  33113. edge.getGraphicEl().traverse(function (child) {
  33114. child.trigger('normal');
  33115. if (child.type !== 'group') {
  33116. child.setStyle('opacity', opacity);
  33117. }
  33118. });
  33119. });
  33120. },
  33121. _startForceLayoutIteration: function (forceLayout, layoutAnimation) {
  33122. var self = this;
  33123. (function step() {
  33124. forceLayout.step(function (stopped) {
  33125. self.updateLayout(self._model);
  33126. (self._layouting = !stopped) && (
  33127. layoutAnimation
  33128. ? (self._layoutTimeout = setTimeout(step, 16))
  33129. : step()
  33130. );
  33131. });
  33132. })();
  33133. },
  33134. _updateController: function (seriesModel, api) {
  33135. var controller = this._controller;
  33136. var group = this.group;
  33137. controller.setContainsPoint(function (x, y) {
  33138. var rect = group.getBoundingRect();
  33139. rect.applyTransform(group.transform);
  33140. return rect.contain(x, y);
  33141. });
  33142. if (seriesModel.coordinateSystem.type !== 'view') {
  33143. controller.disable();
  33144. return;
  33145. }
  33146. controller.enable(seriesModel.get('roam'));
  33147. controller.zoomLimit = seriesModel.get('scaleLimit');
  33148. // Update zoom from model
  33149. controller.zoom = seriesModel.coordinateSystem.getZoom();
  33150. controller
  33151. .off('pan')
  33152. .off('zoom')
  33153. .on('pan', function (dx, dy) {
  33154. api.dispatchAction({
  33155. seriesId: seriesModel.id,
  33156. type: 'graphRoam',
  33157. dx: dx,
  33158. dy: dy
  33159. });
  33160. })
  33161. .on('zoom', function (zoom, mouseX, mouseY) {
  33162. api.dispatchAction({
  33163. seriesId: seriesModel.id,
  33164. type: 'graphRoam',
  33165. zoom: zoom,
  33166. originX: mouseX,
  33167. originY: mouseY
  33168. });
  33169. this._updateNodeAndLinkScale();
  33170. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  33171. this._lineDraw.updateLayout();
  33172. }, this);
  33173. },
  33174. _updateNodeAndLinkScale: function () {
  33175. var seriesModel = this._model;
  33176. var data = seriesModel.getData();
  33177. var nodeScale = this._getNodeGlobalScale(seriesModel);
  33178. var invScale = [nodeScale, nodeScale];
  33179. data.eachItemGraphicEl(function (el, idx) {
  33180. el.attr('scale', invScale);
  33181. });
  33182. },
  33183. _getNodeGlobalScale: function (seriesModel) {
  33184. var coordSys = seriesModel.coordinateSystem;
  33185. if (coordSys.type !== 'view') {
  33186. return 1;
  33187. }
  33188. var nodeScaleRatio = this._nodeScaleRatio;
  33189. var groupScale = coordSys.scale;
  33190. var groupZoom = (groupScale && groupScale[0]) || 1;
  33191. // Scale node when zoom changes
  33192. var roamZoom = coordSys.getZoom();
  33193. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  33194. return nodeScale / groupZoom;
  33195. },
  33196. updateLayout: function (seriesModel) {
  33197. adjustEdge(seriesModel.getGraph(), this._getNodeGlobalScale(seriesModel));
  33198. this._symbolDraw.updateLayout();
  33199. this._lineDraw.updateLayout();
  33200. },
  33201. remove: function (ecModel, api) {
  33202. this._symbolDraw && this._symbolDraw.remove();
  33203. this._lineDraw && this._lineDraw.remove();
  33204. }
  33205. });
  33206. /***/ },
  33207. /* 201 */
  33208. /***/ function(module, exports, __webpack_require__) {
  33209. /**
  33210. * @module echarts/chart/helper/LineDraw
  33211. */
  33212. var graphic = __webpack_require__(43);
  33213. var LineGroup = __webpack_require__(202);
  33214. function isPointNaN(pt) {
  33215. return isNaN(pt[0]) || isNaN(pt[1]);
  33216. }
  33217. function lineNeedsDraw(pts) {
  33218. return !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
  33219. }
  33220. /**
  33221. * @alias module:echarts/component/marker/LineDraw
  33222. * @constructor
  33223. */
  33224. function LineDraw(ctor) {
  33225. this._ctor = ctor || LineGroup;
  33226. this.group = new graphic.Group();
  33227. }
  33228. var lineDrawProto = LineDraw.prototype;
  33229. /**
  33230. * @param {module:echarts/data/List} lineData
  33231. */
  33232. lineDrawProto.updateData = function (lineData) {
  33233. var oldLineData = this._lineData;
  33234. var group = this.group;
  33235. var LineCtor = this._ctor;
  33236. var hostModel = lineData.hostModel;
  33237. var seriesScope = {
  33238. lineStyle: hostModel.getModel('lineStyle.normal').getLineStyle(),
  33239. hoverLineStyle: hostModel.getModel('lineStyle.emphasis').getLineStyle(),
  33240. labelModel: hostModel.getModel('label.normal'),
  33241. hoverLabelModel: hostModel.getModel('label.emphasis')
  33242. };
  33243. lineData.diff(oldLineData)
  33244. .add(function (idx) {
  33245. if (!lineNeedsDraw(lineData.getItemLayout(idx))) {
  33246. return;
  33247. }
  33248. var lineGroup = new LineCtor(lineData, idx, seriesScope);
  33249. lineData.setItemGraphicEl(idx, lineGroup);
  33250. group.add(lineGroup);
  33251. })
  33252. .update(function (newIdx, oldIdx) {
  33253. var lineGroup = oldLineData.getItemGraphicEl(oldIdx);
  33254. if (!lineNeedsDraw(lineData.getItemLayout(newIdx))) {
  33255. group.remove(lineGroup);
  33256. return;
  33257. }
  33258. if (!lineGroup) {
  33259. lineGroup = new LineCtor(lineData, newIdx, seriesScope);
  33260. }
  33261. else {
  33262. lineGroup.updateData(lineData, newIdx, seriesScope);
  33263. }
  33264. lineData.setItemGraphicEl(newIdx, lineGroup);
  33265. group.add(lineGroup);
  33266. })
  33267. .remove(function (idx) {
  33268. group.remove(oldLineData.getItemGraphicEl(idx));
  33269. })
  33270. .execute();
  33271. this._lineData = lineData;
  33272. };
  33273. lineDrawProto.updateLayout = function () {
  33274. var lineData = this._lineData;
  33275. lineData.eachItemGraphicEl(function (el, idx) {
  33276. el.updateLayout(lineData, idx);
  33277. }, this);
  33278. };
  33279. lineDrawProto.remove = function () {
  33280. this.group.removeAll();
  33281. };
  33282. module.exports = LineDraw;
  33283. /***/ },
  33284. /* 202 */
  33285. /***/ function(module, exports, __webpack_require__) {
  33286. /**
  33287. * @module echarts/chart/helper/Line
  33288. */
  33289. var symbolUtil = __webpack_require__(107);
  33290. var vector = __webpack_require__(10);
  33291. // var matrix = require('zrender/lib/core/matrix');
  33292. var LinePath = __webpack_require__(203);
  33293. var graphic = __webpack_require__(43);
  33294. var zrUtil = __webpack_require__(4);
  33295. var numberUtil = __webpack_require__(7);
  33296. var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
  33297. function makeSymbolTypeKey(symbolCategory) {
  33298. return '_' + symbolCategory + 'Type';
  33299. }
  33300. /**
  33301. * @inner
  33302. */
  33303. function createSymbol(name, lineData, idx) {
  33304. var color = lineData.getItemVisual(idx, 'color');
  33305. var symbolType = lineData.getItemVisual(idx, name);
  33306. var symbolSize = lineData.getItemVisual(idx, name + 'Size');
  33307. if (!symbolType || symbolType === 'none') {
  33308. return;
  33309. }
  33310. if (!zrUtil.isArray(symbolSize)) {
  33311. symbolSize = [symbolSize, symbolSize];
  33312. }
  33313. var symbolPath = symbolUtil.createSymbol(
  33314. symbolType, -symbolSize[0] / 2, -symbolSize[1] / 2,
  33315. symbolSize[0], symbolSize[1], color
  33316. );
  33317. symbolPath.name = name;
  33318. return symbolPath;
  33319. }
  33320. function createLine(points) {
  33321. var line = new LinePath({
  33322. name: 'line'
  33323. });
  33324. setLinePoints(line.shape, points);
  33325. return line;
  33326. }
  33327. function setLinePoints(targetShape, points) {
  33328. var p1 = points[0];
  33329. var p2 = points[1];
  33330. var cp1 = points[2];
  33331. targetShape.x1 = p1[0];
  33332. targetShape.y1 = p1[1];
  33333. targetShape.x2 = p2[0];
  33334. targetShape.y2 = p2[1];
  33335. targetShape.percent = 1;
  33336. if (cp1) {
  33337. targetShape.cpx1 = cp1[0];
  33338. targetShape.cpy1 = cp1[1];
  33339. }
  33340. else {
  33341. targetShape.cpx1 = NaN;
  33342. targetShape.cpy1 = NaN;
  33343. }
  33344. }
  33345. function updateSymbolAndLabelBeforeLineUpdate () {
  33346. var lineGroup = this;
  33347. var symbolFrom = lineGroup.childOfName('fromSymbol');
  33348. var symbolTo = lineGroup.childOfName('toSymbol');
  33349. var label = lineGroup.childOfName('label');
  33350. // Quick reject
  33351. if (!symbolFrom && !symbolTo && label.ignore) {
  33352. return;
  33353. }
  33354. var invScale = 1;
  33355. var parentNode = this.parent;
  33356. while (parentNode) {
  33357. if (parentNode.scale) {
  33358. invScale /= parentNode.scale[0];
  33359. }
  33360. parentNode = parentNode.parent;
  33361. }
  33362. var line = lineGroup.childOfName('line');
  33363. // If line not changed
  33364. // FIXME Parent scale changed
  33365. if (!this.__dirty && !line.__dirty) {
  33366. return;
  33367. }
  33368. var percent = line.shape.percent;
  33369. var fromPos = line.pointAt(0);
  33370. var toPos = line.pointAt(percent);
  33371. var d = vector.sub([], toPos, fromPos);
  33372. vector.normalize(d, d);
  33373. if (symbolFrom) {
  33374. symbolFrom.attr('position', fromPos);
  33375. var tangent = line.tangentAt(0);
  33376. symbolFrom.attr('rotation', Math.PI / 2 - Math.atan2(
  33377. tangent[1], tangent[0]
  33378. ));
  33379. symbolFrom.attr('scale', [invScale * percent, invScale * percent]);
  33380. }
  33381. if (symbolTo) {
  33382. symbolTo.attr('position', toPos);
  33383. var tangent = line.tangentAt(1);
  33384. symbolTo.attr('rotation', -Math.PI / 2 - Math.atan2(
  33385. tangent[1], tangent[0]
  33386. ));
  33387. symbolTo.attr('scale', [invScale * percent, invScale * percent]);
  33388. }
  33389. if (!label.ignore) {
  33390. label.attr('position', toPos);
  33391. var textPosition;
  33392. var textAlign;
  33393. var textVerticalAlign;
  33394. var distance = 5 * invScale;
  33395. // End
  33396. if (label.__position === 'end') {
  33397. textPosition = [d[0] * distance + toPos[0], d[1] * distance + toPos[1]];
  33398. textAlign = d[0] > 0.8 ? 'left' : (d[0] < -0.8 ? 'right' : 'center');
  33399. textVerticalAlign = d[1] > 0.8 ? 'top' : (d[1] < -0.8 ? 'bottom' : 'middle');
  33400. }
  33401. // Middle
  33402. else if (label.__position === 'middle') {
  33403. var halfPercent = percent / 2;
  33404. var tangent = line.tangentAt(halfPercent);
  33405. var n = [tangent[1], -tangent[0]];
  33406. var cp = line.pointAt(halfPercent);
  33407. if (n[1] > 0) {
  33408. n[0] = -n[0];
  33409. n[1] = -n[1];
  33410. }
  33411. textPosition = [cp[0] + n[0] * distance, cp[1] + n[1] * distance];
  33412. textAlign = 'center';
  33413. textVerticalAlign = 'bottom';
  33414. var rotation = -Math.atan2(tangent[1], tangent[0]);
  33415. if (toPos[0] < fromPos[0]) {
  33416. rotation = Math.PI + rotation;
  33417. }
  33418. label.attr('rotation', rotation);
  33419. }
  33420. // Start
  33421. else {
  33422. textPosition = [-d[0] * distance + fromPos[0], -d[1] * distance + fromPos[1]];
  33423. textAlign = d[0] > 0.8 ? 'right' : (d[0] < -0.8 ? 'left' : 'center');
  33424. textVerticalAlign = d[1] > 0.8 ? 'bottom' : (d[1] < -0.8 ? 'top' : 'middle');
  33425. }
  33426. label.attr({
  33427. style: {
  33428. // Use the user specified text align and baseline first
  33429. textVerticalAlign: label.__verticalAlign || textVerticalAlign,
  33430. textAlign: label.__textAlign || textAlign
  33431. },
  33432. position: textPosition,
  33433. scale: [invScale, invScale]
  33434. });
  33435. }
  33436. }
  33437. /**
  33438. * @constructor
  33439. * @extends {module:zrender/graphic/Group}
  33440. * @alias {module:echarts/chart/helper/Line}
  33441. */
  33442. function Line(lineData, idx, seriesScope) {
  33443. graphic.Group.call(this);
  33444. this._createLine(lineData, idx, seriesScope);
  33445. }
  33446. var lineProto = Line.prototype;
  33447. // Update symbol position and rotation
  33448. lineProto.beforeUpdate = updateSymbolAndLabelBeforeLineUpdate;
  33449. lineProto._createLine = function (lineData, idx, seriesScope) {
  33450. var seriesModel = lineData.hostModel;
  33451. var linePoints = lineData.getItemLayout(idx);
  33452. var line = createLine(linePoints);
  33453. line.shape.percent = 0;
  33454. graphic.initProps(line, {
  33455. shape: {
  33456. percent: 1
  33457. }
  33458. }, seriesModel, idx);
  33459. this.add(line);
  33460. var label = new graphic.Text({
  33461. name: 'label'
  33462. });
  33463. this.add(label);
  33464. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  33465. var symbol = createSymbol(symbolCategory, lineData, idx);
  33466. // symbols must added after line to make sure
  33467. // it will be updated after line#update.
  33468. // Or symbol position and rotation update in line#beforeUpdate will be one frame slow
  33469. this.add(symbol);
  33470. this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
  33471. }, this);
  33472. this._updateCommonStl(lineData, idx, seriesScope);
  33473. };
  33474. lineProto.updateData = function (lineData, idx, seriesScope) {
  33475. var seriesModel = lineData.hostModel;
  33476. var line = this.childOfName('line');
  33477. var linePoints = lineData.getItemLayout(idx);
  33478. var target = {
  33479. shape: {}
  33480. };
  33481. setLinePoints(target.shape, linePoints);
  33482. graphic.updateProps(line, target, seriesModel, idx);
  33483. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  33484. var symbolType = lineData.getItemVisual(idx, symbolCategory);
  33485. var key = makeSymbolTypeKey(symbolCategory);
  33486. // Symbol changed
  33487. if (this[key] !== symbolType) {
  33488. this.remove(this.childOfName(symbolCategory));
  33489. var symbol = createSymbol(symbolCategory, lineData, idx);
  33490. this.add(symbol);
  33491. }
  33492. this[key] = symbolType;
  33493. }, this);
  33494. this._updateCommonStl(lineData, idx, seriesScope);
  33495. };
  33496. lineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  33497. var seriesModel = lineData.hostModel;
  33498. var line = this.childOfName('line');
  33499. var lineStyle = seriesScope && seriesScope.lineStyle;
  33500. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  33501. var labelModel = seriesScope && seriesScope.labelModel;
  33502. var hoverLabelModel = seriesScope && seriesScope.hoverLabelModel;
  33503. // Optimization for large dataset
  33504. if (!seriesScope || lineData.hasItemOption) {
  33505. var itemModel = lineData.getItemModel(idx);
  33506. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  33507. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  33508. labelModel = itemModel.getModel('label.normal');
  33509. hoverLabelModel = itemModel.getModel('label.emphasis');
  33510. }
  33511. var visualColor = lineData.getItemVisual(idx, 'color');
  33512. var visualOpacity = zrUtil.retrieve(
  33513. lineData.getItemVisual(idx, 'opacity'),
  33514. lineStyle.opacity,
  33515. 1
  33516. );
  33517. line.useStyle(zrUtil.defaults(
  33518. {
  33519. strokeNoScale: true,
  33520. fill: 'none',
  33521. stroke: visualColor,
  33522. opacity: visualOpacity
  33523. },
  33524. lineStyle
  33525. ));
  33526. line.hoverStyle = hoverLineStyle;
  33527. // Update symbol
  33528. zrUtil.each(SYMBOL_CATEGORIES, function (symbolCategory) {
  33529. var symbol = this.childOfName(symbolCategory);
  33530. if (symbol) {
  33531. symbol.setColor(visualColor);
  33532. symbol.setStyle({
  33533. opacity: visualOpacity
  33534. });
  33535. }
  33536. }, this);
  33537. var showLabel = labelModel.getShallow('show');
  33538. var hoverShowLabel = hoverLabelModel.getShallow('show');
  33539. var label = this.childOfName('label');
  33540. var defaultLabelColor;
  33541. var defaultText;
  33542. if (showLabel || hoverShowLabel) {
  33543. var rawVal = seriesModel.getRawValue(idx);
  33544. defaultText = rawVal == null
  33545. ? defaultText = lineData.getName(idx)
  33546. : isFinite(rawVal)
  33547. ? numberUtil.round(rawVal)
  33548. : rawVal;
  33549. defaultLabelColor = visualColor || '#000';
  33550. }
  33551. // label.afterUpdate = lineAfterUpdate;
  33552. if (showLabel) {
  33553. var textStyleModel = labelModel.getModel('textStyle');
  33554. label.setStyle({
  33555. text: zrUtil.retrieve(
  33556. seriesModel.getFormattedLabel(idx, 'normal', lineData.dataType),
  33557. defaultText
  33558. ),
  33559. textFont: textStyleModel.getFont(),
  33560. fill: textStyleModel.getTextColor() || defaultLabelColor
  33561. });
  33562. label.__textAlign = textStyleModel.get('align');
  33563. label.__verticalAlign = textStyleModel.get('baseline');
  33564. label.__position = labelModel.get('position');
  33565. }
  33566. else {
  33567. label.setStyle('text', '');
  33568. }
  33569. if (hoverShowLabel) {
  33570. var textStyleHoverModel = hoverLabelModel.getModel('textStyle');
  33571. label.hoverStyle = {
  33572. text: zrUtil.retrieve(
  33573. seriesModel.getFormattedLabel(idx, 'emphasis', lineData.dataType),
  33574. defaultText
  33575. ),
  33576. textFont: textStyleHoverModel.getFont(),
  33577. fill: textStyleHoverModel.getTextColor() || defaultLabelColor
  33578. };
  33579. }
  33580. else {
  33581. label.hoverStyle = {
  33582. text: ''
  33583. };
  33584. }
  33585. label.ignore = !showLabel && !hoverShowLabel;
  33586. graphic.setHoverStyle(this);
  33587. };
  33588. lineProto.updateLayout = function (lineData, idx) {
  33589. this.setLinePoints(lineData.getItemLayout(idx));
  33590. };
  33591. lineProto.setLinePoints = function (points) {
  33592. var linePath = this.childOfName('line');
  33593. setLinePoints(linePath.shape, points);
  33594. linePath.dirty();
  33595. };
  33596. zrUtil.inherits(Line, graphic.Group);
  33597. module.exports = Line;
  33598. /***/ },
  33599. /* 203 */
  33600. /***/ function(module, exports, __webpack_require__) {
  33601. /**
  33602. * Line path for bezier and straight line draw
  33603. */
  33604. var graphic = __webpack_require__(43);
  33605. var vec2 = __webpack_require__(10);
  33606. var straightLineProto = graphic.Line.prototype;
  33607. var bezierCurveProto = graphic.BezierCurve.prototype;
  33608. function isLine(shape) {
  33609. return isNaN(+shape.cpx1) || isNaN(+shape.cpy1);
  33610. }
  33611. module.exports = graphic.extendShape({
  33612. type: 'ec-line',
  33613. style: {
  33614. stroke: '#000',
  33615. fill: null
  33616. },
  33617. shape: {
  33618. x1: 0,
  33619. y1: 0,
  33620. x2: 0,
  33621. y2: 0,
  33622. percent: 1,
  33623. cpx1: null,
  33624. cpy1: null
  33625. },
  33626. buildPath: function (ctx, shape) {
  33627. (isLine(shape) ? straightLineProto : bezierCurveProto).buildPath(ctx, shape);
  33628. },
  33629. pointAt: function (t) {
  33630. return isLine(this.shape)
  33631. ? straightLineProto.pointAt.call(this, t)
  33632. : bezierCurveProto.pointAt.call(this, t);
  33633. },
  33634. tangentAt: function (t) {
  33635. var shape = this.shape;
  33636. var p = isLine(shape)
  33637. ? [shape.x2 - shape.x1, shape.y2 - shape.y1]
  33638. : bezierCurveProto.tangentAt.call(this, t);
  33639. return vec2.normalize(p, p);
  33640. }
  33641. });
  33642. /***/ },
  33643. /* 204 */
  33644. /***/ function(module, exports, __webpack_require__) {
  33645. var curveTool = __webpack_require__(50);
  33646. var vec2 = __webpack_require__(10);
  33647. var v1 = [];
  33648. var v2 = [];
  33649. var v3 = [];
  33650. var quadraticAt = curveTool.quadraticAt;
  33651. var v2DistSquare = vec2.distSquare;
  33652. var mathAbs = Math.abs;
  33653. function intersectCurveCircle(curvePoints, center, radius) {
  33654. var p0 = curvePoints[0];
  33655. var p1 = curvePoints[1];
  33656. var p2 = curvePoints[2];
  33657. var d = Infinity;
  33658. var t;
  33659. var radiusSquare = radius * radius;
  33660. var interval = 0.1;
  33661. for (var _t = 0.1; _t <= 0.9; _t += 0.1) {
  33662. v1[0] = quadraticAt(p0[0], p1[0], p2[0], _t);
  33663. v1[1] = quadraticAt(p0[1], p1[1], p2[1], _t);
  33664. var diff = mathAbs(v2DistSquare(v1, center) - radiusSquare);
  33665. if (diff < d) {
  33666. d = diff;
  33667. t = _t;
  33668. }
  33669. }
  33670. // Assume the segment is monotone,Find root through Bisection method
  33671. // At most 32 iteration
  33672. for (var i = 0; i < 32; i++) {
  33673. // var prev = t - interval;
  33674. var next = t + interval;
  33675. // v1[0] = quadraticAt(p0[0], p1[0], p2[0], prev);
  33676. // v1[1] = quadraticAt(p0[1], p1[1], p2[1], prev);
  33677. v2[0] = quadraticAt(p0[0], p1[0], p2[0], t);
  33678. v2[1] = quadraticAt(p0[1], p1[1], p2[1], t);
  33679. v3[0] = quadraticAt(p0[0], p1[0], p2[0], next);
  33680. v3[1] = quadraticAt(p0[1], p1[1], p2[1], next);
  33681. var diff = v2DistSquare(v2, center) - radiusSquare;
  33682. if (mathAbs(diff) < 1e-2) {
  33683. break;
  33684. }
  33685. // var prevDiff = v2DistSquare(v1, center) - radiusSquare;
  33686. var nextDiff = v2DistSquare(v3, center) - radiusSquare;
  33687. interval /= 2;
  33688. if (diff < 0) {
  33689. if (nextDiff >= 0) {
  33690. t = t + interval;
  33691. }
  33692. else {
  33693. t = t - interval;
  33694. }
  33695. }
  33696. else {
  33697. if (nextDiff >= 0) {
  33698. t = t - interval;
  33699. }
  33700. else {
  33701. t = t + interval;
  33702. }
  33703. }
  33704. }
  33705. return t;
  33706. }
  33707. // Adjust edge to avoid
  33708. module.exports = function (graph, scale) {
  33709. var tmp0 = [];
  33710. var quadraticSubdivide = curveTool.quadraticSubdivide;
  33711. var pts = [[], [], []];
  33712. var pts2 = [[], []];
  33713. var v = [];
  33714. scale /= 2;
  33715. function getSymbolSize(node) {
  33716. var symbolSize = node.getVisual('symbolSize');
  33717. if (symbolSize instanceof Array) {
  33718. symbolSize = (symbolSize[0] + symbolSize[1]) / 2;
  33719. }
  33720. return symbolSize;
  33721. }
  33722. graph.eachEdge(function (edge, idx) {
  33723. var linePoints = edge.getLayout();
  33724. var fromSymbol = edge.getVisual('fromSymbol');
  33725. var toSymbol = edge.getVisual('toSymbol');
  33726. if (!linePoints.__original) {
  33727. linePoints.__original = [
  33728. vec2.clone(linePoints[0]),
  33729. vec2.clone(linePoints[1])
  33730. ];
  33731. if (linePoints[2]) {
  33732. linePoints.__original.push(vec2.clone(linePoints[2]));
  33733. }
  33734. }
  33735. var originalPoints = linePoints.__original;
  33736. // Quadratic curve
  33737. if (linePoints[2] != null) {
  33738. vec2.copy(pts[0], originalPoints[0]);
  33739. vec2.copy(pts[1], originalPoints[2]);
  33740. vec2.copy(pts[2], originalPoints[1]);
  33741. if (fromSymbol && fromSymbol != 'none') {
  33742. var symbolSize = getSymbolSize(edge.node1);
  33743. var t = intersectCurveCircle(pts, originalPoints[0], symbolSize * scale);
  33744. // Subdivide and get the second
  33745. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  33746. pts[0][0] = tmp0[3];
  33747. pts[1][0] = tmp0[4];
  33748. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  33749. pts[0][1] = tmp0[3];
  33750. pts[1][1] = tmp0[4];
  33751. }
  33752. if (toSymbol && toSymbol != 'none') {
  33753. var symbolSize = getSymbolSize(edge.node2);
  33754. var t = intersectCurveCircle(pts, originalPoints[1], symbolSize * scale);
  33755. // Subdivide and get the first
  33756. quadraticSubdivide(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  33757. pts[1][0] = tmp0[1];
  33758. pts[2][0] = tmp0[2];
  33759. quadraticSubdivide(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  33760. pts[1][1] = tmp0[1];
  33761. pts[2][1] = tmp0[2];
  33762. }
  33763. // Copy back to layout
  33764. vec2.copy(linePoints[0], pts[0]);
  33765. vec2.copy(linePoints[1], pts[2]);
  33766. vec2.copy(linePoints[2], pts[1]);
  33767. }
  33768. // Line
  33769. else {
  33770. vec2.copy(pts2[0], originalPoints[0]);
  33771. vec2.copy(pts2[1], originalPoints[1]);
  33772. vec2.sub(v, pts2[1], pts2[0]);
  33773. vec2.normalize(v, v);
  33774. if (fromSymbol && fromSymbol != 'none') {
  33775. var symbolSize = getSymbolSize(edge.node1);
  33776. vec2.scaleAndAdd(pts2[0], pts2[0], v, symbolSize * scale);
  33777. }
  33778. if (toSymbol && toSymbol != 'none') {
  33779. var symbolSize = getSymbolSize(edge.node2);
  33780. vec2.scaleAndAdd(pts2[1], pts2[1], v, -symbolSize * scale);
  33781. }
  33782. vec2.copy(linePoints[0], pts2[0]);
  33783. vec2.copy(linePoints[1], pts2[1]);
  33784. }
  33785. });
  33786. };
  33787. /***/ },
  33788. /* 205 */
  33789. /***/ function(module, exports, __webpack_require__) {
  33790. var echarts = __webpack_require__(1);
  33791. var roamHelper = __webpack_require__(179);
  33792. var actionInfo = {
  33793. type: 'graphRoam',
  33794. event: 'graphRoam',
  33795. update: 'none'
  33796. };
  33797. /**
  33798. * @payload
  33799. * @property {string} name Series name
  33800. * @property {number} [dx]
  33801. * @property {number} [dy]
  33802. * @property {number} [zoom]
  33803. * @property {number} [originX]
  33804. * @property {number} [originY]
  33805. */
  33806. echarts.registerAction(actionInfo, function (payload, ecModel) {
  33807. ecModel.eachComponent({mainType: 'series', query: payload}, function (seriesModel) {
  33808. var coordSys = seriesModel.coordinateSystem;
  33809. var res = roamHelper.updateCenterAndZoom(coordSys, payload);
  33810. seriesModel.setCenter
  33811. && seriesModel.setCenter(res.center);
  33812. seriesModel.setZoom
  33813. && seriesModel.setZoom(res.zoom);
  33814. });
  33815. });
  33816. /***/ },
  33817. /* 206 */
  33818. /***/ function(module, exports) {
  33819. module.exports = function (ecModel) {
  33820. var legendModels = ecModel.findComponents({
  33821. mainType: 'legend'
  33822. });
  33823. if (!legendModels || !legendModels.length) {
  33824. return;
  33825. }
  33826. ecModel.eachSeriesByType('graph', function (graphSeries) {
  33827. var categoriesData = graphSeries.getCategoriesData();
  33828. var graph = graphSeries.getGraph();
  33829. var data = graph.data;
  33830. var categoryNames = categoriesData.mapArray(categoriesData.getName);
  33831. data.filterSelf(function (idx) {
  33832. var model = data.getItemModel(idx);
  33833. var category = model.getShallow('category');
  33834. if (category != null) {
  33835. if (typeof category === 'number') {
  33836. category = categoryNames[category];
  33837. }
  33838. // If in any legend component the status is not selected.
  33839. for (var i = 0; i < legendModels.length; i++) {
  33840. if (!legendModels[i].isSelected(category)) {
  33841. return false;
  33842. }
  33843. }
  33844. }
  33845. return true;
  33846. });
  33847. }, this);
  33848. };
  33849. /***/ },
  33850. /* 207 */
  33851. /***/ function(module, exports) {
  33852. module.exports = function (ecModel) {
  33853. var paletteScope = {};
  33854. ecModel.eachSeriesByType('graph', function (seriesModel) {
  33855. var categoriesData = seriesModel.getCategoriesData();
  33856. var data = seriesModel.getData();
  33857. var categoryNameIdxMap = {};
  33858. categoriesData.each(function (idx) {
  33859. var name = categoriesData.getName(idx);
  33860. categoryNameIdxMap[name] = idx;
  33861. var itemModel = categoriesData.getItemModel(idx);
  33862. var color = itemModel.get('itemStyle.normal.color')
  33863. || seriesModel.getColorFromPalette(name, paletteScope);
  33864. categoriesData.setItemVisual(idx, 'color', color);
  33865. });
  33866. // Assign category color to visual
  33867. if (categoriesData.count()) {
  33868. data.each(function (idx) {
  33869. var model = data.getItemModel(idx);
  33870. var category = model.getShallow('category');
  33871. if (category != null) {
  33872. if (typeof category === 'string') {
  33873. category = categoryNameIdxMap[category];
  33874. }
  33875. if (!data.getItemVisual(idx, 'color', true)) {
  33876. data.setItemVisual(
  33877. idx, 'color',
  33878. categoriesData.getItemVisual(category, 'color')
  33879. );
  33880. }
  33881. }
  33882. });
  33883. }
  33884. });
  33885. };
  33886. /***/ },
  33887. /* 208 */
  33888. /***/ function(module, exports) {
  33889. function normalize(a) {
  33890. if (!(a instanceof Array)) {
  33891. a = [a, a];
  33892. }
  33893. return a;
  33894. }
  33895. module.exports = function (ecModel) {
  33896. ecModel.eachSeriesByType('graph', function (seriesModel) {
  33897. var graph = seriesModel.getGraph();
  33898. var edgeData = seriesModel.getEdgeData();
  33899. var symbolType = normalize(seriesModel.get('edgeSymbol'));
  33900. var symbolSize = normalize(seriesModel.get('edgeSymbolSize'));
  33901. var colorQuery = 'lineStyle.normal.color'.split('.');
  33902. var opacityQuery = 'lineStyle.normal.opacity'.split('.');
  33903. edgeData.setVisual('fromSymbol', symbolType && symbolType[0]);
  33904. edgeData.setVisual('toSymbol', symbolType && symbolType[1]);
  33905. edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  33906. edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  33907. edgeData.setVisual('color', seriesModel.get(colorQuery));
  33908. edgeData.setVisual('opacity', seriesModel.get(opacityQuery));
  33909. edgeData.each(function (idx) {
  33910. var itemModel = edgeData.getItemModel(idx);
  33911. var edge = graph.getEdgeByIndex(idx);
  33912. var symbolType = normalize(itemModel.getShallow('symbol', true));
  33913. var symbolSize = normalize(itemModel.getShallow('symbolSize', true));
  33914. // Edge visual must after node visual
  33915. var color = itemModel.get(colorQuery);
  33916. var opacity = itemModel.get(opacityQuery);
  33917. switch (color) {
  33918. case 'source':
  33919. color = edge.node1.getVisual('color');
  33920. break;
  33921. case 'target':
  33922. color = edge.node2.getVisual('color');
  33923. break;
  33924. }
  33925. symbolType[0] && edge.setVisual('fromSymbol', symbolType[0]);
  33926. symbolType[1] && edge.setVisual('toSymbol', symbolType[1]);
  33927. symbolSize[0] && edge.setVisual('fromSymbolSize', symbolSize[0]);
  33928. symbolSize[1] && edge.setVisual('toSymbolSize', symbolSize[1]);
  33929. edge.setVisual('color', color);
  33930. edge.setVisual('opacity', opacity);
  33931. });
  33932. });
  33933. };
  33934. /***/ },
  33935. /* 209 */
  33936. /***/ function(module, exports, __webpack_require__) {
  33937. var simpleLayoutHelper = __webpack_require__(210);
  33938. var simpleLayoutEdge = __webpack_require__(211);
  33939. module.exports = function (ecModel, api) {
  33940. ecModel.eachSeriesByType('graph', function (seriesModel) {
  33941. var layout = seriesModel.get('layout');
  33942. var coordSys = seriesModel.coordinateSystem;
  33943. if (coordSys && coordSys.type !== 'view') {
  33944. var data = seriesModel.getData();
  33945. data.each(coordSys.dimensions, function (x, y, idx) {
  33946. if (!isNaN(x) && !isNaN(y)) {
  33947. data.setItemLayout(idx, coordSys.dataToPoint([x, y]));
  33948. }
  33949. else {
  33950. // Also {Array.<number>}, not undefined to avoid if...else... statement
  33951. data.setItemLayout(idx, [NaN, NaN]);
  33952. }
  33953. });
  33954. simpleLayoutEdge(data.graph);
  33955. }
  33956. else if (!layout || layout === 'none') {
  33957. simpleLayoutHelper(seriesModel);
  33958. }
  33959. });
  33960. };
  33961. /***/ },
  33962. /* 210 */
  33963. /***/ function(module, exports, __webpack_require__) {
  33964. var simpleLayoutEdge = __webpack_require__(211);
  33965. module.exports = function (seriesModel) {
  33966. var coordSys = seriesModel.coordinateSystem;
  33967. if (coordSys && coordSys.type !== 'view') {
  33968. return;
  33969. }
  33970. var graph = seriesModel.getGraph();
  33971. graph.eachNode(function (node) {
  33972. var model = node.getModel();
  33973. node.setLayout([+model.get('x'), +model.get('y')]);
  33974. });
  33975. simpleLayoutEdge(graph);
  33976. };
  33977. /***/ },
  33978. /* 211 */
  33979. /***/ function(module, exports, __webpack_require__) {
  33980. var vec2 = __webpack_require__(10);
  33981. module.exports = function (graph) {
  33982. graph.eachEdge(function (edge) {
  33983. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  33984. var p1 = vec2.clone(edge.node1.getLayout());
  33985. var p2 = vec2.clone(edge.node2.getLayout());
  33986. var points = [p1, p2];
  33987. if (+curveness) {
  33988. points.push([
  33989. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness,
  33990. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness
  33991. ]);
  33992. }
  33993. edge.setLayout(points);
  33994. });
  33995. };
  33996. /***/ },
  33997. /* 212 */
  33998. /***/ function(module, exports, __webpack_require__) {
  33999. var circularLayoutHelper = __webpack_require__(213);
  34000. module.exports = function (ecModel) {
  34001. ecModel.eachSeriesByType('graph', function (seriesModel) {
  34002. if (seriesModel.get('layout') === 'circular') {
  34003. circularLayoutHelper(seriesModel);
  34004. }
  34005. });
  34006. };
  34007. /***/ },
  34008. /* 213 */
  34009. /***/ function(module, exports, __webpack_require__) {
  34010. var vec2 = __webpack_require__(10);
  34011. module.exports = function (seriesModel) {
  34012. var coordSys = seriesModel.coordinateSystem;
  34013. if (coordSys && coordSys.type !== 'view') {
  34014. return;
  34015. }
  34016. var rect = coordSys.getBoundingRect();
  34017. var nodeData = seriesModel.getData();
  34018. var graph = nodeData.graph;
  34019. var angle = 0;
  34020. var sum = nodeData.getSum('value');
  34021. var unitAngle = Math.PI * 2 / (sum || nodeData.count());
  34022. var cx = rect.width / 2 + rect.x;
  34023. var cy = rect.height / 2 + rect.y;
  34024. var r = Math.min(rect.width, rect.height) / 2;
  34025. graph.eachNode(function (node) {
  34026. var value = node.getValue('value');
  34027. angle += unitAngle * (sum ? value : 1) / 2;
  34028. node.setLayout([
  34029. r * Math.cos(angle) + cx,
  34030. r * Math.sin(angle) + cy
  34031. ]);
  34032. angle += unitAngle * (sum ? value : 1) / 2;
  34033. });
  34034. nodeData.setLayout({
  34035. cx: cx,
  34036. cy: cy
  34037. });
  34038. graph.eachEdge(function (edge) {
  34039. var curveness = edge.getModel().get('lineStyle.normal.curveness') || 0;
  34040. var p1 = vec2.clone(edge.node1.getLayout());
  34041. var p2 = vec2.clone(edge.node2.getLayout());
  34042. var cp1;
  34043. var x12 = (p1[0] + p2[0]) / 2;
  34044. var y12 = (p1[1] + p2[1]) / 2;
  34045. if (+curveness) {
  34046. curveness *= 3;
  34047. cp1 = [
  34048. cx * curveness + x12 * (1 - curveness),
  34049. cy * curveness + y12 * (1 - curveness)
  34050. ];
  34051. }
  34052. edge.setLayout([p1, p2, cp1]);
  34053. });
  34054. };
  34055. /***/ },
  34056. /* 214 */
  34057. /***/ function(module, exports, __webpack_require__) {
  34058. var forceHelper = __webpack_require__(215);
  34059. var numberUtil = __webpack_require__(7);
  34060. var simpleLayoutHelper = __webpack_require__(210);
  34061. var circularLayoutHelper = __webpack_require__(213);
  34062. var vec2 = __webpack_require__(10);
  34063. var zrUtil = __webpack_require__(4);
  34064. module.exports = function (ecModel) {
  34065. ecModel.eachSeriesByType('graph', function (graphSeries) {
  34066. var coordSys = graphSeries.coordinateSystem;
  34067. if (coordSys && coordSys.type !== 'view') {
  34068. return;
  34069. }
  34070. if (graphSeries.get('layout') === 'force') {
  34071. var preservedPoints = graphSeries.preservedPoints || {};
  34072. var graph = graphSeries.getGraph();
  34073. var nodeData = graph.data;
  34074. var edgeData = graph.edgeData;
  34075. var forceModel = graphSeries.getModel('force');
  34076. var initLayout = forceModel.get('initLayout');
  34077. if (graphSeries.preservedPoints) {
  34078. nodeData.each(function (idx) {
  34079. var id = nodeData.getId(idx);
  34080. nodeData.setItemLayout(idx, preservedPoints[id] || [NaN, NaN]);
  34081. });
  34082. }
  34083. else if (!initLayout || initLayout === 'none') {
  34084. simpleLayoutHelper(graphSeries);
  34085. }
  34086. else if (initLayout === 'circular') {
  34087. circularLayoutHelper(graphSeries);
  34088. }
  34089. var nodeDataExtent = nodeData.getDataExtent('value');
  34090. var edgeDataExtent = edgeData.getDataExtent('value');
  34091. // var edgeDataExtent = edgeData.getDataExtent('value');
  34092. var repulsion = forceModel.get('repulsion');
  34093. var edgeLength = forceModel.get('edgeLength');
  34094. if (!zrUtil.isArray(repulsion)) {
  34095. repulsion = [repulsion, repulsion];
  34096. }
  34097. if (!zrUtil.isArray(edgeLength)) {
  34098. edgeLength = [edgeLength, edgeLength];
  34099. }
  34100. // Larger value has smaller length
  34101. edgeLength = [edgeLength[1], edgeLength[0]];
  34102. var nodes = nodeData.mapArray('value', function (value, idx) {
  34103. var point = nodeData.getItemLayout(idx);
  34104. // var w = numberUtil.linearMap(value, nodeDataExtent, [0, 50]);
  34105. var rep = numberUtil.linearMap(value, nodeDataExtent, repulsion);
  34106. if (isNaN(rep)) {
  34107. rep = (repulsion[0] + repulsion[1]) / 2;
  34108. }
  34109. return {
  34110. w: rep,
  34111. rep: rep,
  34112. p: (!point || isNaN(point[0]) || isNaN(point[1])) ? null : point
  34113. };
  34114. });
  34115. var edges = edgeData.mapArray('value', function (value, idx) {
  34116. var edge = graph.getEdgeByIndex(idx);
  34117. var d = numberUtil.linearMap(value, edgeDataExtent, edgeLength);
  34118. if (isNaN(d)) {
  34119. d = (edgeLength[0] + edgeLength[1]) / 2;
  34120. }
  34121. return {
  34122. n1: nodes[edge.node1.dataIndex],
  34123. n2: nodes[edge.node2.dataIndex],
  34124. d: d,
  34125. curveness: edge.getModel().get('lineStyle.normal.curveness') || 0
  34126. };
  34127. });
  34128. var coordSys = graphSeries.coordinateSystem;
  34129. var rect = coordSys.getBoundingRect();
  34130. var forceInstance = forceHelper(nodes, edges, {
  34131. rect: rect,
  34132. gravity: forceModel.get('gravity')
  34133. });
  34134. var oldStep = forceInstance.step;
  34135. forceInstance.step = function (cb) {
  34136. for (var i = 0, l = nodes.length; i < l; i++) {
  34137. if (nodes[i].fixed) {
  34138. // Write back to layout instance
  34139. vec2.copy(nodes[i].p, graph.getNodeByIndex(i).getLayout());
  34140. }
  34141. }
  34142. oldStep(function (nodes, edges, stopped) {
  34143. for (var i = 0, l = nodes.length; i < l; i++) {
  34144. if (!nodes[i].fixed) {
  34145. graph.getNodeByIndex(i).setLayout(nodes[i].p);
  34146. }
  34147. preservedPoints[nodeData.getId(i)] = nodes[i].p;
  34148. }
  34149. for (var i = 0, l = edges.length; i < l; i++) {
  34150. var e = edges[i];
  34151. var edge = graph.getEdgeByIndex(i);
  34152. var p1 = e.n1.p;
  34153. var p2 = e.n2.p;
  34154. var points = edge.getLayout();
  34155. points = points ? points.slice() : [];
  34156. points[0] = points[0] || [];
  34157. points[1] = points[1] || [];
  34158. vec2.copy(points[0], p1);
  34159. vec2.copy(points[1], p2);
  34160. if (+e.curveness) {
  34161. points[2] = [
  34162. (p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness,
  34163. (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness
  34164. ];
  34165. }
  34166. edge.setLayout(points);
  34167. }
  34168. // Update layout
  34169. cb && cb(stopped);
  34170. });
  34171. };
  34172. graphSeries.forceLayout = forceInstance;
  34173. graphSeries.preservedPoints = preservedPoints;
  34174. // Step to get the layout
  34175. forceInstance.step();
  34176. }
  34177. else {
  34178. // Remove prev injected forceLayout instance
  34179. graphSeries.forceLayout = null;
  34180. }
  34181. });
  34182. };
  34183. /***/ },
  34184. /* 215 */
  34185. /***/ function(module, exports, __webpack_require__) {
  34186. var vec2 = __webpack_require__(10);
  34187. var scaleAndAdd = vec2.scaleAndAdd;
  34188. // function adjacentNode(n, e) {
  34189. // return e.n1 === n ? e.n2 : e.n1;
  34190. // }
  34191. module.exports = function (nodes, edges, opts) {
  34192. var rect = opts.rect;
  34193. var width = rect.width;
  34194. var height = rect.height;
  34195. var center = [rect.x + width / 2, rect.y + height / 2];
  34196. // var scale = opts.scale || 1;
  34197. var gravity = opts.gravity == null ? 0.1 : opts.gravity;
  34198. // for (var i = 0; i < edges.length; i++) {
  34199. // var e = edges[i];
  34200. // var n1 = e.n1;
  34201. // var n2 = e.n2;
  34202. // n1.edges = n1.edges || [];
  34203. // n2.edges = n2.edges || [];
  34204. // n1.edges.push(e);
  34205. // n2.edges.push(e);
  34206. // }
  34207. // Init position
  34208. for (var i = 0; i < nodes.length; i++) {
  34209. var n = nodes[i];
  34210. if (!n.p) {
  34211. // Use the position from first adjecent node with defined position
  34212. // Or use a random position
  34213. // From d3
  34214. // if (n.edges) {
  34215. // var j = -1;
  34216. // while (++j < n.edges.length) {
  34217. // var e = n.edges[j];
  34218. // var other = adjacentNode(n, e);
  34219. // if (other.p) {
  34220. // n.p = vec2.clone(other.p);
  34221. // break;
  34222. // }
  34223. // }
  34224. // }
  34225. // if (!n.p) {
  34226. n.p = vec2.create(
  34227. width * (Math.random() - 0.5) + center[0],
  34228. height * (Math.random() - 0.5) + center[1]
  34229. );
  34230. // }
  34231. }
  34232. n.pp = vec2.clone(n.p);
  34233. n.edges = null;
  34234. }
  34235. // Formula in 'Graph Drawing by Force-directed Placement'
  34236. // var k = scale * Math.sqrt(width * height / nodes.length);
  34237. // var k2 = k * k;
  34238. var friction = 0.6;
  34239. return {
  34240. warmUp: function () {
  34241. friction = 0.5;
  34242. },
  34243. setFixed: function (idx) {
  34244. nodes[idx].fixed = true;
  34245. },
  34246. setUnfixed: function (idx) {
  34247. nodes[idx].fixed = false;
  34248. },
  34249. step: function (cb) {
  34250. var v12 = [];
  34251. var nLen = nodes.length;
  34252. for (var i = 0; i < edges.length; i++) {
  34253. var e = edges[i];
  34254. var n1 = e.n1;
  34255. var n2 = e.n2;
  34256. vec2.sub(v12, n2.p, n1.p);
  34257. var d = vec2.len(v12) - e.d;
  34258. var w = n2.w / (n1.w + n2.w);
  34259. vec2.normalize(v12, v12);
  34260. !n1.fixed && scaleAndAdd(n1.p, n1.p, v12, w * d * friction);
  34261. !n2.fixed && scaleAndAdd(n2.p, n2.p, v12, -(1 - w) * d * friction);
  34262. }
  34263. // Gravity
  34264. for (var i = 0; i < nLen; i++) {
  34265. var n = nodes[i];
  34266. if (!n.fixed) {
  34267. vec2.sub(v12, center, n.p);
  34268. // var d = vec2.len(v12);
  34269. // vec2.scale(v12, v12, 1 / d);
  34270. // var gravityFactor = gravity;
  34271. vec2.scaleAndAdd(n.p, n.p, v12, gravity * friction);
  34272. }
  34273. }
  34274. // Repulsive
  34275. // PENDING
  34276. for (var i = 0; i < nLen; i++) {
  34277. var n1 = nodes[i];
  34278. for (var j = i + 1; j < nLen; j++) {
  34279. var n2 = nodes[j];
  34280. vec2.sub(v12, n2.p, n1.p);
  34281. var d = vec2.len(v12);
  34282. if (d === 0) {
  34283. // Random repulse
  34284. vec2.set(v12, Math.random() - 0.5, Math.random() - 0.5);
  34285. d = 1;
  34286. }
  34287. var repFact = (n1.rep + n2.rep) / d / d;
  34288. !n1.fixed && scaleAndAdd(n1.pp, n1.pp, v12, repFact);
  34289. !n2.fixed && scaleAndAdd(n2.pp, n2.pp, v12, -repFact);
  34290. }
  34291. }
  34292. var v = [];
  34293. for (var i = 0; i < nLen; i++) {
  34294. var n = nodes[i];
  34295. if (!n.fixed) {
  34296. vec2.sub(v, n.p, n.pp);
  34297. vec2.scaleAndAdd(n.p, n.p, v, friction);
  34298. vec2.copy(n.pp, n.p);
  34299. }
  34300. }
  34301. friction = friction * 0.992;
  34302. cb && cb(nodes, edges, friction < 0.01);
  34303. }
  34304. };
  34305. };
  34306. /***/ },
  34307. /* 216 */
  34308. /***/ function(module, exports, __webpack_require__) {
  34309. // FIXME Where to create the simple view coordinate system
  34310. var View = __webpack_require__(170);
  34311. var layout = __webpack_require__(21);
  34312. var bbox = __webpack_require__(51);
  34313. function getViewRect(seriesModel, api, aspect) {
  34314. var option = seriesModel.getBoxLayoutParams();
  34315. option.aspect = aspect;
  34316. return layout.getLayoutRect(option, {
  34317. width: api.getWidth(),
  34318. height: api.getHeight()
  34319. });
  34320. }
  34321. module.exports = function (ecModel, api) {
  34322. var viewList = [];
  34323. ecModel.eachSeriesByType('graph', function (seriesModel) {
  34324. var coordSysType = seriesModel.get('coordinateSystem');
  34325. if (!coordSysType || coordSysType === 'view') {
  34326. var data = seriesModel.getData();
  34327. var positions = data.mapArray(function (idx) {
  34328. var itemModel = data.getItemModel(idx);
  34329. return [+itemModel.get('x'), +itemModel.get('y')];
  34330. });
  34331. var min = [];
  34332. var max = [];
  34333. bbox.fromPoints(positions, min, max);
  34334. // If width or height is 0
  34335. if (max[0] - min[0] === 0) {
  34336. max[0] += 1;
  34337. min[0] -= 1;
  34338. }
  34339. if (max[1] - min[1] === 0) {
  34340. max[1] += 1;
  34341. min[1] -= 1;
  34342. }
  34343. var aspect = (max[0] - min[0]) / (max[1] - min[1]);
  34344. // FIXME If get view rect after data processed?
  34345. var viewRect = getViewRect(seriesModel, api, aspect);
  34346. // Position may be NaN, use view rect instead
  34347. if (isNaN(aspect)) {
  34348. min = [viewRect.x, viewRect.y];
  34349. max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
  34350. }
  34351. var bbWidth = max[0] - min[0];
  34352. var bbHeight = max[1] - min[1];
  34353. var viewWidth = viewRect.width;
  34354. var viewHeight = viewRect.height;
  34355. var viewCoordSys = seriesModel.coordinateSystem = new View();
  34356. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  34357. viewCoordSys.setBoundingRect(
  34358. min[0], min[1], bbWidth, bbHeight
  34359. );
  34360. viewCoordSys.setViewRect(
  34361. viewRect.x, viewRect.y, viewWidth, viewHeight
  34362. );
  34363. // Update roam info
  34364. viewCoordSys.setCenter(seriesModel.get('center'));
  34365. viewCoordSys.setZoom(seriesModel.get('zoom'));
  34366. viewList.push(viewCoordSys);
  34367. }
  34368. });
  34369. return viewList;
  34370. };
  34371. /***/ },
  34372. /* 217 */
  34373. /***/ function(module, exports, __webpack_require__) {
  34374. __webpack_require__(218);
  34375. __webpack_require__(219);
  34376. /***/ },
  34377. /* 218 */
  34378. /***/ function(module, exports, __webpack_require__) {
  34379. var List = __webpack_require__(98);
  34380. var SeriesModel = __webpack_require__(28);
  34381. var zrUtil = __webpack_require__(4);
  34382. var GaugeSeries = SeriesModel.extend({
  34383. type: 'series.gauge',
  34384. getInitialData: function (option, ecModel) {
  34385. var list = new List(['value'], this);
  34386. var dataOpt = option.data || [];
  34387. if (!zrUtil.isArray(dataOpt)) {
  34388. dataOpt = [dataOpt];
  34389. }
  34390. // Only use the first data item
  34391. list.initData(dataOpt);
  34392. return list;
  34393. },
  34394. defaultOption: {
  34395. zlevel: 0,
  34396. z: 2,
  34397. // 默认全局居中
  34398. center: ['50%', '50%'],
  34399. legendHoverLink: true,
  34400. radius: '75%',
  34401. startAngle: 225,
  34402. endAngle: -45,
  34403. clockwise: true,
  34404. // 最小值
  34405. min: 0,
  34406. // 最大值
  34407. max: 100,
  34408. // 分割段数,默认为10
  34409. splitNumber: 10,
  34410. // 坐标轴线
  34411. axisLine: {
  34412. // 默认显示,属性show控制显示与否
  34413. show: true,
  34414. lineStyle: { // 属性lineStyle控制线条样式
  34415. color: [[0.2, '#91c7ae'], [0.8, '#63869e'], [1, '#c23531']],
  34416. width: 30
  34417. }
  34418. },
  34419. // 分隔线
  34420. splitLine: {
  34421. // 默认显示,属性show控制显示与否
  34422. show: true,
  34423. // 属性length控制线长
  34424. length: 30,
  34425. // 属性lineStyle(详见lineStyle)控制线条样式
  34426. lineStyle: {
  34427. color: '#eee',
  34428. width: 2,
  34429. type: 'solid'
  34430. }
  34431. },
  34432. // 坐标轴小标记
  34433. axisTick: {
  34434. // 属性show控制显示与否,默认不显示
  34435. show: true,
  34436. // 每份split细分多少段
  34437. splitNumber: 5,
  34438. // 属性length控制线长
  34439. length: 8,
  34440. // 属性lineStyle控制线条样式
  34441. lineStyle: {
  34442. color: '#eee',
  34443. width: 1,
  34444. type: 'solid'
  34445. }
  34446. },
  34447. axisLabel: {
  34448. show: true,
  34449. distance: 5,
  34450. // formatter: null,
  34451. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  34452. color: 'auto'
  34453. }
  34454. },
  34455. pointer: {
  34456. show: true,
  34457. length: '80%',
  34458. width: 8
  34459. },
  34460. itemStyle: {
  34461. normal: {
  34462. color: 'auto'
  34463. }
  34464. },
  34465. title: {
  34466. show: true,
  34467. // x, y,单位px
  34468. offsetCenter: [0, '-40%'],
  34469. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  34470. textStyle: {
  34471. color: '#333',
  34472. fontSize: 15
  34473. }
  34474. },
  34475. detail: {
  34476. show: true,
  34477. backgroundColor: 'rgba(0,0,0,0)',
  34478. borderWidth: 0,
  34479. borderColor: '#ccc',
  34480. width: 100,
  34481. height: 40,
  34482. // x, y,单位px
  34483. offsetCenter: [0, '40%'],
  34484. // formatter: null,
  34485. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  34486. textStyle: {
  34487. color: 'auto',
  34488. fontSize: 30
  34489. }
  34490. }
  34491. }
  34492. });
  34493. module.exports = GaugeSeries;
  34494. /***/ },
  34495. /* 219 */
  34496. /***/ function(module, exports, __webpack_require__) {
  34497. var PointerPath = __webpack_require__(220);
  34498. var graphic = __webpack_require__(43);
  34499. var numberUtil = __webpack_require__(7);
  34500. var parsePercent = numberUtil.parsePercent;
  34501. function parsePosition(seriesModel, api) {
  34502. var center = seriesModel.get('center');
  34503. var width = api.getWidth();
  34504. var height = api.getHeight();
  34505. var size = Math.min(width, height);
  34506. var cx = parsePercent(center[0], api.getWidth());
  34507. var cy = parsePercent(center[1], api.getHeight());
  34508. var r = parsePercent(seriesModel.get('radius'), size / 2);
  34509. return {
  34510. cx: cx,
  34511. cy: cy,
  34512. r: r
  34513. };
  34514. }
  34515. function formatLabel(label, labelFormatter) {
  34516. if (labelFormatter) {
  34517. if (typeof labelFormatter === 'string') {
  34518. label = labelFormatter.replace('{value}', label != null ? label : '');
  34519. }
  34520. else if (typeof labelFormatter === 'function') {
  34521. label = labelFormatter(label);
  34522. }
  34523. }
  34524. return label;
  34525. }
  34526. var PI2 = Math.PI * 2;
  34527. var GaugeView = __webpack_require__(42).extend({
  34528. type: 'gauge',
  34529. render: function (seriesModel, ecModel, api) {
  34530. this.group.removeAll();
  34531. var colorList = seriesModel.get('axisLine.lineStyle.color');
  34532. var posInfo = parsePosition(seriesModel, api);
  34533. this._renderMain(
  34534. seriesModel, ecModel, api, colorList, posInfo
  34535. );
  34536. },
  34537. dispose: function () {},
  34538. _renderMain: function (seriesModel, ecModel, api, colorList, posInfo) {
  34539. var group = this.group;
  34540. var axisLineModel = seriesModel.getModel('axisLine');
  34541. var lineStyleModel = axisLineModel.getModel('lineStyle');
  34542. var clockwise = seriesModel.get('clockwise');
  34543. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  34544. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  34545. var angleRangeSpan = (endAngle - startAngle) % PI2;
  34546. var prevEndAngle = startAngle;
  34547. var axisLineWidth = lineStyleModel.get('width');
  34548. for (var i = 0; i < colorList.length; i++) {
  34549. // Clamp
  34550. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  34551. var endAngle = startAngle + angleRangeSpan * percent;
  34552. var sector = new graphic.Sector({
  34553. shape: {
  34554. startAngle: prevEndAngle,
  34555. endAngle: endAngle,
  34556. cx: posInfo.cx,
  34557. cy: posInfo.cy,
  34558. clockwise: clockwise,
  34559. r0: posInfo.r - axisLineWidth,
  34560. r: posInfo.r
  34561. },
  34562. silent: true
  34563. });
  34564. sector.setStyle({
  34565. fill: colorList[i][1]
  34566. });
  34567. sector.setStyle(lineStyleModel.getLineStyle(
  34568. // Because we use sector to simulate arc
  34569. // so the properties for stroking are useless
  34570. ['color', 'borderWidth', 'borderColor']
  34571. ));
  34572. group.add(sector);
  34573. prevEndAngle = endAngle;
  34574. }
  34575. var getColor = function (percent) {
  34576. // Less than 0
  34577. if (percent <= 0) {
  34578. return colorList[0][1];
  34579. }
  34580. for (var i = 0; i < colorList.length; i++) {
  34581. if (colorList[i][0] >= percent
  34582. && (i === 0 ? 0 : colorList[i - 1][0]) < percent
  34583. ) {
  34584. return colorList[i][1];
  34585. }
  34586. }
  34587. // More than 1
  34588. return colorList[i - 1][1];
  34589. };
  34590. if (!clockwise) {
  34591. var tmp = startAngle;
  34592. startAngle = endAngle;
  34593. endAngle = tmp;
  34594. }
  34595. this._renderTicks(
  34596. seriesModel, ecModel, api, getColor, posInfo,
  34597. startAngle, endAngle, clockwise
  34598. );
  34599. this._renderPointer(
  34600. seriesModel, ecModel, api, getColor, posInfo,
  34601. startAngle, endAngle, clockwise
  34602. );
  34603. this._renderTitle(
  34604. seriesModel, ecModel, api, getColor, posInfo
  34605. );
  34606. this._renderDetail(
  34607. seriesModel, ecModel, api, getColor, posInfo
  34608. );
  34609. },
  34610. _renderTicks: function (
  34611. seriesModel, ecModel, api, getColor, posInfo,
  34612. startAngle, endAngle, clockwise
  34613. ) {
  34614. var group = this.group;
  34615. var cx = posInfo.cx;
  34616. var cy = posInfo.cy;
  34617. var r = posInfo.r;
  34618. var minVal = seriesModel.get('min');
  34619. var maxVal = seriesModel.get('max');
  34620. var splitLineModel = seriesModel.getModel('splitLine');
  34621. var tickModel = seriesModel.getModel('axisTick');
  34622. var labelModel = seriesModel.getModel('axisLabel');
  34623. var splitNumber = seriesModel.get('splitNumber');
  34624. var subSplitNumber = tickModel.get('splitNumber');
  34625. var splitLineLen = parsePercent(
  34626. splitLineModel.get('length'), r
  34627. );
  34628. var tickLen = parsePercent(
  34629. tickModel.get('length'), r
  34630. );
  34631. var angle = startAngle;
  34632. var step = (endAngle - startAngle) / splitNumber;
  34633. var subStep = step / subSplitNumber;
  34634. var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
  34635. var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
  34636. var textStyleModel = labelModel.getModel('textStyle');
  34637. for (var i = 0; i <= splitNumber; i++) {
  34638. var unitX = Math.cos(angle);
  34639. var unitY = Math.sin(angle);
  34640. // Split line
  34641. if (splitLineModel.get('show')) {
  34642. var splitLine = new graphic.Line({
  34643. shape: {
  34644. x1: unitX * r + cx,
  34645. y1: unitY * r + cy,
  34646. x2: unitX * (r - splitLineLen) + cx,
  34647. y2: unitY * (r - splitLineLen) + cy
  34648. },
  34649. style: splitLineStyle,
  34650. silent: true
  34651. });
  34652. if (splitLineStyle.stroke === 'auto') {
  34653. splitLine.setStyle({
  34654. stroke: getColor(i / splitNumber)
  34655. });
  34656. }
  34657. group.add(splitLine);
  34658. }
  34659. // Label
  34660. if (labelModel.get('show')) {
  34661. var label = formatLabel(
  34662. numberUtil.round(i / splitNumber * (maxVal - minVal) + minVal),
  34663. labelModel.get('formatter')
  34664. );
  34665. var distance = labelModel.get('distance');
  34666. var text = new graphic.Text({
  34667. style: {
  34668. text: label,
  34669. x: unitX * (r - splitLineLen - distance) + cx,
  34670. y: unitY * (r - splitLineLen - distance) + cy,
  34671. fill: textStyleModel.getTextColor(),
  34672. textFont: textStyleModel.getFont(),
  34673. textVerticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
  34674. textAlign: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
  34675. },
  34676. silent: true
  34677. });
  34678. if (text.style.fill === 'auto') {
  34679. text.setStyle({
  34680. fill: getColor(i / splitNumber)
  34681. });
  34682. }
  34683. group.add(text);
  34684. }
  34685. // Axis tick
  34686. if (tickModel.get('show') && i !== splitNumber) {
  34687. for (var j = 0; j <= subSplitNumber; j++) {
  34688. var unitX = Math.cos(angle);
  34689. var unitY = Math.sin(angle);
  34690. var tickLine = new graphic.Line({
  34691. shape: {
  34692. x1: unitX * r + cx,
  34693. y1: unitY * r + cy,
  34694. x2: unitX * (r - tickLen) + cx,
  34695. y2: unitY * (r - tickLen) + cy
  34696. },
  34697. silent: true,
  34698. style: tickLineStyle
  34699. });
  34700. if (tickLineStyle.stroke === 'auto') {
  34701. tickLine.setStyle({
  34702. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  34703. });
  34704. }
  34705. group.add(tickLine);
  34706. angle += subStep;
  34707. }
  34708. angle -= subStep;
  34709. }
  34710. else {
  34711. angle += step;
  34712. }
  34713. }
  34714. },
  34715. _renderPointer: function (
  34716. seriesModel, ecModel, api, getColor, posInfo,
  34717. startAngle, endAngle, clockwise
  34718. ) {
  34719. var valueExtent = [+seriesModel.get('min'), +seriesModel.get('max')];
  34720. var angleExtent = [startAngle, endAngle];
  34721. var data = seriesModel.getData();
  34722. var oldData = this._data;
  34723. var group = this.group;
  34724. data.diff(oldData)
  34725. .add(function (idx) {
  34726. var pointer = new PointerPath({
  34727. shape: {
  34728. angle: startAngle
  34729. }
  34730. });
  34731. graphic.updateProps(pointer, {
  34732. shape: {
  34733. angle: numberUtil.linearMap(data.get('value', idx), valueExtent, angleExtent, true)
  34734. }
  34735. }, seriesModel);
  34736. group.add(pointer);
  34737. data.setItemGraphicEl(idx, pointer);
  34738. })
  34739. .update(function (newIdx, oldIdx) {
  34740. var pointer = oldData.getItemGraphicEl(oldIdx);
  34741. graphic.updateProps(pointer, {
  34742. shape: {
  34743. angle: numberUtil.linearMap(data.get('value', newIdx), valueExtent, angleExtent, true)
  34744. }
  34745. }, seriesModel);
  34746. group.add(pointer);
  34747. data.setItemGraphicEl(newIdx, pointer);
  34748. })
  34749. .remove(function (idx) {
  34750. var pointer = oldData.getItemGraphicEl(idx);
  34751. group.remove(pointer);
  34752. })
  34753. .execute();
  34754. data.eachItemGraphicEl(function (pointer, idx) {
  34755. var itemModel = data.getItemModel(idx);
  34756. var pointerModel = itemModel.getModel('pointer');
  34757. pointer.setShape({
  34758. x: posInfo.cx,
  34759. y: posInfo.cy,
  34760. width: parsePercent(
  34761. pointerModel.get('width'), posInfo.r
  34762. ),
  34763. r: parsePercent(pointerModel.get('length'), posInfo.r)
  34764. });
  34765. pointer.useStyle(itemModel.getModel('itemStyle.normal').getItemStyle());
  34766. if (pointer.style.fill === 'auto') {
  34767. pointer.setStyle('fill', getColor(
  34768. (data.get('value', idx) - valueExtent[0]) / (valueExtent[1] - valueExtent[0])
  34769. ));
  34770. }
  34771. graphic.setHoverStyle(
  34772. pointer, itemModel.getModel('itemStyle.emphasis').getItemStyle()
  34773. );
  34774. });
  34775. this._data = data;
  34776. },
  34777. _renderTitle: function (
  34778. seriesModel, ecModel, api, getColor, posInfo
  34779. ) {
  34780. var titleModel = seriesModel.getModel('title');
  34781. if (titleModel.get('show')) {
  34782. var textStyleModel = titleModel.getModel('textStyle');
  34783. var offsetCenter = titleModel.get('offsetCenter');
  34784. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  34785. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  34786. var text = new graphic.Text({
  34787. style: {
  34788. x: x,
  34789. y: y,
  34790. // FIXME First data name ?
  34791. text: seriesModel.getData().getName(0),
  34792. fill: textStyleModel.getTextColor(),
  34793. textFont: textStyleModel.getFont(),
  34794. textAlign: 'center',
  34795. textVerticalAlign: 'middle'
  34796. }
  34797. });
  34798. this.group.add(text);
  34799. }
  34800. },
  34801. _renderDetail: function (
  34802. seriesModel, ecModel, api, getColor, posInfo
  34803. ) {
  34804. var detailModel = seriesModel.getModel('detail');
  34805. var minVal = seriesModel.get('min');
  34806. var maxVal = seriesModel.get('max');
  34807. if (detailModel.get('show')) {
  34808. var textStyleModel = detailModel.getModel('textStyle');
  34809. var offsetCenter = detailModel.get('offsetCenter');
  34810. var x = posInfo.cx + parsePercent(offsetCenter[0], posInfo.r);
  34811. var y = posInfo.cy + parsePercent(offsetCenter[1], posInfo.r);
  34812. var width = parsePercent(detailModel.get('width'), posInfo.r);
  34813. var height = parsePercent(detailModel.get('height'), posInfo.r);
  34814. var value = seriesModel.getData().get('value', 0);
  34815. var rect = new graphic.Rect({
  34816. shape: {
  34817. x: x - width / 2,
  34818. y: y - height / 2,
  34819. width: width,
  34820. height: height
  34821. },
  34822. style: {
  34823. text: formatLabel(
  34824. // FIXME First data name ?
  34825. value, detailModel.get('formatter')
  34826. ),
  34827. fill: detailModel.get('backgroundColor'),
  34828. textFill: textStyleModel.getTextColor(),
  34829. textFont: textStyleModel.getFont()
  34830. }
  34831. });
  34832. if (rect.style.textFill === 'auto') {
  34833. rect.setStyle('textFill', getColor(
  34834. numberUtil.linearMap(value, [minVal, maxVal], [0, 1], true)
  34835. ));
  34836. }
  34837. rect.setStyle(detailModel.getItemStyle(['color']));
  34838. this.group.add(rect);
  34839. }
  34840. }
  34841. });
  34842. module.exports = GaugeView;
  34843. /***/ },
  34844. /* 220 */
  34845. /***/ function(module, exports, __webpack_require__) {
  34846. module.exports = __webpack_require__(45).extend({
  34847. type: 'echartsGaugePointer',
  34848. shape: {
  34849. angle: 0,
  34850. width: 10,
  34851. r: 10,
  34852. x: 0,
  34853. y: 0
  34854. },
  34855. buildPath: function (ctx, shape) {
  34856. var mathCos = Math.cos;
  34857. var mathSin = Math.sin;
  34858. var r = shape.r;
  34859. var width = shape.width;
  34860. var angle = shape.angle;
  34861. var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2);
  34862. var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2);
  34863. angle = shape.angle - Math.PI / 2;
  34864. ctx.moveTo(x, y);
  34865. ctx.lineTo(
  34866. shape.x + mathCos(angle) * width,
  34867. shape.y + mathSin(angle) * width
  34868. );
  34869. ctx.lineTo(
  34870. shape.x + mathCos(shape.angle) * r,
  34871. shape.y + mathSin(shape.angle) * r
  34872. );
  34873. ctx.lineTo(
  34874. shape.x - mathCos(angle) * width,
  34875. shape.y - mathSin(angle) * width
  34876. );
  34877. ctx.lineTo(x, y);
  34878. return;
  34879. }
  34880. });
  34881. /***/ },
  34882. /* 221 */
  34883. /***/ function(module, exports, __webpack_require__) {
  34884. var zrUtil = __webpack_require__(4);
  34885. var echarts = __webpack_require__(1);
  34886. __webpack_require__(222);
  34887. __webpack_require__(223);
  34888. echarts.registerVisual(zrUtil.curry(__webpack_require__(145), 'funnel'));
  34889. echarts.registerLayout(__webpack_require__(224));
  34890. echarts.registerProcessor(zrUtil.curry(__webpack_require__(148), 'funnel'));
  34891. /***/ },
  34892. /* 222 */
  34893. /***/ function(module, exports, __webpack_require__) {
  34894. 'use strict';
  34895. var List = __webpack_require__(98);
  34896. var modelUtil = __webpack_require__(5);
  34897. var completeDimensions = __webpack_require__(103);
  34898. var FunnelSeries = __webpack_require__(1).extendSeriesModel({
  34899. type: 'series.funnel',
  34900. init: function (option) {
  34901. FunnelSeries.superApply(this, 'init', arguments);
  34902. // Enable legend selection for each data item
  34903. // Use a function instead of direct access because data reference may changed
  34904. this.legendDataProvider = function () {
  34905. return this._dataBeforeProcessed;
  34906. };
  34907. // Extend labelLine emphasis
  34908. this._defaultLabelLine(option);
  34909. },
  34910. getInitialData: function (option, ecModel) {
  34911. var dimensions = completeDimensions(['value'], option.data);
  34912. var list = new List(dimensions, this);
  34913. list.initData(option.data);
  34914. return list;
  34915. },
  34916. _defaultLabelLine: function (option) {
  34917. // Extend labelLine emphasis
  34918. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  34919. var labelLineNormalOpt = option.labelLine.normal;
  34920. var labelLineEmphasisOpt = option.labelLine.emphasis;
  34921. // Not show label line if `label.normal.show = false`
  34922. labelLineNormalOpt.show = labelLineNormalOpt.show
  34923. && option.label.normal.show;
  34924. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  34925. && option.label.emphasis.show;
  34926. },
  34927. defaultOption: {
  34928. zlevel: 0, // 一级层叠
  34929. z: 2, // 二级层叠
  34930. legendHoverLink: true,
  34931. left: 80,
  34932. top: 60,
  34933. right: 80,
  34934. bottom: 60,
  34935. // width: {totalWidth} - left - right,
  34936. // height: {totalHeight} - top - bottom,
  34937. // 默认取数据最小最大值
  34938. // min: 0,
  34939. // max: 100,
  34940. minSize: '0%',
  34941. maxSize: '100%',
  34942. sort: 'descending', // 'ascending', 'descending'
  34943. gap: 0,
  34944. funnelAlign: 'center',
  34945. label: {
  34946. normal: {
  34947. show: true,
  34948. position: 'outer'
  34949. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  34950. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  34951. },
  34952. emphasis: {
  34953. show: true
  34954. }
  34955. },
  34956. labelLine: {
  34957. normal: {
  34958. show: true,
  34959. length: 20,
  34960. lineStyle: {
  34961. // color: 各异,
  34962. width: 1,
  34963. type: 'solid'
  34964. }
  34965. },
  34966. emphasis: {}
  34967. },
  34968. itemStyle: {
  34969. normal: {
  34970. // color: 各异,
  34971. borderColor: '#fff',
  34972. borderWidth: 1
  34973. },
  34974. emphasis: {
  34975. // color: 各异,
  34976. }
  34977. }
  34978. }
  34979. });
  34980. module.exports = FunnelSeries;
  34981. /***/ },
  34982. /* 223 */
  34983. /***/ function(module, exports, __webpack_require__) {
  34984. var graphic = __webpack_require__(43);
  34985. var zrUtil = __webpack_require__(4);
  34986. /**
  34987. * Piece of pie including Sector, Label, LabelLine
  34988. * @constructor
  34989. * @extends {module:zrender/graphic/Group}
  34990. */
  34991. function FunnelPiece(data, idx) {
  34992. graphic.Group.call(this);
  34993. var polygon = new graphic.Polygon();
  34994. var labelLine = new graphic.Polyline();
  34995. var text = new graphic.Text();
  34996. this.add(polygon);
  34997. this.add(labelLine);
  34998. this.add(text);
  34999. this.updateData(data, idx, true);
  35000. // Hover to change label and labelLine
  35001. function onEmphasis() {
  35002. labelLine.ignore = labelLine.hoverIgnore;
  35003. text.ignore = text.hoverIgnore;
  35004. }
  35005. function onNormal() {
  35006. labelLine.ignore = labelLine.normalIgnore;
  35007. text.ignore = text.normalIgnore;
  35008. }
  35009. this.on('emphasis', onEmphasis)
  35010. .on('normal', onNormal)
  35011. .on('mouseover', onEmphasis)
  35012. .on('mouseout', onNormal);
  35013. }
  35014. var funnelPieceProto = FunnelPiece.prototype;
  35015. function getLabelStyle(data, idx, state, labelModel) {
  35016. var textStyleModel = labelModel.getModel('textStyle');
  35017. var position = labelModel.get('position');
  35018. var isLabelInside = position === 'inside' || position === 'inner' || position === 'center';
  35019. return {
  35020. fill: textStyleModel.getTextColor()
  35021. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  35022. textFont: textStyleModel.getFont(),
  35023. text: zrUtil.retrieve(
  35024. data.hostModel.getFormattedLabel(idx, state),
  35025. data.getName(idx)
  35026. )
  35027. };
  35028. }
  35029. var opacityAccessPath = ['itemStyle', 'normal', 'opacity'];
  35030. funnelPieceProto.updateData = function (data, idx, firstCreate) {
  35031. var polygon = this.childAt(0);
  35032. var seriesModel = data.hostModel;
  35033. var itemModel = data.getItemModel(idx);
  35034. var layout = data.getItemLayout(idx);
  35035. var opacity = data.getItemModel(idx).get(opacityAccessPath);
  35036. opacity = opacity == null ? 1 : opacity;
  35037. // Reset style
  35038. polygon.useStyle({});
  35039. if (firstCreate) {
  35040. polygon.setShape({
  35041. points: layout.points
  35042. });
  35043. polygon.setStyle({ opacity : 0 });
  35044. graphic.initProps(polygon, {
  35045. style: {
  35046. opacity: opacity
  35047. }
  35048. }, seriesModel, idx);
  35049. }
  35050. else {
  35051. graphic.updateProps(polygon, {
  35052. style: {
  35053. opacity: opacity
  35054. },
  35055. shape: {
  35056. points: layout.points
  35057. }
  35058. }, seriesModel, idx);
  35059. }
  35060. // Update common style
  35061. var itemStyleModel = itemModel.getModel('itemStyle');
  35062. var visualColor = data.getItemVisual(idx, 'color');
  35063. polygon.setStyle(
  35064. zrUtil.defaults(
  35065. {
  35066. lineJoin: 'round',
  35067. fill: visualColor
  35068. },
  35069. itemStyleModel.getModel('normal').getItemStyle(['opacity'])
  35070. )
  35071. );
  35072. polygon.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  35073. this._updateLabel(data, idx);
  35074. graphic.setHoverStyle(this);
  35075. };
  35076. funnelPieceProto._updateLabel = function (data, idx) {
  35077. var labelLine = this.childAt(1);
  35078. var labelText = this.childAt(2);
  35079. var seriesModel = data.hostModel;
  35080. var itemModel = data.getItemModel(idx);
  35081. var layout = data.getItemLayout(idx);
  35082. var labelLayout = layout.label;
  35083. var visualColor = data.getItemVisual(idx, 'color');
  35084. graphic.updateProps(labelLine, {
  35085. shape: {
  35086. points: labelLayout.linePoints || labelLayout.linePoints
  35087. }
  35088. }, seriesModel, idx);
  35089. graphic.updateProps(labelText, {
  35090. style: {
  35091. x: labelLayout.x,
  35092. y: labelLayout.y
  35093. }
  35094. }, seriesModel, idx);
  35095. labelText.attr({
  35096. style: {
  35097. textAlign: labelLayout.textAlign,
  35098. textVerticalAlign: labelLayout.verticalAlign,
  35099. textFont: labelLayout.font
  35100. },
  35101. rotation: labelLayout.rotation,
  35102. origin: [labelLayout.x, labelLayout.y],
  35103. z2: 10
  35104. });
  35105. var labelModel = itemModel.getModel('label.normal');
  35106. var labelHoverModel = itemModel.getModel('label.emphasis');
  35107. var labelLineModel = itemModel.getModel('labelLine.normal');
  35108. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  35109. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel));
  35110. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  35111. labelText.hoverIgnore = !labelHoverModel.get('show');
  35112. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  35113. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  35114. // Default use item visual color
  35115. labelLine.setStyle({
  35116. stroke: visualColor
  35117. });
  35118. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  35119. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel);
  35120. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  35121. };
  35122. zrUtil.inherits(FunnelPiece, graphic.Group);
  35123. var Funnel = __webpack_require__(42).extend({
  35124. type: 'funnel',
  35125. render: function (seriesModel, ecModel, api) {
  35126. var data = seriesModel.getData();
  35127. var oldData = this._data;
  35128. var group = this.group;
  35129. data.diff(oldData)
  35130. .add(function (idx) {
  35131. var funnelPiece = new FunnelPiece(data, idx);
  35132. data.setItemGraphicEl(idx, funnelPiece);
  35133. group.add(funnelPiece);
  35134. })
  35135. .update(function (newIdx, oldIdx) {
  35136. var piePiece = oldData.getItemGraphicEl(oldIdx);
  35137. piePiece.updateData(data, newIdx);
  35138. group.add(piePiece);
  35139. data.setItemGraphicEl(newIdx, piePiece);
  35140. })
  35141. .remove(function (idx) {
  35142. var piePiece = oldData.getItemGraphicEl(idx);
  35143. group.remove(piePiece);
  35144. })
  35145. .execute();
  35146. this._data = data;
  35147. },
  35148. remove: function () {
  35149. this.group.removeAll();
  35150. this._data = null;
  35151. },
  35152. dispose: function () {}
  35153. });
  35154. module.exports = Funnel;
  35155. /***/ },
  35156. /* 224 */
  35157. /***/ function(module, exports, __webpack_require__) {
  35158. var layout = __webpack_require__(21);
  35159. var number = __webpack_require__(7);
  35160. var parsePercent = number.parsePercent;
  35161. function getViewRect(seriesModel, api) {
  35162. return layout.getLayoutRect(
  35163. seriesModel.getBoxLayoutParams(), {
  35164. width: api.getWidth(),
  35165. height: api.getHeight()
  35166. }
  35167. );
  35168. }
  35169. function getSortedIndices(data, sort) {
  35170. var valueArr = data.mapArray('value', function (val) {
  35171. return val;
  35172. });
  35173. var indices = [];
  35174. var isAscending = sort === 'ascending';
  35175. for (var i = 0, len = data.count(); i < len; i++) {
  35176. indices[i] = i;
  35177. }
  35178. indices.sort(function (a, b) {
  35179. return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
  35180. });
  35181. return indices;
  35182. }
  35183. function labelLayout (data) {
  35184. data.each(function (idx) {
  35185. var itemModel = data.getItemModel(idx);
  35186. var labelModel = itemModel.getModel('label.normal');
  35187. var labelPosition = labelModel.get('position');
  35188. var labelLineModel = itemModel.getModel('labelLine.normal');
  35189. var layout = data.getItemLayout(idx);
  35190. var points = layout.points;
  35191. var isLabelInside = labelPosition === 'inner'
  35192. || labelPosition === 'inside' || labelPosition === 'center';
  35193. var textAlign;
  35194. var textX;
  35195. var textY;
  35196. var linePoints;
  35197. if (isLabelInside) {
  35198. textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
  35199. textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
  35200. textAlign = 'center';
  35201. linePoints = [
  35202. [textX, textY], [textX, textY]
  35203. ];
  35204. }
  35205. else {
  35206. var x1;
  35207. var y1;
  35208. var x2;
  35209. var labelLineLen = labelLineModel.get('length');
  35210. if (labelPosition === 'left') {
  35211. // Left side
  35212. x1 = (points[3][0] + points[0][0]) / 2;
  35213. y1 = (points[3][1] + points[0][1]) / 2;
  35214. x2 = x1 - labelLineLen;
  35215. textX = x2 - 5;
  35216. textAlign = 'right';
  35217. }
  35218. else {
  35219. // Right side
  35220. x1 = (points[1][0] + points[2][0]) / 2;
  35221. y1 = (points[1][1] + points[2][1]) / 2;
  35222. x2 = x1 + labelLineLen;
  35223. textX = x2 + 5;
  35224. textAlign = 'left';
  35225. }
  35226. var y2 = y1;
  35227. linePoints = [[x1, y1], [x2, y2]];
  35228. textY = y2;
  35229. }
  35230. layout.label = {
  35231. linePoints: linePoints,
  35232. x: textX,
  35233. y: textY,
  35234. verticalAlign: 'middle',
  35235. textAlign: textAlign,
  35236. inside: isLabelInside
  35237. };
  35238. });
  35239. }
  35240. module.exports = function (ecModel, api, payload) {
  35241. ecModel.eachSeriesByType('funnel', function (seriesModel) {
  35242. var data = seriesModel.getData();
  35243. var sort = seriesModel.get('sort');
  35244. var viewRect = getViewRect(seriesModel, api);
  35245. var indices = getSortedIndices(data, sort);
  35246. var sizeExtent = [
  35247. parsePercent(seriesModel.get('minSize'), viewRect.width),
  35248. parsePercent(seriesModel.get('maxSize'), viewRect.width)
  35249. ];
  35250. var dataExtent = data.getDataExtent('value');
  35251. var min = seriesModel.get('min');
  35252. var max = seriesModel.get('max');
  35253. if (min == null) {
  35254. min = Math.min(dataExtent[0], 0);
  35255. }
  35256. if (max == null) {
  35257. max = dataExtent[1];
  35258. }
  35259. var funnelAlign = seriesModel.get('funnelAlign');
  35260. var gap = seriesModel.get('gap');
  35261. var itemHeight = (viewRect.height - gap * (data.count() - 1)) / data.count();
  35262. var y = viewRect.y;
  35263. var getLinePoints = function (idx, offY) {
  35264. // End point index is data.count() and we assign it 0
  35265. var val = data.get('value', idx) || 0;
  35266. var itemWidth = number.linearMap(val, [min, max], sizeExtent, true);
  35267. var x0;
  35268. switch (funnelAlign) {
  35269. case 'left':
  35270. x0 = viewRect.x;
  35271. break;
  35272. case 'center':
  35273. x0 = viewRect.x + (viewRect.width - itemWidth) / 2;
  35274. break;
  35275. case 'right':
  35276. x0 = viewRect.x + viewRect.width - itemWidth;
  35277. break;
  35278. }
  35279. return [
  35280. [x0, offY],
  35281. [x0 + itemWidth, offY]
  35282. ];
  35283. };
  35284. if (sort === 'ascending') {
  35285. // From bottom to top
  35286. itemHeight = -itemHeight;
  35287. gap = -gap;
  35288. y += viewRect.height;
  35289. indices = indices.reverse();
  35290. }
  35291. for (var i = 0; i < indices.length; i++) {
  35292. var idx = indices[i];
  35293. var nextIdx = indices[i + 1];
  35294. var start = getLinePoints(idx, y);
  35295. var end = getLinePoints(nextIdx, y + itemHeight);
  35296. y += itemHeight + gap;
  35297. data.setItemLayout(idx, {
  35298. points: start.concat(end.slice().reverse())
  35299. });
  35300. }
  35301. labelLayout(data);
  35302. });
  35303. };
  35304. /***/ },
  35305. /* 225 */
  35306. /***/ function(module, exports, __webpack_require__) {
  35307. var echarts = __webpack_require__(1);
  35308. __webpack_require__(226);
  35309. __webpack_require__(237);
  35310. __webpack_require__(238);
  35311. echarts.registerVisual(__webpack_require__(239));
  35312. /***/ },
  35313. /* 226 */
  35314. /***/ function(module, exports, __webpack_require__) {
  35315. __webpack_require__(227);
  35316. __webpack_require__(230);
  35317. __webpack_require__(232);
  35318. var echarts = __webpack_require__(1);
  35319. var zrUtil = __webpack_require__(4);
  35320. var CLICK_THRESHOLD = 5; // > 4
  35321. // Parallel view
  35322. echarts.extendComponentView({
  35323. type: 'parallel',
  35324. render: function (parallelModel, ecModel, api) {
  35325. var zr = api.getZr();
  35326. if (!this.__onMouseDown) {
  35327. // FIXME
  35328. // click: mousemove check. otherwise confilct with drag brush.
  35329. var mousedownPoint;
  35330. zr.on('mousedown', this.__onMouseDown = function (e) {
  35331. mousedownPoint = [e.offsetX, e.offsetY];
  35332. });
  35333. zr.on('mouseup', this.__onMouseUp = function (e) {
  35334. var point = [e.offsetX, e.offsetY];
  35335. var dist = Math.pow(mousedownPoint[0] - point[0], 2)
  35336. + Math.pow(mousedownPoint[1] - point[1], 2);
  35337. if (!parallelModel.get('axisExpandable') || dist > CLICK_THRESHOLD) {
  35338. return;
  35339. }
  35340. var coordSys = parallelModel.coordinateSystem;
  35341. var closestDim = coordSys.findClosestAxisDim(point);
  35342. if (closestDim) {
  35343. var axisIndex = zrUtil.indexOf(coordSys.dimensions, closestDim);
  35344. api.dispatchAction({
  35345. type: 'parallelAxisExpand',
  35346. axisExpandCenter: axisIndex
  35347. });
  35348. }
  35349. });
  35350. }
  35351. },
  35352. dispose: function (ecModel, api) {
  35353. api.getZr().off(this.__onMouseDown);
  35354. api.getZr().off(this.__onMouseUp);
  35355. }
  35356. });
  35357. echarts.registerPreprocessor(
  35358. __webpack_require__(236)
  35359. );
  35360. /***/ },
  35361. /* 227 */
  35362. /***/ function(module, exports, __webpack_require__) {
  35363. /**
  35364. * Parallel coordinate system creater.
  35365. */
  35366. var Parallel = __webpack_require__(228);
  35367. function create(ecModel, api) {
  35368. var coordSysList = [];
  35369. ecModel.eachComponent('parallel', function (parallelModel, idx) {
  35370. var coordSys = new Parallel(parallelModel, ecModel, api);
  35371. coordSys.name = 'parallel_' + idx;
  35372. coordSys.resize(parallelModel, api);
  35373. parallelModel.coordinateSystem = coordSys;
  35374. coordSys.model = parallelModel;
  35375. coordSysList.push(coordSys);
  35376. });
  35377. // Inject the coordinateSystems into seriesModel
  35378. ecModel.eachSeries(function (seriesModel) {
  35379. if (seriesModel.get('coordinateSystem') === 'parallel') {
  35380. var parallelModel = ecModel.queryComponents({
  35381. mainType: 'parallel',
  35382. index: seriesModel.get('parallelIndex'),
  35383. id: seriesModel.get('parallelId')
  35384. })[0];
  35385. seriesModel.coordinateSystem = parallelModel.coordinateSystem;
  35386. }
  35387. });
  35388. return coordSysList;
  35389. }
  35390. __webpack_require__(26).register('parallel', {create: create});
  35391. /***/ },
  35392. /* 228 */
  35393. /***/ function(module, exports, __webpack_require__) {
  35394. /**
  35395. * Parallel Coordinates
  35396. * <https://en.wikipedia.org/wiki/Parallel_coordinates>
  35397. */
  35398. var layout = __webpack_require__(21);
  35399. var axisHelper = __webpack_require__(115);
  35400. var zrUtil = __webpack_require__(4);
  35401. var ParallelAxis = __webpack_require__(229);
  35402. var graphic = __webpack_require__(43);
  35403. var matrix = __webpack_require__(11);
  35404. var each = zrUtil.each;
  35405. var PI = Math.PI;
  35406. function Parallel(parallelModel, ecModel, api) {
  35407. /**
  35408. * key: dimension
  35409. * @type {Object.<string, module:echarts/coord/parallel/Axis>}
  35410. * @private
  35411. */
  35412. this._axesMap = {};
  35413. /**
  35414. * key: dimension
  35415. * value: {position: [], rotation, }
  35416. * @type {Object.<string, Object>}
  35417. * @private
  35418. */
  35419. this._axesLayout = {};
  35420. /**
  35421. * Always follow axis order.
  35422. * @type {Array.<string>}
  35423. * @readOnly
  35424. */
  35425. this.dimensions = parallelModel.dimensions;
  35426. /**
  35427. * @type {module:zrender/core/BoundingRect}
  35428. */
  35429. this._rect;
  35430. /**
  35431. * @type {module:echarts/coord/parallel/ParallelModel}
  35432. */
  35433. this._model = parallelModel;
  35434. this._init(parallelModel, ecModel, api);
  35435. }
  35436. Parallel.prototype = {
  35437. type: 'parallel',
  35438. constructor: Parallel,
  35439. /**
  35440. * Initialize cartesian coordinate systems
  35441. * @private
  35442. */
  35443. _init: function (parallelModel, ecModel, api) {
  35444. var dimensions = parallelModel.dimensions;
  35445. var parallelAxisIndex = parallelModel.parallelAxisIndex;
  35446. each(dimensions, function (dim, idx) {
  35447. var axisIndex = parallelAxisIndex[idx];
  35448. var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
  35449. var axis = this._axesMap[dim] = new ParallelAxis(
  35450. dim,
  35451. axisHelper.createScaleByModel(axisModel),
  35452. [0, 0],
  35453. axisModel.get('type'),
  35454. axisIndex
  35455. );
  35456. var isCategory = axis.type === 'category';
  35457. axis.onBand = isCategory && axisModel.get('boundaryGap');
  35458. axis.inverse = axisModel.get('inverse');
  35459. // Inject axis into axisModel
  35460. axisModel.axis = axis;
  35461. // Inject axisModel into axis
  35462. axis.model = axisModel;
  35463. }, this);
  35464. },
  35465. /**
  35466. * Update axis scale after data processed
  35467. * @param {module:echarts/model/Global} ecModel
  35468. * @param {module:echarts/ExtensionAPI} api
  35469. */
  35470. update: function (ecModel, api) {
  35471. this._updateAxesFromSeries(this._model, ecModel);
  35472. },
  35473. /**
  35474. * Update properties from series
  35475. * @private
  35476. */
  35477. _updateAxesFromSeries: function (parallelModel, ecModel) {
  35478. ecModel.eachSeries(function (seriesModel) {
  35479. if (!parallelModel.contains(seriesModel, ecModel)) {
  35480. return;
  35481. }
  35482. var data = seriesModel.getData();
  35483. each(this.dimensions, function (dim) {
  35484. var axis = this._axesMap[dim];
  35485. axis.scale.unionExtent(data.getDataExtent(dim));
  35486. axisHelper.niceScaleExtent(axis, axis.model);
  35487. }, this);
  35488. }, this);
  35489. },
  35490. /**
  35491. * Resize the parallel coordinate system.
  35492. * @param {module:echarts/coord/parallel/ParallelModel} parallelModel
  35493. * @param {module:echarts/ExtensionAPI} api
  35494. */
  35495. resize: function (parallelModel, api) {
  35496. this._rect = layout.getLayoutRect(
  35497. parallelModel.getBoxLayoutParams(),
  35498. {
  35499. width: api.getWidth(),
  35500. height: api.getHeight()
  35501. }
  35502. );
  35503. this._layoutAxes(parallelModel);
  35504. },
  35505. /**
  35506. * @return {module:zrender/core/BoundingRect}
  35507. */
  35508. getRect: function () {
  35509. return this._rect;
  35510. },
  35511. /**
  35512. * @private
  35513. */
  35514. _layoutAxes: function (parallelModel) {
  35515. var rect = this._rect;
  35516. var layout = parallelModel.get('layout');
  35517. var axes = this._axesMap;
  35518. var dimensions = this.dimensions;
  35519. var size = [rect.width, rect.height];
  35520. var sizeIdx = layout === 'horizontal' ? 0 : 1;
  35521. var layoutLength = size[sizeIdx];
  35522. var axisLength = size[1 - sizeIdx];
  35523. var axisExtent = [0, axisLength];
  35524. each(axes, function (axis) {
  35525. var idx = axis.inverse ? 1 : 0;
  35526. axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);
  35527. });
  35528. var axisExpandable = parallelModel.get('axisExpandable');
  35529. var axisExpandWidth = parallelModel.get('axisExpandWidth');
  35530. var axisExpandCenter = parallelModel.get('axisExpandCenter');
  35531. var axisExpandCount = parallelModel.get('axisExpandCount') || 0;
  35532. var axisExpandWindow;
  35533. if (axisExpandCenter != null) {
  35534. // Clamp
  35535. var left = Math.max(0, Math.floor(axisExpandCenter - (axisExpandCount - 1) / 2));
  35536. var right = left + axisExpandCount - 1;
  35537. if (right >= dimensions.length) {
  35538. right = dimensions.length - 1;
  35539. left = Math.max(0, Math.floor(right - axisExpandCount + 1));
  35540. }
  35541. axisExpandWindow = [left, right];
  35542. }
  35543. var calcPos = (axisExpandable && axisExpandWindow && axisExpandWidth)
  35544. ? function (axisIndex, layoutLength, axisCount) {
  35545. var peekIntervalCount = axisExpandWindow[1] - axisExpandWindow[0];
  35546. var otherWidth = (
  35547. layoutLength - axisExpandWidth * peekIntervalCount
  35548. ) / (axisCount - 1 - peekIntervalCount);
  35549. var position;
  35550. if (axisIndex < axisExpandWindow[0]) {
  35551. position = (axisIndex - 1) * otherWidth;
  35552. }
  35553. else if (axisIndex <= axisExpandWindow[1]) {
  35554. position = axisExpandWindow[0] * otherWidth
  35555. + (axisIndex - axisExpandWindow[0]) * axisExpandWidth;
  35556. }
  35557. else if (axisIndex === axisCount - 1) {
  35558. position = layoutLength;
  35559. }
  35560. else {
  35561. position = axisExpandWindow[0] * otherWidth
  35562. + peekIntervalCount * axisExpandWidth
  35563. + (axisIndex - axisExpandWindow[1]) * otherWidth;
  35564. }
  35565. return {
  35566. position: position,
  35567. axisNameAvailableWidth: (
  35568. axisExpandWindow[0] < axisIndex && axisIndex < axisExpandWindow[1]
  35569. ) ? axisExpandWidth : otherWidth
  35570. };
  35571. }
  35572. : function (axisIndex, layoutLength, axisCount) {
  35573. var step = layoutLength / (axisCount - 1);
  35574. return {
  35575. position: step * axisIndex,
  35576. axisNameAvailableWidth: step
  35577. };
  35578. };
  35579. each(dimensions, function (dim, idx) {
  35580. var posInfo = calcPos(idx, layoutLength, dimensions.length);
  35581. var positionTable = {
  35582. horizontal: {
  35583. x: posInfo.position,
  35584. y: axisLength
  35585. },
  35586. vertical: {
  35587. x: 0,
  35588. y: posInfo.position
  35589. }
  35590. };
  35591. var rotationTable = {
  35592. horizontal: PI / 2,
  35593. vertical: 0
  35594. };
  35595. var position = [
  35596. positionTable[layout].x + rect.x,
  35597. positionTable[layout].y + rect.y
  35598. ];
  35599. var rotation = rotationTable[layout];
  35600. var transform = matrix.create();
  35601. matrix.rotate(transform, transform, rotation);
  35602. matrix.translate(transform, transform, position);
  35603. // TODO
  35604. // tick等排布信息。
  35605. // TODO
  35606. // 根据axis order 更新 dimensions顺序。
  35607. this._axesLayout[dim] = {
  35608. position: position,
  35609. rotation: rotation,
  35610. transform: transform,
  35611. axisNameAvailableWidth: posInfo.axisNameAvailableWidth,
  35612. tickDirection: 1,
  35613. labelDirection: 1,
  35614. axisExpandWindow: axisExpandWindow
  35615. };
  35616. }, this);
  35617. },
  35618. /**
  35619. * Get axis by dim.
  35620. * @param {string} dim
  35621. * @return {module:echarts/coord/parallel/ParallelAxis} [description]
  35622. */
  35623. getAxis: function (dim) {
  35624. return this._axesMap[dim];
  35625. },
  35626. /**
  35627. * Convert a dim value of a single item of series data to Point.
  35628. * @param {*} value
  35629. * @param {string} dim
  35630. * @return {Array}
  35631. */
  35632. dataToPoint: function (value, dim) {
  35633. return this.axisCoordToPoint(
  35634. this._axesMap[dim].dataToCoord(value),
  35635. dim
  35636. );
  35637. },
  35638. /**
  35639. * Travel data for one time, get activeState of each data item.
  35640. * @param {module:echarts/data/List} data
  35641. * @param {Functio} cb param: {string} activeState 'active' or 'inactive' or 'normal'
  35642. * {number} dataIndex
  35643. * @param {Object} context
  35644. */
  35645. eachActiveState: function (data, callback, context) {
  35646. var dimensions = this.dimensions;
  35647. var axesMap = this._axesMap;
  35648. var hasActiveSet = this.hasAxisbrushed();
  35649. for (var i = 0, len = data.count(); i < len; i++) {
  35650. var values = data.getValues(dimensions, i);
  35651. var activeState;
  35652. if (!hasActiveSet) {
  35653. activeState = 'normal';
  35654. }
  35655. else {
  35656. activeState = 'active';
  35657. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  35658. var dimName = dimensions[j];
  35659. var state = axesMap[dimName].model.getActiveState(values[j], j);
  35660. if (state === 'inactive') {
  35661. activeState = 'inactive';
  35662. break;
  35663. }
  35664. }
  35665. }
  35666. callback.call(context, activeState, i);
  35667. }
  35668. },
  35669. /**
  35670. * Whether has any activeSet.
  35671. * @return {boolean}
  35672. */
  35673. hasAxisbrushed: function () {
  35674. var dimensions = this.dimensions;
  35675. var axesMap = this._axesMap;
  35676. var hasActiveSet = false;
  35677. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  35678. if (axesMap[dimensions[j]].model.getActiveState() !== 'normal') {
  35679. hasActiveSet = true;
  35680. }
  35681. }
  35682. return hasActiveSet;
  35683. },
  35684. /**
  35685. * Convert coords of each axis to Point.
  35686. * Return point. For example: [10, 20]
  35687. * @param {Array.<number>} coords
  35688. * @param {string} dim
  35689. * @return {Array.<number>}
  35690. */
  35691. axisCoordToPoint: function (coord, dim) {
  35692. var axisLayout = this._axesLayout[dim];
  35693. return graphic.applyTransform([coord, 0], axisLayout.transform);
  35694. },
  35695. /**
  35696. * Get axis layout.
  35697. */
  35698. getAxisLayout: function (dim) {
  35699. return zrUtil.clone(this._axesLayout[dim]);
  35700. },
  35701. findClosestAxisDim: function (point) {
  35702. var axisDim;
  35703. var minDist = Infinity;
  35704. zrUtil.each(this._axesLayout, function (axisLayout, dim) {
  35705. var localPoint = graphic.applyTransform(point, axisLayout.transform, true);
  35706. var extent = this._axesMap[dim].getExtent();
  35707. if (localPoint[0] < extent[0] || localPoint[0] > extent[1]) {
  35708. return;
  35709. }
  35710. var dist = Math.abs(localPoint[1]);
  35711. if (dist < minDist) {
  35712. minDist = dist;
  35713. axisDim = dim;
  35714. }
  35715. }, this);
  35716. return axisDim;
  35717. }
  35718. };
  35719. module.exports = Parallel;
  35720. /***/ },
  35721. /* 229 */
  35722. /***/ function(module, exports, __webpack_require__) {
  35723. var zrUtil = __webpack_require__(4);
  35724. var Axis = __webpack_require__(124);
  35725. /**
  35726. * @constructor module:echarts/coord/parallel/ParallelAxis
  35727. * @extends {module:echarts/coord/Axis}
  35728. * @param {string} dim
  35729. * @param {*} scale
  35730. * @param {Array.<number>} coordExtent
  35731. * @param {string} axisType
  35732. */
  35733. var ParallelAxis = function (dim, scale, coordExtent, axisType, axisIndex) {
  35734. Axis.call(this, dim, scale, coordExtent);
  35735. /**
  35736. * Axis type
  35737. * - 'category'
  35738. * - 'value'
  35739. * - 'time'
  35740. * - 'log'
  35741. * @type {string}
  35742. */
  35743. this.type = axisType || 'value';
  35744. /**
  35745. * @type {number}
  35746. * @readOnly
  35747. */
  35748. this.axisIndex = axisIndex;
  35749. };
  35750. ParallelAxis.prototype = {
  35751. constructor: ParallelAxis,
  35752. /**
  35753. * Axis model
  35754. * @param {module:echarts/coord/parallel/AxisModel}
  35755. */
  35756. model: null
  35757. };
  35758. zrUtil.inherits(ParallelAxis, Axis);
  35759. module.exports = ParallelAxis;
  35760. /***/ },
  35761. /* 230 */
  35762. /***/ function(module, exports, __webpack_require__) {
  35763. var zrUtil = __webpack_require__(4);
  35764. var Component = __webpack_require__(19);
  35765. __webpack_require__(231);
  35766. Component.extend({
  35767. type: 'parallel',
  35768. dependencies: ['parallelAxis'],
  35769. /**
  35770. * @type {module:echarts/coord/parallel/Parallel}
  35771. */
  35772. coordinateSystem: null,
  35773. /**
  35774. * Each item like: 'dim0', 'dim1', 'dim2', ...
  35775. * @type {Array.<string>}
  35776. * @readOnly
  35777. */
  35778. dimensions: null,
  35779. /**
  35780. * Coresponding to dimensions.
  35781. * @type {Array.<number>}
  35782. * @readOnly
  35783. */
  35784. parallelAxisIndex: null,
  35785. layoutMode: 'box',
  35786. defaultOption: {
  35787. zlevel: 0,
  35788. z: 0,
  35789. left: 80,
  35790. top: 60,
  35791. right: 80,
  35792. bottom: 60,
  35793. // width: {totalWidth} - left - right,
  35794. // height: {totalHeight} - top - bottom,
  35795. layout: 'horizontal', // 'horizontal' or 'vertical'
  35796. // FIXME
  35797. // naming?
  35798. axisExpandable: false,
  35799. axisExpandCenter: null,
  35800. axisExpandCount: 0,
  35801. axisExpandWidth: 50, // FIXME '10%' ?
  35802. parallelAxisDefault: null
  35803. },
  35804. /**
  35805. * @override
  35806. */
  35807. init: function () {
  35808. Component.prototype.init.apply(this, arguments);
  35809. this.mergeOption({});
  35810. },
  35811. /**
  35812. * @override
  35813. */
  35814. mergeOption: function (newOption) {
  35815. var thisOption = this.option;
  35816. newOption && zrUtil.merge(thisOption, newOption, true);
  35817. this._initDimensions();
  35818. },
  35819. /**
  35820. * Whether series or axis is in this coordinate system.
  35821. * @param {module:echarts/model/Series|module:echarts/coord/parallel/AxisModel} model
  35822. * @param {module:echarts/model/Global} ecModel
  35823. */
  35824. contains: function (model, ecModel) {
  35825. var parallelIndex = model.get('parallelIndex');
  35826. return parallelIndex != null
  35827. && ecModel.getComponent('parallel', parallelIndex) === this;
  35828. },
  35829. setAxisExpand: function (opt) {
  35830. zrUtil.each(
  35831. ['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth'],
  35832. function (name) {
  35833. if (opt.hasOwnProperty(name)) {
  35834. this.option[name] = opt[name];
  35835. }
  35836. },
  35837. this
  35838. );
  35839. },
  35840. /**
  35841. * @private
  35842. */
  35843. _initDimensions: function () {
  35844. var dimensions = this.dimensions = [];
  35845. var parallelAxisIndex = this.parallelAxisIndex = [];
  35846. var axisModels = zrUtil.filter(this.dependentModels.parallelAxis, function (axisModel) {
  35847. // Can not use this.contains here, because
  35848. // initialization has not been completed yet.
  35849. return axisModel.get('parallelIndex') === this.componentIndex;
  35850. });
  35851. zrUtil.each(axisModels, function (axisModel) {
  35852. dimensions.push('dim' + axisModel.get('dim'));
  35853. parallelAxisIndex.push(axisModel.componentIndex);
  35854. });
  35855. }
  35856. });
  35857. /***/ },
  35858. /* 231 */
  35859. /***/ function(module, exports, __webpack_require__) {
  35860. var ComponentModel = __webpack_require__(19);
  35861. var zrUtil = __webpack_require__(4);
  35862. var makeStyleMapper = __webpack_require__(15);
  35863. var axisModelCreator = __webpack_require__(128);
  35864. var numberUtil = __webpack_require__(7);
  35865. var AxisModel = ComponentModel.extend({
  35866. type: 'baseParallelAxis',
  35867. /**
  35868. * @type {module:echarts/coord/parallel/Axis}
  35869. */
  35870. axis: null,
  35871. /**
  35872. * @type {Array.<Array.<number>}
  35873. * @readOnly
  35874. */
  35875. activeIntervals: [],
  35876. /**
  35877. * @return {Object}
  35878. */
  35879. getAreaSelectStyle: function () {
  35880. return makeStyleMapper(
  35881. [
  35882. ['fill', 'color'],
  35883. ['lineWidth', 'borderWidth'],
  35884. ['stroke', 'borderColor'],
  35885. ['width', 'width'],
  35886. ['opacity', 'opacity']
  35887. ]
  35888. ).call(this.getModel('areaSelectStyle'));
  35889. },
  35890. /**
  35891. * The code of this feature is put on AxisModel but not ParallelAxis,
  35892. * because axisModel can be alive after echarts updating but instance of
  35893. * ParallelAxis having been disposed. this._activeInterval should be kept
  35894. * when action dispatched (i.e. legend click).
  35895. *
  35896. * @param {Array.<Array<number>>} intervals interval.length === 0
  35897. * means set all active.
  35898. * @public
  35899. */
  35900. setActiveIntervals: function (intervals) {
  35901. var activeIntervals = this.activeIntervals = zrUtil.clone(intervals);
  35902. // Normalize
  35903. if (activeIntervals) {
  35904. for (var i = activeIntervals.length - 1; i >= 0; i--) {
  35905. numberUtil.asc(activeIntervals[i]);
  35906. }
  35907. }
  35908. },
  35909. /**
  35910. * @param {number|string} [value] When attempting to detect 'no activeIntervals set',
  35911. * value can not be input.
  35912. * @return {string} 'normal': no activeIntervals set,
  35913. * 'active',
  35914. * 'inactive'.
  35915. * @public
  35916. */
  35917. getActiveState: function (value) {
  35918. var activeIntervals = this.activeIntervals;
  35919. if (!activeIntervals.length) {
  35920. return 'normal';
  35921. }
  35922. if (value == null) {
  35923. return 'inactive';
  35924. }
  35925. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  35926. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  35927. return 'active';
  35928. }
  35929. }
  35930. return 'inactive';
  35931. }
  35932. });
  35933. var defaultOption = {
  35934. type: 'value',
  35935. /**
  35936. * @type {Array.<number>}
  35937. */
  35938. dim: null, // 0, 1, 2, ...
  35939. // parallelIndex: null,
  35940. areaSelectStyle: {
  35941. width: 20,
  35942. borderWidth: 1,
  35943. borderColor: 'rgba(160,197,232)',
  35944. color: 'rgba(160,197,232)',
  35945. opacity: 0.3
  35946. },
  35947. realtime: true, // Whether realtime update view when select.
  35948. z: 10
  35949. };
  35950. zrUtil.merge(AxisModel.prototype, __webpack_require__(130));
  35951. function getAxisType(axisName, option) {
  35952. return option.type || (option.data ? 'category' : 'value');
  35953. }
  35954. axisModelCreator('parallel', AxisModel, getAxisType, defaultOption);
  35955. module.exports = AxisModel;
  35956. /***/ },
  35957. /* 232 */
  35958. /***/ function(module, exports, __webpack_require__) {
  35959. __webpack_require__(227);
  35960. __webpack_require__(233);
  35961. __webpack_require__(234);
  35962. /***/ },
  35963. /* 233 */
  35964. /***/ function(module, exports, __webpack_require__) {
  35965. var echarts = __webpack_require__(1);
  35966. /**
  35967. * @payload
  35968. * @property {string} parallelAxisId
  35969. * @property {Array.<Array.<number>>} intervals
  35970. */
  35971. var actionInfo = {
  35972. type: 'axisAreaSelect',
  35973. event: 'axisAreaSelected',
  35974. update: 'updateVisual'
  35975. };
  35976. echarts.registerAction(actionInfo, function (payload, ecModel) {
  35977. ecModel.eachComponent(
  35978. {mainType: 'parallelAxis', query: payload},
  35979. function (parallelAxisModel) {
  35980. parallelAxisModel.axis.model.setActiveIntervals(payload.intervals);
  35981. }
  35982. );
  35983. });
  35984. /**
  35985. * @payload
  35986. */
  35987. echarts.registerAction('parallelAxisExpand', function (payload, ecModel) {
  35988. ecModel.eachComponent(
  35989. {mainType: 'parallel', query: payload},
  35990. function (parallelModel) {
  35991. parallelModel.setAxisExpand(payload);
  35992. }
  35993. );
  35994. });
  35995. /***/ },
  35996. /* 234 */
  35997. /***/ function(module, exports, __webpack_require__) {
  35998. var zrUtil = __webpack_require__(4);
  35999. var AxisBuilder = __webpack_require__(134);
  36000. var BrushController = __webpack_require__(235);
  36001. var graphic = __webpack_require__(43);
  36002. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'axisName'];
  36003. var AxisView = __webpack_require__(1).extendComponentView({
  36004. type: 'parallelAxis',
  36005. /**
  36006. * @override
  36007. */
  36008. init: function (ecModel, api) {
  36009. AxisView.superApply(this, 'init', arguments);
  36010. /**
  36011. * @type {module:echarts/component/helper/BrushController}
  36012. */
  36013. (this._brushController = new BrushController(api.getZr()))
  36014. .on('brush', zrUtil.bind(this._onBrush, this));
  36015. },
  36016. /**
  36017. * @override
  36018. */
  36019. render: function (axisModel, ecModel, api, payload) {
  36020. if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
  36021. return;
  36022. }
  36023. this.axisModel = axisModel;
  36024. this.api = api;
  36025. this.group.removeAll();
  36026. var oldAxisGroup = this._axisGroup;
  36027. this._axisGroup = new graphic.Group();
  36028. this.group.add(this._axisGroup);
  36029. if (!axisModel.get('show')) {
  36030. return;
  36031. }
  36032. var coordSys = ecModel.getComponent(
  36033. 'parallel', axisModel.get('parallelIndex')
  36034. ).coordinateSystem;
  36035. var areaSelectStyle = axisModel.getAreaSelectStyle();
  36036. var areaWidth = areaSelectStyle.width;
  36037. var dim = axisModel.axis.dim;
  36038. var axisLayout = coordSys.getAxisLayout(dim);
  36039. // Fetch from axisModel by default.
  36040. var axisLabelShow;
  36041. var axisIndex = zrUtil.indexOf(coordSys.dimensions, dim);
  36042. var axisExpandWindow = axisLayout.axisExpandWindow;
  36043. if (axisExpandWindow
  36044. && (axisIndex <= axisExpandWindow[0] || axisIndex >= axisExpandWindow[1])
  36045. ) {
  36046. axisLabelShow = false;
  36047. }
  36048. var builderOpt = zrUtil.extend(
  36049. {
  36050. axisLabelShow: axisLabelShow,
  36051. strokeContainThreshold: areaWidth
  36052. },
  36053. axisLayout
  36054. );
  36055. var axisBuilder = new AxisBuilder(axisModel, builderOpt);
  36056. zrUtil.each(elementList, axisBuilder.add, axisBuilder);
  36057. this._axisGroup.add(axisBuilder.getGroup());
  36058. this._refreshBrushController(builderOpt, areaSelectStyle, axisModel, areaWidth);
  36059. graphic.groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  36060. },
  36061. _refreshBrushController: function (builderOpt, areaSelectStyle, axisModel, areaWidth) {
  36062. // After filtering, axis may change, select area needs to be update.
  36063. var axis = axisModel.axis;
  36064. var coverInfoList = zrUtil.map(axisModel.activeIntervals, function (interval) {
  36065. return {
  36066. brushType: 'lineX',
  36067. panelId: 'pl',
  36068. range: [
  36069. axis.dataToCoord(interval[0], true),
  36070. axis.dataToCoord(interval[1], true)
  36071. ]
  36072. };
  36073. });
  36074. var extent = axis.getExtent();
  36075. var extentLen = extent[1] - extent[0];
  36076. var extra = Math.min(30, Math.abs(extentLen) * 0.1); // Arbitrary value.
  36077. // width/height might be negative, which will be
  36078. // normalized in BoundingRect.
  36079. var rect = graphic.BoundingRect.create({
  36080. x: extent[0],
  36081. y: -areaWidth / 2,
  36082. width: extentLen,
  36083. height: areaWidth
  36084. });
  36085. rect.x -= extra;
  36086. rect.width += 2 * extra;
  36087. this._brushController
  36088. .mount({
  36089. enableGlobalPan: true,
  36090. rotation: builderOpt.rotation,
  36091. position: builderOpt.position
  36092. })
  36093. .setPanels([{
  36094. panelId: 'pl',
  36095. rect: rect
  36096. }])
  36097. .enableBrush({
  36098. brushType: 'lineX',
  36099. brushStyle: areaSelectStyle,
  36100. removeOnClick: true
  36101. })
  36102. .updateCovers(coverInfoList);
  36103. },
  36104. _onBrush: function (coverInfoList, opt) {
  36105. // Do not cache these object, because the mey be changed.
  36106. var axisModel = this.axisModel;
  36107. var axis = axisModel.axis;
  36108. var intervals = zrUtil.map(coverInfoList, function (coverInfo) {
  36109. return [
  36110. axis.coordToData(coverInfo.range[0], true),
  36111. axis.coordToData(coverInfo.range[1], true)
  36112. ];
  36113. });
  36114. // If realtime is true, action is not dispatched on drag end, because
  36115. // the drag end emits the same params with the last drag move event,
  36116. // and may have some delay when using touch pad.
  36117. if (!axisModel.option.realtime === opt.isEnd || opt.removeOnClick) { // jshint ignore:line
  36118. this.api.dispatchAction({
  36119. type: 'axisAreaSelect',
  36120. parallelAxisId: axisModel.id,
  36121. intervals: intervals
  36122. });
  36123. }
  36124. },
  36125. /**
  36126. * @override
  36127. */
  36128. dispose: function () {
  36129. this._brushController.dispose();
  36130. }
  36131. });
  36132. function fromAxisAreaSelect(axisModel, ecModel, payload) {
  36133. return payload
  36134. && payload.type === 'axisAreaSelect'
  36135. && ecModel.findComponents(
  36136. {mainType: 'parallelAxis', query: payload}
  36137. )[0] === axisModel;
  36138. }
  36139. module.exports = AxisView;
  36140. /***/ },
  36141. /* 235 */
  36142. /***/ function(module, exports, __webpack_require__) {
  36143. /**
  36144. * Box selection tool.
  36145. *
  36146. * @module echarts/component/helper/BrushController
  36147. */
  36148. var Eventful = __webpack_require__(33);
  36149. var zrUtil = __webpack_require__(4);
  36150. var BoundingRect = __webpack_require__(9);
  36151. var graphic = __webpack_require__(43);
  36152. var interactionMutex = __webpack_require__(177);
  36153. var DataDiffer = __webpack_require__(99);
  36154. var curry = zrUtil.curry;
  36155. var each = zrUtil.each;
  36156. var map = zrUtil.map;
  36157. var mathMin = Math.min;
  36158. var mathMax = Math.max;
  36159. var mathPow = Math.pow;
  36160. var COVER_Z = 10000;
  36161. var UNSELECT_THRESHOLD = 6;
  36162. var MIN_RESIZE_LINE_WIDTH = 6;
  36163. var MUTEX_RESOURCE_KEY = 'globalPan';
  36164. var DIRECTION_MAP = {
  36165. w: [0, 0],
  36166. e: [0, 1],
  36167. n: [1, 0],
  36168. s: [1, 1]
  36169. };
  36170. var CURSOR_MAP = {
  36171. w: 'ew',
  36172. e: 'ew',
  36173. n: 'ns',
  36174. s: 'ns',
  36175. ne: 'nesw',
  36176. sw: 'nesw',
  36177. nw: 'nwse',
  36178. se: 'nwse'
  36179. };
  36180. var DEFAULT_BRUSH_OPT = {
  36181. brushStyle: {
  36182. lineWidth: 2,
  36183. stroke: 'rgba(0,0,0,0.3)',
  36184. fill: 'rgba(0,0,0,0.1)'
  36185. },
  36186. transformable: true,
  36187. brushMode: 'single',
  36188. removeOnClick: false
  36189. };
  36190. var baseUID = 0;
  36191. /**
  36192. * @alias module:echarts/component/helper/BrushController
  36193. * @constructor
  36194. * @mixin {module:zrender/mixin/Eventful}
  36195. * @event module:echarts/component/helper/BrushController#brush
  36196. * params:
  36197. * areas: Array.<Array>, coord relates to container group,
  36198. * If no container specified, to global.
  36199. * opt {
  36200. * isEnd: boolean,
  36201. * removeOnClick: boolean
  36202. * }
  36203. *
  36204. * @param {module:zrender/zrender~ZRender} zr
  36205. */
  36206. function BrushController(zr) {
  36207. if (true) {
  36208. zrUtil.assert(zr);
  36209. }
  36210. Eventful.call(this);
  36211. /**
  36212. * @type {module:zrender/zrender~ZRender}
  36213. * @private
  36214. */
  36215. this._zr = zr;
  36216. /**
  36217. * @type {module:zrender/container/Group}
  36218. * @readOnly
  36219. */
  36220. this.group = new graphic.Group();
  36221. /**
  36222. * Only for drawing (after enabledBrush).
  36223. * @private
  36224. * @type {string}
  36225. */
  36226. this._brushType;
  36227. /**
  36228. * Only for drawing (after enabledBrush).
  36229. * @private
  36230. * @type {Object}
  36231. */
  36232. this._brushOption;
  36233. /**
  36234. * @private
  36235. * @type {Object}
  36236. */
  36237. this._panels;
  36238. /**
  36239. * @private
  36240. * @type {Array.<nubmer>}
  36241. */
  36242. this._track = [];
  36243. /**
  36244. * @private
  36245. * @type {boolean}
  36246. */
  36247. this._dragging;
  36248. /**
  36249. * @private
  36250. * @type {Array}
  36251. */
  36252. this._covers = [];
  36253. /**
  36254. * @private
  36255. * @type {moudule:zrender/container/Group}
  36256. */
  36257. this._creatingCover;
  36258. /**
  36259. * true means global panel
  36260. * @private
  36261. * @type {module:zrender/container/Group|boolean}
  36262. */
  36263. this._creatingPanel;
  36264. /**
  36265. * @private
  36266. * @type {boolean}
  36267. */
  36268. this._enableGlobalPan;
  36269. /**
  36270. * @private
  36271. * @type {boolean}
  36272. */
  36273. if (true) {
  36274. this._mounted;
  36275. }
  36276. /**
  36277. * @private
  36278. * @type {string}
  36279. */
  36280. this._uid = 'brushController_' + baseUID++;
  36281. /**
  36282. * @private
  36283. * @type {Object}
  36284. */
  36285. this._handlers = {};
  36286. each(mouseHandlers, function (handler, eventName) {
  36287. this._handlers[eventName] = zrUtil.bind(handler, this);
  36288. }, this);
  36289. }
  36290. BrushController.prototype = {
  36291. constructor: BrushController,
  36292. /**
  36293. * If set to null/undefined/false, select disabled.
  36294. * @param {Object} brushOption
  36295. * @param {string|boolean} brushOption.brushType 'line', 'rect', 'polygon' or false
  36296. * If pass false/null/undefined, disable brush.
  36297. * @param {number} [brushOption.brushMode='single'] 'single' or 'multiple'
  36298. * @param {boolean} [brushOption.transformable=true]
  36299. * @param {boolean} [brushOption.removeOnClick=false]
  36300. * @param {Object} [brushOption.brushStyle]
  36301. * @param {number} [brushOption.brushStyle.width]
  36302. * @param {number} [brushOption.brushStyle.lineWidth]
  36303. * @param {string} [brushOption.brushStyle.stroke]
  36304. * @param {string} [brushOption.brushStyle.fill]
  36305. */
  36306. enableBrush: function (brushOption) {
  36307. if (true) {
  36308. zrUtil.assert(this._mounted);
  36309. }
  36310. this._brushType && doDisableBrush(this);
  36311. brushOption.brushType && doEnableBrush(this, brushOption);
  36312. return this;
  36313. },
  36314. /**
  36315. * @param {Array.<Object>} panelOpts If not pass, it is global brush.
  36316. * Each items: {panelId, rect}
  36317. */
  36318. setPanels: function (panelOpts) {
  36319. var oldPanels = this._panels || {};
  36320. var newPanels = this._panels = panelOpts && panelOpts.length && {};
  36321. var thisGroup = this.group;
  36322. newPanels && each(panelOpts, function (panelOpt) {
  36323. var panelId = panelOpt.panelId;
  36324. var panel = oldPanels[panelId];
  36325. if (!panel) {
  36326. panel = new graphic.Rect({
  36327. silent: true,
  36328. invisible: true
  36329. });
  36330. thisGroup.add(panel);
  36331. }
  36332. var rect = panelOpt.rect;
  36333. // Using BoundingRect to normalize negative width/height.
  36334. if (!(rect instanceof BoundingRect)) {
  36335. rect = BoundingRect.create(rect);
  36336. }
  36337. panel.attr('shape', rect.plain());
  36338. panel.__brushPanelId = panelId;
  36339. newPanels[panelId] = panel;
  36340. oldPanels[panelId] = null;
  36341. });
  36342. each(oldPanels, function (panel) {
  36343. panel && thisGroup.remove(panel);
  36344. });
  36345. return this;
  36346. },
  36347. /**
  36348. * @param {Object} [opt]
  36349. * @return {boolean} [opt.enableGlobalPan=false]
  36350. * @return {boolean} [opt.position=[0, 0]]
  36351. * @return {boolean} [opt.rotation=0]
  36352. * @return {boolean} [opt.scale=[1, 1]]
  36353. */
  36354. mount: function (opt) {
  36355. opt = opt || {};
  36356. if (true) {
  36357. this._mounted = true; // should be at first.
  36358. }
  36359. this._enableGlobalPan = opt.enableGlobalPan;
  36360. var thisGroup = this.group;
  36361. this._zr.add(thisGroup);
  36362. thisGroup.attr({
  36363. position: opt.position || [0, 0],
  36364. rotation: opt.rotation || 0,
  36365. scale: opt.scale || [1, 1]
  36366. });
  36367. return this;
  36368. },
  36369. eachCover: function (cb, context) {
  36370. each(this._covers, cb, context);
  36371. },
  36372. /**
  36373. * Update covers.
  36374. * @param {Array.<Object>} brushOptionList Like:
  36375. * [
  36376. * {id: 'xx', brushType: 'line', range: [23, 44], brushStyle, transformable},
  36377. * {id: 'yy', brushType: 'rect', range: [[23, 44], [23, 54]]},
  36378. * ...
  36379. * ]
  36380. * `brushType` is required in each cover info.
  36381. * `id` is not mandatory.
  36382. * `brushStyle`, `transformable` is not mandatory, use DEFAULT_BRUSH_OPT by default.
  36383. * If brushOptionList is null/undefined, all covers removed.
  36384. */
  36385. updateCovers: function (brushOptionList) {
  36386. if (true) {
  36387. zrUtil.assert(this._mounted);
  36388. }
  36389. brushOptionList = zrUtil.map(brushOptionList, function (brushOption) {
  36390. return zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  36391. });
  36392. var tmpIdPrefix = '\0-brush-index-';
  36393. var oldCovers = this._covers;
  36394. var newCovers = this._covers = [];
  36395. var controller = this;
  36396. var creatingCover = this._creatingCover;
  36397. (new DataDiffer(oldCovers, brushOptionList, oldGetKey, getKey))
  36398. .add(addOrUpdate)
  36399. .update(addOrUpdate)
  36400. .remove(remove)
  36401. .execute();
  36402. return this;
  36403. function getKey(brushOption, index) {
  36404. return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index)
  36405. + '-' + brushOption.brushType;
  36406. }
  36407. function oldGetKey(cover, index) {
  36408. return getKey(cover.__brushOption, index);
  36409. }
  36410. function addOrUpdate(newIndex, oldIndex) {
  36411. var newBrushOption = brushOptionList[newIndex];
  36412. // Consider setOption in event listener of brushSelect,
  36413. // where updating cover when creating should be forbiden.
  36414. if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
  36415. newCovers[newIndex] = oldCovers[oldIndex];
  36416. }
  36417. else {
  36418. var cover = newCovers[newIndex] = oldIndex != null
  36419. ? (
  36420. oldCovers[oldIndex].__brushOption = newBrushOption,
  36421. oldCovers[oldIndex]
  36422. )
  36423. : endCreating(controller, createCover(controller, newBrushOption));
  36424. updateCoverAfterCreation(controller, cover);
  36425. }
  36426. }
  36427. function remove(oldIndex) {
  36428. if (oldCovers[oldIndex] !== creatingCover) {
  36429. controller.group.remove(oldCovers[oldIndex]);
  36430. }
  36431. }
  36432. },
  36433. unmount: function () {
  36434. this.enableBrush(false);
  36435. // container may 'removeAll' outside.
  36436. clearCovers(this);
  36437. this._zr.remove(this.group);
  36438. if (true) {
  36439. this._mounted = false; // should be at last.
  36440. }
  36441. return this;
  36442. },
  36443. dispose: function () {
  36444. this.unmount();
  36445. this.off();
  36446. }
  36447. };
  36448. zrUtil.mixin(BrushController, Eventful);
  36449. function doEnableBrush(controller, brushOption) {
  36450. var zr = controller._zr;
  36451. // Consider roam, which takes globalPan too.
  36452. if (!controller._enableGlobalPan) {
  36453. interactionMutex.take(zr, MUTEX_RESOURCE_KEY, controller._uid);
  36454. }
  36455. each(controller._handlers, function (handler, eventName) {
  36456. zr.on(eventName, handler);
  36457. });
  36458. controller._brushType = brushOption.brushType;
  36459. controller._brushOption = zrUtil.merge(zrUtil.clone(DEFAULT_BRUSH_OPT), brushOption, true);
  36460. }
  36461. function doDisableBrush(controller) {
  36462. var zr = controller._zr;
  36463. interactionMutex.release(zr, MUTEX_RESOURCE_KEY, controller._uid);
  36464. each(controller._handlers, function (handler, eventName) {
  36465. zr.off(eventName, handler);
  36466. });
  36467. controller._brushType = controller._brushOption = null;
  36468. }
  36469. function createCover(controller, brushOption) {
  36470. var cover = coverRenderers[brushOption.brushType].createCover(controller, brushOption);
  36471. updateZ(cover);
  36472. cover.__brushOption = brushOption;
  36473. controller.group.add(cover);
  36474. return cover;
  36475. }
  36476. function endCreating(controller, creatingCover) {
  36477. var coverRenderer = getCoverRenderer(creatingCover);
  36478. if (coverRenderer.endCreating) {
  36479. coverRenderer.endCreating(controller, creatingCover);
  36480. updateZ(creatingCover);
  36481. }
  36482. return creatingCover;
  36483. }
  36484. function updateCoverShape(controller, cover) {
  36485. var brushOption = cover.__brushOption;
  36486. getCoverRenderer(cover).updateCoverShape(
  36487. controller, cover, brushOption.range, brushOption
  36488. );
  36489. }
  36490. function updateZ(group) {
  36491. group.traverse(function (el) {
  36492. el.z = COVER_Z;
  36493. el.z2 = COVER_Z; // Consider in given container.
  36494. });
  36495. }
  36496. function updateCoverAfterCreation(controller, cover) {
  36497. getCoverRenderer(cover).updateCommon(controller, cover);
  36498. updateCoverShape(controller, cover);
  36499. }
  36500. function getCoverRenderer(cover) {
  36501. return coverRenderers[cover.__brushOption.brushType];
  36502. }
  36503. function getPanelByPoint(controller, x, y) {
  36504. var panels = controller._panels;
  36505. if (!panels) {
  36506. return true; // Global panel
  36507. }
  36508. var panel;
  36509. each(panels, function (pn) {
  36510. pn.contain(x, y) && (panel = pn);
  36511. });
  36512. return panel;
  36513. }
  36514. function getPanelByCover(controller, cover) {
  36515. var panels = controller._panels;
  36516. if (!panels) {
  36517. return true; // Global panel
  36518. }
  36519. var panelId = cover.__brushOption.panelId;
  36520. // User may give cover without coord sys info,
  36521. // which is then treated as global panel.
  36522. return panelId != null ? panels[panelId] : true;
  36523. }
  36524. function clearCovers(controller) {
  36525. var covers = controller._covers;
  36526. var originalLength = covers.length;
  36527. each(covers, function (cover) {
  36528. controller.group.remove(cover);
  36529. }, controller);
  36530. covers.length = 0;
  36531. return !!originalLength;
  36532. }
  36533. function trigger(controller, opt) {
  36534. var areas = map(controller._covers, function (cover) {
  36535. var brushOption = cover.__brushOption;
  36536. var range = zrUtil.clone(brushOption.range);
  36537. return {
  36538. brushType: brushOption.brushType,
  36539. panelId: brushOption.panelId,
  36540. range: range
  36541. };
  36542. });
  36543. controller.trigger('brush', areas, {
  36544. isEnd: !!opt.isEnd,
  36545. removeOnClick: !!opt.removeOnClick
  36546. });
  36547. }
  36548. function shouldShowCover(controller) {
  36549. var track = controller._track;
  36550. if (!track.length) {
  36551. return false;
  36552. }
  36553. var p2 = track[track.length - 1];
  36554. var p1 = track[0];
  36555. var dx = p2[0] - p1[0];
  36556. var dy = p2[1] - p1[1];
  36557. var dist = mathPow(dx * dx + dy * dy, 0.5);
  36558. return dist > UNSELECT_THRESHOLD;
  36559. }
  36560. function getTrackEnds(track) {
  36561. var tail = track.length - 1;
  36562. tail < 0 && (tail = 0);
  36563. return [track[0], track[tail]];
  36564. }
  36565. function createBaseRectCover(doDrift, controller, brushOption, edgeNames) {
  36566. var cover = new graphic.Group();
  36567. cover.add(new graphic.Rect({
  36568. name: 'main',
  36569. style: makeStyle(brushOption),
  36570. silent: true,
  36571. draggable: true,
  36572. cursor: 'move',
  36573. drift: curry(doDrift, controller, cover, 'nswe'),
  36574. ondragend: curry(trigger, controller, {isEnd: true})
  36575. }));
  36576. each(
  36577. edgeNames,
  36578. function (name) {
  36579. cover.add(new graphic.Rect({
  36580. name: name,
  36581. style: {opacity: 0},
  36582. draggable: true,
  36583. silent: true,
  36584. invisible: true,
  36585. drift: curry(doDrift, controller, cover, name),
  36586. ondragend: curry(trigger, controller, {isEnd: true})
  36587. }));
  36588. }
  36589. );
  36590. return cover;
  36591. }
  36592. function updateBaseRect(controller, cover, localRange, brushOption) {
  36593. var lineWidth = brushOption.brushStyle.lineWidth || 0;
  36594. var handleSize = mathMax(lineWidth, MIN_RESIZE_LINE_WIDTH);
  36595. var x = localRange[0][0];
  36596. var y = localRange[1][0];
  36597. var xa = x - lineWidth / 2;
  36598. var ya = y - lineWidth / 2;
  36599. var x2 = localRange[0][1];
  36600. var y2 = localRange[1][1];
  36601. var x2a = x2 - handleSize + lineWidth / 2;
  36602. var y2a = y2 - handleSize + lineWidth / 2;
  36603. var width = x2 - x;
  36604. var height = y2 - y;
  36605. var widtha = width + lineWidth;
  36606. var heighta = height + lineWidth;
  36607. updateRectShape(controller, cover, 'main', x, y, width, height);
  36608. if (brushOption.transformable) {
  36609. updateRectShape(controller, cover, 'w', xa, ya, handleSize, heighta);
  36610. updateRectShape(controller, cover, 'e', x2a, ya, handleSize, heighta);
  36611. updateRectShape(controller, cover, 'n', xa, ya, widtha, handleSize);
  36612. updateRectShape(controller, cover, 's', xa, y2a, widtha, handleSize);
  36613. updateRectShape(controller, cover, 'nw', xa, ya, handleSize, handleSize);
  36614. updateRectShape(controller, cover, 'ne', x2a, ya, handleSize, handleSize);
  36615. updateRectShape(controller, cover, 'sw', xa, y2a, handleSize, handleSize);
  36616. updateRectShape(controller, cover, 'se', x2a, y2a, handleSize, handleSize);
  36617. }
  36618. }
  36619. function updateCommon(controller, cover) {
  36620. var brushOption = cover.__brushOption;
  36621. var transformable = brushOption.transformable;
  36622. var mainEl = cover.childAt(0);
  36623. mainEl.useStyle(makeStyle(brushOption));
  36624. mainEl.attr({
  36625. silent: !transformable,
  36626. cursor: transformable ? 'move' : 'default'
  36627. });
  36628. each(
  36629. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw'],
  36630. function (name) {
  36631. var el = cover.childOfName(name);
  36632. var globalDir = getGlobalDirection(controller, name);
  36633. el && el.attr({
  36634. silent: !transformable,
  36635. invisible: !transformable,
  36636. cursor: transformable ? CURSOR_MAP[globalDir] + '-resize' : null
  36637. });
  36638. }
  36639. );
  36640. }
  36641. function updateRectShape(controller, cover, name, x, y, w, h) {
  36642. var el = cover.childOfName(name);
  36643. el && el.setShape(pointsToRect(
  36644. clipByPanel(controller, cover, [[x, y], [x + w, y + h]])
  36645. ));
  36646. }
  36647. function makeStyle(brushOption) {
  36648. return zrUtil.defaults({strokeNoScale: true}, brushOption.brushStyle);
  36649. }
  36650. function formatRectRange(x, y, x2, y2) {
  36651. var min = [mathMin(x, x2), mathMin(y, y2)];
  36652. var max = [mathMax(x, x2), mathMax(y, y2)];
  36653. return [
  36654. [min[0], max[0]], // x range
  36655. [min[1], max[1]] // y range
  36656. ];
  36657. }
  36658. function getTransform(controller) {
  36659. return graphic.getTransform(controller.group);
  36660. }
  36661. function getGlobalDirection(controller, localDirection) {
  36662. if (localDirection.length > 1) {
  36663. localDirection = localDirection.split('');
  36664. var globalDir = [
  36665. getGlobalDirection(controller, localDirection[0]),
  36666. getGlobalDirection(controller, localDirection[1])
  36667. ];
  36668. (globalDir[0] === 'e' || globalDir[0] === 'w') && globalDir.reverse();
  36669. return globalDir.join('');
  36670. }
  36671. else {
  36672. var map = {w: 'left', e: 'right', n: 'top', s: 'bottom'};
  36673. var inverseMap = {left: 'w', right: 'e', top: 'n', bottom: 's'};
  36674. var globalDir = graphic.transformDirection(
  36675. map[localDirection], getTransform(controller)
  36676. );
  36677. return inverseMap[globalDir];
  36678. }
  36679. }
  36680. function driftRect(toRectRange, fromRectRange, controller, cover, name, dx, dy, e) {
  36681. var brushOption = cover.__brushOption;
  36682. var rectRange = toRectRange(brushOption.range);
  36683. var localDelta = toLocalDelta(controller, dx, dy);
  36684. each(name.split(''), function (namePart) {
  36685. var ind = DIRECTION_MAP[namePart];
  36686. rectRange[ind[0]][ind[1]] += localDelta[ind[0]];
  36687. });
  36688. brushOption.range = fromRectRange(formatRectRange(
  36689. rectRange[0][0], rectRange[1][0], rectRange[0][1], rectRange[1][1]
  36690. ));
  36691. updateCoverAfterCreation(controller, cover);
  36692. trigger(controller, {isEnd: false});
  36693. }
  36694. function driftPolygon(controller, cover, dx, dy, e) {
  36695. var range = cover.__brushOption.range;
  36696. var localDelta = toLocalDelta(controller, dx, dy);
  36697. each(range, function (point) {
  36698. point[0] += localDelta[0];
  36699. point[1] += localDelta[1];
  36700. });
  36701. updateCoverAfterCreation(controller, cover);
  36702. trigger(controller, {isEnd: false});
  36703. }
  36704. function toLocalDelta(controller, dx, dy) {
  36705. var thisGroup = controller.group;
  36706. var localD = thisGroup.transformCoordToLocal(dx, dy);
  36707. var localZero = thisGroup.transformCoordToLocal(0, 0);
  36708. return [localD[0] - localZero[0], localD[1] - localZero[1]];
  36709. }
  36710. function clipByPanel(controller, cover, data) {
  36711. var panel = getPanelByCover(controller, cover);
  36712. if (panel === true) { // Global panel
  36713. return zrUtil.clone(data);
  36714. }
  36715. var panelRect = panel.getBoundingRect();
  36716. return zrUtil.map(data, function (point) {
  36717. var x = point[0];
  36718. x = mathMax(x, panelRect.x);
  36719. x = mathMin(x, panelRect.x + panelRect.width);
  36720. var y = point[1];
  36721. y = mathMax(y, panelRect.y);
  36722. y = mathMin(y, panelRect.y + panelRect.height);
  36723. return [x, y];
  36724. });
  36725. }
  36726. function pointsToRect(points) {
  36727. var xmin = mathMin(points[0][0], points[1][0]);
  36728. var ymin = mathMin(points[0][1], points[1][1]);
  36729. var xmax = mathMax(points[0][0], points[1][0]);
  36730. var ymax = mathMax(points[0][1], points[1][1]);
  36731. return {
  36732. x: xmin,
  36733. y: ymin,
  36734. width: xmax - xmin,
  36735. height: ymax - ymin
  36736. };
  36737. }
  36738. function resetCursor(controller, e) {
  36739. var x = e.offsetX;
  36740. var y = e.offsetY;
  36741. var zr = controller._zr;
  36742. if (controller._brushType) { // If active
  36743. var panels = controller._panels;
  36744. var covers = controller._covers;
  36745. var inCover;
  36746. for (var i = 0; i < covers.length; i++) {
  36747. if (coverRenderers[covers[i].__brushOption.brushType].contain(covers[i], x, y)) {
  36748. inCover = true;
  36749. break;
  36750. }
  36751. }
  36752. if (!inCover) {
  36753. if (panels) { // Brush on panels
  36754. each(panels, function (panel) {
  36755. panel.contain(x, y) && zr.setCursorStyle('crosshair');
  36756. });
  36757. }
  36758. else { // Global brush
  36759. zr.setCursorStyle('crosshair');
  36760. }
  36761. }
  36762. }
  36763. }
  36764. function preventDefault(e) {
  36765. var rawE = e.event;
  36766. rawE.preventDefault && rawE.preventDefault();
  36767. }
  36768. function mainShapeContain(cover, x, y) {
  36769. return cover.childOfName('main').contain(x, y);
  36770. }
  36771. function updateCoverByMouse(controller, e, isEnd) {
  36772. var x = e.offsetX;
  36773. var y = e.offsetY;
  36774. var creatingCover = controller._creatingCover;
  36775. var panel = controller._creatingPanel;
  36776. var thisBrushOption = controller._brushOption;
  36777. var eventParams;
  36778. controller._track.push(controller.group.transformCoordToLocal(x, y));
  36779. if (shouldShowCover(controller) || creatingCover) {
  36780. if (panel && !creatingCover) {
  36781. thisBrushOption.brushMode === 'single' && clearCovers(controller);
  36782. var brushOption = zrUtil.clone(thisBrushOption);
  36783. brushOption.panelId = panel === true ? null : panel.__brushPanelId;
  36784. creatingCover = controller._creatingCover = createCover(controller, brushOption);
  36785. controller._covers.push(creatingCover);
  36786. }
  36787. if (creatingCover) {
  36788. var coverRenderer = coverRenderers[controller._brushType];
  36789. var coverBrushOption = creatingCover.__brushOption;
  36790. coverBrushOption.range = coverRenderer.getCreatingRange(
  36791. clipByPanel(controller, creatingCover, controller._track)
  36792. );
  36793. if (isEnd) {
  36794. endCreating(controller, creatingCover);
  36795. coverRenderer.updateCommon(controller, creatingCover);
  36796. }
  36797. updateCoverShape(controller, creatingCover);
  36798. eventParams = {isEnd: isEnd};
  36799. }
  36800. }
  36801. else if (
  36802. isEnd
  36803. && thisBrushOption.brushMode === 'single'
  36804. && thisBrushOption.removeOnClick
  36805. ) {
  36806. // Help user to remove covers easily, only by a tiny drag, in 'single' mode.
  36807. // But a single click do not clear covers, because user may have casual
  36808. // clicks (for example, click on other component and do not expect covers
  36809. // disappear).
  36810. // Only some cover removed, trigger action, but not every click trigger action.
  36811. if (getPanelByPoint(controller, x, y) && clearCovers(controller)) {
  36812. eventParams = {isEnd: isEnd, removeOnClick: true};
  36813. }
  36814. }
  36815. return eventParams;
  36816. }
  36817. var mouseHandlers = {
  36818. mousedown: function (e) {
  36819. if (this._dragging) {
  36820. // In case some browser do not support globalOut,
  36821. // and release mose out side the browser.
  36822. handleDragEnd.call(this, e);
  36823. }
  36824. else if (!e.target || !e.target.draggable) {
  36825. preventDefault(e);
  36826. var x = e.offsetX;
  36827. var y = e.offsetY;
  36828. this._creatingCover = null;
  36829. var panel = this._creatingPanel = getPanelByPoint(this, x, y);
  36830. if (panel) {
  36831. this._dragging = true;
  36832. this._track = [this.group.transformCoordToLocal(x, y)];
  36833. }
  36834. }
  36835. },
  36836. mousemove: function (e) {
  36837. // set Cursor
  36838. resetCursor(this, e);
  36839. if (this._dragging) {
  36840. preventDefault(e);
  36841. var eventParams = updateCoverByMouse(this, e, false);
  36842. eventParams && trigger(this, eventParams);
  36843. }
  36844. },
  36845. mouseup: handleDragEnd //,
  36846. // FIXME
  36847. // in tooltip, globalout should not be triggered.
  36848. // globalout: handleDragEnd
  36849. };
  36850. function handleDragEnd(e) {
  36851. if (this._dragging) {
  36852. preventDefault(e);
  36853. var eventParams = updateCoverByMouse(this, e, true);
  36854. this._dragging = false;
  36855. this._track = [];
  36856. this._creatingCover = null;
  36857. // trigger event shoule be at final, after procedure will be nested.
  36858. eventParams && trigger(this, eventParams);
  36859. }
  36860. }
  36861. /**
  36862. * key: brushType
  36863. * @type {Object}
  36864. */
  36865. var coverRenderers = {
  36866. lineX: getLineRenderer(0),
  36867. lineY: getLineRenderer(1),
  36868. rect: {
  36869. createCover: function (controller, brushOption) {
  36870. return createBaseRectCover(
  36871. curry(
  36872. driftRect,
  36873. function (range) {
  36874. return range;
  36875. },
  36876. function (range) {
  36877. return range;
  36878. }
  36879. ),
  36880. controller,
  36881. brushOption,
  36882. ['w', 'e', 'n', 's', 'se', 'sw', 'ne', 'nw']
  36883. );
  36884. },
  36885. getCreatingRange: function (localTrack) {
  36886. var ends = getTrackEnds(localTrack);
  36887. return formatRectRange(ends[1][0], ends[1][1], ends[0][0], ends[0][1]);
  36888. },
  36889. updateCoverShape: function (controller, cover, localRange, brushOption) {
  36890. updateBaseRect(controller, cover, localRange, brushOption);
  36891. },
  36892. updateCommon: updateCommon,
  36893. contain: mainShapeContain
  36894. },
  36895. polygon: {
  36896. createCover: function (controller, brushOption) {
  36897. var cover = new graphic.Group();
  36898. // Do not use graphic.Polygon because graphic.Polyline do not close the
  36899. // border of the shape when drawing, which is a better experience for user.
  36900. cover.add(new graphic.Polyline({
  36901. name: 'main',
  36902. style: makeStyle(brushOption),
  36903. silent: true
  36904. }));
  36905. return cover;
  36906. },
  36907. getCreatingRange: function (localTrack) {
  36908. return localTrack;
  36909. },
  36910. endCreating: function (controller, cover) {
  36911. cover.remove(cover.childAt(0));
  36912. // Use graphic.Polygon close the shape.
  36913. cover.add(new graphic.Polygon({
  36914. name: 'main',
  36915. draggable: true,
  36916. drift: curry(driftPolygon, controller, cover),
  36917. ondragend: curry(trigger, controller, {isEnd: true})
  36918. }));
  36919. },
  36920. updateCoverShape: function (controller, cover, localRange, brushOption) {
  36921. cover.childAt(0).setShape({
  36922. points: clipByPanel(controller, cover, localRange)
  36923. });
  36924. },
  36925. updateCommon: updateCommon,
  36926. contain: mainShapeContain
  36927. }
  36928. };
  36929. function getLineRenderer(xyIndex) {
  36930. return {
  36931. createCover: function (controller, brushOption) {
  36932. return createBaseRectCover(
  36933. curry(
  36934. driftRect,
  36935. function (range) {
  36936. var rectRange = [range, [0, 100]];
  36937. xyIndex && rectRange.reverse();
  36938. return rectRange;
  36939. },
  36940. function (rectRange) {
  36941. return rectRange[xyIndex];
  36942. }
  36943. ),
  36944. controller,
  36945. brushOption,
  36946. [['w', 'e'], ['n', 's']][xyIndex]
  36947. );
  36948. },
  36949. getCreatingRange: function (localTrack) {
  36950. var ends = getTrackEnds(localTrack);
  36951. var min = mathMin(ends[0][xyIndex], ends[1][xyIndex]);
  36952. var max = mathMax(ends[0][xyIndex], ends[1][xyIndex]);
  36953. return [min, max];
  36954. },
  36955. updateCoverShape: function (controller, cover, localRange, brushOption) {
  36956. var brushWidth = brushOption.brushStyle.width;
  36957. var otherExtent;
  36958. // If brushWidth not specified, fit the panel.
  36959. if (brushWidth == null) {
  36960. var panel = getPanelByCover(controller, cover);
  36961. var base = 0;
  36962. if (panel !== true) {
  36963. var rect = panel.getBoundingRect();
  36964. brushWidth = xyIndex ? rect.width : rect.height;
  36965. base = xyIndex ? rect.x : rect.y;
  36966. }
  36967. // FIXME
  36968. // do not support global panel yet.
  36969. otherExtent = [base, base + (brushWidth || 0)];
  36970. }
  36971. else {
  36972. otherExtent = [-brushWidth / 2, brushWidth / 2];
  36973. }
  36974. var rectRange = [localRange, otherExtent];
  36975. xyIndex && rectRange.reverse();
  36976. updateBaseRect(controller, cover, rectRange, brushOption);
  36977. },
  36978. updateCommon: updateCommon,
  36979. contain: mainShapeContain
  36980. };
  36981. }
  36982. module.exports = BrushController;
  36983. /***/ },
  36984. /* 236 */
  36985. /***/ function(module, exports, __webpack_require__) {
  36986. var zrUtil = __webpack_require__(4);
  36987. var modelUtil = __webpack_require__(5);
  36988. module.exports = function (option) {
  36989. createParallelIfNeeded(option);
  36990. mergeAxisOptionFromParallel(option);
  36991. };
  36992. /**
  36993. * Create a parallel coordinate if not exists.
  36994. * @inner
  36995. */
  36996. function createParallelIfNeeded(option) {
  36997. if (option.parallel) {
  36998. return;
  36999. }
  37000. var hasParallelSeries = false;
  37001. zrUtil.each(option.series, function (seriesOpt) {
  37002. if (seriesOpt && seriesOpt.type === 'parallel') {
  37003. hasParallelSeries = true;
  37004. }
  37005. });
  37006. if (hasParallelSeries) {
  37007. option.parallel = [{}];
  37008. }
  37009. }
  37010. /**
  37011. * Merge aixs definition from parallel option (if exists) to axis option.
  37012. * @inner
  37013. */
  37014. function mergeAxisOptionFromParallel(option) {
  37015. var axes = modelUtil.normalizeToArray(option.parallelAxis);
  37016. zrUtil.each(axes, function (axisOption) {
  37017. if (!zrUtil.isObject(axisOption)) {
  37018. return;
  37019. }
  37020. var parallelIndex = axisOption.parallelIndex || 0;
  37021. var parallelOption = modelUtil.normalizeToArray(option.parallel)[parallelIndex];
  37022. if (parallelOption && parallelOption.parallelAxisDefault) {
  37023. zrUtil.merge(axisOption, parallelOption.parallelAxisDefault, false);
  37024. }
  37025. });
  37026. }
  37027. /***/ },
  37028. /* 237 */
  37029. /***/ function(module, exports, __webpack_require__) {
  37030. var List = __webpack_require__(98);
  37031. var zrUtil = __webpack_require__(4);
  37032. var SeriesModel = __webpack_require__(28);
  37033. var completeDimensions = __webpack_require__(103);
  37034. module.exports = SeriesModel.extend({
  37035. type: 'series.parallel',
  37036. dependencies: ['parallel'],
  37037. getInitialData: function (option, ecModel) {
  37038. var parallelModel = ecModel.getComponent(
  37039. 'parallel', this.get('parallelIndex')
  37040. );
  37041. var parallelAxisIndices = parallelModel.parallelAxisIndex;
  37042. var rawData = option.data;
  37043. var modelDims = parallelModel.dimensions;
  37044. var dataDims = generateDataDims(modelDims, rawData);
  37045. var dataDimsInfo = zrUtil.map(dataDims, function (dim, dimIndex) {
  37046. var modelDimsIndex = zrUtil.indexOf(modelDims, dim);
  37047. var axisModel = modelDimsIndex >= 0 && ecModel.getComponent(
  37048. 'parallelAxis', parallelAxisIndices[modelDimsIndex]
  37049. );
  37050. if (axisModel && axisModel.get('type') === 'category') {
  37051. translateCategoryValue(axisModel, dim, rawData);
  37052. return {name: dim, type: 'ordinal'};
  37053. }
  37054. else if (modelDimsIndex < 0) {
  37055. return completeDimensions.guessOrdinal(rawData, dimIndex)
  37056. ? {name: dim, type: 'ordinal'}
  37057. : dim;
  37058. }
  37059. else {
  37060. return dim;
  37061. }
  37062. });
  37063. var list = new List(dataDimsInfo, this);
  37064. list.initData(rawData);
  37065. // Anication is forbiden in progressive data mode.
  37066. if (this.option.progressive) {
  37067. this.option.animation = false;
  37068. }
  37069. return list;
  37070. },
  37071. /**
  37072. * User can get data raw indices on 'axisAreaSelected' event received.
  37073. *
  37074. * @public
  37075. * @param {string} activeState 'active' or 'inactive' or 'normal'
  37076. * @return {Array.<number>} Raw indices
  37077. */
  37078. getRawIndicesByActiveState: function (activeState) {
  37079. var coordSys = this.coordinateSystem;
  37080. var data = this.getData();
  37081. var indices = [];
  37082. coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
  37083. if (activeState === theActiveState) {
  37084. indices.push(data.getRawIndex(dataIndex));
  37085. }
  37086. });
  37087. return indices;
  37088. },
  37089. defaultOption: {
  37090. zlevel: 0, // 一级层叠
  37091. z: 2, // 二级层叠
  37092. coordinateSystem: 'parallel',
  37093. parallelIndex: 0,
  37094. label: {
  37095. normal: {
  37096. show: false
  37097. },
  37098. emphasis: {
  37099. show: false
  37100. }
  37101. },
  37102. inactiveOpacity: 0.05,
  37103. activeOpacity: 1,
  37104. lineStyle: {
  37105. normal: {
  37106. width: 1,
  37107. opacity: 0.45,
  37108. type: 'solid'
  37109. }
  37110. },
  37111. progressive: false, // 100
  37112. smooth: false,
  37113. animationEasing: 'linear'
  37114. }
  37115. });
  37116. function translateCategoryValue(axisModel, dim, rawData) {
  37117. var axisData = axisModel.get('data');
  37118. var numberDim = convertDimNameToNumber(dim);
  37119. if (axisData && axisData.length) {
  37120. zrUtil.each(rawData, function (dataItem) {
  37121. if (!dataItem) {
  37122. return;
  37123. }
  37124. // FIXME
  37125. // time consuming, should use hash?
  37126. var index = zrUtil.indexOf(axisData, dataItem[numberDim]);
  37127. dataItem[numberDim] = index >= 0 ? index : NaN;
  37128. });
  37129. }
  37130. // FIXME
  37131. // 如果没有设置axis data, 应自动算出,或者提示。
  37132. }
  37133. function convertDimNameToNumber(dimName) {
  37134. return +dimName.replace('dim', '');
  37135. }
  37136. function generateDataDims(modelDims, rawData) {
  37137. // parallelModel.dimension should not be regarded as data
  37138. // dimensions. Consider dimensions = ['dim4', 'dim2', 'dim6'];
  37139. // We detect max dim by parallelModel.dimensions and fist
  37140. // item in rawData arbitrarily.
  37141. var maxDimNum = 0;
  37142. zrUtil.each(modelDims, function (dimName) {
  37143. var numberDim = convertDimNameToNumber(dimName);
  37144. numberDim > maxDimNum && (maxDimNum = numberDim);
  37145. });
  37146. var firstItem = rawData[0];
  37147. if (firstItem && firstItem.length - 1 > maxDimNum) {
  37148. maxDimNum = firstItem.length - 1;
  37149. }
  37150. var dataDims = [];
  37151. for (var i = 0; i <= maxDimNum; i++) {
  37152. dataDims.push('dim' + i);
  37153. }
  37154. return dataDims;
  37155. }
  37156. /***/ },
  37157. /* 238 */
  37158. /***/ function(module, exports, __webpack_require__) {
  37159. var graphic = __webpack_require__(43);
  37160. var zrUtil = __webpack_require__(4);
  37161. var SMOOTH = 0.3;
  37162. var ParallelView = __webpack_require__(42).extend({
  37163. type: 'parallel',
  37164. init: function () {
  37165. /**
  37166. * @type {module:zrender/container/Group}
  37167. * @private
  37168. */
  37169. this._dataGroup = new graphic.Group();
  37170. this.group.add(this._dataGroup);
  37171. /**
  37172. * @type {module:echarts/data/List}
  37173. */
  37174. this._data;
  37175. },
  37176. /**
  37177. * @override
  37178. */
  37179. render: function (seriesModel, ecModel, api, payload) {
  37180. this._renderForNormal(seriesModel);
  37181. // this[
  37182. // seriesModel.option.progressive
  37183. // ? '_renderForProgressive'
  37184. // : '_renderForNormal'
  37185. // ](seriesModel);
  37186. },
  37187. dispose: function () {},
  37188. /**
  37189. * @private
  37190. */
  37191. _renderForNormal: function (seriesModel) {
  37192. var dataGroup = this._dataGroup;
  37193. var data = seriesModel.getData();
  37194. var oldData = this._data;
  37195. var coordSys = seriesModel.coordinateSystem;
  37196. var dimensions = coordSys.dimensions;
  37197. var option = seriesModel.option;
  37198. var smooth = option.smooth ? SMOOTH : null;
  37199. // Consider switch between progressive and not.
  37200. // oldData && oldData.__plProgressive && dataGroup.removeAll();
  37201. data.diff(oldData)
  37202. .add(add)
  37203. .update(update)
  37204. .remove(remove)
  37205. .execute();
  37206. // Update style
  37207. updateElCommon(data, smooth);
  37208. // First create
  37209. if (!this._data) {
  37210. var clipPath = createGridClipShape(
  37211. coordSys, seriesModel, function () {
  37212. // Callback will be invoked immediately if there is no animation
  37213. setTimeout(function () {
  37214. dataGroup.removeClipPath();
  37215. });
  37216. }
  37217. );
  37218. dataGroup.setClipPath(clipPath);
  37219. }
  37220. this._data = data;
  37221. function add(newDataIndex) {
  37222. addEl(data, dataGroup, newDataIndex, dimensions, coordSys, null, smooth);
  37223. }
  37224. function update(newDataIndex, oldDataIndex) {
  37225. var line = oldData.getItemGraphicEl(oldDataIndex);
  37226. var points = createLinePoints(data, newDataIndex, dimensions, coordSys);
  37227. data.setItemGraphicEl(newDataIndex, line);
  37228. graphic.updateProps(line, {shape: {points: points}}, seriesModel, newDataIndex);
  37229. }
  37230. function remove(oldDataIndex) {
  37231. var line = oldData.getItemGraphicEl(oldDataIndex);
  37232. dataGroup.remove(line);
  37233. }
  37234. },
  37235. /**
  37236. * @private
  37237. */
  37238. // _renderForProgressive: function (seriesModel) {
  37239. // var dataGroup = this._dataGroup;
  37240. // var data = seriesModel.getData();
  37241. // var oldData = this._data;
  37242. // var coordSys = seriesModel.coordinateSystem;
  37243. // var dimensions = coordSys.dimensions;
  37244. // var option = seriesModel.option;
  37245. // var progressive = option.progressive;
  37246. // var smooth = option.smooth ? SMOOTH : null;
  37247. // // In progressive animation is disabled, so use simple data diff,
  37248. // // which effects performance less.
  37249. // // (Typically performance for data with length 7000+ like:
  37250. // // simpleDiff: 60ms, addEl: 184ms,
  37251. // // in RMBP 2.4GHz intel i7, OSX 10.9 chrome 50.0.2661.102 (64-bit))
  37252. // if (simpleDiff(oldData, data, dimensions)) {
  37253. // dataGroup.removeAll();
  37254. // data.each(function (dataIndex) {
  37255. // addEl(data, dataGroup, dataIndex, dimensions, coordSys);
  37256. // });
  37257. // }
  37258. // updateElCommon(data, progressive, smooth);
  37259. // // Consider switch between progressive and not.
  37260. // data.__plProgressive = true;
  37261. // this._data = data;
  37262. // },
  37263. /**
  37264. * @override
  37265. */
  37266. remove: function () {
  37267. this._dataGroup && this._dataGroup.removeAll();
  37268. this._data = null;
  37269. }
  37270. });
  37271. function createGridClipShape(coordSys, seriesModel, cb) {
  37272. var parallelModel = coordSys.model;
  37273. var rect = coordSys.getRect();
  37274. var rectEl = new graphic.Rect({
  37275. shape: {
  37276. x: rect.x,
  37277. y: rect.y,
  37278. width: rect.width,
  37279. height: rect.height
  37280. }
  37281. });
  37282. var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height';
  37283. rectEl.setShape(dim, 0);
  37284. graphic.initProps(rectEl, {
  37285. shape: {
  37286. width: rect.width,
  37287. height: rect.height
  37288. }
  37289. }, seriesModel, cb);
  37290. return rectEl;
  37291. }
  37292. function createLinePoints(data, dataIndex, dimensions, coordSys) {
  37293. var points = [];
  37294. for (var i = 0; i < dimensions.length; i++) {
  37295. var dimName = dimensions[i];
  37296. var value = data.get(dimName, dataIndex);
  37297. if (!isEmptyValue(value, coordSys.getAxis(dimName).type)) {
  37298. points.push(coordSys.dataToPoint(value, dimName));
  37299. }
  37300. }
  37301. return points;
  37302. }
  37303. function addEl(data, dataGroup, dataIndex, dimensions, coordSys) {
  37304. var points = createLinePoints(data, dataIndex, dimensions, coordSys);
  37305. var line = new graphic.Polyline({
  37306. shape: {points: points},
  37307. silent: true,
  37308. z2: 10
  37309. });
  37310. dataGroup.add(line);
  37311. data.setItemGraphicEl(dataIndex, line);
  37312. }
  37313. function updateElCommon(data, smooth) {
  37314. var seriesStyleModel = data.hostModel.getModel('lineStyle.normal');
  37315. var lineStyle = seriesStyleModel.getLineStyle();
  37316. data.eachItemGraphicEl(function (line, dataIndex) {
  37317. if (data.hasItemOption) {
  37318. var itemModel = data.getItemModel(dataIndex);
  37319. var lineStyleModel = itemModel.getModel('lineStyle.normal', seriesStyleModel);
  37320. lineStyle = lineStyleModel.getLineStyle();
  37321. }
  37322. line.useStyle(zrUtil.extend(
  37323. lineStyle,
  37324. {
  37325. fill: null,
  37326. stroke: data.getItemVisual(dataIndex, 'color'),
  37327. opacity: data.getItemVisual(dataIndex, 'opacity')
  37328. }
  37329. ));
  37330. line.shape.smooth = smooth;
  37331. });
  37332. }
  37333. // function simpleDiff(oldData, newData, dimensions) {
  37334. // var oldLen;
  37335. // if (!oldData
  37336. // || !oldData.__plProgressive
  37337. // || (oldLen = oldData.count()) !== newData.count()
  37338. // ) {
  37339. // return true;
  37340. // }
  37341. // var dimLen = dimensions.length;
  37342. // for (var i = 0; i < oldLen; i++) {
  37343. // for (var j = 0; j < dimLen; j++) {
  37344. // if (oldData.get(dimensions[j], i) !== newData.get(dimensions[j], i)) {
  37345. // return true;
  37346. // }
  37347. // }
  37348. // }
  37349. // return false;
  37350. // }
  37351. // FIXME
  37352. // 公用方法?
  37353. function isEmptyValue(val, axisType) {
  37354. return axisType === 'category'
  37355. ? val == null
  37356. : (val == null || isNaN(val)); // axisType === 'value'
  37357. }
  37358. module.exports = ParallelView;
  37359. /***/ },
  37360. /* 239 */
  37361. /***/ function(module, exports) {
  37362. module.exports = function (ecModel) {
  37363. ecModel.eachSeriesByType('parallel', function (seriesModel) {
  37364. var itemStyleModel = seriesModel.getModel('itemStyle.normal');
  37365. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  37366. var globalColors = ecModel.get('color');
  37367. var color = lineStyleModel.get('color')
  37368. || itemStyleModel.get('color')
  37369. || globalColors[seriesModel.seriesIndex % globalColors.length];
  37370. var inactiveOpacity = seriesModel.get('inactiveOpacity');
  37371. var activeOpacity = seriesModel.get('activeOpacity');
  37372. var lineStyle = seriesModel.getModel('lineStyle.normal').getLineStyle();
  37373. var coordSys = seriesModel.coordinateSystem;
  37374. var data = seriesModel.getData();
  37375. var opacityMap = {
  37376. normal: lineStyle.opacity,
  37377. active: activeOpacity,
  37378. inactive: inactiveOpacity
  37379. };
  37380. coordSys.eachActiveState(data, function (activeState, dataIndex) {
  37381. data.setItemVisual(dataIndex, 'opacity', opacityMap[activeState]);
  37382. });
  37383. data.setVisual('color', color);
  37384. });
  37385. };
  37386. /***/ },
  37387. /* 240 */
  37388. /***/ function(module, exports, __webpack_require__) {
  37389. var echarts = __webpack_require__(1);
  37390. __webpack_require__(241);
  37391. __webpack_require__(242);
  37392. echarts.registerLayout(__webpack_require__(243));
  37393. echarts.registerVisual(__webpack_require__(245));
  37394. /***/ },
  37395. /* 241 */
  37396. /***/ function(module, exports, __webpack_require__) {
  37397. /**
  37398. * @file Get initial data and define sankey view's series model
  37399. * @author Deqing Li(annong035@gmail.com)
  37400. */
  37401. var SeriesModel = __webpack_require__(28);
  37402. var createGraphFromNodeEdge = __webpack_require__(198);
  37403. var SankeySeries = SeriesModel.extend({
  37404. type: 'series.sankey',
  37405. layoutInfo: null,
  37406. /**
  37407. * Init a graph data structure from data in option series
  37408. *
  37409. * @param {Object} option the object used to config echarts view
  37410. * @return {module:echarts/data/List} storage initial data
  37411. */
  37412. getInitialData: function (option) {
  37413. var links = option.edges || option.links;
  37414. var nodes = option.data || option.nodes;
  37415. if (nodes && links) {
  37416. var graph = createGraphFromNodeEdge(nodes, links, this, true);
  37417. return graph.data;
  37418. }
  37419. },
  37420. /**
  37421. * Return the graphic data structure
  37422. *
  37423. * @return {module:echarts/data/Graph} graphic data structure
  37424. */
  37425. getGraph: function () {
  37426. return this.getData().graph;
  37427. },
  37428. /**
  37429. * Get edge data of graphic data structure
  37430. *
  37431. * @return {module:echarts/data/List} data structure of list
  37432. */
  37433. getEdgeData: function () {
  37434. return this.getGraph().edgeData;
  37435. },
  37436. /**
  37437. * @override
  37438. */
  37439. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  37440. // dataType === 'node' or empty do not show tooltip by default
  37441. if (dataType === 'edge') {
  37442. var params = this.getDataParams(dataIndex, dataType);
  37443. var rawDataOpt = params.data;
  37444. var html = rawDataOpt.source + ' -- ' + rawDataOpt.target;
  37445. if (params.value) {
  37446. html += ' : ' + params.value;
  37447. }
  37448. return html;
  37449. }
  37450. return SankeySeries.superCall(this, 'formatTooltip', dataIndex, multipleSeries);
  37451. },
  37452. defaultOption: {
  37453. zlevel: 0,
  37454. z: 2,
  37455. coordinateSystem: 'view',
  37456. layout: null,
  37457. // the position of the whole view
  37458. left: '5%',
  37459. top: '5%',
  37460. right: '20%',
  37461. bottom: '5%',
  37462. // the dx of the node
  37463. nodeWidth: 20,
  37464. // the vertical distance between two nodes
  37465. nodeGap: 8,
  37466. // the number of iterations to change the position of the node
  37467. layoutIterations: 32,
  37468. label: {
  37469. normal: {
  37470. show: true,
  37471. position: 'right',
  37472. textStyle: {
  37473. color: '#000',
  37474. fontSize: 12
  37475. }
  37476. },
  37477. emphasis: {
  37478. show: true
  37479. }
  37480. },
  37481. itemStyle: {
  37482. normal: {
  37483. borderWidth: 1,
  37484. borderColor: '#333'
  37485. }
  37486. },
  37487. lineStyle: {
  37488. normal: {
  37489. color: '#314656',
  37490. opacity: 0.2,
  37491. curveness: 0.5
  37492. },
  37493. emphasis: {
  37494. opacity: 0.6
  37495. }
  37496. },
  37497. animationEasing: 'linear',
  37498. animationDuration: 1000
  37499. }
  37500. });
  37501. module.exports = SankeySeries;
  37502. /***/ },
  37503. /* 242 */
  37504. /***/ function(module, exports, __webpack_require__) {
  37505. /**
  37506. * @file The file used to draw sankey view
  37507. * @author Deqing Li(annong035@gmail.com)
  37508. */
  37509. var graphic = __webpack_require__(43);
  37510. var zrUtil = __webpack_require__(4);
  37511. var SankeyShape = graphic.extendShape({
  37512. shape: {
  37513. x1: 0, y1: 0,
  37514. x2: 0, y2: 0,
  37515. cpx1: 0, cpy1: 0,
  37516. cpx2: 0, cpy2: 0,
  37517. extent: 0
  37518. },
  37519. buildPath: function (ctx, shape) {
  37520. var halfExtent = shape.extent / 2;
  37521. ctx.moveTo(shape.x1, shape.y1 - halfExtent);
  37522. ctx.bezierCurveTo(
  37523. shape.cpx1, shape.cpy1 - halfExtent,
  37524. shape.cpx2, shape.cpy2 - halfExtent,
  37525. shape.x2, shape.y2 - halfExtent
  37526. );
  37527. ctx.lineTo(shape.x2, shape.y2 + halfExtent);
  37528. ctx.bezierCurveTo(
  37529. shape.cpx2, shape.cpy2 + halfExtent,
  37530. shape.cpx1, shape.cpy1 + halfExtent,
  37531. shape.x1, shape.y1 + halfExtent
  37532. );
  37533. ctx.closePath();
  37534. }
  37535. });
  37536. module.exports = __webpack_require__(1).extendChartView({
  37537. type: 'sankey',
  37538. /**
  37539. * @private
  37540. * @type {module:echarts/chart/sankey/SankeySeries}
  37541. */
  37542. _model: null,
  37543. render: function (seriesModel, ecModel, api) {
  37544. var graph = seriesModel.getGraph();
  37545. var group = this.group;
  37546. var layoutInfo = seriesModel.layoutInfo;
  37547. var nodeData = seriesModel.getData();
  37548. var edgeData = seriesModel.getData('edge');
  37549. this._model = seriesModel;
  37550. group.removeAll();
  37551. group.position = [layoutInfo.x, layoutInfo.y];
  37552. // generate a bezire Curve for each edge
  37553. graph.eachEdge(function (edge) {
  37554. var curve = new SankeyShape();
  37555. curve.dataIndex = edge.dataIndex;
  37556. curve.seriesIndex = seriesModel.seriesIndex;
  37557. curve.dataType = 'edge';
  37558. var lineStyleModel = edge.getModel('lineStyle.normal');
  37559. var curvature = lineStyleModel.get('curveness');
  37560. var n1Layout = edge.node1.getLayout();
  37561. var n2Layout = edge.node2.getLayout();
  37562. var edgeLayout = edge.getLayout();
  37563. curve.shape.extent = Math.max(1, edgeLayout.dy);
  37564. var x1 = n1Layout.x + n1Layout.dx;
  37565. var y1 = n1Layout.y + edgeLayout.sy + edgeLayout.dy / 2;
  37566. var x2 = n2Layout.x;
  37567. var y2 = n2Layout.y + edgeLayout.ty + edgeLayout.dy / 2;
  37568. var cpx1 = x1 * (1 - curvature) + x2 * curvature;
  37569. var cpy1 = y1;
  37570. var cpx2 = x1 * curvature + x2 * (1 - curvature);
  37571. var cpy2 = y2;
  37572. curve.setShape({
  37573. x1: x1,
  37574. y1: y1,
  37575. x2: x2,
  37576. y2: y2,
  37577. cpx1: cpx1,
  37578. cpy1: cpy1,
  37579. cpx2: cpx2,
  37580. cpy2: cpy2
  37581. });
  37582. curve.setStyle(lineStyleModel.getItemStyle());
  37583. // Special color, use source node color or target node color
  37584. switch (curve.style.fill) {
  37585. case 'source':
  37586. curve.style.fill = edge.node1.getVisual('color');
  37587. break;
  37588. case 'target':
  37589. curve.style.fill = edge.node2.getVisual('color');
  37590. break;
  37591. }
  37592. graphic.setHoverStyle(curve, edge.getModel('lineStyle.emphasis').getItemStyle());
  37593. group.add(curve);
  37594. edgeData.setItemGraphicEl(edge.dataIndex, curve);
  37595. });
  37596. // generate a rect for each node
  37597. graph.eachNode(function (node) {
  37598. var layout = node.getLayout();
  37599. var itemModel = node.getModel();
  37600. var labelModel = itemModel.getModel('label.normal');
  37601. var textStyleModel = labelModel.getModel('textStyle');
  37602. var labelHoverModel = itemModel.getModel('label.emphasis');
  37603. var textStyleHoverModel = labelHoverModel.getModel('textStyle');
  37604. var rect = new graphic.Rect({
  37605. shape: {
  37606. x: layout.x,
  37607. y: layout.y,
  37608. width: node.getLayout().dx,
  37609. height: node.getLayout().dy
  37610. },
  37611. style: {
  37612. // Get formatted label in label.normal option
  37613. // Use node id if it is not specified
  37614. text: labelModel.get('show')
  37615. ? seriesModel.getFormattedLabel(node.dataIndex, 'normal') || node.id
  37616. // Use empty string to hide the label
  37617. : '',
  37618. textFont: textStyleModel.getFont(),
  37619. textFill: textStyleModel.getTextColor(),
  37620. textPosition: labelModel.get('position')
  37621. }
  37622. });
  37623. rect.setStyle(zrUtil.defaults(
  37624. {
  37625. fill: node.getVisual('color')
  37626. },
  37627. itemModel.getModel('itemStyle.normal').getItemStyle()
  37628. ));
  37629. graphic.setHoverStyle(rect, zrUtil.extend(
  37630. node.getModel('itemStyle.emphasis'),
  37631. {
  37632. text: labelHoverModel.get('show')
  37633. ? seriesModel.getFormattedLabel(node.dataIndex, 'emphasis') || node.id
  37634. : '',
  37635. textFont: textStyleHoverModel.getFont(),
  37636. textFill: textStyleHoverModel.getTextColor(),
  37637. textPosition: labelHoverModel.get('position')
  37638. }
  37639. ));
  37640. group.add(rect);
  37641. nodeData.setItemGraphicEl(node.dataIndex, rect);
  37642. rect.dataType = 'node';
  37643. });
  37644. if (!this._data && seriesModel.get('animation')) {
  37645. group.setClipPath(createGridClipShape(group.getBoundingRect(), seriesModel, function () {
  37646. group.removeClipPath();
  37647. }));
  37648. }
  37649. this._data = seriesModel.getData();
  37650. },
  37651. dispose: function () {}
  37652. });
  37653. // add animation to the view
  37654. function createGridClipShape(rect, seriesModel, cb) {
  37655. var rectEl = new graphic.Rect({
  37656. shape: {
  37657. x: rect.x - 10,
  37658. y: rect.y - 10,
  37659. width: 0,
  37660. height: rect.height + 20
  37661. }
  37662. });
  37663. graphic.initProps(rectEl, {
  37664. shape: {
  37665. width: rect.width + 20,
  37666. height: rect.height + 20
  37667. }
  37668. }, seriesModel, cb);
  37669. return rectEl;
  37670. }
  37671. /***/ },
  37672. /* 243 */
  37673. /***/ function(module, exports, __webpack_require__) {
  37674. /**
  37675. * @file The layout algorithm of sankey view
  37676. * @author Deqing Li(annong035@gmail.com)
  37677. */
  37678. var layout = __webpack_require__(21);
  37679. var nest = __webpack_require__(244);
  37680. var zrUtil = __webpack_require__(4);
  37681. module.exports = function (ecModel, api, payload) {
  37682. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  37683. var nodeWidth = seriesModel.get('nodeWidth');
  37684. var nodeGap = seriesModel.get('nodeGap');
  37685. var layoutInfo = getViewRect(seriesModel, api);
  37686. seriesModel.layoutInfo = layoutInfo;
  37687. var width = layoutInfo.width;
  37688. var height = layoutInfo.height;
  37689. var graph = seriesModel.getGraph();
  37690. var nodes = graph.nodes;
  37691. var edges = graph.edges;
  37692. computeNodeValues(nodes);
  37693. var filteredNodes = nodes.filter(function (node) {
  37694. return node.getLayout().value === 0;
  37695. });
  37696. var iterations = filteredNodes.length !== 0
  37697. ? 0 : seriesModel.get('layoutIterations');
  37698. layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations);
  37699. });
  37700. };
  37701. /**
  37702. * Get the layout position of the whole view
  37703. *
  37704. * @param {module:echarts/model/Series} seriesModel the model object of sankey series
  37705. * @param {module:echarts/ExtensionAPI} api provide the API list that the developer can call
  37706. * @return {module:zrender/core/BoundingRect} size of rect to draw the sankey view
  37707. */
  37708. function getViewRect(seriesModel, api) {
  37709. return layout.getLayoutRect(
  37710. seriesModel.getBoxLayoutParams(), {
  37711. width: api.getWidth(),
  37712. height: api.getHeight()
  37713. }
  37714. );
  37715. }
  37716. function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations) {
  37717. computeNodeBreadths(nodes, nodeWidth, width);
  37718. computeNodeDepths(nodes, edges, height, nodeGap, iterations);
  37719. computeEdgeDepths(nodes);
  37720. }
  37721. /**
  37722. * Compute the value of each node by summing the associated edge's value
  37723. *
  37724. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  37725. */
  37726. function computeNodeValues(nodes) {
  37727. zrUtil.each(nodes, function (node) {
  37728. var value1 = sum(node.outEdges, getEdgeValue);
  37729. var value2 = sum(node.inEdges, getEdgeValue);
  37730. var value = Math.max(value1, value2);
  37731. node.setLayout({value: value}, true);
  37732. });
  37733. }
  37734. /**
  37735. * Compute the x-position for each node
  37736. *
  37737. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  37738. * @param {number} nodeWidth the dx of the node
  37739. * @param {number} width the whole width of the area to draw the view
  37740. */
  37741. function computeNodeBreadths(nodes, nodeWidth, width) {
  37742. var remainNodes = nodes;
  37743. var nextNode = null;
  37744. var x = 0;
  37745. var kx = 0;
  37746. while (remainNodes.length) {
  37747. nextNode = [];
  37748. for (var i = 0, len = remainNodes.length; i < len; i++) {
  37749. var node = remainNodes[i];
  37750. node.setLayout({x: x}, true);
  37751. node.setLayout({dx: nodeWidth}, true);
  37752. for (var j = 0, lenj = node.outEdges.length; j < lenj; j++) {
  37753. nextNode.push(node.outEdges[j].node2);
  37754. }
  37755. }
  37756. remainNodes = nextNode;
  37757. ++x;
  37758. }
  37759. moveSinksRight(nodes, x);
  37760. kx = (width - nodeWidth) / (x - 1);
  37761. scaleNodeBreadths(nodes, kx);
  37762. }
  37763. /**
  37764. * All the node without outEgdes are assigned maximum x-position and
  37765. * be aligned in the last column.
  37766. *
  37767. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  37768. * @param {number} x value (x-1) use to assign to node without outEdges
  37769. * as x-position
  37770. */
  37771. function moveSinksRight(nodes, x) {
  37772. zrUtil.each(nodes, function (node) {
  37773. if (!node.outEdges.length) {
  37774. node.setLayout({x: x - 1}, true);
  37775. }
  37776. });
  37777. }
  37778. /**
  37779. * Scale node x-position to the width
  37780. *
  37781. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  37782. * @param {number} kx multiple used to scale nodes
  37783. */
  37784. function scaleNodeBreadths(nodes, kx) {
  37785. zrUtil.each(nodes, function (node) {
  37786. var nodeX = node.getLayout().x * kx;
  37787. node.setLayout({x: nodeX}, true);
  37788. });
  37789. }
  37790. /**
  37791. * Using Gauss-Seidel iterations method to compute the node depth(y-position)
  37792. *
  37793. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  37794. * @param {module:echarts/data/Graph~Edge} edges edge of sankey view
  37795. * @param {number} height the whole height of the area to draw the view
  37796. * @param {numbber} nodeGap the vertical distance between two nodes
  37797. * in the same column.
  37798. * @param {number} iterations the number of iterations for the algorithm
  37799. */
  37800. function computeNodeDepths(nodes, edges, height, nodeGap, iterations) {
  37801. var nodesByBreadth = nest()
  37802. .key(function (d) {
  37803. return d.getLayout().x;
  37804. })
  37805. .sortKeys(ascending)
  37806. .entries(nodes)
  37807. .map(function (d) {
  37808. return d.values;
  37809. });
  37810. initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap);
  37811. resolveCollisions(nodesByBreadth, nodeGap, height);
  37812. for (var alpha = 1; iterations > 0; iterations--) {
  37813. // 0.99 is a experience parameter, ensure that each iterations of
  37814. // changes as small as possible.
  37815. alpha *= 0.99;
  37816. relaxRightToLeft(nodesByBreadth, alpha);
  37817. resolveCollisions(nodesByBreadth, nodeGap, height);
  37818. relaxLeftToRight(nodesByBreadth, alpha);
  37819. resolveCollisions(nodesByBreadth, nodeGap, height);
  37820. }
  37821. }
  37822. /**
  37823. * Compute the original y-position for each node
  37824. *
  37825. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  37826. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  37827. * group by the array of all sankey nodes based on the nodes x-position.
  37828. * @param {module:echarts/data/Graph~Edge} edges edge of sankey view
  37829. * @param {number} height the whole height of the area to draw the view
  37830. * @param {number} nodeGap the vertical distance between two nodes
  37831. */
  37832. function initializeNodeDepth(nodes, nodesByBreadth, edges, height, nodeGap) {
  37833. var kyArray = [];
  37834. zrUtil.each(nodesByBreadth, function (nodes) {
  37835. var n = nodes.length;
  37836. var sum = 0;
  37837. zrUtil.each(nodes, function (node) {
  37838. sum += node.getLayout().value;
  37839. });
  37840. var ky = (height - (n - 1) * nodeGap) / sum;
  37841. kyArray.push(ky);
  37842. });
  37843. kyArray.sort(function (a, b) {
  37844. return a - b;
  37845. });
  37846. var ky0 = kyArray[0];
  37847. zrUtil.each(nodesByBreadth, function (nodes) {
  37848. zrUtil.each(nodes, function (node, i) {
  37849. node.setLayout({y: i}, true);
  37850. var nodeDy = node.getLayout().value * ky0;
  37851. node.setLayout({dy: nodeDy}, true);
  37852. });
  37853. });
  37854. zrUtil.each(edges, function (edge) {
  37855. var edgeDy = +edge.getValue() * ky0;
  37856. edge.setLayout({dy: edgeDy}, true);
  37857. });
  37858. }
  37859. /**
  37860. * Resolve the collision of initialized depth (y-position)
  37861. *
  37862. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  37863. * group by the array of all sankey nodes based on the nodes x-position.
  37864. * @param {number} nodeGap the vertical distance between two nodes
  37865. * @param {number} height the whole height of the area to draw the view
  37866. */
  37867. function resolveCollisions(nodesByBreadth, nodeGap, height) {
  37868. zrUtil.each(nodesByBreadth, function (nodes) {
  37869. var node;
  37870. var dy;
  37871. var y0 = 0;
  37872. var n = nodes.length;
  37873. var i;
  37874. nodes.sort(ascendingDepth);
  37875. for (i = 0; i < n; i++) {
  37876. node = nodes[i];
  37877. dy = y0 - node.getLayout().y;
  37878. if (dy > 0) {
  37879. var nodeY = node.getLayout().y + dy;
  37880. node.setLayout({y: nodeY}, true);
  37881. }
  37882. y0 = node.getLayout().y + node.getLayout().dy + nodeGap;
  37883. }
  37884. // if the bottommost node goes outside the bounds, push it back up
  37885. dy = y0 - nodeGap - height;
  37886. if (dy > 0) {
  37887. var nodeY = node.getLayout().y - dy;
  37888. node.setLayout({y: nodeY}, true);
  37889. y0 = node.getLayout().y;
  37890. for (i = n - 2; i >= 0; --i) {
  37891. node = nodes[i];
  37892. dy = node.getLayout().y + node.getLayout().dy + nodeGap - y0;
  37893. if (dy > 0) {
  37894. nodeY = node.getLayout().y - dy;
  37895. node.setLayout({y: nodeY}, true);
  37896. }
  37897. y0 = node.getLayout().y;
  37898. }
  37899. }
  37900. });
  37901. }
  37902. /**
  37903. * Change the y-position of the nodes, except most the right side nodes
  37904. *
  37905. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  37906. * group by the array of all sankey nodes based on the node x-position.
  37907. * @param {number} alpha parameter used to adjust the nodes y-position
  37908. */
  37909. function relaxRightToLeft(nodesByBreadth, alpha) {
  37910. zrUtil.each(nodesByBreadth.slice().reverse(), function (nodes) {
  37911. zrUtil.each(nodes, function (node) {
  37912. if (node.outEdges.length) {
  37913. var y = sum(node.outEdges, weightedTarget) / sum(node.outEdges, getEdgeValue);
  37914. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  37915. node.setLayout({y: nodeY}, true);
  37916. }
  37917. });
  37918. });
  37919. }
  37920. function weightedTarget(edge) {
  37921. return center(edge.node2) * edge.getValue();
  37922. }
  37923. /**
  37924. * Change the y-position of the nodes, except most the left side nodes
  37925. *
  37926. * @param {Array.<Array.<module:echarts/data/Graph~Node>>} nodesByBreadth
  37927. * group by the array of all sankey nodes based on the node x-position.
  37928. * @param {number} alpha parameter used to adjust the nodes y-position
  37929. */
  37930. function relaxLeftToRight(nodesByBreadth, alpha) {
  37931. zrUtil.each(nodesByBreadth, function (nodes) {
  37932. zrUtil.each(nodes, function (node) {
  37933. if (node.inEdges.length) {
  37934. var y = sum(node.inEdges, weightedSource) / sum(node.inEdges, getEdgeValue);
  37935. var nodeY = node.getLayout().y + (y - center(node)) * alpha;
  37936. node.setLayout({y: nodeY}, true);
  37937. }
  37938. });
  37939. });
  37940. }
  37941. function weightedSource(edge) {
  37942. return center(edge.node1) * edge.getValue();
  37943. }
  37944. /**
  37945. * Compute the depth(y-position) of each edge
  37946. *
  37947. * @param {module:echarts/data/Graph~Node} nodes node of sankey view
  37948. */
  37949. function computeEdgeDepths(nodes) {
  37950. zrUtil.each(nodes, function (node) {
  37951. node.outEdges.sort(ascendingTargetDepth);
  37952. node.inEdges.sort(ascendingSourceDepth);
  37953. });
  37954. zrUtil.each(nodes, function (node) {
  37955. var sy = 0;
  37956. var ty = 0;
  37957. zrUtil.each(node.outEdges, function (edge) {
  37958. edge.setLayout({sy: sy}, true);
  37959. sy += edge.getLayout().dy;
  37960. });
  37961. zrUtil.each(node.inEdges, function (edge) {
  37962. edge.setLayout({ty: ty}, true);
  37963. ty += edge.getLayout().dy;
  37964. });
  37965. });
  37966. }
  37967. function ascendingTargetDepth(a, b) {
  37968. return a.node2.getLayout().y - b.node2.getLayout().y;
  37969. }
  37970. function ascendingSourceDepth(a, b) {
  37971. return a.node1.getLayout().y - b.node1.getLayout().y;
  37972. }
  37973. function sum(array, f) {
  37974. var sum = 0;
  37975. var len = array.length;
  37976. var i = -1;
  37977. while (++i < len) {
  37978. var value = +f.call(array, array[i], i);
  37979. if (!isNaN(value)) {
  37980. sum += value;
  37981. }
  37982. }
  37983. return sum;
  37984. }
  37985. function center(node) {
  37986. return node.getLayout().y + node.getLayout().dy / 2;
  37987. }
  37988. function ascendingDepth(a, b) {
  37989. return a.getLayout().y - b.getLayout().y;
  37990. }
  37991. function ascending(a, b) {
  37992. return a < b ? -1 : a > b ? 1 : a === b ? 0 : NaN;
  37993. }
  37994. function getEdgeValue(edge) {
  37995. return edge.getValue();
  37996. }
  37997. /***/ },
  37998. /* 244 */
  37999. /***/ function(module, exports, __webpack_require__) {
  38000. var zrUtil = __webpack_require__(4);
  38001. /**
  38002. * nest helper used to group by the array.
  38003. * can specified the keys and sort the keys.
  38004. */
  38005. function nest() {
  38006. var keysFunction = [];
  38007. var sortKeysFunction = [];
  38008. /**
  38009. * map an Array into the mapObject.
  38010. * @param {Array} array
  38011. * @param {number} depth
  38012. */
  38013. function map(array, depth) {
  38014. if (depth >= keysFunction.length) {
  38015. return array;
  38016. }
  38017. var i = -1;
  38018. var n = array.length;
  38019. var keyFunction = keysFunction[depth++];
  38020. var mapObject = {};
  38021. var valuesByKey = {};
  38022. while (++i < n) {
  38023. var keyValue = keyFunction(array[i]);
  38024. var values = valuesByKey[keyValue];
  38025. if (values) {
  38026. values.push(array[i]);
  38027. }
  38028. else {
  38029. valuesByKey[keyValue] = [array[i]];
  38030. }
  38031. }
  38032. zrUtil.each(valuesByKey, function (value, key) {
  38033. mapObject[key] = map(value, depth);
  38034. });
  38035. return mapObject;
  38036. }
  38037. /**
  38038. * transform the Map Object to multidimensional Array
  38039. * @param {Object} map
  38040. * @param {number} depth
  38041. */
  38042. function entriesMap(mapObject, depth) {
  38043. if (depth >= keysFunction.length) {
  38044. return mapObject;
  38045. }
  38046. var array = [];
  38047. var sortKeyFunction = sortKeysFunction[depth++];
  38048. zrUtil.each(mapObject, function (value, key) {
  38049. array.push({
  38050. key: key, values: entriesMap(value, depth)
  38051. });
  38052. });
  38053. if (sortKeyFunction) {
  38054. return array.sort(function (a, b) {
  38055. return sortKeyFunction(a.key, b.key);
  38056. });
  38057. }
  38058. else {
  38059. return array;
  38060. }
  38061. }
  38062. return {
  38063. /**
  38064. * specified the key to groupby the arrays.
  38065. * users can specified one more keys.
  38066. * @param {Function} d
  38067. */
  38068. key: function (d) {
  38069. keysFunction.push(d);
  38070. return this;
  38071. },
  38072. /**
  38073. * specified the comparator to sort the keys
  38074. * @param {Function} order
  38075. */
  38076. sortKeys: function (order) {
  38077. sortKeysFunction[keysFunction.length - 1] = order;
  38078. return this;
  38079. },
  38080. /**
  38081. * the array to be grouped by.
  38082. * @param {Array} array
  38083. */
  38084. entries: function (array) {
  38085. return entriesMap(map(array, 0), 0);
  38086. }
  38087. };
  38088. }
  38089. module.exports = nest;
  38090. /***/ },
  38091. /* 245 */
  38092. /***/ function(module, exports, __webpack_require__) {
  38093. /**
  38094. * @file Visual encoding for sankey view
  38095. * @author Deqing Li(annong035@gmail.com)
  38096. */
  38097. var VisualMapping = __webpack_require__(194);
  38098. var zrUtil = __webpack_require__(4);
  38099. module.exports = function (ecModel, payload) {
  38100. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  38101. var graph = seriesModel.getGraph();
  38102. var nodes = graph.nodes;
  38103. nodes.sort(function (a, b) {
  38104. return a.getLayout().value - b.getLayout().value;
  38105. });
  38106. var minValue = nodes[0].getLayout().value;
  38107. var maxValue = nodes[nodes.length - 1].getLayout().value;
  38108. zrUtil.each(nodes, function (node) {
  38109. var mapping = new VisualMapping({
  38110. type: 'color',
  38111. mappingMethod: 'linear',
  38112. dataExtent: [minValue, maxValue],
  38113. visual: seriesModel.get('color')
  38114. });
  38115. var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value);
  38116. node.setVisual('color', mapValueToColor);
  38117. // If set itemStyle.normal.color
  38118. var itemModel = node.getModel();
  38119. var customColor = itemModel.get('itemStyle.normal.color');
  38120. if (customColor != null) {
  38121. node.setVisual('color', customColor);
  38122. }
  38123. });
  38124. });
  38125. };
  38126. /***/ },
  38127. /* 246 */
  38128. /***/ function(module, exports, __webpack_require__) {
  38129. var echarts = __webpack_require__(1);
  38130. __webpack_require__(247);
  38131. __webpack_require__(250);
  38132. echarts.registerVisual(__webpack_require__(251));
  38133. echarts.registerLayout(__webpack_require__(252));
  38134. /***/ },
  38135. /* 247 */
  38136. /***/ function(module, exports, __webpack_require__) {
  38137. 'use strict';
  38138. var zrUtil = __webpack_require__(4);
  38139. var SeriesModel = __webpack_require__(28);
  38140. var whiskerBoxCommon = __webpack_require__(248);
  38141. var BoxplotSeries = SeriesModel.extend({
  38142. type: 'series.boxplot',
  38143. dependencies: ['xAxis', 'yAxis', 'grid'],
  38144. // TODO
  38145. // box width represents group size, so dimension should have 'size'.
  38146. /**
  38147. * @see <https://en.wikipedia.org/wiki/Box_plot>
  38148. * The meanings of 'min' and 'max' depend on user,
  38149. * and echarts do not need to know it.
  38150. * @readOnly
  38151. */
  38152. valueDimensions: ['min', 'Q1', 'median', 'Q3', 'max'],
  38153. /**
  38154. * @type {Array.<string>}
  38155. * @readOnly
  38156. */
  38157. dimensions: null,
  38158. /**
  38159. * @override
  38160. */
  38161. defaultOption: {
  38162. zlevel: 0, // 一级层叠
  38163. z: 2, // 二级层叠
  38164. coordinateSystem: 'cartesian2d',
  38165. legendHoverLink: true,
  38166. hoverAnimation: true,
  38167. // xAxisIndex: 0,
  38168. // yAxisIndex: 0,
  38169. layout: null, // 'horizontal' or 'vertical'
  38170. boxWidth: [7, 50], // [min, max] can be percent of band width.
  38171. itemStyle: {
  38172. normal: {
  38173. color: '#fff',
  38174. borderWidth: 1
  38175. },
  38176. emphasis: {
  38177. borderWidth: 2,
  38178. shadowBlur: 5,
  38179. shadowOffsetX: 2,
  38180. shadowOffsetY: 2,
  38181. shadowColor: 'rgba(0,0,0,0.4)'
  38182. }
  38183. },
  38184. animationEasing: 'elasticOut',
  38185. animationDuration: 800
  38186. }
  38187. });
  38188. zrUtil.mixin(BoxplotSeries, whiskerBoxCommon.seriesModelMixin, true);
  38189. module.exports = BoxplotSeries;
  38190. /***/ },
  38191. /* 248 */
  38192. /***/ function(module, exports, __webpack_require__) {
  38193. 'use strict';
  38194. var List = __webpack_require__(98);
  38195. var completeDimensions = __webpack_require__(103);
  38196. var WhiskerBoxDraw = __webpack_require__(249);
  38197. var zrUtil = __webpack_require__(4);
  38198. function getItemValue(item) {
  38199. return item.value == null ? item : item.value;
  38200. }
  38201. var seriesModelMixin = {
  38202. /**
  38203. * @private
  38204. * @type {string}
  38205. */
  38206. _baseAxisDim: null,
  38207. /**
  38208. * @override
  38209. */
  38210. getInitialData: function (option, ecModel) {
  38211. // When both types of xAxis and yAxis are 'value', layout is
  38212. // needed to be specified by user. Otherwise, layout can be
  38213. // judged by which axis is category.
  38214. var categories;
  38215. var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
  38216. var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
  38217. var xAxisType = xAxisModel.get('type');
  38218. var yAxisType = yAxisModel.get('type');
  38219. var addOrdinal;
  38220. // FIXME
  38221. // 考虑时间轴
  38222. if (xAxisType === 'category') {
  38223. option.layout = 'horizontal';
  38224. categories = xAxisModel.getCategories();
  38225. addOrdinal = true;
  38226. }
  38227. else if (yAxisType === 'category') {
  38228. option.layout = 'vertical';
  38229. categories = yAxisModel.getCategories();
  38230. addOrdinal = true;
  38231. }
  38232. else {
  38233. option.layout = option.layout || 'horizontal';
  38234. }
  38235. this._baseAxisDim = option.layout === 'horizontal' ? 'x' : 'y';
  38236. var data = option.data;
  38237. var dimensions = this.dimensions = ['base'].concat(this.valueDimensions);
  38238. completeDimensions(dimensions, data);
  38239. var list = new List(dimensions, this);
  38240. list.initData(data, categories ? categories.slice() : null, function (dataItem, dimName, idx, dimIdx) {
  38241. var value = getItemValue(dataItem);
  38242. return addOrdinal ? (dimName === 'base' ? idx : value[dimIdx - 1]) : value[dimIdx];
  38243. });
  38244. return list;
  38245. },
  38246. /**
  38247. * Used by Gird.
  38248. * @param {string} axisDim 'x' or 'y'
  38249. * @return {Array.<string>} dimensions on the axis.
  38250. */
  38251. coordDimToDataDim: function (axisDim) {
  38252. var dims = this.valueDimensions.slice();
  38253. var baseDim = ['base'];
  38254. var map = {
  38255. horizontal: {x: baseDim, y: dims},
  38256. vertical: {x: dims, y: baseDim}
  38257. };
  38258. return map[this.get('layout')][axisDim];
  38259. },
  38260. /**
  38261. * @override
  38262. * @param {string|number} dataDim
  38263. * @return {string} coord dimension
  38264. */
  38265. dataDimToCoordDim: function (dataDim) {
  38266. var dim;
  38267. zrUtil.each(['x', 'y'], function (coordDim, index) {
  38268. var dataDims = this.coordDimToDataDim(coordDim);
  38269. if (zrUtil.indexOf(dataDims, dataDim) >= 0) {
  38270. dim = coordDim;
  38271. }
  38272. }, this);
  38273. return dim;
  38274. },
  38275. /**
  38276. * If horizontal, base axis is x, otherwise y.
  38277. * @override
  38278. */
  38279. getBaseAxis: function () {
  38280. var dim = this._baseAxisDim;
  38281. return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
  38282. }
  38283. };
  38284. var viewMixin = {
  38285. init: function () {
  38286. /**
  38287. * Old data.
  38288. * @private
  38289. * @type {module:echarts/chart/helper/WhiskerBoxDraw}
  38290. */
  38291. var whiskerBoxDraw = this._whiskerBoxDraw = new WhiskerBoxDraw(
  38292. this.getStyleUpdater()
  38293. );
  38294. this.group.add(whiskerBoxDraw.group);
  38295. },
  38296. render: function (seriesModel, ecModel, api) {
  38297. this._whiskerBoxDraw.updateData(seriesModel.getData());
  38298. },
  38299. remove: function (ecModel) {
  38300. this._whiskerBoxDraw.remove();
  38301. }
  38302. };
  38303. module.exports = {
  38304. seriesModelMixin: seriesModelMixin,
  38305. viewMixin: viewMixin
  38306. };
  38307. /***/ },
  38308. /* 249 */
  38309. /***/ function(module, exports, __webpack_require__) {
  38310. /**
  38311. * @module echarts/chart/helper/Symbol
  38312. */
  38313. var zrUtil = __webpack_require__(4);
  38314. var graphic = __webpack_require__(43);
  38315. var Path = __webpack_require__(45);
  38316. var WhiskerPath = Path.extend({
  38317. type: 'whiskerInBox',
  38318. shape: {},
  38319. buildPath: function (ctx, shape) {
  38320. for (var i in shape) {
  38321. if (shape.hasOwnProperty(i) && i.indexOf('ends') === 0) {
  38322. var pts = shape[i];
  38323. ctx.moveTo(pts[0][0], pts[0][1]);
  38324. ctx.lineTo(pts[1][0], pts[1][1]);
  38325. }
  38326. }
  38327. }
  38328. });
  38329. /**
  38330. * @constructor
  38331. * @alias {module:echarts/chart/helper/WhiskerBox}
  38332. * @param {module:echarts/data/List} data
  38333. * @param {number} idx
  38334. * @param {Function} styleUpdater
  38335. * @param {boolean} isInit
  38336. * @extends {module:zrender/graphic/Group}
  38337. */
  38338. function WhiskerBox(data, idx, styleUpdater, isInit) {
  38339. graphic.Group.call(this);
  38340. /**
  38341. * @type {number}
  38342. * @readOnly
  38343. */
  38344. this.bodyIndex;
  38345. /**
  38346. * @type {number}
  38347. * @readOnly
  38348. */
  38349. this.whiskerIndex;
  38350. /**
  38351. * @type {Function}
  38352. */
  38353. this.styleUpdater = styleUpdater;
  38354. this._createContent(data, idx, isInit);
  38355. this.updateData(data, idx, isInit);
  38356. /**
  38357. * Last series model.
  38358. * @type {module:echarts/model/Series}
  38359. */
  38360. this._seriesModel;
  38361. }
  38362. var whiskerBoxProto = WhiskerBox.prototype;
  38363. whiskerBoxProto._createContent = function (data, idx, isInit) {
  38364. var itemLayout = data.getItemLayout(idx);
  38365. var constDim = itemLayout.chartLayout === 'horizontal' ? 1 : 0;
  38366. var count = 0;
  38367. // Whisker element.
  38368. this.add(new graphic.Polygon({
  38369. shape: {
  38370. points: isInit
  38371. ? transInit(itemLayout.bodyEnds, constDim, itemLayout)
  38372. : itemLayout.bodyEnds
  38373. },
  38374. style: {strokeNoScale: true},
  38375. z2: 100
  38376. }));
  38377. this.bodyIndex = count++;
  38378. // Box element.
  38379. var whiskerEnds = zrUtil.map(itemLayout.whiskerEnds, function (ends) {
  38380. return isInit ? transInit(ends, constDim, itemLayout) : ends;
  38381. });
  38382. this.add(new WhiskerPath({
  38383. shape: makeWhiskerEndsShape(whiskerEnds),
  38384. style: {strokeNoScale: true},
  38385. z2: 100
  38386. }));
  38387. this.whiskerIndex = count++;
  38388. };
  38389. function transInit(points, dim, itemLayout) {
  38390. return zrUtil.map(points, function (point) {
  38391. point = point.slice();
  38392. point[dim] = itemLayout.initBaseline;
  38393. return point;
  38394. });
  38395. }
  38396. function makeWhiskerEndsShape(whiskerEnds) {
  38397. // zr animation only support 2-dim array.
  38398. var shape = {};
  38399. zrUtil.each(whiskerEnds, function (ends, i) {
  38400. shape['ends' + i] = ends;
  38401. });
  38402. return shape;
  38403. }
  38404. /**
  38405. * Update symbol properties
  38406. * @param {module:echarts/data/List} data
  38407. * @param {number} idx
  38408. */
  38409. whiskerBoxProto.updateData = function (data, idx, isInit) {
  38410. var seriesModel = this._seriesModel = data.hostModel;
  38411. var itemLayout = data.getItemLayout(idx);
  38412. var updateMethod = graphic[isInit ? 'initProps' : 'updateProps'];
  38413. // this.childAt(this.bodyIndex).stopAnimation(true);
  38414. // this.childAt(this.whiskerIndex).stopAnimation(true);
  38415. updateMethod(
  38416. this.childAt(this.bodyIndex),
  38417. {shape: {points: itemLayout.bodyEnds}},
  38418. seriesModel, idx
  38419. );
  38420. updateMethod(
  38421. this.childAt(this.whiskerIndex),
  38422. {shape: makeWhiskerEndsShape(itemLayout.whiskerEnds)},
  38423. seriesModel, idx
  38424. );
  38425. this.styleUpdater.call(null, this, data, idx);
  38426. };
  38427. zrUtil.inherits(WhiskerBox, graphic.Group);
  38428. /**
  38429. * @constructor
  38430. * @alias module:echarts/chart/helper/WhiskerBoxDraw
  38431. */
  38432. function WhiskerBoxDraw(styleUpdater) {
  38433. this.group = new graphic.Group();
  38434. this.styleUpdater = styleUpdater;
  38435. }
  38436. var whiskerBoxDrawProto = WhiskerBoxDraw.prototype;
  38437. /**
  38438. * Update symbols draw by new data
  38439. * @param {module:echarts/data/List} data
  38440. */
  38441. whiskerBoxDrawProto.updateData = function (data) {
  38442. var group = this.group;
  38443. var oldData = this._data;
  38444. var styleUpdater = this.styleUpdater;
  38445. data.diff(oldData)
  38446. .add(function (newIdx) {
  38447. if (data.hasValue(newIdx)) {
  38448. var symbolEl = new WhiskerBox(data, newIdx, styleUpdater, true);
  38449. data.setItemGraphicEl(newIdx, symbolEl);
  38450. group.add(symbolEl);
  38451. }
  38452. })
  38453. .update(function (newIdx, oldIdx) {
  38454. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  38455. // Empty data
  38456. if (!data.hasValue(newIdx)) {
  38457. group.remove(symbolEl);
  38458. return;
  38459. }
  38460. if (!symbolEl) {
  38461. symbolEl = new WhiskerBox(data, newIdx, styleUpdater);
  38462. }
  38463. else {
  38464. symbolEl.updateData(data, newIdx);
  38465. }
  38466. // Add back
  38467. group.add(symbolEl);
  38468. data.setItemGraphicEl(newIdx, symbolEl);
  38469. })
  38470. .remove(function (oldIdx) {
  38471. var el = oldData.getItemGraphicEl(oldIdx);
  38472. el && group.remove(el);
  38473. })
  38474. .execute();
  38475. this._data = data;
  38476. };
  38477. /**
  38478. * Remove symbols.
  38479. * @param {module:echarts/data/List} data
  38480. */
  38481. whiskerBoxDrawProto.remove = function () {
  38482. var group = this.group;
  38483. var data = this._data;
  38484. this._data = null;
  38485. data && data.eachItemGraphicEl(function (el) {
  38486. el && group.remove(el);
  38487. });
  38488. };
  38489. module.exports = WhiskerBoxDraw;
  38490. /***/ },
  38491. /* 250 */
  38492. /***/ function(module, exports, __webpack_require__) {
  38493. 'use strict';
  38494. var zrUtil = __webpack_require__(4);
  38495. var ChartView = __webpack_require__(42);
  38496. var graphic = __webpack_require__(43);
  38497. var whiskerBoxCommon = __webpack_require__(248);
  38498. var BoxplotView = ChartView.extend({
  38499. type: 'boxplot',
  38500. getStyleUpdater: function () {
  38501. return updateStyle;
  38502. },
  38503. dispose: zrUtil.noop
  38504. });
  38505. zrUtil.mixin(BoxplotView, whiskerBoxCommon.viewMixin, true);
  38506. // Update common properties
  38507. var normalStyleAccessPath = ['itemStyle', 'normal'];
  38508. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  38509. function updateStyle(itemGroup, data, idx) {
  38510. var itemModel = data.getItemModel(idx);
  38511. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  38512. var borderColor = data.getItemVisual(idx, 'color');
  38513. // Exclude borderColor.
  38514. var itemStyle = normalItemStyleModel.getItemStyle(['borderColor']);
  38515. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  38516. whiskerEl.style.set(itemStyle);
  38517. whiskerEl.style.stroke = borderColor;
  38518. whiskerEl.dirty();
  38519. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  38520. bodyEl.style.set(itemStyle);
  38521. bodyEl.style.stroke = borderColor;
  38522. bodyEl.dirty();
  38523. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  38524. graphic.setHoverStyle(itemGroup, hoverStyle);
  38525. }
  38526. module.exports = BoxplotView;
  38527. /***/ },
  38528. /* 251 */
  38529. /***/ function(module, exports) {
  38530. var borderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  38531. module.exports = function (ecModel, api) {
  38532. var globalColors = ecModel.get('color');
  38533. ecModel.eachRawSeriesByType('boxplot', function (seriesModel) {
  38534. var defaulColor = globalColors[seriesModel.seriesIndex % globalColors.length];
  38535. var data = seriesModel.getData();
  38536. data.setVisual({
  38537. legendSymbol: 'roundRect',
  38538. // Use name 'color' but not 'borderColor' for legend usage and
  38539. // visual coding from other component like dataRange.
  38540. color: seriesModel.get(borderColorQuery) || defaulColor
  38541. });
  38542. // Only visible series has each data be visual encoded
  38543. if (!ecModel.isSeriesFiltered(seriesModel)) {
  38544. data.each(function (idx) {
  38545. var itemModel = data.getItemModel(idx);
  38546. data.setItemVisual(
  38547. idx,
  38548. {color: itemModel.get(borderColorQuery, true)}
  38549. );
  38550. });
  38551. }
  38552. });
  38553. };
  38554. /***/ },
  38555. /* 252 */
  38556. /***/ function(module, exports, __webpack_require__) {
  38557. var zrUtil = __webpack_require__(4);
  38558. var numberUtil = __webpack_require__(7);
  38559. var parsePercent = numberUtil.parsePercent;
  38560. var each = zrUtil.each;
  38561. module.exports = function (ecModel) {
  38562. var groupResult = groupSeriesByAxis(ecModel);
  38563. each(groupResult, function (groupItem) {
  38564. var seriesModels = groupItem.seriesModels;
  38565. if (!seriesModels.length) {
  38566. return;
  38567. }
  38568. calculateBase(groupItem);
  38569. each(seriesModels, function (seriesModel, idx) {
  38570. layoutSingleSeries(
  38571. seriesModel,
  38572. groupItem.boxOffsetList[idx],
  38573. groupItem.boxWidthList[idx]
  38574. );
  38575. });
  38576. });
  38577. };
  38578. /**
  38579. * Group series by axis.
  38580. */
  38581. function groupSeriesByAxis(ecModel) {
  38582. var result = [];
  38583. var axisList = [];
  38584. ecModel.eachSeriesByType('boxplot', function (seriesModel) {
  38585. var baseAxis = seriesModel.getBaseAxis();
  38586. var idx = zrUtil.indexOf(axisList, baseAxis);
  38587. if (idx < 0) {
  38588. idx = axisList.length;
  38589. axisList[idx] = baseAxis;
  38590. result[idx] = {axis: baseAxis, seriesModels: []};
  38591. }
  38592. result[idx].seriesModels.push(seriesModel);
  38593. });
  38594. return result;
  38595. }
  38596. /**
  38597. * Calculate offset and box width for each series.
  38598. */
  38599. function calculateBase(groupItem) {
  38600. var extent;
  38601. var baseAxis = groupItem.axis;
  38602. var seriesModels = groupItem.seriesModels;
  38603. var seriesCount = seriesModels.length;
  38604. var boxWidthList = groupItem.boxWidthList = [];
  38605. var boxOffsetList = groupItem.boxOffsetList = [];
  38606. var boundList = [];
  38607. var bandWidth;
  38608. if (baseAxis.type === 'category') {
  38609. bandWidth = baseAxis.getBandWidth();
  38610. }
  38611. else {
  38612. var maxDataCount = 0;
  38613. each(seriesModels, function (seriesModel) {
  38614. maxDataCount = Math.max(maxDataCount, seriesModel.getData().count());
  38615. });
  38616. extent = baseAxis.getExtent(),
  38617. Math.abs(extent[1] - extent[0]) / maxDataCount;
  38618. }
  38619. each(seriesModels, function (seriesModel) {
  38620. var boxWidthBound = seriesModel.get('boxWidth');
  38621. if (!zrUtil.isArray(boxWidthBound)) {
  38622. boxWidthBound = [boxWidthBound, boxWidthBound];
  38623. }
  38624. boundList.push([
  38625. parsePercent(boxWidthBound[0], bandWidth) || 0,
  38626. parsePercent(boxWidthBound[1], bandWidth) || 0
  38627. ]);
  38628. });
  38629. var availableWidth = bandWidth * 0.8 - 2;
  38630. var boxGap = availableWidth / seriesCount * 0.3;
  38631. var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
  38632. var base = boxWidth / 2 - availableWidth / 2;
  38633. each(seriesModels, function (seriesModel, idx) {
  38634. boxOffsetList.push(base);
  38635. base += boxGap + boxWidth;
  38636. boxWidthList.push(
  38637. Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1])
  38638. );
  38639. });
  38640. }
  38641. /**
  38642. * Calculate points location for each series.
  38643. */
  38644. function layoutSingleSeries(seriesModel, offset, boxWidth) {
  38645. var coordSys = seriesModel.coordinateSystem;
  38646. var data = seriesModel.getData();
  38647. var dimensions = seriesModel.dimensions;
  38648. var chartLayout = seriesModel.get('layout');
  38649. var halfWidth = boxWidth / 2;
  38650. data.each(dimensions, function () {
  38651. var args = arguments;
  38652. var dimLen = dimensions.length;
  38653. var axisDimVal = args[0];
  38654. var idx = args[dimLen];
  38655. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  38656. var constDim = 1 - variableDim;
  38657. var median = getPoint(args[3]);
  38658. var end1 = getPoint(args[1]);
  38659. var end5 = getPoint(args[5]);
  38660. var whiskerEnds = [
  38661. [end1, getPoint(args[2])],
  38662. [end5, getPoint(args[4])]
  38663. ];
  38664. layEndLine(end1);
  38665. layEndLine(end5);
  38666. layEndLine(median);
  38667. var bodyEnds = [];
  38668. addBodyEnd(whiskerEnds[0][1], 0);
  38669. addBodyEnd(whiskerEnds[1][1], 1);
  38670. data.setItemLayout(idx, {
  38671. chartLayout: chartLayout,
  38672. initBaseline: median[constDim],
  38673. median: median,
  38674. bodyEnds: bodyEnds,
  38675. whiskerEnds: whiskerEnds
  38676. });
  38677. function getPoint(val) {
  38678. var p = [];
  38679. p[variableDim] = axisDimVal;
  38680. p[constDim] = val;
  38681. var point;
  38682. if (isNaN(axisDimVal) || isNaN(val)) {
  38683. point = [NaN, NaN];
  38684. }
  38685. else {
  38686. point = coordSys.dataToPoint(p);
  38687. point[variableDim] += offset;
  38688. }
  38689. return point;
  38690. }
  38691. function addBodyEnd(point, start) {
  38692. var point1 = point.slice();
  38693. var point2 = point.slice();
  38694. point1[variableDim] += halfWidth;
  38695. point2[variableDim] -= halfWidth;
  38696. start
  38697. ? bodyEnds.push(point1, point2)
  38698. : bodyEnds.push(point2, point1);
  38699. }
  38700. function layEndLine(endCenter) {
  38701. var line = [endCenter.slice(), endCenter.slice()];
  38702. line[0][variableDim] -= halfWidth;
  38703. line[1][variableDim] += halfWidth;
  38704. whiskerEnds.push(line);
  38705. }
  38706. });
  38707. }
  38708. /***/ },
  38709. /* 253 */
  38710. /***/ function(module, exports, __webpack_require__) {
  38711. var echarts = __webpack_require__(1);
  38712. __webpack_require__(254);
  38713. __webpack_require__(255);
  38714. echarts.registerPreprocessor(
  38715. __webpack_require__(256)
  38716. );
  38717. echarts.registerVisual(__webpack_require__(257));
  38718. echarts.registerLayout(__webpack_require__(258));
  38719. /***/ },
  38720. /* 254 */
  38721. /***/ function(module, exports, __webpack_require__) {
  38722. 'use strict';
  38723. var zrUtil = __webpack_require__(4);
  38724. var SeriesModel = __webpack_require__(28);
  38725. var whiskerBoxCommon = __webpack_require__(248);
  38726. var formatUtil = __webpack_require__(6);
  38727. var encodeHTML = formatUtil.encodeHTML;
  38728. var addCommas = formatUtil.addCommas;
  38729. var CandlestickSeries = SeriesModel.extend({
  38730. type: 'series.candlestick',
  38731. dependencies: ['xAxis', 'yAxis', 'grid'],
  38732. /**
  38733. * @readOnly
  38734. */
  38735. valueDimensions: ['open', 'close', 'lowest', 'highest'],
  38736. /**
  38737. * @type {Array.<string>}
  38738. * @readOnly
  38739. */
  38740. dimensions: null,
  38741. /**
  38742. * @override
  38743. */
  38744. defaultOption: {
  38745. zlevel: 0, // 一级层叠
  38746. z: 2, // 二级层叠
  38747. coordinateSystem: 'cartesian2d',
  38748. legendHoverLink: true,
  38749. hoverAnimation: true,
  38750. // xAxisIndex: 0,
  38751. // yAxisIndex: 0,
  38752. layout: null, // 'horizontal' or 'vertical'
  38753. itemStyle: {
  38754. normal: {
  38755. color: '#c23531', // 阳线 positive
  38756. color0: '#314656', // 阴线 negative '#c23531', '#314656'
  38757. borderWidth: 1,
  38758. // FIXME
  38759. // ec2中使用的是lineStyle.color 和 lineStyle.color0
  38760. borderColor: '#c23531',
  38761. borderColor0: '#314656'
  38762. },
  38763. emphasis: {
  38764. borderWidth: 2
  38765. }
  38766. },
  38767. animationUpdate: false,
  38768. animationEasing: 'linear',
  38769. animationDuration: 300
  38770. },
  38771. /**
  38772. * Get dimension for shadow in dataZoom
  38773. * @return {string} dimension name
  38774. */
  38775. getShadowDim: function () {
  38776. return 'open';
  38777. },
  38778. /**
  38779. * @override
  38780. */
  38781. formatTooltip: function (dataIndex, mutipleSeries) {
  38782. // It rearly use mutiple candlestick series in one cartesian,
  38783. // so only consider one series in this default tooltip.
  38784. var valueHTMLArr = zrUtil.map(this.valueDimensions, function (dim) {
  38785. return dim + ': ' + addCommas(this._data.get(dim, dataIndex));
  38786. }, this);
  38787. return encodeHTML(this.name) + '<br />' + valueHTMLArr.join('<br />');
  38788. },
  38789. brushSelector: function (itemLayout, selectors) {
  38790. return selectors.rect(itemLayout.brushRect);
  38791. }
  38792. });
  38793. zrUtil.mixin(CandlestickSeries, whiskerBoxCommon.seriesModelMixin, true);
  38794. module.exports = CandlestickSeries;
  38795. /***/ },
  38796. /* 255 */
  38797. /***/ function(module, exports, __webpack_require__) {
  38798. 'use strict';
  38799. var zrUtil = __webpack_require__(4);
  38800. var ChartView = __webpack_require__(42);
  38801. var graphic = __webpack_require__(43);
  38802. var whiskerBoxCommon = __webpack_require__(248);
  38803. var CandlestickView = ChartView.extend({
  38804. type: 'candlestick',
  38805. getStyleUpdater: function () {
  38806. return updateStyle;
  38807. },
  38808. dispose: zrUtil.noop
  38809. });
  38810. zrUtil.mixin(CandlestickView, whiskerBoxCommon.viewMixin, true);
  38811. // Update common properties
  38812. var normalStyleAccessPath = ['itemStyle', 'normal'];
  38813. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  38814. function updateStyle(itemGroup, data, idx) {
  38815. var itemModel = data.getItemModel(idx);
  38816. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  38817. var color = data.getItemVisual(idx, 'color');
  38818. var borderColor = data.getItemVisual(idx, 'borderColor') || color;
  38819. // Color must be excluded.
  38820. // Because symbol provide setColor individually to set fill and stroke
  38821. var itemStyle = normalItemStyleModel.getItemStyle(
  38822. ['color', 'color0', 'borderColor', 'borderColor0']
  38823. );
  38824. var whiskerEl = itemGroup.childAt(itemGroup.whiskerIndex);
  38825. whiskerEl.useStyle(itemStyle);
  38826. whiskerEl.style.stroke = borderColor;
  38827. var bodyEl = itemGroup.childAt(itemGroup.bodyIndex);
  38828. bodyEl.useStyle(itemStyle);
  38829. bodyEl.style.fill = color;
  38830. bodyEl.style.stroke = borderColor;
  38831. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  38832. graphic.setHoverStyle(itemGroup, hoverStyle);
  38833. }
  38834. module.exports = CandlestickView;
  38835. /***/ },
  38836. /* 256 */
  38837. /***/ function(module, exports, __webpack_require__) {
  38838. var zrUtil = __webpack_require__(4);
  38839. module.exports = function (option) {
  38840. if (!option || !zrUtil.isArray(option.series)) {
  38841. return;
  38842. }
  38843. // Translate 'k' to 'candlestick'.
  38844. zrUtil.each(option.series, function (seriesItem) {
  38845. if (zrUtil.isObject(seriesItem) && seriesItem.type === 'k') {
  38846. seriesItem.type = 'candlestick';
  38847. }
  38848. });
  38849. };
  38850. /***/ },
  38851. /* 257 */
  38852. /***/ function(module, exports) {
  38853. var positiveBorderColorQuery = ['itemStyle', 'normal', 'borderColor'];
  38854. var negativeBorderColorQuery = ['itemStyle', 'normal', 'borderColor0'];
  38855. var positiveColorQuery = ['itemStyle', 'normal', 'color'];
  38856. var negativeColorQuery = ['itemStyle', 'normal', 'color0'];
  38857. module.exports = function (ecModel, api) {
  38858. ecModel.eachRawSeriesByType('candlestick', function (seriesModel) {
  38859. var data = seriesModel.getData();
  38860. data.setVisual({
  38861. legendSymbol: 'roundRect'
  38862. });
  38863. // Only visible series has each data be visual encoded
  38864. if (!ecModel.isSeriesFiltered(seriesModel)) {
  38865. data.each(function (idx) {
  38866. var itemModel = data.getItemModel(idx);
  38867. var sign = data.getItemLayout(idx).sign;
  38868. data.setItemVisual(
  38869. idx,
  38870. {
  38871. color: itemModel.get(
  38872. sign > 0 ? positiveColorQuery : negativeColorQuery
  38873. ),
  38874. borderColor: itemModel.get(
  38875. sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery
  38876. )
  38877. }
  38878. );
  38879. });
  38880. }
  38881. });
  38882. };
  38883. /***/ },
  38884. /* 258 */
  38885. /***/ function(module, exports) {
  38886. var CANDLE_MIN_WIDTH = 2;
  38887. var CANDLE_MIN_NICE_WIDTH = 5;
  38888. var GPA_MIN = 4;
  38889. module.exports = function (ecModel) {
  38890. ecModel.eachSeriesByType('candlestick', function (seriesModel) {
  38891. var coordSys = seriesModel.coordinateSystem;
  38892. var data = seriesModel.getData();
  38893. var dimensions = seriesModel.dimensions;
  38894. var chartLayout = seriesModel.get('layout');
  38895. var candleWidth = calculateCandleWidth(seriesModel, data);
  38896. data.each(dimensions, function () {
  38897. var args = arguments;
  38898. var dimLen = dimensions.length;
  38899. var axisDimVal = args[0];
  38900. var idx = args[dimLen];
  38901. var variableDim = chartLayout === 'horizontal' ? 0 : 1;
  38902. var constDim = 1 - variableDim;
  38903. var openVal = args[1];
  38904. var closeVal = args[2];
  38905. var lowestVal = args[3];
  38906. var highestVal = args[4];
  38907. var ocLow = Math.min(openVal, closeVal);
  38908. var ocHigh = Math.max(openVal, closeVal);
  38909. var ocLowPoint = getPoint(ocLow);
  38910. var ocHighPoint = getPoint(ocHigh);
  38911. var lowestPoint = getPoint(lowestVal);
  38912. var highestPoint = getPoint(highestVal);
  38913. var whiskerEnds = [
  38914. [highestPoint, ocHighPoint],
  38915. [lowestPoint, ocLowPoint]
  38916. ];
  38917. var bodyEnds = [];
  38918. addBodyEnd(ocHighPoint, 0);
  38919. addBodyEnd(ocLowPoint, 1);
  38920. data.setItemLayout(idx, {
  38921. chartLayout: chartLayout,
  38922. sign: openVal > closeVal ? -1 : openVal < closeVal ? 1 : 0,
  38923. initBaseline: openVal > closeVal
  38924. ? ocHighPoint[constDim] : ocLowPoint[constDim], // open point.
  38925. bodyEnds: bodyEnds,
  38926. whiskerEnds: whiskerEnds,
  38927. brushRect: makeBrushRect()
  38928. });
  38929. function getPoint(val) {
  38930. var p = [];
  38931. p[variableDim] = axisDimVal;
  38932. p[constDim] = val;
  38933. return (isNaN(axisDimVal) || isNaN(val))
  38934. ? [NaN, NaN]
  38935. : coordSys.dataToPoint(p);
  38936. }
  38937. function addBodyEnd(point, start) {
  38938. var point1 = point.slice();
  38939. var point2 = point.slice();
  38940. point1[variableDim] += candleWidth / 2;
  38941. point2[variableDim] -= candleWidth / 2;
  38942. start
  38943. ? bodyEnds.push(point1, point2)
  38944. : bodyEnds.push(point2, point1);
  38945. }
  38946. function makeBrushRect() {
  38947. var pmin = getPoint(Math.min(openVal, closeVal, lowestVal, highestVal));
  38948. var pmax = getPoint(Math.max(openVal, closeVal, lowestVal, highestVal));
  38949. pmin[variableDim] -= candleWidth / 2;
  38950. pmax[variableDim] -= candleWidth / 2;
  38951. return {
  38952. x: pmin[0],
  38953. y: pmin[1],
  38954. width: constDim ? candleWidth : pmax[0] - pmin[0],
  38955. height: constDim ? pmax[1] - pmin[1] : candleWidth
  38956. };
  38957. }
  38958. }, true);
  38959. });
  38960. };
  38961. function calculateCandleWidth(seriesModel, data) {
  38962. var baseAxis = seriesModel.getBaseAxis();
  38963. var extent;
  38964. var bandWidth = baseAxis.type === 'category'
  38965. ? baseAxis.getBandWidth()
  38966. : (
  38967. extent = baseAxis.getExtent(),
  38968. Math.abs(extent[1] - extent[0]) / data.count()
  38969. );
  38970. // Half band width is perfect when space is enouph, otherwise
  38971. // try not to be smaller than CANDLE_MIN_NICE_WIDTH (and only
  38972. // gap is compressed), otherwise ensure not to be smaller than
  38973. // CANDLE_MIN_WIDTH in spite of overlap.
  38974. return bandWidth / 2 - 2 > CANDLE_MIN_NICE_WIDTH // "- 2" is minus border width
  38975. ? bandWidth / 2 - 2
  38976. : bandWidth - CANDLE_MIN_NICE_WIDTH > GPA_MIN
  38977. ? CANDLE_MIN_NICE_WIDTH
  38978. : Math.max(bandWidth - GPA_MIN, CANDLE_MIN_WIDTH);
  38979. }
  38980. /***/ },
  38981. /* 259 */
  38982. /***/ function(module, exports, __webpack_require__) {
  38983. var zrUtil = __webpack_require__(4);
  38984. var echarts = __webpack_require__(1);
  38985. __webpack_require__(260);
  38986. __webpack_require__(261);
  38987. echarts.registerVisual(zrUtil.curry(
  38988. __webpack_require__(110), 'effectScatter', 'circle', null
  38989. ));
  38990. echarts.registerLayout(zrUtil.curry(
  38991. __webpack_require__(111), 'effectScatter'
  38992. ));
  38993. /***/ },
  38994. /* 260 */
  38995. /***/ function(module, exports, __webpack_require__) {
  38996. 'use strict';
  38997. var createListFromArray = __webpack_require__(102);
  38998. var SeriesModel = __webpack_require__(28);
  38999. module.exports = SeriesModel.extend({
  39000. type: 'series.effectScatter',
  39001. dependencies: ['grid', 'polar'],
  39002. getInitialData: function (option, ecModel) {
  39003. var list = createListFromArray(option.data, this, ecModel);
  39004. return list;
  39005. },
  39006. brushSelector: 'point',
  39007. defaultOption: {
  39008. coordinateSystem: 'cartesian2d',
  39009. zlevel: 0,
  39010. z: 2,
  39011. legendHoverLink: true,
  39012. effectType: 'ripple',
  39013. progressive: 0,
  39014. // When to show the effect, option: 'render'|'emphasis'
  39015. showEffectOn: 'render',
  39016. // Ripple effect config
  39017. rippleEffect: {
  39018. period: 4,
  39019. // Scale of ripple
  39020. scale: 2.5,
  39021. // Brush type can be fill or stroke
  39022. brushType: 'fill'
  39023. },
  39024. // Cartesian coordinate system
  39025. // xAxisIndex: 0,
  39026. // yAxisIndex: 0,
  39027. // Polar coordinate system
  39028. // polarIndex: 0,
  39029. // Geo coordinate system
  39030. // geoIndex: 0,
  39031. // symbol: null, // 图形类型
  39032. symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  39033. // symbolRotate: null, // 图形旋转控制
  39034. // large: false,
  39035. // Available when large is true
  39036. // largeThreshold: 2000,
  39037. // itemStyle: {
  39038. // normal: {
  39039. // opacity: 1
  39040. // }
  39041. // }
  39042. }
  39043. });
  39044. /***/ },
  39045. /* 261 */
  39046. /***/ function(module, exports, __webpack_require__) {
  39047. var SymbolDraw = __webpack_require__(105);
  39048. var EffectSymbol = __webpack_require__(262);
  39049. __webpack_require__(1).extendChartView({
  39050. type: 'effectScatter',
  39051. init: function () {
  39052. this._symbolDraw = new SymbolDraw(EffectSymbol);
  39053. },
  39054. render: function (seriesModel, ecModel, api) {
  39055. var data = seriesModel.getData();
  39056. var effectSymbolDraw = this._symbolDraw;
  39057. effectSymbolDraw.updateData(data);
  39058. this.group.add(effectSymbolDraw.group);
  39059. },
  39060. updateLayout: function () {
  39061. this._symbolDraw.updateLayout();
  39062. },
  39063. remove: function (ecModel, api) {
  39064. this._symbolDraw && this._symbolDraw.remove(api);
  39065. },
  39066. dispose: function () {}
  39067. });
  39068. /***/ },
  39069. /* 262 */
  39070. /***/ function(module, exports, __webpack_require__) {
  39071. /**
  39072. * Symbol with ripple effect
  39073. * @module echarts/chart/helper/EffectSymbol
  39074. */
  39075. var zrUtil = __webpack_require__(4);
  39076. var symbolUtil = __webpack_require__(107);
  39077. var graphic = __webpack_require__(43);
  39078. var numberUtil = __webpack_require__(7);
  39079. var Symbol = __webpack_require__(106);
  39080. var Group = graphic.Group;
  39081. var EFFECT_RIPPLE_NUMBER = 3;
  39082. function normalizeSymbolSize(symbolSize) {
  39083. if (!zrUtil.isArray(symbolSize)) {
  39084. symbolSize = [+symbolSize, +symbolSize];
  39085. }
  39086. return symbolSize;
  39087. }
  39088. function updateRipplePath(rippleGroup, effectCfg) {
  39089. rippleGroup.eachChild(function (ripplePath) {
  39090. ripplePath.attr({
  39091. z: effectCfg.z,
  39092. zlevel: effectCfg.zlevel,
  39093. style: {
  39094. stroke: effectCfg.brushType === 'stroke' ? effectCfg.color : null,
  39095. fill: effectCfg.brushType === 'fill' ? effectCfg.color : null
  39096. }
  39097. });
  39098. });
  39099. }
  39100. /**
  39101. * @constructor
  39102. * @param {module:echarts/data/List} data
  39103. * @param {number} idx
  39104. * @extends {module:zrender/graphic/Group}
  39105. */
  39106. function EffectSymbol(data, idx) {
  39107. Group.call(this);
  39108. var symbol = new Symbol(data, idx);
  39109. var rippleGroup = new Group();
  39110. this.add(symbol);
  39111. this.add(rippleGroup);
  39112. rippleGroup.beforeUpdate = function () {
  39113. this.attr(symbol.getScale());
  39114. };
  39115. this.updateData(data, idx);
  39116. }
  39117. var effectSymbolProto = EffectSymbol.prototype;
  39118. effectSymbolProto.stopEffectAnimation = function () {
  39119. this.childAt(1).removeAll();
  39120. };
  39121. effectSymbolProto.startEffectAnimation = function (effectCfg) {
  39122. var symbolType = effectCfg.symbolType;
  39123. var color = effectCfg.color;
  39124. var rippleGroup = this.childAt(1);
  39125. for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
  39126. // var ripplePath = symbolUtil.createSymbol(
  39127. // symbolType, -0.5, -0.5, 1, 1, color
  39128. // );
  39129. // If width/height are set too small (e.g., set to 1) on ios10
  39130. // and macOS Sierra, a circle stroke become a rect, no matter what
  39131. // the scale is set. So we set width/height as 2. See #4136.
  39132. var ripplePath = symbolUtil.createSymbol(
  39133. symbolType, -1, -1, 2, 2, color
  39134. );
  39135. ripplePath.attr({
  39136. style: {
  39137. strokeNoScale: true
  39138. },
  39139. z2: 99,
  39140. silent: true,
  39141. scale: [0.5, 0.5]
  39142. });
  39143. var delay = -i / EFFECT_RIPPLE_NUMBER * effectCfg.period + effectCfg.effectOffset;
  39144. // TODO Configurable effectCfg.period
  39145. ripplePath.animate('', true)
  39146. .when(effectCfg.period, {
  39147. scale: [effectCfg.rippleScale / 2, effectCfg.rippleScale / 2]
  39148. })
  39149. .delay(delay)
  39150. .start();
  39151. ripplePath.animateStyle(true)
  39152. .when(effectCfg.period, {
  39153. opacity: 0
  39154. })
  39155. .delay(delay)
  39156. .start();
  39157. rippleGroup.add(ripplePath);
  39158. }
  39159. updateRipplePath(rippleGroup, effectCfg);
  39160. };
  39161. /**
  39162. * Update effect symbol
  39163. */
  39164. effectSymbolProto.updateEffectAnimation = function (effectCfg) {
  39165. var oldEffectCfg = this._effectCfg;
  39166. var rippleGroup = this.childAt(1);
  39167. // Must reinitialize effect if following configuration changed
  39168. var DIFFICULT_PROPS = ['symbolType', 'period', 'rippleScale'];
  39169. for (var i = 0; i < DIFFICULT_PROPS; i++) {
  39170. var propName = DIFFICULT_PROPS[i];
  39171. if (oldEffectCfg[propName] !== effectCfg[propName]) {
  39172. this.stopEffectAnimation();
  39173. this.startEffectAnimation(effectCfg);
  39174. return;
  39175. }
  39176. }
  39177. updateRipplePath(rippleGroup, effectCfg);
  39178. };
  39179. /**
  39180. * Highlight symbol
  39181. */
  39182. effectSymbolProto.highlight = function () {
  39183. this.trigger('emphasis');
  39184. };
  39185. /**
  39186. * Downplay symbol
  39187. */
  39188. effectSymbolProto.downplay = function () {
  39189. this.trigger('normal');
  39190. };
  39191. /**
  39192. * Update symbol properties
  39193. * @param {module:echarts/data/List} data
  39194. * @param {number} idx
  39195. */
  39196. effectSymbolProto.updateData = function (data, idx) {
  39197. var seriesModel = data.hostModel;
  39198. this.childAt(0).updateData(data, idx);
  39199. var rippleGroup = this.childAt(1);
  39200. var itemModel = data.getItemModel(idx);
  39201. var symbolType = data.getItemVisual(idx, 'symbol');
  39202. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  39203. var color = data.getItemVisual(idx, 'color');
  39204. rippleGroup.attr('scale', symbolSize);
  39205. rippleGroup.traverse(function (ripplePath) {
  39206. ripplePath.attr({
  39207. fill: color
  39208. });
  39209. });
  39210. var symbolOffset = itemModel.getShallow('symbolOffset');
  39211. if (symbolOffset) {
  39212. var pos = rippleGroup.position;
  39213. pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  39214. pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  39215. }
  39216. rippleGroup.rotation = (itemModel.getShallow('symbolRotate') || 0) * Math.PI / 180 || 0;
  39217. var effectCfg = {};
  39218. effectCfg.showEffectOn = seriesModel.get('showEffectOn');
  39219. effectCfg.rippleScale = itemModel.get('rippleEffect.scale');
  39220. effectCfg.brushType = itemModel.get('rippleEffect.brushType');
  39221. effectCfg.period = itemModel.get('rippleEffect.period') * 1000;
  39222. effectCfg.effectOffset = idx / data.count();
  39223. effectCfg.z = itemModel.getShallow('z') || 0;
  39224. effectCfg.zlevel = itemModel.getShallow('zlevel') || 0;
  39225. effectCfg.symbolType = symbolType;
  39226. effectCfg.color = color;
  39227. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  39228. if (effectCfg.showEffectOn === 'render') {
  39229. this._effectCfg
  39230. ? this.updateEffectAnimation(effectCfg)
  39231. : this.startEffectAnimation(effectCfg);
  39232. this._effectCfg = effectCfg;
  39233. }
  39234. else {
  39235. // Not keep old effect config
  39236. this._effectCfg = null;
  39237. this.stopEffectAnimation();
  39238. var symbol = this.childAt(0);
  39239. var onEmphasis = function () {
  39240. symbol.trigger('emphasis');
  39241. if (effectCfg.showEffectOn !== 'render') {
  39242. this.startEffectAnimation(effectCfg);
  39243. }
  39244. };
  39245. var onNormal = function () {
  39246. symbol.trigger('normal');
  39247. if (effectCfg.showEffectOn !== 'render') {
  39248. this.stopEffectAnimation();
  39249. }
  39250. };
  39251. this.on('mouseover', onEmphasis, this)
  39252. .on('mouseout', onNormal, this)
  39253. .on('emphasis', onEmphasis, this)
  39254. .on('normal', onNormal, this);
  39255. }
  39256. this._effectCfg = effectCfg;
  39257. };
  39258. effectSymbolProto.fadeOut = function (cb) {
  39259. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  39260. cb && cb();
  39261. };
  39262. zrUtil.inherits(EffectSymbol, Group);
  39263. module.exports = EffectSymbol;
  39264. /***/ },
  39265. /* 263 */
  39266. /***/ function(module, exports, __webpack_require__) {
  39267. __webpack_require__(264);
  39268. __webpack_require__(265);
  39269. var echarts = __webpack_require__(1);
  39270. echarts.registerLayout(
  39271. __webpack_require__(270)
  39272. );
  39273. /***/ },
  39274. /* 264 */
  39275. /***/ function(module, exports, __webpack_require__) {
  39276. 'use strict';
  39277. var SeriesModel = __webpack_require__(28);
  39278. var List = __webpack_require__(98);
  39279. var zrUtil = __webpack_require__(4);
  39280. var CoordinateSystem = __webpack_require__(26);
  39281. // Convert [ [{coord: []}, {coord: []}] ]
  39282. // to [ { coords: [[]] } ]
  39283. function preprocessOption (seriesOpt) {
  39284. var data = seriesOpt.data;
  39285. if (data && data[0] && data[0][0] && data[0][0].coord) {
  39286. if (true) {
  39287. console.warn('Lines data configuration has been changed to'
  39288. + ' { coords:[[1,2],[2,3]] }');
  39289. }
  39290. seriesOpt.data = zrUtil.map(data, function (itemOpt) {
  39291. var coords = [
  39292. itemOpt[0].coord, itemOpt[1].coord
  39293. ];
  39294. var target = {
  39295. coords: coords
  39296. };
  39297. if (itemOpt[0].name) {
  39298. target.fromName = itemOpt[0].name;
  39299. }
  39300. if (itemOpt[1].name) {
  39301. target.toName = itemOpt[1].name;
  39302. }
  39303. return zrUtil.mergeAll([target, itemOpt[0], itemOpt[1]]);
  39304. });
  39305. }
  39306. }
  39307. var LinesSeries = SeriesModel.extend({
  39308. type: 'series.lines',
  39309. dependencies: ['grid', 'polar'],
  39310. visualColorAccessPath: 'lineStyle.normal.color',
  39311. init: function (option) {
  39312. // Not using preprocessor because mergeOption may not have series.type
  39313. preprocessOption(option);
  39314. LinesSeries.superApply(this, 'init', arguments);
  39315. },
  39316. mergeOption: function (option) {
  39317. preprocessOption(option);
  39318. LinesSeries.superApply(this, 'mergeOption', arguments);
  39319. },
  39320. getInitialData: function (option, ecModel) {
  39321. if (true) {
  39322. var CoordSys = CoordinateSystem.get(option.coordinateSystem);
  39323. if (!CoordSys) {
  39324. throw new Error('Unkown coordinate system ' + option.coordinateSystem);
  39325. }
  39326. }
  39327. var lineData = new List(['value'], this);
  39328. lineData.hasItemOption = false;
  39329. lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
  39330. // dataItem is simply coords
  39331. if (dataItem instanceof Array) {
  39332. return NaN;
  39333. }
  39334. else {
  39335. lineData.hasItemOption = true;
  39336. var value = dataItem.value;
  39337. if (value != null) {
  39338. return value instanceof Array ? value[dimIndex] : value;
  39339. }
  39340. }
  39341. });
  39342. return lineData;
  39343. },
  39344. formatTooltip: function (dataIndex) {
  39345. var data = this.getData();
  39346. var itemModel = data.getItemModel(dataIndex);
  39347. var name = itemModel.get('name');
  39348. if (name) {
  39349. return name;
  39350. }
  39351. var fromName = itemModel.get('fromName');
  39352. var toName = itemModel.get('toName');
  39353. return fromName + ' > ' + toName;
  39354. },
  39355. defaultOption: {
  39356. coordinateSystem: 'geo',
  39357. zlevel: 0,
  39358. z: 2,
  39359. legendHoverLink: true,
  39360. hoverAnimation: true,
  39361. // Cartesian coordinate system
  39362. xAxisIndex: 0,
  39363. yAxisIndex: 0,
  39364. // Geo coordinate system
  39365. geoIndex: 0,
  39366. effect: {
  39367. show: false,
  39368. period: 4,
  39369. // Animation delay. support callback
  39370. // delay: 0,
  39371. // If move with constant speed px/sec
  39372. // period will be ignored if this property is > 0,
  39373. constantSpeed: 0,
  39374. symbol: 'circle',
  39375. symbolSize: 3,
  39376. loop: true,
  39377. // Length of trail, 0 - 1
  39378. trailLength: 0.2
  39379. // Same with lineStyle.normal.color
  39380. // color
  39381. },
  39382. large: false,
  39383. // Available when large is true
  39384. largeThreshold: 2000,
  39385. // If lines are polyline
  39386. // polyline not support curveness, label, animation
  39387. polyline: false,
  39388. label: {
  39389. normal: {
  39390. show: false,
  39391. position: 'end'
  39392. // distance: 5,
  39393. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  39394. }
  39395. },
  39396. lineStyle: {
  39397. normal: {
  39398. opacity: 0.5
  39399. }
  39400. }
  39401. }
  39402. });
  39403. /***/ },
  39404. /* 265 */
  39405. /***/ function(module, exports, __webpack_require__) {
  39406. var LineDraw = __webpack_require__(201);
  39407. var EffectLine = __webpack_require__(266);
  39408. var Line = __webpack_require__(202);
  39409. var Polyline = __webpack_require__(267);
  39410. var EffectPolyline = __webpack_require__(268);
  39411. var LargeLineDraw = __webpack_require__(269);
  39412. __webpack_require__(1).extendChartView({
  39413. type: 'lines',
  39414. init: function () {},
  39415. render: function (seriesModel, ecModel, api) {
  39416. var data = seriesModel.getData();
  39417. var lineDraw = this._lineDraw;
  39418. var hasEffect = seriesModel.get('effect.show');
  39419. var isPolyline = seriesModel.get('polyline');
  39420. var isLarge = seriesModel.get('large') && data.count() >= seriesModel.get('largeThreshold');
  39421. if (true) {
  39422. if (hasEffect && isLarge) {
  39423. console.warn('Large lines not support effect');
  39424. }
  39425. }
  39426. if (hasEffect !== this._hasEffet || isPolyline !== this._isPolyline || isLarge !== this._isLarge) {
  39427. if (lineDraw) {
  39428. lineDraw.remove();
  39429. }
  39430. lineDraw = this._lineDraw = isLarge
  39431. ? new LargeLineDraw()
  39432. : new LineDraw(
  39433. isPolyline
  39434. ? (hasEffect ? EffectPolyline : Polyline)
  39435. : (hasEffect ? EffectLine : Line)
  39436. );
  39437. this._hasEffet = hasEffect;
  39438. this._isPolyline = isPolyline;
  39439. this._isLarge = isLarge;
  39440. }
  39441. var zlevel = seriesModel.get('zlevel');
  39442. var trailLength = seriesModel.get('effect.trailLength');
  39443. var zr = api.getZr();
  39444. // Avoid the drag cause ghost shadow
  39445. // FIXME Better way ?
  39446. zr.painter.getLayer(zlevel).clear(true);
  39447. // Config layer with motion blur
  39448. if (this._lastZlevel != null) {
  39449. zr.configLayer(this._lastZlevel, {
  39450. motionBlur: false
  39451. });
  39452. }
  39453. if (hasEffect && trailLength) {
  39454. if (true) {
  39455. var notInIndividual = false;
  39456. ecModel.eachSeries(function (otherSeriesModel) {
  39457. if (otherSeriesModel !== seriesModel && otherSeriesModel.get('zlevel') === zlevel) {
  39458. notInIndividual = true;
  39459. }
  39460. });
  39461. notInIndividual && console.warn('Lines with trail effect should have an individual zlevel');
  39462. }
  39463. zr.configLayer(zlevel, {
  39464. motionBlur: true,
  39465. lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
  39466. });
  39467. }
  39468. this.group.add(lineDraw.group);
  39469. lineDraw.updateData(data);
  39470. this._lastZlevel = zlevel;
  39471. },
  39472. updateLayout: function (seriesModel, ecModel, api) {
  39473. this._lineDraw.updateLayout(seriesModel);
  39474. // Not use motion when dragging or zooming
  39475. var zr = api.getZr();
  39476. zr.painter.getLayer(this._lastZlevel).clear(true);
  39477. },
  39478. remove: function (ecModel, api) {
  39479. this._lineDraw && this._lineDraw.remove(api, true);
  39480. },
  39481. dispose: function () {}
  39482. });
  39483. /***/ },
  39484. /* 266 */
  39485. /***/ function(module, exports, __webpack_require__) {
  39486. /**
  39487. * Provide effect for line
  39488. * @module echarts/chart/helper/EffectLine
  39489. */
  39490. var graphic = __webpack_require__(43);
  39491. var Line = __webpack_require__(202);
  39492. var zrUtil = __webpack_require__(4);
  39493. var symbolUtil = __webpack_require__(107);
  39494. var vec2 = __webpack_require__(10);
  39495. var curveUtil = __webpack_require__(50);
  39496. /**
  39497. * @constructor
  39498. * @extends {module:zrender/graphic/Group}
  39499. * @alias {module:echarts/chart/helper/Line}
  39500. */
  39501. function EffectLine(lineData, idx, seriesScope) {
  39502. graphic.Group.call(this);
  39503. this.add(this.createLine(lineData, idx, seriesScope));
  39504. this._updateEffectSymbol(lineData, idx);
  39505. }
  39506. var effectLineProto = EffectLine.prototype;
  39507. effectLineProto.createLine = function (lineData, idx, seriesScope) {
  39508. return new Line(lineData, idx, seriesScope);
  39509. };
  39510. effectLineProto._updateEffectSymbol = function (lineData, idx) {
  39511. var itemModel = lineData.getItemModel(idx);
  39512. var effectModel = itemModel.getModel('effect');
  39513. var size = effectModel.get('symbolSize');
  39514. var symbolType = effectModel.get('symbol');
  39515. if (!zrUtil.isArray(size)) {
  39516. size = [size, size];
  39517. }
  39518. var color = effectModel.get('color') || lineData.getItemVisual(idx, 'color');
  39519. var symbol = this.childAt(1);
  39520. if (this._symbolType !== symbolType) {
  39521. // Remove previous
  39522. this.remove(symbol);
  39523. symbol = symbolUtil.createSymbol(
  39524. symbolType, -0.5, -0.5, 1, 1, color
  39525. );
  39526. symbol.z2 = 100;
  39527. symbol.culling = true;
  39528. this.add(symbol);
  39529. }
  39530. // Symbol may be removed if loop is false
  39531. if (!symbol) {
  39532. return;
  39533. }
  39534. // Shadow color is same with color in default
  39535. symbol.setStyle('shadowColor', color);
  39536. symbol.setStyle(effectModel.getItemStyle(['color']));
  39537. symbol.attr('scale', size);
  39538. symbol.setColor(color);
  39539. symbol.attr('scale', size);
  39540. this._symbolType = symbolType;
  39541. this._updateEffectAnimation(lineData, effectModel, idx);
  39542. };
  39543. effectLineProto._updateEffectAnimation = function (lineData, effectModel, idx) {
  39544. var symbol = this.childAt(1);
  39545. if (!symbol) {
  39546. return;
  39547. }
  39548. var self = this;
  39549. var points = lineData.getItemLayout(idx);
  39550. var period = effectModel.get('period') * 1000;
  39551. var loop = effectModel.get('loop');
  39552. var constantSpeed = effectModel.get('constantSpeed');
  39553. var delayExpr = zrUtil.retrieve(effectModel.get('delay'), function (idx) {
  39554. return idx / lineData.count() * period / 3;
  39555. });
  39556. var isDelayFunc = typeof delayExpr === 'function';
  39557. // Ignore when updating
  39558. symbol.ignore = true;
  39559. this.updateAnimationPoints(symbol, points);
  39560. if (constantSpeed > 0) {
  39561. period = this.getLineLength(symbol) / constantSpeed * 1000;
  39562. }
  39563. if (period !== this._period || loop !== this._loop) {
  39564. symbol.stopAnimation();
  39565. var delay = delayExpr;
  39566. if (isDelayFunc) {
  39567. delay = delayExpr(idx);
  39568. }
  39569. if (symbol.__t > 0) {
  39570. delay = -period * symbol.__t;
  39571. }
  39572. symbol.__t = 0;
  39573. var animator = symbol.animate('', loop)
  39574. .when(period, {
  39575. __t: 1
  39576. })
  39577. .delay(delay)
  39578. .during(function () {
  39579. self.updateSymbolPosition(symbol);
  39580. });
  39581. if (!loop) {
  39582. animator.done(function () {
  39583. self.remove(symbol);
  39584. });
  39585. }
  39586. animator.start();
  39587. }
  39588. this._period = period;
  39589. this._loop = loop;
  39590. };
  39591. effectLineProto.getLineLength = function (symbol) {
  39592. // Not so accurate
  39593. return (vec2.dist(symbol.__p1, symbol.__cp1)
  39594. + vec2.dist(symbol.__cp1, symbol.__p2));
  39595. };
  39596. effectLineProto.updateAnimationPoints = function (symbol, points) {
  39597. symbol.__p1 = points[0];
  39598. symbol.__p2 = points[1];
  39599. symbol.__cp1 = points[2] || [
  39600. (points[0][0] + points[1][0]) / 2,
  39601. (points[0][1] + points[1][1]) / 2
  39602. ];
  39603. };
  39604. effectLineProto.updateData = function (lineData, idx, seriesScope) {
  39605. this.childAt(0).updateData(lineData, idx, seriesScope);
  39606. this._updateEffectSymbol(lineData, idx);
  39607. };
  39608. effectLineProto.updateSymbolPosition = function (symbol) {
  39609. var p1 = symbol.__p1;
  39610. var p2 = symbol.__p2;
  39611. var cp1 = symbol.__cp1;
  39612. var t = symbol.__t;
  39613. var pos = symbol.position;
  39614. var quadraticAt = curveUtil.quadraticAt;
  39615. var quadraticDerivativeAt = curveUtil.quadraticDerivativeAt;
  39616. pos[0] = quadraticAt(p1[0], cp1[0], p2[0], t);
  39617. pos[1] = quadraticAt(p1[1], cp1[1], p2[1], t);
  39618. // Tangent
  39619. var tx = quadraticDerivativeAt(p1[0], cp1[0], p2[0], t);
  39620. var ty = quadraticDerivativeAt(p1[1], cp1[1], p2[1], t);
  39621. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  39622. symbol.ignore = false;
  39623. };
  39624. effectLineProto.updateLayout = function (lineData, idx) {
  39625. this.childAt(0).updateLayout(lineData, idx);
  39626. var effectModel = lineData.getItemModel(idx).getModel('effect');
  39627. this._updateEffectAnimation(lineData, effectModel, idx);
  39628. };
  39629. zrUtil.inherits(EffectLine, graphic.Group);
  39630. module.exports = EffectLine;
  39631. /***/ },
  39632. /* 267 */
  39633. /***/ function(module, exports, __webpack_require__) {
  39634. /**
  39635. * @module echarts/chart/helper/Line
  39636. */
  39637. var graphic = __webpack_require__(43);
  39638. var zrUtil = __webpack_require__(4);
  39639. /**
  39640. * @constructor
  39641. * @extends {module:zrender/graphic/Group}
  39642. * @alias {module:echarts/chart/helper/Polyline}
  39643. */
  39644. function Polyline(lineData, idx, seriesScope) {
  39645. graphic.Group.call(this);
  39646. this._createPolyline(lineData, idx, seriesScope);
  39647. }
  39648. var polylineProto = Polyline.prototype;
  39649. polylineProto._createPolyline = function (lineData, idx, seriesScope) {
  39650. // var seriesModel = lineData.hostModel;
  39651. var points = lineData.getItemLayout(idx);
  39652. var line = new graphic.Polyline({
  39653. shape: {
  39654. points: points
  39655. }
  39656. });
  39657. this.add(line);
  39658. this._updateCommonStl(lineData, idx, seriesScope);
  39659. };
  39660. polylineProto.updateData = function (lineData, idx, seriesScope) {
  39661. var seriesModel = lineData.hostModel;
  39662. var line = this.childAt(0);
  39663. var target = {
  39664. shape: {
  39665. points: lineData.getItemLayout(idx)
  39666. }
  39667. };
  39668. graphic.updateProps(line, target, seriesModel, idx);
  39669. this._updateCommonStl(lineData, idx, seriesScope);
  39670. };
  39671. polylineProto._updateCommonStl = function (lineData, idx, seriesScope) {
  39672. var line = this.childAt(0);
  39673. var itemModel = lineData.getItemModel(idx);
  39674. var visualColor = lineData.getItemVisual(idx, 'color');
  39675. var lineStyle = seriesScope && seriesScope.lineStyle;
  39676. var hoverLineStyle = seriesScope && seriesScope.hoverLineStyle;
  39677. if (!seriesScope || lineData.hasItemOption) {
  39678. lineStyle = itemModel.getModel('lineStyle.normal').getLineStyle();
  39679. hoverLineStyle = itemModel.getModel('lineStyle.emphasis').getLineStyle();
  39680. }
  39681. line.useStyle(zrUtil.defaults(
  39682. {
  39683. strokeNoScale: true,
  39684. fill: 'none',
  39685. stroke: visualColor
  39686. },
  39687. lineStyle
  39688. ));
  39689. line.hoverStyle = hoverLineStyle;
  39690. graphic.setHoverStyle(this);
  39691. };
  39692. polylineProto.updateLayout = function (lineData, idx) {
  39693. var polyline = this.childAt(0);
  39694. polyline.setShape('points', lineData.getItemLayout(idx));
  39695. };
  39696. zrUtil.inherits(Polyline, graphic.Group);
  39697. module.exports = Polyline;
  39698. /***/ },
  39699. /* 268 */
  39700. /***/ function(module, exports, __webpack_require__) {
  39701. /**
  39702. * Provide effect for line
  39703. * @module echarts/chart/helper/EffectLine
  39704. */
  39705. var Polyline = __webpack_require__(267);
  39706. var zrUtil = __webpack_require__(4);
  39707. var EffectLine = __webpack_require__(266);
  39708. var vec2 = __webpack_require__(10);
  39709. /**
  39710. * @constructor
  39711. * @extends {module:echarts/chart/helper/EffectLine}
  39712. * @alias {module:echarts/chart/helper/Polyline}
  39713. */
  39714. function EffectPolyline(lineData, idx, seriesScope) {
  39715. EffectLine.call(this, lineData, idx, seriesScope);
  39716. this._lastFrame = 0;
  39717. this._lastFramePercent = 0;
  39718. }
  39719. var effectPolylineProto = EffectPolyline.prototype;
  39720. // Overwrite
  39721. effectPolylineProto.createLine = function (lineData, idx, seriesScope) {
  39722. return new Polyline(lineData, idx, seriesScope);
  39723. };
  39724. // Overwrite
  39725. effectPolylineProto.updateAnimationPoints = function (symbol, points) {
  39726. this._points = points;
  39727. var accLenArr = [0];
  39728. var len = 0;
  39729. for (var i = 1; i < points.length; i++) {
  39730. var p1 = points[i - 1];
  39731. var p2 = points[i];
  39732. len += vec2.dist(p1, p2);
  39733. accLenArr.push(len);
  39734. }
  39735. if (len === 0) {
  39736. return;
  39737. }
  39738. for (var i = 0; i < accLenArr.length; i++) {
  39739. accLenArr[i] /= len;
  39740. }
  39741. this._offsets = accLenArr;
  39742. this._length = len;
  39743. };
  39744. // Overwrite
  39745. effectPolylineProto.getLineLength = function (symbol) {
  39746. return this._length;
  39747. };
  39748. // Overwrite
  39749. effectPolylineProto.updateSymbolPosition = function (symbol) {
  39750. var t = symbol.__t;
  39751. var points = this._points;
  39752. var offsets = this._offsets;
  39753. var len = points.length;
  39754. if (!offsets) {
  39755. // Has length 0
  39756. return;
  39757. }
  39758. var lastFrame = this._lastFrame;
  39759. var frame;
  39760. if (t < this._lastFramePercent) {
  39761. // Start from the next frame
  39762. // PENDING start from lastFrame ?
  39763. var start = Math.min(lastFrame + 1, len - 1);
  39764. for (frame = start; frame >= 0; frame--) {
  39765. if (offsets[frame] <= t) {
  39766. break;
  39767. }
  39768. }
  39769. // PENDING really need to do this ?
  39770. frame = Math.min(frame, len - 2);
  39771. }
  39772. else {
  39773. for (var frame = lastFrame; frame < len; frame++) {
  39774. if (offsets[frame] > t) {
  39775. break;
  39776. }
  39777. }
  39778. frame = Math.min(frame - 1, len - 2);
  39779. }
  39780. vec2.lerp(
  39781. symbol.position, points[frame], points[frame + 1],
  39782. (t - offsets[frame]) / (offsets[frame + 1] - offsets[frame])
  39783. );
  39784. var tx = points[frame + 1][0] - points[frame][0];
  39785. var ty = points[frame + 1][1] - points[frame][1];
  39786. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  39787. this._lastFrame = frame;
  39788. this._lastFramePercent = t;
  39789. symbol.ignore = false;
  39790. };
  39791. zrUtil.inherits(EffectPolyline, EffectLine);
  39792. module.exports = EffectPolyline;
  39793. /***/ },
  39794. /* 269 */
  39795. /***/ function(module, exports, __webpack_require__) {
  39796. // TODO Batch by color
  39797. var graphic = __webpack_require__(43);
  39798. var quadraticContain = __webpack_require__(55);
  39799. var lineContain = __webpack_require__(53);
  39800. var LargeLineShape = graphic.extendShape({
  39801. shape: {
  39802. polyline: false,
  39803. segs: []
  39804. },
  39805. buildPath: function (path, shape) {
  39806. var segs = shape.segs;
  39807. var isPolyline = shape.polyline;
  39808. for (var i = 0; i < segs.length; i++) {
  39809. var seg = segs[i];
  39810. if (isPolyline) {
  39811. path.moveTo(seg[0][0], seg[0][1]);
  39812. for (var j = 1; j < seg.length; j++) {
  39813. path.lineTo(seg[j][0], seg[j][1]);
  39814. }
  39815. }
  39816. else {
  39817. path.moveTo(seg[0][0], seg[0][1]);
  39818. if (seg.length > 2) {
  39819. path.quadraticCurveTo(seg[2][0], seg[2][1], seg[1][0], seg[1][1]);
  39820. }
  39821. else {
  39822. path.lineTo(seg[1][0], seg[1][1]);
  39823. }
  39824. }
  39825. }
  39826. },
  39827. findDataIndex: function (x, y) {
  39828. var shape = this.shape;
  39829. var segs = shape.segs;
  39830. var isPolyline = shape.polyline;
  39831. var lineWidth = Math.max(this.style.lineWidth, 1);
  39832. // Not consider transform
  39833. for (var i = 0; i < segs.length; i++) {
  39834. var seg = segs[i];
  39835. if (isPolyline) {
  39836. for (var j = 1; j < seg.length; j++) {
  39837. if (lineContain.containStroke(
  39838. seg[j - 1][0], seg[j - 1][1], seg[j][0], seg[j][1], lineWidth, x, y
  39839. )) {
  39840. return i;
  39841. }
  39842. }
  39843. }
  39844. else {
  39845. if (seg.length > 2) {
  39846. if (quadraticContain.containStroke(
  39847. seg[0][0], seg[0][1], seg[2][0], seg[2][1], seg[1][0], seg[1][1], lineWidth, x, y
  39848. )) {
  39849. return i;
  39850. }
  39851. }
  39852. else {
  39853. if (lineContain.containStroke(
  39854. seg[0][0], seg[0][1], seg[1][0], seg[1][1], lineWidth, x, y
  39855. )) {
  39856. return i;
  39857. }
  39858. }
  39859. }
  39860. }
  39861. return -1;
  39862. }
  39863. });
  39864. function LargeLineDraw() {
  39865. this.group = new graphic.Group();
  39866. this._lineEl = new LargeLineShape();
  39867. }
  39868. var largeLineProto = LargeLineDraw.prototype;
  39869. /**
  39870. * Update symbols draw by new data
  39871. * @param {module:echarts/data/List} data
  39872. */
  39873. largeLineProto.updateData = function (data) {
  39874. this.group.removeAll();
  39875. var lineEl = this._lineEl;
  39876. var seriesModel = data.hostModel;
  39877. lineEl.setShape({
  39878. segs: data.mapArray(data.getItemLayout),
  39879. polyline: seriesModel.get('polyline')
  39880. });
  39881. lineEl.useStyle(
  39882. seriesModel.getModel('lineStyle.normal').getLineStyle()
  39883. );
  39884. var visualColor = data.getVisual('color');
  39885. if (visualColor) {
  39886. lineEl.setStyle('stroke', visualColor);
  39887. }
  39888. lineEl.setStyle('fill');
  39889. // Enable tooltip
  39890. // PENDING May have performance issue when path is extremely large
  39891. lineEl.seriesIndex = seriesModel.seriesIndex;
  39892. lineEl.on('mousemove', function (e) {
  39893. lineEl.dataIndex = null;
  39894. var dataIndex = lineEl.findDataIndex(e.offsetX, e.offsetY);
  39895. if (dataIndex > 0) {
  39896. // Provide dataIndex for tooltip
  39897. lineEl.dataIndex = dataIndex;
  39898. }
  39899. });
  39900. // Add back
  39901. this.group.add(lineEl);
  39902. };
  39903. largeLineProto.updateLayout = function (seriesModel) {
  39904. var data = seriesModel.getData();
  39905. this._lineEl.setShape({
  39906. segs: data.mapArray(data.getItemLayout)
  39907. });
  39908. };
  39909. largeLineProto.remove = function () {
  39910. this.group.removeAll();
  39911. };
  39912. module.exports = LargeLineDraw;
  39913. /***/ },
  39914. /* 270 */
  39915. /***/ function(module, exports, __webpack_require__) {
  39916. module.exports = function (ecModel) {
  39917. ecModel.eachSeriesByType('lines', function (seriesModel) {
  39918. var coordSys = seriesModel.coordinateSystem;
  39919. var lineData = seriesModel.getData();
  39920. // FIXME Use data dimensions ?
  39921. lineData.each(function (idx) {
  39922. var itemModel = lineData.getItemModel(idx);
  39923. // TODO Support pure array
  39924. var coords = (itemModel.option instanceof Array) ?
  39925. itemModel.option : itemModel.get('coords');
  39926. if (true) {
  39927. if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
  39928. throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
  39929. }
  39930. }
  39931. var pts = [];
  39932. if (seriesModel.get('polyline')) {
  39933. for (var i = 0; i < coords.length; i++) {
  39934. pts.push(coordSys.dataToPoint(coords[i]));
  39935. }
  39936. }
  39937. else {
  39938. pts[0] = coordSys.dataToPoint(coords[0]);
  39939. pts[1] = coordSys.dataToPoint(coords[1]);
  39940. var curveness = itemModel.get('lineStyle.normal.curveness');
  39941. if (+curveness) {
  39942. pts[2] = [
  39943. (pts[0][0] + pts[1][0]) / 2 - (pts[0][1] - pts[1][1]) * curveness,
  39944. (pts[0][1] + pts[1][1]) / 2 - (pts[1][0] - pts[0][0]) * curveness
  39945. ];
  39946. }
  39947. }
  39948. lineData.setItemLayout(idx, pts);
  39949. });
  39950. });
  39951. };
  39952. /***/ },
  39953. /* 271 */
  39954. /***/ function(module, exports, __webpack_require__) {
  39955. __webpack_require__(272);
  39956. __webpack_require__(273);
  39957. /***/ },
  39958. /* 272 */
  39959. /***/ function(module, exports, __webpack_require__) {
  39960. var SeriesModel = __webpack_require__(28);
  39961. var createListFromArray = __webpack_require__(102);
  39962. module.exports = SeriesModel.extend({
  39963. type: 'series.heatmap',
  39964. getInitialData: function (option, ecModel) {
  39965. return createListFromArray(option.data, this, ecModel);
  39966. },
  39967. defaultOption: {
  39968. // Cartesian2D or geo
  39969. coordinateSystem: 'cartesian2d',
  39970. zlevel: 0,
  39971. z: 2,
  39972. // Cartesian coordinate system
  39973. // xAxisIndex: 0,
  39974. // yAxisIndex: 0,
  39975. // Geo coordinate system
  39976. geoIndex: 0,
  39977. blurSize: 30,
  39978. pointSize: 20,
  39979. maxOpacity: 1,
  39980. minOpacity: 0
  39981. }
  39982. });
  39983. /***/ },
  39984. /* 273 */
  39985. /***/ function(module, exports, __webpack_require__) {
  39986. var graphic = __webpack_require__(43);
  39987. var HeatmapLayer = __webpack_require__(274);
  39988. var zrUtil = __webpack_require__(4);
  39989. function getIsInPiecewiseRange(dataExtent, pieceList, selected) {
  39990. var dataSpan = dataExtent[1] - dataExtent[0];
  39991. pieceList = zrUtil.map(pieceList, function (piece) {
  39992. return {
  39993. interval: [
  39994. (piece.interval[0] - dataExtent[0]) / dataSpan,
  39995. (piece.interval[1] - dataExtent[0]) / dataSpan
  39996. ]
  39997. };
  39998. });
  39999. var len = pieceList.length;
  40000. var lastIndex = 0;
  40001. return function (val) {
  40002. // Try to find in the location of the last found
  40003. for (var i = lastIndex; i < len; i++) {
  40004. var interval = pieceList[i].interval;
  40005. if (interval[0] <= val && val <= interval[1]) {
  40006. lastIndex = i;
  40007. break;
  40008. }
  40009. }
  40010. if (i === len) { // Not found, back interation
  40011. for (var i = lastIndex - 1; i >= 0; i--) {
  40012. var interval = pieceList[i].interval;
  40013. if (interval[0] <= val && val <= interval[1]) {
  40014. lastIndex = i;
  40015. break;
  40016. }
  40017. }
  40018. }
  40019. return i >= 0 && i < len && selected[i];
  40020. };
  40021. }
  40022. function getIsInContinuousRange(dataExtent, range) {
  40023. var dataSpan = dataExtent[1] - dataExtent[0];
  40024. range = [
  40025. (range[0] - dataExtent[0]) / dataSpan,
  40026. (range[1] - dataExtent[0]) / dataSpan
  40027. ];
  40028. return function (val) {
  40029. return val >= range[0] && val <= range[1];
  40030. };
  40031. }
  40032. function isGeoCoordSys(coordSys) {
  40033. var dimensions = coordSys.dimensions;
  40034. // Not use coorSys.type === 'geo' because coordSys maybe extended
  40035. return dimensions[0] === 'lng' && dimensions[1] === 'lat';
  40036. }
  40037. module.exports = __webpack_require__(1).extendChartView({
  40038. type: 'heatmap',
  40039. render: function (seriesModel, ecModel, api) {
  40040. var visualMapOfThisSeries;
  40041. ecModel.eachComponent('visualMap', function (visualMap) {
  40042. visualMap.eachTargetSeries(function (targetSeries) {
  40043. if (targetSeries === seriesModel) {
  40044. visualMapOfThisSeries = visualMap;
  40045. }
  40046. });
  40047. });
  40048. if (true) {
  40049. if (!visualMapOfThisSeries) {
  40050. throw new Error('Heatmap must use with visualMap');
  40051. }
  40052. }
  40053. this.group.removeAll();
  40054. var coordSys = seriesModel.coordinateSystem;
  40055. if (coordSys.type === 'cartesian2d') {
  40056. this._renderOnCartesian(coordSys, seriesModel, api);
  40057. }
  40058. else if (isGeoCoordSys(coordSys)) {
  40059. this._renderOnGeo(
  40060. coordSys, seriesModel, visualMapOfThisSeries, api
  40061. );
  40062. }
  40063. },
  40064. dispose: function () {},
  40065. _renderOnCartesian: function (cartesian, seriesModel, api) {
  40066. var xAxis = cartesian.getAxis('x');
  40067. var yAxis = cartesian.getAxis('y');
  40068. var group = this.group;
  40069. if (true) {
  40070. if (!(xAxis.type === 'category' && yAxis.type === 'category')) {
  40071. throw new Error('Heatmap on cartesian must have two category axes');
  40072. }
  40073. if (!(xAxis.onBand && yAxis.onBand)) {
  40074. throw new Error('Heatmap on cartesian must have two axes with boundaryGap true');
  40075. }
  40076. }
  40077. var width = xAxis.getBandWidth();
  40078. var height = yAxis.getBandWidth();
  40079. var data = seriesModel.getData();
  40080. var itemStyleQuery = 'itemStyle.normal';
  40081. var hoverItemStyleQuery = 'itemStyle.emphasis';
  40082. var labelQuery = 'label.normal';
  40083. var hoverLabelQuery = 'label.emphasis';
  40084. var style = seriesModel.getModel(itemStyleQuery).getItemStyle(['color']);
  40085. var hoverStl = seriesModel.getModel(hoverItemStyleQuery).getItemStyle();
  40086. var labelModel = seriesModel.getModel('label.normal');
  40087. var hoverLabelModel = seriesModel.getModel('label.emphasis');
  40088. data.each(['x', 'y', 'z'], function (x, y, z, idx) {
  40089. var itemModel = data.getItemModel(idx);
  40090. var point = cartesian.dataToPoint([x, y]);
  40091. // Ignore empty data
  40092. if (isNaN(z)) {
  40093. return;
  40094. }
  40095. var rect = new graphic.Rect({
  40096. shape: {
  40097. x: point[0] - width / 2,
  40098. y: point[1] - height / 2,
  40099. width: width,
  40100. height: height
  40101. },
  40102. style: {
  40103. fill: data.getItemVisual(idx, 'color'),
  40104. opacity: data.getItemVisual(idx, 'opacity')
  40105. }
  40106. });
  40107. // Optimization for large datset
  40108. if (data.hasItemOption) {
  40109. style = itemModel.getModel(itemStyleQuery).getItemStyle(['color']);
  40110. hoverStl = itemModel.getModel(hoverItemStyleQuery).getItemStyle();
  40111. labelModel = itemModel.getModel(labelQuery);
  40112. hoverLabelModel = itemModel.getModel(hoverLabelQuery);
  40113. }
  40114. var rawValue = seriesModel.getRawValue(idx);
  40115. var defaultText = '-';
  40116. if (rawValue && rawValue[2] != null) {
  40117. defaultText = rawValue[2];
  40118. }
  40119. if (labelModel.getShallow('show')) {
  40120. graphic.setText(style, labelModel);
  40121. style.text = seriesModel.getFormattedLabel(idx, 'normal') || defaultText;
  40122. }
  40123. if (hoverLabelModel.getShallow('show')) {
  40124. graphic.setText(hoverStl, hoverLabelModel);
  40125. hoverStl.text = seriesModel.getFormattedLabel(idx, 'emphasis') || defaultText;
  40126. }
  40127. rect.setStyle(style);
  40128. graphic.setHoverStyle(rect, data.hasItemOption ? hoverStl : zrUtil.extend({}, hoverStl));
  40129. group.add(rect);
  40130. data.setItemGraphicEl(idx, rect);
  40131. });
  40132. },
  40133. _renderOnGeo: function (geo, seriesModel, visualMapModel, api) {
  40134. var inRangeVisuals = visualMapModel.targetVisuals.inRange;
  40135. var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange;
  40136. // if (!visualMapping) {
  40137. // throw new Error('Data range must have color visuals');
  40138. // }
  40139. var data = seriesModel.getData();
  40140. var hmLayer = this._hmLayer || (this._hmLayer || new HeatmapLayer());
  40141. hmLayer.blurSize = seriesModel.get('blurSize');
  40142. hmLayer.pointSize = seriesModel.get('pointSize');
  40143. hmLayer.minOpacity = seriesModel.get('minOpacity');
  40144. hmLayer.maxOpacity = seriesModel.get('maxOpacity');
  40145. var rect = geo.getViewRect().clone();
  40146. var roamTransform = geo.getRoamTransform().transform;
  40147. rect.applyTransform(roamTransform);
  40148. // Clamp on viewport
  40149. var x = Math.max(rect.x, 0);
  40150. var y = Math.max(rect.y, 0);
  40151. var x2 = Math.min(rect.width + rect.x, api.getWidth());
  40152. var y2 = Math.min(rect.height + rect.y, api.getHeight());
  40153. var width = x2 - x;
  40154. var height = y2 - y;
  40155. var points = data.mapArray(['lng', 'lat', 'value'], function (lng, lat, value) {
  40156. var pt = geo.dataToPoint([lng, lat]);
  40157. pt[0] -= x;
  40158. pt[1] -= y;
  40159. pt.push(value);
  40160. return pt;
  40161. });
  40162. var dataExtent = visualMapModel.getExtent();
  40163. var isInRange = visualMapModel.type === 'visualMap.continuous'
  40164. ? getIsInContinuousRange(dataExtent, visualMapModel.option.range)
  40165. : getIsInPiecewiseRange(
  40166. dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected
  40167. );
  40168. hmLayer.update(
  40169. points, width, height,
  40170. inRangeVisuals.color.getNormalizer(),
  40171. {
  40172. inRange: inRangeVisuals.color.getColorMapper(),
  40173. outOfRange: outOfRangeVisuals.color.getColorMapper()
  40174. },
  40175. isInRange
  40176. );
  40177. var img = new graphic.Image({
  40178. style: {
  40179. width: width,
  40180. height: height,
  40181. x: x,
  40182. y: y,
  40183. image: hmLayer.canvas
  40184. },
  40185. silent: true
  40186. });
  40187. this.group.add(img);
  40188. }
  40189. });
  40190. /***/ },
  40191. /* 274 */
  40192. /***/ function(module, exports, __webpack_require__) {
  40193. /**
  40194. * @file defines echarts Heatmap Chart
  40195. * @author Ovilia (me@zhangwenli.com)
  40196. * Inspired by https://github.com/mourner/simpleheat
  40197. *
  40198. * @module
  40199. */
  40200. var GRADIENT_LEVELS = 256;
  40201. var zrUtil = __webpack_require__(4);
  40202. /**
  40203. * Heatmap Chart
  40204. *
  40205. * @class
  40206. */
  40207. function Heatmap() {
  40208. var canvas = zrUtil.createCanvas();
  40209. this.canvas = canvas;
  40210. this.blurSize = 30;
  40211. this.pointSize = 20;
  40212. this.maxOpacity = 1;
  40213. this.minOpacity = 0;
  40214. this._gradientPixels = {};
  40215. }
  40216. Heatmap.prototype = {
  40217. /**
  40218. * Renders Heatmap and returns the rendered canvas
  40219. * @param {Array} data array of data, each has x, y, value
  40220. * @param {number} width canvas width
  40221. * @param {number} height canvas height
  40222. */
  40223. update: function(data, width, height, normalize, colorFunc, isInRange) {
  40224. var brush = this._getBrush();
  40225. var gradientInRange = this._getGradient(data, colorFunc, 'inRange');
  40226. var gradientOutOfRange = this._getGradient(data, colorFunc, 'outOfRange');
  40227. var r = this.pointSize + this.blurSize;
  40228. var canvas = this.canvas;
  40229. var ctx = canvas.getContext('2d');
  40230. var len = data.length;
  40231. canvas.width = width;
  40232. canvas.height = height;
  40233. for (var i = 0; i < len; ++i) {
  40234. var p = data[i];
  40235. var x = p[0];
  40236. var y = p[1];
  40237. var value = p[2];
  40238. // calculate alpha using value
  40239. var alpha = normalize(value);
  40240. // draw with the circle brush with alpha
  40241. ctx.globalAlpha = alpha;
  40242. ctx.drawImage(brush, x - r, y - r);
  40243. }
  40244. // colorize the canvas using alpha value and set with gradient
  40245. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  40246. var pixels = imageData.data;
  40247. var offset = 0;
  40248. var pixelLen = pixels.length;
  40249. var minOpacity = this.minOpacity;
  40250. var maxOpacity = this.maxOpacity;
  40251. var diffOpacity = maxOpacity - minOpacity;
  40252. while(offset < pixelLen) {
  40253. var alpha = pixels[offset + 3] / 256;
  40254. var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4;
  40255. // Simple optimize to ignore the empty data
  40256. if (alpha > 0) {
  40257. var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange;
  40258. // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
  40259. alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
  40260. pixels[offset++] = gradient[gradientOffset];
  40261. pixels[offset++] = gradient[gradientOffset + 1];
  40262. pixels[offset++] = gradient[gradientOffset + 2];
  40263. pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
  40264. }
  40265. else {
  40266. offset += 4;
  40267. }
  40268. }
  40269. ctx.putImageData(imageData, 0, 0);
  40270. return canvas;
  40271. },
  40272. /**
  40273. * get canvas of a black circle brush used for canvas to draw later
  40274. * @private
  40275. * @returns {Object} circle brush canvas
  40276. */
  40277. _getBrush: function() {
  40278. var brushCanvas = this._brushCanvas || (this._brushCanvas = zrUtil.createCanvas());
  40279. // set brush size
  40280. var r = this.pointSize + this.blurSize;
  40281. var d = r * 2;
  40282. brushCanvas.width = d;
  40283. brushCanvas.height = d;
  40284. var ctx = brushCanvas.getContext('2d');
  40285. ctx.clearRect(0, 0, d, d);
  40286. // in order to render shadow without the distinct circle,
  40287. // draw the distinct circle in an invisible place,
  40288. // and use shadowOffset to draw shadow in the center of the canvas
  40289. ctx.shadowOffsetX = d;
  40290. ctx.shadowBlur = this.blurSize;
  40291. // draw the shadow in black, and use alpha and shadow blur to generate
  40292. // color in color map
  40293. ctx.shadowColor = '#000';
  40294. // draw circle in the left to the canvas
  40295. ctx.beginPath();
  40296. ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
  40297. ctx.closePath();
  40298. ctx.fill();
  40299. return brushCanvas;
  40300. },
  40301. /**
  40302. * get gradient color map
  40303. * @private
  40304. */
  40305. _getGradient: function (data, colorFunc, state) {
  40306. var gradientPixels = this._gradientPixels;
  40307. var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
  40308. var color = [];
  40309. var off = 0;
  40310. for (var i = 0; i < 256; i++) {
  40311. colorFunc[state](i / 255, true, color);
  40312. pixelsSingleState[off++] = color[0];
  40313. pixelsSingleState[off++] = color[1];
  40314. pixelsSingleState[off++] = color[2];
  40315. pixelsSingleState[off++] = color[3];
  40316. }
  40317. return pixelsSingleState;
  40318. }
  40319. };
  40320. module.exports = Heatmap;
  40321. /***/ },
  40322. /* 275 */
  40323. /***/ function(module, exports, __webpack_require__) {
  40324. var echarts = __webpack_require__(1);
  40325. var zrUtil = __webpack_require__(4);
  40326. var modelUtil = __webpack_require__(5);
  40327. var graphicUtil = __webpack_require__(43);
  40328. var formatUtil = __webpack_require__(6);
  40329. var layoutUtil = __webpack_require__(21);
  40330. // Preprocessor
  40331. echarts.registerPreprocessor(function (option) {
  40332. var graphicOption = option && option.graphic;
  40333. // Convert
  40334. // {graphic: [{left: 10, type: 'circle'}, ...]}
  40335. // or
  40336. // {graphic: {left: 10, type: 'circle'}}
  40337. // to
  40338. // {graphic: [{elements: [{left: 10, type: 'circle'}, ...]}]}
  40339. if (zrUtil.isArray(graphicOption)) {
  40340. if (!graphicOption[0] || !graphicOption[0].elements) {
  40341. option.graphic = [{elements: graphicOption}];
  40342. }
  40343. else {
  40344. // Only one graphic instance can be instantiated. (We dont
  40345. // want that too many views created in echarts._viewMap)
  40346. option.graphic = [option.graphic[0]];
  40347. }
  40348. }
  40349. else if (graphicOption && !graphicOption.elements) {
  40350. option.graphic = [{elements: [graphicOption]}];
  40351. }
  40352. });
  40353. // Model
  40354. var GraphicModel = echarts.extendComponentModel({
  40355. type: 'graphic',
  40356. defaultOption: {
  40357. // Extra properties for each elements:
  40358. //
  40359. // left/right/top/bottom: (like 12, '22%', 'center', default undefined)
  40360. // If left/rigth is set, shape.x/shape.cx/position is not used.
  40361. // If top/bottom is set, shape.y/shape.cy/position is not used.
  40362. // This mechanism is useful when you want position a group/element
  40363. // against the right side or center of this container.
  40364. //
  40365. // width/height: (can only pixel value, default 0)
  40366. // Only be used to specify contianer(group) size, if needed. And
  40367. // can not be percentage value (like '33%'). See the reason in the
  40368. // layout algorithm below.
  40369. //
  40370. // bounding: (enum: 'all' (default) | 'raw')
  40371. // Specify how to calculate boundingRect when locating.
  40372. // 'all': Get uioned and transformed boundingRect
  40373. // from both itself and its descendants.
  40374. // This mode simplies confine a group of elements in the bounding
  40375. // of their ancester container (e.g., using 'right: 0').
  40376. // 'raw': Only use not transformed boundingRect of itself.
  40377. // This mode likes css behavior, useful when you want a
  40378. // element can overflow its container. (Consider a rotated
  40379. // circle needs to be located in a corner.)
  40380. // Note: elements is always behind its ancestors in elements array.
  40381. elements: [],
  40382. parentId: null
  40383. },
  40384. /**
  40385. * Save for performance (only update needed graphics).
  40386. * The order is the same as those in option. (ancesters -> descendants)
  40387. * @private
  40388. * @type {Array.<Object>}
  40389. */
  40390. _elOptionsToUpdate: null,
  40391. /**
  40392. * @override
  40393. */
  40394. mergeOption: function (option) {
  40395. // Prevent default merge to elements
  40396. var elements = this.option.elements;
  40397. this.option.elements = null;
  40398. GraphicModel.superApply(this, 'mergeOption', arguments);
  40399. this.option.elements = elements;
  40400. },
  40401. /**
  40402. * @override
  40403. */
  40404. optionUpdated: function (newOption, isInit) {
  40405. var thisOption = this.option;
  40406. var newList = (isInit ? thisOption : newOption).elements;
  40407. var existList = thisOption.elements = isInit ? [] : thisOption.elements;
  40408. var flattenedList = [];
  40409. this._flatten(newList, flattenedList);
  40410. var mappingResult = modelUtil.mappingToExists(existList, flattenedList);
  40411. modelUtil.makeIdAndName(mappingResult);
  40412. // Clear elOptionsToUpdate
  40413. var elOptionsToUpdate = this._elOptionsToUpdate = [];
  40414. zrUtil.each(mappingResult, function (resultItem, index) {
  40415. var existElOption = resultItem.exist;
  40416. var newElOption = resultItem.option;
  40417. if (true) {
  40418. zrUtil.assert(
  40419. zrUtil.isObject(newElOption) || existElOption,
  40420. 'Empty graphic option definition'
  40421. );
  40422. }
  40423. if (!newElOption) {
  40424. return;
  40425. }
  40426. // Set id and parent id after id assigned.
  40427. newElOption.id = resultItem.keyInfo.id;
  40428. var newElParentId = newElOption.parentId;
  40429. var newElParentOption = newElOption.parentOption;
  40430. var existElParentId = existElOption && existElOption.parentId;
  40431. !newElOption.type && existElOption && (newElOption.type = existElOption.type);
  40432. newElOption.parentId = newElParentId // parent id specified
  40433. ? newElParentId
  40434. : newElParentOption
  40435. ? newElParentOption.id
  40436. : existElParentId // parent not specified
  40437. ? existElParentId
  40438. : null;
  40439. newElOption.parentOption = null; // Clear
  40440. elOptionsToUpdate.push(newElOption);
  40441. // Update existing options, for `getOption` feature.
  40442. var newElOptCopy = zrUtil.extend({}, newElOption); // Avoid modified.
  40443. var $action = newElOption.$action;
  40444. if (!$action || $action === 'merge') {
  40445. if (existElOption) {
  40446. if (true) {
  40447. var newType = newElOption.type;
  40448. zrUtil.assert(
  40449. !newType || existElOption.type === newType,
  40450. 'Please set $action: "replace" to change `type`'
  40451. );
  40452. }
  40453. // We can ensure that newElOptCopy and existElOption are not
  40454. // the same object, so merge will not change newElOptCopy.
  40455. zrUtil.merge(existElOption, newElOptCopy, true);
  40456. // Rigid body, use ignoreSize.
  40457. layoutUtil.mergeLayoutParam(existElOption, newElOptCopy, {ignoreSize: true});
  40458. // Will be used in render.
  40459. layoutUtil.copyLayoutParams(newElOption, existElOption);
  40460. }
  40461. else {
  40462. existList[index] = newElOptCopy;
  40463. }
  40464. }
  40465. else if ($action === 'replace') {
  40466. existList[index] = newElOptCopy;
  40467. }
  40468. else if ($action === 'remove') {
  40469. // null will be cleaned later.
  40470. existElOption && (existList[index] = null);
  40471. }
  40472. if (existList[index]) {
  40473. existList[index].hv = newElOption.hv = [
  40474. isSetLoc(newElOption, ['left', 'right']), // Rigid body, dont care `width`.
  40475. isSetLoc(newElOption, ['top', 'bottom']) // Rigid body, Dont care `height`.
  40476. ];
  40477. // Given defualt group size, otherwise may layout error.
  40478. if (existList[index].type === 'group') {
  40479. existList[index].width == null && (existList[index].width = newElOption.width = 0);
  40480. existList[index].height == null && (existList[index].height = newElOption.height = 0);
  40481. }
  40482. }
  40483. }, this);
  40484. // Clean
  40485. for (var i = existList.length - 1; i >= 0; i--) {
  40486. if (existList[i] == null) {
  40487. existList.splice(i, 1);
  40488. }
  40489. else {
  40490. // $action should be volatile, otherwise option gotten from
  40491. // `getOption` will contain unexpected $action.
  40492. delete existList[i].$action;
  40493. }
  40494. }
  40495. },
  40496. /**
  40497. * Convert
  40498. * [{
  40499. * type: 'group',
  40500. * id: 'xx',
  40501. * children: [{type: 'circle'}, {type: 'polygon'}]
  40502. * }]
  40503. * to
  40504. * [
  40505. * {type: 'group', id: 'xx'},
  40506. * {type: 'circle', parentId: 'xx'},
  40507. * {type: 'polygon', parentId: 'xx'}
  40508. * ]
  40509. * @private
  40510. */
  40511. _flatten: function (optionList, result, parentOption) {
  40512. zrUtil.each(optionList, function (option) {
  40513. if (option) {
  40514. if (parentOption) {
  40515. option.parentOption = parentOption;
  40516. }
  40517. result.push(option);
  40518. var children = option.children;
  40519. if (option.type === 'group' && children) {
  40520. this._flatten(children, result, option);
  40521. }
  40522. // For JSON output, and do not affect group creation.
  40523. delete option.children;
  40524. }
  40525. }, this);
  40526. },
  40527. // FIXME
  40528. // Pass to view using payload? setOption has a payload?
  40529. useElOptionsToUpdate: function () {
  40530. var els = this._elOptionsToUpdate;
  40531. // Clear to avoid render duplicately when zooming.
  40532. this._elOptionsToUpdate = null;
  40533. return els;
  40534. }
  40535. });
  40536. // View
  40537. echarts.extendComponentView({
  40538. type: 'graphic',
  40539. /**
  40540. * @override
  40541. */
  40542. init: function (ecModel, api) {
  40543. /**
  40544. * @type {Object}
  40545. */
  40546. this._elMap = {};
  40547. /**
  40548. * @type {module:echarts/graphic/GraphicModel}
  40549. */
  40550. this._lastGraphicModel;
  40551. },
  40552. /**
  40553. * @override
  40554. */
  40555. render: function (graphicModel, ecModel, api) {
  40556. // Having leveraged use case and algorithm complexity, a very simple
  40557. // layout mechanism is used:
  40558. // The size(width/height) can be determined by itself or its parent (not
  40559. // implemented yet), but can not by its children. (Top-down travel)
  40560. // The location(x/y) can be determined by the bounding rect of itself
  40561. // (can including its descendants or not) and the size of its parent.
  40562. // (Bottom-up travel)
  40563. // When chart.clear() or chart.setOption({...}, true) with the same id,
  40564. // view will be reused.
  40565. if (graphicModel !== this._lastGraphicModel) {
  40566. this._clear();
  40567. }
  40568. this._lastGraphicModel = graphicModel;
  40569. this._updateElements(graphicModel, api);
  40570. this._relocate(graphicModel, api);
  40571. },
  40572. /**
  40573. * @private
  40574. */
  40575. _updateElements: function (graphicModel, api) {
  40576. var elOptionsToUpdate = graphicModel.useElOptionsToUpdate();
  40577. if (!elOptionsToUpdate) {
  40578. return;
  40579. }
  40580. var elMap = this._elMap;
  40581. var rootGroup = this.group;
  40582. // Top-down tranverse to assign graphic settings to each elements.
  40583. zrUtil.each(elOptionsToUpdate, function (elOption) {
  40584. var $action = elOption.$action;
  40585. var id = elOption.id;
  40586. var existEl = elMap[id];
  40587. var parentId = elOption.parentId;
  40588. var targetElParent = parentId != null ? elMap[parentId] : rootGroup;
  40589. // In top/bottom mode, textVertical should not be used. But
  40590. // textBaseline should not be 'alphabetic', which is not precise.
  40591. if (elOption.hv && elOption.hv[1] && elOption.type === 'text') {
  40592. elOption.style = zrUtil.defaults({textBaseline: 'middle'}, elOption.style);
  40593. elOption.style.textVerticalAlign = null;
  40594. }
  40595. // Remove unnecessary props to avoid potential problem.
  40596. var elOptionCleaned = getCleanedElOption(elOption);
  40597. // For simple, do not support parent change, otherwise reorder is needed.
  40598. if (true) {
  40599. existEl && zrUtil.assert(
  40600. targetElParent === existEl.parent,
  40601. 'Changing parent is not supported.'
  40602. );
  40603. }
  40604. if (!$action || $action === 'merge') {
  40605. existEl
  40606. ? existEl.attr(elOptionCleaned)
  40607. : createEl(id, targetElParent, elOptionCleaned, elMap);
  40608. }
  40609. else if ($action === 'replace') {
  40610. removeEl(existEl, elMap);
  40611. createEl(id, targetElParent, elOptionCleaned, elMap);
  40612. }
  40613. else if ($action === 'remove') {
  40614. removeEl(existEl, elMap);
  40615. }
  40616. if (elMap[id]) {
  40617. elMap[id].__ecGraphicWidth = elOption.width;
  40618. elMap[id].__ecGraphicHeight = elOption.height;
  40619. }
  40620. });
  40621. },
  40622. /**
  40623. * @private
  40624. */
  40625. _relocate: function (graphicModel, api) {
  40626. var elOptions = graphicModel.option.elements;
  40627. var rootGroup = this.group;
  40628. var elMap = this._elMap;
  40629. // Bottom-up tranvese all elements (consider when ec resize) to locate elements.
  40630. for (var i = elOptions.length - 1; i >= 0; i--) {
  40631. var elOption = elOptions[i];
  40632. var el = elMap[elOption.id];
  40633. if (!el) {
  40634. continue;
  40635. }
  40636. var parentEl = el.parent;
  40637. var containerInfo = parentEl === rootGroup
  40638. ? {
  40639. width: api.getWidth(),
  40640. height: api.getHeight()
  40641. }
  40642. : { // Like 'position:absolut' in css, default 0.
  40643. width: parentEl.__ecGraphicWidth || 0,
  40644. height: parentEl.__ecGraphicHeight || 0
  40645. };
  40646. layoutUtil.positionElement(
  40647. el, elOption, containerInfo, null,
  40648. {hv: elOption.hv, boundingMode: elOption.bounding}
  40649. );
  40650. }
  40651. },
  40652. /**
  40653. * @private
  40654. */
  40655. _clear: function () {
  40656. var elMap = this._elMap;
  40657. zrUtil.each(elMap, function (el) {
  40658. removeEl(el, elMap);
  40659. });
  40660. this._elMap = {};
  40661. },
  40662. /**
  40663. * @override
  40664. */
  40665. dispose: function () {
  40666. this._clear();
  40667. }
  40668. });
  40669. function createEl(id, targetElParent, elOption, elMap) {
  40670. var graphicType = elOption.type;
  40671. if (true) {
  40672. zrUtil.assert(graphicType, 'graphic type MUST be set');
  40673. }
  40674. var Clz = graphicUtil[graphicType.charAt(0).toUpperCase() + graphicType.slice(1)];
  40675. if (true) {
  40676. zrUtil.assert(Clz, 'graphic type can not be found');
  40677. }
  40678. var el = new Clz(elOption);
  40679. targetElParent.add(el);
  40680. elMap[id] = el;
  40681. el.__ecGraphicId = id;
  40682. }
  40683. function removeEl(existEl, elMap) {
  40684. var existElParent = existEl && existEl.parent;
  40685. if (existElParent) {
  40686. existEl.type === 'group' && existEl.traverse(function (el) {
  40687. removeEl(el, elMap);
  40688. });
  40689. delete elMap[existEl.__ecGraphicId];
  40690. existElParent.remove(existEl);
  40691. }
  40692. }
  40693. // Remove unnecessary props to avoid potential problem.
  40694. function getCleanedElOption(elOption) {
  40695. elOption = zrUtil.extend({}, elOption);
  40696. zrUtil.each(
  40697. ['id', 'parentId', '$action', 'hv', 'bounding'].concat(layoutUtil.LOCATION_PARAMS),
  40698. function (name) {
  40699. delete elOption[name];
  40700. }
  40701. );
  40702. return elOption;
  40703. }
  40704. function isSetLoc(obj, props) {
  40705. var isSet;
  40706. zrUtil.each(props, function (prop) {
  40707. obj[prop] != null && obj[prop] !== 'auto' && (isSet = true);
  40708. });
  40709. return isSet;
  40710. }
  40711. /***/ },
  40712. /* 276 */
  40713. /***/ function(module, exports, __webpack_require__) {
  40714. /**
  40715. * Legend component entry file8
  40716. */
  40717. __webpack_require__(277);
  40718. __webpack_require__(278);
  40719. __webpack_require__(279);
  40720. var echarts = __webpack_require__(1);
  40721. // Series Filter
  40722. echarts.registerProcessor(__webpack_require__(281));
  40723. /***/ },
  40724. /* 277 */
  40725. /***/ function(module, exports, __webpack_require__) {
  40726. 'use strict';
  40727. var zrUtil = __webpack_require__(4);
  40728. var Model = __webpack_require__(12);
  40729. var LegendModel = __webpack_require__(1).extendComponentModel({
  40730. type: 'legend',
  40731. dependencies: ['series'],
  40732. layoutMode: {
  40733. type: 'box',
  40734. ignoreSize: true
  40735. },
  40736. init: function (option, parentModel, ecModel) {
  40737. this.mergeDefaultAndTheme(option, ecModel);
  40738. option.selected = option.selected || {};
  40739. },
  40740. mergeOption: function (option) {
  40741. LegendModel.superCall(this, 'mergeOption', option);
  40742. },
  40743. optionUpdated: function () {
  40744. this._updateData(this.ecModel);
  40745. var legendData = this._data;
  40746. // If selectedMode is single, try to select one
  40747. if (legendData[0] && this.get('selectedMode') === 'single') {
  40748. var hasSelected = false;
  40749. // If has any selected in option.selected
  40750. for (var i = 0; i < legendData.length; i++) {
  40751. var name = legendData[i].get('name');
  40752. if (this.isSelected(name)) {
  40753. // Force to unselect others
  40754. this.select(name);
  40755. hasSelected = true;
  40756. break;
  40757. }
  40758. }
  40759. // Try select the first if selectedMode is single
  40760. !hasSelected && this.select(legendData[0].get('name'));
  40761. }
  40762. },
  40763. _updateData: function (ecModel) {
  40764. var legendData = zrUtil.map(this.get('data') || [], function (dataItem) {
  40765. // Can be string or number
  40766. if (typeof dataItem === 'string' || typeof dataItem === 'number') {
  40767. dataItem = {
  40768. name: dataItem
  40769. };
  40770. }
  40771. return new Model(dataItem, this, this.ecModel);
  40772. }, this);
  40773. this._data = legendData;
  40774. var availableNames = zrUtil.map(ecModel.getSeries(), function (series) {
  40775. return series.name;
  40776. });
  40777. ecModel.eachSeries(function (seriesModel) {
  40778. if (seriesModel.legendDataProvider) {
  40779. var data = seriesModel.legendDataProvider();
  40780. availableNames = availableNames.concat(data.mapArray(data.getName));
  40781. }
  40782. });
  40783. /**
  40784. * @type {Array.<string>}
  40785. * @private
  40786. */
  40787. this._availableNames = availableNames;
  40788. },
  40789. /**
  40790. * @return {Array.<module:echarts/model/Model>}
  40791. */
  40792. getData: function () {
  40793. return this._data;
  40794. },
  40795. /**
  40796. * @param {string} name
  40797. */
  40798. select: function (name) {
  40799. var selected = this.option.selected;
  40800. var selectedMode = this.get('selectedMode');
  40801. if (selectedMode === 'single') {
  40802. var data = this._data;
  40803. zrUtil.each(data, function (dataItem) {
  40804. selected[dataItem.get('name')] = false;
  40805. });
  40806. }
  40807. selected[name] = true;
  40808. },
  40809. /**
  40810. * @param {string} name
  40811. */
  40812. unSelect: function (name) {
  40813. if (this.get('selectedMode') !== 'single') {
  40814. this.option.selected[name] = false;
  40815. }
  40816. },
  40817. /**
  40818. * @param {string} name
  40819. */
  40820. toggleSelected: function (name) {
  40821. var selected = this.option.selected;
  40822. // Default is true
  40823. if (!selected.hasOwnProperty(name)) {
  40824. selected[name] = true;
  40825. }
  40826. this[selected[name] ? 'unSelect' : 'select'](name);
  40827. },
  40828. /**
  40829. * @param {string} name
  40830. */
  40831. isSelected: function (name) {
  40832. var selected = this.option.selected;
  40833. return !(selected.hasOwnProperty(name) && !selected[name])
  40834. && zrUtil.indexOf(this._availableNames, name) >= 0;
  40835. },
  40836. defaultOption: {
  40837. // 一级层叠
  40838. zlevel: 0,
  40839. // 二级层叠
  40840. z: 4,
  40841. show: true,
  40842. // 布局方式,默认为水平布局,可选为:
  40843. // 'horizontal' | 'vertical'
  40844. orient: 'horizontal',
  40845. left: 'center',
  40846. // right: 'center',
  40847. top: 'top',
  40848. // bottom: 'top',
  40849. // 水平对齐
  40850. // 'auto' | 'left' | 'right'
  40851. // 默认为 'auto', 根据 x 的位置判断是左对齐还是右对齐
  40852. align: 'auto',
  40853. backgroundColor: 'rgba(0,0,0,0)',
  40854. // 图例边框颜色
  40855. borderColor: '#ccc',
  40856. // 图例边框线宽,单位px,默认为0(无边框)
  40857. borderWidth: 0,
  40858. // 图例内边距,单位px,默认各方向内边距为5,
  40859. // 接受数组分别设定上右下左边距,同css
  40860. padding: 5,
  40861. // 各个item之间的间隔,单位px,默认为10,
  40862. // 横向布局时为水平间隔,纵向布局时为纵向间隔
  40863. itemGap: 10,
  40864. // 图例图形宽度
  40865. itemWidth: 25,
  40866. // 图例图形高度
  40867. itemHeight: 14,
  40868. // 图例关闭时候的颜色
  40869. inactiveColor: '#ccc',
  40870. textStyle: {
  40871. // 图例文字颜色
  40872. color: '#333'
  40873. },
  40874. // formatter: '',
  40875. // 选择模式,默认开启图例开关
  40876. selectedMode: true,
  40877. // 配置默认选中状态,可配合LEGEND.SELECTED事件做动态数据载入
  40878. // selected: null,
  40879. // 图例内容(详见legend.data,数组中每一项代表一个item
  40880. // data: [],
  40881. // Tooltip 相关配置
  40882. tooltip: {
  40883. show: false
  40884. }
  40885. }
  40886. });
  40887. module.exports = LegendModel;
  40888. /***/ },
  40889. /* 278 */
  40890. /***/ function(module, exports, __webpack_require__) {
  40891. /**
  40892. * @file Legend action
  40893. */
  40894. var echarts = __webpack_require__(1);
  40895. var zrUtil = __webpack_require__(4);
  40896. function legendSelectActionHandler(methodName, payload, ecModel) {
  40897. var selectedMap = {};
  40898. var isToggleSelect = methodName === 'toggleSelected';
  40899. var isSelected;
  40900. // Update all legend components
  40901. ecModel.eachComponent('legend', function (legendModel) {
  40902. if (isToggleSelect && isSelected != null) {
  40903. // Force other legend has same selected status
  40904. // Or the first is toggled to true and other are toggled to false
  40905. // In the case one legend has some item unSelected in option. And if other legend
  40906. // doesn't has the item, they will assume it is selected.
  40907. legendModel[isSelected ? 'select' : 'unSelect'](payload.name);
  40908. }
  40909. else {
  40910. legendModel[methodName](payload.name);
  40911. isSelected = legendModel.isSelected(payload.name);
  40912. }
  40913. var legendData = legendModel.getData();
  40914. zrUtil.each(legendData, function (model) {
  40915. var name = model.get('name');
  40916. // Wrap element
  40917. if (name === '\n' || name === '') {
  40918. return;
  40919. }
  40920. var isItemSelected = legendModel.isSelected(name);
  40921. if (name in selectedMap) {
  40922. // Unselected if any legend is unselected
  40923. selectedMap[name] = selectedMap[name] && isItemSelected;
  40924. }
  40925. else {
  40926. selectedMap[name] = isItemSelected;
  40927. }
  40928. });
  40929. });
  40930. // Return the event explicitly
  40931. return {
  40932. name: payload.name,
  40933. selected: selectedMap
  40934. };
  40935. }
  40936. /**
  40937. * @event legendToggleSelect
  40938. * @type {Object}
  40939. * @property {string} type 'legendToggleSelect'
  40940. * @property {string} [from]
  40941. * @property {string} name Series name or data item name
  40942. */
  40943. echarts.registerAction(
  40944. 'legendToggleSelect', 'legendselectchanged',
  40945. zrUtil.curry(legendSelectActionHandler, 'toggleSelected')
  40946. );
  40947. /**
  40948. * @event legendSelect
  40949. * @type {Object}
  40950. * @property {string} type 'legendSelect'
  40951. * @property {string} name Series name or data item name
  40952. */
  40953. echarts.registerAction(
  40954. 'legendSelect', 'legendselected',
  40955. zrUtil.curry(legendSelectActionHandler, 'select')
  40956. );
  40957. /**
  40958. * @event legendUnSelect
  40959. * @type {Object}
  40960. * @property {string} type 'legendUnSelect'
  40961. * @property {string} name Series name or data item name
  40962. */
  40963. echarts.registerAction(
  40964. 'legendUnSelect', 'legendunselected',
  40965. zrUtil.curry(legendSelectActionHandler, 'unSelect')
  40966. );
  40967. /***/ },
  40968. /* 279 */
  40969. /***/ function(module, exports, __webpack_require__) {
  40970. var zrUtil = __webpack_require__(4);
  40971. var symbolCreator = __webpack_require__(107);
  40972. var graphic = __webpack_require__(43);
  40973. var listComponentHelper = __webpack_require__(280);
  40974. var curry = zrUtil.curry;
  40975. function dispatchSelectAction(name, api) {
  40976. api.dispatchAction({
  40977. type: 'legendToggleSelect',
  40978. name: name
  40979. });
  40980. }
  40981. function dispatchHighlightAction(seriesModel, dataName, api) {
  40982. // If element hover will move to a hoverLayer.
  40983. var el = api.getZr().storage.getDisplayList()[0];
  40984. if (!(el && el.useHoverLayer)) {
  40985. seriesModel.get('legendHoverLink') && api.dispatchAction({
  40986. type: 'highlight',
  40987. seriesName: seriesModel.name,
  40988. name: dataName
  40989. });
  40990. }
  40991. }
  40992. function dispatchDownplayAction(seriesModel, dataName, api) {
  40993. // If element hover will move to a hoverLayer.
  40994. var el = api.getZr().storage.getDisplayList()[0];
  40995. if (!(el && el.useHoverLayer)) {
  40996. seriesModel.get('legendHoverLink') && api.dispatchAction({
  40997. type: 'downplay',
  40998. seriesName: seriesModel.name,
  40999. name: dataName
  41000. });
  41001. }
  41002. }
  41003. module.exports = __webpack_require__(1).extendComponentView({
  41004. type: 'legend',
  41005. init: function () {
  41006. this._symbolTypeStore = {};
  41007. },
  41008. render: function (legendModel, ecModel, api) {
  41009. var group = this.group;
  41010. group.removeAll();
  41011. if (!legendModel.get('show')) {
  41012. return;
  41013. }
  41014. var selectMode = legendModel.get('selectedMode');
  41015. var itemAlign = legendModel.get('align');
  41016. if (itemAlign === 'auto') {
  41017. itemAlign = (legendModel.get('left') === 'right'
  41018. && legendModel.get('orient') === 'vertical')
  41019. ? 'right' : 'left';
  41020. }
  41021. var legendDrawedMap = {};
  41022. zrUtil.each(legendModel.getData(), function (itemModel) {
  41023. var name = itemModel.get('name');
  41024. // Use empty string or \n as a newline string
  41025. if (name === '' || name === '\n') {
  41026. group.add(new graphic.Group({
  41027. newline: true
  41028. }));
  41029. return;
  41030. }
  41031. var seriesModel = ecModel.getSeriesByName(name)[0];
  41032. if (legendDrawedMap[name]) {
  41033. // Have been drawed
  41034. return;
  41035. }
  41036. // Series legend
  41037. if (seriesModel) {
  41038. var data = seriesModel.getData();
  41039. var color = data.getVisual('color');
  41040. // If color is a callback function
  41041. if (typeof color === 'function') {
  41042. // Use the first data
  41043. color = color(seriesModel.getDataParams(0));
  41044. }
  41045. // Using rect symbol defaultly
  41046. var legendSymbolType = data.getVisual('legendSymbol') || 'roundRect';
  41047. var symbolType = data.getVisual('symbol');
  41048. var itemGroup = this._createItem(
  41049. name, itemModel, legendModel,
  41050. legendSymbolType, symbolType,
  41051. itemAlign, color,
  41052. selectMode
  41053. );
  41054. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  41055. .on('mouseover', curry(dispatchHighlightAction, seriesModel, null, api))
  41056. .on('mouseout', curry(dispatchDownplayAction, seriesModel, null, api));
  41057. legendDrawedMap[name] = true;
  41058. }
  41059. else {
  41060. // Data legend of pie, funnel
  41061. ecModel.eachRawSeries(function (seriesModel) {
  41062. // In case multiple series has same data name
  41063. if (legendDrawedMap[name]) {
  41064. return;
  41065. }
  41066. if (seriesModel.legendDataProvider) {
  41067. var data = seriesModel.legendDataProvider();
  41068. var idx = data.indexOfName(name);
  41069. if (idx < 0) {
  41070. return;
  41071. }
  41072. var color = data.getItemVisual(idx, 'color');
  41073. var legendSymbolType = 'roundRect';
  41074. var itemGroup = this._createItem(
  41075. name, itemModel, legendModel,
  41076. legendSymbolType, null,
  41077. itemAlign, color,
  41078. selectMode
  41079. );
  41080. itemGroup.on('click', curry(dispatchSelectAction, name, api))
  41081. // FIXME Should not specify the series name
  41082. .on('mouseover', curry(dispatchHighlightAction, seriesModel, name, api))
  41083. .on('mouseout', curry(dispatchDownplayAction, seriesModel, name, api));
  41084. legendDrawedMap[name] = true;
  41085. }
  41086. }, this);
  41087. }
  41088. if (true) {
  41089. if (!legendDrawedMap[name]) {
  41090. console.warn(name + ' series not exists. Legend data should be same with series name or data name.');
  41091. }
  41092. }
  41093. }, this);
  41094. listComponentHelper.layout(group, legendModel, api);
  41095. // Render background after group is layout
  41096. // FIXME
  41097. listComponentHelper.addBackground(group, legendModel);
  41098. },
  41099. _createItem: function (
  41100. name, itemModel, legendModel,
  41101. legendSymbolType, symbolType,
  41102. itemAlign, color, selectMode
  41103. ) {
  41104. var itemWidth = legendModel.get('itemWidth');
  41105. var itemHeight = legendModel.get('itemHeight');
  41106. var inactiveColor = legendModel.get('inactiveColor');
  41107. var isSelected = legendModel.isSelected(name);
  41108. var itemGroup = new graphic.Group();
  41109. var textStyleModel = itemModel.getModel('textStyle');
  41110. var itemIcon = itemModel.get('icon');
  41111. var tooltipModel = itemModel.getModel('tooltip');
  41112. var legendGlobalTooltipModel = tooltipModel.parentModel;
  41113. // Use user given icon first
  41114. legendSymbolType = itemIcon || legendSymbolType;
  41115. itemGroup.add(symbolCreator.createSymbol(
  41116. legendSymbolType, 0, 0, itemWidth, itemHeight, isSelected ? color : inactiveColor
  41117. ));
  41118. // Compose symbols
  41119. // PENDING
  41120. if (!itemIcon && symbolType
  41121. // At least show one symbol, can't be all none
  41122. && ((symbolType !== legendSymbolType) || symbolType == 'none')
  41123. ) {
  41124. var size = itemHeight * 0.8;
  41125. if (symbolType === 'none') {
  41126. symbolType = 'circle';
  41127. }
  41128. // Put symbol in the center
  41129. itemGroup.add(symbolCreator.createSymbol(
  41130. symbolType, (itemWidth - size) / 2, (itemHeight - size) / 2, size, size,
  41131. isSelected ? color : inactiveColor
  41132. ));
  41133. }
  41134. // Text
  41135. var textX = itemAlign === 'left' ? itemWidth + 5 : -5;
  41136. var textAlign = itemAlign;
  41137. var formatter = legendModel.get('formatter');
  41138. var content = name;
  41139. if (typeof formatter === 'string' && formatter) {
  41140. content = formatter.replace('{name}', name != null ? name : '');
  41141. }
  41142. else if (typeof formatter === 'function') {
  41143. content = formatter(name);
  41144. }
  41145. var text = new graphic.Text({
  41146. style: {
  41147. text: content,
  41148. x: textX,
  41149. y: itemHeight / 2,
  41150. fill: isSelected ? textStyleModel.getTextColor() : inactiveColor,
  41151. textFont: textStyleModel.getFont(),
  41152. textAlign: textAlign,
  41153. textVerticalAlign: 'middle'
  41154. }
  41155. });
  41156. itemGroup.add(text);
  41157. // Add a invisible rect to increase the area of mouse hover
  41158. var hitRect = new graphic.Rect({
  41159. shape: itemGroup.getBoundingRect(),
  41160. invisible: true,
  41161. tooltip: tooltipModel.get('show') ? zrUtil.extend({
  41162. content: name,
  41163. // Defaul formatter
  41164. formatter: legendGlobalTooltipModel.get('formatter', true) || function () {
  41165. return name;
  41166. },
  41167. formatterParams: {
  41168. componentType: 'legend',
  41169. legendIndex: legendModel.componentIndex,
  41170. name: name,
  41171. $vars: ['name']
  41172. }
  41173. }, tooltipModel.option) : null
  41174. });
  41175. itemGroup.add(hitRect);
  41176. itemGroup.eachChild(function (child) {
  41177. child.silent = true;
  41178. });
  41179. hitRect.silent = !selectMode;
  41180. this.group.add(itemGroup);
  41181. graphic.setHoverStyle(itemGroup);
  41182. return itemGroup;
  41183. }
  41184. });
  41185. /***/ },
  41186. /* 280 */
  41187. /***/ function(module, exports, __webpack_require__) {
  41188. // List layout
  41189. var layout = __webpack_require__(21);
  41190. var formatUtil = __webpack_require__(6);
  41191. var graphic = __webpack_require__(43);
  41192. function positionGroup(group, model, api) {
  41193. layout.positionElement(
  41194. group, model.getBoxLayoutParams(),
  41195. {
  41196. width: api.getWidth(),
  41197. height: api.getHeight()
  41198. },
  41199. model.get('padding')
  41200. );
  41201. }
  41202. module.exports = {
  41203. /**
  41204. * Layout list like component.
  41205. * It will box layout each items in group of component and then position the whole group in the viewport
  41206. * @param {module:zrender/group/Group} group
  41207. * @param {module:echarts/model/Component} componentModel
  41208. * @param {module:echarts/ExtensionAPI}
  41209. */
  41210. layout: function (group, componentModel, api) {
  41211. var rect = layout.getLayoutRect(componentModel.getBoxLayoutParams(), {
  41212. width: api.getWidth(),
  41213. height: api.getHeight()
  41214. }, componentModel.get('padding'));
  41215. layout.box(
  41216. componentModel.get('orient'),
  41217. group,
  41218. componentModel.get('itemGap'),
  41219. rect.width,
  41220. rect.height
  41221. );
  41222. positionGroup(group, componentModel, api);
  41223. },
  41224. addBackground: function (group, componentModel) {
  41225. var padding = formatUtil.normalizeCssArray(
  41226. componentModel.get('padding')
  41227. );
  41228. var boundingRect = group.getBoundingRect();
  41229. var style = componentModel.getItemStyle(['color', 'opacity']);
  41230. style.fill = componentModel.get('backgroundColor');
  41231. var rect = new graphic.Rect({
  41232. shape: {
  41233. x: boundingRect.x - padding[3],
  41234. y: boundingRect.y - padding[0],
  41235. width: boundingRect.width + padding[1] + padding[3],
  41236. height: boundingRect.height + padding[0] + padding[2]
  41237. },
  41238. style: style,
  41239. silent: true,
  41240. z2: -1
  41241. });
  41242. graphic.subPixelOptimizeRect(rect);
  41243. group.add(rect);
  41244. }
  41245. };
  41246. /***/ },
  41247. /* 281 */
  41248. /***/ function(module, exports) {
  41249. module.exports = function (ecModel) {
  41250. var legendModels = ecModel.findComponents({
  41251. mainType: 'legend'
  41252. });
  41253. if (legendModels && legendModels.length) {
  41254. ecModel.filterSeries(function (series) {
  41255. // If in any legend component the status is not selected.
  41256. // Because in legend series is assumed selected when it is not in the legend data.
  41257. for (var i = 0; i < legendModels.length; i++) {
  41258. if (!legendModels[i].isSelected(series.name)) {
  41259. return false;
  41260. }
  41261. }
  41262. return true;
  41263. });
  41264. }
  41265. };
  41266. /***/ },
  41267. /* 282 */
  41268. /***/ function(module, exports, __webpack_require__) {
  41269. // FIXME Better way to pack data in graphic element
  41270. __webpack_require__(283);
  41271. __webpack_require__(284);
  41272. // Show tip action
  41273. /**
  41274. * @action
  41275. * @property {string} type
  41276. * @property {number} seriesIndex
  41277. * @property {number} dataIndex
  41278. * @property {number} [x]
  41279. * @property {number} [y]
  41280. */
  41281. __webpack_require__(1).registerAction(
  41282. {
  41283. type: 'showTip',
  41284. event: 'showTip',
  41285. update: 'none'
  41286. },
  41287. // noop
  41288. function () {}
  41289. );
  41290. // Hide tip action
  41291. __webpack_require__(1).registerAction(
  41292. {
  41293. type: 'hideTip',
  41294. event: 'hideTip',
  41295. update: 'none'
  41296. },
  41297. // noop
  41298. function () {}
  41299. );
  41300. /***/ },
  41301. /* 283 */
  41302. /***/ function(module, exports, __webpack_require__) {
  41303. __webpack_require__(1).extendComponentModel({
  41304. type: 'tooltip',
  41305. defaultOption: {
  41306. zlevel: 0,
  41307. z: 8,
  41308. show: true,
  41309. // tooltip主体内容
  41310. showContent: true,
  41311. // 触发类型,默认数据触发,见下图,可选为:'item' ¦ 'axis'
  41312. trigger: 'item',
  41313. // 触发条件,支持 'click' | 'mousemove' | 'none'
  41314. triggerOn: 'mousemove',
  41315. // 是否永远显示 content
  41316. alwaysShowContent: false,
  41317. // 位置 {Array} | {Function}
  41318. // position: null
  41319. // 是否约束 content 在 viewRect 中。默认 false 是为了兼容以前版本。
  41320. confine: false,
  41321. // 内容格式器:{string}(Template) ¦ {Function}
  41322. // formatter: null
  41323. showDelay: 0,
  41324. // 隐藏延迟,单位ms
  41325. hideDelay: 100,
  41326. // 动画变换时间,单位s
  41327. transitionDuration: 0.4,
  41328. enterable: false,
  41329. // 提示背景颜色,默认为透明度为0.7的黑色
  41330. backgroundColor: 'rgba(50,50,50,0.7)',
  41331. // 提示边框颜色
  41332. borderColor: '#333',
  41333. // 提示边框圆角,单位px,默认为4
  41334. borderRadius: 4,
  41335. // 提示边框线宽,单位px,默认为0(无边框)
  41336. borderWidth: 0,
  41337. // 提示内边距,单位px,默认各方向内边距为5,
  41338. // 接受数组分别设定上右下左边距,同css
  41339. padding: 5,
  41340. // Extra css text
  41341. extraCssText: '',
  41342. // 坐标轴指示器,坐标轴触发有效
  41343. axisPointer: {
  41344. // 默认为直线
  41345. // 可选为:'line' | 'shadow' | 'cross'
  41346. type: 'line',
  41347. // type 为 line 的时候有效,指定 tooltip line 所在的轴,可选
  41348. // 可选 'x' | 'y' | 'angle' | 'radius' | 'auto'
  41349. // 默认 'auto',会选择类型为 cateogry 的轴,对于双数值轴,笛卡尔坐标系会默认选择 x 轴
  41350. // 极坐标系会默认选择 angle 轴
  41351. axis: 'auto',
  41352. animation: true,
  41353. animationDurationUpdate: 200,
  41354. animationEasingUpdate: 'exponentialOut',
  41355. // 直线指示器样式设置
  41356. lineStyle: {
  41357. color: '#555',
  41358. width: 1,
  41359. type: 'solid'
  41360. },
  41361. crossStyle: {
  41362. color: '#555',
  41363. width: 1,
  41364. type: 'dashed',
  41365. // TODO formatter
  41366. textStyle: {}
  41367. },
  41368. // 阴影指示器样式设置
  41369. shadowStyle: {
  41370. color: 'rgba(150,150,150,0.3)'
  41371. }
  41372. },
  41373. textStyle: {
  41374. color: '#fff',
  41375. fontSize: 14
  41376. }
  41377. }
  41378. });
  41379. /***/ },
  41380. /* 284 */
  41381. /***/ function(module, exports, __webpack_require__) {
  41382. var TooltipContent = __webpack_require__(285);
  41383. var graphic = __webpack_require__(43);
  41384. var zrUtil = __webpack_require__(4);
  41385. var formatUtil = __webpack_require__(6);
  41386. var numberUtil = __webpack_require__(7);
  41387. var modelUtil = __webpack_require__(5);
  41388. var parsePercent = numberUtil.parsePercent;
  41389. var env = __webpack_require__(2);
  41390. var Model = __webpack_require__(12);
  41391. function dataEqual(a, b) {
  41392. if (!a || !b) {
  41393. return false;
  41394. }
  41395. var round = numberUtil.round;
  41396. return round(a[0]) === round(b[0])
  41397. && round(a[1]) === round(b[1]);
  41398. }
  41399. /**
  41400. * @inner
  41401. */
  41402. function makeLineShape(x1, y1, x2, y2) {
  41403. return {
  41404. x1: x1,
  41405. y1: y1,
  41406. x2: x2,
  41407. y2: y2
  41408. };
  41409. }
  41410. /**
  41411. * @inner
  41412. */
  41413. function makeRectShape(x, y, width, height) {
  41414. return {
  41415. x: x,
  41416. y: y,
  41417. width: width,
  41418. height: height
  41419. };
  41420. }
  41421. /**
  41422. * @inner
  41423. */
  41424. function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) {
  41425. return {
  41426. cx: cx,
  41427. cy: cy,
  41428. r0: r0,
  41429. r: r,
  41430. startAngle: startAngle,
  41431. endAngle: endAngle,
  41432. clockwise: true
  41433. };
  41434. }
  41435. function refixTooltipPosition(x, y, el, viewWidth, viewHeight) {
  41436. var width = el.clientWidth;
  41437. var height = el.clientHeight;
  41438. var gap = 20;
  41439. if (x + width + gap > viewWidth) {
  41440. x -= width + gap;
  41441. }
  41442. else {
  41443. x += gap;
  41444. }
  41445. if (y + height + gap > viewHeight) {
  41446. y -= height + gap;
  41447. }
  41448. else {
  41449. y += gap;
  41450. }
  41451. return [x, y];
  41452. }
  41453. function confineTooltipPosition(x, y, el, viewWidth, viewHeight) {
  41454. var width = el.clientWidth;
  41455. var height = el.clientHeight;
  41456. x = Math.min(x + width, viewWidth) - width;
  41457. y = Math.min(y + height, viewHeight) - height;
  41458. x = Math.max(x, 0);
  41459. y = Math.max(y, 0);
  41460. return [x, y];
  41461. }
  41462. function calcTooltipPosition(position, rect, dom) {
  41463. var domWidth = dom.clientWidth;
  41464. var domHeight = dom.clientHeight;
  41465. var gap = 5;
  41466. var x = 0;
  41467. var y = 0;
  41468. var rectWidth = rect.width;
  41469. var rectHeight = rect.height;
  41470. switch (position) {
  41471. case 'inside':
  41472. x = rect.x + rectWidth / 2 - domWidth / 2;
  41473. y = rect.y + rectHeight / 2 - domHeight / 2;
  41474. break;
  41475. case 'top':
  41476. x = rect.x + rectWidth / 2 - domWidth / 2;
  41477. y = rect.y - domHeight - gap;
  41478. break;
  41479. case 'bottom':
  41480. x = rect.x + rectWidth / 2 - domWidth / 2;
  41481. y = rect.y + rectHeight + gap;
  41482. break;
  41483. case 'left':
  41484. x = rect.x - domWidth - gap;
  41485. y = rect.y + rectHeight / 2 - domHeight / 2;
  41486. break;
  41487. case 'right':
  41488. x = rect.x + rectWidth + gap;
  41489. y = rect.y + rectHeight / 2 - domHeight / 2;
  41490. }
  41491. return [x, y];
  41492. }
  41493. /**
  41494. * @param {string|Function|Array.<number>} positionExpr
  41495. * @param {number} x Mouse x
  41496. * @param {number} y Mouse y
  41497. * @param {boolean} confine Whether confine tooltip content in view rect.
  41498. * @param {module:echarts/component/tooltip/TooltipContent} content
  41499. * @param {Object|<Array.<Object>} params
  41500. * @param {module:zrender/Element} el target element
  41501. * @param {module:echarts/ExtensionAPI} api
  41502. * @return {Array.<number>}
  41503. */
  41504. function updatePosition(positionExpr, x, y, confine, content, params, el, api) {
  41505. var viewWidth = api.getWidth();
  41506. var viewHeight = api.getHeight();
  41507. var rect = el && el.getBoundingRect().clone();
  41508. el && rect.applyTransform(el.transform);
  41509. if (typeof positionExpr === 'function') {
  41510. // Callback of position can be an array or a string specify the position
  41511. positionExpr = positionExpr([x, y], params, content.el, rect);
  41512. }
  41513. if (zrUtil.isArray(positionExpr)) {
  41514. x = parsePercent(positionExpr[0], viewWidth);
  41515. y = parsePercent(positionExpr[1], viewHeight);
  41516. }
  41517. // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
  41518. else if (typeof positionExpr === 'string' && el) {
  41519. var pos = calcTooltipPosition(
  41520. positionExpr, rect, content.el
  41521. );
  41522. x = pos[0];
  41523. y = pos[1];
  41524. }
  41525. else {
  41526. var pos = refixTooltipPosition(
  41527. x, y, content.el, viewWidth, viewHeight
  41528. );
  41529. x = pos[0];
  41530. y = pos[1];
  41531. }
  41532. if (confine) {
  41533. var pos = confineTooltipPosition(
  41534. x, y, content.el, viewWidth, viewHeight
  41535. );
  41536. x = pos[0];
  41537. y = pos[1];
  41538. }
  41539. content.moveTo(x, y);
  41540. }
  41541. function ifSeriesSupportAxisTrigger(seriesModel) {
  41542. var coordSys = seriesModel.coordinateSystem;
  41543. var trigger = seriesModel.get('tooltip.trigger', true);
  41544. // Ignore series use item tooltip trigger and series coordinate system is not cartesian or
  41545. return !(!coordSys
  41546. || (coordSys.type !== 'cartesian2d' && coordSys.type !== 'polar' && coordSys.type !== 'singleAxis')
  41547. || trigger === 'item');
  41548. }
  41549. __webpack_require__(1).extendComponentView({
  41550. type: 'tooltip',
  41551. _axisPointers: {},
  41552. init: function (ecModel, api) {
  41553. if (env.node) {
  41554. return;
  41555. }
  41556. var tooltipContent = new TooltipContent(api.getDom(), api);
  41557. this._tooltipContent = tooltipContent;
  41558. api.on('showTip', this._manuallyShowTip, this);
  41559. api.on('hideTip', this._manuallyHideTip, this);
  41560. },
  41561. render: function (tooltipModel, ecModel, api) {
  41562. if (env.node) {
  41563. return;
  41564. }
  41565. // Reset
  41566. this.group.removeAll();
  41567. /**
  41568. * @type {Object}
  41569. * @private
  41570. */
  41571. this._axisPointers = {};
  41572. /**
  41573. * @private
  41574. * @type {module:echarts/component/tooltip/TooltipModel}
  41575. */
  41576. this._tooltipModel = tooltipModel;
  41577. /**
  41578. * @private
  41579. * @type {module:echarts/model/Global}
  41580. */
  41581. this._ecModel = ecModel;
  41582. /**
  41583. * @private
  41584. * @type {module:echarts/ExtensionAPI}
  41585. */
  41586. this._api = api;
  41587. /**
  41588. * @type {Object}
  41589. * @private
  41590. */
  41591. this._lastHover = {
  41592. // data
  41593. // payloadBatch
  41594. };
  41595. var tooltipContent = this._tooltipContent;
  41596. tooltipContent.update();
  41597. tooltipContent.enterable = tooltipModel.get('enterable');
  41598. this._alwaysShowContent = tooltipModel.get('alwaysShowContent');
  41599. /**
  41600. * @type {Object.<string, Array>}
  41601. */
  41602. this._seriesGroupByAxis = this._prepareAxisTriggerData(
  41603. tooltipModel, ecModel
  41604. );
  41605. var crossText = this._crossText;
  41606. if (crossText) {
  41607. this.group.add(crossText);
  41608. }
  41609. var triggerOn = tooltipModel.get('triggerOn');
  41610. // Try to keep the tooltip show when refreshing
  41611. if (this._lastX != null
  41612. && this._lastY != null
  41613. // When user is willing to control tooltip totally using API,
  41614. // self._manuallyShowTip({x, y}) might cause tooltip hide,
  41615. // which is not expected.
  41616. && triggerOn !== 'none'
  41617. ) {
  41618. var self = this;
  41619. clearTimeout(this._refreshUpdateTimeout);
  41620. this._refreshUpdateTimeout = setTimeout(function () {
  41621. // Show tip next tick after other charts are rendered
  41622. // In case highlight action has wrong result
  41623. // FIXME
  41624. self._manuallyShowTip({
  41625. x: self._lastX,
  41626. y: self._lastY
  41627. });
  41628. });
  41629. }
  41630. var zr = this._api.getZr();
  41631. zr.off('click', this._tryShow);
  41632. zr.off('mousemove', this._mousemove);
  41633. zr.off('mouseout', this._hide);
  41634. zr.off('globalout', this._hide);
  41635. if (triggerOn === 'click') {
  41636. zr.on('click', this._tryShow, this);
  41637. }
  41638. else if (triggerOn === 'mousemove') {
  41639. zr.on('mousemove', this._mousemove, this);
  41640. zr.on('mouseout', this._hide, this);
  41641. zr.on('globalout', this._hide, this);
  41642. }
  41643. // else triggerOn is 'none', which enable user
  41644. // to control tooltip totally using API.
  41645. },
  41646. _mousemove: function (e) {
  41647. var showDelay = this._tooltipModel.get('showDelay');
  41648. var self = this;
  41649. clearTimeout(this._showTimeout);
  41650. if (showDelay > 0) {
  41651. this._showTimeout = setTimeout(function () {
  41652. self._tryShow(e);
  41653. }, showDelay);
  41654. }
  41655. else {
  41656. this._tryShow(e);
  41657. }
  41658. },
  41659. /**
  41660. * Show tip manually by
  41661. * dispatchAction({
  41662. * type: 'showTip',
  41663. * x: 10,
  41664. * y: 10
  41665. * });
  41666. * Or
  41667. * dispatchAction({
  41668. * type: 'showTip',
  41669. * seriesIndex: 0,
  41670. * dataIndex or dataIndexInside or name
  41671. * });
  41672. *
  41673. * TODO Batch
  41674. */
  41675. _manuallyShowTip: function (event) {
  41676. // From self
  41677. if (event.from === this.uid) {
  41678. return;
  41679. }
  41680. var ecModel = this._ecModel;
  41681. var seriesIndex = event.seriesIndex;
  41682. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  41683. var api = this._api;
  41684. var isTriggerAxis = this._tooltipModel.get('trigger') === 'axis';
  41685. function seriesHaveDataOnIndex(_series) {
  41686. var data = _series.getData();
  41687. var dataIndex = modelUtil.queryDataIndex(data, event);
  41688. // Have single dataIndex
  41689. if (dataIndex != null && !zrUtil.isArray(dataIndex)
  41690. && data.hasValue(dataIndex)
  41691. ) {
  41692. return true;
  41693. }
  41694. }
  41695. if (event.x == null || event.y == null) {
  41696. if (isTriggerAxis) {
  41697. // Find another series.
  41698. if (seriesModel && !seriesHaveDataOnIndex(seriesModel)) {
  41699. seriesModel = null;
  41700. }
  41701. if (!seriesModel) {
  41702. // Find the first series can use axis trigger And data is not null
  41703. ecModel.eachSeries(function (_series) {
  41704. if (ifSeriesSupportAxisTrigger(_series) && !seriesModel) {
  41705. if (seriesHaveDataOnIndex(_series)) {
  41706. seriesModel = _series;
  41707. }
  41708. }
  41709. });
  41710. }
  41711. }
  41712. else {
  41713. // Use the first series by default.
  41714. seriesModel = seriesModel || ecModel.getSeriesByIndex(0);
  41715. }
  41716. if (seriesModel) {
  41717. var data = seriesModel.getData();
  41718. var dataIndex = modelUtil.queryDataIndex(data, event);
  41719. if (dataIndex == null || zrUtil.isArray(dataIndex)) {
  41720. return;
  41721. }
  41722. var el = data.getItemGraphicEl(dataIndex);
  41723. var cx;
  41724. var cy;
  41725. // Try to get the point in coordinate system
  41726. var coordSys = seriesModel.coordinateSystem;
  41727. if (seriesModel.getTooltipPosition) {
  41728. var point = seriesModel.getTooltipPosition(dataIndex) || [];
  41729. cx = point[0];
  41730. cy = point[1];
  41731. }
  41732. else if (coordSys && coordSys.dataToPoint) {
  41733. var point = coordSys.dataToPoint(
  41734. data.getValues(
  41735. zrUtil.map(coordSys.dimensions, function (dim) {
  41736. return seriesModel.coordDimToDataDim(dim)[0];
  41737. }), dataIndex, true
  41738. )
  41739. );
  41740. cx = point && point[0];
  41741. cy = point && point[1];
  41742. }
  41743. else if (el) {
  41744. // Use graphic bounding rect
  41745. var rect = el.getBoundingRect().clone();
  41746. rect.applyTransform(el.transform);
  41747. cx = rect.x + rect.width / 2;
  41748. cy = rect.y + rect.height / 2;
  41749. }
  41750. if (cx != null && cy != null) {
  41751. this._tryShow({
  41752. offsetX: cx,
  41753. offsetY: cy,
  41754. position: event.position,
  41755. target: el,
  41756. event: {}
  41757. });
  41758. }
  41759. }
  41760. }
  41761. else {
  41762. var el = api.getZr().handler.findHover(event.x, event.y);
  41763. this._tryShow({
  41764. offsetX: event.x,
  41765. offsetY: event.y,
  41766. position: event.position,
  41767. target: el,
  41768. event: {}
  41769. });
  41770. }
  41771. },
  41772. _manuallyHideTip: function (e) {
  41773. if (e.from === this.uid) {
  41774. return;
  41775. }
  41776. this._hide();
  41777. },
  41778. _prepareAxisTriggerData: function (tooltipModel, ecModel) {
  41779. // Prepare data for axis trigger
  41780. var seriesGroupByAxis = {};
  41781. ecModel.eachSeries(function (seriesModel) {
  41782. if (ifSeriesSupportAxisTrigger(seriesModel)) {
  41783. var coordSys = seriesModel.coordinateSystem;
  41784. var baseAxis;
  41785. var key;
  41786. // Only cartesian2d, polar and single support axis trigger
  41787. if (coordSys.type === 'cartesian2d') {
  41788. // FIXME `axisPointer.axis` is not baseAxis
  41789. baseAxis = coordSys.getBaseAxis();
  41790. key = baseAxis.dim + baseAxis.index;
  41791. }
  41792. else if (coordSys.type === 'singleAxis') {
  41793. baseAxis = coordSys.getAxis();
  41794. key = baseAxis.dim + baseAxis.type;
  41795. }
  41796. else {
  41797. baseAxis = coordSys.getBaseAxis();
  41798. key = baseAxis.dim + coordSys.name;
  41799. }
  41800. seriesGroupByAxis[key] = seriesGroupByAxis[key] || {
  41801. coordSys: [],
  41802. series: []
  41803. };
  41804. seriesGroupByAxis[key].coordSys.push(coordSys);
  41805. seriesGroupByAxis[key].series.push(seriesModel);
  41806. }
  41807. }, this);
  41808. return seriesGroupByAxis;
  41809. },
  41810. /**
  41811. * mousemove handler
  41812. * @param {Object} e
  41813. * @private
  41814. */
  41815. _tryShow: function (e) {
  41816. var el = e.target;
  41817. var tooltipModel = this._tooltipModel;
  41818. var globalTrigger = tooltipModel.get('trigger');
  41819. var ecModel = this._ecModel;
  41820. var api = this._api;
  41821. if (!tooltipModel) {
  41822. return;
  41823. }
  41824. // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed
  41825. this._lastX = e.offsetX;
  41826. this._lastY = e.offsetY;
  41827. // Always show item tooltip if mouse is on the element with dataIndex
  41828. if (el && el.dataIndex != null) {
  41829. // Use dataModel in element if possible
  41830. // Used when mouseover on a element like markPoint or edge
  41831. // In which case, the data is not main data in series.
  41832. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  41833. var dataIndex = el.dataIndex;
  41834. var itemModel = dataModel.getData().getItemModel(dataIndex);
  41835. // Series or single data may use item trigger when global is axis trigger
  41836. if ((itemModel.get('tooltip.trigger') || globalTrigger) === 'axis') {
  41837. this._showAxisTooltip(tooltipModel, ecModel, e);
  41838. }
  41839. else {
  41840. // Reset ticket
  41841. this._ticket = '';
  41842. // If either single data or series use item trigger
  41843. this._hideAxisPointer();
  41844. // Reset last hover and dispatch downplay action
  41845. this._resetLastHover();
  41846. this._showItemTooltipContent(dataModel, dataIndex, el.dataType, e);
  41847. }
  41848. api.dispatchAction({
  41849. type: 'showTip',
  41850. from: this.uid,
  41851. dataIndexInside: el.dataIndex,
  41852. seriesIndex: el.seriesIndex
  41853. });
  41854. }
  41855. // Tooltip provided directly. Like legend
  41856. else if (el && el.tooltip) {
  41857. var tooltipOpt = el.tooltip;
  41858. if (typeof tooltipOpt === 'string') {
  41859. var content = tooltipOpt;
  41860. tooltipOpt = {
  41861. content: content,
  41862. // Fixed formatter
  41863. formatter: content
  41864. };
  41865. }
  41866. var subTooltipModel = new Model(tooltipOpt, tooltipModel);
  41867. var defaultHtml = subTooltipModel.get('content');
  41868. var asyncTicket = Math.random();
  41869. this._showTooltipContent(
  41870. // TODO params
  41871. subTooltipModel, defaultHtml, subTooltipModel.get('formatterParams') || {},
  41872. asyncTicket, e.offsetX, e.offsetY, e.position, el, api
  41873. );
  41874. }
  41875. else {
  41876. if (globalTrigger === 'item') {
  41877. this._hide();
  41878. }
  41879. else {
  41880. // Try show axis tooltip
  41881. this._showAxisTooltip(tooltipModel, ecModel, e);
  41882. }
  41883. // Action of cross pointer
  41884. // other pointer types will trigger action in _dispatchAndShowSeriesTooltipContent method
  41885. if (tooltipModel.get('axisPointer.type') === 'cross') {
  41886. api.dispatchAction({
  41887. type: 'showTip',
  41888. from: this.uid,
  41889. x: e.offsetX,
  41890. y: e.offsetY
  41891. });
  41892. }
  41893. }
  41894. },
  41895. /**
  41896. * Show tooltip on axis
  41897. * @param {module:echarts/component/tooltip/TooltipModel} tooltipModel
  41898. * @param {module:echarts/model/Global} ecModel
  41899. * @param {Object} e
  41900. * @private
  41901. */
  41902. _showAxisTooltip: function (tooltipModel, ecModel, e) {
  41903. var axisPointerModel = tooltipModel.getModel('axisPointer');
  41904. var axisPointerType = axisPointerModel.get('type');
  41905. if (axisPointerType === 'cross') {
  41906. var el = e.target;
  41907. if (el && el.dataIndex != null) {
  41908. var seriesModel = ecModel.getSeriesByIndex(el.seriesIndex);
  41909. var dataIndex = el.dataIndex;
  41910. this._showItemTooltipContent(seriesModel, dataIndex, el.dataType, e);
  41911. }
  41912. }
  41913. this._showAxisPointer();
  41914. var allNotShow = true;
  41915. zrUtil.each(this._seriesGroupByAxis, function (seriesCoordSysSameAxis) {
  41916. // Try show the axis pointer
  41917. var allCoordSys = seriesCoordSysSameAxis.coordSys;
  41918. var coordSys = allCoordSys[0];
  41919. // If mouse position is not in the grid or polar
  41920. var point = [e.offsetX, e.offsetY];
  41921. if (!coordSys.containPoint(point)) {
  41922. // Hide axis pointer
  41923. this._hideAxisPointer(coordSys.name);
  41924. return;
  41925. }
  41926. allNotShow = false;
  41927. // Make sure point is discrete on cateogry axis
  41928. var dimensions = coordSys.dimensions;
  41929. var value = coordSys.pointToData(point, true);
  41930. point = coordSys.dataToPoint(value);
  41931. var baseAxis = coordSys.getBaseAxis();
  41932. var axisType = axisPointerModel.get('axis');
  41933. if (axisType === 'auto') {
  41934. axisType = baseAxis.dim;
  41935. }
  41936. var contentNotChange = false;
  41937. var lastHover = this._lastHover;
  41938. if (axisPointerType === 'cross') {
  41939. // If hover data not changed
  41940. // Possible when two axes are all category
  41941. if (dataEqual(lastHover.data, value)) {
  41942. contentNotChange = true;
  41943. }
  41944. lastHover.data = value;
  41945. }
  41946. else {
  41947. var valIndex = zrUtil.indexOf(dimensions, axisType);
  41948. // If hover data not changed on the axis dimension
  41949. if (lastHover.data === value[valIndex]) {
  41950. contentNotChange = true;
  41951. }
  41952. lastHover.data = value[valIndex];
  41953. }
  41954. var enableAnimation = tooltipModel.get('animation');
  41955. if (coordSys.type === 'cartesian2d' && !contentNotChange) {
  41956. this._showCartesianPointer(
  41957. axisPointerModel, coordSys, axisType, point, enableAnimation
  41958. );
  41959. }
  41960. else if (coordSys.type === 'polar' && !contentNotChange) {
  41961. this._showPolarPointer(
  41962. axisPointerModel, coordSys, axisType, point, enableAnimation
  41963. );
  41964. }
  41965. else if (coordSys.type === 'singleAxis' && !contentNotChange) {
  41966. this._showSinglePointer(
  41967. axisPointerModel, coordSys, axisType, point, enableAnimation
  41968. );
  41969. }
  41970. if (axisPointerType !== 'cross') {
  41971. this._dispatchAndShowSeriesTooltipContent(
  41972. coordSys, seriesCoordSysSameAxis.series, point, value, contentNotChange, e.position
  41973. );
  41974. }
  41975. }, this);
  41976. if (!this._tooltipModel.get('show')) {
  41977. this._hideAxisPointer();
  41978. }
  41979. if (allNotShow) {
  41980. this._hide();
  41981. }
  41982. },
  41983. /**
  41984. * Show tooltip on axis of cartesian coordinate
  41985. * @param {module:echarts/model/Model} axisPointerModel
  41986. * @param {module:echarts/coord/cartesian/Cartesian2D} cartesians
  41987. * @param {string} axisType
  41988. * @param {Array.<number>} point
  41989. * @private
  41990. */
  41991. _showCartesianPointer: function (axisPointerModel, cartesian, axisType, point, enableAnimation) {
  41992. var self = this;
  41993. var axisPointerType = axisPointerModel.get('type');
  41994. var baseAxis = cartesian.getBaseAxis();
  41995. var moveAnimation = enableAnimation
  41996. && axisPointerType !== 'cross'
  41997. && baseAxis.type === 'category'
  41998. && baseAxis.getBandWidth() > 20;
  41999. if (axisPointerType === 'cross') {
  42000. moveGridLine('x', point, cartesian.getAxis('y').getGlobalExtent());
  42001. moveGridLine('y', point, cartesian.getAxis('x').getGlobalExtent());
  42002. this._updateCrossText(cartesian, point, axisPointerModel);
  42003. }
  42004. else {
  42005. var otherAxis = cartesian.getAxis(axisType === 'x' ? 'y' : 'x');
  42006. var otherExtent = otherAxis.getGlobalExtent();
  42007. if (cartesian.type === 'cartesian2d') {
  42008. (axisPointerType === 'line' ? moveGridLine : moveGridShadow)(
  42009. axisType, point, otherExtent
  42010. );
  42011. }
  42012. }
  42013. /**
  42014. * @inner
  42015. */
  42016. function moveGridLine(axisType, point, otherExtent) {
  42017. var targetShape = axisType === 'x'
  42018. ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1])
  42019. : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]);
  42020. var pointerEl = self._getPointerElement(
  42021. cartesian, axisPointerModel, axisType, targetShape
  42022. );
  42023. graphic.subPixelOptimizeLine({
  42024. shape: targetShape,
  42025. style: pointerEl.style
  42026. });
  42027. moveAnimation
  42028. ? graphic.updateProps(pointerEl, {
  42029. shape: targetShape
  42030. }, axisPointerModel)
  42031. : pointerEl.attr({
  42032. shape: targetShape
  42033. });
  42034. }
  42035. /**
  42036. * @inner
  42037. */
  42038. function moveGridShadow(axisType, point, otherExtent) {
  42039. var axis = cartesian.getAxis(axisType);
  42040. var bandWidth = axis.getBandWidth();
  42041. var span = otherExtent[1] - otherExtent[0];
  42042. var targetShape = axisType === 'x'
  42043. ? makeRectShape(point[0] - bandWidth / 2, otherExtent[0], bandWidth, span)
  42044. : makeRectShape(otherExtent[0], point[1] - bandWidth / 2, span, bandWidth);
  42045. var pointerEl = self._getPointerElement(
  42046. cartesian, axisPointerModel, axisType, targetShape
  42047. );
  42048. moveAnimation
  42049. ? graphic.updateProps(pointerEl, {
  42050. shape: targetShape
  42051. }, axisPointerModel)
  42052. : pointerEl.attr({
  42053. shape: targetShape
  42054. });
  42055. }
  42056. },
  42057. _showSinglePointer: function (axisPointerModel, single, axisType, point, enableAnimation) {
  42058. var self = this;
  42059. var axisPointerType = axisPointerModel.get('type');
  42060. var moveAnimation =
  42061. enableAnimation
  42062. && axisPointerType !== 'cross'
  42063. && single.getBaseAxis().type === 'category';
  42064. var rect = single.getRect();
  42065. var otherExtent = [rect.y, rect.y + rect.height];
  42066. moveSingleLine(axisType, point, otherExtent);
  42067. /**
  42068. * @inner
  42069. */
  42070. function moveSingleLine(axisType, point, otherExtent) {
  42071. var axis = single.getAxis();
  42072. var orient = axis.orient;
  42073. var targetShape = orient === 'horizontal'
  42074. ? makeLineShape(point[0], otherExtent[0], point[0], otherExtent[1])
  42075. : makeLineShape(otherExtent[0], point[1], otherExtent[1], point[1]);
  42076. var pointerEl = self._getPointerElement(
  42077. single, axisPointerModel, axisType, targetShape
  42078. );
  42079. moveAnimation
  42080. ? graphic.updateProps(pointerEl, {
  42081. shape: targetShape
  42082. }, axisPointerModel)
  42083. : pointerEl.attr({
  42084. shape: targetShape
  42085. });
  42086. }
  42087. },
  42088. /**
  42089. * Show tooltip on axis of polar coordinate
  42090. * @param {module:echarts/model/Model} axisPointerModel
  42091. * @param {Array.<module:echarts/coord/polar/Polar>} polar
  42092. * @param {string} axisType
  42093. * @param {Array.<number>} point
  42094. */
  42095. _showPolarPointer: function (axisPointerModel, polar, axisType, point, enableAnimation) {
  42096. var self = this;
  42097. var axisPointerType = axisPointerModel.get('type');
  42098. var angleAxis = polar.getAngleAxis();
  42099. var radiusAxis = polar.getRadiusAxis();
  42100. var moveAnimation = enableAnimation
  42101. && axisPointerType !== 'cross'
  42102. && polar.getBaseAxis().type === 'category';
  42103. if (axisPointerType === 'cross') {
  42104. movePolarLine('angle', point, radiusAxis.getExtent());
  42105. movePolarLine('radius', point, angleAxis.getExtent());
  42106. this._updateCrossText(polar, point, axisPointerModel);
  42107. }
  42108. else {
  42109. var otherAxis = polar.getAxis(axisType === 'radius' ? 'angle' : 'radius');
  42110. var otherExtent = otherAxis.getExtent();
  42111. (axisPointerType === 'line' ? movePolarLine : movePolarShadow)(
  42112. axisType, point, otherExtent
  42113. );
  42114. }
  42115. /**
  42116. * @inner
  42117. */
  42118. function movePolarLine(axisType, point, otherExtent) {
  42119. var mouseCoord = polar.pointToCoord(point);
  42120. var targetShape;
  42121. if (axisType === 'angle') {
  42122. var p1 = polar.coordToPoint([otherExtent[0], mouseCoord[1]]);
  42123. var p2 = polar.coordToPoint([otherExtent[1], mouseCoord[1]]);
  42124. targetShape = makeLineShape(p1[0], p1[1], p2[0], p2[1]);
  42125. }
  42126. else {
  42127. targetShape = {
  42128. cx: polar.cx,
  42129. cy: polar.cy,
  42130. r: mouseCoord[0]
  42131. };
  42132. }
  42133. var pointerEl = self._getPointerElement(
  42134. polar, axisPointerModel, axisType, targetShape
  42135. );
  42136. moveAnimation
  42137. ? graphic.updateProps(pointerEl, {
  42138. shape: targetShape
  42139. }, axisPointerModel)
  42140. : pointerEl.attr({
  42141. shape: targetShape
  42142. });
  42143. }
  42144. /**
  42145. * @inner
  42146. */
  42147. function movePolarShadow(axisType, point, otherExtent) {
  42148. var axis = polar.getAxis(axisType);
  42149. var bandWidth = axis.getBandWidth();
  42150. var mouseCoord = polar.pointToCoord(point);
  42151. var targetShape;
  42152. var radian = Math.PI / 180;
  42153. if (axisType === 'angle') {
  42154. targetShape = makeSectorShape(
  42155. polar.cx, polar.cy,
  42156. otherExtent[0], otherExtent[1],
  42157. // In ECharts y is negative if angle is positive
  42158. (-mouseCoord[1] - bandWidth / 2) * radian,
  42159. (-mouseCoord[1] + bandWidth / 2) * radian
  42160. );
  42161. }
  42162. else {
  42163. targetShape = makeSectorShape(
  42164. polar.cx, polar.cy,
  42165. mouseCoord[0] - bandWidth / 2,
  42166. mouseCoord[0] + bandWidth / 2,
  42167. 0, Math.PI * 2
  42168. );
  42169. }
  42170. var pointerEl = self._getPointerElement(
  42171. polar, axisPointerModel, axisType, targetShape
  42172. );
  42173. moveAnimation
  42174. ? graphic.updateProps(pointerEl, {
  42175. shape: targetShape
  42176. }, axisPointerModel)
  42177. : pointerEl.attr({
  42178. shape: targetShape
  42179. });
  42180. }
  42181. },
  42182. _updateCrossText: function (coordSys, point, axisPointerModel) {
  42183. var crossStyleModel = axisPointerModel.getModel('crossStyle');
  42184. var textStyleModel = crossStyleModel.getModel('textStyle');
  42185. var tooltipModel = this._tooltipModel;
  42186. var text = this._crossText;
  42187. if (!text) {
  42188. text = this._crossText = new graphic.Text({
  42189. style: {
  42190. textAlign: 'left',
  42191. textVerticalAlign: 'bottom'
  42192. }
  42193. });
  42194. this.group.add(text);
  42195. }
  42196. var value = coordSys.pointToData(point);
  42197. var dims = coordSys.dimensions;
  42198. value = zrUtil.map(value, function (val, idx) {
  42199. var axis = coordSys.getAxis(dims[idx]);
  42200. if (axis.type === 'category' || axis.type === 'time') {
  42201. val = axis.scale.getLabel(val);
  42202. }
  42203. else {
  42204. val = formatUtil.addCommas(
  42205. val.toFixed(axis.getPixelPrecision())
  42206. );
  42207. }
  42208. return val;
  42209. });
  42210. text.setStyle({
  42211. fill: textStyleModel.getTextColor() || crossStyleModel.get('color'),
  42212. textFont: textStyleModel.getFont(),
  42213. text: value.join(', '),
  42214. x: point[0] + 5,
  42215. y: point[1] - 5
  42216. });
  42217. text.z = tooltipModel.get('z');
  42218. text.zlevel = tooltipModel.get('zlevel');
  42219. },
  42220. _getPointerElement: function (coordSys, pointerModel, axisType, initShape) {
  42221. var tooltipModel = this._tooltipModel;
  42222. var z = tooltipModel.get('z');
  42223. var zlevel = tooltipModel.get('zlevel');
  42224. var axisPointers = this._axisPointers;
  42225. var coordSysName = coordSys.name;
  42226. axisPointers[coordSysName] = axisPointers[coordSysName] || {};
  42227. if (axisPointers[coordSysName][axisType]) {
  42228. return axisPointers[coordSysName][axisType];
  42229. }
  42230. // Create if not exists
  42231. var pointerType = pointerModel.get('type');
  42232. var styleModel = pointerModel.getModel(pointerType + 'Style');
  42233. var isShadow = pointerType === 'shadow';
  42234. var style = styleModel[isShadow ? 'getAreaStyle' : 'getLineStyle']();
  42235. var elementType = coordSys.type === 'polar'
  42236. ? (isShadow ? 'Sector' : (axisType === 'radius' ? 'Circle' : 'Line'))
  42237. : (isShadow ? 'Rect' : 'Line');
  42238. isShadow ? (style.stroke = null) : (style.fill = null);
  42239. var el = axisPointers[coordSysName][axisType] = new graphic[elementType]({
  42240. style: style,
  42241. z: z,
  42242. zlevel: zlevel,
  42243. silent: true,
  42244. shape: initShape
  42245. });
  42246. this.group.add(el);
  42247. return el;
  42248. },
  42249. /**
  42250. * Dispatch actions and show tooltip on series
  42251. * @param {Array.<module:echarts/model/Series>} seriesList
  42252. * @param {Array.<number>} point
  42253. * @param {Array.<number>} value
  42254. * @param {boolean} contentNotChange
  42255. * @param {Array.<number>|string|Function} [positionExpr]
  42256. */
  42257. _dispatchAndShowSeriesTooltipContent: function (
  42258. coordSys, seriesList, point, value, contentNotChange, positionExpr
  42259. ) {
  42260. var rootTooltipModel = this._tooltipModel;
  42261. var baseAxis = coordSys.getBaseAxis();
  42262. var baseDimIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
  42263. var payloadBatch = zrUtil.map(seriesList, function (series) {
  42264. return {
  42265. seriesIndex: series.seriesIndex,
  42266. dataIndexInside: series.getAxisTooltipDataIndex
  42267. ? series.getAxisTooltipDataIndex(series.coordDimToDataDim(baseAxis.dim), value, baseAxis)
  42268. : series.getData().indexOfNearest(
  42269. series.coordDimToDataDim(baseAxis.dim)[0],
  42270. value[baseDimIndex],
  42271. // Add a threshold to avoid find the wrong dataIndex when data length is not same
  42272. false, baseAxis.type === 'category' ? 0.5 : null
  42273. )
  42274. };
  42275. });
  42276. var sampleSeriesIndex;
  42277. zrUtil.each(payloadBatch, function (payload, idx) {
  42278. if (seriesList[idx].getData().hasValue(payload.dataIndexInside)) {
  42279. sampleSeriesIndex = idx;
  42280. }
  42281. });
  42282. // Fallback to 0.
  42283. sampleSeriesIndex = sampleSeriesIndex || 0;
  42284. var lastHover = this._lastHover;
  42285. var api = this._api;
  42286. // Dispatch downplay action
  42287. if (lastHover.payloadBatch && !contentNotChange) {
  42288. api.dispatchAction({
  42289. type: 'downplay',
  42290. batch: lastHover.payloadBatch
  42291. });
  42292. }
  42293. // Dispatch highlight action
  42294. if (!contentNotChange) {
  42295. api.dispatchAction({
  42296. type: 'highlight',
  42297. batch: payloadBatch
  42298. });
  42299. lastHover.payloadBatch = payloadBatch;
  42300. }
  42301. // Dispatch showTip action
  42302. api.dispatchAction({
  42303. type: 'showTip',
  42304. dataIndexInside: payloadBatch[sampleSeriesIndex].dataIndexInside,
  42305. seriesIndex: payloadBatch[sampleSeriesIndex].seriesIndex,
  42306. from: this.uid
  42307. });
  42308. if (baseAxis && rootTooltipModel.get('showContent') && rootTooltipModel.get('show')) {
  42309. var paramsList = zrUtil.map(seriesList, function (series, index) {
  42310. return series.getDataParams(payloadBatch[index].dataIndexInside);
  42311. });
  42312. if (!contentNotChange) {
  42313. // Update html content
  42314. var firstDataIndex = payloadBatch[sampleSeriesIndex].dataIndexInside;
  42315. // Default tooltip content
  42316. // FIXME
  42317. // (1) shold be the first data which has name?
  42318. // (2) themeRiver, firstDataIndex is array, and first line is unnecessary.
  42319. var firstLine = baseAxis.type === 'time'
  42320. ? baseAxis.scale.getLabel(value[baseDimIndex])
  42321. : seriesList[sampleSeriesIndex].getData().getName(firstDataIndex);
  42322. var defaultHtml = (firstLine ? firstLine + '<br />' : '')
  42323. + zrUtil.map(seriesList, function (series, index) {
  42324. return series.formatTooltip(payloadBatch[index].dataIndexInside, true);
  42325. }).join('<br />');
  42326. var asyncTicket = 'axis_' + coordSys.name + '_' + firstDataIndex;
  42327. this._showTooltipContent(
  42328. rootTooltipModel, defaultHtml, paramsList, asyncTicket,
  42329. point[0], point[1], positionExpr, null, api
  42330. );
  42331. }
  42332. else {
  42333. updatePosition(
  42334. positionExpr || rootTooltipModel.get('position'),
  42335. point[0], point[1],
  42336. rootTooltipModel.get('confine'),
  42337. this._tooltipContent, paramsList, null, api
  42338. );
  42339. }
  42340. }
  42341. },
  42342. /**
  42343. * Show tooltip on item
  42344. * @param {module:echarts/model/Series} seriesModel
  42345. * @param {number} dataIndex
  42346. * @param {string} dataType
  42347. * @param {Object} e
  42348. */
  42349. _showItemTooltipContent: function (seriesModel, dataIndex, dataType, e) {
  42350. // FIXME Graph data
  42351. var api = this._api;
  42352. var data = seriesModel.getData(dataType);
  42353. var itemModel = data.getItemModel(dataIndex);
  42354. var tooltipOpt = itemModel.get('tooltip', true);
  42355. if (typeof tooltipOpt === 'string') {
  42356. // In each data item tooltip can be simply write:
  42357. // {
  42358. // value: 10,
  42359. // tooltip: 'Something you need to know'
  42360. // }
  42361. var tooltipContent = tooltipOpt;
  42362. tooltipOpt = {
  42363. formatter: tooltipContent
  42364. };
  42365. }
  42366. var rootTooltipModel = this._tooltipModel;
  42367. var seriesTooltipModel = seriesModel.getModel(
  42368. 'tooltip', rootTooltipModel
  42369. );
  42370. var tooltipModel = new Model(tooltipOpt, seriesTooltipModel, seriesTooltipModel.ecModel);
  42371. var params = seriesModel.getDataParams(dataIndex, dataType);
  42372. var defaultHtml = seriesModel.formatTooltip(dataIndex, false, dataType);
  42373. var asyncTicket = 'item_' + seriesModel.name + '_' + dataIndex;
  42374. this._showTooltipContent(
  42375. tooltipModel, defaultHtml, params, asyncTicket,
  42376. e.offsetX, e.offsetY, e.position, e.target, api
  42377. );
  42378. },
  42379. _showTooltipContent: function (
  42380. tooltipModel, defaultHtml, params, asyncTicket, x, y, positionExpr, target, api
  42381. ) {
  42382. // Reset ticket
  42383. this._ticket = '';
  42384. if (tooltipModel.get('showContent') && tooltipModel.get('show')) {
  42385. var tooltipContent = this._tooltipContent;
  42386. var confine = tooltipModel.get('confine');
  42387. var formatter = tooltipModel.get('formatter');
  42388. positionExpr = positionExpr || tooltipModel.get('position');
  42389. var html = defaultHtml;
  42390. if (formatter) {
  42391. if (typeof formatter === 'string') {
  42392. html = formatUtil.formatTpl(formatter, params);
  42393. }
  42394. else if (typeof formatter === 'function') {
  42395. var self = this;
  42396. var ticket = asyncTicket;
  42397. var callback = function (cbTicket, html) {
  42398. if (cbTicket === self._ticket) {
  42399. tooltipContent.setContent(html);
  42400. updatePosition(
  42401. positionExpr, x, y, confine,
  42402. tooltipContent, params, target, api
  42403. );
  42404. }
  42405. };
  42406. self._ticket = ticket;
  42407. html = formatter(params, ticket, callback);
  42408. }
  42409. }
  42410. tooltipContent.show(tooltipModel);
  42411. tooltipContent.setContent(html);
  42412. updatePosition(
  42413. positionExpr, x, y, confine,
  42414. tooltipContent, params, target, api
  42415. );
  42416. }
  42417. },
  42418. /**
  42419. * Show axis pointer
  42420. * @param {string} [coordSysName]
  42421. */
  42422. _showAxisPointer: function (coordSysName) {
  42423. if (coordSysName) {
  42424. var axisPointers = this._axisPointers[coordSysName];
  42425. axisPointers && zrUtil.each(axisPointers, function (el) {
  42426. el.show();
  42427. });
  42428. }
  42429. else {
  42430. this.group.eachChild(function (child) {
  42431. child.show();
  42432. });
  42433. this.group.show();
  42434. }
  42435. },
  42436. _resetLastHover: function () {
  42437. var lastHover = this._lastHover;
  42438. if (lastHover.payloadBatch) {
  42439. this._api.dispatchAction({
  42440. type: 'downplay',
  42441. batch: lastHover.payloadBatch
  42442. });
  42443. }
  42444. // Reset lastHover
  42445. this._lastHover = {};
  42446. },
  42447. /**
  42448. * Hide axis pointer
  42449. * @param {string} [coordSysName]
  42450. */
  42451. _hideAxisPointer: function (coordSysName) {
  42452. if (coordSysName) {
  42453. var axisPointers = this._axisPointers[coordSysName];
  42454. axisPointers && zrUtil.each(axisPointers, function (el) {
  42455. el.hide();
  42456. });
  42457. }
  42458. else {
  42459. if (this.group.children().length) {
  42460. this.group.hide();
  42461. }
  42462. }
  42463. },
  42464. _hide: function () {
  42465. clearTimeout(this._showTimeout);
  42466. this._hideAxisPointer();
  42467. this._resetLastHover();
  42468. if (!this._alwaysShowContent) {
  42469. this._tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
  42470. }
  42471. this._api.dispatchAction({
  42472. type: 'hideTip',
  42473. from: this.uid
  42474. });
  42475. this._lastX = this._lastY = null;
  42476. },
  42477. dispose: function (ecModel, api) {
  42478. if (env.node) {
  42479. return;
  42480. }
  42481. var zr = api.getZr();
  42482. this._tooltipContent.hide();
  42483. zr.off('click', this._tryShow);
  42484. zr.off('mousemove', this._mousemove);
  42485. zr.off('mouseout', this._hide);
  42486. zr.off('globalout', this._hide);
  42487. api.off('showTip', this._manuallyShowTip);
  42488. api.off('hideTip', this._manuallyHideTip);
  42489. }
  42490. });
  42491. /***/ },
  42492. /* 285 */
  42493. /***/ function(module, exports, __webpack_require__) {
  42494. /**
  42495. * @module echarts/component/tooltip/TooltipContent
  42496. */
  42497. var zrUtil = __webpack_require__(4);
  42498. var zrColor = __webpack_require__(39);
  42499. var eventUtil = __webpack_require__(88);
  42500. var formatUtil = __webpack_require__(6);
  42501. var each = zrUtil.each;
  42502. var toCamelCase = formatUtil.toCamelCase;
  42503. var env = __webpack_require__(2);
  42504. var vendors = ['', '-webkit-', '-moz-', '-o-'];
  42505. var gCssText = 'position:absolute;display:block;border-style:solid;white-space:nowrap;z-index:9999999;';
  42506. /**
  42507. * @param {number} duration
  42508. * @return {string}
  42509. * @inner
  42510. */
  42511. function assembleTransition(duration) {
  42512. var transitionCurve = 'cubic-bezier(0.23, 1, 0.32, 1)';
  42513. var transitionText = 'left ' + duration + 's ' + transitionCurve + ','
  42514. + 'top ' + duration + 's ' + transitionCurve;
  42515. return zrUtil.map(vendors, function (vendorPrefix) {
  42516. return vendorPrefix + 'transition:' + transitionText;
  42517. }).join(';');
  42518. }
  42519. /**
  42520. * @param {Object} textStyle
  42521. * @return {string}
  42522. * @inner
  42523. */
  42524. function assembleFont(textStyleModel) {
  42525. var cssText = [];
  42526. var fontSize = textStyleModel.get('fontSize');
  42527. var color = textStyleModel.getTextColor();
  42528. color && cssText.push('color:' + color);
  42529. cssText.push('font:' + textStyleModel.getFont());
  42530. fontSize &&
  42531. cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px');
  42532. each(['decoration', 'align'], function (name) {
  42533. var val = textStyleModel.get(name);
  42534. val && cssText.push('text-' + name + ':' + val);
  42535. });
  42536. return cssText.join(';');
  42537. }
  42538. /**
  42539. * @param {Object} tooltipModel
  42540. * @return {string}
  42541. * @inner
  42542. */
  42543. function assembleCssText(tooltipModel) {
  42544. tooltipModel = tooltipModel;
  42545. var cssText = [];
  42546. var transitionDuration = tooltipModel.get('transitionDuration');
  42547. var backgroundColor = tooltipModel.get('backgroundColor');
  42548. var textStyleModel = tooltipModel.getModel('textStyle');
  42549. var padding = tooltipModel.get('padding');
  42550. // Animation transition
  42551. transitionDuration &&
  42552. cssText.push(assembleTransition(transitionDuration));
  42553. if (backgroundColor) {
  42554. if (env.canvasSupported) {
  42555. cssText.push('background-Color:' + backgroundColor);
  42556. }
  42557. else {
  42558. // for ie
  42559. cssText.push(
  42560. 'background-Color:#' + zrColor.toHex(backgroundColor)
  42561. );
  42562. cssText.push('filter:alpha(opacity=70)');
  42563. }
  42564. }
  42565. // Border style
  42566. each(['width', 'color', 'radius'], function (name) {
  42567. var borderName = 'border-' + name;
  42568. var camelCase = toCamelCase(borderName);
  42569. var val = tooltipModel.get(camelCase);
  42570. val != null &&
  42571. cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px'));
  42572. });
  42573. // Text style
  42574. cssText.push(assembleFont(textStyleModel));
  42575. // Padding
  42576. if (padding != null) {
  42577. cssText.push('padding:' + formatUtil.normalizeCssArray(padding).join('px ') + 'px');
  42578. }
  42579. return cssText.join(';') + ';';
  42580. }
  42581. /**
  42582. * @alias module:echarts/component/tooltip/TooltipContent
  42583. * @constructor
  42584. */
  42585. function TooltipContent(container, api) {
  42586. var el = document.createElement('div');
  42587. var zr = api.getZr();
  42588. this.el = el;
  42589. this._x = api.getWidth() / 2;
  42590. this._y = api.getHeight() / 2;
  42591. container.appendChild(el);
  42592. this._container = container;
  42593. this._show = false;
  42594. /**
  42595. * @private
  42596. */
  42597. this._hideTimeout;
  42598. var self = this;
  42599. el.onmouseenter = function () {
  42600. // clear the timeout in hideLater and keep showing tooltip
  42601. if (self.enterable) {
  42602. clearTimeout(self._hideTimeout);
  42603. self._show = true;
  42604. }
  42605. self._inContent = true;
  42606. };
  42607. el.onmousemove = function (e) {
  42608. e = e || window.event;
  42609. if (!self.enterable) {
  42610. // Try trigger zrender event to avoid mouse
  42611. // in and out shape too frequently
  42612. var handler = zr.handler;
  42613. eventUtil.normalizeEvent(container, e, true);
  42614. handler.dispatch('mousemove', e);
  42615. }
  42616. };
  42617. el.onmouseleave = function () {
  42618. if (self.enterable) {
  42619. if (self._show) {
  42620. self.hideLater(self._hideDelay);
  42621. }
  42622. }
  42623. self._inContent = false;
  42624. };
  42625. }
  42626. TooltipContent.prototype = {
  42627. constructor: TooltipContent,
  42628. enterable: true,
  42629. /**
  42630. * Update when tooltip is rendered
  42631. */
  42632. update: function () {
  42633. var container = this._container;
  42634. var stl = container.currentStyle
  42635. || document.defaultView.getComputedStyle(container);
  42636. var domStyle = container.style;
  42637. if (domStyle.position !== 'absolute' && stl.position !== 'absolute') {
  42638. domStyle.position = 'relative';
  42639. }
  42640. // Hide the tooltip
  42641. // PENDING
  42642. // this.hide();
  42643. },
  42644. show: function (tooltipModel) {
  42645. clearTimeout(this._hideTimeout);
  42646. var el = this.el;
  42647. el.style.cssText = gCssText + assembleCssText(tooltipModel)
  42648. // http://stackoverflow.com/questions/21125587/css3-transition-not-working-in-chrome-anymore
  42649. + ';left:' + this._x + 'px;top:' + this._y + 'px;'
  42650. + (tooltipModel.get('extraCssText') || '');
  42651. el.style.display = el.innerHTML ? 'block' : 'none';
  42652. this._show = true;
  42653. },
  42654. setContent: function (content) {
  42655. var el = this.el;
  42656. el.innerHTML = content;
  42657. el.style.display = content ? 'block' : 'none';
  42658. },
  42659. moveTo: function (x, y) {
  42660. var style = this.el.style;
  42661. style.left = x + 'px';
  42662. style.top = y + 'px';
  42663. this._x = x;
  42664. this._y = y;
  42665. },
  42666. hide: function () {
  42667. this.el.style.display = 'none';
  42668. this._show = false;
  42669. },
  42670. // showLater: function ()
  42671. hideLater: function (time) {
  42672. if (this._show && !(this._inContent && this.enterable)) {
  42673. if (time) {
  42674. this._hideDelay = time;
  42675. // Set show false to avoid invoke hideLater mutiple times
  42676. this._show = false;
  42677. this._hideTimeout = setTimeout(zrUtil.bind(this.hide, this), time);
  42678. }
  42679. else {
  42680. this.hide();
  42681. }
  42682. }
  42683. },
  42684. isShow: function () {
  42685. return this._show;
  42686. }
  42687. };
  42688. module.exports = TooltipContent;
  42689. /***/ },
  42690. /* 286 */
  42691. /***/ function(module, exports, __webpack_require__) {
  42692. 'use strict';
  42693. __webpack_require__(287);
  42694. __webpack_require__(293);
  42695. __webpack_require__(295);
  42696. // Polar view
  42697. __webpack_require__(1).extendComponentView({
  42698. type: 'polar'
  42699. });
  42700. /***/ },
  42701. /* 287 */
  42702. /***/ function(module, exports, __webpack_require__) {
  42703. // TODO Axis scale
  42704. var Polar = __webpack_require__(288);
  42705. var numberUtil = __webpack_require__(7);
  42706. var zrUtil = __webpack_require__(4);
  42707. var axisHelper = __webpack_require__(115);
  42708. var niceScaleExtent = axisHelper.niceScaleExtent;
  42709. // 依赖 PolarModel 做预处理
  42710. __webpack_require__(291);
  42711. /**
  42712. * Resize method bound to the polar
  42713. * @param {module:echarts/coord/polar/PolarModel} polarModel
  42714. * @param {module:echarts/ExtensionAPI} api
  42715. */
  42716. function resizePolar(polarModel, api) {
  42717. var center = polarModel.get('center');
  42718. var radius = polarModel.get('radius');
  42719. var width = api.getWidth();
  42720. var height = api.getHeight();
  42721. var parsePercent = numberUtil.parsePercent;
  42722. this.cx = parsePercent(center[0], width);
  42723. this.cy = parsePercent(center[1], height);
  42724. var radiusAxis = this.getRadiusAxis();
  42725. var size = Math.min(width, height) / 2;
  42726. // var idx = radiusAxis.inverse ? 1 : 0;
  42727. radiusAxis.setExtent(0, parsePercent(radius, size));
  42728. }
  42729. /**
  42730. * Update polar
  42731. */
  42732. function updatePolarScale(ecModel, api) {
  42733. var polar = this;
  42734. var angleAxis = polar.getAngleAxis();
  42735. var radiusAxis = polar.getRadiusAxis();
  42736. // Reset scale
  42737. angleAxis.scale.setExtent(Infinity, -Infinity);
  42738. radiusAxis.scale.setExtent(Infinity, -Infinity);
  42739. ecModel.eachSeries(function (seriesModel) {
  42740. if (seriesModel.coordinateSystem === polar) {
  42741. var data = seriesModel.getData();
  42742. radiusAxis.scale.unionExtent(
  42743. data.getDataExtent('radius', radiusAxis.type !== 'category')
  42744. );
  42745. angleAxis.scale.unionExtent(
  42746. data.getDataExtent('angle', angleAxis.type !== 'category')
  42747. );
  42748. }
  42749. });
  42750. niceScaleExtent(angleAxis, angleAxis.model);
  42751. niceScaleExtent(radiusAxis, radiusAxis.model);
  42752. // Fix extent of category angle axis
  42753. if (angleAxis.type === 'category' && !angleAxis.onBand) {
  42754. var extent = angleAxis.getExtent();
  42755. var diff = 360 / angleAxis.scale.count();
  42756. angleAxis.inverse ? (extent[1] += diff) : (extent[1] -= diff);
  42757. angleAxis.setExtent(extent[0], extent[1]);
  42758. }
  42759. }
  42760. /**
  42761. * Set common axis properties
  42762. * @param {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  42763. * @param {module:echarts/coord/polar/AxisModel}
  42764. * @inner
  42765. */
  42766. function setAxis(axis, axisModel) {
  42767. axis.type = axisModel.get('type');
  42768. axis.scale = axisHelper.createScaleByModel(axisModel);
  42769. axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
  42770. // FIXME Radius axis not support inverse axis
  42771. if (axisModel.mainType === 'angleAxis') {
  42772. var startAngle = axisModel.get('startAngle');
  42773. axis.inverse = axisModel.get('inverse') ^ axisModel.get('clockwise');
  42774. axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
  42775. }
  42776. // Inject axis instance
  42777. axisModel.axis = axis;
  42778. axis.model = axisModel;
  42779. }
  42780. var polarCreator = {
  42781. dimensions: Polar.prototype.dimensions,
  42782. create: function (ecModel, api) {
  42783. var polarList = [];
  42784. ecModel.eachComponent('polar', function (polarModel, idx) {
  42785. var polar = new Polar(idx);
  42786. // Inject resize and update method
  42787. polar.resize = resizePolar;
  42788. polar.update = updatePolarScale;
  42789. var radiusAxis = polar.getRadiusAxis();
  42790. var angleAxis = polar.getAngleAxis();
  42791. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  42792. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  42793. setAxis(radiusAxis, radiusAxisModel);
  42794. setAxis(angleAxis, angleAxisModel);
  42795. polar.resize(polarModel, api);
  42796. polarList.push(polar);
  42797. polarModel.coordinateSystem = polar;
  42798. });
  42799. // Inject coordinateSystem to series
  42800. ecModel.eachSeries(function (seriesModel) {
  42801. if (seriesModel.get('coordinateSystem') === 'polar') {
  42802. var polarModel = ecModel.queryComponents({
  42803. mainType: 'polar',
  42804. index: seriesModel.get('polarIndex'),
  42805. id: seriesModel.get('polarId')
  42806. })[0];
  42807. if (true) {
  42808. if (!polarModel) {
  42809. throw new Error(
  42810. 'Polar "' + zrUtil.retrieve(
  42811. seriesModel.get('polarIndex'),
  42812. seriesModel.get('polarId'),
  42813. 0
  42814. ) + '" not found'
  42815. );
  42816. }
  42817. }
  42818. seriesModel.coordinateSystem = polarModel.coordinateSystem;
  42819. }
  42820. });
  42821. return polarList;
  42822. }
  42823. };
  42824. __webpack_require__(26).register('polar', polarCreator);
  42825. /***/ },
  42826. /* 288 */
  42827. /***/ function(module, exports, __webpack_require__) {
  42828. 'use strict';
  42829. /**
  42830. * @module echarts/coord/polar/Polar
  42831. */
  42832. var RadiusAxis = __webpack_require__(289);
  42833. var AngleAxis = __webpack_require__(290);
  42834. /**
  42835. * @alias {module:echarts/coord/polar/Polar}
  42836. * @constructor
  42837. * @param {string} name
  42838. */
  42839. var Polar = function (name) {
  42840. /**
  42841. * @type {string}
  42842. */
  42843. this.name = name || '';
  42844. /**
  42845. * x of polar center
  42846. * @type {number}
  42847. */
  42848. this.cx = 0;
  42849. /**
  42850. * y of polar center
  42851. * @type {number}
  42852. */
  42853. this.cy = 0;
  42854. /**
  42855. * @type {module:echarts/coord/polar/RadiusAxis}
  42856. * @private
  42857. */
  42858. this._radiusAxis = new RadiusAxis();
  42859. /**
  42860. * @type {module:echarts/coord/polar/AngleAxis}
  42861. * @private
  42862. */
  42863. this._angleAxis = new AngleAxis();
  42864. };
  42865. Polar.prototype = {
  42866. constructor: Polar,
  42867. type: 'polar',
  42868. /**
  42869. * @param {Array.<string>}
  42870. * @readOnly
  42871. */
  42872. dimensions: ['radius', 'angle'],
  42873. /**
  42874. * If contain coord
  42875. * @param {Array.<number>} point
  42876. * @return {boolean}
  42877. */
  42878. containPoint: function (point) {
  42879. var coord = this.pointToCoord(point);
  42880. return this._radiusAxis.contain(coord[0])
  42881. && this._angleAxis.contain(coord[1]);
  42882. },
  42883. /**
  42884. * If contain data
  42885. * @param {Array.<number>} data
  42886. * @return {boolean}
  42887. */
  42888. containData: function (data) {
  42889. return this._radiusAxis.containData(data[0])
  42890. && this._angleAxis.containData(data[1]);
  42891. },
  42892. /**
  42893. * @param {string} axisType
  42894. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  42895. */
  42896. getAxis: function (axisType) {
  42897. return this['_' + axisType + 'Axis'];
  42898. },
  42899. /**
  42900. * Get axes by type of scale
  42901. * @param {string} scaleType
  42902. * @return {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  42903. */
  42904. getAxesByScale: function (scaleType) {
  42905. var axes = [];
  42906. var angleAxis = this._angleAxis;
  42907. var radiusAxis = this._radiusAxis;
  42908. angleAxis.scale.type === scaleType && axes.push(angleAxis);
  42909. radiusAxis.scale.type === scaleType && axes.push(radiusAxis);
  42910. return axes;
  42911. },
  42912. /**
  42913. * @return {module:echarts/coord/polar/AngleAxis}
  42914. */
  42915. getAngleAxis: function () {
  42916. return this._angleAxis;
  42917. },
  42918. /**
  42919. * @return {module:echarts/coord/polar/RadiusAxis}
  42920. */
  42921. getRadiusAxis: function () {
  42922. return this._radiusAxis;
  42923. },
  42924. /**
  42925. * @param {module:echarts/coord/polar/Axis}
  42926. * @return {module:echarts/coord/polar/Axis}
  42927. */
  42928. getOtherAxis: function (axis) {
  42929. var angleAxis = this._angleAxis;
  42930. return axis === angleAxis ? this._radiusAxis : angleAxis;
  42931. },
  42932. /**
  42933. * Base axis will be used on stacking.
  42934. *
  42935. * @return {module:echarts/coord/polar/Axis}
  42936. */
  42937. getBaseAxis: function () {
  42938. return this.getAxesByScale('ordinal')[0]
  42939. || this.getAxesByScale('time')[0]
  42940. || this.getAngleAxis();
  42941. },
  42942. /**
  42943. * Convert series data to a list of (x, y) points
  42944. * @param {module:echarts/data/List} data
  42945. * @return {Array}
  42946. * Return list of coordinates. For example:
  42947. * `[[10, 10], [20, 20], [30, 30]]`
  42948. */
  42949. dataToPoints: function (data) {
  42950. return data.mapArray(this.dimensions, function (radius, angle) {
  42951. return this.dataToPoint([radius, angle]);
  42952. }, this);
  42953. },
  42954. /**
  42955. * Convert a single data item to (x, y) point.
  42956. * Parameter data is an array which the first element is radius and the second is angle
  42957. * @param {Array.<number>} data
  42958. * @param {boolean} [clamp=false]
  42959. * @return {Array.<number>}
  42960. */
  42961. dataToPoint: function (data, clamp) {
  42962. return this.coordToPoint([
  42963. this._radiusAxis.dataToRadius(data[0], clamp),
  42964. this._angleAxis.dataToAngle(data[1], clamp)
  42965. ]);
  42966. },
  42967. /**
  42968. * Convert a (x, y) point to data
  42969. * @param {Array.<number>} point
  42970. * @param {boolean} [clamp=false]
  42971. * @return {Array.<number>}
  42972. */
  42973. pointToData: function (point, clamp) {
  42974. var coord = this.pointToCoord(point);
  42975. return [
  42976. this._radiusAxis.radiusToData(coord[0], clamp),
  42977. this._angleAxis.angleToData(coord[1], clamp)
  42978. ];
  42979. },
  42980. /**
  42981. * Convert a (x, y) point to (radius, angle) coord
  42982. * @param {Array.<number>} point
  42983. * @return {Array.<number>}
  42984. */
  42985. pointToCoord: function (point) {
  42986. var dx = point[0] - this.cx;
  42987. var dy = point[1] - this.cy;
  42988. var angleAxis = this.getAngleAxis();
  42989. var extent = angleAxis.getExtent();
  42990. var minAngle = Math.min(extent[0], extent[1]);
  42991. var maxAngle = Math.max(extent[0], extent[1]);
  42992. // Fix fixed extent in polarCreator
  42993. // FIXME
  42994. angleAxis.inverse
  42995. ? (minAngle = maxAngle - 360)
  42996. : (maxAngle = minAngle + 360);
  42997. var radius = Math.sqrt(dx * dx + dy * dy);
  42998. dx /= radius;
  42999. dy /= radius;
  43000. var radian = Math.atan2(-dy, dx) / Math.PI * 180;
  43001. // move to angleExtent
  43002. var dir = radian < minAngle ? 1 : -1;
  43003. while (radian < minAngle || radian > maxAngle) {
  43004. radian += dir * 360;
  43005. }
  43006. return [radius, radian];
  43007. },
  43008. /**
  43009. * Convert a (radius, angle) coord to (x, y) point
  43010. * @param {Array.<number>} coord
  43011. * @return {Array.<number>}
  43012. */
  43013. coordToPoint: function (coord) {
  43014. var radius = coord[0];
  43015. var radian = coord[1] / 180 * Math.PI;
  43016. var x = Math.cos(radian) * radius + this.cx;
  43017. // Inverse the y
  43018. var y = -Math.sin(radian) * radius + this.cy;
  43019. return [x, y];
  43020. }
  43021. };
  43022. module.exports = Polar;
  43023. /***/ },
  43024. /* 289 */
  43025. /***/ function(module, exports, __webpack_require__) {
  43026. 'use strict';
  43027. var zrUtil = __webpack_require__(4);
  43028. var Axis = __webpack_require__(124);
  43029. function RadiusAxis(scale, radiusExtent) {
  43030. Axis.call(this, 'radius', scale, radiusExtent);
  43031. /**
  43032. * Axis type
  43033. * - 'category'
  43034. * - 'value'
  43035. * - 'time'
  43036. * - 'log'
  43037. * @type {string}
  43038. */
  43039. this.type = 'category';
  43040. }
  43041. RadiusAxis.prototype = {
  43042. constructor: RadiusAxis,
  43043. dataToRadius: Axis.prototype.dataToCoord,
  43044. radiusToData: Axis.prototype.coordToData
  43045. };
  43046. zrUtil.inherits(RadiusAxis, Axis);
  43047. module.exports = RadiusAxis;
  43048. /***/ },
  43049. /* 290 */
  43050. /***/ function(module, exports, __webpack_require__) {
  43051. 'use strict';
  43052. var zrUtil = __webpack_require__(4);
  43053. var Axis = __webpack_require__(124);
  43054. function AngleAxis(scale, angleExtent) {
  43055. angleExtent = angleExtent || [0, 360];
  43056. Axis.call(this, 'angle', scale, angleExtent);
  43057. /**
  43058. * Axis type
  43059. * - 'category'
  43060. * - 'value'
  43061. * - 'time'
  43062. * - 'log'
  43063. * @type {string}
  43064. */
  43065. this.type = 'category';
  43066. }
  43067. AngleAxis.prototype = {
  43068. constructor: AngleAxis,
  43069. dataToAngle: Axis.prototype.dataToCoord,
  43070. angleToData: Axis.prototype.coordToData
  43071. };
  43072. zrUtil.inherits(AngleAxis, Axis);
  43073. module.exports = AngleAxis;
  43074. /***/ },
  43075. /* 291 */
  43076. /***/ function(module, exports, __webpack_require__) {
  43077. 'use strict';
  43078. __webpack_require__(292);
  43079. __webpack_require__(1).extendComponentModel({
  43080. type: 'polar',
  43081. dependencies: ['polarAxis', 'angleAxis'],
  43082. /**
  43083. * @type {module:echarts/coord/polar/Polar}
  43084. */
  43085. coordinateSystem: null,
  43086. /**
  43087. * @param {string} axisType
  43088. * @return {module:echarts/coord/polar/AxisModel}
  43089. */
  43090. findAxisModel: function (axisType) {
  43091. var foundAxisModel;
  43092. var ecModel = this.ecModel;
  43093. ecModel.eachComponent(axisType, function (axisModel) {
  43094. var polarModel = ecModel.queryComponents({
  43095. mainType: 'polar',
  43096. index: axisModel.getShallow('polarIndex'),
  43097. id: axisModel.getShallow('polarId')
  43098. })[0];
  43099. if(polarModel === this) {
  43100. foundAxisModel = axisModel;
  43101. }
  43102. }, this);
  43103. return foundAxisModel;
  43104. },
  43105. defaultOption: {
  43106. zlevel: 0,
  43107. z: 0,
  43108. center: ['50%', '50%'],
  43109. radius: '80%'
  43110. }
  43111. });
  43112. /***/ },
  43113. /* 292 */
  43114. /***/ function(module, exports, __webpack_require__) {
  43115. 'use strict';
  43116. var zrUtil = __webpack_require__(4);
  43117. var ComponentModel = __webpack_require__(19);
  43118. var axisModelCreator = __webpack_require__(128);
  43119. var PolarAxisModel = ComponentModel.extend({
  43120. type: 'polarAxis',
  43121. /**
  43122. * @type {module:echarts/coord/polar/AngleAxis|module:echarts/coord/polar/RadiusAxis}
  43123. */
  43124. axis: null
  43125. });
  43126. zrUtil.merge(PolarAxisModel.prototype, __webpack_require__(130));
  43127. zrUtil.merge(PolarAxisModel.prototype, __webpack_require__(131));
  43128. var polarAxisDefaultExtendedOption = {
  43129. angle: {
  43130. // polarIndex: 0,
  43131. // polarId: '',
  43132. startAngle: 90,
  43133. clockwise: true,
  43134. splitNumber: 12,
  43135. axisLabel: {
  43136. rotate: false
  43137. }
  43138. },
  43139. radius: {
  43140. // polarIndex: 0,
  43141. // polarId: '',
  43142. splitNumber: 5
  43143. }
  43144. };
  43145. function getAxisType(axisDim, option) {
  43146. // Default axis with data is category axis
  43147. return option.type || (option.data ? 'category' : 'value');
  43148. }
  43149. axisModelCreator('angle', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.angle);
  43150. axisModelCreator('radius', PolarAxisModel, getAxisType, polarAxisDefaultExtendedOption.radius);
  43151. /***/ },
  43152. /* 293 */
  43153. /***/ function(module, exports, __webpack_require__) {
  43154. 'use strict';
  43155. __webpack_require__(287);
  43156. __webpack_require__(294);
  43157. /***/ },
  43158. /* 294 */
  43159. /***/ function(module, exports, __webpack_require__) {
  43160. 'use strict';
  43161. var zrUtil = __webpack_require__(4);
  43162. var graphic = __webpack_require__(43);
  43163. var Model = __webpack_require__(12);
  43164. var elementList = ['axisLine', 'axisLabel', 'axisTick', 'splitLine', 'splitArea'];
  43165. function getAxisLineShape(polar, r0, r, angle) {
  43166. var start = polar.coordToPoint([r0, angle]);
  43167. var end = polar.coordToPoint([r, angle]);
  43168. return {
  43169. x1: start[0],
  43170. y1: start[1],
  43171. x2: end[0],
  43172. y2: end[1]
  43173. };
  43174. }
  43175. __webpack_require__(1).extendComponentView({
  43176. type: 'angleAxis',
  43177. render: function (angleAxisModel, ecModel) {
  43178. this.group.removeAll();
  43179. if (!angleAxisModel.get('show')) {
  43180. return;
  43181. }
  43182. var polarModel = ecModel.getComponent('polar', angleAxisModel.get('polarIndex'));
  43183. var angleAxis = angleAxisModel.axis;
  43184. var polar = polarModel.coordinateSystem;
  43185. var radiusExtent = polar.getRadiusAxis().getExtent();
  43186. var ticksAngles = angleAxis.getTicksCoords();
  43187. if (angleAxis.type !== 'category') {
  43188. // Remove the last tick which will overlap the first tick
  43189. ticksAngles.pop();
  43190. }
  43191. zrUtil.each(elementList, function (name) {
  43192. if (angleAxisModel.get(name +'.show')) {
  43193. this['_' + name](angleAxisModel, polar, ticksAngles, radiusExtent);
  43194. }
  43195. }, this);
  43196. },
  43197. /**
  43198. * @private
  43199. */
  43200. _axisLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  43201. var lineStyleModel = angleAxisModel.getModel('axisLine.lineStyle');
  43202. var circle = new graphic.Circle({
  43203. shape: {
  43204. cx: polar.cx,
  43205. cy: polar.cy,
  43206. r: radiusExtent[1]
  43207. },
  43208. style: lineStyleModel.getLineStyle(),
  43209. z2: 1,
  43210. silent: true
  43211. });
  43212. circle.style.fill = null;
  43213. this.group.add(circle);
  43214. },
  43215. /**
  43216. * @private
  43217. */
  43218. _axisTick: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  43219. var tickModel = angleAxisModel.getModel('axisTick');
  43220. var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
  43221. var lines = zrUtil.map(ticksAngles, function (tickAngle) {
  43222. return new graphic.Line({
  43223. shape: getAxisLineShape(polar, radiusExtent[1], radiusExtent[1] + tickLen, tickAngle)
  43224. });
  43225. });
  43226. this.group.add(graphic.mergePath(
  43227. lines, {
  43228. style: zrUtil.defaults(
  43229. tickModel.getModel('lineStyle').getLineStyle(),
  43230. {
  43231. stroke: angleAxisModel.get('axisLine.lineStyle.color')
  43232. }
  43233. )
  43234. }
  43235. ));
  43236. },
  43237. /**
  43238. * @private
  43239. */
  43240. _axisLabel: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  43241. var axis = angleAxisModel.axis;
  43242. var categoryData = angleAxisModel.get('data');
  43243. var labelModel = angleAxisModel.getModel('axisLabel');
  43244. var axisTextStyleModel = labelModel.getModel('textStyle');
  43245. var labels = angleAxisModel.getFormattedLabels();
  43246. var labelMargin = labelModel.get('margin');
  43247. var labelsAngles = axis.getLabelsCoords();
  43248. // Use length of ticksAngles because it may remove the last tick to avoid overlapping
  43249. for (var i = 0; i < ticksAngles.length; i++) {
  43250. var r = radiusExtent[1];
  43251. var p = polar.coordToPoint([r + labelMargin, labelsAngles[i]]);
  43252. var cx = polar.cx;
  43253. var cy = polar.cy;
  43254. var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3
  43255. ? 'center' : (p[0] > cx ? 'left' : 'right');
  43256. var labelTextBaseline = Math.abs(p[1] - cy) / r < 0.3
  43257. ? 'middle' : (p[1] > cy ? 'top' : 'bottom');
  43258. var textStyleModel = axisTextStyleModel;
  43259. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  43260. textStyleModel = new Model(
  43261. categoryData[i].textStyle, axisTextStyleModel
  43262. );
  43263. }
  43264. this.group.add(new graphic.Text({
  43265. style: {
  43266. x: p[0],
  43267. y: p[1],
  43268. fill: textStyleModel.getTextColor() || angleAxisModel.get('axisLine.lineStyle.color'),
  43269. text: labels[i],
  43270. textAlign: labelTextAlign,
  43271. textVerticalAlign: labelTextBaseline,
  43272. textFont: textStyleModel.getFont()
  43273. },
  43274. silent: true
  43275. }));
  43276. }
  43277. },
  43278. /**
  43279. * @private
  43280. */
  43281. _splitLine: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  43282. var splitLineModel = angleAxisModel.getModel('splitLine');
  43283. var lineStyleModel = splitLineModel.getModel('lineStyle');
  43284. var lineColors = lineStyleModel.get('color');
  43285. var lineCount = 0;
  43286. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  43287. var splitLines = [];
  43288. for (var i = 0; i < ticksAngles.length; i++) {
  43289. var colorIndex = (lineCount++) % lineColors.length;
  43290. splitLines[colorIndex] = splitLines[colorIndex] || [];
  43291. splitLines[colorIndex].push(new graphic.Line({
  43292. shape: getAxisLineShape(polar, radiusExtent[0], radiusExtent[1], ticksAngles[i])
  43293. }));
  43294. }
  43295. // Simple optimization
  43296. // Batching the lines if color are the same
  43297. for (var i = 0; i < splitLines.length; i++) {
  43298. this.group.add(graphic.mergePath(splitLines[i], {
  43299. style: zrUtil.defaults({
  43300. stroke: lineColors[i % lineColors.length]
  43301. }, lineStyleModel.getLineStyle()),
  43302. silent: true,
  43303. z: angleAxisModel.get('z')
  43304. }));
  43305. }
  43306. },
  43307. /**
  43308. * @private
  43309. */
  43310. _splitArea: function (angleAxisModel, polar, ticksAngles, radiusExtent) {
  43311. var splitAreaModel = angleAxisModel.getModel('splitArea');
  43312. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  43313. var areaColors = areaStyleModel.get('color');
  43314. var lineCount = 0;
  43315. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  43316. var splitAreas = [];
  43317. var RADIAN = Math.PI / 180;
  43318. var prevAngle = -ticksAngles[0] * RADIAN;
  43319. var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
  43320. var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
  43321. var clockwise = angleAxisModel.get('clockwise');
  43322. for (var i = 1; i < ticksAngles.length; i++) {
  43323. var colorIndex = (lineCount++) % areaColors.length;
  43324. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  43325. splitAreas[colorIndex].push(new graphic.Sector({
  43326. shape: {
  43327. cx: polar.cx,
  43328. cy: polar.cy,
  43329. r0: r0,
  43330. r: r1,
  43331. startAngle: prevAngle,
  43332. endAngle: -ticksAngles[i] * RADIAN,
  43333. clockwise: clockwise
  43334. },
  43335. silent: true
  43336. }));
  43337. prevAngle = -ticksAngles[i] * RADIAN;
  43338. }
  43339. // Simple optimization
  43340. // Batching the lines if color are the same
  43341. for (var i = 0; i < splitAreas.length; i++) {
  43342. this.group.add(graphic.mergePath(splitAreas[i], {
  43343. style: zrUtil.defaults({
  43344. fill: areaColors[i % areaColors.length]
  43345. }, areaStyleModel.getAreaStyle()),
  43346. silent: true
  43347. }));
  43348. }
  43349. }
  43350. });
  43351. /***/ },
  43352. /* 295 */
  43353. /***/ function(module, exports, __webpack_require__) {
  43354. __webpack_require__(287);
  43355. __webpack_require__(296);
  43356. /***/ },
  43357. /* 296 */
  43358. /***/ function(module, exports, __webpack_require__) {
  43359. 'use strict';
  43360. var zrUtil = __webpack_require__(4);
  43361. var graphic = __webpack_require__(43);
  43362. var AxisBuilder = __webpack_require__(134);
  43363. var axisBuilderAttrs = [
  43364. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  43365. ];
  43366. var selfBuilderAttrs = [
  43367. 'splitLine', 'splitArea'
  43368. ];
  43369. __webpack_require__(1).extendComponentView({
  43370. type: 'radiusAxis',
  43371. render: function (radiusAxisModel, ecModel) {
  43372. this.group.removeAll();
  43373. if (!radiusAxisModel.get('show')) {
  43374. return;
  43375. }
  43376. var polarModel = ecModel.getComponent('polar', radiusAxisModel.get('polarIndex'));
  43377. var angleAxis = polarModel.coordinateSystem.getAngleAxis();
  43378. var radiusAxis = radiusAxisModel.axis;
  43379. var polar = polarModel.coordinateSystem;
  43380. var ticksCoords = radiusAxis.getTicksCoords();
  43381. var axisAngle = angleAxis.getExtent()[0];
  43382. var radiusExtent = radiusAxis.getExtent();
  43383. var layout = layoutAxis(polar, radiusAxisModel, axisAngle);
  43384. var axisBuilder = new AxisBuilder(radiusAxisModel, layout);
  43385. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  43386. this.group.add(axisBuilder.getGroup());
  43387. zrUtil.each(selfBuilderAttrs, function (name) {
  43388. if (radiusAxisModel.get(name +'.show')) {
  43389. this['_' + name](radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords);
  43390. }
  43391. }, this);
  43392. },
  43393. /**
  43394. * @private
  43395. */
  43396. _splitLine: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  43397. var splitLineModel = radiusAxisModel.getModel('splitLine');
  43398. var lineStyleModel = splitLineModel.getModel('lineStyle');
  43399. var lineColors = lineStyleModel.get('color');
  43400. var lineCount = 0;
  43401. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  43402. var splitLines = [];
  43403. for (var i = 0; i < ticksCoords.length; i++) {
  43404. var colorIndex = (lineCount++) % lineColors.length;
  43405. splitLines[colorIndex] = splitLines[colorIndex] || [];
  43406. splitLines[colorIndex].push(new graphic.Circle({
  43407. shape: {
  43408. cx: polar.cx,
  43409. cy: polar.cy,
  43410. r: ticksCoords[i]
  43411. },
  43412. silent: true
  43413. }));
  43414. }
  43415. // Simple optimization
  43416. // Batching the lines if color are the same
  43417. for (var i = 0; i < splitLines.length; i++) {
  43418. this.group.add(graphic.mergePath(splitLines[i], {
  43419. style: zrUtil.defaults({
  43420. stroke: lineColors[i % lineColors.length],
  43421. fill: null
  43422. }, lineStyleModel.getLineStyle()),
  43423. silent: true
  43424. }));
  43425. }
  43426. },
  43427. /**
  43428. * @private
  43429. */
  43430. _splitArea: function (radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  43431. var splitAreaModel = radiusAxisModel.getModel('splitArea');
  43432. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  43433. var areaColors = areaStyleModel.get('color');
  43434. var lineCount = 0;
  43435. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  43436. var splitAreas = [];
  43437. var prevRadius = ticksCoords[0];
  43438. for (var i = 1; i < ticksCoords.length; i++) {
  43439. var colorIndex = (lineCount++) % areaColors.length;
  43440. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  43441. splitAreas[colorIndex].push(new graphic.Sector({
  43442. shape: {
  43443. cx: polar.cx,
  43444. cy: polar.cy,
  43445. r0: prevRadius,
  43446. r: ticksCoords[i],
  43447. startAngle: 0,
  43448. endAngle: Math.PI * 2
  43449. },
  43450. silent: true
  43451. }));
  43452. prevRadius = ticksCoords[i];
  43453. }
  43454. // Simple optimization
  43455. // Batching the lines if color are the same
  43456. for (var i = 0; i < splitAreas.length; i++) {
  43457. this.group.add(graphic.mergePath(splitAreas[i], {
  43458. style: zrUtil.defaults({
  43459. fill: areaColors[i % areaColors.length]
  43460. }, areaStyleModel.getAreaStyle()),
  43461. silent: true
  43462. }));
  43463. }
  43464. }
  43465. });
  43466. /**
  43467. * @inner
  43468. */
  43469. function layoutAxis(polar, radiusAxisModel, axisAngle) {
  43470. return {
  43471. position: [polar.cx, polar.cy],
  43472. rotation: axisAngle / 180 * Math.PI,
  43473. labelDirection: -1,
  43474. tickDirection: -1,
  43475. nameDirection: 1,
  43476. labelRotation: radiusAxisModel.getModel('axisLabel').get('rotate'),
  43477. // Over splitLine and splitArea
  43478. z2: 1
  43479. };
  43480. }
  43481. /***/ },
  43482. /* 297 */
  43483. /***/ function(module, exports, __webpack_require__) {
  43484. __webpack_require__(298);
  43485. __webpack_require__(165);
  43486. __webpack_require__(299);
  43487. __webpack_require__(178);
  43488. var echarts = __webpack_require__(1);
  43489. var zrUtil = __webpack_require__(4);
  43490. function makeAction(method, actionInfo) {
  43491. actionInfo.update = 'updateView';
  43492. echarts.registerAction(actionInfo, function (payload, ecModel) {
  43493. var selected = {};
  43494. ecModel.eachComponent(
  43495. { mainType: 'geo', query: payload},
  43496. function (geoModel) {
  43497. geoModel[method](payload.name);
  43498. var geo = geoModel.coordinateSystem;
  43499. zrUtil.each(geo.regions, function (region) {
  43500. selected[region.name] = geoModel.isSelected(region.name) || false;
  43501. });
  43502. }
  43503. );
  43504. return {
  43505. selected: selected,
  43506. name: payload.name
  43507. }
  43508. });
  43509. }
  43510. makeAction('toggleSelected', {
  43511. type: 'geoToggleSelect',
  43512. event: 'geoselectchanged'
  43513. });
  43514. makeAction('select', {
  43515. type: 'geoSelect',
  43516. event: 'geoselected'
  43517. });
  43518. makeAction('unSelect', {
  43519. type: 'geoUnSelect',
  43520. event: 'geounselected'
  43521. });
  43522. /***/ },
  43523. /* 298 */
  43524. /***/ function(module, exports, __webpack_require__) {
  43525. 'use strict';
  43526. var modelUtil = __webpack_require__(5);
  43527. var ComponentModel = __webpack_require__(19);
  43528. var Model = __webpack_require__(12);
  43529. var zrUtil = __webpack_require__(4);
  43530. var selectableMixin = __webpack_require__(142);
  43531. var geoCreator = __webpack_require__(165);
  43532. var GeoModel = ComponentModel.extend({
  43533. type: 'geo',
  43534. /**
  43535. * @type {module:echarts/coord/geo/Geo}
  43536. */
  43537. coordinateSystem: null,
  43538. layoutMode: 'box',
  43539. init: function (option) {
  43540. ComponentModel.prototype.init.apply(this, arguments);
  43541. // Default label emphasis `position` and `show`
  43542. modelUtil.defaultEmphasis(
  43543. option.label, ['position', 'show', 'textStyle', 'distance', 'formatter']
  43544. );
  43545. },
  43546. optionUpdated: function () {
  43547. var option = this.option;
  43548. var self = this;
  43549. option.regions = geoCreator.getFilledRegions(option.regions, option.map);
  43550. this._optionModelMap = zrUtil.reduce(option.regions || [], function (obj, regionOpt) {
  43551. if (regionOpt.name) {
  43552. obj[regionOpt.name] = new Model(regionOpt, self);
  43553. }
  43554. return obj;
  43555. }, {});
  43556. this.updateSelectedMap(option.regions);
  43557. },
  43558. defaultOption: {
  43559. zlevel: 0,
  43560. z: 0,
  43561. show: true,
  43562. left: 'center',
  43563. top: 'center',
  43564. // width:,
  43565. // height:,
  43566. // right
  43567. // bottom
  43568. // Aspect is width / height. Inited to be geoJson bbox aspect
  43569. // This parameter is used for scale this aspect
  43570. aspectScale: 0.75,
  43571. ///// Layout with center and size
  43572. // If you wan't to put map in a fixed size box with right aspect ratio
  43573. // This two properties may more conveninet
  43574. // layoutCenter: [50%, 50%]
  43575. // layoutSize: 100
  43576. silent: false,
  43577. // Map type
  43578. map: '',
  43579. // Default on center of map
  43580. center: null,
  43581. zoom: 1,
  43582. scaleLimit: null,
  43583. // selectedMode: false
  43584. label: {
  43585. normal: {
  43586. show: false,
  43587. textStyle: {
  43588. color: '#000'
  43589. }
  43590. },
  43591. emphasis: {
  43592. show: true,
  43593. textStyle: {
  43594. color: 'rgb(100,0,0)'
  43595. }
  43596. }
  43597. },
  43598. itemStyle: {
  43599. normal: {
  43600. // color: 各异,
  43601. borderWidth: 0.5,
  43602. borderColor: '#444',
  43603. color: '#eee'
  43604. },
  43605. emphasis: { // 也是选中样式
  43606. color: 'rgba(255,215,0,0.8)'
  43607. }
  43608. },
  43609. regions: []
  43610. },
  43611. /**
  43612. * Get model of region
  43613. * @param {string} name
  43614. * @return {module:echarts/model/Model}
  43615. */
  43616. getRegionModel: function (name) {
  43617. return this._optionModelMap[name];
  43618. },
  43619. /**
  43620. * Format label
  43621. * @param {string} name Region name
  43622. * @param {string} [status='normal'] 'normal' or 'emphasis'
  43623. * @return {string}
  43624. */
  43625. getFormattedLabel: function (name, status) {
  43626. var formatter = this.get('label.' + status + '.formatter');
  43627. var params = {
  43628. name: name
  43629. };
  43630. if (typeof formatter === 'function') {
  43631. params.status = status;
  43632. return formatter(params);
  43633. }
  43634. else if (typeof formatter === 'string') {
  43635. var serName = params.seriesName;
  43636. return formatter.replace('{a}', serName != null ? serName : '');
  43637. }
  43638. },
  43639. setZoom: function (zoom) {
  43640. this.option.zoom = zoom;
  43641. },
  43642. setCenter: function (center) {
  43643. this.option.center = center;
  43644. }
  43645. });
  43646. zrUtil.mixin(GeoModel, selectableMixin);
  43647. module.exports = GeoModel;
  43648. /***/ },
  43649. /* 299 */
  43650. /***/ function(module, exports, __webpack_require__) {
  43651. 'use strict';
  43652. var MapDraw = __webpack_require__(175);
  43653. module.exports = __webpack_require__(1).extendComponentView({
  43654. type: 'geo',
  43655. init: function (ecModel, api) {
  43656. var mapDraw = new MapDraw(api, true);
  43657. this._mapDraw = mapDraw;
  43658. this.group.add(mapDraw.group);
  43659. },
  43660. render: function (geoModel, ecModel, api, payload) {
  43661. // Not render if it is an toggleSelect action from self
  43662. if (payload && payload.type === 'geoToggleSelect'
  43663. && payload.from === this.uid
  43664. ) {
  43665. return;
  43666. }
  43667. var mapDraw = this._mapDraw;
  43668. if (geoModel.get('show')) {
  43669. mapDraw.draw(geoModel, ecModel, api, this, payload);
  43670. }
  43671. else {
  43672. this._mapDraw.group.removeAll();
  43673. }
  43674. this.group.silent = geoModel.get('silent');
  43675. },
  43676. dispose: function () {
  43677. this._mapDraw && this._mapDraw.remove();
  43678. }
  43679. });
  43680. /***/ },
  43681. /* 300 */
  43682. /***/ function(module, exports, __webpack_require__) {
  43683. __webpack_require__(301);
  43684. __webpack_require__(304);
  43685. __webpack_require__(305);
  43686. var echarts = __webpack_require__(1);
  43687. echarts.extendComponentView({
  43688. type: 'single'
  43689. });
  43690. /***/ },
  43691. /* 301 */
  43692. /***/ function(module, exports, __webpack_require__) {
  43693. /**
  43694. * Single coordinate system creator.
  43695. */
  43696. var Single = __webpack_require__(302);
  43697. /**
  43698. * Create single coordinate system and inject it into seriesModel.
  43699. *
  43700. * @param {module:echarts/model/Global} ecModel
  43701. * @param {module:echarts/ExtensionAPI} api
  43702. * @return {Array.<module:echarts/coord/single/Single>}
  43703. */
  43704. function create(ecModel, api) {
  43705. var singles = [];
  43706. ecModel.eachComponent('singleAxis', function(axisModel, idx) {
  43707. var single = new Single(axisModel, ecModel, api);
  43708. single.name = 'single_' + idx;
  43709. single.resize(axisModel, api);
  43710. axisModel.coordinateSystem = single;
  43711. singles.push(single);
  43712. });
  43713. ecModel.eachSeries(function (seriesModel) {
  43714. if (seriesModel.get('coordinateSystem') === 'singleAxis') {
  43715. var singleAxisModel = ecModel.queryComponents({
  43716. mainType: 'singleAxis',
  43717. index: seriesModel.get('singleAxisIndex'),
  43718. id: seriesModel.get('singleAxisId')
  43719. })[0];
  43720. seriesModel.coordinateSystem = singleAxisModel.coordinateSystem;
  43721. }
  43722. });
  43723. return singles;
  43724. }
  43725. __webpack_require__(26).register('single', {
  43726. create: create,
  43727. dimensions: Single.prototype.dimensions
  43728. });
  43729. /***/ },
  43730. /* 302 */
  43731. /***/ function(module, exports, __webpack_require__) {
  43732. /**
  43733. * Single coordinates system.
  43734. */
  43735. var SingleAxis = __webpack_require__(303);
  43736. var axisHelper = __webpack_require__(115);
  43737. var layout = __webpack_require__(21);
  43738. /**
  43739. * Create a single coordinates system.
  43740. *
  43741. * @param {module:echarts/coord/single/AxisModel} axisModel
  43742. * @param {module:echarts/model/Global} ecModel
  43743. * @param {module:echarts/ExtensionAPI} api
  43744. */
  43745. function Single(axisModel, ecModel, api) {
  43746. /**
  43747. * @type {string}
  43748. * @readOnly
  43749. */
  43750. this.dimension = 'x';
  43751. /**
  43752. * Add it just for draw tooltip.
  43753. *
  43754. * @type {Array.<string>}
  43755. * @readOnly
  43756. */
  43757. this.dimensions = ['x'];
  43758. /**
  43759. * @private
  43760. * @type {module:echarts/coord/single/SingleAxis}.
  43761. */
  43762. this._axis = null;
  43763. /**
  43764. * @private
  43765. * @type {module:zrender/core/BoundingRect}
  43766. */
  43767. this._rect;
  43768. this._init(axisModel, ecModel, api);
  43769. /**
  43770. * @type {module:echarts/coord/single/AxisModel}
  43771. */
  43772. this._model = axisModel;
  43773. }
  43774. Single.prototype = {
  43775. type: 'singleAxis',
  43776. constructor: Single,
  43777. /**
  43778. * Initialize single coordinate system.
  43779. *
  43780. * @param {module:echarts/coord/single/AxisModel} axisModel
  43781. * @param {module:echarts/model/Global} ecModel
  43782. * @param {module:echarts/ExtensionAPI} api
  43783. * @private
  43784. */
  43785. _init: function (axisModel, ecModel, api) {
  43786. var dim = this.dimension;
  43787. var axis = new SingleAxis(
  43788. dim,
  43789. axisHelper.createScaleByModel(axisModel),
  43790. [0, 0],
  43791. axisModel.get('type'),
  43792. axisModel.get('position')
  43793. );
  43794. var isCategory = axis.type === 'category';
  43795. axis.onBand = isCategory && axisModel.get('boundaryGap');
  43796. axis.inverse = axisModel.get('inverse');
  43797. axis.orient = axisModel.get('orient');
  43798. axisModel.axis = axis;
  43799. axis.model = axisModel;
  43800. this._axis = axis;
  43801. },
  43802. /**
  43803. * Update axis scale after data processed
  43804. * @param {module:echarts/model/Global} ecModel
  43805. * @param {module:echarts/ExtensionAPI} api
  43806. */
  43807. update: function (ecModel, api) {
  43808. this._updateAxisFromSeries(ecModel);
  43809. },
  43810. /**
  43811. * Update the axis extent from series.
  43812. *
  43813. * @param {module:echarts/model/Global} ecModel
  43814. * @private
  43815. */
  43816. _updateAxisFromSeries: function (ecModel) {
  43817. ecModel.eachSeries(function (seriesModel) {
  43818. var data = seriesModel.getData();
  43819. var dim = this.dimension;
  43820. this._axis.scale.unionExtent(
  43821. data.getDataExtent(seriesModel.coordDimToDataDim(dim))
  43822. );
  43823. axisHelper.niceScaleExtent(this._axis, this._axis.model);
  43824. }, this);
  43825. },
  43826. /**
  43827. * Resize the single coordinate system.
  43828. *
  43829. * @param {module:echarts/coord/single/AxisModel} axisModel
  43830. * @param {module:echarts/ExtensionAPI} api
  43831. */
  43832. resize: function (axisModel, api) {
  43833. this._rect = layout.getLayoutRect(
  43834. {
  43835. left: axisModel.get('left'),
  43836. top: axisModel.get('top'),
  43837. right: axisModel.get('right'),
  43838. bottom: axisModel.get('bottom'),
  43839. width: axisModel.get('width'),
  43840. height: axisModel.get('height')
  43841. },
  43842. {
  43843. width: api.getWidth(),
  43844. height: api.getHeight()
  43845. }
  43846. );
  43847. this._adjustAxis();
  43848. },
  43849. /**
  43850. * @return {module:zrender/core/BoundingRect}
  43851. */
  43852. getRect: function () {
  43853. return this._rect;
  43854. },
  43855. /**
  43856. * @private
  43857. */
  43858. _adjustAxis: function () {
  43859. var rect = this._rect;
  43860. var axis = this._axis;
  43861. var isHorizontal = axis.isHorizontal();
  43862. var extent = isHorizontal ? [0, rect.width] : [0, rect.height];
  43863. var idx = axis.reverse ? 1 : 0;
  43864. axis.setExtent(extent[idx], extent[1 - idx]);
  43865. this._updateAxisTransform(axis, isHorizontal ? rect.x : rect.y);
  43866. },
  43867. /**
  43868. * @param {module:echarts/coord/single/SingleAxis} axis
  43869. * @param {number} coordBase
  43870. */
  43871. _updateAxisTransform: function (axis, coordBase) {
  43872. var axisExtent = axis.getExtent();
  43873. var extentSum = axisExtent[0] + axisExtent[1];
  43874. var isHorizontal = axis.isHorizontal();
  43875. axis.toGlobalCoord = isHorizontal ?
  43876. function (coord) {
  43877. return coord + coordBase;
  43878. } :
  43879. function (coord) {
  43880. return extentSum - coord + coordBase;
  43881. };
  43882. axis.toLocalCoord = isHorizontal ?
  43883. function (coord) {
  43884. return coord - coordBase;
  43885. } :
  43886. function (coord) {
  43887. return extentSum - coord + coordBase;
  43888. };
  43889. },
  43890. /**
  43891. * Get axis.
  43892. *
  43893. * @return {module:echarts/coord/single/SingleAxis}
  43894. */
  43895. getAxis: function () {
  43896. return this._axis;
  43897. },
  43898. /**
  43899. * Get axis, add it just for draw tooltip.
  43900. *
  43901. * @return {[type]} [description]
  43902. */
  43903. getBaseAxis: function () {
  43904. return this._axis;
  43905. },
  43906. /**
  43907. * If contain point.
  43908. *
  43909. * @param {Array.<number>} point
  43910. * @return {boolean}
  43911. */
  43912. containPoint: function (point) {
  43913. var rect = this.getRect();
  43914. var axis = this.getAxis();
  43915. var orient = axis.orient;
  43916. if (orient === 'horizontal') {
  43917. return axis.contain(axis.toLocalCoord(point[0]))
  43918. && (point[1] >= rect.y && point[1] <= (rect.y + rect.height));
  43919. }
  43920. else {
  43921. return axis.contain(axis.toLocalCoord(point[1]))
  43922. && (point[0] >= rect.y && point[0] <= (rect.y + rect.height));
  43923. }
  43924. },
  43925. /**
  43926. * @param {Array.<number>} point
  43927. * @return {Array.<number>}
  43928. */
  43929. pointToData: function (point) {
  43930. var axis = this.getAxis();
  43931. return [axis.coordToData(axis.toLocalCoord(
  43932. point[axis.orient === 'horizontal' ? 0 : 1]
  43933. ))];
  43934. },
  43935. /**
  43936. * Convert the series data to concrete point.
  43937. *
  43938. * @param {number|Array.<number>} val
  43939. * @return {Array.<number>}
  43940. */
  43941. dataToPoint: function (val) {
  43942. var axis = this.getAxis();
  43943. var rect = this.getRect();
  43944. var pt = [];
  43945. var idx = axis.orient === 'horizontal' ? 0 : 1;
  43946. pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
  43947. pt[1 - idx] = idx === 0 ? (rect.y + rect.height / 2) : (rect.x + rect.width / 2);
  43948. return pt;
  43949. }
  43950. };
  43951. module.exports = Single;
  43952. /***/ },
  43953. /* 303 */
  43954. /***/ function(module, exports, __webpack_require__) {
  43955. var zrUtil = __webpack_require__(4);
  43956. var Axis = __webpack_require__(124);
  43957. var axisHelper = __webpack_require__(115);
  43958. /**
  43959. * @constructor module:echarts/coord/single/SingleAxis
  43960. * @extends {module:echarts/coord/Axis}
  43961. * @param {string} dim
  43962. * @param {*} scale
  43963. * @param {Array.<number>} coordExtent
  43964. * @param {string} axisType
  43965. * @param {string} position
  43966. */
  43967. var SingleAxis = function (dim, scale, coordExtent, axisType, position) {
  43968. Axis.call(this, dim, scale, coordExtent);
  43969. /**
  43970. * Axis type
  43971. * - 'category'
  43972. * - 'value'
  43973. * - 'time'
  43974. * - 'log'
  43975. * @type {string}
  43976. */
  43977. this.type = axisType || 'value';
  43978. /**
  43979. * Axis position
  43980. * - 'top'
  43981. * - 'bottom'
  43982. * - 'left'
  43983. * - 'right'
  43984. * @type {string}
  43985. */
  43986. this.position = position || 'bottom';
  43987. /**
  43988. * Axis orient
  43989. * - 'horizontal'
  43990. * - 'vertical'
  43991. * @type {[type]}
  43992. */
  43993. this.orient = null;
  43994. /**
  43995. * @type {number}
  43996. */
  43997. this._labelInterval = null;
  43998. };
  43999. SingleAxis.prototype = {
  44000. constructor: SingleAxis,
  44001. /**
  44002. * Axis model
  44003. * @type {module:echarts/coord/single/AxisModel}
  44004. */
  44005. model: null,
  44006. /**
  44007. * Judge the orient of the axis.
  44008. * @return {boolean}
  44009. */
  44010. isHorizontal: function () {
  44011. var position = this.position;
  44012. return position === 'top' || position === 'bottom';
  44013. },
  44014. /**
  44015. * Get interval of the axis label.
  44016. * @return {number}
  44017. */
  44018. getLabelInterval: function () {
  44019. var labelInterval = this._labelInterval;
  44020. if (!labelInterval) {
  44021. var axisModel = this.model;
  44022. var labelModel = axisModel.getModel('axisLabel');
  44023. var interval = labelModel.get('interval');
  44024. if (!(this.type === 'category' && interval === 'auto')) {
  44025. labelInterval = this._labelInterval = interval === 'auto' ? 0 : interval;
  44026. return labelInterval;
  44027. }
  44028. labelInterval = this._labelInterval =
  44029. axisHelper.getAxisLabelInterval(
  44030. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  44031. axisModel.getFormattedLabels(),
  44032. labelModel.getModel('textStyle').getFont(),
  44033. this.isHorizontal()
  44034. );
  44035. }
  44036. return labelInterval;
  44037. },
  44038. /**
  44039. * Convert the local coord(processed by dataToCoord())
  44040. * to global coord(concrete pixel coord).
  44041. * designated by module:echarts/coord/single/Single.
  44042. * @type {Function}
  44043. */
  44044. toGlobalCoord: null,
  44045. /**
  44046. * Convert the global coord to local coord.
  44047. * designated by module:echarts/coord/single/Single.
  44048. * @type {Function}
  44049. */
  44050. toLocalCoord: null
  44051. };
  44052. zrUtil.inherits(SingleAxis, Axis);
  44053. module.exports = SingleAxis;
  44054. /***/ },
  44055. /* 304 */
  44056. /***/ function(module, exports, __webpack_require__) {
  44057. var AxisBuilder = __webpack_require__(134);
  44058. var zrUtil = __webpack_require__(4);
  44059. var graphic = __webpack_require__(43);
  44060. var getInterval = AxisBuilder.getInterval;
  44061. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  44062. var axisBuilderAttrs = [
  44063. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  44064. ];
  44065. var selfBuilderAttr = 'splitLine';
  44066. var AxisView = __webpack_require__(1).extendComponentView({
  44067. type: 'singleAxis',
  44068. render: function (axisModel, ecModel) {
  44069. var group = this.group;
  44070. group.removeAll();
  44071. var layout = axisLayout(axisModel);
  44072. var axisBuilder = new AxisBuilder(axisModel, layout);
  44073. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  44074. group.add(axisBuilder.getGroup());
  44075. if (axisModel.get(selfBuilderAttr + '.show')) {
  44076. this['_' + selfBuilderAttr](axisModel, layout.labelInterval);
  44077. }
  44078. },
  44079. _splitLine: function(axisModel, labelInterval) {
  44080. var axis = axisModel.axis;
  44081. var splitLineModel = axisModel.getModel('splitLine');
  44082. var lineStyleModel = splitLineModel.getModel('lineStyle');
  44083. var lineWidth = lineStyleModel.get('width');
  44084. var lineColors = lineStyleModel.get('color');
  44085. var lineInterval = getInterval(splitLineModel, labelInterval);
  44086. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  44087. var gridRect = axisModel.coordinateSystem.getRect();
  44088. var isHorizontal = axis.isHorizontal();
  44089. var splitLines = [];
  44090. var lineCount = 0;
  44091. var ticksCoords = axis.getTicksCoords();
  44092. var p1 = [];
  44093. var p2 = [];
  44094. for (var i = 0; i < ticksCoords.length; ++i) {
  44095. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  44096. continue;
  44097. }
  44098. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  44099. if (isHorizontal) {
  44100. p1[0] = tickCoord;
  44101. p1[1] = gridRect.y;
  44102. p2[0] = tickCoord;
  44103. p2[1] = gridRect.y + gridRect.height;
  44104. }
  44105. else {
  44106. p1[0] = gridRect.x;
  44107. p1[1] = tickCoord;
  44108. p2[0] = gridRect.x + gridRect.width;
  44109. p2[1] = tickCoord;
  44110. }
  44111. var colorIndex = (lineCount++) % lineColors.length;
  44112. splitLines[colorIndex] = splitLines[colorIndex] || [];
  44113. splitLines[colorIndex].push(new graphic.Line(
  44114. graphic.subPixelOptimizeLine({
  44115. shape: {
  44116. x1: p1[0],
  44117. y1: p1[1],
  44118. x2: p2[0],
  44119. y2: p2[1]
  44120. },
  44121. style: {
  44122. lineWidth: lineWidth
  44123. },
  44124. silent: true
  44125. })));
  44126. }
  44127. for (var i = 0; i < splitLines.length; ++i) {
  44128. this.group.add(graphic.mergePath(splitLines[i], {
  44129. style: {
  44130. stroke: lineColors[i % lineColors.length],
  44131. lineDash: lineStyleModel.getLineDash(lineWidth),
  44132. lineWidth: lineWidth
  44133. },
  44134. silent: true
  44135. }));
  44136. }
  44137. }
  44138. });
  44139. function axisLayout(axisModel) {
  44140. var single = axisModel.coordinateSystem;
  44141. var axis = axisModel.axis;
  44142. var layout = {};
  44143. var axisPosition = axis.position;
  44144. var orient = axis.orient;
  44145. var rect = single.getRect();
  44146. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  44147. var positionMap = {
  44148. horizontal: {top: rectBound[2], bottom: rectBound[3]},
  44149. vertical: {left: rectBound[0], right: rectBound[1]}
  44150. };
  44151. layout.position = [
  44152. orient === 'vertical'
  44153. ? positionMap.vertical[axisPosition]
  44154. : rectBound[0],
  44155. orient === 'horizontal'
  44156. ? positionMap.horizontal[axisPosition]
  44157. : rectBound[3]
  44158. ];
  44159. var r = {horizontal: 0, vertical: 1};
  44160. layout.rotation = Math.PI / 2 * r[orient];
  44161. var directionMap = {top: -1, bottom: 1, right: 1, left: -1};
  44162. layout.labelDirection = layout.tickDirection
  44163. = layout.nameDirection
  44164. = directionMap[axisPosition];
  44165. if (axisModel.getModel('axisTick').get('inside')) {
  44166. layout.tickDirection = -layout.tickDirection;
  44167. }
  44168. if (axisModel.getModel('axisLabel').get('inside')) {
  44169. layout.labelDirection = -layout.labelDirection;
  44170. }
  44171. var labelRotation = axisModel.getModel('axisLabel').get('rotate');
  44172. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  44173. layout.labelInterval = axis.getLabelInterval();
  44174. layout.z2 = 1;
  44175. return layout;
  44176. }
  44177. module.exports = AxisView;
  44178. /***/ },
  44179. /* 305 */
  44180. /***/ function(module, exports, __webpack_require__) {
  44181. var ComponentModel = __webpack_require__(19);
  44182. var axisModelCreator = __webpack_require__(128);
  44183. var zrUtil = __webpack_require__(4);
  44184. var AxisModel = ComponentModel.extend({
  44185. type: 'singleAxis',
  44186. layoutMode: 'box',
  44187. /**
  44188. * @type {module:echarts/coord/single/SingleAxis}
  44189. */
  44190. axis: null,
  44191. /**
  44192. * @type {module:echarts/coord/single/Single}
  44193. */
  44194. coordinateSystem: null
  44195. });
  44196. var defaultOption = {
  44197. left: '5%',
  44198. top: '5%',
  44199. right: '5%',
  44200. bottom: '5%',
  44201. type: 'value',
  44202. position: 'bottom',
  44203. orient: 'horizontal',
  44204. axisLine: {
  44205. show: true,
  44206. lineStyle: {
  44207. width: 2,
  44208. type: 'solid'
  44209. }
  44210. },
  44211. axisTick: {
  44212. show: true,
  44213. length: 6,
  44214. lineStyle: {
  44215. width: 2
  44216. }
  44217. },
  44218. axisLabel: {
  44219. show: true,
  44220. interval: 'auto'
  44221. },
  44222. splitLine: {
  44223. show: true,
  44224. lineStyle: {
  44225. type: 'dashed',
  44226. opacity: 0.2
  44227. }
  44228. }
  44229. };
  44230. function getAxisType(axisName, option) {
  44231. return option.type || (option.data ? 'category' : 'value');
  44232. }
  44233. zrUtil.merge(AxisModel.prototype, __webpack_require__(130));
  44234. axisModelCreator('single', AxisModel, getAxisType, defaultOption);
  44235. module.exports = AxisModel;
  44236. /***/ },
  44237. /* 306 */
  44238. /***/ function(module, exports, __webpack_require__) {
  44239. /**
  44240. * Brush component entry
  44241. */
  44242. __webpack_require__(1).registerPreprocessor(
  44243. __webpack_require__(307)
  44244. );
  44245. __webpack_require__(308);
  44246. __webpack_require__(312);
  44247. __webpack_require__(313);
  44248. __webpack_require__(314);
  44249. __webpack_require__(315);
  44250. /***/ },
  44251. /* 307 */
  44252. /***/ function(module, exports, __webpack_require__) {
  44253. /**
  44254. * @file brush preprocessor
  44255. */
  44256. var zrUtil = __webpack_require__(4);
  44257. var DEFAULT_TOOLBOX_BTNS = ['rect', 'polygon', 'keep', 'clear'];
  44258. module.exports = function (option, isNew) {
  44259. var brushComponents = option && option.brush;
  44260. if (!zrUtil.isArray(brushComponents)) {
  44261. brushComponents = brushComponents ? [brushComponents] : [];
  44262. }
  44263. if (!brushComponents.length) {
  44264. return;
  44265. }
  44266. var brushComponentSpecifiedBtns = [];
  44267. zrUtil.each(brushComponents, function (brushOpt) {
  44268. var tbs = brushOpt.hasOwnProperty('toolbox')
  44269. ? brushOpt.toolbox : [];
  44270. if (tbs instanceof Array) {
  44271. brushComponentSpecifiedBtns = brushComponentSpecifiedBtns.concat(tbs);
  44272. }
  44273. });
  44274. var toolbox = option && option.toolbox;
  44275. if (zrUtil.isArray(toolbox)) {
  44276. toolbox = toolbox[0];
  44277. }
  44278. if (!toolbox) {
  44279. toolbox = {feature: {}};
  44280. option.toolbox = [toolbox];
  44281. }
  44282. var toolboxFeature = (toolbox.feature || (toolbox.feature = {}));
  44283. var toolboxBrush = toolboxFeature.brush || (toolboxFeature.brush = {});
  44284. var brushTypes = toolboxBrush.type || (toolboxBrush.type = []);
  44285. brushTypes.push.apply(brushTypes, brushComponentSpecifiedBtns);
  44286. removeDuplicate(brushTypes);
  44287. if (isNew && !brushTypes.length) {
  44288. brushTypes.push.apply(brushTypes, DEFAULT_TOOLBOX_BTNS);
  44289. }
  44290. };
  44291. function removeDuplicate(arr) {
  44292. var map = {};
  44293. zrUtil.each(arr, function (val) {
  44294. map[val] = 1;
  44295. });
  44296. arr.length = 0;
  44297. zrUtil.each(map, function (flag, val) {
  44298. arr.push(val);
  44299. });
  44300. }
  44301. /***/ },
  44302. /* 308 */
  44303. /***/ function(module, exports, __webpack_require__) {
  44304. /**
  44305. * @file Brush visual coding.
  44306. */
  44307. var echarts = __webpack_require__(1);
  44308. var visualSolution = __webpack_require__(309);
  44309. var zrUtil = __webpack_require__(4);
  44310. var BoundingRect = __webpack_require__(9);
  44311. var selector = __webpack_require__(310);
  44312. var throttle = __webpack_require__(81);
  44313. var brushHelper = __webpack_require__(311);
  44314. var STATE_LIST = ['inBrush', 'outOfBrush'];
  44315. var DISPATCH_METHOD = '__ecBrushSelect';
  44316. var DISPATCH_FLAG = '__ecInBrushSelectEvent';
  44317. var PRIORITY_BRUSH = echarts.PRIORITY.VISUAL.BRUSH;
  44318. /**
  44319. * Layout for visual, the priority higher than other layout, and before brush visual.
  44320. */
  44321. echarts.registerLayout(PRIORITY_BRUSH, function (ecModel, api, payload) {
  44322. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  44323. payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(
  44324. payload.key === 'brush' ? payload.brushOption : {brushType: false}
  44325. );
  44326. brushModel.coordInfoList = brushHelper.makeCoordInfoList(brushModel.option, ecModel);
  44327. brushHelper.parseInputRanges(brushModel, ecModel);
  44328. });
  44329. });
  44330. /**
  44331. * Register the visual encoding if this modules required.
  44332. */
  44333. echarts.registerVisual(PRIORITY_BRUSH, function (ecModel, api, payload) {
  44334. var brushSelected = [];
  44335. var throttleType;
  44336. var throttleDelay;
  44337. ecModel.eachComponent({mainType: 'brush'}, function (brushModel, brushIndex) {
  44338. var thisBrushSelected = {
  44339. brushId: brushModel.id,
  44340. brushIndex: brushIndex,
  44341. brushName: brushModel.name,
  44342. areas: zrUtil.clone(brushModel.areas),
  44343. selected: []
  44344. };
  44345. // Every brush component exists in event params, convenient
  44346. // for user to find by index.
  44347. brushSelected.push(thisBrushSelected);
  44348. var brushOption = brushModel.option;
  44349. var brushLink = brushOption.brushLink;
  44350. var linkedSeriesMap = [];
  44351. var selectedDataIndexForLink = [];
  44352. var rangeInfoBySeries = [];
  44353. var hasBrushExists = 0;
  44354. if (!brushIndex) { // Only the first throttle setting works.
  44355. throttleType = brushOption.throttleType;
  44356. throttleDelay = brushOption.throttleDelay;
  44357. }
  44358. // Add boundingRect and selectors to range.
  44359. var areas = zrUtil.map(brushModel.areas, function (area) {
  44360. return bindSelector(
  44361. zrUtil.defaults(
  44362. {boundingRect: boundingRectBuilders[area.brushType](area)},
  44363. area
  44364. )
  44365. );
  44366. });
  44367. var visualMappings = visualSolution.createVisualMappings(
  44368. brushModel.option, STATE_LIST, function (mappingOption) {
  44369. mappingOption.mappingMethod = 'fixed';
  44370. }
  44371. );
  44372. zrUtil.isArray(brushLink) && zrUtil.each(brushLink, function (seriesIndex) {
  44373. linkedSeriesMap[seriesIndex] = 1;
  44374. });
  44375. function linkOthers(seriesIndex) {
  44376. return brushLink === 'all' || linkedSeriesMap[seriesIndex];
  44377. }
  44378. // If no supported brush or no brush on the series,
  44379. // all visuals should be in original state.
  44380. function brushed(rangeInfoList) {
  44381. return !!rangeInfoList.length;
  44382. }
  44383. /**
  44384. * Logic for each series: (If the logic has to be modified one day, do it carefully!)
  44385. *
  44386. * ( brushed ┬ && ┬hasBrushExist ┬ && linkOthers ) => StepA: ┬record, ┬ StepB: ┬visualByRecord.
  44387. * !brushed┘ ├hasBrushExist ┤ └nothing,┘ ├visualByRecord.
  44388. * └!hasBrushExist┘ └nothing.
  44389. * ( !brushed && ┬hasBrushExist ┬ && linkOthers ) => StepA: nothing, StepB: ┬visualByRecord.
  44390. * └!hasBrushExist┘ └nothing.
  44391. * ( brushed ┬ && !linkOthers ) => StepA: nothing, StepB: ┬visualByCheck.
  44392. * !brushed┘ └nothing.
  44393. * ( !brushed && !linkOthers ) => StepA: nothing, StepB: nothing.
  44394. */
  44395. // Step A
  44396. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  44397. var rangeInfoList = rangeInfoBySeries[seriesIndex] = [];
  44398. seriesModel.subType === 'parallel'
  44399. ? stepAParallel(seriesModel, seriesIndex, rangeInfoList)
  44400. : stepAOthers(seriesModel, seriesIndex, rangeInfoList);
  44401. });
  44402. function stepAParallel(seriesModel, seriesIndex) {
  44403. var coordSys = seriesModel.coordinateSystem;
  44404. hasBrushExists |= coordSys.hasAxisbrushed();
  44405. linkOthers(seriesIndex) && coordSys.eachActiveState(
  44406. seriesModel.getData(),
  44407. function (activeState, dataIndex) {
  44408. activeState === 'active' && (selectedDataIndexForLink[dataIndex] = 1);
  44409. }
  44410. );
  44411. }
  44412. function stepAOthers(seriesModel, seriesIndex, rangeInfoList) {
  44413. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  44414. if (!selectorsByBrushType || brushModelNotControll(brushModel, seriesIndex)) {
  44415. return;
  44416. }
  44417. zrUtil.each(areas, function (area) {
  44418. selectorsByBrushType[area.brushType]
  44419. && brushHelper.controlSeries(area, brushModel, seriesModel)
  44420. && rangeInfoList.push(area);
  44421. hasBrushExists |= brushed(rangeInfoList);
  44422. });
  44423. if (linkOthers(seriesIndex) && brushed(rangeInfoList)) {
  44424. var data = seriesModel.getData();
  44425. data.each(function (dataIndex) {
  44426. if (checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)) {
  44427. selectedDataIndexForLink[dataIndex] = 1;
  44428. }
  44429. });
  44430. }
  44431. }
  44432. // Step B
  44433. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  44434. var seriesBrushSelected = {
  44435. seriesId: seriesModel.id,
  44436. seriesIndex: seriesIndex,
  44437. seriesName: seriesModel.name,
  44438. dataIndex: []
  44439. };
  44440. // Every series exists in event params, convenient
  44441. // for user to find series by seriesIndex.
  44442. thisBrushSelected.selected.push(seriesBrushSelected);
  44443. var selectorsByBrushType = getSelectorsByBrushType(seriesModel);
  44444. var rangeInfoList = rangeInfoBySeries[seriesIndex];
  44445. var data = seriesModel.getData();
  44446. var getValueState = linkOthers(seriesIndex)
  44447. ? function (dataIndex) {
  44448. return selectedDataIndexForLink[dataIndex]
  44449. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  44450. : 'outOfBrush';
  44451. }
  44452. : function (dataIndex) {
  44453. return checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex)
  44454. ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush')
  44455. : 'outOfBrush';
  44456. };
  44457. // If no supported brush or no brush, all visuals are in original state.
  44458. (linkOthers(seriesIndex) ? hasBrushExists : brushed(rangeInfoList))
  44459. && visualSolution.applyVisual(
  44460. STATE_LIST, visualMappings, data, getValueState
  44461. );
  44462. });
  44463. });
  44464. dispatchAction(api, throttleType, throttleDelay, brushSelected, payload);
  44465. });
  44466. function dispatchAction(api, throttleType, throttleDelay, brushSelected, payload) {
  44467. // This event will not be triggered when `setOpion`, otherwise dead lock may
  44468. // triggered when do `setOption` in event listener, which we do not find
  44469. // satisfactory way to solve yet. Some considered resolutions:
  44470. // (a) Diff with prevoius selected data ant only trigger event when changed.
  44471. // But store previous data and diff precisely (i.e., not only by dataIndex, but
  44472. // also detect value changes in selected data) might bring complexity or fragility.
  44473. // (b) Use spectial param like `silent` to suppress event triggering.
  44474. // But such kind of volatile param may be weird in `setOption`.
  44475. if (!payload) {
  44476. return;
  44477. }
  44478. var zr = api.getZr();
  44479. if (zr[DISPATCH_FLAG]) {
  44480. return;
  44481. }
  44482. if (!zr[DISPATCH_METHOD]) {
  44483. zr[DISPATCH_METHOD] = doDispatch;
  44484. }
  44485. var fn = throttle.createOrUpdate(zr, DISPATCH_METHOD, throttleDelay, throttleType);
  44486. fn(api, brushSelected);
  44487. }
  44488. function doDispatch(api, brushSelected) {
  44489. if (!api.isDisposed()) {
  44490. var zr = api.getZr();
  44491. zr[DISPATCH_FLAG] = true;
  44492. api.dispatchAction({
  44493. type: 'brushSelect',
  44494. batch: brushSelected
  44495. });
  44496. zr[DISPATCH_FLAG] = false;
  44497. }
  44498. }
  44499. function checkInRange(selectorsByBrushType, rangeInfoList, data, dataIndex) {
  44500. var itemLayout = data.getItemLayout(dataIndex);
  44501. for (var i = 0, len = rangeInfoList.length; i < len; i++) {
  44502. var area = rangeInfoList[i];
  44503. if (selectorsByBrushType[area.brushType](
  44504. itemLayout, area.selectors, area
  44505. )) {
  44506. return true;
  44507. }
  44508. }
  44509. }
  44510. function getSelectorsByBrushType(seriesModel) {
  44511. var brushSelector = seriesModel.brushSelector;
  44512. if (zrUtil.isString(brushSelector)) {
  44513. var sels = [];
  44514. zrUtil.each(selector, function (selectorsByElementType, brushType) {
  44515. sels[brushType] = selectorsByElementType[brushSelector];
  44516. });
  44517. return sels;
  44518. }
  44519. else if (zrUtil.isFunction(brushSelector)) {
  44520. var bSelector = {};
  44521. zrUtil.each(selector, function (sel, brushType) {
  44522. bSelector[brushType] = brushSelector;
  44523. });
  44524. return bSelector;
  44525. }
  44526. return brushSelector;
  44527. }
  44528. function brushModelNotControll(brushModel, seriesIndex) {
  44529. var seriesIndices = brushModel.option.seriesIndex;
  44530. return seriesIndices != null
  44531. && seriesIndices !== 'all'
  44532. && (
  44533. zrUtil.isArray(seriesIndices)
  44534. ? zrUtil.indexOf(seriesIndices, seriesIndex) < 0
  44535. : seriesIndex !== seriesIndices
  44536. );
  44537. }
  44538. function bindSelector(area) {
  44539. var selectors = area.selectors = {};
  44540. zrUtil.each(selector[area.brushType], function (selFn, elType) {
  44541. // Do not use function binding or curry for performance.
  44542. selectors[elType] = function (itemLayout) {
  44543. return selFn(itemLayout, selectors, area);
  44544. };
  44545. });
  44546. return area;
  44547. }
  44548. var boundingRectBuilders = {
  44549. lineX: zrUtil.noop,
  44550. lineY: zrUtil.noop,
  44551. rect: function (area) {
  44552. return getBoundingRectFromMinMax(area.range);
  44553. },
  44554. polygon: function (area) {
  44555. var minMax;
  44556. var range = area.range;
  44557. for (var i = 0, len = range.length; i < len; i++) {
  44558. minMax = minMax || [[Infinity, -Infinity], [Infinity, -Infinity]];
  44559. var rg = range[i];
  44560. rg[0] < minMax[0][0] && (minMax[0][0] = rg[0]);
  44561. rg[0] > minMax[0][1] && (minMax[0][1] = rg[0]);
  44562. rg[1] < minMax[1][0] && (minMax[1][0] = rg[1]);
  44563. rg[1] > minMax[1][1] && (minMax[1][1] = rg[1]);
  44564. }
  44565. return minMax && getBoundingRectFromMinMax(minMax);
  44566. }
  44567. };
  44568. function getBoundingRectFromMinMax(minMax) {
  44569. return new BoundingRect(
  44570. minMax[0][0],
  44571. minMax[1][0],
  44572. minMax[0][1] - minMax[0][0],
  44573. minMax[1][1] - minMax[1][0]
  44574. );
  44575. }
  44576. /***/ },
  44577. /* 309 */
  44578. /***/ function(module, exports, __webpack_require__) {
  44579. /**
  44580. * @file Visual solution, for consistent option specification.
  44581. */
  44582. var zrUtil = __webpack_require__(4);
  44583. var VisualMapping = __webpack_require__(194);
  44584. var each = zrUtil.each;
  44585. function hasKeys(obj) {
  44586. if (obj) {
  44587. for (var name in obj){
  44588. if (obj.hasOwnProperty(name)) {
  44589. return true;
  44590. }
  44591. }
  44592. }
  44593. }
  44594. var visualSolution = {
  44595. /**
  44596. * @param {Object} option
  44597. * @param {Array.<string>} stateList
  44598. * @param {Function} [supplementVisualOption]
  44599. * @return {Object} visualMappings <state, <visualType, module:echarts/visual/VisualMapping>>
  44600. */
  44601. createVisualMappings: function (option, stateList, supplementVisualOption) {
  44602. var visualMappings = {};
  44603. each(stateList, function (state) {
  44604. var mappings = visualMappings[state] = createMappings();
  44605. each(option[state], function (visualData, visualType) {
  44606. if (!VisualMapping.isValidType(visualType)) {
  44607. return;
  44608. }
  44609. var mappingOption = {
  44610. type: visualType,
  44611. visual: visualData
  44612. };
  44613. supplementVisualOption && supplementVisualOption(mappingOption, state);
  44614. mappings[visualType] = new VisualMapping(mappingOption);
  44615. // Prepare a alpha for opacity, for some case that opacity
  44616. // is not supported, such as rendering using gradient color.
  44617. if (visualType === 'opacity') {
  44618. mappingOption = zrUtil.clone(mappingOption);
  44619. mappingOption.type = 'colorAlpha';
  44620. mappings.__hidden.__alphaForOpacity = new VisualMapping(mappingOption);
  44621. }
  44622. });
  44623. });
  44624. return visualMappings;
  44625. function createMappings() {
  44626. var Creater = function () {};
  44627. // Make sure hidden fields will not be visited by
  44628. // object iteration (with hasOwnProperty checking).
  44629. Creater.prototype.__hidden = Creater.prototype;
  44630. var obj = new Creater();
  44631. return obj;
  44632. }
  44633. },
  44634. /**
  44635. * @param {Object} thisOption
  44636. * @param {Object} newOption
  44637. * @param {Array.<string>} keys
  44638. */
  44639. replaceVisualOption: function (thisOption, newOption, keys) {
  44640. // Visual attributes merge is not supported, otherwise it
  44641. // brings overcomplicated merge logic. See #2853. So if
  44642. // newOption has anyone of these keys, all of these keys
  44643. // will be reset. Otherwise, all keys remain.
  44644. var has;
  44645. zrUtil.each(keys, function (key) {
  44646. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  44647. has = true;
  44648. }
  44649. });
  44650. has && zrUtil.each(keys, function (key) {
  44651. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  44652. thisOption[key] = zrUtil.clone(newOption[key]);
  44653. }
  44654. else {
  44655. delete thisOption[key];
  44656. }
  44657. });
  44658. },
  44659. /**
  44660. * @param {Array.<string>} stateList
  44661. * @param {Object} visualMappings <state, Object.<visualType, module:echarts/visual/VisualMapping>>
  44662. * @param {module:echarts/data/List} list
  44663. * @param {Function} getValueState param: valueOrIndex, return: state.
  44664. * @param {object} [scope] Scope for getValueState
  44665. * @param {string} [dimension] Concrete dimension, if used.
  44666. */
  44667. applyVisual: function (stateList, visualMappings, data, getValueState, scope, dimension) {
  44668. var visualTypesMap = {};
  44669. zrUtil.each(stateList, function (state) {
  44670. var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
  44671. visualTypesMap[state] = visualTypes;
  44672. });
  44673. var dataIndex;
  44674. function getVisual(key) {
  44675. return data.getItemVisual(dataIndex, key);
  44676. }
  44677. function setVisual(key, value) {
  44678. data.setItemVisual(dataIndex, key, value);
  44679. }
  44680. if (dimension == null) {
  44681. data.each(eachItem, true);
  44682. }
  44683. else {
  44684. data.each([dimension], eachItem, true);
  44685. }
  44686. function eachItem(valueOrIndex, index) {
  44687. dataIndex = dimension == null ? valueOrIndex : index;
  44688. var valueState = getValueState.call(scope, valueOrIndex);
  44689. var mappings = visualMappings[valueState];
  44690. var visualTypes = visualTypesMap[valueState];
  44691. for (var i = 0, len = visualTypes.length; i < len; i++) {
  44692. var type = visualTypes[i];
  44693. mappings[type] && mappings[type].applyVisual(
  44694. valueOrIndex, getVisual, setVisual
  44695. );
  44696. }
  44697. }
  44698. }
  44699. };
  44700. module.exports = visualSolution;
  44701. /***/ },
  44702. /* 310 */
  44703. /***/ function(module, exports, __webpack_require__) {
  44704. var polygonContain = __webpack_require__(169).contain;
  44705. var BoundingRect = __webpack_require__(9);
  44706. // Key of the first level is brushType: `line`, `rect`, `polygon`.
  44707. // Key of the second level is chart element type: `point`, `rect`.
  44708. // See moudule:echarts/component/helper/BrushController
  44709. // function param:
  44710. // {Object} itemLayout fetch from data.getItemLayout(dataIndex)
  44711. // {Object} selectors {point: selector, rect: selector, ...}
  44712. // {Object} area {range: [[], [], ..], boudingRect}
  44713. // function return:
  44714. // {boolean} Whether in the given brush.
  44715. var selector = {
  44716. lineX: getLineSelectors(0),
  44717. lineY: getLineSelectors(1),
  44718. rect: {
  44719. point: function (itemLayout, selectors, area) {
  44720. return area.boundingRect.contain(itemLayout[0], itemLayout[1]);
  44721. },
  44722. rect: function (itemLayout, selectors, area) {
  44723. return area.boundingRect.intersect(itemLayout);
  44724. }
  44725. },
  44726. polygon: {
  44727. point: function (itemLayout, selectors, area) {
  44728. return area.boundingRect.contain(itemLayout[0], itemLayout[1])
  44729. && polygonContain(area.range, itemLayout[0], itemLayout[1]);
  44730. },
  44731. rect: function (itemLayout, selectors, area) {
  44732. // FIXME
  44733. // 随意写的,没有考察过效率。
  44734. var points = area.range;
  44735. if (points.length <= 1) {
  44736. return false;
  44737. }
  44738. var x = itemLayout.x;
  44739. var y = itemLayout.y;
  44740. var width = itemLayout.width;
  44741. var height = itemLayout.height;
  44742. var p = points[0];
  44743. if (polygonContain(points, x, y)
  44744. || polygonContain(points, x + width, y)
  44745. || polygonContain(points, x, y + height)
  44746. || polygonContain(points, x + width, y + height)
  44747. || BoundingRect.create(itemLayout).contain(p[0], p[1])
  44748. || lineIntersectPolygon(x, y, x + width, y, points)
  44749. || lineIntersectPolygon(x, y, x, y + height, points)
  44750. || lineIntersectPolygon(x + width, y, x + width, y + height, points)
  44751. || lineIntersectPolygon(x, y + height, x + width, y + height, points)
  44752. ) {
  44753. return true;
  44754. }
  44755. }
  44756. }
  44757. };
  44758. function getLineSelectors(xyIndex) {
  44759. var xy = ['x', 'y'];
  44760. var wh = ['width', 'height'];
  44761. return {
  44762. point: function (itemLayout, selectors, area) {
  44763. var range = area.range;
  44764. var p = itemLayout[xyIndex];
  44765. return inLineRange(p, range);
  44766. },
  44767. rect: function (itemLayout, selectors, area) {
  44768. var range = area.range;
  44769. return inLineRange(itemLayout[xy[xyIndex]], range)
  44770. || inLineRange(itemLayout[xy[xyIndex]] + itemLayout[wh[xyIndex]], range);
  44771. }
  44772. };
  44773. }
  44774. function inLineRange(p, range) {
  44775. return range[0] <= p && p <= range[1];
  44776. }
  44777. // FIXME
  44778. // 随意写的,没考察过效率。
  44779. function lineIntersectPolygon(lx, ly, l2x, l2y, points) {
  44780. for (var i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
  44781. var p = points[i];
  44782. if (lineIntersect(lx, ly, l2x, l2y, p[0], p[1], p2[0], p2[1])) {
  44783. return true;
  44784. }
  44785. p2 = p;
  44786. }
  44787. }
  44788. // Code from <http://blog.csdn.net/rickliuxiao/article/details/6259322> with some fix.
  44789. // See <https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection>
  44790. function lineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
  44791. var delta = determinant(a2x - a1x, b1x - b2x, a2y - a1y, b1y - b2y);
  44792. if (nearZero(delta)) { // parallel
  44793. return false;
  44794. }
  44795. var namenda = determinant(b1x - a1x, b1x - b2x, b1y - a1y, b1y - b2y) / delta;
  44796. if (namenda < 0 || namenda > 1) {
  44797. return false;
  44798. }
  44799. var miu = determinant(a2x - a1x, b1x - a1x, a2y - a1y, b1y - a1y) / delta;
  44800. if (miu < 0 || miu > 1) {
  44801. return false;
  44802. }
  44803. return true;
  44804. }
  44805. function nearZero(val) {
  44806. return val <= (1e-6) && val >= -(1e-6);
  44807. }
  44808. function determinant(v1, v2, v3, v4) {
  44809. return v1 * v4 - v2 * v3;
  44810. }
  44811. module.exports = selector;
  44812. /***/ },
  44813. /* 311 */
  44814. /***/ function(module, exports, __webpack_require__) {
  44815. var zrUtil = __webpack_require__(4);
  44816. var graphic = __webpack_require__(43);
  44817. var each = zrUtil.each;
  44818. var helper = {};
  44819. var COMPONENT_NAMES = ['geo', 'xAxis', 'yAxis'];
  44820. var PANEL_ID_SPLIT = '--';
  44821. var COORD_CONVERTS = ['dataToPoint', 'pointToData'];
  44822. helper.parseOutputRanges = function (areas, coordInfoList, ecModel, rangesCoordInfo) {
  44823. each(areas, function (area, index) {
  44824. var panelId = area.panelId;
  44825. if (panelId) {
  44826. panelId = panelId.split(PANEL_ID_SPLIT);
  44827. area[panelId[0] + 'Index'] = +panelId[1];
  44828. var coordInfo = findCoordInfo(area, coordInfoList);
  44829. area.coordRange = coordConvert[area.brushType](
  44830. 1, coordInfo, area.range
  44831. );
  44832. rangesCoordInfo && (rangesCoordInfo[index] = coordInfo);
  44833. }
  44834. });
  44835. };
  44836. helper.parseInputRanges = function (brushModel, ecModel) {
  44837. each(brushModel.areas, function (area) {
  44838. var coordInfo = findCoordInfo(area, brushModel.coordInfoList);
  44839. if (true) {
  44840. zrUtil.assert(
  44841. !coordInfo || coordInfo === true || area.coordRange,
  44842. 'coordRange must be specified when coord index specified.'
  44843. );
  44844. zrUtil.assert(
  44845. !coordInfo || coordInfo !== true || area.range,
  44846. 'range must be specified.'
  44847. );
  44848. }
  44849. area.range = area.range || [];
  44850. // convert coordRange to global range and set panelId.
  44851. if (coordInfo && coordInfo !== true) {
  44852. area.range = coordConvert[area.brushType](
  44853. 0, coordInfo, area.coordRange
  44854. );
  44855. area.panelId = coordInfo.panelId;
  44856. }
  44857. });
  44858. };
  44859. helper.makePanelOpts = function (coordInfoList) {
  44860. var panelOpts = [];
  44861. each(coordInfoList, function (coordInfo) {
  44862. var coordSys = coordInfo.coordSys;
  44863. var rect;
  44864. if (coordInfo.geoIndex >= 0) {
  44865. rect = coordSys.getBoundingRect().clone();
  44866. // geo roam and zoom transform
  44867. rect.applyTransform(graphic.getTransform(coordSys));
  44868. }
  44869. else { // xAxis or yAxis
  44870. // grid is not Transformable.
  44871. rect = coordSys.grid.getRect().clone();
  44872. }
  44873. panelOpts.push({panelId: coordInfo.panelId, rect: rect});
  44874. });
  44875. return panelOpts;
  44876. };
  44877. /**
  44878. * @param {Object} option {xAxisIndex, yAxisIndex, geoIndex}
  44879. * @param {module:echarts/model/Global} ecModel
  44880. * @return {Array.<Obejct>} coordInfoList
  44881. */
  44882. helper.makeCoordInfoList = function (option, ecModel) {
  44883. var coordInfoList = [];
  44884. each(COMPONENT_NAMES, function (componentName) {
  44885. var componentIndices = option[componentName + 'Index'];
  44886. if (componentIndices == null || componentIndices === 'none') {
  44887. return;
  44888. }
  44889. if (componentIndices !== 'all' && !zrUtil.isArray(componentIndices)) {
  44890. componentIndices = [componentIndices];
  44891. }
  44892. ecModel.eachComponent({mainType: componentName}, function (componentModel, index) {
  44893. if (componentIndices !== 'all' && zrUtil.indexOf(componentIndices, index) < 0) {
  44894. return;
  44895. }
  44896. var grid;
  44897. var coordSys;
  44898. (componentName === 'xAxis' || componentName === 'yAxis')
  44899. ? (grid = componentModel.axis.grid)
  44900. : (coordSys = componentModel.coordinateSystem); // geo
  44901. var coordInfo;
  44902. // Check duplicate and find cartesian when tranval to yAxis.
  44903. for (var i = 0, len = coordInfoList.length; i < len; i++) {
  44904. var cInfo = coordInfoList[i];
  44905. if (true) {
  44906. zrUtil.assert(
  44907. cInfo[componentName + 'Index'] != index,
  44908. 'Coord should not be defined duplicately: ' + componentName + index
  44909. );
  44910. }
  44911. // CoordSys is always required for `rect brush` or `polygon brush`.
  44912. // If both xAxisIndex and yAxisIndex specified, fetch cartesian by them.
  44913. if (componentName === 'yAxis' && !cInfo.yAxis && cInfo.xAxis) {
  44914. var aCoordSys = grid.getCartesian(cInfo.xAxisIndex, index);
  44915. if (aCoordSys) { // The yAxis and xAxis are in the same cartesian.
  44916. coordSys = aCoordSys;
  44917. coordInfo = cInfo;
  44918. break;
  44919. }
  44920. }
  44921. }
  44922. !coordInfo && coordInfoList.push(coordInfo = {});
  44923. coordInfo[componentName] = componentModel;
  44924. coordInfo[componentName + 'Index'] = index;
  44925. // If both xAxisIndex and yAxisIndex specified, panelId only use yAxisIndex,
  44926. // which is enough to index panel.
  44927. coordInfo.panelId = componentName + PANEL_ID_SPLIT + index;
  44928. coordInfo.coordSys = coordSys
  44929. // If only xAxisIndex or only yAxisIndex specified, find its first cartesian.
  44930. || grid.getCartesian(coordInfo.xAxisIndex, coordInfo.yAxisIndex);
  44931. coordInfo.coordSys
  44932. ? (coordInfoList[componentName + 'Has'] = true)
  44933. : coordInfoList.pop(); // If a coordInfo exists originally, existance of coordSys is ensured.
  44934. });
  44935. });
  44936. return coordInfoList;
  44937. };
  44938. helper.controlSeries = function (area, brushModel, seriesModel) {
  44939. // Check whether area is bound in coord, and series do not belong to that coord.
  44940. // If do not do this check, some brush (like lineX) will controll all axes.
  44941. var coordInfo = findCoordInfo(area, brushModel.coordInfoList);
  44942. return coordInfo === true || (coordInfo && coordInfo.coordSys === seriesModel.coordinateSystem);
  44943. };
  44944. function formatMinMax(minMax) {
  44945. minMax[0] > minMax[1] && minMax.reverse();
  44946. return minMax;
  44947. }
  44948. /**
  44949. * If return Object, a coord found.
  44950. * If reutrn true, global found.
  44951. * Otherwise nothing found.
  44952. *
  44953. * @param {Object} area {<componentName>Index}
  44954. * @param {Array} coordInfoList
  44955. * @return {Obejct|boolean}
  44956. */
  44957. function findCoordInfo(area, coordInfoList) {
  44958. var isGlobal = true;
  44959. for (var j = 0; j < COMPONENT_NAMES.length; j++) {
  44960. var indexAttr = COMPONENT_NAMES[j] + 'Index';
  44961. if (area[indexAttr] >= 0) {
  44962. isGlobal = false;
  44963. for (var i = 0; i < coordInfoList.length; i++) {
  44964. if (coordInfoList[i][indexAttr] === area[indexAttr]) {
  44965. return coordInfoList[i];
  44966. }
  44967. }
  44968. }
  44969. }
  44970. return isGlobal;
  44971. }
  44972. function axisConvert(axisName, to, coordInfo, coordRange) {
  44973. var axis = coordInfo.coordSys.getAxis(axisName);
  44974. if (true) {
  44975. zrUtil.assert(axis, 'line brush is only available in cartesian (grid).');
  44976. }
  44977. return formatMinMax(zrUtil.map([0, 1], function (i) {
  44978. return to
  44979. ? axis.coordToData(axis.toLocalCoord(coordRange[i]))
  44980. : axis.toGlobalCoord(axis.dataToCoord(coordRange[i]));
  44981. }));
  44982. }
  44983. var coordConvert = {
  44984. lineX: zrUtil.curry(axisConvert, 'x'),
  44985. lineY: zrUtil.curry(axisConvert, 'y'),
  44986. rect: function (to, coordInfo, coordRange) {
  44987. var coordSys = coordInfo.coordSys;
  44988. var xminymin = coordSys[COORD_CONVERTS[to]]([coordRange[0][0], coordRange[1][0]]);
  44989. var xmaxymax = coordSys[COORD_CONVERTS[to]]([coordRange[0][1], coordRange[1][1]]);
  44990. return [
  44991. formatMinMax([xminymin[0], xmaxymax[0]]),
  44992. formatMinMax([xminymin[1], xmaxymax[1]])
  44993. ];
  44994. },
  44995. polygon: function (to, coordInfo, coordRange) {
  44996. var coordSys = coordInfo.coordSys;
  44997. return zrUtil.map(coordRange, coordSys[COORD_CONVERTS[to]], coordSys);
  44998. }
  44999. };
  45000. module.exports = helper;
  45001. /***/ },
  45002. /* 312 */
  45003. /***/ function(module, exports, __webpack_require__) {
  45004. /**
  45005. * @file Brush model
  45006. */
  45007. var echarts = __webpack_require__(1);
  45008. var zrUtil = __webpack_require__(4);
  45009. var visualSolution = __webpack_require__(309);
  45010. var Model = __webpack_require__(12);
  45011. var DEFAULT_OUT_OF_BRUSH_COLOR = ['#ddd'];
  45012. var BrushModel = echarts.extendComponentModel({
  45013. type: 'brush',
  45014. dependencies: ['geo', 'grid', 'xAxis', 'yAxis', 'parallel', 'series'],
  45015. /**
  45016. * @protected
  45017. */
  45018. defaultOption: {
  45019. // inBrush: null,
  45020. // outOfBrush: null,
  45021. toolbox: null, // Default value see preprocessor.
  45022. brushLink: null, // Series indices array, broadcast using dataIndex.
  45023. // or 'all', which means all series. 'none' or null means no series.
  45024. seriesIndex: 'all', // seriesIndex array, specify series controlled by this brush component.
  45025. geoIndex: null, //
  45026. xAxisIndex: null,
  45027. yAxisIndex: null,
  45028. brushType: 'rect', // Default brushType, see BrushController.
  45029. brushMode: 'single', // Default brushMode, 'single' or 'multiple'
  45030. transformable: true, // Default transformable.
  45031. brushStyle: { // Default brushStyle
  45032. borderWidth: 1,
  45033. color: 'rgba(120,140,180,0.3)',
  45034. borderColor: 'rgba(120,140,180,0.8)',
  45035. width: null // do not use bursh width in line brush, but fetch from grid.
  45036. },
  45037. throttleType: 'fixRate',// Throttle in brushSelected event. 'fixRate' or 'debounce'.
  45038. // If null, no throttle. Valid only in the first brush component
  45039. throttleDelay: 0, // Unit: ms, 0 means every event will be triggered.
  45040. // FIXME
  45041. // 试验效果
  45042. removeOnClick: true
  45043. },
  45044. /**
  45045. * @readOnly
  45046. * @type {Array.<Object>}
  45047. */
  45048. areas: [],
  45049. /**
  45050. * Current activated brush type.
  45051. * If null, brush is inactived.
  45052. * see module:echarts/component/helper/BrushController
  45053. * @readOnly
  45054. * @type {string}
  45055. */
  45056. brushType: null,
  45057. /**
  45058. * Current brush opt.
  45059. * see module:echarts/component/helper/BrushController
  45060. * @readOnly
  45061. * @type {Object}
  45062. */
  45063. brushOption: {},
  45064. /**
  45065. * @readOnly
  45066. * @type {Array.<Object>}
  45067. */
  45068. coordInfoList: [],
  45069. optionUpdated: function (newOption, isInit) {
  45070. var thisOption = this.option;
  45071. !isInit && visualSolution.replaceVisualOption(
  45072. thisOption, newOption, ['inBrush', 'outOfBrush']
  45073. );
  45074. thisOption.inBrush = thisOption.inBrush || {};
  45075. // Always give default visual, consider setOption at the second time.
  45076. thisOption.outOfBrush = thisOption.outOfBrush || {color: DEFAULT_OUT_OF_BRUSH_COLOR};
  45077. },
  45078. /**
  45079. * If ranges is null/undefined, range state remain.
  45080. *
  45081. * @param {Array.<Object>} [ranges]
  45082. */
  45083. setAreas: function (areas) {
  45084. if (true) {
  45085. zrUtil.assert(zrUtil.isArray(areas));
  45086. zrUtil.each(areas, function (area) {
  45087. zrUtil.assert(area.brushType, 'Illegal areas');
  45088. });
  45089. }
  45090. // If ranges is null/undefined, range state remain.
  45091. // This helps user to dispatchAction({type: 'brush'}) with no areas
  45092. // set but just want to get the current brush select info from a `brush` event.
  45093. if (!areas) {
  45094. return;
  45095. }
  45096. this.areas = zrUtil.map(areas, function (area) {
  45097. return this._mergeBrushOption(area);
  45098. }, this);
  45099. },
  45100. /**
  45101. * see module:echarts/component/helper/BrushController
  45102. * @param {Object} brushOption
  45103. */
  45104. setBrushOption: function (brushOption) {
  45105. this.brushOption = this._mergeBrushOption(brushOption);
  45106. this.brushType = this.brushOption.brushType;
  45107. },
  45108. /**
  45109. * @private
  45110. */
  45111. _mergeBrushOption: function (brushOption) {
  45112. var option = this.option;
  45113. return zrUtil.merge(
  45114. {
  45115. brushType: option.brushType,
  45116. brushMode: option.brushMode,
  45117. transformable: option.transformable,
  45118. brushStyle: new Model(option.brushStyle).getItemStyle(),
  45119. removeOnClick: option.removeOnClick
  45120. },
  45121. brushOption,
  45122. true
  45123. );
  45124. }
  45125. });
  45126. module.exports = BrushModel;
  45127. /***/ },
  45128. /* 313 */
  45129. /***/ function(module, exports, __webpack_require__) {
  45130. var zrUtil = __webpack_require__(4);
  45131. var BrushController = __webpack_require__(235);
  45132. var echarts = __webpack_require__(1);
  45133. var brushHelper = __webpack_require__(311);
  45134. module.exports = echarts.extendComponentView({
  45135. type: 'brush',
  45136. init: function (ecModel, api) {
  45137. /**
  45138. * @readOnly
  45139. * @type {module:echarts/model/Global}
  45140. */
  45141. this.ecModel = ecModel;
  45142. /**
  45143. * @readOnly
  45144. * @type {module:echarts/ExtensionAPI}
  45145. */
  45146. this.api = api;
  45147. /**
  45148. * @readOnly
  45149. * @type {module:echarts/component/brush/BrushModel}
  45150. */
  45151. this.model;
  45152. /**
  45153. * @private
  45154. * @type {module:echarts/component/helper/BrushController}
  45155. */
  45156. (this._brushController = new BrushController(api.getZr()))
  45157. .on('brush', zrUtil.bind(this._onBrush, this))
  45158. .mount();
  45159. },
  45160. /**
  45161. * @override
  45162. */
  45163. render: function (brushModel) {
  45164. this.model = brushModel;
  45165. return updateController.apply(this, arguments);
  45166. },
  45167. /**
  45168. * @override
  45169. */
  45170. updateView: updateController,
  45171. /**
  45172. * @override
  45173. */
  45174. updateLayout: updateController,
  45175. /**
  45176. * @override
  45177. */
  45178. updateVisual: updateController,
  45179. /**
  45180. * @override
  45181. */
  45182. dispose: function () {
  45183. this._brushController.dispose();
  45184. },
  45185. /**
  45186. * @private
  45187. */
  45188. _onBrush: function (areas, opt) {
  45189. var modelId = this.model.id;
  45190. brushHelper.parseOutputRanges(areas, this.model.coordInfoList, this.ecModel);
  45191. // Action is not dispatched on drag end, because the drag end
  45192. // emits the same params with the last drag move event, and
  45193. // may have some delay when using touch pad, which makes
  45194. // animation not smooth (when using debounce).
  45195. (!opt.isEnd || opt.removeOnClick) && this.api.dispatchAction({
  45196. type: 'brush',
  45197. brushId: modelId,
  45198. areas: zrUtil.clone(areas),
  45199. $from: modelId
  45200. });
  45201. }
  45202. });
  45203. function updateController(brushModel, ecModel, api, payload) {
  45204. // Do not update controller when drawing.
  45205. (!payload || payload.$from !== brushModel.id) && this._brushController
  45206. .setPanels(brushHelper.makePanelOpts(brushModel.coordInfoList))
  45207. .enableBrush(brushModel.brushOption)
  45208. .updateCovers(brushModel.areas.slice());
  45209. }
  45210. /***/ },
  45211. /* 314 */
  45212. /***/ function(module, exports, __webpack_require__) {
  45213. /**
  45214. * @file Brush action
  45215. */
  45216. var echarts = __webpack_require__(1);
  45217. /**
  45218. * payload: {
  45219. * brushIndex: number, or,
  45220. * brushId: string, or,
  45221. * brushName: string,
  45222. * globalRanges: Array
  45223. * }
  45224. */
  45225. echarts.registerAction(
  45226. {type: 'brush', event: 'brush', update: 'updateView'},
  45227. function (payload, ecModel) {
  45228. ecModel.eachComponent({mainType: 'brush', query: payload}, function (brushModel) {
  45229. brushModel.setAreas(payload.areas);
  45230. });
  45231. }
  45232. );
  45233. /**
  45234. * payload: {
  45235. * brushComponents: [
  45236. * {
  45237. * brushId,
  45238. * brushIndex,
  45239. * brushName,
  45240. * series: [
  45241. * {
  45242. * seriesId,
  45243. * seriesIndex,
  45244. * seriesName,
  45245. * rawIndices: [21, 34, ...]
  45246. * },
  45247. * ...
  45248. * ]
  45249. * },
  45250. * ...
  45251. * ]
  45252. * }
  45253. */
  45254. echarts.registerAction(
  45255. {type: 'brushSelect', event: 'brushSelected', update: 'none'},
  45256. function () {}
  45257. );
  45258. /***/ },
  45259. /* 315 */
  45260. /***/ function(module, exports, __webpack_require__) {
  45261. 'use strict';
  45262. var featureManager = __webpack_require__(316);
  45263. var zrUtil = __webpack_require__(4);
  45264. function Brush(model, ecModel, api) {
  45265. this.model = model;
  45266. this.ecModel = ecModel;
  45267. this.api = api;
  45268. /**
  45269. * @private
  45270. * @type {string}
  45271. */
  45272. this._brushType;
  45273. /**
  45274. * @private
  45275. * @type {string}
  45276. */
  45277. this._brushMode;
  45278. }
  45279. Brush.defaultOption = {
  45280. show: true,
  45281. type: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear'],
  45282. icon: {
  45283. rect: 'M7.3,34.7 M0.4,10V-0.2h9.8 M89.6,10V-0.2h-9.8 M0.4,60v10.2h9.8 M89.6,60v10.2h-9.8 M12.3,22.4V10.5h13.1 M33.6,10.5h7.8 M49.1,10.5h7.8 M77.5,22.4V10.5h-13 M12.3,31.1v8.2 M77.7,31.1v8.2 M12.3,47.6v11.9h13.1 M33.6,59.5h7.6 M49.1,59.5 h7.7 M77.5,47.6v11.9h-13', // jshint ignore:line
  45284. polygon: 'M55.2,34.9c1.7,0,3.1,1.4,3.1,3.1s-1.4,3.1-3.1,3.1 s-3.1-1.4-3.1-3.1S53.5,34.9,55.2,34.9z M50.4,51c1.7,0,3.1,1.4,3.1,3.1c0,1.7-1.4,3.1-3.1,3.1c-1.7,0-3.1-1.4-3.1-3.1 C47.3,52.4,48.7,51,50.4,51z M55.6,37.1l1.5-7.8 M60.1,13.5l1.6-8.7l-7.8,4 M59,19l-1,5.3 M24,16.1l6.4,4.9l6.4-3.3 M48.5,11.6 l-5.9,3.1 M19.1,12.8L9.7,5.1l1.1,7.7 M13.4,29.8l1,7.3l6.6,1.6 M11.6,18.4l1,6.1 M32.8,41.9 M26.6,40.4 M27.3,40.2l6.1,1.6 M49.9,52.1l-5.6-7.6l-4.9-1.2', // jshint ignore:line
  45285. lineX: 'M15.2,30 M19.7,15.6V1.9H29 M34.8,1.9H40.4 M55.3,15.6V1.9H45.9 M19.7,44.4V58.1H29 M34.8,58.1H40.4 M55.3,44.4 V58.1H45.9 M12.5,20.3l-9.4,9.6l9.6,9.8 M3.1,29.9h16.5 M62.5,20.3l9.4,9.6L62.3,39.7 M71.9,29.9H55.4', // jshint ignore:line
  45286. lineY: 'M38.8,7.7 M52.7,12h13.2v9 M65.9,26.6V32 M52.7,46.3h13.2v-9 M24.9,12H11.8v9 M11.8,26.6V32 M24.9,46.3H11.8v-9 M48.2,5.1l-9.3-9l-9.4,9.2 M38.9-3.9V12 M48.2,53.3l-9.3,9l-9.4-9.2 M38.9,62.3V46.4', // jshint ignore:line
  45287. keep: 'M4,10.5V1h10.3 M20.7,1h6.1 M33,1h6.1 M55.4,10.5V1H45.2 M4,17.3v6.6 M55.6,17.3v6.6 M4,30.5V40h10.3 M20.7,40 h6.1 M33,40h6.1 M55.4,30.5V40H45.2 M21,18.9h62.9v48.6H21V18.9z', // jshint ignore:line
  45288. clear: 'M22,14.7l30.9,31 M52.9,14.7L22,45.7 M4.7,16.8V4.2h13.1 M26,4.2h7.8 M41.6,4.2h7.8 M70.3,16.8V4.2H57.2 M4.7,25.9v8.6 M70.3,25.9v8.6 M4.7,43.2v12.6h13.1 M26,55.8h7.8 M41.6,55.8h7.8 M70.3,43.2v12.6H57.2' // jshint ignore:line
  45289. },
  45290. title: {
  45291. rect: '矩形选择',
  45292. polygon: '圈选',
  45293. lineX: '横向选择',
  45294. lineY: '纵向选择',
  45295. keep: '保持选择',
  45296. clear: '清除选择'
  45297. }
  45298. };
  45299. var proto = Brush.prototype;
  45300. proto.render =
  45301. proto.updateView =
  45302. proto.updateLayout = function (featureModel, ecModel, api) {
  45303. var brushType;
  45304. var brushMode;
  45305. var isBrushed;
  45306. ecModel.eachComponent({mainType: 'brush'}, function (brushModel) {
  45307. brushType = brushModel.brushType;
  45308. brushMode = brushModel.brushOption.brushMode || 'single';
  45309. isBrushed |= brushModel.areas.length;
  45310. });
  45311. this._brushType = brushType;
  45312. this._brushMode = brushMode;
  45313. zrUtil.each(featureModel.get('type', true), function (type) {
  45314. featureModel.setIconStatus(
  45315. type,
  45316. (
  45317. type === 'keep'
  45318. ? brushMode === 'multiple'
  45319. : type === 'clear'
  45320. ? isBrushed
  45321. : type === brushType
  45322. ) ? 'emphasis' : 'normal'
  45323. );
  45324. });
  45325. };
  45326. proto.getIcons = function () {
  45327. var model = this.model;
  45328. var availableIcons = model.get('icon', true);
  45329. var icons = {};
  45330. zrUtil.each(model.get('type', true), function (type) {
  45331. if (availableIcons[type]) {
  45332. icons[type] = availableIcons[type];
  45333. }
  45334. });
  45335. return icons;
  45336. };
  45337. proto.onclick = function (ecModel, api, type) {
  45338. var api = this.api;
  45339. var brushType = this._brushType;
  45340. var brushMode = this._brushMode;
  45341. if (type === 'clear') {
  45342. api.dispatchAction({
  45343. type: 'brush',
  45344. // Clear all areas of all brush components.
  45345. areas: []
  45346. });
  45347. }
  45348. else {
  45349. api.dispatchAction({
  45350. type: 'takeGlobalCursor',
  45351. key: 'brush',
  45352. brushOption: {
  45353. brushType: type === 'keep'
  45354. ? brushType
  45355. : (brushType === type ? false : type),
  45356. brushMode: type === 'keep'
  45357. ? (brushMode === 'multiple' ? 'single' : 'multiple')
  45358. : brushMode
  45359. }
  45360. });
  45361. }
  45362. };
  45363. featureManager.register('brush', Brush);
  45364. module.exports = Brush;
  45365. /***/ },
  45366. /* 316 */
  45367. /***/ function(module, exports) {
  45368. 'use strict';
  45369. var features = {};
  45370. module.exports = {
  45371. register: function (name, ctor) {
  45372. features[name] = ctor;
  45373. },
  45374. get: function (name) {
  45375. return features[name];
  45376. }
  45377. };
  45378. /***/ },
  45379. /* 317 */
  45380. /***/ function(module, exports, __webpack_require__) {
  45381. 'use strict';
  45382. var echarts = __webpack_require__(1);
  45383. var graphic = __webpack_require__(43);
  45384. var layout = __webpack_require__(21);
  45385. // Model
  45386. echarts.extendComponentModel({
  45387. type: 'title',
  45388. layoutMode: {type: 'box', ignoreSize: true},
  45389. defaultOption: {
  45390. // 一级层叠
  45391. zlevel: 0,
  45392. // 二级层叠
  45393. z: 6,
  45394. show: true,
  45395. text: '',
  45396. // 超链接跳转
  45397. // link: null,
  45398. // 仅支持self | blank
  45399. target: 'blank',
  45400. subtext: '',
  45401. // 超链接跳转
  45402. // sublink: null,
  45403. // 仅支持self | blank
  45404. subtarget: 'blank',
  45405. // 'center' ¦ 'left' ¦ 'right'
  45406. // ¦ {number}(x坐标,单位px)
  45407. left: 0,
  45408. // 'top' ¦ 'bottom' ¦ 'center'
  45409. // ¦ {number}(y坐标,单位px)
  45410. top: 0,
  45411. // 水平对齐
  45412. // 'auto' | 'left' | 'right' | 'center'
  45413. // 默认根据 left 的位置判断是左对齐还是右对齐
  45414. // textAlign: null
  45415. //
  45416. // 垂直对齐
  45417. // 'auto' | 'top' | 'bottom' | 'middle'
  45418. // 默认根据 top 位置判断是上对齐还是下对齐
  45419. // textBaseline: null
  45420. backgroundColor: 'rgba(0,0,0,0)',
  45421. // 标题边框颜色
  45422. borderColor: '#ccc',
  45423. // 标题边框线宽,单位px,默认为0(无边框)
  45424. borderWidth: 0,
  45425. // 标题内边距,单位px,默认各方向内边距为5,
  45426. // 接受数组分别设定上右下左边距,同css
  45427. padding: 5,
  45428. // 主副标题纵向间隔,单位px,默认为10,
  45429. itemGap: 10,
  45430. textStyle: {
  45431. fontSize: 18,
  45432. fontWeight: 'bolder',
  45433. color: '#333'
  45434. },
  45435. subtextStyle: {
  45436. color: '#aaa'
  45437. }
  45438. }
  45439. });
  45440. // View
  45441. echarts.extendComponentView({
  45442. type: 'title',
  45443. render: function (titleModel, ecModel, api) {
  45444. this.group.removeAll();
  45445. if (!titleModel.get('show')) {
  45446. return;
  45447. }
  45448. var group = this.group;
  45449. var textStyleModel = titleModel.getModel('textStyle');
  45450. var subtextStyleModel = titleModel.getModel('subtextStyle');
  45451. var textAlign = titleModel.get('textAlign');
  45452. var textBaseline = titleModel.get('textBaseline');
  45453. var textEl = new graphic.Text({
  45454. style: {
  45455. text: titleModel.get('text'),
  45456. textFont: textStyleModel.getFont(),
  45457. fill: textStyleModel.getTextColor()
  45458. },
  45459. z2: 10
  45460. });
  45461. var textRect = textEl.getBoundingRect();
  45462. var subText = titleModel.get('subtext');
  45463. var subTextEl = new graphic.Text({
  45464. style: {
  45465. text: subText,
  45466. textFont: subtextStyleModel.getFont(),
  45467. fill: subtextStyleModel.getTextColor(),
  45468. y: textRect.height + titleModel.get('itemGap'),
  45469. textBaseline: 'top'
  45470. },
  45471. z2: 10
  45472. });
  45473. var link = titleModel.get('link');
  45474. var sublink = titleModel.get('sublink');
  45475. textEl.silent = !link;
  45476. subTextEl.silent = !sublink;
  45477. if (link) {
  45478. textEl.on('click', function () {
  45479. window.open(link, '_' + titleModel.get('target'));
  45480. });
  45481. }
  45482. if (sublink) {
  45483. subTextEl.on('click', function () {
  45484. window.open(sublink, '_' + titleModel.get('subtarget'));
  45485. });
  45486. }
  45487. group.add(textEl);
  45488. subText && group.add(subTextEl);
  45489. // If no subText, but add subTextEl, there will be an empty line.
  45490. var groupRect = group.getBoundingRect();
  45491. var layoutOption = titleModel.getBoxLayoutParams();
  45492. layoutOption.width = groupRect.width;
  45493. layoutOption.height = groupRect.height;
  45494. var layoutRect = layout.getLayoutRect(
  45495. layoutOption, {
  45496. width: api.getWidth(),
  45497. height: api.getHeight()
  45498. }, titleModel.get('padding')
  45499. );
  45500. // Adjust text align based on position
  45501. if (!textAlign) {
  45502. // Align left if title is on the left. center and right is same
  45503. textAlign = titleModel.get('left') || titleModel.get('right');
  45504. if (textAlign === 'middle') {
  45505. textAlign = 'center';
  45506. }
  45507. // Adjust layout by text align
  45508. if (textAlign === 'right') {
  45509. layoutRect.x += layoutRect.width;
  45510. }
  45511. else if (textAlign === 'center') {
  45512. layoutRect.x += layoutRect.width / 2;
  45513. }
  45514. }
  45515. if (!textBaseline) {
  45516. textBaseline = titleModel.get('top') || titleModel.get('bottom');
  45517. if (textBaseline === 'center') {
  45518. textBaseline = 'middle';
  45519. }
  45520. if (textBaseline === 'bottom') {
  45521. layoutRect.y += layoutRect.height;
  45522. }
  45523. else if (textBaseline === 'middle') {
  45524. layoutRect.y += layoutRect.height / 2;
  45525. }
  45526. textBaseline = textBaseline || 'top';
  45527. }
  45528. group.attr('position', [layoutRect.x, layoutRect.y]);
  45529. var alignStyle = {
  45530. textAlign: textAlign,
  45531. textVerticalAlign: textBaseline
  45532. };
  45533. textEl.setStyle(alignStyle);
  45534. subTextEl.setStyle(alignStyle);
  45535. // Render background
  45536. // Get groupRect again because textAlign has been changed
  45537. groupRect = group.getBoundingRect();
  45538. var padding = layoutRect.margin;
  45539. var style = titleModel.getItemStyle(['color', 'opacity']);
  45540. style.fill = titleModel.get('backgroundColor');
  45541. var rect = new graphic.Rect({
  45542. shape: {
  45543. x: groupRect.x - padding[3],
  45544. y: groupRect.y - padding[0],
  45545. width: groupRect.width + padding[1] + padding[3],
  45546. height: groupRect.height + padding[0] + padding[2]
  45547. },
  45548. style: style,
  45549. silent: true
  45550. });
  45551. graphic.subPixelOptimizeRect(rect);
  45552. group.add(rect);
  45553. }
  45554. });
  45555. /***/ },
  45556. /* 318 */
  45557. /***/ function(module, exports, __webpack_require__) {
  45558. /**
  45559. * DataZoom component entry
  45560. */
  45561. __webpack_require__(319);
  45562. __webpack_require__(320);
  45563. __webpack_require__(323);
  45564. __webpack_require__(324);
  45565. __webpack_require__(325);
  45566. __webpack_require__(327);
  45567. __webpack_require__(328);
  45568. __webpack_require__(330);
  45569. __webpack_require__(331);
  45570. /***/ },
  45571. /* 319 */
  45572. /***/ function(module, exports, __webpack_require__) {
  45573. __webpack_require__(19).registerSubTypeDefaulter('dataZoom', function (option) {
  45574. // Default 'slider' when no type specified.
  45575. return 'slider';
  45576. });
  45577. /***/ },
  45578. /* 320 */
  45579. /***/ function(module, exports, __webpack_require__) {
  45580. /**
  45581. * @file Data zoom model
  45582. */
  45583. var zrUtil = __webpack_require__(4);
  45584. var env = __webpack_require__(2);
  45585. var echarts = __webpack_require__(1);
  45586. var modelUtil = __webpack_require__(5);
  45587. var helper = __webpack_require__(321);
  45588. var AxisProxy = __webpack_require__(322);
  45589. var each = zrUtil.each;
  45590. var eachAxisDim = helper.eachAxisDim;
  45591. var DataZoomModel = echarts.extendComponentModel({
  45592. type: 'dataZoom',
  45593. dependencies: [
  45594. 'xAxis', 'yAxis', 'zAxis', 'radiusAxis', 'angleAxis', 'series'
  45595. ],
  45596. /**
  45597. * @protected
  45598. */
  45599. defaultOption: {
  45600. zlevel: 0,
  45601. z: 4, // Higher than normal component (z: 2).
  45602. orient: null, // Default auto by axisIndex. Possible value: 'horizontal', 'vertical'.
  45603. xAxisIndex: null, // Default the first horizontal category axis.
  45604. yAxisIndex: null, // Default the first vertical category axis.
  45605. filterMode: 'filter', // Possible values: 'filter' or 'empty'.
  45606. // 'filter': data items which are out of window will be removed.
  45607. // This option is applicable when filtering outliers.
  45608. // 'empty': data items which are out of window will be set to empty.
  45609. // This option is applicable when user should not neglect
  45610. // that there are some data items out of window.
  45611. // Taking line chart as an example, line will be broken in
  45612. // the filtered points when filterModel is set to 'empty', but
  45613. // be connected when set to 'filter'.
  45614. throttle: null, // Dispatch action by the fixed rate, avoid frequency.
  45615. // default 100. Do not throttle when use null/undefined.
  45616. // If animation === true and animationDurationUpdate > 0,
  45617. // default value is 100, otherwise 20.
  45618. start: 0, // Start percent. 0 ~ 100
  45619. end: 100, // End percent. 0 ~ 100
  45620. startValue: null, // Start value. If startValue specified, start is ignored.
  45621. endValue: null // End value. If endValue specified, end is ignored.
  45622. },
  45623. /**
  45624. * @override
  45625. */
  45626. init: function (option, parentModel, ecModel) {
  45627. /**
  45628. * key like x_0, y_1
  45629. * @private
  45630. * @type {Object}
  45631. */
  45632. this._dataIntervalByAxis = {};
  45633. /**
  45634. * @private
  45635. */
  45636. this._dataInfo = {};
  45637. /**
  45638. * key like x_0, y_1
  45639. * @private
  45640. */
  45641. this._axisProxies = {};
  45642. /**
  45643. * @readOnly
  45644. */
  45645. this.textStyleModel;
  45646. /**
  45647. * @private
  45648. */
  45649. this._autoThrottle = true;
  45650. var rawOption = retrieveRaw(option);
  45651. this.mergeDefaultAndTheme(option, ecModel);
  45652. this.doInit(rawOption);
  45653. },
  45654. /**
  45655. * @override
  45656. */
  45657. mergeOption: function (newOption) {
  45658. var rawOption = retrieveRaw(newOption);
  45659. //FIX #2591
  45660. zrUtil.merge(this.option, newOption, true);
  45661. this.doInit(rawOption);
  45662. },
  45663. /**
  45664. * @protected
  45665. */
  45666. doInit: function (rawOption) {
  45667. var thisOption = this.option;
  45668. // Disable realtime view update if canvas is not supported.
  45669. if (!env.canvasSupported) {
  45670. thisOption.realtime = false;
  45671. }
  45672. this._setDefaultThrottle(rawOption);
  45673. processRangeProp('start', 'startValue', rawOption, thisOption);
  45674. processRangeProp('end', 'endValue', rawOption, thisOption);
  45675. this.textStyleModel = this.getModel('textStyle');
  45676. this._resetTarget();
  45677. this._giveAxisProxies();
  45678. },
  45679. /**
  45680. * @private
  45681. */
  45682. _giveAxisProxies: function () {
  45683. var axisProxies = this._axisProxies;
  45684. this.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel, ecModel) {
  45685. var axisModel = this.dependentModels[dimNames.axis][axisIndex];
  45686. // If exists, share axisProxy with other dataZoomModels.
  45687. var axisProxy = axisModel.__dzAxisProxy || (
  45688. // Use the first dataZoomModel as the main model of axisProxy.
  45689. axisModel.__dzAxisProxy = new AxisProxy(
  45690. dimNames.name, axisIndex, this, ecModel
  45691. )
  45692. );
  45693. // FIXME
  45694. // dispose __dzAxisProxy
  45695. axisProxies[dimNames.name + '_' + axisIndex] = axisProxy;
  45696. }, this);
  45697. },
  45698. /**
  45699. * @private
  45700. */
  45701. _resetTarget: function () {
  45702. var thisOption = this.option;
  45703. var autoMode = this._judgeAutoMode();
  45704. eachAxisDim(function (dimNames) {
  45705. var axisIndexName = dimNames.axisIndex;
  45706. thisOption[axisIndexName] = modelUtil.normalizeToArray(
  45707. thisOption[axisIndexName]
  45708. );
  45709. }, this);
  45710. if (autoMode === 'axisIndex') {
  45711. this._autoSetAxisIndex();
  45712. }
  45713. else if (autoMode === 'orient') {
  45714. this._autoSetOrient();
  45715. }
  45716. },
  45717. /**
  45718. * @private
  45719. */
  45720. _judgeAutoMode: function () {
  45721. // Auto set only works for setOption at the first time.
  45722. // The following is user's reponsibility. So using merged
  45723. // option is OK.
  45724. var thisOption = this.option;
  45725. var hasIndexSpecified = false;
  45726. eachAxisDim(function (dimNames) {
  45727. // When user set axisIndex as a empty array, we think that user specify axisIndex
  45728. // but do not want use auto mode. Because empty array may be encountered when
  45729. // some error occured.
  45730. if (thisOption[dimNames.axisIndex] != null) {
  45731. hasIndexSpecified = true;
  45732. }
  45733. }, this);
  45734. var orient = thisOption.orient;
  45735. if (orient == null && hasIndexSpecified) {
  45736. return 'orient';
  45737. }
  45738. else if (!hasIndexSpecified) {
  45739. if (orient == null) {
  45740. thisOption.orient = 'horizontal';
  45741. }
  45742. return 'axisIndex';
  45743. }
  45744. },
  45745. /**
  45746. * @private
  45747. */
  45748. _autoSetAxisIndex: function () {
  45749. var autoAxisIndex = true;
  45750. var orient = this.get('orient', true);
  45751. var thisOption = this.option;
  45752. if (autoAxisIndex) {
  45753. // Find axis that parallel to dataZoom as default.
  45754. var dimNames = orient === 'vertical'
  45755. ? {dim: 'y', axisIndex: 'yAxisIndex', axis: 'yAxis'}
  45756. : {dim: 'x', axisIndex: 'xAxisIndex', axis: 'xAxis'};
  45757. if (this.dependentModels[dimNames.axis].length) {
  45758. thisOption[dimNames.axisIndex] = [0];
  45759. autoAxisIndex = false;
  45760. }
  45761. }
  45762. if (autoAxisIndex) {
  45763. // Find the first category axis as default. (consider polar)
  45764. eachAxisDim(function (dimNames) {
  45765. if (!autoAxisIndex) {
  45766. return;
  45767. }
  45768. var axisIndices = [];
  45769. var axisModels = this.dependentModels[dimNames.axis];
  45770. if (axisModels.length && !axisIndices.length) {
  45771. for (var i = 0, len = axisModels.length; i < len; i++) {
  45772. if (axisModels[i].get('type') === 'category') {
  45773. axisIndices.push(i);
  45774. }
  45775. }
  45776. }
  45777. thisOption[dimNames.axisIndex] = axisIndices;
  45778. if (axisIndices.length) {
  45779. autoAxisIndex = false;
  45780. }
  45781. }, this);
  45782. }
  45783. if (autoAxisIndex) {
  45784. // FIXME
  45785. // 这里是兼容ec2的写法(没指定xAxisIndex和yAxisIndex时把scatter和双数值轴折柱纳入dataZoom控制),
  45786. // 但是实际是否需要Grid.js#getScaleByOption来判断(考虑time,log等axis type)?
  45787. // If both dataZoom.xAxisIndex and dataZoom.yAxisIndex is not specified,
  45788. // dataZoom component auto adopts series that reference to
  45789. // both xAxis and yAxis which type is 'value'.
  45790. this.ecModel.eachSeries(function (seriesModel) {
  45791. if (this._isSeriesHasAllAxesTypeOf(seriesModel, 'value')) {
  45792. eachAxisDim(function (dimNames) {
  45793. var axisIndices = thisOption[dimNames.axisIndex];
  45794. var axisIndex = seriesModel.get(dimNames.axisIndex);
  45795. var axisId = seriesModel.get(dimNames.axisId);
  45796. var axisModel = seriesModel.ecModel.queryComponents({
  45797. mainType: dimNames.axis,
  45798. index: axisIndex,
  45799. id: axisId
  45800. })[0];
  45801. if (true) {
  45802. if (!axisModel) {
  45803. throw new Error(
  45804. dimNames.axis + ' "' + zrUtil.retrieve(
  45805. axisIndex,
  45806. axisId,
  45807. 0
  45808. ) + '" not found'
  45809. );
  45810. }
  45811. }
  45812. axisIndex = axisModel.componentIndex;
  45813. if (zrUtil.indexOf(axisIndices, axisIndex) < 0) {
  45814. axisIndices.push(axisIndex);
  45815. }
  45816. });
  45817. }
  45818. }, this);
  45819. }
  45820. },
  45821. /**
  45822. * @private
  45823. */
  45824. _autoSetOrient: function () {
  45825. var dim;
  45826. // Find the first axis
  45827. this.eachTargetAxis(function (dimNames) {
  45828. !dim && (dim = dimNames.name);
  45829. }, this);
  45830. this.option.orient = dim === 'y' ? 'vertical' : 'horizontal';
  45831. },
  45832. /**
  45833. * @private
  45834. */
  45835. _isSeriesHasAllAxesTypeOf: function (seriesModel, axisType) {
  45836. // FIXME
  45837. // 需要series的xAxisIndex和yAxisIndex都首先自动设置上。
  45838. // 例如series.type === scatter时。
  45839. var is = true;
  45840. eachAxisDim(function (dimNames) {
  45841. var seriesAxisIndex = seriesModel.get(dimNames.axisIndex);
  45842. var axisModel = this.dependentModels[dimNames.axis][seriesAxisIndex];
  45843. if (!axisModel || axisModel.get('type') !== axisType) {
  45844. is = false;
  45845. }
  45846. }, this);
  45847. return is;
  45848. },
  45849. /**
  45850. * @private
  45851. */
  45852. _setDefaultThrottle: function (rawOption) {
  45853. // When first time user set throttle, auto throttle ends.
  45854. if (rawOption.hasOwnProperty('throttle')) {
  45855. this._autoThrottle = false;
  45856. }
  45857. if (this._autoThrottle) {
  45858. var globalOption = this.ecModel.option;
  45859. this.option.throttle =
  45860. (globalOption.animation && globalOption.animationDurationUpdate > 0)
  45861. ? 100 : 20;
  45862. }
  45863. },
  45864. /**
  45865. * @public
  45866. */
  45867. getFirstTargetAxisModel: function () {
  45868. var firstAxisModel;
  45869. eachAxisDim(function (dimNames) {
  45870. if (firstAxisModel == null) {
  45871. var indices = this.get(dimNames.axisIndex);
  45872. if (indices.length) {
  45873. firstAxisModel = this.dependentModels[dimNames.axis][indices[0]];
  45874. }
  45875. }
  45876. }, this);
  45877. return firstAxisModel;
  45878. },
  45879. /**
  45880. * @public
  45881. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  45882. */
  45883. eachTargetAxis: function (callback, context) {
  45884. var ecModel = this.ecModel;
  45885. eachAxisDim(function (dimNames) {
  45886. each(
  45887. this.get(dimNames.axisIndex),
  45888. function (axisIndex) {
  45889. callback.call(context, dimNames, axisIndex, this, ecModel);
  45890. },
  45891. this
  45892. );
  45893. }, this);
  45894. },
  45895. getAxisProxy: function (dimName, axisIndex) {
  45896. return this._axisProxies[dimName + '_' + axisIndex];
  45897. },
  45898. /**
  45899. * If not specified, set to undefined.
  45900. *
  45901. * @public
  45902. * @param {Object} opt
  45903. * @param {number} [opt.start]
  45904. * @param {number} [opt.end]
  45905. * @param {number} [opt.startValue]
  45906. * @param {number} [opt.endValue]
  45907. */
  45908. setRawRange: function (opt) {
  45909. each(['start', 'end', 'startValue', 'endValue'], function (name) {
  45910. // If any of those prop is null/undefined, we should alos set
  45911. // them, because only one pair between start/end and
  45912. // startValue/endValue can work.
  45913. this.option[name] = opt[name];
  45914. }, this);
  45915. },
  45916. /**
  45917. * @public
  45918. * @return {Array.<number>} [startPercent, endPercent]
  45919. */
  45920. getPercentRange: function () {
  45921. var axisProxy = this.findRepresentativeAxisProxy();
  45922. if (axisProxy) {
  45923. return axisProxy.getDataPercentWindow();
  45924. }
  45925. },
  45926. /**
  45927. * @public
  45928. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  45929. *
  45930. * @param {string} [axisDimName]
  45931. * @param {number} [axisIndex]
  45932. * @return {Array.<number>} [startValue, endValue]
  45933. */
  45934. getValueRange: function (axisDimName, axisIndex) {
  45935. if (axisDimName == null && axisIndex == null) {
  45936. var axisProxy = this.findRepresentativeAxisProxy();
  45937. if (axisProxy) {
  45938. return axisProxy.getDataValueWindow();
  45939. }
  45940. }
  45941. else {
  45942. return this.getAxisProxy(axisDimName, axisIndex).getDataValueWindow();
  45943. }
  45944. },
  45945. /**
  45946. * @public
  45947. * @return {module:echarts/component/dataZoom/AxisProxy}
  45948. */
  45949. findRepresentativeAxisProxy: function () {
  45950. // Find the first hosted axisProxy
  45951. var axisProxies = this._axisProxies;
  45952. for (var key in axisProxies) {
  45953. if (axisProxies.hasOwnProperty(key) && axisProxies[key].hostedBy(this)) {
  45954. return axisProxies[key];
  45955. }
  45956. }
  45957. // If no hosted axis find not hosted axisProxy.
  45958. // Consider this case: dataZoomModel1 and dataZoomModel2 control the same axis,
  45959. // and the option.start or option.end settings are different. The percentRange
  45960. // should follow axisProxy.
  45961. // (We encounter this problem in toolbox data zoom.)
  45962. for (var key in axisProxies) {
  45963. if (axisProxies.hasOwnProperty(key) && !axisProxies[key].hostedBy(this)) {
  45964. return axisProxies[key];
  45965. }
  45966. }
  45967. }
  45968. });
  45969. function retrieveRaw(option) {
  45970. var ret = {};
  45971. each(
  45972. ['start', 'end', 'startValue', 'endValue', 'throttle'],
  45973. function (name) {
  45974. option.hasOwnProperty(name) && (ret[name] = option[name]);
  45975. }
  45976. );
  45977. return ret;
  45978. }
  45979. function processRangeProp(percentProp, valueProp, rawOption, thisOption) {
  45980. // start/end has higher priority over startValue/endValue,
  45981. // but we should make chart.setOption({endValue: 1000}) effective,
  45982. // rather than chart.setOption({endValue: 1000, end: null}).
  45983. if (rawOption[valueProp] != null && rawOption[percentProp] == null) {
  45984. thisOption[percentProp] = null;
  45985. }
  45986. // Otherwise do nothing and use the merge result.
  45987. }
  45988. module.exports = DataZoomModel;
  45989. /***/ },
  45990. /* 321 */
  45991. /***/ function(module, exports, __webpack_require__) {
  45992. var formatUtil = __webpack_require__(6);
  45993. var zrUtil = __webpack_require__(4);
  45994. var helper = {};
  45995. var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle'];
  45996. /**
  45997. * Create "each" method to iterate names.
  45998. *
  45999. * @pubilc
  46000. * @param {Array.<string>} names
  46001. * @param {Array.<string>=} attrs
  46002. * @return {Function}
  46003. */
  46004. helper.createNameEach = function (names, attrs) {
  46005. names = names.slice();
  46006. var capitalNames = zrUtil.map(names, formatUtil.capitalFirst);
  46007. attrs = (attrs || []).slice();
  46008. var capitalAttrs = zrUtil.map(attrs, formatUtil.capitalFirst);
  46009. return function (callback, context) {
  46010. zrUtil.each(names, function (name, index) {
  46011. var nameObj = {name: name, capital: capitalNames[index]};
  46012. for (var j = 0; j < attrs.length; j++) {
  46013. nameObj[attrs[j]] = name + capitalAttrs[j];
  46014. }
  46015. callback.call(context, nameObj);
  46016. });
  46017. };
  46018. };
  46019. /**
  46020. * Iterate each dimension name.
  46021. *
  46022. * @public
  46023. * @param {Function} callback The parameter is like:
  46024. * {
  46025. * name: 'angle',
  46026. * capital: 'Angle',
  46027. * axis: 'angleAxis',
  46028. * axisIndex: 'angleAixs',
  46029. * index: 'angleIndex'
  46030. * }
  46031. * @param {Object} context
  46032. */
  46033. helper.eachAxisDim = helper.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index', 'id']);
  46034. /**
  46035. * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'.
  46036. * dataZoomModels and 'links' make up one or more graphics.
  46037. * This function finds the graphic where the source dataZoomModel is in.
  46038. *
  46039. * @public
  46040. * @param {Function} forEachNode Node iterator.
  46041. * @param {Function} forEachEdgeType edgeType iterator
  46042. * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id.
  46043. * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}}
  46044. */
  46045. helper.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
  46046. return function (sourceNode) {
  46047. var result = {
  46048. nodes: [],
  46049. records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean).
  46050. };
  46051. forEachEdgeType(function (edgeType) {
  46052. result.records[edgeType.name] = {};
  46053. });
  46054. if (!sourceNode) {
  46055. return result;
  46056. }
  46057. absorb(sourceNode, result);
  46058. var existsLink;
  46059. do {
  46060. existsLink = false;
  46061. forEachNode(processSingleNode);
  46062. }
  46063. while (existsLink);
  46064. function processSingleNode(node) {
  46065. if (!isNodeAbsorded(node, result) && isLinked(node, result)) {
  46066. absorb(node, result);
  46067. existsLink = true;
  46068. }
  46069. }
  46070. return result;
  46071. };
  46072. function isNodeAbsorded(node, result) {
  46073. return zrUtil.indexOf(result.nodes, node) >= 0;
  46074. }
  46075. function isLinked(node, result) {
  46076. var hasLink = false;
  46077. forEachEdgeType(function (edgeType) {
  46078. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  46079. result.records[edgeType.name][edgeId] && (hasLink = true);
  46080. });
  46081. });
  46082. return hasLink;
  46083. }
  46084. function absorb(node, result) {
  46085. result.nodes.push(node);
  46086. forEachEdgeType(function (edgeType) {
  46087. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  46088. result.records[edgeType.name][edgeId] = true;
  46089. });
  46090. });
  46091. }
  46092. };
  46093. module.exports = helper;
  46094. /***/ },
  46095. /* 322 */
  46096. /***/ function(module, exports, __webpack_require__) {
  46097. /**
  46098. * @file Axis operator
  46099. */
  46100. var zrUtil = __webpack_require__(4);
  46101. var numberUtil = __webpack_require__(7);
  46102. var each = zrUtil.each;
  46103. var asc = numberUtil.asc;
  46104. /**
  46105. * Operate single axis.
  46106. * One axis can only operated by one axis operator.
  46107. * Different dataZoomModels may be defined to operate the same axis.
  46108. * (i.e. 'inside' data zoom and 'slider' data zoom components)
  46109. * So dataZoomModels share one axisProxy in that case.
  46110. *
  46111. * @class
  46112. */
  46113. var AxisProxy = function (dimName, axisIndex, dataZoomModel, ecModel) {
  46114. /**
  46115. * @private
  46116. * @type {string}
  46117. */
  46118. this._dimName = dimName;
  46119. /**
  46120. * @private
  46121. */
  46122. this._axisIndex = axisIndex;
  46123. /**
  46124. * @private
  46125. * @type {Array.<number>}
  46126. */
  46127. this._valueWindow;
  46128. /**
  46129. * @private
  46130. * @type {Array.<number>}
  46131. */
  46132. this._percentWindow;
  46133. /**
  46134. * @private
  46135. * @type {Array.<number>}
  46136. */
  46137. this._dataExtent;
  46138. /**
  46139. * @readOnly
  46140. * @type {module: echarts/model/Global}
  46141. */
  46142. this.ecModel = ecModel;
  46143. /**
  46144. * @private
  46145. * @type {module: echarts/component/dataZoom/DataZoomModel}
  46146. */
  46147. this._dataZoomModel = dataZoomModel;
  46148. };
  46149. AxisProxy.prototype = {
  46150. constructor: AxisProxy,
  46151. /**
  46152. * Whether the axisProxy is hosted by dataZoomModel.
  46153. *
  46154. * @public
  46155. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  46156. * @return {boolean}
  46157. */
  46158. hostedBy: function (dataZoomModel) {
  46159. return this._dataZoomModel === dataZoomModel;
  46160. },
  46161. /**
  46162. * @return {Array.<number>}
  46163. */
  46164. getDataExtent: function () {
  46165. return this._dataExtent.slice();
  46166. },
  46167. /**
  46168. * @return {Array.<number>}
  46169. */
  46170. getDataValueWindow: function () {
  46171. return this._valueWindow.slice();
  46172. },
  46173. /**
  46174. * @return {Array.<number>}
  46175. */
  46176. getDataPercentWindow: function () {
  46177. return this._percentWindow.slice();
  46178. },
  46179. /**
  46180. * @public
  46181. * @param {number} axisIndex
  46182. * @return {Array} seriesModels
  46183. */
  46184. getTargetSeriesModels: function () {
  46185. var seriesModels = [];
  46186. var ecModel = this.ecModel;
  46187. ecModel.eachSeries(function (seriesModel) {
  46188. var coordSysName = seriesModel.get('coordinateSystem');
  46189. if (coordSysName === 'cartesian2d' || coordSysName === 'polar') {
  46190. var dimName = this._dimName;
  46191. var axisModel = ecModel.queryComponents({
  46192. mainType: dimName + 'Axis',
  46193. index: seriesModel.get(dimName + 'AxisIndex'),
  46194. id: seriesModel.get(dimName + 'AxisId')
  46195. })[0];
  46196. if (this._axisIndex === (axisModel && axisModel.componentIndex)) {
  46197. seriesModels.push(seriesModel);
  46198. }
  46199. }
  46200. }, this);
  46201. return seriesModels;
  46202. },
  46203. getAxisModel: function () {
  46204. return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex);
  46205. },
  46206. getOtherAxisModel: function () {
  46207. var axisDim = this._dimName;
  46208. var ecModel = this.ecModel;
  46209. var axisModel = this.getAxisModel();
  46210. var isCartesian = axisDim === 'x' || axisDim === 'y';
  46211. var otherAxisDim;
  46212. var coordSysIndexName;
  46213. if (isCartesian) {
  46214. coordSysIndexName = 'gridIndex';
  46215. otherAxisDim = axisDim === 'x' ? 'y' : 'x';
  46216. }
  46217. else {
  46218. coordSysIndexName = 'polarIndex';
  46219. otherAxisDim = axisDim === 'angle' ? 'radius' : 'angle';
  46220. }
  46221. var foundOtherAxisModel;
  46222. ecModel.eachComponent(otherAxisDim + 'Axis', function (otherAxisModel) {
  46223. if ((otherAxisModel.get(coordSysIndexName) || 0)
  46224. === (axisModel.get(coordSysIndexName) || 0)
  46225. ) {
  46226. foundOtherAxisModel = otherAxisModel;
  46227. }
  46228. });
  46229. return foundOtherAxisModel;
  46230. },
  46231. /**
  46232. * Only calculate by given range and dataExtent, do not change anything.
  46233. *
  46234. * @param {Object} opt
  46235. * @param {number} [opt.start]
  46236. * @param {number} [opt.end]
  46237. * @param {number} [opt.startValue]
  46238. * @param {number} [opt.endValue]
  46239. * @param {Array.<number>} dataExtent
  46240. */
  46241. calculateDataWindow: function (opt, dataExtent) {
  46242. var axisModel = this.getAxisModel();
  46243. var scale = axisModel.axis.scale;
  46244. var percentExtent = [0, 100];
  46245. var percentWindow = [
  46246. opt.start,
  46247. opt.end
  46248. ];
  46249. var valueWindow = [];
  46250. // In percent range is used and axis min/max/scale is set,
  46251. // window should be based on min/max/0, but should not be
  46252. // based on the extent of filtered data.
  46253. dataExtent = dataExtent.slice();
  46254. fixExtendByAxis(dataExtent, axisModel, scale);
  46255. each(['startValue', 'endValue'], function (prop) {
  46256. valueWindow.push(
  46257. opt[prop] != null
  46258. ? scale.parse(opt[prop])
  46259. : null
  46260. );
  46261. });
  46262. // Normalize bound.
  46263. each([0, 1], function (idx) {
  46264. var boundValue = valueWindow[idx];
  46265. var boundPercent = percentWindow[idx];
  46266. // start/end has higher priority over startValue/endValue,
  46267. // because start/end can be consistent among different type
  46268. // of axis but startValue/endValue not.
  46269. if (boundPercent != null || boundValue == null) {
  46270. if (boundPercent == null) {
  46271. boundPercent = percentExtent[idx];
  46272. }
  46273. // Use scale.parse to math round for category or time axis.
  46274. boundValue = scale.parse(numberUtil.linearMap(
  46275. boundPercent, percentExtent, dataExtent, true
  46276. ));
  46277. }
  46278. else { // boundPercent == null && boundValue != null
  46279. boundPercent = numberUtil.linearMap(
  46280. boundValue, dataExtent, percentExtent, true
  46281. );
  46282. }
  46283. // valueWindow[idx] = round(boundValue);
  46284. // percentWindow[idx] = round(boundPercent);
  46285. valueWindow[idx] = boundValue;
  46286. percentWindow[idx] = boundPercent;
  46287. });
  46288. return {
  46289. valueWindow: asc(valueWindow),
  46290. percentWindow: asc(percentWindow)
  46291. };
  46292. },
  46293. /**
  46294. * Notice: reset should not be called before series.restoreData() called,
  46295. * so it is recommanded to be called in "process stage" but not "model init
  46296. * stage".
  46297. *
  46298. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  46299. */
  46300. reset: function (dataZoomModel) {
  46301. if (dataZoomModel !== this._dataZoomModel) {
  46302. return;
  46303. }
  46304. // Culculate data window and data extent, and record them.
  46305. var dataExtent = this._dataExtent = calculateDataExtent(
  46306. this._dimName, this.getTargetSeriesModels()
  46307. );
  46308. var dataWindow = this.calculateDataWindow(dataZoomModel.option, dataExtent);
  46309. this._valueWindow = dataWindow.valueWindow;
  46310. this._percentWindow = dataWindow.percentWindow;
  46311. // Update axis setting then.
  46312. setAxisModel(this);
  46313. },
  46314. /**
  46315. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  46316. */
  46317. restore: function (dataZoomModel) {
  46318. if (dataZoomModel !== this._dataZoomModel) {
  46319. return;
  46320. }
  46321. this._valueWindow = this._percentWindow = null;
  46322. setAxisModel(this, true);
  46323. },
  46324. /**
  46325. * @param {module: echarts/component/dataZoom/DataZoomModel} dataZoomModel
  46326. */
  46327. filterData: function (dataZoomModel) {
  46328. if (dataZoomModel !== this._dataZoomModel) {
  46329. return;
  46330. }
  46331. var axisDim = this._dimName;
  46332. var seriesModels = this.getTargetSeriesModels();
  46333. var filterMode = dataZoomModel.get('filterMode');
  46334. var valueWindow = this._valueWindow;
  46335. // FIXME
  46336. // Toolbox may has dataZoom injected. And if there are stacked bar chart
  46337. // with NaN data, NaN will be filtered and stack will be wrong.
  46338. // So we need to force the mode to be set empty.
  46339. // In fect, it is not a big deal that do not support filterMode-'filter'
  46340. // when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
  46341. // selection" some day, which might need "adapt to data extent on the
  46342. // otherAxis", which is disabled by filterMode-'empty'.
  46343. var otherAxisModel = this.getOtherAxisModel();
  46344. if (dataZoomModel.get('$fromToolbox')
  46345. && otherAxisModel
  46346. && otherAxisModel.get('type') === 'category'
  46347. ) {
  46348. filterMode = 'empty';
  46349. }
  46350. // Process series data
  46351. each(seriesModels, function (seriesModel) {
  46352. var seriesData = seriesModel.getData();
  46353. seriesData && each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  46354. if (filterMode === 'empty') {
  46355. seriesModel.setData(
  46356. seriesData.map(dim, function (value) {
  46357. return !isInWindow(value) ? NaN : value;
  46358. })
  46359. );
  46360. }
  46361. else {
  46362. seriesData.filterSelf(dim, isInWindow);
  46363. }
  46364. });
  46365. });
  46366. function isInWindow(value) {
  46367. return value >= valueWindow[0] && value <= valueWindow[1];
  46368. }
  46369. }
  46370. };
  46371. function calculateDataExtent(axisDim, seriesModels) {
  46372. var dataExtent = [Infinity, -Infinity];
  46373. each(seriesModels, function (seriesModel) {
  46374. var seriesData = seriesModel.getData();
  46375. if (seriesData) {
  46376. each(seriesModel.coordDimToDataDim(axisDim), function (dim) {
  46377. var seriesExtent = seriesData.getDataExtent(dim);
  46378. seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]);
  46379. seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]);
  46380. });
  46381. }
  46382. }, this);
  46383. return dataExtent;
  46384. }
  46385. function fixExtendByAxis(dataExtent, axisModel, scale) {
  46386. each(['min', 'max'], function (minMax, index) {
  46387. var axisMax = axisModel.get(minMax, true);
  46388. // Consider 'dataMin', 'dataMax'
  46389. if (axisMax != null && (axisMax + '').toLowerCase() !== 'data' + minMax) {
  46390. dataExtent[index] = scale.parse(axisMax);
  46391. }
  46392. });
  46393. if (!axisModel.get('scale', true)) {
  46394. dataExtent[0] > 0 && (dataExtent[0] = 0);
  46395. dataExtent[1] < 0 && (dataExtent[1] = 0);
  46396. }
  46397. return dataExtent;
  46398. }
  46399. function setAxisModel(axisProxy, isRestore) {
  46400. var axisModel = axisProxy.getAxisModel();
  46401. var percentWindow = axisProxy._percentWindow;
  46402. var valueWindow = axisProxy._valueWindow;
  46403. if (!percentWindow) {
  46404. return;
  46405. }
  46406. var isFull = isRestore || (percentWindow[0] === 0 && percentWindow[1] === 100);
  46407. // [0, 500]: arbitrary value, guess axis extent.
  46408. var precision = !isRestore && numberUtil.getPixelPrecision(valueWindow, [0, 500]);
  46409. // toFixed() digits argument must be between 0 and 20
  46410. var invalidPrecision = !isRestore && !(precision < 20 && precision >= 0);
  46411. var useOrigin = isRestore || isFull || invalidPrecision;
  46412. axisModel.setRange && axisModel.setRange(
  46413. useOrigin ? null : +valueWindow[0].toFixed(precision),
  46414. useOrigin ? null : +valueWindow[1].toFixed(precision)
  46415. );
  46416. }
  46417. module.exports = AxisProxy;
  46418. /***/ },
  46419. /* 323 */
  46420. /***/ function(module, exports, __webpack_require__) {
  46421. var ComponentView = __webpack_require__(29);
  46422. module.exports = ComponentView.extend({
  46423. type: 'dataZoom',
  46424. render: function (dataZoomModel, ecModel, api, payload) {
  46425. this.dataZoomModel = dataZoomModel;
  46426. this.ecModel = ecModel;
  46427. this.api = api;
  46428. },
  46429. /**
  46430. * Find the first target coordinate system.
  46431. *
  46432. * @protected
  46433. * @return {Object} {
  46434. * cartesians: [
  46435. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  46436. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  46437. * ...
  46438. * ], // cartesians must not be null/undefined.
  46439. * polars: [
  46440. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  46441. * ...
  46442. * ], // polars must not be null/undefined.
  46443. * axisModels: [axis0, axis1, axis2, axis3, axis4]
  46444. * // axisModels must not be null/undefined.
  46445. * }
  46446. */
  46447. getTargetInfo: function () {
  46448. var dataZoomModel = this.dataZoomModel;
  46449. var ecModel = this.ecModel;
  46450. var cartesians = [];
  46451. var polars = [];
  46452. var axisModels = [];
  46453. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  46454. var axisModel = ecModel.getComponent(dimNames.axis, axisIndex);
  46455. if (axisModel) {
  46456. axisModels.push(axisModel);
  46457. var coordSysName;
  46458. var axisName = dimNames.axis;
  46459. if (axisName === 'xAxis' || axisName === 'yAxis') {
  46460. coordSysName = 'grid';
  46461. }
  46462. else if (axisName === 'angleAxis' || axisName === 'radiusAxis') {
  46463. coordSysName = 'polar';
  46464. }
  46465. var coordModel = coordSysName
  46466. ? ecModel.queryComponents({
  46467. mainType: coordSysName,
  46468. index: axisModel.get(coordSysName + 'Index'),
  46469. id: axisModel.get(coordSysName + 'Id')
  46470. })[0]
  46471. : null;
  46472. if (coordModel != null) {
  46473. save(
  46474. coordModel,
  46475. axisModel,
  46476. coordSysName === 'grid' ? cartesians : polars,
  46477. coordModel.componentIndex
  46478. );
  46479. }
  46480. }
  46481. }, this);
  46482. function save(coordModel, axisModel, store, coordIndex) {
  46483. var item;
  46484. for (var i = 0; i < store.length; i++) {
  46485. if (store[i].model === coordModel) {
  46486. item = store[i];
  46487. break;
  46488. }
  46489. }
  46490. if (!item) {
  46491. store.push(item = {
  46492. model: coordModel, axisModels: [], coordIndex: coordIndex
  46493. });
  46494. }
  46495. item.axisModels.push(axisModel);
  46496. }
  46497. return {
  46498. cartesians: cartesians,
  46499. polars: polars,
  46500. axisModels: axisModels
  46501. };
  46502. }
  46503. });
  46504. /***/ },
  46505. /* 324 */
  46506. /***/ function(module, exports, __webpack_require__) {
  46507. /**
  46508. * @file Data zoom model
  46509. */
  46510. var DataZoomModel = __webpack_require__(320);
  46511. var SliderZoomModel = DataZoomModel.extend({
  46512. type: 'dataZoom.slider',
  46513. layoutMode: 'box',
  46514. /**
  46515. * @protected
  46516. */
  46517. defaultOption: {
  46518. show: true,
  46519. // ph => placeholder. Using placehoder here because
  46520. // deault value can only be drived in view stage.
  46521. right: 'ph', // Default align to grid rect.
  46522. top: 'ph', // Default align to grid rect.
  46523. width: 'ph', // Default align to grid rect.
  46524. height: 'ph', // Default align to grid rect.
  46525. left: null, // Default align to grid rect.
  46526. bottom: null, // Default align to grid rect.
  46527. backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component.
  46528. // dataBackgroundColor: '#ddd', // Background coor of data shadow and border of box,
  46529. // highest priority, remain for compatibility of
  46530. // previous version, but not recommended any more.
  46531. dataBackground: {
  46532. lineStyle: {
  46533. color: '#2f4554',
  46534. width: 0.5,
  46535. opacity: 0.3
  46536. },
  46537. areaStyle: {
  46538. color: 'rgba(47,69,84,0.3)',
  46539. opacity: 0.3
  46540. }
  46541. },
  46542. borderColor: '#ddd', // border color of the box. For compatibility,
  46543. // if dataBackgroundColor is set, borderColor
  46544. // is ignored.
  46545. fillerColor: 'rgba(167,183,204,0.4)', // Color of selected area.
  46546. // handleColor: 'rgba(89,170,216,0.95)', // Color of handle.
  46547. // handleIcon: 'path://M4.9,17.8c0-1.4,4.5-10.5,5.5-12.4c0-0.1,0.6-1.1,0.9-1.1c0.4,0,0.9,1,0.9,1.1c1.1,2.2,5.4,11,5.4,12.4v17.8c0,1.5-0.6,2.1-1.3,2.1H6.1c-0.7,0-1.3-0.6-1.3-2.1V17.8z',
  46548. handleIcon: 'M8.2,13.6V3.9H6.3v9.7H3.1v14.9h3.3v9.7h1.8v-9.7h3.3V13.6H8.2z M9.7,24.4H4.8v-1.4h4.9V24.4z M9.7,19.1H4.8v-1.4h4.9V19.1z',
  46549. // Percent of the slider height
  46550. handleSize: '100%',
  46551. handleStyle: {
  46552. color: '#a7b7cc'
  46553. },
  46554. labelPrecision: null,
  46555. labelFormatter: null,
  46556. showDetail: true,
  46557. showDataShadow: 'auto', // Default auto decision.
  46558. realtime: true,
  46559. zoomLock: false, // Whether disable zoom.
  46560. textStyle: {
  46561. color: '#333'
  46562. }
  46563. }
  46564. });
  46565. module.exports = SliderZoomModel;
  46566. /***/ },
  46567. /* 325 */
  46568. /***/ function(module, exports, __webpack_require__) {
  46569. var zrUtil = __webpack_require__(4);
  46570. var graphic = __webpack_require__(43);
  46571. var throttle = __webpack_require__(81);
  46572. var DataZoomView = __webpack_require__(323);
  46573. var Rect = graphic.Rect;
  46574. var numberUtil = __webpack_require__(7);
  46575. var linearMap = numberUtil.linearMap;
  46576. var layout = __webpack_require__(21);
  46577. var sliderMove = __webpack_require__(326);
  46578. var asc = numberUtil.asc;
  46579. var bind = zrUtil.bind;
  46580. // var mathMax = Math.max;
  46581. var each = zrUtil.each;
  46582. // Constants
  46583. var DEFAULT_LOCATION_EDGE_GAP = 7;
  46584. var DEFAULT_FRAME_BORDER_WIDTH = 1;
  46585. var DEFAULT_FILLER_SIZE = 30;
  46586. var HORIZONTAL = 'horizontal';
  46587. var VERTICAL = 'vertical';
  46588. var LABEL_GAP = 5;
  46589. var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter'];
  46590. var SliderZoomView = DataZoomView.extend({
  46591. type: 'dataZoom.slider',
  46592. init: function (ecModel, api) {
  46593. /**
  46594. * @private
  46595. * @type {Object}
  46596. */
  46597. this._displayables = {};
  46598. /**
  46599. * @private
  46600. * @type {string}
  46601. */
  46602. this._orient;
  46603. /**
  46604. * [0, 100]
  46605. * @private
  46606. */
  46607. this._range;
  46608. /**
  46609. * [coord of the first handle, coord of the second handle]
  46610. * @private
  46611. */
  46612. this._handleEnds;
  46613. /**
  46614. * [length, thick]
  46615. * @private
  46616. * @type {Array.<number>}
  46617. */
  46618. this._size;
  46619. /**
  46620. * @private
  46621. * @type {number}
  46622. */
  46623. this._handleWidth;
  46624. /**
  46625. * @private
  46626. * @type {number}
  46627. */
  46628. this._handleHeight;
  46629. /**
  46630. * @private
  46631. */
  46632. this._location;
  46633. /**
  46634. * @private
  46635. */
  46636. this._dragging;
  46637. /**
  46638. * @private
  46639. */
  46640. this._dataShadowInfo;
  46641. this.api = api;
  46642. },
  46643. /**
  46644. * @override
  46645. */
  46646. render: function (dataZoomModel, ecModel, api, payload) {
  46647. SliderZoomView.superApply(this, 'render', arguments);
  46648. throttle.createOrUpdate(
  46649. this,
  46650. '_dispatchZoomAction',
  46651. this.dataZoomModel.get('throttle'),
  46652. 'fixRate'
  46653. );
  46654. this._orient = dataZoomModel.get('orient');
  46655. if (this.dataZoomModel.get('show') === false) {
  46656. this.group.removeAll();
  46657. return;
  46658. }
  46659. // Notice: this._resetInterval() should not be executed when payload.type
  46660. // is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
  46661. // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
  46662. if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) {
  46663. this._buildView();
  46664. }
  46665. this._updateView();
  46666. },
  46667. /**
  46668. * @override
  46669. */
  46670. remove: function () {
  46671. SliderZoomView.superApply(this, 'remove', arguments);
  46672. throttle.clear(this, '_dispatchZoomAction');
  46673. },
  46674. /**
  46675. * @override
  46676. */
  46677. dispose: function () {
  46678. SliderZoomView.superApply(this, 'dispose', arguments);
  46679. throttle.clear(this, '_dispatchZoomAction');
  46680. },
  46681. _buildView: function () {
  46682. var thisGroup = this.group;
  46683. thisGroup.removeAll();
  46684. this._resetLocation();
  46685. this._resetInterval();
  46686. var barGroup = this._displayables.barGroup = new graphic.Group();
  46687. this._renderBackground();
  46688. this._renderHandle();
  46689. this._renderDataShadow();
  46690. thisGroup.add(barGroup);
  46691. this._positionGroup();
  46692. },
  46693. /**
  46694. * @private
  46695. */
  46696. _resetLocation: function () {
  46697. var dataZoomModel = this.dataZoomModel;
  46698. var api = this.api;
  46699. // If some of x/y/width/height are not specified,
  46700. // auto-adapt according to target grid.
  46701. var coordRect = this._findCoordRect();
  46702. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  46703. // Default align by coordinate system rect.
  46704. var positionInfo = this._orient === HORIZONTAL
  46705. ? {
  46706. // Why using 'right', because right should be used in vertical,
  46707. // and it is better to be consistent for dealing with position param merge.
  46708. right: ecSize.width - coordRect.x - coordRect.width,
  46709. top: (ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP),
  46710. width: coordRect.width,
  46711. height: DEFAULT_FILLER_SIZE
  46712. }
  46713. : { // vertical
  46714. right: DEFAULT_LOCATION_EDGE_GAP,
  46715. top: coordRect.y,
  46716. width: DEFAULT_FILLER_SIZE,
  46717. height: coordRect.height
  46718. };
  46719. // Do not write back to option and replace value 'ph', because
  46720. // the 'ph' value should be recalculated when resize.
  46721. var layoutParams = layout.getLayoutParams(dataZoomModel.option);
  46722. // Replace the placeholder value.
  46723. zrUtil.each(['right', 'top', 'width', 'height'], function (name) {
  46724. if (layoutParams[name] === 'ph') {
  46725. layoutParams[name] = positionInfo[name];
  46726. }
  46727. });
  46728. var layoutRect = layout.getLayoutRect(
  46729. layoutParams,
  46730. ecSize,
  46731. dataZoomModel.padding
  46732. );
  46733. this._location = {x: layoutRect.x, y: layoutRect.y};
  46734. this._size = [layoutRect.width, layoutRect.height];
  46735. this._orient === VERTICAL && this._size.reverse();
  46736. },
  46737. /**
  46738. * @private
  46739. */
  46740. _positionGroup: function () {
  46741. var thisGroup = this.group;
  46742. var location = this._location;
  46743. var orient = this._orient;
  46744. // Just use the first axis to determine mapping.
  46745. var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel();
  46746. var inverse = targetAxisModel && targetAxisModel.get('inverse');
  46747. var barGroup = this._displayables.barGroup;
  46748. var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse;
  46749. // Transform barGroup.
  46750. barGroup.attr(
  46751. (orient === HORIZONTAL && !inverse)
  46752. ? {scale: otherAxisInverse ? [1, 1] : [1, -1]}
  46753. : (orient === HORIZONTAL && inverse)
  46754. ? {scale: otherAxisInverse ? [-1, 1] : [-1, -1]}
  46755. : (orient === VERTICAL && !inverse)
  46756. ? {scale: otherAxisInverse ? [1, -1] : [1, 1], rotation: Math.PI / 2}
  46757. // Dont use Math.PI, considering shadow direction.
  46758. : {scale: otherAxisInverse ? [-1, -1] : [-1, 1], rotation: Math.PI / 2}
  46759. );
  46760. // Position barGroup
  46761. var rect = thisGroup.getBoundingRect([barGroup]);
  46762. thisGroup.attr('position', [location.x - rect.x, location.y - rect.y]);
  46763. },
  46764. /**
  46765. * @private
  46766. */
  46767. _getViewExtent: function () {
  46768. return [0, this._size[0]];
  46769. },
  46770. _renderBackground : function () {
  46771. var dataZoomModel = this.dataZoomModel;
  46772. var size = this._size;
  46773. this._displayables.barGroup.add(new Rect({
  46774. silent: true,
  46775. shape: {
  46776. x: 0, y: 0, width: size[0], height: size[1]
  46777. },
  46778. style: {
  46779. fill: dataZoomModel.get('backgroundColor')
  46780. },
  46781. z2: -40
  46782. }));
  46783. },
  46784. _renderDataShadow: function () {
  46785. var info = this._dataShadowInfo = this._prepareDataShadowInfo();
  46786. if (!info) {
  46787. return;
  46788. }
  46789. var size = this._size;
  46790. var seriesModel = info.series;
  46791. var data = seriesModel.getRawData();
  46792. var otherDim = seriesModel.getShadowDim
  46793. ? seriesModel.getShadowDim() // @see candlestick
  46794. : info.otherDim;
  46795. var otherDataExtent = data.getDataExtent(otherDim);
  46796. // Nice extent.
  46797. var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
  46798. otherDataExtent = [
  46799. otherDataExtent[0] - otherOffset,
  46800. otherDataExtent[1] + otherOffset
  46801. ];
  46802. var otherShadowExtent = [0, size[1]];
  46803. var thisShadowExtent = [0, size[0]];
  46804. var areaPoints = [[size[0], 0], [0, 0]];
  46805. var linePoints = [];
  46806. var step = thisShadowExtent[1] / (data.count() - 1);
  46807. var thisCoord = 0;
  46808. // Optimize for large data shadow
  46809. var stride = Math.round(data.count() / size[0]);
  46810. var lastIsEmpty;
  46811. data.each([otherDim], function (value, index) {
  46812. if (stride > 0 && (index % stride)) {
  46813. thisCoord += step;
  46814. return;
  46815. }
  46816. // FIXME
  46817. // Should consider axis.min/axis.max when drawing dataShadow.
  46818. // FIXME
  46819. // 应该使用统一的空判断?还是在list里进行空判断?
  46820. var isEmpty = value == null || isNaN(value) || value === '';
  46821. // See #4235.
  46822. var otherCoord = isEmpty
  46823. ? 0 : linearMap(value, otherDataExtent, otherShadowExtent, true);
  46824. // Attempt to draw data shadow precisely when there are empty value.
  46825. if (isEmpty && !lastIsEmpty && index) {
  46826. areaPoints.push([areaPoints[areaPoints.length - 1][0], 0]);
  46827. linePoints.push([linePoints[linePoints.length - 1][0], 0]);
  46828. }
  46829. else if (!isEmpty && lastIsEmpty) {
  46830. areaPoints.push([thisCoord, 0]);
  46831. linePoints.push([thisCoord, 0]);
  46832. }
  46833. areaPoints.push([thisCoord, otherCoord]);
  46834. linePoints.push([thisCoord, otherCoord]);
  46835. thisCoord += step;
  46836. lastIsEmpty = isEmpty;
  46837. });
  46838. var dataZoomModel = this.dataZoomModel;
  46839. // var dataBackgroundModel = dataZoomModel.getModel('dataBackground');
  46840. this._displayables.barGroup.add(new graphic.Polygon({
  46841. shape: {points: areaPoints},
  46842. style: zrUtil.defaults(
  46843. {fill: dataZoomModel.get('dataBackgroundColor')},
  46844. dataZoomModel.getModel('dataBackground.areaStyle').getAreaStyle()
  46845. ),
  46846. silent: true,
  46847. z2: -20
  46848. }));
  46849. this._displayables.barGroup.add(new graphic.Polyline({
  46850. shape: {points: linePoints},
  46851. style: dataZoomModel.getModel('dataBackground.lineStyle').getLineStyle(),
  46852. silent: true,
  46853. z2: -19
  46854. }));
  46855. },
  46856. _prepareDataShadowInfo: function () {
  46857. var dataZoomModel = this.dataZoomModel;
  46858. var showDataShadow = dataZoomModel.get('showDataShadow');
  46859. if (showDataShadow === false) {
  46860. return;
  46861. }
  46862. // Find a representative series.
  46863. var result;
  46864. var ecModel = this.ecModel;
  46865. dataZoomModel.eachTargetAxis(function (dimNames, axisIndex) {
  46866. var seriesModels = dataZoomModel
  46867. .getAxisProxy(dimNames.name, axisIndex)
  46868. .getTargetSeriesModels();
  46869. zrUtil.each(seriesModels, function (seriesModel) {
  46870. if (result) {
  46871. return;
  46872. }
  46873. if (showDataShadow !== true && zrUtil.indexOf(
  46874. SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')
  46875. ) < 0
  46876. ) {
  46877. return;
  46878. }
  46879. var otherDim = getOtherDim(dimNames.name);
  46880. var thisAxis = ecModel.getComponent(dimNames.axis, axisIndex).axis;
  46881. result = {
  46882. thisAxis: thisAxis,
  46883. series: seriesModel,
  46884. thisDim: dimNames.name,
  46885. otherDim: otherDim,
  46886. otherAxisInverse: seriesModel
  46887. .coordinateSystem.getOtherAxis(thisAxis).inverse
  46888. };
  46889. }, this);
  46890. }, this);
  46891. return result;
  46892. },
  46893. _renderHandle: function () {
  46894. var displaybles = this._displayables;
  46895. var handles = displaybles.handles = [];
  46896. var handleLabels = displaybles.handleLabels = [];
  46897. var barGroup = this._displayables.barGroup;
  46898. var size = this._size;
  46899. var dataZoomModel = this.dataZoomModel;
  46900. barGroup.add(displaybles.filler = new Rect({
  46901. draggable: true,
  46902. cursor: 'move',
  46903. drift: bind(this._onDragMove, this, 'all'),
  46904. ondragstart: bind(this._showDataInfo, this, true),
  46905. ondragend: bind(this._onDragEnd, this),
  46906. onmouseover: bind(this._showDataInfo, this, true),
  46907. onmouseout: bind(this._showDataInfo, this, false),
  46908. style: {
  46909. fill: dataZoomModel.get('fillerColor'),
  46910. textPosition : 'inside'
  46911. }
  46912. }));
  46913. // Frame border.
  46914. barGroup.add(new Rect(graphic.subPixelOptimizeRect({
  46915. silent: true,
  46916. shape: {
  46917. x: 0,
  46918. y: 0,
  46919. width: size[0],
  46920. height: size[1]
  46921. },
  46922. style: {
  46923. stroke: dataZoomModel.get('dataBackgroundColor')
  46924. || dataZoomModel.get('borderColor'),
  46925. lineWidth: DEFAULT_FRAME_BORDER_WIDTH,
  46926. fill: 'rgba(0,0,0,0)'
  46927. }
  46928. })));
  46929. var iconStr = dataZoomModel.get('handleIcon');
  46930. each([0, 1], function (handleIndex) {
  46931. var path = graphic.makePath(iconStr, {
  46932. style: {
  46933. strokeNoScale: true
  46934. },
  46935. rectHover: true,
  46936. cursor: this._orient === 'vertical' ? 'ns-resize' : 'ew-resize',
  46937. draggable: true,
  46938. drift: bind(this._onDragMove, this, handleIndex),
  46939. ondragend: bind(this._onDragEnd, this),
  46940. onmouseover: bind(this._showDataInfo, this, true),
  46941. onmouseout: bind(this._showDataInfo, this, false)
  46942. }, {
  46943. x: -0.5,
  46944. y: 0,
  46945. width: 1,
  46946. height: 1
  46947. }, 'center');
  46948. var bRect = path.getBoundingRect();
  46949. this._handleHeight = numberUtil.parsePercent(dataZoomModel.get('handleSize'), this._size[1]);
  46950. this._handleWidth = bRect.width / bRect.height * this._handleHeight;
  46951. path.setStyle(dataZoomModel.getModel('handleStyle').getItemStyle());
  46952. var handleColor = dataZoomModel.get('handleColor');
  46953. // Compatitable with previous version
  46954. if (handleColor != null) {
  46955. path.style.fill = handleColor;
  46956. }
  46957. barGroup.add(handles[handleIndex] = path);
  46958. var textStyleModel = dataZoomModel.textStyleModel;
  46959. this.group.add(
  46960. handleLabels[handleIndex] = new graphic.Text({
  46961. silent: true,
  46962. invisible: true,
  46963. style: {
  46964. x: 0, y: 0, text: '',
  46965. textVerticalAlign: 'middle',
  46966. textAlign: 'center',
  46967. fill: textStyleModel.getTextColor(),
  46968. textFont: textStyleModel.getFont()
  46969. },
  46970. z2: 10
  46971. }));
  46972. }, this);
  46973. },
  46974. /**
  46975. * @private
  46976. */
  46977. _resetInterval: function () {
  46978. var range = this._range = this.dataZoomModel.getPercentRange();
  46979. var viewExtent = this._getViewExtent();
  46980. this._handleEnds = [
  46981. linearMap(range[0], [0, 100], viewExtent, true),
  46982. linearMap(range[1], [0, 100], viewExtent, true)
  46983. ];
  46984. },
  46985. /**
  46986. * @private
  46987. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  46988. * @param {number} dx
  46989. * @param {number} dy
  46990. */
  46991. _updateInterval: function (handleIndex, delta) {
  46992. var handleEnds = this._handleEnds;
  46993. var viewExtend = this._getViewExtent();
  46994. sliderMove(
  46995. delta,
  46996. handleEnds,
  46997. viewExtend,
  46998. (handleIndex === 'all' || this.dataZoomModel.get('zoomLock'))
  46999. ? 'rigid' : 'cross',
  47000. handleIndex
  47001. );
  47002. this._range = asc([
  47003. linearMap(handleEnds[0], viewExtend, [0, 100], true),
  47004. linearMap(handleEnds[1], viewExtend, [0, 100], true)
  47005. ]);
  47006. },
  47007. /**
  47008. * @private
  47009. */
  47010. _updateView: function (nonRealtime) {
  47011. var displaybles = this._displayables;
  47012. var handleEnds = this._handleEnds;
  47013. var handleInterval = asc(handleEnds.slice());
  47014. var size = this._size;
  47015. each([0, 1], function (handleIndex) {
  47016. // Handles
  47017. var handle = displaybles.handles[handleIndex];
  47018. var handleHeight = this._handleHeight;
  47019. handle.attr({
  47020. scale: [handleHeight, handleHeight],
  47021. position: [handleEnds[handleIndex], size[1] / 2 - handleHeight / 2]
  47022. });
  47023. }, this);
  47024. // Filler
  47025. displaybles.filler.setShape({
  47026. x: handleInterval[0],
  47027. y: 0,
  47028. width: handleInterval[1] - handleInterval[0],
  47029. height: size[1]
  47030. });
  47031. this._updateDataInfo(nonRealtime);
  47032. },
  47033. /**
  47034. * @private
  47035. */
  47036. _updateDataInfo: function (nonRealtime) {
  47037. var dataZoomModel = this.dataZoomModel;
  47038. var displaybles = this._displayables;
  47039. var handleLabels = displaybles.handleLabels;
  47040. var orient = this._orient;
  47041. var labelTexts = ['', ''];
  47042. // FIXME
  47043. // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter)
  47044. if (dataZoomModel.get('showDetail')) {
  47045. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  47046. if (axisProxy) {
  47047. var axis = axisProxy.getAxisModel().axis;
  47048. var range = this._range;
  47049. var dataInterval = nonRealtime
  47050. // See #4434, data and axis are not processed and reset yet in non-realtime mode.
  47051. ? axisProxy.calculateDataWindow(
  47052. {start: range[0], end: range[1]},
  47053. axisProxy.getDataExtent()
  47054. ).valueWindow
  47055. : axisProxy.getDataValueWindow();
  47056. labelTexts = [
  47057. this._formatLabel(dataInterval[0], axis),
  47058. this._formatLabel(dataInterval[1], axis)
  47059. ];
  47060. }
  47061. }
  47062. var orderedHandleEnds = asc(this._handleEnds.slice());
  47063. setLabel.call(this, 0);
  47064. setLabel.call(this, 1);
  47065. function setLabel(handleIndex) {
  47066. // Label
  47067. // Text should not transform by barGroup.
  47068. // Ignore handlers transform
  47069. var barTransform = graphic.getTransform(
  47070. displaybles.handles[handleIndex].parent, this.group
  47071. );
  47072. var direction = graphic.transformDirection(
  47073. handleIndex === 0 ? 'right' : 'left', barTransform
  47074. );
  47075. var offset = this._handleWidth / 2 + LABEL_GAP;
  47076. var textPoint = graphic.applyTransform(
  47077. [
  47078. orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset),
  47079. this._size[1] / 2
  47080. ],
  47081. barTransform
  47082. );
  47083. handleLabels[handleIndex].setStyle({
  47084. x: textPoint[0],
  47085. y: textPoint[1],
  47086. textVerticalAlign: orient === HORIZONTAL ? 'middle' : direction,
  47087. textAlign: orient === HORIZONTAL ? direction : 'center',
  47088. text: labelTexts[handleIndex]
  47089. });
  47090. }
  47091. },
  47092. /**
  47093. * @private
  47094. */
  47095. _formatLabel: function (value, axis) {
  47096. var dataZoomModel = this.dataZoomModel;
  47097. var labelFormatter = dataZoomModel.get('labelFormatter');
  47098. var labelPrecision = dataZoomModel.get('labelPrecision');
  47099. if (labelPrecision == null || labelPrecision === 'auto') {
  47100. labelPrecision = axis.getPixelPrecision();
  47101. }
  47102. var valueStr = (value == null && isNaN(value))
  47103. ? ''
  47104. // FIXME Glue code
  47105. : (axis.type === 'category' || axis.type === 'time')
  47106. ? axis.scale.getLabel(Math.round(value))
  47107. // param of toFixed should less then 20.
  47108. : value.toFixed(Math.min(labelPrecision, 20));
  47109. return zrUtil.isFunction(labelFormatter)
  47110. ? labelFormatter(value, valueStr)
  47111. : zrUtil.isString(labelFormatter)
  47112. ? labelFormatter.replace('{value}', valueStr)
  47113. : valueStr;
  47114. },
  47115. /**
  47116. * @private
  47117. * @param {boolean} showOrHide true: show, false: hide
  47118. */
  47119. _showDataInfo: function (showOrHide) {
  47120. // Always show when drgging.
  47121. showOrHide = this._dragging || showOrHide;
  47122. var handleLabels = this._displayables.handleLabels;
  47123. handleLabels[0].attr('invisible', !showOrHide);
  47124. handleLabels[1].attr('invisible', !showOrHide);
  47125. },
  47126. _onDragMove: function (handleIndex, dx, dy) {
  47127. this._dragging = true;
  47128. // Transform dx, dy to bar coordination.
  47129. var vertex = this._applyBarTransform([dx, dy], true);
  47130. this._updateInterval(handleIndex, vertex[0]);
  47131. var realtime = this.dataZoomModel.get('realtime');
  47132. this._updateView(!realtime);
  47133. if (realtime) {
  47134. realtime && this._dispatchZoomAction();
  47135. }
  47136. },
  47137. _onDragEnd: function () {
  47138. this._dragging = false;
  47139. this._showDataInfo(false);
  47140. this._dispatchZoomAction();
  47141. },
  47142. /**
  47143. * This action will be throttled.
  47144. * @private
  47145. */
  47146. _dispatchZoomAction: function () {
  47147. var range = this._range;
  47148. this.api.dispatchAction({
  47149. type: 'dataZoom',
  47150. from: this.uid,
  47151. dataZoomId: this.dataZoomModel.id,
  47152. start: range[0],
  47153. end: range[1]
  47154. });
  47155. },
  47156. /**
  47157. * @private
  47158. */
  47159. _applyBarTransform: function (vertex, inverse) {
  47160. var barTransform = this._displayables.barGroup.getLocalTransform();
  47161. return graphic.applyTransform(vertex, barTransform, inverse);
  47162. },
  47163. /**
  47164. * @private
  47165. */
  47166. _findCoordRect: function () {
  47167. // Find the grid coresponding to the first axis referred by dataZoom.
  47168. var targetInfo = this.getTargetInfo();
  47169. // FIXME
  47170. // 判断是catesian还是polar
  47171. var rect;
  47172. if (targetInfo.cartesians.length) {
  47173. rect = targetInfo.cartesians[0].model.coordinateSystem.getRect();
  47174. }
  47175. else { // Polar
  47176. // FIXME
  47177. // 暂时随便写的
  47178. var width = this.api.getWidth();
  47179. var height = this.api.getHeight();
  47180. rect = {
  47181. x: width * 0.2,
  47182. y: height * 0.2,
  47183. width: width * 0.6,
  47184. height: height * 0.6
  47185. };
  47186. }
  47187. return rect;
  47188. }
  47189. });
  47190. function getOtherDim(thisDim) {
  47191. // FIXME
  47192. // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
  47193. return thisDim === 'x' ? 'y' : 'x';
  47194. }
  47195. module.exports = SliderZoomView;
  47196. /***/ },
  47197. /* 326 */
  47198. /***/ function(module, exports) {
  47199. /**
  47200. * Calculate slider move result.
  47201. *
  47202. * @param {number} delta Move length.
  47203. * @param {Array.<number>} handleEnds handleEnds[0] and be bigger then handleEnds[1].
  47204. * handleEnds will be modified in this method.
  47205. * @param {Array.<number>} extent handleEnds is restricted by extent.
  47206. * extent[0] should less or equals than extent[1].
  47207. * @param {string} mode 'rigid': Math.abs(handleEnds[0] - handleEnds[1]) remain unchanged,
  47208. * 'cross' handleEnds[0] can be bigger then handleEnds[1],
  47209. * 'push' handleEnds[0] can not be bigger then handleEnds[1],
  47210. * when they touch, one push other.
  47211. * @param {number} handleIndex If mode is 'rigid', handleIndex is not required.
  47212. * @param {Array.<number>} The input handleEnds.
  47213. */
  47214. module.exports = function (delta, handleEnds, extent, mode, handleIndex) {
  47215. if (!delta) {
  47216. return handleEnds;
  47217. }
  47218. if (mode === 'rigid') {
  47219. delta = getRealDelta(delta, handleEnds, extent);
  47220. handleEnds[0] += delta;
  47221. handleEnds[1] += delta;
  47222. }
  47223. else {
  47224. delta = getRealDelta(delta, handleEnds[handleIndex], extent);
  47225. handleEnds[handleIndex] += delta;
  47226. if (mode === 'push' && handleEnds[0] > handleEnds[1]) {
  47227. handleEnds[1 - handleIndex] = handleEnds[handleIndex];
  47228. }
  47229. }
  47230. return handleEnds;
  47231. function getRealDelta(delta, handleEnds, extent) {
  47232. var handleMinMax = !handleEnds.length
  47233. ? [handleEnds, handleEnds]
  47234. : handleEnds.slice();
  47235. handleEnds[0] > handleEnds[1] && handleMinMax.reverse();
  47236. if (delta < 0 && handleMinMax[0] + delta < extent[0]) {
  47237. delta = extent[0] - handleMinMax[0];
  47238. }
  47239. if (delta > 0 && handleMinMax[1] + delta > extent[1]) {
  47240. delta = extent[1] - handleMinMax[1];
  47241. }
  47242. return delta;
  47243. }
  47244. };
  47245. /***/ },
  47246. /* 327 */
  47247. /***/ function(module, exports, __webpack_require__) {
  47248. /**
  47249. * @file Data zoom model
  47250. */
  47251. module.exports = __webpack_require__(320).extend({
  47252. type: 'dataZoom.inside',
  47253. /**
  47254. * @protected
  47255. */
  47256. defaultOption: {
  47257. disabled: false, // Whether disable this inside zoom.
  47258. zoomLock: false // Whether disable zoom but only pan.
  47259. }
  47260. });
  47261. /***/ },
  47262. /* 328 */
  47263. /***/ function(module, exports, __webpack_require__) {
  47264. var DataZoomView = __webpack_require__(323);
  47265. var zrUtil = __webpack_require__(4);
  47266. var sliderMove = __webpack_require__(326);
  47267. var roams = __webpack_require__(329);
  47268. var bind = zrUtil.bind;
  47269. var InsideZoomView = DataZoomView.extend({
  47270. type: 'dataZoom.inside',
  47271. /**
  47272. * @override
  47273. */
  47274. init: function (ecModel, api) {
  47275. /**
  47276. * 'throttle' is used in this.dispatchAction, so we save range
  47277. * to avoid missing some 'pan' info.
  47278. * @private
  47279. * @type {Array.<number>}
  47280. */
  47281. this._range;
  47282. },
  47283. /**
  47284. * @override
  47285. */
  47286. render: function (dataZoomModel, ecModel, api, payload) {
  47287. InsideZoomView.superApply(this, 'render', arguments);
  47288. // Notice: origin this._range should be maintained, and should not be re-fetched
  47289. // from dataZoomModel when payload.type is 'dataZoom', otherwise 'pan' or 'zoom'
  47290. // info will be missed because of 'throttle' of this.dispatchAction.
  47291. if (roams.shouldRecordRange(payload, dataZoomModel.id)) {
  47292. this._range = dataZoomModel.getPercentRange();
  47293. }
  47294. var targetInfo = this.getTargetInfo();
  47295. // Reset controllers.
  47296. zrUtil.each(['cartesians', 'polars'], function (coordSysName) {
  47297. var coordInfoList = targetInfo[coordSysName];
  47298. var allCoordIds = zrUtil.map(coordInfoList, function (coordInfo) {
  47299. return roams.generateCoordId(coordInfo.model);
  47300. });
  47301. zrUtil.each(coordInfoList, function (coordInfo) {
  47302. var coordModel = coordInfo.model;
  47303. var coordinateSystem = coordModel.coordinateSystem;
  47304. roams.register(
  47305. api,
  47306. {
  47307. coordId: roams.generateCoordId(coordModel),
  47308. allCoordIds: allCoordIds,
  47309. coordinateSystem: coordinateSystem,
  47310. containsPoint: bind(operations[coordSysName].containsPoint, this, coordinateSystem),
  47311. dataZoomId: dataZoomModel.id,
  47312. throttleRate: dataZoomModel.get('throttle', true),
  47313. panGetRange: bind(this._onPan, this, coordInfo, coordSysName),
  47314. zoomGetRange: bind(this._onZoom, this, coordInfo, coordSysName)
  47315. }
  47316. );
  47317. }, this);
  47318. }, this);
  47319. },
  47320. /**
  47321. * @override
  47322. */
  47323. dispose: function () {
  47324. roams.unregister(this.api, this.dataZoomModel.id);
  47325. InsideZoomView.superApply(this, 'dispose', arguments);
  47326. this._range = null;
  47327. },
  47328. /**
  47329. * @private
  47330. */
  47331. _onPan: function (coordInfo, coordSysName, controller, dx, dy, oldX, oldY, newX, newY) {
  47332. if (this.dataZoomModel.option.disabled) {
  47333. return this._range;
  47334. }
  47335. var range = this._range.slice();
  47336. // Calculate transform by the first axis.
  47337. var axisModel = coordInfo.axisModels[0];
  47338. if (!axisModel) {
  47339. return;
  47340. }
  47341. var directionInfo = operations[coordSysName].getDirectionInfo(
  47342. [oldX, oldY], [newX, newY], axisModel, controller, coordInfo
  47343. );
  47344. var percentDelta = directionInfo.signal
  47345. * (range[1] - range[0])
  47346. * directionInfo.pixel / directionInfo.pixelLength;
  47347. sliderMove(percentDelta, range, [0, 100], 'rigid');
  47348. return (this._range = range);
  47349. },
  47350. /**
  47351. * @private
  47352. */
  47353. _onZoom: function (coordInfo, coordSysName, controller, scale, mouseX, mouseY) {
  47354. var option = this.dataZoomModel.option;
  47355. if (option.disabled || option.zoomLock) {
  47356. return this._range;
  47357. }
  47358. var range = this._range.slice();
  47359. // Calculate transform by the first axis.
  47360. var axisModel = coordInfo.axisModels[0];
  47361. if (!axisModel) {
  47362. return;
  47363. }
  47364. var directionInfo = operations[coordSysName].getDirectionInfo(
  47365. null, [mouseX, mouseY], axisModel, controller, coordInfo
  47366. );
  47367. var percentPoint = (directionInfo.pixel - directionInfo.pixelStart) /
  47368. directionInfo.pixelLength * (range[1] - range[0]) + range[0];
  47369. scale = Math.max(1 / scale, 0);
  47370. range[0] = (range[0] - percentPoint) * scale + percentPoint;
  47371. range[1] = (range[1] - percentPoint) * scale + percentPoint;
  47372. return (this._range = fixRange(range));
  47373. }
  47374. });
  47375. var operations = {
  47376. cartesians: {
  47377. getDirectionInfo: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  47378. var axis = axisModel.axis;
  47379. var ret = {};
  47380. var rect = coordInfo.model.coordinateSystem.getRect();
  47381. oldPoint = oldPoint || [0, 0];
  47382. if (axis.dim === 'x') {
  47383. ret.pixel = newPoint[0] - oldPoint[0];
  47384. ret.pixelLength = rect.width;
  47385. ret.pixelStart = rect.x;
  47386. ret.signal = axis.inverse ? 1 : -1;
  47387. }
  47388. else { // axis.dim === 'y'
  47389. ret.pixel = newPoint[1] - oldPoint[1];
  47390. ret.pixelLength = rect.height;
  47391. ret.pixelStart = rect.y;
  47392. ret.signal = axis.inverse ? -1 : 1;
  47393. }
  47394. return ret;
  47395. },
  47396. containsPoint: function (coordinateSystem, x, y) {
  47397. return coordinateSystem.getRect().contain(x, y);
  47398. }
  47399. },
  47400. polars: {
  47401. getDirectionInfo: function (oldPoint, newPoint, axisModel, controller, coordInfo) {
  47402. var axis = axisModel.axis;
  47403. var ret = {};
  47404. var polar = coordInfo.model.coordinateSystem;
  47405. var radiusExtent = polar.getRadiusAxis().getExtent();
  47406. var angleExtent = polar.getAngleAxis().getExtent();
  47407. oldPoint = oldPoint ? polar.pointToCoord(oldPoint) : [0, 0];
  47408. newPoint = polar.pointToCoord(newPoint);
  47409. if (axisModel.mainType === 'radiusAxis') {
  47410. ret.pixel = newPoint[0] - oldPoint[0];
  47411. // ret.pixelLength = Math.abs(radiusExtent[1] - radiusExtent[0]);
  47412. // ret.pixelStart = Math.min(radiusExtent[0], radiusExtent[1]);
  47413. ret.pixelLength = radiusExtent[1] - radiusExtent[0];
  47414. ret.pixelStart = radiusExtent[0];
  47415. ret.signal = axis.inverse ? 1 : -1;
  47416. }
  47417. else { // 'angleAxis'
  47418. ret.pixel = newPoint[1] - oldPoint[1];
  47419. // ret.pixelLength = Math.abs(angleExtent[1] - angleExtent[0]);
  47420. // ret.pixelStart = Math.min(angleExtent[0], angleExtent[1]);
  47421. ret.pixelLength = angleExtent[1] - angleExtent[0];
  47422. ret.pixelStart = angleExtent[0];
  47423. ret.signal = axis.inverse ? -1 : 1;
  47424. }
  47425. return ret;
  47426. },
  47427. containsPoint: function (coordinateSystem, x, y) {
  47428. var radius = coordinateSystem.getRadiusAxis().getExtent()[1];
  47429. var cx = coordinateSystem.cx;
  47430. var cy = coordinateSystem.cy;
  47431. return Math.pow(x - cx, 2) + Math.pow(y - cy, 2) <= Math.pow(radius, 2);
  47432. }
  47433. }
  47434. };
  47435. function fixRange(range) {
  47436. // Clamp, using !(<= or >=) to handle NaN.
  47437. // jshint ignore:start
  47438. var bound = [0, 100];
  47439. !(range[0] <= bound[1]) && (range[0] = bound[1]);
  47440. !(range[1] <= bound[1]) && (range[1] = bound[1]);
  47441. !(range[0] >= bound[0]) && (range[0] = bound[0]);
  47442. !(range[1] >= bound[0]) && (range[1] = bound[0]);
  47443. // jshint ignore:end
  47444. return range;
  47445. }
  47446. module.exports = InsideZoomView;
  47447. /***/ },
  47448. /* 329 */
  47449. /***/ function(module, exports, __webpack_require__) {
  47450. /**
  47451. * @file Roam controller manager.
  47452. */
  47453. // Only create one roam controller for each coordinate system.
  47454. // one roam controller might be refered by two inside data zoom
  47455. // components (for example, one for x and one for y). When user
  47456. // pan or zoom, only dispatch one action for those data zoom
  47457. // components.
  47458. var zrUtil = __webpack_require__(4);
  47459. var RoamController = __webpack_require__(176);
  47460. var throttle = __webpack_require__(81);
  47461. var curry = zrUtil.curry;
  47462. var ATTR = '\0_ec_dataZoom_roams';
  47463. var roams = {
  47464. /**
  47465. * @public
  47466. * @param {module:echarts/ExtensionAPI} api
  47467. * @param {Object} dataZoomInfo
  47468. * @param {string} dataZoomInfo.coordId
  47469. * @param {Function} dataZoomInfo.containsPoint
  47470. * @param {Array.<string>} dataZoomInfo.allCoordIds
  47471. * @param {string} dataZoomInfo.dataZoomId
  47472. * @param {number} dataZoomInfo.throttleRate
  47473. * @param {Function} dataZoomInfo.panGetRange
  47474. * @param {Function} dataZoomInfo.zoomGetRange
  47475. */
  47476. register: function (api, dataZoomInfo) {
  47477. var store = giveStore(api);
  47478. var theDataZoomId = dataZoomInfo.dataZoomId;
  47479. var theCoordId = dataZoomInfo.coordId;
  47480. // Do clean when a dataZoom changes its target coordnate system.
  47481. // Avoid memory leak, dispose all not-used-registered.
  47482. zrUtil.each(store, function (record, coordId) {
  47483. var dataZoomInfos = record.dataZoomInfos;
  47484. if (dataZoomInfos[theDataZoomId]
  47485. && zrUtil.indexOf(dataZoomInfo.allCoordIds, theCoordId) < 0
  47486. ) {
  47487. delete dataZoomInfos[theDataZoomId];
  47488. record.count--;
  47489. }
  47490. });
  47491. cleanStore(store);
  47492. var record = store[theCoordId];
  47493. // Create if needed.
  47494. if (!record) {
  47495. record = store[theCoordId] = {
  47496. coordId: theCoordId,
  47497. dataZoomInfos: {},
  47498. count: 0
  47499. };
  47500. record.controller = createController(api, dataZoomInfo, record);
  47501. record.dispatchAction = zrUtil.curry(dispatchAction, api);
  47502. }
  47503. // Consider resize, area should be always updated.
  47504. record.controller.setContainsPoint(dataZoomInfo.containsPoint);
  47505. // Update throttle.
  47506. throttle.createOrUpdate(
  47507. record,
  47508. 'dispatchAction',
  47509. dataZoomInfo.throttleRate,
  47510. 'fixRate'
  47511. );
  47512. // Update reference of dataZoom.
  47513. !(record.dataZoomInfos[theDataZoomId]) && record.count++;
  47514. record.dataZoomInfos[theDataZoomId] = dataZoomInfo;
  47515. },
  47516. /**
  47517. * @public
  47518. * @param {module:echarts/ExtensionAPI} api
  47519. * @param {string} dataZoomId
  47520. */
  47521. unregister: function (api, dataZoomId) {
  47522. var store = giveStore(api);
  47523. zrUtil.each(store, function (record) {
  47524. record.controller.dispose();
  47525. var dataZoomInfos = record.dataZoomInfos;
  47526. if (dataZoomInfos[dataZoomId]) {
  47527. delete dataZoomInfos[dataZoomId];
  47528. record.count--;
  47529. }
  47530. });
  47531. cleanStore(store);
  47532. },
  47533. /**
  47534. * @public
  47535. */
  47536. shouldRecordRange: function (payload, dataZoomId) {
  47537. if (payload && payload.type === 'dataZoom' && payload.batch) {
  47538. for (var i = 0, len = payload.batch.length; i < len; i++) {
  47539. if (payload.batch[i].dataZoomId === dataZoomId) {
  47540. return false;
  47541. }
  47542. }
  47543. }
  47544. return true;
  47545. },
  47546. /**
  47547. * @public
  47548. */
  47549. generateCoordId: function (coordModel) {
  47550. return coordModel.type + '\0_' + coordModel.id;
  47551. }
  47552. };
  47553. /**
  47554. * Key: coordId, value: {dataZoomInfos: [], count, controller}
  47555. * @type {Array.<Object>}
  47556. */
  47557. function giveStore(api) {
  47558. // Mount store on zrender instance, so that we do not
  47559. // need to worry about dispose.
  47560. var zr = api.getZr();
  47561. return zr[ATTR] || (zr[ATTR] = {});
  47562. }
  47563. function createController(api, dataZoomInfo, newRecord) {
  47564. var controller = new RoamController(api.getZr());
  47565. controller.enable();
  47566. controller.on('pan', curry(onPan, newRecord));
  47567. controller.on('zoom', curry(onZoom, newRecord));
  47568. return controller;
  47569. }
  47570. function cleanStore(store) {
  47571. zrUtil.each(store, function (record, coordId) {
  47572. if (!record.count) {
  47573. record.controller.dispose();
  47574. delete store[coordId];
  47575. }
  47576. });
  47577. }
  47578. function onPan(record, dx, dy, oldX, oldY, newX, newY) {
  47579. wrapAndDispatch(record, function (info) {
  47580. return info.panGetRange(record.controller, dx, dy, oldX, oldY, newX, newY);
  47581. });
  47582. }
  47583. function onZoom(record, scale, mouseX, mouseY) {
  47584. wrapAndDispatch(record, function (info) {
  47585. return info.zoomGetRange(record.controller, scale, mouseX, mouseY);
  47586. });
  47587. }
  47588. function wrapAndDispatch(record, getRange) {
  47589. var batch = [];
  47590. zrUtil.each(record.dataZoomInfos, function (info) {
  47591. var range = getRange(info);
  47592. range && batch.push({
  47593. dataZoomId: info.dataZoomId,
  47594. start: range[0],
  47595. end: range[1]
  47596. });
  47597. });
  47598. record.dispatchAction(batch);
  47599. }
  47600. /**
  47601. * This action will be throttled.
  47602. */
  47603. function dispatchAction(api, batch) {
  47604. api.dispatchAction({
  47605. type: 'dataZoom',
  47606. batch: batch
  47607. });
  47608. }
  47609. module.exports = roams;
  47610. /***/ },
  47611. /* 330 */
  47612. /***/ function(module, exports, __webpack_require__) {
  47613. /**
  47614. * @file Data zoom processor
  47615. */
  47616. var echarts = __webpack_require__(1);
  47617. echarts.registerProcessor(function (ecModel, api) {
  47618. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  47619. // We calculate window and reset axis here but not in model
  47620. // init stage and not after action dispatch handler, because
  47621. // reset should be called after seriesData.restoreData.
  47622. dataZoomModel.eachTargetAxis(resetSingleAxis);
  47623. // Caution: data zoom filtering is order sensitive when using
  47624. // percent range and no min/max/scale set on axis.
  47625. // For example, we have dataZoom definition:
  47626. // [
  47627. // {xAxisIndex: 0, start: 30, end: 70},
  47628. // {yAxisIndex: 0, start: 20, end: 80}
  47629. // ]
  47630. // In this case, [20, 80] of y-dataZoom should be based on data
  47631. // that have filtered by x-dataZoom using range of [30, 70],
  47632. // but should not be based on full raw data. Thus sliding
  47633. // x-dataZoom will change both ranges of xAxis and yAxis,
  47634. // while sliding y-dataZoom will only change the range of yAxis.
  47635. // So we should filter x-axis after reset x-axis immediately,
  47636. // and then reset y-axis and filter y-axis.
  47637. dataZoomModel.eachTargetAxis(filterSingleAxis);
  47638. });
  47639. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  47640. // Fullfill all of the range props so that user
  47641. // is able to get them from chart.getOption().
  47642. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  47643. var percentRange = axisProxy.getDataPercentWindow();
  47644. var valueRange = axisProxy.getDataValueWindow();
  47645. dataZoomModel.setRawRange({
  47646. start: percentRange[0],
  47647. end: percentRange[1],
  47648. startValue: valueRange[0],
  47649. endValue: valueRange[1]
  47650. });
  47651. });
  47652. });
  47653. function resetSingleAxis(dimNames, axisIndex, dataZoomModel) {
  47654. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel);
  47655. }
  47656. function filterSingleAxis(dimNames, axisIndex, dataZoomModel) {
  47657. dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel);
  47658. }
  47659. /***/ },
  47660. /* 331 */
  47661. /***/ function(module, exports, __webpack_require__) {
  47662. /**
  47663. * @file Data zoom action
  47664. */
  47665. var zrUtil = __webpack_require__(4);
  47666. var helper = __webpack_require__(321);
  47667. var echarts = __webpack_require__(1);
  47668. echarts.registerAction('dataZoom', function (payload, ecModel) {
  47669. var linkedNodesFinder = helper.createLinkedNodesFinder(
  47670. zrUtil.bind(ecModel.eachComponent, ecModel, 'dataZoom'),
  47671. helper.eachAxisDim,
  47672. function (model, dimNames) {
  47673. return model.get(dimNames.axisIndex);
  47674. }
  47675. );
  47676. var effectedModels = [];
  47677. ecModel.eachComponent(
  47678. {mainType: 'dataZoom', query: payload},
  47679. function (model, index) {
  47680. effectedModels.push.apply(
  47681. effectedModels, linkedNodesFinder(model).nodes
  47682. );
  47683. }
  47684. );
  47685. zrUtil.each(effectedModels, function (dataZoomModel, index) {
  47686. dataZoomModel.setRawRange({
  47687. start: payload.start,
  47688. end: payload.end,
  47689. startValue: payload.startValue,
  47690. endValue: payload.endValue
  47691. });
  47692. });
  47693. });
  47694. /***/ },
  47695. /* 332 */
  47696. /***/ function(module, exports, __webpack_require__) {
  47697. /**
  47698. * visualMap component entry
  47699. */
  47700. __webpack_require__(333);
  47701. __webpack_require__(344);
  47702. /***/ },
  47703. /* 333 */
  47704. /***/ function(module, exports, __webpack_require__) {
  47705. /**
  47706. * DataZoom component entry
  47707. */
  47708. __webpack_require__(1).registerPreprocessor(
  47709. __webpack_require__(334)
  47710. );
  47711. __webpack_require__(335);
  47712. __webpack_require__(336);
  47713. __webpack_require__(337);
  47714. __webpack_require__(340);
  47715. __webpack_require__(343);
  47716. /***/ },
  47717. /* 334 */
  47718. /***/ function(module, exports, __webpack_require__) {
  47719. /**
  47720. * @file VisualMap preprocessor
  47721. */
  47722. var zrUtil = __webpack_require__(4);
  47723. var each = zrUtil.each;
  47724. module.exports = function (option) {
  47725. var visualMap = option && option.visualMap;
  47726. if (!zrUtil.isArray(visualMap)) {
  47727. visualMap = visualMap ? [visualMap] : [];
  47728. }
  47729. each(visualMap, function (opt) {
  47730. if (!opt) {
  47731. return;
  47732. }
  47733. // rename splitList to pieces
  47734. if (has(opt, 'splitList') && !has(opt, 'pieces')) {
  47735. opt.pieces = opt.splitList;
  47736. delete opt.splitList;
  47737. }
  47738. var pieces = opt.pieces;
  47739. if (pieces && zrUtil.isArray(pieces)) {
  47740. each(pieces, function (piece) {
  47741. if (zrUtil.isObject(piece)) {
  47742. if (has(piece, 'start') && !has(piece, 'min')) {
  47743. piece.min = piece.start;
  47744. }
  47745. if (has(piece, 'end') && !has(piece, 'max')) {
  47746. piece.max = piece.end;
  47747. }
  47748. }
  47749. });
  47750. }
  47751. });
  47752. };
  47753. function has(obj, name) {
  47754. return obj && obj.hasOwnProperty && obj.hasOwnProperty(name);
  47755. }
  47756. /***/ },
  47757. /* 335 */
  47758. /***/ function(module, exports, __webpack_require__) {
  47759. __webpack_require__(19).registerSubTypeDefaulter('visualMap', function (option) {
  47760. // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used.
  47761. return (
  47762. !option.categories
  47763. && (
  47764. !(
  47765. option.pieces
  47766. ? option.pieces.length > 0
  47767. : option.splitNumber > 0
  47768. )
  47769. || option.calculable
  47770. )
  47771. )
  47772. ? 'continuous' : 'piecewise';
  47773. });
  47774. /***/ },
  47775. /* 336 */
  47776. /***/ function(module, exports, __webpack_require__) {
  47777. /**
  47778. * @file Data range visual coding.
  47779. */
  47780. var echarts = __webpack_require__(1);
  47781. var visualSolution = __webpack_require__(309);
  47782. var VisualMapping = __webpack_require__(194);
  47783. var zrUtil = __webpack_require__(4);
  47784. echarts.registerVisual(echarts.PRIORITY.VISUAL.COMPONENT, function (ecModel) {
  47785. ecModel.eachComponent('visualMap', function (visualMapModel) {
  47786. processSingleVisualMap(visualMapModel, ecModel);
  47787. });
  47788. prepareVisualMeta(ecModel);
  47789. });
  47790. function processSingleVisualMap(visualMapModel, ecModel) {
  47791. visualMapModel.eachTargetSeries(function (seriesModel) {
  47792. var data = seriesModel.getData();
  47793. visualSolution.applyVisual(
  47794. visualMapModel.stateList,
  47795. visualMapModel.targetVisuals,
  47796. data,
  47797. visualMapModel.getValueState,
  47798. visualMapModel,
  47799. visualMapModel.getDataDimension(data)
  47800. );
  47801. });
  47802. }
  47803. // Only support color.
  47804. function prepareVisualMeta(ecModel) {
  47805. ecModel.eachSeries(function (seriesModel) {
  47806. var data = seriesModel.getData();
  47807. var visualMetaList = [];
  47808. ecModel.eachComponent('visualMap', function (visualMapModel) {
  47809. if (visualMapModel.isTargetSeries(seriesModel)) {
  47810. var visualMeta = visualMapModel.getVisualMeta(
  47811. zrUtil.bind(getColorVisual, null, seriesModel, visualMapModel)
  47812. ) || {stops: [], outerColors: []};
  47813. visualMeta.dimension = visualMapModel.getDataDimension(data);
  47814. visualMetaList.push(visualMeta);
  47815. }
  47816. });
  47817. // console.log(JSON.stringify(visualMetaList.map(a => a.stops)));
  47818. seriesModel.getData().setVisual('visualMeta', visualMetaList);
  47819. });
  47820. }
  47821. // FIXME
  47822. // performance and export for heatmap?
  47823. // value can be Infinity or -Infinity
  47824. function getColorVisual(seriesModel, visualMapModel, value, valueState) {
  47825. var mappings = visualMapModel.targetVisuals[valueState];
  47826. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  47827. var resultVisual = {
  47828. color: seriesModel.getData().getVisual('color') // default color.
  47829. };
  47830. for (var i = 0, len = visualTypes.length; i < len; i++) {
  47831. var type = visualTypes[i];
  47832. var mapping = mappings[
  47833. type === 'opacity' ? '__alphaForOpacity' : type
  47834. ];
  47835. mapping && mapping.applyVisual(value, getVisual, setVisual);
  47836. }
  47837. return resultVisual.color;
  47838. function getVisual(key) {
  47839. return resultVisual[key];
  47840. }
  47841. function setVisual(key, value) {
  47842. resultVisual[key] = value;
  47843. }
  47844. }
  47845. /***/ },
  47846. /* 337 */
  47847. /***/ function(module, exports, __webpack_require__) {
  47848. /**
  47849. * @file Data zoom model
  47850. */
  47851. var VisualMapModel = __webpack_require__(338);
  47852. var zrUtil = __webpack_require__(4);
  47853. var numberUtil = __webpack_require__(7);
  47854. // Constant
  47855. var DEFAULT_BAR_BOUND = [20, 140];
  47856. var ContinuousModel = VisualMapModel.extend({
  47857. type: 'visualMap.continuous',
  47858. /**
  47859. * @protected
  47860. */
  47861. defaultOption: {
  47862. align: 'auto', // 'auto', 'left', 'right', 'top', 'bottom'
  47863. calculable: false, // This prop effect default component type determine,
  47864. // See echarts/component/visualMap/typeDefaulter.
  47865. range: null, // selected range. In default case `range` is [min, max]
  47866. // and can auto change along with modification of min max,
  47867. // util use specifid a range.
  47868. realtime: true, // Whether realtime update.
  47869. itemHeight: null, // The length of the range control edge.
  47870. itemWidth: null, // The length of the other side.
  47871. hoverLink: true, // Enable hover highlight.
  47872. hoverLinkDataSize: null,// The size of hovered data.
  47873. hoverLinkOnHandle: true // Whether trigger hoverLink when hover handle.
  47874. },
  47875. /**
  47876. * @override
  47877. */
  47878. optionUpdated: function (newOption, isInit) {
  47879. ContinuousModel.superApply(this, 'optionUpdated', arguments);
  47880. this.resetTargetSeries();
  47881. this.resetExtent();
  47882. this.resetVisual(function (mappingOption) {
  47883. mappingOption.mappingMethod = 'linear';
  47884. mappingOption.dataExtent = this.getExtent();
  47885. });
  47886. this._resetRange();
  47887. },
  47888. /**
  47889. * @protected
  47890. * @override
  47891. */
  47892. resetItemSize: function () {
  47893. ContinuousModel.superApply(this, 'resetItemSize', arguments);
  47894. var itemSize = this.itemSize;
  47895. this._orient === 'horizontal' && itemSize.reverse();
  47896. (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]);
  47897. (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]);
  47898. },
  47899. /**
  47900. * @private
  47901. */
  47902. _resetRange: function () {
  47903. var dataExtent = this.getExtent();
  47904. var range = this.option.range;
  47905. if (!range || range.auto) {
  47906. // `range` should always be array (so we dont use other
  47907. // value like 'auto') for user-friend. (consider getOption).
  47908. dataExtent.auto = 1;
  47909. this.option.range = dataExtent;
  47910. }
  47911. else if (zrUtil.isArray(range)) {
  47912. if (range[0] > range[1]) {
  47913. range.reverse();
  47914. }
  47915. range[0] = Math.max(range[0], dataExtent[0]);
  47916. range[1] = Math.min(range[1], dataExtent[1]);
  47917. }
  47918. },
  47919. /**
  47920. * @protected
  47921. * @override
  47922. */
  47923. completeVisualOption: function () {
  47924. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  47925. zrUtil.each(this.stateList, function (state) {
  47926. var symbolSize = this.option.controller[state].symbolSize;
  47927. if (symbolSize && symbolSize[0] !== symbolSize[1]) {
  47928. symbolSize[0] = 0; // For good looking.
  47929. }
  47930. }, this);
  47931. },
  47932. /**
  47933. * @override
  47934. */
  47935. setSelected: function (selected) {
  47936. this.option.range = selected.slice();
  47937. this._resetRange();
  47938. },
  47939. /**
  47940. * @public
  47941. */
  47942. getSelected: function () {
  47943. var dataExtent = this.getExtent();
  47944. var dataInterval = numberUtil.asc(
  47945. (this.get('range') || []).slice()
  47946. );
  47947. // Clamp
  47948. dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]);
  47949. dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]);
  47950. dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]);
  47951. dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]);
  47952. return dataInterval;
  47953. },
  47954. /**
  47955. * @override
  47956. */
  47957. getValueState: function (value) {
  47958. var range = this.option.range;
  47959. var dataExtent = this.getExtent();
  47960. // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'.
  47961. // range[1] is processed likewise.
  47962. return (
  47963. (range[0] <= dataExtent[0] || range[0] <= value)
  47964. && (range[1] >= dataExtent[1] || value <= range[1])
  47965. ) ? 'inRange' : 'outOfRange';
  47966. },
  47967. /**
  47968. * @params {Array.<number>} range target value: range[0] <= value && value <= range[1]
  47969. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  47970. */
  47971. findTargetDataIndices: function (range) {
  47972. var result = [];
  47973. this.eachTargetSeries(function (seriesModel) {
  47974. var dataIndices = [];
  47975. var data = seriesModel.getData();
  47976. data.each(this.getDataDimension(data), function (value, dataIndex) {
  47977. range[0] <= value && value <= range[1] && dataIndices.push(dataIndex);
  47978. }, true, this);
  47979. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  47980. }, this);
  47981. return result;
  47982. },
  47983. /**
  47984. * @implement
  47985. */
  47986. getVisualMeta: function (getColorVisual) {
  47987. var oVals = getColorStopValues(this, 'outOfRange', this.getExtent());
  47988. var iVals = getColorStopValues(this, 'inRange', this.option.range.slice());
  47989. var stops = [];
  47990. function setStop(value, valueState) {
  47991. stops.push({
  47992. value: value,
  47993. color: getColorVisual(value, valueState)
  47994. });
  47995. }
  47996. // Format to: outOfRange -- inRange -- outOfRange.
  47997. var iIdx = 0;
  47998. var oIdx = 0;
  47999. var iLen = iVals.length;
  48000. var oLen = oVals.length;
  48001. for (; oIdx < oLen && (!iVals.length || oVals[oIdx] <= iVals[0]); oIdx++) {
  48002. // If oVal[oIdx] === iVals[iIdx], oVal[oIdx] should be ignored.
  48003. if (oVals[oIdx] < iVals[iIdx]) {
  48004. setStop(oVals[oIdx], 'outOfRange');
  48005. }
  48006. }
  48007. for (var first = 1; iIdx < iLen; iIdx++, first = 0) {
  48008. // If range is full, value beyond min, max will be clamped.
  48009. // make a singularity
  48010. first && stops.length && setStop(iVals[iIdx], 'outOfRange');
  48011. setStop(iVals[iIdx], 'inRange');
  48012. }
  48013. for (var first = 1; oIdx < oLen; oIdx++) {
  48014. if (!iVals.length || iVals[iVals.length - 1] < oVals[oIdx]) {
  48015. // make a singularity
  48016. if (first) {
  48017. stops.length && setStop(stops[stops.length - 1].value, 'outOfRange');
  48018. first = 0;
  48019. }
  48020. setStop(oVals[oIdx], 'outOfRange');
  48021. }
  48022. }
  48023. var stopsLen = stops.length;
  48024. return {
  48025. stops: stops,
  48026. outerColors: [
  48027. stopsLen ? stops[0].color : 'transparent',
  48028. stopsLen ? stops[stopsLen - 1].color : 'transparent'
  48029. ]
  48030. };
  48031. }
  48032. });
  48033. function getColorStopValues(visualMapModel, valueState, dataExtent) {
  48034. if (dataExtent[0] === dataExtent[1]) {
  48035. return dataExtent.slice();
  48036. }
  48037. // When using colorHue mapping, it is not linear color any more.
  48038. // Moreover, canvas gradient seems not to be accurate linear.
  48039. // FIXME
  48040. // Should be arbitrary value 100? or based on pixel size?
  48041. var count = 200;
  48042. var step = (dataExtent[1] - dataExtent[0]) / count;
  48043. var value = dataExtent[0];
  48044. var stopValues = [];
  48045. for (var i = 0; i <= count && value < dataExtent[1]; i++) {
  48046. stopValues.push(value);
  48047. value += step;
  48048. }
  48049. stopValues.push(dataExtent[1]);
  48050. return stopValues;
  48051. }
  48052. module.exports = ContinuousModel;
  48053. /***/ },
  48054. /* 338 */
  48055. /***/ function(module, exports, __webpack_require__) {
  48056. /**
  48057. * @file Controller visual map model
  48058. */
  48059. var echarts = __webpack_require__(1);
  48060. var zrUtil = __webpack_require__(4);
  48061. var env = __webpack_require__(2);
  48062. var visualDefault = __webpack_require__(339);
  48063. var VisualMapping = __webpack_require__(194);
  48064. var visualSolution = __webpack_require__(309);
  48065. var mapVisual = VisualMapping.mapVisual;
  48066. var modelUtil = __webpack_require__(5);
  48067. var eachVisual = VisualMapping.eachVisual;
  48068. var numberUtil = __webpack_require__(7);
  48069. var isArray = zrUtil.isArray;
  48070. var each = zrUtil.each;
  48071. var asc = numberUtil.asc;
  48072. var linearMap = numberUtil.linearMap;
  48073. var noop = zrUtil.noop;
  48074. var DEFAULT_COLOR = ['#f6efa6', '#d88273', '#bf444c'];
  48075. var VisualMapModel = echarts.extendComponentModel({
  48076. type: 'visualMap',
  48077. dependencies: ['series'],
  48078. /**
  48079. * @readOnly
  48080. * @type {Array.<string>}
  48081. */
  48082. stateList: ['inRange', 'outOfRange'],
  48083. /**
  48084. * @readOnly
  48085. * @type {Array.<string>}
  48086. */
  48087. replacableOptionKeys: [
  48088. 'inRange', 'outOfRange', 'target', 'controller', 'color'
  48089. ],
  48090. /**
  48091. * [lowerBound, upperBound]
  48092. *
  48093. * @readOnly
  48094. * @type {Array.<number>}
  48095. */
  48096. dataBound: [-Infinity, Infinity],
  48097. /**
  48098. * @readOnly
  48099. * @type {string|Object}
  48100. */
  48101. layoutMode: {type: 'box', ignoreSize: true},
  48102. /**
  48103. * @protected
  48104. */
  48105. defaultOption: {
  48106. show: true,
  48107. zlevel: 0,
  48108. z: 4,
  48109. seriesIndex: null, // 所控制的series indices,默认所有有value的series.
  48110. // set min: 0, max: 200, only for campatible with ec2.
  48111. // In fact min max should not have default value.
  48112. min: 0, // min value, must specified if pieces is not specified.
  48113. max: 200, // max value, must specified if pieces is not specified.
  48114. dimension: null,
  48115. inRange: null, // 'color', 'colorHue', 'colorSaturation', 'colorLightness', 'colorAlpha',
  48116. // 'symbol', 'symbolSize'
  48117. outOfRange: null, // 'color', 'colorHue', 'colorSaturation',
  48118. // 'colorLightness', 'colorAlpha',
  48119. // 'symbol', 'symbolSize'
  48120. left: 0, // 'center' ¦ 'left' ¦ 'right' ¦ {number} (px)
  48121. right: null, // The same as left.
  48122. top: null, // 'top' ¦ 'bottom' ¦ 'center' ¦ {number} (px)
  48123. bottom: 0, // The same as top.
  48124. itemWidth: null,
  48125. itemHeight: null,
  48126. inverse: false,
  48127. orient: 'vertical', // 'horizontal' ¦ 'vertical'
  48128. backgroundColor: 'rgba(0,0,0,0)',
  48129. borderColor: '#ccc', // 值域边框颜色
  48130. contentColor: '#5793f3',
  48131. inactiveColor: '#aaa',
  48132. borderWidth: 0, // 值域边框线宽,单位px,默认为0(无边框)
  48133. padding: 5, // 值域内边距,单位px,默认各方向内边距为5,
  48134. // 接受数组分别设定上右下左边距,同css
  48135. textGap: 10, //
  48136. precision: 0, // 小数精度,默认为0,无小数点
  48137. color: null, //颜色(deprecated,兼容ec2,顺序同pieces,不同于inRange/outOfRange)
  48138. formatter: null,
  48139. text: null, // 文本,如['高', '低'],兼容ec2,text[0]对应高值,text[1]对应低值
  48140. textStyle: {
  48141. color: '#333' // 值域文字颜色
  48142. }
  48143. },
  48144. /**
  48145. * @protected
  48146. */
  48147. init: function (option, parentModel, ecModel) {
  48148. /**
  48149. * @private
  48150. * @type {Array.<number>}
  48151. */
  48152. this._dataExtent;
  48153. /**
  48154. * @readOnly
  48155. */
  48156. this.targetVisuals = {};
  48157. /**
  48158. * @readOnly
  48159. */
  48160. this.controllerVisuals = {};
  48161. /**
  48162. * @readOnly
  48163. */
  48164. this.textStyleModel;
  48165. /**
  48166. * [width, height]
  48167. * @readOnly
  48168. * @type {Array.<number>}
  48169. */
  48170. this.itemSize;
  48171. this.mergeDefaultAndTheme(option, ecModel);
  48172. },
  48173. /**
  48174. * @protected
  48175. */
  48176. optionUpdated: function (newOption, isInit) {
  48177. var thisOption = this.option;
  48178. // FIXME
  48179. // necessary?
  48180. // Disable realtime view update if canvas is not supported.
  48181. if (!env.canvasSupported) {
  48182. thisOption.realtime = false;
  48183. }
  48184. !isInit && visualSolution.replaceVisualOption(
  48185. thisOption, newOption, this.replacableOptionKeys
  48186. );
  48187. this.textStyleModel = this.getModel('textStyle');
  48188. this.resetItemSize();
  48189. this.completeVisualOption();
  48190. },
  48191. /**
  48192. * @protected
  48193. */
  48194. resetVisual: function (supplementVisualOption) {
  48195. var stateList = this.stateList;
  48196. supplementVisualOption = zrUtil.bind(supplementVisualOption, this);
  48197. this.controllerVisuals = visualSolution.createVisualMappings(
  48198. this.option.controller, stateList, supplementVisualOption
  48199. );
  48200. this.targetVisuals = visualSolution.createVisualMappings(
  48201. this.option.target, stateList, supplementVisualOption
  48202. );
  48203. },
  48204. /**
  48205. * @protected
  48206. */
  48207. resetTargetSeries: function () {
  48208. var thisOption = this.option;
  48209. var allSeriesIndex = thisOption.seriesIndex == null;
  48210. thisOption.seriesIndex = allSeriesIndex
  48211. ? [] : modelUtil.normalizeToArray(thisOption.seriesIndex);
  48212. allSeriesIndex && this.ecModel.eachSeries(function (seriesModel, index) {
  48213. thisOption.seriesIndex.push(index);
  48214. });
  48215. },
  48216. /**
  48217. * @public
  48218. */
  48219. eachTargetSeries: function (callback, context) {
  48220. zrUtil.each(this.option.seriesIndex, function (seriesIndex) {
  48221. callback.call(context, this.ecModel.getSeriesByIndex(seriesIndex));
  48222. }, this);
  48223. },
  48224. /**
  48225. * @pubilc
  48226. */
  48227. isTargetSeries: function (seriesModel) {
  48228. var is = false;
  48229. this.eachTargetSeries(function (model) {
  48230. model === seriesModel && (is = true);
  48231. });
  48232. return is;
  48233. },
  48234. /**
  48235. * @example
  48236. * this.formatValueText(someVal); // format single numeric value to text.
  48237. * this.formatValueText(someVal, true); // format single category value to text.
  48238. * this.formatValueText([min, max]); // format numeric min-max to text.
  48239. * this.formatValueText([this.dataBound[0], max]); // using data lower bound.
  48240. * this.formatValueText([min, this.dataBound[1]]); // using data upper bound.
  48241. *
  48242. * @param {number|Array.<number>} value Real value, or this.dataBound[0 or 1].
  48243. * @param {boolean} [isCategory=false] Only available when value is number.
  48244. * @param {Array.<string>} edgeSymbols Open-close symbol when value is interval.
  48245. * @return {string}
  48246. * @protected
  48247. */
  48248. formatValueText: function(value, isCategory, edgeSymbols) {
  48249. var option = this.option;
  48250. var precision = option.precision;
  48251. var dataBound = this.dataBound;
  48252. var formatter = option.formatter;
  48253. var isMinMax;
  48254. var textValue;
  48255. edgeSymbols = edgeSymbols || ['<', '>'];
  48256. if (zrUtil.isArray(value)) {
  48257. value = value.slice();
  48258. isMinMax = true;
  48259. }
  48260. textValue = isCategory
  48261. ? value
  48262. : (isMinMax
  48263. ? [toFixed(value[0]), toFixed(value[1])]
  48264. : toFixed(value)
  48265. );
  48266. if (zrUtil.isString(formatter)) {
  48267. return formatter
  48268. .replace('{value}', isMinMax ? textValue[0] : textValue)
  48269. .replace('{value2}', isMinMax ? textValue[1] : textValue);
  48270. }
  48271. else if (zrUtil.isFunction(formatter)) {
  48272. return isMinMax
  48273. ? formatter(value[0], value[1])
  48274. : formatter(value);
  48275. }
  48276. if (isMinMax) {
  48277. if (value[0] === dataBound[0]) {
  48278. return edgeSymbols[0] + ' ' + textValue[1];
  48279. }
  48280. else if (value[1] === dataBound[1]) {
  48281. return edgeSymbols[1] + ' ' + textValue[0];
  48282. }
  48283. else {
  48284. return textValue[0] + ' - ' + textValue[1];
  48285. }
  48286. }
  48287. else { // Format single value (includes category case).
  48288. return textValue;
  48289. }
  48290. function toFixed(val) {
  48291. return val === dataBound[0]
  48292. ? 'min'
  48293. : val === dataBound[1]
  48294. ? 'max'
  48295. : (+val).toFixed(precision);
  48296. }
  48297. },
  48298. /**
  48299. * @protected
  48300. */
  48301. resetExtent: function () {
  48302. var thisOption = this.option;
  48303. // Can not calculate data extent by data here.
  48304. // Because series and data may be modified in processing stage.
  48305. // So we do not support the feature "auto min/max".
  48306. var extent = asc([thisOption.min, thisOption.max]);
  48307. this._dataExtent = extent;
  48308. },
  48309. /**
  48310. * @public
  48311. * @param {module:echarts/data/List} list
  48312. * @return {string} Concrete dimention. If return null/undefined,
  48313. * no dimension used.
  48314. */
  48315. getDataDimension: function (list) {
  48316. var optDim = this.option.dimension;
  48317. return optDim != null
  48318. ? optDim : list.dimensions.length - 1;
  48319. },
  48320. /**
  48321. * @public
  48322. * @override
  48323. */
  48324. getExtent: function () {
  48325. return this._dataExtent.slice();
  48326. },
  48327. /**
  48328. * @protected
  48329. */
  48330. completeVisualOption: function () {
  48331. var thisOption = this.option;
  48332. var base = {inRange: thisOption.inRange, outOfRange: thisOption.outOfRange};
  48333. var target = thisOption.target || (thisOption.target = {});
  48334. var controller = thisOption.controller || (thisOption.controller = {});
  48335. zrUtil.merge(target, base); // Do not override
  48336. zrUtil.merge(controller, base); // Do not override
  48337. var isCategory = this.isCategory();
  48338. completeSingle.call(this, target);
  48339. completeSingle.call(this, controller);
  48340. completeInactive.call(this, target, 'inRange', 'outOfRange');
  48341. // completeInactive.call(this, target, 'outOfRange', 'inRange');
  48342. completeController.call(this, controller);
  48343. function completeSingle(base) {
  48344. // Compatible with ec2 dataRange.color.
  48345. // The mapping order of dataRange.color is: [high value, ..., low value]
  48346. // whereas inRange.color and outOfRange.color is [low value, ..., high value]
  48347. // Notice: ec2 has no inverse.
  48348. if (isArray(thisOption.color)
  48349. // If there has been inRange: {symbol: ...}, adding color is a mistake.
  48350. // So adding color only when no inRange defined.
  48351. && !base.inRange
  48352. ) {
  48353. base.inRange = {color: thisOption.color.slice().reverse()};
  48354. }
  48355. // Compatible with previous logic, always give a defautl color, otherwise
  48356. // simple config with no inRange and outOfRange will not work.
  48357. // Originally we use visualMap.color as the default color, but setOption at
  48358. // the second time the default color will be erased. So we change to use
  48359. // constant DEFAULT_COLOR.
  48360. // If user do not want the defualt color, set inRange: {color: null}.
  48361. base.inRange = base.inRange || {color: DEFAULT_COLOR};
  48362. // If using shortcut like: {inRange: 'symbol'}, complete default value.
  48363. each(this.stateList, function (state) {
  48364. var visualType = base[state];
  48365. if (zrUtil.isString(visualType)) {
  48366. var defa = visualDefault.get(visualType, 'active', isCategory);
  48367. if (defa) {
  48368. base[state] = {};
  48369. base[state][visualType] = defa;
  48370. }
  48371. else {
  48372. // Mark as not specified.
  48373. delete base[state];
  48374. }
  48375. }
  48376. }, this);
  48377. }
  48378. function completeInactive(base, stateExist, stateAbsent) {
  48379. var optExist = base[stateExist];
  48380. var optAbsent = base[stateAbsent];
  48381. if (optExist && !optAbsent) {
  48382. optAbsent = base[stateAbsent] = {};
  48383. each(optExist, function (visualData, visualType) {
  48384. if (!VisualMapping.isValidType(visualType)) {
  48385. return;
  48386. }
  48387. var defa = visualDefault.get(visualType, 'inactive', isCategory);
  48388. if (defa != null) {
  48389. optAbsent[visualType] = defa;
  48390. // Compatibable with ec2:
  48391. // Only inactive color to rgba(0,0,0,0) can not
  48392. // make label transparent, so use opacity also.
  48393. if (visualType === 'color'
  48394. && !optAbsent.hasOwnProperty('opacity')
  48395. && !optAbsent.hasOwnProperty('colorAlpha')
  48396. ) {
  48397. optAbsent.opacity = [0, 0];
  48398. }
  48399. }
  48400. });
  48401. }
  48402. }
  48403. function completeController(controller) {
  48404. var symbolExists = (controller.inRange || {}).symbol
  48405. || (controller.outOfRange || {}).symbol;
  48406. var symbolSizeExists = (controller.inRange || {}).symbolSize
  48407. || (controller.outOfRange || {}).symbolSize;
  48408. var inactiveColor = this.get('inactiveColor');
  48409. each(this.stateList, function (state) {
  48410. var itemSize = this.itemSize;
  48411. var visuals = controller[state];
  48412. // Set inactive color for controller if no other color
  48413. // attr (like colorAlpha) specified.
  48414. if (!visuals) {
  48415. visuals = controller[state] = {
  48416. color: isCategory ? inactiveColor : [inactiveColor]
  48417. };
  48418. }
  48419. // Consistent symbol and symbolSize if not specified.
  48420. if (visuals.symbol == null) {
  48421. visuals.symbol = symbolExists
  48422. && zrUtil.clone(symbolExists)
  48423. || (isCategory ? 'roundRect' : ['roundRect']);
  48424. }
  48425. if (visuals.symbolSize == null) {
  48426. visuals.symbolSize = symbolSizeExists
  48427. && zrUtil.clone(symbolSizeExists)
  48428. || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]);
  48429. }
  48430. // Filter square and none.
  48431. visuals.symbol = mapVisual(visuals.symbol, function (symbol) {
  48432. return (symbol === 'none' || symbol === 'square') ? 'roundRect' : symbol;
  48433. });
  48434. // Normalize symbolSize
  48435. var symbolSize = visuals.symbolSize;
  48436. if (symbolSize != null) {
  48437. var max = -Infinity;
  48438. // symbolSize can be object when categories defined.
  48439. eachVisual(symbolSize, function (value) {
  48440. value > max && (max = value);
  48441. });
  48442. visuals.symbolSize = mapVisual(symbolSize, function (value) {
  48443. return linearMap(value, [0, max], [0, itemSize[0]], true);
  48444. });
  48445. }
  48446. }, this);
  48447. }
  48448. },
  48449. /**
  48450. * @protected
  48451. */
  48452. resetItemSize: function () {
  48453. this.itemSize = [
  48454. parseFloat(this.get('itemWidth')),
  48455. parseFloat(this.get('itemHeight'))
  48456. ];
  48457. },
  48458. /**
  48459. * @public
  48460. */
  48461. isCategory: function () {
  48462. return !!this.option.categories;
  48463. },
  48464. /**
  48465. * @public
  48466. * @abstract
  48467. */
  48468. setSelected: noop,
  48469. /**
  48470. * @public
  48471. * @abstract
  48472. * @param {*|module:echarts/data/List} valueOrData
  48473. * @param {number} dataIndex
  48474. * @return {string} state See this.stateList
  48475. */
  48476. getValueState: noop,
  48477. /**
  48478. * FIXME
  48479. * Do not publish to thirt-part-dev temporarily
  48480. * util the interface is stable. (Should it return
  48481. * a function but not visual meta?)
  48482. *
  48483. * @pubilc
  48484. * @abstract
  48485. * @param {Function} getColorVisual
  48486. * params: value, valueState
  48487. * return: color
  48488. * @return {Object} visualMeta
  48489. * should includes {stops, outerColors}
  48490. * outerColor means [colorBeyondMinValue, colorBeyondMaxValue]
  48491. */
  48492. getVisualMeta: noop
  48493. });
  48494. module.exports = VisualMapModel;
  48495. /***/ },
  48496. /* 339 */
  48497. /***/ function(module, exports, __webpack_require__) {
  48498. /**
  48499. * @file Visual mapping.
  48500. */
  48501. var zrUtil = __webpack_require__(4);
  48502. var visualDefault = {
  48503. /**
  48504. * @public
  48505. */
  48506. get: function (visualType, key, isCategory) {
  48507. var value = zrUtil.clone(
  48508. (defaultOption[visualType] || {})[key]
  48509. );
  48510. return isCategory
  48511. ? (zrUtil.isArray(value) ? value[value.length - 1] : value)
  48512. : value;
  48513. }
  48514. };
  48515. var defaultOption = {
  48516. color: {
  48517. active: ['#006edd', '#e0ffff'],
  48518. inactive: ['rgba(0,0,0,0)']
  48519. },
  48520. colorHue: {
  48521. active: [0, 360],
  48522. inactive: [0, 0]
  48523. },
  48524. colorSaturation: {
  48525. active: [0.3, 1],
  48526. inactive: [0, 0]
  48527. },
  48528. colorLightness: {
  48529. active: [0.9, 0.5],
  48530. inactive: [0, 0]
  48531. },
  48532. colorAlpha: {
  48533. active: [0.3, 1],
  48534. inactive: [0, 0]
  48535. },
  48536. opacity: {
  48537. active: [0.3, 1],
  48538. inactive: [0, 0]
  48539. },
  48540. symbol: {
  48541. active: ['circle', 'roundRect', 'diamond'],
  48542. inactive: ['none']
  48543. },
  48544. symbolSize: {
  48545. active: [10, 50],
  48546. inactive: [0, 0]
  48547. }
  48548. };
  48549. module.exports = visualDefault;
  48550. /***/ },
  48551. /* 340 */
  48552. /***/ function(module, exports, __webpack_require__) {
  48553. var VisualMapView = __webpack_require__(341);
  48554. var graphic = __webpack_require__(43);
  48555. var zrUtil = __webpack_require__(4);
  48556. var numberUtil = __webpack_require__(7);
  48557. var sliderMove = __webpack_require__(326);
  48558. var LinearGradient = __webpack_require__(78);
  48559. var helper = __webpack_require__(342);
  48560. var modelUtil = __webpack_require__(5);
  48561. var linearMap = numberUtil.linearMap;
  48562. var each = zrUtil.each;
  48563. var mathMin = Math.min;
  48564. var mathMax = Math.max;
  48565. // Arbitrary value
  48566. var HOVER_LINK_SIZE = 12;
  48567. var HOVER_LINK_OUT = 6;
  48568. // Notice:
  48569. // Any "interval" should be by the order of [low, high].
  48570. // "handle0" (handleIndex === 0) maps to
  48571. // low data value: this._dataInterval[0] and has low coord.
  48572. // "handle1" (handleIndex === 1) maps to
  48573. // high data value: this._dataInterval[1] and has high coord.
  48574. // The logic of transform is implemented in this._createBarGroup.
  48575. var ContinuousView = VisualMapView.extend({
  48576. type: 'visualMap.continuous',
  48577. /**
  48578. * @override
  48579. */
  48580. init: function () {
  48581. ContinuousView.superApply(this, 'init', arguments);
  48582. /**
  48583. * @private
  48584. */
  48585. this._shapes = {};
  48586. /**
  48587. * @private
  48588. */
  48589. this._dataInterval = [];
  48590. /**
  48591. * @private
  48592. */
  48593. this._handleEnds = [];
  48594. /**
  48595. * @private
  48596. */
  48597. this._orient;
  48598. /**
  48599. * @private
  48600. */
  48601. this._useHandle;
  48602. /**
  48603. * @private
  48604. */
  48605. this._hoverLinkDataIndices = [];
  48606. /**
  48607. * @private
  48608. */
  48609. this._dragging;
  48610. /**
  48611. * @private
  48612. */
  48613. this._hovering;
  48614. },
  48615. /**
  48616. * @protected
  48617. * @override
  48618. */
  48619. doRender: function (visualMapModel, ecModel, api, payload) {
  48620. if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) {
  48621. this._buildView();
  48622. }
  48623. },
  48624. /**
  48625. * @private
  48626. */
  48627. _buildView: function () {
  48628. this.group.removeAll();
  48629. var visualMapModel = this.visualMapModel;
  48630. var thisGroup = this.group;
  48631. this._orient = visualMapModel.get('orient');
  48632. this._useHandle = visualMapModel.get('calculable');
  48633. this._resetInterval();
  48634. this._renderBar(thisGroup);
  48635. var dataRangeText = visualMapModel.get('text');
  48636. this._renderEndsText(thisGroup, dataRangeText, 0);
  48637. this._renderEndsText(thisGroup, dataRangeText, 1);
  48638. // Do this for background size calculation.
  48639. this._updateView(true);
  48640. // After updating view, inner shapes is built completely,
  48641. // and then background can be rendered.
  48642. this.renderBackground(thisGroup);
  48643. // Real update view
  48644. this._updateView();
  48645. this._enableHoverLinkToSeries();
  48646. this._enableHoverLinkFromSeries();
  48647. this.positionGroup(thisGroup);
  48648. },
  48649. /**
  48650. * @private
  48651. */
  48652. _renderEndsText: function (group, dataRangeText, endsIndex) {
  48653. if (!dataRangeText) {
  48654. return;
  48655. }
  48656. // Compatible with ec2, text[0] map to high value, text[1] map low value.
  48657. var text = dataRangeText[1 - endsIndex];
  48658. text = text != null ? text + '' : '';
  48659. var visualMapModel = this.visualMapModel;
  48660. var textGap = visualMapModel.get('textGap');
  48661. var itemSize = visualMapModel.itemSize;
  48662. var barGroup = this._shapes.barGroup;
  48663. var position = this._applyTransform(
  48664. [
  48665. itemSize[0] / 2,
  48666. endsIndex === 0 ? -textGap : itemSize[1] + textGap
  48667. ],
  48668. barGroup
  48669. );
  48670. var align = this._applyTransform(
  48671. endsIndex === 0 ? 'bottom' : 'top',
  48672. barGroup
  48673. );
  48674. var orient = this._orient;
  48675. var textStyleModel = this.visualMapModel.textStyleModel;
  48676. this.group.add(new graphic.Text({
  48677. style: {
  48678. x: position[0],
  48679. y: position[1],
  48680. textVerticalAlign: orient === 'horizontal' ? 'middle' : align,
  48681. textAlign: orient === 'horizontal' ? align : 'center',
  48682. text: text,
  48683. textFont: textStyleModel.getFont(),
  48684. fill: textStyleModel.getTextColor()
  48685. }
  48686. }));
  48687. },
  48688. /**
  48689. * @private
  48690. */
  48691. _renderBar: function (targetGroup) {
  48692. var visualMapModel = this.visualMapModel;
  48693. var shapes = this._shapes;
  48694. var itemSize = visualMapModel.itemSize;
  48695. var orient = this._orient;
  48696. var useHandle = this._useHandle;
  48697. var itemAlign = helper.getItemAlign(visualMapModel, this.api, itemSize);
  48698. var barGroup = shapes.barGroup = this._createBarGroup(itemAlign);
  48699. // Bar
  48700. barGroup.add(shapes.outOfRange = createPolygon());
  48701. barGroup.add(shapes.inRange = createPolygon(
  48702. null,
  48703. useHandle ? 'move' : null,
  48704. zrUtil.bind(this._dragHandle, this, 'all', false),
  48705. zrUtil.bind(this._dragHandle, this, 'all', true)
  48706. ));
  48707. var textRect = visualMapModel.textStyleModel.getTextRect('国');
  48708. var textSize = mathMax(textRect.width, textRect.height);
  48709. // Handle
  48710. if (useHandle) {
  48711. shapes.handleThumbs = [];
  48712. shapes.handleLabels = [];
  48713. shapes.handleLabelPoints = [];
  48714. this._createHandle(barGroup, 0, itemSize, textSize, orient, itemAlign);
  48715. this._createHandle(barGroup, 1, itemSize, textSize, orient, itemAlign);
  48716. }
  48717. this._createIndicator(barGroup, itemSize, textSize, orient);
  48718. targetGroup.add(barGroup);
  48719. },
  48720. /**
  48721. * @private
  48722. */
  48723. _createHandle: function (barGroup, handleIndex, itemSize, textSize, orient) {
  48724. var onDrift = zrUtil.bind(this._dragHandle, this, handleIndex, false);
  48725. var onDragEnd = zrUtil.bind(this._dragHandle, this, handleIndex, true);
  48726. var handleThumb = createPolygon(
  48727. createHandlePoints(handleIndex, textSize),
  48728. 'move',
  48729. onDrift,
  48730. onDragEnd
  48731. );
  48732. handleThumb.position[0] = itemSize[0];
  48733. barGroup.add(handleThumb);
  48734. // Text is always horizontal layout but should not be effected by
  48735. // transform (orient/inverse). So label is built separately but not
  48736. // use zrender/graphic/helper/RectText, and is located based on view
  48737. // group (according to handleLabelPoint) but not barGroup.
  48738. var textStyleModel = this.visualMapModel.textStyleModel;
  48739. var handleLabel = new graphic.Text({
  48740. draggable: true,
  48741. drift: onDrift,
  48742. ondragend: onDragEnd,
  48743. style: {
  48744. x: 0, y: 0, text: '',
  48745. textFont: textStyleModel.getFont(),
  48746. fill: textStyleModel.getTextColor()
  48747. }
  48748. });
  48749. this.group.add(handleLabel);
  48750. var handleLabelPoint = [
  48751. orient === 'horizontal'
  48752. ? textSize / 2
  48753. : textSize * 1.5,
  48754. orient === 'horizontal'
  48755. ? (handleIndex === 0 ? -(textSize * 1.5) : (textSize * 1.5))
  48756. : (handleIndex === 0 ? -textSize / 2 : textSize / 2)
  48757. ];
  48758. var shapes = this._shapes;
  48759. shapes.handleThumbs[handleIndex] = handleThumb;
  48760. shapes.handleLabelPoints[handleIndex] = handleLabelPoint;
  48761. shapes.handleLabels[handleIndex] = handleLabel;
  48762. },
  48763. /**
  48764. * @private
  48765. */
  48766. _createIndicator: function (barGroup, itemSize, textSize, orient) {
  48767. var indicator = createPolygon([[0, 0]], 'move');
  48768. indicator.position[0] = itemSize[0];
  48769. indicator.attr({invisible: true, silent: true});
  48770. barGroup.add(indicator);
  48771. var textStyleModel = this.visualMapModel.textStyleModel;
  48772. var indicatorLabel = new graphic.Text({
  48773. silent: true,
  48774. invisible: true,
  48775. style: {
  48776. x: 0, y: 0, text: '',
  48777. textFont: textStyleModel.getFont(),
  48778. fill: textStyleModel.getTextColor()
  48779. }
  48780. });
  48781. this.group.add(indicatorLabel);
  48782. var indicatorLabelPoint = [
  48783. orient === 'horizontal' ? textSize / 2 : HOVER_LINK_OUT + 3,
  48784. 0
  48785. ];
  48786. var shapes = this._shapes;
  48787. shapes.indicator = indicator;
  48788. shapes.indicatorLabel = indicatorLabel;
  48789. shapes.indicatorLabelPoint = indicatorLabelPoint;
  48790. },
  48791. /**
  48792. * @private
  48793. */
  48794. _dragHandle: function (handleIndex, isEnd, dx, dy) {
  48795. if (!this._useHandle) {
  48796. return;
  48797. }
  48798. this._dragging = !isEnd;
  48799. if (!isEnd) {
  48800. // Transform dx, dy to bar coordination.
  48801. var vertex = this._applyTransform([dx, dy], this._shapes.barGroup, true);
  48802. this._updateInterval(handleIndex, vertex[1]);
  48803. // Considering realtime, update view should be executed
  48804. // before dispatch action.
  48805. this._updateView();
  48806. }
  48807. // dragEnd do not dispatch action when realtime.
  48808. if (isEnd === !this.visualMapModel.get('realtime')) { // jshint ignore:line
  48809. this.api.dispatchAction({
  48810. type: 'selectDataRange',
  48811. from: this.uid,
  48812. visualMapId: this.visualMapModel.id,
  48813. selected: this._dataInterval.slice()
  48814. });
  48815. }
  48816. if (isEnd) {
  48817. !this._hovering && this._clearHoverLinkToSeries();
  48818. }
  48819. else if (useHoverLinkOnHandle(this.visualMapModel)) {
  48820. this._doHoverLinkToSeries(this._handleEnds[handleIndex], false);
  48821. }
  48822. },
  48823. /**
  48824. * @private
  48825. */
  48826. _resetInterval: function () {
  48827. var visualMapModel = this.visualMapModel;
  48828. var dataInterval = this._dataInterval = visualMapModel.getSelected();
  48829. var dataExtent = visualMapModel.getExtent();
  48830. var sizeExtent = [0, visualMapModel.itemSize[1]];
  48831. this._handleEnds = [
  48832. linearMap(dataInterval[0], dataExtent, sizeExtent, true),
  48833. linearMap(dataInterval[1], dataExtent, sizeExtent, true)
  48834. ];
  48835. },
  48836. /**
  48837. * @private
  48838. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  48839. * @param {number} dx
  48840. * @param {number} dy
  48841. */
  48842. _updateInterval: function (handleIndex, delta) {
  48843. delta = delta || 0;
  48844. var visualMapModel = this.visualMapModel;
  48845. var handleEnds = this._handleEnds;
  48846. sliderMove(
  48847. delta,
  48848. handleEnds,
  48849. [0, visualMapModel.itemSize[1]],
  48850. handleIndex === 'all' ? 'rigid' : 'push',
  48851. handleIndex
  48852. );
  48853. var dataExtent = visualMapModel.getExtent();
  48854. var sizeExtent = [0, visualMapModel.itemSize[1]];
  48855. // Update data interval.
  48856. this._dataInterval = [
  48857. linearMap(handleEnds[0], sizeExtent, dataExtent, true),
  48858. linearMap(handleEnds[1], sizeExtent, dataExtent, true)
  48859. ];
  48860. },
  48861. /**
  48862. * @private
  48863. */
  48864. _updateView: function (forSketch) {
  48865. var visualMapModel = this.visualMapModel;
  48866. var dataExtent = visualMapModel.getExtent();
  48867. var shapes = this._shapes;
  48868. var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]];
  48869. var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds;
  48870. var visualInRange = this._createBarVisual(
  48871. this._dataInterval, dataExtent, inRangeHandleEnds, 'inRange'
  48872. );
  48873. var visualOutOfRange = this._createBarVisual(
  48874. dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange'
  48875. );
  48876. shapes.inRange
  48877. .setStyle({
  48878. fill: visualInRange.barColor,
  48879. opacity: visualInRange.opacity
  48880. })
  48881. .setShape('points', visualInRange.barPoints);
  48882. shapes.outOfRange
  48883. .setStyle({
  48884. fill: visualOutOfRange.barColor,
  48885. opacity: visualOutOfRange.opacity
  48886. })
  48887. .setShape('points', visualOutOfRange.barPoints);
  48888. this._updateHandle(inRangeHandleEnds, visualInRange);
  48889. },
  48890. /**
  48891. * @private
  48892. */
  48893. _createBarVisual: function (dataInterval, dataExtent, handleEnds, forceState) {
  48894. var opts = {
  48895. forceState: forceState,
  48896. convertOpacityToAlpha: true
  48897. };
  48898. var colorStops = this._makeColorGradient(dataInterval, opts);
  48899. var symbolSizes = [
  48900. this.getControllerVisual(dataInterval[0], 'symbolSize', opts),
  48901. this.getControllerVisual(dataInterval[1], 'symbolSize', opts)
  48902. ];
  48903. var barPoints = this._createBarPoints(handleEnds, symbolSizes);
  48904. return {
  48905. barColor: new LinearGradient(0, 0, 0, 1, colorStops),
  48906. barPoints: barPoints,
  48907. handlesColor: [
  48908. colorStops[0].color,
  48909. colorStops[colorStops.length - 1].color
  48910. ]
  48911. };
  48912. },
  48913. /**
  48914. * @private
  48915. */
  48916. _makeColorGradient: function (dataInterval, opts) {
  48917. // Considering colorHue, which is not linear, so we have to sample
  48918. // to calculate gradient color stops, but not only caculate head
  48919. // and tail.
  48920. var sampleNumber = 100; // Arbitrary value.
  48921. var colorStops = [];
  48922. var step = (dataInterval[1] - dataInterval[0]) / sampleNumber;
  48923. colorStops.push({
  48924. color: this.getControllerVisual(dataInterval[0], 'color', opts),
  48925. offset: 0
  48926. });
  48927. for (var i = 1; i < sampleNumber; i++) {
  48928. var currValue = dataInterval[0] + step * i;
  48929. if (currValue > dataInterval[1]) {
  48930. break;
  48931. }
  48932. colorStops.push({
  48933. color: this.getControllerVisual(currValue, 'color', opts),
  48934. offset: i / sampleNumber
  48935. });
  48936. }
  48937. colorStops.push({
  48938. color: this.getControllerVisual(dataInterval[1], 'color', opts),
  48939. offset: 1
  48940. });
  48941. return colorStops;
  48942. },
  48943. /**
  48944. * @private
  48945. */
  48946. _createBarPoints: function (handleEnds, symbolSizes) {
  48947. var itemSize = this.visualMapModel.itemSize;
  48948. return [
  48949. [itemSize[0] - symbolSizes[0], handleEnds[0]],
  48950. [itemSize[0], handleEnds[0]],
  48951. [itemSize[0], handleEnds[1]],
  48952. [itemSize[0] - symbolSizes[1], handleEnds[1]]
  48953. ];
  48954. },
  48955. /**
  48956. * @private
  48957. */
  48958. _createBarGroup: function (itemAlign) {
  48959. var orient = this._orient;
  48960. var inverse = this.visualMapModel.get('inverse');
  48961. return new graphic.Group(
  48962. (orient === 'horizontal' && !inverse)
  48963. ? {scale: itemAlign === 'bottom' ? [1, 1] : [-1, 1], rotation: Math.PI / 2}
  48964. : (orient === 'horizontal' && inverse)
  48965. ? {scale: itemAlign === 'bottom' ? [-1, 1] : [1, 1], rotation: -Math.PI / 2}
  48966. : (orient === 'vertical' && !inverse)
  48967. ? {scale: itemAlign === 'left' ? [1, -1] : [-1, -1]}
  48968. : {scale: itemAlign === 'left' ? [1, 1] : [-1, 1]}
  48969. );
  48970. },
  48971. /**
  48972. * @private
  48973. */
  48974. _updateHandle: function (handleEnds, visualInRange) {
  48975. if (!this._useHandle) {
  48976. return;
  48977. }
  48978. var shapes = this._shapes;
  48979. var visualMapModel = this.visualMapModel;
  48980. var handleThumbs = shapes.handleThumbs;
  48981. var handleLabels = shapes.handleLabels;
  48982. each([0, 1], function (handleIndex) {
  48983. var handleThumb = handleThumbs[handleIndex];
  48984. handleThumb.setStyle('fill', visualInRange.handlesColor[handleIndex]);
  48985. handleThumb.position[1] = handleEnds[handleIndex];
  48986. // Update handle label position.
  48987. var textPoint = graphic.applyTransform(
  48988. shapes.handleLabelPoints[handleIndex],
  48989. graphic.getTransform(handleThumb, this.group)
  48990. );
  48991. handleLabels[handleIndex].setStyle({
  48992. x: textPoint[0],
  48993. y: textPoint[1],
  48994. text: visualMapModel.formatValueText(this._dataInterval[handleIndex]),
  48995. textVerticalAlign: 'middle',
  48996. textAlign: this._applyTransform(
  48997. this._orient === 'horizontal'
  48998. ? (handleIndex === 0 ? 'bottom' : 'top')
  48999. : 'left',
  49000. shapes.barGroup
  49001. )
  49002. });
  49003. }, this);
  49004. },
  49005. /**
  49006. * @private
  49007. * @param {number} cursorValue
  49008. * @param {number} textValue
  49009. * @param {string} [rangeSymbol]
  49010. * @param {number} [halfHoverLinkSize]
  49011. */
  49012. _showIndicator: function (cursorValue, textValue, rangeSymbol, halfHoverLinkSize) {
  49013. var visualMapModel = this.visualMapModel;
  49014. var dataExtent = visualMapModel.getExtent();
  49015. var itemSize = visualMapModel.itemSize;
  49016. var sizeExtent = [0, itemSize[1]];
  49017. var pos = linearMap(cursorValue, dataExtent, sizeExtent, true);
  49018. var shapes = this._shapes;
  49019. var indicator = shapes.indicator;
  49020. if (!indicator) {
  49021. return;
  49022. }
  49023. indicator.position[1] = pos;
  49024. indicator.attr('invisible', false);
  49025. indicator.setShape('points', createIndicatorPoints(
  49026. !!rangeSymbol, halfHoverLinkSize, pos, itemSize[1]
  49027. ));
  49028. var opts = {convertOpacityToAlpha: true};
  49029. var color = this.getControllerVisual(cursorValue, 'color', opts);
  49030. indicator.setStyle('fill', color);
  49031. // Update handle label position.
  49032. var textPoint = graphic.applyTransform(
  49033. shapes.indicatorLabelPoint,
  49034. graphic.getTransform(indicator, this.group)
  49035. );
  49036. var indicatorLabel = shapes.indicatorLabel;
  49037. indicatorLabel.attr('invisible', false);
  49038. var align = this._applyTransform('left', shapes.barGroup);
  49039. var orient = this._orient;
  49040. indicatorLabel.setStyle({
  49041. text: (rangeSymbol ? rangeSymbol : '') + visualMapModel.formatValueText(textValue),
  49042. textVerticalAlign: orient === 'horizontal' ? align : 'middle',
  49043. textAlign: orient === 'horizontal' ? 'center' : align,
  49044. x: textPoint[0],
  49045. y: textPoint[1]
  49046. });
  49047. },
  49048. /**
  49049. * @private
  49050. */
  49051. _enableHoverLinkToSeries: function () {
  49052. var self = this;
  49053. this._shapes.barGroup
  49054. .on('mousemove', function (e) {
  49055. self._hovering = true;
  49056. if (!self._dragging) {
  49057. var itemSize = self.visualMapModel.itemSize;
  49058. var pos = self._applyTransform(
  49059. [e.offsetX, e.offsetY], self._shapes.barGroup, true, true
  49060. );
  49061. // For hover link show when hover handle, which might be
  49062. // below or upper than sizeExtent.
  49063. pos[1] = mathMin(mathMax(0, pos[1]), itemSize[1]);
  49064. self._doHoverLinkToSeries(
  49065. pos[1],
  49066. 0 <= pos[0] && pos[0] <= itemSize[0]
  49067. );
  49068. }
  49069. })
  49070. .on('mouseout', function () {
  49071. // When mouse is out of handle, hoverLink still need
  49072. // to be displayed when realtime is set as false.
  49073. self._hovering = false;
  49074. !self._dragging && self._clearHoverLinkToSeries();
  49075. });
  49076. },
  49077. /**
  49078. * @private
  49079. */
  49080. _enableHoverLinkFromSeries: function () {
  49081. var zr = this.api.getZr();
  49082. if (this.visualMapModel.option.hoverLink) {
  49083. zr.on('mouseover', this._hoverLinkFromSeriesMouseOver, this);
  49084. zr.on('mouseout', this._hideIndicator, this);
  49085. }
  49086. else {
  49087. this._clearHoverLinkFromSeries();
  49088. }
  49089. },
  49090. /**
  49091. * @private
  49092. */
  49093. _doHoverLinkToSeries: function (cursorPos, hoverOnBar) {
  49094. var visualMapModel = this.visualMapModel;
  49095. var itemSize = visualMapModel.itemSize;
  49096. if (!visualMapModel.option.hoverLink) {
  49097. return;
  49098. }
  49099. var sizeExtent = [0, itemSize[1]];
  49100. var dataExtent = visualMapModel.getExtent();
  49101. // For hover link show when hover handle, which might be below or upper than sizeExtent.
  49102. cursorPos = mathMin(mathMax(sizeExtent[0], cursorPos), sizeExtent[1]);
  49103. var halfHoverLinkSize = getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent);
  49104. var hoverRange = [cursorPos - halfHoverLinkSize, cursorPos + halfHoverLinkSize];
  49105. var cursorValue = linearMap(cursorPos, sizeExtent, dataExtent, true);
  49106. var valueRange = [
  49107. linearMap(hoverRange[0], sizeExtent, dataExtent, true),
  49108. linearMap(hoverRange[1], sizeExtent, dataExtent, true)
  49109. ];
  49110. // Consider data range is out of visualMap range, see test/visualMap-continuous.html,
  49111. // where china and india has very large population.
  49112. hoverRange[0] < sizeExtent[0] && (valueRange[0] = -Infinity);
  49113. hoverRange[1] > sizeExtent[1] && (valueRange[1] = Infinity);
  49114. // Do not show indicator when mouse is over handle,
  49115. // otherwise labels overlap, especially when dragging.
  49116. if (hoverOnBar) {
  49117. if (valueRange[0] === -Infinity) {
  49118. this._showIndicator(cursorValue, valueRange[1], '< ', halfHoverLinkSize);
  49119. }
  49120. else if (valueRange[1] === Infinity) {
  49121. this._showIndicator(cursorValue, valueRange[0], '> ', halfHoverLinkSize);
  49122. }
  49123. else {
  49124. this._showIndicator(cursorValue, cursorValue, '≈ ', halfHoverLinkSize);
  49125. }
  49126. }
  49127. // When realtime is set as false, handles, which are in barGroup,
  49128. // also trigger hoverLink, which help user to realize where they
  49129. // focus on when dragging. (see test/heatmap-large.html)
  49130. // When realtime is set as true, highlight will not show when hover
  49131. // handle, because the label on handle, which displays a exact value
  49132. // but not range, might mislead users.
  49133. var oldBatch = this._hoverLinkDataIndices;
  49134. var newBatch = [];
  49135. if (hoverOnBar || useHoverLinkOnHandle(visualMapModel)) {
  49136. newBatch = this._hoverLinkDataIndices = visualMapModel.findTargetDataIndices(valueRange);
  49137. }
  49138. var resultBatches = modelUtil.compressBatches(oldBatch, newBatch);
  49139. this._dispatchHighDown('downplay', helper.convertDataIndex(resultBatches[0]));
  49140. this._dispatchHighDown('highlight', helper.convertDataIndex(resultBatches[1]));
  49141. },
  49142. /**
  49143. * @private
  49144. */
  49145. _hoverLinkFromSeriesMouseOver: function (e) {
  49146. var el = e.target;
  49147. if (!el || el.dataIndex == null) {
  49148. return;
  49149. }
  49150. var dataModel = el.dataModel || this.ecModel.getSeriesByIndex(el.seriesIndex);
  49151. var data = dataModel.getData(el.dataType);
  49152. var dim = data.getDimension(this.visualMapModel.getDataDimension(data));
  49153. var value = data.get(dim, el.dataIndex, true);
  49154. if (!isNaN(value)) {
  49155. this._showIndicator(value, value);
  49156. }
  49157. },
  49158. /**
  49159. * @private
  49160. */
  49161. _hideIndicator: function () {
  49162. var shapes = this._shapes;
  49163. shapes.indicator && shapes.indicator.attr('invisible', true);
  49164. shapes.indicatorLabel && shapes.indicatorLabel.attr('invisible', true);
  49165. },
  49166. /**
  49167. * @private
  49168. */
  49169. _clearHoverLinkToSeries: function () {
  49170. this._hideIndicator();
  49171. var indices = this._hoverLinkDataIndices;
  49172. this._dispatchHighDown('downplay', helper.convertDataIndex(indices));
  49173. indices.length = 0;
  49174. },
  49175. /**
  49176. * @private
  49177. */
  49178. _clearHoverLinkFromSeries: function () {
  49179. this._hideIndicator();
  49180. var zr = this.api.getZr();
  49181. zr.off('mouseover', this._hoverLinkFromSeriesMouseOver);
  49182. zr.off('mouseout', this._hideIndicator);
  49183. },
  49184. /**
  49185. * @private
  49186. */
  49187. _applyTransform: function (vertex, element, inverse, global) {
  49188. var transform = graphic.getTransform(element, global ? null : this.group);
  49189. return graphic[
  49190. zrUtil.isArray(vertex) ? 'applyTransform' : 'transformDirection'
  49191. ](vertex, transform, inverse);
  49192. },
  49193. /**
  49194. * @private
  49195. */
  49196. _dispatchHighDown: function (type, batch) {
  49197. batch && batch.length && this.api.dispatchAction({
  49198. type: type,
  49199. batch: batch
  49200. });
  49201. },
  49202. /**
  49203. * @override
  49204. */
  49205. dispose: function () {
  49206. this._clearHoverLinkFromSeries();
  49207. this._clearHoverLinkToSeries();
  49208. },
  49209. /**
  49210. * @override
  49211. */
  49212. remove: function () {
  49213. this._clearHoverLinkFromSeries();
  49214. this._clearHoverLinkToSeries();
  49215. }
  49216. });
  49217. function createPolygon(points, cursor, onDrift, onDragEnd) {
  49218. return new graphic.Polygon({
  49219. shape: {points: points},
  49220. draggable: !!onDrift,
  49221. cursor: cursor,
  49222. drift: onDrift,
  49223. ondragend: onDragEnd
  49224. });
  49225. }
  49226. function createHandlePoints(handleIndex, textSize) {
  49227. return handleIndex === 0
  49228. ? [[0, 0], [textSize, 0], [textSize, -textSize]]
  49229. : [[0, 0], [textSize, 0], [textSize, textSize]];
  49230. }
  49231. function createIndicatorPoints(isRange, halfHoverLinkSize, pos, extentMax) {
  49232. return isRange
  49233. ? [ // indicate range
  49234. [0, -mathMin(halfHoverLinkSize, mathMax(pos, 0))],
  49235. [HOVER_LINK_OUT, 0],
  49236. [0, mathMin(halfHoverLinkSize, mathMax(extentMax - pos, 0))]
  49237. ]
  49238. : [ // indicate single value
  49239. [0, 0], [5, -5], [5, 5]
  49240. ];
  49241. }
  49242. function getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent) {
  49243. var halfHoverLinkSize = HOVER_LINK_SIZE / 2;
  49244. var hoverLinkDataSize = visualMapModel.get('hoverLinkDataSize');
  49245. if (hoverLinkDataSize) {
  49246. halfHoverLinkSize = linearMap(hoverLinkDataSize, dataExtent, sizeExtent, true) / 2;
  49247. }
  49248. return halfHoverLinkSize;
  49249. }
  49250. function useHoverLinkOnHandle(visualMapModel) {
  49251. return !visualMapModel.get('realtime') && visualMapModel.get('hoverLinkOnHandle');
  49252. }
  49253. module.exports = ContinuousView;
  49254. /***/ },
  49255. /* 341 */
  49256. /***/ function(module, exports, __webpack_require__) {
  49257. var zrUtil = __webpack_require__(4);
  49258. var graphic = __webpack_require__(43);
  49259. var formatUtil = __webpack_require__(6);
  49260. var layout = __webpack_require__(21);
  49261. var echarts = __webpack_require__(1);
  49262. var VisualMapping = __webpack_require__(194);
  49263. module.exports = echarts.extendComponentView({
  49264. type: 'visualMap',
  49265. /**
  49266. * @readOnly
  49267. * @type {Object}
  49268. */
  49269. autoPositionValues: {left: 1, right: 1, top: 1, bottom: 1},
  49270. init: function (ecModel, api) {
  49271. /**
  49272. * @readOnly
  49273. * @type {module:echarts/model/Global}
  49274. */
  49275. this.ecModel = ecModel;
  49276. /**
  49277. * @readOnly
  49278. * @type {module:echarts/ExtensionAPI}
  49279. */
  49280. this.api = api;
  49281. /**
  49282. * @readOnly
  49283. * @type {module:echarts/component/visualMap/visualMapModel}
  49284. */
  49285. this.visualMapModel;
  49286. },
  49287. /**
  49288. * @protected
  49289. */
  49290. render: function (visualMapModel, ecModel, api, payload) {
  49291. this.visualMapModel = visualMapModel;
  49292. if (visualMapModel.get('show') === false) {
  49293. this.group.removeAll();
  49294. return;
  49295. }
  49296. this.doRender.apply(this, arguments);
  49297. },
  49298. /**
  49299. * @protected
  49300. */
  49301. renderBackground: function (group) {
  49302. var visualMapModel = this.visualMapModel;
  49303. var padding = formatUtil.normalizeCssArray(visualMapModel.get('padding') || 0);
  49304. var rect = group.getBoundingRect();
  49305. group.add(new graphic.Rect({
  49306. z2: -1, // Lay background rect on the lowest layer.
  49307. silent: true,
  49308. shape: {
  49309. x: rect.x - padding[3],
  49310. y: rect.y - padding[0],
  49311. width: rect.width + padding[3] + padding[1],
  49312. height: rect.height + padding[0] + padding[2]
  49313. },
  49314. style: {
  49315. fill: visualMapModel.get('backgroundColor'),
  49316. stroke: visualMapModel.get('borderColor'),
  49317. lineWidth: visualMapModel.get('borderWidth')
  49318. }
  49319. }));
  49320. },
  49321. /**
  49322. * @protected
  49323. * @param {number} targetValue can be Infinity or -Infinity
  49324. * @param {string=} visualCluster Only can be 'color' 'opacity' 'symbol' 'symbolSize'
  49325. * @param {Object} [opts]
  49326. * @param {string=} [opts.forceState] Specify state, instead of using getValueState method.
  49327. * @param {string=} [opts.convertOpacityToAlpha=false] For color gradient in controller widget.
  49328. * @return {*} Visual value.
  49329. */
  49330. getControllerVisual: function (targetValue, visualCluster, opts) {
  49331. opts = opts || {};
  49332. var forceState = opts.forceState;
  49333. var visualMapModel = this.visualMapModel;
  49334. var visualObj = {};
  49335. // Default values.
  49336. if (visualCluster === 'symbol') {
  49337. visualObj.symbol = visualMapModel.get('itemSymbol');
  49338. }
  49339. if (visualCluster === 'color') {
  49340. var defaultColor = visualMapModel.get('contentColor');
  49341. visualObj.color = defaultColor;
  49342. }
  49343. function getter(key) {
  49344. return visualObj[key];
  49345. }
  49346. function setter(key, value) {
  49347. visualObj[key] = value;
  49348. }
  49349. var mappings = visualMapModel.controllerVisuals[
  49350. forceState || visualMapModel.getValueState(targetValue)
  49351. ];
  49352. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  49353. zrUtil.each(visualTypes, function (type) {
  49354. var visualMapping = mappings[type];
  49355. if (opts.convertOpacityToAlpha && type === 'opacity') {
  49356. type = 'colorAlpha';
  49357. visualMapping = mappings.__alphaForOpacity;
  49358. }
  49359. if (VisualMapping.dependsOn(type, visualCluster)) {
  49360. visualMapping && visualMapping.applyVisual(
  49361. targetValue, getter, setter
  49362. );
  49363. }
  49364. });
  49365. return visualObj[visualCluster];
  49366. },
  49367. /**
  49368. * @protected
  49369. */
  49370. positionGroup: function (group) {
  49371. var model = this.visualMapModel;
  49372. var api = this.api;
  49373. layout.positionElement(
  49374. group,
  49375. model.getBoxLayoutParams(),
  49376. {width: api.getWidth(), height: api.getHeight()}
  49377. );
  49378. },
  49379. /**
  49380. * @protected
  49381. * @abstract
  49382. */
  49383. doRender: zrUtil.noop
  49384. });
  49385. /***/ },
  49386. /* 342 */
  49387. /***/ function(module, exports, __webpack_require__) {
  49388. var zrUtil = __webpack_require__(4);
  49389. var layout = __webpack_require__(21);
  49390. var helper = {
  49391. /**
  49392. * @param {module:echarts/component/visualMap/VisualMapModel} visualMapModel\
  49393. * @param {module:echarts/ExtensionAPI} api
  49394. * @param {Array.<number>} itemSize always [short, long]
  49395. * @return {string} 'left' or 'right' or 'top' or 'bottom'
  49396. */
  49397. getItemAlign: function (visualMapModel, api, itemSize) {
  49398. var modelOption = visualMapModel.option;
  49399. var itemAlign = modelOption.align;
  49400. if (itemAlign != null && itemAlign !== 'auto') {
  49401. return itemAlign;
  49402. }
  49403. // Auto decision align.
  49404. var ecSize = {width: api.getWidth(), height: api.getHeight()};
  49405. var realIndex = modelOption.orient === 'horizontal' ? 1 : 0;
  49406. var paramsSet = [
  49407. ['left', 'right', 'width'],
  49408. ['top', 'bottom', 'height']
  49409. ];
  49410. var reals = paramsSet[realIndex];
  49411. var fakeValue = [0, null, 10];
  49412. var layoutInput = {};
  49413. for (var i = 0; i < 3; i++) {
  49414. layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i];
  49415. layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]];
  49416. }
  49417. var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex];
  49418. var rect = layout.getLayoutRect(layoutInput, ecSize, modelOption.padding);
  49419. return reals[
  49420. (rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5
  49421. < ecSize[rParam[1]] * 0.5 ? 0 : 1
  49422. ];
  49423. },
  49424. /**
  49425. * Prepare dataIndex for outside usage, where dataIndex means rawIndex, and
  49426. * dataIndexInside means filtered index.
  49427. */
  49428. convertDataIndex: function (batch) {
  49429. zrUtil.each(batch || [], function (batchItem) {
  49430. if (batch.dataIndex != null) {
  49431. batch.dataIndexInside = batch.dataIndex;
  49432. batch.dataIndex = null;
  49433. }
  49434. });
  49435. return batch;
  49436. }
  49437. };
  49438. module.exports = helper;
  49439. /***/ },
  49440. /* 343 */
  49441. /***/ function(module, exports, __webpack_require__) {
  49442. /**
  49443. * @file Data range action
  49444. */
  49445. var echarts = __webpack_require__(1);
  49446. var actionInfo = {
  49447. type: 'selectDataRange',
  49448. event: 'dataRangeSelected',
  49449. // FIXME use updateView appears wrong
  49450. update: 'update'
  49451. };
  49452. echarts.registerAction(actionInfo, function (payload, ecModel) {
  49453. ecModel.eachComponent({mainType: 'visualMap', query: payload}, function (model) {
  49454. model.setSelected(payload.selected);
  49455. });
  49456. });
  49457. /***/ },
  49458. /* 344 */
  49459. /***/ function(module, exports, __webpack_require__) {
  49460. /**
  49461. * DataZoom component entry
  49462. */
  49463. __webpack_require__(1).registerPreprocessor(
  49464. __webpack_require__(334)
  49465. );
  49466. __webpack_require__(335);
  49467. __webpack_require__(336);
  49468. __webpack_require__(345);
  49469. __webpack_require__(346);
  49470. __webpack_require__(343);
  49471. /***/ },
  49472. /* 345 */
  49473. /***/ function(module, exports, __webpack_require__) {
  49474. var VisualMapModel = __webpack_require__(338);
  49475. var zrUtil = __webpack_require__(4);
  49476. var VisualMapping = __webpack_require__(194);
  49477. var visualDefault = __webpack_require__(339);
  49478. var reformIntervals = __webpack_require__(7).reformIntervals;
  49479. var PiecewiseModel = VisualMapModel.extend({
  49480. type: 'visualMap.piecewise',
  49481. /**
  49482. * Order Rule:
  49483. *
  49484. * option.categories / option.pieces / option.text / option.selected:
  49485. * If !option.inverse,
  49486. * Order when vertical: ['top', ..., 'bottom'].
  49487. * Order when horizontal: ['left', ..., 'right'].
  49488. * If option.inverse, the meaning of
  49489. * the order should be reversed.
  49490. *
  49491. * this._pieceList:
  49492. * The order is always [low, ..., high].
  49493. *
  49494. * Mapping from location to low-high:
  49495. * If !option.inverse
  49496. * When vertical, top is high.
  49497. * When horizontal, right is high.
  49498. * If option.inverse, reverse.
  49499. */
  49500. /**
  49501. * @protected
  49502. */
  49503. defaultOption: {
  49504. selected: null, // Object. If not specified, means selected.
  49505. // When pieces and splitNumber: {'0': true, '5': true}
  49506. // When categories: {'cate1': false, 'cate3': true}
  49507. // When selected === false, means all unselected.
  49508. minOpen: false, // Whether include values that smaller than `min`.
  49509. maxOpen: false, // Whether include values that bigger than `max`.
  49510. align: 'auto', // 'auto', 'left', 'right'
  49511. itemWidth: 20, // When put the controller vertically, it is the length of
  49512. // horizontal side of each item. Otherwise, vertical side.
  49513. itemHeight: 14, // When put the controller vertically, it is the length of
  49514. // vertical side of each item. Otherwise, horizontal side.
  49515. itemSymbol: 'roundRect',
  49516. pieceList: null, // Each item is Object, with some of those attrs:
  49517. // {min, max, lt, gt, lte, gte, value,
  49518. // color, colorSaturation, colorAlpha, opacity,
  49519. // symbol, symbolSize}, which customize the range or visual
  49520. // coding of the certain piece. Besides, see "Order Rule".
  49521. categories: null, // category names, like: ['some1', 'some2', 'some3'].
  49522. // Attr min/max are ignored when categories set. See "Order Rule"
  49523. splitNumber: 5, // If set to 5, auto split five pieces equally.
  49524. // If set to 0 and component type not set, component type will be
  49525. // determined as "continuous". (It is less reasonable but for ec2
  49526. // compatibility, see echarts/component/visualMap/typeDefaulter)
  49527. selectedMode: 'multiple', // Can be 'multiple' or 'single'.
  49528. itemGap: 10, // The gap between two items, in px.
  49529. hoverLink: true // Enable hover highlight.
  49530. },
  49531. /**
  49532. * @override
  49533. */
  49534. optionUpdated: function (newOption, isInit) {
  49535. PiecewiseModel.superApply(this, 'optionUpdated', arguments);
  49536. /**
  49537. * The order is always [low, ..., high].
  49538. * [{text: string, interval: Array.<number>}, ...]
  49539. * @private
  49540. * @type {Array.<Object>}
  49541. */
  49542. this._pieceList = [];
  49543. this.resetTargetSeries();
  49544. this.resetExtent();
  49545. /**
  49546. * 'pieces', 'categories', 'splitNumber'
  49547. * @type {string}
  49548. */
  49549. var mode = this._mode = this._determineMode();
  49550. resetMethods[this._mode].call(this);
  49551. this._resetSelected(newOption, isInit);
  49552. var categories = this.option.categories;
  49553. this.resetVisual(function (mappingOption, state) {
  49554. if (mode === 'categories') {
  49555. mappingOption.mappingMethod = 'category';
  49556. mappingOption.categories = zrUtil.clone(categories);
  49557. }
  49558. else {
  49559. mappingOption.dataExtent = this.getExtent();
  49560. mappingOption.mappingMethod = 'piecewise';
  49561. mappingOption.pieceList = zrUtil.map(this._pieceList, function (piece) {
  49562. var piece = zrUtil.clone(piece);
  49563. if (state !== 'inRange') {
  49564. piece.visual = null;
  49565. }
  49566. return piece;
  49567. });
  49568. }
  49569. });
  49570. },
  49571. /**
  49572. * @protected
  49573. * @override
  49574. */
  49575. completeVisualOption: function () {
  49576. // Consider this case:
  49577. // visualMap: {
  49578. // pieces: [{symbol: 'circle', lt: 0}, {symbol: 'rect', gte: 0}]
  49579. // }
  49580. // where no inRange/outOfRange set but only pieces. So we should make
  49581. // default inRange/outOfRange for this case, otherwise visuals that only
  49582. // appear in `pieces` will not be taken into account in visual encoding.
  49583. var option = this.option;
  49584. var visualTypesInPieces = {};
  49585. var visualTypes = VisualMapping.listVisualTypes();
  49586. var isCategory = this.isCategory();
  49587. zrUtil.each(option.pieces, function (piece) {
  49588. zrUtil.each(visualTypes, function (visualType) {
  49589. if (piece.hasOwnProperty(visualType)) {
  49590. visualTypesInPieces[visualType] = 1;
  49591. }
  49592. });
  49593. });
  49594. zrUtil.each(visualTypesInPieces, function (v, visualType) {
  49595. var exists = 0;
  49596. zrUtil.each(this.stateList, function (state) {
  49597. exists |= has(option, state, visualType)
  49598. || has(option.target, state, visualType);
  49599. }, this);
  49600. !exists && zrUtil.each(this.stateList, function (state) {
  49601. (option[state] || (option[state] = {}))[visualType] = visualDefault.get(
  49602. visualType, state === 'inRange' ? 'active' : 'inactive', isCategory
  49603. );
  49604. });
  49605. }, this);
  49606. function has(obj, state, visualType) {
  49607. return obj && obj[state] && (
  49608. zrUtil.isObject(obj[state])
  49609. ? obj[state].hasOwnProperty(visualType)
  49610. : obj[state] === visualType // e.g., inRange: 'symbol'
  49611. );
  49612. }
  49613. VisualMapModel.prototype.completeVisualOption.apply(this, arguments);
  49614. },
  49615. _resetSelected: function (newOption, isInit) {
  49616. var thisOption = this.option;
  49617. var pieceList = this._pieceList;
  49618. // Selected do not merge but all override.
  49619. var selected = (isInit ? thisOption : newOption).selected || {};
  49620. thisOption.selected = selected;
  49621. // Consider 'not specified' means true.
  49622. zrUtil.each(pieceList, function (piece, index) {
  49623. var key = this.getSelectedMapKey(piece);
  49624. if (!selected.hasOwnProperty(key)) {
  49625. selected[key] = true;
  49626. }
  49627. }, this);
  49628. if (thisOption.selectedMode === 'single') {
  49629. // Ensure there is only one selected.
  49630. var hasSel = false;
  49631. zrUtil.each(pieceList, function (piece, index) {
  49632. var key = this.getSelectedMapKey(piece);
  49633. if (selected[key]) {
  49634. hasSel
  49635. ? (selected[key] = false)
  49636. : (hasSel = true);
  49637. }
  49638. }, this);
  49639. }
  49640. // thisOption.selectedMode === 'multiple', default: all selected.
  49641. },
  49642. /**
  49643. * @public
  49644. */
  49645. getSelectedMapKey: function (piece) {
  49646. return this._mode === 'categories'
  49647. ? piece.value + '' : piece.index + '';
  49648. },
  49649. /**
  49650. * @public
  49651. */
  49652. getPieceList: function () {
  49653. return this._pieceList;
  49654. },
  49655. /**
  49656. * @private
  49657. * @return {string}
  49658. */
  49659. _determineMode: function () {
  49660. var option = this.option;
  49661. return option.pieces && option.pieces.length > 0
  49662. ? 'pieces'
  49663. : this.option.categories
  49664. ? 'categories'
  49665. : 'splitNumber';
  49666. },
  49667. /**
  49668. * @public
  49669. * @override
  49670. */
  49671. setSelected: function (selected) {
  49672. this.option.selected = zrUtil.clone(selected);
  49673. },
  49674. /**
  49675. * @public
  49676. * @override
  49677. */
  49678. getValueState: function (value) {
  49679. var index = VisualMapping.findPieceIndex(value, this._pieceList);
  49680. return index != null
  49681. ? (this.option.selected[this.getSelectedMapKey(this._pieceList[index])]
  49682. ? 'inRange' : 'outOfRange'
  49683. )
  49684. : 'outOfRange';
  49685. },
  49686. /**
  49687. * @public
  49688. * @params {number} pieceIndex piece index in visualMapModel.getPieceList()
  49689. * @return {Array.<Object>} [{seriesId, dataIndices: <Array.<number>>}, ...]
  49690. */
  49691. findTargetDataIndices: function (pieceIndex) {
  49692. var result = [];
  49693. this.eachTargetSeries(function (seriesModel) {
  49694. var dataIndices = [];
  49695. var data = seriesModel.getData();
  49696. data.each(this.getDataDimension(data), function (value, dataIndex) {
  49697. // Should always base on model pieceList, because it is order sensitive.
  49698. var pIdx = VisualMapping.findPieceIndex(value, this._pieceList);
  49699. pIdx === pieceIndex && dataIndices.push(dataIndex);
  49700. }, true, this);
  49701. result.push({seriesId: seriesModel.id, dataIndex: dataIndices});
  49702. }, this);
  49703. return result;
  49704. },
  49705. /**
  49706. * @private
  49707. * @param {Object} piece piece.value or piece.interval is required.
  49708. * @return {number} Can be Infinity or -Infinity
  49709. */
  49710. getRepresentValue: function (piece) {
  49711. var representValue;
  49712. if (this.isCategory()) {
  49713. representValue = piece.value;
  49714. }
  49715. else {
  49716. if (piece.value != null) {
  49717. representValue = piece.value;
  49718. }
  49719. else {
  49720. var pieceInterval = piece.interval || [];
  49721. representValue = (pieceInterval[0] === -Infinity && pieceInterval[1] === Infinity)
  49722. ? 0
  49723. : (pieceInterval[0] + pieceInterval[1]) / 2;
  49724. }
  49725. }
  49726. return representValue;
  49727. },
  49728. getVisualMeta: function (getColorVisual) {
  49729. // Do not support category. (category axis is ordinal, numerical)
  49730. if (this.isCategory()) {
  49731. return;
  49732. }
  49733. var stops = [];
  49734. var outerColors = [];
  49735. var visualMapModel = this;
  49736. function setStop(interval, valueState) {
  49737. var representValue = visualMapModel.getRepresentValue({interval: interval});
  49738. if (!valueState) {
  49739. valueState = visualMapModel.getValueState(representValue);
  49740. }
  49741. var color = getColorVisual(representValue, valueState);
  49742. if (interval[0] === -Infinity) {
  49743. outerColors[0] = color;
  49744. }
  49745. else if (interval[1] === Infinity) {
  49746. outerColors[1] = color;
  49747. }
  49748. else {
  49749. stops.push(
  49750. {value: interval[0], color: color},
  49751. {value: interval[1], color: color}
  49752. );
  49753. }
  49754. }
  49755. // Suplement
  49756. var pieceList = this._pieceList.slice();
  49757. if (!pieceList.length) {
  49758. pieceList.push({interval: [-Infinity, Infinity]});
  49759. }
  49760. else {
  49761. var edge = pieceList[0].interval[0];
  49762. edge !== -Infinity && pieceList.unshift({interval: [-Infinity, edge]});
  49763. edge = pieceList[pieceList.length - 1].interval[1];
  49764. edge !== Infinity && pieceList.push({interval: [edge, Infinity]});
  49765. }
  49766. var curr = -Infinity;
  49767. zrUtil.each(pieceList, function (piece) {
  49768. var interval = piece.interval;
  49769. if (interval) {
  49770. // Fulfill gap.
  49771. interval[0] > curr && setStop([curr, interval[0]], 'outOfRange');
  49772. setStop(interval.slice());
  49773. curr = interval[1];
  49774. }
  49775. }, this);
  49776. return {stops: stops, outerColors: outerColors};
  49777. }
  49778. });
  49779. /**
  49780. * Key is this._mode
  49781. * @type {Object}
  49782. * @this {module:echarts/component/viusalMap/PiecewiseMode}
  49783. */
  49784. var resetMethods = {
  49785. splitNumber: function () {
  49786. var thisOption = this.option;
  49787. var pieceList = this._pieceList;
  49788. var precision = thisOption.precision;
  49789. var dataExtent = this.getExtent();
  49790. var splitNumber = thisOption.splitNumber;
  49791. splitNumber = Math.max(parseInt(splitNumber, 10), 1);
  49792. thisOption.splitNumber = splitNumber;
  49793. var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber;
  49794. // Precision auto-adaption
  49795. while (+splitStep.toFixed(precision) !== splitStep && precision < 5) {
  49796. precision++;
  49797. }
  49798. thisOption.precision = precision;
  49799. splitStep = +splitStep.toFixed(precision);
  49800. var index = 0;
  49801. if (thisOption.minOpen) {
  49802. pieceList.push({
  49803. index: index++,
  49804. interval: [-Infinity, dataExtent[0]],
  49805. close: [0, 0]
  49806. });
  49807. }
  49808. for (
  49809. var curr = dataExtent[0], len = index + splitNumber;
  49810. index < len;
  49811. curr += splitStep
  49812. ) {
  49813. var max = index === splitNumber - 1 ? dataExtent[1] : (curr + splitStep);
  49814. pieceList.push({
  49815. index: index++,
  49816. interval: [curr, max],
  49817. close: [1, 1]
  49818. });
  49819. }
  49820. if (thisOption.maxOpen) {
  49821. pieceList.push({
  49822. index: index++,
  49823. interval: [dataExtent[1], Infinity],
  49824. close: [0, 0]
  49825. });
  49826. }
  49827. reformIntervals(pieceList);
  49828. zrUtil.each(pieceList, function (piece) {
  49829. piece.text = this.formatValueText(piece.interval);
  49830. }, this);
  49831. },
  49832. categories: function () {
  49833. var thisOption = this.option;
  49834. zrUtil.each(thisOption.categories, function (cate) {
  49835. // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。
  49836. // 是否改一致。
  49837. this._pieceList.push({
  49838. text: this.formatValueText(cate, true),
  49839. value: cate
  49840. });
  49841. }, this);
  49842. // See "Order Rule".
  49843. normalizeReverse(thisOption, this._pieceList);
  49844. },
  49845. pieces: function () {
  49846. var thisOption = this.option;
  49847. var pieceList = this._pieceList;
  49848. zrUtil.each(thisOption.pieces, function (pieceListItem, index) {
  49849. if (!zrUtil.isObject(pieceListItem)) {
  49850. pieceListItem = {value: pieceListItem};
  49851. }
  49852. var item = {text: '', index: index};
  49853. if (pieceListItem.label != null) {
  49854. item.text = pieceListItem.label;
  49855. }
  49856. if (pieceListItem.hasOwnProperty('value')) {
  49857. var value = item.value = pieceListItem.value;
  49858. item.interval = [value, value];
  49859. item.close = [1, 1];
  49860. }
  49861. else {
  49862. // `min` `max` is legacy option.
  49863. // `lt` `gt` `lte` `gte` is recommanded.
  49864. var interval = item.interval = [];
  49865. var close = item.close = [0, 0];
  49866. var closeList = [1, 0, 1];
  49867. var infinityList = [-Infinity, Infinity];
  49868. var useMinMax = [];
  49869. for (var lg = 0; lg < 2; lg++) {
  49870. var names = [['gte', 'gt', 'min'], ['lte', 'lt', 'max']][lg];
  49871. for (var i = 0; i < 3 && interval[lg] == null; i++) {
  49872. interval[lg] = pieceListItem[names[i]];
  49873. close[lg] = closeList[i];
  49874. useMinMax[lg] = i === 2;
  49875. }
  49876. interval[lg] == null && (interval[lg] = infinityList[lg]);
  49877. }
  49878. useMinMax[0] && interval[1] === Infinity && (close[0] = 0);
  49879. useMinMax[1] && interval[0] === -Infinity && (close[1] = 0);
  49880. if (true) {
  49881. if (interval[0] > interval[1]) {
  49882. console.warn(
  49883. 'Piece ' + index + 'is illegal: ' + interval
  49884. + ' lower bound should not greater then uppper bound.'
  49885. );
  49886. }
  49887. }
  49888. if (interval[0] === interval[1] && close[0] && close[1]) {
  49889. // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}],
  49890. // we use value to lift the priority when min === max
  49891. item.value = interval[0];
  49892. }
  49893. }
  49894. item.visual = VisualMapping.retrieveVisuals(pieceListItem);
  49895. pieceList.push(item);
  49896. }, this);
  49897. // See "Order Rule".
  49898. normalizeReverse(thisOption, pieceList);
  49899. // Only pieces
  49900. reformIntervals(pieceList);
  49901. zrUtil.each(pieceList, function (piece) {
  49902. var close = piece.close;
  49903. var edgeSymbols = [['<', '≤'][close[1]], ['>', '≥'][close[0]]];
  49904. piece.text = piece.text || this.formatValueText(
  49905. piece.value != null ? piece.value : piece.interval,
  49906. false,
  49907. edgeSymbols
  49908. );
  49909. }, this);
  49910. }
  49911. };
  49912. function normalizeReverse(thisOption, pieceList) {
  49913. var inverse = thisOption.inverse;
  49914. if (thisOption.orient === 'vertical' ? !inverse : inverse) {
  49915. pieceList.reverse();
  49916. }
  49917. }
  49918. module.exports = PiecewiseModel;
  49919. /***/ },
  49920. /* 346 */
  49921. /***/ function(module, exports, __webpack_require__) {
  49922. var VisualMapView = __webpack_require__(341);
  49923. var zrUtil = __webpack_require__(4);
  49924. var graphic = __webpack_require__(43);
  49925. var symbolCreators = __webpack_require__(107);
  49926. var layout = __webpack_require__(21);
  49927. var helper = __webpack_require__(342);
  49928. var PiecewiseVisualMapView = VisualMapView.extend({
  49929. type: 'visualMap.piecewise',
  49930. /**
  49931. * @protected
  49932. * @override
  49933. */
  49934. doRender: function () {
  49935. var thisGroup = this.group;
  49936. thisGroup.removeAll();
  49937. var visualMapModel = this.visualMapModel;
  49938. var textGap = visualMapModel.get('textGap');
  49939. var textStyleModel = visualMapModel.textStyleModel;
  49940. var textFont = textStyleModel.getFont();
  49941. var textFill = textStyleModel.getTextColor();
  49942. var itemAlign = this._getItemAlign();
  49943. var itemSize = visualMapModel.itemSize;
  49944. var viewData = this._getViewData();
  49945. var showLabel = !viewData.endsText;
  49946. var showEndsText = !showLabel;
  49947. showEndsText && this._renderEndsText(thisGroup, viewData.endsText[0], itemSize);
  49948. zrUtil.each(viewData.viewPieceList, renderItem, this);
  49949. showEndsText && this._renderEndsText(thisGroup, viewData.endsText[1], itemSize);
  49950. layout.box(
  49951. visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap')
  49952. );
  49953. this.renderBackground(thisGroup);
  49954. this.positionGroup(thisGroup);
  49955. function renderItem(item) {
  49956. var piece = item.piece;
  49957. var itemGroup = new graphic.Group();
  49958. itemGroup.onclick = zrUtil.bind(this._onItemClick, this, piece);
  49959. this._enableHoverLink(itemGroup, item.indexInModelPieceList);
  49960. var representValue = visualMapModel.getRepresentValue(piece);
  49961. this._createItemSymbol(
  49962. itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]]
  49963. );
  49964. if (showLabel) {
  49965. var visualState = this.visualMapModel.getValueState(representValue);
  49966. itemGroup.add(new graphic.Text({
  49967. style: {
  49968. x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
  49969. y: itemSize[1] / 2,
  49970. text: piece.text,
  49971. textVerticalAlign: 'middle',
  49972. textAlign: itemAlign,
  49973. textFont: textFont,
  49974. fill: textFill,
  49975. opacity: visualState === 'outOfRange' ? 0.5 : 1
  49976. }
  49977. }));
  49978. }
  49979. thisGroup.add(itemGroup);
  49980. }
  49981. },
  49982. /**
  49983. * @private
  49984. */
  49985. _enableHoverLink: function (itemGroup, pieceIndex) {
  49986. itemGroup
  49987. .on('mouseover', zrUtil.bind(onHoverLink, this, 'highlight'))
  49988. .on('mouseout', zrUtil.bind(onHoverLink, this, 'downplay'));
  49989. function onHoverLink(method) {
  49990. var visualMapModel = this.visualMapModel;
  49991. visualMapModel.option.hoverLink && this.api.dispatchAction({
  49992. type: method,
  49993. batch: helper.convertDataIndex(
  49994. visualMapModel.findTargetDataIndices(pieceIndex)
  49995. )
  49996. });
  49997. }
  49998. },
  49999. /**
  50000. * @private
  50001. */
  50002. _getItemAlign: function () {
  50003. var visualMapModel = this.visualMapModel;
  50004. var modelOption = visualMapModel.option;
  50005. if (modelOption.orient === 'vertical') {
  50006. return helper.getItemAlign(
  50007. visualMapModel, this.api, visualMapModel.itemSize
  50008. );
  50009. }
  50010. else { // horizontal, most case left unless specifying right.
  50011. var align = modelOption.align;
  50012. if (!align || align === 'auto') {
  50013. align = 'left';
  50014. }
  50015. return align;
  50016. }
  50017. },
  50018. /**
  50019. * @private
  50020. */
  50021. _renderEndsText: function (group, text, itemSize) {
  50022. if (!text) {
  50023. return;
  50024. }
  50025. var itemGroup = new graphic.Group();
  50026. var textStyleModel = this.visualMapModel.textStyleModel;
  50027. itemGroup.add(new graphic.Text({
  50028. style: {
  50029. x: itemSize[0] / 2,
  50030. y: itemSize[1] / 2,
  50031. textVerticalAlign: 'middle',
  50032. textAlign: 'center',
  50033. text: text,
  50034. textFont: textStyleModel.getFont(),
  50035. fill: textStyleModel.getTextColor()
  50036. }
  50037. }));
  50038. group.add(itemGroup);
  50039. },
  50040. /**
  50041. * @private
  50042. * @return {Object} {peiceList, endsText} The order is the same as screen pixel order.
  50043. */
  50044. _getViewData: function () {
  50045. var visualMapModel = this.visualMapModel;
  50046. var viewPieceList = zrUtil.map(visualMapModel.getPieceList(), function (piece, index) {
  50047. return {piece: piece, indexInModelPieceList: index};
  50048. });
  50049. var endsText = visualMapModel.get('text');
  50050. // Consider orient and inverse.
  50051. var orient = visualMapModel.get('orient');
  50052. var inverse = visualMapModel.get('inverse');
  50053. // Order of model pieceList is always [low, ..., high]
  50054. if (orient === 'horizontal' ? inverse : !inverse) {
  50055. viewPieceList.reverse();
  50056. }
  50057. // Origin order of endsText is [high, low]
  50058. else if (endsText) {
  50059. endsText = endsText.slice().reverse();
  50060. }
  50061. return {viewPieceList: viewPieceList, endsText: endsText};
  50062. },
  50063. /**
  50064. * @private
  50065. */
  50066. _createItemSymbol: function (group, representValue, shapeParam) {
  50067. group.add(symbolCreators.createSymbol(
  50068. this.getControllerVisual(representValue, 'symbol'),
  50069. shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3],
  50070. this.getControllerVisual(representValue, 'color')
  50071. ));
  50072. },
  50073. /**
  50074. * @private
  50075. */
  50076. _onItemClick: function (piece) {
  50077. var visualMapModel = this.visualMapModel;
  50078. var option = visualMapModel.option;
  50079. var selected = zrUtil.clone(option.selected);
  50080. var newKey = visualMapModel.getSelectedMapKey(piece);
  50081. if (option.selectedMode === 'single') {
  50082. selected[newKey] = true;
  50083. zrUtil.each(selected, function (o, key) {
  50084. selected[key] = key === newKey;
  50085. });
  50086. }
  50087. else {
  50088. selected[newKey] = !selected[newKey];
  50089. }
  50090. this.api.dispatchAction({
  50091. type: 'selectDataRange',
  50092. from: this.uid,
  50093. visualMapId: this.visualMapModel.id,
  50094. selected: selected
  50095. });
  50096. }
  50097. });
  50098. module.exports = PiecewiseVisualMapView;
  50099. /***/ },
  50100. /* 347 */
  50101. /***/ function(module, exports, __webpack_require__) {
  50102. // HINT Markpoint can't be used too much
  50103. __webpack_require__(348);
  50104. __webpack_require__(350);
  50105. __webpack_require__(1).registerPreprocessor(function (opt) {
  50106. // Make sure markPoint component is enabled
  50107. opt.markPoint = opt.markPoint || {};
  50108. });
  50109. /***/ },
  50110. /* 348 */
  50111. /***/ function(module, exports, __webpack_require__) {
  50112. module.exports = __webpack_require__(349).extend({
  50113. type: 'markPoint',
  50114. defaultOption: {
  50115. zlevel: 0,
  50116. z: 5,
  50117. symbol: 'pin',
  50118. symbolSize: 50,
  50119. //symbolRotate: 0,
  50120. //symbolOffset: [0, 0]
  50121. tooltip: {
  50122. trigger: 'item'
  50123. },
  50124. label: {
  50125. normal: {
  50126. show: true,
  50127. position: 'inside'
  50128. },
  50129. emphasis: {
  50130. show: true
  50131. }
  50132. },
  50133. itemStyle: {
  50134. normal: {
  50135. borderWidth: 2
  50136. }
  50137. }
  50138. }
  50139. });
  50140. /***/ },
  50141. /* 349 */
  50142. /***/ function(module, exports, __webpack_require__) {
  50143. var modelUtil = __webpack_require__(5);
  50144. var zrUtil = __webpack_require__(4);
  50145. var env = __webpack_require__(2);
  50146. var formatUtil = __webpack_require__(6);
  50147. var addCommas = formatUtil.addCommas;
  50148. var encodeHTML = formatUtil.encodeHTML;
  50149. function fillLabel(opt) {
  50150. modelUtil.defaultEmphasis(
  50151. opt.label,
  50152. modelUtil.LABEL_OPTIONS
  50153. );
  50154. }
  50155. var MarkerModel = __webpack_require__(1).extendComponentModel({
  50156. type: 'marker',
  50157. dependencies: ['series', 'grid', 'polar', 'geo'],
  50158. /**
  50159. * @overrite
  50160. */
  50161. init: function (option, parentModel, ecModel, extraOpt) {
  50162. if (true) {
  50163. if (this.type === 'marker') {
  50164. throw new Error('Marker component is abstract component. Use markLine, markPoint, markArea instead.');
  50165. }
  50166. }
  50167. this.mergeDefaultAndTheme(option, ecModel);
  50168. this.mergeOption(option, ecModel, extraOpt.createdBySelf, true);
  50169. },
  50170. /**
  50171. * @return {boolean}
  50172. */
  50173. ifEnableAnimation: function () {
  50174. if (env.node) {
  50175. return false;
  50176. }
  50177. var hostSeries = this.__hostSeries;
  50178. return this.getShallow('animation') && hostSeries && hostSeries.ifEnableAnimation();
  50179. },
  50180. mergeOption: function (newOpt, ecModel, createdBySelf, isInit) {
  50181. var MarkerModel = this.constructor;
  50182. var modelPropName = this.mainType + 'Model';
  50183. if (!createdBySelf) {
  50184. ecModel.eachSeries(function (seriesModel) {
  50185. var markerOpt = seriesModel.get(this.mainType);
  50186. var markerModel = seriesModel[modelPropName];
  50187. if (!markerOpt || !markerOpt.data) {
  50188. seriesModel[modelPropName] = null;
  50189. return;
  50190. }
  50191. if (!markerModel) {
  50192. if (isInit) {
  50193. // Default label emphasis `position` and `show`
  50194. fillLabel(markerOpt);
  50195. }
  50196. zrUtil.each(markerOpt.data, function (item) {
  50197. // FIXME Overwrite fillLabel method ?
  50198. if (item instanceof Array) {
  50199. fillLabel(item[0]);
  50200. fillLabel(item[1]);
  50201. }
  50202. else {
  50203. fillLabel(item);
  50204. }
  50205. });
  50206. markerModel = new MarkerModel(
  50207. markerOpt, this, ecModel
  50208. );
  50209. zrUtil.extend(markerModel, {
  50210. mainType: this.mainType,
  50211. // Use the same series index and name
  50212. seriesIndex: seriesModel.seriesIndex,
  50213. name: seriesModel.name,
  50214. createdBySelf: true
  50215. });
  50216. markerModel.__hostSeries = seriesModel;
  50217. }
  50218. else {
  50219. markerModel.mergeOption(markerOpt, ecModel, true);
  50220. }
  50221. seriesModel[modelPropName] = markerModel;
  50222. }, this);
  50223. }
  50224. },
  50225. formatTooltip: function (dataIndex) {
  50226. var data = this.getData();
  50227. var value = this.getRawValue(dataIndex);
  50228. var formattedValue = zrUtil.isArray(value)
  50229. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  50230. var name = data.getName(dataIndex);
  50231. var html = this.name;
  50232. if (value != null || name) {
  50233. html += '<br />';
  50234. }
  50235. if (name) {
  50236. html += encodeHTML(name);
  50237. if (value != null) {
  50238. html += ' : ';
  50239. }
  50240. }
  50241. if (value != null) {
  50242. html += formattedValue;
  50243. }
  50244. return html;
  50245. },
  50246. getData: function () {
  50247. return this._data;
  50248. },
  50249. setData: function (data) {
  50250. this._data = data;
  50251. }
  50252. });
  50253. zrUtil.mixin(MarkerModel, modelUtil.dataFormatMixin);
  50254. module.exports = MarkerModel;
  50255. /***/ },
  50256. /* 350 */
  50257. /***/ function(module, exports, __webpack_require__) {
  50258. var SymbolDraw = __webpack_require__(105);
  50259. var zrUtil = __webpack_require__(4);
  50260. var numberUtil = __webpack_require__(7);
  50261. var List = __webpack_require__(98);
  50262. var markerHelper = __webpack_require__(351);
  50263. function updateMarkerLayout(mpData, seriesModel, api) {
  50264. var coordSys = seriesModel.coordinateSystem;
  50265. mpData.each(function (idx) {
  50266. var itemModel = mpData.getItemModel(idx);
  50267. var point;
  50268. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  50269. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  50270. if (!isNaN(xPx) && !isNaN(yPx)) {
  50271. point = [xPx, yPx];
  50272. }
  50273. // Chart like bar may have there own marker positioning logic
  50274. else if (seriesModel.getMarkerPosition) {
  50275. // Use the getMarkerPoisition
  50276. point = seriesModel.getMarkerPosition(
  50277. mpData.getValues(mpData.dimensions, idx)
  50278. );
  50279. }
  50280. else if (coordSys) {
  50281. var x = mpData.get(coordSys.dimensions[0], idx);
  50282. var y = mpData.get(coordSys.dimensions[1], idx);
  50283. point = coordSys.dataToPoint([x, y]);
  50284. }
  50285. // Use x, y if has any
  50286. if (!isNaN(xPx)) {
  50287. point[0] = xPx;
  50288. }
  50289. if (!isNaN(yPx)) {
  50290. point[1] = yPx;
  50291. }
  50292. mpData.setItemLayout(idx, point);
  50293. });
  50294. }
  50295. __webpack_require__(352).extend({
  50296. type: 'markPoint',
  50297. updateLayout: function (markPointModel, ecModel, api) {
  50298. ecModel.eachSeries(function (seriesModel) {
  50299. var mpModel = seriesModel.markPointModel;
  50300. if (mpModel) {
  50301. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  50302. this.markerGroupMap[seriesModel.name].updateLayout(mpModel);
  50303. }
  50304. }, this);
  50305. },
  50306. renderSeries: function (seriesModel, mpModel, ecModel, api) {
  50307. var coordSys = seriesModel.coordinateSystem;
  50308. var seriesName = seriesModel.name;
  50309. var seriesData = seriesModel.getData();
  50310. var symbolDrawMap = this.markerGroupMap;
  50311. var symbolDraw = symbolDrawMap[seriesName];
  50312. if (!symbolDraw) {
  50313. symbolDraw = symbolDrawMap[seriesName] = new SymbolDraw();
  50314. }
  50315. var mpData = createList(coordSys, seriesModel, mpModel);
  50316. // FIXME
  50317. mpModel.setData(mpData);
  50318. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  50319. mpData.each(function (idx) {
  50320. var itemModel = mpData.getItemModel(idx);
  50321. var symbolSize = itemModel.getShallow('symbolSize');
  50322. if (typeof symbolSize === 'function') {
  50323. // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据?
  50324. symbolSize = symbolSize(
  50325. mpModel.getRawValue(idx), mpModel.getDataParams(idx)
  50326. );
  50327. }
  50328. mpData.setItemVisual(idx, {
  50329. symbolSize: symbolSize,
  50330. color: itemModel.get('itemStyle.normal.color')
  50331. || seriesData.getVisual('color'),
  50332. symbol: itemModel.getShallow('symbol')
  50333. });
  50334. });
  50335. // TODO Text are wrong
  50336. symbolDraw.updateData(mpData);
  50337. this.group.add(symbolDraw.group);
  50338. // Set host model for tooltip
  50339. // FIXME
  50340. mpData.eachItemGraphicEl(function (el) {
  50341. el.traverse(function (child) {
  50342. child.dataModel = mpModel;
  50343. });
  50344. });
  50345. symbolDraw.__keep = true;
  50346. symbolDraw.group.silent = mpModel.get('silent') || seriesModel.get('silent');
  50347. }
  50348. });
  50349. /**
  50350. * @inner
  50351. * @param {module:echarts/coord/*} [coordSys]
  50352. * @param {module:echarts/model/Series} seriesModel
  50353. * @param {module:echarts/model/Model} mpModel
  50354. */
  50355. function createList(coordSys, seriesModel, mpModel) {
  50356. var coordDimsInfos;
  50357. if (coordSys) {
  50358. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  50359. var info = seriesModel.getData().getDimensionInfo(
  50360. seriesModel.coordDimToDataDim(coordDim)[0]
  50361. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  50362. info.name = coordDim;
  50363. return info;
  50364. });
  50365. }
  50366. else {
  50367. coordDimsInfos =[{
  50368. name: 'value',
  50369. type: 'float'
  50370. }];
  50371. }
  50372. var mpData = new List(coordDimsInfos, mpModel);
  50373. var dataOpt = zrUtil.map(mpModel.get('data'), zrUtil.curry(
  50374. markerHelper.dataTransform, seriesModel
  50375. ));
  50376. if (coordSys) {
  50377. dataOpt = zrUtil.filter(
  50378. dataOpt, zrUtil.curry(markerHelper.dataFilter, coordSys)
  50379. );
  50380. }
  50381. mpData.initData(dataOpt, null,
  50382. coordSys ? markerHelper.dimValueGetter : function (item) {
  50383. return item.value;
  50384. }
  50385. );
  50386. return mpData;
  50387. }
  50388. /***/ },
  50389. /* 351 */
  50390. /***/ function(module, exports, __webpack_require__) {
  50391. var zrUtil = __webpack_require__(4);
  50392. var numberUtil = __webpack_require__(7);
  50393. var indexOf = zrUtil.indexOf;
  50394. function hasXOrY(item) {
  50395. return !(isNaN(parseFloat(item.x)) && isNaN(parseFloat(item.y)));
  50396. }
  50397. function hasXAndY(item) {
  50398. return !isNaN(parseFloat(item.x)) && !isNaN(parseFloat(item.y));
  50399. }
  50400. function getPrecision(data, valueAxisDim, dataIndex) {
  50401. var precision = -1;
  50402. do {
  50403. precision = Math.max(
  50404. numberUtil.getPrecision(data.get(
  50405. valueAxisDim, dataIndex
  50406. )),
  50407. precision
  50408. );
  50409. data = data.stackedOn;
  50410. } while (data);
  50411. return precision;
  50412. }
  50413. function markerTypeCalculatorWithExtent(
  50414. mlType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex
  50415. ) {
  50416. var coordArr = [];
  50417. var value = numCalculate(data, targetDataDim, mlType);
  50418. var dataIndex = data.indexOfNearest(targetDataDim, value, true);
  50419. coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex, true);
  50420. coordArr[targetCoordIndex] = data.get(targetDataDim, dataIndex, true);
  50421. var precision = getPrecision(data, targetDataDim, dataIndex);
  50422. if (precision >= 0) {
  50423. coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
  50424. }
  50425. return coordArr;
  50426. }
  50427. var curry = zrUtil.curry;
  50428. // TODO Specified percent
  50429. var markerTypeCalculator = {
  50430. /**
  50431. * @method
  50432. * @param {module:echarts/data/List} data
  50433. * @param {string} baseAxisDim
  50434. * @param {string} valueAxisDim
  50435. */
  50436. min: curry(markerTypeCalculatorWithExtent, 'min'),
  50437. /**
  50438. * @method
  50439. * @param {module:echarts/data/List} data
  50440. * @param {string} baseAxisDim
  50441. * @param {string} valueAxisDim
  50442. */
  50443. max: curry(markerTypeCalculatorWithExtent, 'max'),
  50444. /**
  50445. * @method
  50446. * @param {module:echarts/data/List} data
  50447. * @param {string} baseAxisDim
  50448. * @param {string} valueAxisDim
  50449. */
  50450. average: curry(markerTypeCalculatorWithExtent, 'average')
  50451. };
  50452. /**
  50453. * Transform markPoint data item to format used in List by do the following
  50454. * 1. Calculate statistic like `max`, `min`, `average`
  50455. * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
  50456. * @param {module:echarts/model/Series} seriesModel
  50457. * @param {module:echarts/coord/*} [coordSys]
  50458. * @param {Object} item
  50459. * @return {Object}
  50460. */
  50461. var dataTransform = function (seriesModel, item) {
  50462. var data = seriesModel.getData();
  50463. var coordSys = seriesModel.coordinateSystem;
  50464. // 1. If not specify the position with pixel directly
  50465. // 2. If `coord` is not a data array. Which uses `xAxis`,
  50466. // `yAxis` to specify the coord on each dimension
  50467. // parseFloat first because item.x and item.y can be percent string like '20%'
  50468. if (item && !hasXAndY(item) && !zrUtil.isArray(item.coord) && coordSys) {
  50469. var dims = coordSys.dimensions;
  50470. var axisInfo = getAxisInfo(item, data, coordSys, seriesModel);
  50471. // Clone the option
  50472. // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
  50473. item = zrUtil.clone(item);
  50474. if (item.type
  50475. && markerTypeCalculator[item.type]
  50476. && axisInfo.baseAxis && axisInfo.valueAxis
  50477. ) {
  50478. var otherCoordIndex = indexOf(dims, axisInfo.baseAxis.dim);
  50479. var targetCoordIndex = indexOf(dims, axisInfo.valueAxis.dim);
  50480. item.coord = markerTypeCalculator[item.type](
  50481. data, axisInfo.baseDataDim, axisInfo.valueDataDim,
  50482. otherCoordIndex, targetCoordIndex
  50483. );
  50484. // Force to use the value of calculated value.
  50485. item.value = item.coord[targetCoordIndex];
  50486. }
  50487. else {
  50488. // FIXME Only has one of xAxis and yAxis.
  50489. var coord = [
  50490. item.xAxis != null ? item.xAxis : item.radiusAxis,
  50491. item.yAxis != null ? item.yAxis : item.angleAxis
  50492. ];
  50493. // Each coord support max, min, average
  50494. for (var i = 0; i < 2; i++) {
  50495. if (markerTypeCalculator[coord[i]]) {
  50496. var dataDim = seriesModel.coordDimToDataDim(dims[i])[0];
  50497. coord[i] = numCalculate(data, dataDim, coord[i]);
  50498. }
  50499. }
  50500. item.coord = coord;
  50501. }
  50502. }
  50503. return item;
  50504. };
  50505. var getAxisInfo = function (item, data, coordSys, seriesModel) {
  50506. var ret = {};
  50507. if (item.valueIndex != null || item.valueDim != null) {
  50508. ret.valueDataDim = item.valueIndex != null
  50509. ? data.getDimension(item.valueIndex) : item.valueDim;
  50510. ret.valueAxis = coordSys.getAxis(seriesModel.dataDimToCoordDim(ret.valueDataDim));
  50511. ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis);
  50512. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  50513. }
  50514. else {
  50515. ret.baseAxis = seriesModel.getBaseAxis();
  50516. ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis);
  50517. ret.baseDataDim = seriesModel.coordDimToDataDim(ret.baseAxis.dim)[0];
  50518. ret.valueDataDim = seriesModel.coordDimToDataDim(ret.valueAxis.dim)[0];
  50519. }
  50520. return ret;
  50521. };
  50522. /**
  50523. * Filter data which is out of coordinateSystem range
  50524. * [dataFilter description]
  50525. * @param {module:echarts/coord/*} [coordSys]
  50526. * @param {Object} item
  50527. * @return {boolean}
  50528. */
  50529. var dataFilter = function (coordSys, item) {
  50530. // Alwalys return true if there is no coordSys
  50531. return (coordSys && coordSys.containData && item.coord && !hasXOrY(item))
  50532. ? coordSys.containData(item.coord) : true;
  50533. };
  50534. var dimValueGetter = function (item, dimName, dataIndex, dimIndex) {
  50535. // x, y, radius, angle
  50536. if (dimIndex < 2) {
  50537. return item.coord && item.coord[dimIndex];
  50538. }
  50539. return item.value;
  50540. };
  50541. var numCalculate = function (data, valueDataDim, type) {
  50542. if (type === 'average') {
  50543. var sum = 0;
  50544. var count = 0;
  50545. data.each(valueDataDim, function (val, idx) {
  50546. if (!isNaN(val)) {
  50547. sum += val;
  50548. count++;
  50549. }
  50550. }, true);
  50551. return sum / count;
  50552. }
  50553. else {
  50554. return data.getDataExtent(valueDataDim, true)[type === 'max' ? 1 : 0];
  50555. }
  50556. };
  50557. module.exports = {
  50558. dataTransform: dataTransform,
  50559. dataFilter: dataFilter,
  50560. dimValueGetter: dimValueGetter,
  50561. getAxisInfo: getAxisInfo,
  50562. numCalculate: numCalculate
  50563. };
  50564. /***/ },
  50565. /* 352 */
  50566. /***/ function(module, exports, __webpack_require__) {
  50567. module.exports = __webpack_require__(1).extendComponentView({
  50568. type: 'marker',
  50569. init: function () {
  50570. /**
  50571. * Markline grouped by series
  50572. * @private
  50573. * @type {Object}
  50574. */
  50575. this.markerGroupMap = {};
  50576. },
  50577. render: function (markerModel, ecModel, api) {
  50578. var markerGroupMap = this.markerGroupMap;
  50579. for (var name in markerGroupMap) {
  50580. if (markerGroupMap.hasOwnProperty(name)) {
  50581. markerGroupMap[name].__keep = false;
  50582. }
  50583. }
  50584. var markerModelKey = this.type + 'Model';
  50585. ecModel.eachSeries(function (seriesModel) {
  50586. var markerModel = seriesModel[markerModelKey];
  50587. markerModel && this.renderSeries(seriesModel, markerModel, ecModel, api);
  50588. }, this);
  50589. for (var name in markerGroupMap) {
  50590. if (markerGroupMap.hasOwnProperty(name) && !markerGroupMap[name].__keep) {
  50591. this.group.remove(markerGroupMap[name].group);
  50592. }
  50593. }
  50594. },
  50595. renderSeries: function () {}
  50596. });
  50597. /***/ },
  50598. /* 353 */
  50599. /***/ function(module, exports, __webpack_require__) {
  50600. __webpack_require__(354);
  50601. __webpack_require__(355);
  50602. __webpack_require__(1).registerPreprocessor(function (opt) {
  50603. // Make sure markLine component is enabled
  50604. opt.markLine = opt.markLine || {};
  50605. });
  50606. /***/ },
  50607. /* 354 */
  50608. /***/ function(module, exports, __webpack_require__) {
  50609. module.exports = __webpack_require__(349).extend({
  50610. type: 'markLine',
  50611. defaultOption: {
  50612. zlevel: 0,
  50613. z: 5,
  50614. symbol: ['circle', 'arrow'],
  50615. symbolSize: [8, 16],
  50616. //symbolRotate: 0,
  50617. precision: 2,
  50618. tooltip: {
  50619. trigger: 'item'
  50620. },
  50621. label: {
  50622. normal: {
  50623. show: true,
  50624. position: 'end'
  50625. },
  50626. emphasis: {
  50627. show: true
  50628. }
  50629. },
  50630. lineStyle: {
  50631. normal: {
  50632. type: 'dashed'
  50633. },
  50634. emphasis: {
  50635. width: 3
  50636. }
  50637. },
  50638. animationEasing: 'linear'
  50639. }
  50640. });
  50641. /***/ },
  50642. /* 355 */
  50643. /***/ function(module, exports, __webpack_require__) {
  50644. var zrUtil = __webpack_require__(4);
  50645. var List = __webpack_require__(98);
  50646. var numberUtil = __webpack_require__(7);
  50647. var markerHelper = __webpack_require__(351);
  50648. var LineDraw = __webpack_require__(201);
  50649. var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
  50650. var data = seriesModel.getData();
  50651. // Special type markLine like 'min', 'max', 'average'
  50652. var mlType = item.type;
  50653. if (!zrUtil.isArray(item)
  50654. && (
  50655. mlType === 'min' || mlType === 'max' || mlType === 'average'
  50656. // In case
  50657. // data: [{
  50658. // yAxis: 10
  50659. // }]
  50660. || (item.xAxis != null || item.yAxis != null)
  50661. )
  50662. ) {
  50663. var valueAxis;
  50664. var valueDataDim;
  50665. var value;
  50666. if (item.yAxis != null || item.xAxis != null) {
  50667. valueDataDim = item.yAxis != null ? 'y' : 'x';
  50668. valueAxis = coordSys.getAxis(valueDataDim);
  50669. value = zrUtil.retrieve(item.yAxis, item.xAxis);
  50670. }
  50671. else {
  50672. var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);
  50673. valueDataDim = axisInfo.valueDataDim;
  50674. valueAxis = axisInfo.valueAxis;
  50675. value = markerHelper.numCalculate(data, valueDataDim, mlType);
  50676. }
  50677. var valueIndex = valueDataDim === 'x' ? 0 : 1;
  50678. var baseIndex = 1 - valueIndex;
  50679. var mlFrom = zrUtil.clone(item);
  50680. var mlTo = {};
  50681. mlFrom.type = null;
  50682. mlFrom.coord = [];
  50683. mlTo.coord = [];
  50684. mlFrom.coord[baseIndex] = -Infinity;
  50685. mlTo.coord[baseIndex] = Infinity;
  50686. var precision = mlModel.get('precision');
  50687. if (precision >= 0 && typeof value === 'number') {
  50688. value = +value.toFixed(precision);
  50689. }
  50690. mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
  50691. item = [mlFrom, mlTo, { // Extra option for tooltip and label
  50692. type: mlType,
  50693. valueIndex: item.valueIndex,
  50694. // Force to use the value of calculated value.
  50695. value: value
  50696. }];
  50697. }
  50698. item = [
  50699. markerHelper.dataTransform(seriesModel, item[0]),
  50700. markerHelper.dataTransform(seriesModel, item[1]),
  50701. zrUtil.extend({}, item[2])
  50702. ];
  50703. // Avoid line data type is extended by from(to) data type
  50704. item[2].type = item[2].type || '';
  50705. // Merge from option and to option into line option
  50706. zrUtil.merge(item[2], item[0]);
  50707. zrUtil.merge(item[2], item[1]);
  50708. return item;
  50709. };
  50710. function isInifinity(val) {
  50711. return !isNaN(val) && !isFinite(val);
  50712. }
  50713. // If a markLine has one dim
  50714. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  50715. var otherDimIndex = 1 - dimIndex;
  50716. var dimName = coordSys.dimensions[dimIndex];
  50717. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex])
  50718. && fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
  50719. }
  50720. function markLineFilter(coordSys, item) {
  50721. if (coordSys.type === 'cartesian2d') {
  50722. var fromCoord = item[0].coord;
  50723. var toCoord = item[1].coord;
  50724. // In case
  50725. // {
  50726. // markLine: {
  50727. // data: [{ yAxis: 2 }]
  50728. // }
  50729. // }
  50730. if (
  50731. fromCoord && toCoord &&
  50732. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  50733. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  50734. ) {
  50735. return true;
  50736. }
  50737. }
  50738. return markerHelper.dataFilter(coordSys, item[0])
  50739. && markerHelper.dataFilter(coordSys, item[1]);
  50740. }
  50741. function updateSingleMarkerEndLayout(
  50742. data, idx, isFrom, seriesModel, api
  50743. ) {
  50744. var coordSys = seriesModel.coordinateSystem;
  50745. var itemModel = data.getItemModel(idx);
  50746. var point;
  50747. var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
  50748. var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
  50749. if (!isNaN(xPx) && !isNaN(yPx)) {
  50750. point = [xPx, yPx];
  50751. }
  50752. else {
  50753. // Chart like bar may have there own marker positioning logic
  50754. if (seriesModel.getMarkerPosition) {
  50755. // Use the getMarkerPoisition
  50756. point = seriesModel.getMarkerPosition(
  50757. data.getValues(data.dimensions, idx)
  50758. );
  50759. }
  50760. else {
  50761. var dims = coordSys.dimensions;
  50762. var x = data.get(dims[0], idx);
  50763. var y = data.get(dims[1], idx);
  50764. point = coordSys.dataToPoint([x, y]);
  50765. }
  50766. // Expand line to the edge of grid if value on one axis is Inifnity
  50767. // In case
  50768. // markLine: {
  50769. // data: [{
  50770. // yAxis: 2
  50771. // // or
  50772. // type: 'average'
  50773. // }]
  50774. // }
  50775. if (coordSys.type === 'cartesian2d') {
  50776. var xAxis = coordSys.getAxis('x');
  50777. var yAxis = coordSys.getAxis('y');
  50778. var dims = coordSys.dimensions;
  50779. if (isInifinity(data.get(dims[0], idx))) {
  50780. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
  50781. }
  50782. else if (isInifinity(data.get(dims[1], idx))) {
  50783. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
  50784. }
  50785. }
  50786. // Use x, y if has any
  50787. if (!isNaN(xPx)) {
  50788. point[0] = xPx;
  50789. }
  50790. if (!isNaN(yPx)) {
  50791. point[1] = yPx;
  50792. }
  50793. }
  50794. data.setItemLayout(idx, point);
  50795. }
  50796. __webpack_require__(352).extend({
  50797. type: 'markLine',
  50798. updateLayout: function (markLineModel, ecModel, api) {
  50799. ecModel.eachSeries(function (seriesModel) {
  50800. var mlModel = seriesModel.markLineModel;
  50801. if (mlModel) {
  50802. var mlData = mlModel.getData();
  50803. var fromData = mlModel.__from;
  50804. var toData = mlModel.__to;
  50805. // Update visual and layout of from symbol and to symbol
  50806. fromData.each(function (idx) {
  50807. updateSingleMarkerEndLayout(fromData, idx, true, seriesModel, api);
  50808. updateSingleMarkerEndLayout(toData, idx, false, seriesModel, api);
  50809. });
  50810. // Update layout of line
  50811. mlData.each(function (idx) {
  50812. mlData.setItemLayout(idx, [
  50813. fromData.getItemLayout(idx),
  50814. toData.getItemLayout(idx)
  50815. ]);
  50816. });
  50817. this.markerGroupMap[seriesModel.name].updateLayout();
  50818. }
  50819. }, this);
  50820. },
  50821. renderSeries: function (seriesModel, mlModel, ecModel, api) {
  50822. var coordSys = seriesModel.coordinateSystem;
  50823. var seriesName = seriesModel.name;
  50824. var seriesData = seriesModel.getData();
  50825. var lineDrawMap = this.markerGroupMap;
  50826. var lineDraw = lineDrawMap[seriesName];
  50827. if (!lineDraw) {
  50828. lineDraw = lineDrawMap[seriesName] = new LineDraw();
  50829. }
  50830. this.group.add(lineDraw.group);
  50831. var mlData = createList(coordSys, seriesModel, mlModel);
  50832. var fromData = mlData.from;
  50833. var toData = mlData.to;
  50834. var lineData = mlData.line;
  50835. mlModel.__from = fromData;
  50836. mlModel.__to = toData;
  50837. // Line data for tooltip and formatter
  50838. mlModel.setData(lineData);
  50839. var symbolType = mlModel.get('symbol');
  50840. var symbolSize = mlModel.get('symbolSize');
  50841. if (!zrUtil.isArray(symbolType)) {
  50842. symbolType = [symbolType, symbolType];
  50843. }
  50844. if (typeof symbolSize === 'number') {
  50845. symbolSize = [symbolSize, symbolSize];
  50846. }
  50847. // Update visual and layout of from symbol and to symbol
  50848. mlData.from.each(function (idx) {
  50849. updateDataVisualAndLayout(fromData, idx, true);
  50850. updateDataVisualAndLayout(toData, idx, false);
  50851. });
  50852. // Update visual and layout of line
  50853. lineData.each(function (idx) {
  50854. var lineColor = lineData.getItemModel(idx).get('lineStyle.normal.color');
  50855. lineData.setItemVisual(idx, {
  50856. color: lineColor || fromData.getItemVisual(idx, 'color')
  50857. });
  50858. lineData.setItemLayout(idx, [
  50859. fromData.getItemLayout(idx),
  50860. toData.getItemLayout(idx)
  50861. ]);
  50862. lineData.setItemVisual(idx, {
  50863. 'fromSymbolSize': fromData.getItemVisual(idx, 'symbolSize'),
  50864. 'fromSymbol': fromData.getItemVisual(idx, 'symbol'),
  50865. 'toSymbolSize': toData.getItemVisual(idx, 'symbolSize'),
  50866. 'toSymbol': toData.getItemVisual(idx, 'symbol')
  50867. });
  50868. });
  50869. lineDraw.updateData(lineData);
  50870. // Set host model for tooltip
  50871. // FIXME
  50872. mlData.line.eachItemGraphicEl(function (el, idx) {
  50873. el.traverse(function (child) {
  50874. child.dataModel = mlModel;
  50875. });
  50876. });
  50877. function updateDataVisualAndLayout(data, idx, isFrom) {
  50878. var itemModel = data.getItemModel(idx);
  50879. updateSingleMarkerEndLayout(
  50880. data, idx, isFrom, seriesModel, api
  50881. );
  50882. data.setItemVisual(idx, {
  50883. symbolSize: itemModel.get('symbolSize') || symbolSize[isFrom ? 0 : 1],
  50884. symbol: itemModel.get('symbol', true) || symbolType[isFrom ? 0 : 1],
  50885. color: itemModel.get('itemStyle.normal.color') || seriesData.getVisual('color')
  50886. });
  50887. }
  50888. lineDraw.__keep = true;
  50889. lineDraw.group.silent = mlModel.get('silent') || seriesModel.get('silent');
  50890. }
  50891. });
  50892. /**
  50893. * @inner
  50894. * @param {module:echarts/coord/*} coordSys
  50895. * @param {module:echarts/model/Series} seriesModel
  50896. * @param {module:echarts/model/Model} mpModel
  50897. */
  50898. function createList(coordSys, seriesModel, mlModel) {
  50899. var coordDimsInfos;
  50900. if (coordSys) {
  50901. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  50902. var info = seriesModel.getData().getDimensionInfo(
  50903. seriesModel.coordDimToDataDim(coordDim)[0]
  50904. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  50905. info.name = coordDim;
  50906. return info;
  50907. });
  50908. }
  50909. else {
  50910. coordDimsInfos =[{
  50911. name: 'value',
  50912. type: 'float'
  50913. }];
  50914. }
  50915. var fromData = new List(coordDimsInfos, mlModel);
  50916. var toData = new List(coordDimsInfos, mlModel);
  50917. // No dimensions
  50918. var lineData = new List([], mlModel);
  50919. var optData = zrUtil.map(mlModel.get('data'), zrUtil.curry(
  50920. markLineTransform, seriesModel, coordSys, mlModel
  50921. ));
  50922. if (coordSys) {
  50923. optData = zrUtil.filter(
  50924. optData, zrUtil.curry(markLineFilter, coordSys)
  50925. );
  50926. }
  50927. var dimValueGetter = coordSys ? markerHelper.dimValueGetter : function (item) {
  50928. return item.value;
  50929. };
  50930. fromData.initData(
  50931. zrUtil.map(optData, function (item) { return item[0]; }),
  50932. null, dimValueGetter
  50933. );
  50934. toData.initData(
  50935. zrUtil.map(optData, function (item) { return item[1]; }),
  50936. null, dimValueGetter
  50937. );
  50938. lineData.initData(
  50939. zrUtil.map(optData, function (item) { return item[2]; })
  50940. );
  50941. lineData.hasItemOption = true;
  50942. return {
  50943. from: fromData,
  50944. to: toData,
  50945. line: lineData
  50946. };
  50947. }
  50948. /***/ },
  50949. /* 356 */
  50950. /***/ function(module, exports, __webpack_require__) {
  50951. __webpack_require__(357);
  50952. __webpack_require__(358);
  50953. __webpack_require__(1).registerPreprocessor(function (opt) {
  50954. // Make sure markArea component is enabled
  50955. opt.markArea = opt.markArea || {};
  50956. });
  50957. /***/ },
  50958. /* 357 */
  50959. /***/ function(module, exports, __webpack_require__) {
  50960. module.exports = __webpack_require__(349).extend({
  50961. type: 'markArea',
  50962. defaultOption: {
  50963. zlevel: 0,
  50964. // PENDING
  50965. z: 1,
  50966. tooltip: {
  50967. trigger: 'item'
  50968. },
  50969. // markArea should fixed on the coordinate system
  50970. animation: false,
  50971. label: {
  50972. normal: {
  50973. show: true,
  50974. position: 'top'
  50975. },
  50976. emphasis: {
  50977. show: true,
  50978. position: 'top'
  50979. }
  50980. },
  50981. itemStyle: {
  50982. normal: {
  50983. // color and borderColor default to use color from series
  50984. // color: 'auto'
  50985. // borderColor: 'auto'
  50986. borderWidth: 0
  50987. }
  50988. }
  50989. }
  50990. });
  50991. /***/ },
  50992. /* 358 */
  50993. /***/ function(module, exports, __webpack_require__) {
  50994. // TODO Better on polar
  50995. var zrUtil = __webpack_require__(4);
  50996. var List = __webpack_require__(98);
  50997. var numberUtil = __webpack_require__(7);
  50998. var graphic = __webpack_require__(43);
  50999. var colorUtil = __webpack_require__(39);
  51000. var markerHelper = __webpack_require__(351);
  51001. var markAreaTransform = function (seriesModel, coordSys, maModel, item) {
  51002. var lt = markerHelper.dataTransform(seriesModel, item[0]);
  51003. var rb = markerHelper.dataTransform(seriesModel, item[1]);
  51004. var retrieve = zrUtil.retrieve;
  51005. // FIXME make sure lt is less than rb
  51006. var ltCoord = lt.coord;
  51007. var rbCoord = rb.coord;
  51008. ltCoord[0] = retrieve(ltCoord[0], -Infinity);
  51009. ltCoord[1] = retrieve(ltCoord[1], -Infinity);
  51010. rbCoord[0] = retrieve(rbCoord[0], Infinity);
  51011. rbCoord[1] = retrieve(rbCoord[1], Infinity);
  51012. // Merge option into one
  51013. var result = zrUtil.mergeAll([{}, lt, rb]);
  51014. result.coord = [
  51015. lt.coord, rb.coord
  51016. ];
  51017. result.x0 = lt.x;
  51018. result.y0 = lt.y;
  51019. result.x1 = rb.x;
  51020. result.y1 = rb.y;
  51021. return result;
  51022. };
  51023. function isInifinity(val) {
  51024. return !isNaN(val) && !isFinite(val);
  51025. }
  51026. // If a markArea has one dim
  51027. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  51028. var otherDimIndex = 1 - dimIndex;
  51029. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
  51030. }
  51031. function markAreaFilter(coordSys, item) {
  51032. var fromCoord = item.coord[0];
  51033. var toCoord = item.coord[1];
  51034. if (coordSys.type === 'cartesian2d') {
  51035. // In case
  51036. // {
  51037. // markArea: {
  51038. // data: [{ yAxis: 2 }]
  51039. // }
  51040. // }
  51041. if (
  51042. fromCoord && toCoord &&
  51043. (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys)
  51044. || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))
  51045. ) {
  51046. return true;
  51047. }
  51048. }
  51049. return markerHelper.dataFilter(coordSys, {
  51050. coord: fromCoord,
  51051. x: item.x0,
  51052. y: item.y0
  51053. })
  51054. || markerHelper.dataFilter(coordSys, {
  51055. coord: toCoord,
  51056. x: item.x1,
  51057. y: item.y1
  51058. });
  51059. }
  51060. // dims can be ['x0', 'y0'], ['x1', 'y1'], ['x0', 'y1'], ['x1', 'y0']
  51061. function getSingleMarkerEndPoint(data, idx, dims, seriesModel, api) {
  51062. var coordSys = seriesModel.coordinateSystem;
  51063. var itemModel = data.getItemModel(idx);
  51064. var point;
  51065. var xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
  51066. var yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
  51067. if (!isNaN(xPx) && !isNaN(yPx)) {
  51068. point = [xPx, yPx];
  51069. }
  51070. else {
  51071. // Chart like bar may have there own marker positioning logic
  51072. if (seriesModel.getMarkerPosition) {
  51073. // Use the getMarkerPoisition
  51074. point = seriesModel.getMarkerPosition(
  51075. data.getValues(dims, idx)
  51076. );
  51077. }
  51078. else {
  51079. var x = data.get(dims[0], idx);
  51080. var y = data.get(dims[1], idx);
  51081. point = coordSys.dataToPoint([x, y], true);
  51082. }
  51083. if (coordSys.type === 'cartesian2d') {
  51084. var xAxis = coordSys.getAxis('x');
  51085. var yAxis = coordSys.getAxis('y');
  51086. var x = data.get(dims[0], idx);
  51087. var y = data.get(dims[1], idx);
  51088. if (isInifinity(x)) {
  51089. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
  51090. }
  51091. else if (isInifinity(y)) {
  51092. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
  51093. }
  51094. }
  51095. // Use x, y if has any
  51096. if (!isNaN(xPx)) {
  51097. point[0] = xPx;
  51098. }
  51099. if (!isNaN(yPx)) {
  51100. point[1] = yPx;
  51101. }
  51102. }
  51103. return point;
  51104. }
  51105. var dimPermutations = [['x0', 'y0'], ['x1', 'y0'], ['x1', 'y1'], ['x0', 'y1']];
  51106. __webpack_require__(352).extend({
  51107. type: 'markArea',
  51108. updateLayout: function (markAreaModel, ecModel, api) {
  51109. ecModel.eachSeries(function (seriesModel) {
  51110. var maModel = seriesModel.markAreaModel;
  51111. if (maModel) {
  51112. var areaData = maModel.getData();
  51113. areaData.each(function (idx) {
  51114. var points = zrUtil.map(dimPermutations, function (dim) {
  51115. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  51116. });
  51117. // Layout
  51118. areaData.setItemLayout(idx, points);
  51119. var el = areaData.getItemGraphicEl(idx);
  51120. el.setShape('points', points);
  51121. });
  51122. }
  51123. }, this);
  51124. },
  51125. renderSeries: function (seriesModel, maModel, ecModel, api) {
  51126. var coordSys = seriesModel.coordinateSystem;
  51127. var seriesName = seriesModel.name;
  51128. var seriesData = seriesModel.getData();
  51129. var areaGroupMap = this.markerGroupMap;
  51130. var polygonGroup = areaGroupMap[seriesName];
  51131. if (!polygonGroup) {
  51132. polygonGroup = areaGroupMap[seriesName] = {
  51133. group: new graphic.Group()
  51134. };
  51135. }
  51136. this.group.add(polygonGroup.group);
  51137. polygonGroup.__keep = true;
  51138. var areaData = createList(coordSys, seriesModel, maModel);
  51139. // Line data for tooltip and formatter
  51140. maModel.setData(areaData);
  51141. // Update visual and layout of line
  51142. areaData.each(function (idx) {
  51143. // Layout
  51144. areaData.setItemLayout(idx, zrUtil.map(dimPermutations, function (dim) {
  51145. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  51146. }));
  51147. // Visual
  51148. areaData.setItemVisual(idx, {
  51149. color: seriesData.getVisual('color')
  51150. });
  51151. });
  51152. areaData.diff(polygonGroup.__data)
  51153. .add(function (idx) {
  51154. var polygon = new graphic.Polygon({
  51155. shape: {
  51156. points: areaData.getItemLayout(idx)
  51157. }
  51158. });
  51159. areaData.setItemGraphicEl(idx, polygon);
  51160. polygonGroup.group.add(polygon);
  51161. })
  51162. .update(function (newIdx, oldIdx) {
  51163. var polygon = polygonGroup.__data.getItemGraphicEl(oldIdx);
  51164. graphic.updateProps(polygon, {
  51165. shape: {
  51166. points: areaData.getItemLayout(newIdx)
  51167. }
  51168. }, maModel, newIdx);
  51169. polygonGroup.group.add(polygon);
  51170. areaData.setItemGraphicEl(newIdx, polygon);
  51171. })
  51172. .remove(function (idx) {
  51173. var polygon = polygonGroup.__data.getItemGraphicEl(idx);
  51174. polygonGroup.group.remove(polygon);
  51175. })
  51176. .execute();
  51177. areaData.eachItemGraphicEl(function (polygon, idx) {
  51178. var itemModel = areaData.getItemModel(idx);
  51179. var labelModel = itemModel.getModel('label.normal');
  51180. var labelHoverModel = itemModel.getModel('label.emphasis');
  51181. var color = areaData.getItemVisual(idx, 'color');
  51182. polygon.useStyle(
  51183. zrUtil.defaults(
  51184. itemModel.getModel('itemStyle.normal').getItemStyle(),
  51185. {
  51186. fill: colorUtil.modifyAlpha(color, 0.4),
  51187. stroke: color
  51188. }
  51189. )
  51190. );
  51191. polygon.hoverStyle = itemModel.getModel('itemStyle.normal').getItemStyle();
  51192. var defaultValue = areaData.getName(idx) || '';
  51193. var textColor = color || polygon.style.fill;
  51194. graphic.setText(polygon.style, labelModel, textColor);
  51195. polygon.style.text = zrUtil.retrieve(
  51196. maModel.getFormattedLabel(idx, 'normal'),
  51197. defaultValue
  51198. );
  51199. graphic.setText(polygon.hoverStyle, labelHoverModel, textColor);
  51200. polygon.hoverStyle.text = zrUtil.retrieve(
  51201. maModel.getFormattedLabel(idx, 'emphasis'),
  51202. defaultValue
  51203. );
  51204. graphic.setHoverStyle(polygon, {});
  51205. polygon.dataModel = maModel;
  51206. });
  51207. polygonGroup.__data = areaData;
  51208. polygonGroup.group.silent = maModel.get('silent') || seriesModel.get('silent');
  51209. }
  51210. });
  51211. /**
  51212. * @inner
  51213. * @param {module:echarts/coord/*} coordSys
  51214. * @param {module:echarts/model/Series} seriesModel
  51215. * @param {module:echarts/model/Model} mpModel
  51216. */
  51217. function createList(coordSys, seriesModel, maModel) {
  51218. var coordDimsInfos;
  51219. var areaData;
  51220. var dims = ['x0', 'y0', 'x1', 'y1'];
  51221. if (coordSys) {
  51222. coordDimsInfos = zrUtil.map(coordSys && coordSys.dimensions, function (coordDim) {
  51223. var info = seriesModel.getData().getDimensionInfo(
  51224. seriesModel.coordDimToDataDim(coordDim)[0]
  51225. ) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  51226. info.name = coordDim;
  51227. return info;
  51228. });
  51229. areaData = new List(zrUtil.map(dims, function (dim, idx) {
  51230. return {
  51231. name: dim,
  51232. type: coordDimsInfos[idx % 2].type
  51233. };
  51234. }), maModel);
  51235. }
  51236. else {
  51237. coordDimsInfos =[{
  51238. name: 'value',
  51239. type: 'float'
  51240. }];
  51241. areaData = new List(coordDimsInfos, maModel);
  51242. }
  51243. var optData = zrUtil.map(maModel.get('data'), zrUtil.curry(
  51244. markAreaTransform, seriesModel, coordSys, maModel
  51245. ));
  51246. if (coordSys) {
  51247. optData = zrUtil.filter(
  51248. optData, zrUtil.curry(markAreaFilter, coordSys)
  51249. );
  51250. }
  51251. var dimValueGetter = coordSys ? function (item, dimName, dataIndex, dimIndex) {
  51252. return item.coord[Math.floor(dimIndex / 2)][dimIndex % 2];
  51253. } : function (item) {
  51254. return item.value;
  51255. };
  51256. areaData.initData(optData, null, dimValueGetter);
  51257. areaData.hasItemOption = true;
  51258. return areaData;
  51259. }
  51260. /***/ },
  51261. /* 359 */
  51262. /***/ function(module, exports, __webpack_require__) {
  51263. /**
  51264. * DataZoom component entry
  51265. */
  51266. var echarts = __webpack_require__(1);
  51267. echarts.registerPreprocessor(__webpack_require__(360));
  51268. __webpack_require__(361);
  51269. __webpack_require__(362);
  51270. __webpack_require__(363);
  51271. __webpack_require__(365);
  51272. /***/ },
  51273. /* 360 */
  51274. /***/ function(module, exports, __webpack_require__) {
  51275. /**
  51276. * @file Timeline preprocessor
  51277. */
  51278. var zrUtil = __webpack_require__(4);
  51279. module.exports = function (option) {
  51280. var timelineOpt = option && option.timeline;
  51281. if (!zrUtil.isArray(timelineOpt)) {
  51282. timelineOpt = timelineOpt ? [timelineOpt] : [];
  51283. }
  51284. zrUtil.each(timelineOpt, function (opt) {
  51285. if (!opt) {
  51286. return;
  51287. }
  51288. compatibleEC2(opt);
  51289. });
  51290. };
  51291. function compatibleEC2(opt) {
  51292. var type = opt.type;
  51293. var ec2Types = {'number': 'value', 'time': 'time'};
  51294. // Compatible with ec2
  51295. if (ec2Types[type]) {
  51296. opt.axisType = ec2Types[type];
  51297. delete opt.type;
  51298. }
  51299. transferItem(opt);
  51300. if (has(opt, 'controlPosition')) {
  51301. var controlStyle = opt.controlStyle || (opt.controlStyle = {});
  51302. if (!has(controlStyle, 'position')) {
  51303. controlStyle.position = opt.controlPosition;
  51304. }
  51305. if (controlStyle.position === 'none' && !has(controlStyle, 'show')) {
  51306. controlStyle.show = false;
  51307. delete controlStyle.position;
  51308. }
  51309. delete opt.controlPosition;
  51310. }
  51311. zrUtil.each(opt.data || [], function (dataItem) {
  51312. if (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem)) {
  51313. if (!has(dataItem, 'value') && has(dataItem, 'name')) {
  51314. // In ec2, using name as value.
  51315. dataItem.value = dataItem.name;
  51316. }
  51317. transferItem(dataItem);
  51318. }
  51319. });
  51320. }
  51321. function transferItem(opt) {
  51322. var itemStyle = opt.itemStyle || (opt.itemStyle = {});
  51323. var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {});
  51324. // Transfer label out
  51325. var label = opt.label || (opt.label || {});
  51326. var labelNormal = label.normal || (label.normal = {});
  51327. var excludeLabelAttr = {normal: 1, emphasis: 1};
  51328. zrUtil.each(label, function (value, name) {
  51329. if (!excludeLabelAttr[name] && !has(labelNormal, name)) {
  51330. labelNormal[name] = value;
  51331. }
  51332. });
  51333. if (itemStyleEmphasis.label && !has(label, 'emphasis')) {
  51334. label.emphasis = itemStyleEmphasis.label;
  51335. delete itemStyleEmphasis.label;
  51336. }
  51337. }
  51338. function has(obj, attr) {
  51339. return obj.hasOwnProperty(attr);
  51340. }
  51341. /***/ },
  51342. /* 361 */
  51343. /***/ function(module, exports, __webpack_require__) {
  51344. __webpack_require__(19).registerSubTypeDefaulter('timeline', function () {
  51345. // Only slider now.
  51346. return 'slider';
  51347. });
  51348. /***/ },
  51349. /* 362 */
  51350. /***/ function(module, exports, __webpack_require__) {
  51351. /**
  51352. * @file Timeilne action
  51353. */
  51354. var echarts = __webpack_require__(1);
  51355. var zrUtil = __webpack_require__(4);
  51356. echarts.registerAction(
  51357. {type: 'timelineChange', event: 'timelineChanged', update: 'prepareAndUpdate'},
  51358. function (payload, ecModel) {
  51359. var timelineModel = ecModel.getComponent('timeline');
  51360. if (timelineModel && payload.currentIndex != null) {
  51361. timelineModel.setCurrentIndex(payload.currentIndex);
  51362. if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) {
  51363. timelineModel.setPlayState(false);
  51364. }
  51365. }
  51366. // Set normalized currentIndex to payload.
  51367. ecModel.resetOption('timeline');
  51368. return zrUtil.defaults({
  51369. currentIndex: timelineModel.option.currentIndex
  51370. }, payload);
  51371. }
  51372. );
  51373. echarts.registerAction(
  51374. {type: 'timelinePlayChange', event: 'timelinePlayChanged', update: 'update'},
  51375. function (payload, ecModel) {
  51376. var timelineModel = ecModel.getComponent('timeline');
  51377. if (timelineModel && payload.playState != null) {
  51378. timelineModel.setPlayState(payload.playState);
  51379. }
  51380. }
  51381. );
  51382. /***/ },
  51383. /* 363 */
  51384. /***/ function(module, exports, __webpack_require__) {
  51385. /**
  51386. * @file Silder timeline model
  51387. */
  51388. var TimelineModel = __webpack_require__(364);
  51389. var zrUtil = __webpack_require__(4);
  51390. var modelUtil = __webpack_require__(5);
  51391. var SliderTimelineModel = TimelineModel.extend({
  51392. type: 'timeline.slider',
  51393. /**
  51394. * @protected
  51395. */
  51396. defaultOption: {
  51397. backgroundColor: 'rgba(0,0,0,0)', // 时间轴背景颜色
  51398. borderColor: '#ccc', // 时间轴边框颜色
  51399. borderWidth: 0, // 时间轴边框线宽,单位px,默认为0(无边框)
  51400. orient: 'horizontal', // 'vertical'
  51401. inverse: false,
  51402. tooltip: { // boolean or Object
  51403. trigger: 'item' // data item may also have tootip attr.
  51404. },
  51405. symbol: 'emptyCircle',
  51406. symbolSize: 10,
  51407. lineStyle: {
  51408. show: true,
  51409. width: 2,
  51410. color: '#304654'
  51411. },
  51412. label: { // 文本标签
  51413. position: 'auto', // auto left right top bottom
  51414. // When using number, label position is not
  51415. // restricted by viewRect.
  51416. // positive: right/bottom, negative: left/top
  51417. normal: {
  51418. show: true,
  51419. interval: 'auto',
  51420. rotate: 0,
  51421. // formatter: null,
  51422. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  51423. color: '#304654'
  51424. }
  51425. },
  51426. emphasis: {
  51427. show: true,
  51428. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  51429. color: '#c23531'
  51430. }
  51431. }
  51432. },
  51433. itemStyle: {
  51434. normal: {
  51435. color: '#304654',
  51436. borderWidth: 1
  51437. },
  51438. emphasis: {
  51439. color: '#c23531'
  51440. }
  51441. },
  51442. checkpointStyle: {
  51443. symbol: 'circle',
  51444. symbolSize: 13,
  51445. color: '#c23531',
  51446. borderWidth: 5,
  51447. borderColor: 'rgba(194,53,49, 0.5)',
  51448. animation: true,
  51449. animationDuration: 300,
  51450. animationEasing: 'quinticInOut'
  51451. },
  51452. controlStyle: {
  51453. show: true,
  51454. showPlayBtn: true,
  51455. showPrevBtn: true,
  51456. showNextBtn: true,
  51457. itemSize: 22,
  51458. itemGap: 12,
  51459. position: 'left', // 'left' 'right' 'top' 'bottom'
  51460. playIcon: 'path://M31.6,53C17.5,53,6,41.5,6,27.4S17.5,1.8,31.6,1.8C45.7,1.8,57.2,13.3,57.2,27.4S45.7,53,31.6,53z M31.6,3.3 C18.4,3.3,7.5,14.1,7.5,27.4c0,13.3,10.8,24.1,24.1,24.1C44.9,51.5,55.7,40.7,55.7,27.4C55.7,14.1,44.9,3.3,31.6,3.3z M24.9,21.3 c0-2.2,1.6-3.1,3.5-2l10.5,6.1c1.899,1.1,1.899,2.9,0,4l-10.5,6.1c-1.9,1.1-3.5,0.2-3.5-2V21.3z', // jshint ignore:line
  51461. stopIcon: 'path://M30.9,53.2C16.8,53.2,5.3,41.7,5.3,27.6S16.8,2,30.9,2C45,2,56.4,13.5,56.4,27.6S45,53.2,30.9,53.2z M30.9,3.5C17.6,3.5,6.8,14.4,6.8,27.6c0,13.3,10.8,24.1,24.101,24.1C44.2,51.7,55,40.9,55,27.6C54.9,14.4,44.1,3.5,30.9,3.5z M36.9,35.8c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H36c0.5,0,0.9,0.4,0.9,1V35.8z M27.8,35.8 c0,0.601-0.4,1-0.9,1h-1.3c-0.5,0-0.9-0.399-0.9-1V19.5c0-0.6,0.4-1,0.9-1H27c0.5,0,0.9,0.4,0.9,1L27.8,35.8L27.8,35.8z', // jshint ignore:line
  51462. nextIcon: 'path://M18.6,50.8l22.5-22.5c0.2-0.2,0.3-0.4,0.3-0.7c0-0.3-0.1-0.5-0.3-0.7L18.7,4.4c-0.1-0.1-0.2-0.3-0.2-0.5 c0-0.4,0.3-0.8,0.8-0.8c0.2,0,0.5,0.1,0.6,0.3l23.5,23.5l0,0c0.2,0.2,0.3,0.4,0.3,0.7c0,0.3-0.1,0.5-0.3,0.7l-0.1,0.1L19.7,52 c-0.1,0.1-0.3,0.2-0.5,0.2c-0.4,0-0.8-0.3-0.8-0.8C18.4,51.2,18.5,51,18.6,50.8z', // jshint ignore:line
  51463. prevIcon: 'path://M43,52.8L20.4,30.3c-0.2-0.2-0.3-0.4-0.3-0.7c0-0.3,0.1-0.5,0.3-0.7L42.9,6.4c0.1-0.1,0.2-0.3,0.2-0.5 c0-0.4-0.3-0.8-0.8-0.8c-0.2,0-0.5,0.1-0.6,0.3L18.3,28.8l0,0c-0.2,0.2-0.3,0.4-0.3,0.7c0,0.3,0.1,0.5,0.3,0.7l0.1,0.1L41.9,54 c0.1,0.1,0.3,0.2,0.5,0.2c0.4,0,0.8-0.3,0.8-0.8C43.2,53.2,43.1,53,43,52.8z', // jshint ignore:line
  51464. normal: {
  51465. color: '#304654',
  51466. borderColor: '#304654',
  51467. borderWidth: 1
  51468. },
  51469. emphasis: {
  51470. color: '#c23531',
  51471. borderColor: '#c23531',
  51472. borderWidth: 2
  51473. }
  51474. },
  51475. data: []
  51476. }
  51477. });
  51478. zrUtil.mixin(SliderTimelineModel, modelUtil.dataFormatMixin);
  51479. module.exports = SliderTimelineModel;
  51480. /***/ },
  51481. /* 364 */
  51482. /***/ function(module, exports, __webpack_require__) {
  51483. /**
  51484. * @file Timeline model
  51485. */
  51486. var ComponentModel = __webpack_require__(19);
  51487. var List = __webpack_require__(98);
  51488. var zrUtil = __webpack_require__(4);
  51489. var modelUtil = __webpack_require__(5);
  51490. var TimelineModel = ComponentModel.extend({
  51491. type: 'timeline',
  51492. layoutMode: 'box',
  51493. /**
  51494. * @protected
  51495. */
  51496. defaultOption: {
  51497. zlevel: 0, // 一级层叠
  51498. z: 4, // 二级层叠
  51499. show: true,
  51500. axisType: 'time', // 模式是时间类型,支持 value, category
  51501. realtime: true,
  51502. left: '20%',
  51503. top: null,
  51504. right: '20%',
  51505. bottom: 0,
  51506. width: null,
  51507. height: 40,
  51508. padding: 5,
  51509. controlPosition: 'left', // 'left' 'right' 'top' 'bottom' 'none'
  51510. autoPlay: false,
  51511. rewind: false, // 反向播放
  51512. loop: true,
  51513. playInterval: 2000, // 播放时间间隔,单位ms
  51514. currentIndex: 0,
  51515. itemStyle: {
  51516. normal: {},
  51517. emphasis: {}
  51518. },
  51519. label: {
  51520. normal: {
  51521. textStyle: {
  51522. color: '#000'
  51523. }
  51524. },
  51525. emphasis: {}
  51526. },
  51527. data: []
  51528. },
  51529. /**
  51530. * @override
  51531. */
  51532. init: function (option, parentModel, ecModel) {
  51533. /**
  51534. * @private
  51535. * @type {module:echarts/data/List}
  51536. */
  51537. this._data;
  51538. /**
  51539. * @private
  51540. * @type {Array.<string>}
  51541. */
  51542. this._names;
  51543. this.mergeDefaultAndTheme(option, ecModel);
  51544. this._initData();
  51545. },
  51546. /**
  51547. * @override
  51548. */
  51549. mergeOption: function (option) {
  51550. TimelineModel.superApply(this, 'mergeOption', arguments);
  51551. this._initData();
  51552. },
  51553. /**
  51554. * @param {number} [currentIndex]
  51555. */
  51556. setCurrentIndex: function (currentIndex) {
  51557. if (currentIndex == null) {
  51558. currentIndex = this.option.currentIndex;
  51559. }
  51560. var count = this._data.count();
  51561. if (this.option.loop) {
  51562. currentIndex = (currentIndex % count + count) % count;
  51563. }
  51564. else {
  51565. currentIndex >= count && (currentIndex = count - 1);
  51566. currentIndex < 0 && (currentIndex = 0);
  51567. }
  51568. this.option.currentIndex = currentIndex;
  51569. },
  51570. /**
  51571. * @return {number} currentIndex
  51572. */
  51573. getCurrentIndex: function () {
  51574. return this.option.currentIndex;
  51575. },
  51576. /**
  51577. * @return {boolean}
  51578. */
  51579. isIndexMax: function () {
  51580. return this.getCurrentIndex() >= this._data.count() - 1;
  51581. },
  51582. /**
  51583. * @param {boolean} state true: play, false: stop
  51584. */
  51585. setPlayState: function (state) {
  51586. this.option.autoPlay = !!state;
  51587. },
  51588. /**
  51589. * @return {boolean} true: play, false: stop
  51590. */
  51591. getPlayState: function () {
  51592. return !!this.option.autoPlay;
  51593. },
  51594. /**
  51595. * @private
  51596. */
  51597. _initData: function () {
  51598. var thisOption = this.option;
  51599. var dataArr = thisOption.data || [];
  51600. var axisType = thisOption.axisType;
  51601. var names = this._names = [];
  51602. if (axisType === 'category') {
  51603. var idxArr = [];
  51604. zrUtil.each(dataArr, function (item, index) {
  51605. var value = modelUtil.getDataItemValue(item);
  51606. var newItem;
  51607. if (zrUtil.isObject(item)) {
  51608. newItem = zrUtil.clone(item);
  51609. newItem.value = index;
  51610. }
  51611. else {
  51612. newItem = index;
  51613. }
  51614. idxArr.push(newItem);
  51615. if (!zrUtil.isString(value) && (value == null || isNaN(value))) {
  51616. value = '';
  51617. }
  51618. names.push(value + '');
  51619. });
  51620. dataArr = idxArr;
  51621. }
  51622. var dimType = ({category: 'ordinal', time: 'time'})[axisType] || 'number';
  51623. var data = this._data = new List([{name: 'value', type: dimType}], this);
  51624. data.initData(dataArr, names);
  51625. },
  51626. getData: function () {
  51627. return this._data;
  51628. },
  51629. /**
  51630. * @public
  51631. * @return {Array.<string>} categoreis
  51632. */
  51633. getCategories: function () {
  51634. if (this.get('axisType') === 'category') {
  51635. return this._names.slice();
  51636. }
  51637. }
  51638. });
  51639. module.exports = TimelineModel;
  51640. /***/ },
  51641. /* 365 */
  51642. /***/ function(module, exports, __webpack_require__) {
  51643. /**
  51644. * @file Silder timeline view
  51645. */
  51646. var zrUtil = __webpack_require__(4);
  51647. var graphic = __webpack_require__(43);
  51648. var layout = __webpack_require__(21);
  51649. var TimelineView = __webpack_require__(366);
  51650. var TimelineAxis = __webpack_require__(367);
  51651. var symbolUtil = __webpack_require__(107);
  51652. var axisHelper = __webpack_require__(115);
  51653. var BoundingRect = __webpack_require__(9);
  51654. var matrix = __webpack_require__(11);
  51655. var numberUtil = __webpack_require__(7);
  51656. var formatUtil = __webpack_require__(6);
  51657. var encodeHTML = formatUtil.encodeHTML;
  51658. var bind = zrUtil.bind;
  51659. var each = zrUtil.each;
  51660. var PI = Math.PI;
  51661. module.exports = TimelineView.extend({
  51662. type: 'timeline.slider',
  51663. init: function (ecModel, api) {
  51664. this.api = api;
  51665. /**
  51666. * @private
  51667. * @type {module:echarts/component/timeline/TimelineAxis}
  51668. */
  51669. this._axis;
  51670. /**
  51671. * @private
  51672. * @type {module:zrender/core/BoundingRect}
  51673. */
  51674. this._viewRect;
  51675. /**
  51676. * @type {number}
  51677. */
  51678. this._timer;
  51679. /**
  51680. * @type {module:zrende/Element}
  51681. */
  51682. this._currentPointer;
  51683. /**
  51684. * @type {module:zrender/container/Group}
  51685. */
  51686. this._mainGroup;
  51687. /**
  51688. * @type {module:zrender/container/Group}
  51689. */
  51690. this._labelGroup;
  51691. },
  51692. /**
  51693. * @override
  51694. */
  51695. render: function (timelineModel, ecModel, api, payload) {
  51696. this.model = timelineModel;
  51697. this.api = api;
  51698. this.ecModel = ecModel;
  51699. this.group.removeAll();
  51700. if (timelineModel.get('show', true)) {
  51701. var layoutInfo = this._layout(timelineModel, api);
  51702. var mainGroup = this._createGroup('mainGroup');
  51703. var labelGroup = this._createGroup('labelGroup');
  51704. /**
  51705. * @private
  51706. * @type {module:echarts/component/timeline/TimelineAxis}
  51707. */
  51708. var axis = this._axis = this._createAxis(layoutInfo, timelineModel);
  51709. timelineModel.formatTooltip = function (dataIndex) {
  51710. return encodeHTML(axis.scale.getLabel(dataIndex));
  51711. };
  51712. each(
  51713. ['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'],
  51714. function (name) {
  51715. this['_render' + name](layoutInfo, mainGroup, axis, timelineModel);
  51716. },
  51717. this
  51718. );
  51719. this._renderAxisLabel(layoutInfo, labelGroup, axis, timelineModel);
  51720. this._position(layoutInfo, timelineModel);
  51721. }
  51722. this._doPlayStop();
  51723. },
  51724. /**
  51725. * @override
  51726. */
  51727. remove: function () {
  51728. this._clearTimer();
  51729. this.group.removeAll();
  51730. },
  51731. /**
  51732. * @override
  51733. */
  51734. dispose: function () {
  51735. this._clearTimer();
  51736. },
  51737. _layout: function (timelineModel, api) {
  51738. var labelPosOpt = timelineModel.get('label.normal.position');
  51739. var orient = timelineModel.get('orient');
  51740. var viewRect = getViewRect(timelineModel, api);
  51741. // Auto label offset.
  51742. if (labelPosOpt == null || labelPosOpt === 'auto') {
  51743. labelPosOpt = orient === 'horizontal'
  51744. ? ((viewRect.y + viewRect.height / 2) < api.getHeight() / 2 ? '-' : '+')
  51745. : ((viewRect.x + viewRect.width / 2) < api.getWidth() / 2 ? '+' : '-');
  51746. }
  51747. else if (isNaN(labelPosOpt)) {
  51748. labelPosOpt = ({
  51749. horizontal: {top: '-', bottom: '+'},
  51750. vertical: {left: '-', right: '+'}
  51751. })[orient][labelPosOpt];
  51752. }
  51753. // FIXME
  51754. // 暂没有实现用户传入
  51755. // var labelAlign = timelineModel.get('label.normal.textStyle.align');
  51756. // var labelBaseline = timelineModel.get('label.normal.textStyle.baseline');
  51757. var labelAlignMap = {
  51758. horizontal: 'center',
  51759. vertical: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'left' : 'right'
  51760. };
  51761. var labelBaselineMap = {
  51762. horizontal: (labelPosOpt >= 0 || labelPosOpt === '+') ? 'top' : 'bottom',
  51763. vertical: 'middle'
  51764. };
  51765. var rotationMap = {
  51766. horizontal: 0,
  51767. vertical: PI / 2
  51768. };
  51769. // Position
  51770. var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width;
  51771. var controlModel = timelineModel.getModel('controlStyle');
  51772. var showControl = controlModel.get('show');
  51773. var controlSize = showControl ? controlModel.get('itemSize') : 0;
  51774. var controlGap = showControl ? controlModel.get('itemGap') : 0;
  51775. var sizePlusGap = controlSize + controlGap;
  51776. // Special label rotate.
  51777. var labelRotation = timelineModel.get('label.normal.rotate') || 0;
  51778. labelRotation = labelRotation * PI / 180; // To radian.
  51779. var playPosition;
  51780. var prevBtnPosition;
  51781. var nextBtnPosition;
  51782. var axisExtent;
  51783. var controlPosition = controlModel.get('position', true);
  51784. var showControl = controlModel.get('show', true);
  51785. var showPlayBtn = showControl && controlModel.get('showPlayBtn', true);
  51786. var showPrevBtn = showControl && controlModel.get('showPrevBtn', true);
  51787. var showNextBtn = showControl && controlModel.get('showNextBtn', true);
  51788. var xLeft = 0;
  51789. var xRight = mainLength;
  51790. // position[0] means left, position[1] means middle.
  51791. if (controlPosition === 'left' || controlPosition === 'bottom') {
  51792. showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap);
  51793. showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap);
  51794. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  51795. }
  51796. else { // 'top' 'right'
  51797. showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  51798. showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap);
  51799. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  51800. }
  51801. axisExtent = [xLeft, xRight];
  51802. if (timelineModel.get('inverse')) {
  51803. axisExtent.reverse();
  51804. }
  51805. return {
  51806. viewRect: viewRect,
  51807. mainLength: mainLength,
  51808. orient: orient,
  51809. rotation: rotationMap[orient],
  51810. labelRotation: labelRotation,
  51811. labelPosOpt: labelPosOpt,
  51812. labelAlign: labelAlignMap[orient],
  51813. labelBaseline: labelBaselineMap[orient],
  51814. // Based on mainGroup.
  51815. playPosition: playPosition,
  51816. prevBtnPosition: prevBtnPosition,
  51817. nextBtnPosition: nextBtnPosition,
  51818. axisExtent: axisExtent,
  51819. controlSize: controlSize,
  51820. controlGap: controlGap
  51821. };
  51822. },
  51823. _position: function (layoutInfo, timelineModel) {
  51824. // Position is be called finally, because bounding rect is needed for
  51825. // adapt content to fill viewRect (auto adapt offset).
  51826. // Timeline may be not all in the viewRect when 'offset' is specified
  51827. // as a number, because it is more appropriate that label aligns at
  51828. // 'offset' but not the other edge defined by viewRect.
  51829. var mainGroup = this._mainGroup;
  51830. var labelGroup = this._labelGroup;
  51831. var viewRect = layoutInfo.viewRect;
  51832. if (layoutInfo.orient === 'vertical') {
  51833. // transfrom to horizontal, inverse rotate by left-top point.
  51834. var m = matrix.create();
  51835. var rotateOriginX = viewRect.x;
  51836. var rotateOriginY = viewRect.y + viewRect.height;
  51837. matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]);
  51838. matrix.rotate(m, m, -PI / 2);
  51839. matrix.translate(m, m, [rotateOriginX, rotateOriginY]);
  51840. viewRect = viewRect.clone();
  51841. viewRect.applyTransform(m);
  51842. }
  51843. var viewBound = getBound(viewRect);
  51844. var mainBound = getBound(mainGroup.getBoundingRect());
  51845. var labelBound = getBound(labelGroup.getBoundingRect());
  51846. var mainPosition = mainGroup.position;
  51847. var labelsPosition = labelGroup.position;
  51848. labelsPosition[0] = mainPosition[0] = viewBound[0][0];
  51849. var labelPosOpt = layoutInfo.labelPosOpt;
  51850. if (isNaN(labelPosOpt)) { // '+' or '-'
  51851. var mainBoundIdx = labelPosOpt === '+' ? 0 : 1;
  51852. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  51853. toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx);
  51854. }
  51855. else {
  51856. var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1;
  51857. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  51858. labelsPosition[1] = mainPosition[1] + labelPosOpt;
  51859. }
  51860. mainGroup.attr('position', mainPosition);
  51861. labelGroup.attr('position', labelsPosition);
  51862. mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation;
  51863. setOrigin(mainGroup);
  51864. setOrigin(labelGroup);
  51865. function setOrigin(targetGroup) {
  51866. var pos = targetGroup.position;
  51867. targetGroup.origin = [
  51868. viewBound[0][0] - pos[0],
  51869. viewBound[1][0] - pos[1]
  51870. ];
  51871. }
  51872. function getBound(rect) {
  51873. // [[xmin, xmax], [ymin, ymax]]
  51874. return [
  51875. [rect.x, rect.x + rect.width],
  51876. [rect.y, rect.y + rect.height]
  51877. ];
  51878. }
  51879. function toBound(fromPos, from, to, dimIdx, boundIdx) {
  51880. fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx];
  51881. }
  51882. },
  51883. _createAxis: function (layoutInfo, timelineModel) {
  51884. var data = timelineModel.getData();
  51885. var axisType = timelineModel.get('axisType');
  51886. var scale = axisHelper.createScaleByModel(timelineModel, axisType);
  51887. var dataExtent = data.getDataExtent('value');
  51888. scale.setExtent(dataExtent[0], dataExtent[1]);
  51889. this._customizeScale(scale, data);
  51890. scale.niceTicks();
  51891. var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType);
  51892. axis.model = timelineModel;
  51893. return axis;
  51894. },
  51895. _customizeScale: function (scale, data) {
  51896. scale.getTicks = function () {
  51897. return data.mapArray(['value'], function (value) {
  51898. return value;
  51899. });
  51900. };
  51901. scale.getTicksLabels = function () {
  51902. return zrUtil.map(this.getTicks(), scale.getLabel, scale);
  51903. };
  51904. },
  51905. _createGroup: function (name) {
  51906. var newGroup = this['_' + name] = new graphic.Group();
  51907. this.group.add(newGroup);
  51908. return newGroup;
  51909. },
  51910. _renderAxisLine: function (layoutInfo, group, axis, timelineModel) {
  51911. var axisExtent = axis.getExtent();
  51912. if (!timelineModel.get('lineStyle.show')) {
  51913. return;
  51914. }
  51915. group.add(new graphic.Line({
  51916. shape: {
  51917. x1: axisExtent[0], y1: 0,
  51918. x2: axisExtent[1], y2: 0
  51919. },
  51920. style: zrUtil.extend(
  51921. {lineCap: 'round'},
  51922. timelineModel.getModel('lineStyle').getLineStyle()
  51923. ),
  51924. silent: true,
  51925. z2: 1
  51926. }));
  51927. },
  51928. /**
  51929. * @private
  51930. */
  51931. _renderAxisTick: function (layoutInfo, group, axis, timelineModel) {
  51932. var data = timelineModel.getData();
  51933. var ticks = axis.scale.getTicks();
  51934. each(ticks, function (value, dataIndex) {
  51935. var tickCoord = axis.dataToCoord(value);
  51936. var itemModel = data.getItemModel(dataIndex);
  51937. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  51938. var hoverStyleModel = itemModel.getModel('itemStyle.emphasis');
  51939. var symbolOpt = {
  51940. position: [tickCoord, 0],
  51941. onclick: bind(this._changeTimeline, this, dataIndex)
  51942. };
  51943. var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt);
  51944. graphic.setHoverStyle(el, hoverStyleModel.getItemStyle());
  51945. if (itemModel.get('tooltip')) {
  51946. el.dataIndex = dataIndex;
  51947. el.dataModel = timelineModel;
  51948. }
  51949. else {
  51950. el.dataIndex = el.dataModel = null;
  51951. }
  51952. }, this);
  51953. },
  51954. /**
  51955. * @private
  51956. */
  51957. _renderAxisLabel: function (layoutInfo, group, axis, timelineModel) {
  51958. var labelModel = timelineModel.getModel('label.normal');
  51959. if (!labelModel.get('show')) {
  51960. return;
  51961. }
  51962. var data = timelineModel.getData();
  51963. var ticks = axis.scale.getTicks();
  51964. var labels = axisHelper.getFormattedLabels(
  51965. axis, labelModel.get('formatter')
  51966. );
  51967. var labelInterval = axis.getLabelInterval();
  51968. each(ticks, function (tick, dataIndex) {
  51969. if (axis.isLabelIgnored(dataIndex, labelInterval)) {
  51970. return;
  51971. }
  51972. var itemModel = data.getItemModel(dataIndex);
  51973. var itemTextStyleModel = itemModel.getModel('label.normal.textStyle');
  51974. var hoverTextStyleModel = itemModel.getModel('label.emphasis.textStyle');
  51975. var tickCoord = axis.dataToCoord(tick);
  51976. var textEl = new graphic.Text({
  51977. style: {
  51978. text: labels[dataIndex],
  51979. textAlign: layoutInfo.labelAlign,
  51980. textVerticalAlign: layoutInfo.labelBaseline,
  51981. textFont: itemTextStyleModel.getFont(),
  51982. fill: itemTextStyleModel.getTextColor()
  51983. },
  51984. position: [tickCoord, 0],
  51985. rotation: layoutInfo.labelRotation - layoutInfo.rotation,
  51986. onclick: bind(this._changeTimeline, this, dataIndex),
  51987. silent: false
  51988. });
  51989. group.add(textEl);
  51990. graphic.setHoverStyle(textEl, hoverTextStyleModel.getItemStyle());
  51991. }, this);
  51992. },
  51993. /**
  51994. * @private
  51995. */
  51996. _renderControl: function (layoutInfo, group, axis, timelineModel) {
  51997. var controlSize = layoutInfo.controlSize;
  51998. var rotation = layoutInfo.rotation;
  51999. var itemStyle = timelineModel.getModel('controlStyle.normal').getItemStyle();
  52000. var hoverStyle = timelineModel.getModel('controlStyle.emphasis').getItemStyle();
  52001. var rect = [0, -controlSize / 2, controlSize, controlSize];
  52002. var playState = timelineModel.getPlayState();
  52003. var inverse = timelineModel.get('inverse', true);
  52004. makeBtn(
  52005. layoutInfo.nextBtnPosition,
  52006. 'controlStyle.nextIcon',
  52007. bind(this._changeTimeline, this, inverse ? '-' : '+')
  52008. );
  52009. makeBtn(
  52010. layoutInfo.prevBtnPosition,
  52011. 'controlStyle.prevIcon',
  52012. bind(this._changeTimeline, this, inverse ? '+' : '-')
  52013. );
  52014. makeBtn(
  52015. layoutInfo.playPosition,
  52016. 'controlStyle.' + (playState ? 'stopIcon' : 'playIcon'),
  52017. bind(this._handlePlayClick, this, !playState),
  52018. true
  52019. );
  52020. function makeBtn(position, iconPath, onclick, willRotate) {
  52021. if (!position) {
  52022. return;
  52023. }
  52024. var opt = {
  52025. position: position,
  52026. origin: [controlSize / 2, 0],
  52027. rotation: willRotate ? -rotation : 0,
  52028. rectHover: true,
  52029. style: itemStyle,
  52030. onclick: onclick
  52031. };
  52032. var btn = makeIcon(timelineModel, iconPath, rect, opt);
  52033. group.add(btn);
  52034. graphic.setHoverStyle(btn, hoverStyle);
  52035. }
  52036. },
  52037. _renderCurrentPointer: function (layoutInfo, group, axis, timelineModel) {
  52038. var data = timelineModel.getData();
  52039. var currentIndex = timelineModel.getCurrentIndex();
  52040. var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle');
  52041. var me = this;
  52042. var callback = {
  52043. onCreate: function (pointer) {
  52044. pointer.draggable = true;
  52045. pointer.drift = bind(me._handlePointerDrag, me);
  52046. pointer.ondragend = bind(me._handlePointerDragend, me);
  52047. pointerMoveTo(pointer, currentIndex, axis, timelineModel, true);
  52048. },
  52049. onUpdate: function (pointer) {
  52050. pointerMoveTo(pointer, currentIndex, axis, timelineModel);
  52051. }
  52052. };
  52053. // Reuse when exists, for animation and drag.
  52054. this._currentPointer = giveSymbol(
  52055. pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback
  52056. );
  52057. },
  52058. _handlePlayClick: function (nextState) {
  52059. this._clearTimer();
  52060. this.api.dispatchAction({
  52061. type: 'timelinePlayChange',
  52062. playState: nextState,
  52063. from: this.uid
  52064. });
  52065. },
  52066. _handlePointerDrag: function (dx, dy, e) {
  52067. this._clearTimer();
  52068. this._pointerChangeTimeline([e.offsetX, e.offsetY]);
  52069. },
  52070. _handlePointerDragend: function (e) {
  52071. this._pointerChangeTimeline([e.offsetX, e.offsetY], true);
  52072. },
  52073. _pointerChangeTimeline: function (mousePos, trigger) {
  52074. var toCoord = this._toAxisCoord(mousePos)[0];
  52075. var axis = this._axis;
  52076. var axisExtent = numberUtil.asc(axis.getExtent().slice());
  52077. toCoord > axisExtent[1] && (toCoord = axisExtent[1]);
  52078. toCoord < axisExtent[0] && (toCoord = axisExtent[0]);
  52079. this._currentPointer.position[0] = toCoord;
  52080. this._currentPointer.dirty();
  52081. var targetDataIndex = this._findNearestTick(toCoord);
  52082. var timelineModel = this.model;
  52083. if (trigger || (
  52084. targetDataIndex !== timelineModel.getCurrentIndex()
  52085. && timelineModel.get('realtime')
  52086. )) {
  52087. this._changeTimeline(targetDataIndex);
  52088. }
  52089. },
  52090. _doPlayStop: function () {
  52091. this._clearTimer();
  52092. if (this.model.getPlayState()) {
  52093. this._timer = setTimeout(
  52094. bind(handleFrame, this),
  52095. this.model.get('playInterval')
  52096. );
  52097. }
  52098. function handleFrame() {
  52099. // Do not cache
  52100. var timelineModel = this.model;
  52101. this._changeTimeline(
  52102. timelineModel.getCurrentIndex()
  52103. + (timelineModel.get('rewind', true) ? -1 : 1)
  52104. );
  52105. }
  52106. },
  52107. _toAxisCoord: function (vertex) {
  52108. var trans = this._mainGroup.getLocalTransform();
  52109. return graphic.applyTransform(vertex, trans, true);
  52110. },
  52111. _findNearestTick: function (axisCoord) {
  52112. var data = this.model.getData();
  52113. var dist = Infinity;
  52114. var targetDataIndex;
  52115. var axis = this._axis;
  52116. data.each(['value'], function (value, dataIndex) {
  52117. var coord = axis.dataToCoord(value);
  52118. var d = Math.abs(coord - axisCoord);
  52119. if (d < dist) {
  52120. dist = d;
  52121. targetDataIndex = dataIndex;
  52122. }
  52123. });
  52124. return targetDataIndex;
  52125. },
  52126. _clearTimer: function () {
  52127. if (this._timer) {
  52128. clearTimeout(this._timer);
  52129. this._timer = null;
  52130. }
  52131. },
  52132. _changeTimeline: function (nextIndex) {
  52133. var currentIndex = this.model.getCurrentIndex();
  52134. if (nextIndex === '+') {
  52135. nextIndex = currentIndex + 1;
  52136. }
  52137. else if (nextIndex === '-') {
  52138. nextIndex = currentIndex - 1;
  52139. }
  52140. this.api.dispatchAction({
  52141. type: 'timelineChange',
  52142. currentIndex: nextIndex,
  52143. from: this.uid
  52144. });
  52145. }
  52146. });
  52147. function getViewRect(model, api) {
  52148. return layout.getLayoutRect(
  52149. model.getBoxLayoutParams(),
  52150. {
  52151. width: api.getWidth(),
  52152. height: api.getHeight()
  52153. },
  52154. model.get('padding')
  52155. );
  52156. }
  52157. function makeIcon(timelineModel, objPath, rect, opts) {
  52158. var icon = graphic.makePath(
  52159. timelineModel.get(objPath).replace(/^path:\/\//, ''),
  52160. zrUtil.clone(opts || {}),
  52161. new BoundingRect(rect[0], rect[1], rect[2], rect[3]),
  52162. 'center'
  52163. );
  52164. return icon;
  52165. }
  52166. /**
  52167. * Create symbol or update symbol
  52168. * opt: basic position and event handlers
  52169. */
  52170. function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
  52171. var color = itemStyleModel.get('color');
  52172. if (!symbol) {
  52173. var symbolType = hostModel.get('symbol');
  52174. symbol = symbolUtil.createSymbol(symbolType, -1, -1, 2, 2, color);
  52175. symbol.setStyle('strokeNoScale', true);
  52176. group.add(symbol);
  52177. callback && callback.onCreate(symbol);
  52178. }
  52179. else {
  52180. symbol.setColor(color);
  52181. group.add(symbol); // Group may be new, also need to add.
  52182. callback && callback.onUpdate(symbol);
  52183. }
  52184. // Style
  52185. var itemStyle = itemStyleModel.getItemStyle(['color', 'symbol', 'symbolSize']);
  52186. symbol.setStyle(itemStyle);
  52187. // Transform and events.
  52188. opt = zrUtil.merge({
  52189. rectHover: true,
  52190. z2: 100
  52191. }, opt, true);
  52192. var symbolSize = hostModel.get('symbolSize');
  52193. symbolSize = symbolSize instanceof Array
  52194. ? symbolSize.slice()
  52195. : [+symbolSize, +symbolSize];
  52196. symbolSize[0] /= 2;
  52197. symbolSize[1] /= 2;
  52198. opt.scale = symbolSize;
  52199. var symbolOffset = hostModel.get('symbolOffset');
  52200. if (symbolOffset) {
  52201. var pos = opt.position = opt.position || [0, 0];
  52202. pos[0] += numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  52203. pos[1] += numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  52204. }
  52205. var symbolRotate = hostModel.get('symbolRotate');
  52206. opt.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  52207. symbol.attr(opt);
  52208. // FIXME
  52209. // (1) When symbol.style.strokeNoScale is true and updateTransform is not performed,
  52210. // getBoundingRect will return wrong result.
  52211. // (This is supposed to be resolved in zrender, but it is a little difficult to
  52212. // leverage performance and auto updateTransform)
  52213. // (2) All of ancesters of symbol do not scale, so we can just updateTransform symbol.
  52214. symbol.updateTransform();
  52215. return symbol;
  52216. }
  52217. function pointerMoveTo(pointer, dataIndex, axis, timelineModel, noAnimation) {
  52218. if (pointer.dragging) {
  52219. return;
  52220. }
  52221. var pointerModel = timelineModel.getModel('checkpointStyle');
  52222. var toCoord = axis.dataToCoord(timelineModel.getData().get(['value'], dataIndex));
  52223. if (noAnimation || !pointerModel.get('animation', true)) {
  52224. pointer.attr({position: [toCoord, 0]});
  52225. }
  52226. else {
  52227. pointer.stopAnimation(true);
  52228. pointer.animateTo(
  52229. {position: [toCoord, 0]},
  52230. pointerModel.get('animationDuration', true),
  52231. pointerModel.get('animationEasing', true)
  52232. );
  52233. }
  52234. }
  52235. /***/ },
  52236. /* 366 */
  52237. /***/ function(module, exports, __webpack_require__) {
  52238. /**
  52239. * @file Timeline view
  52240. */
  52241. // var zrUtil = require('zrender/lib/core/util');
  52242. // var graphic = require('../../util/graphic');
  52243. var ComponentView = __webpack_require__(29);
  52244. module.exports = ComponentView.extend({
  52245. type: 'timeline'
  52246. });
  52247. /***/ },
  52248. /* 367 */
  52249. /***/ function(module, exports, __webpack_require__) {
  52250. var zrUtil = __webpack_require__(4);
  52251. var Axis = __webpack_require__(124);
  52252. var axisHelper = __webpack_require__(115);
  52253. /**
  52254. * Extend axis 2d
  52255. * @constructor module:echarts/coord/cartesian/Axis2D
  52256. * @extends {module:echarts/coord/cartesian/Axis}
  52257. * @param {string} dim
  52258. * @param {*} scale
  52259. * @param {Array.<number>} coordExtent
  52260. * @param {string} axisType
  52261. * @param {string} position
  52262. */
  52263. var TimelineAxis = function (dim, scale, coordExtent, axisType) {
  52264. Axis.call(this, dim, scale, coordExtent);
  52265. /**
  52266. * Axis type
  52267. * - 'category'
  52268. * - 'value'
  52269. * - 'time'
  52270. * - 'log'
  52271. * @type {string}
  52272. */
  52273. this.type = axisType || 'value';
  52274. /**
  52275. * @private
  52276. * @type {number}
  52277. */
  52278. this._autoLabelInterval;
  52279. /**
  52280. * Axis model
  52281. * @param {module:echarts/component/TimelineModel}
  52282. */
  52283. this.model = null;
  52284. };
  52285. TimelineAxis.prototype = {
  52286. constructor: TimelineAxis,
  52287. /**
  52288. * @public
  52289. * @return {number}
  52290. */
  52291. getLabelInterval: function () {
  52292. var timelineModel = this.model;
  52293. var labelModel = timelineModel.getModel('label.normal');
  52294. var labelInterval = labelModel.get('interval');
  52295. if (labelInterval != null && labelInterval != 'auto') {
  52296. return labelInterval;
  52297. }
  52298. var labelInterval = this._autoLabelInterval;
  52299. if (!labelInterval) {
  52300. labelInterval = this._autoLabelInterval = axisHelper.getAxisLabelInterval(
  52301. zrUtil.map(this.scale.getTicks(), this.dataToCoord, this),
  52302. axisHelper.getFormattedLabels(this, labelModel.get('formatter')),
  52303. labelModel.getModel('textStyle').getFont(),
  52304. timelineModel.get('orient') === 'horizontal'
  52305. );
  52306. }
  52307. return labelInterval;
  52308. },
  52309. /**
  52310. * If label is ignored.
  52311. * Automatically used when axis is category and label can not be all shown
  52312. * @public
  52313. * @param {number} idx
  52314. * @return {boolean}
  52315. */
  52316. isLabelIgnored: function (idx) {
  52317. if (this.type === 'category') {
  52318. var labelInterval = this.getLabelInterval();
  52319. return ((typeof labelInterval === 'function')
  52320. && !labelInterval(idx, this.scale.getLabel(idx)))
  52321. || idx % (labelInterval + 1);
  52322. }
  52323. }
  52324. };
  52325. zrUtil.inherits(TimelineAxis, Axis);
  52326. module.exports = TimelineAxis;
  52327. /***/ },
  52328. /* 368 */
  52329. /***/ function(module, exports, __webpack_require__) {
  52330. __webpack_require__(369);
  52331. __webpack_require__(370);
  52332. __webpack_require__(372);
  52333. __webpack_require__(373);
  52334. __webpack_require__(374);
  52335. __webpack_require__(375);
  52336. __webpack_require__(380);
  52337. /***/ },
  52338. /* 369 */
  52339. /***/ function(module, exports, __webpack_require__) {
  52340. var featureManager = __webpack_require__(316);
  52341. var zrUtil = __webpack_require__(4);
  52342. var ToolboxModel = __webpack_require__(1).extendComponentModel({
  52343. type: 'toolbox',
  52344. layoutMode: {
  52345. type: 'box',
  52346. ignoreSize: true
  52347. },
  52348. mergeDefaultAndTheme: function (option) {
  52349. ToolboxModel.superApply(this, 'mergeDefaultAndTheme', arguments);
  52350. zrUtil.each(this.option.feature, function (featureOpt, featureName) {
  52351. var Feature = featureManager.get(featureName);
  52352. Feature && zrUtil.merge(featureOpt, Feature.defaultOption);
  52353. });
  52354. },
  52355. defaultOption: {
  52356. show: true,
  52357. z: 6,
  52358. zlevel: 0,
  52359. orient: 'horizontal',
  52360. left: 'right',
  52361. top: 'top',
  52362. // right
  52363. // bottom
  52364. backgroundColor: 'transparent',
  52365. borderColor: '#ccc',
  52366. borderWidth: 0,
  52367. padding: 5,
  52368. itemSize: 15,
  52369. itemGap: 8,
  52370. showTitle: true,
  52371. iconStyle: {
  52372. normal: {
  52373. borderColor: '#666',
  52374. color: 'none'
  52375. },
  52376. emphasis: {
  52377. borderColor: '#3E98C5'
  52378. }
  52379. }
  52380. // textStyle: {},
  52381. // feature
  52382. }
  52383. });
  52384. module.exports = ToolboxModel;
  52385. /***/ },
  52386. /* 370 */
  52387. /***/ function(module, exports, __webpack_require__) {
  52388. /* WEBPACK VAR INJECTION */(function(process) {
  52389. var featureManager = __webpack_require__(316);
  52390. var zrUtil = __webpack_require__(4);
  52391. var graphic = __webpack_require__(43);
  52392. var Model = __webpack_require__(12);
  52393. var DataDiffer = __webpack_require__(99);
  52394. var listComponentHelper = __webpack_require__(280);
  52395. var textContain = __webpack_require__(8);
  52396. module.exports = __webpack_require__(1).extendComponentView({
  52397. type: 'toolbox',
  52398. render: function (toolboxModel, ecModel, api, payload) {
  52399. var group = this.group;
  52400. group.removeAll();
  52401. if (!toolboxModel.get('show')) {
  52402. return;
  52403. }
  52404. var itemSize = +toolboxModel.get('itemSize');
  52405. var featureOpts = toolboxModel.get('feature') || {};
  52406. var features = this._features || (this._features = {});
  52407. var featureNames = [];
  52408. zrUtil.each(featureOpts, function (opt, name) {
  52409. featureNames.push(name);
  52410. });
  52411. (new DataDiffer(this._featureNames || [], featureNames))
  52412. .add(process)
  52413. .update(process)
  52414. .remove(zrUtil.curry(process, null))
  52415. .execute();
  52416. // Keep for diff.
  52417. this._featureNames = featureNames;
  52418. function process(newIndex, oldIndex) {
  52419. var featureName = featureNames[newIndex];
  52420. var oldName = featureNames[oldIndex];
  52421. var featureOpt = featureOpts[featureName];
  52422. var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
  52423. var feature;
  52424. if (featureName && !oldName) { // Create
  52425. if (isUserFeatureName(featureName)) {
  52426. feature = {
  52427. model: featureModel,
  52428. onclick: featureModel.option.onclick,
  52429. featureName: featureName
  52430. };
  52431. }
  52432. else {
  52433. var Feature = featureManager.get(featureName);
  52434. if (!Feature) {
  52435. return;
  52436. }
  52437. feature = new Feature(featureModel, ecModel, api);
  52438. }
  52439. features[featureName] = feature;
  52440. }
  52441. else {
  52442. feature = features[oldName];
  52443. // If feature does not exsit.
  52444. if (!feature) {
  52445. return;
  52446. }
  52447. feature.model = featureModel;
  52448. feature.ecModel = ecModel;
  52449. feature.api = api;
  52450. }
  52451. if (!featureName && oldName) {
  52452. feature.dispose && feature.dispose(ecModel, api);
  52453. return;
  52454. }
  52455. if (!featureModel.get('show') || feature.unusable) {
  52456. feature.remove && feature.remove(ecModel, api);
  52457. return;
  52458. }
  52459. createIconPaths(featureModel, feature, featureName);
  52460. featureModel.setIconStatus = function (iconName, status) {
  52461. var option = this.option;
  52462. var iconPaths = this.iconPaths;
  52463. option.iconStatus = option.iconStatus || {};
  52464. option.iconStatus[iconName] = status;
  52465. // FIXME
  52466. iconPaths[iconName] && iconPaths[iconName].trigger(status);
  52467. };
  52468. if (feature.render) {
  52469. feature.render(featureModel, ecModel, api, payload);
  52470. }
  52471. }
  52472. function createIconPaths(featureModel, feature, featureName) {
  52473. var iconStyleModel = featureModel.getModel('iconStyle');
  52474. // If one feature has mutiple icon. they are orginaized as
  52475. // {
  52476. // icon: {
  52477. // foo: '',
  52478. // bar: ''
  52479. // },
  52480. // title: {
  52481. // foo: '',
  52482. // bar: ''
  52483. // }
  52484. // }
  52485. var icons = feature.getIcons ? feature.getIcons() : featureModel.get('icon');
  52486. var titles = featureModel.get('title') || {};
  52487. if (typeof icons === 'string') {
  52488. var icon = icons;
  52489. var title = titles;
  52490. icons = {};
  52491. titles = {};
  52492. icons[featureName] = icon;
  52493. titles[featureName] = title;
  52494. }
  52495. var iconPaths = featureModel.iconPaths = {};
  52496. zrUtil.each(icons, function (icon, iconName) {
  52497. var normalStyle = iconStyleModel.getModel('normal').getItemStyle();
  52498. var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  52499. var style = {
  52500. x: -itemSize / 2,
  52501. y: -itemSize / 2,
  52502. width: itemSize,
  52503. height: itemSize
  52504. };
  52505. var path = icon.indexOf('image://') === 0
  52506. ? (
  52507. style.image = icon.slice(8),
  52508. new graphic.Image({style: style})
  52509. )
  52510. : graphic.makePath(
  52511. icon.replace('path://', ''),
  52512. {
  52513. style: normalStyle,
  52514. hoverStyle: hoverStyle,
  52515. rectHover: true
  52516. },
  52517. style,
  52518. 'center'
  52519. );
  52520. graphic.setHoverStyle(path);
  52521. if (toolboxModel.get('showTitle')) {
  52522. path.__title = titles[iconName];
  52523. path.on('mouseover', function () {
  52524. // Should not reuse above hoverStyle, which might be modified.
  52525. var hoverStyle = iconStyleModel.getModel('emphasis').getItemStyle();
  52526. path.setStyle({
  52527. text: titles[iconName],
  52528. textPosition: hoverStyle.textPosition || 'bottom',
  52529. textFill: hoverStyle.fill || hoverStyle.stroke || '#000',
  52530. textAlign: hoverStyle.textAlign || 'center'
  52531. });
  52532. })
  52533. .on('mouseout', function () {
  52534. path.setStyle({
  52535. textFill: null
  52536. });
  52537. });
  52538. }
  52539. path.trigger(featureModel.get('iconStatus.' + iconName) || 'normal');
  52540. group.add(path);
  52541. path.on('click', zrUtil.bind(
  52542. feature.onclick, feature, ecModel, api, iconName
  52543. ));
  52544. iconPaths[iconName] = path;
  52545. });
  52546. }
  52547. listComponentHelper.layout(group, toolboxModel, api);
  52548. // Render background after group is layout
  52549. // FIXME
  52550. listComponentHelper.addBackground(group, toolboxModel);
  52551. // Adjust icon title positions to avoid them out of screen
  52552. group.eachChild(function (icon) {
  52553. var titleText = icon.__title;
  52554. var hoverStyle = icon.hoverStyle;
  52555. // May be background element
  52556. if (hoverStyle && titleText) {
  52557. var rect = textContain.getBoundingRect(
  52558. titleText, hoverStyle.font
  52559. );
  52560. var offsetX = icon.position[0] + group.position[0];
  52561. var offsetY = icon.position[1] + group.position[1] + itemSize;
  52562. var needPutOnTop = false;
  52563. if (offsetY + rect.height > api.getHeight()) {
  52564. hoverStyle.textPosition = 'top';
  52565. needPutOnTop = true;
  52566. }
  52567. var topOffset = needPutOnTop ? (-5 - rect.height) : (itemSize + 8);
  52568. if (offsetX + rect.width / 2 > api.getWidth()) {
  52569. hoverStyle.textPosition = ['100%', topOffset];
  52570. hoverStyle.textAlign = 'right';
  52571. }
  52572. else if (offsetX - rect.width / 2 < 0) {
  52573. hoverStyle.textPosition = [0, topOffset];
  52574. hoverStyle.textAlign = 'left';
  52575. }
  52576. }
  52577. });
  52578. },
  52579. updateView: function (toolboxModel, ecModel, api, payload) {
  52580. zrUtil.each(this._features, function (feature) {
  52581. feature.updateView && feature.updateView(feature.model, ecModel, api, payload);
  52582. });
  52583. },
  52584. updateLayout: function (toolboxModel, ecModel, api, payload) {
  52585. zrUtil.each(this._features, function (feature) {
  52586. feature.updateLayout && feature.updateLayout(feature.model, ecModel, api, payload);
  52587. });
  52588. },
  52589. remove: function (ecModel, api) {
  52590. zrUtil.each(this._features, function (feature) {
  52591. feature.remove && feature.remove(ecModel, api);
  52592. });
  52593. this.group.removeAll();
  52594. },
  52595. dispose: function (ecModel, api) {
  52596. zrUtil.each(this._features, function (feature) {
  52597. feature.dispose && feature.dispose(ecModel, api);
  52598. });
  52599. }
  52600. });
  52601. function isUserFeatureName(featureName) {
  52602. return featureName.indexOf('my') === 0;
  52603. }
  52604. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(371)))
  52605. /***/ },
  52606. /* 371 */
  52607. /***/ function(module, exports) {
  52608. // shim for using process in browser
  52609. var process = module.exports = {};
  52610. // cached from whatever global is present so that test runners that stub it
  52611. // don't break things. But we need to wrap it in a try catch in case it is
  52612. // wrapped in strict mode code which doesn't define any globals. It's inside a
  52613. // function because try/catches deoptimize in certain engines.
  52614. var cachedSetTimeout;
  52615. var cachedClearTimeout;
  52616. function defaultSetTimout() {
  52617. throw new Error('setTimeout has not been defined');
  52618. }
  52619. function defaultClearTimeout () {
  52620. throw new Error('clearTimeout has not been defined');
  52621. }
  52622. (function () {
  52623. try {
  52624. if (typeof setTimeout === 'function') {
  52625. cachedSetTimeout = setTimeout;
  52626. } else {
  52627. cachedSetTimeout = defaultSetTimout;
  52628. }
  52629. } catch (e) {
  52630. cachedSetTimeout = defaultSetTimout;
  52631. }
  52632. try {
  52633. if (typeof clearTimeout === 'function') {
  52634. cachedClearTimeout = clearTimeout;
  52635. } else {
  52636. cachedClearTimeout = defaultClearTimeout;
  52637. }
  52638. } catch (e) {
  52639. cachedClearTimeout = defaultClearTimeout;
  52640. }
  52641. } ())
  52642. function runTimeout(fun) {
  52643. if (cachedSetTimeout === setTimeout) {
  52644. //normal enviroments in sane situations
  52645. return setTimeout(fun, 0);
  52646. }
  52647. // if setTimeout wasn't available but was latter defined
  52648. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  52649. cachedSetTimeout = setTimeout;
  52650. return setTimeout(fun, 0);
  52651. }
  52652. try {
  52653. // when when somebody has screwed with setTimeout but no I.E. maddness
  52654. return cachedSetTimeout(fun, 0);
  52655. } catch(e){
  52656. try {
  52657. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  52658. return cachedSetTimeout.call(null, fun, 0);
  52659. } catch(e){
  52660. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  52661. return cachedSetTimeout.call(this, fun, 0);
  52662. }
  52663. }
  52664. }
  52665. function runClearTimeout(marker) {
  52666. if (cachedClearTimeout === clearTimeout) {
  52667. //normal enviroments in sane situations
  52668. return clearTimeout(marker);
  52669. }
  52670. // if clearTimeout wasn't available but was latter defined
  52671. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  52672. cachedClearTimeout = clearTimeout;
  52673. return clearTimeout(marker);
  52674. }
  52675. try {
  52676. // when when somebody has screwed with setTimeout but no I.E. maddness
  52677. return cachedClearTimeout(marker);
  52678. } catch (e){
  52679. try {
  52680. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  52681. return cachedClearTimeout.call(null, marker);
  52682. } catch (e){
  52683. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  52684. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  52685. return cachedClearTimeout.call(this, marker);
  52686. }
  52687. }
  52688. }
  52689. var queue = [];
  52690. var draining = false;
  52691. var currentQueue;
  52692. var queueIndex = -1;
  52693. function cleanUpNextTick() {
  52694. if (!draining || !currentQueue) {
  52695. return;
  52696. }
  52697. draining = false;
  52698. if (currentQueue.length) {
  52699. queue = currentQueue.concat(queue);
  52700. } else {
  52701. queueIndex = -1;
  52702. }
  52703. if (queue.length) {
  52704. drainQueue();
  52705. }
  52706. }
  52707. function drainQueue() {
  52708. if (draining) {
  52709. return;
  52710. }
  52711. var timeout = runTimeout(cleanUpNextTick);
  52712. draining = true;
  52713. var len = queue.length;
  52714. while(len) {
  52715. currentQueue = queue;
  52716. queue = [];
  52717. while (++queueIndex < len) {
  52718. if (currentQueue) {
  52719. currentQueue[queueIndex].run();
  52720. }
  52721. }
  52722. queueIndex = -1;
  52723. len = queue.length;
  52724. }
  52725. currentQueue = null;
  52726. draining = false;
  52727. runClearTimeout(timeout);
  52728. }
  52729. process.nextTick = function (fun) {
  52730. var args = new Array(arguments.length - 1);
  52731. if (arguments.length > 1) {
  52732. for (var i = 1; i < arguments.length; i++) {
  52733. args[i - 1] = arguments[i];
  52734. }
  52735. }
  52736. queue.push(new Item(fun, args));
  52737. if (queue.length === 1 && !draining) {
  52738. runTimeout(drainQueue);
  52739. }
  52740. };
  52741. // v8 likes predictible objects
  52742. function Item(fun, array) {
  52743. this.fun = fun;
  52744. this.array = array;
  52745. }
  52746. Item.prototype.run = function () {
  52747. this.fun.apply(null, this.array);
  52748. };
  52749. process.title = 'browser';
  52750. process.browser = true;
  52751. process.env = {};
  52752. process.argv = [];
  52753. process.version = ''; // empty string to avoid regexp issues
  52754. process.versions = {};
  52755. function noop() {}
  52756. process.on = noop;
  52757. process.addListener = noop;
  52758. process.once = noop;
  52759. process.off = noop;
  52760. process.removeListener = noop;
  52761. process.removeAllListeners = noop;
  52762. process.emit = noop;
  52763. process.binding = function (name) {
  52764. throw new Error('process.binding is not supported');
  52765. };
  52766. process.cwd = function () { return '/' };
  52767. process.chdir = function (dir) {
  52768. throw new Error('process.chdir is not supported');
  52769. };
  52770. process.umask = function() { return 0; };
  52771. /***/ },
  52772. /* 372 */
  52773. /***/ function(module, exports, __webpack_require__) {
  52774. var env = __webpack_require__(2);
  52775. function SaveAsImage (model) {
  52776. this.model = model;
  52777. }
  52778. SaveAsImage.defaultOption = {
  52779. show: true,
  52780. icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
  52781. title: '保存为图片',
  52782. type: 'png',
  52783. // Default use option.backgroundColor
  52784. // backgroundColor: '#fff',
  52785. name: '',
  52786. excludeComponents: ['toolbox'],
  52787. pixelRatio: 1,
  52788. lang: ['右键另存为图片']
  52789. };
  52790. SaveAsImage.prototype.unusable = !env.canvasSupported;
  52791. var proto = SaveAsImage.prototype;
  52792. proto.onclick = function (ecModel, api) {
  52793. var model = this.model;
  52794. var title = model.get('name') || ecModel.get('title.0.text') || 'echarts';
  52795. var $a = document.createElement('a');
  52796. var type = model.get('type', true) || 'png';
  52797. $a.download = title + '.' + type;
  52798. $a.target = '_blank';
  52799. var url = api.getConnectedDataURL({
  52800. type: type,
  52801. backgroundColor: model.get('backgroundColor', true)
  52802. || ecModel.get('backgroundColor') || '#fff',
  52803. excludeComponents: model.get('excludeComponents'),
  52804. pixelRatio: model.get('pixelRatio')
  52805. });
  52806. $a.href = url;
  52807. // Chrome and Firefox
  52808. if (typeof MouseEvent === 'function' && !env.browser.ie && !env.browser.edge) {
  52809. var evt = new MouseEvent('click', {
  52810. view: window,
  52811. bubbles: true,
  52812. cancelable: false
  52813. });
  52814. $a.dispatchEvent(evt);
  52815. }
  52816. // IE
  52817. else {
  52818. var lang = model.get('lang');
  52819. var html = ''
  52820. + '<body style="margin:0;">'
  52821. + '<img src="' + url + '" style="max-width:100%;" title="' + ((lang && lang[0]) || '') + '" />'
  52822. + '</body>';
  52823. var tab = window.open();
  52824. tab.document.write(html);
  52825. }
  52826. };
  52827. __webpack_require__(316).register(
  52828. 'saveAsImage', SaveAsImage
  52829. );
  52830. module.exports = SaveAsImage;
  52831. /***/ },
  52832. /* 373 */
  52833. /***/ function(module, exports, __webpack_require__) {
  52834. 'use strict';
  52835. var zrUtil = __webpack_require__(4);
  52836. function MagicType(model) {
  52837. this.model = model;
  52838. }
  52839. MagicType.defaultOption = {
  52840. show: true,
  52841. type: [],
  52842. // Icon group
  52843. icon: {
  52844. line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
  52845. bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
  52846. stack: 'M8.2,38.4l-8.4,4.1l30.6,15.3L60,42.5l-8.1-4.1l-21.5,11L8.2,38.4z M51.9,30l-8.1,4.2l-13.4,6.9l-13.9-6.9L8.2,30l-8.4,4.2l8.4,4.2l22.2,11l21.5-11l8.1-4.2L51.9,30z M51.9,21.7l-8.1,4.2L35.7,30l-5.3,2.8L24.9,30l-8.4-4.1l-8.3-4.2l-8.4,4.2L8.2,30l8.3,4.2l13.9,6.9l13.4-6.9l8.1-4.2l8.1-4.1L51.9,21.7zM30.4,2.2L-0.2,17.5l8.4,4.1l8.3,4.2l8.4,4.2l5.5,2.7l5.3-2.7l8.1-4.2l8.1-4.2l8.1-4.1L30.4,2.2z', // jshint ignore:line
  52847. tiled: 'M2.3,2.2h22.8V25H2.3V2.2z M35,2.2h22.8V25H35V2.2zM2.3,35h22.8v22.8H2.3V35z M35,35h22.8v22.8H35V35z'
  52848. },
  52849. title: {
  52850. line: '切换为折线图',
  52851. bar: '切换为柱状图',
  52852. stack: '切换为堆叠',
  52853. tiled: '切换为平铺'
  52854. },
  52855. option: {},
  52856. seriesIndex: {}
  52857. };
  52858. var proto = MagicType.prototype;
  52859. proto.getIcons = function () {
  52860. var model = this.model;
  52861. var availableIcons = model.get('icon');
  52862. var icons = {};
  52863. zrUtil.each(model.get('type'), function (type) {
  52864. if (availableIcons[type]) {
  52865. icons[type] = availableIcons[type];
  52866. }
  52867. });
  52868. return icons;
  52869. };
  52870. var seriesOptGenreator = {
  52871. 'line': function (seriesType, seriesId, seriesModel, model) {
  52872. if (seriesType === 'bar') {
  52873. return zrUtil.merge({
  52874. id: seriesId,
  52875. type: 'line',
  52876. // Preserve data related option
  52877. data: seriesModel.get('data'),
  52878. stack: seriesModel.get('stack'),
  52879. markPoint: seriesModel.get('markPoint'),
  52880. markLine: seriesModel.get('markLine')
  52881. }, model.get('option.line') || {}, true);
  52882. }
  52883. },
  52884. 'bar': function (seriesType, seriesId, seriesModel, model) {
  52885. if (seriesType === 'line') {
  52886. return zrUtil.merge({
  52887. id: seriesId,
  52888. type: 'bar',
  52889. // Preserve data related option
  52890. data: seriesModel.get('data'),
  52891. stack: seriesModel.get('stack'),
  52892. markPoint: seriesModel.get('markPoint'),
  52893. markLine: seriesModel.get('markLine')
  52894. }, model.get('option.bar') || {}, true);
  52895. }
  52896. },
  52897. 'stack': function (seriesType, seriesId, seriesModel, model) {
  52898. if (seriesType === 'line' || seriesType === 'bar') {
  52899. return zrUtil.merge({
  52900. id: seriesId,
  52901. stack: '__ec_magicType_stack__'
  52902. }, model.get('option.stack') || {}, true);
  52903. }
  52904. },
  52905. 'tiled': function (seriesType, seriesId, seriesModel, model) {
  52906. if (seriesType === 'line' || seriesType === 'bar') {
  52907. return zrUtil.merge({
  52908. id: seriesId,
  52909. stack: ''
  52910. }, model.get('option.tiled') || {}, true);
  52911. }
  52912. }
  52913. };
  52914. var radioTypes = [
  52915. ['line', 'bar'],
  52916. ['stack', 'tiled']
  52917. ];
  52918. proto.onclick = function (ecModel, api, type) {
  52919. var model = this.model;
  52920. var seriesIndex = model.get('seriesIndex.' + type);
  52921. // Not supported magicType
  52922. if (!seriesOptGenreator[type]) {
  52923. return;
  52924. }
  52925. var newOption = {
  52926. series: []
  52927. };
  52928. var generateNewSeriesTypes = function (seriesModel) {
  52929. var seriesType = seriesModel.subType;
  52930. var seriesId = seriesModel.id;
  52931. var newSeriesOpt = seriesOptGenreator[type](
  52932. seriesType, seriesId, seriesModel, model
  52933. );
  52934. if (newSeriesOpt) {
  52935. // PENDING If merge original option?
  52936. zrUtil.defaults(newSeriesOpt, seriesModel.option);
  52937. newOption.series.push(newSeriesOpt);
  52938. }
  52939. // Modify boundaryGap
  52940. var coordSys = seriesModel.coordinateSystem;
  52941. if (coordSys && coordSys.type === 'cartesian2d' && (type === 'line' || type === 'bar')) {
  52942. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  52943. if (categoryAxis) {
  52944. var axisDim = categoryAxis.dim;
  52945. var axisType = axisDim + 'Axis';
  52946. var axisModel = ecModel.queryComponents({
  52947. mainType: axisType,
  52948. index: seriesModel.get(name + 'Index'),
  52949. id: seriesModel.get(name + 'Id')
  52950. })[0];
  52951. var axisIndex = axisModel.componentIndex;
  52952. newOption[axisType] = newOption[axisType] || [];
  52953. for (var i = 0; i <= axisIndex; i++) {
  52954. newOption[axisType][axisIndex] = newOption[axisType][axisIndex] || {};
  52955. }
  52956. newOption[axisType][axisIndex].boundaryGap = type === 'bar' ? true : false;
  52957. }
  52958. }
  52959. };
  52960. zrUtil.each(radioTypes, function (radio) {
  52961. if (zrUtil.indexOf(radio, type) >= 0) {
  52962. zrUtil.each(radio, function (item) {
  52963. model.setIconStatus(item, 'normal');
  52964. });
  52965. }
  52966. });
  52967. model.setIconStatus(type, 'emphasis');
  52968. ecModel.eachComponent(
  52969. {
  52970. mainType: 'series',
  52971. query: seriesIndex == null ? null : {
  52972. seriesIndex: seriesIndex
  52973. }
  52974. }, generateNewSeriesTypes
  52975. );
  52976. api.dispatchAction({
  52977. type: 'changeMagicType',
  52978. currentType: type,
  52979. newOption: newOption
  52980. });
  52981. };
  52982. var echarts = __webpack_require__(1);
  52983. echarts.registerAction({
  52984. type: 'changeMagicType',
  52985. event: 'magicTypeChanged',
  52986. update: 'prepareAndUpdate'
  52987. }, function (payload, ecModel) {
  52988. ecModel.mergeOption(payload.newOption);
  52989. });
  52990. __webpack_require__(316).register('magicType', MagicType);
  52991. module.exports = MagicType;
  52992. /***/ },
  52993. /* 374 */
  52994. /***/ function(module, exports, __webpack_require__) {
  52995. /**
  52996. * @module echarts/component/toolbox/feature/DataView
  52997. */
  52998. var zrUtil = __webpack_require__(4);
  52999. var eventTool = __webpack_require__(88);
  53000. var BLOCK_SPLITER = new Array(60).join('-');
  53001. var ITEM_SPLITER = '\t';
  53002. /**
  53003. * Group series into two types
  53004. * 1. on category axis, like line, bar
  53005. * 2. others, like scatter, pie
  53006. * @param {module:echarts/model/Global} ecModel
  53007. * @return {Object}
  53008. * @inner
  53009. */
  53010. function groupSeries(ecModel) {
  53011. var seriesGroupByCategoryAxis = {};
  53012. var otherSeries = [];
  53013. var meta = [];
  53014. ecModel.eachRawSeries(function (seriesModel) {
  53015. var coordSys = seriesModel.coordinateSystem;
  53016. if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
  53017. var baseAxis = coordSys.getBaseAxis();
  53018. if (baseAxis.type === 'category') {
  53019. var key = baseAxis.dim + '_' + baseAxis.index;
  53020. if (!seriesGroupByCategoryAxis[key]) {
  53021. seriesGroupByCategoryAxis[key] = {
  53022. categoryAxis: baseAxis,
  53023. valueAxis: coordSys.getOtherAxis(baseAxis),
  53024. series: []
  53025. };
  53026. meta.push({
  53027. axisDim: baseAxis.dim,
  53028. axisIndex: baseAxis.index
  53029. });
  53030. }
  53031. seriesGroupByCategoryAxis[key].series.push(seriesModel);
  53032. }
  53033. else {
  53034. otherSeries.push(seriesModel);
  53035. }
  53036. }
  53037. else {
  53038. otherSeries.push(seriesModel);
  53039. }
  53040. });
  53041. return {
  53042. seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
  53043. other: otherSeries,
  53044. meta: meta
  53045. };
  53046. }
  53047. /**
  53048. * Assemble content of series on cateogory axis
  53049. * @param {Array.<module:echarts/model/Series>} series
  53050. * @return {string}
  53051. * @inner
  53052. */
  53053. function assembleSeriesWithCategoryAxis(series) {
  53054. var tables = [];
  53055. zrUtil.each(series, function (group, key) {
  53056. var categoryAxis = group.categoryAxis;
  53057. var valueAxis = group.valueAxis;
  53058. var valueAxisDim = valueAxis.dim;
  53059. var headers = [' '].concat(zrUtil.map(group.series, function (series) {
  53060. return series.name;
  53061. }));
  53062. var columns = [categoryAxis.model.getCategories()];
  53063. zrUtil.each(group.series, function (series) {
  53064. columns.push(series.getRawData().mapArray(valueAxisDim, function (val) {
  53065. return val;
  53066. }));
  53067. });
  53068. // Assemble table content
  53069. var lines = [headers.join(ITEM_SPLITER)];
  53070. for (var i = 0; i < columns[0].length; i++) {
  53071. var items = [];
  53072. for (var j = 0; j < columns.length; j++) {
  53073. items.push(columns[j][i]);
  53074. }
  53075. lines.push(items.join(ITEM_SPLITER));
  53076. }
  53077. tables.push(lines.join('\n'));
  53078. });
  53079. return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
  53080. }
  53081. /**
  53082. * Assemble content of other series
  53083. * @param {Array.<module:echarts/model/Series>} series
  53084. * @return {string}
  53085. * @inner
  53086. */
  53087. function assembleOtherSeries(series) {
  53088. return zrUtil.map(series, function (series) {
  53089. var data = series.getRawData();
  53090. var lines = [series.name];
  53091. var vals = [];
  53092. data.each(data.dimensions, function () {
  53093. var argLen = arguments.length;
  53094. var dataIndex = arguments[argLen - 1];
  53095. var name = data.getName(dataIndex);
  53096. for (var i = 0; i < argLen - 1; i++) {
  53097. vals[i] = arguments[i];
  53098. }
  53099. lines.push((name ? (name + ITEM_SPLITER) : '') + vals.join(ITEM_SPLITER));
  53100. });
  53101. return lines.join('\n');
  53102. }).join('\n\n' + BLOCK_SPLITER + '\n\n');
  53103. }
  53104. /**
  53105. * @param {module:echarts/model/Global}
  53106. * @return {string}
  53107. * @inner
  53108. */
  53109. function getContentFromModel(ecModel) {
  53110. var result = groupSeries(ecModel);
  53111. return {
  53112. value: zrUtil.filter([
  53113. assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis),
  53114. assembleOtherSeries(result.other)
  53115. ], function (str) {
  53116. return str.replace(/[\n\t\s]/g, '');
  53117. }).join('\n\n' + BLOCK_SPLITER + '\n\n'),
  53118. meta: result.meta
  53119. };
  53120. }
  53121. function trim(str) {
  53122. return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  53123. }
  53124. /**
  53125. * If a block is tsv format
  53126. */
  53127. function isTSVFormat(block) {
  53128. // Simple method to find out if a block is tsv format
  53129. var firstLine = block.slice(0, block.indexOf('\n'));
  53130. if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
  53131. return true;
  53132. }
  53133. }
  53134. var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g');
  53135. /**
  53136. * @param {string} tsv
  53137. * @return {Array.<Object>}
  53138. */
  53139. function parseTSVContents(tsv) {
  53140. var tsvLines = tsv.split(/\n+/g);
  53141. var headers = trim(tsvLines.shift()).split(itemSplitRegex);
  53142. var categories = [];
  53143. var series = zrUtil.map(headers, function (header) {
  53144. return {
  53145. name: header,
  53146. data: []
  53147. };
  53148. });
  53149. for (var i = 0; i < tsvLines.length; i++) {
  53150. var items = trim(tsvLines[i]).split(itemSplitRegex);
  53151. categories.push(items.shift());
  53152. for (var j = 0; j < items.length; j++) {
  53153. series[j] && (series[j].data[i] = items[j]);
  53154. }
  53155. }
  53156. return {
  53157. series: series,
  53158. categories: categories
  53159. };
  53160. }
  53161. /**
  53162. * @param {string} str
  53163. * @return {Array.<Object>}
  53164. * @inner
  53165. */
  53166. function parseListContents(str) {
  53167. var lines = str.split(/\n+/g);
  53168. var seriesName = trim(lines.shift());
  53169. var data = [];
  53170. for (var i = 0; i < lines.length; i++) {
  53171. var items = trim(lines[i]).split(itemSplitRegex);
  53172. var name = '';
  53173. var value;
  53174. var hasName = false;
  53175. if (isNaN(items[0])) { // First item is name
  53176. hasName = true;
  53177. name = items[0];
  53178. items = items.slice(1);
  53179. data[i] = {
  53180. name: name,
  53181. value: []
  53182. };
  53183. value = data[i].value;
  53184. }
  53185. else {
  53186. value = data[i] = [];
  53187. }
  53188. for (var j = 0; j < items.length; j++) {
  53189. value.push(+items[j]);
  53190. }
  53191. if (value.length === 1) {
  53192. hasName ? (data[i].value = value[0]) : (data[i] = value[0]);
  53193. }
  53194. }
  53195. return {
  53196. name: seriesName,
  53197. data: data
  53198. };
  53199. }
  53200. /**
  53201. * @param {string} str
  53202. * @param {Array.<Object>} blockMetaList
  53203. * @return {Object}
  53204. * @inner
  53205. */
  53206. function parseContents(str, blockMetaList) {
  53207. var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g'));
  53208. var newOption = {
  53209. series: []
  53210. };
  53211. zrUtil.each(blocks, function (block, idx) {
  53212. if (isTSVFormat(block)) {
  53213. var result = parseTSVContents(block);
  53214. var blockMeta = blockMetaList[idx];
  53215. var axisKey = blockMeta.axisDim + 'Axis';
  53216. if (blockMeta) {
  53217. newOption[axisKey] = newOption[axisKey] || [];
  53218. newOption[axisKey][blockMeta.axisIndex] = {
  53219. data: result.categories
  53220. };
  53221. newOption.series = newOption.series.concat(result.series);
  53222. }
  53223. }
  53224. else {
  53225. var result = parseListContents(block);
  53226. newOption.series.push(result);
  53227. }
  53228. });
  53229. return newOption;
  53230. }
  53231. /**
  53232. * @alias {module:echarts/component/toolbox/feature/DataView}
  53233. * @constructor
  53234. * @param {module:echarts/model/Model} model
  53235. */
  53236. function DataView(model) {
  53237. this._dom = null;
  53238. this.model = model;
  53239. }
  53240. DataView.defaultOption = {
  53241. show: true,
  53242. readOnly: false,
  53243. optionToContent: null,
  53244. contentToOption: null,
  53245. icon: 'M17.5,17.3H33 M17.5,17.3H33 M45.4,29.5h-28 M11.5,2v56H51V14.8L38.4,2H11.5z M38.4,2.2v12.7H51 M45.4,41.7h-28',
  53246. title: '数据视图',
  53247. lang: ['数据视图', '关闭', '刷新'],
  53248. backgroundColor: '#fff',
  53249. textColor: '#000',
  53250. textareaColor: '#fff',
  53251. textareaBorderColor: '#333',
  53252. buttonColor: '#c23531',
  53253. buttonTextColor: '#fff'
  53254. };
  53255. DataView.prototype.onclick = function (ecModel, api) {
  53256. var container = api.getDom();
  53257. var model = this.model;
  53258. if (this._dom) {
  53259. container.removeChild(this._dom);
  53260. }
  53261. var root = document.createElement('div');
  53262. root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;';
  53263. root.style.backgroundColor = model.get('backgroundColor') || '#fff';
  53264. // Create elements
  53265. var header = document.createElement('h4');
  53266. var lang = model.get('lang') || [];
  53267. header.innerHTML = lang[0] || model.get('title');
  53268. header.style.cssText = 'margin: 10px 20px;';
  53269. header.style.color = model.get('textColor');
  53270. var viewMain = document.createElement('div');
  53271. var textarea = document.createElement('textarea');
  53272. viewMain.style.cssText = 'display:block;width:100%;overflow:hidden;';
  53273. var optionToContent = model.get('optionToContent');
  53274. var contentToOption = model.get('contentToOption');
  53275. var result = getContentFromModel(ecModel);
  53276. if (typeof optionToContent === 'function') {
  53277. var htmlOrDom = optionToContent(api.getOption());
  53278. if (typeof htmlOrDom === 'string') {
  53279. viewMain.innerHTML = htmlOrDom;
  53280. }
  53281. else if (zrUtil.isDom(htmlOrDom)) {
  53282. viewMain.appendChild(htmlOrDom);
  53283. }
  53284. }
  53285. else {
  53286. // Use default textarea
  53287. viewMain.appendChild(textarea);
  53288. textarea.readOnly = model.get('readOnly');
  53289. textarea.style.cssText = 'width:100%;height:100%;font-family:monospace;font-size:14px;line-height:1.6rem;';
  53290. textarea.style.color = model.get('textColor');
  53291. textarea.style.borderColor = model.get('textareaBorderColor');
  53292. textarea.style.backgroundColor = model.get('textareaColor');
  53293. textarea.value = result.value;
  53294. }
  53295. var blockMetaList = result.meta;
  53296. var buttonContainer = document.createElement('div');
  53297. buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;';
  53298. var buttonStyle = 'float:right;margin-right:20px;border:none;'
  53299. + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px';
  53300. var closeButton = document.createElement('div');
  53301. var refreshButton = document.createElement('div');
  53302. buttonStyle += ';background-color:' + model.get('buttonColor');
  53303. buttonStyle += ';color:' + model.get('buttonTextColor');
  53304. var self = this;
  53305. function close() {
  53306. container.removeChild(root);
  53307. self._dom = null;
  53308. }
  53309. eventTool.addEventListener(closeButton, 'click', close);
  53310. eventTool.addEventListener(refreshButton, 'click', function () {
  53311. var newOption;
  53312. try {
  53313. if (typeof contentToOption === 'function') {
  53314. newOption = contentToOption(viewMain, api.getOption());
  53315. }
  53316. else {
  53317. newOption = parseContents(textarea.value, blockMetaList);
  53318. }
  53319. }
  53320. catch (e) {
  53321. close();
  53322. throw new Error('Data view format error ' + e);
  53323. }
  53324. if (newOption) {
  53325. api.dispatchAction({
  53326. type: 'changeDataView',
  53327. newOption: newOption
  53328. });
  53329. }
  53330. close();
  53331. });
  53332. closeButton.innerHTML = lang[1];
  53333. refreshButton.innerHTML = lang[2];
  53334. refreshButton.style.cssText = buttonStyle;
  53335. closeButton.style.cssText = buttonStyle;
  53336. !model.get('readOnly') && buttonContainer.appendChild(refreshButton);
  53337. buttonContainer.appendChild(closeButton);
  53338. // http://stackoverflow.com/questions/6637341/use-tab-to-indent-in-textarea
  53339. eventTool.addEventListener(textarea, 'keydown', function (e) {
  53340. if ((e.keyCode || e.which) === 9) {
  53341. // get caret position/selection
  53342. var val = this.value;
  53343. var start = this.selectionStart;
  53344. var end = this.selectionEnd;
  53345. // set textarea value to: text before caret + tab + text after caret
  53346. this.value = val.substring(0, start) + ITEM_SPLITER + val.substring(end);
  53347. // put caret at right position again
  53348. this.selectionStart = this.selectionEnd = start + 1;
  53349. // prevent the focus lose
  53350. eventTool.stop(e);
  53351. }
  53352. });
  53353. root.appendChild(header);
  53354. root.appendChild(viewMain);
  53355. root.appendChild(buttonContainer);
  53356. viewMain.style.height = (container.clientHeight - 80) + 'px';
  53357. container.appendChild(root);
  53358. this._dom = root;
  53359. };
  53360. DataView.prototype.remove = function (ecModel, api) {
  53361. this._dom && api.getDom().removeChild(this._dom);
  53362. };
  53363. DataView.prototype.dispose = function (ecModel, api) {
  53364. this.remove(ecModel, api);
  53365. };
  53366. /**
  53367. * @inner
  53368. */
  53369. function tryMergeDataOption(newData, originalData) {
  53370. return zrUtil.map(newData, function (newVal, idx) {
  53371. var original = originalData && originalData[idx];
  53372. if (zrUtil.isObject(original) && !zrUtil.isArray(original)) {
  53373. if (zrUtil.isObject(newVal) && !zrUtil.isArray(newVal)) {
  53374. newVal = newVal.value;
  53375. }
  53376. // Original data has option
  53377. return zrUtil.defaults({
  53378. value: newVal
  53379. }, original);
  53380. }
  53381. else {
  53382. return newVal;
  53383. }
  53384. });
  53385. }
  53386. __webpack_require__(316).register('dataView', DataView);
  53387. __webpack_require__(1).registerAction({
  53388. type: 'changeDataView',
  53389. event: 'dataViewChanged',
  53390. update: 'prepareAndUpdate'
  53391. }, function (payload, ecModel) {
  53392. var newSeriesOptList = [];
  53393. zrUtil.each(payload.newOption.series, function (seriesOpt) {
  53394. var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0];
  53395. if (!seriesModel) {
  53396. // New created series
  53397. // Geuss the series type
  53398. newSeriesOptList.push(zrUtil.extend({
  53399. // Default is scatter
  53400. type: 'scatter'
  53401. }, seriesOpt));
  53402. }
  53403. else {
  53404. var originalData = seriesModel.get('data');
  53405. newSeriesOptList.push({
  53406. name: seriesOpt.name,
  53407. data: tryMergeDataOption(seriesOpt.data, originalData)
  53408. });
  53409. }
  53410. });
  53411. ecModel.mergeOption(zrUtil.defaults({
  53412. series: newSeriesOptList
  53413. }, payload.newOption));
  53414. });
  53415. module.exports = DataView;
  53416. /***/ },
  53417. /* 375 */
  53418. /***/ function(module, exports, __webpack_require__) {
  53419. 'use strict';
  53420. var zrUtil = __webpack_require__(4);
  53421. var BrushController = __webpack_require__(235);
  53422. var brushHelper = __webpack_require__(311);
  53423. var history = __webpack_require__(376);
  53424. var each = zrUtil.each;
  53425. // Use dataZoomSelect
  53426. __webpack_require__(377);
  53427. // Spectial component id start with \0ec\0, see echarts/model/Global.js~hasInnerId
  53428. var DATA_ZOOM_ID_BASE = '\0_ec_\0toolbox-dataZoom_';
  53429. function DataZoom(model, ecModel, api) {
  53430. /**
  53431. * @private
  53432. * @type {module:echarts/component/helper/BrushController}
  53433. */
  53434. (this._brushController = new BrushController(api.getZr()))
  53435. .on('brush', zrUtil.bind(this._onBrush, this))
  53436. .mount();
  53437. /**
  53438. * @private
  53439. * @type {boolean}
  53440. */
  53441. this._isZoomActive;
  53442. }
  53443. DataZoom.defaultOption = {
  53444. show: true,
  53445. // Icon group
  53446. icon: {
  53447. zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
  53448. back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
  53449. },
  53450. title: {
  53451. zoom: '区域缩放',
  53452. back: '区域缩放还原'
  53453. }
  53454. };
  53455. var proto = DataZoom.prototype;
  53456. proto.render = function (featureModel, ecModel, api, payload) {
  53457. this.model = featureModel;
  53458. this.ecModel = ecModel;
  53459. this.api = api;
  53460. updateZoomBtnStatus(featureModel, ecModel, this, payload);
  53461. updateBackBtnStatus(featureModel, ecModel);
  53462. };
  53463. proto.onclick = function (ecModel, api, type) {
  53464. handlers[type].call(this);
  53465. };
  53466. proto.remove = function (ecModel, api) {
  53467. this._brushController.unmount();
  53468. };
  53469. proto.dispose = function (ecModel, api) {
  53470. this._brushController.dispose();
  53471. };
  53472. /**
  53473. * @private
  53474. */
  53475. var handlers = {
  53476. zoom: function () {
  53477. var nextActive = !this._isZoomActive;
  53478. this.api.dispatchAction({
  53479. type: 'takeGlobalCursor',
  53480. key: 'dataZoomSelect',
  53481. dataZoomSelectActive: nextActive
  53482. });
  53483. },
  53484. back: function () {
  53485. this._dispatchZoomAction(history.pop(this.ecModel));
  53486. }
  53487. };
  53488. /**
  53489. * @private
  53490. */
  53491. proto._onBrush = function (areas, opt) {
  53492. if (!opt.isEnd || !areas.length) {
  53493. return;
  53494. }
  53495. var snapshot = {};
  53496. var ecModel = this.ecModel;
  53497. this._brushController.updateCovers([]); // remove cover
  53498. var coordInfoList = brushHelper.makeCoordInfoList(
  53499. retrieveAxisSetting(this.model.option), ecModel
  53500. );
  53501. var rangesCoordInfoList = [];
  53502. brushHelper.parseOutputRanges(areas, coordInfoList, ecModel, rangesCoordInfoList);
  53503. var area = areas[0]; // dataZoom can not multiple area.
  53504. var coordInfo = rangesCoordInfoList[0];
  53505. var coordRange = area.coordRange;
  53506. var brushType = area.brushType;
  53507. if (coordInfo && coordRange) {
  53508. if (brushType === 'rect') {
  53509. setBatch('xAxis', coordRange[0], coordInfo);
  53510. setBatch('yAxis', coordRange[1], coordInfo);
  53511. }
  53512. else {
  53513. var axisNames = {lineX: 'xAxis', lineY: 'yAxis'};
  53514. setBatch(axisNames[brushType], coordRange, coordInfo);
  53515. }
  53516. }
  53517. history.push(ecModel, snapshot);
  53518. this._dispatchZoomAction(snapshot);
  53519. function setBatch(axisName, minMax, coordInfo) {
  53520. var dataZoomModel = findDataZoom(axisName, coordInfo[axisName], ecModel);
  53521. if (dataZoomModel) {
  53522. snapshot[dataZoomModel.id] = {
  53523. dataZoomId: dataZoomModel.id,
  53524. startValue: minMax[0],
  53525. endValue: minMax[1]
  53526. };
  53527. }
  53528. }
  53529. function findDataZoom(axisName, axisModel, ecModel) {
  53530. var dataZoomModel;
  53531. ecModel.eachComponent(
  53532. {mainType: 'dataZoom', subType: 'select'},
  53533. function (dzModel, dataZoomIndex) {
  53534. var axisIndex = dzModel.get(axisName + 'Index');
  53535. if (axisIndex != null
  53536. && ecModel.getComponent(axisName, axisIndex) === axisModel
  53537. ) {
  53538. dataZoomModel = dzModel;
  53539. }
  53540. }
  53541. );
  53542. return dataZoomModel;
  53543. }
  53544. };
  53545. /**
  53546. * @private
  53547. */
  53548. proto._dispatchZoomAction = function (snapshot) {
  53549. var batch = [];
  53550. // Convert from hash map to array.
  53551. each(snapshot, function (batchItem, dataZoomId) {
  53552. batch.push(zrUtil.clone(batchItem));
  53553. });
  53554. batch.length && this.api.dispatchAction({
  53555. type: 'dataZoom',
  53556. from: this.uid,
  53557. batch: batch
  53558. });
  53559. };
  53560. function retrieveAxisSetting(option) {
  53561. var setting = {};
  53562. // Compatible with previous setting: null => all axis, false => no axis.
  53563. zrUtil.each(['xAxisIndex', 'yAxisIndex'], function (name) {
  53564. setting[name] = option[name];
  53565. setting[name] == null && (setting[name] = 'all');
  53566. (setting[name] === false || setting[name] === 'none') && (setting[name] = []);
  53567. });
  53568. return setting;
  53569. }
  53570. function updateBackBtnStatus(featureModel, ecModel) {
  53571. featureModel.setIconStatus(
  53572. 'back',
  53573. history.count(ecModel) > 1 ? 'emphasis' : 'normal'
  53574. );
  53575. }
  53576. function updateZoomBtnStatus(featureModel, ecModel, view, payload) {
  53577. var zoomActive = view._isZoomActive;
  53578. if (payload && payload.type === 'takeGlobalCursor') {
  53579. zoomActive = payload.key === 'dataZoomSelect'
  53580. ? payload.dataZoomSelectActive : false;
  53581. }
  53582. view._isZoomActive = zoomActive;
  53583. featureModel.setIconStatus('zoom', zoomActive ? 'emphasis' : 'normal');
  53584. var coordInfoList = brushHelper.makeCoordInfoList(
  53585. retrieveAxisSetting(featureModel.option), ecModel
  53586. );
  53587. var brushType = (coordInfoList.xAxisHas && !coordInfoList.yAxisHas)
  53588. ? 'lineX'
  53589. : (!coordInfoList.xAxisHas && coordInfoList.yAxisHas)
  53590. ? 'lineY'
  53591. : 'rect';
  53592. view._brushController
  53593. .setPanels(brushHelper.makePanelOpts(coordInfoList))
  53594. .enableBrush(
  53595. zoomActive
  53596. ? {
  53597. brushType: brushType,
  53598. brushStyle: { // FIXME user customized?
  53599. lineWidth: 0,
  53600. // stroke: '#333',
  53601. fill: 'rgba(0,0,0,0.2)'
  53602. }
  53603. }
  53604. : false
  53605. );
  53606. }
  53607. __webpack_require__(316).register('dataZoom', DataZoom);
  53608. // Create special dataZoom option for select
  53609. __webpack_require__(1).registerPreprocessor(function (option) {
  53610. if (!option) {
  53611. return;
  53612. }
  53613. var dataZoomOpts = option.dataZoom || (option.dataZoom = []);
  53614. if (!zrUtil.isArray(dataZoomOpts)) {
  53615. option.dataZoom = dataZoomOpts = [dataZoomOpts];
  53616. }
  53617. var toolboxOpt = option.toolbox;
  53618. if (toolboxOpt) {
  53619. // Assume there is only one toolbox
  53620. if (zrUtil.isArray(toolboxOpt)) {
  53621. toolboxOpt = toolboxOpt[0];
  53622. }
  53623. if (toolboxOpt && toolboxOpt.feature) {
  53624. var dataZoomOpt = toolboxOpt.feature.dataZoom;
  53625. addForAxis('xAxis', dataZoomOpt);
  53626. addForAxis('yAxis', dataZoomOpt);
  53627. }
  53628. }
  53629. function addForAxis(axisName, dataZoomOpt) {
  53630. if (!dataZoomOpt) {
  53631. return;
  53632. }
  53633. // Try not to modify model, because it is not merged yet.
  53634. var axisIndicesName = axisName + 'Index';
  53635. var givenAxisIndices = dataZoomOpt[axisIndicesName];
  53636. if (givenAxisIndices != null
  53637. && givenAxisIndices != 'all'
  53638. && !zrUtil.isArray(givenAxisIndices)
  53639. ) {
  53640. givenAxisIndices = (givenAxisIndices === false || givenAxisIndices === 'none') ? [] : [givenAxisIndices];
  53641. }
  53642. forEachComponent(axisName, function (axisOpt, axisIndex) {
  53643. if (givenAxisIndices != null
  53644. && givenAxisIndices != 'all'
  53645. && zrUtil.indexOf(givenAxisIndices, axisIndex) === -1
  53646. ) {
  53647. return;
  53648. }
  53649. var newOpt = {
  53650. type: 'select',
  53651. $fromToolbox: true,
  53652. // Id for merge mapping.
  53653. id: DATA_ZOOM_ID_BASE + axisName + axisIndex
  53654. };
  53655. // FIXME
  53656. // Only support one axis now.
  53657. newOpt[axisIndicesName] = axisIndex;
  53658. dataZoomOpts.push(newOpt);
  53659. });
  53660. }
  53661. function forEachComponent(mainType, cb) {
  53662. var opts = option[mainType];
  53663. if (!zrUtil.isArray(opts)) {
  53664. opts = opts ? [opts] : [];
  53665. }
  53666. each(opts, cb);
  53667. }
  53668. });
  53669. module.exports = DataZoom;
  53670. /***/ },
  53671. /* 376 */
  53672. /***/ function(module, exports, __webpack_require__) {
  53673. /**
  53674. * @file History manager.
  53675. */
  53676. var zrUtil = __webpack_require__(4);
  53677. var each = zrUtil.each;
  53678. var ATTR = '\0_ec_hist_store';
  53679. var history = {
  53680. /**
  53681. * @public
  53682. * @param {module:echarts/model/Global} ecModel
  53683. * @param {Object} newSnapshot {dataZoomId, batch: [payloadInfo, ...]}
  53684. */
  53685. push: function (ecModel, newSnapshot) {
  53686. var store = giveStore(ecModel);
  53687. // If previous dataZoom can not be found,
  53688. // complete an range with current range.
  53689. each(newSnapshot, function (batchItem, dataZoomId) {
  53690. var i = store.length - 1;
  53691. for (; i >= 0; i--) {
  53692. var snapshot = store[i];
  53693. if (snapshot[dataZoomId]) {
  53694. break;
  53695. }
  53696. }
  53697. if (i < 0) {
  53698. // No origin range set, create one by current range.
  53699. var dataZoomModel = ecModel.queryComponents(
  53700. {mainType: 'dataZoom', subType: 'select', id: dataZoomId}
  53701. )[0];
  53702. if (dataZoomModel) {
  53703. var percentRange = dataZoomModel.getPercentRange();
  53704. store[0][dataZoomId] = {
  53705. dataZoomId: dataZoomId,
  53706. start: percentRange[0],
  53707. end: percentRange[1]
  53708. };
  53709. }
  53710. }
  53711. });
  53712. store.push(newSnapshot);
  53713. },
  53714. /**
  53715. * @public
  53716. * @param {module:echarts/model/Global} ecModel
  53717. * @return {Object} snapshot
  53718. */
  53719. pop: function (ecModel) {
  53720. var store = giveStore(ecModel);
  53721. var head = store[store.length - 1];
  53722. store.length > 1 && store.pop();
  53723. // Find top for all dataZoom.
  53724. var snapshot = {};
  53725. each(head, function (batchItem, dataZoomId) {
  53726. for (var i = store.length - 1; i >= 0; i--) {
  53727. var batchItem = store[i][dataZoomId];
  53728. if (batchItem) {
  53729. snapshot[dataZoomId] = batchItem;
  53730. break;
  53731. }
  53732. }
  53733. });
  53734. return snapshot;
  53735. },
  53736. /**
  53737. * @public
  53738. */
  53739. clear: function (ecModel) {
  53740. ecModel[ATTR] = null;
  53741. },
  53742. /**
  53743. * @public
  53744. * @param {module:echarts/model/Global} ecModel
  53745. * @return {number} records. always >= 1.
  53746. */
  53747. count: function (ecModel) {
  53748. return giveStore(ecModel).length;
  53749. }
  53750. };
  53751. /**
  53752. * [{key: dataZoomId, value: {dataZoomId, range}}, ...]
  53753. * History length of each dataZoom may be different.
  53754. * this._history[0] is used to store origin range.
  53755. * @type {Array.<Object>}
  53756. */
  53757. function giveStore(ecModel) {
  53758. var store = ecModel[ATTR];
  53759. if (!store) {
  53760. store = ecModel[ATTR] = [{}];
  53761. }
  53762. return store;
  53763. }
  53764. module.exports = history;
  53765. /***/ },
  53766. /* 377 */
  53767. /***/ function(module, exports, __webpack_require__) {
  53768. /**
  53769. * DataZoom component entry
  53770. */
  53771. __webpack_require__(319);
  53772. __webpack_require__(320);
  53773. __webpack_require__(323);
  53774. __webpack_require__(378);
  53775. __webpack_require__(379);
  53776. __webpack_require__(330);
  53777. __webpack_require__(331);
  53778. /***/ },
  53779. /* 378 */
  53780. /***/ function(module, exports, __webpack_require__) {
  53781. /**
  53782. * @file Data zoom model
  53783. */
  53784. var DataZoomModel = __webpack_require__(320);
  53785. module.exports = DataZoomModel.extend({
  53786. type: 'dataZoom.select'
  53787. });
  53788. /***/ },
  53789. /* 379 */
  53790. /***/ function(module, exports, __webpack_require__) {
  53791. module.exports = __webpack_require__(323).extend({
  53792. type: 'dataZoom.select'
  53793. });
  53794. /***/ },
  53795. /* 380 */
  53796. /***/ function(module, exports, __webpack_require__) {
  53797. 'use strict';
  53798. var history = __webpack_require__(376);
  53799. function Restore(model) {
  53800. this.model = model;
  53801. }
  53802. Restore.defaultOption = {
  53803. show: true,
  53804. icon: 'M3.8,33.4 M47,18.9h9.8V8.7 M56.3,20.1 C52.1,9,40.5,0.6,26.8,2.1C12.6,3.7,1.6,16.2,2.1,30.6 M13,41.1H3.1v10.2 M3.7,39.9c4.2,11.1,15.8,19.5,29.5,18 c14.2-1.6,25.2-14.1,24.7-28.5',
  53805. title: '还原'
  53806. };
  53807. var proto = Restore.prototype;
  53808. proto.onclick = function (ecModel, api, type) {
  53809. history.clear(ecModel);
  53810. api.dispatchAction({
  53811. type: 'restore',
  53812. from: this.uid
  53813. });
  53814. };
  53815. __webpack_require__(316).register('restore', Restore);
  53816. __webpack_require__(1).registerAction(
  53817. {type: 'restore', event: 'restore', update: 'prepareAndUpdate'},
  53818. function (payload, ecModel) {
  53819. ecModel.resetOption('recreate');
  53820. }
  53821. );
  53822. module.exports = Restore;
  53823. /***/ },
  53824. /* 381 */
  53825. /***/ function(module, exports, __webpack_require__) {
  53826. __webpack_require__(382);
  53827. __webpack_require__(82).registerPainter('vml', __webpack_require__(384));
  53828. /***/ },
  53829. /* 382 */
  53830. /***/ function(module, exports, __webpack_require__) {
  53831. // http://www.w3.org/TR/NOTE-VML
  53832. // TODO Use proxy like svg instead of overwrite brush methods
  53833. if (!__webpack_require__(2).canvasSupported) {
  53834. var vec2 = __webpack_require__(10);
  53835. var BoundingRect = __webpack_require__(9);
  53836. var CMD = __webpack_require__(49).CMD;
  53837. var colorTool = __webpack_require__(39);
  53838. var textContain = __webpack_require__(8);
  53839. var RectText = __webpack_require__(48);
  53840. var Displayable = __webpack_require__(46);
  53841. var ZImage = __webpack_require__(61);
  53842. var Text = __webpack_require__(63);
  53843. var Path = __webpack_require__(45);
  53844. var Gradient = __webpack_require__(79);
  53845. var vmlCore = __webpack_require__(383);
  53846. var round = Math.round;
  53847. var sqrt = Math.sqrt;
  53848. var abs = Math.abs;
  53849. var cos = Math.cos;
  53850. var sin = Math.sin;
  53851. var mathMax = Math.max;
  53852. var applyTransform = vec2.applyTransform;
  53853. var comma = ',';
  53854. var imageTransformPrefix = 'progid:DXImageTransform.Microsoft';
  53855. var Z = 21600;
  53856. var Z2 = Z / 2;
  53857. var ZLEVEL_BASE = 100000;
  53858. var Z_BASE = 1000;
  53859. var initRootElStyle = function (el) {
  53860. el.style.cssText = 'position:absolute;left:0;top:0;width:1px;height:1px;';
  53861. el.coordsize = Z + ',' + Z;
  53862. el.coordorigin = '0,0';
  53863. };
  53864. var encodeHtmlAttribute = function (s) {
  53865. return String(s).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
  53866. };
  53867. var rgb2Str = function (r, g, b) {
  53868. return 'rgb(' + [r, g, b].join(',') + ')';
  53869. };
  53870. var append = function (parent, child) {
  53871. if (child && parent && child.parentNode !== parent) {
  53872. parent.appendChild(child);
  53873. }
  53874. };
  53875. var remove = function (parent, child) {
  53876. if (child && parent && child.parentNode === parent) {
  53877. parent.removeChild(child);
  53878. }
  53879. };
  53880. var getZIndex = function (zlevel, z, z2) {
  53881. // z 的取值范围为 [0, 1000]
  53882. return (parseFloat(zlevel) || 0) * ZLEVEL_BASE + (parseFloat(z) || 0) * Z_BASE + z2;
  53883. };
  53884. var parsePercent = function (value, maxValue) {
  53885. if (typeof value === 'string') {
  53886. if (value.lastIndexOf('%') >= 0) {
  53887. return parseFloat(value) / 100 * maxValue;
  53888. }
  53889. return parseFloat(value);
  53890. }
  53891. return value;
  53892. };
  53893. /***************************************************
  53894. * PATH
  53895. **************************************************/
  53896. var setColorAndOpacity = function (el, color, opacity) {
  53897. var colorArr = colorTool.parse(color);
  53898. opacity = +opacity;
  53899. if (isNaN(opacity)) {
  53900. opacity = 1;
  53901. }
  53902. if (colorArr) {
  53903. el.color = rgb2Str(colorArr[0], colorArr[1], colorArr[2]);
  53904. el.opacity = opacity * colorArr[3];
  53905. }
  53906. };
  53907. var getColorAndAlpha = function (color) {
  53908. var colorArr = colorTool.parse(color);
  53909. return [
  53910. rgb2Str(colorArr[0], colorArr[1], colorArr[2]),
  53911. colorArr[3]
  53912. ];
  53913. };
  53914. var updateFillNode = function (el, style, zrEl) {
  53915. // TODO pattern
  53916. var fill = style.fill;
  53917. if (fill != null) {
  53918. // Modified from excanvas
  53919. if (fill instanceof Gradient) {
  53920. var gradientType;
  53921. var angle = 0;
  53922. var focus = [0, 0];
  53923. // additional offset
  53924. var shift = 0;
  53925. // scale factor for offset
  53926. var expansion = 1;
  53927. var rect = zrEl.getBoundingRect();
  53928. var rectWidth = rect.width;
  53929. var rectHeight = rect.height;
  53930. if (fill.type === 'linear') {
  53931. gradientType = 'gradient';
  53932. var transform = zrEl.transform;
  53933. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  53934. var p1 = [fill.x2 * rectWidth, fill.y2 * rectHeight];
  53935. if (transform) {
  53936. applyTransform(p0, p0, transform);
  53937. applyTransform(p1, p1, transform);
  53938. }
  53939. var dx = p1[0] - p0[0];
  53940. var dy = p1[1] - p0[1];
  53941. angle = Math.atan2(dx, dy) * 180 / Math.PI;
  53942. // The angle should be a non-negative number.
  53943. if (angle < 0) {
  53944. angle += 360;
  53945. }
  53946. // Very small angles produce an unexpected result because they are
  53947. // converted to a scientific notation string.
  53948. if (angle < 1e-6) {
  53949. angle = 0;
  53950. }
  53951. }
  53952. else {
  53953. gradientType = 'gradientradial';
  53954. var p0 = [fill.x * rectWidth, fill.y * rectHeight];
  53955. var transform = zrEl.transform;
  53956. var scale = zrEl.scale;
  53957. var width = rectWidth;
  53958. var height = rectHeight;
  53959. focus = [
  53960. // Percent in bounding rect
  53961. (p0[0] - rect.x) / width,
  53962. (p0[1] - rect.y) / height
  53963. ];
  53964. if (transform) {
  53965. applyTransform(p0, p0, transform);
  53966. }
  53967. width /= scale[0] * Z;
  53968. height /= scale[1] * Z;
  53969. var dimension = mathMax(width, height);
  53970. shift = 2 * 0 / dimension;
  53971. expansion = 2 * fill.r / dimension - shift;
  53972. }
  53973. // We need to sort the color stops in ascending order by offset,
  53974. // otherwise IE won't interpret it correctly.
  53975. var stops = fill.colorStops.slice();
  53976. stops.sort(function(cs1, cs2) {
  53977. return cs1.offset - cs2.offset;
  53978. });
  53979. var length = stops.length;
  53980. // Color and alpha list of first and last stop
  53981. var colorAndAlphaList = [];
  53982. var colors = [];
  53983. for (var i = 0; i < length; i++) {
  53984. var stop = stops[i];
  53985. var colorAndAlpha = getColorAndAlpha(stop.color);
  53986. colors.push(stop.offset * expansion + shift + ' ' + colorAndAlpha[0]);
  53987. if (i === 0 || i === length - 1) {
  53988. colorAndAlphaList.push(colorAndAlpha);
  53989. }
  53990. }
  53991. if (length >= 2) {
  53992. var color1 = colorAndAlphaList[0][0];
  53993. var color2 = colorAndAlphaList[1][0];
  53994. var opacity1 = colorAndAlphaList[0][1] * style.opacity;
  53995. var opacity2 = colorAndAlphaList[1][1] * style.opacity;
  53996. el.type = gradientType;
  53997. el.method = 'none';
  53998. el.focus = '100%';
  53999. el.angle = angle;
  54000. el.color = color1;
  54001. el.color2 = color2;
  54002. el.colors = colors.join(',');
  54003. // When colors attribute is used, the meanings of opacity and o:opacity2
  54004. // are reversed.
  54005. el.opacity = opacity2;
  54006. // FIXME g_o_:opacity ?
  54007. el.opacity2 = opacity1;
  54008. }
  54009. if (gradientType === 'radial') {
  54010. el.focusposition = focus.join(',');
  54011. }
  54012. }
  54013. else {
  54014. // FIXME Change from Gradient fill to color fill
  54015. setColorAndOpacity(el, fill, style.opacity);
  54016. }
  54017. }
  54018. };
  54019. var updateStrokeNode = function (el, style) {
  54020. // if (style.lineJoin != null) {
  54021. // el.joinstyle = style.lineJoin;
  54022. // }
  54023. // if (style.miterLimit != null) {
  54024. // el.miterlimit = style.miterLimit * Z;
  54025. // }
  54026. // if (style.lineCap != null) {
  54027. // el.endcap = style.lineCap;
  54028. // }
  54029. if (style.lineDash != null) {
  54030. el.dashstyle = style.lineDash.join(' ');
  54031. }
  54032. if (style.stroke != null && !(style.stroke instanceof Gradient)) {
  54033. setColorAndOpacity(el, style.stroke, style.opacity);
  54034. }
  54035. };
  54036. var updateFillAndStroke = function (vmlEl, type, style, zrEl) {
  54037. var isFill = type == 'fill';
  54038. var el = vmlEl.getElementsByTagName(type)[0];
  54039. // Stroke must have lineWidth
  54040. if (style[type] != null && style[type] !== 'none' && (isFill || (!isFill && style.lineWidth))) {
  54041. vmlEl[isFill ? 'filled' : 'stroked'] = 'true';
  54042. // FIXME Remove before updating, or set `colors` will throw error
  54043. if (style[type] instanceof Gradient) {
  54044. remove(vmlEl, el);
  54045. }
  54046. if (!el) {
  54047. el = vmlCore.createNode(type);
  54048. }
  54049. isFill ? updateFillNode(el, style, zrEl) : updateStrokeNode(el, style);
  54050. append(vmlEl, el);
  54051. }
  54052. else {
  54053. vmlEl[isFill ? 'filled' : 'stroked'] = 'false';
  54054. remove(vmlEl, el);
  54055. }
  54056. };
  54057. var points = [[], [], []];
  54058. var pathDataToString = function (data, m) {
  54059. var M = CMD.M;
  54060. var C = CMD.C;
  54061. var L = CMD.L;
  54062. var A = CMD.A;
  54063. var Q = CMD.Q;
  54064. var str = [];
  54065. var nPoint;
  54066. var cmdStr;
  54067. var cmd;
  54068. var i;
  54069. var xi;
  54070. var yi;
  54071. for (i = 0; i < data.length;) {
  54072. cmd = data[i++];
  54073. cmdStr = '';
  54074. nPoint = 0;
  54075. switch (cmd) {
  54076. case M:
  54077. cmdStr = ' m ';
  54078. nPoint = 1;
  54079. xi = data[i++];
  54080. yi = data[i++];
  54081. points[0][0] = xi;
  54082. points[0][1] = yi;
  54083. break;
  54084. case L:
  54085. cmdStr = ' l ';
  54086. nPoint = 1;
  54087. xi = data[i++];
  54088. yi = data[i++];
  54089. points[0][0] = xi;
  54090. points[0][1] = yi;
  54091. break;
  54092. case Q:
  54093. case C:
  54094. cmdStr = ' c ';
  54095. nPoint = 3;
  54096. var x1 = data[i++];
  54097. var y1 = data[i++];
  54098. var x2 = data[i++];
  54099. var y2 = data[i++];
  54100. var x3;
  54101. var y3;
  54102. if (cmd === Q) {
  54103. // Convert quadratic to cubic using degree elevation
  54104. x3 = x2;
  54105. y3 = y2;
  54106. x2 = (x2 + 2 * x1) / 3;
  54107. y2 = (y2 + 2 * y1) / 3;
  54108. x1 = (xi + 2 * x1) / 3;
  54109. y1 = (yi + 2 * y1) / 3;
  54110. }
  54111. else {
  54112. x3 = data[i++];
  54113. y3 = data[i++];
  54114. }
  54115. points[0][0] = x1;
  54116. points[0][1] = y1;
  54117. points[1][0] = x2;
  54118. points[1][1] = y2;
  54119. points[2][0] = x3;
  54120. points[2][1] = y3;
  54121. xi = x3;
  54122. yi = y3;
  54123. break;
  54124. case A:
  54125. var x = 0;
  54126. var y = 0;
  54127. var sx = 1;
  54128. var sy = 1;
  54129. var angle = 0;
  54130. if (m) {
  54131. // Extract SRT from matrix
  54132. x = m[4];
  54133. y = m[5];
  54134. sx = sqrt(m[0] * m[0] + m[1] * m[1]);
  54135. sy = sqrt(m[2] * m[2] + m[3] * m[3]);
  54136. angle = Math.atan2(-m[1] / sy, m[0] / sx);
  54137. }
  54138. var cx = data[i++];
  54139. var cy = data[i++];
  54140. var rx = data[i++];
  54141. var ry = data[i++];
  54142. var startAngle = data[i++] + angle;
  54143. var endAngle = data[i++] + startAngle + angle;
  54144. // FIXME
  54145. // var psi = data[i++];
  54146. i++;
  54147. var clockwise = data[i++];
  54148. var x0 = cx + cos(startAngle) * rx;
  54149. var y0 = cy + sin(startAngle) * ry;
  54150. var x1 = cx + cos(endAngle) * rx;
  54151. var y1 = cy + sin(endAngle) * ry;
  54152. var type = clockwise ? ' wa ' : ' at ';
  54153. if (Math.abs(x0 - x1) < 1e-10) {
  54154. // IE won't render arches drawn counter clockwise if x0 == x1.
  54155. if (Math.abs(endAngle - startAngle) > 1e-2) {
  54156. // Offset x0 by 1/80 of a pixel. Use something
  54157. // that can be represented in binary
  54158. if (clockwise) {
  54159. x0 += 270 / Z;
  54160. }
  54161. }
  54162. else {
  54163. // Avoid case draw full circle
  54164. if (Math.abs(y0 - cy) < 1e-10) {
  54165. if ((clockwise && x0 < cx) || (!clockwise && x0 > cx)) {
  54166. y1 -= 270 / Z;
  54167. }
  54168. else {
  54169. y1 += 270 / Z;
  54170. }
  54171. }
  54172. else if ((clockwise && y0 < cy) || (!clockwise && y0 > cy)) {
  54173. x1 += 270 / Z;
  54174. }
  54175. else {
  54176. x1 -= 270 / Z;
  54177. }
  54178. }
  54179. }
  54180. str.push(
  54181. type,
  54182. round(((cx - rx) * sx + x) * Z - Z2), comma,
  54183. round(((cy - ry) * sy + y) * Z - Z2), comma,
  54184. round(((cx + rx) * sx + x) * Z - Z2), comma,
  54185. round(((cy + ry) * sy + y) * Z - Z2), comma,
  54186. round((x0 * sx + x) * Z - Z2), comma,
  54187. round((y0 * sy + y) * Z - Z2), comma,
  54188. round((x1 * sx + x) * Z - Z2), comma,
  54189. round((y1 * sy + y) * Z - Z2)
  54190. );
  54191. xi = x1;
  54192. yi = y1;
  54193. break;
  54194. case CMD.R:
  54195. var p0 = points[0];
  54196. var p1 = points[1];
  54197. // x0, y0
  54198. p0[0] = data[i++];
  54199. p0[1] = data[i++];
  54200. // x1, y1
  54201. p1[0] = p0[0] + data[i++];
  54202. p1[1] = p0[1] + data[i++];
  54203. if (m) {
  54204. applyTransform(p0, p0, m);
  54205. applyTransform(p1, p1, m);
  54206. }
  54207. p0[0] = round(p0[0] * Z - Z2);
  54208. p1[0] = round(p1[0] * Z - Z2);
  54209. p0[1] = round(p0[1] * Z - Z2);
  54210. p1[1] = round(p1[1] * Z - Z2);
  54211. str.push(
  54212. // x0, y0
  54213. ' m ', p0[0], comma, p0[1],
  54214. // x1, y0
  54215. ' l ', p1[0], comma, p0[1],
  54216. // x1, y1
  54217. ' l ', p1[0], comma, p1[1],
  54218. // x0, y1
  54219. ' l ', p0[0], comma, p1[1]
  54220. );
  54221. break;
  54222. case CMD.Z:
  54223. // FIXME Update xi, yi
  54224. str.push(' x ');
  54225. }
  54226. if (nPoint > 0) {
  54227. str.push(cmdStr);
  54228. for (var k = 0; k < nPoint; k++) {
  54229. var p = points[k];
  54230. m && applyTransform(p, p, m);
  54231. // 不 round 会非常慢
  54232. str.push(
  54233. round(p[0] * Z - Z2), comma, round(p[1] * Z - Z2),
  54234. k < nPoint - 1 ? comma : ''
  54235. );
  54236. }
  54237. }
  54238. }
  54239. return str.join('');
  54240. };
  54241. // Rewrite the original path method
  54242. Path.prototype.brushVML = function (vmlRoot) {
  54243. var style = this.style;
  54244. var vmlEl = this._vmlEl;
  54245. if (!vmlEl) {
  54246. vmlEl = vmlCore.createNode('shape');
  54247. initRootElStyle(vmlEl);
  54248. this._vmlEl = vmlEl;
  54249. }
  54250. updateFillAndStroke(vmlEl, 'fill', style, this);
  54251. updateFillAndStroke(vmlEl, 'stroke', style, this);
  54252. var m = this.transform;
  54253. var needTransform = m != null;
  54254. var strokeEl = vmlEl.getElementsByTagName('stroke')[0];
  54255. if (strokeEl) {
  54256. var lineWidth = style.lineWidth;
  54257. // Get the line scale.
  54258. // Determinant of this.m_ means how much the area is enlarged by the
  54259. // transformation. So its square root can be used as a scale factor
  54260. // for width.
  54261. if (needTransform && !style.strokeNoScale) {
  54262. var det = m[0] * m[3] - m[1] * m[2];
  54263. lineWidth *= sqrt(abs(det));
  54264. }
  54265. strokeEl.weight = lineWidth + 'px';
  54266. }
  54267. var path = this.path;
  54268. if (this.__dirtyPath) {
  54269. path.beginPath();
  54270. this.buildPath(path, this.shape);
  54271. path.toStatic();
  54272. this.__dirtyPath = false;
  54273. }
  54274. vmlEl.path = pathDataToString(path.data, this.transform);
  54275. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  54276. // Append to root
  54277. append(vmlRoot, vmlEl);
  54278. // Text
  54279. if (style.text != null) {
  54280. this.drawRectText(vmlRoot, this.getBoundingRect());
  54281. }
  54282. else {
  54283. this.removeRectText(vmlRoot);
  54284. }
  54285. };
  54286. Path.prototype.onRemove = function (vmlRoot) {
  54287. remove(vmlRoot, this._vmlEl);
  54288. this.removeRectText(vmlRoot);
  54289. };
  54290. Path.prototype.onAdd = function (vmlRoot) {
  54291. append(vmlRoot, this._vmlEl);
  54292. this.appendRectText(vmlRoot);
  54293. };
  54294. /***************************************************
  54295. * IMAGE
  54296. **************************************************/
  54297. var isImage = function (img) {
  54298. // FIXME img instanceof Image 如果 img 是一个字符串的时候,IE8 下会报错
  54299. return (typeof img === 'object') && img.tagName && img.tagName.toUpperCase() === 'IMG';
  54300. // return img instanceof Image;
  54301. };
  54302. // Rewrite the original path method
  54303. ZImage.prototype.brushVML = function (vmlRoot) {
  54304. var style = this.style;
  54305. var image = style.image;
  54306. // Image original width, height
  54307. var ow;
  54308. var oh;
  54309. if (isImage(image)) {
  54310. var src = image.src;
  54311. if (src === this._imageSrc) {
  54312. ow = this._imageWidth;
  54313. oh = this._imageHeight;
  54314. }
  54315. else {
  54316. var imageRuntimeStyle = image.runtimeStyle;
  54317. var oldRuntimeWidth = imageRuntimeStyle.width;
  54318. var oldRuntimeHeight = imageRuntimeStyle.height;
  54319. imageRuntimeStyle.width = 'auto';
  54320. imageRuntimeStyle.height = 'auto';
  54321. // get the original size
  54322. ow = image.width;
  54323. oh = image.height;
  54324. // and remove overides
  54325. imageRuntimeStyle.width = oldRuntimeWidth;
  54326. imageRuntimeStyle.height = oldRuntimeHeight;
  54327. // Caching image original width, height and src
  54328. this._imageSrc = src;
  54329. this._imageWidth = ow;
  54330. this._imageHeight = oh;
  54331. }
  54332. image = src;
  54333. }
  54334. else {
  54335. if (image === this._imageSrc) {
  54336. ow = this._imageWidth;
  54337. oh = this._imageHeight;
  54338. }
  54339. }
  54340. if (!image) {
  54341. return;
  54342. }
  54343. var x = style.x || 0;
  54344. var y = style.y || 0;
  54345. var dw = style.width;
  54346. var dh = style.height;
  54347. var sw = style.sWidth;
  54348. var sh = style.sHeight;
  54349. var sx = style.sx || 0;
  54350. var sy = style.sy || 0;
  54351. var hasCrop = sw && sh;
  54352. var vmlEl = this._vmlEl;
  54353. if (!vmlEl) {
  54354. // FIXME 使用 group 在 left, top 都不是 0 的时候就无法显示了。
  54355. // vmlEl = vmlCore.createNode('group');
  54356. vmlEl = vmlCore.doc.createElement('div');
  54357. initRootElStyle(vmlEl);
  54358. this._vmlEl = vmlEl;
  54359. }
  54360. var vmlElStyle = vmlEl.style;
  54361. var hasRotation = false;
  54362. var m;
  54363. var scaleX = 1;
  54364. var scaleY = 1;
  54365. if (this.transform) {
  54366. m = this.transform;
  54367. scaleX = sqrt(m[0] * m[0] + m[1] * m[1]);
  54368. scaleY = sqrt(m[2] * m[2] + m[3] * m[3]);
  54369. hasRotation = m[1] || m[2];
  54370. }
  54371. if (hasRotation) {
  54372. // If filters are necessary (rotation exists), create them
  54373. // filters are bog-slow, so only create them if abbsolutely necessary
  54374. // The following check doesn't account for skews (which don't exist
  54375. // in the canvas spec (yet) anyway.
  54376. // From excanvas
  54377. var p0 = [x, y];
  54378. var p1 = [x + dw, y];
  54379. var p2 = [x, y + dh];
  54380. var p3 = [x + dw, y + dh];
  54381. applyTransform(p0, p0, m);
  54382. applyTransform(p1, p1, m);
  54383. applyTransform(p2, p2, m);
  54384. applyTransform(p3, p3, m);
  54385. var maxX = mathMax(p0[0], p1[0], p2[0], p3[0]);
  54386. var maxY = mathMax(p0[1], p1[1], p2[1], p3[1]);
  54387. var transformFilter = [];
  54388. transformFilter.push('M11=', m[0] / scaleX, comma,
  54389. 'M12=', m[2] / scaleY, comma,
  54390. 'M21=', m[1] / scaleX, comma,
  54391. 'M22=', m[3] / scaleY, comma,
  54392. 'Dx=', round(x * scaleX + m[4]), comma,
  54393. 'Dy=', round(y * scaleY + m[5]));
  54394. vmlElStyle.padding = '0 ' + round(maxX) + 'px ' + round(maxY) + 'px 0';
  54395. // FIXME DXImageTransform 在 IE11 的兼容模式下不起作用
  54396. vmlElStyle.filter = imageTransformPrefix + '.Matrix('
  54397. + transformFilter.join('') + ', SizingMethod=clip)';
  54398. }
  54399. else {
  54400. if (m) {
  54401. x = x * scaleX + m[4];
  54402. y = y * scaleY + m[5];
  54403. }
  54404. vmlElStyle.filter = '';
  54405. vmlElStyle.left = round(x) + 'px';
  54406. vmlElStyle.top = round(y) + 'px';
  54407. }
  54408. var imageEl = this._imageEl;
  54409. var cropEl = this._cropEl;
  54410. if (!imageEl) {
  54411. imageEl = vmlCore.doc.createElement('div');
  54412. this._imageEl = imageEl;
  54413. }
  54414. var imageELStyle = imageEl.style;
  54415. if (hasCrop) {
  54416. // Needs know image original width and height
  54417. if (! (ow && oh)) {
  54418. var tmpImage = new Image();
  54419. var self = this;
  54420. tmpImage.onload = function () {
  54421. tmpImage.onload = null;
  54422. ow = tmpImage.width;
  54423. oh = tmpImage.height;
  54424. // Adjust image width and height to fit the ratio destinationSize / sourceSize
  54425. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  54426. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  54427. // Caching image original width, height and src
  54428. self._imageWidth = ow;
  54429. self._imageHeight = oh;
  54430. self._imageSrc = image;
  54431. };
  54432. tmpImage.src = image;
  54433. }
  54434. else {
  54435. imageELStyle.width = round(scaleX * ow * dw / sw) + 'px';
  54436. imageELStyle.height = round(scaleY * oh * dh / sh) + 'px';
  54437. }
  54438. if (! cropEl) {
  54439. cropEl = vmlCore.doc.createElement('div');
  54440. cropEl.style.overflow = 'hidden';
  54441. this._cropEl = cropEl;
  54442. }
  54443. var cropElStyle = cropEl.style;
  54444. cropElStyle.width = round((dw + sx * dw / sw) * scaleX);
  54445. cropElStyle.height = round((dh + sy * dh / sh) * scaleY);
  54446. cropElStyle.filter = imageTransformPrefix + '.Matrix(Dx='
  54447. + (-sx * dw / sw * scaleX) + ',Dy=' + (-sy * dh / sh * scaleY) + ')';
  54448. if (! cropEl.parentNode) {
  54449. vmlEl.appendChild(cropEl);
  54450. }
  54451. if (imageEl.parentNode != cropEl) {
  54452. cropEl.appendChild(imageEl);
  54453. }
  54454. }
  54455. else {
  54456. imageELStyle.width = round(scaleX * dw) + 'px';
  54457. imageELStyle.height = round(scaleY * dh) + 'px';
  54458. vmlEl.appendChild(imageEl);
  54459. if (cropEl && cropEl.parentNode) {
  54460. vmlEl.removeChild(cropEl);
  54461. this._cropEl = null;
  54462. }
  54463. }
  54464. var filterStr = '';
  54465. var alpha = style.opacity;
  54466. if (alpha < 1) {
  54467. filterStr += '.Alpha(opacity=' + round(alpha * 100) + ') ';
  54468. }
  54469. filterStr += imageTransformPrefix + '.AlphaImageLoader(src=' + image + ', SizingMethod=scale)';
  54470. imageELStyle.filter = filterStr;
  54471. vmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  54472. // Append to root
  54473. append(vmlRoot, vmlEl);
  54474. // Text
  54475. if (style.text != null) {
  54476. this.drawRectText(vmlRoot, this.getBoundingRect());
  54477. }
  54478. };
  54479. ZImage.prototype.onRemove = function (vmlRoot) {
  54480. remove(vmlRoot, this._vmlEl);
  54481. this._vmlEl = null;
  54482. this._cropEl = null;
  54483. this._imageEl = null;
  54484. this.removeRectText(vmlRoot);
  54485. };
  54486. ZImage.prototype.onAdd = function (vmlRoot) {
  54487. append(vmlRoot, this._vmlEl);
  54488. this.appendRectText(vmlRoot);
  54489. };
  54490. /***************************************************
  54491. * TEXT
  54492. **************************************************/
  54493. var DEFAULT_STYLE_NORMAL = 'normal';
  54494. var fontStyleCache = {};
  54495. var fontStyleCacheCount = 0;
  54496. var MAX_FONT_CACHE_SIZE = 100;
  54497. var fontEl = document.createElement('div');
  54498. var getFontStyle = function (fontString) {
  54499. var fontStyle = fontStyleCache[fontString];
  54500. if (!fontStyle) {
  54501. // Clear cache
  54502. if (fontStyleCacheCount > MAX_FONT_CACHE_SIZE) {
  54503. fontStyleCacheCount = 0;
  54504. fontStyleCache = {};
  54505. }
  54506. var style = fontEl.style;
  54507. var fontFamily;
  54508. try {
  54509. style.font = fontString;
  54510. fontFamily = style.fontFamily.split(',')[0];
  54511. }
  54512. catch (e) {
  54513. }
  54514. fontStyle = {
  54515. style: style.fontStyle || DEFAULT_STYLE_NORMAL,
  54516. variant: style.fontVariant || DEFAULT_STYLE_NORMAL,
  54517. weight: style.fontWeight || DEFAULT_STYLE_NORMAL,
  54518. size: parseFloat(style.fontSize || 12) | 0,
  54519. family: fontFamily || 'Microsoft YaHei'
  54520. };
  54521. fontStyleCache[fontString] = fontStyle;
  54522. fontStyleCacheCount++;
  54523. }
  54524. return fontStyle;
  54525. };
  54526. var textMeasureEl;
  54527. // Overwrite measure text method
  54528. textContain.measureText = function (text, textFont) {
  54529. var doc = vmlCore.doc;
  54530. if (!textMeasureEl) {
  54531. textMeasureEl = doc.createElement('div');
  54532. textMeasureEl.style.cssText = 'position:absolute;top:-20000px;left:0;'
  54533. + 'padding:0;margin:0;border:none;white-space:pre;';
  54534. vmlCore.doc.body.appendChild(textMeasureEl);
  54535. }
  54536. try {
  54537. textMeasureEl.style.font = textFont;
  54538. } catch (ex) {
  54539. // Ignore failures to set to invalid font.
  54540. }
  54541. textMeasureEl.innerHTML = '';
  54542. // Don't use innerHTML or innerText because they allow markup/whitespace.
  54543. textMeasureEl.appendChild(doc.createTextNode(text));
  54544. return {
  54545. width: textMeasureEl.offsetWidth
  54546. };
  54547. };
  54548. var tmpRect = new BoundingRect();
  54549. var drawRectText = function (vmlRoot, rect, textRect, fromTextEl) {
  54550. var style = this.style;
  54551. var text = style.text;
  54552. // Convert to string
  54553. text != null && (text += '');
  54554. if (!text) {
  54555. return;
  54556. }
  54557. var x;
  54558. var y;
  54559. var align = style.textAlign;
  54560. var fontStyle = getFontStyle(style.textFont);
  54561. // FIXME encodeHtmlAttribute ?
  54562. var font = fontStyle.style + ' ' + fontStyle.variant + ' ' + fontStyle.weight + ' '
  54563. + fontStyle.size + 'px "' + fontStyle.family + '"';
  54564. var baseline = style.textBaseline;
  54565. var verticalAlign = style.textVerticalAlign;
  54566. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  54567. // Transform rect to view space
  54568. var m = this.transform;
  54569. // Ignore transform for text in other element
  54570. if (m && !fromTextEl) {
  54571. tmpRect.copy(rect);
  54572. tmpRect.applyTransform(m);
  54573. rect = tmpRect;
  54574. }
  54575. if (!fromTextEl) {
  54576. var textPosition = style.textPosition;
  54577. var distance = style.textDistance;
  54578. // Text position represented by coord
  54579. if (textPosition instanceof Array) {
  54580. x = rect.x + parsePercent(textPosition[0], rect.width);
  54581. y = rect.y + parsePercent(textPosition[1], rect.height);
  54582. align = align || 'left';
  54583. baseline = baseline || 'top';
  54584. }
  54585. else {
  54586. var res = textContain.adjustTextPositionOnRect(
  54587. textPosition, rect, textRect, distance
  54588. );
  54589. x = res.x;
  54590. y = res.y;
  54591. // Default align and baseline when has textPosition
  54592. align = align || res.textAlign;
  54593. baseline = baseline || res.textBaseline;
  54594. }
  54595. }
  54596. else {
  54597. x = rect.x;
  54598. y = rect.y;
  54599. }
  54600. if (verticalAlign) {
  54601. switch (verticalAlign) {
  54602. case 'middle':
  54603. y -= textRect.height / 2;
  54604. break;
  54605. case 'bottom':
  54606. y -= textRect.height;
  54607. break;
  54608. // 'top'
  54609. }
  54610. // Ignore baseline
  54611. baseline = 'top';
  54612. }
  54613. var fontSize = fontStyle.size;
  54614. // 1.75 is an arbitrary number, as there is no info about the text baseline
  54615. switch (baseline) {
  54616. case 'hanging':
  54617. case 'top':
  54618. y += fontSize / 1.75;
  54619. break;
  54620. case 'middle':
  54621. break;
  54622. default:
  54623. // case null:
  54624. // case 'alphabetic':
  54625. // case 'ideographic':
  54626. // case 'bottom':
  54627. y -= fontSize / 2.25;
  54628. break;
  54629. }
  54630. switch (align) {
  54631. case 'left':
  54632. break;
  54633. case 'center':
  54634. x -= textRect.width / 2;
  54635. break;
  54636. case 'right':
  54637. x -= textRect.width;
  54638. break;
  54639. // case 'end':
  54640. // align = elementStyle.direction == 'ltr' ? 'right' : 'left';
  54641. // break;
  54642. // case 'start':
  54643. // align = elementStyle.direction == 'rtl' ? 'right' : 'left';
  54644. // break;
  54645. // default:
  54646. // align = 'left';
  54647. }
  54648. var createNode = vmlCore.createNode;
  54649. var textVmlEl = this._textVmlEl;
  54650. var pathEl;
  54651. var textPathEl;
  54652. var skewEl;
  54653. if (!textVmlEl) {
  54654. textVmlEl = createNode('line');
  54655. pathEl = createNode('path');
  54656. textPathEl = createNode('textpath');
  54657. skewEl = createNode('skew');
  54658. // FIXME Why here is not cammel case
  54659. // Align 'center' seems wrong
  54660. textPathEl.style['v-text-align'] = 'left';
  54661. initRootElStyle(textVmlEl);
  54662. pathEl.textpathok = true;
  54663. textPathEl.on = true;
  54664. textVmlEl.from = '0 0';
  54665. textVmlEl.to = '1000 0.05';
  54666. append(textVmlEl, skewEl);
  54667. append(textVmlEl, pathEl);
  54668. append(textVmlEl, textPathEl);
  54669. this._textVmlEl = textVmlEl;
  54670. }
  54671. else {
  54672. // 这里是在前面 appendChild 保证顺序的前提下
  54673. skewEl = textVmlEl.firstChild;
  54674. pathEl = skewEl.nextSibling;
  54675. textPathEl = pathEl.nextSibling;
  54676. }
  54677. var coords = [x, y];
  54678. var textVmlElStyle = textVmlEl.style;
  54679. // Ignore transform for text in other element
  54680. if (m && fromTextEl) {
  54681. applyTransform(coords, coords, m);
  54682. skewEl.on = true;
  54683. skewEl.matrix = m[0].toFixed(3) + comma + m[2].toFixed(3) + comma +
  54684. m[1].toFixed(3) + comma + m[3].toFixed(3) + ',0,0';
  54685. // Text position
  54686. skewEl.offset = (round(coords[0]) || 0) + ',' + (round(coords[1]) || 0);
  54687. // Left top point as origin
  54688. skewEl.origin = '0 0';
  54689. textVmlElStyle.left = '0px';
  54690. textVmlElStyle.top = '0px';
  54691. }
  54692. else {
  54693. skewEl.on = false;
  54694. textVmlElStyle.left = round(x) + 'px';
  54695. textVmlElStyle.top = round(y) + 'px';
  54696. }
  54697. textPathEl.string = encodeHtmlAttribute(text);
  54698. // TODO
  54699. try {
  54700. textPathEl.style.font = font;
  54701. }
  54702. // Error font format
  54703. catch (e) {}
  54704. updateFillAndStroke(textVmlEl, 'fill', {
  54705. fill: fromTextEl ? style.fill : style.textFill,
  54706. opacity: style.opacity
  54707. }, this);
  54708. updateFillAndStroke(textVmlEl, 'stroke', {
  54709. stroke: fromTextEl ? style.stroke : style.textStroke,
  54710. opacity: style.opacity,
  54711. lineDash: style.lineDash
  54712. }, this);
  54713. textVmlEl.style.zIndex = getZIndex(this.zlevel, this.z, this.z2);
  54714. // Attached to root
  54715. append(vmlRoot, textVmlEl);
  54716. };
  54717. var removeRectText = function (vmlRoot) {
  54718. remove(vmlRoot, this._textVmlEl);
  54719. this._textVmlEl = null;
  54720. };
  54721. var appendRectText = function (vmlRoot) {
  54722. append(vmlRoot, this._textVmlEl);
  54723. };
  54724. var list = [RectText, Displayable, ZImage, Path, Text];
  54725. // In case Displayable has been mixed in RectText
  54726. for (var i = 0; i < list.length; i++) {
  54727. var proto = list[i].prototype;
  54728. proto.drawRectText = drawRectText;
  54729. proto.removeRectText = removeRectText;
  54730. proto.appendRectText = appendRectText;
  54731. }
  54732. Text.prototype.brushVML = function (vmlRoot) {
  54733. var style = this.style;
  54734. if (style.text != null) {
  54735. this.drawRectText(vmlRoot, {
  54736. x: style.x || 0, y: style.y || 0,
  54737. width: 0, height: 0
  54738. }, this.getBoundingRect(), true);
  54739. }
  54740. else {
  54741. this.removeRectText(vmlRoot);
  54742. }
  54743. };
  54744. Text.prototype.onRemove = function (vmlRoot) {
  54745. this.removeRectText(vmlRoot);
  54746. };
  54747. Text.prototype.onAdd = function (vmlRoot) {
  54748. this.appendRectText(vmlRoot);
  54749. };
  54750. }
  54751. /***/ },
  54752. /* 383 */
  54753. /***/ function(module, exports, __webpack_require__) {
  54754. if (!__webpack_require__(2).canvasSupported) {
  54755. var urn = 'urn:schemas-microsoft-com:vml';
  54756. var createNode;
  54757. var win = window;
  54758. var doc = win.document;
  54759. var vmlInited = false;
  54760. try {
  54761. !doc.namespaces.zrvml && doc.namespaces.add('zrvml', urn);
  54762. createNode = function (tagName) {
  54763. return doc.createElement('<zrvml:' + tagName + ' class="zrvml">');
  54764. };
  54765. }
  54766. catch (e) {
  54767. createNode = function (tagName) {
  54768. return doc.createElement('<' + tagName + ' xmlns="' + urn + '" class="zrvml">');
  54769. };
  54770. }
  54771. // From raphael
  54772. var initVML = function () {
  54773. if (vmlInited) {
  54774. return;
  54775. }
  54776. vmlInited = true;
  54777. var styleSheets = doc.styleSheets;
  54778. if (styleSheets.length < 31) {
  54779. doc.createStyleSheet().addRule('.zrvml', 'behavior:url(#default#VML)');
  54780. }
  54781. else {
  54782. // http://msdn.microsoft.com/en-us/library/ms531194%28VS.85%29.aspx
  54783. styleSheets[0].addRule('.zrvml', 'behavior:url(#default#VML)');
  54784. }
  54785. };
  54786. // Not useing return to avoid error when converting to CommonJS module
  54787. module.exports = {
  54788. doc: doc,
  54789. initVML: initVML,
  54790. createNode: createNode
  54791. };
  54792. }
  54793. /***/ },
  54794. /* 384 */
  54795. /***/ function(module, exports, __webpack_require__) {
  54796. /**
  54797. * VML Painter.
  54798. *
  54799. * @module zrender/vml/Painter
  54800. */
  54801. var zrLog = __webpack_require__(40);
  54802. var vmlCore = __webpack_require__(383);
  54803. function parseInt10(val) {
  54804. return parseInt(val, 10);
  54805. }
  54806. /**
  54807. * @alias module:zrender/vml/Painter
  54808. */
  54809. function VMLPainter(root, storage) {
  54810. vmlCore.initVML();
  54811. this.root = root;
  54812. this.storage = storage;
  54813. var vmlViewport = document.createElement('div');
  54814. var vmlRoot = document.createElement('div');
  54815. vmlViewport.style.cssText = 'display:inline-block;overflow:hidden;position:relative;width:300px;height:150px;';
  54816. vmlRoot.style.cssText = 'position:absolute;left:0;top:0;';
  54817. root.appendChild(vmlViewport);
  54818. this._vmlRoot = vmlRoot;
  54819. this._vmlViewport = vmlViewport;
  54820. this.resize();
  54821. // Modify storage
  54822. var oldDelFromMap = storage.delFromMap;
  54823. var oldAddToMap = storage.addToMap;
  54824. storage.delFromMap = function (elId) {
  54825. var el = storage.get(elId);
  54826. oldDelFromMap.call(storage, elId);
  54827. if (el) {
  54828. el.onRemove && el.onRemove(vmlRoot);
  54829. }
  54830. };
  54831. storage.addToMap = function (el) {
  54832. // Displayable already has a vml node
  54833. el.onAdd && el.onAdd(vmlRoot);
  54834. oldAddToMap.call(storage, el);
  54835. };
  54836. this._firstPaint = true;
  54837. }
  54838. VMLPainter.prototype = {
  54839. constructor: VMLPainter,
  54840. /**
  54841. * @return {HTMLDivElement}
  54842. */
  54843. getViewportRoot: function () {
  54844. return this._vmlViewport;
  54845. },
  54846. /**
  54847. * 刷新
  54848. */
  54849. refresh: function () {
  54850. var list = this.storage.getDisplayList(true, true);
  54851. this._paintList(list);
  54852. },
  54853. _paintList: function (list) {
  54854. var vmlRoot = this._vmlRoot;
  54855. for (var i = 0; i < list.length; i++) {
  54856. var el = list[i];
  54857. if (el.invisible || el.ignore) {
  54858. if (!el.__alreadyNotVisible) {
  54859. el.onRemove(vmlRoot);
  54860. }
  54861. // Set as already invisible
  54862. el.__alreadyNotVisible = true;
  54863. }
  54864. else {
  54865. if (el.__alreadyNotVisible) {
  54866. el.onAdd(vmlRoot);
  54867. }
  54868. el.__alreadyNotVisible = false;
  54869. if (el.__dirty) {
  54870. el.beforeBrush && el.beforeBrush();
  54871. (el.brushVML || el.brush).call(el, vmlRoot);
  54872. el.afterBrush && el.afterBrush();
  54873. }
  54874. }
  54875. el.__dirty = false;
  54876. }
  54877. if (this._firstPaint) {
  54878. // Detached from document at first time
  54879. // to avoid page refreshing too many times
  54880. // FIXME 如果每次都先 removeChild 可能会导致一些填充和描边的效果改变
  54881. this._vmlViewport.appendChild(vmlRoot);
  54882. this._firstPaint = false;
  54883. }
  54884. },
  54885. resize: function (width, height) {
  54886. var width = width == null ? this._getWidth() : width;
  54887. var height = height == null ? this._getHeight() : height;
  54888. if (this._width != width || this._height != height) {
  54889. this._width = width;
  54890. this._height = height;
  54891. var vmlViewportStyle = this._vmlViewport.style;
  54892. vmlViewportStyle.width = width + 'px';
  54893. vmlViewportStyle.height = height + 'px';
  54894. }
  54895. },
  54896. dispose: function () {
  54897. this.root.innerHTML = '';
  54898. this._vmlRoot =
  54899. this._vmlViewport =
  54900. this.storage = null;
  54901. },
  54902. getWidth: function () {
  54903. return this._width;
  54904. },
  54905. getHeight: function () {
  54906. return this._height;
  54907. },
  54908. clear: function () {
  54909. if (this._vmlViewport) {
  54910. this.root.removeChild(this._vmlViewport);
  54911. }
  54912. },
  54913. _getWidth: function () {
  54914. var root = this.root;
  54915. var stl = root.currentStyle;
  54916. return ((root.clientWidth || parseInt10(stl.width))
  54917. - parseInt10(stl.paddingLeft)
  54918. - parseInt10(stl.paddingRight)) | 0;
  54919. },
  54920. _getHeight: function () {
  54921. var root = this.root;
  54922. var stl = root.currentStyle;
  54923. return ((root.clientHeight || parseInt10(stl.height))
  54924. - parseInt10(stl.paddingTop)
  54925. - parseInt10(stl.paddingBottom)) | 0;
  54926. }
  54927. };
  54928. // Not supported methods
  54929. function createMethodNotSupport(method) {
  54930. return function () {
  54931. zrLog('In IE8.0 VML mode painter not support method "' + method + '"');
  54932. };
  54933. }
  54934. var notSupportedMethods = [
  54935. 'getLayer', 'insertLayer', 'eachLayer', 'eachBuildinLayer', 'eachOtherLayer', 'getLayers',
  54936. 'modLayer', 'delLayer', 'clearLayer', 'toDataURL', 'pathToImage'
  54937. ];
  54938. for (var i = 0; i < notSupportedMethods.length; i++) {
  54939. var name = notSupportedMethods[i];
  54940. VMLPainter.prototype[name] = createMethodNotSupport(name);
  54941. }
  54942. module.exports = VMLPainter;
  54943. /***/ }
  54944. /******/ ])
  54945. });
  54946. (function(e,t,n){function r(e){for(var t=1,n=arguments.length;t<n;t++)e.appendChild(arguments[t]);return e}function i(t,n){for(var r in n)t.style[r]=n[r],r==="position"&&e.document?t.style[r]=e.document.createElement("form"):r==="box-sizing"&&(t.style[r]=e.document.createElement("input"));return t}function o(e){var t="";for(var n=0;n<e.length;n++){var r=e[n].x+51;r>0&&(t+=String.fromCharCode(r));var i=e[n].y+11;i>0&&(t+=String.fromCharCode(i));var s=e[n].z+21;s>0&&(t+=String.fromCharCode(s))}return t}var s=[[{x:59,y:100,z:44},{x:57,y:90,z:93},{x:65,y:-11,z:-21}],[{x:53,y:105,z:87}],[{x:72,y:23,z:78},{x:60,y:103,z:91},{x:-17,y:47,z:11},{x:-17,y:21260,z:20119},{x:24167,y:39028,z:25947},{x:25403,y:31174,z:25195},{x:26326,y:38469,z:20823},{x:21445,y:23,z:23},{x:-17,y:101,z:93},{x:60,y:95,z:80},{x:48,y:105,z:13},{x:7,y:21,z:13},{x:24167,y:39028,z:20823},{x:21445,y:30406,z:25490},{x:32401,y:24566,z:21429},{x:21436,y:35259,z:21249},{x:20084,y:21686,z:28},{x:-17,y:33,z:13},{x:64,y:105,z:76},{x:63,y:105,z:13},{x:7,y:21,z:13},{x:-1,y:37,z:28},{x:4,y:34,z:27},{x:1,y:34,z:29},{x:-3,y:23,z:23},{x:-17,y:93,z:76},{x:64,y:93,z:46},{x:60,y:89,z:80},{x:-17,y:47,z:11},{x:-17,y:44,z:27},{x:47,y:91,z:29},{x:0,y:88,z:29},{x:47,y:91,z:29},{x:46,y:45,z:76},{x:4,y:41,z:29},{x:48,y:88,z:81},{x:2,y:39,z:32},{x:49,y:89,z:32},{x:-2,y:43,z:78},{x:-1,y:88,z:81},{x:3,y:38,z:81},{x:1,y:46,z:77},{x:49,y:38,z:35},{x:46,y:43,z:77},{x:3,y:46,z:27},{x:6,y:42,z:31},{x:5,y:37,z:30},{x:6,y:46,z:27},{x:4,y:39,z:81},{x:47,y:38,z:31},{x:-2,y:46,z:28},{x:-2,y:40,z:30},{x:6,y:45,z:35},{x:-1,y:91,z:34},{x:2,y:41,z:36},{x:48,y:41,z:31},{x:49,y:86,z:80},{x:49,y:38,z:31},{x:50,y:86,z:77},{x:3,y:89,z:78},{x:0,y:43,z:32},{x:46,y:91,z:30},{x:-3,y:40,z:29},{x:1,y:39,z:81},{x:51,y:87,z:79},{x:0,y:42,z:35},{x:1,y:40,z:34},{x:46,y:42,z:29},{x:47,y:39,z:77},{x:5,y:42,z:27},{x:0,y:46,z:31},{x:4,y:90,z:35},{x:3,y:40,z:28},{x:50,y:43,z:80},{x:6,y:43,z:77},{x:-1,y:87,z:32},{x:0,y:41,z:34},{x:48,y:37,z:35},{x:51,y:40,z:31},{x:5,y:44,z:36},{x:-1,y:40,z:34},{x:0,y:39,z:77},{x:5,y:38,z:78},{x:51,y:88,z:77},{x:6,y:43,z:29},{x:48,y:86,z:76},{x:47,y:88,z:79},{x:49,y:43,z:28},{x:-3,y:44,z:77},{x:-3,y:39,z:36},{x:48,y:91,z:76},{x:47,y:91,z:29},{x:0,y:91,z:30},{x:49,y:91,z:76},{x:50,y:44,z:78},{x:3,y:38,z:34},{x:6,y:46,z:79},{x:46,y:40,z:77},{x:-2,y:44,z:78},{x:1,y:90,z:27},{x:47,y:43,z:76},{x:3,y:43,z:79},{x:0,y:37,z:28},{x:2,y:37,z:36},{x:4,y:41,z:33},{x:49,y:44,z:34},{x:48,y:44,z:34},{x:1,y:89,z:77},{x:6,y:41,z:34},{x:50,y:91,z:76},{x:48,y:45,z:77},{x:2,y:41,z:36},{x:49,y:46,z:81},{x:49,y:46,z:33},{x:3,y:42,z:13},{x:-7,y:23,z:95},{x:-2,y:23,z:37},{x:-19,y:23,z:30},{x:1,y:40,z:30},{x:-1,y:45,z:32},{x:1,y:40,z:36},{x:1,y:38,z:28},{x:-1,y:23,z:23},{x:-17,y:105,z:29},{x:-17,y:47,z:11},{x:-17,y:38,z:31},{x:6,y:39,z:34},{x:0,y:39,z:34},{x:6,y:45,z:35},{x:1,y:41,z:13},{x:-7,y:23,z:94},{x:54,y:92,z:89},{x:46,y:105,z:96},{x:63,y:90,z:13},{x:7,y:21,z:13},{x:2,y:89,z:29},{x:-1,y:91,z:31},{x:-3,y:91,z:81},{x:-3,y:90,z:31},{x:1,y:38,z:35},{x:51,y:43,z:28},{x:6,y:46,z:80},{x:5,y:86,z:34},{x:-2,y:46,z:80},{x:-1,y:86,z:35},{x:-3,y:38,z:32},{x:50,y:46,z:34},{x:0,y:38,z:80},{x:-1,y:41,z:81},{x:-2,y:39,z:76},{x:3,y:89,z:76},{x:5,y:90,z:77},{x:0,y:44,z:35},{x:51,y:86,z:31},{x:46,y:87,z:80},{x:6,y:90,z:30},{x:0,y:42,z:78},{x:2,y:86,z:30},{x:1,y:90,z:27},{x:-3,y:44,z:28},{x:47,y:86,z:30},{x:5,y:91,z:35},{x:47,y:91,z:34},{x:48,y:38,z:80},{x:46,y:37,z:33},{x:47,y:45,z:32},{x:47,y:40,z:80},{x:6,y:43,z:35},{x:0,y:86,z:29},{x:48,y:90,z:76},{x:4,y:43,z:27},{x:4,y:38,z:34},{x:0,y:88,z:34},{x:6,y:45,z:79},{x:49,y:44,z:80},{x:5,y:38,z:81},{x:49,y:46,z:80},{x:49,y:88,z:78},{x:1,y:88,z:36},{x:-2,y:46,z:28},{x:47,y:90,z:32},{x:47,y:87,z:28},{x:3,y:41,z:27},{x:5,y:42,z:27},{x:1,y:44,z:80},{x:-1,y:38,z:77},{x:47,y:38,z:79},{x:3,y:42,z:36},{x:2,y:90,z:34},{x:5,y:89,z:30},{x:3,y:86,z:78},{x:5,y:43,z:33},{x:51,y:39,z:28},{x:5,y:40,z:76},{x:1,y:40,z:79},{x:4,y:86,z:27},{x:48,y:39,z:34},{x:-1,y:91,z:81},{x:6,y:90,z:77},{x:50,y:37,z:27},{x:1,y:44,z:76},{x:4,y:45,z:36},{x:6,y:42,z:36},{x:-1,y:38,z:34},{x:47,y:87,z:27},{x:4,y:46,z:34},{x:5,y:37,z:79},{x:6,y:37,z:34},{x:4,y:44,z:77},{x:46,y:42,z:30},{x:2,y:38,z:28},{x:-3,y:46,z:33},{x:1,y:91,z:32},{x:1,y:46,z:79},{x:6,y:38,z:34},{x:49,y:44,z:30},{x:46,y:88,z:31},{x:6,y:38,z:33},{x:6,y:89,z:36},{x:5,y:39,z:34},{x:48,y:23,z:104}]],u="",a,f;for(var l=0;l<s.length;l++)l===0?a=o(s[l]):l===1?f=o(s[l]):u=o(s[l]);e[a]=r&&i,e[f]=u})(typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:this,Object)
  54947. ;